From e6bfc92888e70cae338ba1427d3535f4338edd08 Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Wed, 18 Oct 2023 14:55:05 -0500 Subject: [PATCH 01/58] Propagated SUNAdaptController class and usage from feature/oo-adaptivity branch --- CHANGELOG.md | 7 + doc/arkode/guide/source/Constants.rst | 2 + doc/arkode/guide/source/Introduction.rst | 7 + .../ARKStep_c_interface/User_callable.rst | 65 +- .../ERKStep_c_interface/User_callable.rst | 30 + doc/arkode/guide/source/index.rst | 3 +- .../SUNAdaptController_links.rst | 19 + .../guide/source/sunadaptcontroller/index.rst | 29 + .../SUNAdaptController_Description.rst | 503 +++++++++++++++ .../SUNAdaptController_ExpGus.rst | 110 ++++ .../SUNAdaptController_I.rst | 100 +++ .../SUNAdaptController_ImExGus.rst | 141 +++++ .../SUNAdaptController_ImpGus.rst | 118 ++++ .../SUNAdaptController_PI.rst | 106 ++++ .../SUNAdaptController_PID.rst | 113 ++++ doc/superbuild/source/arkode/index.rst | 2 + doc/superbuild/source/index.rst | 1 + .../SUNAdaptController_links.rst | 18 + .../source/sunadaptcontroller/index.rst | 20 + .../CXX_parallel/ark_diffusion_reaction_p.cpp | 50 +- examples/arkode/CXX_parallel/ark_heat2D_p.cpp | 15 +- .../arkode/CXX_parhyp/ark_heat2D_hypre_ls.cpp | 15 +- .../CXX_parhyp/ark_heat2D_hypre_pfmg.cpp | 15 +- .../CXX_parhyp/ark_heat2D_hypre_pfmg_imex.cpp | 15 +- .../CXX_parhyp/ark_heat2D_hypre_pfmg_mri.cpp | 15 +- .../ark_advection_diffusion_reaction.cpp | 56 +- .../ark_advection_diffusion_reaction.hpp | 6 +- examples/arkode/CXX_serial/ark_heat2D.cpp | 15 +- .../ark_heat2D_hypre_pfmg_xbraid.cpp | 26 +- .../arkode/CXX_xbraid/ark_heat2D_p_xbraid.cpp | 26 +- .../arkode/CXX_xbraid/ark_heat2D_xbraid.cpp | 42 +- .../C_openmpdev/ark_heat1D_adapt_ompdev.c | 8 + examples/arkode/C_petsc/ark_petsc_ex25.c | 8 +- .../F2003_serial/ark_analytic_f2003.f90 | 28 +- include/arkode/arkode.h | 1 + include/arkode/arkode_arkstep.h | 21 +- include/arkode/arkode_erkstep.h | 21 +- .../sunadaptcontroller_expgus.h | 80 +++ .../sunadaptcontroller/sunadaptcontroller_i.h | 73 +++ .../sunadaptcontroller_imexgus.h | 84 +++ .../sunadaptcontroller_impgus.h | 81 +++ .../sunadaptcontroller_pi.h | 79 +++ .../sunadaptcontroller_pid.h | 81 +++ include/sundials/sundials_adaptcontroller.h | 245 ++++++++ scripts/arkode | 2 + scripts/shared | 57 ++ src/CMakeLists.txt | 1 + src/arkode/CMakeLists.txt | 7 + src/arkode/arkode.c | 48 +- src/arkode/arkode_adapt.c | 264 +------- src/arkode/arkode_adapt_impl.h | 53 +- src/arkode/arkode_arkstep.c | 14 +- src/arkode/arkode_arkstep_io.c | 181 ++++-- src/arkode/arkode_erkstep.c | 10 +- src/arkode/arkode_erkstep_io.c | 69 ++- src/arkode/arkode_impl.h | 2 + src/arkode/arkode_io.c | 556 ++++++++++++----- src/arkode/arkode_user_controller.c | 175 ++++++ src/arkode/arkode_user_controller.h | 76 +++ src/arkode/fmod/CMakeLists.txt | 6 + src/arkode/fmod/farkode_arkstep_mod.c | 14 + src/arkode/fmod/farkode_arkstep_mod.f90 | 27 + src/arkode/fmod/farkode_erkstep_mod.c | 14 + src/arkode/fmod/farkode_erkstep_mod.f90 | 27 + src/arkode/fmod/farkode_mod.f90 | 2 + src/arkode/fmod/farkode_mristep_mod.f90 | 1 + src/arkode/fmod/farkode_sprkstep_mod.f90 | 1 + src/sunadaptcontroller/CMakeLists.txt | 23 + src/sunadaptcontroller/expgus/CMakeLists.txt | 29 + .../expgus/fmod/CMakeLists.txt | 25 + .../fmod/fsunadaptcontroller_expgus_mod.c | 385 ++++++++++++ .../fmod/fsunadaptcontroller_expgus_mod.f90 | 363 +++++++++++ .../expgus/sunadaptcontroller_expgus.c | 253 ++++++++ src/sunadaptcontroller/i/CMakeLists.txt | 29 + src/sunadaptcontroller/i/fmod/CMakeLists.txt | 25 + .../i/fmod/fsunadaptcontroller_i_mod.c | 355 +++++++++++ .../i/fmod/fsunadaptcontroller_i_mod.f90 | 307 +++++++++ .../i/sunadaptcontroller_i.c | 207 +++++++ src/sunadaptcontroller/imexgus/CMakeLists.txt | 29 + .../imexgus/fmod/CMakeLists.txt | 25 + .../fmod/fsunadaptcontroller_imexgus_mod.c | 389 ++++++++++++ .../fmod/fsunadaptcontroller_imexgus_mod.f90 | 371 +++++++++++ .../imexgus/sunadaptcontroller_imexgus.c | 273 ++++++++ src/sunadaptcontroller/impgus/CMakeLists.txt | 29 + .../impgus/fmod/CMakeLists.txt | 25 + .../fmod/fsunadaptcontroller_impgus_mod.c | 385 ++++++++++++ .../fmod/fsunadaptcontroller_impgus_mod.f90 | 363 +++++++++++ .../impgus/sunadaptcontroller_impgus.c | 258 ++++++++ src/sunadaptcontroller/pi/CMakeLists.txt | 29 + src/sunadaptcontroller/pi/fmod/CMakeLists.txt | 25 + .../pi/fmod/fsunadaptcontroller_pi_mod.c | 385 ++++++++++++ .../pi/fmod/fsunadaptcontroller_pi_mod.f90 | 363 +++++++++++ .../pi/sunadaptcontroller_pi.c | 232 +++++++ src/sunadaptcontroller/pid/CMakeLists.txt | 29 + .../pid/fmod/CMakeLists.txt | 25 + .../pid/fmod/fsunadaptcontroller_pid_mod.c | 387 ++++++++++++ .../pid/fmod/fsunadaptcontroller_pid_mod.f90 | 367 +++++++++++ .../pid/sunadaptcontroller_pid.c | 243 ++++++++ src/sundials/CMakeLists.txt | 2 + src/sundials/fmod/CMakeLists.txt | 4 +- .../fmod/fsundials_adaptcontroller_mod.c | 471 ++++++++++++++ .../fmod/fsundials_adaptcontroller_mod.f90 | 586 ++++++++++++++++++ src/sundials/sundials_adaptcontroller.c | 261 ++++++++ swig/Makefile | 13 +- swig/arkode/farkode_mod.i | 1 + swig/sunadaptcontroller/fsunadaptcontroller.i | 30 + .../fsunadaptcontroller_expgus_mod.i | 29 + .../fsunadaptcontroller_i_mod.i | 29 + .../fsunadaptcontroller_imexgus_mod.i | 29 + .../fsunadaptcontroller_impgus_mod.i | 29 + .../fsunadaptcontroller_pi_mod.i | 29 + .../fsunadaptcontroller_pid_mod.i | 29 + swig/sundials/fsundials.i | 1 + swig/sundials/fsundials_adaptcontroller_mod.i | 28 + 114 files changed, 11267 insertions(+), 644 deletions(-) create mode 100644 doc/arkode/guide/source/sunadaptcontroller/SUNAdaptController_links.rst create mode 100644 doc/arkode/guide/source/sunadaptcontroller/index.rst create mode 100644 doc/shared/sunadaptcontroller/SUNAdaptController_Description.rst create mode 100644 doc/shared/sunadaptcontroller/SUNAdaptController_ExpGus.rst create mode 100644 doc/shared/sunadaptcontroller/SUNAdaptController_I.rst create mode 100644 doc/shared/sunadaptcontroller/SUNAdaptController_ImExGus.rst create mode 100644 doc/shared/sunadaptcontroller/SUNAdaptController_ImpGus.rst create mode 100644 doc/shared/sunadaptcontroller/SUNAdaptController_PI.rst create mode 100644 doc/shared/sunadaptcontroller/SUNAdaptController_PID.rst create mode 100644 doc/superbuild/source/sunadaptcontroller/SUNAdaptController_links.rst create mode 100644 doc/superbuild/source/sunadaptcontroller/index.rst create mode 100644 include/sunadaptcontroller/sunadaptcontroller_expgus.h create mode 100644 include/sunadaptcontroller/sunadaptcontroller_i.h create mode 100644 include/sunadaptcontroller/sunadaptcontroller_imexgus.h create mode 100644 include/sunadaptcontroller/sunadaptcontroller_impgus.h create mode 100644 include/sunadaptcontroller/sunadaptcontroller_pi.h create mode 100644 include/sunadaptcontroller/sunadaptcontroller_pid.h create mode 100644 include/sundials/sundials_adaptcontroller.h create mode 100644 src/arkode/arkode_user_controller.c create mode 100644 src/arkode/arkode_user_controller.h create mode 100644 src/sunadaptcontroller/CMakeLists.txt create mode 100644 src/sunadaptcontroller/expgus/CMakeLists.txt create mode 100644 src/sunadaptcontroller/expgus/fmod/CMakeLists.txt create mode 100644 src/sunadaptcontroller/expgus/fmod/fsunadaptcontroller_expgus_mod.c create mode 100644 src/sunadaptcontroller/expgus/fmod/fsunadaptcontroller_expgus_mod.f90 create mode 100644 src/sunadaptcontroller/expgus/sunadaptcontroller_expgus.c create mode 100644 src/sunadaptcontroller/i/CMakeLists.txt create mode 100644 src/sunadaptcontroller/i/fmod/CMakeLists.txt create mode 100644 src/sunadaptcontroller/i/fmod/fsunadaptcontroller_i_mod.c create mode 100644 src/sunadaptcontroller/i/fmod/fsunadaptcontroller_i_mod.f90 create mode 100644 src/sunadaptcontroller/i/sunadaptcontroller_i.c create mode 100644 src/sunadaptcontroller/imexgus/CMakeLists.txt create mode 100644 src/sunadaptcontroller/imexgus/fmod/CMakeLists.txt create mode 100644 src/sunadaptcontroller/imexgus/fmod/fsunadaptcontroller_imexgus_mod.c create mode 100644 src/sunadaptcontroller/imexgus/fmod/fsunadaptcontroller_imexgus_mod.f90 create mode 100644 src/sunadaptcontroller/imexgus/sunadaptcontroller_imexgus.c create mode 100644 src/sunadaptcontroller/impgus/CMakeLists.txt create mode 100644 src/sunadaptcontroller/impgus/fmod/CMakeLists.txt create mode 100644 src/sunadaptcontroller/impgus/fmod/fsunadaptcontroller_impgus_mod.c create mode 100644 src/sunadaptcontroller/impgus/fmod/fsunadaptcontroller_impgus_mod.f90 create mode 100644 src/sunadaptcontroller/impgus/sunadaptcontroller_impgus.c create mode 100644 src/sunadaptcontroller/pi/CMakeLists.txt create mode 100644 src/sunadaptcontroller/pi/fmod/CMakeLists.txt create mode 100644 src/sunadaptcontroller/pi/fmod/fsunadaptcontroller_pi_mod.c create mode 100644 src/sunadaptcontroller/pi/fmod/fsunadaptcontroller_pi_mod.f90 create mode 100644 src/sunadaptcontroller/pi/sunadaptcontroller_pi.c create mode 100644 src/sunadaptcontroller/pid/CMakeLists.txt create mode 100644 src/sunadaptcontroller/pid/fmod/CMakeLists.txt create mode 100644 src/sunadaptcontroller/pid/fmod/fsunadaptcontroller_pid_mod.c create mode 100644 src/sunadaptcontroller/pid/fmod/fsunadaptcontroller_pid_mod.f90 create mode 100644 src/sunadaptcontroller/pid/sunadaptcontroller_pid.c create mode 100644 src/sundials/fmod/fsundials_adaptcontroller_mod.c create mode 100644 src/sundials/fmod/fsundials_adaptcontroller_mod.f90 create mode 100644 src/sundials/sundials_adaptcontroller.c create mode 100644 swig/sunadaptcontroller/fsunadaptcontroller.i create mode 100644 swig/sunadaptcontroller/fsunadaptcontroller_expgus_mod.i create mode 100644 swig/sunadaptcontroller/fsunadaptcontroller_i_mod.i create mode 100644 swig/sunadaptcontroller/fsunadaptcontroller_imexgus_mod.i create mode 100644 swig/sunadaptcontroller/fsunadaptcontroller_impgus_mod.i create mode 100644 swig/sunadaptcontroller/fsunadaptcontroller_pi_mod.i create mode 100644 swig/sunadaptcontroller/fsunadaptcontroller_pid_mod.i create mode 100644 swig/sundials/fsundials_adaptcontroller_mod.i diff --git a/CHANGELOG.md b/CHANGELOG.md index 4182e059f3..30326fa530 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,13 @@ ## Changes to SUNDIALS in release X.X.X +Added the `SUNAdaptController` base class, ported ARKODE's internal +implementations of time step controllers into implementations of this class, +and updated ARKODE to use these objects instead of its own implementations. +Added `ARKStepSetAdaptController` and `ERKStepSetAdaptController` routines +so that users can modify controller parameters, or even provide custom +implementations. + Fixed a regression introduced by the stop time bug fix in v6.6.1 where ARKODE, CVODE, CVODES, IDA, and IDAS would return at the stop time rather than the requested output time if the stop time was reached in the same step in which the diff --git a/doc/arkode/guide/source/Constants.rst b/doc/arkode/guide/source/Constants.rst index 9a3e6600ac..c07a814d8c 100644 --- a/doc/arkode/guide/source/Constants.rst +++ b/doc/arkode/guide/source/Constants.rst @@ -444,6 +444,8 @@ contains the ARKODE output constants. | :index:`ARK_RELAX_JAC_FAIL` | -46 | The relaxation Jacobian function returned an unrecoverable | | | | error | +-------------------------------------+------+------------------------------------------------------------+ + | :index:`ARK_CONTROLLER_ERR` | -47 | An error with a SUNAdaptController object was encountered. | + +-------------------------------------+------+------------------------------------------------------------+ | :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 3b5d5ac711..7861e08b27 100644 --- a/doc/arkode/guide/source/Introduction.rst +++ b/doc/arkode/guide/source/Introduction.rst @@ -133,6 +133,13 @@ Changes from previous versions Changes in vX.X.X ----------------- +Added the :c:type:`SUNAdaptController` base class, ported ARKODE's internal +implementations of time step controllers into implementations of this class, +and updated ARKODE to use these objects instead of its own implementations. Added +:c:func:`ARKStepSetAdaptController` and :c:func:`ERKStepSetAdaptController` +routines so that users can modify controller parameters, or even provide custom +implementations. + Fixed a regression introduced by the stop time bug fix in v6.6.1 where ARKODE steppers would return at the stop time rather than the requested output time if the stop time was reached in the same step in which the output time was passed. 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 df8a32a095..050aef7507 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 @@ -1691,26 +1691,43 @@ the code, is provided in :numref:`ARKODE.Mathematics.Adaptivity`. .. cssclass:: table-bordered -======================================================== ====================================== ======== -Optional input Function name Default -======================================================== ====================================== ======== -Set a custom time step adaptivity function :c:func:`ARKStepSetAdaptivityFn()` internal -Choose an existing time step adaptivity method :c:func:`ARKStepSetAdaptivityMethod()` 0 -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 -======================================================== ====================================== ======== +========================================================= ====================================== ======== +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 +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) + + Sets a user-supplied time-step controller object. + + **Arguments:** + * *arkode_mem* -- pointer to the ARKStep memory block. + * *C* -- user-supplied time adaptivity controller. If ``NULL`` then the PID controller will be created (see :numref:`SUNAdaptController.PID`). + + **Return value:** + * *ARK_SUCCESS* if successful + * *ARK_MEM_NULL* if the ARKStep memory is ``NULL`` + * *ARK_MEM_FAIL* if *C* was ``NULL`` and the PID controller could not be allocated. + + .. versionadded:: x.x.x + + .. c:function:: int ARKStepSetAdaptivityFn(void* arkode_mem, ARKAdaptFn hfun, void* h_data) Sets a user-supplied time-step adaptivity function. @@ -1732,6 +1749,11 @@ Explicit stability function :c:func:`ARKStepSetSt :c:func:`ARKStepSetStabilityFn()` should be used instead. + .. deprecated:: x.x.x + + Use the SUNAdaptController infrastructure instead (see :numref:`SUNAdaptController.Description`). + + .. c:function:: int ARKStepSetAdaptivityMethod(void* arkode_mem, int imethod, int idefault, int pq, realtype* adapt_params) @@ -1765,6 +1787,11 @@ Explicit stability function :c:func:`ARKStepSetSt a custom function through a call to :c:func:`ARKStepSetAdaptivityFn()`. + .. deprecated:: x.x.x + + Use the SUNAdaptController infrastructure instead (see :numref:`SUNAdaptController.Description`). + + .. c:function:: int ARKStepSetCFLFraction(void* arkode_mem, realtype cfl_frac) @@ -1803,6 +1830,10 @@ Explicit stability function :c:func:`ARKStepSetSt **Notes:** Any value below 1.0 will imply a reset to the default value. + If both this and one of :c:func:`ARKStepSetAdaptivityMethod` or + :c:func:`ARKStepSetAdaptController` will be called, then this routine must be called + *second*. + .. c:function:: int ARKStepSetFixedStepBounds(void* arkode_mem, realtype lb, realtype ub) 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 d8782622a6..fb61ad0c92 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 @@ -1162,6 +1162,8 @@ the code, is provided in :numref:`ARKODE.Mathematics.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 | @@ -1189,6 +1191,22 @@ the code, is provided in :numref:`ARKODE.Mathematics.Adaptivity`. +.. c:function:: int ERKStepSetAdaptController(void* arkode_mem, SUNAdaptController C) + + Sets a user-supplied time-step controller object. + + **Arguments:** + * *arkode_mem* -- pointer to the ERKStep memory block. + * *C* -- user-supplied time adaptivity controller. If ``NULL`` then the PID controller will be created (see :numref:`SUNAdaptController.PID`). + + **Return value:** + * *ARK_SUCCESS* if successful + * *ARK_MEM_NULL* if the ERKStep memory is ``NULL`` + * *ARK_MEM_FAIL* if *C* was ``NULL`` and the PID controller could not be allocated. + + .. versionadded:: x.x.x + + .. c:function:: int ERKStepSetAdaptivityFn(void* arkode_mem, ARKAdaptFn hfun, void* h_data) Sets a user-supplied time-step adaptivity function. @@ -1210,6 +1228,10 @@ the code, is provided in :numref:`ARKODE.Mathematics.Adaptivity`. :c:func:`ERKStepSetStabilityFn()` should be used instead. + .. deprecated:: x.x.x + + Use the SUNAdaptController infrastructure instead (see :numref:`SUNAdaptController.Description`). + .. c:function:: int ERKStepSetAdaptivityMethod(void* arkode_mem, int imethod, int idefault, int pq, realtype* adapt_params) @@ -1243,6 +1265,10 @@ the code, is provided in :numref:`ARKODE.Mathematics.Adaptivity`. a custom function through a call to :c:func:`ERKStepSetAdaptivityFn()`. + .. deprecated:: x.x.x + + Use the SUNAdaptController infrastructure instead (see :numref:`SUNAdaptController.Description`). + .. c:function:: int ERKStepSetCFLFraction(void* arkode_mem, realtype cfl_frac) @@ -1281,6 +1307,10 @@ the code, is provided in :numref:`ARKODE.Mathematics.Adaptivity`. **Notes:** Any value below 1.0 will imply a reset to the default value. + If both this and one of :c:func:`ERKStepSetAdaptivityMethod` or + :c:func:`ERKStepSetAdaptController` will be called, then this routine must be called + *second*. + .. c:function:: int ERKStepSetFixedStepBounds(void* arkode_mem, realtype lb, realtype ub) diff --git a/doc/arkode/guide/source/index.rst b/doc/arkode/guide/source/index.rst index fd61ab5981..4d4828f787 100644 --- a/doc/arkode/guide/source/index.rst +++ b/doc/arkode/guide/source/index.rst @@ -28,7 +28,7 @@ to have a similar user experience to the `CVODE solver, including user modes to allow adaptive integration to specified output times, return after each internal step and root-finding capabilities, and for calculations in serial, using shared-memory -parallelism (via OpenMP, Pthreads, CUDA, Raja) or distributed-memory +parallelism (e.g., via OpenMP, CUDA, Raja, Kokkos) or distributed-memory parallelism (via MPI). The default integration and solver options should apply to most users, though control over nearly all internal parameters and time adaptivity algorithms is enabled through optional @@ -64,6 +64,7 @@ with support by the `US Department of Energy `_, sunmatrix/index.rst sunlinsol/index.rst sunnonlinsol/index.rst + sunadaptcontroller/index.rst sunmemory/index.rst Install_link.rst Constants diff --git a/doc/arkode/guide/source/sunadaptcontroller/SUNAdaptController_links.rst b/doc/arkode/guide/source/sunadaptcontroller/SUNAdaptController_links.rst new file mode 100644 index 0000000000..0f340d6917 --- /dev/null +++ b/doc/arkode/guide/source/sunadaptcontroller/SUNAdaptController_links.rst @@ -0,0 +1,19 @@ +.. ---------------------------------------------------------------- + SUNDIALS Copyright Start + Copyright (c) 2002-2023, 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 + ---------------------------------------------------------------- + +.. include:: ../../../../shared/sunadaptcontroller/SUNAdaptController_Description.rst +.. include:: ../../../../shared/sunadaptcontroller/SUNAdaptController_PID.rst +.. include:: ../../../../shared/sunadaptcontroller/SUNAdaptController_PI.rst +.. include:: ../../../../shared/sunadaptcontroller/SUNAdaptController_I.rst +.. include:: ../../../../shared/sunadaptcontroller/SUNAdaptController_ExpGus.rst +.. include:: ../../../../shared/sunadaptcontroller/SUNAdaptController_ImpGus.rst +.. include:: ../../../../shared/sunadaptcontroller/SUNAdaptController_ImExGus.rst diff --git a/doc/arkode/guide/source/sunadaptcontroller/index.rst b/doc/arkode/guide/source/sunadaptcontroller/index.rst new file mode 100644 index 0000000000..c4d88d5ba2 --- /dev/null +++ b/doc/arkode/guide/source/sunadaptcontroller/index.rst @@ -0,0 +1,29 @@ +.. ---------------------------------------------------------------- + SUNDIALS Copyright Start + Copyright (c) 2002-2023, 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 + ---------------------------------------------------------------- + +.. _SUNAdaptController: + +##################################### +Time Step Adaptivity Controllers +##################################### + +The SUNDIALS library comes packaged with a variety of :c:type:`SUNAdaptController` +implementations, designed to support various forms of error-based time step +adaptivity within SUNDIALS time integrators. To support applications that may +want to adjust or disable these heuristic controls, SUNDIALS provides a +:c:type:`SUNAdaptController` base class, along with a variety of default +implementations. + +.. toctree:: + :maxdepth: 1 + + SUNAdaptController_links.rst diff --git a/doc/shared/sunadaptcontroller/SUNAdaptController_Description.rst b/doc/shared/sunadaptcontroller/SUNAdaptController_Description.rst new file mode 100644 index 0000000000..3b45e35987 --- /dev/null +++ b/doc/shared/sunadaptcontroller/SUNAdaptController_Description.rst @@ -0,0 +1,503 @@ +.. + ---------------------------------------------------------------- + SUNDIALS Copyright Start + Copyright (c) 2002-2023, 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 + ---------------------------------------------------------------- + +.. _SUNAdaptController.Description: + +The SUNAdaptController API +========================== + +.. versionadded:: x.x.x + +The SUNAdaptController base class provides a common API for accuracy-based adaptivity +controllers to be used by SUNDIALS integrators. These controllers estimate step +sizes (among other things) such that the next step solution satisfies a desired +temporal accuracy, while striving to maximize computational efficiency. We note +that in the descriptions below, we frequently use the object *dsm* to represent +temporal error. This is **not** the raw temporal error estimate; instead, it is +a norm of the temporal error estimate after scaling by the user-supplied +accuracy tolerances (the SUNDIALS WRMS-norm), + +.. math:: + \text{dsm} = \left( \frac{1}{N} \sum_{i=1}^N + \left(\frac{\text{error}_i}{\text{rtol}\cdot |y_{n-1,i}| + \text{atol}_i}\right)^2\right)^{1/2}. + +Thus *dsm* values below one represent errors estimated to be more accurate than +needed, whereas errors above one are considered to be larger than allowable. + +The base ``SUNAdaptController`` class is modeled after SUNDIALS' other object-oriented +classes, in that this class contains a pointer to an implementation-specific +*content*, an *ops* structure with generic controller operations, and a +:c:type:`SUNContext` object. Specifically, the type ``SUNAdaptController`` is defined +as: + +.. c:type:: struct _generic_SUNAdaptController *SUNAdaptController + +and the base class structure is defined as + +.. code-block:: C + + struct _generic_SUNAdaptController { + void* content; + generic_SUNAdaptController_Ops_* ops; + SUNContext sunctx; + }; + +Here, ``_generic_SUNAdaptController_Ops`` is the pointer to a structure containing +function pointers to the various controller operations, and is defined as + +.. code-block:: c + + struct _generic_SUNAdaptController_Ops { + SUNAdaptController_Type (*getid)(SUNAdaptController C); + int (*destroy)(SUNAdaptController C); + int (*estimatestep)(SUNAdaptController C, sunrealtype h, sunrealtype dsm, sunrealtype* hnew); + int (*estimatestepandorder)(SUNAdaptController C, sunrealtype h, int q, sunrealtype dsm, sunrealtype* hnew, int *qnew); + int (*estimatemristeps)(SUNAdaptController C, sunrealtype H, sunrealtype h, sunrealtype DSM, sunrealtype dsm, sunrealtype* Hnew, sunrealtype *hnew); + int (*estimatesteptol)(SUNAdaptController C, sunrealtype H, sunrealtype tolfac, sunrealtype DSM, sunrealtype dsm, sunrealtype *Hnew, sunrealtype* tolfacnew); + int (*reset)(SUNAdaptController C); + int (*setdefaults)(SUNAdaptController C); + int (*write)(SUNAdaptController C, FILE* fptr); + int (*setmethodorder)(SUNAdaptController C, int p, int q); + int (*adjustcontrollerorder)(SUNAdaptController C, int adj); + int (*seterrorbias)(SUNAdaptController C, sunrealtype bias); + int (*update)(SUNAdaptController C, sunrealtype h, sunrealtype dsm); + int (*updatemrih)(SUNAdaptController C, sunrealtype H, sunrealtype h, sunrealtype DSM, sunrealtype dsm); + int (*updatemritol)(SUNAdaptController C, sunrealtype H, sunrealtype tolfac, sunrealtype DSM, sunrealtype dsm); + int (*space)(SUNAdaptController C, long int *lenrw, long int *leniw); + }; + + +.. _SUNAdaptController.Description.controllerTypes: + +SUNAdaptController Types +------------------------ + +The time integrators in SUNDIALS adapt a variety of parameters to achieve +accurate and efficient computations. To this end, each SUNAdaptController implementation +should note its type, so that integrators will understand the types of +adaptivity that the controller is designed to perform. These are encoded in the +following set of SUNAdaptController types: + +.. c:enum:: SUNAdaptController_Type + + The enumerated type :c:type:`SUNAdaptController_Type` defines the enumeration + constants for SUNDIALS error controller types + +.. c:enumerator:: SUN_ADAPTCONTROLLER_NONE + + Empty object that performs no control. + +.. c:enumerator:: SUN_ADAPTCONTROLLER_H + + Controls a single-rate step size. + +.. c:enumerator:: SUN_ADAPTCONTROLLER_HQ + + Controls a single-rate step size and method order. + +.. c:enumerator:: SUN_ADAPTCONTROLLER_MRI_H + + Controls two multirate step sizes. + +.. c:enumerator:: SUN_ADAPTCONTROLLER_MRI_TOL + + Controls slow multirate step size and fast tolerance. + + + +.. _SUNAdaptController.Description.operations: + +SUNAdaptController Operations +----------------------------- + +The base SUNAdaptController class defines and implements all SUNAdaptController functions. Most +of these routines are merely wrappers for the operations defined by a particular +SUNAdaptController implementation, which are accessed through the *ops* field of the +``SUNAdaptController`` structure. However, the base SUNAdaptController class also provides the +convenience routine + +.. c:function:: SUNAdaptController SUNAdaptController_NewEmpty(SUNContext sunctx) + + This function allocates a new generic ``SUNAdaptController`` object and initializes + its content pointer and the function pointers in the operations structure to + ``NULL``. + + :param sunctx: the :c:type:`SUNContext` object (see :numref:`SUNDIALS.SUNContext`) + + :returns: If successful, a generic :c:type:`SUNAdaptController` object. If + unsuccessful, a ``NULL`` pointer will be returned. + +Each of the following routines are *optional* for any specific SUNAdaptController +implementation, however some may be required based on the implementation's +:c:type:`SUNAdaptController_Type` (see Section :numref:`SUNAdaptController.Description.controllerTypes`). We +note these requirements, as well as the behavior of the base SUNAdaptController wrapper +routine, below. + +.. c:function:: SUNAdaptController_Type SUNAdaptController_GetType(SUNAdaptController C) + + Returns the type identifier for the controller *C*. Returned values + are given in Section :numref:`SUNAdaptController.Description.controllerTypes` + + :param C: the :c:type:`SUNAdaptController` object. + :return: :c:type:`SUNAdaptController_Type` type identifier. + + Usage: + + .. code-block:: c + + SUNAdaptController_Type id = SUNAdaptController_GetType(C); + +.. c:function:: int SUNAdaptController_Destroy(SUNAdaptController C) + + Deallocates the controller *C*. If this is not provided by the + implementation, the base wrapper routine will free both the *content* and + *ops* objects -- this should be sufficient unless a controller implementation + performs dynamic memory allocation of its own (note that the + SUNDIALS-provided SUNAdaptController implementations do not need to supply this + routine). + + :param C: the :c:type:`SUNAdaptController` object. + :return: error code indicating success failure + (see :numref:`SUNAdaptController.Description.errorCodes`). + + Usage: + + .. code-block:: c + + retval = SUNAdaptController_Destroy(C); + +.. c:function:: int SUNAdaptController_EstimateStep(SUNAdaptController C, sunrealtype h, sunrealtype dsm, sunrealtype* hnew) + + Estimates a single-rate step size. This routine is required for controllers + of type ``SUN_ADAPTCONTROLLER_H``. + + :param C: the :c:type:`SUNAdaptController` object. + :param h: the step size from the previous step attempt. + :param dsm: the local temporal estimate from the previous step attempt. + :param hnew: (output) pointer to the estimated step size. + :return: error code indicating success failure + (see :numref:`SUNAdaptController.Description.errorCodes`). + + Usage: + + .. code-block:: c + + retval = SUNAdaptController_EstimateStep(C, hcur, dsm, &hnew); + +.. c:function:: int SUNAdaptController_EstimateStepAndOrder(SUNAdaptController C, sunrealtype h, int q, sunrealtype dsm, sunrealtype* hnew, int* qnew) + + Estimates a single-rate step size and corresponding method order. This + routine is required for controllers of type ``SUN_ADAPTCONTROLLER_HQ``. + + :param C: the :c:type:`SUNAdaptController` object. + :param h: the step size from the previous step attempt. + :param q: the method order from the previous step attempt. + :param dsm: the local temporal estimate from the previous step attempt. + :param hnew: (output) pointer to the estimated step size. + :param qnew: (output) pointer to the estimated method order. + :return: error code indicating success failure + (see :numref:`SUNAdaptController.Description.errorCodes`). + + Usage: + + .. code-block:: c + + retval = SUNAdaptController_EstimateStepAndOrder(C, hcur, qcur, dsm, &hnew, &qnew); + +.. c:function:: int SUNAdaptController_EstimateMRISteps(SUNAdaptController C, sunrealtype H, sunrealtype h, sunrealtype DSM, sunrealtype dsm, sunrealtype* Hnew, sunrealtype *hnew) + + Estimates the slow and fast multirate step sizes. This routine is required + for controllers of type ``SUN_ADAPTCONTROLLER_MRI_H``. + + :param C: the :c:type:`SUNAdaptController` object. + :param H: the slow step size from the previous multirate step attempt. + :param h: the fast step size from the previous multirate step attempt. + :param DSM: the local slow temporal error estimate from the previous step + attempt. + :param dsm: the local fast temporal error estimate from the previous step + attempt. + :param Hnew: (output) pointer to the estimated slow step size. + :param hnew: (output) pointer to the estimated fast step size. + :return: error code indicating success failure + (see :numref:`SUNAdaptController.Description.errorCodes`). + + Usage: + + .. code-block:: c + + retval = SUNAdaptController_EstimateMRISteps(C, Hcur, hcur, DSM, &Hnew, &hnew); + +.. c:function:: int SUNAdaptController_EstimateStepTol(SUNAdaptController C, sunrealtype H, sunrealtype tolfac, sunrealtype DSM, sunrealtype *Hnew, sunrealtype* tolfacnew) + + Estimates the slow step size and recommended fast relative tolerance factor + for a multirate step. This routine is required for controllers of type + ``SUN_ADAPTCONTROLLER_MRI_TOL``. + + :param C: the :c:type:`SUNAdaptController` object. + :param H: the slow step size from the previous multirate step attempt. + :param tolfac: the ratio of fast/slow relative tolerances, + :math:`\text{reltol}/\text{RELTOL}`, from the previous + multirate step attempt. + :param DSM: the local slow temporal error estimate from the previous step + attempt. + :param dsm: the local fast temporal error estimate from the previous step + attempt. + :param Hnew: (output) pointer to the estimated slow step size. + :param tolfacnew: (output) pointer to the estimated relative tolerance + ratio. + :return: error code indicating success failure + (see :numref:`SUNAdaptController.Description.errorCodes`). + + Usage: + + .. code-block:: c + + retval = SUNAdaptController_EstimateStepTol(C, Hcur, tolfaccur, DSM, &Hnew, &tolfacnew); + +.. c:function:: int SUNAdaptController_Reset(SUNAdaptController C) + + Resets the controller to its initial state, e.g., if it stores a small number + of previous *dsm* or *h* values. The return value is an integer flag denoting + success/failure of the routine (see + :numref:`SUNAdaptController.Description.errorCodes`). + + :param C: the :c:type:`SUNAdaptController` object. + :return: error code indicating success failure + (see :numref:`SUNAdaptController.Description.errorCodes`). + + Usage: + + .. code-block:: c + + retval = SUNAdaptController_Reset(C); + +.. c:function:: int SUNAdaptController_SetDefaults(SUNAdaptController C) + + Sets the controller parameters to their default values. + + :param C: the :c:type:`SUNAdaptController` object.. + :return: error code indicating success failure + (see :numref:`SUNAdaptController.Description.errorCodes`). + + Usage: + + .. code-block:: c + + retval = SUNAdaptController_SetDefaults(C); + +.. c:function:: int SUNAdaptController_Write(SUNAdaptController C, FILE* fptr) + + Writes all controller parameters to the indicated file pointer. + + :param C: the :c:type:`SUNAdaptController` object. + :param fptr: the output stream to write the parameters. + :return: error code indicating success failure + (see :numref:`SUNAdaptController.Description.errorCodes`). + + Usage: + + .. code-block:: c + + retval = SUNAdaptController_Write(C, stdout); + +.. c:function:: int SUNAdaptController_SetMethodOrder(SUNAdaptController C, int p, int q) + + Called by the time integrator to inform the controller of the asymptotic + order of accuracy for the method and its embedding. + + :param C: the :c:type:`SUNAdaptController` object. + :param p: the asymptotic order of accuracy for the time integration method. + :param q: the asymptotic order of accuracy for the time integration method embedding. + :return: error code indicating success failure + (see :numref:`SUNAdaptController.Description.errorCodes`). + + Usage: + + .. code-block:: c + + retval = SUNAdaptController_SetMethodOrder(C, 3, 2); + +.. c:function:: int SUNAdaptController_AdjustControllerOrder(SUNAdaptController C, int adj) + + Called by a user to request that the controller adjust the order specified by the time + integration method when performing temporal adaptivity, e.g., 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:`adj < 0`. This + adjustment will apply to all subsequent time step adaptivity estimates used by the + controller, and may be undone by a call with :math:`adj = 0`. + + :param C: the :c:type:`SUNAdaptController` object. + :param p: the adjustment that will be applied to the values *p* and *q* from + :c:func:`SUNAdaptController_SetMethodOrder`. + :return: error code indicating success failure + (see :numref:`SUNAdaptController.Description.errorCodes`). + + Usage: + + .. code-block:: c + + retval = SUNAdaptController_AdjustControllerOrder(C, -1); + +.. c:function:: int SUNAdaptController_SetErrorBias(SUNAdaptController C, sunrealtype bias) + + Sets an error bias factor for scaling the local error factors. This is + typically used to slightly exaggerate the temporal error during the + estimation process, leading to a more conservative estimated step size. + + :param C: the :c:type:`SUNAdaptController` object. + :param bias: the error bias factor -- an input :math:`\leq 0` indicates to use + the default value for the controller. + :return: error code indicating success failure + (see :numref:`SUNAdaptController.Description.errorCodes`). + + Usage: + + .. code-block:: c + + retval = SUNAdaptController_SetErrorBias(C, 1.2); + +.. c:function:: int SUNAdaptController_Update(SUNAdaptController C, sunrealtype h, sunrealtype dsm) + + Notifies the controller of a successful time step of size *h* and with + temporal error estimate *dsm*. This is typically used for controllers that + store a history of either step sizes or error estimates for performing the + estimation process. + + :param C: the :c:type:`SUNAdaptController` object. + :param h: the successful step size. + :param dsm: the successful temporal error estimate. + :return: error code indicating success failure + (see :numref:`SUNAdaptController.Description.errorCodes`). + + Usage: + + .. code-block:: c + + retval = SUNAdaptController_Update(C, h, dsm); + +.. c:function:: int SUNAdaptController_UpdateMRIH(SUNAdaptController C, sunrealtype H, sunrealtype h, sunrealtype DSM, sunrealtype dsm) + + Notifies the controller of a successful multirate time step of sizes *H* and + *h*, and with temporal error estimates *DSM* and *dsm*. This is used for + controllers of type *SUN_ADAPTCONTROLLER_MRI_H* that store a history of either + step size inputs or resulting error estimates for performing the estimation + process. + + :param C: the :c:type:`SUNAdaptController` object. + :param H: the successful slow step size. + :param h: the successful fast step size. + :param DSM: the successful slow temporal error estimate. + :param dsm: the successful fast temporal error estimate. + :return: error code indicating success failure + (see :numref:`SUNAdaptController.Description.errorCodes`). + + Usage: + + .. code-block:: c + + retval = SUNAdaptController_UpdateMRIH(C, H, h, DSM, dsm); + +.. c:function:: int SUNAdaptController_UpdateMRITol(SUNAdaptController C, sunrealtype H, sunrealtype tolfac, sunrealtype DSM, sunrealtype dsm) + + Notifies the controller of a successful multirate time step of size *H* and + fast tolerance factor *tolfac*, that resulted in temporal error estimates + *DSM* and *dsm*. This is typically used for controllers of type + *SUN_ADAPTCONTROLLER_MRI_TOL* that store a history of either control inputs or + resulting error estimates for performing the estimation process. + + :param C: the :c:type:`SUNAdaptController` object. + :param H: the successful slow step size. + :param tolfac: the successful fast relative tolerance factor. + :param DSM: the successful slow temporal error estimate. + :param dsm: the successful fast temporal error estimate. + :return: error code indicating success failure + (see :numref:`SUNAdaptController.Description.errorCodes`). + + Usage: + + .. code-block:: c + + retval = SUNAdaptController_Update(C, h, dsm); + +.. c:function:: int SUNAdaptController_Space(SUNAdaptController C, long int *lenrw, long int *leniw) + + Informative routine that returns the memory requirements of the + :c:type:`SUNAdaptController` object. + + :param C: the :c:type:`SUNAdaptController` object.. + :param lenrw: (output) number of ``sunsunrealtype`` words stored in the + controller. + :param leniw: (output) number of ``sunindextype`` words stored in the + controller. This may also include pointers, `int` and + `long int` words. + :return: error code indicating success failure + (see :numref:`SUNAdaptController.Description.errorCodes`). + + Usage: + + .. code-block:: c + + retval = SUNAdaptController_Space(C, &lenrw, &leniw); + + + +.. _SUNAdaptController.Description.errorCodes: + +SUNAdaptController Error Codes +------------------------------ + +SUNAdaptController functions return one of the following set of error codes: + +* ``SUNADAPTCONTROLLER_SUCCESS`` (0) -- successful call. + +* ``SUNADAPTCONTROLLER_ILL_INPUT`` (-1001) -- an illegal input has been provided to the function. + +* ``SUNADAPTCONTROLLER_MEM_FAIL`` (-1002) -- a memory access or allocation failed. + +* ``SUNADAPTCONTROLLER_USER_FCN_FAIL`` (-1003) -- a user-supplied function returned a nonzero [error] value. + +* ``SUNADAPTCONTROLLER_OPERATION_FAIL`` (-1004) -- catch-all for errors not in the above list. + + +C/C++ API Usage +--------------- + +Specific SUNDIALS adaptivity controller modules can be used in C and C++ programs by including +the corresponding header file for that module, e.g. ``sunadaptcontroller/sunadaptcontrollerXYZ.h``. + +Example usage (here ``SUNAdaptControllerXYZ`` is a placeholder for an actual SUNAdaptController +constructor): + +.. code-block:: c + + #include + #include + #include + #include + #include + + int main() + { + /* Create a SUNContext object */ + SUNContext sunctx = ...; + + /* Create a SUNAdaptController object */ + SUNAdaptController C = SUNAdaptControllerXYZ(sunctx); + + /* Use the control object */ + + /* Destroy the control object */ + retval = SUNAdaptController_Destroy(C); + + return 0; + } diff --git a/doc/shared/sunadaptcontroller/SUNAdaptController_ExpGus.rst b/doc/shared/sunadaptcontroller/SUNAdaptController_ExpGus.rst new file mode 100644 index 0000000000..4703d51b14 --- /dev/null +++ b/doc/shared/sunadaptcontroller/SUNAdaptController_ExpGus.rst @@ -0,0 +1,110 @@ +.. + Programmer(s): Daniel R. Reynolds @ SMU + ---------------------------------------------------------------- + SUNDIALS Copyright Start + Copyright (c) 2002-2023, 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 + ---------------------------------------------------------------- + +.. _SUNAdaptController.ExpGus: + +The SUNAdaptController_ExpGus Module +====================================== + +The explicit Gustafsson implementation of the SUNAdaptController class, +SUNAdaptController_ExpGus, implements a controller proposed by K. Gustafsson for +explicit Runge--Kutta methods in :cite:p:`Gust:91`. This controller has the +form + +.. math:: + h' \;=\; \begin{cases} + h_1\; \varepsilon_1^{-1/ord}, &\quad\text{on the first step}, \\ + h_n\; \varepsilon_n^{-k_1/ord}\; + \left(\dfrac{\varepsilon_n}{\varepsilon_{n-1}}\right)^{k_2/ord}, & + \quad\text{on subsequent steps}, + \end{cases} + +with default values :math:`k_1=0.367` and :math:`k_2=0.268`, and where :math:`ord = p+1+adj`, +with both :math:`p` and :math:`adj` described below. In this estimate, a floor of +:math:`\varepsilon > 10^{-10}` is enforced to avoid division-by-zero errors. + +The SUNAdaptController_ExpGus controller is implemented as a derived SUNAdaptController class, +and defines its *content* field as: + +.. code-block:: c + + struct _SUNAdaptControllerContent_ExpGus { + sunrealtype k1; + sunrealtype k2; + sunrealtype bias; + sunrealtype ep; + int p; + int adj; + int pq; + sunbooleantype firststep; + }; + +These entries of the *content* field contain the following information: + +* ``k1, k2`` - controller parameters above. + +* ``bias`` - error bias factor, that converts from an input temporal error + estimate via :math:`\varepsilon = \text{bias}*\text{dsm}`. + +* ``ep`` - storage for the previous error estimate, :math:`\varepsilon_{n-1}`. + +* ``p`` - asymptotic order to use in error control. + +* ``adj`` - order of accuracy adjustment to use within the controller [default ``-1``]. + +* ``pq`` - flag indicating whether ``p`` corresponds to the order of accuracy + for the time integration method (``1``), the embedding (``0``), or the + minimum of the two (``-1``) [default ``0``]. + +* ``firststep`` - flag indicating whether a step has successfully completed, in which + case the formula above transitions from :math:`h_1` to :math:`h_n`. + +The header file to be included when using this module is +``sunadaptcontroller/sunadaptcontroller_expgus.h``. + + +The SUNAdaptController_ExpGus class provides implementations of all operations +relevant to a `SUN_ADAPTCONTROLLER_H` controller listed in +:numref:`SUNAdaptController.Description.operations`. The +SUNAdaptController_ExpGus class also provides the following additional user-callable +routines: + + +.. c:function:: SUNAdaptController SUNAdaptController_ExpGus(SUNContext sunctx) + + This constructor function creates and allocates memory for a SUNAdaptController_ExpGus + object, and inserts its default parameters. + + :param sunctx: the current :c:type:`SUNContext` object. + :return: if successful, a usable :c:type:`SUNAdaptController` object; otherwise it will return ``NULL``. + + Usage: + + .. code-block:: c + + SUNAdaptController C = SUNAdaptController_ExpGus(sunctx); + +.. c:function:: int SUNAdaptController_SetParams_ExpGus(SUNAdaptController C, int pq, sunrealtype k1, sunrealtype k2) + + :param C: the SUNAdaptController_ExpGus object + :param pq: the integer parameter indicating how to interpret the method and embedding orders of accuracy + :param k1: parameter used within the controller time step estimate (only stored if non-negative) + :param k2: parameter used within the controller time step estimate (only stored if non-negative) + :return: error code indication success or failure (see :numref:`SUNAdaptController.Description.errorCodes`). + + Usage: + + .. code-block:: c + + retval = SUNAdaptController_SetParams_ExpGus(C, -1, 0.4, 0.25); diff --git a/doc/shared/sunadaptcontroller/SUNAdaptController_I.rst b/doc/shared/sunadaptcontroller/SUNAdaptController_I.rst new file mode 100644 index 0000000000..b84b32a7cc --- /dev/null +++ b/doc/shared/sunadaptcontroller/SUNAdaptController_I.rst @@ -0,0 +1,100 @@ +.. + Programmer(s): Daniel R. Reynolds @ SMU + ---------------------------------------------------------------- + SUNDIALS Copyright Start + Copyright (c) 2002-2023, 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 + ---------------------------------------------------------------- + +.. _SUNAdaptController.I: + +The SUNAdaptController_I Module +====================================== + +The I implementation of the SUNAdaptController class, SUNAdaptController_I, implements a +standard I temporal adaptivity controller. This is the standard time adaptivity +control algorithm in use by most publicly-available ODE solver codes. It bases +the prospective time step estimate entirely off of the current local error +estimate, + +.. math:: + h' \;=\; h_n\; \varepsilon_n^{-k_1/ord}, + +where :math:`ord = p+1+adj`, where both :math:`p` and :math:`adj` are +described below. In this estimate, a floor of :math:`\varepsilon > 10^{-10}` is enforced to +avoid division-by-zero errors. By default the constant :math:`k_1=1`. + +This is implemented as a derived SUNAdaptController class, and defines its *content* +field as: + +.. code-block:: c + + struct _SUNAdaptControllerContent_I { + sunrealtype k1; + sunrealtype bias; + int p; + int adj; + int pq; + }; + +These entries of the *content* field contain the following information: + +* ``k1`` - controller parameter above. + +* ``bias`` - error bias factor, that converts from an input temporal error + estimate via :math:`\varepsilon = \text{bias}*\text{dsm}`. + +* ``p`` - asymptotic order to use in error control. + +* ``adj`` - order of accuracy adjustment to use within the controller [default ``-1``]. + +* ``pq`` - flag indicating whether ``p`` corresponds to the order of accuracy + for the time integration method (``1``), the embedding (``0``), or the + minimum of the two (``-1``) [default ``0``]. + + +The header file to be included when using this module is +``sunadaptcontroller/sunadaptcontroller_i.h``. + +The SUNAdaptController_I class provides implementations of all operations +relevant to a `SUN_ADAPTCONTROLLER_H` controller listed in +:numref:`SUNAdaptController.Description.operations`. The SUNAdaptController_I class +also provides the following additional user-callable routines: + + +.. c:function:: SUNAdaptController SUNAdaptController_I(SUNContext sunctx) + + This constructor function creates and allocates memory for a SUNAdaptController_I + object, and inserts its default parameters. + + :param sunctx: the current :c:type:`SUNContext` object. + :return: if successful, a usable :c:type:`SUNAdaptController` object; otherwise it will return ``NULL``. + + Usage: + + .. code-block:: c + + SUNAdaptController C = SUNAdaptController_I(sunctx); + +.. c:function:: int SUNAdaptController_SetParams_I(SUNAdaptController C, int pq, sunrealtype k1) + + This user-callable function provides control over the relevant parameters + above. This should be called *before* the time integrator is called to evolve + the problem. + + :param C: the SUNAdaptController_I object + :param pq: the integer parameter indicating how to interpret the method and embedding orders of accuracy + :param k1: parameter used within the controller time step estimate (only stored if non-negative) + :return: error code indication success or failure (see :numref:`SUNAdaptController.Description.errorCodes`). + + Usage: + + .. code-block:: c + + retval = SUNAdaptController_SetParams_I(C, -1, 0.95); diff --git a/doc/shared/sunadaptcontroller/SUNAdaptController_ImExGus.rst b/doc/shared/sunadaptcontroller/SUNAdaptController_ImExGus.rst new file mode 100644 index 0000000000..f656f6d9b3 --- /dev/null +++ b/doc/shared/sunadaptcontroller/SUNAdaptController_ImExGus.rst @@ -0,0 +1,141 @@ +.. + Programmer(s): Daniel R. Reynolds @ SMU + ---------------------------------------------------------------- + SUNDIALS Copyright Start + Copyright (c) 2002-2023, 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 + ---------------------------------------------------------------- + +.. _SUNAdaptController.ImExGus: + +The SUNAdaptController_ImExGus Module +====================================== + +The ImEx Gustafsson implementation of the SUNAdaptController class, SUNAdaptController_ImExGus, +implements a combination of two adaptivity controllers proposed +by K. Gustafsson. His "explicit" controller was proposed in :cite:p:`Gust:91`, +is primarily useful with explicit Runge--Kutta methods, and has the form + +.. math:: + h' \;=\; \begin{cases} + h_1\; \varepsilon_1^{-1/ord}, &\quad\text{on the first step}, \\ + h_n\; \varepsilon_n^{-k_1/ord}\; + \left(\dfrac{\varepsilon_n}{\varepsilon_{n-1}}\right)^{k_2/ord}, & + \quad\text{on subsequent steps}. + \end{cases} + :label: expGusController + +The default values of :math:`k_1` and :math:`k_2` are 0.367 and 0.268, +respectively, and :math:`ord = p+1+adj`, where both :math:`p` and :math:`adj` are +described below. In this estimate, a floor of :math:`\varepsilon > 10^{-10}` is enforced to +avoid division-by-zero errors. + +Gustafsson also proposed a controller for implicit Runge--Kutta methods in :cite:p:`Gust:94`, +with the form + +.. math:: + h' = \begin{cases} + h_1 \varepsilon_1^{-1/ord}, &\quad\text{on the first step}, \\ + h_n \left(\dfrac{h_n}{h_{n-1}}\right) \varepsilon_n^{-k_1/ord} + \left(\dfrac{\varepsilon_n}{\varepsilon_{n-1}}\right)^{-k_2/ord}, & + \quad\text{on subsequent steps}, + \end{cases} + :label: impGusController + +where the default parameter values are :math:`k_1 = 0.98` and :math:`k_2 = 0.95`. + +The SUNAdaptController_ImExGus controller implements both formulas +:eq:`expGusController` and :eq:`impGusController`, and sets its recommended step +size as the minimum of these two. It is implemented as a derived SUNAdaptController +class, and defines its *content* field as: + +.. code-block:: c + + struct _SUNAdaptControllerContent_ImExGus { + sunrealtype k1e; + sunrealtype k2e; + sunrealtype k1i; + sunrealtype k2i; + sunrealtype bias; + sunrealtype ep; + sunrealtype hp; + int p; + int adj; + int pq; + sunbooleantype firststep; + }; + +These entries of the *content* field contain the following information: + +* ``k1e, k2e`` - explicit controller parameters used in :eq:`expGusController`. + +* ``k1i, k2i`` - implicit controller parameters used in :eq:`impGusController`. + +* ``bias`` - error bias factor, that converts from an input temporal error + estimate via :math:`\varepsilon = \text{bias}*\text{dsm}`. + +* ``ep`` - storage for the previous error estimate, :math:`\varepsilon_{n-1}`. + +* ``hp`` - storage for the previous step size, :math:`h_{n-1}`. + +* ``p`` - asymptotic order to use in error control. + +* ``adj`` - order of accuracy adjustment to use within the controller [default ``-1``]. + +* ``pq`` - flag indicating whether ``p`` corresponds to the order of accuracy + for the time integration method (``1``), the embedding (``0``), or the + minimum of the two (``-1``) [default ``0``]. + +* ``firststep`` - flag indicating whether a step has completed successfully, allowing + the formulas above to transition between :math:`h_1` and :math:`h_n`. + +The header file to be included when using this module is +``sunadaptcontroller/sunadaptcontroller_imexgus.h``. + + +The SUNAdaptController_ImExGus class provides implementations of all operations +relevant to a `SUN_ADAPTCONTROLLER_H` controller listed in +:numref:`SUNAdaptController.Description.operations`. The +SUNAdaptController_ImExGus class also provides the following additional user-callable +routines: + + +.. c:function:: SUNAdaptController SUNAdaptController_ImExGus(SUNContext sunctx) + + This constructor function creates and allocates memory for a SUNAdaptController_ImExGus + object, and inserts its default parameters. + + :param sunctx: the current :c:type:`SUNContext` object. + :return: if successful, a usable :c:type:`SUNAdaptController` object; otherwise it will return ``NULL``. + + Usage: + + .. code-block:: c + + SUNAdaptController C = SUNAdaptController_ImExGus(sunctx); + +.. c:function:: int SUNAdaptController_SetParams_ImExGus(SUNAdaptController C, int pq, sunrealtype k1e, sunrealtype k2e, sunrealtype k1i, sunrealtype k2i) + + This user-callable function provides control over the relevant parameters + above. This should be called *before* the time integrator is called to evolve + the problem. + + :param C: the SUNAdaptController_ImExGus object + :param pq: the integer parameter indicating how to interpret the method and embedding orders of accuracy + :param k1e: parameter used within the controller time step estimate (only stored if non-negative) + :param k2e: parameter used within the controller time step estimate (only stored if non-negative) + :param k1i: parameter used within the controller time step estimate (only stored if non-negative) + :param k2i: parameter used within the controller time step estimate (only stored if non-negative) + :return: error code indication success or failure (see :numref:`SUNAdaptController.Description.errorCodes`). + + Usage: + + .. code-block:: c + + retval = SUNAdaptController_SetParams_ImExGus(C, -1, 0.4, 0.3, -1.0, 1.0); diff --git a/doc/shared/sunadaptcontroller/SUNAdaptController_ImpGus.rst b/doc/shared/sunadaptcontroller/SUNAdaptController_ImpGus.rst new file mode 100644 index 0000000000..419ae0f658 --- /dev/null +++ b/doc/shared/sunadaptcontroller/SUNAdaptController_ImpGus.rst @@ -0,0 +1,118 @@ +.. + Programmer(s): Daniel R. Reynolds @ SMU + ---------------------------------------------------------------- + SUNDIALS Copyright Start + Copyright (c) 2002-2023, 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 + ---------------------------------------------------------------- + +.. _SUNAdaptController.ImpGus: + +The SUNAdaptController_ImpGus Module +====================================== + +The implicit Gustafsson implementation of the SUNAdaptController class, +SUNAdaptController_ImpGus, implements a controller proposed by K. Gustafsson for +implicit Runge--Kutta methods in :cite:p:`Gust:94`. This controller has the +form + +.. math:: + h' = \begin{cases} + h_1 \varepsilon_1^{-1/ord}, &\quad\text{on the first step}, \\ + h_n \left(\dfrac{h_n}{h_{n-1}}\right) \varepsilon_n^{-k_1/ord} + \left(\dfrac{\varepsilon_n}{\varepsilon_{n-1}}\right)^{-k_2/ord}, & + \quad\text{on subsequent steps}, + \end{cases} + +with default parameter values :math:`k_1 = 0.98` and :math:`k_2 = 0.95`, and where +:math:`ord = p+1+adj`, where both :math:`p` and :math:`adj` are described below. In +this estimate, a floor of :math:`\varepsilon > 10^{-10}` is enforced to avoid +division-by-zero errors. + +The SUNAdaptController_ImpGus controller is implemented as a derived SUNAdaptController class, +and defines its *content* field as: + +.. code-block:: c + + struct _SUNAdaptControllerContent_ImpGus { + sunrealtype k1; + sunrealtype k2; + sunrealtype bias; + sunrealtype ep; + sunrealtype hp; + int p; + int adj; + int pq; + sunbooleantype firststep; + }; + +These entries of the *content* field contain the following information: + +* ``k1, k2`` - controller parameters above. + +* ``bias`` - error bias factor, that converts from an input temporal error + estimate via :math:`\varepsilon = \text{bias}*\text{dsm}`. + +* ``ep`` - storage for the previous error estimate, :math:`\varepsilon_{n-1}`. + +* ``hp`` - storage for the previous step size, :math:`h_{n-1}`. + +* ``p`` - asymptotic order to use in error control. + +* ``adj`` - order of accuracy adjustment to use within the controller [default ``-1``]. + +* ``pq`` - flag indicating whether ``p`` corresponds to the order of accuracy + for the time integration method (``1``), the embedding (``0``), or the + minimum of the two (``-1``) [default ``0``]. + +* ``firststep`` - flag indicating whether any time steps have completed + successfully (and thus to transition from :math:`h_1` to :math:`h_n` in + the formula above). + +The header file to be included when using this module is +``sunadaptcontroller/sunadaptcontroller_impgus.h``. + + +The SUNAdaptController_ImpGus class provides implementations of all operations +relevant to a `SUN_ADAPTCONTROLLER_H` controller listed in +:numref:`SUNAdaptController.Description.operations`. This class +also provides the following additional user-callable routines: + + +.. c:function:: SUNAdaptController SUNAdaptController_ImpGus(SUNContext sunctx) + + This constructor function creates and allocates memory for a SUNAdaptController_ImpGus + object, and inserts its default parameters. + + :param sunctx: the current :c:type:`SUNContext` object. + :return: if successful, a usable :c:type:`SUNAdaptController` object; otherwise it will return ``NULL``. + + Usage: + + .. code-block:: c + + SUNAdaptController C = SUNAdaptController_ImpGus(sunctx); + +.. c:function:: int SUNAdaptController_SetParams_ImpGus(SUNAdaptController C, int pq, sunrealtype k1, sunrealtype k2) + + This user-callable function provides control over the relevant parameters + above. This should be called *before* the time integrator is called to evolve + the problem. + + :param C: the SUNAdaptController_ImpGus object + :param pq: the integer parameter indicating how to interpret the method and embedding orders of accuracy + :param k1: parameter used within the controller time step estimate (only stored if non-negative) + :param k2: parameter used within the controller time step estimate (only stored if non-negative) + :return: error code indication success or failure (see :numref:`SUNAdaptController.Description.errorCodes`). + + Usage: + + .. code-block:: c + + retval = SUNAdaptController_SetParams_ImpGus(C, -1, 1.0, 0.9); diff --git a/doc/shared/sunadaptcontroller/SUNAdaptController_PI.rst b/doc/shared/sunadaptcontroller/SUNAdaptController_PI.rst new file mode 100644 index 0000000000..2ab7de72bf --- /dev/null +++ b/doc/shared/sunadaptcontroller/SUNAdaptController_PI.rst @@ -0,0 +1,106 @@ +.. + Programmer(s): Daniel R. Reynolds @ SMU + ---------------------------------------------------------------- + SUNDIALS Copyright Start + Copyright (c) 2002-2023, 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 + ---------------------------------------------------------------- + +.. _SUNAdaptController.PI: + +The SUNAdaptController_PI Module +====================================== + +The PI implementation of the SUNAdaptController class, SUNAdaptController_PI, implements a +standard PI temporal adaptivity controller. Like with SUNAdaptController_PID, the PI +controller derives from those found in :cite:p:`KenCarp:03`, :cite:p:`Sod:98`, +:cite:p:`Sod:03` and :cite:p:`Sod:06`, but it differs in that it only uses the +two most recent step sizes in its adaptivity algorithm, + +.. math:: + h' \;=\; h_n\; \varepsilon_n^{-k_1/ord}\; \varepsilon_{n-1}^{k_2/ord}. + +where the constants :math:`k_1` and :math:`k_2` default to 0.8 and 0.31, +respectively, and :math:`ord = p+1+adj`, where both :math:`p` and :math:`adj` are +described below. In this estimate, a floor of :math:`\varepsilon > 10^{-10}` is enforced to +avoid division-by-zero errors. + +This is implemented as a derived SUNAdaptController class, and defines its *content* +field as: + +.. code-block:: c + + struct _SUNAdaptControllerContent_PI { + sunrealtype k1; + sunrealtype k2; + sunrealtype bias; + sunrealtype ep; + int p; + int adj; + int pq; + }; + +These entries of the *content* field contain the following information: + +* ``k1, k2`` - controller parameters above. + +* ``bias`` - error bias factor, that converts from an input temporal error + estimate via :math:`\varepsilon = \text{bias}*\text{dsm}`. + +* ``ep`` - storage for the previous error estimate, :math:`\varepsilon_{n-1}`. + +* ``p`` - asymptotic order to use in error control. + +* ``adj`` - order of accuracy adjustment to use within the controller [default ``-1``]. + +* ``pq`` - flag indicating whether ``p`` corresponds to the order of accuracy + for the time integration method (``1``), the embedding (``0``), or the + minimum of the two (``-1``) [default ``0``]. + + +The header file to be included when using this module is +``sunadaptcontroller/sunadaptcontroller_pi.h``. + +The SUNAdaptController_PI class provides implementations of all operations +relevant to a `SUN_ADAPTCONTROLLER_H` controller listed in +:numref:`SUNAdaptController.Description.operations`. The SUNAdaptController_PI class +also provides the following additional user-callable routines: + + +.. c:function:: SUNAdaptController SUNAdaptController_PI(SUNContext sunctx) + + This constructor function creates and allocates memory for a SUNAdaptController_PI + object, and inserts its default parameters. + + :param sunctx: the current :c:type:`SUNContext` object. + :return: if successful, a usable :c:type:`SUNAdaptController` object; otherwise it will return ``NULL``. + + Usage: + + .. code-block:: c + + SUNAdaptController C = SUNAdaptController_PI(sunctx); + +.. c:function:: int SUNAdaptController_SetParams_PI(SUNAdaptController C, int pq, sunrealtype k1, sunrealtype k2) + + This user-callable function provides control over the relevant parameters + above. This should be called *before* the time integrator is called to evolve + the problem. + + :param C: the SUNAdaptController_PI object + :param pq: the integer parameter indicating how to interpret the method and embedding orders of accuracy + :param k1: parameter used within the controller time step estimate (only stored if non-negative) + :param k2: parameter used within the controller time step estimate (only stored if non-negative) + :return: error code indication success or failure (see :numref:`SUNAdaptController.Description.errorCodes`). + + Usage: + + .. code-block:: c + + retval = SUNAdaptController_SetParams_PI(C, -1, 0.9, 0.3); diff --git a/doc/shared/sunadaptcontroller/SUNAdaptController_PID.rst b/doc/shared/sunadaptcontroller/SUNAdaptController_PID.rst new file mode 100644 index 0000000000..a6696ffba1 --- /dev/null +++ b/doc/shared/sunadaptcontroller/SUNAdaptController_PID.rst @@ -0,0 +1,113 @@ +.. + Programmer(s): Daniel R. Reynolds @ SMU + ---------------------------------------------------------------- + SUNDIALS Copyright Start + Copyright (c) 2002-2023, 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 + ---------------------------------------------------------------- + +.. _SUNAdaptController.PID: + +The SUNAdaptController_PID Module +====================================== + +The PID implementation of the SUNAdaptController class, SUNAdaptController_PID, implements a +standard PID temporal adaptivity controller. It derives from those found in +:cite:p:`KenCarp:03`, :cite:p:`Sod:98`, :cite:p:`Sod:03` and :cite:p:`Sod:06`, +and uses three temporal error estimates, :math:`\varepsilon_n`, +:math:`\varepsilon_{n-1}` and :math:`\varepsilon_{n-2}` in determination of a +prospective step size, + +.. math:: + h' \;=\; h_n\; \varepsilon_n^{-k_1/ord}\; \varepsilon_{n-1}^{k_2/ord}\; + \varepsilon_{n-2}^{-k_3/ord}, + +where the constants :math:`k_1`, :math:`k_2` and :math:`k_3` default to 0.58, +0.21 and 0.1, respectively, and :math:`ord = p+1+adj`, where both :math:`p` and :math:`adj` are +described below. In this estimate, a floor of :math:`\varepsilon > 10^{-10}` is enforced to +avoid division-by-zero errors. + +This is implemented as a derived SUNAdaptController class, and defines its *content* +field as: + +.. code-block:: c + + struct _SUNAdaptControllerContent_PID { + sunrealtype k1; + sunrealtype k2; + sunrealtype k3; + sunrealtype bias; + sunrealtype ep; + sunrealtype epp; + int p; + int adj; + int pq; + }; + +These entries of the *content* field contain the following information: + +* ``k1, k2, k3`` - controller parameters above. + +* ``bias`` - error bias factor, that converts from an input temporal error + estimate via :math:`\varepsilon = \text{bias}*\text{dsm}`. + +* ``ep, epp`` - storage for the two previous error estimates, + :math:`\varepsilon_{n-1}` and :math:`varepsilon_{n-2}`. + +* ``p`` - asymptotic order to use in error control. + +* ``adj`` - order of accuracy adjustment to use within the controller [default ``-1``]. + +* ``pq`` - flag indicating whether ``p`` corresponds to the order of accuracy + for the time integration method (``1``), the embedding (``0``), or the + minimum of the two (``-1``) [default ``0``]. + + +The header file to be included when using this module is +``sunadaptcontroller/sunadaptcontroller_pid.h``. + + +The SUNAdaptController_PID class provides implementations of all operations +relevant to a `SUN_ADAPTCONTROLLER_H` controller listed in +:numref:`SUNAdaptController.Description.operations`. The SUNAdaptController_PID class +also provides the following additional user-callable routines: + + +.. c:function:: SUNAdaptController SUNAdaptController_PID(SUNContext sunctx) + + This constructor function creates and allocates memory for a SUNAdaptController_PID + object, and inserts its default parameters. + + :param sunctx: the current :c:type:`SUNContext` object. + :return: if successful, a usable :c:type:`SUNAdaptController` object; otherwise it will return ``NULL``. + + Usage: + + .. code-block:: c + + SUNAdaptController C = SUNAdaptController_PID(sunctx); + +.. c:function:: int SUNAdaptController_SetParams_PID(SUNAdaptController C, int pq, sunrealtype k1, sunrealtype k2, sunrealtype k3) + + This user-callable function provides control over the relevant parameters + above. This should be called *before* the time integrator is called to evolve + the problem. + + :param C: the SUNAdaptController_PID object + :param pq: the integer parameter indicating how to interpret the method and embedding orders of accuracy + :param k1: parameter used within the controller time step estimate (only stored if non-negative) + :param k2: parameter used within the controller time step estimate (only stored if non-negative) + :param k3: parameter used within the controller time step estimate (only stored if non-negative) + :return: error code indication success or failure (see :numref:`SUNAdaptController.Description.errorCodes`). + + Usage: + + .. code-block:: c + + retval = SUNAdaptController_SetParams_PID(C, -1, 0.6, 0.2, -1.0); diff --git a/doc/superbuild/source/arkode/index.rst b/doc/superbuild/source/arkode/index.rst index 5d09b7044c..972153c5a4 100644 --- a/doc/superbuild/source/arkode/index.rst +++ b/doc/superbuild/source/arkode/index.rst @@ -14,6 +14,8 @@ ARKODE Documentation ******************** +.. include:: ../../../arkode/guide/source/Landing.rst + **Table of Contents**: .. toctree:: diff --git a/doc/superbuild/source/index.rst b/doc/superbuild/source/index.rst index 571e8f9c2d..a0a56ed96e 100644 --- a/doc/superbuild/source/index.rst +++ b/doc/superbuild/source/index.rst @@ -39,6 +39,7 @@ SUNDIALS is developed on `GitHub `_. sunmatrix/index.rst sunlinsol/index.rst sunnonlinsol/index.rst + sunadaptcontroller/index.rst sunmemory/index.rst Install_link.rst History_link.rst diff --git a/doc/superbuild/source/sunadaptcontroller/SUNAdaptController_links.rst b/doc/superbuild/source/sunadaptcontroller/SUNAdaptController_links.rst new file mode 100644 index 0000000000..644d07639e --- /dev/null +++ b/doc/superbuild/source/sunadaptcontroller/SUNAdaptController_links.rst @@ -0,0 +1,18 @@ +.. ---------------------------------------------------------------- + SUNDIALS Copyright Start + Copyright (c) 2002-2023, 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 + ---------------------------------------------------------------- + +.. include:: ../../../shared/sunadaptcontroller/SUNAdaptController_PID.rst +.. include:: ../../../shared/sunadaptcontroller/SUNAdaptController_PI.rst +.. include:: ../../../shared/sunadaptcontroller/SUNAdaptController_I.rst +.. include:: ../../../shared/sunadaptcontroller/SUNAdaptController_ExpGus.rst +.. include:: ../../../shared/sunadaptcontroller/SUNAdaptController_ImpGus.rst +.. include:: ../../../shared/sunadaptcontroller/SUNAdaptController_ImExGus.rst diff --git a/doc/superbuild/source/sunadaptcontroller/index.rst b/doc/superbuild/source/sunadaptcontroller/index.rst new file mode 100644 index 0000000000..34cb523c96 --- /dev/null +++ b/doc/superbuild/source/sunadaptcontroller/index.rst @@ -0,0 +1,20 @@ +.. + Daniel R. Reynolds @ SMU + ---------------------------------------------------------------- + SUNDIALS Copyright Start + Copyright (c) 2002-2023, 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 + ---------------------------------------------------------------- + +.. include:: ../../../shared/sunadaptcontroller/SUNAdaptController_Description.rst + +.. toctree:: + :maxdepth: 1 + + SUNAdaptController_links.rst diff --git a/examples/arkode/CXX_parallel/ark_diffusion_reaction_p.cpp b/examples/arkode/CXX_parallel/ark_diffusion_reaction_p.cpp index 15fac77098..48e3fa6de6 100644 --- a/examples/arkode/CXX_parallel/ark_diffusion_reaction_p.cpp +++ b/examples/arkode/CXX_parallel/ark_diffusion_reaction_p.cpp @@ -67,7 +67,7 @@ // Include MPI #include "mpi.h" -// Include desired integrators, vectors, linear solvers, and nonlinear sovlers +// Include desired integrators, vectors, linear solvers, and nonlinear solvers #include "arkode/arkode_arkstep.h" #include "arkode/arkode_mristep.h" #include "cvode/cvode.h" @@ -393,10 +393,11 @@ static int SetupDecomp(UserData *udata); // Integrator setup functions static int SetupARK(SUNContext ctx, UserData *udata, N_Vector u, - SUNLinearSolver LS, void **arkode_mem); + SUNLinearSolver LS, SUNAdaptController *Ctrl, + void **arkode_mem); static int SetupMRI(SUNContext ctx, UserData *udata, N_Vector u, - SUNLinearSolver LS, void **arkode_mem, - MRIStepInnerStepper *stepper); + SUNLinearSolver LS, SUNAdaptController *Ctrl, + void **arkode_mem, MRIStepInnerStepper *stepper); static int SetupMRICVODE(SUNContext ctx, UserData *udata, N_Vector u, SUNLinearSolver LS, SUNNonlinearSolver *NLS, void **arkode_mem, MRIStepInnerStepper *stepper); @@ -588,15 +589,18 @@ int main(int argc, char* argv[]) // Inner stepper nonlinear solver (CVODE) SUNNonlinearSolver NLS = NULL; + // Timestep adaptivity controller + SUNAdaptController Ctrl = NULL; + // Create integrator switch(udata.integrator) { case(0): - flag = SetupARK(ctx, &udata, u, LS, &arkode_mem); + flag = SetupARK(ctx, &udata, u, LS, &Ctrl, &arkode_mem); if (check_flag((void *) arkode_mem, "SetupARK", 0)) return 1; break; case(1): - flag = SetupMRI(ctx, &udata, u, LS, &arkode_mem, &stepper); + flag = SetupMRI(ctx, &udata, u, LS, &Ctrl, &arkode_mem, &stepper); if (check_flag((void *) arkode_mem, "SetupMRI", 0)) return 1; break; case(2): @@ -746,6 +750,7 @@ int main(int argc, char* argv[]) N_VDestroy(N_VGetLocalVector_MPIPlusX(u)); N_VDestroy(u); FreeUserData(&udata); + (void) SUNAdaptController_Destroy(Ctrl); SUNContext_Free(&ctx); flag = MPI_Finalize(); return 0; @@ -955,7 +960,8 @@ static int SetupDecomp(UserData *udata) static int SetupARK(SUNContext ctx, UserData* udata, N_Vector u, - SUNLinearSolver LS, void** arkode_mem) + SUNLinearSolver LS, SUNAdaptController *Ctrl, + void** arkode_mem) { int flag; @@ -1016,9 +1022,16 @@ static int SetupARK(SUNContext ctx, UserData* udata, N_Vector u, } else { - flag = ARKStepSetAdaptivityMethod(*arkode_mem, udata->controller, SUNTRUE, - SUNFALSE, NULL); - if (check_flag(&flag, "ARKStepSetAdaptivityMethod", 1)) return 1; + switch (udata->controller) { + case (ARK_ADAPT_PID): *Ctrl = SUNAdaptController_PID(ctx); break; + case (ARK_ADAPT_PI): *Ctrl = SUNAdaptController_PI(ctx); break; + case (ARK_ADAPT_I): *Ctrl = SUNAdaptController_I(ctx); break; + case (ARK_ADAPT_EXP_GUS): *Ctrl = SUNAdaptController_ExpGus(ctx); break; + 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; } // Set max steps between outputs @@ -1041,8 +1054,8 @@ static int SetupARK(SUNContext ctx, UserData* udata, N_Vector u, static int SetupMRI(SUNContext ctx, UserData* udata, N_Vector y, - SUNLinearSolver LS, void** arkode_mem, - MRIStepInnerStepper* stepper) + SUNLinearSolver LS, SUNAdaptController *Ctrl, + void** arkode_mem, MRIStepInnerStepper* stepper) { int flag; @@ -1075,9 +1088,16 @@ static int SetupMRI(SUNContext ctx, UserData* udata, N_Vector y, } else { - flag = ARKStepSetAdaptivityMethod(inner_arkode_mem, udata->controller, - SUNTRUE, SUNFALSE, NULL); - if (check_flag(&flag, "ARKStepSetAdaptivityMethod", 1)) return 1; + switch (udata->controller) { + case (ARK_ADAPT_PID): *Ctrl = SUNAdaptController_PID(ctx); break; + case (ARK_ADAPT_PI): *Ctrl = SUNAdaptController_PI(ctx); break; + case (ARK_ADAPT_I): *Ctrl = SUNAdaptController_I(ctx); break; + case (ARK_ADAPT_EXP_GUS): *Ctrl = SUNAdaptController_ExpGus(ctx); break; + 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; } // Set max steps between outputs diff --git a/examples/arkode/CXX_parallel/ark_heat2D_p.cpp b/examples/arkode/CXX_parallel/ark_heat2D_p.cpp index 32623f530c..809c0bb7d6 100644 --- a/examples/arkode/CXX_parallel/ark_heat2D_p.cpp +++ b/examples/arkode/CXX_parallel/ark_heat2D_p.cpp @@ -279,6 +279,7 @@ int main(int argc, char* argv[]) SUNLinearSolver LS = NULL; // linear solver memory structure void *arkode_mem = NULL; // ARKODE memory structure FILE *diagfp = NULL; // diagnostics output file + SUNAdaptController C = NULL; // timestep adaptivity controller // Timing variables double t1 = 0.0; @@ -463,9 +464,16 @@ int main(int argc, char* argv[]) } else { - flag = ARKStepSetAdaptivityMethod(arkode_mem, udata->controller, SUNTRUE, - SUNFALSE, NULL); - if (check_flag(&flag, "ARKStepSetAdaptivityMethod", 1)) return 1; + switch (udata->controller) { + case (ARK_ADAPT_PID): C = SUNAdaptController_PID(ctx); break; + case (ARK_ADAPT_PI): C = SUNAdaptController_PI(ctx); break; + case (ARK_ADAPT_I): C = SUNAdaptController_I(ctx); break; + case (ARK_ADAPT_EXP_GUS): C = SUNAdaptController_ExpGus(ctx); break; + 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; } // Specify linearly implicit non-time-dependent RHS @@ -579,6 +587,7 @@ int main(int argc, char* argv[]) 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 flag = MPI_Finalize(); // Finalize MPI return 0; diff --git a/examples/arkode/CXX_parhyp/ark_heat2D_hypre_ls.cpp b/examples/arkode/CXX_parhyp/ark_heat2D_hypre_ls.cpp index f4b27d9bf8..b38e7ded64 100644 --- a/examples/arkode/CXX_parhyp/ark_heat2D_hypre_ls.cpp +++ b/examples/arkode/CXX_parhyp/ark_heat2D_hypre_ls.cpp @@ -363,6 +363,7 @@ int main(int argc, char* argv[]) SUNLinearSolver LS = NULL; // linear solver memory structure void *arkode_mem = NULL; // ARKODE memory structure FILE *diagfp = NULL; // diagnostics output file + SUNAdaptController C = NULL; // timestep adaptivity controller // Timing variables double t1 = 0.0; @@ -513,9 +514,16 @@ int main(int argc, char* argv[]) } else { - flag = ARKStepSetAdaptivityMethod(arkode_mem, udata->controller, SUNTRUE, - SUNFALSE, NULL); - if (check_flag(&flag, "ARKStepSetAdaptivityMethod", 1)) return 1; + switch (udata->controller) { + case (ARK_ADAPT_PID): C = SUNAdaptController_PID(ctx); break; + case (ARK_ADAPT_PI): C = SUNAdaptController_PI(ctx); break; + case (ARK_ADAPT_I): C = SUNAdaptController_I(ctx); break; + case (ARK_ADAPT_EXP_GUS): C = SUNAdaptController_ExpGus(ctx); break; + 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; } // Specify linearly implicit non-time-dependent RHS @@ -630,6 +638,7 @@ int main(int argc, char* argv[]) 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 flag = MPI_Finalize(); // Finalize MPI return 0; diff --git a/examples/arkode/CXX_parhyp/ark_heat2D_hypre_pfmg.cpp b/examples/arkode/CXX_parhyp/ark_heat2D_hypre_pfmg.cpp index b9468dfc3f..29c9a4d0ee 100644 --- a/examples/arkode/CXX_parhyp/ark_heat2D_hypre_pfmg.cpp +++ b/examples/arkode/CXX_parhyp/ark_heat2D_hypre_pfmg.cpp @@ -322,6 +322,7 @@ int main(int argc, char* argv[]) SUNLinearSolver LS = NULL; // linear solver memory structure void *arkode_mem = NULL; // ARKODE memory structure FILE *diagfp = NULL; // diagnostics output file + SUNAdaptController C = NULL; // timestep adaptivity controller // Timing variables double t1 = 0.0; @@ -516,9 +517,16 @@ int main(int argc, char* argv[]) } else { - flag = ARKStepSetAdaptivityMethod(arkode_mem, udata->controller, SUNTRUE, - SUNFALSE, NULL); - if (check_flag(&flag, "ARKStepSetAdaptivityMethod", 1)) return 1; + switch (udata->controller) { + case (ARK_ADAPT_PID): C = SUNAdaptController_PID(ctx); break; + case (ARK_ADAPT_PI): C = SUNAdaptController_PI(ctx); break; + case (ARK_ADAPT_I): C = SUNAdaptController_I(ctx); break; + case (ARK_ADAPT_EXP_GUS): C = SUNAdaptController_ExpGus(ctx); break; + 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; } // Specify linearly implicit non-time-dependent RHS @@ -632,6 +640,7 @@ int main(int argc, char* argv[]) 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 flag = MPI_Finalize(); // Finalize MPI return 0; 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 ecbd9b44c1..b550f9e607 100644 --- a/examples/arkode/CXX_parhyp/ark_heat2D_hypre_pfmg_imex.cpp +++ b/examples/arkode/CXX_parhyp/ark_heat2D_hypre_pfmg_imex.cpp @@ -318,6 +318,7 @@ int main(int argc, char* argv[]) N_Vector u = NULL; // vector for storing solution SUNLinearSolver LS = NULL; // linear solver memory structure void *arkode_mem = NULL; // ARKode memory structure + SUNAdaptController C = NULL; // Time adaptivity controller // Timing variables double t1 = 0.0; @@ -444,9 +445,16 @@ int main(int argc, char* argv[]) } else { - flag = ARKStepSetAdaptivityMethod(arkode_mem, udata.controller, SUNTRUE, - SUNFALSE, NULL); - if (check_flag(&flag, "ARKStepSetAdaptivityMethod", 1)) return 1; + switch (udata.controller) { + case (ARK_ADAPT_PID): C = SUNAdaptController_PID(sunctx); break; + case (ARK_ADAPT_PI): C = SUNAdaptController_PI(sunctx); break; + case (ARK_ADAPT_I): C = SUNAdaptController_I(sunctx); break; + case (ARK_ADAPT_EXP_GUS): C = SUNAdaptController_ExpGus(sunctx); break; + 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; } // Specify linearly implicit non-time-dependent RHS @@ -538,6 +546,7 @@ int main(int argc, char* argv[]) SUNLinSolFree(LS); // Free linear solver N_VDestroy(u); // Free vectors FreeUserData(&udata); // Free user data + (void) SUNAdaptController_Destroy(C); // Free time adaptivity controller } // Finalize MPI 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 8b1d75c513..7445479282 100644 --- a/examples/arkode/CXX_parhyp/ark_heat2D_hypre_pfmg_mri.cpp +++ b/examples/arkode/CXX_parhyp/ark_heat2D_hypre_pfmg_mri.cpp @@ -325,6 +325,7 @@ int main(int argc, char* argv[]) void *inner_arkode_mem = NULL; // ARKode memory structure MRIStepInnerStepper inner_stepper = NULL; // inner stepper MRIStepCoupling C = NULL; // slow coupling coefficients + SUNAdaptController Ctrl = NULL; // timestep adaptivity controller // Timing variables double t1 = 0.0; @@ -439,9 +440,16 @@ int main(int argc, char* argv[]) } else { - flag = ARKStepSetAdaptivityMethod(inner_arkode_mem, udata.controller, SUNTRUE, - SUNFALSE, NULL); - if (check_flag(&flag, "ARKStepSetAdaptivityMethod", 1)) return 1; + switch (udata.controller) { + case (ARK_ADAPT_PID): Ctrl = SUNAdaptController_PID(sunctx); break; + case (ARK_ADAPT_PI): Ctrl = SUNAdaptController_PI(sunctx); break; + case (ARK_ADAPT_I): Ctrl = SUNAdaptController_I(sunctx); break; + case (ARK_ADAPT_EXP_GUS): Ctrl = SUNAdaptController_ExpGus(sunctx); break; + case (ARK_ADAPT_IMP_GUS): Ctrl = SUNAdaptController_ImpGus(sunctx); break; + case (ARK_ADAPT_IMEX_GUS): Ctrl = SUNAdaptController_ImExGus(sunctx); break; + } + flag = ARKStepSetAdaptController(inner_arkode_mem, Ctrl); + if (check_flag(&flag, "ARKStepSetAdaptController", 1)) return 1; } // Attach user data @@ -606,6 +614,7 @@ int main(int argc, char* argv[]) SUNLinSolFree(LSf); // Free linear solver N_VDestroy(u); // Free vectors FreeUserData(&udata); // Free user data + (void) SUNAdaptController_Destroy(Ctrl); // Free timestep adaptivity controller } // Finalize MPI diff --git a/examples/arkode/CXX_serial/ark_advection_diffusion_reaction.cpp b/examples/arkode/CXX_serial/ark_advection_diffusion_reaction.cpp index dfb312466b..cde3f49b41 100644 --- a/examples/arkode/CXX_serial/ark_advection_diffusion_reaction.cpp +++ b/examples/arkode/CXX_serial/ark_advection_diffusion_reaction.cpp @@ -185,6 +185,9 @@ int main(int argc, char* argv[]) SUNMatrix A = nullptr; SUNLinearSolver LS = nullptr; + // Adaptivity controller for DIRK, IMEX or MRI fast integrators + SUNAdaptController C = nullptr; + // Matrix and linear solver for MRI fast integrator SUNMatrix A_fast = nullptr; SUNLinearSolver LS_fast = nullptr; @@ -196,13 +199,13 @@ int main(int argc, char* argv[]) switch(uopts.integrator) { case(0): - flag = SetupERK(ctx, udata, uopts, y, &arkode_mem); + flag = SetupERK(ctx, udata, uopts, y, &C, &arkode_mem); break; case(1): - flag = SetupARK(ctx, udata, uopts, y, &A, &LS, &arkode_mem); + flag = SetupARK(ctx, udata, uopts, y, &A, &LS, &C, &arkode_mem); break; case(2): - flag = SetupMRIARK(ctx, udata, uopts, y, &A, &LS, &A_fast, &LS_fast, + flag = SetupMRIARK(ctx, udata, uopts, y, &A, &LS, &A_fast, &LS_fast, &C, &fast_mem, &arkode_mem); break; case(3): @@ -365,6 +368,7 @@ int main(int argc, char* argv[]) SUNLinSolFree(LS); SUNMatDestroy(A_fast); SUNLinSolFree(LS_fast); + (void) SUNAdaptController_Destroy(C); return 0; } @@ -376,7 +380,7 @@ int main(int argc, char* argv[]) int SetupERK(SUNContext ctx, UserData &udata, UserOptions &uopts, N_Vector y, - void** arkode_mem) + SUNAdaptController* C, void** arkode_mem) { // Problem configuration ARKRhsFn f_RHS; // explicit RHS function @@ -426,9 +430,16 @@ int SetupERK(SUNContext ctx, UserData &udata, UserOptions &uopts, N_Vector y, } else if (uopts.controller >= 0) { - flag = ERKStepSetAdaptivityMethod(*arkode_mem, uopts.controller, SUNTRUE, - SUNFALSE, nullptr); - if (check_flag(flag, "ERKStepSetAdaptivityMethod")) return 1; + switch (uopts.controller) { + case (ARK_ADAPT_PID): *C = SUNAdaptController_PID(ctx); break; + case (ARK_ADAPT_PI): *C = SUNAdaptController_PI(ctx); break; + case (ARK_ADAPT_I): *C = SUNAdaptController_I(ctx); break; + case (ARK_ADAPT_EXP_GUS): *C = SUNAdaptController_ExpGus(ctx); break; + 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; } // Set max steps between outputs @@ -444,7 +455,7 @@ int SetupERK(SUNContext ctx, UserData &udata, UserOptions &uopts, N_Vector y, int SetupARK(SUNContext ctx, UserData &udata, UserOptions &uopts, N_Vector y, - SUNMatrix* A, SUNLinearSolver* LS, void** arkode_mem) + SUNMatrix* A, SUNLinearSolver* LS, SUNAdaptController* C, void** arkode_mem) { // Problem configuration ARKRhsFn fe_RHS; // explicit RHS function @@ -673,9 +684,16 @@ int SetupARK(SUNContext ctx, UserData &udata, UserOptions &uopts, N_Vector y, } else if (uopts.controller >= 0) { - flag = ARKStepSetAdaptivityMethod(*arkode_mem, uopts.controller, SUNTRUE, - SUNFALSE, nullptr); - if (check_flag(flag, "ARKStepSetAdaptivityMethod")) return 1; + switch (uopts.controller) { + case (ARK_ADAPT_PID): *C = SUNAdaptController_PID(ctx); break; + case (ARK_ADAPT_PI): *C = SUNAdaptController_PI(ctx); break; + case (ARK_ADAPT_I): *C = SUNAdaptController_I(ctx); break; + case (ARK_ADAPT_EXP_GUS): *C = SUNAdaptController_ExpGus(ctx); break; + 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; } // Set max steps between outputs @@ -693,7 +711,8 @@ int SetupARK(SUNContext ctx, UserData &udata, UserOptions &uopts, N_Vector y, int SetupMRIARK(SUNContext ctx, UserData &udata, UserOptions &uopts, N_Vector y, SUNMatrix* A, SUNLinearSolver* LS, SUNMatrix* A_fast, SUNLinearSolver* LS_fast, - MRIStepInnerStepper* fast_mem, void** arkode_mem) + SUNAdaptController* C, MRIStepInnerStepper* fast_mem, + void** arkode_mem) { // Problem configuration ARKRhsFn fse_RHS; // slow explicit RHS function @@ -805,9 +824,16 @@ int SetupMRIARK(SUNContext ctx, UserData &udata, UserOptions &uopts, } else if (uopts.controller_fast >= 0) { - flag = ARKStepSetAdaptivityMethod(fast_arkode_mem, uopts.controller_fast, - SUNTRUE, SUNFALSE, nullptr); - if (check_flag(flag, "ARKStepSetAdaptivityMethod")) return 1; + switch (uopts.controller_fast) { + case (ARK_ADAPT_PID): *C = SUNAdaptController_PID(ctx); break; + case (ARK_ADAPT_PI): *C = SUNAdaptController_PI(ctx); break; + case (ARK_ADAPT_I): *C = SUNAdaptController_I(ctx); break; + case (ARK_ADAPT_EXP_GUS): *C = SUNAdaptController_ExpGus(ctx); break; + 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; } // Set max steps between outputs diff --git a/examples/arkode/CXX_serial/ark_advection_diffusion_reaction.hpp b/examples/arkode/CXX_serial/ark_advection_diffusion_reaction.hpp index f4c2a56146..f72f53b066 100644 --- a/examples/arkode/CXX_serial/ark_advection_diffusion_reaction.hpp +++ b/examples/arkode/CXX_serial/ark_advection_diffusion_reaction.hpp @@ -248,14 +248,14 @@ int J_adv_diff_react(realtype t, N_Vector y, N_Vector fy, SUNMatrix J, // Integrator setup functions int SetupERK(SUNContext ctx, UserData &udata, UserOptions &uopts, N_Vector y, - void** arkode_mem); + SUNAdaptController* C, void** arkode_mem); int SetupARK(SUNContext ctx, UserData &udata, UserOptions &uopts, N_Vector y, - SUNMatrix* A, SUNLinearSolver* LS, void** arkode_mem); + SUNMatrix* A, SUNLinearSolver* LS, SUNAdaptController* C, void** arkode_mem); int SetupMRIARK(SUNContext ctx, UserData &udata, UserOptions &uopts, N_Vector y, SUNMatrix* A, SUNLinearSolver* LS, - SUNMatrix* A_fast, SUNLinearSolver* LS_fast, + SUNMatrix* A_fast, SUNLinearSolver* LS_fast, SUNAdaptController* C_fast, MRIStepInnerStepper* fast_mem, void** arkode_mem); int SetupMRICVODE(SUNContext ctx, UserData &udata, UserOptions &uopts, diff --git a/examples/arkode/CXX_serial/ark_heat2D.cpp b/examples/arkode/CXX_serial/ark_heat2D.cpp index 3a78042a25..7c5c677e89 100644 --- a/examples/arkode/CXX_serial/ark_heat2D.cpp +++ b/examples/arkode/CXX_serial/ark_heat2D.cpp @@ -207,6 +207,7 @@ int main(int argc, char* argv[]) N_Vector u = NULL; // vector for storing solution SUNLinearSolver LS = NULL; // linear solver memory structure void *arkode_mem = NULL; // ARKODE memory structure + SUNAdaptController C = NULL; // Adaptivity controller FILE *diagfp = NULL; // diagnostics output file // Timing variables @@ -371,9 +372,16 @@ int main(int argc, char* argv[]) } else { - flag = ARKStepSetAdaptivityMethod(arkode_mem, udata->controller, SUNTRUE, - SUNFALSE, NULL); - if (check_flag(&flag, "ARKStepSetAdaptivityMethod", 1)) return 1; + switch (udata->controller) { + case (ARK_ADAPT_PID): C = SUNAdaptController_PID(ctx); break; + case (ARK_ADAPT_PI): C = SUNAdaptController_PI(ctx); break; + case (ARK_ADAPT_I): C = SUNAdaptController_I(ctx); break; + case (ARK_ADAPT_EXP_GUS): C = SUNAdaptController_ExpGus(ctx); break; + 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; } // Specify linearly implicit non-time-dependent RHS @@ -484,6 +492,7 @@ int main(int argc, char* argv[]) 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 return 0; 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 9aae281556..f20e4c97e0 100644 --- a/examples/arkode/CXX_xbraid/ark_heat2D_hypre_pfmg_xbraid.cpp +++ b/examples/arkode/CXX_xbraid/ark_heat2D_hypre_pfmg_xbraid.cpp @@ -358,6 +358,7 @@ int main(int argc, char* argv[]) FILE *diagfp = NULL; // diagnostics output file braid_Core core = NULL; // XBraid memory structure braid_App app = NULL; // ARKode + XBraid interface structure + SUNAdaptController C = NULL; // time step adaptivity controller // Timing variables double t1 = 0.0; @@ -559,9 +560,11 @@ int main(int argc, char* argv[]) // Set adaptive stepping (XBraid with temporal refinement) options if (udata->x_refine) { - // Use I controller - flag = ARKStepSetAdaptivityMethod(arkode_mem, ARK_ADAPT_I, 1, 0, NULL); - if (check_flag(&flag, "ARKStepSetAdaptivityMethod", 1)) return 1; + // 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; // Set the step size reduction factor limit (1 / refinement factor limit) flag = ARKStepSetMinReduction(arkode_mem, ONE / udata->x_rfactor_limit); @@ -741,15 +744,16 @@ int main(int argc, char* argv[]) if ((udata->diagnostics || udata->lsinfo) && udata->myid_c == 0) fclose(diagfp); - ARKStepFree(&arkode_mem); // Free integrator memory - SUNLinSolFree(LS); // Free linear solver - N_VDestroy(u); // Free vectors - FreeUserData(udata); // Free user data + ARKStepFree(&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 - SUNContext_Free(&ctx); // Free context - flag = MPI_Finalize(); // Finalize MPI + braid_Destroy(core); // Free braid memory + ARKBraid_Free(&app); // Free interface memory + (void) SUNAdaptController_Destroy(C); // Free time adaptivity controller + SUNContext_Free(&ctx); // Free context + flag = MPI_Finalize(); // Finalize MPI return 0; } diff --git a/examples/arkode/CXX_xbraid/ark_heat2D_p_xbraid.cpp b/examples/arkode/CXX_xbraid/ark_heat2D_p_xbraid.cpp index 938562ce40..a9d90df9bd 100644 --- a/examples/arkode/CXX_xbraid/ark_heat2D_p_xbraid.cpp +++ b/examples/arkode/CXX_xbraid/ark_heat2D_p_xbraid.cpp @@ -315,6 +315,7 @@ int main(int argc, char* argv[]) FILE *diagfp = NULL; // diagnostics output file braid_Core core = NULL; // XBraid memory structure braid_App app = NULL; // ARKode + XBraid interface structure + SUNAdaptController C = NULL; // time step adaptivity controller // Timing variables double t1 = 0.0; @@ -506,9 +507,11 @@ int main(int argc, char* argv[]) // Set adaptive stepping (XBraid with temporal refinement) options if (udata->x_refine) { - // Use I controller - flag = ARKStepSetAdaptivityMethod(arkode_mem, ARK_ADAPT_I, 1, 0, NULL); - if (check_flag(&flag, "ARKStepSetAdaptivityMethod", 1)) return 1; + // 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; // Set the step size reduction factor limit (1 / refinement factor limit) flag = ARKStepSetMinReduction(arkode_mem, ONE / udata->x_rfactor_limit); @@ -688,15 +691,16 @@ int main(int argc, char* argv[]) if ((udata->diagnostics || udata->lsinfo) && udata->myid_c == 0) fclose(diagfp); - ARKStepFree(&arkode_mem); // Free integrator memory - SUNLinSolFree(LS); // Free linear solver - N_VDestroy(u); // Free vectors - FreeUserData(udata); // Free user data + ARKStepFree(&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 - SUNContext_Free(&ctx); // Free context - flag = MPI_Finalize(); // Finalize MPI + braid_Destroy(core); // Free braid memory + ARKBraid_Free(&app); // Free interface memory + (void) SUNAdaptController_Destroy(C); // Free time adaptivity controller + SUNContext_Free(&ctx); // Free context + flag = MPI_Finalize(); // Finalize MPI return 0; } diff --git a/examples/arkode/CXX_xbraid/ark_heat2D_xbraid.cpp b/examples/arkode/CXX_xbraid/ark_heat2D_xbraid.cpp index 5e4a0b9104..1b146d8a80 100644 --- a/examples/arkode/CXX_xbraid/ark_heat2D_xbraid.cpp +++ b/examples/arkode/CXX_xbraid/ark_heat2D_xbraid.cpp @@ -239,14 +239,15 @@ static int check_flag(void *flagvalue, const string funcname, int opt); int main(int argc, char* argv[]) { - int flag; // reusable error-checking flag - UserData *udata = NULL; // user data structure - N_Vector u = NULL; // vector for storing solution - SUNLinearSolver LS = NULL; // linear solver memory structure - void *arkode_mem = NULL; // ARKODE memory structure - FILE *diagfp = NULL; // diagnostics output file - braid_Core core = NULL; // XBraid memory structure - braid_App app = NULL; // ARKode + XBraid interface structure + int flag; // reusable error-checking flag + UserData *udata = NULL; // user data structure + N_Vector u = NULL; // vector for storing solution + SUNLinearSolver LS = NULL; // linear solver memory structure + void *arkode_mem = NULL; // ARKODE memory structure + FILE *diagfp = NULL; // diagnostics output file + braid_Core core = NULL; // XBraid memory structure + braid_App app = NULL; // ARKode + XBraid interface structure + SUNAdaptController C = NULL; // time adaptivity controller // Timing variables chrono::time_point t1; @@ -444,9 +445,11 @@ int main(int argc, char* argv[]) // Set adaptive stepping (XBraid with temporal refinement) options if (udata->x_refine) { - // Use I controller - flag = ARKStepSetAdaptivityMethod(arkode_mem, ARK_ADAPT_I, 1, 0, NULL); - if (check_flag(&flag, "ARKStepSetAdaptivityMethod", 1)) return 1; + // 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; // Set the step size reduction factor limit (1 / refinement factor limit) flag = ARKStepSetMinReduction(arkode_mem, ONE / udata->x_rfactor_limit); @@ -626,15 +629,16 @@ int main(int argc, char* argv[]) if (udata->diagnostics || udata->lsinfo) fclose(diagfp); - ARKStepFree(&arkode_mem); // Free integrator memory - SUNLinSolFree(LS); // Free linear solver - N_VDestroy(u); // Free vectors - FreeUserData(udata); // Free user data + ARKStepFree(&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 - SUNContext_Free(&ctx); // Free context - flag = MPI_Finalize(); // Finalize MPI + braid_Destroy(core); // Free braid memory + ARKBraid_Free(&app); // Free interface memory + (void) SUNAdaptController_Destroy(C); // Free time adaptivity controller + SUNContext_Free(&ctx); // Free context + flag = MPI_Finalize(); // Finalize MPI 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 82b50d1a4d..bdadafc89b 100644 --- a/examples/arkode/C_openmpdev/ark_heat1D_adapt_ompdev.c +++ b/examples/arkode/C_openmpdev/ark_heat1D_adapt_ompdev.c @@ -121,6 +121,7 @@ int main() { N_Vector yt = NULL; /* empty vector for swapping */ SUNLinearSolver LS = NULL; /* empty linear solver object */ void *arkode_mem = NULL; /* empty ARKode memory structure */ + SUNAdaptController C = NULL; /* empty controller object */ FILE *XFID, *UFID; realtype t, olddt, newdt; realtype *xnew_host = NULL; @@ -189,6 +190,12 @@ int main() { flag = ARKStepSetPredictorMethod(arkode_mem, 0); /* Set predictor method */ if (check_flag(&flag, "ARKStepSetPredictorMethod", 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; + /* Specify linearly implicit RHS, with time-dependent Jacobian */ flag = ARKStepSetLinear(arkode_mem, 1); if (check_flag(&flag, "ARKStepSetLinear", 1)) return 1; @@ -315,6 +322,7 @@ int main() { free(udata); ARKStepFree(&arkode_mem); /* Free integrator memory */ SUNLinSolFree(LS); /* Free linear solver */ + (void) SUNAdaptController_Destroy(C); /* Free time adaptivity controller */ SUNContext_Free(&ctx); /* Free context */ return 0; diff --git a/examples/arkode/C_petsc/ark_petsc_ex25.c b/examples/arkode/C_petsc/ark_petsc_ex25.c index 9c144a9782..2d88255774 100644 --- a/examples/arkode/C_petsc/ark_petsc_ex25.c +++ b/examples/arkode/C_petsc/ark_petsc_ex25.c @@ -74,6 +74,7 @@ int main(int argc, char **argv) N_Vector nvecx; /* SUNDIALS N_Vector wrapper of X */ SUNNonlinearSolver NLS; /* SUNDIALS nonlinear solver */ SUNContext ctx; /* SUNDIALS context */ + SUNAdaptController C; /* SUNDIALS controller object */ /* PETSc data structures */ SNES snes; /* nonlinear solver */ @@ -205,8 +206,10 @@ int main(int argc, char **argv) ierr = ARKStepSetNonlinearSolver(arkode_mem,NLS); if (check_retval(&ierr,"ARKStepSetNonlinearSolver",1)) return 1; - ierr = ARKStepSetAdaptivityMethod(arkode_mem,2,1,0,NULL); - if (check_retval(&ierr,"ARKStepSetAdaptivity",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 = ARKStepSetInitStep(arkode_mem,dt); if (check_retval(&ierr,"ARKStepSetInitStep",1)) return 1; @@ -251,6 +254,7 @@ int main(int argc, char **argv) N_VDestroy(nvecx); /* Free x nvector */ SUNNonlinSolFree(NLS); /* Free nonlinear solver */ ARKStepFree(&arkode_mem); /* Free integrator memory */ + (void) SUNAdaptController_Destroy(C); /* Free time adaptivity controller */ /* Free petsc data structures */ ierr = MatDestroy(&J);CHKERRQ(ierr); diff --git a/examples/arkode/F2003_serial/ark_analytic_f2003.f90 b/examples/arkode/F2003_serial/ark_analytic_f2003.f90 index 9de6e47616..8a2eaff61e 100644 --- a/examples/arkode/F2003_serial/ark_analytic_f2003.f90 +++ b/examples/arkode/F2003_serial/ark_analytic_f2003.f90 @@ -101,6 +101,8 @@ program main use fsunmatrix_dense_mod ! Fortran interface to dense SUNMatrix use fsunlinsol_dense_mod ! Fortran interface to dense SUNLinearSolver use fsundials_context_mod ! Fortran interface to SUNContext + use fsundials_adaptcontroller_mod ! Fortran interface to the generic SUNAdaptController + use fsunadaptcontroller_impgus_mod ! Fortran interface to ImpGus controller use ode_mod ! ODE functions !======= Declarations ========= @@ -114,17 +116,16 @@ program main real(c_double) :: dtout ! output time interval real(c_double) :: tout ! output time real(c_double) :: tcur(1) ! current time - integer(c_int) :: imethod, idefault, pq ! time step adaptivity parameters - real(c_double) :: adapt_params(3) ! time step adaptivity parameters integer(c_int) :: ierr ! error flag from C functions integer(c_int) :: nout ! number of outputs integer(c_int) :: outstep ! output loop counter - type(N_Vector), pointer :: sunvec_y ! sundials vector - type(SUNMatrix), pointer :: sunmat_A ! sundials matrix - type(SUNLinearSolver), pointer :: sunls ! sundials linear solver - type(c_ptr) :: arkode_mem ! ARKODE memory - real(c_double), pointer :: yvec(:) ! underlying vector + type(N_Vector), pointer :: sunvec_y ! sundials vector + type(SUNMatrix), pointer :: sunmat_A ! sundials matrix + type(SUNLinearSolver), pointer :: sunls ! sundials linear solver + type(SUNAdaptController), pointer :: sunCtrl ! time step controller + type(c_ptr) :: arkode_mem ! ARKODE memory + real(c_double), pointer :: yvec(:) ! underlying vector !======= Internals ============ @@ -183,12 +184,14 @@ program main stop 1 end if - imethod = 4 - idefault = 1 - pq = 0 - ierr = FARKStepSetAdaptivityMethod(arkode_mem, imethod, idefault, pq, adapt_params) + sunCtrl => FSUNAdaptController_ImpGus(ctx) + if (.not. associated(sunCtrl)) then + print *, 'ERROR: sunCtrl = NULL' + stop 1 + end if + ierr = FARKStepSetAdaptController(arkode_mem, sunCtrl) if (ierr /= 0) then - write(*,*) 'Error in FARKStepSetAdaptivityMethod, ierr = ', ierr, '; halting' + write(*,*) 'Error in FARKStepSetAdaptController, ierr = ', ierr, '; halting' stop 1 end if @@ -222,6 +225,7 @@ program main call FN_VDestroy(sunvec_y) call FSUNMatDestroy(sunmat_A) ierr = FSUNLinSolFree(sunls) + ierr = FSUNAdaptController_Destroy(sunCtrl) ierr = FSUNContext_Free(ctx) end program main diff --git a/include/arkode/arkode.h b/include/arkode/arkode.h index 3b12589182..a6ed8ebe83 100644 --- a/include/arkode/arkode.h +++ b/include/arkode/arkode.h @@ -137,6 +137,7 @@ extern "C" { #define ARK_RELAX_FUNC_FAIL -45 #define ARK_RELAX_JAC_FAIL -46 +#define ARK_CONTROLLER_ERR -47 #define ARK_UNRECOGNIZED_ERROR -99 diff --git a/include/arkode/arkode_arkstep.h b/include/arkode/arkode_arkstep.h index a4951bb888..33f22cdc41 100644 --- a/include/arkode/arkode_arkstep.h +++ b/include/arkode/arkode_arkstep.h @@ -20,6 +20,12 @@ #include #include #include +#include +#include +#include +#include +#include +#include #include #include #include @@ -180,6 +186,7 @@ SUNDIALS_EXPORT int ARKStepSetTableNum(void *arkode_mem, ARKODE_DIRKTableID itable, 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 ARKStepSetCFLFraction(void *arkode_mem, realtype cfl_frac); SUNDIALS_EXPORT int ARKStepSetSafetyFactor(void *arkode_mem, @@ -192,13 +199,13 @@ SUNDIALS_EXPORT int ARKStepSetMinReduction(void *arkode_mem, realtype eta_min); SUNDIALS_EXPORT int ARKStepSetFixedStepBounds(void *arkode_mem, realtype lb, realtype ub); -SUNDIALS_EXPORT int ARKStepSetAdaptivityMethod(void *arkode_mem, - int imethod, - int idefault, int pq, - realtype adapt_params[3]); -SUNDIALS_EXPORT int ARKStepSetAdaptivityFn(void *arkode_mem, - ARKAdaptFn hfun, - void *h_data); +SUNDIALS_DEPRECATED_EXPORT_MSG("use SUNAdaptController instead") +int ARKStepSetAdaptivityMethod(void *arkode_mem, int imethod, + int idefault, int pq, + realtype 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, realtype etamx1); SUNDIALS_EXPORT int ARKStepSetMaxEFailGrowth(void *arkode_mem, diff --git a/include/arkode/arkode_erkstep.h b/include/arkode/arkode_erkstep.h index 9f5b56f072..ada9648a6a 100644 --- a/include/arkode/arkode_erkstep.h +++ b/include/arkode/arkode_erkstep.h @@ -18,6 +18,12 @@ #define _ERKSTEP_H #include +#include +#include +#include +#include +#include +#include #include #include @@ -111,6 +117,7 @@ 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 ERKStepSetCFLFraction(void *arkode_mem, realtype cfl_frac); SUNDIALS_EXPORT int ERKStepSetSafetyFactor(void *arkode_mem, @@ -123,13 +130,13 @@ SUNDIALS_EXPORT int ERKStepSetMinReduction(void *arkode_mem, realtype eta_min); SUNDIALS_EXPORT int ERKStepSetFixedStepBounds(void *arkode_mem, realtype lb, realtype ub); -SUNDIALS_EXPORT int ERKStepSetAdaptivityMethod(void *arkode_mem, - int imethod, - int idefault, int pq, - realtype adapt_params[3]); -SUNDIALS_EXPORT int ERKStepSetAdaptivityFn(void *arkode_mem, - ARKAdaptFn hfun, - void *h_data); +SUNDIALS_DEPRECATED_EXPORT_MSG("use SUNAdaptController instead") +int ERKStepSetAdaptivityMethod(void *arkode_mem, int imethod, + int idefault, int pq, + realtype 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, realtype etamx1); SUNDIALS_EXPORT int ERKStepSetMaxEFailGrowth(void *arkode_mem, diff --git a/include/sunadaptcontroller/sunadaptcontroller_expgus.h b/include/sunadaptcontroller/sunadaptcontroller_expgus.h new file mode 100644 index 0000000000..f86df2be71 --- /dev/null +++ b/include/sunadaptcontroller/sunadaptcontroller_expgus.h @@ -0,0 +1,80 @@ +/* ----------------------------------------------------------------- + * Programmer(s): Daniel R. Reynolds @ SMU + * ----------------------------------------------------------------- + * SUNDIALS Copyright Start + * Copyright (c) 2002-2023, Lawrence Livermore National Security + * and Southern Methodist University. + * All rights reserved. + * + * See the top-level LICENSE and NOTICE files for details. + * + * SPDX-License-Identifier: BSD-3-Clause + * SUNDIALS Copyright End + * ----------------------------------------------------------------- + * This is the header file for the SUNAdaptController_ExpGus module. + * -----------------------------------------------------------------*/ + +#ifndef _SUNADAPTCONTROLLER_EXPGUS_H +#define _SUNADAPTCONTROLLER_EXPGUS_H + +#include +#include + +#ifdef __cplusplus /* wrapper to enable C++ usage */ +extern "C" { +#endif + +/* -------------------------------------------------------- + * Explicit Gustafsson implementation of SUNAdaptController + * -------------------------------------------------------- */ + +struct _SUNAdaptControllerContent_ExpGus { + sunrealtype k1; /* internal controller parameters */ + sunrealtype k2; + sunrealtype bias; /* error bias factor */ + sunrealtype ep; /* error from previous step */ + int p; /* method/embedding order of accuracy */ + int adj; /* order of accuracy adjustment to use for controller */ + int pq; /* p is order of embedding (0), method (1), or minimum (-1) */ + sunbooleantype firststep; /* flag indicating first step */ +}; + +typedef struct _SUNAdaptControllerContent_ExpGus *SUNAdaptControllerContent_ExpGus; + +/* ------------------ + * Exported Functions + * ------------------ */ + +SUNDIALS_EXPORT +SUNAdaptController SUNAdaptController_ExpGus(SUNContext sunctx); +SUNDIALS_EXPORT +int SUNAdaptController_SetParams_ExpGus(SUNAdaptController C, int pq, + sunrealtype k1, sunrealtype k2); +SUNDIALS_EXPORT +SUNAdaptController_Type SUNAdaptController_GetType_ExpGus(SUNAdaptController C); +SUNDIALS_EXPORT +int SUNAdaptController_EstimateStep_ExpGus(SUNAdaptController C, sunrealtype h, + sunrealtype dsm, sunrealtype* hnew); +SUNDIALS_EXPORT +int SUNAdaptController_Reset_ExpGus(SUNAdaptController C); +SUNDIALS_EXPORT +int SUNAdaptController_SetDefaults_ExpGus(SUNAdaptController C); +SUNDIALS_EXPORT +int SUNAdaptController_Write_ExpGus(SUNAdaptController C, FILE* fptr); +SUNDIALS_EXPORT +int SUNAdaptController_SetMethodOrder_ExpGus(SUNAdaptController C, int p, int q); +SUNDIALS_EXPORT +int SUNAdaptController_AdjustControllerOrder_ExpGus(SUNAdaptController C, int adj); +SUNDIALS_EXPORT +int SUNAdaptController_SetErrorBias_ExpGus(SUNAdaptController C, sunrealtype bias); +SUNDIALS_EXPORT +int SUNAdaptController_Update_ExpGus(SUNAdaptController C, sunrealtype h, sunrealtype dsm); +SUNDIALS_EXPORT +int SUNAdaptController_Space_ExpGus(SUNAdaptController C, long int *lenrw, + long int *leniw); + +#ifdef __cplusplus +} +#endif + +#endif /* _SUNADAPTCONTROLLER_EXPGUS_H */ diff --git a/include/sunadaptcontroller/sunadaptcontroller_i.h b/include/sunadaptcontroller/sunadaptcontroller_i.h new file mode 100644 index 0000000000..f8b34d7eea --- /dev/null +++ b/include/sunadaptcontroller/sunadaptcontroller_i.h @@ -0,0 +1,73 @@ +/* ----------------------------------------------------------------- + * Programmer(s): Daniel R. Reynolds @ SMU + * ----------------------------------------------------------------- + * SUNDIALS Copyright Start + * Copyright (c) 2002-2023, Lawrence Livermore National Security + * and Southern Methodist University. + * All rights reserved. + * + * See the top-level LICENSE and NOTICE files for details. + * + * SPDX-License-Identifier: BSD-3-Clause + * SUNDIALS Copyright End + * ----------------------------------------------------------------- + * This is the header file for the SUNAdaptController_I module. + * -----------------------------------------------------------------*/ + +#ifndef _SUNADAPTCONTROLLER_I_H +#define _SUNADAPTCONTROLLER_I_H + +#include +#include + +#ifdef __cplusplus /* wrapper to enable C++ usage */ +extern "C" { +#endif + +/* -------------------------------------- + * I implementation of SUNAdaptController + * -------------------------------------- */ + +struct _SUNAdaptControllerContent_I { + sunrealtype k1; /* internal controller parameters */ + sunrealtype bias; /* error bias factor */ + int p; /* method/embedding order of accuracy */ + int adj; /* order of accuracy adjustment to use for controller */ + int pq; /* p is order of embedding (0), method (1), or minimum (-1) */ +}; + +typedef struct _SUNAdaptControllerContent_I *SUNAdaptControllerContent_I; + +/* ------------------ + * Exported Functions + * ------------------ */ + +SUNDIALS_EXPORT +SUNAdaptController SUNAdaptController_I(SUNContext sunctx); +SUNDIALS_EXPORT +int SUNAdaptController_SetParams_I(SUNAdaptController C, int pq, + sunrealtype k1); +SUNDIALS_EXPORT +SUNAdaptController_Type SUNAdaptController_GetType_I(SUNAdaptController C); +SUNDIALS_EXPORT +int SUNAdaptController_EstimateStep_I(SUNAdaptController C, sunrealtype h, + sunrealtype dsm, sunrealtype* hnew); +SUNDIALS_EXPORT +int SUNAdaptController_SetDefaults_I(SUNAdaptController C); +SUNDIALS_EXPORT +int SUNAdaptController_Write_I(SUNAdaptController C, FILE* fptr); +SUNDIALS_EXPORT +int SUNAdaptController_SetMethodOrder_I(SUNAdaptController C, int p, int q); +SUNDIALS_EXPORT +int SUNAdaptController_AdjustControllerOrder_I(SUNAdaptController C, int adj); +SUNDIALS_EXPORT +int SUNAdaptController_SetErrorBias_I(SUNAdaptController C, sunrealtype bias); +SUNDIALS_EXPORT +int SUNAdaptController_Space_I(SUNAdaptController C, long int *lenrw, + long int *leniw); + +#ifdef __cplusplus +} +#endif + +#endif /* _SUNADAPTCONTROLLER_I_H */ diff --git a/include/sunadaptcontroller/sunadaptcontroller_imexgus.h b/include/sunadaptcontroller/sunadaptcontroller_imexgus.h new file mode 100644 index 0000000000..1e4541f31c --- /dev/null +++ b/include/sunadaptcontroller/sunadaptcontroller_imexgus.h @@ -0,0 +1,84 @@ +/* ----------------------------------------------------------------- + * Programmer(s): Daniel R. Reynolds @ SMU + * ----------------------------------------------------------------- + * SUNDIALS Copyright Start + * Copyright (c) 2002-2023, Lawrence Livermore National Security + * and Southern Methodist University. + * All rights reserved. + * + * See the top-level LICENSE and NOTICE files for details. + * + * SPDX-License-Identifier: BSD-3-Clause + * SUNDIALS Copyright End + * ----------------------------------------------------------------- + * This is the header file for the SUNAdaptController_ImExGus module. + * -----------------------------------------------------------------*/ + +#ifndef _SUNADAPTCONTROLLER_IMEXGUS_H +#define _SUNADAPTCONTROLLER_IMEXGUS_H + +#include +#include + +#ifdef __cplusplus /* wrapper to enable C++ usage */ +extern "C" { +#endif + +/* ---------------------------------------------------- + * ImEx Gustafsson implementation of SUNAdaptController + * ---------------------------------------------------- */ + +struct _SUNAdaptControllerContent_ImExGus { + sunrealtype k1i; /* internal controller parameters */ + sunrealtype k2i; + sunrealtype k1e; + sunrealtype k2e; + sunrealtype bias; /* error bias factor */ + sunrealtype ep; /* error from previous step */ + sunrealtype hp; /* previous step size */ + int p; /* method/embedding order of accuracy */ + int adj; /* order of accuracy adjustment to use for controller */ + int pq; /* p is order of embedding (0), method (1), or minimum (-1) */ + sunbooleantype firststep; /* flag indicating first step */ +}; + +typedef struct _SUNAdaptControllerContent_ImExGus *SUNAdaptControllerContent_ImExGus; + +/* ------------------ + * Exported Functions + * ------------------ */ + +SUNDIALS_EXPORT +SUNAdaptController SUNAdaptController_ImExGus(SUNContext sunctx); +SUNDIALS_EXPORT +int SUNAdaptController_SetParams_ImExGus(SUNAdaptController C, int pq, + sunrealtype k1e, sunrealtype k2e, + sunrealtype k1i, sunrealtype k2i); +SUNDIALS_EXPORT +SUNAdaptController_Type SUNAdaptController_GetType_ImExGus(SUNAdaptController C); +SUNDIALS_EXPORT +int SUNAdaptController_EstimateStep_ImExGus(SUNAdaptController C, sunrealtype h, + sunrealtype dsm, sunrealtype* hnew); +SUNDIALS_EXPORT +int SUNAdaptController_Reset_ImExGus(SUNAdaptController C); +SUNDIALS_EXPORT +int SUNAdaptController_SetDefaults_ImExGus(SUNAdaptController C); +SUNDIALS_EXPORT +int SUNAdaptController_Write_ImExGus(SUNAdaptController C, FILE* fptr); +SUNDIALS_EXPORT +int SUNAdaptController_SetMethodOrder_ImExGus(SUNAdaptController C, int p, int q); +SUNDIALS_EXPORT +int SUNAdaptController_AdjustControllerOrder_ImExGus(SUNAdaptController C, int adj); +SUNDIALS_EXPORT +int SUNAdaptController_SetErrorBias_ImExGus(SUNAdaptController C, sunrealtype bias); +SUNDIALS_EXPORT +int SUNAdaptController_Update_ImExGus(SUNAdaptController C, sunrealtype h, sunrealtype dsm); +SUNDIALS_EXPORT +int SUNAdaptController_Space_ImExGus(SUNAdaptController C, long int *lenrw, + long int *leniw); + +#ifdef __cplusplus +} +#endif + +#endif /* _SUNADAPTCONTROLLER_IMPGUS_H */ diff --git a/include/sunadaptcontroller/sunadaptcontroller_impgus.h b/include/sunadaptcontroller/sunadaptcontroller_impgus.h new file mode 100644 index 0000000000..70397f90e5 --- /dev/null +++ b/include/sunadaptcontroller/sunadaptcontroller_impgus.h @@ -0,0 +1,81 @@ +/* ----------------------------------------------------------------- + * Programmer(s): Daniel R. Reynolds @ SMU + * ----------------------------------------------------------------- + * SUNDIALS Copyright Start + * Copyright (c) 2002-2023, Lawrence Livermore National Security + * and Southern Methodist University. + * All rights reserved. + * + * See the top-level LICENSE and NOTICE files for details. + * + * SPDX-License-Identifier: BSD-3-Clause + * SUNDIALS Copyright End + * ----------------------------------------------------------------- + * This is the header file for the SUNAdaptController_ImpGus module. + * -----------------------------------------------------------------*/ + +#ifndef _SUNADAPTCONTROLLER_IMPGUS_H +#define _SUNADAPTCONTROLLER_IMPGUS_H + +#include +#include + +#ifdef __cplusplus /* wrapper to enable C++ usage */ +extern "C" { +#endif + +/* -------------------------------------------------------- + * Implicit Gustafsson implementation of SUNAdaptController + * -------------------------------------------------------- */ + +struct _SUNAdaptControllerContent_ImpGus { + sunrealtype k1; /* internal controller parameters */ + sunrealtype k2; + sunrealtype bias; /* error bias factor */ + sunrealtype ep; /* error from previous step */ + sunrealtype hp; /* previous step size */ + int p; /* method/embedding order of accuracy */ + int adj; /* order of accuracy adjustment to use for controller */ + int pq; /* p is order of embedding (0), method (1), or minimum (-1) */ + sunbooleantype firststep; /* flag indicating first step */ +}; + +typedef struct _SUNAdaptControllerContent_ImpGus *SUNAdaptControllerContent_ImpGus; + +/* ------------------ + * Exported Functions + * ------------------ */ + +SUNDIALS_EXPORT +SUNAdaptController SUNAdaptController_ImpGus(SUNContext sunctx); +SUNDIALS_EXPORT +int SUNAdaptController_SetParams_ImpGus(SUNAdaptController C, int pq, + sunrealtype k1, sunrealtype k2); +SUNDIALS_EXPORT +SUNAdaptController_Type SUNAdaptController_GetType_ImpGus(SUNAdaptController C); +SUNDIALS_EXPORT +int SUNAdaptController_EstimateStep_ImpGus(SUNAdaptController C, sunrealtype h, + sunrealtype dsm, sunrealtype* hnew); +SUNDIALS_EXPORT +int SUNAdaptController_Reset_ImpGus(SUNAdaptController C); +SUNDIALS_EXPORT +int SUNAdaptController_SetDefaults_ImpGus(SUNAdaptController C); +SUNDIALS_EXPORT +int SUNAdaptController_Write_ImpGus(SUNAdaptController C, FILE* fptr); +SUNDIALS_EXPORT +int SUNAdaptController_SetMethodOrder_ImpGus(SUNAdaptController C, int p, int q); +SUNDIALS_EXPORT +int SUNAdaptController_AdjustControllerOrder_ImpGus(SUNAdaptController C, int adj); +SUNDIALS_EXPORT +int SUNAdaptController_SetErrorBias_ImpGus(SUNAdaptController C, sunrealtype bias); +SUNDIALS_EXPORT +int SUNAdaptController_Update_ImpGus(SUNAdaptController C, sunrealtype h, sunrealtype dsm); +SUNDIALS_EXPORT +int SUNAdaptController_Space_ImpGus(SUNAdaptController C, long int *lenrw, + long int *leniw); + +#ifdef __cplusplus +} +#endif + +#endif /* _SUNADAPTCONTROLLER_IMPGUS_H */ diff --git a/include/sunadaptcontroller/sunadaptcontroller_pi.h b/include/sunadaptcontroller/sunadaptcontroller_pi.h new file mode 100644 index 0000000000..cdead7fe8c --- /dev/null +++ b/include/sunadaptcontroller/sunadaptcontroller_pi.h @@ -0,0 +1,79 @@ +/* ----------------------------------------------------------------- + * Programmer(s): Daniel R. Reynolds @ SMU + * ----------------------------------------------------------------- + * SUNDIALS Copyright Start + * Copyright (c) 2002-2023, Lawrence Livermore National Security + * and Southern Methodist University. + * All rights reserved. + * + * See the top-level LICENSE and NOTICE files for details. + * + * SPDX-License-Identifier: BSD-3-Clause + * SUNDIALS Copyright End + * ----------------------------------------------------------------- + * This is the header file for the SUNAdaptController_PI module. + * -----------------------------------------------------------------*/ + +#ifndef _SUNADAPTCONTROLLER_PI_H +#define _SUNADAPTCONTROLLER_PI_H + +#include +#include + +#ifdef __cplusplus /* wrapper to enable C++ usage */ +extern "C" { +#endif + +/* --------------------------------------- + * PI implementation of SUNAdaptController + * --------------------------------------- */ + +struct _SUNAdaptControllerContent_PI { + sunrealtype k1; /* internal controller parameters */ + sunrealtype k2; + sunrealtype bias; /* error bias factor */ + sunrealtype ep; /* error from previous step */ + int p; /* method/embedding order of accuracy */ + int adj; /* order of accuracy adjustment to use for controller */ + int pq; /* p is order of embedding (0), method (1), or minimum (-1) */ +}; + +typedef struct _SUNAdaptControllerContent_PI *SUNAdaptControllerContent_PI; + +/* ------------------ + * Exported Functions + * ------------------ */ + +SUNDIALS_EXPORT +SUNAdaptController SUNAdaptController_PI(SUNContext sunctx); +SUNDIALS_EXPORT +int SUNAdaptController_SetParams_PI(SUNAdaptController C, int pq, + sunrealtype k1, sunrealtype k2); +SUNDIALS_EXPORT +SUNAdaptController_Type SUNAdaptController_GetType_PI(SUNAdaptController C); +SUNDIALS_EXPORT +int SUNAdaptController_EstimateStep_PI(SUNAdaptController C, sunrealtype h, + sunrealtype dsm, sunrealtype* hnew); +SUNDIALS_EXPORT +int SUNAdaptController_Reset_PI(SUNAdaptController C); +SUNDIALS_EXPORT +int SUNAdaptController_SetDefaults_PI(SUNAdaptController C); +SUNDIALS_EXPORT +int SUNAdaptController_Write_PI(SUNAdaptController C, FILE* fptr); +SUNDIALS_EXPORT +int SUNAdaptController_SetMethodOrder_PI(SUNAdaptController C, int p, int q); +SUNDIALS_EXPORT +int SUNAdaptController_AdjustControllerOrder_PI(SUNAdaptController C, int adj); +SUNDIALS_EXPORT +int SUNAdaptController_SetErrorBias_PI(SUNAdaptController C, sunrealtype bias); +SUNDIALS_EXPORT +int SUNAdaptController_Update_PI(SUNAdaptController C, sunrealtype h, sunrealtype dsm); +SUNDIALS_EXPORT +int SUNAdaptController_Space_PI(SUNAdaptController C, long int *lenrw, + long int *leniw); + +#ifdef __cplusplus +} +#endif + +#endif /* _SUNADAPTCONTROLLER_PI_H */ diff --git a/include/sunadaptcontroller/sunadaptcontroller_pid.h b/include/sunadaptcontroller/sunadaptcontroller_pid.h new file mode 100644 index 0000000000..5f24a5df81 --- /dev/null +++ b/include/sunadaptcontroller/sunadaptcontroller_pid.h @@ -0,0 +1,81 @@ +/* ----------------------------------------------------------------- + * Programmer(s): Daniel R. Reynolds @ SMU + * ----------------------------------------------------------------- + * SUNDIALS Copyright Start + * Copyright (c) 2002-2023, Lawrence Livermore National Security + * and Southern Methodist University. + * All rights reserved. + * + * See the top-level LICENSE and NOTICE files for details. + * + * SPDX-License-Identifier: BSD-3-Clause + * SUNDIALS Copyright End + * ----------------------------------------------------------------- + * This is the header file for the SUNAdaptController_PID module. + * -----------------------------------------------------------------*/ + +#ifndef _SUNADAPTCONTROLLER_PID_H +#define _SUNADAPTCONTROLLER_PID_H + +#include +#include + +#ifdef __cplusplus /* wrapper to enable C++ usage */ +extern "C" { +#endif + +/* ---------------------------------------- + * PID implementation of SUNAdaptController + * ---------------------------------------- */ + +struct _SUNAdaptControllerContent_PID { + sunrealtype k1; /* internal controller parameters */ + sunrealtype k2; + sunrealtype k3; + sunrealtype bias; /* error bias factor */ + sunrealtype ep; /* error from previous step */ + sunrealtype epp; /* error from 2 steps ago */ + int p; /* method/embedding order of accuracy */ + int adj; /* order of accuracy adjustment to use for controller */ + int pq; /* p is order of embedding (0), method (1), or minimum (-1) */ +}; + +typedef struct _SUNAdaptControllerContent_PID *SUNAdaptControllerContent_PID; + +/* ------------------ + * Exported Functions + * ------------------ */ + +SUNDIALS_EXPORT +SUNAdaptController SUNAdaptController_PID(SUNContext sunctx); +SUNDIALS_EXPORT +int SUNAdaptController_SetParams_PID(SUNAdaptController C, int pq, + sunrealtype k1, sunrealtype k2, sunrealtype k3); +SUNDIALS_EXPORT +SUNAdaptController_Type SUNAdaptController_GetType_PID(SUNAdaptController C); +SUNDIALS_EXPORT +int SUNAdaptController_EstimateStep_PID(SUNAdaptController C, sunrealtype h, + sunrealtype dsm, sunrealtype* hnew); +SUNDIALS_EXPORT +int SUNAdaptController_Reset_PID(SUNAdaptController C); +SUNDIALS_EXPORT +int SUNAdaptController_SetDefaults_PID(SUNAdaptController C); +SUNDIALS_EXPORT +int SUNAdaptController_Write_PID(SUNAdaptController C, FILE* fptr); +SUNDIALS_EXPORT +int SUNAdaptController_SetMethodOrder_PID(SUNAdaptController C, int p, int q); +SUNDIALS_EXPORT +int SUNAdaptController_AdjustControllerOrder_PID(SUNAdaptController C, int adj); +SUNDIALS_EXPORT +int SUNAdaptController_SetErrorBias_PID(SUNAdaptController C, sunrealtype bias); +SUNDIALS_EXPORT +int SUNAdaptController_Update_PID(SUNAdaptController C, sunrealtype h, sunrealtype dsm); +SUNDIALS_EXPORT +int SUNAdaptController_Space_PID(SUNAdaptController C, long int *lenrw, + long int *leniw); + +#ifdef __cplusplus +} +#endif + +#endif /* _SUNADAPTCONTROLLER_PID_H */ diff --git a/include/sundials/sundials_adaptcontroller.h b/include/sundials/sundials_adaptcontroller.h new file mode 100644 index 0000000000..95c4805dc1 --- /dev/null +++ b/include/sundials/sundials_adaptcontroller.h @@ -0,0 +1,245 @@ +/* ----------------------------------------------------------------- + * Programmer(s): Daniel R. Reynolds @ SMU + * ----------------------------------------------------------------- + * SUNDIALS Copyright Start + * Copyright (c) 2002-2023, 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 + * ----------------------------------------------------------------- + * SUNDIALS accuracy-based adaptivity controller class. These + * objects estimate step sizes for time integration methods such + * that the next step solution should satisfy a desired temporal + * accuracy. + * ----------------------------------------------------------------*/ + +#ifndef _SUNDIALS_ADAPTCONTROLLER_H +#define _SUNDIALS_ADAPTCONTROLLER_H + +#include +#include +#include +#include "sundials/sundials_types.h" + +#ifdef __cplusplus /* wrapper to enable C++ usage */ +extern "C" { +#endif + +/* ----------------------------------------------------------------- + * SUNAdaptController types (currently, only "H" is implemented; + * others are planned): + * NONE - empty controller (does nothing) + * H - controls a single-rate step size + * HQ - controls a single-rate step size and method order + * MRI_H - controls two multirate step sizes + * MRI_TOL - controls slow and fast relative tolerances + * ----------------------------------------------------------------- */ + +typedef enum +{ + SUN_ADAPTCONTROLLER_NONE, + SUN_ADAPTCONTROLLER_H, + SUN_ADAPTCONTROLLER_HQ, + SUN_ADAPTCONTROLLER_MRI_H, + SUN_ADAPTCONTROLLER_MRI_TOL +} SUNAdaptController_Type; + +/* ----------------------------------------------------------------- + * Generic definition of SUNAdaptController + * ----------------------------------------------------------------- */ + +/* Forward reference for pointer to SUNAdaptController_Ops object */ +typedef _SUNDIALS_STRUCT_ _generic_SUNAdaptController_Ops* SUNAdaptController_Ops; + +/* Forward reference for pointer to SUNAdaptController object */ +typedef _SUNDIALS_STRUCT_ _generic_SUNAdaptController* SUNAdaptController; + +/* Structure containing function pointers to controller operations */ +struct _generic_SUNAdaptController_Ops +{ + /* REQUIRED of all controller implementations. */ + SUNAdaptController_Type (*gettype)(SUNAdaptController C); + + /* REQUIRED for controllers of SUN_ADAPTCONTROLLER_H type. */ + int (*estimatestep)(SUNAdaptController C, sunrealtype h, + sunrealtype dsm, sunrealtype* hnew); + + /* REQUIRED for controllers of SUN_ADAPTCONTROLLER_HQ type. */ + int (*estimatestepandorder)(SUNAdaptController C, sunrealtype h, int q, + sunrealtype dsm, sunrealtype* hnew, int *qnew); + + /* REQUIRED for controllers of SUN_ADAPTCONTROLLER_MRI_H type. */ + int (*estimatemristeps)(SUNAdaptController C, sunrealtype H, sunrealtype h, + sunrealtype DSM, sunrealtype dsm, + sunrealtype* Hnew, sunrealtype *hnew); + + /* REQUIRED for controllers of SUN_ADAPTCONTROLLER_MRI_TOL type. */ + int (*estimatesteptol)(SUNAdaptController C, sunrealtype H, sunrealtype tolfac, + sunrealtype DSM, sunrealtype dsm, sunrealtype *Hnew, + sunrealtype* tolfacnew); + + /* OPTIONAL for all SUNAdaptController implementations. */ + int (*destroy)(SUNAdaptController C); + int (*reset)(SUNAdaptController C); + int (*setdefaults)(SUNAdaptController C); + int (*write)(SUNAdaptController C, FILE* fptr); + int (*setmethodorder)(SUNAdaptController C, int p, int q); + int (*adjustcontrollerorder)(SUNAdaptController C, int adj); + int (*seterrorbias)(SUNAdaptController C, sunrealtype bias); + int (*update)(SUNAdaptController C, sunrealtype h, sunrealtype dsm); + int (*updatemrih)(SUNAdaptController C, sunrealtype H, sunrealtype h, + sunrealtype DSM, sunrealtype dsm); + int (*updatemritol)(SUNAdaptController C, sunrealtype H, sunrealtype tolfac, + sunrealtype DSM, sunrealtype dsm); + int (*space)(SUNAdaptController C, long int *lenrw, long int *leniw); +}; + +/* A SUNAdaptController is a structure with an implementation-dependent + 'content' field, and a pointer to a structure of + operations corresponding to that implementation. */ +struct _generic_SUNAdaptController +{ + void* content; + SUNAdaptController_Ops ops; + SUNContext sunctx; +}; + +/* ----------------------------------------------------------------- + * Functions exported by SUNAdaptController module + * ----------------------------------------------------------------- */ + +/* Function to create an empty SUNAdaptController data structure. */ +SUNDIALS_EXPORT +SUNAdaptController SUNAdaptController_NewEmpty(SUNContext sunctx); + +/* Function to report the type of a SUNAdaptController object. */ +SUNDIALS_EXPORT +SUNAdaptController_Type SUNAdaptController_GetType(SUNAdaptController C); + +/* Function to deallocate a SUNAdaptController object. + + Any return value other than SUNADAPTCONTROLLER_SUCCESS will be treated as + an unrecoverable failure. */ +SUNDIALS_EXPORT +int SUNAdaptController_Destroy(SUNAdaptController C); + +/* Main step size controller function. This is called following + a time step with size 'h' and local error factor 'dsm', and the + controller should estimate 'hnew' so that the ensuing step + will have 'dsm' value JUST BELOW 1. + + Any return value other than SUNADAPTCONTROLLER_SUCCESS will be treated as + an unrecoverable failure. */ +SUNDIALS_EXPORT +int SUNAdaptController_EstimateStep(SUNAdaptController C, sunrealtype h, + sunrealtype dsm, sunrealtype* hnew); + +/* Combined step size + order controller function. This is called + following a time step with size 'h' and order 'q' that has local + error factor 'dsm'. The controller should estimate 'hnew' and + 'qnew' so that the ensuing step will have 'dsm' value JUST BELOW 1 + with minimal computational effort. */ +SUNDIALS_EXPORT +int SUNAdaptController_EstimateStepAndOrder(SUNAdaptController C, sunrealtype h, + int q, sunrealtype dsm, + sunrealtype* hnew, int *qnew); + +/* Combined slow/fast multirate step size controller function. This + is called following a slow multirate time step with sizes 'H' and + 'h' (slow and fast, resp.), and error factors 'DSM' and 'dsm' + (slow and fast, resp.). The controller should estimate slow and + fast steps 'Hnew' and 'hnew', resp., so that the ensuing step will + have 'DSM' and 'dsm' values JUST BELOW 1 with minimal computational + effort. */ +SUNDIALS_EXPORT +int SUNAdaptController_EstimateMRISteps(SUNAdaptController C, sunrealtype H, + sunrealtype h, sunrealtype DSM, sunrealtype dsm, + sunrealtype* Hnew, sunrealtype *hnew); + +/* Combined slow step/fast tolerance multirate controller function. + This is called following a slow multirate time step with size 'H' + and fast/slow relative tolerance ratio 'tolfac', and error factors + 'DSM' and 'dsm' (slow and fast, resp.). The controller should + estimate slow stepsize 'Hnew' and updated relative tolerance ratio + 'tolfacnew', so that the ensuing step will have 'DSM' and 'dsm' + values JUST BELOW 1 with minimal computational effort. */ +SUNDIALS_EXPORT +int SUNAdaptController_EstimateStepTol(SUNAdaptController C, sunrealtype H, + sunrealtype tolfac, sunrealtype DSM, + sunrealtype dsm, sunrealtype *Hnew, + sunrealtype* tolfacnew); + +/* Function to reset the controller to its initial state, e.g., if + it stores a small number of previous dsm or step size values. */ +SUNDIALS_EXPORT +int SUNAdaptController_Reset(SUNAdaptController C); + +/* Function to set the controller parameters to their default values. */ +SUNDIALS_EXPORT +int SUNAdaptController_SetDefaults(SUNAdaptController C); + +/* Function to write all controller parameters to the indicated file + pointer. */ +SUNDIALS_EXPORT +int SUNAdaptController_Write(SUNAdaptController C, FILE* fptr); + +/* Function to set the asymptotic order of accuracy for the method and + its embedding. */ +SUNDIALS_EXPORT +int SUNAdaptController_SetMethodOrder(SUNAdaptController C, int p, int q); + +/* Function to adjust the order of accuracy used within the controller. */ +SUNDIALS_EXPORT +int SUNAdaptController_AdjustControllerOrder(SUNAdaptController C, int adj); + +/* Function to set an error bias factor to use for scaling the local error + 'dsm' factors above. */ +SUNDIALS_EXPORT +int SUNAdaptController_SetErrorBias(SUNAdaptController C, sunrealtype bias); + +/* Function to notify the controller of a successful time step with size + h and local error factor dsm, indicating that the step size or local + error factor can be saved for subsequent controller functions. */ +SUNDIALS_EXPORT +int SUNAdaptController_Update(SUNAdaptController C, sunrealtype h, sunrealtype dsm); + +/* Function to notify the controller of a successful multirate time step + with sizes H and h, and local error factors DSM and dsm, indicating that + the step sizes or local error factors can be saved for subsequent + controller functions. */ +SUNDIALS_EXPORT +int SUNAdaptController_UpdateMRIH(SUNAdaptController C, sunrealtype H, sunrealtype h, + sunrealtype DSM, sunrealtype dsm); + +/* Function to notify the controller of a successful multirate time step + with size H and fast tolerance factor tolfac, and local error factors + DSM and dsm, indicating that the step size, tolerance factor, or local + error factors can be saved for subsequent controller functions. */ +SUNDIALS_EXPORT +int SUNAdaptController_UpdateMRITol(SUNAdaptController C, sunrealtype H, sunrealtype tolfac, + sunrealtype DSM, sunrealtype dsm); + +/* Function to return the memory requirements of the controller object. */ +SUNDIALS_EXPORT +int SUNAdaptController_Space(SUNAdaptController C, long int *lenrw, long int *leniw); + + +/* ----------------------------------------------------------------- + * SUNAdaptController error codes + * ----------------------------------------------------------------- */ + +#define SUNADAPTCONTROLLER_SUCCESS 0 /* function successfull */ +#define SUNADAPTCONTROLLER_ILL_INPUT -1001 /* illegal function input */ +#define SUNADAPTCONTROLLER_MEM_FAIL -1002 /* failed memory access/alloc */ +#define SUNADAPTCONTROLLER_USER_FCN_FAIL -1003 /* user-supplied fcn failure */ +#define SUNADAPTCONTROLLER_OPERATION_FAIL -1004 /* catchall failure code */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SUNDIALS_ADAPTCONTROLLER_H */ diff --git a/scripts/arkode b/scripts/arkode index 6df8c34b75..c5f2bc2176 100755 --- a/scripts/arkode +++ b/scripts/arkode @@ -93,6 +93,8 @@ $tar $tarfile $distrobase/src/arkode/arkode_relaxation.c $tar $tarfile $distrobase/src/arkode/arkode_relaxation_impl.h $tar $tarfile $distrobase/src/arkode/arkode_root.c $tar $tarfile $distrobase/src/arkode/arkode_root_impl.h +$tar $tarfile $distrobase/src/arkode/arkode_user_controller.h +$tar $tarfile $distrobase/src/arkode/arkode_user_controller.c $tar $tarfile $distrobase/src/arkode/arkode_types_impl.h $tar $tarfile $distrobase/src/arkode/xbraid/CMakeLists.txt diff --git a/scripts/shared b/scripts/shared index 9e42969552..b5702ea443 100755 --- a/scripts/shared +++ b/scripts/shared @@ -118,6 +118,7 @@ $tar $tarfile $distrobase/cmake/tpl/SundialsXBRAID.cmake echo " --- Add include files to $tarfile" +$tar $tarfile $distrobase/include/sundials/sundials_adaptcontroller.h $tar $tarfile $distrobase/include/sundials/sundials_band.h $tar $tarfile $distrobase/include/sundials/sundials_base.hpp $tar $tarfile $distrobase/include/sundials/sundials_config.in @@ -176,6 +177,13 @@ $tar $tarfile $distrobase/include/nvector/nvector_trilinos.h $tar $tarfile $distrobase/include/nvector/trilinos/SundialsTpetraVectorInterface.hpp $tar $tarfile $distrobase/include/nvector/trilinos/SundialsTpetraVectorKernels.hpp +$tar $tarfile $distrobase/include/sunadaptcontroller/sunadaptcontroller_expgus.h +$tar $tarfile $distrobase/include/sunadaptcontroller/sunadaptcontroller_i.h +$tar $tarfile $distrobase/include/sunadaptcontroller/sunadaptcontroller_imexgus.h +$tar $tarfile $distrobase/include/sunadaptcontroller/sunadaptcontroller_impgus.h +$tar $tarfile $distrobase/include/sunadaptcontroller/sunadaptcontroller_pi.h +$tar $tarfile $distrobase/include/sunadaptcontroller/sunadaptcontroller_pid.h + $tar $tarfile $distrobase/include/sunmatrix/sunmatrix_band.h $tar $tarfile $distrobase/include/sunmatrix/sunmatrix_cusparse.h $tar $tarfile $distrobase/include/sunmatrix/sunmatrix_dense.h @@ -224,6 +232,8 @@ echo " --- Add shared source files to $tarfile" $tar $tarfile $distrobase/src/CMakeLists.txt $tar $tarfile $distrobase/src/sundials/CMakeLists.txt $tar $tarfile $distrobase/src/sundials/fmod/CMakeLists.txt +$tar $tarfile $distrobase/src/sundials/fmod/fsundials_adaptcontroller_mod.c +$tar $tarfile $distrobase/src/sundials/fmod/fsundials_adaptcontroller_mod.f90 $tar $tarfile $distrobase/src/sundials/fmod/fsundials_context_mod.c $tar $tarfile $distrobase/src/sundials/fmod/fsundials_context_mod.f90 $tar $tarfile $distrobase/src/sundials/fmod/fsundials_futils_mod.c @@ -242,6 +252,7 @@ $tar $tarfile $distrobase/src/sundials/fmod/fsundials_profiler_mod.c $tar $tarfile $distrobase/src/sundials/fmod/fsundials_profiler_mod.f90 $tar $tarfile $distrobase/src/sundials/fmod/fsundials_types_mod.c $tar $tarfile $distrobase/src/sundials/fmod/fsundials_types_mod.f90 +$tar $tarfile $distrobase/src/sundials/sundials_adaptcontroller.c $tar $tarfile $distrobase/src/sundials/sundials_band.c $tar $tarfile $distrobase/src/sundials/sundials_context_impl.h $tar $tarfile $distrobase/src/sundials/sundials_context.c @@ -371,6 +382,52 @@ $tar $tarfile $distrobase/src/nvector/mpiplusx/fmod/CMakeLists.txt $tar $tarfile $distrobase/src/nvector/mpiplusx/fmod/fnvector_mpiplusx_mod.c $tar $tarfile $distrobase/src/nvector/mpiplusx/fmod/fnvector_mpiplusx_mod.f90 +echo " --- Add sunadaptcontroller modules to $tarfile" + +$tar $tarfile $distrobase/src/sunadaptcontroller/CMakeLists.txt + +echo " --- Add sunadaptcontroller/exp_gus module to $tarfile" + +$tar $tarfile $distrobase/src/sunadaptcontroller/expgus/CMakeLists.txt +$tar $tarfile $distrobase/src/sunadaptcontroller/expgus/sunadaptcontroller_expgus.c +$tar $tarfile $distrobase/src/sunadaptcontroller/expgus/fmod/fsunadaptcontroller_expgus_mod.c +$tar $tarfile $distrobase/src/sunadaptcontroller/expgus/fmod/fsunadaptcontroller_expgus_mod.f90 + +echo " --- Add sunadaptcontroller/i_control module to $tarfile" + +$tar $tarfile $distrobase/src/sunadaptcontroller/i/CMakeLists.txt +$tar $tarfile $distrobase/src/sunadaptcontroller/i/sunadaptcontroller_i.c +$tar $tarfile $distrobase/src/sunadaptcontroller/i/fmod/fsunadaptcontroller_i_mod.c +$tar $tarfile $distrobase/src/sunadaptcontroller/i/fmod/fsunadaptcontroller_i_mod.f90 + +echo " --- Add sunadaptcontroller/imex_gus module to $tarfile" + +$tar $tarfile $distrobase/src/sunadaptcontroller/imexgus/CMakeLists.txt +$tar $tarfile $distrobase/src/sunadaptcontroller/imexgus/sunadaptcontroller_imexgus.c +$tar $tarfile $distrobase/src/sunadaptcontroller/imexgus/fmod/fsunadaptcontroller_imexgus_mod.c +$tar $tarfile $distrobase/src/sunadaptcontroller/imexgus/fmod/fsunadaptcontroller_imexgus_mod.f90 + +echo " --- Add sunadaptcontroller/imp_gus module to $tarfile" + +$tar $tarfile $distrobase/src/sunadaptcontroller/impgus/CMakeLists.txt +$tar $tarfile $distrobase/src/sunadaptcontroller/impgus/sunadaptcontroller_impgus.c +$tar $tarfile $distrobase/src/sunadaptcontroller/impgus/fmod/fsunadaptcontroller_impgus_mod.c +$tar $tarfile $distrobase/src/sunadaptcontroller/impgus/fmod/fsunadaptcontroller_impgus_mod.f90 + +echo " --- Add sunadaptcontroller/pi_control module to $tarfile" + +$tar $tarfile $distrobase/src/sunadaptcontroller/pi/CMakeLists.txt +$tar $tarfile $distrobase/src/sunadaptcontroller/pi/sunadaptcontroller_pi.c +$tar $tarfile $distrobase/src/sunadaptcontroller/pi/fmod/fsunadaptcontroller_pi_mod.c +$tar $tarfile $distrobase/src/sunadaptcontroller/pi/fmod/fsunadaptcontroller_pi_mod.f90 + +echo " --- Add sunadaptcontroller/pid_control module to $tarfile" + +$tar $tarfile $distrobase/src/sunadaptcontroller/pid/CMakeLists.txt +$tar $tarfile $distrobase/src/sunadaptcontroller/pid/sunadaptcontroller_pid.c +$tar $tarfile $distrobase/src/sunadaptcontroller/pid/fmod/fsunadaptcontroller_pid_mod.c +$tar $tarfile $distrobase/src/sunadaptcontroller/pid/fmod/fsunadaptcontroller_pid_mod.f90 + echo " --- Add sunmatrix modules to $tarfile" $tar $tarfile $distrobase/src/sunmatrix/CMakeLists.txt diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 5cc51eb748..a24be3c65a 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -22,6 +22,7 @@ add_subdirectory(sunmatrix) add_subdirectory(sunlinsol) add_subdirectory(sunnonlinsol) add_subdirectory(sunmemory) +add_subdirectory(sunadaptcontroller) # ARKODE library if(BUILD_ARKODE) diff --git a/src/arkode/CMakeLists.txt b/src/arkode/CMakeLists.txt index cf0254b3e2..c2eb0582e6 100644 --- a/src/arkode/CMakeLists.txt +++ b/src/arkode/CMakeLists.txt @@ -41,6 +41,7 @@ set(arkode_SOURCES arkode_sprkstep_io.c arkode_sprkstep.c arkode_sprk.c + arkode_user_controller.c arkode.c ) @@ -75,6 +76,12 @@ sundials_add_library(sundials_arkode sundials_generic_obj sundials_sunmemsys_obj sundials_nvecserial_obj + sundials_sunadaptcontrollerexpgus_obj + sundials_sunadaptcontrolleri_obj + sundials_sunadaptcontrollerpid_obj + sundials_sunadaptcontrollerimpgus_obj + sundials_sunadaptcontrollerpi_obj + sundials_sunadaptcontrollerimexgus_obj sundials_sunmatrixband_obj sundials_sunmatrixdense_obj sundials_sunmatrixsparse_obj diff --git a/src/arkode/arkode.c b/src/arkode/arkode.c index 601abca7ae..63b8df7f5d 100644 --- a/src/arkode/arkode.c +++ b/src/arkode/arkode.c @@ -31,6 +31,7 @@ #include #include #include +#include /*=============================================================== @@ -49,6 +50,7 @@ ARKodeMem arkCreate(SUNContext sunctx) { int iret; + long int lenrw, leniw; ARKodeMem ark_mem; if (!sunctx) { @@ -133,6 +135,18 @@ ARKodeMem arkCreate(SUNContext sunctx) 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, "ARKODE", "arkCreate", + "Allocation of step controller object failed"); + 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; @@ -1110,6 +1124,9 @@ void arkFree(void **arkode_mem) /* free the time step adaptivity module */ if (ark_mem->hadapt_mem != NULL) { + if (ark_mem->hadapt_mem->owncontroller) { + (void) SUNAdaptController_Destroy(ark_mem->hadapt_mem->hcontroller); + } free(ark_mem->hadapt_mem); ark_mem->hadapt_mem = NULL; } @@ -1247,6 +1264,7 @@ int arkInit(ARKodeMem ark_mem, realtype t0, N_Vector y0, int init_type) { booleantype stepperOK, nvectorOK, allocOK; + int retval; sunindextype lrw1, liw1; /* Check ark_mem */ @@ -1348,15 +1366,18 @@ int arkInit(ARKodeMem ark_mem, realtype t0, N_Vector y0, /* Tolerance scale factor */ ark_mem->tolsf = ONE; + /* Reset error controller object */ + retval = SUNAdaptController_Reset(ark_mem->hadapt_mem->hcontroller); + if (retval != SUNADAPTCONTROLLER_SUCCESS) { + arkProcessError(ark_mem, ARK_CONTROLLER_ERR, "ARKODE", "arkInit", + "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; - /* Error and step size history */ - ark_mem->hadapt_mem->ehist[0] = ONE; - ark_mem->hadapt_mem->ehist[1] = ONE; - ark_mem->hadapt_mem->hhist[0] = ZERO; - ark_mem->hadapt_mem->hhist[1] = ZERO; /* Indicate that evaluation of the full RHS is not required after each step, this flag is updated to SUNTRUE by the interpolation module initialization @@ -2408,10 +2429,10 @@ int arkCompleteStep(ARKodeMem ark_mem, realtype dsm) tstop by roundoff, and in that case, we reset tn (after incrementing by h) to tstop. */ - /* During long-time integration, roundoff can creep into tcur. + /* During long-time integration, roundoff can creep into tcur. Compensated summation fixes this but with increased cost, so it is optional. */ if (ark_mem->use_compensated_sums) { - sunCompensatedSum(ark_mem->tn, ark_mem->h, &ark_mem->tcur, &ark_mem->terr); + sunCompensatedSum(ark_mem->tn, ark_mem->h, &ark_mem->tcur, &ark_mem->terr); } else { ark_mem->tcur = ark_mem->tn + ark_mem->h; } @@ -2455,11 +2476,14 @@ int arkCompleteStep(ARKodeMem ark_mem, realtype dsm) /* update yn to current solution */ N_VScale(ONE, ark_mem->ycur, ark_mem->yn); - /* Update step size and error history arrays */ - ark_mem->hadapt_mem->ehist[1] = ark_mem->hadapt_mem->ehist[0]; - ark_mem->hadapt_mem->ehist[0] = dsm*ark_mem->hadapt_mem->bias; - ark_mem->hadapt_mem->hhist[1] = ark_mem->hadapt_mem->hhist[0]; - ark_mem->hadapt_mem->hhist[0] = ark_mem->h; + /* Notify time step controller object of successful step */ + retval = SUNAdaptController_Update(ark_mem->hadapt_mem->hcontroller, ark_mem->h, dsm); + if (retval != SUNADAPTCONTROLLER_SUCCESS) { + arkProcessError(ark_mem, ARK_CONTROLLER_ERR, "ARKODE", "arkCompleteStep", + "Failure updating controller object"); + return(ARK_CONTROLLER_ERR); + } + /* update scalar quantities */ ark_mem->nst++; diff --git a/src/arkode/arkode_adapt.c b/src/arkode/arkode_adapt.c index 617681e9f5..dae26c5196 100644 --- a/src/arkode/arkode_adapt.c +++ b/src/arkode/arkode_adapt.c @@ -42,10 +42,6 @@ ARKodeHAdaptMem arkAdaptInit() /* initialize values (default parameters are set in arkSetDefaults) */ memset(hadapt_mem, 0, sizeof(struct ARKodeHAdaptMemRec)); - hadapt_mem->ehist[0] = ONE; - hadapt_mem->ehist[1] = ONE; - hadapt_mem->hhist[0] = ZERO; - hadapt_mem->hhist[1] = ZERO; hadapt_mem->nst_acc = 0; hadapt_mem->nst_exp = 0; return(hadapt_mem); @@ -67,25 +63,11 @@ void arkPrintAdaptMem(ARKodeHAdaptMem hadapt_mem, FILE *outfile) fprintf(outfile, "ark_hadapt: etamin = %"RSYM"\n", hadapt_mem->etamin); fprintf(outfile, "ark_hadapt: small_nef = %i\n", hadapt_mem->small_nef); fprintf(outfile, "ark_hadapt: etacf = %"RSYM"\n", hadapt_mem->etacf); - fprintf(outfile, "ark_hadapt: imethod = %i\n", hadapt_mem->imethod); - fprintf(outfile, "ark_hadapt: ehist = %"RSYM" %"RSYM"\n", - hadapt_mem->ehist[0], - hadapt_mem->ehist[1]); - fprintf(outfile, "ark_hadapt: hhist = %"RSYM" %"RSYM"\n", - hadapt_mem->hhist[0], - hadapt_mem->hhist[1]); fprintf(outfile, "ark_hadapt: cfl = %"RSYM"\n", hadapt_mem->cfl); fprintf(outfile, "ark_hadapt: safety = %"RSYM"\n", hadapt_mem->safety); - fprintf(outfile, "ark_hadapt: bias = %"RSYM"\n", hadapt_mem->bias); fprintf(outfile, "ark_hadapt: growth = %"RSYM"\n", hadapt_mem->growth); fprintf(outfile, "ark_hadapt: lbound = %"RSYM"\n", hadapt_mem->lbound); fprintf(outfile, "ark_hadapt: ubound = %"RSYM"\n", hadapt_mem->ubound); - fprintf(outfile, "ark_hadapt: k1 = %"RSYM"\n", hadapt_mem->k1); - fprintf(outfile, "ark_hadapt: k2 = %"RSYM"\n", hadapt_mem->k2); - fprintf(outfile, "ark_hadapt: k3 = %"RSYM"\n", hadapt_mem->k3); - fprintf(outfile, "ark_hadapt: q = %i\n", hadapt_mem->q); - fprintf(outfile, "ark_hadapt: p = %i\n", hadapt_mem->p); - fprintf(outfile, "ark_hadapt: pq = %i\n", hadapt_mem->pq); fprintf(outfile, "ark_hadapt: nst_acc = %li\n", hadapt_mem->nst_acc); fprintf(outfile, "ark_hadapt: nst_exp = %li\n", hadapt_mem->nst_exp); if (hadapt_mem->expstab == arkExpStab) { @@ -95,6 +77,7 @@ void arkPrintAdaptMem(ARKodeHAdaptMem hadapt_mem, FILE *outfile) fprintf(outfile, " ark_hadapt: stability function data pointer = %p\n", hadapt_mem->estab_data); } + (void) SUNAdaptController_Write(hadapt_mem->hcontroller, outfile); } } @@ -110,8 +93,8 @@ int arkAdapt(void* arkode_mem, ARKodeHAdaptMem hadapt_mem, N_Vector ycur, realtype tcur, realtype hcur, realtype dsm, long int nst) { - int ier, k; - realtype ecur, h_acc, h_cfl, int_dir; + int retval; + realtype h_acc, h_cfl, int_dir; ARKodeMem ark_mem; if (arkode_mem == NULL) { arkProcessError(NULL, ARK_MEM_NULL, "ARKODE", @@ -120,80 +103,28 @@ int arkAdapt(void* arkode_mem, ARKodeHAdaptMem hadapt_mem, } ark_mem = (ARKodeMem) arkode_mem; - /* Current error with bias factor */ - ecur = hadapt_mem->bias * dsm; - - /* Set k as either p or q, based on pq flag */ - k = (hadapt_mem->pq) ? hadapt_mem->q : hadapt_mem->p; - - /* Call algorithm-specific error adaptivity method */ - switch (hadapt_mem->imethod) { - case(ARK_ADAPT_PID): /* PID controller */ - ier = arkAdaptPID(hadapt_mem, k, hcur, ecur, &h_acc); - break; - case(ARK_ADAPT_PI): /* PI controller */ - ier = arkAdaptPI(hadapt_mem, k, hcur, ecur, &h_acc); - break; - case(ARK_ADAPT_I): /* I controller */ - ier = arkAdaptI(hadapt_mem, k, hcur, ecur, &h_acc); - break; - case(ARK_ADAPT_EXP_GUS): /* explicit Gustafsson controller */ - ier = arkAdaptExpGus(hadapt_mem, k, nst, hcur, ecur, &h_acc); - break; - case(ARK_ADAPT_IMP_GUS): /* implicit Gustafsson controller */ - ier = arkAdaptImpGus(hadapt_mem, k, nst, hcur, ecur, &h_acc); - break; - case(ARK_ADAPT_IMEX_GUS): /* imex Gustafsson controller */ - ier = arkAdaptImExGus(hadapt_mem, k, nst, hcur, ecur, &h_acc); - break; - case(ARK_ADAPT_CUSTOM): /* user-supplied controller */ - ier = hadapt_mem->HAdapt(ycur, tcur, hcur, hadapt_mem->hhist[0], - hadapt_mem->hhist[1], ecur, - hadapt_mem->ehist[0], - hadapt_mem->ehist[1], - hadapt_mem->q, hadapt_mem->p, - &h_acc, hadapt_mem->HAdapt_data); - break; - default: - arkProcessError(ark_mem, ARK_ILL_INPUT, "ARKODE", "arkAdapt", - "Illegal imethod."); - return (ARK_ILL_INPUT); - } - if (ier != ARK_SUCCESS) { - arkProcessError(ark_mem, ARK_ILL_INPUT, "ARKODE", "arkAdapt", - "Error in accuracy-based adaptivity function."); - return (ARK_ILL_INPUT); + /* Request error-based step size from adaptivity controller */ + retval = SUNAdaptController_EstimateStep(hadapt_mem->hcontroller, + hcur, dsm, &h_acc); + if (retval != SUNADAPTCONTROLLER_SUCCESS) { + arkProcessError(ark_mem, ARK_CONTROLLER_ERR, "ARKODE", "arkAdapt", + "SUNAdaptController_EstimateStep failure."); + return (ARK_CONTROLLER_ERR); } /* determine direction of integration */ int_dir = hcur / SUNRabs(hcur); /* Call explicit stability function */ - ier = hadapt_mem->expstab(ycur, tcur, &h_cfl, hadapt_mem->estab_data); - if (ier != ARK_SUCCESS) { + retval = hadapt_mem->expstab(ycur, tcur, &h_cfl, hadapt_mem->estab_data); + if (retval != ARK_SUCCESS) { arkProcessError(ark_mem, ARK_ILL_INPUT, "ARKODE", "arkAdapt", "Error in explicit stability function."); return (ARK_ILL_INPUT); } if (h_cfl <= ZERO) h_cfl = RCONST(1.0e30) * SUNRabs(hcur); - /* Solver diagnostics reporting */ - if (ark_mem->report) - fprintf(ark_mem->diagfp, "ARKadapt adapt %"RSYM" %"RSYM" %"RSYM" %"RSYM" %"RSYM" %"RSYM" %"RSYM" %"RSYM" ", - ecur, hadapt_mem->ehist[0], hadapt_mem->ehist[1], - hcur, hadapt_mem->hhist[0], hadapt_mem->hhist[1], h_acc, h_cfl); - #if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_INFO - SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_INFO, - "ARKODE::arkAdapt", "error-history", - "ecur = %"RSYM", ehist[0] = %"RSYM", ehist[0] = %"RSYM, - ecur, hadapt_mem->ehist[0], hadapt_mem->ehist[1]); - - SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_INFO, - "ARKODE::arkAdapt", "step-history", - "hcur = %"RSYM", hhist[0] = %"RSYM", hhist[0] = %"RSYM, - hcur, hadapt_mem->hhist[0], hadapt_mem->hhist[1]); - SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_INFO, "ARKODE::arkAdapt", "new-step-before-bounds", "h_acc = %"RSYM", h_cfl = %"RSYM, h_acc, h_cfl); @@ -253,178 +184,9 @@ int arkAdapt(void* arkode_mem, ARKodeHAdaptMem hadapt_mem, "new-step-eta", "eta = %"RSYM, ark_mem->eta); #endif - return(ier); -} - - -/*--------------------------------------------------------------- - arkAdaptPID implements a PID time step control algorithm. - ---------------------------------------------------------------*/ -int arkAdaptPID(ARKodeHAdaptMem hadapt_mem, int k, realtype hcur, - realtype ecur, realtype *hnew) -{ - realtype k1, k2, k3, e1, e2, e3, h_acc; - - /* set usable time-step adaptivity parameters */ - k1 = -hadapt_mem->k1 / k; - k2 = hadapt_mem->k2 / k; - k3 = -hadapt_mem->k3 / k; - e1 = SUNMAX(ecur, TINY); - e2 = SUNMAX(hadapt_mem->ehist[0], TINY); - e3 = SUNMAX(hadapt_mem->ehist[1], TINY); - - /* compute estimated optimal time step size, set into output */ - h_acc = hcur * SUNRpowerR(e1,k1) * SUNRpowerR(e2,k2) * SUNRpowerR(e3,k3); - *hnew = h_acc; - - return(ARK_SUCCESS); -} - - -/*--------------------------------------------------------------- - arkAdaptPI implements a PI time step control algorithm. - ---------------------------------------------------------------*/ -int arkAdaptPI(ARKodeHAdaptMem hadapt_mem, int k, realtype hcur, - realtype ecur, realtype *hnew) -{ - realtype k1, k2, e1, e2, h_acc; - - /* set usable time-step adaptivity parameters */ - k1 = -hadapt_mem->k1 / k; - k2 = hadapt_mem->k2 / k; - e1 = SUNMAX(ecur, TINY); - e2 = SUNMAX(hadapt_mem->ehist[0], TINY); - - /* compute estimated optimal time step size, set into output */ - h_acc = hcur * SUNRpowerR(e1,k1) * SUNRpowerR(e2,k2); - *hnew = h_acc; - - return(ARK_SUCCESS); + return(retval); } - -/*--------------------------------------------------------------- - arkAdaptI implements an I time step control algorithm. - ---------------------------------------------------------------*/ -int arkAdaptI(ARKodeHAdaptMem hadapt_mem, int k, realtype hcur, - realtype ecur, realtype *hnew) -{ - realtype k1, e1, h_acc; - - /* set usable time-step adaptivity parameters */ - k1 = -hadapt_mem->k1 / k; - e1 = SUNMAX(ecur, TINY); - - /* compute estimated optimal time step size, set into output */ - h_acc = hcur * SUNRpowerR(e1,k1); - *hnew = h_acc; - - return(ARK_SUCCESS); -} - - -/*--------------------------------------------------------------- - arkAdaptExpGus implements the explicit Gustafsson time step - control algorithm. - ---------------------------------------------------------------*/ -int arkAdaptExpGus(ARKodeHAdaptMem hadapt_mem, int k, long int nst, - realtype hcur, realtype ecur, realtype *hnew) -{ - realtype k1, k2, e1, e2, h_acc; - - /* modified method for first step */ - if (nst < 2) { - - k1 = -ONE / k; - e1 = SUNMAX(ecur, TINY); - h_acc = hcur * SUNRpowerR(e1,k1); - - /* general estimate */ - } else { - - k1 = -hadapt_mem->k1 / k; - k2 = -hadapt_mem->k2 / k; - e1 = SUNMAX(ecur, TINY); - e2 = e1 / SUNMAX(hadapt_mem->ehist[0], TINY); - h_acc = hcur * SUNRpowerR(e1,k1) * SUNRpowerR(e2,k2); - - } - *hnew = h_acc; - - return(ARK_SUCCESS); -} - - -/*--------------------------------------------------------------- - arkAdaptImpGus implements the implicit Gustafsson time step - control algorithm. - ---------------------------------------------------------------*/ -int arkAdaptImpGus(ARKodeHAdaptMem hadapt_mem, int k, long int nst, - realtype hcur, realtype ecur, realtype *hnew) -{ - realtype k1, k2, e1, e2, hrat, h_acc; - - /* modified method for first step */ - if (nst < 2) { - - k1 = -ONE / k; - e1 = SUNMAX(ecur, TINY); - h_acc = hcur * SUNRpowerR(e1,k1); - - /* general estimate */ - } else { - - k1 = -hadapt_mem->k1 / k; - k2 = -hadapt_mem->k2 / k; - e1 = SUNMAX(ecur, TINY); - e2 = e1 / SUNMAX(hadapt_mem->ehist[0], TINY); - hrat = hcur / hadapt_mem->hhist[0]; - h_acc = hcur * hrat * SUNRpowerR(e1,k1) * SUNRpowerR(e2,k2); - - } - *hnew = h_acc; - - return(ARK_SUCCESS); -} - - -/*--------------------------------------------------------------- - arkAdaptImExGus implements a combination implicit/explicit - Gustafsson time step control algorithm. - ---------------------------------------------------------------*/ -int arkAdaptImExGus(ARKodeHAdaptMem hadapt_mem, int k, long int nst, - realtype hcur, realtype ecur, realtype *hnew) -{ - realtype k1, k2, k3, e1, e2, hrat, h_acc; - - /* modified method for first step */ - if (nst < 2) { - - k1 = -ONE / k; - e1 = SUNMAX(ecur, TINY); - h_acc = hcur * SUNRpowerR(e1,k1); - - /* general estimate */ - } else { - - k1 = -hadapt_mem->k1 / k; - k2 = -hadapt_mem->k2 / k; - k3 = -hadapt_mem->k3 / k; - e1 = SUNMAX(ecur, TINY); - e2 = e1 / SUNMAX(hadapt_mem->ehist[0], TINY); - hrat = hcur / hadapt_mem->hhist[0]; - /* implicit estimate */ - h_acc = hcur * hrat * SUNRpowerR(e1,k3) * SUNRpowerR(e2,k3); - /* explicit estimate */ - h_acc = SUNMIN(h_acc, hcur * SUNRpowerR(e1,k1) * SUNRpowerR(e2,k2)); - - } - *hnew = h_acc; - - return(ARK_SUCCESS); -} - - /*=============================================================== EOF ===============================================================*/ diff --git a/src/arkode/arkode_adapt_impl.h b/src/arkode/arkode_adapt_impl.h index 5cdd3d2e58..fa24af3a00 100644 --- a/src/arkode/arkode_adapt_impl.h +++ b/src/arkode/arkode_adapt_impl.h @@ -20,6 +20,7 @@ #include #include +#include #ifdef __cplusplus /* wrapper to enable C++ usage */ extern "C" { @@ -31,29 +32,15 @@ extern "C" { ===============================================================*/ /* size constants for the adaptivity memory structure */ -#define ARK_ADAPT_LRW 19 -#define ARK_ADAPT_LIW 8 /* includes function/data pointers */ +#define ARK_ADAPT_LRW 10 +#define ARK_ADAPT_LIW 7 /* includes function/data pointers */ /* Time step controller default values */ #define CFLFAC RCONST(0.5) #define SAFETY RCONST(0.96) /* CVODE uses 1.0 */ -#define BIAS RCONST(1.5) /* CVODE uses 6.0 */ #define GROWTH RCONST(20.0) /* CVODE uses 10.0 */ #define HFIXED_LB RCONST(1.0) /* CVODE uses 1.0 */ #define HFIXED_UB RCONST(1.5) /* CVODE uses 1.5 */ -#define AD0_K1 RCONST(0.58) /* PID controller constants */ -#define AD0_K2 RCONST(0.21) -#define AD0_K3 RCONST(0.1) -#define AD1_K1 RCONST(0.8) /* PI controller constants */ -#define AD1_K2 RCONST(0.31) -#define AD2_K1 RCONST(1.0) /* I controller constants */ -#define AD3_K1 RCONST(0.367) /* explicit Gustafsson controller */ -#define AD3_K2 RCONST(0.268) -#define AD4_K1 RCONST(0.98) /* implicit Gustafsson controller */ -#define AD4_K2 RCONST(0.95) -#define AD5_K1 RCONST(0.367) /* imex Gustafsson controller */ -#define AD5_K2 RCONST(0.268) -#define AD5_K3 RCONST(0.95) #define ETAMX1 RCONST(10000.0) /* maximum step size change on first step */ #define ETAMXF RCONST(0.3) /* step size reduction factor on multiple error @@ -85,30 +72,14 @@ typedef struct ARKodeHAdaptMemRec { realtype etamin; /* eta >= etamin on error test fail */ int small_nef; /* bound to determine 'multiple' above */ realtype etacf; /* h reduction factor on nonlinear conv fail */ - ARKAdaptFn HAdapt; /* function to set the new time step size */ - void *HAdapt_data; /* user pointer passed to hadapt */ - realtype ehist[2]; /* error history for time adaptivity */ - realtype hhist[2]; /* step history for time adaptivity */ - int imethod; /* step adaptivity method to use: - -1 -> User-specified function above - 0 -> PID controller - 1 -> PI controller - 2 -> I controller - 3 -> explicit Gustafsson controller - 4 -> implicit Gustafsson controller - 5 -> imex Gustafsson controller */ realtype cfl; /* cfl safety factor */ realtype safety; /* accuracy safety factor on h */ - realtype bias; /* accuracy safety factor on LTE */ realtype growth; /* maximum step growth safety factor */ realtype lbound; /* eta lower bound to leave h unchanged */ realtype ubound; /* eta upper bound to leave h unchanged */ - realtype k1; /* method-specific adaptivity parameters */ - realtype k2; - realtype k3; - int q; /* method order */ - int p; /* embedding order */ - booleantype pq; /* choice of using p (0) vs q (1) */ + + SUNAdaptController hcontroller; /* temporal error controller */ + booleantype owncontroller; /* flag indicating hcontroller ownership */ ARKExpStabFn expstab; /* step stability function */ void *estab_data; /* user pointer passed to expstab */ @@ -128,18 +99,6 @@ void arkPrintAdaptMem(ARKodeHAdaptMem hadapt_mem, FILE *outfile); int arkAdapt(void* arkode_mem, ARKodeHAdaptMem hadapt_mem, N_Vector ycur, realtype tcur, realtype hcur, realtype dsm, long int nst); -int arkAdaptPID(ARKodeHAdaptMem hadapt_mem, int k, - realtype hcur, realtype ecur, realtype *hnew); -int arkAdaptPI(ARKodeHAdaptMem hadapt_mem, int k, - realtype hcur, realtype ecur, realtype *hnew); -int arkAdaptI(ARKodeHAdaptMem hadapt_mem, int k, - realtype hcur, realtype ecur, realtype *hnew); -int arkAdaptExpGus(ARKodeHAdaptMem hadapt_mem, int k, long int nst, - realtype hcur, realtype ecur, realtype *hnew); -int arkAdaptImpGus(ARKodeHAdaptMem hadapt_mem, int k, long int nst, - realtype hcur, realtype ecur, realtype *hnew); -int arkAdaptImExGus(ARKodeHAdaptMem hadapt_mem, int k, long int nst, - realtype hcur, realtype ecur, realtype *hnew); #ifdef __cplusplus diff --git a/src/arkode/arkode_arkstep.c b/src/arkode/arkode_arkstep.c index e1245168e0..8ea0f5316e 100644 --- a/src/arkode/arkode_arkstep.c +++ b/src/arkode/arkode_arkstep.c @@ -1134,11 +1134,17 @@ int arkStep_Init(void* arkode_mem, int init_type) /* Retrieve/store method and embedding orders now that tables are finalized */ if (step_mem->Bi != NULL) { - step_mem->q = ark_mem->hadapt_mem->q = step_mem->Bi->q; - step_mem->p = ark_mem->hadapt_mem->p = step_mem->Bi->p; + step_mem->q = step_mem->Bi->q; + step_mem->p = step_mem->Bi->p; } else { - step_mem->q = ark_mem->hadapt_mem->q = step_mem->Be->q; - step_mem->p = ark_mem->hadapt_mem->p = step_mem->Be->p; + step_mem->q = step_mem->Be->q; + step_mem->p = step_mem->Be->p; + } + retval = SUNAdaptController_SetMethodOrder(ark_mem->hadapt_mem->hcontroller, step_mem->q, step_mem->p); + if (retval != SUNADAPTCONTROLLER_SUCCESS) { + arkProcessError(ark_mem, ARK_CONTROLLER_ERR, "ARKODE::ARKStep", + "arkStep_Init", "SUNAdaptController_SetMethodOrder error"); + return(ARK_CONTROLLER_ERR); } /* Ensure that if adaptivity is enabled, then method includes embedding coefficients */ diff --git a/src/arkode/arkode_arkstep_io.c b/src/arkode/arkode_arkstep_io.c index fc2df26f98..be92679382 100644 --- a/src/arkode/arkode_arkstep_io.c +++ b/src/arkode/arkode_arkstep_io.c @@ -89,11 +89,6 @@ int ARKStepSetMinReduction(void *arkode_mem, realtype eta_min) { return(arkSetMinReduction(arkode_mem, eta_min)); } int ARKStepSetFixedStepBounds(void *arkode_mem, realtype lb, realtype ub) { return(arkSetFixedStepBounds(arkode_mem, lb, ub)); } -int ARKStepSetAdaptivityMethod(void *arkode_mem, int imethod, int idefault, - int pq, realtype adapt_params[3]) { - return(arkSetAdaptivityMethod(arkode_mem, imethod, idefault, pq, adapt_params)); } -int ARKStepSetAdaptivityFn(void *arkode_mem, ARKAdaptFn hfun, void *h_data) { - return(arkSetAdaptivityFn(arkode_mem, hfun, h_data)); } int ARKStepSetMaxFirstGrowth(void *arkode_mem, realtype etamx1) { return(arkSetMaxFirstGrowth(arkode_mem, etamx1)); } int ARKStepSetMaxEFailGrowth(void *arkode_mem, realtype etamxf) { @@ -108,6 +103,8 @@ int ARKStepSetMaxErrTestFails(void *arkode_mem, int maxnef) { return(arkSetMaxErrTestFails(arkode_mem, maxnef)); } int ARKStepSetMaxConvFails(void *arkode_mem, int maxncf) { return(arkSetMaxConvFails(arkode_mem, maxncf)); } +int ARKStepSetAdaptController(void *arkode_mem, SUNAdaptController C) { + return(arkSetAdaptController(arkode_mem, C)); } int ARKStepSetFixedStep(void *arkode_mem, realtype hfixed) { return(arkSetFixedStep(arkode_mem, hfixed)); } @@ -343,6 +340,29 @@ int ARKStepGetNumRelaxSolveIters(void* arkode_mem, long int* iters) return arkRelaxGetNumRelaxSolveIters(arkode_mem, iters); } + + +/*=============================================================== + DEPRECATED ARKStep optional input/output functions + ===============================================================*/ + +/*--------------------------------------------------------------- + ARKStepSetAdaptivityMethod: user should create/attach a + specific SUNAdaptController object. + ---------------------------------------------------------------*/ +int ARKStepSetAdaptivityMethod(void *arkode_mem, int imethod, int idefault, + int pq, realtype adapt_params[3]) { + return(arkSetAdaptivityMethod(arkode_mem, imethod, idefault, pq, adapt_params)); } + +/*--------------------------------------------------------------- + ARKStepSetAdaptivityFn: user should create/attach a custom + SUNAdaptController object. + ---------------------------------------------------------------*/ +int ARKStepSetAdaptivityFn(void *arkode_mem, ARKAdaptFn hfun, void *h_data) { + return(arkSetAdaptivityFn(arkode_mem, hfun, h_data)); } + + + /*=============================================================== ARKStep optional input functions -- stepper-specific ===============================================================*/ @@ -456,6 +476,7 @@ int ARKStepSetOptimalParams(void *arkode_mem) ARKodeARKStepMem step_mem; ARKodeHAdaptMem hadapt_mem; int retval; + long int lenrw, leniw; /* access ARKodeARKStepMem structure */ retval = arkStep_AccessStepMem(arkode_mem, "ARKStepSetOptimalParams", @@ -471,25 +492,52 @@ int ARKStepSetOptimalParams(void *arkode_mem) } hadapt_mem = ark_mem->hadapt_mem; + /* Remove current SUNAdaptController object */ + retval = SUNAdaptController_Space(hadapt_mem->hcontroller, &lenrw, &leniw); + if (retval == SUNADAPTCONTROLLER_SUCCESS) { + ark_mem->liw -= leniw; + ark_mem->lrw -= lenrw; + } + if (hadapt_mem->owncontroller) { + retval = SUNAdaptController_Destroy(hadapt_mem->hcontroller); + if (retval != SUNADAPTCONTROLLER_SUCCESS) { + arkProcessError(ark_mem, ARK_MEM_FAIL, "ARKODE", "ARKStepSetOptimalParams", + "SUNAdaptController_Destroy failure"); + return(ARK_MEM_FAIL); + } + } + hadapt_mem->hcontroller = NULL; + /* Choose values based on method, order */ /* explicit */ if (step_mem->explicit && !step_mem->implicit) { - hadapt_mem->imethod = ARK_ADAPT_PI; + hadapt_mem->hcontroller = SUNAdaptController_PI(ark_mem->sunctx); + if (hadapt_mem->hcontroller == NULL) { + arkProcessError(ark_mem, ARK_MEM_FAIL, "ARKODE::ARKStep", + "ARKStepSetOptimalParams", + "SUNAdaptController_PI allocation failure"); + return(ARK_MEM_FAIL); + } + (void) SUNAdaptController_SetErrorBias(hadapt_mem->hcontroller, RCONST(1.2)); + (void) SUNAdaptController_SetParams_PI(hadapt_mem->hcontroller, SUNFALSE, + RCONST(0.8), RCONST(0.31)); hadapt_mem->safety = RCONST(0.99); - hadapt_mem->bias = RCONST(1.2); hadapt_mem->growth = RCONST(25.0); - hadapt_mem->k1 = RCONST(0.8); - hadapt_mem->k2 = RCONST(0.31); hadapt_mem->etamxf = RCONST(0.3); /* 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->imethod = ARK_ADAPT_PID; + hadapt_mem->hcontroller = SUNAdaptController_PID(ark_mem->sunctx); + if (hadapt_mem->hcontroller == NULL) { + arkProcessError(ark_mem, ARK_MEM_FAIL, "ARKODE::ARKStep", + "ARKStepSetOptimalParams", + "SUNAdaptController_PID allocation failure"); + return(ARK_MEM_FAIL); + } hadapt_mem->safety = SAFETY; - hadapt_mem->bias = BIAS; hadapt_mem->growth = GROWTH; hadapt_mem->etamxf = ETAMXF; hadapt_mem->small_nef = SMALL_NEF; @@ -502,9 +550,15 @@ int ARKStepSetOptimalParams(void *arkode_mem) step_mem->msbp = MSBP; break; case 3: - hadapt_mem->imethod = ARK_ADAPT_I; + hadapt_mem->hcontroller = SUNAdaptController_I(ark_mem->sunctx); + if (hadapt_mem->hcontroller == NULL) { + arkProcessError(ark_mem, ARK_MEM_FAIL, "ARKODE::ARKStep", + "ARKStepSetOptimalParams", + "SUNAdaptController_I allocation failure"); + return(ARK_MEM_FAIL); + } + (void) SUNAdaptController_SetErrorBias(hadapt_mem->hcontroller, RCONST(1.9)); hadapt_mem->safety = RCONST(0.957); - hadapt_mem->bias = RCONST(1.9); hadapt_mem->growth = RCONST(17.6); hadapt_mem->etamxf = RCONST(0.45); hadapt_mem->small_nef = SMALL_NEF; @@ -516,13 +570,18 @@ int ARKStepSetOptimalParams(void *arkode_mem) step_mem->msbp = 60; break; case 4: - hadapt_mem->imethod = ARK_ADAPT_PID; + hadapt_mem->hcontroller = SUNAdaptController_PID(ark_mem->sunctx); + if (hadapt_mem->hcontroller == NULL) { + arkProcessError(ark_mem, ARK_MEM_FAIL, "ARKODE::ARKStep", + "ARKStepSetOptimalParams", + "SUNAdaptController_PID allocation failure"); + return(ARK_MEM_FAIL); + } + (void) SUNAdaptController_SetErrorBias(hadapt_mem->hcontroller, RCONST(1.2)); + (void) SUNAdaptController_SetParams_PID(hadapt_mem->hcontroller, SUNFALSE, + RCONST(0.535), RCONST(0.209), RCONST(0.148)); hadapt_mem->safety = RCONST(0.988); - hadapt_mem->bias = RCONST(1.2); hadapt_mem->growth = RCONST(31.5); - hadapt_mem->k1 = RCONST(0.535); - hadapt_mem->k2 = RCONST(0.209); - hadapt_mem->k3 = RCONST(0.148); hadapt_mem->etamxf = RCONST(0.33); hadapt_mem->small_nef = SMALL_NEF; hadapt_mem->etacf = ETACF; @@ -533,13 +592,18 @@ int ARKStepSetOptimalParams(void *arkode_mem) step_mem->msbp = 31; break; case 5: - hadapt_mem->imethod = ARK_ADAPT_PID; + hadapt_mem->hcontroller = SUNAdaptController_PID(ark_mem->sunctx); + if (hadapt_mem->hcontroller == NULL) { + arkProcessError(ark_mem, ARK_MEM_FAIL, "ARKODE::ARKStep", + "ARKStepSetOptimalParams", + "SUNAdaptController_PID allocation failure"); + return(ARK_MEM_FAIL); + } + (void) SUNAdaptController_SetErrorBias(hadapt_mem->hcontroller, RCONST(3.3)); + (void) SUNAdaptController_SetParams_PID(hadapt_mem->hcontroller, SUNFALSE, + RCONST(0.56), RCONST(0.338), RCONST(0.14)); hadapt_mem->safety = RCONST(0.937); - hadapt_mem->bias = RCONST(3.3); hadapt_mem->growth = RCONST(22.0); - hadapt_mem->k1 = RCONST(0.56); - hadapt_mem->k2 = RCONST(0.338); - hadapt_mem->k3 = RCONST(0.14); hadapt_mem->etamxf = RCONST(0.44); hadapt_mem->small_nef = SMALL_NEF; hadapt_mem->etacf = ETACF; @@ -554,14 +618,39 @@ int ARKStepSetOptimalParams(void *arkode_mem) /* imex */ } else { 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, "ARKODE::ARKStep", + "ARKStepSetOptimalParams", + "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; + step_mem->nlscoef = 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->imethod = ARK_ADAPT_PID; + hadapt_mem->hcontroller = SUNAdaptController_PID(ark_mem->sunctx); + if (hadapt_mem->hcontroller == NULL) { + arkProcessError(ark_mem, ARK_MEM_FAIL, "ARKODE::ARKStep", + "ARKStepSetOptimalParams", + "SUNAdaptController_PID allocation failure"); + return(ARK_MEM_FAIL); + } + (void) SUNAdaptController_SetErrorBias(hadapt_mem->hcontroller, RCONST(1.42)); + (void) SUNAdaptController_SetParams_PID(hadapt_mem->hcontroller, SUNFALSE, + RCONST(0.54), RCONST(0.36), RCONST(0.14)); hadapt_mem->safety = RCONST(0.965); - hadapt_mem->bias = RCONST(1.42); hadapt_mem->growth = RCONST(28.7); - hadapt_mem->k1 = RCONST(0.54); - hadapt_mem->k2 = RCONST(0.36); - hadapt_mem->k3 = RCONST(0.14); hadapt_mem->etamxf = RCONST(0.46); hadapt_mem->small_nef = SMALL_NEF; hadapt_mem->etacf = ETACF; @@ -572,13 +661,18 @@ int ARKStepSetOptimalParams(void *arkode_mem) step_mem->msbp = 60; break; case 4: - hadapt_mem->imethod = ARK_ADAPT_PID; + hadapt_mem->hcontroller = SUNAdaptController_PID(ark_mem->sunctx); + if (hadapt_mem->hcontroller == NULL) { + arkProcessError(ark_mem, ARK_MEM_FAIL, "ARKODE::ARKStep", + "ARKStepSetOptimalParams", + "SUNAdaptController_PID allocation failure"); + return(ARK_MEM_FAIL); + } + (void) SUNAdaptController_SetErrorBias(hadapt_mem->hcontroller, RCONST(1.35)); + (void) SUNAdaptController_SetParams_PID(hadapt_mem->hcontroller, SUNFALSE, + RCONST(0.543), RCONST(0.297), RCONST(0.14)); hadapt_mem->safety = RCONST(0.97); - hadapt_mem->bias = RCONST(1.35); hadapt_mem->growth = RCONST(25.0); - hadapt_mem->k1 = RCONST(0.543); - hadapt_mem->k2 = RCONST(0.297); - hadapt_mem->k3 = RCONST(0.14); hadapt_mem->etamxf = RCONST(0.47); hadapt_mem->small_nef = SMALL_NEF; hadapt_mem->etacf = ETACF; @@ -589,12 +683,18 @@ int ARKStepSetOptimalParams(void *arkode_mem) step_mem->msbp = 31; break; case 5: - hadapt_mem->imethod = ARK_ADAPT_PI; + hadapt_mem->hcontroller = SUNAdaptController_PI(ark_mem->sunctx); + if (hadapt_mem->hcontroller == NULL) { + arkProcessError(ark_mem, ARK_MEM_FAIL, "ARKODE::ARKStep", + "ARKStepSetOptimalParams", + "SUNAdaptController_PI allocation failure"); + return(ARK_MEM_FAIL); + } + (void) SUNAdaptController_SetErrorBias(hadapt_mem->hcontroller, RCONST(1.15)); + (void) SUNAdaptController_SetParams_PI(hadapt_mem->hcontroller, SUNFALSE, + RCONST(0.8), RCONST(0.35)); hadapt_mem->safety = RCONST(0.993); - hadapt_mem->bias = RCONST(1.15); hadapt_mem->growth = RCONST(28.5); - hadapt_mem->k1 = RCONST(0.8); - hadapt_mem->k2 = RCONST(0.35); hadapt_mem->etamxf = RCONST(0.3); hadapt_mem->small_nef = SMALL_NEF; hadapt_mem->etacf = ETACF; @@ -605,6 +705,13 @@ int ARKStepSetOptimalParams(void *arkode_mem) step_mem->msbp = 31; break; } + hadapt_mem->owncontroller = SUNTRUE; + + retval = SUNAdaptController_Space(hadapt_mem->hcontroller, &lenrw, &leniw); + if (retval == SUNADAPTCONTROLLER_SUCCESS) { + ark_mem->liw += leniw; + ark_mem->lrw += lenrw; + } } return(ARK_SUCCESS); diff --git a/src/arkode/arkode_erkstep.c b/src/arkode/arkode_erkstep.c index f21aa2602b..e49a4dc449 100644 --- a/src/arkode/arkode_erkstep.c +++ b/src/arkode/arkode_erkstep.c @@ -537,8 +537,14 @@ int erkStep_Init(void* arkode_mem, int init_type) } /* Retrieve/store method and embedding orders now that table is finalized */ - step_mem->q = ark_mem->hadapt_mem->q = step_mem->B->q; - step_mem->p = ark_mem->hadapt_mem->p = step_mem->B->p; + step_mem->q = step_mem->B->q; + step_mem->p = step_mem->B->p; + retval = SUNAdaptController_SetMethodOrder(ark_mem->hadapt_mem->hcontroller, step_mem->q, step_mem->p); + if (retval != SUNADAPTCONTROLLER_SUCCESS) { + arkProcessError(ark_mem, ARK_CONTROLLER_ERR, "ARKODE::ERKStep", + "erkStep_Init", "SUNAdaptControllerSetMethodOrder error"); + return(ARK_CONTROLLER_ERR); + } /* Ensure that if adaptivity is enabled, then method includes embedding coefficients */ if (!ark_mem->fixedstep && (step_mem->p == 0)) { diff --git a/src/arkode/arkode_erkstep_io.c b/src/arkode/arkode_erkstep_io.c index 34bb7d46c2..2b76209212 100644 --- a/src/arkode/arkode_erkstep_io.c +++ b/src/arkode/arkode_erkstep_io.c @@ -90,11 +90,6 @@ int ERKStepSetMinReduction(void *arkode_mem, realtype eta_min) { return(arkSetMinReduction(arkode_mem, eta_min)); } int ERKStepSetFixedStepBounds(void *arkode_mem, realtype lb, realtype ub) { return(arkSetFixedStepBounds(arkode_mem, lb, ub)); } -int ERKStepSetAdaptivityMethod(void *arkode_mem, int imethod, int idefault, - int pq, realtype 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, realtype etamx1) { return(arkSetMaxFirstGrowth(arkode_mem, etamx1)); } int ERKStepSetMaxEFailGrowth(void *arkode_mem, realtype etamxf) { @@ -107,6 +102,8 @@ int ERKStepSetMaxErrTestFails(void *arkode_mem, int maxnef) { return(arkSetMaxErrTestFails(arkode_mem, maxnef)); } int ERKStepSetFixedStep(void *arkode_mem, realtype hfixed) { return(arkSetFixedStep(arkode_mem, hfixed)); } +int ERKStepSetAdaptController(void *arkode_mem, SUNAdaptController C) { + return(arkSetAdaptController(arkode_mem, C)); } /*=============================================================== @@ -234,6 +231,27 @@ int ERKStepGetNumRelaxSolveIters(void* arkode_mem, long int* iters) return arkRelaxGetNumRelaxSolveIters(arkode_mem, iters); } + +/*=============================================================== + DEPRECATED ERKStep optional input/output functions + ===============================================================*/ + +/*--------------------------------------------------------------- + ERKStepSetAdaptivityMethod: user should create/attach a + specific SUNAdaptController object. + ---------------------------------------------------------------*/ +int ERKStepSetAdaptivityMethod(void *arkode_mem, int imethod, int idefault, + int pq, realtype adapt_params[3]) { + return(arkSetAdaptivityMethod(arkode_mem, imethod, idefault, pq, adapt_params)); } + +/*--------------------------------------------------------------- + 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)); } + + /*=============================================================== ERKStep optional input functions -- stepper-specific ===============================================================*/ @@ -250,6 +268,7 @@ int ERKStepSetDefaults(void* arkode_mem) ARKodeMem ark_mem; ARKodeERKStepMem step_mem; int retval; + long int lenrw, leniw; /* access ARKodeERKStepMem structure */ retval = erkStep_AccessStepMem(arkode_mem, "ERKStepSetDefaults", @@ -265,19 +284,47 @@ int ERKStepSetDefaults(void* arkode_mem) return(retval); } + /* Remove current SUNAdaptController object, and replace with "PI" */ + retval = SUNAdaptController_Space(ark_mem->hadapt_mem->hcontroller, &lenrw, &leniw); + if (retval == SUNADAPTCONTROLLER_SUCCESS) { + ark_mem->liw -= leniw; + ark_mem->lrw -= lenrw; + } + if (ark_mem->hadapt_mem->owncontroller) { + retval = SUNAdaptController_Destroy(ark_mem->hadapt_mem->hcontroller); + if (retval != SUNADAPTCONTROLLER_SUCCESS) { + arkProcessError(ark_mem, ARK_MEM_FAIL, "ARKODE", "ERKStepSetDefaults", + "SUNAdaptController_Destroy failure"); + return(ARK_MEM_FAIL); + } + } + ark_mem->hadapt_mem->hcontroller = NULL; + ark_mem->hadapt_mem->hcontroller = SUNAdaptController_PI(ark_mem->sunctx); + if (ark_mem->hadapt_mem->hcontroller == NULL) { + arkProcessError(ark_mem, ARK_MEM_FAIL, "ARKODE::ERKStep", + "ERKStepSetDefaults", + "SUNAdaptControllerPI allocation failure"); + return(ARK_MEM_FAIL); + } + ark_mem->hadapt_mem->owncontroller = SUNTRUE; + retval = SUNAdaptController_Space(ark_mem->hadapt_mem->hcontroller, &lenrw, &leniw); + if (retval == SUNADAPTCONTROLLER_SUCCESS) { + ark_mem->liw += leniw; + ark_mem->lrw += lenrw; + } + /* Set default values for integrator optional inputs (overwrite some adaptivity params for ERKStep use) */ step_mem->q = Q_DEFAULT; /* method order */ step_mem->p = 0; /* embedding order */ + step_mem->stages = 0; /* no stages */ + step_mem->B = NULL; /* no Butcher table */ ark_mem->hadapt_mem->etamxf = RCONST(0.3); /* max change on error-failed step */ - ark_mem->hadapt_mem->imethod = ARK_ADAPT_PI; /* PI controller */ ark_mem->hadapt_mem->safety = RCONST(0.99); /* step adaptivity safety factor */ - ark_mem->hadapt_mem->bias = RCONST(1.2); /* step adaptivity error bias */ ark_mem->hadapt_mem->growth = RCONST(25.0); /* step adaptivity growth factor */ - ark_mem->hadapt_mem->k1 = RCONST(0.8); /* step adaptivity parameter */ - ark_mem->hadapt_mem->k2 = RCONST(0.31); /* step adaptivity parameter */ - step_mem->stages = 0; /* no stages */ - step_mem->B = NULL; /* no Butcher table */ + (void) SUNAdaptController_SetErrorBias(ark_mem->hadapt_mem->hcontroller, RCONST(1.2)); + (void) SUNAdaptController_SetParams_PI(ark_mem->hadapt_mem->hcontroller, SUNFALSE, + RCONST(0.8), RCONST(0.31)); return(ARK_SUCCESS); } diff --git a/src/arkode/arkode_impl.h b/src/arkode/arkode_impl.h index 32c73219ee..df4ec49ee9 100644 --- a/src/arkode/arkode_impl.h +++ b/src/arkode/arkode_impl.h @@ -25,6 +25,7 @@ #include #include #include +#include #include "arkode_types_impl.h" #include "arkode_adapt_impl.h" @@ -980,6 +981,7 @@ int arkCheckTemporalError(ARKodeMem ark_mem, int *nflagPtr, int *nefPtr, int arkAccessHAdaptMem(void* arkode_mem, const char *fname, ARKodeMem *ark_mem, ARKodeHAdaptMem *hadapt_mem); +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); diff --git a/src/arkode/arkode_io.c b/src/arkode/arkode_io.c index 60e6d04187..8f7dc02afe 100644 --- a/src/arkode/arkode_io.c +++ b/src/arkode/arkode_io.c @@ -23,8 +23,15 @@ #include "arkode_impl.h" #include "arkode_interp_impl.h" +#include "arkode_user_controller.h" #include #include +#include +#include +#include +#include +#include +#include /*=============================================================== @@ -43,6 +50,7 @@ int arkSetDefaults(void *arkode_mem) { ARKodeMem ark_mem; + int retval; if (arkode_mem==NULL) { arkProcessError(NULL, ARK_MEM_NULL, "ARKODE", "arkSetDefaults", MSG_ARK_NO_MEM); @@ -51,7 +59,7 @@ int arkSetDefaults(void *arkode_mem) ark_mem = (ARKodeMem) arkode_mem; /* Set default values for integrator optional inputs */ - ark_mem->use_compensated_sums = SUNFALSE; + ark_mem->use_compensated_sums = SUNFALSE; ark_mem->fixedstep = SUNFALSE; /* default to use adaptive steps */ ark_mem->reltol = RCONST(1.e-4); /* relative tolerance */ ark_mem->itol = ARK_SS; /* scalar-scalar solution tolerances */ @@ -90,21 +98,18 @@ int arkSetDefaults(void *arkode_mem) ark_mem->hadapt_mem->etamin = ETAMIN; /* min bound on time step reduction */ ark_mem->hadapt_mem->small_nef = SMALL_NEF; /* num error fails before ETAMXF enforced */ ark_mem->hadapt_mem->etacf = ETACF; /* max change on convergence failure */ - ark_mem->hadapt_mem->HAdapt = NULL; /* step adaptivity fn */ - ark_mem->hadapt_mem->HAdapt_data = NULL; /* step adaptivity data */ - ark_mem->hadapt_mem->imethod = ARK_ADAPT_PID; /* PID controller */ ark_mem->hadapt_mem->cfl = CFLFAC; /* explicit stability factor */ ark_mem->hadapt_mem->safety = SAFETY; /* step adaptivity safety factor */ - ark_mem->hadapt_mem->bias = BIAS; /* step adaptivity error bias */ ark_mem->hadapt_mem->growth = GROWTH; /* step adaptivity growth factor */ ark_mem->hadapt_mem->lbound = HFIXED_LB; /* step adaptivity no-change lower bound */ ark_mem->hadapt_mem->ubound = HFIXED_UB; /* step adaptivity no-change upper bound */ - ark_mem->hadapt_mem->k1 = AD0_K1; /* step adaptivity parameter */ - ark_mem->hadapt_mem->k2 = AD0_K2; /* step adaptivity parameter */ - ark_mem->hadapt_mem->k3 = AD0_K3; /* step adaptivity parameter */ - ark_mem->hadapt_mem->pq = SUNFALSE; /* use embedding order */ ark_mem->hadapt_mem->expstab = arkExpStab; /* internal explicit stability fn */ ark_mem->hadapt_mem->estab_data = NULL; /* no explicit stability fn data */ + + /* Set default values for controller object */ + retval = SUNAdaptController_SetDefaults(ark_mem->hadapt_mem->hcontroller); + if (retval != SUNADAPTCONTROLLER_SUCCESS) { return(ARK_CONTROLLER_ERR); } + return(ARK_SUCCESS); } @@ -329,6 +334,66 @@ int arkSetDiagnostics(void *arkode_mem, FILE *diagfp) } +/*--------------------------------------------------------------- + arkSetAdaptController: + + Specifies a non-default SUNAdaptController time step controller + object. If a NULL-valued SUNAdaptController is input, the + default will be re-enabled. + ---------------------------------------------------------------*/ +int arkSetAdaptController(void *arkode_mem, SUNAdaptController C) +{ + int retval; + long int lenrw, leniw; + ARKodeMem ark_mem; + if (arkode_mem==NULL) { + arkProcessError(NULL, ARK_MEM_NULL, "ARKODE", + "arkSetAdaptController", MSG_ARK_NO_MEM); + return(ARK_MEM_NULL); + } + 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 == SUNADAPTCONTROLLER_SUCCESS) { + ark_mem->liw -= leniw; + ark_mem->lrw -= lenrw; + } + if (ark_mem->hadapt_mem->owncontroller) { + retval = SUNAdaptController_Destroy(ark_mem->hadapt_mem->hcontroller); + if (retval != SUNADAPTCONTROLLER_SUCCESS) { + arkProcessError(ark_mem, ARK_MEM_FAIL, "ARKODE", "arkSetAdaptController", + "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, "ARKODE", "arkSetAdaptController", + "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 == SUNADAPTCONTROLLER_SUCCESS) { + ark_mem->liw += leniw; + ark_mem->lrw += lenrw; + } + ark_mem->hadapt_mem->hcontroller = C; + + return(ARK_SUCCESS); +} + /*--------------------------------------------------------------- arkSetMaxNumSteps: @@ -388,6 +453,7 @@ int arkSetMaxHnilWarns(void *arkode_mem, int mxhnil) int arkSetInitStep(void *arkode_mem, realtype hin) { ARKodeMem ark_mem; + int retval; if (arkode_mem==NULL) { arkProcessError(NULL, ARK_MEM_NULL, "ARKODE", "arkSetInitStep", MSG_ARK_NO_MEM); @@ -405,11 +471,9 @@ int arkSetInitStep(void *arkode_mem, realtype hin) /* Clear previous initial step */ ark_mem->h0u = ZERO; - /* Clear error and step size history */ - ark_mem->hadapt_mem->ehist[0] = ONE; - ark_mem->hadapt_mem->ehist[1] = ONE; - ark_mem->hadapt_mem->hhist[0] = ZERO; - ark_mem->hadapt_mem->hhist[1] = ZERO; + /* Reset error controller (e.g., error and step size history) */ + retval = SUNAdaptController_Reset(ark_mem->hadapt_mem->hcontroller); + if (retval != SUNADAPTCONTROLLER_SUCCESS) { return(ARK_CONTROLLER_ERR); } return(ARK_SUCCESS); } @@ -580,6 +644,7 @@ int arkClearStopTime(void *arkode_mem) int arkSetFixedStep(void *arkode_mem, realtype hfixed) { int retval; + long int lenrw, leniw; ARKodeMem ark_mem; if (arkode_mem==NULL) { arkProcessError(NULL, ARK_MEM_NULL, "ARKODE", @@ -588,6 +653,44 @@ int arkSetFixedStep(void *arkode_mem, realtype hfixed) } 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 == SUNADAPTCONTROLLER_SUCCESS) { + ark_mem->liw -= leniw; + ark_mem->lrw -= lenrw; + } + if (ark_mem->hadapt_mem->owncontroller) { + retval = SUNAdaptController_Destroy(ark_mem->hadapt_mem->hcontroller); + if (retval != SUNADAPTCONTROLLER_SUCCESS) { + arkProcessError(ark_mem, ARK_MEM_FAIL, "ARKODE", "arkSetFixedStep", + "SUNAdaptController_Destroy failure"); + return(ARK_MEM_FAIL); + } + } + ark_mem->hadapt_mem->hcontroller = NULL; + + /* If re-enabling time adaptivity, create default PID controller + and attach object to ARKODE */ + SUNAdaptController C = NULL; + if (hfixed == ZERO) + { + C = SUNAdaptController_PID(ark_mem->sunctx); + if (C == NULL) { + arkProcessError(ark_mem, ARK_MEM_FAIL, "ARKODE", "arkSetFixedStep", + "SUNAdaptControllerPID allocation failure"); + return(ARK_MEM_FAIL); + } + + retval = SUNAdaptController_Space(C, &lenrw, &leniw); + if (retval == SUNADAPTCONTROLLER_SUCCESS) { + ark_mem->liw += leniw; + ark_mem->lrw += lenrw; + } + ark_mem->hadapt_mem->hcontroller = C; + ark_mem->hadapt_mem->owncontroller = SUNTRUE; + } + /* re-attach internal error weight functions if necessary */ if ((hfixed == ZERO) && (!ark_mem->user_efun)) { if (ark_mem->itol == ARK_SV && ark_mem->Vabstol != NULL) @@ -597,7 +700,7 @@ int arkSetFixedStep(void *arkode_mem, realtype hfixed) if (retval != ARK_SUCCESS) return(retval); } - /* set ark_mem entry */ + /* set ark_mem "fixedstep" entry entry */ if (hfixed != ZERO) { ark_mem->fixedstep = SUNTRUE; ark_mem->hin = hfixed; @@ -605,6 +708,8 @@ int arkSetFixedStep(void *arkode_mem, realtype hfixed) ark_mem->fixedstep = SUNFALSE; } + /* Notify ARKODE to use hfixed as the initial step size, and return */ + retval = arkSetInitStep(arkode_mem, hfixed); return(ARK_SUCCESS); } @@ -767,16 +872,16 @@ int arkSetConstraints(void *arkode_mem, N_Vector constraints) constraints->ops->nvcompare == NULL || constraints->ops->nvconstrmask == NULL || constraints->ops->nvminquotient == NULL) { - arkProcessError(ark_mem, ARK_ILL_INPUT, "ARKODE::ARKStep", - "ARKStepSetConstraints", MSG_ARK_BAD_NVECTOR); + arkProcessError(ark_mem, ARK_ILL_INPUT, "ARKODE", + "arkSetConstraints", MSG_ARK_BAD_NVECTOR); return(ARK_ILL_INPUT); } /* Check the constraints vector */ temptest = N_VMaxNorm(constraints); if ((temptest > RCONST(2.5)) || (temptest < HALF)) { - arkProcessError(ark_mem, ARK_ILL_INPUT, "ARKODE::ARKStep", - "ARKStepSetConstraints", MSG_ARK_BAD_CONSTR); + arkProcessError(ark_mem, ARK_ILL_INPUT, "ARKODE", + "arkSetConstraints", MSG_ARK_BAD_CONSTR); return(ARK_ILL_INPUT); } @@ -818,6 +923,244 @@ int arkSetMaxNumConstrFails(void *arkode_mem, int maxfails) } +/*--------------------------------------------------------------- + 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. + + 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 arkSetAdaptivityMethod(void *arkode_mem, int imethod, int idefault, + int pq, realtype adapt_params[3]) +{ + int retval; + long int lenrw, leniw; + realtype k1, k2, k3; + ARKodeMem ark_mem; + if (arkode_mem==NULL) { + arkProcessError(NULL, ARK_MEM_NULL, "ARKODE", + "arkSetController", MSG_ARK_NO_MEM); + return(ARK_MEM_NULL); + } + ark_mem = (ARKodeMem) arkode_mem; + + /* Check for illegal inputs */ + if ((idefault != 1) && (adapt_params == NULL)) { + arkProcessError(ark_mem, ARK_ILL_INPUT, "ARKODE", + "arkSetAdaptivityMethod", + "NULL-valued adapt_params provided"); + return(ARK_ILL_INPUT); + } + + /* Remove current SUNAdaptController object + (delete if owned, and then nullify pointer) */ + retval = SUNAdaptController_Space(ark_mem->hadapt_mem->hcontroller, &lenrw, &leniw); + if (retval == SUNADAPTCONTROLLER_SUCCESS) { + ark_mem->liw -= leniw; + ark_mem->lrw -= lenrw; + } + if (ark_mem->hadapt_mem->owncontroller) { + retval = SUNAdaptController_Destroy(ark_mem->hadapt_mem->hcontroller); + if (retval != SUNADAPTCONTROLLER_SUCCESS) { + arkProcessError(ark_mem, ARK_MEM_FAIL, "ARKODE", "arkSetAdaptivityMethod", + "SUNAdaptController_Destroy failure"); + return(ARK_MEM_FAIL); + } + } + ark_mem->hadapt_mem->hcontroller = NULL; + + /* set adaptivity parameters from inputs or signal use of defaults */ + if (idefault == 1) { + k1 = -RCONST(1.0); + k2 = -RCONST(1.0); + k3 = -RCONST(1.0); + } else { + k1 = adapt_params[0]; + k2 = adapt_params[1]; + k3 = adapt_params[2]; + } + + /* Create new SUNAdaptController object based on "imethod" input, optionally setting + the specified controller parameters */ + SUNAdaptController C = NULL; + switch (imethod) { + case (ARK_ADAPT_PID): + C = SUNAdaptController_PID(ark_mem->sunctx); + if (C == NULL) { + arkProcessError(ark_mem, ARK_MEM_FAIL, "ARKODE", "arkSetAdaptivityMethod", + "SUNAdaptController_PID allocation failure"); + return(ARK_MEM_FAIL); + } + retval = SUNAdaptController_SetParams_PID(C, pq, k1, k2, k3); + if (retval != SUNADAPTCONTROLLER_SUCCESS) { + arkProcessError(ark_mem, ARK_CONTROLLER_ERR, "ARKODE", + "arkSetAdaptivityMethod", "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, "ARKODE", "arkSetAdaptivityMethod", + "SUNAdaptController_PI allocation failure"); + return(ARK_MEM_FAIL); + } + retval = SUNAdaptController_SetParams_PI(C, pq, k1, k2); + if (retval != SUNADAPTCONTROLLER_SUCCESS) { + arkProcessError(ark_mem, ARK_CONTROLLER_ERR, "ARKODE", + "arkSetAdaptivityMethod", "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, "ARKODE", "arkSetAdaptivityMethod", + "SUNAdaptController_I allocation failure"); + return(ARK_MEM_FAIL); + } + retval = SUNAdaptController_SetParams_I(C, pq, k1); + if (retval != SUNADAPTCONTROLLER_SUCCESS) { + arkProcessError(ark_mem, ARK_CONTROLLER_ERR, "ARKODE", + "arkSetAdaptivityMethod", "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, "ARKODE", "arkSetAdaptivityMethod", + "SUNAdaptController_ExpGus allocation failure"); + return(ARK_MEM_FAIL); + } + retval = SUNAdaptController_SetParams_ExpGus(C, pq, k1, k2); + if (retval != SUNADAPTCONTROLLER_SUCCESS) { + arkProcessError(ark_mem, ARK_CONTROLLER_ERR, "ARKODE", + "arkSetAdaptivityMethod", "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, "ARKODE", "arkSetAdaptivityMethod", + "SUNAdaptController_ImpGus allocation failure"); + return(ARK_MEM_FAIL); + } + retval = SUNAdaptController_SetParams_ImpGus(C, pq, k1, k2); + if (retval != SUNADAPTCONTROLLER_SUCCESS) { + arkProcessError(ark_mem, ARK_CONTROLLER_ERR, "ARKODE", + "arkSetAdaptivityMethod", "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, "ARKODE", "arkSetAdaptivityMethod", + "SUNAdaptController_ImExGus allocation failure"); + return(ARK_MEM_FAIL); + } + retval = SUNAdaptController_SetParams_ImExGus(C, pq, k1, k2, k3, k3); + if (retval != SUNADAPTCONTROLLER_SUCCESS) { + arkProcessError(ark_mem, ARK_CONTROLLER_ERR, "ARKODE", + "arkSetAdaptivityMethod", "SUNAdaptController_SetParams_ImExGus failure"); + return(ARK_CONTROLLER_ERR); + } + break; + default: + arkProcessError(ark_mem, ARK_ILL_INPUT, "ARKODE", + "arkSetAdaptivityMethod", "Illegal imethod"); + return(ARK_ILL_INPUT); + } + + /* Attach new SUNAdaptController object */ + retval = SUNAdaptController_Space(C, &lenrw, &leniw); + if (retval == SUNADAPTCONTROLLER_SUCCESS) { + ark_mem->liw += leniw; + ark_mem->lrw += lenrw; + } + ark_mem->hadapt_mem->hcontroller = C; + ark_mem->hadapt_mem->owncontroller = SUNTRUE; + + return(ARK_SUCCESS); +} + + +/*--------------------------------------------------------------- + arkSetAdaptivityFn: ***DEPRECATED*** + + 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 arkSetAdaptivityFn(void *arkode_mem, ARKAdaptFn hfun, void *h_data) +{ + int retval; + long int lenrw, leniw; + ARKodeMem ark_mem; + if (arkode_mem==NULL) { + arkProcessError(NULL, ARK_MEM_NULL, "ARKODE", + "arkSetAdaptivityFn", MSG_ARK_NO_MEM); + return(ARK_MEM_NULL); + } + 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 == SUNADAPTCONTROLLER_SUCCESS) { + ark_mem->liw -= leniw; + ark_mem->lrw -= lenrw; + } + if (ark_mem->hadapt_mem->owncontroller) { + retval = SUNAdaptController_Destroy(ark_mem->hadapt_mem->hcontroller); + if (retval != SUNADAPTCONTROLLER_SUCCESS) { + arkProcessError(ark_mem, ARK_MEM_FAIL, "ARKODE", "arkSetAdaptivityFn", + "SUNAdaptController_Destroy failure"); + return(ARK_MEM_FAIL); + } + } + ark_mem->hadapt_mem->hcontroller = NULL; + + /* Create new SUNAdaptController object depending on NULL-ity of 'hfun' */ + SUNAdaptController C = NULL; + if (hfun == NULL) { + C = SUNAdaptController_PID(ark_mem->sunctx); + if (C == NULL) { + arkProcessError(ark_mem, ARK_MEM_FAIL, "ARKODE", "arkSetAdaptivityFn", + "SUNAdaptController_PID allocation failure"); + return(ARK_MEM_FAIL); + } + } else { + C = ARKUserControl(ark_mem->sunctx, arkode_mem, hfun, h_data); + if (C == NULL) { + arkProcessError(ark_mem, ARK_MEM_FAIL, "ARKODE", "arkSetAdaptivityFn", + "ARKUserControl allocation failure"); + return(ARK_MEM_FAIL); + } + } + + /* Attach new SUNAdaptController object */ + retval = SUNAdaptController_Space(C, &lenrw, &leniw); + if (retval == SUNADAPTCONTROLLER_SUCCESS) { + ark_mem->liw += leniw; + ark_mem->lrw += lenrw; + } + ark_mem->hadapt_mem->hcontroller = C; + ark_mem->hadapt_mem->owncontroller = SUNTRUE; + + return(ARK_SUCCESS); +} + /*--------------------------------------------------------------- arkSetCFLFraction: @@ -906,11 +1249,15 @@ int arkSetErrorBias(void *arkode_mem, realtype bias) /* set allowed value, otherwise set default */ if (bias < ONE) { - hadapt_mem->bias = BIAS; + retval = SUNAdaptController_SetErrorBias(hadapt_mem->hcontroller, -1.0); } else { - hadapt_mem->bias = bias; + retval = SUNAdaptController_SetErrorBias(hadapt_mem->hcontroller, bias); } - + if (retval != SUNADAPTCONTROLLER_SUCCESS) { + arkProcessError(ark_mem, ARK_CONTROLLER_ERR, "ARKODE", + "arkSetErrorBias", "SUNAdaptController_SetErrorBias failure"); + return(ARK_CONTROLLER_ERR); + } return(ARK_SUCCESS); } @@ -1000,98 +1347,6 @@ int arkSetFixedStepBounds(void *arkode_mem, realtype lb, realtype ub) } -/*--------------------------------------------------------------- - arkSetAdaptivityMethod: - - 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. - ---------------------------------------------------------------*/ -int arkSetAdaptivityMethod(void *arkode_mem, int imethod, int idefault, - int pq, realtype adapt_params[3]) -{ - int retval; - ARKodeHAdaptMem hadapt_mem; - ARKodeMem ark_mem; - retval = arkAccessHAdaptMem(arkode_mem, "arkSetAdaptivityMethod", - &ark_mem, &hadapt_mem); - if (retval != ARK_SUCCESS) return(retval); - - /* check for allowable parameters */ - if ((imethod > ARK_ADAPT_IMEX_GUS) || (imethod < ARK_ADAPT_PID)) { - arkProcessError(ark_mem, ARK_ILL_INPUT, "ARKODE", - "arkSetAdaptivityMethod", "Illegal imethod"); - return(ARK_ILL_INPUT); - } - - /* set adaptivity method */ - hadapt_mem->imethod = imethod; - - /* set flag whether to use p (embedding, 0) or q (method, 1) order */ - hadapt_mem->pq = (pq != 0); - - /* set method parameters */ - if (idefault == 1) { - switch (hadapt_mem->imethod) { - case (ARK_ADAPT_PID): - hadapt_mem->k1 = AD0_K1; - hadapt_mem->k2 = AD0_K2; - hadapt_mem->k3 = AD0_K3; break; - case (ARK_ADAPT_PI): - hadapt_mem->k1 = AD1_K1; - hadapt_mem->k2 = AD1_K2; break; - case (ARK_ADAPT_I): - hadapt_mem->k1 = AD2_K1; break; - case (ARK_ADAPT_EXP_GUS): - hadapt_mem->k1 = AD3_K1; - hadapt_mem->k2 = AD3_K2; break; - case (ARK_ADAPT_IMP_GUS): - hadapt_mem->k1 = AD4_K1; - hadapt_mem->k2 = AD4_K2; break; - case (ARK_ADAPT_IMEX_GUS): - hadapt_mem->k1 = AD5_K1; - hadapt_mem->k2 = AD5_K2; - hadapt_mem->k3 = AD5_K3; break; - } - } else { - hadapt_mem->k1 = adapt_params[0]; - hadapt_mem->k2 = adapt_params[1]; - hadapt_mem->k3 = adapt_params[2]; - } - - return(ARK_SUCCESS); -} - - -/*--------------------------------------------------------------- - arkSetAdaptivityFn: - - Specifies the user-provided time step adaptivity function to use. - ---------------------------------------------------------------*/ -int arkSetAdaptivityFn(void *arkode_mem, ARKAdaptFn hfun, void *h_data) -{ - int retval; - ARKodeHAdaptMem hadapt_mem; - ARKodeMem ark_mem; - retval = arkAccessHAdaptMem(arkode_mem, "arkSetAdaptivityFn", - &ark_mem, &hadapt_mem); - if (retval != ARK_SUCCESS) return(retval); - - /* NULL hfun sets default, otherwise set inputs */ - if (hfun == NULL) { - hadapt_mem->HAdapt = NULL; - hadapt_mem->HAdapt_data = NULL; - hadapt_mem->imethod = ARK_ADAPT_PID; - } else { - hadapt_mem->HAdapt = hfun; - hadapt_mem->HAdapt_data = h_data; - hadapt_mem->imethod = ARK_ADAPT_CUSTOM; - } - - return(ARK_SUCCESS); -} - - /*--------------------------------------------------------------- arkSetMaxFirstGrowth: @@ -1827,6 +2082,9 @@ char *arkGetReturnFlagName(long int flag) 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; @@ -1881,6 +2139,9 @@ char *arkGetReturnFlagName(long int flag) 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; @@ -1905,12 +2166,6 @@ char *arkGetReturnFlagName(long int flag) case ARK_TOO_CLOSE: sprintf(name,"ARK_TOO_CLOSE"); 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_VECTOROP_ERR: sprintf(name,"ARK_VECTOROP_ERR"); break; @@ -1920,6 +2175,9 @@ char *arkGetReturnFlagName(long int flag) 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; @@ -1929,6 +2187,36 @@ char *arkGetReturnFlagName(long int flag) 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"); } @@ -1997,24 +2285,16 @@ int arkWriteParameters(ARKodeMem ark_mem, FILE *fp) ark_mem->hadapt_mem->etacf); fprintf(fp, " Explicit safety factor = %"RSYM"\n", ark_mem->hadapt_mem->cfl); - if (ark_mem->hadapt_mem->HAdapt == NULL) { - fprintf(fp, " Time step adaptivity method %i\n", ark_mem->hadapt_mem->imethod); - fprintf(fp, " Safety factor = %"RSYM"\n", ark_mem->hadapt_mem->safety); - fprintf(fp, " Bias factor = %"RSYM"\n", ark_mem->hadapt_mem->bias); - 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); - fprintf(fp, " k1 = %"RSYM"\n", ark_mem->hadapt_mem->k1); - fprintf(fp, " k2 = %"RSYM"\n", ark_mem->hadapt_mem->k2); - fprintf(fp, " k3 = %"RSYM"\n", ark_mem->hadapt_mem->k3); - if (ark_mem->hadapt_mem->expstab == arkExpStab) { - fprintf(fp, " Default explicit stability function\n"); - } else { - fprintf(fp, " User provided explicit stability function\n"); - } - } else { - fprintf(fp, " User provided time step adaptivity function\n"); - } + 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); diff --git a/src/arkode/arkode_user_controller.c b/src/arkode/arkode_user_controller.c new file mode 100644 index 0000000000..3bb44182cf --- /dev/null +++ b/src/arkode/arkode_user_controller.c @@ -0,0 +1,175 @@ +/* ----------------------------------------------------------------- + * Programmer(s): Daniel R. Reynolds @ SMU + * ----------------------------------------------------------------- + * SUNDIALS Copyright Start + * Copyright (c) 2002-2023, Lawrence Livermore National Security + * and Southern Methodist University. + * All rights reserved. + * + * See the top-level LICENSE and NOTICE files for details. + * + * SPDX-License-Identifier: BSD-3-Clause + * SUNDIALS Copyright End + * ----------------------------------------------------------------- + * This is the implementation file for the ARKUserControl + * SUNAdaptController module. + * -----------------------------------------------------------------*/ + +#include +#include +#include "arkode_user_controller.h" + + +/* --------------- + * Macro accessors + * --------------- */ + +#define SC_CONTENT(C) ( (ARKUserControlContent)(C->content) ) +#define SC_HP(C) ( SC_CONTENT(C)->hp ) +#define SC_HPP(C) ( SC_CONTENT(C)->hpp ) +#define SC_EP(C) ( SC_CONTENT(C)->ep ) +#define SC_EPP(C) ( SC_CONTENT(C)->epp ) +#define SC_P(C) ( SC_CONTENT(C)->p ) +#define SC_Q(C) ( SC_CONTENT(C)->q ) +#define SC_ARKMEM(C) ( SC_CONTENT(C)->ark_mem ) +#define SC_HADAPT(C) ( SC_CONTENT(C)->hadapt ) +#define SC_DATA(C) ( SC_CONTENT(C)->hadapt_data ) + + +/* ----------------------------------------------------------------- + * exported functions + * ----------------------------------------------------------------- */ + +/* ----------------------------------------------------------------- + * Function to create a new ARKUserControl controller + */ + +SUNAdaptController ARKUserControl(SUNContext sunctx, void* arkode_mem, + ARKAdaptFn hadapt, void* hadapt_data) +{ + SUNAdaptController C; + ARKUserControlContent content; + + /* Return with failure if hadapt or arkode_mem are NULL */ + if ((hadapt == NULL) || (arkode_mem == NULL)) { return (NULL); } + + /* Create an empty controller object */ + C = NULL; + C = SUNAdaptController_NewEmpty(sunctx); + if (C == NULL) { return (NULL); } + + /* Attach operations */ + C->ops->gettype = SUNAdaptController_GetType_ARKUserControl; + C->ops->estimatestep = SUNAdaptController_EstimateStep_ARKUserControl; + C->ops->reset = SUNAdaptController_Reset_ARKUserControl; + C->ops->write = SUNAdaptController_Write_ARKUserControl; + C->ops->setmethodorder = SUNAdaptController_SetMethodOrder_ARKUserControl; + C->ops->update = SUNAdaptController_Update_ARKUserControl; + C->ops->space = SUNAdaptController_Space_ARKUserControl; + + /* Create content */ + content = NULL; + content = (ARKUserControlContent)malloc(sizeof *content); + if (content == NULL) + { + (void) SUNAdaptController_Destroy(C); + return (NULL); + } + + /* Attach content */ + C->content = content; + + /* Attach ARKODE memory structure */ + content->ark_mem = (ARKodeMem) arkode_mem; + + /* Attach user-provided adaptivity function and data */ + content->hadapt = hadapt; + content->hadapt_data = hadapt_data; + + /* Initialize method and embedding orders */ + content->p = 1; + content->q = 1; + + /* Fill content with default/reset values */ + SUNAdaptController_Reset_ARKUserControl(C); + + return (C); +} + + +/* ----------------------------------------------------------------- + * implementation of controller operations + * ----------------------------------------------------------------- */ + +SUNAdaptController_Type SUNAdaptController_GetType_ARKUserControl(SUNAdaptController C) +{ return SUN_ADAPTCONTROLLER_H; } + +int SUNAdaptController_EstimateStep_ARKUserControl(SUNAdaptController C, realtype h, + realtype dsm, realtype* hnew) +{ + /* call user-provided function to compute new step */ + sunrealtype ttmp = (dsm <= ONE) ? SC_ARKMEM(C)->tn + SC_ARKMEM(C)->h : SC_ARKMEM(C)->tn; + int retval = SC_HADAPT(C)(SC_ARKMEM(C)->ycur, ttmp, h, SC_HP(C), + SC_HPP(C), dsm, SC_EP(C), SC_EPP(C), SC_Q(C), + SC_P(C), hnew, SC_DATA(C)); + if (retval != SUNADAPTCONTROLLER_SUCCESS) { return(SUNADAPTCONTROLLER_USER_FCN_FAIL); } + return SUNADAPTCONTROLLER_SUCCESS; +} + +int SUNAdaptController_Reset_ARKUserControl(SUNAdaptController C) +{ + SC_EP(C) = RCONST(1.0); + SC_EPP(C) = RCONST(1.0); + SC_HP(C) = RCONST(0.0); + SC_HPP(C) = RCONST(0.0); + return SUNADAPTCONTROLLER_SUCCESS; +} + +int SUNAdaptController_Write_ARKUserControl(SUNAdaptController C, FILE *fptr) +{ + fprintf(fptr, "ARKUserControl module:\n"); +#if defined(SUNDIALS_EXTENDED_PRECISION) + fprintf(fptr, " hp = %12Lg\n", SC_HP(C)); + fprintf(fptr, " hpp = %12Lg\n", SC_HPP(C)); + fprintf(fptr, " ep = %12Lg\n", SC_EP(C)); + fprintf(fptr, " epp = %12Lg\n", SC_EPP(C)); +#else + fprintf(fptr, " hp = %12g\n", SC_HP(C)); + fprintf(fptr, " hpp = %12g\n", SC_HPP(C)); + fprintf(fptr, " ep = %12g\n", SC_EP(C)); + fprintf(fptr, " epp = %12g\n", SC_EPP(C)); +#endif + fprintf(fptr, " p = %i\n", SC_P(C)); + fprintf(fptr, " q = %i\n", SC_Q(C)); + fprintf(fptr, " hadapt_data = %p\n", SC_DATA(C)); + return SUNADAPTCONTROLLER_SUCCESS; +} + +int SUNAdaptController_SetMethodOrder_ARKUserControl(SUNAdaptController C, int p, int q) +{ + /* check for legal input */ + if (p <= 0) { return SUNADAPTCONTROLLER_ILL_INPUT; } + if (q <= 0) { return SUNADAPTCONTROLLER_ILL_INPUT; } + + /* store value and return */ + SC_P(C) = p; + SC_Q(C) = q; + return SUNADAPTCONTROLLER_SUCCESS; +} + +int SUNAdaptController_Update_ARKUserControl(SUNAdaptController C, realtype h, realtype dsm) +{ + SC_HPP(C) = SC_HP(C); + SC_HP(C) = h; + SC_EPP(C) = SC_EP(C); + SC_EP(C) = dsm; + return SUNADAPTCONTROLLER_SUCCESS; +} + +int SUNAdaptController_Space_ARKUserControl(SUNAdaptController C, long int* lenrw, + long int* leniw) +{ + *lenrw = 4; + *leniw = 5; + return SUNADAPTCONTROLLER_SUCCESS; +} diff --git a/src/arkode/arkode_user_controller.h b/src/arkode/arkode_user_controller.h new file mode 100644 index 0000000000..9a56bc1991 --- /dev/null +++ b/src/arkode/arkode_user_controller.h @@ -0,0 +1,76 @@ +/* ----------------------------------------------------------------- + * Programmer(s): Daniel R. Reynolds @ SMU + * ----------------------------------------------------------------- + * SUNDIALS Copyright Start + * Copyright (c) 2002-2023, Lawrence Livermore National Security + * and Southern Methodist University. + * All rights reserved. + * + * See the top-level LICENSE and NOTICE files for details. + * + * SPDX-License-Identifier: BSD-3-Clause + * SUNDIALS Copyright End + * ----------------------------------------------------------------- + * This is the header file for a user-provided controller function + * SUNAdaptController module implementation. This provides backwards- + * compatibility for ARKODE's previous "ARKAdaptFn" + * -----------------------------------------------------------------*/ + +#ifndef _ARK_USERCONTROL_H +#define _ARK_USERCONTROL_H + +#include +#include +#include "arkode_impl.h" + +#ifdef __cplusplus /* wrapper to enable C++ usage */ +extern "C" { +#endif + +/* --------------------------------------------------- + * ARKUserControl implementation of SUNAdaptController + * --------------------------------------------------- */ + +struct _ARKUserControlContent { + realtype hp; /* h from previous step */ + realtype hpp; /* h from 2 steps ago */ + realtype ep; /* error from previous step */ + realtype epp; /* error from 2 steps ago */ + int p; /* embedding order of accuracy */ + int q; /* method order of accuracy */ + ARKodeMem ark_mem; /* main ARKODE memory structure */ + ARKAdaptFn hadapt; /* user-provided adaptivity fn */ + void* hadapt_data; /* user-provided data pointer */ +}; + +typedef struct _ARKUserControlContent *ARKUserControlContent; + +/* ------------------ + * Exported Functions + * ------------------ */ + +SUNDIALS_EXPORT +SUNAdaptController ARKUserControl(SUNContext sunctx, void* arkode_mem, + ARKAdaptFn hadapt, void* hadapt_data); +SUNDIALS_EXPORT +SUNAdaptController_Type SUNAdaptController_GetType_ARKUserControl(SUNAdaptController C); +SUNDIALS_EXPORT +int SUNAdaptController_EstimateStep_ARKUserControl(SUNAdaptController C, realtype h, + realtype dsm, realtype* hnew); +SUNDIALS_EXPORT +int SUNAdaptController_Reset_ARKUserControl(SUNAdaptController C); +SUNDIALS_EXPORT +int SUNAdaptController_Write_ARKUserControl(SUNAdaptController C, FILE* fptr); +SUNDIALS_EXPORT +int SUNAdaptController_SetMethodOrder_ARKUserControl(SUNAdaptController C, int p, int q); +SUNDIALS_EXPORT +int SUNAdaptController_Update_ARKUserControl(SUNAdaptController C, realtype h, realtype dsm); +SUNDIALS_EXPORT +int SUNAdaptController_Space_ARKUserControl(SUNAdaptController C, long int *lenrw, + long int *leniw); + +#ifdef __cplusplus +} +#endif + +#endif /* _ARK_USERCONTROL_H */ diff --git a/src/arkode/fmod/CMakeLists.txt b/src/arkode/fmod/CMakeLists.txt index 5ac015daf1..ffc8784929 100644 --- a/src/arkode/fmod/CMakeLists.txt +++ b/src/arkode/fmod/CMakeLists.txt @@ -33,6 +33,12 @@ sundials_add_f2003_library(sundials_farkode_mod OBJECT_LIBRARIES sundials_fgeneric_mod_obj sundials_fnvecserial_mod_obj + sundials_fsunadaptcontrollerexpgus_mod_obj + sundials_fsunadaptcontrolleri_mod_obj + sundials_fsunadaptcontrollerimexgus_mod_obj + sundials_fsunadaptcontrollerimpgus_mod_obj + sundials_fsunadaptcontrollerpi_mod_obj + sundials_fsunadaptcontrollerpid_mod_obj sundials_fsunmatrixband_mod_obj sundials_fsunmatrixdense_mod_obj sundials_fsunmatrixsparse_mod_obj diff --git a/src/arkode/fmod/farkode_arkstep_mod.c b/src/arkode/fmod/farkode_arkstep_mod.c index 2ae77231a3..e8d6376eac 100644 --- a/src/arkode/fmod/farkode_arkstep_mod.c +++ b/src/arkode/fmod/farkode_arkstep_mod.c @@ -685,6 +685,20 @@ SWIGEXPORT int _wrap_FARKStepSetTableName(void *farg1, SwigArrayWrapper *farg2, } +SWIGEXPORT int _wrap_FARKStepSetAdaptController(void *farg1, SUNAdaptController farg2) { + int fresult ; + void *arg1 = (void *) 0 ; + SUNAdaptController arg2 = (SUNAdaptController) 0 ; + int result; + + arg1 = (void *)(farg1); + arg2 = (SUNAdaptController)(farg2); + result = (int)ARKStepSetAdaptController(arg1,arg2); + fresult = (int)(result); + return fresult; +} + + SWIGEXPORT int _wrap_FARKStepSetCFLFraction(void *farg1, double const *farg2) { 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 c52006c929..04c72689b9 100644 --- a/src/arkode/fmod/farkode_arkstep_mod.f90 +++ b/src/arkode/fmod/farkode_arkstep_mod.f90 @@ -34,6 +34,7 @@ module farkode_arkstep_mod use fsundials_context_mod use fsundials_types_mod use fsundials_nonlinearsolver_mod + use fsundials_adaptcontroller_mod use fsundials_types_mod implicit none private @@ -91,6 +92,7 @@ module farkode_arkstep_mod integer(C_SIZE_T), public :: size = 0 end type public :: FARKStepSetTableName + public :: FARKStepSetAdaptController public :: FARKStepSetCFLFraction public :: FARKStepSetSafetyFactor public :: FARKStepSetErrorBias @@ -518,6 +520,15 @@ function swigc_FARKStepSetTableName(farg1, farg2, farg3) & integer(C_INT) :: fresult end function +function swigc_FARKStepSetAdaptController(farg1, farg2) & +bind(C, name="_wrap_FARKStepSetAdaptController") & +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_FARKStepSetCFLFraction(farg1, farg2) & bind(C, name="_wrap_FARKStepSetCFLFraction") & result(fresult) @@ -2345,6 +2356,22 @@ function FARKStepSetTableName(arkode_mem, itable, etable) & swig_result = fresult end function +function FARKStepSetAdaptController(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_FARKStepSetAdaptController(farg1, farg2) +swig_result = fresult +end function + function FARKStepSetCFLFraction(arkode_mem, cfl_frac) & 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 46836ba780..ab05b80df8 100644 --- a/src/arkode/fmod/farkode_erkstep_mod.c +++ b/src/arkode/fmod/farkode_erkstep_mod.c @@ -479,6 +479,20 @@ SWIGEXPORT int _wrap_FERKStepSetTableName(void *farg1, SwigArrayWrapper *farg2) } +SWIGEXPORT int _wrap_FERKStepSetAdaptController(void *farg1, SUNAdaptController farg2) { + int fresult ; + void *arg1 = (void *) 0 ; + SUNAdaptController arg2 = (SUNAdaptController) 0 ; + int result; + + arg1 = (void *)(farg1); + arg2 = (SUNAdaptController)(farg2); + result = (int)ERKStepSetAdaptController(arg1,arg2); + fresult = (int)(result); + return fresult; +} + + SWIGEXPORT int _wrap_FERKStepSetCFLFraction(void *farg1, double const *farg2) { 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 3857ac1a7d..208a84bdbc 100644 --- a/src/arkode/fmod/farkode_erkstep_mod.f90 +++ b/src/arkode/fmod/farkode_erkstep_mod.f90 @@ -34,6 +34,7 @@ module farkode_erkstep_mod use fsundials_context_mod use fsundials_types_mod use fsundials_nonlinearsolver_mod + use fsundials_adaptcontroller_mod use fsundials_types_mod implicit none private @@ -65,6 +66,7 @@ module farkode_erkstep_mod integer(C_SIZE_T), public :: size = 0 end type public :: FERKStepSetTableName + public :: FERKStepSetAdaptController public :: FERKStepSetCFLFraction public :: FERKStepSetSafetyFactor public :: FERKStepSetErrorBias @@ -300,6 +302,15 @@ function swigc_FERKStepSetTableName(farg1, farg2) & integer(C_INT) :: fresult end function +function swigc_FERKStepSetAdaptController(farg1, farg2) & +bind(C, name="_wrap_FERKStepSetAdaptController") & +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_FERKStepSetCFLFraction(farg1, farg2) & bind(C, name="_wrap_FERKStepSetCFLFraction") & result(fresult) @@ -1319,6 +1330,22 @@ function FERKStepSetTableName(arkode_mem, etable) & swig_result = fresult end function +function FERKStepSetAdaptController(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_FERKStepSetAdaptController(farg1, farg2) +swig_result = fresult +end function + function FERKStepSetCFLFraction(arkode_mem, cfl_frac) & result(swig_result) use, intrinsic :: ISO_C_BINDING diff --git a/src/arkode/fmod/farkode_mod.f90 b/src/arkode/fmod/farkode_mod.f90 index 5ca5dcc9f2..e8c3b9dbd2 100644 --- a/src/arkode/fmod/farkode_mod.f90 +++ b/src/arkode/fmod/farkode_mod.f90 @@ -33,6 +33,7 @@ module farkode_mod use fsundials_context_mod use fsundials_types_mod use fsundials_nonlinearsolver_mod + use fsundials_adaptcontroller_mod use fsundials_types_mod implicit none private @@ -104,6 +105,7 @@ module farkode_mod integer(C_INT), parameter, public :: ARK_RELAX_MEM_NULL = -44_C_INT 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_UNRECOGNIZED_ERROR = -99_C_INT ! typedef enum ARKRelaxSolver enum, bind(c) diff --git a/src/arkode/fmod/farkode_mristep_mod.f90 b/src/arkode/fmod/farkode_mristep_mod.f90 index b80ca727f8..6db939a4b7 100644 --- a/src/arkode/fmod/farkode_mristep_mod.f90 +++ b/src/arkode/fmod/farkode_mristep_mod.f90 @@ -34,6 +34,7 @@ module farkode_mristep_mod use fsundials_context_mod use fsundials_types_mod use fsundials_nonlinearsolver_mod + use fsundials_adaptcontroller_mod use fsundials_types_mod implicit none private diff --git a/src/arkode/fmod/farkode_sprkstep_mod.f90 b/src/arkode/fmod/farkode_sprkstep_mod.f90 index ad9795aba2..7598cdc481 100644 --- a/src/arkode/fmod/farkode_sprkstep_mod.f90 +++ b/src/arkode/fmod/farkode_sprkstep_mod.f90 @@ -34,6 +34,7 @@ module farkode_sprkstep_mod use fsundials_context_mod use fsundials_types_mod use fsundials_nonlinearsolver_mod + use fsundials_adaptcontroller_mod use fsundials_types_mod implicit none private diff --git a/src/sunadaptcontroller/CMakeLists.txt b/src/sunadaptcontroller/CMakeLists.txt new file mode 100644 index 0000000000..f24d46456e --- /dev/null +++ b/src/sunadaptcontroller/CMakeLists.txt @@ -0,0 +1,23 @@ +# ------------------------------------------------------------------------------ +# Programmer(s): Daniel R. Reynolds @ SMU +# ------------------------------------------------------------------------------ +# SUNDIALS Copyright Start +# Copyright (c) 2002-2023, 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 +# ------------------------------------------------------------------------------ +# controller level CMakeLists.txt for SUNDIALS +# ------------------------------------------------------------------------------ + +# required native matrices +add_subdirectory(expgus) +add_subdirectory(i) +add_subdirectory(imexgus) +add_subdirectory(impgus) +add_subdirectory(pi) +add_subdirectory(pid) diff --git a/src/sunadaptcontroller/expgus/CMakeLists.txt b/src/sunadaptcontroller/expgus/CMakeLists.txt new file mode 100644 index 0000000000..f4a38aae0d --- /dev/null +++ b/src/sunadaptcontroller/expgus/CMakeLists.txt @@ -0,0 +1,29 @@ +# --------------------------------------------------------------- +# Programmer(s): Daniel R. Reynolds @ SMU +# --------------------------------------------------------------- +# SUNDIALS Copyright Start +# Copyright (c) 2002-2023, 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 +# --------------------------------------------------------------- + +# Create a library out of the generic sundials modules +sundials_add_library(sundials_sunadaptcontrollerexpgus + SOURCES + sunadaptcontroller_expgus.c + HEADERS + ${SUNDIALS_SOURCE_DIR}/include/sunadaptcontroller/sunadaptcontroller_expgus.h + INCLUDE_SUBDIR + sunadaptcontroller + OBJECT_LIB_ONLY +) + +# Add F2003 module if the interface is enabled +if(BUILD_FORTRAN_MODULE_INTERFACE) + add_subdirectory(fmod) +endif() diff --git a/src/sunadaptcontroller/expgus/fmod/CMakeLists.txt b/src/sunadaptcontroller/expgus/fmod/CMakeLists.txt new file mode 100644 index 0000000000..a8edd5426d --- /dev/null +++ b/src/sunadaptcontroller/expgus/fmod/CMakeLists.txt @@ -0,0 +1,25 @@ +# --------------------------------------------------------------- +# Programmer(s): Daniel R. Reynolds @ SMU +# --------------------------------------------------------------- +# SUNDIALS Copyright Start +# Copyright (c) 2002-2023, 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 +# --------------------------------------------------------------- + +sundials_add_f2003_library(sundials_fsunadaptcontrollerexpgus_mod + SOURCES + fsunadaptcontroller_expgus_mod.f90 fsunadaptcontroller_expgus_mod.c + OBJECT_LIBRARIES + sundials_fgeneric_mod_obj + OUTPUT_NAME + sundials_fsunadaptcontrollerexpgus_mod + OBJECT_LIB_ONLY +) + +message(STATUS "Added SUNAdaptController_ExpGus F2003 interface") diff --git a/src/sunadaptcontroller/expgus/fmod/fsunadaptcontroller_expgus_mod.c b/src/sunadaptcontroller/expgus/fmod/fsunadaptcontroller_expgus_mod.c new file mode 100644 index 0000000000..f250325302 --- /dev/null +++ b/src/sunadaptcontroller/expgus/fmod/fsunadaptcontroller_expgus_mod.c @@ -0,0 +1,385 @@ +/* ---------------------------------------------------------------------------- + * This file was automatically generated by SWIG (http://www.swig.org). + * Version 4.0.0 + * + * This file is not intended to be easily readable and contains a number of + * coding conventions designed to improve portability and efficiency. Do not make + * changes to this file unless you know what you are doing--modify the SWIG + * interface file instead. + * ----------------------------------------------------------------------------- */ + +/* --------------------------------------------------------------- + * Programmer(s): Auto-generated by swig. + * --------------------------------------------------------------- + * SUNDIALS Copyright Start + * Copyright (c) 2002-2023, Lawrence Livermore National Security + * and Southern Methodist University. + * All rights reserved. + * + * See the top-level LICENSE and NOTICE files for details. + * + * SPDX-License-Identifier: BSD-3-Clause + * SUNDIALS Copyright End + * -------------------------------------------------------------*/ + +/* ----------------------------------------------------------------------------- + * This section contains generic SWIG labels for method/variable + * declarations/attributes, and other compiler dependent labels. + * ----------------------------------------------------------------------------- */ + +/* template workaround for compilers that cannot correctly implement the C++ standard */ +#ifndef SWIGTEMPLATEDISAMBIGUATOR +# if defined(__SUNPRO_CC) && (__SUNPRO_CC <= 0x560) +# define SWIGTEMPLATEDISAMBIGUATOR template +# elif defined(__HP_aCC) +/* Needed even with `aCC -AA' when `aCC -V' reports HP ANSI C++ B3910B A.03.55 */ +/* If we find a maximum version that requires this, the test would be __HP_aCC <= 35500 for A.03.55 */ +# define SWIGTEMPLATEDISAMBIGUATOR template +# else +# define SWIGTEMPLATEDISAMBIGUATOR +# endif +#endif + +/* inline attribute */ +#ifndef SWIGINLINE +# if defined(__cplusplus) || (defined(__GNUC__) && !defined(__STRICT_ANSI__)) +# define SWIGINLINE inline +# else +# define SWIGINLINE +# endif +#endif + +/* attribute recognised by some compilers to avoid 'unused' warnings */ +#ifndef SWIGUNUSED +# if defined(__GNUC__) +# if !(defined(__cplusplus)) || (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)) +# define SWIGUNUSED __attribute__ ((__unused__)) +# else +# define SWIGUNUSED +# endif +# elif defined(__ICC) +# define SWIGUNUSED __attribute__ ((__unused__)) +# else +# define SWIGUNUSED +# endif +#endif + +#ifndef SWIG_MSC_UNSUPPRESS_4505 +# if defined(_MSC_VER) +# pragma warning(disable : 4505) /* unreferenced local function has been removed */ +# endif +#endif + +#ifndef SWIGUNUSEDPARM +# ifdef __cplusplus +# define SWIGUNUSEDPARM(p) +# else +# define SWIGUNUSEDPARM(p) p SWIGUNUSED +# endif +#endif + +/* internal SWIG method */ +#ifndef SWIGINTERN +# define SWIGINTERN static SWIGUNUSED +#endif + +/* internal inline SWIG method */ +#ifndef SWIGINTERNINLINE +# define SWIGINTERNINLINE SWIGINTERN SWIGINLINE +#endif + +/* qualifier for exported *const* global data variables*/ +#ifndef SWIGEXTERN +# ifdef __cplusplus +# define SWIGEXTERN extern +# else +# define SWIGEXTERN +# endif +#endif + +/* exporting methods */ +#if defined(__GNUC__) +# if (__GNUC__ >= 4) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) +# ifndef GCC_HASCLASSVISIBILITY +# define GCC_HASCLASSVISIBILITY +# endif +# endif +#endif + +#ifndef SWIGEXPORT +# if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__) +# if defined(STATIC_LINKED) +# define SWIGEXPORT +# else +# define SWIGEXPORT __declspec(dllexport) +# endif +# else +# if defined(__GNUC__) && defined(GCC_HASCLASSVISIBILITY) +# define SWIGEXPORT __attribute__ ((visibility("default"))) +# else +# define SWIGEXPORT +# endif +# endif +#endif + +/* calling conventions for Windows */ +#ifndef SWIGSTDCALL +# if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__) +# define SWIGSTDCALL __stdcall +# else +# define SWIGSTDCALL +# endif +#endif + +/* Deal with Microsoft's attempt at deprecating C standard runtime functions */ +#if !defined(SWIG_NO_CRT_SECURE_NO_DEPRECATE) && defined(_MSC_VER) && !defined(_CRT_SECURE_NO_DEPRECATE) +# define _CRT_SECURE_NO_DEPRECATE +#endif + +/* Deal with Microsoft's attempt at deprecating methods in the standard C++ library */ +#if !defined(SWIG_NO_SCL_SECURE_NO_DEPRECATE) && defined(_MSC_VER) && !defined(_SCL_SECURE_NO_DEPRECATE) +# define _SCL_SECURE_NO_DEPRECATE +#endif + +/* Deal with Apple's deprecated 'AssertMacros.h' from Carbon-framework */ +#if defined(__APPLE__) && !defined(__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES) +# define __ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES 0 +#endif + +/* Intel's compiler complains if a variable which was never initialised is + * cast to void, which is a common idiom which we use to indicate that we + * are aware a variable isn't used. So we just silence that warning. + * See: https://github.com/swig/swig/issues/192 for more discussion. + */ +#ifdef __INTEL_COMPILER +# pragma warning disable 592 +#endif + +/* Errors in SWIG */ +#define SWIG_UnknownError -1 +#define SWIG_IOError -2 +#define SWIG_RuntimeError -3 +#define SWIG_IndexError -4 +#define SWIG_TypeError -5 +#define SWIG_DivisionByZero -6 +#define SWIG_OverflowError -7 +#define SWIG_SyntaxError -8 +#define SWIG_ValueError -9 +#define SWIG_SystemError -10 +#define SWIG_AttributeError -11 +#define SWIG_MemoryError -12 +#define SWIG_NullReferenceError -13 + + + + +#include +#define SWIG_exception_impl(DECL, CODE, MSG, RETURNNULL) \ + { printf("In " DECL ": " MSG); assert(0); RETURNNULL; } + + +#include +#if defined(_MSC_VER) || defined(__BORLANDC__) || defined(_WATCOM) +# ifndef snprintf +# define snprintf _snprintf +# endif +#endif + + +/* Support for the `contract` feature. + * + * Note that RETURNNULL is first because it's inserted via a 'Replaceall' in + * the fortran.cxx file. + */ +#define SWIG_contract_assert(RETURNNULL, EXPR, MSG) \ + if (!(EXPR)) { SWIG_exception_impl("$decl", SWIG_ValueError, MSG, RETURNNULL); } + + +#define SWIGVERSION 0x040000 +#define SWIG_VERSION SWIGVERSION + + +#define SWIG_as_voidptr(a) (void *)((const void *)(a)) +#define SWIG_as_voidptrptr(a) ((void)SWIG_as_voidptr(*a),(void**)(a)) + + +#include "sundials/sundials_adaptcontroller.h" + + +#include "sunadaptcontroller/sunadaptcontroller_expgus.h" + +SWIGEXPORT SUNAdaptController _wrap_FSUNAdaptController_ExpGus(void *farg1) { + SUNAdaptController fresult ; + SUNContext arg1 = (SUNContext) 0 ; + SUNAdaptController result; + + arg1 = (SUNContext)(farg1); + result = (SUNAdaptController)SUNAdaptController_ExpGus(arg1); + fresult = result; + return fresult; +} + + +SWIGEXPORT int _wrap_FSUNAdaptController_SetParams_ExpGus(SUNAdaptController farg1, int const *farg2, double const *farg3, double const *farg4) { + int fresult ; + SUNAdaptController arg1 = (SUNAdaptController) 0 ; + int arg2 ; + sunrealtype arg3 ; + sunrealtype arg4 ; + int result; + + arg1 = (SUNAdaptController)(farg1); + arg2 = (int)(*farg2); + arg3 = (sunrealtype)(*farg3); + arg4 = (sunrealtype)(*farg4); + result = (int)SUNAdaptController_SetParams_ExpGus(arg1,arg2,arg3,arg4); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FSUNAdaptController_GetType_ExpGus(SUNAdaptController farg1) { + int fresult ; + SUNAdaptController arg1 = (SUNAdaptController) 0 ; + SUNAdaptController_Type result; + + arg1 = (SUNAdaptController)(farg1); + result = (SUNAdaptController_Type)SUNAdaptController_GetType_ExpGus(arg1); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FSUNAdaptController_EstimateStep_ExpGus(SUNAdaptController farg1, double const *farg2, double const *farg3, double *farg4) { + int fresult ; + SUNAdaptController arg1 = (SUNAdaptController) 0 ; + sunrealtype arg2 ; + sunrealtype arg3 ; + sunrealtype *arg4 = (sunrealtype *) 0 ; + int result; + + arg1 = (SUNAdaptController)(farg1); + arg2 = (sunrealtype)(*farg2); + arg3 = (sunrealtype)(*farg3); + arg4 = (sunrealtype *)(farg4); + result = (int)SUNAdaptController_EstimateStep_ExpGus(arg1,arg2,arg3,arg4); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FSUNAdaptController_Reset_ExpGus(SUNAdaptController farg1) { + int fresult ; + SUNAdaptController arg1 = (SUNAdaptController) 0 ; + int result; + + arg1 = (SUNAdaptController)(farg1); + result = (int)SUNAdaptController_Reset_ExpGus(arg1); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FSUNAdaptController_SetDefaults_ExpGus(SUNAdaptController farg1) { + int fresult ; + SUNAdaptController arg1 = (SUNAdaptController) 0 ; + int result; + + arg1 = (SUNAdaptController)(farg1); + result = (int)SUNAdaptController_SetDefaults_ExpGus(arg1); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FSUNAdaptController_Write_ExpGus(SUNAdaptController farg1, void *farg2) { + int fresult ; + SUNAdaptController arg1 = (SUNAdaptController) 0 ; + FILE *arg2 = (FILE *) 0 ; + int result; + + arg1 = (SUNAdaptController)(farg1); + arg2 = (FILE *)(farg2); + result = (int)SUNAdaptController_Write_ExpGus(arg1,arg2); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FSUNAdaptController_SetMethodOrder_ExpGus(SUNAdaptController farg1, int const *farg2, int const *farg3) { + int fresult ; + SUNAdaptController arg1 = (SUNAdaptController) 0 ; + int arg2 ; + int arg3 ; + int result; + + arg1 = (SUNAdaptController)(farg1); + arg2 = (int)(*farg2); + arg3 = (int)(*farg3); + result = (int)SUNAdaptController_SetMethodOrder_ExpGus(arg1,arg2,arg3); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FSUNAdaptController_AdjustControllerOrder_ExpGus(SUNAdaptController farg1, int const *farg2) { + int fresult ; + SUNAdaptController arg1 = (SUNAdaptController) 0 ; + int arg2 ; + int result; + + arg1 = (SUNAdaptController)(farg1); + arg2 = (int)(*farg2); + result = (int)SUNAdaptController_AdjustControllerOrder_ExpGus(arg1,arg2); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FSUNAdaptController_SetErrorBias_ExpGus(SUNAdaptController farg1, double const *farg2) { + int fresult ; + SUNAdaptController arg1 = (SUNAdaptController) 0 ; + sunrealtype arg2 ; + int result; + + arg1 = (SUNAdaptController)(farg1); + arg2 = (sunrealtype)(*farg2); + result = (int)SUNAdaptController_SetErrorBias_ExpGus(arg1,arg2); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FSUNAdaptController_Update_ExpGus(SUNAdaptController farg1, double const *farg2, double const *farg3) { + int fresult ; + SUNAdaptController arg1 = (SUNAdaptController) 0 ; + sunrealtype arg2 ; + sunrealtype arg3 ; + int result; + + arg1 = (SUNAdaptController)(farg1); + arg2 = (sunrealtype)(*farg2); + arg3 = (sunrealtype)(*farg3); + result = (int)SUNAdaptController_Update_ExpGus(arg1,arg2,arg3); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FSUNAdaptController_Space_ExpGus(SUNAdaptController farg1, long *farg2, long *farg3) { + int fresult ; + SUNAdaptController arg1 = (SUNAdaptController) 0 ; + long *arg2 = (long *) 0 ; + long *arg3 = (long *) 0 ; + int result; + + arg1 = (SUNAdaptController)(farg1); + arg2 = (long *)(farg2); + arg3 = (long *)(farg3); + result = (int)SUNAdaptController_Space_ExpGus(arg1,arg2,arg3); + fresult = (int)(result); + return fresult; +} + + + diff --git a/src/sunadaptcontroller/expgus/fmod/fsunadaptcontroller_expgus_mod.f90 b/src/sunadaptcontroller/expgus/fmod/fsunadaptcontroller_expgus_mod.f90 new file mode 100644 index 0000000000..83d23f1c51 --- /dev/null +++ b/src/sunadaptcontroller/expgus/fmod/fsunadaptcontroller_expgus_mod.f90 @@ -0,0 +1,363 @@ +! This file was automatically generated by SWIG (http://www.swig.org). +! Version 4.0.0 +! +! Do not make changes to this file unless you know what you are doing--modify +! the SWIG interface file instead. + +! --------------------------------------------------------------- +! Programmer(s): Auto-generated by swig. +! --------------------------------------------------------------- +! SUNDIALS Copyright Start +! Copyright (c) 2002-2023, 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 +! --------------------------------------------------------------- + +module fsunadaptcontroller_expgus_mod + use, intrinsic :: ISO_C_BINDING + use fsundials_adaptcontroller_mod + use fsundials_types_mod + use fsundials_context_mod + implicit none + private + + ! DECLARATION CONSTRUCTS + public :: FSUNAdaptController_ExpGus + public :: FSUNAdaptController_SetParams_ExpGus + public :: FSUNAdaptController_GetType_ExpGus + public :: FSUNAdaptController_EstimateStep_ExpGus + public :: FSUNAdaptController_Reset_ExpGus + public :: FSUNAdaptController_SetDefaults_ExpGus + public :: FSUNAdaptController_Write_ExpGus + public :: FSUNAdaptController_SetMethodOrder_ExpGus + public :: FSUNAdaptController_AdjustControllerOrder_ExpGus + public :: FSUNAdaptController_SetErrorBias_ExpGus + public :: FSUNAdaptController_Update_ExpGus + public :: FSUNAdaptController_Space_ExpGus + +! WRAPPER DECLARATIONS +interface +function swigc_FSUNAdaptController_ExpGus(farg1) & +bind(C, name="_wrap_FSUNAdaptController_ExpGus") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +type(C_PTR), value :: farg1 +type(C_PTR) :: fresult +end function + +function swigc_FSUNAdaptController_SetParams_ExpGus(farg1, farg2, farg3, farg4) & +bind(C, name="_wrap_FSUNAdaptController_SetParams_ExpGus") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +type(C_PTR), value :: farg1 +integer(C_INT), intent(in) :: farg2 +real(C_DOUBLE), intent(in) :: farg3 +real(C_DOUBLE), intent(in) :: farg4 +integer(C_INT) :: fresult +end function + +function swigc_FSUNAdaptController_GetType_ExpGus(farg1) & +bind(C, name="_wrap_FSUNAdaptController_GetType_ExpGus") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +type(C_PTR), value :: farg1 +integer(C_INT) :: fresult +end function + +function swigc_FSUNAdaptController_EstimateStep_ExpGus(farg1, farg2, farg3, farg4) & +bind(C, name="_wrap_FSUNAdaptController_EstimateStep_ExpGus") & +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_PTR), value :: farg4 +integer(C_INT) :: fresult +end function + +function swigc_FSUNAdaptController_Reset_ExpGus(farg1) & +bind(C, name="_wrap_FSUNAdaptController_Reset_ExpGus") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +type(C_PTR), value :: farg1 +integer(C_INT) :: fresult +end function + +function swigc_FSUNAdaptController_SetDefaults_ExpGus(farg1) & +bind(C, name="_wrap_FSUNAdaptController_SetDefaults_ExpGus") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +type(C_PTR), value :: farg1 +integer(C_INT) :: fresult +end function + +function swigc_FSUNAdaptController_Write_ExpGus(farg1, farg2) & +bind(C, name="_wrap_FSUNAdaptController_Write_ExpGus") & +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_FSUNAdaptController_SetMethodOrder_ExpGus(farg1, farg2, farg3) & +bind(C, name="_wrap_FSUNAdaptController_SetMethodOrder_ExpGus") & +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_FSUNAdaptController_AdjustControllerOrder_ExpGus(farg1, farg2) & +bind(C, name="_wrap_FSUNAdaptController_AdjustControllerOrder_ExpGus") & +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_FSUNAdaptController_SetErrorBias_ExpGus(farg1, farg2) & +bind(C, name="_wrap_FSUNAdaptController_SetErrorBias_ExpGus") & +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_FSUNAdaptController_Update_ExpGus(farg1, farg2, farg3) & +bind(C, name="_wrap_FSUNAdaptController_Update_ExpGus") & +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_FSUNAdaptController_Space_ExpGus(farg1, farg2, farg3) & +bind(C, name="_wrap_FSUNAdaptController_Space_ExpGus") & +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 + +end interface + + +contains + ! MODULE SUBPROGRAMS +function FSUNAdaptController_ExpGus(sunctx) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +type(SUNAdaptController), pointer :: swig_result +type(C_PTR) :: sunctx +type(C_PTR) :: fresult +type(C_PTR) :: farg1 + +farg1 = sunctx +fresult = swigc_FSUNAdaptController_ExpGus(farg1) +call c_f_pointer(fresult, swig_result) +end function + +function FSUNAdaptController_SetParams_ExpGus(c, pq, k1, k2) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(SUNAdaptController), target, intent(inout) :: c +integer(C_INT), intent(in) :: pq +real(C_DOUBLE), intent(in) :: k1 +real(C_DOUBLE), intent(in) :: k2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +integer(C_INT) :: farg2 +real(C_DOUBLE) :: farg3 +real(C_DOUBLE) :: farg4 + +farg1 = c_loc(c) +farg2 = pq +farg3 = k1 +farg4 = k2 +fresult = swigc_FSUNAdaptController_SetParams_ExpGus(farg1, farg2, farg3, farg4) +swig_result = fresult +end function + +function FSUNAdaptController_GetType_ExpGus(c) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(SUNAdaptController_Type) :: swig_result +type(SUNAdaptController), target, intent(inout) :: c +integer(C_INT) :: fresult +type(C_PTR) :: farg1 + +farg1 = c_loc(c) +fresult = swigc_FSUNAdaptController_GetType_ExpGus(farg1) +swig_result = fresult +end function + +function FSUNAdaptController_EstimateStep_ExpGus(c, h, dsm, hnew) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(SUNAdaptController), target, intent(inout) :: c +real(C_DOUBLE), intent(in) :: h +real(C_DOUBLE), intent(in) :: dsm +real(C_DOUBLE), target, intent(inout) :: hnew +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +real(C_DOUBLE) :: farg2 +real(C_DOUBLE) :: farg3 +type(C_PTR) :: farg4 + +farg1 = c_loc(c) +farg2 = h +farg3 = dsm +farg4 = c_loc(hnew) +fresult = swigc_FSUNAdaptController_EstimateStep_ExpGus(farg1, farg2, farg3, farg4) +swig_result = fresult +end function + +function FSUNAdaptController_Reset_ExpGus(c) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(SUNAdaptController), target, intent(inout) :: c +integer(C_INT) :: fresult +type(C_PTR) :: farg1 + +farg1 = c_loc(c) +fresult = swigc_FSUNAdaptController_Reset_ExpGus(farg1) +swig_result = fresult +end function + +function FSUNAdaptController_SetDefaults_ExpGus(c) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(SUNAdaptController), target, intent(inout) :: c +integer(C_INT) :: fresult +type(C_PTR) :: farg1 + +farg1 = c_loc(c) +fresult = swigc_FSUNAdaptController_SetDefaults_ExpGus(farg1) +swig_result = fresult +end function + +function FSUNAdaptController_Write_ExpGus(c, fptr) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(SUNAdaptController), target, intent(inout) :: c +type(C_PTR) :: fptr +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 + +farg1 = c_loc(c) +farg2 = fptr +fresult = swigc_FSUNAdaptController_Write_ExpGus(farg1, farg2) +swig_result = fresult +end function + +function FSUNAdaptController_SetMethodOrder_ExpGus(c, p, q) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(SUNAdaptController), target, intent(inout) :: c +integer(C_INT), intent(in) :: p +integer(C_INT), intent(in) :: q +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +integer(C_INT) :: farg2 +integer(C_INT) :: farg3 + +farg1 = c_loc(c) +farg2 = p +farg3 = q +fresult = swigc_FSUNAdaptController_SetMethodOrder_ExpGus(farg1, farg2, farg3) +swig_result = fresult +end function + +function FSUNAdaptController_AdjustControllerOrder_ExpGus(c, adj) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(SUNAdaptController), target, intent(inout) :: c +integer(C_INT), intent(in) :: adj +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +integer(C_INT) :: farg2 + +farg1 = c_loc(c) +farg2 = adj +fresult = swigc_FSUNAdaptController_AdjustControllerOrder_ExpGus(farg1, farg2) +swig_result = fresult +end function + +function FSUNAdaptController_SetErrorBias_ExpGus(c, bias) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(SUNAdaptController), target, intent(inout) :: c +real(C_DOUBLE), intent(in) :: bias +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +real(C_DOUBLE) :: farg2 + +farg1 = c_loc(c) +farg2 = bias +fresult = swigc_FSUNAdaptController_SetErrorBias_ExpGus(farg1, farg2) +swig_result = fresult +end function + +function FSUNAdaptController_Update_ExpGus(c, h, dsm) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(SUNAdaptController), target, intent(inout) :: c +real(C_DOUBLE), intent(in) :: h +real(C_DOUBLE), intent(in) :: dsm +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +real(C_DOUBLE) :: farg2 +real(C_DOUBLE) :: farg3 + +farg1 = c_loc(c) +farg2 = h +farg3 = dsm +fresult = swigc_FSUNAdaptController_Update_ExpGus(farg1, farg2, farg3) +swig_result = fresult +end function + +function FSUNAdaptController_Space_ExpGus(c, lenrw, leniw) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(SUNAdaptController), target, intent(inout) :: c +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 = c_loc(c) +farg2 = c_loc(lenrw(1)) +farg3 = c_loc(leniw(1)) +fresult = swigc_FSUNAdaptController_Space_ExpGus(farg1, farg2, farg3) +swig_result = fresult +end function + + +end module diff --git a/src/sunadaptcontroller/expgus/sunadaptcontroller_expgus.c b/src/sunadaptcontroller/expgus/sunadaptcontroller_expgus.c new file mode 100644 index 0000000000..c9617444c1 --- /dev/null +++ b/src/sunadaptcontroller/expgus/sunadaptcontroller_expgus.c @@ -0,0 +1,253 @@ +/* ----------------------------------------------------------------- + * Programmer(s): Daniel R. Reynolds @ SMU + * ----------------------------------------------------------------- + * SUNDIALS Copyright Start + * Copyright (c) 2002-2023, Lawrence Livermore National Security + * and Southern Methodist University. + * All rights reserved. + * + * See the top-level LICENSE and NOTICE files for details. + * + * SPDX-License-Identifier: BSD-3-Clause + * SUNDIALS Copyright End + * ----------------------------------------------------------------- + * This is the implementation file for the SUNAdaptController_ExpGus + * module. + * -----------------------------------------------------------------*/ + +#include +#include +#include +#include + + +/* --------------- + * Macro accessors + * --------------- */ + +#define SACEXPGUS_CONTENT(C) ( (SUNAdaptControllerContent_ExpGus)(C->content) ) +#define SACEXPGUS_K1(C) ( SACEXPGUS_CONTENT(C)->k1 ) +#define SACEXPGUS_K2(C) ( SACEXPGUS_CONTENT(C)->k2 ) +#define SACEXPGUS_BIAS(C) ( SACEXPGUS_CONTENT(C)->bias ) +#define SACEXPGUS_EP(C) ( SACEXPGUS_CONTENT(C)->ep ) +#define SACEXPGUS_P(C) ( SACEXPGUS_CONTENT(C)->p ) +#define SACEXPGUS_PQ(C) ( SACEXPGUS_CONTENT(C)->pq ) +#define SACEXPGUS_ADJ(C) ( SACEXPGUS_CONTENT(C)->adj ) +#define SACEXPGUS_FIRSTSTEP(C) ( SACEXPGUS_CONTENT(C)->firststep ) + +/* ------------------ + * Default parameters + * ------------------ */ + +#define DEFAULT_K1 RCONST(0.367) +#define DEFAULT_K2 RCONST(0.268) +#define DEFAULT_BIAS RCONST(1.5) +#define DEFAULT_PQ 0 +#define DEFAULT_ADJ -1 +/* #define DEFAULT_PQ -1 */ +/* #define DEFAULT_ADJ 0 */ +#define TINY RCONST(1.0e-10) + + +/* ----------------------------------------------------------------- + * exported functions + * ----------------------------------------------------------------- */ + +/* ----------------------------------------------------------------- + * Function to create a new ExpGus controller + */ + +SUNAdaptController SUNAdaptController_ExpGus(SUNContext sunctx) +{ + SUNAdaptController C; + SUNAdaptControllerContent_ExpGus content; + + /* Create an empty controller object */ + C = NULL; + C = SUNAdaptController_NewEmpty(sunctx); + if (C == NULL) { return (NULL); } + + /* Attach operations */ + C->ops->gettype = SUNAdaptController_GetType_ExpGus; + C->ops->estimatestep = SUNAdaptController_EstimateStep_ExpGus; + C->ops->reset = SUNAdaptController_Reset_ExpGus; + C->ops->setdefaults = SUNAdaptController_SetDefaults_ExpGus; + C->ops->write = SUNAdaptController_Write_ExpGus; + C->ops->setmethodorder = SUNAdaptController_SetMethodOrder_ExpGus; + C->ops->adjustcontrollerorder = SUNAdaptController_AdjustControllerOrder_ExpGus; + C->ops->seterrorbias = SUNAdaptController_SetErrorBias_ExpGus; + C->ops->update = SUNAdaptController_Update_ExpGus; + C->ops->space = SUNAdaptController_Space_ExpGus; + + /* Create content */ + content = NULL; + content = (SUNAdaptControllerContent_ExpGus)malloc(sizeof *content); + if (content == NULL) + { + (void) SUNAdaptController_Destroy(C); + return (NULL); + } + + /* Attach content */ + C->content = content; + + /* Initialize method order */ + content->p = 1; + + /* Fill content with default/reset values */ + SUNAdaptController_SetDefaults_ExpGus(C); + SUNAdaptController_Reset_ExpGus(C); + + return (C); +} + +/* ----------------------------------------------------------------- + * Function to set ExpGus parameters + */ + +int SUNAdaptController_SetParams_ExpGus(SUNAdaptController C, int pq, + sunrealtype k1, sunrealtype k2) +{ + /* store legal inputs, and return with success */ + SACEXPGUS_PQ(C) = pq; + if (k1 >= RCONST(0.0)) { SACEXPGUS_K1(C) = k1; } + if (k2 >= RCONST(0.0)) { SACEXPGUS_K2(C) = k2; } + return SUNADAPTCONTROLLER_SUCCESS; +} + + + +/* ----------------------------------------------------------------- + * implementation of controller operations + * ----------------------------------------------------------------- */ + +SUNAdaptController_Type SUNAdaptController_GetType_ExpGus(SUNAdaptController C) +{ return SUN_ADAPTCONTROLLER_H; } + +int SUNAdaptController_EstimateStep_ExpGus(SUNAdaptController C, sunrealtype h, + sunrealtype dsm, sunrealtype* hnew) +{ + /* order parameter to use in controller */ + const int ord = SACEXPGUS_P(C) + SACEXPGUS_ADJ(C) + 1; + + /* modified method for first step */ + if (SACEXPGUS_FIRSTSTEP(C)) + { + /* set usable time-step adaptivity parameters */ + const sunrealtype k = -RCONST(1.0) / ord; + const sunrealtype e = SUNMAX(SACEXPGUS_BIAS(C) * dsm, TINY); + + /* compute estimated optimal time step size */ + *hnew = h * SUNRpowerR(e,k); + } + else + { + /* set usable time-step adaptivity parameters */ + const sunrealtype k1 = -SACEXPGUS_K1(C) / ord; + const sunrealtype k2 = -SACEXPGUS_K2(C) / ord; + const sunrealtype ecur = SACEXPGUS_BIAS(C) * dsm; + const sunrealtype e1 = SUNMAX(ecur, TINY); + const sunrealtype e2 = e1 / SUNMAX(SACEXPGUS_EP(C), TINY); + + /* compute estimated optimal time step size */ + *hnew = h * SUNRpowerR(e1,k1) * SUNRpowerR(e2,k2); + } + + /* return with success */ + return SUNADAPTCONTROLLER_SUCCESS; +} + +int SUNAdaptController_Reset_ExpGus(SUNAdaptController C) +{ + SACEXPGUS_EP(C) = RCONST(1.0); + SACEXPGUS_FIRSTSTEP(C) = SUNTRUE; + return SUNADAPTCONTROLLER_SUCCESS; +} + +int SUNAdaptController_SetDefaults_ExpGus(SUNAdaptController C) +{ + SACEXPGUS_K1(C) = DEFAULT_K1; + SACEXPGUS_K2(C) = DEFAULT_K2; + SACEXPGUS_BIAS(C) = DEFAULT_BIAS; + SACEXPGUS_PQ(C) = DEFAULT_PQ; + SACEXPGUS_ADJ(C) = DEFAULT_ADJ; + return SUNADAPTCONTROLLER_SUCCESS; +} + +int SUNAdaptController_Write_ExpGus(SUNAdaptController C, FILE *fptr) +{ + fprintf(fptr, "Explicit Gustafsson SUNAdaptController module:\n"); +#if defined(SUNDIALS_EXTENDED_PRECISION) + fprintf(fptr, " k1 = %32Lg\n", SACEXPGUS_K1(C)); + fprintf(fptr, " k2 = %32Lg\n", SACEXPGUS_K2(C)); + fprintf(fptr, " bias factor = %32Lg\n", SACEXPGUS_BIAS(C)); + fprintf(fptr, " previous error = %32g\n", SACEXPGUS_EP(C)); +#else + fprintf(fptr, " k1 = %16g\n", SACEXPGUS_K1(C)); + fprintf(fptr, " k2 = %16g\n", SACEXPGUS_K2(C)); + fprintf(fptr, " bias factor = %16g\n", SACEXPGUS_BIAS(C)); + fprintf(fptr, " previous error = %16g\n", SACEXPGUS_EP(C)); +#endif + if (SACEXPGUS_PQ(C) == 1) + { + fprintf(fptr, " p = %i (method order)\n", SACEXPGUS_P(C)); + } + else if (SACEXPGUS_PQ(C) == 0) + { + fprintf(fptr, " p = %i (embedding order)\n", SACEXPGUS_P(C)); + } + else + { + fprintf(fptr, " p = %i (minimum of method & embedding order)\n", SACEXPGUS_P(C)); + } + fprintf(fptr, " adj = %i\n", SACEXPGUS_ADJ(C)); + return SUNADAPTCONTROLLER_SUCCESS; +} + +int SUNAdaptController_SetMethodOrder_ExpGus(SUNAdaptController C, int p, int q) +{ + /* check for legal inputs */ + if ((p <= 0) || (q <= 0)) { return SUNADAPTCONTROLLER_ILL_INPUT; } + + /* store appropriate value based on "pq" */ + if (SACEXPGUS_PQ(C) == 1) { + SACEXPGUS_P(C) = p; + } else if (SACEXPGUS_PQ(C) == 0) { + SACEXPGUS_P(C) = q; + } else { + SACEXPGUS_P(C) = SUNMIN(p,q); + } + return SUNADAPTCONTROLLER_SUCCESS; +} + +int SUNAdaptController_AdjustControllerOrder_ExpGus(SUNAdaptController C, int adj) +{ + SACEXPGUS_ADJ(C) = adj; + return SUNADAPTCONTROLLER_SUCCESS; +} + +int SUNAdaptController_SetErrorBias_ExpGus(SUNAdaptController C, sunrealtype bias) +{ + /* set allowed value, otherwise set default */ + if (bias <= RCONST(0.0)) { + SACEXPGUS_BIAS(C) = DEFAULT_BIAS; + } else { + SACEXPGUS_BIAS(C) = bias; + } + + return SUNADAPTCONTROLLER_SUCCESS; +} + +int SUNAdaptController_Update_ExpGus(SUNAdaptController C, sunrealtype h, sunrealtype dsm) +{ + SACEXPGUS_EP(C) = SACEXPGUS_BIAS(C) * dsm; + SACEXPGUS_FIRSTSTEP(C) = SUNFALSE; + return SUNADAPTCONTROLLER_SUCCESS; +} + +int SUNAdaptController_Space_ExpGus(SUNAdaptController C, long int* lenrw, long int* leniw) +{ + *lenrw = 5; + *leniw = 4; + return SUNADAPTCONTROLLER_SUCCESS; +} diff --git a/src/sunadaptcontroller/i/CMakeLists.txt b/src/sunadaptcontroller/i/CMakeLists.txt new file mode 100644 index 0000000000..85a3fb019b --- /dev/null +++ b/src/sunadaptcontroller/i/CMakeLists.txt @@ -0,0 +1,29 @@ +# --------------------------------------------------------------- +# Programmer(s): Daniel R. Reynolds @ SMU +# --------------------------------------------------------------- +# SUNDIALS Copyright Start +# Copyright (c) 2002-2023, 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 +# --------------------------------------------------------------- + +# Create a library out of the generic sundials modules +sundials_add_library(sundials_sunadaptcontrolleri + SOURCES + sunadaptcontroller_i.c + HEADERS + ${SUNDIALS_SOURCE_DIR}/include/sunadaptcontroller/sunadaptcontroller_i.h + INCLUDE_SUBDIR + sunadaptcontroller + OBJECT_LIB_ONLY +) + +# Add F2003 module if the interface is enabled +if(BUILD_FORTRAN_MODULE_INTERFACE) + add_subdirectory(fmod) +endif() diff --git a/src/sunadaptcontroller/i/fmod/CMakeLists.txt b/src/sunadaptcontroller/i/fmod/CMakeLists.txt new file mode 100644 index 0000000000..32dc30f4e5 --- /dev/null +++ b/src/sunadaptcontroller/i/fmod/CMakeLists.txt @@ -0,0 +1,25 @@ +# --------------------------------------------------------------- +# Programmer(s): Daniel R. Reynolds @ SMU +# --------------------------------------------------------------- +# SUNDIALS Copyright Start +# Copyright (c) 2002-2023, 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 +# --------------------------------------------------------------- + +sundials_add_f2003_library(sundials_fsunadaptcontrolleri_mod + SOURCES + fsunadaptcontroller_i_mod.f90 fsunadaptcontroller_i_mod.c + OBJECT_LIBRARIES + sundials_fgeneric_mod_obj + OUTPUT_NAME + sundials_fsunadaptcontrolleri_mod + OBJECT_LIB_ONLY +) + +message(STATUS "Added SUNAdaptController_I F2003 interface") diff --git a/src/sunadaptcontroller/i/fmod/fsunadaptcontroller_i_mod.c b/src/sunadaptcontroller/i/fmod/fsunadaptcontroller_i_mod.c new file mode 100644 index 0000000000..c0f4dda981 --- /dev/null +++ b/src/sunadaptcontroller/i/fmod/fsunadaptcontroller_i_mod.c @@ -0,0 +1,355 @@ +/* ---------------------------------------------------------------------------- + * This file was automatically generated by SWIG (http://www.swig.org). + * Version 4.0.0 + * + * This file is not intended to be easily readable and contains a number of + * coding conventions designed to improve portability and efficiency. Do not make + * changes to this file unless you know what you are doing--modify the SWIG + * interface file instead. + * ----------------------------------------------------------------------------- */ + +/* --------------------------------------------------------------- + * Programmer(s): Auto-generated by swig. + * --------------------------------------------------------------- + * SUNDIALS Copyright Start + * Copyright (c) 2002-2023, Lawrence Livermore National Security + * and Southern Methodist University. + * All rights reserved. + * + * See the top-level LICENSE and NOTICE files for details. + * + * SPDX-License-Identifier: BSD-3-Clause + * SUNDIALS Copyright End + * -------------------------------------------------------------*/ + +/* ----------------------------------------------------------------------------- + * This section contains generic SWIG labels for method/variable + * declarations/attributes, and other compiler dependent labels. + * ----------------------------------------------------------------------------- */ + +/* template workaround for compilers that cannot correctly implement the C++ standard */ +#ifndef SWIGTEMPLATEDISAMBIGUATOR +# if defined(__SUNPRO_CC) && (__SUNPRO_CC <= 0x560) +# define SWIGTEMPLATEDISAMBIGUATOR template +# elif defined(__HP_aCC) +/* Needed even with `aCC -AA' when `aCC -V' reports HP ANSI C++ B3910B A.03.55 */ +/* If we find a maximum version that requires this, the test would be __HP_aCC <= 35500 for A.03.55 */ +# define SWIGTEMPLATEDISAMBIGUATOR template +# else +# define SWIGTEMPLATEDISAMBIGUATOR +# endif +#endif + +/* inline attribute */ +#ifndef SWIGINLINE +# if defined(__cplusplus) || (defined(__GNUC__) && !defined(__STRICT_ANSI__)) +# define SWIGINLINE inline +# else +# define SWIGINLINE +# endif +#endif + +/* attribute recognised by some compilers to avoid 'unused' warnings */ +#ifndef SWIGUNUSED +# if defined(__GNUC__) +# if !(defined(__cplusplus)) || (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)) +# define SWIGUNUSED __attribute__ ((__unused__)) +# else +# define SWIGUNUSED +# endif +# elif defined(__ICC) +# define SWIGUNUSED __attribute__ ((__unused__)) +# else +# define SWIGUNUSED +# endif +#endif + +#ifndef SWIG_MSC_UNSUPPRESS_4505 +# if defined(_MSC_VER) +# pragma warning(disable : 4505) /* unreferenced local function has been removed */ +# endif +#endif + +#ifndef SWIGUNUSEDPARM +# ifdef __cplusplus +# define SWIGUNUSEDPARM(p) +# else +# define SWIGUNUSEDPARM(p) p SWIGUNUSED +# endif +#endif + +/* internal SWIG method */ +#ifndef SWIGINTERN +# define SWIGINTERN static SWIGUNUSED +#endif + +/* internal inline SWIG method */ +#ifndef SWIGINTERNINLINE +# define SWIGINTERNINLINE SWIGINTERN SWIGINLINE +#endif + +/* qualifier for exported *const* global data variables*/ +#ifndef SWIGEXTERN +# ifdef __cplusplus +# define SWIGEXTERN extern +# else +# define SWIGEXTERN +# endif +#endif + +/* exporting methods */ +#if defined(__GNUC__) +# if (__GNUC__ >= 4) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) +# ifndef GCC_HASCLASSVISIBILITY +# define GCC_HASCLASSVISIBILITY +# endif +# endif +#endif + +#ifndef SWIGEXPORT +# if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__) +# if defined(STATIC_LINKED) +# define SWIGEXPORT +# else +# define SWIGEXPORT __declspec(dllexport) +# endif +# else +# if defined(__GNUC__) && defined(GCC_HASCLASSVISIBILITY) +# define SWIGEXPORT __attribute__ ((visibility("default"))) +# else +# define SWIGEXPORT +# endif +# endif +#endif + +/* calling conventions for Windows */ +#ifndef SWIGSTDCALL +# if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__) +# define SWIGSTDCALL __stdcall +# else +# define SWIGSTDCALL +# endif +#endif + +/* Deal with Microsoft's attempt at deprecating C standard runtime functions */ +#if !defined(SWIG_NO_CRT_SECURE_NO_DEPRECATE) && defined(_MSC_VER) && !defined(_CRT_SECURE_NO_DEPRECATE) +# define _CRT_SECURE_NO_DEPRECATE +#endif + +/* Deal with Microsoft's attempt at deprecating methods in the standard C++ library */ +#if !defined(SWIG_NO_SCL_SECURE_NO_DEPRECATE) && defined(_MSC_VER) && !defined(_SCL_SECURE_NO_DEPRECATE) +# define _SCL_SECURE_NO_DEPRECATE +#endif + +/* Deal with Apple's deprecated 'AssertMacros.h' from Carbon-framework */ +#if defined(__APPLE__) && !defined(__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES) +# define __ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES 0 +#endif + +/* Intel's compiler complains if a variable which was never initialised is + * cast to void, which is a common idiom which we use to indicate that we + * are aware a variable isn't used. So we just silence that warning. + * See: https://github.com/swig/swig/issues/192 for more discussion. + */ +#ifdef __INTEL_COMPILER +# pragma warning disable 592 +#endif + +/* Errors in SWIG */ +#define SWIG_UnknownError -1 +#define SWIG_IOError -2 +#define SWIG_RuntimeError -3 +#define SWIG_IndexError -4 +#define SWIG_TypeError -5 +#define SWIG_DivisionByZero -6 +#define SWIG_OverflowError -7 +#define SWIG_SyntaxError -8 +#define SWIG_ValueError -9 +#define SWIG_SystemError -10 +#define SWIG_AttributeError -11 +#define SWIG_MemoryError -12 +#define SWIG_NullReferenceError -13 + + + + +#include +#define SWIG_exception_impl(DECL, CODE, MSG, RETURNNULL) \ + { printf("In " DECL ": " MSG); assert(0); RETURNNULL; } + + +#include +#if defined(_MSC_VER) || defined(__BORLANDC__) || defined(_WATCOM) +# ifndef snprintf +# define snprintf _snprintf +# endif +#endif + + +/* Support for the `contract` feature. + * + * Note that RETURNNULL is first because it's inserted via a 'Replaceall' in + * the fortran.cxx file. + */ +#define SWIG_contract_assert(RETURNNULL, EXPR, MSG) \ + if (!(EXPR)) { SWIG_exception_impl("$decl", SWIG_ValueError, MSG, RETURNNULL); } + + +#define SWIGVERSION 0x040000 +#define SWIG_VERSION SWIGVERSION + + +#define SWIG_as_voidptr(a) (void *)((const void *)(a)) +#define SWIG_as_voidptrptr(a) ((void)SWIG_as_voidptr(*a),(void**)(a)) + + +#include "sundials/sundials_adaptcontroller.h" + + +#include "sunadaptcontroller/sunadaptcontroller_i.h" + +SWIGEXPORT SUNAdaptController _wrap_FSUNAdaptController_I(void *farg1) { + SUNAdaptController fresult ; + SUNContext arg1 = (SUNContext) 0 ; + SUNAdaptController result; + + arg1 = (SUNContext)(farg1); + result = (SUNAdaptController)SUNAdaptController_I(arg1); + fresult = result; + return fresult; +} + + +SWIGEXPORT int _wrap_FSUNAdaptController_SetParams_I(SUNAdaptController farg1, int const *farg2, double const *farg3) { + int fresult ; + SUNAdaptController arg1 = (SUNAdaptController) 0 ; + int arg2 ; + sunrealtype arg3 ; + int result; + + arg1 = (SUNAdaptController)(farg1); + arg2 = (int)(*farg2); + arg3 = (sunrealtype)(*farg3); + result = (int)SUNAdaptController_SetParams_I(arg1,arg2,arg3); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FSUNAdaptController_GetType_I(SUNAdaptController farg1) { + int fresult ; + SUNAdaptController arg1 = (SUNAdaptController) 0 ; + SUNAdaptController_Type result; + + arg1 = (SUNAdaptController)(farg1); + result = (SUNAdaptController_Type)SUNAdaptController_GetType_I(arg1); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FSUNAdaptController_EstimateStep_I(SUNAdaptController farg1, double const *farg2, double const *farg3, double *farg4) { + int fresult ; + SUNAdaptController arg1 = (SUNAdaptController) 0 ; + sunrealtype arg2 ; + sunrealtype arg3 ; + sunrealtype *arg4 = (sunrealtype *) 0 ; + int result; + + arg1 = (SUNAdaptController)(farg1); + arg2 = (sunrealtype)(*farg2); + arg3 = (sunrealtype)(*farg3); + arg4 = (sunrealtype *)(farg4); + result = (int)SUNAdaptController_EstimateStep_I(arg1,arg2,arg3,arg4); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FSUNAdaptController_SetDefaults_I(SUNAdaptController farg1) { + int fresult ; + SUNAdaptController arg1 = (SUNAdaptController) 0 ; + int result; + + arg1 = (SUNAdaptController)(farg1); + result = (int)SUNAdaptController_SetDefaults_I(arg1); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FSUNAdaptController_Write_I(SUNAdaptController farg1, void *farg2) { + int fresult ; + SUNAdaptController arg1 = (SUNAdaptController) 0 ; + FILE *arg2 = (FILE *) 0 ; + int result; + + arg1 = (SUNAdaptController)(farg1); + arg2 = (FILE *)(farg2); + result = (int)SUNAdaptController_Write_I(arg1,arg2); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FSUNAdaptController_SetMethodOrder_I(SUNAdaptController farg1, int const *farg2, int const *farg3) { + int fresult ; + SUNAdaptController arg1 = (SUNAdaptController) 0 ; + int arg2 ; + int arg3 ; + int result; + + arg1 = (SUNAdaptController)(farg1); + arg2 = (int)(*farg2); + arg3 = (int)(*farg3); + result = (int)SUNAdaptController_SetMethodOrder_I(arg1,arg2,arg3); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FSUNAdaptController_AdjustControllerOrder_I(SUNAdaptController farg1, int const *farg2) { + int fresult ; + SUNAdaptController arg1 = (SUNAdaptController) 0 ; + int arg2 ; + int result; + + arg1 = (SUNAdaptController)(farg1); + arg2 = (int)(*farg2); + result = (int)SUNAdaptController_AdjustControllerOrder_I(arg1,arg2); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FSUNAdaptController_SetErrorBias_I(SUNAdaptController farg1, double const *farg2) { + int fresult ; + SUNAdaptController arg1 = (SUNAdaptController) 0 ; + sunrealtype arg2 ; + int result; + + arg1 = (SUNAdaptController)(farg1); + arg2 = (sunrealtype)(*farg2); + result = (int)SUNAdaptController_SetErrorBias_I(arg1,arg2); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FSUNAdaptController_Space_I(SUNAdaptController farg1, long *farg2, long *farg3) { + int fresult ; + SUNAdaptController arg1 = (SUNAdaptController) 0 ; + long *arg2 = (long *) 0 ; + long *arg3 = (long *) 0 ; + int result; + + arg1 = (SUNAdaptController)(farg1); + arg2 = (long *)(farg2); + arg3 = (long *)(farg3); + result = (int)SUNAdaptController_Space_I(arg1,arg2,arg3); + fresult = (int)(result); + return fresult; +} + + + diff --git a/src/sunadaptcontroller/i/fmod/fsunadaptcontroller_i_mod.f90 b/src/sunadaptcontroller/i/fmod/fsunadaptcontroller_i_mod.f90 new file mode 100644 index 0000000000..b9aaf00a7f --- /dev/null +++ b/src/sunadaptcontroller/i/fmod/fsunadaptcontroller_i_mod.f90 @@ -0,0 +1,307 @@ +! This file was automatically generated by SWIG (http://www.swig.org). +! Version 4.0.0 +! +! Do not make changes to this file unless you know what you are doing--modify +! the SWIG interface file instead. + +! --------------------------------------------------------------- +! Programmer(s): Auto-generated by swig. +! --------------------------------------------------------------- +! SUNDIALS Copyright Start +! Copyright (c) 2002-2023, 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 +! --------------------------------------------------------------- + +module fsunadaptcontroller_i_mod + use, intrinsic :: ISO_C_BINDING + use fsundials_adaptcontroller_mod + use fsundials_types_mod + use fsundials_context_mod + implicit none + private + + ! DECLARATION CONSTRUCTS + public :: FSUNAdaptController_I + public :: FSUNAdaptController_SetParams_I + public :: FSUNAdaptController_GetType_I + public :: FSUNAdaptController_EstimateStep_I + public :: FSUNAdaptController_SetDefaults_I + public :: FSUNAdaptController_Write_I + public :: FSUNAdaptController_SetMethodOrder_I + public :: FSUNAdaptController_AdjustControllerOrder_I + public :: FSUNAdaptController_SetErrorBias_I + public :: FSUNAdaptController_Space_I + +! WRAPPER DECLARATIONS +interface +function swigc_FSUNAdaptController_I(farg1) & +bind(C, name="_wrap_FSUNAdaptController_I") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +type(C_PTR), value :: farg1 +type(C_PTR) :: fresult +end function + +function swigc_FSUNAdaptController_SetParams_I(farg1, farg2, farg3) & +bind(C, name="_wrap_FSUNAdaptController_SetParams_I") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +type(C_PTR), value :: farg1 +integer(C_INT), intent(in) :: farg2 +real(C_DOUBLE), intent(in) :: farg3 +integer(C_INT) :: fresult +end function + +function swigc_FSUNAdaptController_GetType_I(farg1) & +bind(C, name="_wrap_FSUNAdaptController_GetType_I") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +type(C_PTR), value :: farg1 +integer(C_INT) :: fresult +end function + +function swigc_FSUNAdaptController_EstimateStep_I(farg1, farg2, farg3, farg4) & +bind(C, name="_wrap_FSUNAdaptController_EstimateStep_I") & +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_PTR), value :: farg4 +integer(C_INT) :: fresult +end function + +function swigc_FSUNAdaptController_SetDefaults_I(farg1) & +bind(C, name="_wrap_FSUNAdaptController_SetDefaults_I") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +type(C_PTR), value :: farg1 +integer(C_INT) :: fresult +end function + +function swigc_FSUNAdaptController_Write_I(farg1, farg2) & +bind(C, name="_wrap_FSUNAdaptController_Write_I") & +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_FSUNAdaptController_SetMethodOrder_I(farg1, farg2, farg3) & +bind(C, name="_wrap_FSUNAdaptController_SetMethodOrder_I") & +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_FSUNAdaptController_AdjustControllerOrder_I(farg1, farg2) & +bind(C, name="_wrap_FSUNAdaptController_AdjustControllerOrder_I") & +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_FSUNAdaptController_SetErrorBias_I(farg1, farg2) & +bind(C, name="_wrap_FSUNAdaptController_SetErrorBias_I") & +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_FSUNAdaptController_Space_I(farg1, farg2, farg3) & +bind(C, name="_wrap_FSUNAdaptController_Space_I") & +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 + +end interface + + +contains + ! MODULE SUBPROGRAMS +function FSUNAdaptController_I(sunctx) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +type(SUNAdaptController), pointer :: swig_result +type(C_PTR) :: sunctx +type(C_PTR) :: fresult +type(C_PTR) :: farg1 + +farg1 = sunctx +fresult = swigc_FSUNAdaptController_I(farg1) +call c_f_pointer(fresult, swig_result) +end function + +function FSUNAdaptController_SetParams_I(c, pq, k1) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(SUNAdaptController), target, intent(inout) :: c +integer(C_INT), intent(in) :: pq +real(C_DOUBLE), intent(in) :: k1 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +integer(C_INT) :: farg2 +real(C_DOUBLE) :: farg3 + +farg1 = c_loc(c) +farg2 = pq +farg3 = k1 +fresult = swigc_FSUNAdaptController_SetParams_I(farg1, farg2, farg3) +swig_result = fresult +end function + +function FSUNAdaptController_GetType_I(c) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(SUNAdaptController_Type) :: swig_result +type(SUNAdaptController), target, intent(inout) :: c +integer(C_INT) :: fresult +type(C_PTR) :: farg1 + +farg1 = c_loc(c) +fresult = swigc_FSUNAdaptController_GetType_I(farg1) +swig_result = fresult +end function + +function FSUNAdaptController_EstimateStep_I(c, h, dsm, hnew) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(SUNAdaptController), target, intent(inout) :: c +real(C_DOUBLE), intent(in) :: h +real(C_DOUBLE), intent(in) :: dsm +real(C_DOUBLE), target, intent(inout) :: hnew +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +real(C_DOUBLE) :: farg2 +real(C_DOUBLE) :: farg3 +type(C_PTR) :: farg4 + +farg1 = c_loc(c) +farg2 = h +farg3 = dsm +farg4 = c_loc(hnew) +fresult = swigc_FSUNAdaptController_EstimateStep_I(farg1, farg2, farg3, farg4) +swig_result = fresult +end function + +function FSUNAdaptController_SetDefaults_I(c) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(SUNAdaptController), target, intent(inout) :: c +integer(C_INT) :: fresult +type(C_PTR) :: farg1 + +farg1 = c_loc(c) +fresult = swigc_FSUNAdaptController_SetDefaults_I(farg1) +swig_result = fresult +end function + +function FSUNAdaptController_Write_I(c, fptr) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(SUNAdaptController), target, intent(inout) :: c +type(C_PTR) :: fptr +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 + +farg1 = c_loc(c) +farg2 = fptr +fresult = swigc_FSUNAdaptController_Write_I(farg1, farg2) +swig_result = fresult +end function + +function FSUNAdaptController_SetMethodOrder_I(c, p, q) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(SUNAdaptController), target, intent(inout) :: c +integer(C_INT), intent(in) :: p +integer(C_INT), intent(in) :: q +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +integer(C_INT) :: farg2 +integer(C_INT) :: farg3 + +farg1 = c_loc(c) +farg2 = p +farg3 = q +fresult = swigc_FSUNAdaptController_SetMethodOrder_I(farg1, farg2, farg3) +swig_result = fresult +end function + +function FSUNAdaptController_AdjustControllerOrder_I(c, adj) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(SUNAdaptController), target, intent(inout) :: c +integer(C_INT), intent(in) :: adj +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +integer(C_INT) :: farg2 + +farg1 = c_loc(c) +farg2 = adj +fresult = swigc_FSUNAdaptController_AdjustControllerOrder_I(farg1, farg2) +swig_result = fresult +end function + +function FSUNAdaptController_SetErrorBias_I(c, bias) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(SUNAdaptController), target, intent(inout) :: c +real(C_DOUBLE), intent(in) :: bias +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +real(C_DOUBLE) :: farg2 + +farg1 = c_loc(c) +farg2 = bias +fresult = swigc_FSUNAdaptController_SetErrorBias_I(farg1, farg2) +swig_result = fresult +end function + +function FSUNAdaptController_Space_I(c, lenrw, leniw) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(SUNAdaptController), target, intent(inout) :: c +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 = c_loc(c) +farg2 = c_loc(lenrw(1)) +farg3 = c_loc(leniw(1)) +fresult = swigc_FSUNAdaptController_Space_I(farg1, farg2, farg3) +swig_result = fresult +end function + + +end module diff --git a/src/sunadaptcontroller/i/sunadaptcontroller_i.c b/src/sunadaptcontroller/i/sunadaptcontroller_i.c new file mode 100644 index 0000000000..5fd8067c4f --- /dev/null +++ b/src/sunadaptcontroller/i/sunadaptcontroller_i.c @@ -0,0 +1,207 @@ +/* ----------------------------------------------------------------- + * Programmer(s): Daniel R. Reynolds @ SMU + * ----------------------------------------------------------------- + * SUNDIALS Copyright Start + * Copyright (c) 2002-2023, Lawrence Livermore National Security + * and Southern Methodist University. + * All rights reserved. + * + * See the top-level LICENSE and NOTICE files for details. + * + * SPDX-License-Identifier: BSD-3-Clause + * SUNDIALS Copyright End + * ----------------------------------------------------------------- + * This is the implementation file for the SUNAdaptController_I + * module. + * -----------------------------------------------------------------*/ + +#include +#include +#include +#include + + +/* --------------- + * Macro accessors + * --------------- */ + +#define SACI_CONTENT(C) ( (SUNAdaptControllerContent_I)(C->content) ) +#define SACI_K1(C) ( SACI_CONTENT(C)->k1 ) +#define SACI_BIAS(C) ( SACI_CONTENT(C)->bias ) +#define SACI_P(C) ( SACI_CONTENT(C)->p ) +#define SACI_PQ(C) ( SACI_CONTENT(C)->pq ) +#define SACI_ADJ(C) ( SACI_CONTENT(C)->adj ) + +/* ------------------ + * Default parameters + * ------------------ */ + +#define DEFAULT_K1 RCONST(1.0) +#define DEFAULT_BIAS RCONST(1.5) +#define DEFAULT_PQ 0 +#define DEFAULT_ADJ -1 +/* #define DEFAULT_PQ -1 */ +/* #define DEFAULT_ADJ 0 */ +#define TINY RCONST(1.0e-10) + + +/* ----------------------------------------------------------------- + * exported functions + * ----------------------------------------------------------------- */ + +/* ----------------------------------------------------------------- + * Function to create a new I controller + */ + +SUNAdaptController SUNAdaptController_I(SUNContext sunctx) +{ + SUNAdaptController C; + SUNAdaptControllerContent_I content; + + /* Create an empty controller object */ + C = NULL; + C = SUNAdaptController_NewEmpty(sunctx); + if (C == NULL) { return (NULL); } + + /* Attach operations */ + C->ops->gettype = SUNAdaptController_GetType_I; + C->ops->estimatestep = SUNAdaptController_EstimateStep_I; + C->ops->setdefaults = SUNAdaptController_SetDefaults_I; + C->ops->write = SUNAdaptController_Write_I; + C->ops->setmethodorder = SUNAdaptController_SetMethodOrder_I; + C->ops->adjustcontrollerorder = SUNAdaptController_AdjustControllerOrder_I; + C->ops->seterrorbias = SUNAdaptController_SetErrorBias_I; + C->ops->space = SUNAdaptController_Space_I; + + /* Create content */ + content = NULL; + content = (SUNAdaptControllerContent_I)malloc(sizeof *content); + if (content == NULL) + { + (void) SUNAdaptController_Destroy(C); + return (NULL); + } + + /* Attach content */ + C->content = content; + + /* Initialize method order */ + content->p = 1; + + /* Fill content with default values */ + SUNAdaptController_SetDefaults_I(C); + + return (C); +} + +/* ----------------------------------------------------------------- + * Function to set I parameters + */ + +int SUNAdaptController_SetParams_I(SUNAdaptController C, int pq, + sunrealtype k1) +{ + /* store legal inputs, and return with success */ + SACI_PQ(C) = pq; + if (k1 >= RCONST(0.0)) { SACI_K1(C) = k1; } + return SUNADAPTCONTROLLER_SUCCESS; +} + + + +/* ----------------------------------------------------------------- + * implementation of controller operations + * ----------------------------------------------------------------- */ + +SUNAdaptController_Type SUNAdaptController_GetType_I(SUNAdaptController C) +{ return SUN_ADAPTCONTROLLER_H; } + +int SUNAdaptController_EstimateStep_I(SUNAdaptController C, sunrealtype h, + sunrealtype dsm, sunrealtype* hnew) +{ + /* set usable time-step adaptivity parameters */ + const int ord = SACI_P(C) + SACI_ADJ(C) + 1; + const sunrealtype k1 = -SACI_K1(C) / ord; + const sunrealtype ecur = SACI_BIAS(C) * dsm; + const sunrealtype e1 = SUNMAX(ecur, TINY); + + /* compute estimated optimal time step size and return with success */ + *hnew = h * SUNRpowerR(e1,k1); + return SUNADAPTCONTROLLER_SUCCESS; +} + +int SUNAdaptController_SetDefaults_I(SUNAdaptController C) +{ + SACI_K1(C) = DEFAULT_K1; + SACI_BIAS(C) = DEFAULT_BIAS; + SACI_PQ(C) = DEFAULT_PQ; + SACI_ADJ(C) = DEFAULT_ADJ; + return SUNADAPTCONTROLLER_SUCCESS; +} + +int SUNAdaptController_Write_I(SUNAdaptController C, FILE *fptr) +{ + fprintf(fptr, "I SUNAdaptController module:\n"); +#if defined(SUNDIALS_EXTENDED_PRECISION) + fprintf(fptr, " k1 = %32Lg\n", SACI_K1(C)); + fprintf(fptr, " bias factor = %32Lg\n", SACI_BIAS(C)); +#else + fprintf(fptr, " k1 = %16g\n", SACI_K1(C)); + fprintf(fptr, " bias factor = %16g\n", SACI_BIAS(C)); +#endif + if (SACI_PQ(C) == 1) + { + fprintf(fptr, " p = %i (method order)\n", SACI_P(C)); + } + else if (SACI_PQ(C) == 0) + { + fprintf(fptr, " p = %i (embedding order)\n", SACI_P(C)); + } + else + { + fprintf(fptr, " p = %i (minimum of method & embedding order)\n", SACI_P(C)); + } + fprintf(fptr, " adj = %i\n", SACI_ADJ(C)); + return SUNADAPTCONTROLLER_SUCCESS; +} + +int SUNAdaptController_SetMethodOrder_I(SUNAdaptController C, int p, int q) +{ + /* check for legal inputs */ + if ((p <= 0) || (q <= 0)) { return SUNADAPTCONTROLLER_ILL_INPUT; } + + /* store appropriate value based on "pq" */ + if (SACI_PQ(C) == 1) { + SACI_P(C) = p; + } else if (SACI_PQ(C) == 0) { + SACI_P(C) = q; + } else { + SACI_P(C) = SUNMIN(p,q); + } + return SUNADAPTCONTROLLER_SUCCESS; +} + +int SUNAdaptController_AdjustControllerOrder_I(SUNAdaptController C, int adj) +{ + SACI_ADJ(C) = adj; + return SUNADAPTCONTROLLER_SUCCESS; +} + +int SUNAdaptController_SetErrorBias_I(SUNAdaptController C, sunrealtype bias) +{ + /* set allowed value, otherwise set default */ + if (bias <= RCONST(0.0)) { + SACI_BIAS(C) = DEFAULT_BIAS; + } else { + SACI_BIAS(C) = bias; + } + + return SUNADAPTCONTROLLER_SUCCESS; +} + +int SUNAdaptController_Space_I(SUNAdaptController C, long int* lenrw, long int* leniw) +{ + *lenrw = 3; + *leniw = 3; + return SUNADAPTCONTROLLER_SUCCESS; +} diff --git a/src/sunadaptcontroller/imexgus/CMakeLists.txt b/src/sunadaptcontroller/imexgus/CMakeLists.txt new file mode 100644 index 0000000000..a98374f2a3 --- /dev/null +++ b/src/sunadaptcontroller/imexgus/CMakeLists.txt @@ -0,0 +1,29 @@ +# --------------------------------------------------------------- +# Programmer(s): Daniel R. Reynolds @ SMU +# --------------------------------------------------------------- +# SUNDIALS Copyright Start +# Copyright (c) 2002-2023, 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 +# --------------------------------------------------------------- + +# Create a library out of the generic sundials modules +sundials_add_library(sundials_sunadaptcontrollerimexgus + SOURCES + sunadaptcontroller_imexgus.c + HEADERS + ${SUNDIALS_SOURCE_DIR}/include/sunadaptcontroller/sunadaptcontroller_imexgus.h + INCLUDE_SUBDIR + sunadaptcontroller + OBJECT_LIB_ONLY +) + +# Add F2003 module if the interface is enabled +if(BUILD_FORTRAN_MODULE_INTERFACE) + add_subdirectory(fmod) +endif() diff --git a/src/sunadaptcontroller/imexgus/fmod/CMakeLists.txt b/src/sunadaptcontroller/imexgus/fmod/CMakeLists.txt new file mode 100644 index 0000000000..7c943d4724 --- /dev/null +++ b/src/sunadaptcontroller/imexgus/fmod/CMakeLists.txt @@ -0,0 +1,25 @@ +# --------------------------------------------------------------- +# Programmer(s): Daniel R. Reynolds @ SMU +# --------------------------------------------------------------- +# SUNDIALS Copyright Start +# Copyright (c) 2002-2023, 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 +# --------------------------------------------------------------- + +sundials_add_f2003_library(sundials_fsunadaptcontrollerimexgus_mod + SOURCES + fsunadaptcontroller_imexgus_mod.f90 fsunadaptcontroller_imexgus_mod.c + OBJECT_LIBRARIES + sundials_fgeneric_mod_obj + OUTPUT_NAME + sundials_fsunadaptcontrollerimexgus_mod + OBJECT_LIB_ONLY +) + +message(STATUS "Added SUNAdaptController_ImExGus F2003 interface") diff --git a/src/sunadaptcontroller/imexgus/fmod/fsunadaptcontroller_imexgus_mod.c b/src/sunadaptcontroller/imexgus/fmod/fsunadaptcontroller_imexgus_mod.c new file mode 100644 index 0000000000..3344c1d495 --- /dev/null +++ b/src/sunadaptcontroller/imexgus/fmod/fsunadaptcontroller_imexgus_mod.c @@ -0,0 +1,389 @@ +/* ---------------------------------------------------------------------------- + * This file was automatically generated by SWIG (http://www.swig.org). + * Version 4.0.0 + * + * This file is not intended to be easily readable and contains a number of + * coding conventions designed to improve portability and efficiency. Do not make + * changes to this file unless you know what you are doing--modify the SWIG + * interface file instead. + * ----------------------------------------------------------------------------- */ + +/* --------------------------------------------------------------- + * Programmer(s): Auto-generated by swig. + * --------------------------------------------------------------- + * SUNDIALS Copyright Start + * Copyright (c) 2002-2023, Lawrence Livermore National Security + * and Southern Methodist University. + * All rights reserved. + * + * See the top-level LICENSE and NOTICE files for details. + * + * SPDX-License-Identifier: BSD-3-Clause + * SUNDIALS Copyright End + * -------------------------------------------------------------*/ + +/* ----------------------------------------------------------------------------- + * This section contains generic SWIG labels for method/variable + * declarations/attributes, and other compiler dependent labels. + * ----------------------------------------------------------------------------- */ + +/* template workaround for compilers that cannot correctly implement the C++ standard */ +#ifndef SWIGTEMPLATEDISAMBIGUATOR +# if defined(__SUNPRO_CC) && (__SUNPRO_CC <= 0x560) +# define SWIGTEMPLATEDISAMBIGUATOR template +# elif defined(__HP_aCC) +/* Needed even with `aCC -AA' when `aCC -V' reports HP ANSI C++ B3910B A.03.55 */ +/* If we find a maximum version that requires this, the test would be __HP_aCC <= 35500 for A.03.55 */ +# define SWIGTEMPLATEDISAMBIGUATOR template +# else +# define SWIGTEMPLATEDISAMBIGUATOR +# endif +#endif + +/* inline attribute */ +#ifndef SWIGINLINE +# if defined(__cplusplus) || (defined(__GNUC__) && !defined(__STRICT_ANSI__)) +# define SWIGINLINE inline +# else +# define SWIGINLINE +# endif +#endif + +/* attribute recognised by some compilers to avoid 'unused' warnings */ +#ifndef SWIGUNUSED +# if defined(__GNUC__) +# if !(defined(__cplusplus)) || (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)) +# define SWIGUNUSED __attribute__ ((__unused__)) +# else +# define SWIGUNUSED +# endif +# elif defined(__ICC) +# define SWIGUNUSED __attribute__ ((__unused__)) +# else +# define SWIGUNUSED +# endif +#endif + +#ifndef SWIG_MSC_UNSUPPRESS_4505 +# if defined(_MSC_VER) +# pragma warning(disable : 4505) /* unreferenced local function has been removed */ +# endif +#endif + +#ifndef SWIGUNUSEDPARM +# ifdef __cplusplus +# define SWIGUNUSEDPARM(p) +# else +# define SWIGUNUSEDPARM(p) p SWIGUNUSED +# endif +#endif + +/* internal SWIG method */ +#ifndef SWIGINTERN +# define SWIGINTERN static SWIGUNUSED +#endif + +/* internal inline SWIG method */ +#ifndef SWIGINTERNINLINE +# define SWIGINTERNINLINE SWIGINTERN SWIGINLINE +#endif + +/* qualifier for exported *const* global data variables*/ +#ifndef SWIGEXTERN +# ifdef __cplusplus +# define SWIGEXTERN extern +# else +# define SWIGEXTERN +# endif +#endif + +/* exporting methods */ +#if defined(__GNUC__) +# if (__GNUC__ >= 4) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) +# ifndef GCC_HASCLASSVISIBILITY +# define GCC_HASCLASSVISIBILITY +# endif +# endif +#endif + +#ifndef SWIGEXPORT +# if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__) +# if defined(STATIC_LINKED) +# define SWIGEXPORT +# else +# define SWIGEXPORT __declspec(dllexport) +# endif +# else +# if defined(__GNUC__) && defined(GCC_HASCLASSVISIBILITY) +# define SWIGEXPORT __attribute__ ((visibility("default"))) +# else +# define SWIGEXPORT +# endif +# endif +#endif + +/* calling conventions for Windows */ +#ifndef SWIGSTDCALL +# if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__) +# define SWIGSTDCALL __stdcall +# else +# define SWIGSTDCALL +# endif +#endif + +/* Deal with Microsoft's attempt at deprecating C standard runtime functions */ +#if !defined(SWIG_NO_CRT_SECURE_NO_DEPRECATE) && defined(_MSC_VER) && !defined(_CRT_SECURE_NO_DEPRECATE) +# define _CRT_SECURE_NO_DEPRECATE +#endif + +/* Deal with Microsoft's attempt at deprecating methods in the standard C++ library */ +#if !defined(SWIG_NO_SCL_SECURE_NO_DEPRECATE) && defined(_MSC_VER) && !defined(_SCL_SECURE_NO_DEPRECATE) +# define _SCL_SECURE_NO_DEPRECATE +#endif + +/* Deal with Apple's deprecated 'AssertMacros.h' from Carbon-framework */ +#if defined(__APPLE__) && !defined(__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES) +# define __ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES 0 +#endif + +/* Intel's compiler complains if a variable which was never initialised is + * cast to void, which is a common idiom which we use to indicate that we + * are aware a variable isn't used. So we just silence that warning. + * See: https://github.com/swig/swig/issues/192 for more discussion. + */ +#ifdef __INTEL_COMPILER +# pragma warning disable 592 +#endif + +/* Errors in SWIG */ +#define SWIG_UnknownError -1 +#define SWIG_IOError -2 +#define SWIG_RuntimeError -3 +#define SWIG_IndexError -4 +#define SWIG_TypeError -5 +#define SWIG_DivisionByZero -6 +#define SWIG_OverflowError -7 +#define SWIG_SyntaxError -8 +#define SWIG_ValueError -9 +#define SWIG_SystemError -10 +#define SWIG_AttributeError -11 +#define SWIG_MemoryError -12 +#define SWIG_NullReferenceError -13 + + + + +#include +#define SWIG_exception_impl(DECL, CODE, MSG, RETURNNULL) \ + { printf("In " DECL ": " MSG); assert(0); RETURNNULL; } + + +#include +#if defined(_MSC_VER) || defined(__BORLANDC__) || defined(_WATCOM) +# ifndef snprintf +# define snprintf _snprintf +# endif +#endif + + +/* Support for the `contract` feature. + * + * Note that RETURNNULL is first because it's inserted via a 'Replaceall' in + * the fortran.cxx file. + */ +#define SWIG_contract_assert(RETURNNULL, EXPR, MSG) \ + if (!(EXPR)) { SWIG_exception_impl("$decl", SWIG_ValueError, MSG, RETURNNULL); } + + +#define SWIGVERSION 0x040000 +#define SWIG_VERSION SWIGVERSION + + +#define SWIG_as_voidptr(a) (void *)((const void *)(a)) +#define SWIG_as_voidptrptr(a) ((void)SWIG_as_voidptr(*a),(void**)(a)) + + +#include "sundials/sundials_adaptcontroller.h" + + +#include "sunadaptcontroller/sunadaptcontroller_imexgus.h" + +SWIGEXPORT SUNAdaptController _wrap_FSUNAdaptController_ImExGus(void *farg1) { + SUNAdaptController fresult ; + SUNContext arg1 = (SUNContext) 0 ; + SUNAdaptController result; + + arg1 = (SUNContext)(farg1); + result = (SUNAdaptController)SUNAdaptController_ImExGus(arg1); + fresult = result; + return fresult; +} + + +SWIGEXPORT int _wrap_FSUNAdaptController_SetParams_ImExGus(SUNAdaptController farg1, int const *farg2, double const *farg3, double const *farg4, double const *farg5, double const *farg6) { + int fresult ; + SUNAdaptController arg1 = (SUNAdaptController) 0 ; + int arg2 ; + sunrealtype arg3 ; + sunrealtype arg4 ; + sunrealtype arg5 ; + sunrealtype arg6 ; + int result; + + arg1 = (SUNAdaptController)(farg1); + arg2 = (int)(*farg2); + arg3 = (sunrealtype)(*farg3); + arg4 = (sunrealtype)(*farg4); + arg5 = (sunrealtype)(*farg5); + arg6 = (sunrealtype)(*farg6); + result = (int)SUNAdaptController_SetParams_ImExGus(arg1,arg2,arg3,arg4,arg5,arg6); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FSUNAdaptController_GetType_ImExGus(SUNAdaptController farg1) { + int fresult ; + SUNAdaptController arg1 = (SUNAdaptController) 0 ; + SUNAdaptController_Type result; + + arg1 = (SUNAdaptController)(farg1); + result = (SUNAdaptController_Type)SUNAdaptController_GetType_ImExGus(arg1); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FSUNAdaptController_EstimateStep_ImExGus(SUNAdaptController farg1, double const *farg2, double const *farg3, double *farg4) { + int fresult ; + SUNAdaptController arg1 = (SUNAdaptController) 0 ; + sunrealtype arg2 ; + sunrealtype arg3 ; + sunrealtype *arg4 = (sunrealtype *) 0 ; + int result; + + arg1 = (SUNAdaptController)(farg1); + arg2 = (sunrealtype)(*farg2); + arg3 = (sunrealtype)(*farg3); + arg4 = (sunrealtype *)(farg4); + result = (int)SUNAdaptController_EstimateStep_ImExGus(arg1,arg2,arg3,arg4); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FSUNAdaptController_Reset_ImExGus(SUNAdaptController farg1) { + int fresult ; + SUNAdaptController arg1 = (SUNAdaptController) 0 ; + int result; + + arg1 = (SUNAdaptController)(farg1); + result = (int)SUNAdaptController_Reset_ImExGus(arg1); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FSUNAdaptController_SetDefaults_ImExGus(SUNAdaptController farg1) { + int fresult ; + SUNAdaptController arg1 = (SUNAdaptController) 0 ; + int result; + + arg1 = (SUNAdaptController)(farg1); + result = (int)SUNAdaptController_SetDefaults_ImExGus(arg1); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FSUNAdaptController_Write_ImExGus(SUNAdaptController farg1, void *farg2) { + int fresult ; + SUNAdaptController arg1 = (SUNAdaptController) 0 ; + FILE *arg2 = (FILE *) 0 ; + int result; + + arg1 = (SUNAdaptController)(farg1); + arg2 = (FILE *)(farg2); + result = (int)SUNAdaptController_Write_ImExGus(arg1,arg2); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FSUNAdaptController_SetMethodOrder_ImExGus(SUNAdaptController farg1, int const *farg2, int const *farg3) { + int fresult ; + SUNAdaptController arg1 = (SUNAdaptController) 0 ; + int arg2 ; + int arg3 ; + int result; + + arg1 = (SUNAdaptController)(farg1); + arg2 = (int)(*farg2); + arg3 = (int)(*farg3); + result = (int)SUNAdaptController_SetMethodOrder_ImExGus(arg1,arg2,arg3); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FSUNAdaptController_AdjustControllerOrder_ImExGus(SUNAdaptController farg1, int const *farg2) { + int fresult ; + SUNAdaptController arg1 = (SUNAdaptController) 0 ; + int arg2 ; + int result; + + arg1 = (SUNAdaptController)(farg1); + arg2 = (int)(*farg2); + result = (int)SUNAdaptController_AdjustControllerOrder_ImExGus(arg1,arg2); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FSUNAdaptController_SetErrorBias_ImExGus(SUNAdaptController farg1, double const *farg2) { + int fresult ; + SUNAdaptController arg1 = (SUNAdaptController) 0 ; + sunrealtype arg2 ; + int result; + + arg1 = (SUNAdaptController)(farg1); + arg2 = (sunrealtype)(*farg2); + result = (int)SUNAdaptController_SetErrorBias_ImExGus(arg1,arg2); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FSUNAdaptController_Update_ImExGus(SUNAdaptController farg1, double const *farg2, double const *farg3) { + int fresult ; + SUNAdaptController arg1 = (SUNAdaptController) 0 ; + sunrealtype arg2 ; + sunrealtype arg3 ; + int result; + + arg1 = (SUNAdaptController)(farg1); + arg2 = (sunrealtype)(*farg2); + arg3 = (sunrealtype)(*farg3); + result = (int)SUNAdaptController_Update_ImExGus(arg1,arg2,arg3); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FSUNAdaptController_Space_ImExGus(SUNAdaptController farg1, long *farg2, long *farg3) { + int fresult ; + SUNAdaptController arg1 = (SUNAdaptController) 0 ; + long *arg2 = (long *) 0 ; + long *arg3 = (long *) 0 ; + int result; + + arg1 = (SUNAdaptController)(farg1); + arg2 = (long *)(farg2); + arg3 = (long *)(farg3); + result = (int)SUNAdaptController_Space_ImExGus(arg1,arg2,arg3); + fresult = (int)(result); + return fresult; +} + + + diff --git a/src/sunadaptcontroller/imexgus/fmod/fsunadaptcontroller_imexgus_mod.f90 b/src/sunadaptcontroller/imexgus/fmod/fsunadaptcontroller_imexgus_mod.f90 new file mode 100644 index 0000000000..0032148fd6 --- /dev/null +++ b/src/sunadaptcontroller/imexgus/fmod/fsunadaptcontroller_imexgus_mod.f90 @@ -0,0 +1,371 @@ +! This file was automatically generated by SWIG (http://www.swig.org). +! Version 4.0.0 +! +! Do not make changes to this file unless you know what you are doing--modify +! the SWIG interface file instead. + +! --------------------------------------------------------------- +! Programmer(s): Auto-generated by swig. +! --------------------------------------------------------------- +! SUNDIALS Copyright Start +! Copyright (c) 2002-2023, 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 +! --------------------------------------------------------------- + +module fsunadaptcontroller_imexgus_mod + use, intrinsic :: ISO_C_BINDING + use fsundials_adaptcontroller_mod + use fsundials_types_mod + use fsundials_context_mod + implicit none + private + + ! DECLARATION CONSTRUCTS + public :: FSUNAdaptController_ImExGus + public :: FSUNAdaptController_SetParams_ImExGus + public :: FSUNAdaptController_GetType_ImExGus + public :: FSUNAdaptController_EstimateStep_ImExGus + public :: FSUNAdaptController_Reset_ImExGus + public :: FSUNAdaptController_SetDefaults_ImExGus + public :: FSUNAdaptController_Write_ImExGus + public :: FSUNAdaptController_SetMethodOrder_ImExGus + public :: FSUNAdaptController_AdjustControllerOrder_ImExGus + public :: FSUNAdaptController_SetErrorBias_ImExGus + public :: FSUNAdaptController_Update_ImExGus + public :: FSUNAdaptController_Space_ImExGus + +! WRAPPER DECLARATIONS +interface +function swigc_FSUNAdaptController_ImExGus(farg1) & +bind(C, name="_wrap_FSUNAdaptController_ImExGus") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +type(C_PTR), value :: farg1 +type(C_PTR) :: fresult +end function + +function swigc_FSUNAdaptController_SetParams_ImExGus(farg1, farg2, farg3, farg4, farg5, farg6) & +bind(C, name="_wrap_FSUNAdaptController_SetParams_ImExGus") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +type(C_PTR), value :: farg1 +integer(C_INT), intent(in) :: farg2 +real(C_DOUBLE), intent(in) :: farg3 +real(C_DOUBLE), intent(in) :: farg4 +real(C_DOUBLE), intent(in) :: farg5 +real(C_DOUBLE), intent(in) :: farg6 +integer(C_INT) :: fresult +end function + +function swigc_FSUNAdaptController_GetType_ImExGus(farg1) & +bind(C, name="_wrap_FSUNAdaptController_GetType_ImExGus") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +type(C_PTR), value :: farg1 +integer(C_INT) :: fresult +end function + +function swigc_FSUNAdaptController_EstimateStep_ImExGus(farg1, farg2, farg3, farg4) & +bind(C, name="_wrap_FSUNAdaptController_EstimateStep_ImExGus") & +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_PTR), value :: farg4 +integer(C_INT) :: fresult +end function + +function swigc_FSUNAdaptController_Reset_ImExGus(farg1) & +bind(C, name="_wrap_FSUNAdaptController_Reset_ImExGus") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +type(C_PTR), value :: farg1 +integer(C_INT) :: fresult +end function + +function swigc_FSUNAdaptController_SetDefaults_ImExGus(farg1) & +bind(C, name="_wrap_FSUNAdaptController_SetDefaults_ImExGus") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +type(C_PTR), value :: farg1 +integer(C_INT) :: fresult +end function + +function swigc_FSUNAdaptController_Write_ImExGus(farg1, farg2) & +bind(C, name="_wrap_FSUNAdaptController_Write_ImExGus") & +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_FSUNAdaptController_SetMethodOrder_ImExGus(farg1, farg2, farg3) & +bind(C, name="_wrap_FSUNAdaptController_SetMethodOrder_ImExGus") & +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_FSUNAdaptController_AdjustControllerOrder_ImExGus(farg1, farg2) & +bind(C, name="_wrap_FSUNAdaptController_AdjustControllerOrder_ImExGus") & +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_FSUNAdaptController_SetErrorBias_ImExGus(farg1, farg2) & +bind(C, name="_wrap_FSUNAdaptController_SetErrorBias_ImExGus") & +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_FSUNAdaptController_Update_ImExGus(farg1, farg2, farg3) & +bind(C, name="_wrap_FSUNAdaptController_Update_ImExGus") & +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_FSUNAdaptController_Space_ImExGus(farg1, farg2, farg3) & +bind(C, name="_wrap_FSUNAdaptController_Space_ImExGus") & +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 + +end interface + + +contains + ! MODULE SUBPROGRAMS +function FSUNAdaptController_ImExGus(sunctx) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +type(SUNAdaptController), pointer :: swig_result +type(C_PTR) :: sunctx +type(C_PTR) :: fresult +type(C_PTR) :: farg1 + +farg1 = sunctx +fresult = swigc_FSUNAdaptController_ImExGus(farg1) +call c_f_pointer(fresult, swig_result) +end function + +function FSUNAdaptController_SetParams_ImExGus(c, pq, k1e, k2e, k1i, k2i) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(SUNAdaptController), target, intent(inout) :: c +integer(C_INT), intent(in) :: pq +real(C_DOUBLE), intent(in) :: k1e +real(C_DOUBLE), intent(in) :: k2e +real(C_DOUBLE), intent(in) :: k1i +real(C_DOUBLE), intent(in) :: k2i +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +integer(C_INT) :: farg2 +real(C_DOUBLE) :: farg3 +real(C_DOUBLE) :: farg4 +real(C_DOUBLE) :: farg5 +real(C_DOUBLE) :: farg6 + +farg1 = c_loc(c) +farg2 = pq +farg3 = k1e +farg4 = k2e +farg5 = k1i +farg6 = k2i +fresult = swigc_FSUNAdaptController_SetParams_ImExGus(farg1, farg2, farg3, farg4, farg5, farg6) +swig_result = fresult +end function + +function FSUNAdaptController_GetType_ImExGus(c) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(SUNAdaptController_Type) :: swig_result +type(SUNAdaptController), target, intent(inout) :: c +integer(C_INT) :: fresult +type(C_PTR) :: farg1 + +farg1 = c_loc(c) +fresult = swigc_FSUNAdaptController_GetType_ImExGus(farg1) +swig_result = fresult +end function + +function FSUNAdaptController_EstimateStep_ImExGus(c, h, dsm, hnew) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(SUNAdaptController), target, intent(inout) :: c +real(C_DOUBLE), intent(in) :: h +real(C_DOUBLE), intent(in) :: dsm +real(C_DOUBLE), target, intent(inout) :: hnew +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +real(C_DOUBLE) :: farg2 +real(C_DOUBLE) :: farg3 +type(C_PTR) :: farg4 + +farg1 = c_loc(c) +farg2 = h +farg3 = dsm +farg4 = c_loc(hnew) +fresult = swigc_FSUNAdaptController_EstimateStep_ImExGus(farg1, farg2, farg3, farg4) +swig_result = fresult +end function + +function FSUNAdaptController_Reset_ImExGus(c) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(SUNAdaptController), target, intent(inout) :: c +integer(C_INT) :: fresult +type(C_PTR) :: farg1 + +farg1 = c_loc(c) +fresult = swigc_FSUNAdaptController_Reset_ImExGus(farg1) +swig_result = fresult +end function + +function FSUNAdaptController_SetDefaults_ImExGus(c) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(SUNAdaptController), target, intent(inout) :: c +integer(C_INT) :: fresult +type(C_PTR) :: farg1 + +farg1 = c_loc(c) +fresult = swigc_FSUNAdaptController_SetDefaults_ImExGus(farg1) +swig_result = fresult +end function + +function FSUNAdaptController_Write_ImExGus(c, fptr) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(SUNAdaptController), target, intent(inout) :: c +type(C_PTR) :: fptr +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 + +farg1 = c_loc(c) +farg2 = fptr +fresult = swigc_FSUNAdaptController_Write_ImExGus(farg1, farg2) +swig_result = fresult +end function + +function FSUNAdaptController_SetMethodOrder_ImExGus(c, p, q) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(SUNAdaptController), target, intent(inout) :: c +integer(C_INT), intent(in) :: p +integer(C_INT), intent(in) :: q +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +integer(C_INT) :: farg2 +integer(C_INT) :: farg3 + +farg1 = c_loc(c) +farg2 = p +farg3 = q +fresult = swigc_FSUNAdaptController_SetMethodOrder_ImExGus(farg1, farg2, farg3) +swig_result = fresult +end function + +function FSUNAdaptController_AdjustControllerOrder_ImExGus(c, adj) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(SUNAdaptController), target, intent(inout) :: c +integer(C_INT), intent(in) :: adj +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +integer(C_INT) :: farg2 + +farg1 = c_loc(c) +farg2 = adj +fresult = swigc_FSUNAdaptController_AdjustControllerOrder_ImExGus(farg1, farg2) +swig_result = fresult +end function + +function FSUNAdaptController_SetErrorBias_ImExGus(c, bias) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(SUNAdaptController), target, intent(inout) :: c +real(C_DOUBLE), intent(in) :: bias +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +real(C_DOUBLE) :: farg2 + +farg1 = c_loc(c) +farg2 = bias +fresult = swigc_FSUNAdaptController_SetErrorBias_ImExGus(farg1, farg2) +swig_result = fresult +end function + +function FSUNAdaptController_Update_ImExGus(c, h, dsm) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(SUNAdaptController), target, intent(inout) :: c +real(C_DOUBLE), intent(in) :: h +real(C_DOUBLE), intent(in) :: dsm +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +real(C_DOUBLE) :: farg2 +real(C_DOUBLE) :: farg3 + +farg1 = c_loc(c) +farg2 = h +farg3 = dsm +fresult = swigc_FSUNAdaptController_Update_ImExGus(farg1, farg2, farg3) +swig_result = fresult +end function + +function FSUNAdaptController_Space_ImExGus(c, lenrw, leniw) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(SUNAdaptController), target, intent(inout) :: c +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 = c_loc(c) +farg2 = c_loc(lenrw(1)) +farg3 = c_loc(leniw(1)) +fresult = swigc_FSUNAdaptController_Space_ImExGus(farg1, farg2, farg3) +swig_result = fresult +end function + + +end module diff --git a/src/sunadaptcontroller/imexgus/sunadaptcontroller_imexgus.c b/src/sunadaptcontroller/imexgus/sunadaptcontroller_imexgus.c new file mode 100644 index 0000000000..7a1ef93007 --- /dev/null +++ b/src/sunadaptcontroller/imexgus/sunadaptcontroller_imexgus.c @@ -0,0 +1,273 @@ +/* ----------------------------------------------------------------- + * Programmer(s): Daniel R. Reynolds @ SMU + * ----------------------------------------------------------------- + * SUNDIALS Copyright Start + * Copyright (c) 2002-2023, Lawrence Livermore National Security + * and Southern Methodist University. + * All rights reserved. + * + * See the top-level LICENSE and NOTICE files for details. + * + * SPDX-License-Identifier: BSD-3-Clause + * SUNDIALS Copyright End + * ----------------------------------------------------------------- + * This is the implementation file for the SUNAdaptController_ImExGus + * module. + * -----------------------------------------------------------------*/ + +#include +#include +#include +#include + + +/* --------------- + * Macro accessors + * --------------- */ + +#define SACIMEXGUS_CONTENT(C) ( (SUNAdaptControllerContent_ImExGus)(C->content) ) +#define SACIMEXGUS_K1E(C) ( SACIMEXGUS_CONTENT(C)->k1e ) +#define SACIMEXGUS_K2E(C) ( SACIMEXGUS_CONTENT(C)->k2e ) +#define SACIMEXGUS_K1I(C) ( SACIMEXGUS_CONTENT(C)->k1i ) +#define SACIMEXGUS_K2I(C) ( SACIMEXGUS_CONTENT(C)->k2i ) +#define SACIMEXGUS_BIAS(C) ( SACIMEXGUS_CONTENT(C)->bias ) +#define SACIMEXGUS_EP(C) ( SACIMEXGUS_CONTENT(C)->ep ) +#define SACIMEXGUS_HP(C) ( SACIMEXGUS_CONTENT(C)->hp ) +#define SACIMEXGUS_P(C) ( SACIMEXGUS_CONTENT(C)->p ) +#define SACIMEXGUS_PQ(C) ( SACIMEXGUS_CONTENT(C)->pq ) +#define SACIMEXGUS_ADJ(C) ( SACIMEXGUS_CONTENT(C)->adj ) +#define SACIMEXGUS_FIRSTSTEP(C) ( SACIMEXGUS_CONTENT(C)->firststep ) + +/* ------------------ + * Default parameters + * ------------------ */ + +#define DEFAULT_K1E RCONST(0.367) +#define DEFAULT_K2E RCONST(0.268) +#define DEFAULT_K1I RCONST(0.95) +#define DEFAULT_K2I RCONST(0.95) +#define DEFAULT_BIAS RCONST(1.5) +#define DEFAULT_PQ 0 +#define DEFAULT_ADJ -1 +/* #define DEFAULT_PQ -1 */ +/* #define DEFAULT_ADJ 0 */ +#define TINY RCONST(1.0e-10) + + +/* ----------------------------------------------------------------- + * exported functions + * ----------------------------------------------------------------- */ + +/* ----------------------------------------------------------------- + * Function to create a new ImExGus controller + */ + +SUNAdaptController SUNAdaptController_ImExGus(SUNContext sunctx) +{ + SUNAdaptController C; + SUNAdaptControllerContent_ImExGus content; + + /* Create an empty controller object */ + C = NULL; + C = SUNAdaptController_NewEmpty(sunctx); + if (C == NULL) { return (NULL); } + + /* Attach operations */ + C->ops->gettype = SUNAdaptController_GetType_ImExGus; + C->ops->estimatestep = SUNAdaptController_EstimateStep_ImExGus; + C->ops->reset = SUNAdaptController_Reset_ImExGus; + C->ops->setdefaults = SUNAdaptController_SetDefaults_ImExGus; + C->ops->write = SUNAdaptController_Write_ImExGus; + C->ops->setmethodorder = SUNAdaptController_SetMethodOrder_ImExGus; + C->ops->adjustcontrollerorder = SUNAdaptController_AdjustControllerOrder_ImExGus; + C->ops->seterrorbias = SUNAdaptController_SetErrorBias_ImExGus; + C->ops->update = SUNAdaptController_Update_ImExGus; + C->ops->space = SUNAdaptController_Space_ImExGus; + + /* Create content */ + content = NULL; + content = (SUNAdaptControllerContent_ImExGus)malloc(sizeof *content); + if (content == NULL) + { + (void) SUNAdaptController_Destroy(C); + return (NULL); + } + + /* Attach content */ + C->content = content; + + /* Initialize method order */ + content->p = 1; + + /* Fill content with default/reset values */ + SUNAdaptController_SetDefaults_ImExGus(C); + SUNAdaptController_Reset_ImExGus(C); + + return (C); +} + +/* ----------------------------------------------------------------- + * Function to set ImExGus parameters + */ + +int SUNAdaptController_SetParams_ImExGus(SUNAdaptController C, int pq, + sunrealtype k1e, sunrealtype k2e, + sunrealtype k1i, sunrealtype k2i) +{ + /* store legal inputs, and return with success */ + SACIMEXGUS_PQ(C) = pq; + if (k1e >= RCONST(0.0)) { SACIMEXGUS_K1E(C) = k1e; } + if (k2e >= RCONST(0.0)) { SACIMEXGUS_K2E(C) = k2e; } + if (k1i >= RCONST(0.0)) { SACIMEXGUS_K1I(C) = k1i; } + if (k2i >= RCONST(0.0)) { SACIMEXGUS_K2I(C) = k2i; } + return SUNADAPTCONTROLLER_SUCCESS; +} + + + +/* ----------------------------------------------------------------- + * implementation of controller operations + * ----------------------------------------------------------------- */ + +SUNAdaptController_Type SUNAdaptController_GetType_ImExGus(SUNAdaptController C) +{ return SUN_ADAPTCONTROLLER_H; } + +int SUNAdaptController_EstimateStep_ImExGus(SUNAdaptController C, sunrealtype h, + sunrealtype dsm, sunrealtype* hnew) +{ + /* order parameter to use */ + const int ord = SACIMEXGUS_P(C) + SACIMEXGUS_ADJ(C) + 1; + + /* modified method for first step */ + if (SACIMEXGUS_FIRSTSTEP(C)) + { + /* set usable time-step adaptivity parameters */ + const sunrealtype k = -RCONST(1.0) / ord; + const sunrealtype e = SUNMAX(SACIMEXGUS_BIAS(C) * dsm, TINY); + + /* compute estimated optimal time step size */ + *hnew = h * SUNRpowerR(e,k); + } + else + { + /* set usable time-step adaptivity parameters */ + const sunrealtype k1e = -SACIMEXGUS_K1E(C) / ord; + const sunrealtype k2e = -SACIMEXGUS_K2E(C) / ord; + const sunrealtype k1i = -SACIMEXGUS_K1I(C) / ord; + const sunrealtype k2i = -SACIMEXGUS_K2I(C) / ord; + const sunrealtype e1 = SUNMAX(SACIMEXGUS_BIAS(C) * dsm, TINY); + const sunrealtype e2 = e1 / SUNMAX(SACIMEXGUS_EP(C), TINY); + const sunrealtype hrat = h / SACIMEXGUS_HP(C); + + /* compute estimated optimal time step size */ + *hnew = h * SUNMIN(hrat * SUNRpowerR(e1,k1i) * SUNRpowerR(e2,k2i), + SUNRpowerR(e1,k1e) * SUNRpowerR(e2,k2e)); + } + + /* return with success */ + return SUNADAPTCONTROLLER_SUCCESS; +} + +int SUNAdaptController_Reset_ImExGus(SUNAdaptController C) +{ + SACIMEXGUS_EP(C) = RCONST(1.0); + SACIMEXGUS_FIRSTSTEP(C) = SUNTRUE; + return SUNADAPTCONTROLLER_SUCCESS; +} + +int SUNAdaptController_SetDefaults_ImExGus(SUNAdaptController C) +{ + SACIMEXGUS_K1E(C) = DEFAULT_K1E; + SACIMEXGUS_K2E(C) = DEFAULT_K2E; + SACIMEXGUS_K1I(C) = DEFAULT_K1I; + SACIMEXGUS_K2I(C) = DEFAULT_K2I; + SACIMEXGUS_BIAS(C) = DEFAULT_BIAS; + SACIMEXGUS_PQ(C) = DEFAULT_PQ; + SACIMEXGUS_ADJ(C) = DEFAULT_ADJ; + return SUNADAPTCONTROLLER_SUCCESS; +} + +int SUNAdaptController_Write_ImExGus(SUNAdaptController C, FILE *fptr) +{ + fprintf(fptr, "ImEx Gustafsson SUNAdaptController module:\n"); +#if defined(SUNDIALS_EXTENDED_PRECISION) + fprintf(fptr, " k1e = %32Lg\n", SACIMEXGUS_K1E(C)); + fprintf(fptr, " k2e = %32Lg\n", SACIMEXGUS_K2E(C)); + fprintf(fptr, " k1i = %32Lg\n", SACIMEXGUS_K1I(C)); + fprintf(fptr, " k2i = %32Lg\n", SACIMEXGUS_K2I(C)); + fprintf(fptr, " bias factor = %22Lg\n", SACIMEXGUS_BIAS(C)); + fprintf(fptr, " previous error = %22Lg\n", SACIMEXGUS_EP(C)); + fprintf(fptr, " previous step = %22Lg\n", SACIMEXGUS_HP(C)); +#else + fprintf(fptr, " k1e = %16g\n", SACIMEXGUS_K1E(C)); + fprintf(fptr, " k2e = %16g\n", SACIMEXGUS_K2E(C)); + fprintf(fptr, " k1i = %16g\n", SACIMEXGUS_K1I(C)); + fprintf(fptr, " k2i = %16g\n", SACIMEXGUS_K2I(C)); + fprintf(fptr, " bias factor = %16g\n", SACIMEXGUS_BIAS(C)); + fprintf(fptr, " previous error = %16g\n", SACIMEXGUS_EP(C)); + fprintf(fptr, " previous step = %16g\n", SACIMEXGUS_HP(C)); +#endif + if (SACIMEXGUS_PQ(C) == 1) + { + fprintf(fptr, " p = %i (method order)\n", SACIMEXGUS_P(C)); + } + else if (SACIMEXGUS_PQ(C) == 0) + { + fprintf(fptr, " p = %i (embedding order)\n", SACIMEXGUS_P(C)); + } + else + { + fprintf(fptr, " p = %i (minimum of method & embedding order)\n", SACIMEXGUS_P(C)); + } + fprintf(fptr, " adj = %i\n", SACIMEXGUS_ADJ(C)); + return SUNADAPTCONTROLLER_SUCCESS; +} + +int SUNAdaptController_SetMethodOrder_ImExGus(SUNAdaptController C, int p, int q) +{ + /* check for legal inputs */ + if ((p <= 0) || (q <= 0)) { return SUNADAPTCONTROLLER_ILL_INPUT; } + + /* store appropriate value based on "pq" */ + if (SACIMEXGUS_PQ(C) == 1) { + SACIMEXGUS_P(C) = p; + } else if (SACIMEXGUS_PQ(C) == 0) { + SACIMEXGUS_P(C) = q; + } else { + SACIMEXGUS_P(C) = SUNMIN(p,q); + } + return SUNADAPTCONTROLLER_SUCCESS; +} + +int SUNAdaptController_AdjustControllerOrder_ImExGus(SUNAdaptController C, int adj) +{ + SACIMEXGUS_ADJ(C) = adj; + return SUNADAPTCONTROLLER_SUCCESS; +} + +int SUNAdaptController_SetErrorBias_ImExGus(SUNAdaptController C, sunrealtype bias) +{ + /* set allowed value, otherwise set default */ + if (bias <= RCONST(0.0)) { + SACIMEXGUS_BIAS(C) = DEFAULT_BIAS; + } else { + SACIMEXGUS_BIAS(C) = bias; + } + + return SUNADAPTCONTROLLER_SUCCESS; +} + +int SUNAdaptController_Update_ImExGus(SUNAdaptController C, sunrealtype h, sunrealtype dsm) +{ + SACIMEXGUS_EP(C) = SACIMEXGUS_BIAS(C) * dsm; + SACIMEXGUS_HP(C) = h; + SACIMEXGUS_FIRSTSTEP(C) = SUNFALSE; + return SUNADAPTCONTROLLER_SUCCESS; +} + +int SUNAdaptController_Space_ImExGus(SUNAdaptController C, long int* lenrw, long int* leniw) +{ + *lenrw = 8; + *leniw = 4; + return SUNADAPTCONTROLLER_SUCCESS; +} diff --git a/src/sunadaptcontroller/impgus/CMakeLists.txt b/src/sunadaptcontroller/impgus/CMakeLists.txt new file mode 100644 index 0000000000..0cd952c05f --- /dev/null +++ b/src/sunadaptcontroller/impgus/CMakeLists.txt @@ -0,0 +1,29 @@ +# --------------------------------------------------------------- +# Programmer(s): Daniel R. Reynolds @ SMU +# --------------------------------------------------------------- +# SUNDIALS Copyright Start +# Copyright (c) 2002-2023, 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 +# --------------------------------------------------------------- + +# Create a library out of the generic sundials modules +sundials_add_library(sundials_sunadaptcontrollerimpgus + SOURCES + sunadaptcontroller_impgus.c + HEADERS + ${SUNDIALS_SOURCE_DIR}/include/sunadaptcontroller/sunadaptcontroller_impgus.h + INCLUDE_SUBDIR + sunadaptcontroller + OBJECT_LIB_ONLY +) + +# Add F2003 module if the interface is enabled +if(BUILD_FORTRAN_MODULE_INTERFACE) + add_subdirectory(fmod) +endif() diff --git a/src/sunadaptcontroller/impgus/fmod/CMakeLists.txt b/src/sunadaptcontroller/impgus/fmod/CMakeLists.txt new file mode 100644 index 0000000000..ed5ff03515 --- /dev/null +++ b/src/sunadaptcontroller/impgus/fmod/CMakeLists.txt @@ -0,0 +1,25 @@ +# --------------------------------------------------------------- +# Programmer(s): Daniel R. Reynolds @ SMU +# --------------------------------------------------------------- +# SUNDIALS Copyright Start +# Copyright (c) 2002-2023, 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 +# --------------------------------------------------------------- + +sundials_add_f2003_library(sundials_fsunadaptcontrollerimpgus_mod + SOURCES + fsunadaptcontroller_impgus_mod.f90 fsunadaptcontroller_impgus_mod.c + OBJECT_LIBRARIES + sundials_fgeneric_mod_obj + OUTPUT_NAME + sundials_fsunadaptcontrollerimpgus_mod + OBJECT_LIB_ONLY +) + +message(STATUS "Added SUNAdaptController_ImpGus F2003 interface") diff --git a/src/sunadaptcontroller/impgus/fmod/fsunadaptcontroller_impgus_mod.c b/src/sunadaptcontroller/impgus/fmod/fsunadaptcontroller_impgus_mod.c new file mode 100644 index 0000000000..0b9d713e81 --- /dev/null +++ b/src/sunadaptcontroller/impgus/fmod/fsunadaptcontroller_impgus_mod.c @@ -0,0 +1,385 @@ +/* ---------------------------------------------------------------------------- + * This file was automatically generated by SWIG (http://www.swig.org). + * Version 4.0.0 + * + * This file is not intended to be easily readable and contains a number of + * coding conventions designed to improve portability and efficiency. Do not make + * changes to this file unless you know what you are doing--modify the SWIG + * interface file instead. + * ----------------------------------------------------------------------------- */ + +/* --------------------------------------------------------------- + * Programmer(s): Auto-generated by swig. + * --------------------------------------------------------------- + * SUNDIALS Copyright Start + * Copyright (c) 2002-2023, Lawrence Livermore National Security + * and Southern Methodist University. + * All rights reserved. + * + * See the top-level LICENSE and NOTICE files for details. + * + * SPDX-License-Identifier: BSD-3-Clause + * SUNDIALS Copyright End + * -------------------------------------------------------------*/ + +/* ----------------------------------------------------------------------------- + * This section contains generic SWIG labels for method/variable + * declarations/attributes, and other compiler dependent labels. + * ----------------------------------------------------------------------------- */ + +/* template workaround for compilers that cannot correctly implement the C++ standard */ +#ifndef SWIGTEMPLATEDISAMBIGUATOR +# if defined(__SUNPRO_CC) && (__SUNPRO_CC <= 0x560) +# define SWIGTEMPLATEDISAMBIGUATOR template +# elif defined(__HP_aCC) +/* Needed even with `aCC -AA' when `aCC -V' reports HP ANSI C++ B3910B A.03.55 */ +/* If we find a maximum version that requires this, the test would be __HP_aCC <= 35500 for A.03.55 */ +# define SWIGTEMPLATEDISAMBIGUATOR template +# else +# define SWIGTEMPLATEDISAMBIGUATOR +# endif +#endif + +/* inline attribute */ +#ifndef SWIGINLINE +# if defined(__cplusplus) || (defined(__GNUC__) && !defined(__STRICT_ANSI__)) +# define SWIGINLINE inline +# else +# define SWIGINLINE +# endif +#endif + +/* attribute recognised by some compilers to avoid 'unused' warnings */ +#ifndef SWIGUNUSED +# if defined(__GNUC__) +# if !(defined(__cplusplus)) || (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)) +# define SWIGUNUSED __attribute__ ((__unused__)) +# else +# define SWIGUNUSED +# endif +# elif defined(__ICC) +# define SWIGUNUSED __attribute__ ((__unused__)) +# else +# define SWIGUNUSED +# endif +#endif + +#ifndef SWIG_MSC_UNSUPPRESS_4505 +# if defined(_MSC_VER) +# pragma warning(disable : 4505) /* unreferenced local function has been removed */ +# endif +#endif + +#ifndef SWIGUNUSEDPARM +# ifdef __cplusplus +# define SWIGUNUSEDPARM(p) +# else +# define SWIGUNUSEDPARM(p) p SWIGUNUSED +# endif +#endif + +/* internal SWIG method */ +#ifndef SWIGINTERN +# define SWIGINTERN static SWIGUNUSED +#endif + +/* internal inline SWIG method */ +#ifndef SWIGINTERNINLINE +# define SWIGINTERNINLINE SWIGINTERN SWIGINLINE +#endif + +/* qualifier for exported *const* global data variables*/ +#ifndef SWIGEXTERN +# ifdef __cplusplus +# define SWIGEXTERN extern +# else +# define SWIGEXTERN +# endif +#endif + +/* exporting methods */ +#if defined(__GNUC__) +# if (__GNUC__ >= 4) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) +# ifndef GCC_HASCLASSVISIBILITY +# define GCC_HASCLASSVISIBILITY +# endif +# endif +#endif + +#ifndef SWIGEXPORT +# if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__) +# if defined(STATIC_LINKED) +# define SWIGEXPORT +# else +# define SWIGEXPORT __declspec(dllexport) +# endif +# else +# if defined(__GNUC__) && defined(GCC_HASCLASSVISIBILITY) +# define SWIGEXPORT __attribute__ ((visibility("default"))) +# else +# define SWIGEXPORT +# endif +# endif +#endif + +/* calling conventions for Windows */ +#ifndef SWIGSTDCALL +# if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__) +# define SWIGSTDCALL __stdcall +# else +# define SWIGSTDCALL +# endif +#endif + +/* Deal with Microsoft's attempt at deprecating C standard runtime functions */ +#if !defined(SWIG_NO_CRT_SECURE_NO_DEPRECATE) && defined(_MSC_VER) && !defined(_CRT_SECURE_NO_DEPRECATE) +# define _CRT_SECURE_NO_DEPRECATE +#endif + +/* Deal with Microsoft's attempt at deprecating methods in the standard C++ library */ +#if !defined(SWIG_NO_SCL_SECURE_NO_DEPRECATE) && defined(_MSC_VER) && !defined(_SCL_SECURE_NO_DEPRECATE) +# define _SCL_SECURE_NO_DEPRECATE +#endif + +/* Deal with Apple's deprecated 'AssertMacros.h' from Carbon-framework */ +#if defined(__APPLE__) && !defined(__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES) +# define __ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES 0 +#endif + +/* Intel's compiler complains if a variable which was never initialised is + * cast to void, which is a common idiom which we use to indicate that we + * are aware a variable isn't used. So we just silence that warning. + * See: https://github.com/swig/swig/issues/192 for more discussion. + */ +#ifdef __INTEL_COMPILER +# pragma warning disable 592 +#endif + +/* Errors in SWIG */ +#define SWIG_UnknownError -1 +#define SWIG_IOError -2 +#define SWIG_RuntimeError -3 +#define SWIG_IndexError -4 +#define SWIG_TypeError -5 +#define SWIG_DivisionByZero -6 +#define SWIG_OverflowError -7 +#define SWIG_SyntaxError -8 +#define SWIG_ValueError -9 +#define SWIG_SystemError -10 +#define SWIG_AttributeError -11 +#define SWIG_MemoryError -12 +#define SWIG_NullReferenceError -13 + + + + +#include +#define SWIG_exception_impl(DECL, CODE, MSG, RETURNNULL) \ + { printf("In " DECL ": " MSG); assert(0); RETURNNULL; } + + +#include +#if defined(_MSC_VER) || defined(__BORLANDC__) || defined(_WATCOM) +# ifndef snprintf +# define snprintf _snprintf +# endif +#endif + + +/* Support for the `contract` feature. + * + * Note that RETURNNULL is first because it's inserted via a 'Replaceall' in + * the fortran.cxx file. + */ +#define SWIG_contract_assert(RETURNNULL, EXPR, MSG) \ + if (!(EXPR)) { SWIG_exception_impl("$decl", SWIG_ValueError, MSG, RETURNNULL); } + + +#define SWIGVERSION 0x040000 +#define SWIG_VERSION SWIGVERSION + + +#define SWIG_as_voidptr(a) (void *)((const void *)(a)) +#define SWIG_as_voidptrptr(a) ((void)SWIG_as_voidptr(*a),(void**)(a)) + + +#include "sundials/sundials_adaptcontroller.h" + + +#include "sunadaptcontroller/sunadaptcontroller_impgus.h" + +SWIGEXPORT SUNAdaptController _wrap_FSUNAdaptController_ImpGus(void *farg1) { + SUNAdaptController fresult ; + SUNContext arg1 = (SUNContext) 0 ; + SUNAdaptController result; + + arg1 = (SUNContext)(farg1); + result = (SUNAdaptController)SUNAdaptController_ImpGus(arg1); + fresult = result; + return fresult; +} + + +SWIGEXPORT int _wrap_FSUNAdaptController_SetParams_ImpGus(SUNAdaptController farg1, int const *farg2, double const *farg3, double const *farg4) { + int fresult ; + SUNAdaptController arg1 = (SUNAdaptController) 0 ; + int arg2 ; + sunrealtype arg3 ; + sunrealtype arg4 ; + int result; + + arg1 = (SUNAdaptController)(farg1); + arg2 = (int)(*farg2); + arg3 = (sunrealtype)(*farg3); + arg4 = (sunrealtype)(*farg4); + result = (int)SUNAdaptController_SetParams_ImpGus(arg1,arg2,arg3,arg4); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FSUNAdaptController_GetType_ImpGus(SUNAdaptController farg1) { + int fresult ; + SUNAdaptController arg1 = (SUNAdaptController) 0 ; + SUNAdaptController_Type result; + + arg1 = (SUNAdaptController)(farg1); + result = (SUNAdaptController_Type)SUNAdaptController_GetType_ImpGus(arg1); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FSUNAdaptController_EstimateStep_ImpGus(SUNAdaptController farg1, double const *farg2, double const *farg3, double *farg4) { + int fresult ; + SUNAdaptController arg1 = (SUNAdaptController) 0 ; + sunrealtype arg2 ; + sunrealtype arg3 ; + sunrealtype *arg4 = (sunrealtype *) 0 ; + int result; + + arg1 = (SUNAdaptController)(farg1); + arg2 = (sunrealtype)(*farg2); + arg3 = (sunrealtype)(*farg3); + arg4 = (sunrealtype *)(farg4); + result = (int)SUNAdaptController_EstimateStep_ImpGus(arg1,arg2,arg3,arg4); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FSUNAdaptController_Reset_ImpGus(SUNAdaptController farg1) { + int fresult ; + SUNAdaptController arg1 = (SUNAdaptController) 0 ; + int result; + + arg1 = (SUNAdaptController)(farg1); + result = (int)SUNAdaptController_Reset_ImpGus(arg1); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FSUNAdaptController_SetDefaults_ImpGus(SUNAdaptController farg1) { + int fresult ; + SUNAdaptController arg1 = (SUNAdaptController) 0 ; + int result; + + arg1 = (SUNAdaptController)(farg1); + result = (int)SUNAdaptController_SetDefaults_ImpGus(arg1); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FSUNAdaptController_Write_ImpGus(SUNAdaptController farg1, void *farg2) { + int fresult ; + SUNAdaptController arg1 = (SUNAdaptController) 0 ; + FILE *arg2 = (FILE *) 0 ; + int result; + + arg1 = (SUNAdaptController)(farg1); + arg2 = (FILE *)(farg2); + result = (int)SUNAdaptController_Write_ImpGus(arg1,arg2); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FSUNAdaptController_SetMethodOrder_ImpGus(SUNAdaptController farg1, int const *farg2, int const *farg3) { + int fresult ; + SUNAdaptController arg1 = (SUNAdaptController) 0 ; + int arg2 ; + int arg3 ; + int result; + + arg1 = (SUNAdaptController)(farg1); + arg2 = (int)(*farg2); + arg3 = (int)(*farg3); + result = (int)SUNAdaptController_SetMethodOrder_ImpGus(arg1,arg2,arg3); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FSUNAdaptController_AdjustControllerOrder_ImpGus(SUNAdaptController farg1, int const *farg2) { + int fresult ; + SUNAdaptController arg1 = (SUNAdaptController) 0 ; + int arg2 ; + int result; + + arg1 = (SUNAdaptController)(farg1); + arg2 = (int)(*farg2); + result = (int)SUNAdaptController_AdjustControllerOrder_ImpGus(arg1,arg2); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FSUNAdaptController_SetErrorBias_ImpGus(SUNAdaptController farg1, double const *farg2) { + int fresult ; + SUNAdaptController arg1 = (SUNAdaptController) 0 ; + sunrealtype arg2 ; + int result; + + arg1 = (SUNAdaptController)(farg1); + arg2 = (sunrealtype)(*farg2); + result = (int)SUNAdaptController_SetErrorBias_ImpGus(arg1,arg2); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FSUNAdaptController_Update_ImpGus(SUNAdaptController farg1, double const *farg2, double const *farg3) { + int fresult ; + SUNAdaptController arg1 = (SUNAdaptController) 0 ; + sunrealtype arg2 ; + sunrealtype arg3 ; + int result; + + arg1 = (SUNAdaptController)(farg1); + arg2 = (sunrealtype)(*farg2); + arg3 = (sunrealtype)(*farg3); + result = (int)SUNAdaptController_Update_ImpGus(arg1,arg2,arg3); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FSUNAdaptController_Space_ImpGus(SUNAdaptController farg1, long *farg2, long *farg3) { + int fresult ; + SUNAdaptController arg1 = (SUNAdaptController) 0 ; + long *arg2 = (long *) 0 ; + long *arg3 = (long *) 0 ; + int result; + + arg1 = (SUNAdaptController)(farg1); + arg2 = (long *)(farg2); + arg3 = (long *)(farg3); + result = (int)SUNAdaptController_Space_ImpGus(arg1,arg2,arg3); + fresult = (int)(result); + return fresult; +} + + + diff --git a/src/sunadaptcontroller/impgus/fmod/fsunadaptcontroller_impgus_mod.f90 b/src/sunadaptcontroller/impgus/fmod/fsunadaptcontroller_impgus_mod.f90 new file mode 100644 index 0000000000..508886a19b --- /dev/null +++ b/src/sunadaptcontroller/impgus/fmod/fsunadaptcontroller_impgus_mod.f90 @@ -0,0 +1,363 @@ +! This file was automatically generated by SWIG (http://www.swig.org). +! Version 4.0.0 +! +! Do not make changes to this file unless you know what you are doing--modify +! the SWIG interface file instead. + +! --------------------------------------------------------------- +! Programmer(s): Auto-generated by swig. +! --------------------------------------------------------------- +! SUNDIALS Copyright Start +! Copyright (c) 2002-2023, 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 +! --------------------------------------------------------------- + +module fsunadaptcontroller_impgus_mod + use, intrinsic :: ISO_C_BINDING + use fsundials_adaptcontroller_mod + use fsundials_types_mod + use fsundials_context_mod + implicit none + private + + ! DECLARATION CONSTRUCTS + public :: FSUNAdaptController_ImpGus + public :: FSUNAdaptController_SetParams_ImpGus + public :: FSUNAdaptController_GetType_ImpGus + public :: FSUNAdaptController_EstimateStep_ImpGus + public :: FSUNAdaptController_Reset_ImpGus + public :: FSUNAdaptController_SetDefaults_ImpGus + public :: FSUNAdaptController_Write_ImpGus + public :: FSUNAdaptController_SetMethodOrder_ImpGus + public :: FSUNAdaptController_AdjustControllerOrder_ImpGus + public :: FSUNAdaptController_SetErrorBias_ImpGus + public :: FSUNAdaptController_Update_ImpGus + public :: FSUNAdaptController_Space_ImpGus + +! WRAPPER DECLARATIONS +interface +function swigc_FSUNAdaptController_ImpGus(farg1) & +bind(C, name="_wrap_FSUNAdaptController_ImpGus") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +type(C_PTR), value :: farg1 +type(C_PTR) :: fresult +end function + +function swigc_FSUNAdaptController_SetParams_ImpGus(farg1, farg2, farg3, farg4) & +bind(C, name="_wrap_FSUNAdaptController_SetParams_ImpGus") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +type(C_PTR), value :: farg1 +integer(C_INT), intent(in) :: farg2 +real(C_DOUBLE), intent(in) :: farg3 +real(C_DOUBLE), intent(in) :: farg4 +integer(C_INT) :: fresult +end function + +function swigc_FSUNAdaptController_GetType_ImpGus(farg1) & +bind(C, name="_wrap_FSUNAdaptController_GetType_ImpGus") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +type(C_PTR), value :: farg1 +integer(C_INT) :: fresult +end function + +function swigc_FSUNAdaptController_EstimateStep_ImpGus(farg1, farg2, farg3, farg4) & +bind(C, name="_wrap_FSUNAdaptController_EstimateStep_ImpGus") & +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_PTR), value :: farg4 +integer(C_INT) :: fresult +end function + +function swigc_FSUNAdaptController_Reset_ImpGus(farg1) & +bind(C, name="_wrap_FSUNAdaptController_Reset_ImpGus") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +type(C_PTR), value :: farg1 +integer(C_INT) :: fresult +end function + +function swigc_FSUNAdaptController_SetDefaults_ImpGus(farg1) & +bind(C, name="_wrap_FSUNAdaptController_SetDefaults_ImpGus") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +type(C_PTR), value :: farg1 +integer(C_INT) :: fresult +end function + +function swigc_FSUNAdaptController_Write_ImpGus(farg1, farg2) & +bind(C, name="_wrap_FSUNAdaptController_Write_ImpGus") & +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_FSUNAdaptController_SetMethodOrder_ImpGus(farg1, farg2, farg3) & +bind(C, name="_wrap_FSUNAdaptController_SetMethodOrder_ImpGus") & +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_FSUNAdaptController_AdjustControllerOrder_ImpGus(farg1, farg2) & +bind(C, name="_wrap_FSUNAdaptController_AdjustControllerOrder_ImpGus") & +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_FSUNAdaptController_SetErrorBias_ImpGus(farg1, farg2) & +bind(C, name="_wrap_FSUNAdaptController_SetErrorBias_ImpGus") & +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_FSUNAdaptController_Update_ImpGus(farg1, farg2, farg3) & +bind(C, name="_wrap_FSUNAdaptController_Update_ImpGus") & +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_FSUNAdaptController_Space_ImpGus(farg1, farg2, farg3) & +bind(C, name="_wrap_FSUNAdaptController_Space_ImpGus") & +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 + +end interface + + +contains + ! MODULE SUBPROGRAMS +function FSUNAdaptController_ImpGus(sunctx) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +type(SUNAdaptController), pointer :: swig_result +type(C_PTR) :: sunctx +type(C_PTR) :: fresult +type(C_PTR) :: farg1 + +farg1 = sunctx +fresult = swigc_FSUNAdaptController_ImpGus(farg1) +call c_f_pointer(fresult, swig_result) +end function + +function FSUNAdaptController_SetParams_ImpGus(c, pq, k1, k2) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(SUNAdaptController), target, intent(inout) :: c +integer(C_INT), intent(in) :: pq +real(C_DOUBLE), intent(in) :: k1 +real(C_DOUBLE), intent(in) :: k2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +integer(C_INT) :: farg2 +real(C_DOUBLE) :: farg3 +real(C_DOUBLE) :: farg4 + +farg1 = c_loc(c) +farg2 = pq +farg3 = k1 +farg4 = k2 +fresult = swigc_FSUNAdaptController_SetParams_ImpGus(farg1, farg2, farg3, farg4) +swig_result = fresult +end function + +function FSUNAdaptController_GetType_ImpGus(c) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(SUNAdaptController_Type) :: swig_result +type(SUNAdaptController), target, intent(inout) :: c +integer(C_INT) :: fresult +type(C_PTR) :: farg1 + +farg1 = c_loc(c) +fresult = swigc_FSUNAdaptController_GetType_ImpGus(farg1) +swig_result = fresult +end function + +function FSUNAdaptController_EstimateStep_ImpGus(c, h, dsm, hnew) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(SUNAdaptController), target, intent(inout) :: c +real(C_DOUBLE), intent(in) :: h +real(C_DOUBLE), intent(in) :: dsm +real(C_DOUBLE), target, intent(inout) :: hnew +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +real(C_DOUBLE) :: farg2 +real(C_DOUBLE) :: farg3 +type(C_PTR) :: farg4 + +farg1 = c_loc(c) +farg2 = h +farg3 = dsm +farg4 = c_loc(hnew) +fresult = swigc_FSUNAdaptController_EstimateStep_ImpGus(farg1, farg2, farg3, farg4) +swig_result = fresult +end function + +function FSUNAdaptController_Reset_ImpGus(c) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(SUNAdaptController), target, intent(inout) :: c +integer(C_INT) :: fresult +type(C_PTR) :: farg1 + +farg1 = c_loc(c) +fresult = swigc_FSUNAdaptController_Reset_ImpGus(farg1) +swig_result = fresult +end function + +function FSUNAdaptController_SetDefaults_ImpGus(c) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(SUNAdaptController), target, intent(inout) :: c +integer(C_INT) :: fresult +type(C_PTR) :: farg1 + +farg1 = c_loc(c) +fresult = swigc_FSUNAdaptController_SetDefaults_ImpGus(farg1) +swig_result = fresult +end function + +function FSUNAdaptController_Write_ImpGus(c, fptr) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(SUNAdaptController), target, intent(inout) :: c +type(C_PTR) :: fptr +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 + +farg1 = c_loc(c) +farg2 = fptr +fresult = swigc_FSUNAdaptController_Write_ImpGus(farg1, farg2) +swig_result = fresult +end function + +function FSUNAdaptController_SetMethodOrder_ImpGus(c, p, q) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(SUNAdaptController), target, intent(inout) :: c +integer(C_INT), intent(in) :: p +integer(C_INT), intent(in) :: q +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +integer(C_INT) :: farg2 +integer(C_INT) :: farg3 + +farg1 = c_loc(c) +farg2 = p +farg3 = q +fresult = swigc_FSUNAdaptController_SetMethodOrder_ImpGus(farg1, farg2, farg3) +swig_result = fresult +end function + +function FSUNAdaptController_AdjustControllerOrder_ImpGus(c, adj) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(SUNAdaptController), target, intent(inout) :: c +integer(C_INT), intent(in) :: adj +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +integer(C_INT) :: farg2 + +farg1 = c_loc(c) +farg2 = adj +fresult = swigc_FSUNAdaptController_AdjustControllerOrder_ImpGus(farg1, farg2) +swig_result = fresult +end function + +function FSUNAdaptController_SetErrorBias_ImpGus(c, bias) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(SUNAdaptController), target, intent(inout) :: c +real(C_DOUBLE), intent(in) :: bias +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +real(C_DOUBLE) :: farg2 + +farg1 = c_loc(c) +farg2 = bias +fresult = swigc_FSUNAdaptController_SetErrorBias_ImpGus(farg1, farg2) +swig_result = fresult +end function + +function FSUNAdaptController_Update_ImpGus(c, h, dsm) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(SUNAdaptController), target, intent(inout) :: c +real(C_DOUBLE), intent(in) :: h +real(C_DOUBLE), intent(in) :: dsm +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +real(C_DOUBLE) :: farg2 +real(C_DOUBLE) :: farg3 + +farg1 = c_loc(c) +farg2 = h +farg3 = dsm +fresult = swigc_FSUNAdaptController_Update_ImpGus(farg1, farg2, farg3) +swig_result = fresult +end function + +function FSUNAdaptController_Space_ImpGus(c, lenrw, leniw) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(SUNAdaptController), target, intent(inout) :: c +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 = c_loc(c) +farg2 = c_loc(lenrw(1)) +farg3 = c_loc(leniw(1)) +fresult = swigc_FSUNAdaptController_Space_ImpGus(farg1, farg2, farg3) +swig_result = fresult +end function + + +end module diff --git a/src/sunadaptcontroller/impgus/sunadaptcontroller_impgus.c b/src/sunadaptcontroller/impgus/sunadaptcontroller_impgus.c new file mode 100644 index 0000000000..06990894ef --- /dev/null +++ b/src/sunadaptcontroller/impgus/sunadaptcontroller_impgus.c @@ -0,0 +1,258 @@ +/* ----------------------------------------------------------------- + * Programmer(s): Daniel R. Reynolds @ SMU + * ----------------------------------------------------------------- + * SUNDIALS Copyright Start + * Copyright (c) 2002-2023, Lawrence Livermore National Security + * and Southern Methodist University. + * All rights reserved. + * + * See the top-level LICENSE and NOTICE files for details. + * + * SPDX-License-Identifier: BSD-3-Clause + * SUNDIALS Copyright End + * ----------------------------------------------------------------- + * This is the implementation file for the SUNAdaptController_ImpGus + * module. + * -----------------------------------------------------------------*/ + +#include +#include +#include +#include + + +/* --------------- + * Macro accessors + * --------------- */ + +#define SACIMPGUS_CONTENT(C) ( (SUNAdaptControllerContent_ImpGus)(C->content) ) +#define SACIMPGUS_K1(C) ( SACIMPGUS_CONTENT(C)->k1 ) +#define SACIMPGUS_K2(C) ( SACIMPGUS_CONTENT(C)->k2 ) +#define SACIMPGUS_BIAS(C) ( SACIMPGUS_CONTENT(C)->bias ) +#define SACIMPGUS_EP(C) ( SACIMPGUS_CONTENT(C)->ep ) +#define SACIMPGUS_HP(C) ( SACIMPGUS_CONTENT(C)->hp ) +#define SACIMPGUS_P(C) ( SACIMPGUS_CONTENT(C)->p ) +#define SACIMPGUS_PQ(C) ( SACIMPGUS_CONTENT(C)->pq ) +#define SACIMPGUS_ADJ(C) ( SACIMPGUS_CONTENT(C)->adj ) +#define SACIMPGUS_FIRSTSTEP(C) ( SACIMPGUS_CONTENT(C)->firststep ) + +/* ------------------ + * Default parameters + * ------------------ */ + +#define DEFAULT_K1 RCONST(0.98) +#define DEFAULT_K2 RCONST(0.95) +#define DEFAULT_BIAS RCONST(1.5) +#define DEFAULT_PQ 0 +#define DEFAULT_ADJ -1 +/* #define DEFAULT_PQ -1 */ +/* #define DEFAULT_ADJ 0 */ +#define TINY RCONST(1.0e-10) + + +/* ----------------------------------------------------------------- + * exported functions + * ----------------------------------------------------------------- */ + +/* ----------------------------------------------------------------- + * Function to create a new ImpGus controller + */ + +SUNAdaptController SUNAdaptController_ImpGus(SUNContext sunctx) +{ + SUNAdaptController C; + SUNAdaptControllerContent_ImpGus content; + + /* Create an empty controller object */ + C = NULL; + C = SUNAdaptController_NewEmpty(sunctx); + if (C == NULL) { return (NULL); } + + /* Attach operations */ + C->ops->gettype = SUNAdaptController_GetType_ImpGus; + C->ops->estimatestep = SUNAdaptController_EstimateStep_ImpGus; + C->ops->reset = SUNAdaptController_Reset_ImpGus; + C->ops->setdefaults = SUNAdaptController_SetDefaults_ImpGus; + C->ops->write = SUNAdaptController_Write_ImpGus; + C->ops->setmethodorder = SUNAdaptController_SetMethodOrder_ImpGus; + C->ops->adjustcontrollerorder = SUNAdaptController_AdjustControllerOrder_ImpGus; + C->ops->seterrorbias = SUNAdaptController_SetErrorBias_ImpGus; + C->ops->update = SUNAdaptController_Update_ImpGus; + C->ops->space = SUNAdaptController_Space_ImpGus; + + /* Create content */ + content = NULL; + content = (SUNAdaptControllerContent_ImpGus)malloc(sizeof *content); + if (content == NULL) + { + (void) SUNAdaptController_Destroy(C); + return (NULL); + } + + /* Attach content */ + C->content = content; + + /* Initialize method order */ + content->p = 1; + + /* Fill content with default/reset values */ + SUNAdaptController_SetDefaults_ImpGus(C); + SUNAdaptController_Reset_ImpGus(C); + + return (C); +} + +/* ----------------------------------------------------------------- + * Function to set ImpGus parameters + */ + +int SUNAdaptController_SetParams_ImpGus(SUNAdaptController C, int pq, + sunrealtype k1, sunrealtype k2) +{ + /* store legal inputs, and return with success */ + SACIMPGUS_PQ(C) = pq; + if (k1 >= RCONST(0.0)) { SACIMPGUS_K1(C) = k1; } + if (k2 >= RCONST(0.0)) { SACIMPGUS_K2(C) = k2; } + return SUNADAPTCONTROLLER_SUCCESS; +} + + + +/* ----------------------------------------------------------------- + * implementation of controller operations + * ----------------------------------------------------------------- */ + +SUNAdaptController_Type SUNAdaptController_GetType_ImpGus(SUNAdaptController C) +{ return SUN_ADAPTCONTROLLER_H; } + +int SUNAdaptController_EstimateStep_ImpGus(SUNAdaptController C, sunrealtype h, + sunrealtype dsm, sunrealtype* hnew) +{ + /* order parameter to use */ + const int ord = SACIMPGUS_P(C) + SACIMPGUS_ADJ(C) + 1; + + /* modified method for first step */ + if (SACIMPGUS_FIRSTSTEP(C)) + { + /* set usable time-step adaptivity parameters */ + const sunrealtype k = -RCONST(1.0) / ord; + const sunrealtype e = SUNMAX(SACIMPGUS_BIAS(C) * dsm, TINY); + + /* compute estimated optimal time step size */ + *hnew = h * SUNRpowerR(e,k); + } + else + { + /* set usable time-step adaptivity parameters */ + const sunrealtype k1 = -SACIMPGUS_K1(C) / ord; + const sunrealtype k2 = -SACIMPGUS_K2(C) / ord; + const sunrealtype ecur = SACIMPGUS_BIAS(C) * dsm; + const sunrealtype e1 = SUNMAX(ecur, TINY); + const sunrealtype e2 = e1 / SUNMAX(SACIMPGUS_EP(C), TINY); + const sunrealtype hrat = h / SACIMPGUS_HP(C); + + /* compute estimated optimal time step size */ + *hnew = h * hrat * SUNRpowerR(e1,k1) * SUNRpowerR(e2,k2); + } + + /* return with success */ + return SUNADAPTCONTROLLER_SUCCESS; +} + +int SUNAdaptController_Reset_ImpGus(SUNAdaptController C) +{ + SACIMPGUS_EP(C) = RCONST(1.0); + SACIMPGUS_FIRSTSTEP(C) = SUNTRUE; + return SUNADAPTCONTROLLER_SUCCESS; +} + +int SUNAdaptController_SetDefaults_ImpGus(SUNAdaptController C) +{ + SACIMPGUS_K1(C) = DEFAULT_K1; + SACIMPGUS_K2(C) = DEFAULT_K2; + SACIMPGUS_BIAS(C) = DEFAULT_BIAS; + SACIMPGUS_PQ(C) = DEFAULT_PQ; + SACIMPGUS_ADJ(C) = DEFAULT_ADJ; + return SUNADAPTCONTROLLER_SUCCESS; +} + +int SUNAdaptController_Write_ImpGus(SUNAdaptController C, FILE *fptr) +{ + fprintf(fptr, "Implicit Gustafsson SUNAdaptController module:\n"); +#if defined(SUNDIALS_EXTENDED_PRECISION) + fprintf(fptr, " k1 = %32Lg\n", SACIMPGUS_K1(C)); + fprintf(fptr, " k2 = %32Lg\n", SACIMPGUS_K2(C)); + fprintf(fptr, " bias factor = %32Lg\n", SACIMPGUS_BIAS(C)); + fprintf(fptr, " previous error = %32Lg\n", SACIMPGUS_EP(C)); + fprintf(fptr, " previous step = %32Lg\n", SACIMPGUS_HP(C)); +#else + fprintf(fptr, " k1 = %16g\n", SACIMPGUS_K1(C)); + fprintf(fptr, " k2 = %16g\n", SACIMPGUS_K2(C)); + fprintf(fptr, " bias factor = %16g\n", SACIMPGUS_BIAS(C)); + fprintf(fptr, " previous error = %16g\n", SACIMPGUS_EP(C)); + fprintf(fptr, " previous step = %16g\n", SACIMPGUS_HP(C)); +#endif + if (SACIMPGUS_PQ(C) == 1) + { + fprintf(fptr, " p = %i (method order)\n", SACIMPGUS_P(C)); + } + else if (SACIMPGUS_PQ(C) == 0) + { + fprintf(fptr, " p = %i (embedding order)\n", SACIMPGUS_P(C)); + } + else + { + fprintf(fptr, " p = %i (minimum of method & embedding order)\n", SACIMPGUS_P(C)); + } + fprintf(fptr, " adj = %i\n", SACIMPGUS_ADJ(C)); + return SUNADAPTCONTROLLER_SUCCESS; +} + +int SUNAdaptController_SetMethodOrder_ImpGus(SUNAdaptController C, int p, int q) +{ + /* check for legal inputs */ + if ((p <= 0) || (q <= 0)) { return SUNADAPTCONTROLLER_ILL_INPUT; } + + /* store appropriate value based on "pq" */ + if (SACIMPGUS_PQ(C) == 1) { + SACIMPGUS_P(C) = p; + } else if (SACIMPGUS_PQ(C) == 0) { + SACIMPGUS_P(C) = q; + } else { + SACIMPGUS_P(C) = SUNMIN(p,q); + } + return SUNADAPTCONTROLLER_SUCCESS; +} + +int SUNAdaptController_AdjustControllerOrder_ImpGus(SUNAdaptController C, int adj) +{ + SACIMPGUS_ADJ(C) = adj; + return SUNADAPTCONTROLLER_SUCCESS; +} + +int SUNAdaptController_SetErrorBias_ImpGus(SUNAdaptController C, sunrealtype bias) +{ + /* set allowed value, otherwise set default */ + if (bias <= RCONST(0.0)) { + SACIMPGUS_BIAS(C) = DEFAULT_BIAS; + } else { + SACIMPGUS_BIAS(C) = bias; + } + + return SUNADAPTCONTROLLER_SUCCESS; +} + +int SUNAdaptController_Update_ImpGus(SUNAdaptController C, sunrealtype h, sunrealtype dsm) +{ + SACIMPGUS_EP(C) = SACIMPGUS_BIAS(C) * dsm; + SACIMPGUS_HP(C) = h; + SACIMPGUS_FIRSTSTEP(C) = SUNFALSE; + return SUNADAPTCONTROLLER_SUCCESS; +} + +int SUNAdaptController_Space_ImpGus(SUNAdaptController C, long int* lenrw, long int* leniw) +{ + *lenrw = 6; + *leniw = 4; + return SUNADAPTCONTROLLER_SUCCESS; +} diff --git a/src/sunadaptcontroller/pi/CMakeLists.txt b/src/sunadaptcontroller/pi/CMakeLists.txt new file mode 100644 index 0000000000..c520871959 --- /dev/null +++ b/src/sunadaptcontroller/pi/CMakeLists.txt @@ -0,0 +1,29 @@ +# --------------------------------------------------------------- +# Programmer(s): Daniel R. Reynolds @ SMU +# --------------------------------------------------------------- +# SUNDIALS Copyright Start +# Copyright (c) 2002-2023, 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 +# --------------------------------------------------------------- + +# Create a library out of the generic sundials modules +sundials_add_library(sundials_sunadaptcontrollerpi + SOURCES + sunadaptcontroller_pi.c + HEADERS + ${SUNDIALS_SOURCE_DIR}/include/sunadaptcontroller/sunadaptcontroller_pi.h + INCLUDE_SUBDIR + sunadaptcontroller + OBJECT_LIB_ONLY +) + +# Add F2003 module if the interface is enabled +if(BUILD_FORTRAN_MODULE_INTERFACE) + add_subdirectory(fmod) +endif() diff --git a/src/sunadaptcontroller/pi/fmod/CMakeLists.txt b/src/sunadaptcontroller/pi/fmod/CMakeLists.txt new file mode 100644 index 0000000000..ad55783ce6 --- /dev/null +++ b/src/sunadaptcontroller/pi/fmod/CMakeLists.txt @@ -0,0 +1,25 @@ +# --------------------------------------------------------------- +# Programmer(s): Daniel R. Reynolds @ SMU +# --------------------------------------------------------------- +# SUNDIALS Copyright Start +# Copyright (c) 2002-2023, 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 +# --------------------------------------------------------------- + +sundials_add_f2003_library(sundials_fsunadaptcontrollerpi_mod + SOURCES + fsunadaptcontroller_pi_mod.f90 fsunadaptcontroller_pi_mod.c + OBJECT_LIBRARIES + sundials_fgeneric_mod_obj + OUTPUT_NAME + sundials_fsunadaptcontrollerpi_mod + OBJECT_LIB_ONLY +) + +message(STATUS "Added SUNAdaptController_PI F2003 interface") diff --git a/src/sunadaptcontroller/pi/fmod/fsunadaptcontroller_pi_mod.c b/src/sunadaptcontroller/pi/fmod/fsunadaptcontroller_pi_mod.c new file mode 100644 index 0000000000..2c0f585d3b --- /dev/null +++ b/src/sunadaptcontroller/pi/fmod/fsunadaptcontroller_pi_mod.c @@ -0,0 +1,385 @@ +/* ---------------------------------------------------------------------------- + * This file was automatically generated by SWIG (http://www.swig.org). + * Version 4.0.0 + * + * This file is not intended to be easily readable and contains a number of + * coding conventions designed to improve portability and efficiency. Do not make + * changes to this file unless you know what you are doing--modify the SWIG + * interface file instead. + * ----------------------------------------------------------------------------- */ + +/* --------------------------------------------------------------- + * Programmer(s): Auto-generated by swig. + * --------------------------------------------------------------- + * SUNDIALS Copyright Start + * Copyright (c) 2002-2023, Lawrence Livermore National Security + * and Southern Methodist University. + * All rights reserved. + * + * See the top-level LICENSE and NOTICE files for details. + * + * SPDX-License-Identifier: BSD-3-Clause + * SUNDIALS Copyright End + * -------------------------------------------------------------*/ + +/* ----------------------------------------------------------------------------- + * This section contains generic SWIG labels for method/variable + * declarations/attributes, and other compiler dependent labels. + * ----------------------------------------------------------------------------- */ + +/* template workaround for compilers that cannot correctly implement the C++ standard */ +#ifndef SWIGTEMPLATEDISAMBIGUATOR +# if defined(__SUNPRO_CC) && (__SUNPRO_CC <= 0x560) +# define SWIGTEMPLATEDISAMBIGUATOR template +# elif defined(__HP_aCC) +/* Needed even with `aCC -AA' when `aCC -V' reports HP ANSI C++ B3910B A.03.55 */ +/* If we find a maximum version that requires this, the test would be __HP_aCC <= 35500 for A.03.55 */ +# define SWIGTEMPLATEDISAMBIGUATOR template +# else +# define SWIGTEMPLATEDISAMBIGUATOR +# endif +#endif + +/* inline attribute */ +#ifndef SWIGINLINE +# if defined(__cplusplus) || (defined(__GNUC__) && !defined(__STRICT_ANSI__)) +# define SWIGINLINE inline +# else +# define SWIGINLINE +# endif +#endif + +/* attribute recognised by some compilers to avoid 'unused' warnings */ +#ifndef SWIGUNUSED +# if defined(__GNUC__) +# if !(defined(__cplusplus)) || (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)) +# define SWIGUNUSED __attribute__ ((__unused__)) +# else +# define SWIGUNUSED +# endif +# elif defined(__ICC) +# define SWIGUNUSED __attribute__ ((__unused__)) +# else +# define SWIGUNUSED +# endif +#endif + +#ifndef SWIG_MSC_UNSUPPRESS_4505 +# if defined(_MSC_VER) +# pragma warning(disable : 4505) /* unreferenced local function has been removed */ +# endif +#endif + +#ifndef SWIGUNUSEDPARM +# ifdef __cplusplus +# define SWIGUNUSEDPARM(p) +# else +# define SWIGUNUSEDPARM(p) p SWIGUNUSED +# endif +#endif + +/* internal SWIG method */ +#ifndef SWIGINTERN +# define SWIGINTERN static SWIGUNUSED +#endif + +/* internal inline SWIG method */ +#ifndef SWIGINTERNINLINE +# define SWIGINTERNINLINE SWIGINTERN SWIGINLINE +#endif + +/* qualifier for exported *const* global data variables*/ +#ifndef SWIGEXTERN +# ifdef __cplusplus +# define SWIGEXTERN extern +# else +# define SWIGEXTERN +# endif +#endif + +/* exporting methods */ +#if defined(__GNUC__) +# if (__GNUC__ >= 4) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) +# ifndef GCC_HASCLASSVISIBILITY +# define GCC_HASCLASSVISIBILITY +# endif +# endif +#endif + +#ifndef SWIGEXPORT +# if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__) +# if defined(STATIC_LINKED) +# define SWIGEXPORT +# else +# define SWIGEXPORT __declspec(dllexport) +# endif +# else +# if defined(__GNUC__) && defined(GCC_HASCLASSVISIBILITY) +# define SWIGEXPORT __attribute__ ((visibility("default"))) +# else +# define SWIGEXPORT +# endif +# endif +#endif + +/* calling conventions for Windows */ +#ifndef SWIGSTDCALL +# if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__) +# define SWIGSTDCALL __stdcall +# else +# define SWIGSTDCALL +# endif +#endif + +/* Deal with Microsoft's attempt at deprecating C standard runtime functions */ +#if !defined(SWIG_NO_CRT_SECURE_NO_DEPRECATE) && defined(_MSC_VER) && !defined(_CRT_SECURE_NO_DEPRECATE) +# define _CRT_SECURE_NO_DEPRECATE +#endif + +/* Deal with Microsoft's attempt at deprecating methods in the standard C++ library */ +#if !defined(SWIG_NO_SCL_SECURE_NO_DEPRECATE) && defined(_MSC_VER) && !defined(_SCL_SECURE_NO_DEPRECATE) +# define _SCL_SECURE_NO_DEPRECATE +#endif + +/* Deal with Apple's deprecated 'AssertMacros.h' from Carbon-framework */ +#if defined(__APPLE__) && !defined(__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES) +# define __ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES 0 +#endif + +/* Intel's compiler complains if a variable which was never initialised is + * cast to void, which is a common idiom which we use to indicate that we + * are aware a variable isn't used. So we just silence that warning. + * See: https://github.com/swig/swig/issues/192 for more discussion. + */ +#ifdef __INTEL_COMPILER +# pragma warning disable 592 +#endif + +/* Errors in SWIG */ +#define SWIG_UnknownError -1 +#define SWIG_IOError -2 +#define SWIG_RuntimeError -3 +#define SWIG_IndexError -4 +#define SWIG_TypeError -5 +#define SWIG_DivisionByZero -6 +#define SWIG_OverflowError -7 +#define SWIG_SyntaxError -8 +#define SWIG_ValueError -9 +#define SWIG_SystemError -10 +#define SWIG_AttributeError -11 +#define SWIG_MemoryError -12 +#define SWIG_NullReferenceError -13 + + + + +#include +#define SWIG_exception_impl(DECL, CODE, MSG, RETURNNULL) \ + { printf("In " DECL ": " MSG); assert(0); RETURNNULL; } + + +#include +#if defined(_MSC_VER) || defined(__BORLANDC__) || defined(_WATCOM) +# ifndef snprintf +# define snprintf _snprintf +# endif +#endif + + +/* Support for the `contract` feature. + * + * Note that RETURNNULL is first because it's inserted via a 'Replaceall' in + * the fortran.cxx file. + */ +#define SWIG_contract_assert(RETURNNULL, EXPR, MSG) \ + if (!(EXPR)) { SWIG_exception_impl("$decl", SWIG_ValueError, MSG, RETURNNULL); } + + +#define SWIGVERSION 0x040000 +#define SWIG_VERSION SWIGVERSION + + +#define SWIG_as_voidptr(a) (void *)((const void *)(a)) +#define SWIG_as_voidptrptr(a) ((void)SWIG_as_voidptr(*a),(void**)(a)) + + +#include "sundials/sundials_adaptcontroller.h" + + +#include "sunadaptcontroller/sunadaptcontroller_pi.h" + +SWIGEXPORT SUNAdaptController _wrap_FSUNAdaptController_PI(void *farg1) { + SUNAdaptController fresult ; + SUNContext arg1 = (SUNContext) 0 ; + SUNAdaptController result; + + arg1 = (SUNContext)(farg1); + result = (SUNAdaptController)SUNAdaptController_PI(arg1); + fresult = result; + return fresult; +} + + +SWIGEXPORT int _wrap_FSUNAdaptController_SetParams_PI(SUNAdaptController farg1, int const *farg2, double const *farg3, double const *farg4) { + int fresult ; + SUNAdaptController arg1 = (SUNAdaptController) 0 ; + int arg2 ; + sunrealtype arg3 ; + sunrealtype arg4 ; + int result; + + arg1 = (SUNAdaptController)(farg1); + arg2 = (int)(*farg2); + arg3 = (sunrealtype)(*farg3); + arg4 = (sunrealtype)(*farg4); + result = (int)SUNAdaptController_SetParams_PI(arg1,arg2,arg3,arg4); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FSUNAdaptController_GetType_PI(SUNAdaptController farg1) { + int fresult ; + SUNAdaptController arg1 = (SUNAdaptController) 0 ; + SUNAdaptController_Type result; + + arg1 = (SUNAdaptController)(farg1); + result = (SUNAdaptController_Type)SUNAdaptController_GetType_PI(arg1); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FSUNAdaptController_EstimateStep_PI(SUNAdaptController farg1, double const *farg2, double const *farg3, double *farg4) { + int fresult ; + SUNAdaptController arg1 = (SUNAdaptController) 0 ; + sunrealtype arg2 ; + sunrealtype arg3 ; + sunrealtype *arg4 = (sunrealtype *) 0 ; + int result; + + arg1 = (SUNAdaptController)(farg1); + arg2 = (sunrealtype)(*farg2); + arg3 = (sunrealtype)(*farg3); + arg4 = (sunrealtype *)(farg4); + result = (int)SUNAdaptController_EstimateStep_PI(arg1,arg2,arg3,arg4); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FSUNAdaptController_Reset_PI(SUNAdaptController farg1) { + int fresult ; + SUNAdaptController arg1 = (SUNAdaptController) 0 ; + int result; + + arg1 = (SUNAdaptController)(farg1); + result = (int)SUNAdaptController_Reset_PI(arg1); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FSUNAdaptController_SetDefaults_PI(SUNAdaptController farg1) { + int fresult ; + SUNAdaptController arg1 = (SUNAdaptController) 0 ; + int result; + + arg1 = (SUNAdaptController)(farg1); + result = (int)SUNAdaptController_SetDefaults_PI(arg1); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FSUNAdaptController_Write_PI(SUNAdaptController farg1, void *farg2) { + int fresult ; + SUNAdaptController arg1 = (SUNAdaptController) 0 ; + FILE *arg2 = (FILE *) 0 ; + int result; + + arg1 = (SUNAdaptController)(farg1); + arg2 = (FILE *)(farg2); + result = (int)SUNAdaptController_Write_PI(arg1,arg2); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FSUNAdaptController_SetMethodOrder_PI(SUNAdaptController farg1, int const *farg2, int const *farg3) { + int fresult ; + SUNAdaptController arg1 = (SUNAdaptController) 0 ; + int arg2 ; + int arg3 ; + int result; + + arg1 = (SUNAdaptController)(farg1); + arg2 = (int)(*farg2); + arg3 = (int)(*farg3); + result = (int)SUNAdaptController_SetMethodOrder_PI(arg1,arg2,arg3); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FSUNAdaptController_AdjustControllerOrder_PI(SUNAdaptController farg1, int const *farg2) { + int fresult ; + SUNAdaptController arg1 = (SUNAdaptController) 0 ; + int arg2 ; + int result; + + arg1 = (SUNAdaptController)(farg1); + arg2 = (int)(*farg2); + result = (int)SUNAdaptController_AdjustControllerOrder_PI(arg1,arg2); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FSUNAdaptController_SetErrorBias_PI(SUNAdaptController farg1, double const *farg2) { + int fresult ; + SUNAdaptController arg1 = (SUNAdaptController) 0 ; + sunrealtype arg2 ; + int result; + + arg1 = (SUNAdaptController)(farg1); + arg2 = (sunrealtype)(*farg2); + result = (int)SUNAdaptController_SetErrorBias_PI(arg1,arg2); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FSUNAdaptController_Update_PI(SUNAdaptController farg1, double const *farg2, double const *farg3) { + int fresult ; + SUNAdaptController arg1 = (SUNAdaptController) 0 ; + sunrealtype arg2 ; + sunrealtype arg3 ; + int result; + + arg1 = (SUNAdaptController)(farg1); + arg2 = (sunrealtype)(*farg2); + arg3 = (sunrealtype)(*farg3); + result = (int)SUNAdaptController_Update_PI(arg1,arg2,arg3); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FSUNAdaptController_Space_PI(SUNAdaptController farg1, long *farg2, long *farg3) { + int fresult ; + SUNAdaptController arg1 = (SUNAdaptController) 0 ; + long *arg2 = (long *) 0 ; + long *arg3 = (long *) 0 ; + int result; + + arg1 = (SUNAdaptController)(farg1); + arg2 = (long *)(farg2); + arg3 = (long *)(farg3); + result = (int)SUNAdaptController_Space_PI(arg1,arg2,arg3); + fresult = (int)(result); + return fresult; +} + + + diff --git a/src/sunadaptcontroller/pi/fmod/fsunadaptcontroller_pi_mod.f90 b/src/sunadaptcontroller/pi/fmod/fsunadaptcontroller_pi_mod.f90 new file mode 100644 index 0000000000..34be923c0b --- /dev/null +++ b/src/sunadaptcontroller/pi/fmod/fsunadaptcontroller_pi_mod.f90 @@ -0,0 +1,363 @@ +! This file was automatically generated by SWIG (http://www.swig.org). +! Version 4.0.0 +! +! Do not make changes to this file unless you know what you are doing--modify +! the SWIG interface file instead. + +! --------------------------------------------------------------- +! Programmer(s): Auto-generated by swig. +! --------------------------------------------------------------- +! SUNDIALS Copyright Start +! Copyright (c) 2002-2023, 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 +! --------------------------------------------------------------- + +module fsunadaptcontroller_pi_mod + use, intrinsic :: ISO_C_BINDING + use fsundials_adaptcontroller_mod + use fsundials_types_mod + use fsundials_context_mod + implicit none + private + + ! DECLARATION CONSTRUCTS + public :: FSUNAdaptController_PI + public :: FSUNAdaptController_SetParams_PI + public :: FSUNAdaptController_GetType_PI + public :: FSUNAdaptController_EstimateStep_PI + public :: FSUNAdaptController_Reset_PI + public :: FSUNAdaptController_SetDefaults_PI + public :: FSUNAdaptController_Write_PI + public :: FSUNAdaptController_SetMethodOrder_PI + public :: FSUNAdaptController_AdjustControllerOrder_PI + public :: FSUNAdaptController_SetErrorBias_PI + public :: FSUNAdaptController_Update_PI + public :: FSUNAdaptController_Space_PI + +! WRAPPER DECLARATIONS +interface +function swigc_FSUNAdaptController_PI(farg1) & +bind(C, name="_wrap_FSUNAdaptController_PI") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +type(C_PTR), value :: farg1 +type(C_PTR) :: fresult +end function + +function swigc_FSUNAdaptController_SetParams_PI(farg1, farg2, farg3, farg4) & +bind(C, name="_wrap_FSUNAdaptController_SetParams_PI") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +type(C_PTR), value :: farg1 +integer(C_INT), intent(in) :: farg2 +real(C_DOUBLE), intent(in) :: farg3 +real(C_DOUBLE), intent(in) :: farg4 +integer(C_INT) :: fresult +end function + +function swigc_FSUNAdaptController_GetType_PI(farg1) & +bind(C, name="_wrap_FSUNAdaptController_GetType_PI") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +type(C_PTR), value :: farg1 +integer(C_INT) :: fresult +end function + +function swigc_FSUNAdaptController_EstimateStep_PI(farg1, farg2, farg3, farg4) & +bind(C, name="_wrap_FSUNAdaptController_EstimateStep_PI") & +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_PTR), value :: farg4 +integer(C_INT) :: fresult +end function + +function swigc_FSUNAdaptController_Reset_PI(farg1) & +bind(C, name="_wrap_FSUNAdaptController_Reset_PI") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +type(C_PTR), value :: farg1 +integer(C_INT) :: fresult +end function + +function swigc_FSUNAdaptController_SetDefaults_PI(farg1) & +bind(C, name="_wrap_FSUNAdaptController_SetDefaults_PI") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +type(C_PTR), value :: farg1 +integer(C_INT) :: fresult +end function + +function swigc_FSUNAdaptController_Write_PI(farg1, farg2) & +bind(C, name="_wrap_FSUNAdaptController_Write_PI") & +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_FSUNAdaptController_SetMethodOrder_PI(farg1, farg2, farg3) & +bind(C, name="_wrap_FSUNAdaptController_SetMethodOrder_PI") & +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_FSUNAdaptController_AdjustControllerOrder_PI(farg1, farg2) & +bind(C, name="_wrap_FSUNAdaptController_AdjustControllerOrder_PI") & +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_FSUNAdaptController_SetErrorBias_PI(farg1, farg2) & +bind(C, name="_wrap_FSUNAdaptController_SetErrorBias_PI") & +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_FSUNAdaptController_Update_PI(farg1, farg2, farg3) & +bind(C, name="_wrap_FSUNAdaptController_Update_PI") & +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_FSUNAdaptController_Space_PI(farg1, farg2, farg3) & +bind(C, name="_wrap_FSUNAdaptController_Space_PI") & +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 + +end interface + + +contains + ! MODULE SUBPROGRAMS +function FSUNAdaptController_PI(sunctx) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +type(SUNAdaptController), pointer :: swig_result +type(C_PTR) :: sunctx +type(C_PTR) :: fresult +type(C_PTR) :: farg1 + +farg1 = sunctx +fresult = swigc_FSUNAdaptController_PI(farg1) +call c_f_pointer(fresult, swig_result) +end function + +function FSUNAdaptController_SetParams_PI(c, pq, k1, k2) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(SUNAdaptController), target, intent(inout) :: c +integer(C_INT), intent(in) :: pq +real(C_DOUBLE), intent(in) :: k1 +real(C_DOUBLE), intent(in) :: k2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +integer(C_INT) :: farg2 +real(C_DOUBLE) :: farg3 +real(C_DOUBLE) :: farg4 + +farg1 = c_loc(c) +farg2 = pq +farg3 = k1 +farg4 = k2 +fresult = swigc_FSUNAdaptController_SetParams_PI(farg1, farg2, farg3, farg4) +swig_result = fresult +end function + +function FSUNAdaptController_GetType_PI(c) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(SUNAdaptController_Type) :: swig_result +type(SUNAdaptController), target, intent(inout) :: c +integer(C_INT) :: fresult +type(C_PTR) :: farg1 + +farg1 = c_loc(c) +fresult = swigc_FSUNAdaptController_GetType_PI(farg1) +swig_result = fresult +end function + +function FSUNAdaptController_EstimateStep_PI(c, h, dsm, hnew) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(SUNAdaptController), target, intent(inout) :: c +real(C_DOUBLE), intent(in) :: h +real(C_DOUBLE), intent(in) :: dsm +real(C_DOUBLE), target, intent(inout) :: hnew +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +real(C_DOUBLE) :: farg2 +real(C_DOUBLE) :: farg3 +type(C_PTR) :: farg4 + +farg1 = c_loc(c) +farg2 = h +farg3 = dsm +farg4 = c_loc(hnew) +fresult = swigc_FSUNAdaptController_EstimateStep_PI(farg1, farg2, farg3, farg4) +swig_result = fresult +end function + +function FSUNAdaptController_Reset_PI(c) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(SUNAdaptController), target, intent(inout) :: c +integer(C_INT) :: fresult +type(C_PTR) :: farg1 + +farg1 = c_loc(c) +fresult = swigc_FSUNAdaptController_Reset_PI(farg1) +swig_result = fresult +end function + +function FSUNAdaptController_SetDefaults_PI(c) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(SUNAdaptController), target, intent(inout) :: c +integer(C_INT) :: fresult +type(C_PTR) :: farg1 + +farg1 = c_loc(c) +fresult = swigc_FSUNAdaptController_SetDefaults_PI(farg1) +swig_result = fresult +end function + +function FSUNAdaptController_Write_PI(c, fptr) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(SUNAdaptController), target, intent(inout) :: c +type(C_PTR) :: fptr +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 + +farg1 = c_loc(c) +farg2 = fptr +fresult = swigc_FSUNAdaptController_Write_PI(farg1, farg2) +swig_result = fresult +end function + +function FSUNAdaptController_SetMethodOrder_PI(c, p, q) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(SUNAdaptController), target, intent(inout) :: c +integer(C_INT), intent(in) :: p +integer(C_INT), intent(in) :: q +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +integer(C_INT) :: farg2 +integer(C_INT) :: farg3 + +farg1 = c_loc(c) +farg2 = p +farg3 = q +fresult = swigc_FSUNAdaptController_SetMethodOrder_PI(farg1, farg2, farg3) +swig_result = fresult +end function + +function FSUNAdaptController_AdjustControllerOrder_PI(c, adj) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(SUNAdaptController), target, intent(inout) :: c +integer(C_INT), intent(in) :: adj +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +integer(C_INT) :: farg2 + +farg1 = c_loc(c) +farg2 = adj +fresult = swigc_FSUNAdaptController_AdjustControllerOrder_PI(farg1, farg2) +swig_result = fresult +end function + +function FSUNAdaptController_SetErrorBias_PI(c, bias) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(SUNAdaptController), target, intent(inout) :: c +real(C_DOUBLE), intent(in) :: bias +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +real(C_DOUBLE) :: farg2 + +farg1 = c_loc(c) +farg2 = bias +fresult = swigc_FSUNAdaptController_SetErrorBias_PI(farg1, farg2) +swig_result = fresult +end function + +function FSUNAdaptController_Update_PI(c, h, dsm) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(SUNAdaptController), target, intent(inout) :: c +real(C_DOUBLE), intent(in) :: h +real(C_DOUBLE), intent(in) :: dsm +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +real(C_DOUBLE) :: farg2 +real(C_DOUBLE) :: farg3 + +farg1 = c_loc(c) +farg2 = h +farg3 = dsm +fresult = swigc_FSUNAdaptController_Update_PI(farg1, farg2, farg3) +swig_result = fresult +end function + +function FSUNAdaptController_Space_PI(c, lenrw, leniw) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(SUNAdaptController), target, intent(inout) :: c +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 = c_loc(c) +farg2 = c_loc(lenrw(1)) +farg3 = c_loc(leniw(1)) +fresult = swigc_FSUNAdaptController_Space_PI(farg1, farg2, farg3) +swig_result = fresult +end function + + +end module diff --git a/src/sunadaptcontroller/pi/sunadaptcontroller_pi.c b/src/sunadaptcontroller/pi/sunadaptcontroller_pi.c new file mode 100644 index 0000000000..391648c46d --- /dev/null +++ b/src/sunadaptcontroller/pi/sunadaptcontroller_pi.c @@ -0,0 +1,232 @@ +/* ----------------------------------------------------------------- + * Programmer(s): Daniel R. Reynolds @ SMU + * ----------------------------------------------------------------- + * SUNDIALS Copyright Start + * Copyright (c) 2002-2023, Lawrence Livermore National Security + * and Southern Methodist University. + * All rights reserved. + * + * See the top-level LICENSE and NOTICE files for details. + * + * SPDX-License-Identifier: BSD-3-Clause + * SUNDIALS Copyright End + * ----------------------------------------------------------------- + * This is the implementation file for the SUNAdaptController_PI + * module. + * -----------------------------------------------------------------*/ + +#include +#include +#include +#include + + +/* --------------- + * Macro accessors + * --------------- */ + +#define SACPI_CONTENT(C) ( (SUNAdaptControllerContent_PI)(C->content) ) +#define SACPI_K1(C) ( SACPI_CONTENT(C)->k1 ) +#define SACPI_K2(C) ( SACPI_CONTENT(C)->k2 ) +#define SACPI_BIAS(C) ( SACPI_CONTENT(C)->bias ) +#define SACPI_EP(C) ( SACPI_CONTENT(C)->ep ) +#define SACPI_P(C) ( SACPI_CONTENT(C)->p ) +#define SACPI_PQ(C) ( SACPI_CONTENT(C)->pq ) +#define SACPI_ADJ(C) ( SACPI_CONTENT(C)->adj ) + +/* ------------------ + * Default parameters + * ------------------ */ + +#define DEFAULT_K1 RCONST(0.8) +#define DEFAULT_K2 RCONST(0.31) +#define DEFAULT_BIAS RCONST(1.5) +#define DEFAULT_PQ 0 +#define DEFAULT_ADJ -1 +/* #define DEFAULT_PQ -1 */ +/* #define DEFAULT_ADJ 0 */ +#define TINY RCONST(1.0e-10) + + +/* ----------------------------------------------------------------- + * exported functions + * ----------------------------------------------------------------- */ + +/* ----------------------------------------------------------------- + * Function to create a new PI controller + */ + +SUNAdaptController SUNAdaptController_PI(SUNContext sunctx) +{ + SUNAdaptController C; + SUNAdaptControllerContent_PI content; + + /* Create an empty controller object */ + C = NULL; + C = SUNAdaptController_NewEmpty(sunctx); + if (C == NULL) { return (NULL); } + + /* Attach operations */ + C->ops->gettype = SUNAdaptController_GetType_PI; + C->ops->estimatestep = SUNAdaptController_EstimateStep_PI; + C->ops->reset = SUNAdaptController_Reset_PI; + C->ops->setdefaults = SUNAdaptController_SetDefaults_PI; + C->ops->write = SUNAdaptController_Write_PI; + C->ops->setmethodorder = SUNAdaptController_SetMethodOrder_PI; + C->ops->adjustcontrollerorder = SUNAdaptController_AdjustControllerOrder_PI; + C->ops->seterrorbias = SUNAdaptController_SetErrorBias_PI; + C->ops->update = SUNAdaptController_Update_PI; + C->ops->space = SUNAdaptController_Space_PI; + + /* Create content */ + content = NULL; + content = (SUNAdaptControllerContent_PI)malloc(sizeof *content); + if (content == NULL) + { + (void) SUNAdaptController_Destroy(C); + return (NULL); + } + + /* Attach content */ + C->content = content; + + /* Initialize method order */ + content->p = 1; + + /* Fill content with default/reset values */ + SUNAdaptController_SetDefaults_PI(C); + SUNAdaptController_Reset_PI(C); + + return (C); +} + +/* ----------------------------------------------------------------- + * Function to set PI parameters + */ + +int SUNAdaptController_SetParams_PI(SUNAdaptController C, int pq, + sunrealtype k1, sunrealtype k2) +{ + /* store legal inputs, and return with success */ + SACPI_PQ(C) = pq; + if (k1 >= RCONST(0.0)) { SACPI_K1(C) = k1; } + if (k2 >= RCONST(0.0)) { SACPI_K2(C) = k2; } + return SUNADAPTCONTROLLER_SUCCESS; +} + + +/* ----------------------------------------------------------------- + * implementation of controller operations + * ----------------------------------------------------------------- */ + +SUNAdaptController_Type SUNAdaptController_GetType_PI(SUNAdaptController C) +{ return SUN_ADAPTCONTROLLER_H; } + +int SUNAdaptController_EstimateStep_PI(SUNAdaptController C, sunrealtype h, + sunrealtype dsm, sunrealtype* hnew) +{ + /* set usable time-step adaptivity parameters */ + const int ord = SACPI_P(C) + SACPI_ADJ(C) + 1; + const sunrealtype k1 = -SACPI_K1(C) / ord; + const sunrealtype k2 = SACPI_K2(C) / ord; + const sunrealtype ecur = SACPI_BIAS(C) * dsm; + const sunrealtype e1 = SUNMAX(ecur, TINY); + const sunrealtype e2 = SUNMAX(SACPI_EP(C), TINY); + + /* compute estimated optimal time step size and return with success */ + *hnew = h * SUNRpowerR(e1,k1) * SUNRpowerR(e2,k2); + return SUNADAPTCONTROLLER_SUCCESS; +} + +int SUNAdaptController_Reset_PI(SUNAdaptController C) +{ + SACPI_EP(C) = RCONST(1.0); + return SUNADAPTCONTROLLER_SUCCESS; +} + +int SUNAdaptController_SetDefaults_PI(SUNAdaptController C) +{ + SACPI_K1(C) = DEFAULT_K1; + SACPI_K2(C) = DEFAULT_K2; + SACPI_BIAS(C) = DEFAULT_BIAS; + SACPI_PQ(C) = DEFAULT_PQ; + SACPI_ADJ(C) = DEFAULT_ADJ; + return SUNADAPTCONTROLLER_SUCCESS; +} + +int SUNAdaptController_Write_PI(SUNAdaptController C, FILE *fptr) +{ + fprintf(fptr, "PI SUNAdaptController module:\n"); +#if defined(SUNDIALS_EXTENDED_PRECISION) + fprintf(fptr, " k1 = %32Lg\n", SACPI_K1(C)); + fprintf(fptr, " k2 = %32Lg\n", SACPI_K2(C)); + fprintf(fptr, " bias factor = %32Lg\n", SACPI_BIAS(C)); + fprintf(fptr, " previous error = %32Lg\n", SACPI_EP(C)); +#else + fprintf(fptr, " k1 = %16g\n", SACPI_K1(C)); + fprintf(fptr, " k2 = %16g\n", SACPI_K2(C)); + fprintf(fptr, " bias factor = %16g\n", SACPI_BIAS(C)); + fprintf(fptr, " previous error = %16g\n", SACPI_EP(C)); +#endif + if (SACPI_PQ(C) == 1) + { + fprintf(fptr, " p = %i (method order)\n", SACPI_P(C)); + } + else if (SACPI_PQ(C) == 0) + { + fprintf(fptr, " p = %i (embedding order)\n", SACPI_P(C)); + } + else + { + fprintf(fptr, " p = %i (minimum of method & embedding order)\n", SACPI_P(C)); + } + fprintf(fptr, " adj = %i\n", SACPI_ADJ(C)); + return SUNADAPTCONTROLLER_SUCCESS; +} + +int SUNAdaptController_SetMethodOrder_PI(SUNAdaptController C, int p, int q) +{ + /* check for legal inputs */ + if ((p <= 0) || (q <= 0)) { return SUNADAPTCONTROLLER_ILL_INPUT; } + + /* store appropriate value based on "pq" */ + if (SACPI_PQ(C) == 1) { + SACPI_P(C) = p; + } else if (SACPI_PQ(C) == 0) { + SACPI_P(C) = q; + } else { + SACPI_P(C) = SUNMIN(p,q); + } + return SUNADAPTCONTROLLER_SUCCESS; +} + +int SUNAdaptController_AdjustControllerOrder_PI(SUNAdaptController C, int adj) +{ + SACPI_ADJ(C) = adj; + return SUNADAPTCONTROLLER_SUCCESS; +} + +int SUNAdaptController_SetErrorBias_PI(SUNAdaptController C, sunrealtype bias) +{ + /* set allowed value, otherwise set default */ + if (bias <= RCONST(0.0)) { + SACPI_BIAS(C) = DEFAULT_BIAS; + } else { + SACPI_BIAS(C) = bias; + } + + return SUNADAPTCONTROLLER_SUCCESS; +} + +int SUNAdaptController_Update_PI(SUNAdaptController C, sunrealtype h, sunrealtype dsm) +{ + SACPI_EP(C) = SACPI_BIAS(C) * dsm; + return SUNADAPTCONTROLLER_SUCCESS; +} + +int SUNAdaptController_Space_PI(SUNAdaptController C, long int* lenrw, long int* leniw) +{ + *lenrw = 5; + *leniw = 3; + return SUNADAPTCONTROLLER_SUCCESS; +} diff --git a/src/sunadaptcontroller/pid/CMakeLists.txt b/src/sunadaptcontroller/pid/CMakeLists.txt new file mode 100644 index 0000000000..6a048371e6 --- /dev/null +++ b/src/sunadaptcontroller/pid/CMakeLists.txt @@ -0,0 +1,29 @@ +# --------------------------------------------------------------- +# Programmer(s): Daniel R. Reynolds @ SMU +# --------------------------------------------------------------- +# SUNDIALS Copyright Start +# Copyright (c) 2002-2023, 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 +# --------------------------------------------------------------- + +# Create a library out of the generic sundials modules +sundials_add_library(sundials_sunadaptcontrollerpid + SOURCES + sunadaptcontroller_pid.c + HEADERS + ${SUNDIALS_SOURCE_DIR}/include/sunadaptcontroller/sunadaptcontroller_pid.h + INCLUDE_SUBDIR + sunadaptcontroller + OBJECT_LIB_ONLY +) + +# Add F2003 module if the interface is enabled +if(BUILD_FORTRAN_MODULE_INTERFACE) + add_subdirectory(fmod) +endif() diff --git a/src/sunadaptcontroller/pid/fmod/CMakeLists.txt b/src/sunadaptcontroller/pid/fmod/CMakeLists.txt new file mode 100644 index 0000000000..b8e62c2d00 --- /dev/null +++ b/src/sunadaptcontroller/pid/fmod/CMakeLists.txt @@ -0,0 +1,25 @@ +# --------------------------------------------------------------- +# Programmer(s): Daniel R. Reynolds @ SMU +# --------------------------------------------------------------- +# SUNDIALS Copyright Start +# Copyright (c) 2002-2023, 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 +# --------------------------------------------------------------- + +sundials_add_f2003_library(sundials_fsunadaptcontrollerpid_mod + SOURCES + fsunadaptcontroller_pid_mod.f90 fsunadaptcontroller_pid_mod.c + OBJECT_LIBRARIES + sundials_fgeneric_mod_obj + OUTPUT_NAME + sundials_fsunadaptcontrollerpid_mod + OBJECT_LIB_ONLY +) + +message(STATUS "Added SUNAdaptController_PID F2003 interface") diff --git a/src/sunadaptcontroller/pid/fmod/fsunadaptcontroller_pid_mod.c b/src/sunadaptcontroller/pid/fmod/fsunadaptcontroller_pid_mod.c new file mode 100644 index 0000000000..d3f48b5234 --- /dev/null +++ b/src/sunadaptcontroller/pid/fmod/fsunadaptcontroller_pid_mod.c @@ -0,0 +1,387 @@ +/* ---------------------------------------------------------------------------- + * This file was automatically generated by SWIG (http://www.swig.org). + * Version 4.0.0 + * + * This file is not intended to be easily readable and contains a number of + * coding conventions designed to improve portability and efficiency. Do not make + * changes to this file unless you know what you are doing--modify the SWIG + * interface file instead. + * ----------------------------------------------------------------------------- */ + +/* --------------------------------------------------------------- + * Programmer(s): Auto-generated by swig. + * --------------------------------------------------------------- + * SUNDIALS Copyright Start + * Copyright (c) 2002-2023, Lawrence Livermore National Security + * and Southern Methodist University. + * All rights reserved. + * + * See the top-level LICENSE and NOTICE files for details. + * + * SPDX-License-Identifier: BSD-3-Clause + * SUNDIALS Copyright End + * -------------------------------------------------------------*/ + +/* ----------------------------------------------------------------------------- + * This section contains generic SWIG labels for method/variable + * declarations/attributes, and other compiler dependent labels. + * ----------------------------------------------------------------------------- */ + +/* template workaround for compilers that cannot correctly implement the C++ standard */ +#ifndef SWIGTEMPLATEDISAMBIGUATOR +# if defined(__SUNPRO_CC) && (__SUNPRO_CC <= 0x560) +# define SWIGTEMPLATEDISAMBIGUATOR template +# elif defined(__HP_aCC) +/* Needed even with `aCC -AA' when `aCC -V' reports HP ANSI C++ B3910B A.03.55 */ +/* If we find a maximum version that requires this, the test would be __HP_aCC <= 35500 for A.03.55 */ +# define SWIGTEMPLATEDISAMBIGUATOR template +# else +# define SWIGTEMPLATEDISAMBIGUATOR +# endif +#endif + +/* inline attribute */ +#ifndef SWIGINLINE +# if defined(__cplusplus) || (defined(__GNUC__) && !defined(__STRICT_ANSI__)) +# define SWIGINLINE inline +# else +# define SWIGINLINE +# endif +#endif + +/* attribute recognised by some compilers to avoid 'unused' warnings */ +#ifndef SWIGUNUSED +# if defined(__GNUC__) +# if !(defined(__cplusplus)) || (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)) +# define SWIGUNUSED __attribute__ ((__unused__)) +# else +# define SWIGUNUSED +# endif +# elif defined(__ICC) +# define SWIGUNUSED __attribute__ ((__unused__)) +# else +# define SWIGUNUSED +# endif +#endif + +#ifndef SWIG_MSC_UNSUPPRESS_4505 +# if defined(_MSC_VER) +# pragma warning(disable : 4505) /* unreferenced local function has been removed */ +# endif +#endif + +#ifndef SWIGUNUSEDPARM +# ifdef __cplusplus +# define SWIGUNUSEDPARM(p) +# else +# define SWIGUNUSEDPARM(p) p SWIGUNUSED +# endif +#endif + +/* internal SWIG method */ +#ifndef SWIGINTERN +# define SWIGINTERN static SWIGUNUSED +#endif + +/* internal inline SWIG method */ +#ifndef SWIGINTERNINLINE +# define SWIGINTERNINLINE SWIGINTERN SWIGINLINE +#endif + +/* qualifier for exported *const* global data variables*/ +#ifndef SWIGEXTERN +# ifdef __cplusplus +# define SWIGEXTERN extern +# else +# define SWIGEXTERN +# endif +#endif + +/* exporting methods */ +#if defined(__GNUC__) +# if (__GNUC__ >= 4) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) +# ifndef GCC_HASCLASSVISIBILITY +# define GCC_HASCLASSVISIBILITY +# endif +# endif +#endif + +#ifndef SWIGEXPORT +# if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__) +# if defined(STATIC_LINKED) +# define SWIGEXPORT +# else +# define SWIGEXPORT __declspec(dllexport) +# endif +# else +# if defined(__GNUC__) && defined(GCC_HASCLASSVISIBILITY) +# define SWIGEXPORT __attribute__ ((visibility("default"))) +# else +# define SWIGEXPORT +# endif +# endif +#endif + +/* calling conventions for Windows */ +#ifndef SWIGSTDCALL +# if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__) +# define SWIGSTDCALL __stdcall +# else +# define SWIGSTDCALL +# endif +#endif + +/* Deal with Microsoft's attempt at deprecating C standard runtime functions */ +#if !defined(SWIG_NO_CRT_SECURE_NO_DEPRECATE) && defined(_MSC_VER) && !defined(_CRT_SECURE_NO_DEPRECATE) +# define _CRT_SECURE_NO_DEPRECATE +#endif + +/* Deal with Microsoft's attempt at deprecating methods in the standard C++ library */ +#if !defined(SWIG_NO_SCL_SECURE_NO_DEPRECATE) && defined(_MSC_VER) && !defined(_SCL_SECURE_NO_DEPRECATE) +# define _SCL_SECURE_NO_DEPRECATE +#endif + +/* Deal with Apple's deprecated 'AssertMacros.h' from Carbon-framework */ +#if defined(__APPLE__) && !defined(__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES) +# define __ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES 0 +#endif + +/* Intel's compiler complains if a variable which was never initialised is + * cast to void, which is a common idiom which we use to indicate that we + * are aware a variable isn't used. So we just silence that warning. + * See: https://github.com/swig/swig/issues/192 for more discussion. + */ +#ifdef __INTEL_COMPILER +# pragma warning disable 592 +#endif + +/* Errors in SWIG */ +#define SWIG_UnknownError -1 +#define SWIG_IOError -2 +#define SWIG_RuntimeError -3 +#define SWIG_IndexError -4 +#define SWIG_TypeError -5 +#define SWIG_DivisionByZero -6 +#define SWIG_OverflowError -7 +#define SWIG_SyntaxError -8 +#define SWIG_ValueError -9 +#define SWIG_SystemError -10 +#define SWIG_AttributeError -11 +#define SWIG_MemoryError -12 +#define SWIG_NullReferenceError -13 + + + + +#include +#define SWIG_exception_impl(DECL, CODE, MSG, RETURNNULL) \ + { printf("In " DECL ": " MSG); assert(0); RETURNNULL; } + + +#include +#if defined(_MSC_VER) || defined(__BORLANDC__) || defined(_WATCOM) +# ifndef snprintf +# define snprintf _snprintf +# endif +#endif + + +/* Support for the `contract` feature. + * + * Note that RETURNNULL is first because it's inserted via a 'Replaceall' in + * the fortran.cxx file. + */ +#define SWIG_contract_assert(RETURNNULL, EXPR, MSG) \ + if (!(EXPR)) { SWIG_exception_impl("$decl", SWIG_ValueError, MSG, RETURNNULL); } + + +#define SWIGVERSION 0x040000 +#define SWIG_VERSION SWIGVERSION + + +#define SWIG_as_voidptr(a) (void *)((const void *)(a)) +#define SWIG_as_voidptrptr(a) ((void)SWIG_as_voidptr(*a),(void**)(a)) + + +#include "sundials/sundials_adaptcontroller.h" + + +#include "sunadaptcontroller/sunadaptcontroller_pid.h" + +SWIGEXPORT SUNAdaptController _wrap_FSUNAdaptController_PID(void *farg1) { + SUNAdaptController fresult ; + SUNContext arg1 = (SUNContext) 0 ; + SUNAdaptController result; + + arg1 = (SUNContext)(farg1); + result = (SUNAdaptController)SUNAdaptController_PID(arg1); + fresult = result; + return fresult; +} + + +SWIGEXPORT int _wrap_FSUNAdaptController_SetParams_PID(SUNAdaptController farg1, int const *farg2, double const *farg3, double const *farg4, double const *farg5) { + int fresult ; + SUNAdaptController arg1 = (SUNAdaptController) 0 ; + int arg2 ; + sunrealtype arg3 ; + sunrealtype arg4 ; + sunrealtype arg5 ; + int result; + + arg1 = (SUNAdaptController)(farg1); + arg2 = (int)(*farg2); + arg3 = (sunrealtype)(*farg3); + arg4 = (sunrealtype)(*farg4); + arg5 = (sunrealtype)(*farg5); + result = (int)SUNAdaptController_SetParams_PID(arg1,arg2,arg3,arg4,arg5); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FSUNAdaptController_GetType_PID(SUNAdaptController farg1) { + int fresult ; + SUNAdaptController arg1 = (SUNAdaptController) 0 ; + SUNAdaptController_Type result; + + arg1 = (SUNAdaptController)(farg1); + result = (SUNAdaptController_Type)SUNAdaptController_GetType_PID(arg1); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FSUNAdaptController_EstimateStep_PID(SUNAdaptController farg1, double const *farg2, double const *farg3, double *farg4) { + int fresult ; + SUNAdaptController arg1 = (SUNAdaptController) 0 ; + sunrealtype arg2 ; + sunrealtype arg3 ; + sunrealtype *arg4 = (sunrealtype *) 0 ; + int result; + + arg1 = (SUNAdaptController)(farg1); + arg2 = (sunrealtype)(*farg2); + arg3 = (sunrealtype)(*farg3); + arg4 = (sunrealtype *)(farg4); + result = (int)SUNAdaptController_EstimateStep_PID(arg1,arg2,arg3,arg4); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FSUNAdaptController_Reset_PID(SUNAdaptController farg1) { + int fresult ; + SUNAdaptController arg1 = (SUNAdaptController) 0 ; + int result; + + arg1 = (SUNAdaptController)(farg1); + result = (int)SUNAdaptController_Reset_PID(arg1); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FSUNAdaptController_SetDefaults_PID(SUNAdaptController farg1) { + int fresult ; + SUNAdaptController arg1 = (SUNAdaptController) 0 ; + int result; + + arg1 = (SUNAdaptController)(farg1); + result = (int)SUNAdaptController_SetDefaults_PID(arg1); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FSUNAdaptController_Write_PID(SUNAdaptController farg1, void *farg2) { + int fresult ; + SUNAdaptController arg1 = (SUNAdaptController) 0 ; + FILE *arg2 = (FILE *) 0 ; + int result; + + arg1 = (SUNAdaptController)(farg1); + arg2 = (FILE *)(farg2); + result = (int)SUNAdaptController_Write_PID(arg1,arg2); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FSUNAdaptController_SetMethodOrder_PID(SUNAdaptController farg1, int const *farg2, int const *farg3) { + int fresult ; + SUNAdaptController arg1 = (SUNAdaptController) 0 ; + int arg2 ; + int arg3 ; + int result; + + arg1 = (SUNAdaptController)(farg1); + arg2 = (int)(*farg2); + arg3 = (int)(*farg3); + result = (int)SUNAdaptController_SetMethodOrder_PID(arg1,arg2,arg3); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FSUNAdaptController_AdjustControllerOrder_PID(SUNAdaptController farg1, int const *farg2) { + int fresult ; + SUNAdaptController arg1 = (SUNAdaptController) 0 ; + int arg2 ; + int result; + + arg1 = (SUNAdaptController)(farg1); + arg2 = (int)(*farg2); + result = (int)SUNAdaptController_AdjustControllerOrder_PID(arg1,arg2); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FSUNAdaptController_SetErrorBias_PID(SUNAdaptController farg1, double const *farg2) { + int fresult ; + SUNAdaptController arg1 = (SUNAdaptController) 0 ; + sunrealtype arg2 ; + int result; + + arg1 = (SUNAdaptController)(farg1); + arg2 = (sunrealtype)(*farg2); + result = (int)SUNAdaptController_SetErrorBias_PID(arg1,arg2); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FSUNAdaptController_Update_PID(SUNAdaptController farg1, double const *farg2, double const *farg3) { + int fresult ; + SUNAdaptController arg1 = (SUNAdaptController) 0 ; + sunrealtype arg2 ; + sunrealtype arg3 ; + int result; + + arg1 = (SUNAdaptController)(farg1); + arg2 = (sunrealtype)(*farg2); + arg3 = (sunrealtype)(*farg3); + result = (int)SUNAdaptController_Update_PID(arg1,arg2,arg3); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FSUNAdaptController_Space_PID(SUNAdaptController farg1, long *farg2, long *farg3) { + int fresult ; + SUNAdaptController arg1 = (SUNAdaptController) 0 ; + long *arg2 = (long *) 0 ; + long *arg3 = (long *) 0 ; + int result; + + arg1 = (SUNAdaptController)(farg1); + arg2 = (long *)(farg2); + arg3 = (long *)(farg3); + result = (int)SUNAdaptController_Space_PID(arg1,arg2,arg3); + fresult = (int)(result); + return fresult; +} + + + diff --git a/src/sunadaptcontroller/pid/fmod/fsunadaptcontroller_pid_mod.f90 b/src/sunadaptcontroller/pid/fmod/fsunadaptcontroller_pid_mod.f90 new file mode 100644 index 0000000000..288d474671 --- /dev/null +++ b/src/sunadaptcontroller/pid/fmod/fsunadaptcontroller_pid_mod.f90 @@ -0,0 +1,367 @@ +! This file was automatically generated by SWIG (http://www.swig.org). +! Version 4.0.0 +! +! Do not make changes to this file unless you know what you are doing--modify +! the SWIG interface file instead. + +! --------------------------------------------------------------- +! Programmer(s): Auto-generated by swig. +! --------------------------------------------------------------- +! SUNDIALS Copyright Start +! Copyright (c) 2002-2023, 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 +! --------------------------------------------------------------- + +module fsunadaptcontroller_pid_mod + use, intrinsic :: ISO_C_BINDING + use fsundials_adaptcontroller_mod + use fsundials_types_mod + use fsundials_context_mod + implicit none + private + + ! DECLARATION CONSTRUCTS + public :: FSUNAdaptController_PID + public :: FSUNAdaptController_SetParams_PID + public :: FSUNAdaptController_GetType_PID + public :: FSUNAdaptController_EstimateStep_PID + public :: FSUNAdaptController_Reset_PID + public :: FSUNAdaptController_SetDefaults_PID + public :: FSUNAdaptController_Write_PID + public :: FSUNAdaptController_SetMethodOrder_PID + public :: FSUNAdaptController_AdjustControllerOrder_PID + public :: FSUNAdaptController_SetErrorBias_PID + public :: FSUNAdaptController_Update_PID + public :: FSUNAdaptController_Space_PID + +! WRAPPER DECLARATIONS +interface +function swigc_FSUNAdaptController_PID(farg1) & +bind(C, name="_wrap_FSUNAdaptController_PID") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +type(C_PTR), value :: farg1 +type(C_PTR) :: fresult +end function + +function swigc_FSUNAdaptController_SetParams_PID(farg1, farg2, farg3, farg4, farg5) & +bind(C, name="_wrap_FSUNAdaptController_SetParams_PID") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +type(C_PTR), value :: farg1 +integer(C_INT), intent(in) :: farg2 +real(C_DOUBLE), intent(in) :: farg3 +real(C_DOUBLE), intent(in) :: farg4 +real(C_DOUBLE), intent(in) :: farg5 +integer(C_INT) :: fresult +end function + +function swigc_FSUNAdaptController_GetType_PID(farg1) & +bind(C, name="_wrap_FSUNAdaptController_GetType_PID") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +type(C_PTR), value :: farg1 +integer(C_INT) :: fresult +end function + +function swigc_FSUNAdaptController_EstimateStep_PID(farg1, farg2, farg3, farg4) & +bind(C, name="_wrap_FSUNAdaptController_EstimateStep_PID") & +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_PTR), value :: farg4 +integer(C_INT) :: fresult +end function + +function swigc_FSUNAdaptController_Reset_PID(farg1) & +bind(C, name="_wrap_FSUNAdaptController_Reset_PID") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +type(C_PTR), value :: farg1 +integer(C_INT) :: fresult +end function + +function swigc_FSUNAdaptController_SetDefaults_PID(farg1) & +bind(C, name="_wrap_FSUNAdaptController_SetDefaults_PID") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +type(C_PTR), value :: farg1 +integer(C_INT) :: fresult +end function + +function swigc_FSUNAdaptController_Write_PID(farg1, farg2) & +bind(C, name="_wrap_FSUNAdaptController_Write_PID") & +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_FSUNAdaptController_SetMethodOrder_PID(farg1, farg2, farg3) & +bind(C, name="_wrap_FSUNAdaptController_SetMethodOrder_PID") & +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_FSUNAdaptController_AdjustControllerOrder_PID(farg1, farg2) & +bind(C, name="_wrap_FSUNAdaptController_AdjustControllerOrder_PID") & +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_FSUNAdaptController_SetErrorBias_PID(farg1, farg2) & +bind(C, name="_wrap_FSUNAdaptController_SetErrorBias_PID") & +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_FSUNAdaptController_Update_PID(farg1, farg2, farg3) & +bind(C, name="_wrap_FSUNAdaptController_Update_PID") & +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_FSUNAdaptController_Space_PID(farg1, farg2, farg3) & +bind(C, name="_wrap_FSUNAdaptController_Space_PID") & +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 + +end interface + + +contains + ! MODULE SUBPROGRAMS +function FSUNAdaptController_PID(sunctx) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +type(SUNAdaptController), pointer :: swig_result +type(C_PTR) :: sunctx +type(C_PTR) :: fresult +type(C_PTR) :: farg1 + +farg1 = sunctx +fresult = swigc_FSUNAdaptController_PID(farg1) +call c_f_pointer(fresult, swig_result) +end function + +function FSUNAdaptController_SetParams_PID(c, pq, k1, k2, k3) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(SUNAdaptController), target, intent(inout) :: c +integer(C_INT), intent(in) :: pq +real(C_DOUBLE), intent(in) :: k1 +real(C_DOUBLE), intent(in) :: k2 +real(C_DOUBLE), intent(in) :: k3 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +integer(C_INT) :: farg2 +real(C_DOUBLE) :: farg3 +real(C_DOUBLE) :: farg4 +real(C_DOUBLE) :: farg5 + +farg1 = c_loc(c) +farg2 = pq +farg3 = k1 +farg4 = k2 +farg5 = k3 +fresult = swigc_FSUNAdaptController_SetParams_PID(farg1, farg2, farg3, farg4, farg5) +swig_result = fresult +end function + +function FSUNAdaptController_GetType_PID(c) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(SUNAdaptController_Type) :: swig_result +type(SUNAdaptController), target, intent(inout) :: c +integer(C_INT) :: fresult +type(C_PTR) :: farg1 + +farg1 = c_loc(c) +fresult = swigc_FSUNAdaptController_GetType_PID(farg1) +swig_result = fresult +end function + +function FSUNAdaptController_EstimateStep_PID(c, h, dsm, hnew) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(SUNAdaptController), target, intent(inout) :: c +real(C_DOUBLE), intent(in) :: h +real(C_DOUBLE), intent(in) :: dsm +real(C_DOUBLE), target, intent(inout) :: hnew +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +real(C_DOUBLE) :: farg2 +real(C_DOUBLE) :: farg3 +type(C_PTR) :: farg4 + +farg1 = c_loc(c) +farg2 = h +farg3 = dsm +farg4 = c_loc(hnew) +fresult = swigc_FSUNAdaptController_EstimateStep_PID(farg1, farg2, farg3, farg4) +swig_result = fresult +end function + +function FSUNAdaptController_Reset_PID(c) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(SUNAdaptController), target, intent(inout) :: c +integer(C_INT) :: fresult +type(C_PTR) :: farg1 + +farg1 = c_loc(c) +fresult = swigc_FSUNAdaptController_Reset_PID(farg1) +swig_result = fresult +end function + +function FSUNAdaptController_SetDefaults_PID(c) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(SUNAdaptController), target, intent(inout) :: c +integer(C_INT) :: fresult +type(C_PTR) :: farg1 + +farg1 = c_loc(c) +fresult = swigc_FSUNAdaptController_SetDefaults_PID(farg1) +swig_result = fresult +end function + +function FSUNAdaptController_Write_PID(c, fptr) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(SUNAdaptController), target, intent(inout) :: c +type(C_PTR) :: fptr +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 + +farg1 = c_loc(c) +farg2 = fptr +fresult = swigc_FSUNAdaptController_Write_PID(farg1, farg2) +swig_result = fresult +end function + +function FSUNAdaptController_SetMethodOrder_PID(c, p, q) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(SUNAdaptController), target, intent(inout) :: c +integer(C_INT), intent(in) :: p +integer(C_INT), intent(in) :: q +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +integer(C_INT) :: farg2 +integer(C_INT) :: farg3 + +farg1 = c_loc(c) +farg2 = p +farg3 = q +fresult = swigc_FSUNAdaptController_SetMethodOrder_PID(farg1, farg2, farg3) +swig_result = fresult +end function + +function FSUNAdaptController_AdjustControllerOrder_PID(c, adj) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(SUNAdaptController), target, intent(inout) :: c +integer(C_INT), intent(in) :: adj +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +integer(C_INT) :: farg2 + +farg1 = c_loc(c) +farg2 = adj +fresult = swigc_FSUNAdaptController_AdjustControllerOrder_PID(farg1, farg2) +swig_result = fresult +end function + +function FSUNAdaptController_SetErrorBias_PID(c, bias) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(SUNAdaptController), target, intent(inout) :: c +real(C_DOUBLE), intent(in) :: bias +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +real(C_DOUBLE) :: farg2 + +farg1 = c_loc(c) +farg2 = bias +fresult = swigc_FSUNAdaptController_SetErrorBias_PID(farg1, farg2) +swig_result = fresult +end function + +function FSUNAdaptController_Update_PID(c, h, dsm) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(SUNAdaptController), target, intent(inout) :: c +real(C_DOUBLE), intent(in) :: h +real(C_DOUBLE), intent(in) :: dsm +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +real(C_DOUBLE) :: farg2 +real(C_DOUBLE) :: farg3 + +farg1 = c_loc(c) +farg2 = h +farg3 = dsm +fresult = swigc_FSUNAdaptController_Update_PID(farg1, farg2, farg3) +swig_result = fresult +end function + +function FSUNAdaptController_Space_PID(c, lenrw, leniw) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(SUNAdaptController), target, intent(inout) :: c +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 = c_loc(c) +farg2 = c_loc(lenrw(1)) +farg3 = c_loc(leniw(1)) +fresult = swigc_FSUNAdaptController_Space_PID(farg1, farg2, farg3) +swig_result = fresult +end function + + +end module diff --git a/src/sunadaptcontroller/pid/sunadaptcontroller_pid.c b/src/sunadaptcontroller/pid/sunadaptcontroller_pid.c new file mode 100644 index 0000000000..4e63386e57 --- /dev/null +++ b/src/sunadaptcontroller/pid/sunadaptcontroller_pid.c @@ -0,0 +1,243 @@ +/* ----------------------------------------------------------------- + * Programmer(s): Daniel R. Reynolds @ SMU + * ----------------------------------------------------------------- + * SUNDIALS Copyright Start + * Copyright (c) 2002-2023, Lawrence Livermore National Security + * and Southern Methodist University. + * All rights reserved. + * + * See the top-level LICENSE and NOTICE files for details. + * + * SPDX-License-Identifier: BSD-3-Clause + * SUNDIALS Copyright End + * ----------------------------------------------------------------- + * This is the implementation file for the SUNAdaptController_PID + * module. + * -----------------------------------------------------------------*/ + +#include +#include +#include +#include + + +/* --------------- + * Macro accessors + * --------------- */ + +#define SACPID_CONTENT(C) ( (SUNAdaptControllerContent_PID)(C->content) ) +#define SACPID_K1(C) ( SACPID_CONTENT(C)->k1 ) +#define SACPID_K2(C) ( SACPID_CONTENT(C)->k2 ) +#define SACPID_K3(C) ( SACPID_CONTENT(C)->k3 ) +#define SACPID_BIAS(C) ( SACPID_CONTENT(C)->bias ) +#define SACPID_EP(C) ( SACPID_CONTENT(C)->ep ) +#define SACPID_EPP(C) ( SACPID_CONTENT(C)->epp ) +#define SACPID_P(C) ( SACPID_CONTENT(C)->p ) +#define SACPID_PQ(C) ( SACPID_CONTENT(C)->pq ) +#define SACPID_ADJ(C) ( SACPID_CONTENT(C)->adj ) + +/* ------------------ + * Default parameters + * ------------------ */ + +#define DEFAULT_K1 RCONST(0.58) +#define DEFAULT_K2 RCONST(0.21) +#define DEFAULT_K3 RCONST(0.1) +#define DEFAULT_BIAS RCONST(1.5) +#define DEFAULT_PQ 0 +#define DEFAULT_ADJ -1 +/* #define DEFAULT_PQ -1 */ +/* #define DEFAULT_ADJ 0 */ +#define TINY RCONST(1.0e-10) + + +/* ----------------------------------------------------------------- + * exported functions + * ----------------------------------------------------------------- */ + +/* ----------------------------------------------------------------- + * Function to create a new PID controller + */ + +SUNAdaptController SUNAdaptController_PID(SUNContext sunctx) +{ + SUNAdaptController C; + SUNAdaptControllerContent_PID content; + + /* Create an empty controller object */ + C = NULL; + C = SUNAdaptController_NewEmpty(sunctx); + if (C == NULL) { return (NULL); } + + /* Attach operations */ + C->ops->gettype = SUNAdaptController_GetType_PID; + C->ops->estimatestep = SUNAdaptController_EstimateStep_PID; + C->ops->reset = SUNAdaptController_Reset_PID; + C->ops->setdefaults = SUNAdaptController_SetDefaults_PID; + C->ops->write = SUNAdaptController_Write_PID; + C->ops->setmethodorder = SUNAdaptController_SetMethodOrder_PID; + C->ops->adjustcontrollerorder = SUNAdaptController_AdjustControllerOrder_PID; + C->ops->seterrorbias = SUNAdaptController_SetErrorBias_PID; + C->ops->update = SUNAdaptController_Update_PID; + C->ops->space = SUNAdaptController_Space_PID; + + /* Create content */ + content = NULL; + content = (SUNAdaptControllerContent_PID)malloc(sizeof *content); + if (content == NULL) + { + (void) SUNAdaptController_Destroy(C); + return (NULL); + } + + /* Attach content */ + C->content = content; + + /* Initialize method order */ + content->p = 1; + + /* Fill content with default/reset values */ + SUNAdaptController_SetDefaults_PID(C); + SUNAdaptController_Reset_PID(C); + + return (C); +} + +/* ----------------------------------------------------------------- + * Function to set PID parameters + */ + +int SUNAdaptController_SetParams_PID(SUNAdaptController C, int pq, + sunrealtype k1, sunrealtype k2, sunrealtype k3) +{ + /* store legal inputs, and return with success */ + SACPID_PQ(C) = pq; + if (k1 >= RCONST(0.0)) { SACPID_K1(C) = k1; } + if (k2 >= RCONST(0.0)) { SACPID_K2(C) = k2; } + if (k3 >= RCONST(0.0)) { SACPID_K3(C) = k3; } + return SUNADAPTCONTROLLER_SUCCESS; +} + + +/* ----------------------------------------------------------------- + * implementation of controller operations + * ----------------------------------------------------------------- */ + +SUNAdaptController_Type SUNAdaptController_GetType_PID(SUNAdaptController C) +{ return SUN_ADAPTCONTROLLER_H; } + +int SUNAdaptController_EstimateStep_PID(SUNAdaptController C, sunrealtype h, + sunrealtype dsm, sunrealtype* hnew) +{ + /* set usable time-step adaptivity parameters */ + const int ord = SACPID_P(C) + SACPID_ADJ(C) + 1; + const sunrealtype k1 = -SACPID_K1(C) / ord; + const sunrealtype k2 = SACPID_K2(C) / ord; + const sunrealtype k3 = -SACPID_K3(C) / ord; + const sunrealtype ecur = SACPID_BIAS(C) * dsm; + const sunrealtype e1 = SUNMAX(ecur, TINY); + const sunrealtype e2 = SUNMAX(SACPID_EP(C), TINY); + const sunrealtype e3 = SUNMAX(SACPID_EPP(C), TINY); + + /* compute estimated optimal time step size and return with success */ + *hnew = h * SUNRpowerR(e1,k1) * SUNRpowerR(e2,k2) * SUNRpowerR(e3,k3); + return SUNADAPTCONTROLLER_SUCCESS; +} + +int SUNAdaptController_Reset_PID(SUNAdaptController C) +{ + SACPID_EP(C) = RCONST(1.0); + SACPID_EPP(C) = RCONST(1.0); + return SUNADAPTCONTROLLER_SUCCESS; +} + +int SUNAdaptController_SetDefaults_PID(SUNAdaptController C) +{ + SACPID_K1(C) = DEFAULT_K1; + SACPID_K2(C) = DEFAULT_K2; + SACPID_K3(C) = DEFAULT_K3; + SACPID_BIAS(C) = DEFAULT_BIAS; + SACPID_PQ(C) = DEFAULT_PQ; + SACPID_ADJ(C) = DEFAULT_ADJ; + return SUNADAPTCONTROLLER_SUCCESS; +} + +int SUNAdaptController_Write_PID(SUNAdaptController C, FILE *fptr) +{ + fprintf(fptr, "PID SUNAdaptController module:\n"); +#if defined(SUNDIALS_EXTENDED_PRECISION) + fprintf(fptr, " k1 = %32Lg\n", SACPID_K1(C)); + fprintf(fptr, " k2 = %32Lg\n", SACPID_K2(C)); + fprintf(fptr, " k3 = %32Lg\n", SACPID_K3(C)); + fprintf(fptr, " bias factor = %32Lg\n", SACPID_BIAS(C)); + fprintf(fptr, " previous errors = %32Lg %32Lg\n", SACPID_EP(C), SACPID_EPP(C)); +#else + fprintf(fptr, " k1 = %16g\n", SACPID_K1(C)); + fprintf(fptr, " k2 = %16g\n", SACPID_K2(C)); + fprintf(fptr, " k3 = %16g\n", SACPID_K3(C)); + fprintf(fptr, " bias factor = %16g\n", SACPID_BIAS(C)); + fprintf(fptr, " previous errors = %16g %16g\n", SACPID_EP(C), SACPID_EPP(C)); +#endif + if (SACPID_PQ(C) == 1) + { + fprintf(fptr, " p = %i (method order)\n", SACPID_P(C)); + } + else if (SACPID_PQ(C) == 0) + { + fprintf(fptr, " p = %i (embedding order)\n", SACPID_P(C)); + } + else + { + fprintf(fptr, " p = %i (minimum of method & embedding order)\n", SACPID_P(C)); + } + fprintf(fptr, " adj = %i\n", SACPID_ADJ(C)); + return SUNADAPTCONTROLLER_SUCCESS; +} + +int SUNAdaptController_SetMethodOrder_PID(SUNAdaptController C, int p, int q) +{ + /* check for legal inputs */ + if ((p <= 0) || (q <= 0)) { return SUNADAPTCONTROLLER_ILL_INPUT; } + + /* store appropriate value based on "pq" */ + if (SACPID_PQ(C) == 1) { + SACPID_P(C) = p; + } else if (SACPID_PQ(C) == 0) { + SACPID_P(C) = q; + } else { + SACPID_P(C) = SUNMIN(p,q); + } + return SUNADAPTCONTROLLER_SUCCESS; +} + +int SUNAdaptController_AdjustControllerOrder_PID(SUNAdaptController C, int adj) +{ + SACPID_ADJ(C) = adj; + return SUNADAPTCONTROLLER_SUCCESS; +} + +int SUNAdaptController_SetErrorBias_PID(SUNAdaptController C, sunrealtype bias) +{ + /* set allowed value, otherwise set default */ + if (bias <= RCONST(0.0)) { + SACPID_BIAS(C) = DEFAULT_BIAS; + } else { + SACPID_BIAS(C) = bias; + } + + return SUNADAPTCONTROLLER_SUCCESS; +} + +int SUNAdaptController_Update_PID(SUNAdaptController C, sunrealtype h, sunrealtype dsm) +{ + SACPID_EPP(C) = SACPID_EP(C); + SACPID_EP(C) = SACPID_BIAS(C) * dsm; + return SUNADAPTCONTROLLER_SUCCESS; +} + +int SUNAdaptController_Space_PID(SUNAdaptController C, long int* lenrw, long int* leniw) +{ + *lenrw = 7; + *leniw = 3; + return SUNADAPTCONTROLLER_SUCCESS; +} diff --git a/src/sundials/CMakeLists.txt b/src/sundials/CMakeLists.txt index 16dd005cee..5a84e80329 100644 --- a/src/sundials/CMakeLists.txt +++ b/src/sundials/CMakeLists.txt @@ -21,6 +21,7 @@ install(CODE "MESSAGE(\"\nInstall shared components\n\")") # Add variable sundials_HEADERS with the exported SUNDIALS header files set(sundials_HEADERS + sundials_adaptcontroller.h sundials_base.hpp sundials_band.h sundials_context.h @@ -77,6 +78,7 @@ endif() add_prefix(${SUNDIALS_SOURCE_DIR}/include/sundials/ sundials_HEADERS) set(sundials_SOURCES + sundials_adaptcontroller.c sundials_band.c sundials_context.c sundials_dense.c diff --git a/src/sundials/fmod/CMakeLists.txt b/src/sundials/fmod/CMakeLists.txt index e3e05f4cd7..94325ce9d8 100644 --- a/src/sundials/fmod/CMakeLists.txt +++ b/src/sundials/fmod/CMakeLists.txt @@ -30,7 +30,9 @@ set(sundials_SOURCES fsundials_types_mod.f90 fsundials_types_mod.c fsundials_context_mod.f90 - fsundials_context_mod.c) + fsundials_context_mod.c + fsundials_adaptcontroller_mod.f90 + fsundials_adaptcontroller_mod.c) if(SUNDIALS_BUILD_WITH_PROFILING) list(APPEND sundials_SOURCES diff --git a/src/sundials/fmod/fsundials_adaptcontroller_mod.c b/src/sundials/fmod/fsundials_adaptcontroller_mod.c new file mode 100644 index 0000000000..02f8b0710c --- /dev/null +++ b/src/sundials/fmod/fsundials_adaptcontroller_mod.c @@ -0,0 +1,471 @@ +/* ---------------------------------------------------------------------------- + * This file was automatically generated by SWIG (http://www.swig.org). + * Version 4.0.0 + * + * This file is not intended to be easily readable and contains a number of + * coding conventions designed to improve portability and efficiency. Do not make + * changes to this file unless you know what you are doing--modify the SWIG + * interface file instead. + * ----------------------------------------------------------------------------- */ +/* ----------------------------------------------------------------------------- + * This section contains generic SWIG labels for method/variable + * declarations/attributes, and other compiler dependent labels. + * ----------------------------------------------------------------------------- */ + +/* template workaround for compilers that cannot correctly implement the C++ standard */ +#ifndef SWIGTEMPLATEDISAMBIGUATOR +# if defined(__SUNPRO_CC) && (__SUNPRO_CC <= 0x560) +# define SWIGTEMPLATEDISAMBIGUATOR template +# elif defined(__HP_aCC) +/* Needed even with `aCC -AA' when `aCC -V' reports HP ANSI C++ B3910B A.03.55 */ +/* If we find a maximum version that requires this, the test would be __HP_aCC <= 35500 for A.03.55 */ +# define SWIGTEMPLATEDISAMBIGUATOR template +# else +# define SWIGTEMPLATEDISAMBIGUATOR +# endif +#endif + +/* inline attribute */ +#ifndef SWIGINLINE +# if defined(__cplusplus) || (defined(__GNUC__) && !defined(__STRICT_ANSI__)) +# define SWIGINLINE inline +# else +# define SWIGINLINE +# endif +#endif + +/* attribute recognised by some compilers to avoid 'unused' warnings */ +#ifndef SWIGUNUSED +# if defined(__GNUC__) +# if !(defined(__cplusplus)) || (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)) +# define SWIGUNUSED __attribute__ ((__unused__)) +# else +# define SWIGUNUSED +# endif +# elif defined(__ICC) +# define SWIGUNUSED __attribute__ ((__unused__)) +# else +# define SWIGUNUSED +# endif +#endif + +#ifndef SWIG_MSC_UNSUPPRESS_4505 +# if defined(_MSC_VER) +# pragma warning(disable : 4505) /* unreferenced local function has been removed */ +# endif +#endif + +#ifndef SWIGUNUSEDPARM +# ifdef __cplusplus +# define SWIGUNUSEDPARM(p) +# else +# define SWIGUNUSEDPARM(p) p SWIGUNUSED +# endif +#endif + +/* internal SWIG method */ +#ifndef SWIGINTERN +# define SWIGINTERN static SWIGUNUSED +#endif + +/* internal inline SWIG method */ +#ifndef SWIGINTERNINLINE +# define SWIGINTERNINLINE SWIGINTERN SWIGINLINE +#endif + +/* qualifier for exported *const* global data variables*/ +#ifndef SWIGEXTERN +# ifdef __cplusplus +# define SWIGEXTERN extern +# else +# define SWIGEXTERN +# endif +#endif + +/* exporting methods */ +#if defined(__GNUC__) +# if (__GNUC__ >= 4) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) +# ifndef GCC_HASCLASSVISIBILITY +# define GCC_HASCLASSVISIBILITY +# endif +# endif +#endif + +#ifndef SWIGEXPORT +# if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__) +# if defined(STATIC_LINKED) +# define SWIGEXPORT +# else +# define SWIGEXPORT __declspec(dllexport) +# endif +# else +# if defined(__GNUC__) && defined(GCC_HASCLASSVISIBILITY) +# define SWIGEXPORT __attribute__ ((visibility("default"))) +# else +# define SWIGEXPORT +# endif +# endif +#endif + +/* calling conventions for Windows */ +#ifndef SWIGSTDCALL +# if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__) +# define SWIGSTDCALL __stdcall +# else +# define SWIGSTDCALL +# endif +#endif + +/* Deal with Microsoft's attempt at deprecating C standard runtime functions */ +#if !defined(SWIG_NO_CRT_SECURE_NO_DEPRECATE) && defined(_MSC_VER) && !defined(_CRT_SECURE_NO_DEPRECATE) +# define _CRT_SECURE_NO_DEPRECATE +#endif + +/* Deal with Microsoft's attempt at deprecating methods in the standard C++ library */ +#if !defined(SWIG_NO_SCL_SECURE_NO_DEPRECATE) && defined(_MSC_VER) && !defined(_SCL_SECURE_NO_DEPRECATE) +# define _SCL_SECURE_NO_DEPRECATE +#endif + +/* Deal with Apple's deprecated 'AssertMacros.h' from Carbon-framework */ +#if defined(__APPLE__) && !defined(__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES) +# define __ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES 0 +#endif + +/* Intel's compiler complains if a variable which was never initialised is + * cast to void, which is a common idiom which we use to indicate that we + * are aware a variable isn't used. So we just silence that warning. + * See: https://github.com/swig/swig/issues/192 for more discussion. + */ +#ifdef __INTEL_COMPILER +# pragma warning disable 592 +#endif + +/* Errors in SWIG */ +#define SWIG_UnknownError -1 +#define SWIG_IOError -2 +#define SWIG_RuntimeError -3 +#define SWIG_IndexError -4 +#define SWIG_TypeError -5 +#define SWIG_DivisionByZero -6 +#define SWIG_OverflowError -7 +#define SWIG_SyntaxError -8 +#define SWIG_ValueError -9 +#define SWIG_SystemError -10 +#define SWIG_AttributeError -11 +#define SWIG_MemoryError -12 +#define SWIG_NullReferenceError -13 + + + + +#include +#define SWIG_exception_impl(DECL, CODE, MSG, RETURNNULL) \ + { printf("In " DECL ": " MSG); assert(0); RETURNNULL; } + + +#include +#if defined(_MSC_VER) || defined(__BORLANDC__) || defined(_WATCOM) +# ifndef snprintf +# define snprintf _snprintf +# endif +#endif + + +/* Support for the `contract` feature. + * + * Note that RETURNNULL is first because it's inserted via a 'Replaceall' in + * the fortran.cxx file. + */ +#define SWIG_contract_assert(RETURNNULL, EXPR, MSG) \ + if (!(EXPR)) { SWIG_exception_impl("$decl", SWIG_ValueError, MSG, RETURNNULL); } + + +#define SWIGVERSION 0x040000 +#define SWIG_VERSION SWIGVERSION + + +#define SWIG_as_voidptr(a) (void *)((const void *)(a)) +#define SWIG_as_voidptrptr(a) ((void)SWIG_as_voidptr(*a),(void**)(a)) + + +#include "sundials/sundials_adaptcontroller.h" + +SWIGEXPORT SUNAdaptController _wrap_FSUNAdaptController_NewEmpty(void *farg1) { + SUNAdaptController fresult ; + SUNContext arg1 = (SUNContext) 0 ; + SUNAdaptController result; + + arg1 = (SUNContext)(farg1); + result = (SUNAdaptController)SUNAdaptController_NewEmpty(arg1); + fresult = result; + return fresult; +} + + +SWIGEXPORT int _wrap_FSUNAdaptController_GetType(SUNAdaptController farg1) { + int fresult ; + SUNAdaptController arg1 = (SUNAdaptController) 0 ; + SUNAdaptController_Type result; + + arg1 = (SUNAdaptController)(farg1); + result = (SUNAdaptController_Type)SUNAdaptController_GetType(arg1); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FSUNAdaptController_Destroy(SUNAdaptController farg1) { + int fresult ; + SUNAdaptController arg1 = (SUNAdaptController) 0 ; + int result; + + arg1 = (SUNAdaptController)(farg1); + result = (int)SUNAdaptController_Destroy(arg1); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FSUNAdaptController_EstimateStep(SUNAdaptController farg1, double const *farg2, double const *farg3, double *farg4) { + int fresult ; + SUNAdaptController arg1 = (SUNAdaptController) 0 ; + sunrealtype arg2 ; + sunrealtype arg3 ; + sunrealtype *arg4 = (sunrealtype *) 0 ; + int result; + + arg1 = (SUNAdaptController)(farg1); + arg2 = (sunrealtype)(*farg2); + arg3 = (sunrealtype)(*farg3); + arg4 = (sunrealtype *)(farg4); + result = (int)SUNAdaptController_EstimateStep(arg1,arg2,arg3,arg4); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FSUNAdaptController_EstimateStepAndOrder(SUNAdaptController farg1, double const *farg2, int const *farg3, double const *farg4, double *farg5, int *farg6) { + int fresult ; + SUNAdaptController arg1 = (SUNAdaptController) 0 ; + sunrealtype arg2 ; + int arg3 ; + sunrealtype arg4 ; + sunrealtype *arg5 = (sunrealtype *) 0 ; + int *arg6 = (int *) 0 ; + int result; + + arg1 = (SUNAdaptController)(farg1); + arg2 = (sunrealtype)(*farg2); + arg3 = (int)(*farg3); + arg4 = (sunrealtype)(*farg4); + arg5 = (sunrealtype *)(farg5); + arg6 = (int *)(farg6); + result = (int)SUNAdaptController_EstimateStepAndOrder(arg1,arg2,arg3,arg4,arg5,arg6); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FSUNAdaptController_EstimateMRISteps(SUNAdaptController farg1, double const *farg2, double const *farg3, double const *farg4, double const *farg5, double *farg6, double *farg7) { + int fresult ; + SUNAdaptController arg1 = (SUNAdaptController) 0 ; + sunrealtype arg2 ; + sunrealtype arg3 ; + sunrealtype arg4 ; + sunrealtype arg5 ; + sunrealtype *arg6 = (sunrealtype *) 0 ; + sunrealtype *arg7 = (sunrealtype *) 0 ; + int result; + + arg1 = (SUNAdaptController)(farg1); + arg2 = (sunrealtype)(*farg2); + arg3 = (sunrealtype)(*farg3); + arg4 = (sunrealtype)(*farg4); + arg5 = (sunrealtype)(*farg5); + arg6 = (sunrealtype *)(farg6); + arg7 = (sunrealtype *)(farg7); + result = (int)SUNAdaptController_EstimateMRISteps(arg1,arg2,arg3,arg4,arg5,arg6,arg7); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FSUNAdaptController_EstimateStepTol(SUNAdaptController farg1, double const *farg2, double const *farg3, double const *farg4, double const *farg5, double *farg6, double *farg7) { + int fresult ; + SUNAdaptController arg1 = (SUNAdaptController) 0 ; + sunrealtype arg2 ; + sunrealtype arg3 ; + sunrealtype arg4 ; + sunrealtype arg5 ; + sunrealtype *arg6 = (sunrealtype *) 0 ; + sunrealtype *arg7 = (sunrealtype *) 0 ; + int result; + + arg1 = (SUNAdaptController)(farg1); + arg2 = (sunrealtype)(*farg2); + arg3 = (sunrealtype)(*farg3); + arg4 = (sunrealtype)(*farg4); + arg5 = (sunrealtype)(*farg5); + arg6 = (sunrealtype *)(farg6); + arg7 = (sunrealtype *)(farg7); + result = (int)SUNAdaptController_EstimateStepTol(arg1,arg2,arg3,arg4,arg5,arg6,arg7); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FSUNAdaptController_Reset(SUNAdaptController farg1) { + int fresult ; + SUNAdaptController arg1 = (SUNAdaptController) 0 ; + int result; + + arg1 = (SUNAdaptController)(farg1); + result = (int)SUNAdaptController_Reset(arg1); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FSUNAdaptController_SetDefaults(SUNAdaptController farg1) { + int fresult ; + SUNAdaptController arg1 = (SUNAdaptController) 0 ; + int result; + + arg1 = (SUNAdaptController)(farg1); + result = (int)SUNAdaptController_SetDefaults(arg1); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FSUNAdaptController_Write(SUNAdaptController farg1, void *farg2) { + int fresult ; + SUNAdaptController arg1 = (SUNAdaptController) 0 ; + FILE *arg2 = (FILE *) 0 ; + int result; + + arg1 = (SUNAdaptController)(farg1); + arg2 = (FILE *)(farg2); + result = (int)SUNAdaptController_Write(arg1,arg2); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FSUNAdaptController_SetMethodOrder(SUNAdaptController farg1, int const *farg2, int const *farg3) { + int fresult ; + SUNAdaptController arg1 = (SUNAdaptController) 0 ; + int arg2 ; + int arg3 ; + int result; + + arg1 = (SUNAdaptController)(farg1); + arg2 = (int)(*farg2); + arg3 = (int)(*farg3); + result = (int)SUNAdaptController_SetMethodOrder(arg1,arg2,arg3); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FSUNAdaptController_AdjustControllerOrder(SUNAdaptController farg1, int const *farg2) { + int fresult ; + SUNAdaptController arg1 = (SUNAdaptController) 0 ; + int arg2 ; + int result; + + arg1 = (SUNAdaptController)(farg1); + arg2 = (int)(*farg2); + result = (int)SUNAdaptController_AdjustControllerOrder(arg1,arg2); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FSUNAdaptController_SetErrorBias(SUNAdaptController farg1, double const *farg2) { + int fresult ; + SUNAdaptController arg1 = (SUNAdaptController) 0 ; + sunrealtype arg2 ; + int result; + + arg1 = (SUNAdaptController)(farg1); + arg2 = (sunrealtype)(*farg2); + result = (int)SUNAdaptController_SetErrorBias(arg1,arg2); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FSUNAdaptController_Update(SUNAdaptController farg1, double const *farg2, double const *farg3) { + int fresult ; + SUNAdaptController arg1 = (SUNAdaptController) 0 ; + sunrealtype arg2 ; + sunrealtype arg3 ; + int result; + + arg1 = (SUNAdaptController)(farg1); + arg2 = (sunrealtype)(*farg2); + arg3 = (sunrealtype)(*farg3); + result = (int)SUNAdaptController_Update(arg1,arg2,arg3); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FSUNAdaptController_UpdateMRIH(SUNAdaptController farg1, double const *farg2, double const *farg3, double const *farg4, double const *farg5) { + int fresult ; + SUNAdaptController arg1 = (SUNAdaptController) 0 ; + sunrealtype arg2 ; + sunrealtype arg3 ; + sunrealtype arg4 ; + sunrealtype arg5 ; + int result; + + arg1 = (SUNAdaptController)(farg1); + arg2 = (sunrealtype)(*farg2); + arg3 = (sunrealtype)(*farg3); + arg4 = (sunrealtype)(*farg4); + arg5 = (sunrealtype)(*farg5); + result = (int)SUNAdaptController_UpdateMRIH(arg1,arg2,arg3,arg4,arg5); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FSUNAdaptController_UpdateMRITol(SUNAdaptController farg1, double const *farg2, double const *farg3, double const *farg4, double const *farg5) { + int fresult ; + SUNAdaptController arg1 = (SUNAdaptController) 0 ; + sunrealtype arg2 ; + sunrealtype arg3 ; + sunrealtype arg4 ; + sunrealtype arg5 ; + int result; + + arg1 = (SUNAdaptController)(farg1); + arg2 = (sunrealtype)(*farg2); + arg3 = (sunrealtype)(*farg3); + arg4 = (sunrealtype)(*farg4); + arg5 = (sunrealtype)(*farg5); + result = (int)SUNAdaptController_UpdateMRITol(arg1,arg2,arg3,arg4,arg5); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FSUNAdaptController_Space(SUNAdaptController farg1, long *farg2, long *farg3) { + int fresult ; + SUNAdaptController arg1 = (SUNAdaptController) 0 ; + long *arg2 = (long *) 0 ; + long *arg3 = (long *) 0 ; + int result; + + arg1 = (SUNAdaptController)(farg1); + arg2 = (long *)(farg2); + arg3 = (long *)(farg3); + result = (int)SUNAdaptController_Space(arg1,arg2,arg3); + fresult = (int)(result); + return fresult; +} + + + diff --git a/src/sundials/fmod/fsundials_adaptcontroller_mod.f90 b/src/sundials/fmod/fsundials_adaptcontroller_mod.f90 new file mode 100644 index 0000000000..de55e65e0a --- /dev/null +++ b/src/sundials/fmod/fsundials_adaptcontroller_mod.f90 @@ -0,0 +1,586 @@ +! This file was automatically generated by SWIG (http://www.swig.org). +! Version 4.0.0 +! +! Do not make changes to this file unless you know what you are doing--modify +! the SWIG interface file instead. +module fsundials_adaptcontroller_mod + use, intrinsic :: ISO_C_BINDING + use fsundials_types_mod + use fsundials_context_mod + implicit none + private + + ! DECLARATION CONSTRUCTS + ! typedef enum SUNAdaptController_Type + enum, bind(c) + enumerator :: SUN_ADAPTCONTROLLER_NONE + enumerator :: SUN_ADAPTCONTROLLER_H + enumerator :: SUN_ADAPTCONTROLLER_HQ + enumerator :: SUN_ADAPTCONTROLLER_MRI_H + enumerator :: SUN_ADAPTCONTROLLER_MRI_TOL + end enum + integer, parameter, public :: SUNAdaptController_Type = kind(SUN_ADAPTCONTROLLER_NONE) + public :: SUN_ADAPTCONTROLLER_NONE, SUN_ADAPTCONTROLLER_H, SUN_ADAPTCONTROLLER_HQ, SUN_ADAPTCONTROLLER_MRI_H, & + SUN_ADAPTCONTROLLER_MRI_TOL + ! struct struct _generic_SUNAdaptController_Ops + type, bind(C), public :: SUNAdaptController_Ops + type(C_FUNPTR), public :: gettype + type(C_FUNPTR), public :: estimatestep + type(C_FUNPTR), public :: estimatestepandorder + type(C_FUNPTR), public :: estimatemristeps + type(C_FUNPTR), public :: estimatesteptol + type(C_FUNPTR), public :: destroy + type(C_FUNPTR), public :: reset + type(C_FUNPTR), public :: setdefaults + type(C_FUNPTR), public :: write + type(C_FUNPTR), public :: setmethodorder + type(C_FUNPTR), public :: adjustcontrollerorder + type(C_FUNPTR), public :: seterrorbias + type(C_FUNPTR), public :: update + type(C_FUNPTR), public :: updatemrih + type(C_FUNPTR), public :: updatemritol + type(C_FUNPTR), public :: space + end type SUNAdaptController_Ops + ! struct struct _generic_SUNAdaptController + type, bind(C), public :: SUNAdaptController + type(C_PTR), public :: content + type(C_PTR), public :: ops + type(C_PTR), public :: sunctx + end type SUNAdaptController + public :: FSUNAdaptController_NewEmpty + public :: FSUNAdaptController_GetType + public :: FSUNAdaptController_Destroy + public :: FSUNAdaptController_EstimateStep + public :: FSUNAdaptController_EstimateStepAndOrder + public :: FSUNAdaptController_EstimateMRISteps + public :: FSUNAdaptController_EstimateStepTol + public :: FSUNAdaptController_Reset + public :: FSUNAdaptController_SetDefaults + public :: FSUNAdaptController_Write + public :: FSUNAdaptController_SetMethodOrder + public :: FSUNAdaptController_AdjustControllerOrder + public :: FSUNAdaptController_SetErrorBias + public :: FSUNAdaptController_Update + public :: FSUNAdaptController_UpdateMRIH + public :: FSUNAdaptController_UpdateMRITol + public :: FSUNAdaptController_Space + integer(C_INT), parameter, public :: SUNADAPTCONTROLLER_SUCCESS = 0_C_INT + integer(C_INT), parameter, public :: SUNADAPTCONTROLLER_ILL_INPUT = -1001_C_INT + integer(C_INT), parameter, public :: SUNADAPTCONTROLLER_MEM_FAIL = -1002_C_INT + integer(C_INT), parameter, public :: SUNADAPTCONTROLLER_USER_FCN_FAIL = -1003_C_INT + integer(C_INT), parameter, public :: SUNADAPTCONTROLLER_OPERATION_FAIL = -1004_C_INT + +! WRAPPER DECLARATIONS +interface +function swigc_FSUNAdaptController_NewEmpty(farg1) & +bind(C, name="_wrap_FSUNAdaptController_NewEmpty") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +type(C_PTR), value :: farg1 +type(C_PTR) :: fresult +end function + +function swigc_FSUNAdaptController_GetType(farg1) & +bind(C, name="_wrap_FSUNAdaptController_GetType") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +type(C_PTR), value :: farg1 +integer(C_INT) :: fresult +end function + +function swigc_FSUNAdaptController_Destroy(farg1) & +bind(C, name="_wrap_FSUNAdaptController_Destroy") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +type(C_PTR), value :: farg1 +integer(C_INT) :: fresult +end function + +function swigc_FSUNAdaptController_EstimateStep(farg1, farg2, farg3, farg4) & +bind(C, name="_wrap_FSUNAdaptController_EstimateStep") & +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_PTR), value :: farg4 +integer(C_INT) :: fresult +end function + +function swigc_FSUNAdaptController_EstimateStepAndOrder(farg1, farg2, farg3, farg4, farg5, farg6) & +bind(C, name="_wrap_FSUNAdaptController_EstimateStepAndOrder") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +type(C_PTR), value :: farg1 +real(C_DOUBLE), intent(in) :: farg2 +integer(C_INT), intent(in) :: farg3 +real(C_DOUBLE), intent(in) :: farg4 +type(C_PTR), value :: farg5 +type(C_PTR), value :: farg6 +integer(C_INT) :: fresult +end function + +function swigc_FSUNAdaptController_EstimateMRISteps(farg1, farg2, farg3, farg4, farg5, farg6, farg7) & +bind(C, name="_wrap_FSUNAdaptController_EstimateMRISteps") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +type(C_PTR), value :: farg1 +real(C_DOUBLE), intent(in) :: farg2 +real(C_DOUBLE), intent(in) :: farg3 +real(C_DOUBLE), intent(in) :: farg4 +real(C_DOUBLE), intent(in) :: farg5 +type(C_PTR), value :: farg6 +type(C_PTR), value :: farg7 +integer(C_INT) :: fresult +end function + +function swigc_FSUNAdaptController_EstimateStepTol(farg1, farg2, farg3, farg4, farg5, farg6, farg7) & +bind(C, name="_wrap_FSUNAdaptController_EstimateStepTol") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +type(C_PTR), value :: farg1 +real(C_DOUBLE), intent(in) :: farg2 +real(C_DOUBLE), intent(in) :: farg3 +real(C_DOUBLE), intent(in) :: farg4 +real(C_DOUBLE), intent(in) :: farg5 +type(C_PTR), value :: farg6 +type(C_PTR), value :: farg7 +integer(C_INT) :: fresult +end function + +function swigc_FSUNAdaptController_Reset(farg1) & +bind(C, name="_wrap_FSUNAdaptController_Reset") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +type(C_PTR), value :: farg1 +integer(C_INT) :: fresult +end function + +function swigc_FSUNAdaptController_SetDefaults(farg1) & +bind(C, name="_wrap_FSUNAdaptController_SetDefaults") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +type(C_PTR), value :: farg1 +integer(C_INT) :: fresult +end function + +function swigc_FSUNAdaptController_Write(farg1, farg2) & +bind(C, name="_wrap_FSUNAdaptController_Write") & +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_FSUNAdaptController_SetMethodOrder(farg1, farg2, farg3) & +bind(C, name="_wrap_FSUNAdaptController_SetMethodOrder") & +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_FSUNAdaptController_AdjustControllerOrder(farg1, farg2) & +bind(C, name="_wrap_FSUNAdaptController_AdjustControllerOrder") & +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_FSUNAdaptController_SetErrorBias(farg1, farg2) & +bind(C, name="_wrap_FSUNAdaptController_SetErrorBias") & +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_FSUNAdaptController_Update(farg1, farg2, farg3) & +bind(C, name="_wrap_FSUNAdaptController_Update") & +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_FSUNAdaptController_UpdateMRIH(farg1, farg2, farg3, farg4, farg5) & +bind(C, name="_wrap_FSUNAdaptController_UpdateMRIH") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +type(C_PTR), value :: farg1 +real(C_DOUBLE), intent(in) :: farg2 +real(C_DOUBLE), intent(in) :: farg3 +real(C_DOUBLE), intent(in) :: farg4 +real(C_DOUBLE), intent(in) :: farg5 +integer(C_INT) :: fresult +end function + +function swigc_FSUNAdaptController_UpdateMRITol(farg1, farg2, farg3, farg4, farg5) & +bind(C, name="_wrap_FSUNAdaptController_UpdateMRITol") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +type(C_PTR), value :: farg1 +real(C_DOUBLE), intent(in) :: farg2 +real(C_DOUBLE), intent(in) :: farg3 +real(C_DOUBLE), intent(in) :: farg4 +real(C_DOUBLE), intent(in) :: farg5 +integer(C_INT) :: fresult +end function + +function swigc_FSUNAdaptController_Space(farg1, farg2, farg3) & +bind(C, name="_wrap_FSUNAdaptController_Space") & +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 + +end interface + + +contains + ! MODULE SUBPROGRAMS +function FSUNAdaptController_NewEmpty(sunctx) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +type(SUNAdaptController), pointer :: swig_result +type(C_PTR) :: sunctx +type(C_PTR) :: fresult +type(C_PTR) :: farg1 + +farg1 = sunctx +fresult = swigc_FSUNAdaptController_NewEmpty(farg1) +call c_f_pointer(fresult, swig_result) +end function + +function FSUNAdaptController_GetType(c) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(SUNAdaptController_Type) :: swig_result +type(SUNAdaptController), target, intent(inout) :: c +integer(C_INT) :: fresult +type(C_PTR) :: farg1 + +farg1 = c_loc(c) +fresult = swigc_FSUNAdaptController_GetType(farg1) +swig_result = fresult +end function + +function FSUNAdaptController_Destroy(c) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(SUNAdaptController), target, intent(inout) :: c +integer(C_INT) :: fresult +type(C_PTR) :: farg1 + +farg1 = c_loc(c) +fresult = swigc_FSUNAdaptController_Destroy(farg1) +swig_result = fresult +end function + +function FSUNAdaptController_EstimateStep(c, h, dsm, hnew) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(SUNAdaptController), target, intent(inout) :: c +real(C_DOUBLE), intent(in) :: h +real(C_DOUBLE), intent(in) :: dsm +real(C_DOUBLE), target, intent(inout) :: hnew +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +real(C_DOUBLE) :: farg2 +real(C_DOUBLE) :: farg3 +type(C_PTR) :: farg4 + +farg1 = c_loc(c) +farg2 = h +farg3 = dsm +farg4 = c_loc(hnew) +fresult = swigc_FSUNAdaptController_EstimateStep(farg1, farg2, farg3, farg4) +swig_result = fresult +end function + +function FSUNAdaptController_EstimateStepAndOrder(c, h, q, dsm, hnew, qnew) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(SUNAdaptController), target, intent(inout) :: c +real(C_DOUBLE), intent(in) :: h +integer(C_INT), intent(in) :: q +real(C_DOUBLE), intent(in) :: dsm +real(C_DOUBLE), target, intent(inout) :: hnew +integer(C_INT), dimension(*), target, intent(inout) :: qnew +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +real(C_DOUBLE) :: farg2 +integer(C_INT) :: farg3 +real(C_DOUBLE) :: farg4 +type(C_PTR) :: farg5 +type(C_PTR) :: farg6 + +farg1 = c_loc(c) +farg2 = h +farg3 = q +farg4 = dsm +farg5 = c_loc(hnew) +farg6 = c_loc(qnew(1)) +fresult = swigc_FSUNAdaptController_EstimateStepAndOrder(farg1, farg2, farg3, farg4, farg5, farg6) +swig_result = fresult +end function + +function FSUNAdaptController_EstimateMRISteps(c, h, h2, dsm, dsm4, hnew, hnew6) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(SUNAdaptController), target, intent(inout) :: c +real(C_DOUBLE), intent(in) :: h +real(C_DOUBLE), intent(in) :: h2 +real(C_DOUBLE), intent(in) :: dsm +real(C_DOUBLE), intent(in) :: dsm4 +real(C_DOUBLE), target, intent(inout) :: hnew +real(C_DOUBLE), target, intent(inout) :: hnew6 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +real(C_DOUBLE) :: farg2 +real(C_DOUBLE) :: farg3 +real(C_DOUBLE) :: farg4 +real(C_DOUBLE) :: farg5 +type(C_PTR) :: farg6 +type(C_PTR) :: farg7 + +farg1 = c_loc(c) +farg2 = h +farg3 = h2 +farg4 = dsm +farg5 = dsm4 +farg6 = c_loc(hnew) +farg7 = c_loc(hnew6) +fresult = swigc_FSUNAdaptController_EstimateMRISteps(farg1, farg2, farg3, farg4, farg5, farg6, farg7) +swig_result = fresult +end function + +function FSUNAdaptController_EstimateStepTol(c, h, tolfac, dsm, dsm4, hnew, tolfacnew) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(SUNAdaptController), target, intent(inout) :: c +real(C_DOUBLE), intent(in) :: h +real(C_DOUBLE), intent(in) :: tolfac +real(C_DOUBLE), intent(in) :: dsm +real(C_DOUBLE), intent(in) :: dsm4 +real(C_DOUBLE), target, intent(inout) :: hnew +real(C_DOUBLE), target, intent(inout) :: tolfacnew +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +real(C_DOUBLE) :: farg2 +real(C_DOUBLE) :: farg3 +real(C_DOUBLE) :: farg4 +real(C_DOUBLE) :: farg5 +type(C_PTR) :: farg6 +type(C_PTR) :: farg7 + +farg1 = c_loc(c) +farg2 = h +farg3 = tolfac +farg4 = dsm +farg5 = dsm4 +farg6 = c_loc(hnew) +farg7 = c_loc(tolfacnew) +fresult = swigc_FSUNAdaptController_EstimateStepTol(farg1, farg2, farg3, farg4, farg5, farg6, farg7) +swig_result = fresult +end function + +function FSUNAdaptController_Reset(c) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(SUNAdaptController), target, intent(inout) :: c +integer(C_INT) :: fresult +type(C_PTR) :: farg1 + +farg1 = c_loc(c) +fresult = swigc_FSUNAdaptController_Reset(farg1) +swig_result = fresult +end function + +function FSUNAdaptController_SetDefaults(c) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(SUNAdaptController), target, intent(inout) :: c +integer(C_INT) :: fresult +type(C_PTR) :: farg1 + +farg1 = c_loc(c) +fresult = swigc_FSUNAdaptController_SetDefaults(farg1) +swig_result = fresult +end function + +function FSUNAdaptController_Write(c, fptr) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(SUNAdaptController), target, intent(inout) :: c +type(C_PTR) :: fptr +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 + +farg1 = c_loc(c) +farg2 = fptr +fresult = swigc_FSUNAdaptController_Write(farg1, farg2) +swig_result = fresult +end function + +function FSUNAdaptController_SetMethodOrder(c, p, q) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(SUNAdaptController), target, intent(inout) :: c +integer(C_INT), intent(in) :: p +integer(C_INT), intent(in) :: q +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +integer(C_INT) :: farg2 +integer(C_INT) :: farg3 + +farg1 = c_loc(c) +farg2 = p +farg3 = q +fresult = swigc_FSUNAdaptController_SetMethodOrder(farg1, farg2, farg3) +swig_result = fresult +end function + +function FSUNAdaptController_AdjustControllerOrder(c, adj) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(SUNAdaptController), target, intent(inout) :: c +integer(C_INT), intent(in) :: adj +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +integer(C_INT) :: farg2 + +farg1 = c_loc(c) +farg2 = adj +fresult = swigc_FSUNAdaptController_AdjustControllerOrder(farg1, farg2) +swig_result = fresult +end function + +function FSUNAdaptController_SetErrorBias(c, bias) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(SUNAdaptController), target, intent(inout) :: c +real(C_DOUBLE), intent(in) :: bias +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +real(C_DOUBLE) :: farg2 + +farg1 = c_loc(c) +farg2 = bias +fresult = swigc_FSUNAdaptController_SetErrorBias(farg1, farg2) +swig_result = fresult +end function + +function FSUNAdaptController_Update(c, h, dsm) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(SUNAdaptController), target, intent(inout) :: c +real(C_DOUBLE), intent(in) :: h +real(C_DOUBLE), intent(in) :: dsm +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +real(C_DOUBLE) :: farg2 +real(C_DOUBLE) :: farg3 + +farg1 = c_loc(c) +farg2 = h +farg3 = dsm +fresult = swigc_FSUNAdaptController_Update(farg1, farg2, farg3) +swig_result = fresult +end function + +function FSUNAdaptController_UpdateMRIH(c, h, h2, dsm, dsm4) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(SUNAdaptController), target, intent(inout) :: c +real(C_DOUBLE), intent(in) :: h +real(C_DOUBLE), intent(in) :: h2 +real(C_DOUBLE), intent(in) :: dsm +real(C_DOUBLE), intent(in) :: dsm4 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +real(C_DOUBLE) :: farg2 +real(C_DOUBLE) :: farg3 +real(C_DOUBLE) :: farg4 +real(C_DOUBLE) :: farg5 + +farg1 = c_loc(c) +farg2 = h +farg3 = h2 +farg4 = dsm +farg5 = dsm4 +fresult = swigc_FSUNAdaptController_UpdateMRIH(farg1, farg2, farg3, farg4, farg5) +swig_result = fresult +end function + +function FSUNAdaptController_UpdateMRITol(c, h, tolfac, dsm, dsm4) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(SUNAdaptController), target, intent(inout) :: c +real(C_DOUBLE), intent(in) :: h +real(C_DOUBLE), intent(in) :: tolfac +real(C_DOUBLE), intent(in) :: dsm +real(C_DOUBLE), intent(in) :: dsm4 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +real(C_DOUBLE) :: farg2 +real(C_DOUBLE) :: farg3 +real(C_DOUBLE) :: farg4 +real(C_DOUBLE) :: farg5 + +farg1 = c_loc(c) +farg2 = h +farg3 = tolfac +farg4 = dsm +farg5 = dsm4 +fresult = swigc_FSUNAdaptController_UpdateMRITol(farg1, farg2, farg3, farg4, farg5) +swig_result = fresult +end function + +function FSUNAdaptController_Space(c, lenrw, leniw) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(SUNAdaptController), target, intent(inout) :: c +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 = c_loc(c) +farg2 = c_loc(lenrw(1)) +farg3 = c_loc(leniw(1)) +fresult = swigc_FSUNAdaptController_Space(farg1, farg2, farg3) +swig_result = fresult +end function + + +end module diff --git a/src/sundials/sundials_adaptcontroller.c b/src/sundials/sundials_adaptcontroller.c new file mode 100644 index 0000000000..153d5abea1 --- /dev/null +++ b/src/sundials/sundials_adaptcontroller.c @@ -0,0 +1,261 @@ +/* ----------------------------------------------------------------- + * Programmer(s): Daniel R. Reynolds @ SMU + * ----------------------------------------------------------------- + * SUNDIALS Copyright Start + * Copyright (c) 2002-2023, Lawrence Livermore National Security + * and Southern Methodist University. + * All rights reserved. + * + * See the top-level LICENSE and NOTICE files for details. + * + * SPDX-License-Identifier: BSD-3-Clause + * SUNDIALS Copyright End + * ----------------------------------------------------------------- + * This is the implementation file for a generic SUNAdaptController + * package. It contains the implementation of the SUNAdaptController + * operations listed in sundials_adaptcontroller.h + * -----------------------------------------------------------------*/ + +#include + +/* ----------------------------------------------------------------- + * Create a new empty SUNAdaptController object + * ----------------------------------------------------------------- */ + +SUNAdaptController SUNAdaptController_NewEmpty(SUNContext sunctx) +{ + SUNAdaptController C; + SUNAdaptController_Ops ops; + + /* a context is required */ + if (sunctx == NULL) return(NULL); + + /* create controller object */ + C = NULL; + C = (SUNAdaptController) malloc(sizeof *C); + if (C == NULL) return(NULL); + + /* create matrix ops structure */ + ops = NULL; + ops = (SUNAdaptController_Ops) malloc(sizeof *ops); + if (ops == NULL) { free(C); return(NULL); } + + /* initialize operations to NULL */ + ops->gettype = NULL; + ops->destroy = NULL; + ops->reset = NULL; + ops->estimatestep = NULL; + ops->estimatestepandorder = NULL; + ops->estimatemristeps = NULL; + ops->estimatesteptol = NULL; + ops->setdefaults = NULL; + ops->write = NULL; + ops->setmethodorder = NULL; + ops->adjustcontrollerorder = NULL; + ops->seterrorbias = NULL; + ops->update = NULL; + ops->updatemrih = NULL; + ops->updatemritol = NULL; + ops->space = NULL; + + /* attach ops and initialize content to NULL */ + C->ops = ops; + C->content = NULL; + C->sunctx = sunctx; + + return(C); +} + + +/* ----------------------------------------------------------------- + * Free a generic SUNAdaptController (assumes content is already empty) + * ----------------------------------------------------------------- */ + +void SUNAdaptController_FreeEmpty(SUNAdaptController C) +{ + if (C == NULL) return; + + /* free non-NULL ops structure */ + if (C->ops) free(C->ops); + C->ops = NULL; + + /* free overall SUNAdaptController object and return */ + free(C); + return; +} + + +/* ----------------------------------------------------------------- + * Required functions in the 'ops' structure for non-NULL controller + * ----------------------------------------------------------------- */ + +SUNAdaptController_Type SUNAdaptController_GetType(SUNAdaptController C) +{ + if (C == NULL) { return SUN_ADAPTCONTROLLER_NONE; } + return(C->ops->gettype(C)); +} + +/* ----------------------------------------------------------------- + * Optional functions in the 'ops' structure + * ----------------------------------------------------------------- */ + +int SUNAdaptController_Destroy(SUNAdaptController C) +{ + if (C == NULL) return(SUNADAPTCONTROLLER_SUCCESS); + + /* if the destroy operation exists use it */ + if (C->ops) + if (C->ops->destroy) { return(C->ops->destroy(C)); } + + /* if we reach this point, either ops == NULL or destroy == NULL, + try to cleanup by freeing the content, ops, and matrix */ + if (C->content) { free(C->content); C->content = NULL; } + if (C->ops) { free(C->ops); C->ops = NULL; } + free(C); C = NULL; + + return(SUNADAPTCONTROLLER_SUCCESS); +} + +int SUNAdaptController_EstimateStep(SUNAdaptController C, sunrealtype h, sunrealtype dsm, + sunrealtype* hnew) +{ + int ier = 0; + *hnew = h; /* initialize output with identity */ + if (C == NULL) { return ier; } + if (C->ops->estimatestep) + { + ier = C->ops->estimatestep(C, h, dsm, hnew); + } + return(ier); +} + + +int SUNAdaptController_EstimateStepAndOrder(SUNAdaptController C, sunrealtype h, int q, + sunrealtype dsm, sunrealtype* hnew, + int *qnew) +{ + int ier = 0; + *hnew = h; /* initialize outputs with identity */ + *qnew = q; + if (C == NULL) { return ier; } + if (C->ops->estimatestepandorder) + { + ier = C->ops->estimatestepandorder(C, h, q, dsm, hnew, qnew); + } + return(ier); +} + +int SUNAdaptController_EstimateMRISteps(SUNAdaptController C, sunrealtype H, sunrealtype h, + sunrealtype DSM, sunrealtype dsm, + sunrealtype* Hnew, sunrealtype *hnew) +{ + int ier = 0; + *Hnew = H; /* initialize outputs with identity */ + *hnew = h; + if (C == NULL) { return ier; } + if (C->ops->estimatemristeps) + { + ier = C->ops->estimatemristeps(C, H, DSM, dsm, h, Hnew, hnew); + } + return(ier); +} + +int SUNAdaptController_EstimateStepTol(SUNAdaptController C, sunrealtype H, + sunrealtype tolfac, sunrealtype DSM, + sunrealtype dsm, sunrealtype *Hnew, + sunrealtype* tolfacnew) +{ + int ier = 0; + *Hnew = H; /* initialize outputs with identity */ + *tolfacnew = tolfac; + if (C == NULL) { return ier; } + if (C->ops->estimatesteptol) + { + ier = C->ops->estimatesteptol(C, H, tolfac, DSM, dsm, + Hnew, tolfacnew); + } + return(ier); +} + +int SUNAdaptController_Reset(SUNAdaptController C) +{ + int ier = 0; + if (C == NULL) { return ier; } + if (C->ops->reset) { ier = C->ops->reset(C); } + return(ier); +} + +int SUNAdaptController_SetDefaults(SUNAdaptController C) +{ + int ier = 0; + if (C->ops->setdefaults) { ier = C->ops->setdefaults(C); } + return(ier); +} + +int SUNAdaptController_Write(SUNAdaptController C, FILE* fptr) +{ + int ier = 0; + if (C == NULL) { return ier; } + if (C->ops->write) { ier = C->ops->write(C, fptr); } + return(ier); +} + +int SUNAdaptController_SetMethodOrder(SUNAdaptController C, int p, int q) +{ + int ier = 0; + if (C == NULL) { return ier; } + if (C->ops->setmethodorder) { ier = C->ops->setmethodorder(C, p, q); } + return(ier); +} + +int SUNAdaptController_AdjustControllerOrder(SUNAdaptController C, int adj) +{ + int ier = 0; + if (C == NULL) { return ier; } + if (C->ops->adjustcontrollerorder) { ier = C->ops->adjustcontrollerorder(C, adj); } + return(ier); +} + +int SUNAdaptController_SetErrorBias(SUNAdaptController C, sunrealtype bias) +{ + int ier = 0; + if (C == NULL) { return ier; } + if (C->ops->seterrorbias) { ier = C->ops->seterrorbias(C, bias); } + return(ier); +} + +int SUNAdaptController_Update(SUNAdaptController C, sunrealtype h, sunrealtype dsm) +{ + int ier = 0; + if (C == NULL) { return ier; } + if (C->ops->update) { ier = C->ops->update(C, h, dsm); } + return(ier); +} + +int SUNAdaptController_UpdateMRIH(SUNAdaptController C, sunrealtype H, sunrealtype h, + sunrealtype DSM, sunrealtype dsm) +{ + int ier = 0; + if (C == NULL) { return ier; } + if (C->ops->updatemrih) { ier = C->ops->updatemrih(C, H, h, DSM, dsm); } + return(ier); +} + +int SUNAdaptController_UpdateMRITol(SUNAdaptController C, sunrealtype H, sunrealtype tolfac, + sunrealtype DSM, sunrealtype dsm) +{ + int ier = 0; + if (C == NULL) { return ier; } + if (C->ops->updatemritol) { ier = C->ops->updatemritol(C, H, tolfac, DSM, dsm); } + return(ier); +} + +int SUNAdaptController_Space(SUNAdaptController C, long int *lenrw, long int *leniw) +{ + int ier = 0; + *lenrw = 0; /* initialize outputs with identity */ + *leniw = 0; + if (C == NULL) { return ier; } + if (C->ops->space) { ier = C->ops->space(C, lenrw, leniw); } + return(ier); +} diff --git a/swig/Makefile b/swig/Makefile index ce4f536a66..94bd0782d6 100644 --- a/swig/Makefile +++ b/swig/Makefile @@ -20,17 +20,18 @@ CVODES=fcvodes_mod IDA=fida_mod IDAS=fidas_mod KINSOL=fkinsol_mod -GENERIC=fsundials_types_mod fsundials_nvector_mod fsundials_matrix_mod fsundials_linearsolver_mod fsundials_nonlinearsolver_mod fsundials_futils_mod fsundials_context_mod fsundials_profiler_mod fsundials_logger_mod +GENERIC=fsundials_types_mod fsundials_nvector_mod fsundials_matrix_mod fsundials_linearsolver_mod fsundials_nonlinearsolver_mod fsundials_futils_mod fsundials_context_mod fsundials_profiler_mod fsundials_logger_mod fsundials_adaptcontroller_mod NVECTOR=openmp pthreads serial parallel manyvector mpiplusx SUNMATRIX=band dense sparse SUNLINSOL=band dense klu spbcgs spfgmr spgmr sptfqmr pcg SUNNONLINSOL=newton fixedpoint +SUNADAPTCONTROLLER=expgus imexgus i impgus pid pi INCLUDES=-I../include -.PHONY: generic arkode cvode cvodes ida idas kinsol nvector sunmatrix sunlinsol sunnonlinsol patch +.PHONY: generic arkode cvode cvodes ida idas kinsol nvector sunmatrix sunlinsol sunnonlinsol sunadaptcontroller patch -all: generic arkode cvode cvodes ida idas kinsol nvector sunmatrix sunlinsol sunnonlinsol patch +all: generic arkode cvode cvodes ida idas kinsol nvector sunmatrix sunlinsol sunnonlinsol sunadaptcontroller patch arkode: $(ARKODE:%:arkode/%.i) @for i in ${ARKODE} ; do \ @@ -102,6 +103,12 @@ sunnonlinsol: $(SUNNONLINSOL:%:sunnonlinsol/fsunnonlinsol_%_mod.i) swig -fortran -outdir ../src/sunnonlinsol/$${i}/fmod -o ../src/sunnonlinsol/$${i}/fmod/fsunnonlinsol_$${i}_mod.c ${INCLUDES} sunnonlinsol/fsunnonlinsol_$${i}_mod.i ; \ done +sunadaptcontroller: $(SUNADAPTCONTROLLER:%:sunadaptcontroller/fsunadaptcontroller_%_mod.i) + @for i in ${SUNADAPTCONTROLLER} ; do \ + echo "swig -fortran -outdir ../src/sunadaptcontroller/$${i}/fmod -o ../src/sunadaptcontroller/$${i}/fmod ${INCLUDES} sunadaptcontroller/fsunadaptcontroller_$${i}_mod.i" ; \ + swig -fortran -outdir ../src/sunadaptcontroller/$${i}/fmod -o ../src/sunadaptcontroller/$${i}/fmod/fsunadaptcontroller_$${i}_mod.c ${INCLUDES} sunadaptcontroller/fsunadaptcontroller_$${i}_mod.i ; \ + done + patch: .FORCE cd ..; diff --git a/swig/arkode/farkode_mod.i b/swig/arkode/farkode_mod.i index caaad3f3c1..926f895ab8 100644 --- a/swig/arkode/farkode_mod.i +++ b/swig/arkode/farkode_mod.i @@ -34,6 +34,7 @@ %import "../sundials/fsundials_matrix_mod.i" %import "../sundials/fsundials_linearsolver_mod.i" %import "../sundials/fsundials_nonlinearsolver_mod.i" +%import "../sundials/fsundials_adaptcontroller_mod.i" %import "../sundials/fsundials_types_mod.i" // Treat ARKodeButcherTable as an opaque pointer diff --git a/swig/sunadaptcontroller/fsunadaptcontroller.i b/swig/sunadaptcontroller/fsunadaptcontroller.i new file mode 100644 index 0000000000..3fd2354fa3 --- /dev/null +++ b/swig/sunadaptcontroller/fsunadaptcontroller.i @@ -0,0 +1,30 @@ +// --------------------------------------------------------------- +// Programmer: Daniel R. Reynolds @ SMU +// --------------------------------------------------------------- +// SUNDIALS Copyright Start +// Copyright (c) 2002-2023, 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 +// --------------------------------------------------------------- +// Swig interface file +// --------------------------------------------------------------- + +// Include shared configuration +%include "../sundials/fsundials.i" + +%{ +#include "sundials/sundials_adaptcontroller.h" +%} + +// Load the typedefs and generate "use" statements +%import "../sundials/fsundials_adaptcontroller_mod.i" + +// Macro for creating an interface to a SUNAdaptController +%define %sunadaptcontroller_impl(TYPE) + %ignore _SUNAdaptControllerContent_## TYPE ##; +%enddef diff --git a/swig/sunadaptcontroller/fsunadaptcontroller_expgus_mod.i b/swig/sunadaptcontroller/fsunadaptcontroller_expgus_mod.i new file mode 100644 index 0000000000..b3644741e2 --- /dev/null +++ b/swig/sunadaptcontroller/fsunadaptcontroller_expgus_mod.i @@ -0,0 +1,29 @@ +// --------------------------------------------------------------- +// Programmer: Daniel R. Reynolds @ SMU +// --------------------------------------------------------------- +// SUNDIALS Copyright Start +// Copyright (c) 2002-2023, 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 +// --------------------------------------------------------------- +// Swig interface file +// --------------------------------------------------------------- + +%module fsunadaptcontroller_expgus_mod + +// include code common to all implementations +%include "fsunadaptcontroller.i" + +%{ +#include "sunadaptcontroller/sunadaptcontroller_expgus.h" +%} + +%sunadaptcontroller_impl(ExpGus) + +// Process and wrap functions in the following files +%include "sunadaptcontroller/sunadaptcontroller_expgus.h" diff --git a/swig/sunadaptcontroller/fsunadaptcontroller_i_mod.i b/swig/sunadaptcontroller/fsunadaptcontroller_i_mod.i new file mode 100644 index 0000000000..25e4a61797 --- /dev/null +++ b/swig/sunadaptcontroller/fsunadaptcontroller_i_mod.i @@ -0,0 +1,29 @@ +// --------------------------------------------------------------- +// Programmer: Daniel R. Reynolds @ SMU +// --------------------------------------------------------------- +// SUNDIALS Copyright Start +// Copyright (c) 2002-2023, 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 +// --------------------------------------------------------------- +// Swig interface file +// --------------------------------------------------------------- + +%module fsunadaptcontroller_i_mod + +// include code common to all implementations +%include "fsunadaptcontroller.i" + +%{ +#include "sunadaptcontroller/sunadaptcontroller_i.h" +%} + +%sunadaptcontroller_impl(I) + +// Process and wrap functions in the following files +%include "sunadaptcontroller/sunadaptcontroller_i.h" diff --git a/swig/sunadaptcontroller/fsunadaptcontroller_imexgus_mod.i b/swig/sunadaptcontroller/fsunadaptcontroller_imexgus_mod.i new file mode 100644 index 0000000000..1b319a8b7c --- /dev/null +++ b/swig/sunadaptcontroller/fsunadaptcontroller_imexgus_mod.i @@ -0,0 +1,29 @@ +// --------------------------------------------------------------- +// Programmer: Daniel R. Reynolds @ SMU +// --------------------------------------------------------------- +// SUNDIALS Copyright Start +// Copyright (c) 2002-2023, 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 +// --------------------------------------------------------------- +// Swig interface file +// --------------------------------------------------------------- + +%module fsunadaptcontroller_imexgus_mod + +// include code common to all implementations +%include "fsunadaptcontroller.i" + +%{ +#include "sunadaptcontroller/sunadaptcontroller_imexgus.h" +%} + +%sunadaptcontroller_impl(ImExGus) + +// Process and wrap functions in the following files +%include "sunadaptcontroller/sunadaptcontroller_imexgus.h" diff --git a/swig/sunadaptcontroller/fsunadaptcontroller_impgus_mod.i b/swig/sunadaptcontroller/fsunadaptcontroller_impgus_mod.i new file mode 100644 index 0000000000..e9f693c861 --- /dev/null +++ b/swig/sunadaptcontroller/fsunadaptcontroller_impgus_mod.i @@ -0,0 +1,29 @@ +// --------------------------------------------------------------- +// Programmer: Daniel R. Reynolds @ SMU +// --------------------------------------------------------------- +// SUNDIALS Copyright Start +// Copyright (c) 2002-2023, 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 +// --------------------------------------------------------------- +// Swig interface file +// --------------------------------------------------------------- + +%module fsunadaptcontroller_impgus_mod + +// include code common to all implementations +%include "fsunadaptcontroller.i" + +%{ +#include "sunadaptcontroller/sunadaptcontroller_impgus.h" +%} + +%sunadaptcontroller_impl(ImpGus) + +// Process and wrap functions in the following files +%include "sunadaptcontroller/sunadaptcontroller_impgus.h" diff --git a/swig/sunadaptcontroller/fsunadaptcontroller_pi_mod.i b/swig/sunadaptcontroller/fsunadaptcontroller_pi_mod.i new file mode 100644 index 0000000000..e715b80356 --- /dev/null +++ b/swig/sunadaptcontroller/fsunadaptcontroller_pi_mod.i @@ -0,0 +1,29 @@ +// --------------------------------------------------------------- +// Programmer: Daniel R. Reynolds @ SMU +// --------------------------------------------------------------- +// SUNDIALS Copyright Start +// Copyright (c) 2002-2023, 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 +// --------------------------------------------------------------- +// Swig interface file +// --------------------------------------------------------------- + +%module fsunadaptcontroller_pi_mod + +// include code common to all implementations +%include "fsunadaptcontroller.i" + +%{ +#include "sunadaptcontroller/sunadaptcontroller_pi.h" +%} + +%sunadaptcontroller_impl(PI) + +// Process and wrap functions in the following files +%include "sunadaptcontroller/sunadaptcontroller_pi.h" diff --git a/swig/sunadaptcontroller/fsunadaptcontroller_pid_mod.i b/swig/sunadaptcontroller/fsunadaptcontroller_pid_mod.i new file mode 100644 index 0000000000..67e04144e2 --- /dev/null +++ b/swig/sunadaptcontroller/fsunadaptcontroller_pid_mod.i @@ -0,0 +1,29 @@ +// --------------------------------------------------------------- +// Programmer: Daniel R. Reynolds @ SMU +// --------------------------------------------------------------- +// SUNDIALS Copyright Start +// Copyright (c) 2002-2023, 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 +// --------------------------------------------------------------- +// Swig interface file +// --------------------------------------------------------------- + +%module fsunadaptcontroller_pid_mod + +// include code common to all implementations +%include "fsunadaptcontroller.i" + +%{ +#include "sunadaptcontroller/sunadaptcontroller_pid.h" +%} + +%sunadaptcontroller_impl(PID) + +// Process and wrap functions in the following files +%include "sunadaptcontroller/sunadaptcontroller_pid.h" diff --git a/swig/sundials/fsundials.i b/swig/sundials/fsundials.i index dcda29e1c8..bac0f74646 100644 --- a/swig/sundials/fsundials.i +++ b/swig/sundials/fsundials.i @@ -37,6 +37,7 @@ %sundials_generic(SUNLinearSolver) %sundials_generic(SUNNonlinearSolver) %sundials_generic(SUNMatrix) +%sundials_generic(SUNAdaptController) // Treat FILE* as an opaque pointer %apply void* { FILE* }; diff --git a/swig/sundials/fsundials_adaptcontroller_mod.i b/swig/sundials/fsundials_adaptcontroller_mod.i new file mode 100644 index 0000000000..ff88ab8893 --- /dev/null +++ b/swig/sundials/fsundials_adaptcontroller_mod.i @@ -0,0 +1,28 @@ +// --------------------------------------------------------------- +// Programmer: Daniel R. Reynolds @ SMU +// --------------------------------------------------------------- +// SUNDIALS Copyright Start +// Copyright (c) 2002-2023, 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 +// --------------------------------------------------------------- +// Swig interface file +// --------------------------------------------------------------- + +%module fsundials_adaptcontroller_mod + +// Load the typedefs and generate a "use" statement in the module +%import "../sundials/fsundials_types_mod.i" +%import "../sundials/fsundials_context_mod.i" + +%{ +#include "sundials/sundials_adaptcontroller.h" +%} + +// Process and wrap functions in the following files +%include "sundials/sundials_adaptcontroller.h" From f94e99b5b6466b681dd7074135a0598b4b6b0c1f Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Wed, 18 Oct 2023 15:18:38 -0500 Subject: [PATCH 02/58] Added no-op SUNAdaptController implementation, to be used with fixed stepsize runs --- .../sunadaptcontroller_noop.h | 44 ++++ src/arkode/CMakeLists.txt | 1 + src/arkode/arkode_io.c | 26 +- src/sunadaptcontroller/CMakeLists.txt | 1 + src/sunadaptcontroller/noop/CMakeLists.txt | 29 +++ .../noop/fmod/CMakeLists.txt | 25 ++ .../noop/fmod/fsunadaptcontroller_noop_mod.c | 235 ++++++++++++++++++ .../fmod/fsunadaptcontroller_noop_mod.f90 | 83 +++++++ .../noop/sunadaptcontroller_noop.c | 52 ++++ swig/Makefile | 6 +- .../fsunadaptcontroller_noop_mod.i | 29 +++ 11 files changed, 519 insertions(+), 12 deletions(-) create mode 100644 include/sunadaptcontroller/sunadaptcontroller_noop.h create mode 100644 src/sunadaptcontroller/noop/CMakeLists.txt create mode 100644 src/sunadaptcontroller/noop/fmod/CMakeLists.txt create mode 100644 src/sunadaptcontroller/noop/fmod/fsunadaptcontroller_noop_mod.c create mode 100644 src/sunadaptcontroller/noop/fmod/fsunadaptcontroller_noop_mod.f90 create mode 100644 src/sunadaptcontroller/noop/sunadaptcontroller_noop.c create mode 100644 swig/sunadaptcontroller/fsunadaptcontroller_noop_mod.i diff --git a/include/sunadaptcontroller/sunadaptcontroller_noop.h b/include/sunadaptcontroller/sunadaptcontroller_noop.h new file mode 100644 index 0000000000..8dd61cce74 --- /dev/null +++ b/include/sunadaptcontroller/sunadaptcontroller_noop.h @@ -0,0 +1,44 @@ +/* ----------------------------------------------------------------- + * Programmer(s): Daniel R. Reynolds @ SMU + * ----------------------------------------------------------------- + * SUNDIALS Copyright Start + * Copyright (c) 2002-2023, Lawrence Livermore National Security + * and Southern Methodist University. + * All rights reserved. + * + * See the top-level LICENSE and NOTICE files for details. + * + * SPDX-License-Identifier: BSD-3-Clause + * SUNDIALS Copyright End + * ----------------------------------------------------------------- + * This is the header file for the SUNAdaptController_NOOP module. + * -----------------------------------------------------------------*/ + +#ifndef _SUNADAPTCONTROLLER_NOOP_H +#define _SUNADAPTCONTROLLER_NOOP_H + +#include +#include + +#ifdef __cplusplus /* wrapper to enable C++ usage */ +extern "C" { +#endif + +/* ------------------------------------------ + * No-op implementation of SUNAdaptController + * ------------------------------------------ */ + +/* ------------------ + * Exported Functions + * ------------------ */ + +SUNDIALS_EXPORT +SUNAdaptController SUNAdaptController_NoOp(SUNContext sunctx); +SUNDIALS_EXPORT +SUNAdaptController_Type SUNAdaptController_GetType_NoOp(SUNAdaptController C); + +#ifdef __cplusplus +} +#endif + +#endif /* _SUNADAPTCONTROLLER_PID_H */ diff --git a/src/arkode/CMakeLists.txt b/src/arkode/CMakeLists.txt index c2eb0582e6..c8888ccd08 100644 --- a/src/arkode/CMakeLists.txt +++ b/src/arkode/CMakeLists.txt @@ -82,6 +82,7 @@ sundials_add_library(sundials_arkode sundials_sunadaptcontrollerimpgus_obj sundials_sunadaptcontrollerpi_obj sundials_sunadaptcontrollerimexgus_obj + sundials_sunadaptcontrollernoop_obj sundials_sunmatrixband_obj sundials_sunmatrixdense_obj sundials_sunmatrixsparse_obj diff --git a/src/arkode/arkode_io.c b/src/arkode/arkode_io.c index 8f7dc02afe..cca8d034ad 100644 --- a/src/arkode/arkode_io.c +++ b/src/arkode/arkode_io.c @@ -32,6 +32,7 @@ #include #include #include +#include /*=============================================================== @@ -671,25 +672,32 @@ int arkSetFixedStep(void *arkode_mem, realtype hfixed) ark_mem->hadapt_mem->hcontroller = NULL; /* If re-enabling time adaptivity, create default PID controller - and attach object to ARKODE */ + and attach object to ARKODE. + Otherwise, create No-op controller and attach to ARKODE. */ SUNAdaptController C = NULL; if (hfixed == ZERO) { C = SUNAdaptController_PID(ark_mem->sunctx); if (C == NULL) { arkProcessError(ark_mem, ARK_MEM_FAIL, "ARKODE", "arkSetFixedStep", - "SUNAdaptControllerPID allocation failure"); + "SUNAdaptController_PID allocation failure"); return(ARK_MEM_FAIL); } - - retval = SUNAdaptController_Space(C, &lenrw, &leniw); - if (retval == SUNADAPTCONTROLLER_SUCCESS) { - ark_mem->liw += leniw; - ark_mem->lrw += lenrw; + } else { + C = SUNAdaptController_NoOp(ark_mem->sunctx); + if (C == NULL) { + arkProcessError(ark_mem, ARK_MEM_FAIL, "ARKODE", "arkSetFixedStep", + "SUNAdaptController_NoOp allocation failure"); + return(ARK_MEM_FAIL); } - ark_mem->hadapt_mem->hcontroller = C; - ark_mem->hadapt_mem->owncontroller = SUNTRUE; } + retval = SUNAdaptController_Space(C, &lenrw, &leniw); + if (retval == SUNADAPTCONTROLLER_SUCCESS) { + ark_mem->liw += leniw; + ark_mem->lrw += lenrw; + } + ark_mem->hadapt_mem->hcontroller = C; + ark_mem->hadapt_mem->owncontroller = SUNTRUE; /* re-attach internal error weight functions if necessary */ if ((hfixed == ZERO) && (!ark_mem->user_efun)) { diff --git a/src/sunadaptcontroller/CMakeLists.txt b/src/sunadaptcontroller/CMakeLists.txt index f24d46456e..bb3a248f70 100644 --- a/src/sunadaptcontroller/CMakeLists.txt +++ b/src/sunadaptcontroller/CMakeLists.txt @@ -19,5 +19,6 @@ add_subdirectory(expgus) add_subdirectory(i) add_subdirectory(imexgus) add_subdirectory(impgus) +add_subdirectory(noop) add_subdirectory(pi) add_subdirectory(pid) diff --git a/src/sunadaptcontroller/noop/CMakeLists.txt b/src/sunadaptcontroller/noop/CMakeLists.txt new file mode 100644 index 0000000000..0941825c54 --- /dev/null +++ b/src/sunadaptcontroller/noop/CMakeLists.txt @@ -0,0 +1,29 @@ +# --------------------------------------------------------------- +# Programmer(s): Daniel R. Reynolds @ SMU +# --------------------------------------------------------------- +# SUNDIALS Copyright Start +# Copyright (c) 2002-2023, 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 +# --------------------------------------------------------------- + +# Create a library out of the generic sundials modules +sundials_add_library(sundials_sunadaptcontrollernoop + SOURCES + sunadaptcontroller_noop.c + HEADERS + ${SUNDIALS_SOURCE_DIR}/include/sunadaptcontroller/sunadaptcontroller_noop.h + INCLUDE_SUBDIR + sunadaptcontroller + OBJECT_LIB_ONLY +) + +# Add F2003 module if the interface is enabled +if(BUILD_FORTRAN_MODULE_INTERFACE) + add_subdirectory(fmod) +endif() diff --git a/src/sunadaptcontroller/noop/fmod/CMakeLists.txt b/src/sunadaptcontroller/noop/fmod/CMakeLists.txt new file mode 100644 index 0000000000..57f2a4e7fd --- /dev/null +++ b/src/sunadaptcontroller/noop/fmod/CMakeLists.txt @@ -0,0 +1,25 @@ +# --------------------------------------------------------------- +# Programmer(s): Daniel R. Reynolds @ SMU +# --------------------------------------------------------------- +# SUNDIALS Copyright Start +# Copyright (c) 2002-2023, 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 +# --------------------------------------------------------------- + +sundials_add_f2003_library(sundials_fsunadaptcontrollernoop_mod + SOURCES + fsunadaptcontroller_noop_mod.f90 fsunadaptcontroller_noop_mod.c + OBJECT_LIBRARIES + sundials_fgeneric_mod_obj + OUTPUT_NAME + sundials_fsunadaptcontrollernoop_mod + OBJECT_LIB_ONLY +) + +message(STATUS "Added SUNAdaptController_NOOP F2003 interface") diff --git a/src/sunadaptcontroller/noop/fmod/fsunadaptcontroller_noop_mod.c b/src/sunadaptcontroller/noop/fmod/fsunadaptcontroller_noop_mod.c new file mode 100644 index 0000000000..ad0c233426 --- /dev/null +++ b/src/sunadaptcontroller/noop/fmod/fsunadaptcontroller_noop_mod.c @@ -0,0 +1,235 @@ +/* ---------------------------------------------------------------------------- + * This file was automatically generated by SWIG (http://www.swig.org). + * Version 4.0.0 + * + * This file is not intended to be easily readable and contains a number of + * coding conventions designed to improve portability and efficiency. Do not make + * changes to this file unless you know what you are doing--modify the SWIG + * interface file instead. + * ----------------------------------------------------------------------------- */ + +/* --------------------------------------------------------------- + * Programmer(s): Auto-generated by swig. + * --------------------------------------------------------------- + * SUNDIALS Copyright Start + * Copyright (c) 2002-2023, Lawrence Livermore National Security + * and Southern Methodist University. + * All rights reserved. + * + * See the top-level LICENSE and NOTICE files for details. + * + * SPDX-License-Identifier: BSD-3-Clause + * SUNDIALS Copyright End + * -------------------------------------------------------------*/ + +/* ----------------------------------------------------------------------------- + * This section contains generic SWIG labels for method/variable + * declarations/attributes, and other compiler dependent labels. + * ----------------------------------------------------------------------------- */ + +/* template workaround for compilers that cannot correctly implement the C++ standard */ +#ifndef SWIGTEMPLATEDISAMBIGUATOR +# if defined(__SUNPRO_CC) && (__SUNPRO_CC <= 0x560) +# define SWIGTEMPLATEDISAMBIGUATOR template +# elif defined(__HP_aCC) +/* Needed even with `aCC -AA' when `aCC -V' reports HP ANSI C++ B3910B A.03.55 */ +/* If we find a maximum version that requires this, the test would be __HP_aCC <= 35500 for A.03.55 */ +# define SWIGTEMPLATEDISAMBIGUATOR template +# else +# define SWIGTEMPLATEDISAMBIGUATOR +# endif +#endif + +/* inline attribute */ +#ifndef SWIGINLINE +# if defined(__cplusplus) || (defined(__GNUC__) && !defined(__STRICT_ANSI__)) +# define SWIGINLINE inline +# else +# define SWIGINLINE +# endif +#endif + +/* attribute recognised by some compilers to avoid 'unused' warnings */ +#ifndef SWIGUNUSED +# if defined(__GNUC__) +# if !(defined(__cplusplus)) || (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)) +# define SWIGUNUSED __attribute__ ((__unused__)) +# else +# define SWIGUNUSED +# endif +# elif defined(__ICC) +# define SWIGUNUSED __attribute__ ((__unused__)) +# else +# define SWIGUNUSED +# endif +#endif + +#ifndef SWIG_MSC_UNSUPPRESS_4505 +# if defined(_MSC_VER) +# pragma warning(disable : 4505) /* unreferenced local function has been removed */ +# endif +#endif + +#ifndef SWIGUNUSEDPARM +# ifdef __cplusplus +# define SWIGUNUSEDPARM(p) +# else +# define SWIGUNUSEDPARM(p) p SWIGUNUSED +# endif +#endif + +/* internal SWIG method */ +#ifndef SWIGINTERN +# define SWIGINTERN static SWIGUNUSED +#endif + +/* internal inline SWIG method */ +#ifndef SWIGINTERNINLINE +# define SWIGINTERNINLINE SWIGINTERN SWIGINLINE +#endif + +/* qualifier for exported *const* global data variables*/ +#ifndef SWIGEXTERN +# ifdef __cplusplus +# define SWIGEXTERN extern +# else +# define SWIGEXTERN +# endif +#endif + +/* exporting methods */ +#if defined(__GNUC__) +# if (__GNUC__ >= 4) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) +# ifndef GCC_HASCLASSVISIBILITY +# define GCC_HASCLASSVISIBILITY +# endif +# endif +#endif + +#ifndef SWIGEXPORT +# if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__) +# if defined(STATIC_LINKED) +# define SWIGEXPORT +# else +# define SWIGEXPORT __declspec(dllexport) +# endif +# else +# if defined(__GNUC__) && defined(GCC_HASCLASSVISIBILITY) +# define SWIGEXPORT __attribute__ ((visibility("default"))) +# else +# define SWIGEXPORT +# endif +# endif +#endif + +/* calling conventions for Windows */ +#ifndef SWIGSTDCALL +# if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__) +# define SWIGSTDCALL __stdcall +# else +# define SWIGSTDCALL +# endif +#endif + +/* Deal with Microsoft's attempt at deprecating C standard runtime functions */ +#if !defined(SWIG_NO_CRT_SECURE_NO_DEPRECATE) && defined(_MSC_VER) && !defined(_CRT_SECURE_NO_DEPRECATE) +# define _CRT_SECURE_NO_DEPRECATE +#endif + +/* Deal with Microsoft's attempt at deprecating methods in the standard C++ library */ +#if !defined(SWIG_NO_SCL_SECURE_NO_DEPRECATE) && defined(_MSC_VER) && !defined(_SCL_SECURE_NO_DEPRECATE) +# define _SCL_SECURE_NO_DEPRECATE +#endif + +/* Deal with Apple's deprecated 'AssertMacros.h' from Carbon-framework */ +#if defined(__APPLE__) && !defined(__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES) +# define __ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES 0 +#endif + +/* Intel's compiler complains if a variable which was never initialised is + * cast to void, which is a common idiom which we use to indicate that we + * are aware a variable isn't used. So we just silence that warning. + * See: https://github.com/swig/swig/issues/192 for more discussion. + */ +#ifdef __INTEL_COMPILER +# pragma warning disable 592 +#endif + +/* Errors in SWIG */ +#define SWIG_UnknownError -1 +#define SWIG_IOError -2 +#define SWIG_RuntimeError -3 +#define SWIG_IndexError -4 +#define SWIG_TypeError -5 +#define SWIG_DivisionByZero -6 +#define SWIG_OverflowError -7 +#define SWIG_SyntaxError -8 +#define SWIG_ValueError -9 +#define SWIG_SystemError -10 +#define SWIG_AttributeError -11 +#define SWIG_MemoryError -12 +#define SWIG_NullReferenceError -13 + + + + +#include +#define SWIG_exception_impl(DECL, CODE, MSG, RETURNNULL) \ + { printf("In " DECL ": " MSG); assert(0); RETURNNULL; } + + +#include +#if defined(_MSC_VER) || defined(__BORLANDC__) || defined(_WATCOM) +# ifndef snprintf +# define snprintf _snprintf +# endif +#endif + + +/* Support for the `contract` feature. + * + * Note that RETURNNULL is first because it's inserted via a 'Replaceall' in + * the fortran.cxx file. + */ +#define SWIG_contract_assert(RETURNNULL, EXPR, MSG) \ + if (!(EXPR)) { SWIG_exception_impl("$decl", SWIG_ValueError, MSG, RETURNNULL); } + + +#define SWIGVERSION 0x040000 +#define SWIG_VERSION SWIGVERSION + + +#define SWIG_as_voidptr(a) (void *)((const void *)(a)) +#define SWIG_as_voidptrptr(a) ((void)SWIG_as_voidptr(*a),(void**)(a)) + + +#include "sundials/sundials_adaptcontroller.h" + + +#include "sunadaptcontroller/sunadaptcontroller_noop.h" + +SWIGEXPORT SUNAdaptController _wrap_FSUNAdaptController_NoOp(void *farg1) { + SUNAdaptController fresult ; + SUNContext arg1 = (SUNContext) 0 ; + SUNAdaptController result; + + arg1 = (SUNContext)(farg1); + result = (SUNAdaptController)SUNAdaptController_NoOp(arg1); + fresult = result; + return fresult; +} + + +SWIGEXPORT int _wrap_FSUNAdaptController_GetType_NoOp(SUNAdaptController farg1) { + int fresult ; + SUNAdaptController arg1 = (SUNAdaptController) 0 ; + SUNAdaptController_Type result; + + arg1 = (SUNAdaptController)(farg1); + result = (SUNAdaptController_Type)SUNAdaptController_GetType_NoOp(arg1); + fresult = (int)(result); + return fresult; +} + + + diff --git a/src/sunadaptcontroller/noop/fmod/fsunadaptcontroller_noop_mod.f90 b/src/sunadaptcontroller/noop/fmod/fsunadaptcontroller_noop_mod.f90 new file mode 100644 index 0000000000..5084c8fef3 --- /dev/null +++ b/src/sunadaptcontroller/noop/fmod/fsunadaptcontroller_noop_mod.f90 @@ -0,0 +1,83 @@ +! This file was automatically generated by SWIG (http://www.swig.org). +! Version 4.0.0 +! +! Do not make changes to this file unless you know what you are doing--modify +! the SWIG interface file instead. + +! --------------------------------------------------------------- +! Programmer(s): Auto-generated by swig. +! --------------------------------------------------------------- +! SUNDIALS Copyright Start +! Copyright (c) 2002-2023, 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 +! --------------------------------------------------------------- + +module fsunadaptcontroller_noop_mod + use, intrinsic :: ISO_C_BINDING + use fsundials_adaptcontroller_mod + use fsundials_types_mod + use fsundials_context_mod + implicit none + private + + ! DECLARATION CONSTRUCTS + public :: FSUNAdaptController_NoOp + public :: FSUNAdaptController_GetType_NoOp + +! WRAPPER DECLARATIONS +interface +function swigc_FSUNAdaptController_NoOp(farg1) & +bind(C, name="_wrap_FSUNAdaptController_NoOp") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +type(C_PTR), value :: farg1 +type(C_PTR) :: fresult +end function + +function swigc_FSUNAdaptController_GetType_NoOp(farg1) & +bind(C, name="_wrap_FSUNAdaptController_GetType_NoOp") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +type(C_PTR), value :: farg1 +integer(C_INT) :: fresult +end function + +end interface + + +contains + ! MODULE SUBPROGRAMS +function FSUNAdaptController_NoOp(sunctx) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +type(SUNAdaptController), pointer :: swig_result +type(C_PTR) :: sunctx +type(C_PTR) :: fresult +type(C_PTR) :: farg1 + +farg1 = sunctx +fresult = swigc_FSUNAdaptController_NoOp(farg1) +call c_f_pointer(fresult, swig_result) +end function + +function FSUNAdaptController_GetType_NoOp(c) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(SUNAdaptController_Type) :: swig_result +type(SUNAdaptController), target, intent(inout) :: c +integer(C_INT) :: fresult +type(C_PTR) :: farg1 + +farg1 = c_loc(c) +fresult = swigc_FSUNAdaptController_GetType_NoOp(farg1) +swig_result = fresult +end function + + +end module diff --git a/src/sunadaptcontroller/noop/sunadaptcontroller_noop.c b/src/sunadaptcontroller/noop/sunadaptcontroller_noop.c new file mode 100644 index 0000000000..88aea62181 --- /dev/null +++ b/src/sunadaptcontroller/noop/sunadaptcontroller_noop.c @@ -0,0 +1,52 @@ +/* ----------------------------------------------------------------- + * Programmer(s): Daniel R. Reynolds @ SMU + * ----------------------------------------------------------------- + * SUNDIALS Copyright Start + * Copyright (c) 2002-2023, Lawrence Livermore National Security + * and Southern Methodist University. + * All rights reserved. + * + * See the top-level LICENSE and NOTICE files for details. + * + * SPDX-License-Identifier: BSD-3-Clause + * SUNDIALS Copyright End + * ----------------------------------------------------------------- + * This is the implementation file for the SUNAdaptController_NOOP + * module. + * -----------------------------------------------------------------*/ + +#include +#include +#include +#include + + +/* ----------------------------------------------------------------- + * exported functions + * ----------------------------------------------------------------- */ + +/* ----------------------------------------------------------------- + * Function to create a new No-op controller + */ + +SUNAdaptController SUNAdaptController_NoOp(SUNContext sunctx) +{ + /* Create an empty controller object */ + SUNAdaptController C = NULL; + C = SUNAdaptController_NewEmpty(sunctx); + if (C == NULL) { return (NULL); } + + /* Attach operations */ + C->ops->gettype = SUNAdaptController_GetType_NoOp; + + /* Set NULL-valued content and return */ + C->content = NULL; + return (C); +} + +/* ----------------------------------------------------------------- + * implementation of controller operations + * ----------------------------------------------------------------- */ + +SUNAdaptController_Type SUNAdaptController_GetType_NoOp(SUNAdaptController C) +{ return SUN_ADAPTCONTROLLER_NONE; } diff --git a/swig/Makefile b/swig/Makefile index 94bd0782d6..7811ad296a 100644 --- a/swig/Makefile +++ b/swig/Makefile @@ -25,7 +25,7 @@ NVECTOR=openmp pthreads serial parallel manyvector mpiplusx SUNMATRIX=band dense sparse SUNLINSOL=band dense klu spbcgs spfgmr spgmr sptfqmr pcg SUNNONLINSOL=newton fixedpoint -SUNADAPTCONTROLLER=expgus imexgus i impgus pid pi +SUNADAPTCONTROLLER=expgus imexgus i impgus pid pi noop INCLUDES=-I../include @@ -110,8 +110,8 @@ sunadaptcontroller: $(SUNADAPTCONTROLLER:%:sunadaptcontroller/fsunadaptcontrolle done patch: .FORCE - cd ..; - + cd ..; + clean: rm ../src/**/fmod/*.c; rm ../src/**/fmod/*.f90 diff --git a/swig/sunadaptcontroller/fsunadaptcontroller_noop_mod.i b/swig/sunadaptcontroller/fsunadaptcontroller_noop_mod.i new file mode 100644 index 0000000000..b86c9cfb17 --- /dev/null +++ b/swig/sunadaptcontroller/fsunadaptcontroller_noop_mod.i @@ -0,0 +1,29 @@ +// --------------------------------------------------------------- +// Programmer: Daniel R. Reynolds @ SMU +// --------------------------------------------------------------- +// SUNDIALS Copyright Start +// Copyright (c) 2002-2023, 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 +// --------------------------------------------------------------- +// Swig interface file +// --------------------------------------------------------------- + +%module fsunadaptcontroller_noop_mod + +// include code common to all implementations +%include "fsunadaptcontroller.i" + +%{ +#include "sunadaptcontroller/sunadaptcontroller_noop.h" +%} + +%sunadaptcontroller_impl(NoOp) + +// Process and wrap functions in the following files +%include "sunadaptcontroller/sunadaptcontroller_noop.h" From 7f4c52c5dc7ac348ac6840f63b444f811e2ffbe5 Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Wed, 18 Oct 2023 15:26:28 -0500 Subject: [PATCH 03/58] Moved stepsize bound enforcement inside arkCheckTemporalError, following David's suggestion in feature/oo-adaptivity PR review --- src/arkode/arkode.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/arkode/arkode.c b/src/arkode/arkode.c index 63b8df7f5d..3b040b04e0 100644 --- a/src/arkode/arkode.c +++ b/src/arkode/arkode.c @@ -902,13 +902,6 @@ int arkEvolve(ARKodeMem ark_mem, realtype tout, N_Vector yout, if (kflag < 0) break; } - /* 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 ignoring temporal error test result (XBraid) force step to pass */ if (ark_mem->force_pass) { ark_mem->last_kflag = kflag; @@ -3074,6 +3067,13 @@ int arkCheckTemporalError(ARKodeMem ark_mem, int *nflagPtr, int *nefPtr, realtyp ark_mem->h, dsm, nsttmp); if (retval != ARK_SUCCESS) return(ARK_ERR_FAILURE); + /* 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); From 0e3433f5db920f46cf13d7e1bee438e4173cdebe Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Wed, 18 Oct 2023 16:38:42 -0500 Subject: [PATCH 04/58] Minor update to fix a corner case arising from the previous commit --- src/arkode/arkode.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/arkode/arkode.c b/src/arkode/arkode.c index 3b040b04e0..6d3d7ce8a1 100644 --- a/src/arkode/arkode.c +++ b/src/arkode/arkode.c @@ -3088,10 +3088,15 @@ int arkCheckTemporalError(ARKodeMem ark_mem, int *nflagPtr, int *nefPtr, realtyp /* Set etamax=1 to prevent step size increase at end of this step */ hadapt_mem->etamax = ONE; - /* Enforce failure bounds on eta, update h, and return for retry of step */ + /* Enforce failure bounds on eta */ if (*nefPtr >= hadapt_mem->small_nef) ark_mem->eta = SUNMIN(ark_mem->eta, hadapt_mem->etamxf); + /* 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); } From d1e53f35188ae47ac596ba1df4592fa8b64bb5ad Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Wed, 18 Oct 2023 16:53:11 -0500 Subject: [PATCH 05/58] Fixed C90 errors --- src/arkode/arkode_io.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/arkode/arkode_io.c b/src/arkode/arkode_io.c index cca8d034ad..4e4bf541f6 100644 --- a/src/arkode/arkode_io.c +++ b/src/arkode/arkode_io.c @@ -647,6 +647,7 @@ int arkSetFixedStep(void *arkode_mem, realtype hfixed) int retval; long int lenrw, leniw; ARKodeMem ark_mem; + SUNAdaptController C; if (arkode_mem==NULL) { arkProcessError(NULL, ARK_MEM_NULL, "ARKODE", "arkSetFixedStep", MSG_ARK_NO_MEM); @@ -674,7 +675,7 @@ int arkSetFixedStep(void *arkode_mem, realtype hfixed) /* If re-enabling time adaptivity, create default PID controller and attach object to ARKODE. Otherwise, create No-op controller and attach to ARKODE. */ - SUNAdaptController C = NULL; + C = NULL; if (hfixed == ZERO) { C = SUNAdaptController_PID(ark_mem->sunctx); @@ -949,6 +950,7 @@ int arkSetAdaptivityMethod(void *arkode_mem, int imethod, int idefault, long int lenrw, leniw; realtype k1, k2, k3; ARKodeMem ark_mem; + SUNAdaptController C; if (arkode_mem==NULL) { arkProcessError(NULL, ARK_MEM_NULL, "ARKODE", "arkSetController", MSG_ARK_NO_MEM); @@ -994,7 +996,7 @@ int arkSetAdaptivityMethod(void *arkode_mem, int imethod, int idefault, /* Create new SUNAdaptController object based on "imethod" input, optionally setting the specified controller parameters */ - SUNAdaptController C = NULL; + C = NULL; switch (imethod) { case (ARK_ADAPT_PID): C = SUNAdaptController_PID(ark_mem->sunctx); @@ -1115,6 +1117,7 @@ int arkSetAdaptivityFn(void *arkode_mem, ARKAdaptFn hfun, void *h_data) int retval; long int lenrw, leniw; ARKodeMem ark_mem; + SUNAdaptController C; if (arkode_mem==NULL) { arkProcessError(NULL, ARK_MEM_NULL, "ARKODE", "arkSetAdaptivityFn", MSG_ARK_NO_MEM); @@ -1140,7 +1143,7 @@ int arkSetAdaptivityFn(void *arkode_mem, ARKAdaptFn hfun, void *h_data) ark_mem->hadapt_mem->hcontroller = NULL; /* Create new SUNAdaptController object depending on NULL-ity of 'hfun' */ - SUNAdaptController C = NULL; + C = NULL; if (hfun == NULL) { C = SUNAdaptController_PID(ark_mem->sunctx); if (C == NULL) { From 47a7e88935c2ecbad944a9c1781ad6df7c5f0267 Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Thu, 19 Oct 2023 10:10:46 -0500 Subject: [PATCH 06/58] Moved 'pq' flag out of individual controllers and back into ARKodeHAdaptMem, so that it would be easier to deprecate the idea later on --- .../SUNAdaptController_Description.rst | 15 ++++--- .../SUNAdaptController_ExpGus.rst | 20 ++++------ .../SUNAdaptController_I.rst | 18 ++++----- .../SUNAdaptController_ImExGus.rst | 24 +++++------- .../SUNAdaptController_ImpGus.rst | 20 ++++------ .../SUNAdaptController_PI.rst | 20 ++++------ .../SUNAdaptController_PID.rst | 22 +++++------ .../sunadaptcontroller_expgus.h | 5 +-- .../sunadaptcontroller/sunadaptcontroller_i.h | 6 +-- .../sunadaptcontroller_imexgus.h | 5 +-- .../sunadaptcontroller_impgus.h | 5 +-- .../sunadaptcontroller_pi.h | 5 +-- .../sunadaptcontroller_pid.h | 7 ++-- include/sundials/sundials_adaptcontroller.h | 4 +- src/arkode/arkode_adapt.c | 3 ++ src/arkode/arkode_adapt_impl.h | 10 ++++- src/arkode/arkode_arkstep.c | 19 ++++++--- src/arkode/arkode_arkstep_io.c | 39 ++++++++++++------- src/arkode/arkode_erkstep.c | 15 +++++-- src/arkode/arkode_erkstep_io.c | 2 +- src/arkode/arkode_io.c | 16 +++++--- src/arkode/arkode_user_controller.c | 34 +++++----------- src/arkode/arkode_user_controller.h | 2 - .../fmod/fsunadaptcontroller_expgus_mod.c | 16 +++----- .../fmod/fsunadaptcontroller_expgus_mod.f90 | 28 +++++-------- .../expgus/sunadaptcontroller_expgus.c | 34 +++------------- .../i/fmod/fsunadaptcontroller_i_mod.c | 16 +++----- .../i/fmod/fsunadaptcontroller_i_mod.f90 | 26 +++++-------- .../i/sunadaptcontroller_i.c | 35 +++-------------- .../fmod/fsunadaptcontroller_imexgus_mod.c | 16 +++----- .../fmod/fsunadaptcontroller_imexgus_mod.f90 | 32 ++++++--------- .../imexgus/sunadaptcontroller_imexgus.c | 34 +++------------- .../fmod/fsunadaptcontroller_impgus_mod.c | 16 +++----- .../fmod/fsunadaptcontroller_impgus_mod.f90 | 28 +++++-------- .../impgus/sunadaptcontroller_impgus.c | 35 +++-------------- .../pi/fmod/fsunadaptcontroller_pi_mod.c | 16 +++----- .../pi/fmod/fsunadaptcontroller_pi_mod.f90 | 28 +++++-------- .../pi/sunadaptcontroller_pi.c | 34 +++------------- .../pid/fmod/fsunadaptcontroller_pid_mod.c | 16 +++----- .../pid/fmod/fsunadaptcontroller_pid_mod.f90 | 30 ++++++-------- .../pid/sunadaptcontroller_pid.c | 36 +++-------------- .../fmod/fsundials_adaptcontroller_mod.c | 6 +-- .../fmod/fsundials_adaptcontroller_mod.f90 | 10 ++--- src/sundials/sundials_adaptcontroller.c | 4 +- 44 files changed, 290 insertions(+), 522 deletions(-) diff --git a/doc/shared/sunadaptcontroller/SUNAdaptController_Description.rst b/doc/shared/sunadaptcontroller/SUNAdaptController_Description.rst index 3b45e35987..fc58f1f65b 100644 --- a/doc/shared/sunadaptcontroller/SUNAdaptController_Description.rst +++ b/doc/shared/sunadaptcontroller/SUNAdaptController_Description.rst @@ -67,7 +67,7 @@ function pointers to the various controller operations, and is defined as int (*reset)(SUNAdaptController C); int (*setdefaults)(SUNAdaptController C); int (*write)(SUNAdaptController C, FILE* fptr); - int (*setmethodorder)(SUNAdaptController C, int p, int q); + int (*setmethodorder)(SUNAdaptController C, int p); int (*adjustcontrollerorder)(SUNAdaptController C, int adj); int (*seterrorbias)(SUNAdaptController C, sunrealtype bias); int (*update)(SUNAdaptController C, sunrealtype h, sunrealtype dsm); @@ -310,14 +310,13 @@ routine, below. retval = SUNAdaptController_Write(C, stdout); -.. c:function:: int SUNAdaptController_SetMethodOrder(SUNAdaptController C, int p, int q) +.. c:function:: int SUNAdaptController_SetMethodOrder(SUNAdaptController C, int p) Called by the time integrator to inform the controller of the asymptotic - order of accuracy for the method and its embedding. + order of accuracy for the method. :param C: the :c:type:`SUNAdaptController` object. - :param p: the asymptotic order of accuracy for the time integration method. - :param q: the asymptotic order of accuracy for the time integration method embedding. + :param p: the asymptotic method order of accuracy to use. :return: error code indicating success failure (see :numref:`SUNAdaptController.Description.errorCodes`). @@ -468,6 +467,12 @@ SUNAdaptController functions return one of the following set of error codes: * ``SUNADAPTCONTROLLER_OPERATION_FAIL`` (-1004) -- catch-all for errors not in the above list. +.. note:: + The SUNDIALS time integrators do not rely on these specific return values (only + on whether the returned values are 0 (successful) or negative (failure). Thus, + user-defined implementations are not required to use these specific error codes, + so long as the zero/negative structure is followed. + C/C++ API Usage --------------- diff --git a/doc/shared/sunadaptcontroller/SUNAdaptController_ExpGus.rst b/doc/shared/sunadaptcontroller/SUNAdaptController_ExpGus.rst index 4703d51b14..18acb21267 100644 --- a/doc/shared/sunadaptcontroller/SUNAdaptController_ExpGus.rst +++ b/doc/shared/sunadaptcontroller/SUNAdaptController_ExpGus.rst @@ -46,7 +46,6 @@ and defines its *content* field as: sunrealtype ep; int p; int adj; - int pq; sunbooleantype firststep; }; @@ -59,14 +58,12 @@ These entries of the *content* field contain the following information: * ``ep`` - storage for the previous error estimate, :math:`\varepsilon_{n-1}`. -* ``p`` - asymptotic order to use in error control. +* ``p`` - asymptotic order to use in error control. This is provided by + the time integrator, corresponding to the order of accuracy for the time + integration method, the embedding, or the minimum of the two. * ``adj`` - order of accuracy adjustment to use within the controller [default ``-1``]. -* ``pq`` - flag indicating whether ``p`` corresponds to the order of accuracy - for the time integration method (``1``), the embedding (``0``), or the - minimum of the two (``-1``) [default ``0``]. - * ``firststep`` - flag indicating whether a step has successfully completed, in which case the formula above transitions from :math:`h_1` to :math:`h_n`. @@ -95,16 +92,15 @@ routines: SUNAdaptController C = SUNAdaptController_ExpGus(sunctx); -.. c:function:: int SUNAdaptController_SetParams_ExpGus(SUNAdaptController C, int pq, sunrealtype k1, sunrealtype k2) +.. c:function:: int SUNAdaptController_SetParams_ExpGus(SUNAdaptController C, sunrealtype k1, sunrealtype k2) - :param C: the SUNAdaptController_ExpGus object - :param pq: the integer parameter indicating how to interpret the method and embedding orders of accuracy - :param k1: parameter used within the controller time step estimate (only stored if non-negative) - :param k2: parameter used within the controller time step estimate (only stored if non-negative) + :param C: the SUNAdaptController_ExpGus object. + :param k1: parameter used within the controller time step estimate (only stored if non-negative). + :param k2: parameter used within the controller time step estimate (only stored if non-negative). :return: error code indication success or failure (see :numref:`SUNAdaptController.Description.errorCodes`). Usage: .. code-block:: c - retval = SUNAdaptController_SetParams_ExpGus(C, -1, 0.4, 0.25); + retval = SUNAdaptController_SetParams_ExpGus(C, 0.4, 0.25); diff --git a/doc/shared/sunadaptcontroller/SUNAdaptController_I.rst b/doc/shared/sunadaptcontroller/SUNAdaptController_I.rst index b84b32a7cc..e2b4ce0759 100644 --- a/doc/shared/sunadaptcontroller/SUNAdaptController_I.rst +++ b/doc/shared/sunadaptcontroller/SUNAdaptController_I.rst @@ -40,7 +40,6 @@ field as: sunrealtype bias; int p; int adj; - int pq; }; These entries of the *content* field contain the following information: @@ -50,14 +49,12 @@ These entries of the *content* field contain the following information: * ``bias`` - error bias factor, that converts from an input temporal error estimate via :math:`\varepsilon = \text{bias}*\text{dsm}`. -* ``p`` - asymptotic order to use in error control. +* ``p`` - asymptotic order to use in error control. This is provided by + the time integrator, corresponding to the order of accuracy for the time + integration method, the embedding, or the minimum of the two. * ``adj`` - order of accuracy adjustment to use within the controller [default ``-1``]. -* ``pq`` - flag indicating whether ``p`` corresponds to the order of accuracy - for the time integration method (``1``), the embedding (``0``), or the - minimum of the two (``-1``) [default ``0``]. - The header file to be included when using this module is ``sunadaptcontroller/sunadaptcontroller_i.h``. @@ -82,19 +79,18 @@ also provides the following additional user-callable routines: SUNAdaptController C = SUNAdaptController_I(sunctx); -.. c:function:: int SUNAdaptController_SetParams_I(SUNAdaptController C, int pq, sunrealtype k1) +.. c:function:: int SUNAdaptController_SetParams_I(SUNAdaptController C, sunrealtype k1) This user-callable function provides control over the relevant parameters above. This should be called *before* the time integrator is called to evolve the problem. - :param C: the SUNAdaptController_I object - :param pq: the integer parameter indicating how to interpret the method and embedding orders of accuracy - :param k1: parameter used within the controller time step estimate (only stored if non-negative) + :param C: the SUNAdaptController_I object. + :param k1: parameter used within the controller time step estimate (only stored if non-negative). :return: error code indication success or failure (see :numref:`SUNAdaptController.Description.errorCodes`). Usage: .. code-block:: c - retval = SUNAdaptController_SetParams_I(C, -1, 0.95); + retval = SUNAdaptController_SetParams_I(C, 0.95); diff --git a/doc/shared/sunadaptcontroller/SUNAdaptController_ImExGus.rst b/doc/shared/sunadaptcontroller/SUNAdaptController_ImExGus.rst index f656f6d9b3..cdf97ae1bd 100644 --- a/doc/shared/sunadaptcontroller/SUNAdaptController_ImExGus.rst +++ b/doc/shared/sunadaptcontroller/SUNAdaptController_ImExGus.rst @@ -67,7 +67,6 @@ class, and defines its *content* field as: sunrealtype hp; int p; int adj; - int pq; sunbooleantype firststep; }; @@ -84,14 +83,12 @@ These entries of the *content* field contain the following information: * ``hp`` - storage for the previous step size, :math:`h_{n-1}`. -* ``p`` - asymptotic order to use in error control. +* ``p`` - asymptotic order to use in error control. This is provided by + the time integrator, corresponding to the order of accuracy for the time + integration method, the embedding, or the minimum of the two. * ``adj`` - order of accuracy adjustment to use within the controller [default ``-1``]. -* ``pq`` - flag indicating whether ``p`` corresponds to the order of accuracy - for the time integration method (``1``), the embedding (``0``), or the - minimum of the two (``-1``) [default ``0``]. - * ``firststep`` - flag indicating whether a step has completed successfully, allowing the formulas above to transition between :math:`h_1` and :math:`h_n`. @@ -120,22 +117,21 @@ routines: SUNAdaptController C = SUNAdaptController_ImExGus(sunctx); -.. c:function:: int SUNAdaptController_SetParams_ImExGus(SUNAdaptController C, int pq, sunrealtype k1e, sunrealtype k2e, sunrealtype k1i, sunrealtype k2i) +.. c:function:: int SUNAdaptController_SetParams_ImExGus(SUNAdaptController C, sunrealtype k1e, sunrealtype k2e, sunrealtype k1i, sunrealtype k2i) This user-callable function provides control over the relevant parameters above. This should be called *before* the time integrator is called to evolve the problem. - :param C: the SUNAdaptController_ImExGus object - :param pq: the integer parameter indicating how to interpret the method and embedding orders of accuracy - :param k1e: parameter used within the controller time step estimate (only stored if non-negative) - :param k2e: parameter used within the controller time step estimate (only stored if non-negative) - :param k1i: parameter used within the controller time step estimate (only stored if non-negative) - :param k2i: parameter used within the controller time step estimate (only stored if non-negative) + :param C: the SUNAdaptController_ImExGus object. + :param k1e: parameter used within the controller time step estimate (only stored if non-negative). + :param k2e: parameter used within the controller time step estimate (only stored if non-negative). + :param k1i: parameter used within the controller time step estimate (only stored if non-negative). + :param k2i: parameter used within the controller time step estimate (only stored if non-negative). :return: error code indication success or failure (see :numref:`SUNAdaptController.Description.errorCodes`). Usage: .. code-block:: c - retval = SUNAdaptController_SetParams_ImExGus(C, -1, 0.4, 0.3, -1.0, 1.0); + retval = SUNAdaptController_SetParams_ImExGus(C, 0.4, 0.3, -1.0, 1.0); diff --git a/doc/shared/sunadaptcontroller/SUNAdaptController_ImpGus.rst b/doc/shared/sunadaptcontroller/SUNAdaptController_ImpGus.rst index 419ae0f658..7fd5c5d0f1 100644 --- a/doc/shared/sunadaptcontroller/SUNAdaptController_ImpGus.rst +++ b/doc/shared/sunadaptcontroller/SUNAdaptController_ImpGus.rst @@ -48,7 +48,6 @@ and defines its *content* field as: sunrealtype hp; int p; int adj; - int pq; sunbooleantype firststep; }; @@ -63,14 +62,12 @@ These entries of the *content* field contain the following information: * ``hp`` - storage for the previous step size, :math:`h_{n-1}`. -* ``p`` - asymptotic order to use in error control. +* ``p`` - asymptotic order to use in error control. This is provided by + the time integrator, corresponding to the order of accuracy for the time + integration method, the embedding, or the minimum of the two. * ``adj`` - order of accuracy adjustment to use within the controller [default ``-1``]. -* ``pq`` - flag indicating whether ``p`` corresponds to the order of accuracy - for the time integration method (``1``), the embedding (``0``), or the - minimum of the two (``-1``) [default ``0``]. - * ``firststep`` - flag indicating whether any time steps have completed successfully (and thus to transition from :math:`h_1` to :math:`h_n` in the formula above). @@ -99,20 +96,19 @@ also provides the following additional user-callable routines: SUNAdaptController C = SUNAdaptController_ImpGus(sunctx); -.. c:function:: int SUNAdaptController_SetParams_ImpGus(SUNAdaptController C, int pq, sunrealtype k1, sunrealtype k2) +.. c:function:: int SUNAdaptController_SetParams_ImpGus(SUNAdaptController C, sunrealtype k1, sunrealtype k2) This user-callable function provides control over the relevant parameters above. This should be called *before* the time integrator is called to evolve the problem. - :param C: the SUNAdaptController_ImpGus object - :param pq: the integer parameter indicating how to interpret the method and embedding orders of accuracy - :param k1: parameter used within the controller time step estimate (only stored if non-negative) - :param k2: parameter used within the controller time step estimate (only stored if non-negative) + :param C: the SUNAdaptController_ImpGus object. + :param k1: parameter used within the controller time step estimate (only stored if non-negative). + :param k2: parameter used within the controller time step estimate (only stored if non-negative). :return: error code indication success or failure (see :numref:`SUNAdaptController.Description.errorCodes`). Usage: .. code-block:: c - retval = SUNAdaptController_SetParams_ImpGus(C, -1, 1.0, 0.9); + retval = SUNAdaptController_SetParams_ImpGus(C, 1.0, 0.9); diff --git a/doc/shared/sunadaptcontroller/SUNAdaptController_PI.rst b/doc/shared/sunadaptcontroller/SUNAdaptController_PI.rst index 2ab7de72bf..773580ff91 100644 --- a/doc/shared/sunadaptcontroller/SUNAdaptController_PI.rst +++ b/doc/shared/sunadaptcontroller/SUNAdaptController_PI.rst @@ -43,7 +43,6 @@ field as: sunrealtype ep; int p; int adj; - int pq; }; These entries of the *content* field contain the following information: @@ -55,14 +54,12 @@ These entries of the *content* field contain the following information: * ``ep`` - storage for the previous error estimate, :math:`\varepsilon_{n-1}`. -* ``p`` - asymptotic order to use in error control. +* ``p`` - asymptotic order to use in error control. This is provided by + the time integrator, corresponding to the order of accuracy for the time + integration method, the embedding, or the minimum of the two. * ``adj`` - order of accuracy adjustment to use within the controller [default ``-1``]. -* ``pq`` - flag indicating whether ``p`` corresponds to the order of accuracy - for the time integration method (``1``), the embedding (``0``), or the - minimum of the two (``-1``) [default ``0``]. - The header file to be included when using this module is ``sunadaptcontroller/sunadaptcontroller_pi.h``. @@ -87,20 +84,19 @@ also provides the following additional user-callable routines: SUNAdaptController C = SUNAdaptController_PI(sunctx); -.. c:function:: int SUNAdaptController_SetParams_PI(SUNAdaptController C, int pq, sunrealtype k1, sunrealtype k2) +.. c:function:: int SUNAdaptController_SetParams_PI(SUNAdaptController C, sunrealtype k1, sunrealtype k2) This user-callable function provides control over the relevant parameters above. This should be called *before* the time integrator is called to evolve the problem. - :param C: the SUNAdaptController_PI object - :param pq: the integer parameter indicating how to interpret the method and embedding orders of accuracy - :param k1: parameter used within the controller time step estimate (only stored if non-negative) - :param k2: parameter used within the controller time step estimate (only stored if non-negative) + :param C: the SUNAdaptController_PI object. + :param k1: parameter used within the controller time step estimate (only stored if non-negative). + :param k2: parameter used within the controller time step estimate (only stored if non-negative). :return: error code indication success or failure (see :numref:`SUNAdaptController.Description.errorCodes`). Usage: .. code-block:: c - retval = SUNAdaptController_SetParams_PI(C, -1, 0.9, 0.3); + retval = SUNAdaptController_SetParams_PI(C, 0.9, 0.3); diff --git a/doc/shared/sunadaptcontroller/SUNAdaptController_PID.rst b/doc/shared/sunadaptcontroller/SUNAdaptController_PID.rst index a6696ffba1..961a1be9a4 100644 --- a/doc/shared/sunadaptcontroller/SUNAdaptController_PID.rst +++ b/doc/shared/sunadaptcontroller/SUNAdaptController_PID.rst @@ -47,7 +47,6 @@ field as: sunrealtype epp; int p; int adj; - int pq; }; These entries of the *content* field contain the following information: @@ -60,14 +59,12 @@ These entries of the *content* field contain the following information: * ``ep, epp`` - storage for the two previous error estimates, :math:`\varepsilon_{n-1}` and :math:`varepsilon_{n-2}`. -* ``p`` - asymptotic order to use in error control. +* ``p`` - asymptotic order to use in error control. This is provided by + the time integrator, corresponding to the order of accuracy for the time + integration method, the embedding, or the minimum of the two. * ``adj`` - order of accuracy adjustment to use within the controller [default ``-1``]. -* ``pq`` - flag indicating whether ``p`` corresponds to the order of accuracy - for the time integration method (``1``), the embedding (``0``), or the - minimum of the two (``-1``) [default ``0``]. - The header file to be included when using this module is ``sunadaptcontroller/sunadaptcontroller_pid.h``. @@ -93,21 +90,20 @@ also provides the following additional user-callable routines: SUNAdaptController C = SUNAdaptController_PID(sunctx); -.. c:function:: int SUNAdaptController_SetParams_PID(SUNAdaptController C, int pq, sunrealtype k1, sunrealtype k2, sunrealtype k3) +.. c:function:: int SUNAdaptController_SetParams_PID(SUNAdaptController C, sunrealtype k1, sunrealtype k2, sunrealtype k3) This user-callable function provides control over the relevant parameters above. This should be called *before* the time integrator is called to evolve the problem. - :param C: the SUNAdaptController_PID object - :param pq: the integer parameter indicating how to interpret the method and embedding orders of accuracy - :param k1: parameter used within the controller time step estimate (only stored if non-negative) - :param k2: parameter used within the controller time step estimate (only stored if non-negative) - :param k3: parameter used within the controller time step estimate (only stored if non-negative) + :param C: the SUNAdaptController_PID object. + :param k1: parameter used within the controller time step estimate (only stored if non-negative). + :param k2: parameter used within the controller time step estimate (only stored if non-negative). + :param k3: parameter used within the controller time step estimate (only stored if non-negative). :return: error code indication success or failure (see :numref:`SUNAdaptController.Description.errorCodes`). Usage: .. code-block:: c - retval = SUNAdaptController_SetParams_PID(C, -1, 0.6, 0.2, -1.0); + retval = SUNAdaptController_SetParams_PID(C, 0.6, 0.2, -1.0); diff --git a/include/sunadaptcontroller/sunadaptcontroller_expgus.h b/include/sunadaptcontroller/sunadaptcontroller_expgus.h index f86df2be71..324b9abf6a 100644 --- a/include/sunadaptcontroller/sunadaptcontroller_expgus.h +++ b/include/sunadaptcontroller/sunadaptcontroller_expgus.h @@ -35,7 +35,6 @@ struct _SUNAdaptControllerContent_ExpGus { sunrealtype ep; /* error from previous step */ int p; /* method/embedding order of accuracy */ int adj; /* order of accuracy adjustment to use for controller */ - int pq; /* p is order of embedding (0), method (1), or minimum (-1) */ sunbooleantype firststep; /* flag indicating first step */ }; @@ -48,7 +47,7 @@ typedef struct _SUNAdaptControllerContent_ExpGus *SUNAdaptControllerContent_ExpG SUNDIALS_EXPORT SUNAdaptController SUNAdaptController_ExpGus(SUNContext sunctx); SUNDIALS_EXPORT -int SUNAdaptController_SetParams_ExpGus(SUNAdaptController C, int pq, +int SUNAdaptController_SetParams_ExpGus(SUNAdaptController C, sunrealtype k1, sunrealtype k2); SUNDIALS_EXPORT SUNAdaptController_Type SUNAdaptController_GetType_ExpGus(SUNAdaptController C); @@ -62,7 +61,7 @@ int SUNAdaptController_SetDefaults_ExpGus(SUNAdaptController C); SUNDIALS_EXPORT int SUNAdaptController_Write_ExpGus(SUNAdaptController C, FILE* fptr); SUNDIALS_EXPORT -int SUNAdaptController_SetMethodOrder_ExpGus(SUNAdaptController C, int p, int q); +int SUNAdaptController_SetMethodOrder_ExpGus(SUNAdaptController C, int p); SUNDIALS_EXPORT int SUNAdaptController_AdjustControllerOrder_ExpGus(SUNAdaptController C, int adj); SUNDIALS_EXPORT diff --git a/include/sunadaptcontroller/sunadaptcontroller_i.h b/include/sunadaptcontroller/sunadaptcontroller_i.h index f8b34d7eea..30488a892a 100644 --- a/include/sunadaptcontroller/sunadaptcontroller_i.h +++ b/include/sunadaptcontroller/sunadaptcontroller_i.h @@ -33,7 +33,6 @@ struct _SUNAdaptControllerContent_I { sunrealtype bias; /* error bias factor */ int p; /* method/embedding order of accuracy */ int adj; /* order of accuracy adjustment to use for controller */ - int pq; /* p is order of embedding (0), method (1), or minimum (-1) */ }; typedef struct _SUNAdaptControllerContent_I *SUNAdaptControllerContent_I; @@ -45,8 +44,7 @@ typedef struct _SUNAdaptControllerContent_I *SUNAdaptControllerContent_I; SUNDIALS_EXPORT SUNAdaptController SUNAdaptController_I(SUNContext sunctx); SUNDIALS_EXPORT -int SUNAdaptController_SetParams_I(SUNAdaptController C, int pq, - sunrealtype k1); +int SUNAdaptController_SetParams_I(SUNAdaptController C, sunrealtype k1); SUNDIALS_EXPORT SUNAdaptController_Type SUNAdaptController_GetType_I(SUNAdaptController C); SUNDIALS_EXPORT @@ -57,7 +55,7 @@ int SUNAdaptController_SetDefaults_I(SUNAdaptController C); SUNDIALS_EXPORT int SUNAdaptController_Write_I(SUNAdaptController C, FILE* fptr); SUNDIALS_EXPORT -int SUNAdaptController_SetMethodOrder_I(SUNAdaptController C, int p, int q); +int SUNAdaptController_SetMethodOrder_I(SUNAdaptController C, int p); SUNDIALS_EXPORT int SUNAdaptController_AdjustControllerOrder_I(SUNAdaptController C, int adj); SUNDIALS_EXPORT diff --git a/include/sunadaptcontroller/sunadaptcontroller_imexgus.h b/include/sunadaptcontroller/sunadaptcontroller_imexgus.h index 1e4541f31c..26121b2b76 100644 --- a/include/sunadaptcontroller/sunadaptcontroller_imexgus.h +++ b/include/sunadaptcontroller/sunadaptcontroller_imexgus.h @@ -38,7 +38,6 @@ struct _SUNAdaptControllerContent_ImExGus { sunrealtype hp; /* previous step size */ int p; /* method/embedding order of accuracy */ int adj; /* order of accuracy adjustment to use for controller */ - int pq; /* p is order of embedding (0), method (1), or minimum (-1) */ sunbooleantype firststep; /* flag indicating first step */ }; @@ -51,7 +50,7 @@ typedef struct _SUNAdaptControllerContent_ImExGus *SUNAdaptControllerContent_ImE SUNDIALS_EXPORT SUNAdaptController SUNAdaptController_ImExGus(SUNContext sunctx); SUNDIALS_EXPORT -int SUNAdaptController_SetParams_ImExGus(SUNAdaptController C, int pq, +int SUNAdaptController_SetParams_ImExGus(SUNAdaptController C, sunrealtype k1e, sunrealtype k2e, sunrealtype k1i, sunrealtype k2i); SUNDIALS_EXPORT @@ -66,7 +65,7 @@ int SUNAdaptController_SetDefaults_ImExGus(SUNAdaptController C); SUNDIALS_EXPORT int SUNAdaptController_Write_ImExGus(SUNAdaptController C, FILE* fptr); SUNDIALS_EXPORT -int SUNAdaptController_SetMethodOrder_ImExGus(SUNAdaptController C, int p, int q); +int SUNAdaptController_SetMethodOrder_ImExGus(SUNAdaptController C, int p); SUNDIALS_EXPORT int SUNAdaptController_AdjustControllerOrder_ImExGus(SUNAdaptController C, int adj); SUNDIALS_EXPORT diff --git a/include/sunadaptcontroller/sunadaptcontroller_impgus.h b/include/sunadaptcontroller/sunadaptcontroller_impgus.h index 70397f90e5..dc065ceb9d 100644 --- a/include/sunadaptcontroller/sunadaptcontroller_impgus.h +++ b/include/sunadaptcontroller/sunadaptcontroller_impgus.h @@ -36,7 +36,6 @@ struct _SUNAdaptControllerContent_ImpGus { sunrealtype hp; /* previous step size */ int p; /* method/embedding order of accuracy */ int adj; /* order of accuracy adjustment to use for controller */ - int pq; /* p is order of embedding (0), method (1), or minimum (-1) */ sunbooleantype firststep; /* flag indicating first step */ }; @@ -49,7 +48,7 @@ typedef struct _SUNAdaptControllerContent_ImpGus *SUNAdaptControllerContent_ImpG SUNDIALS_EXPORT SUNAdaptController SUNAdaptController_ImpGus(SUNContext sunctx); SUNDIALS_EXPORT -int SUNAdaptController_SetParams_ImpGus(SUNAdaptController C, int pq, +int SUNAdaptController_SetParams_ImpGus(SUNAdaptController C, sunrealtype k1, sunrealtype k2); SUNDIALS_EXPORT SUNAdaptController_Type SUNAdaptController_GetType_ImpGus(SUNAdaptController C); @@ -63,7 +62,7 @@ int SUNAdaptController_SetDefaults_ImpGus(SUNAdaptController C); SUNDIALS_EXPORT int SUNAdaptController_Write_ImpGus(SUNAdaptController C, FILE* fptr); SUNDIALS_EXPORT -int SUNAdaptController_SetMethodOrder_ImpGus(SUNAdaptController C, int p, int q); +int SUNAdaptController_SetMethodOrder_ImpGus(SUNAdaptController C, int p); SUNDIALS_EXPORT int SUNAdaptController_AdjustControllerOrder_ImpGus(SUNAdaptController C, int adj); SUNDIALS_EXPORT diff --git a/include/sunadaptcontroller/sunadaptcontroller_pi.h b/include/sunadaptcontroller/sunadaptcontroller_pi.h index cdead7fe8c..344db4c766 100644 --- a/include/sunadaptcontroller/sunadaptcontroller_pi.h +++ b/include/sunadaptcontroller/sunadaptcontroller_pi.h @@ -35,7 +35,6 @@ struct _SUNAdaptControllerContent_PI { sunrealtype ep; /* error from previous step */ int p; /* method/embedding order of accuracy */ int adj; /* order of accuracy adjustment to use for controller */ - int pq; /* p is order of embedding (0), method (1), or minimum (-1) */ }; typedef struct _SUNAdaptControllerContent_PI *SUNAdaptControllerContent_PI; @@ -47,7 +46,7 @@ typedef struct _SUNAdaptControllerContent_PI *SUNAdaptControllerContent_PI; SUNDIALS_EXPORT SUNAdaptController SUNAdaptController_PI(SUNContext sunctx); SUNDIALS_EXPORT -int SUNAdaptController_SetParams_PI(SUNAdaptController C, int pq, +int SUNAdaptController_SetParams_PI(SUNAdaptController C, sunrealtype k1, sunrealtype k2); SUNDIALS_EXPORT SUNAdaptController_Type SUNAdaptController_GetType_PI(SUNAdaptController C); @@ -61,7 +60,7 @@ int SUNAdaptController_SetDefaults_PI(SUNAdaptController C); SUNDIALS_EXPORT int SUNAdaptController_Write_PI(SUNAdaptController C, FILE* fptr); SUNDIALS_EXPORT -int SUNAdaptController_SetMethodOrder_PI(SUNAdaptController C, int p, int q); +int SUNAdaptController_SetMethodOrder_PI(SUNAdaptController C, int p); SUNDIALS_EXPORT int SUNAdaptController_AdjustControllerOrder_PI(SUNAdaptController C, int adj); SUNDIALS_EXPORT diff --git a/include/sunadaptcontroller/sunadaptcontroller_pid.h b/include/sunadaptcontroller/sunadaptcontroller_pid.h index 5f24a5df81..5e8f0707c9 100644 --- a/include/sunadaptcontroller/sunadaptcontroller_pid.h +++ b/include/sunadaptcontroller/sunadaptcontroller_pid.h @@ -37,7 +37,6 @@ struct _SUNAdaptControllerContent_PID { sunrealtype epp; /* error from 2 steps ago */ int p; /* method/embedding order of accuracy */ int adj; /* order of accuracy adjustment to use for controller */ - int pq; /* p is order of embedding (0), method (1), or minimum (-1) */ }; typedef struct _SUNAdaptControllerContent_PID *SUNAdaptControllerContent_PID; @@ -49,8 +48,8 @@ typedef struct _SUNAdaptControllerContent_PID *SUNAdaptControllerContent_PID; SUNDIALS_EXPORT SUNAdaptController SUNAdaptController_PID(SUNContext sunctx); SUNDIALS_EXPORT -int SUNAdaptController_SetParams_PID(SUNAdaptController C, int pq, - sunrealtype k1, sunrealtype k2, sunrealtype k3); +int SUNAdaptController_SetParams_PID(SUNAdaptController C, sunrealtype k1, + sunrealtype k2, sunrealtype k3); SUNDIALS_EXPORT SUNAdaptController_Type SUNAdaptController_GetType_PID(SUNAdaptController C); SUNDIALS_EXPORT @@ -63,7 +62,7 @@ int SUNAdaptController_SetDefaults_PID(SUNAdaptController C); SUNDIALS_EXPORT int SUNAdaptController_Write_PID(SUNAdaptController C, FILE* fptr); SUNDIALS_EXPORT -int SUNAdaptController_SetMethodOrder_PID(SUNAdaptController C, int p, int q); +int SUNAdaptController_SetMethodOrder_PID(SUNAdaptController C, int p); SUNDIALS_EXPORT int SUNAdaptController_AdjustControllerOrder_PID(SUNAdaptController C, int adj); SUNDIALS_EXPORT diff --git a/include/sundials/sundials_adaptcontroller.h b/include/sundials/sundials_adaptcontroller.h index 95c4805dc1..6d94bdf191 100644 --- a/include/sundials/sundials_adaptcontroller.h +++ b/include/sundials/sundials_adaptcontroller.h @@ -87,7 +87,7 @@ struct _generic_SUNAdaptController_Ops int (*reset)(SUNAdaptController C); int (*setdefaults)(SUNAdaptController C); int (*write)(SUNAdaptController C, FILE* fptr); - int (*setmethodorder)(SUNAdaptController C, int p, int q); + int (*setmethodorder)(SUNAdaptController C, int p); int (*adjustcontrollerorder)(SUNAdaptController C, int adj); int (*seterrorbias)(SUNAdaptController C, sunrealtype bias); int (*update)(SUNAdaptController C, sunrealtype h, sunrealtype dsm); @@ -190,7 +190,7 @@ int SUNAdaptController_Write(SUNAdaptController C, FILE* fptr); /* Function to set the asymptotic order of accuracy for the method and its embedding. */ SUNDIALS_EXPORT -int SUNAdaptController_SetMethodOrder(SUNAdaptController C, int p, int q); +int SUNAdaptController_SetMethodOrder(SUNAdaptController C, int p); /* Function to adjust the order of accuracy used within the controller. */ SUNDIALS_EXPORT diff --git a/src/arkode/arkode_adapt.c b/src/arkode/arkode_adapt.c index dae26c5196..68dfd57c78 100644 --- a/src/arkode/arkode_adapt.c +++ b/src/arkode/arkode_adapt.c @@ -70,6 +70,9 @@ void arkPrintAdaptMem(ARKodeHAdaptMem hadapt_mem, FILE *outfile) fprintf(outfile, "ark_hadapt: ubound = %"RSYM"\n", hadapt_mem->ubound); fprintf(outfile, "ark_hadapt: nst_acc = %li\n", hadapt_mem->nst_acc); fprintf(outfile, "ark_hadapt: nst_exp = %li\n", hadapt_mem->nst_exp); + fprintf(outfile, "ark_hadapt: pq = %i\n", hadapt_mem->pq); + fprintf(outfile, "ark_hadapt: p = %i\n", hadapt_mem->p); + fprintf(outfile, "ark_hadapt: q = %i\n", hadapt_mem->q); if (hadapt_mem->expstab == arkExpStab) { fprintf(outfile, " ark_hadapt: Default explicit stability function\n"); } else { diff --git a/src/arkode/arkode_adapt_impl.h b/src/arkode/arkode_adapt_impl.h index fa24af3a00..2c26a957ce 100644 --- a/src/arkode/arkode_adapt_impl.h +++ b/src/arkode/arkode_adapt_impl.h @@ -51,6 +51,9 @@ extern "C" { 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, -1=min(method,embedding) + REMOVE AT SAME TIME AS ARKStepSetAdaptivityMethod */ /*=============================================================== @@ -77,9 +80,12 @@ typedef struct ARKodeHAdaptMemRec { realtype growth; /* maximum step growth safety factor */ realtype lbound; /* eta lower bound to leave h unchanged */ realtype ubound; /* eta upper bound to leave h unchanged */ + int p; /* embedding order */ + int q; /* method order */ + int pq; /* decision flag for controller order */ - SUNAdaptController hcontroller; /* temporal error controller */ - booleantype owncontroller; /* flag indicating hcontroller ownership */ + SUNAdaptController hcontroller; /* temporal error controller */ + booleantype owncontroller; /* flag indicating hcontroller ownership */ ARKExpStabFn expstab; /* step stability function */ void *estab_data; /* user pointer passed to expstab */ diff --git a/src/arkode/arkode_arkstep.c b/src/arkode/arkode_arkstep.c index 8ea0f5316e..fb0e6e8732 100644 --- a/src/arkode/arkode_arkstep.c +++ b/src/arkode/arkode_arkstep.c @@ -1085,7 +1085,7 @@ int arkStep_Init(void* arkode_mem, int init_type) { ARKodeMem ark_mem; ARKodeARKStepMem step_mem; - int j, retval; + int j, retval, controller_order; booleantype reset_efun; /* access ARKodeARKStepMem structure */ @@ -1134,13 +1134,20 @@ int arkStep_Init(void* arkode_mem, int init_type) /* Retrieve/store method and embedding orders now that tables are finalized */ if (step_mem->Bi != NULL) { - step_mem->q = step_mem->Bi->q; - step_mem->p = step_mem->Bi->p; + step_mem->q = ark_mem->hadapt_mem->q = step_mem->Bi->q; + step_mem->p = ark_mem->hadapt_mem->p = step_mem->Bi->p; } else { - step_mem->q = step_mem->Be->q; - step_mem->p = step_mem->Be->p; + step_mem->q = ark_mem->hadapt_mem->q = step_mem->Be->q; + step_mem->p = ark_mem->hadapt_mem->p = step_mem->Be->p; } - retval = SUNAdaptController_SetMethodOrder(ark_mem->hadapt_mem->hcontroller, step_mem->q, step_mem->p); + if (ark_mem->hadapt_mem->pq == 0) { + controller_order = step_mem->p; + } else if (ark_mem->hadapt_mem->pq == 1) { + controller_order = step_mem->q; + } else { + controller_order = SUNMIN(step_mem->p, step_mem->q); + } + retval = SUNAdaptController_SetMethodOrder(ark_mem->hadapt_mem->hcontroller, controller_order); if (retval != SUNADAPTCONTROLLER_SUCCESS) { arkProcessError(ark_mem, ARK_CONTROLLER_ERR, "ARKODE::ARKStep", "arkStep_Init", "SUNAdaptController_SetMethodOrder error"); diff --git a/src/arkode/arkode_arkstep_io.c b/src/arkode/arkode_arkstep_io.c index be92679382..8edcacd6a2 100644 --- a/src/arkode/arkode_arkstep_io.c +++ b/src/arkode/arkode_arkstep_io.c @@ -520,11 +520,12 @@ int ARKStepSetOptimalParams(void *arkode_mem) return(ARK_MEM_FAIL); } (void) SUNAdaptController_SetErrorBias(hadapt_mem->hcontroller, RCONST(1.2)); - (void) SUNAdaptController_SetParams_PI(hadapt_mem->hcontroller, SUNFALSE, - RCONST(0.8), RCONST(0.31)); - hadapt_mem->safety = RCONST(0.99); - hadapt_mem->growth = RCONST(25.0); - hadapt_mem->etamxf = RCONST(0.3); + (void) SUNAdaptController_SetParams_PI(hadapt_mem->hcontroller, RCONST(0.8), + RCONST(0.31)); + hadapt_mem->safety = RCONST(0.99); + hadapt_mem->growth = RCONST(25.0); + hadapt_mem->etamxf = RCONST(0.3); + hadapt_mem->pq = PQ; /* implicit */ } else if (step_mem->implicit && !step_mem->explicit) { @@ -542,6 +543,7 @@ int ARKStepSetOptimalParams(void *arkode_mem) hadapt_mem->etamxf = ETAMXF; hadapt_mem->small_nef = SMALL_NEF; hadapt_mem->etacf = ETACF; + hadapt_mem->pq = PQ; step_mem->nlscoef = RCONST(0.001); step_mem->maxcor = 5; step_mem->crdown = CRDOWN; @@ -563,6 +565,7 @@ int ARKStepSetOptimalParams(void *arkode_mem) hadapt_mem->etamxf = RCONST(0.45); hadapt_mem->small_nef = SMALL_NEF; hadapt_mem->etacf = ETACF; + hadapt_mem->pq = PQ; step_mem->nlscoef = RCONST(0.22); step_mem->crdown = RCONST(0.17); step_mem->rdiv = RCONST(2.3); @@ -578,13 +581,14 @@ int ARKStepSetOptimalParams(void *arkode_mem) return(ARK_MEM_FAIL); } (void) SUNAdaptController_SetErrorBias(hadapt_mem->hcontroller, RCONST(1.2)); - (void) SUNAdaptController_SetParams_PID(hadapt_mem->hcontroller, SUNFALSE, - RCONST(0.535), RCONST(0.209), RCONST(0.148)); + (void) SUNAdaptController_SetParams_PID(hadapt_mem->hcontroller, RCONST(0.535), + RCONST(0.209), RCONST(0.148)); hadapt_mem->safety = RCONST(0.988); hadapt_mem->growth = RCONST(31.5); hadapt_mem->etamxf = RCONST(0.33); hadapt_mem->small_nef = SMALL_NEF; hadapt_mem->etacf = ETACF; + hadapt_mem->pq = PQ; step_mem->nlscoef = RCONST(0.24); step_mem->crdown = RCONST(0.26); step_mem->rdiv = RCONST(2.3); @@ -600,13 +604,14 @@ int ARKStepSetOptimalParams(void *arkode_mem) return(ARK_MEM_FAIL); } (void) SUNAdaptController_SetErrorBias(hadapt_mem->hcontroller, RCONST(3.3)); - (void) SUNAdaptController_SetParams_PID(hadapt_mem->hcontroller, SUNFALSE, - RCONST(0.56), RCONST(0.338), RCONST(0.14)); + (void) SUNAdaptController_SetParams_PID(hadapt_mem->hcontroller, RCONST(0.56), + RCONST(0.338), RCONST(0.14)); hadapt_mem->safety = RCONST(0.937); hadapt_mem->growth = RCONST(22.0); hadapt_mem->etamxf = RCONST(0.44); hadapt_mem->small_nef = SMALL_NEF; hadapt_mem->etacf = ETACF; + hadapt_mem->pq = PQ; step_mem->nlscoef = RCONST(0.25); step_mem->crdown = RCONST(0.4); step_mem->rdiv = RCONST(2.3); @@ -631,6 +636,7 @@ int ARKStepSetOptimalParams(void *arkode_mem) hadapt_mem->etamxf = ETAMXF; hadapt_mem->small_nef = SMALL_NEF; hadapt_mem->etacf = ETACF; + hadapt_mem->pq = PQ; step_mem->nlscoef = RCONST(0.001); step_mem->maxcor = 5; step_mem->crdown = CRDOWN; @@ -647,13 +653,14 @@ int ARKStepSetOptimalParams(void *arkode_mem) return(ARK_MEM_FAIL); } (void) SUNAdaptController_SetErrorBias(hadapt_mem->hcontroller, RCONST(1.42)); - (void) SUNAdaptController_SetParams_PID(hadapt_mem->hcontroller, SUNFALSE, - RCONST(0.54), RCONST(0.36), RCONST(0.14)); + (void) SUNAdaptController_SetParams_PID(hadapt_mem->hcontroller, RCONST(0.54), + RCONST(0.36), RCONST(0.14)); hadapt_mem->safety = RCONST(0.965); hadapt_mem->growth = RCONST(28.7); hadapt_mem->etamxf = RCONST(0.46); hadapt_mem->small_nef = SMALL_NEF; hadapt_mem->etacf = ETACF; + hadapt_mem->pq = PQ; step_mem->nlscoef = RCONST(0.22); step_mem->crdown = RCONST(0.17); step_mem->rdiv = RCONST(2.3); @@ -669,13 +676,14 @@ int ARKStepSetOptimalParams(void *arkode_mem) return(ARK_MEM_FAIL); } (void) SUNAdaptController_SetErrorBias(hadapt_mem->hcontroller, RCONST(1.35)); - (void) SUNAdaptController_SetParams_PID(hadapt_mem->hcontroller, SUNFALSE, - RCONST(0.543), RCONST(0.297), RCONST(0.14)); + (void) SUNAdaptController_SetParams_PID(hadapt_mem->hcontroller, RCONST(0.543), + RCONST(0.297), RCONST(0.14)); hadapt_mem->safety = RCONST(0.97); hadapt_mem->growth = RCONST(25.0); hadapt_mem->etamxf = RCONST(0.47); hadapt_mem->small_nef = SMALL_NEF; hadapt_mem->etacf = ETACF; + hadapt_mem->pq = PQ; step_mem->nlscoef = RCONST(0.24); step_mem->crdown = RCONST(0.26); step_mem->rdiv = RCONST(2.3); @@ -691,13 +699,14 @@ int ARKStepSetOptimalParams(void *arkode_mem) return(ARK_MEM_FAIL); } (void) SUNAdaptController_SetErrorBias(hadapt_mem->hcontroller, RCONST(1.15)); - (void) SUNAdaptController_SetParams_PI(hadapt_mem->hcontroller, SUNFALSE, - RCONST(0.8), RCONST(0.35)); + (void) SUNAdaptController_SetParams_PI(hadapt_mem->hcontroller, RCONST(0.8), + RCONST(0.35)); hadapt_mem->safety = RCONST(0.993); hadapt_mem->growth = RCONST(28.5); hadapt_mem->etamxf = RCONST(0.3); hadapt_mem->small_nef = SMALL_NEF; hadapt_mem->etacf = ETACF; + hadapt_mem->pq = PQ; step_mem->nlscoef = RCONST(0.25); step_mem->crdown = RCONST(0.4); step_mem->rdiv = RCONST(2.3); diff --git a/src/arkode/arkode_erkstep.c b/src/arkode/arkode_erkstep.c index e49a4dc449..9c4b65cdc7 100644 --- a/src/arkode/arkode_erkstep.c +++ b/src/arkode/arkode_erkstep.c @@ -501,7 +501,7 @@ int erkStep_Init(void* arkode_mem, int init_type) { ARKodeMem ark_mem; ARKodeERKStepMem step_mem; - int retval, j; + int retval, j, controller_order; /* access ARKodeERKStepMem structure */ retval = erkStep_AccessStepMem(arkode_mem, "erkStep_Init", @@ -537,9 +537,16 @@ int erkStep_Init(void* arkode_mem, int init_type) } /* Retrieve/store method and embedding orders now that table is finalized */ - step_mem->q = step_mem->B->q; - step_mem->p = step_mem->B->p; - retval = SUNAdaptController_SetMethodOrder(ark_mem->hadapt_mem->hcontroller, step_mem->q, step_mem->p); + step_mem->q = ark_mem->hadapt_mem->q = step_mem->B->q; + step_mem->p = ark_mem->hadapt_mem->p = step_mem->B->p; + if (ark_mem->hadapt_mem->pq == 0) { + controller_order = step_mem->p; + } else if (ark_mem->hadapt_mem->pq == 1) { + controller_order = step_mem->q; + } else { + controller_order = SUNMIN(step_mem->p, step_mem->q); + } + retval = SUNAdaptController_SetMethodOrder(ark_mem->hadapt_mem->hcontroller, controller_order); if (retval != SUNADAPTCONTROLLER_SUCCESS) { arkProcessError(ark_mem, ARK_CONTROLLER_ERR, "ARKODE::ERKStep", "erkStep_Init", "SUNAdaptControllerSetMethodOrder error"); diff --git a/src/arkode/arkode_erkstep_io.c b/src/arkode/arkode_erkstep_io.c index 2b76209212..ed9a9ccf9b 100644 --- a/src/arkode/arkode_erkstep_io.c +++ b/src/arkode/arkode_erkstep_io.c @@ -323,7 +323,7 @@ int ERKStepSetDefaults(void* arkode_mem) ark_mem->hadapt_mem->safety = RCONST(0.99); /* step adaptivity safety factor */ ark_mem->hadapt_mem->growth = RCONST(25.0); /* step adaptivity growth factor */ (void) SUNAdaptController_SetErrorBias(ark_mem->hadapt_mem->hcontroller, RCONST(1.2)); - (void) SUNAdaptController_SetParams_PI(ark_mem->hadapt_mem->hcontroller, SUNFALSE, + (void) SUNAdaptController_SetParams_PI(ark_mem->hadapt_mem->hcontroller, RCONST(0.8), RCONST(0.31)); return(ARK_SUCCESS); } diff --git a/src/arkode/arkode_io.c b/src/arkode/arkode_io.c index 4e4bf541f6..363389be20 100644 --- a/src/arkode/arkode_io.c +++ b/src/arkode/arkode_io.c @@ -106,6 +106,9 @@ int arkSetDefaults(void *arkode_mem) ark_mem->hadapt_mem->ubound = HFIXED_UB; /* step adaptivity no-change upper bound */ ark_mem->hadapt_mem->expstab = arkExpStab; /* internal explicit stability fn */ ark_mem->hadapt_mem->estab_data = NULL; /* no explicit stability fn data */ + ark_mem->hadapt_mem->pq = PQ; /* embedding order */ + ark_mem->hadapt_mem->p = 0; /* no default embedding order */ + ark_mem->hadapt_mem->q = 0; /* no default method order */ /* Set default values for controller object */ retval = SUNAdaptController_SetDefaults(ark_mem->hadapt_mem->hcontroller); @@ -993,6 +996,7 @@ int arkSetAdaptivityMethod(void *arkode_mem, int imethod, int idefault, k2 = adapt_params[1]; k3 = adapt_params[2]; } + ark_mem->hadapt_mem->pq = pq; /* Create new SUNAdaptController object based on "imethod" input, optionally setting the specified controller parameters */ @@ -1005,7 +1009,7 @@ int arkSetAdaptivityMethod(void *arkode_mem, int imethod, int idefault, "SUNAdaptController_PID allocation failure"); return(ARK_MEM_FAIL); } - retval = SUNAdaptController_SetParams_PID(C, pq, k1, k2, k3); + retval = SUNAdaptController_SetParams_PID(C, k1, k2, k3); if (retval != SUNADAPTCONTROLLER_SUCCESS) { arkProcessError(ark_mem, ARK_CONTROLLER_ERR, "ARKODE", "arkSetAdaptivityMethod", "SUNAdaptController_SetParams_PID failure"); @@ -1019,7 +1023,7 @@ int arkSetAdaptivityMethod(void *arkode_mem, int imethod, int idefault, "SUNAdaptController_PI allocation failure"); return(ARK_MEM_FAIL); } - retval = SUNAdaptController_SetParams_PI(C, pq, k1, k2); + retval = SUNAdaptController_SetParams_PI(C, k1, k2); if (retval != SUNADAPTCONTROLLER_SUCCESS) { arkProcessError(ark_mem, ARK_CONTROLLER_ERR, "ARKODE", "arkSetAdaptivityMethod", "SUNAdaptController_SetParams_PI failure"); @@ -1033,7 +1037,7 @@ int arkSetAdaptivityMethod(void *arkode_mem, int imethod, int idefault, "SUNAdaptController_I allocation failure"); return(ARK_MEM_FAIL); } - retval = SUNAdaptController_SetParams_I(C, pq, k1); + retval = SUNAdaptController_SetParams_I(C, k1); if (retval != SUNADAPTCONTROLLER_SUCCESS) { arkProcessError(ark_mem, ARK_CONTROLLER_ERR, "ARKODE", "arkSetAdaptivityMethod", "SUNAdaptController_SetParams_I failure"); @@ -1047,7 +1051,7 @@ int arkSetAdaptivityMethod(void *arkode_mem, int imethod, int idefault, "SUNAdaptController_ExpGus allocation failure"); return(ARK_MEM_FAIL); } - retval = SUNAdaptController_SetParams_ExpGus(C, pq, k1, k2); + retval = SUNAdaptController_SetParams_ExpGus(C, k1, k2); if (retval != SUNADAPTCONTROLLER_SUCCESS) { arkProcessError(ark_mem, ARK_CONTROLLER_ERR, "ARKODE", "arkSetAdaptivityMethod", "SUNAdaptController_SetParams_ExpGus failure"); @@ -1061,7 +1065,7 @@ int arkSetAdaptivityMethod(void *arkode_mem, int imethod, int idefault, "SUNAdaptController_ImpGus allocation failure"); return(ARK_MEM_FAIL); } - retval = SUNAdaptController_SetParams_ImpGus(C, pq, k1, k2); + retval = SUNAdaptController_SetParams_ImpGus(C, k1, k2); if (retval != SUNADAPTCONTROLLER_SUCCESS) { arkProcessError(ark_mem, ARK_CONTROLLER_ERR, "ARKODE", "arkSetAdaptivityMethod", "SUNAdaptController_SetParams_ImpGus failure"); @@ -1075,7 +1079,7 @@ int arkSetAdaptivityMethod(void *arkode_mem, int imethod, int idefault, "SUNAdaptController_ImExGus allocation failure"); return(ARK_MEM_FAIL); } - retval = SUNAdaptController_SetParams_ImExGus(C, pq, k1, k2, k3, k3); + retval = SUNAdaptController_SetParams_ImExGus(C, k1, k2, k3, k3); if (retval != SUNADAPTCONTROLLER_SUCCESS) { arkProcessError(ark_mem, ARK_CONTROLLER_ERR, "ARKODE", "arkSetAdaptivityMethod", "SUNAdaptController_SetParams_ImExGus failure"); diff --git a/src/arkode/arkode_user_controller.c b/src/arkode/arkode_user_controller.c index 3bb44182cf..c24dd599b8 100644 --- a/src/arkode/arkode_user_controller.c +++ b/src/arkode/arkode_user_controller.c @@ -29,8 +29,6 @@ #define SC_HPP(C) ( SC_CONTENT(C)->hpp ) #define SC_EP(C) ( SC_CONTENT(C)->ep ) #define SC_EPP(C) ( SC_CONTENT(C)->epp ) -#define SC_P(C) ( SC_CONTENT(C)->p ) -#define SC_Q(C) ( SC_CONTENT(C)->q ) #define SC_ARKMEM(C) ( SC_CONTENT(C)->ark_mem ) #define SC_HADAPT(C) ( SC_CONTENT(C)->hadapt ) #define SC_DATA(C) ( SC_CONTENT(C)->hadapt_data ) @@ -59,13 +57,12 @@ SUNAdaptController ARKUserControl(SUNContext sunctx, void* arkode_mem, if (C == NULL) { return (NULL); } /* Attach operations */ - C->ops->gettype = SUNAdaptController_GetType_ARKUserControl; - C->ops->estimatestep = SUNAdaptController_EstimateStep_ARKUserControl; - C->ops->reset = SUNAdaptController_Reset_ARKUserControl; - C->ops->write = SUNAdaptController_Write_ARKUserControl; - C->ops->setmethodorder = SUNAdaptController_SetMethodOrder_ARKUserControl; - C->ops->update = SUNAdaptController_Update_ARKUserControl; - C->ops->space = SUNAdaptController_Space_ARKUserControl; + C->ops->gettype = SUNAdaptController_GetType_ARKUserControl; + C->ops->estimatestep = SUNAdaptController_EstimateStep_ARKUserControl; + C->ops->reset = SUNAdaptController_Reset_ARKUserControl; + C->ops->write = SUNAdaptController_Write_ARKUserControl; + C->ops->update = SUNAdaptController_Update_ARKUserControl; + C->ops->space = SUNAdaptController_Space_ARKUserControl; /* Create content */ content = NULL; @@ -110,8 +107,9 @@ int SUNAdaptController_EstimateStep_ARKUserControl(SUNAdaptController C, realtyp /* call user-provided function to compute new step */ sunrealtype ttmp = (dsm <= ONE) ? SC_ARKMEM(C)->tn + SC_ARKMEM(C)->h : SC_ARKMEM(C)->tn; int retval = SC_HADAPT(C)(SC_ARKMEM(C)->ycur, ttmp, h, SC_HP(C), - SC_HPP(C), dsm, SC_EP(C), SC_EPP(C), SC_Q(C), - SC_P(C), hnew, SC_DATA(C)); + SC_HPP(C), dsm, SC_EP(C), SC_EPP(C), + SC_ARKMEM(C)->hadapt_mem->q, SC_ARKMEM(C)->hadapt_mem->p, + hnew, SC_DATA(C)); if (retval != SUNADAPTCONTROLLER_SUCCESS) { return(SUNADAPTCONTROLLER_USER_FCN_FAIL); } return SUNADAPTCONTROLLER_SUCCESS; } @@ -139,24 +137,10 @@ int SUNAdaptController_Write_ARKUserControl(SUNAdaptController C, FILE *fptr) fprintf(fptr, " ep = %12g\n", SC_EP(C)); fprintf(fptr, " epp = %12g\n", SC_EPP(C)); #endif - fprintf(fptr, " p = %i\n", SC_P(C)); - fprintf(fptr, " q = %i\n", SC_Q(C)); fprintf(fptr, " hadapt_data = %p\n", SC_DATA(C)); return SUNADAPTCONTROLLER_SUCCESS; } -int SUNAdaptController_SetMethodOrder_ARKUserControl(SUNAdaptController C, int p, int q) -{ - /* check for legal input */ - if (p <= 0) { return SUNADAPTCONTROLLER_ILL_INPUT; } - if (q <= 0) { return SUNADAPTCONTROLLER_ILL_INPUT; } - - /* store value and return */ - SC_P(C) = p; - SC_Q(C) = q; - return SUNADAPTCONTROLLER_SUCCESS; -} - int SUNAdaptController_Update_ARKUserControl(SUNAdaptController C, realtype h, realtype dsm) { SC_HPP(C) = SC_HP(C); diff --git a/src/arkode/arkode_user_controller.h b/src/arkode/arkode_user_controller.h index 9a56bc1991..b348fdeb7b 100644 --- a/src/arkode/arkode_user_controller.h +++ b/src/arkode/arkode_user_controller.h @@ -62,8 +62,6 @@ int SUNAdaptController_Reset_ARKUserControl(SUNAdaptController C); SUNDIALS_EXPORT int SUNAdaptController_Write_ARKUserControl(SUNAdaptController C, FILE* fptr); SUNDIALS_EXPORT -int SUNAdaptController_SetMethodOrder_ARKUserControl(SUNAdaptController C, int p, int q); -SUNDIALS_EXPORT int SUNAdaptController_Update_ARKUserControl(SUNAdaptController C, realtype h, realtype dsm); SUNDIALS_EXPORT int SUNAdaptController_Space_ARKUserControl(SUNAdaptController C, long int *lenrw, diff --git a/src/sunadaptcontroller/expgus/fmod/fsunadaptcontroller_expgus_mod.c b/src/sunadaptcontroller/expgus/fmod/fsunadaptcontroller_expgus_mod.c index f250325302..ec975d5bc3 100644 --- a/src/sunadaptcontroller/expgus/fmod/fsunadaptcontroller_expgus_mod.c +++ b/src/sunadaptcontroller/expgus/fmod/fsunadaptcontroller_expgus_mod.c @@ -220,19 +220,17 @@ SWIGEXPORT SUNAdaptController _wrap_FSUNAdaptController_ExpGus(void *farg1) { } -SWIGEXPORT int _wrap_FSUNAdaptController_SetParams_ExpGus(SUNAdaptController farg1, int const *farg2, double const *farg3, double const *farg4) { +SWIGEXPORT int _wrap_FSUNAdaptController_SetParams_ExpGus(SUNAdaptController farg1, double const *farg2, double const *farg3) { int fresult ; SUNAdaptController arg1 = (SUNAdaptController) 0 ; - int arg2 ; + sunrealtype arg2 ; sunrealtype arg3 ; - sunrealtype arg4 ; int result; arg1 = (SUNAdaptController)(farg1); - arg2 = (int)(*farg2); + arg2 = (sunrealtype)(*farg2); arg3 = (sunrealtype)(*farg3); - arg4 = (sunrealtype)(*farg4); - result = (int)SUNAdaptController_SetParams_ExpGus(arg1,arg2,arg3,arg4); + result = (int)SUNAdaptController_SetParams_ExpGus(arg1,arg2,arg3); fresult = (int)(result); return fresult; } @@ -306,17 +304,15 @@ SWIGEXPORT int _wrap_FSUNAdaptController_Write_ExpGus(SUNAdaptController farg1, } -SWIGEXPORT int _wrap_FSUNAdaptController_SetMethodOrder_ExpGus(SUNAdaptController farg1, int const *farg2, int const *farg3) { +SWIGEXPORT int _wrap_FSUNAdaptController_SetMethodOrder_ExpGus(SUNAdaptController farg1, int const *farg2) { int fresult ; SUNAdaptController arg1 = (SUNAdaptController) 0 ; int arg2 ; - int arg3 ; int result; arg1 = (SUNAdaptController)(farg1); arg2 = (int)(*farg2); - arg3 = (int)(*farg3); - result = (int)SUNAdaptController_SetMethodOrder_ExpGus(arg1,arg2,arg3); + result = (int)SUNAdaptController_SetMethodOrder_ExpGus(arg1,arg2); fresult = (int)(result); return fresult; } diff --git a/src/sunadaptcontroller/expgus/fmod/fsunadaptcontroller_expgus_mod.f90 b/src/sunadaptcontroller/expgus/fmod/fsunadaptcontroller_expgus_mod.f90 index 83d23f1c51..2a2c5433af 100644 --- a/src/sunadaptcontroller/expgus/fmod/fsunadaptcontroller_expgus_mod.f90 +++ b/src/sunadaptcontroller/expgus/fmod/fsunadaptcontroller_expgus_mod.f90 @@ -50,14 +50,13 @@ function swigc_FSUNAdaptController_ExpGus(farg1) & type(C_PTR) :: fresult end function -function swigc_FSUNAdaptController_SetParams_ExpGus(farg1, farg2, farg3, farg4) & +function swigc_FSUNAdaptController_SetParams_ExpGus(farg1, farg2, farg3) & bind(C, name="_wrap_FSUNAdaptController_SetParams_ExpGus") & 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 -real(C_DOUBLE), intent(in) :: farg4 integer(C_INT) :: fresult end function @@ -105,13 +104,12 @@ function swigc_FSUNAdaptController_Write_ExpGus(farg1, farg2) & integer(C_INT) :: fresult end function -function swigc_FSUNAdaptController_SetMethodOrder_ExpGus(farg1, farg2, farg3) & +function swigc_FSUNAdaptController_SetMethodOrder_ExpGus(farg1, farg2) & bind(C, name="_wrap_FSUNAdaptController_SetMethodOrder_ExpGus") & 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 @@ -171,25 +169,22 @@ function FSUNAdaptController_ExpGus(sunctx) & call c_f_pointer(fresult, swig_result) end function -function FSUNAdaptController_SetParams_ExpGus(c, pq, k1, k2) & +function FSUNAdaptController_SetParams_ExpGus(c, k1, k2) & result(swig_result) use, intrinsic :: ISO_C_BINDING integer(C_INT) :: swig_result type(SUNAdaptController), target, intent(inout) :: c -integer(C_INT), intent(in) :: pq real(C_DOUBLE), intent(in) :: k1 real(C_DOUBLE), intent(in) :: k2 integer(C_INT) :: fresult type(C_PTR) :: farg1 -integer(C_INT) :: farg2 +real(C_DOUBLE) :: farg2 real(C_DOUBLE) :: farg3 -real(C_DOUBLE) :: farg4 farg1 = c_loc(c) -farg2 = pq -farg3 = k1 -farg4 = k2 -fresult = swigc_FSUNAdaptController_SetParams_ExpGus(farg1, farg2, farg3, farg4) +farg2 = k1 +farg3 = k2 +fresult = swigc_FSUNAdaptController_SetParams_ExpGus(farg1, farg2, farg3) swig_result = fresult end function @@ -270,22 +265,19 @@ function FSUNAdaptController_Write_ExpGus(c, fptr) & swig_result = fresult end function -function FSUNAdaptController_SetMethodOrder_ExpGus(c, p, q) & +function FSUNAdaptController_SetMethodOrder_ExpGus(c, p) & result(swig_result) use, intrinsic :: ISO_C_BINDING integer(C_INT) :: swig_result type(SUNAdaptController), target, intent(inout) :: c integer(C_INT), intent(in) :: p -integer(C_INT), intent(in) :: q integer(C_INT) :: fresult type(C_PTR) :: farg1 integer(C_INT) :: farg2 -integer(C_INT) :: farg3 farg1 = c_loc(c) farg2 = p -farg3 = q -fresult = swigc_FSUNAdaptController_SetMethodOrder_ExpGus(farg1, farg2, farg3) +fresult = swigc_FSUNAdaptController_SetMethodOrder_ExpGus(farg1, farg2) swig_result = fresult end function diff --git a/src/sunadaptcontroller/expgus/sunadaptcontroller_expgus.c b/src/sunadaptcontroller/expgus/sunadaptcontroller_expgus.c index c9617444c1..a51a272845 100644 --- a/src/sunadaptcontroller/expgus/sunadaptcontroller_expgus.c +++ b/src/sunadaptcontroller/expgus/sunadaptcontroller_expgus.c @@ -31,7 +31,6 @@ #define SACEXPGUS_BIAS(C) ( SACEXPGUS_CONTENT(C)->bias ) #define SACEXPGUS_EP(C) ( SACEXPGUS_CONTENT(C)->ep ) #define SACEXPGUS_P(C) ( SACEXPGUS_CONTENT(C)->p ) -#define SACEXPGUS_PQ(C) ( SACEXPGUS_CONTENT(C)->pq ) #define SACEXPGUS_ADJ(C) ( SACEXPGUS_CONTENT(C)->adj ) #define SACEXPGUS_FIRSTSTEP(C) ( SACEXPGUS_CONTENT(C)->firststep ) @@ -42,9 +41,7 @@ #define DEFAULT_K1 RCONST(0.367) #define DEFAULT_K2 RCONST(0.268) #define DEFAULT_BIAS RCONST(1.5) -#define DEFAULT_PQ 0 #define DEFAULT_ADJ -1 -/* #define DEFAULT_PQ -1 */ /* #define DEFAULT_ADJ 0 */ #define TINY RCONST(1.0e-10) @@ -105,11 +102,10 @@ SUNAdaptController SUNAdaptController_ExpGus(SUNContext sunctx) * Function to set ExpGus parameters */ -int SUNAdaptController_SetParams_ExpGus(SUNAdaptController C, int pq, +int SUNAdaptController_SetParams_ExpGus(SUNAdaptController C, sunrealtype k1, sunrealtype k2) { /* store legal inputs, and return with success */ - SACEXPGUS_PQ(C) = pq; if (k1 >= RCONST(0.0)) { SACEXPGUS_K1(C) = k1; } if (k2 >= RCONST(0.0)) { SACEXPGUS_K2(C) = k2; } return SUNADAPTCONTROLLER_SUCCESS; @@ -169,7 +165,6 @@ int SUNAdaptController_SetDefaults_ExpGus(SUNAdaptController C) SACEXPGUS_K1(C) = DEFAULT_K1; SACEXPGUS_K2(C) = DEFAULT_K2; SACEXPGUS_BIAS(C) = DEFAULT_BIAS; - SACEXPGUS_PQ(C) = DEFAULT_PQ; SACEXPGUS_ADJ(C) = DEFAULT_ADJ; return SUNADAPTCONTROLLER_SUCCESS; } @@ -188,35 +183,16 @@ int SUNAdaptController_Write_ExpGus(SUNAdaptController C, FILE *fptr) fprintf(fptr, " bias factor = %16g\n", SACEXPGUS_BIAS(C)); fprintf(fptr, " previous error = %16g\n", SACEXPGUS_EP(C)); #endif - if (SACEXPGUS_PQ(C) == 1) - { - fprintf(fptr, " p = %i (method order)\n", SACEXPGUS_P(C)); - } - else if (SACEXPGUS_PQ(C) == 0) - { - fprintf(fptr, " p = %i (embedding order)\n", SACEXPGUS_P(C)); - } - else - { - fprintf(fptr, " p = %i (minimum of method & embedding order)\n", SACEXPGUS_P(C)); - } + fprintf(fptr, " p = %i\n", SACEXPGUS_P(C)); fprintf(fptr, " adj = %i\n", SACEXPGUS_ADJ(C)); return SUNADAPTCONTROLLER_SUCCESS; } -int SUNAdaptController_SetMethodOrder_ExpGus(SUNAdaptController C, int p, int q) +int SUNAdaptController_SetMethodOrder_ExpGus(SUNAdaptController C, int p) { /* check for legal inputs */ - if ((p <= 0) || (q <= 0)) { return SUNADAPTCONTROLLER_ILL_INPUT; } - - /* store appropriate value based on "pq" */ - if (SACEXPGUS_PQ(C) == 1) { - SACEXPGUS_P(C) = p; - } else if (SACEXPGUS_PQ(C) == 0) { - SACEXPGUS_P(C) = q; - } else { - SACEXPGUS_P(C) = SUNMIN(p,q); - } + if (p <= 0) { return SUNADAPTCONTROLLER_ILL_INPUT; } + SACEXPGUS_P(C) = p; return SUNADAPTCONTROLLER_SUCCESS; } diff --git a/src/sunadaptcontroller/i/fmod/fsunadaptcontroller_i_mod.c b/src/sunadaptcontroller/i/fmod/fsunadaptcontroller_i_mod.c index c0f4dda981..58f4da9061 100644 --- a/src/sunadaptcontroller/i/fmod/fsunadaptcontroller_i_mod.c +++ b/src/sunadaptcontroller/i/fmod/fsunadaptcontroller_i_mod.c @@ -220,17 +220,15 @@ SWIGEXPORT SUNAdaptController _wrap_FSUNAdaptController_I(void *farg1) { } -SWIGEXPORT int _wrap_FSUNAdaptController_SetParams_I(SUNAdaptController farg1, int const *farg2, double const *farg3) { +SWIGEXPORT int _wrap_FSUNAdaptController_SetParams_I(SUNAdaptController farg1, double const *farg2) { int fresult ; SUNAdaptController arg1 = (SUNAdaptController) 0 ; - int arg2 ; - sunrealtype arg3 ; + sunrealtype arg2 ; int result; arg1 = (SUNAdaptController)(farg1); - arg2 = (int)(*farg2); - arg3 = (sunrealtype)(*farg3); - result = (int)SUNAdaptController_SetParams_I(arg1,arg2,arg3); + arg2 = (sunrealtype)(*farg2); + result = (int)SUNAdaptController_SetParams_I(arg1,arg2); fresult = (int)(result); return fresult; } @@ -292,17 +290,15 @@ SWIGEXPORT int _wrap_FSUNAdaptController_Write_I(SUNAdaptController farg1, void } -SWIGEXPORT int _wrap_FSUNAdaptController_SetMethodOrder_I(SUNAdaptController farg1, int const *farg2, int const *farg3) { +SWIGEXPORT int _wrap_FSUNAdaptController_SetMethodOrder_I(SUNAdaptController farg1, int const *farg2) { int fresult ; SUNAdaptController arg1 = (SUNAdaptController) 0 ; int arg2 ; - int arg3 ; int result; arg1 = (SUNAdaptController)(farg1); arg2 = (int)(*farg2); - arg3 = (int)(*farg3); - result = (int)SUNAdaptController_SetMethodOrder_I(arg1,arg2,arg3); + result = (int)SUNAdaptController_SetMethodOrder_I(arg1,arg2); fresult = (int)(result); return fresult; } diff --git a/src/sunadaptcontroller/i/fmod/fsunadaptcontroller_i_mod.f90 b/src/sunadaptcontroller/i/fmod/fsunadaptcontroller_i_mod.f90 index b9aaf00a7f..a16c3513ff 100644 --- a/src/sunadaptcontroller/i/fmod/fsunadaptcontroller_i_mod.f90 +++ b/src/sunadaptcontroller/i/fmod/fsunadaptcontroller_i_mod.f90 @@ -48,13 +48,12 @@ function swigc_FSUNAdaptController_I(farg1) & type(C_PTR) :: fresult end function -function swigc_FSUNAdaptController_SetParams_I(farg1, farg2, farg3) & +function swigc_FSUNAdaptController_SetParams_I(farg1, farg2) & bind(C, name="_wrap_FSUNAdaptController_SetParams_I") & result(fresult) use, intrinsic :: ISO_C_BINDING type(C_PTR), value :: farg1 -integer(C_INT), intent(in) :: farg2 -real(C_DOUBLE), intent(in) :: farg3 +real(C_DOUBLE), intent(in) :: farg2 integer(C_INT) :: fresult end function @@ -94,13 +93,12 @@ function swigc_FSUNAdaptController_Write_I(farg1, farg2) & integer(C_INT) :: fresult end function -function swigc_FSUNAdaptController_SetMethodOrder_I(farg1, farg2, farg3) & +function swigc_FSUNAdaptController_SetMethodOrder_I(farg1, farg2) & bind(C, name="_wrap_FSUNAdaptController_SetMethodOrder_I") & 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 @@ -150,22 +148,19 @@ function FSUNAdaptController_I(sunctx) & call c_f_pointer(fresult, swig_result) end function -function FSUNAdaptController_SetParams_I(c, pq, k1) & +function FSUNAdaptController_SetParams_I(c, k1) & result(swig_result) use, intrinsic :: ISO_C_BINDING integer(C_INT) :: swig_result type(SUNAdaptController), target, intent(inout) :: c -integer(C_INT), intent(in) :: pq real(C_DOUBLE), intent(in) :: k1 integer(C_INT) :: fresult type(C_PTR) :: farg1 -integer(C_INT) :: farg2 -real(C_DOUBLE) :: farg3 +real(C_DOUBLE) :: farg2 farg1 = c_loc(c) -farg2 = pq -farg3 = k1 -fresult = swigc_FSUNAdaptController_SetParams_I(farg1, farg2, farg3) +farg2 = k1 +fresult = swigc_FSUNAdaptController_SetParams_I(farg1, farg2) swig_result = fresult end function @@ -233,22 +228,19 @@ function FSUNAdaptController_Write_I(c, fptr) & swig_result = fresult end function -function FSUNAdaptController_SetMethodOrder_I(c, p, q) & +function FSUNAdaptController_SetMethodOrder_I(c, p) & result(swig_result) use, intrinsic :: ISO_C_BINDING integer(C_INT) :: swig_result type(SUNAdaptController), target, intent(inout) :: c integer(C_INT), intent(in) :: p -integer(C_INT), intent(in) :: q integer(C_INT) :: fresult type(C_PTR) :: farg1 integer(C_INT) :: farg2 -integer(C_INT) :: farg3 farg1 = c_loc(c) farg2 = p -farg3 = q -fresult = swigc_FSUNAdaptController_SetMethodOrder_I(farg1, farg2, farg3) +fresult = swigc_FSUNAdaptController_SetMethodOrder_I(farg1, farg2) swig_result = fresult end function diff --git a/src/sunadaptcontroller/i/sunadaptcontroller_i.c b/src/sunadaptcontroller/i/sunadaptcontroller_i.c index 5fd8067c4f..30ee6b0984 100644 --- a/src/sunadaptcontroller/i/sunadaptcontroller_i.c +++ b/src/sunadaptcontroller/i/sunadaptcontroller_i.c @@ -29,7 +29,6 @@ #define SACI_K1(C) ( SACI_CONTENT(C)->k1 ) #define SACI_BIAS(C) ( SACI_CONTENT(C)->bias ) #define SACI_P(C) ( SACI_CONTENT(C)->p ) -#define SACI_PQ(C) ( SACI_CONTENT(C)->pq ) #define SACI_ADJ(C) ( SACI_CONTENT(C)->adj ) /* ------------------ @@ -38,9 +37,7 @@ #define DEFAULT_K1 RCONST(1.0) #define DEFAULT_BIAS RCONST(1.5) -#define DEFAULT_PQ 0 #define DEFAULT_ADJ -1 -/* #define DEFAULT_PQ -1 */ /* #define DEFAULT_ADJ 0 */ #define TINY RCONST(1.0e-10) @@ -98,11 +95,9 @@ SUNAdaptController SUNAdaptController_I(SUNContext sunctx) * Function to set I parameters */ -int SUNAdaptController_SetParams_I(SUNAdaptController C, int pq, - sunrealtype k1) +int SUNAdaptController_SetParams_I(SUNAdaptController C, sunrealtype k1) { /* store legal inputs, and return with success */ - SACI_PQ(C) = pq; if (k1 >= RCONST(0.0)) { SACI_K1(C) = k1; } return SUNADAPTCONTROLLER_SUCCESS; } @@ -134,7 +129,6 @@ int SUNAdaptController_SetDefaults_I(SUNAdaptController C) { SACI_K1(C) = DEFAULT_K1; SACI_BIAS(C) = DEFAULT_BIAS; - SACI_PQ(C) = DEFAULT_PQ; SACI_ADJ(C) = DEFAULT_ADJ; return SUNADAPTCONTROLLER_SUCCESS; } @@ -149,35 +143,16 @@ int SUNAdaptController_Write_I(SUNAdaptController C, FILE *fptr) fprintf(fptr, " k1 = %16g\n", SACI_K1(C)); fprintf(fptr, " bias factor = %16g\n", SACI_BIAS(C)); #endif - if (SACI_PQ(C) == 1) - { - fprintf(fptr, " p = %i (method order)\n", SACI_P(C)); - } - else if (SACI_PQ(C) == 0) - { - fprintf(fptr, " p = %i (embedding order)\n", SACI_P(C)); - } - else - { - fprintf(fptr, " p = %i (minimum of method & embedding order)\n", SACI_P(C)); - } + fprintf(fptr, " p = %i\n", SACI_P(C)); fprintf(fptr, " adj = %i\n", SACI_ADJ(C)); return SUNADAPTCONTROLLER_SUCCESS; } -int SUNAdaptController_SetMethodOrder_I(SUNAdaptController C, int p, int q) +int SUNAdaptController_SetMethodOrder_I(SUNAdaptController C, int p) { /* check for legal inputs */ - if ((p <= 0) || (q <= 0)) { return SUNADAPTCONTROLLER_ILL_INPUT; } - - /* store appropriate value based on "pq" */ - if (SACI_PQ(C) == 1) { - SACI_P(C) = p; - } else if (SACI_PQ(C) == 0) { - SACI_P(C) = q; - } else { - SACI_P(C) = SUNMIN(p,q); - } + if (p <= 0) { return SUNADAPTCONTROLLER_ILL_INPUT; } + SACI_P(C) = p; return SUNADAPTCONTROLLER_SUCCESS; } diff --git a/src/sunadaptcontroller/imexgus/fmod/fsunadaptcontroller_imexgus_mod.c b/src/sunadaptcontroller/imexgus/fmod/fsunadaptcontroller_imexgus_mod.c index 3344c1d495..4b979b6575 100644 --- a/src/sunadaptcontroller/imexgus/fmod/fsunadaptcontroller_imexgus_mod.c +++ b/src/sunadaptcontroller/imexgus/fmod/fsunadaptcontroller_imexgus_mod.c @@ -220,23 +220,21 @@ SWIGEXPORT SUNAdaptController _wrap_FSUNAdaptController_ImExGus(void *farg1) { } -SWIGEXPORT int _wrap_FSUNAdaptController_SetParams_ImExGus(SUNAdaptController farg1, int const *farg2, double const *farg3, double const *farg4, double const *farg5, double const *farg6) { +SWIGEXPORT int _wrap_FSUNAdaptController_SetParams_ImExGus(SUNAdaptController farg1, double const *farg2, double const *farg3, double const *farg4, double const *farg5) { int fresult ; SUNAdaptController arg1 = (SUNAdaptController) 0 ; - int arg2 ; + sunrealtype arg2 ; sunrealtype arg3 ; sunrealtype arg4 ; sunrealtype arg5 ; - sunrealtype arg6 ; int result; arg1 = (SUNAdaptController)(farg1); - arg2 = (int)(*farg2); + arg2 = (sunrealtype)(*farg2); arg3 = (sunrealtype)(*farg3); arg4 = (sunrealtype)(*farg4); arg5 = (sunrealtype)(*farg5); - arg6 = (sunrealtype)(*farg6); - result = (int)SUNAdaptController_SetParams_ImExGus(arg1,arg2,arg3,arg4,arg5,arg6); + result = (int)SUNAdaptController_SetParams_ImExGus(arg1,arg2,arg3,arg4,arg5); fresult = (int)(result); return fresult; } @@ -310,17 +308,15 @@ SWIGEXPORT int _wrap_FSUNAdaptController_Write_ImExGus(SUNAdaptController farg1, } -SWIGEXPORT int _wrap_FSUNAdaptController_SetMethodOrder_ImExGus(SUNAdaptController farg1, int const *farg2, int const *farg3) { +SWIGEXPORT int _wrap_FSUNAdaptController_SetMethodOrder_ImExGus(SUNAdaptController farg1, int const *farg2) { int fresult ; SUNAdaptController arg1 = (SUNAdaptController) 0 ; int arg2 ; - int arg3 ; int result; arg1 = (SUNAdaptController)(farg1); arg2 = (int)(*farg2); - arg3 = (int)(*farg3); - result = (int)SUNAdaptController_SetMethodOrder_ImExGus(arg1,arg2,arg3); + result = (int)SUNAdaptController_SetMethodOrder_ImExGus(arg1,arg2); fresult = (int)(result); return fresult; } diff --git a/src/sunadaptcontroller/imexgus/fmod/fsunadaptcontroller_imexgus_mod.f90 b/src/sunadaptcontroller/imexgus/fmod/fsunadaptcontroller_imexgus_mod.f90 index 0032148fd6..a8c4b63280 100644 --- a/src/sunadaptcontroller/imexgus/fmod/fsunadaptcontroller_imexgus_mod.f90 +++ b/src/sunadaptcontroller/imexgus/fmod/fsunadaptcontroller_imexgus_mod.f90 @@ -50,16 +50,15 @@ function swigc_FSUNAdaptController_ImExGus(farg1) & type(C_PTR) :: fresult end function -function swigc_FSUNAdaptController_SetParams_ImExGus(farg1, farg2, farg3, farg4, farg5, farg6) & +function swigc_FSUNAdaptController_SetParams_ImExGus(farg1, farg2, farg3, farg4, farg5) & bind(C, name="_wrap_FSUNAdaptController_SetParams_ImExGus") & 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 real(C_DOUBLE), intent(in) :: farg4 real(C_DOUBLE), intent(in) :: farg5 -real(C_DOUBLE), intent(in) :: farg6 integer(C_INT) :: fresult end function @@ -107,13 +106,12 @@ function swigc_FSUNAdaptController_Write_ImExGus(farg1, farg2) & integer(C_INT) :: fresult end function -function swigc_FSUNAdaptController_SetMethodOrder_ImExGus(farg1, farg2, farg3) & +function swigc_FSUNAdaptController_SetMethodOrder_ImExGus(farg1, farg2) & bind(C, name="_wrap_FSUNAdaptController_SetMethodOrder_ImExGus") & 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 @@ -173,31 +171,28 @@ function FSUNAdaptController_ImExGus(sunctx) & call c_f_pointer(fresult, swig_result) end function -function FSUNAdaptController_SetParams_ImExGus(c, pq, k1e, k2e, k1i, k2i) & +function FSUNAdaptController_SetParams_ImExGus(c, k1e, k2e, k1i, k2i) & result(swig_result) use, intrinsic :: ISO_C_BINDING integer(C_INT) :: swig_result type(SUNAdaptController), target, intent(inout) :: c -integer(C_INT), intent(in) :: pq real(C_DOUBLE), intent(in) :: k1e real(C_DOUBLE), intent(in) :: k2e real(C_DOUBLE), intent(in) :: k1i real(C_DOUBLE), intent(in) :: k2i integer(C_INT) :: fresult type(C_PTR) :: farg1 -integer(C_INT) :: farg2 +real(C_DOUBLE) :: farg2 real(C_DOUBLE) :: farg3 real(C_DOUBLE) :: farg4 real(C_DOUBLE) :: farg5 -real(C_DOUBLE) :: farg6 farg1 = c_loc(c) -farg2 = pq -farg3 = k1e -farg4 = k2e -farg5 = k1i -farg6 = k2i -fresult = swigc_FSUNAdaptController_SetParams_ImExGus(farg1, farg2, farg3, farg4, farg5, farg6) +farg2 = k1e +farg3 = k2e +farg4 = k1i +farg5 = k2i +fresult = swigc_FSUNAdaptController_SetParams_ImExGus(farg1, farg2, farg3, farg4, farg5) swig_result = fresult end function @@ -278,22 +273,19 @@ function FSUNAdaptController_Write_ImExGus(c, fptr) & swig_result = fresult end function -function FSUNAdaptController_SetMethodOrder_ImExGus(c, p, q) & +function FSUNAdaptController_SetMethodOrder_ImExGus(c, p) & result(swig_result) use, intrinsic :: ISO_C_BINDING integer(C_INT) :: swig_result type(SUNAdaptController), target, intent(inout) :: c integer(C_INT), intent(in) :: p -integer(C_INT), intent(in) :: q integer(C_INT) :: fresult type(C_PTR) :: farg1 integer(C_INT) :: farg2 -integer(C_INT) :: farg3 farg1 = c_loc(c) farg2 = p -farg3 = q -fresult = swigc_FSUNAdaptController_SetMethodOrder_ImExGus(farg1, farg2, farg3) +fresult = swigc_FSUNAdaptController_SetMethodOrder_ImExGus(farg1, farg2) swig_result = fresult end function diff --git a/src/sunadaptcontroller/imexgus/sunadaptcontroller_imexgus.c b/src/sunadaptcontroller/imexgus/sunadaptcontroller_imexgus.c index 7a1ef93007..e67ceaa994 100644 --- a/src/sunadaptcontroller/imexgus/sunadaptcontroller_imexgus.c +++ b/src/sunadaptcontroller/imexgus/sunadaptcontroller_imexgus.c @@ -34,7 +34,6 @@ #define SACIMEXGUS_EP(C) ( SACIMEXGUS_CONTENT(C)->ep ) #define SACIMEXGUS_HP(C) ( SACIMEXGUS_CONTENT(C)->hp ) #define SACIMEXGUS_P(C) ( SACIMEXGUS_CONTENT(C)->p ) -#define SACIMEXGUS_PQ(C) ( SACIMEXGUS_CONTENT(C)->pq ) #define SACIMEXGUS_ADJ(C) ( SACIMEXGUS_CONTENT(C)->adj ) #define SACIMEXGUS_FIRSTSTEP(C) ( SACIMEXGUS_CONTENT(C)->firststep ) @@ -47,9 +46,7 @@ #define DEFAULT_K1I RCONST(0.95) #define DEFAULT_K2I RCONST(0.95) #define DEFAULT_BIAS RCONST(1.5) -#define DEFAULT_PQ 0 #define DEFAULT_ADJ -1 -/* #define DEFAULT_PQ -1 */ /* #define DEFAULT_ADJ 0 */ #define TINY RCONST(1.0e-10) @@ -110,12 +107,11 @@ SUNAdaptController SUNAdaptController_ImExGus(SUNContext sunctx) * Function to set ImExGus parameters */ -int SUNAdaptController_SetParams_ImExGus(SUNAdaptController C, int pq, +int SUNAdaptController_SetParams_ImExGus(SUNAdaptController C, sunrealtype k1e, sunrealtype k2e, sunrealtype k1i, sunrealtype k2i) { /* store legal inputs, and return with success */ - SACIMEXGUS_PQ(C) = pq; if (k1e >= RCONST(0.0)) { SACIMEXGUS_K1E(C) = k1e; } if (k2e >= RCONST(0.0)) { SACIMEXGUS_K2E(C) = k2e; } if (k1i >= RCONST(0.0)) { SACIMEXGUS_K1I(C) = k1i; } @@ -182,7 +178,6 @@ int SUNAdaptController_SetDefaults_ImExGus(SUNAdaptController C) SACIMEXGUS_K1I(C) = DEFAULT_K1I; SACIMEXGUS_K2I(C) = DEFAULT_K2I; SACIMEXGUS_BIAS(C) = DEFAULT_BIAS; - SACIMEXGUS_PQ(C) = DEFAULT_PQ; SACIMEXGUS_ADJ(C) = DEFAULT_ADJ; return SUNADAPTCONTROLLER_SUCCESS; } @@ -207,35 +202,16 @@ int SUNAdaptController_Write_ImExGus(SUNAdaptController C, FILE *fptr) fprintf(fptr, " previous error = %16g\n", SACIMEXGUS_EP(C)); fprintf(fptr, " previous step = %16g\n", SACIMEXGUS_HP(C)); #endif - if (SACIMEXGUS_PQ(C) == 1) - { - fprintf(fptr, " p = %i (method order)\n", SACIMEXGUS_P(C)); - } - else if (SACIMEXGUS_PQ(C) == 0) - { - fprintf(fptr, " p = %i (embedding order)\n", SACIMEXGUS_P(C)); - } - else - { - fprintf(fptr, " p = %i (minimum of method & embedding order)\n", SACIMEXGUS_P(C)); - } + fprintf(fptr, " p = %i\n", SACIMEXGUS_P(C)); fprintf(fptr, " adj = %i\n", SACIMEXGUS_ADJ(C)); return SUNADAPTCONTROLLER_SUCCESS; } -int SUNAdaptController_SetMethodOrder_ImExGus(SUNAdaptController C, int p, int q) +int SUNAdaptController_SetMethodOrder_ImExGus(SUNAdaptController C, int p) { /* check for legal inputs */ - if ((p <= 0) || (q <= 0)) { return SUNADAPTCONTROLLER_ILL_INPUT; } - - /* store appropriate value based on "pq" */ - if (SACIMEXGUS_PQ(C) == 1) { - SACIMEXGUS_P(C) = p; - } else if (SACIMEXGUS_PQ(C) == 0) { - SACIMEXGUS_P(C) = q; - } else { - SACIMEXGUS_P(C) = SUNMIN(p,q); - } + if (p <= 0) { return SUNADAPTCONTROLLER_ILL_INPUT; } + SACIMEXGUS_P(C) = p; return SUNADAPTCONTROLLER_SUCCESS; } diff --git a/src/sunadaptcontroller/impgus/fmod/fsunadaptcontroller_impgus_mod.c b/src/sunadaptcontroller/impgus/fmod/fsunadaptcontroller_impgus_mod.c index 0b9d713e81..0166d77a00 100644 --- a/src/sunadaptcontroller/impgus/fmod/fsunadaptcontroller_impgus_mod.c +++ b/src/sunadaptcontroller/impgus/fmod/fsunadaptcontroller_impgus_mod.c @@ -220,19 +220,17 @@ SWIGEXPORT SUNAdaptController _wrap_FSUNAdaptController_ImpGus(void *farg1) { } -SWIGEXPORT int _wrap_FSUNAdaptController_SetParams_ImpGus(SUNAdaptController farg1, int const *farg2, double const *farg3, double const *farg4) { +SWIGEXPORT int _wrap_FSUNAdaptController_SetParams_ImpGus(SUNAdaptController farg1, double const *farg2, double const *farg3) { int fresult ; SUNAdaptController arg1 = (SUNAdaptController) 0 ; - int arg2 ; + sunrealtype arg2 ; sunrealtype arg3 ; - sunrealtype arg4 ; int result; arg1 = (SUNAdaptController)(farg1); - arg2 = (int)(*farg2); + arg2 = (sunrealtype)(*farg2); arg3 = (sunrealtype)(*farg3); - arg4 = (sunrealtype)(*farg4); - result = (int)SUNAdaptController_SetParams_ImpGus(arg1,arg2,arg3,arg4); + result = (int)SUNAdaptController_SetParams_ImpGus(arg1,arg2,arg3); fresult = (int)(result); return fresult; } @@ -306,17 +304,15 @@ SWIGEXPORT int _wrap_FSUNAdaptController_Write_ImpGus(SUNAdaptController farg1, } -SWIGEXPORT int _wrap_FSUNAdaptController_SetMethodOrder_ImpGus(SUNAdaptController farg1, int const *farg2, int const *farg3) { +SWIGEXPORT int _wrap_FSUNAdaptController_SetMethodOrder_ImpGus(SUNAdaptController farg1, int const *farg2) { int fresult ; SUNAdaptController arg1 = (SUNAdaptController) 0 ; int arg2 ; - int arg3 ; int result; arg1 = (SUNAdaptController)(farg1); arg2 = (int)(*farg2); - arg3 = (int)(*farg3); - result = (int)SUNAdaptController_SetMethodOrder_ImpGus(arg1,arg2,arg3); + result = (int)SUNAdaptController_SetMethodOrder_ImpGus(arg1,arg2); fresult = (int)(result); return fresult; } diff --git a/src/sunadaptcontroller/impgus/fmod/fsunadaptcontroller_impgus_mod.f90 b/src/sunadaptcontroller/impgus/fmod/fsunadaptcontroller_impgus_mod.f90 index 508886a19b..3123b96a0b 100644 --- a/src/sunadaptcontroller/impgus/fmod/fsunadaptcontroller_impgus_mod.f90 +++ b/src/sunadaptcontroller/impgus/fmod/fsunadaptcontroller_impgus_mod.f90 @@ -50,14 +50,13 @@ function swigc_FSUNAdaptController_ImpGus(farg1) & type(C_PTR) :: fresult end function -function swigc_FSUNAdaptController_SetParams_ImpGus(farg1, farg2, farg3, farg4) & +function swigc_FSUNAdaptController_SetParams_ImpGus(farg1, farg2, farg3) & bind(C, name="_wrap_FSUNAdaptController_SetParams_ImpGus") & 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 -real(C_DOUBLE), intent(in) :: farg4 integer(C_INT) :: fresult end function @@ -105,13 +104,12 @@ function swigc_FSUNAdaptController_Write_ImpGus(farg1, farg2) & integer(C_INT) :: fresult end function -function swigc_FSUNAdaptController_SetMethodOrder_ImpGus(farg1, farg2, farg3) & +function swigc_FSUNAdaptController_SetMethodOrder_ImpGus(farg1, farg2) & bind(C, name="_wrap_FSUNAdaptController_SetMethodOrder_ImpGus") & 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 @@ -171,25 +169,22 @@ function FSUNAdaptController_ImpGus(sunctx) & call c_f_pointer(fresult, swig_result) end function -function FSUNAdaptController_SetParams_ImpGus(c, pq, k1, k2) & +function FSUNAdaptController_SetParams_ImpGus(c, k1, k2) & result(swig_result) use, intrinsic :: ISO_C_BINDING integer(C_INT) :: swig_result type(SUNAdaptController), target, intent(inout) :: c -integer(C_INT), intent(in) :: pq real(C_DOUBLE), intent(in) :: k1 real(C_DOUBLE), intent(in) :: k2 integer(C_INT) :: fresult type(C_PTR) :: farg1 -integer(C_INT) :: farg2 +real(C_DOUBLE) :: farg2 real(C_DOUBLE) :: farg3 -real(C_DOUBLE) :: farg4 farg1 = c_loc(c) -farg2 = pq -farg3 = k1 -farg4 = k2 -fresult = swigc_FSUNAdaptController_SetParams_ImpGus(farg1, farg2, farg3, farg4) +farg2 = k1 +farg3 = k2 +fresult = swigc_FSUNAdaptController_SetParams_ImpGus(farg1, farg2, farg3) swig_result = fresult end function @@ -270,22 +265,19 @@ function FSUNAdaptController_Write_ImpGus(c, fptr) & swig_result = fresult end function -function FSUNAdaptController_SetMethodOrder_ImpGus(c, p, q) & +function FSUNAdaptController_SetMethodOrder_ImpGus(c, p) & result(swig_result) use, intrinsic :: ISO_C_BINDING integer(C_INT) :: swig_result type(SUNAdaptController), target, intent(inout) :: c integer(C_INT), intent(in) :: p -integer(C_INT), intent(in) :: q integer(C_INT) :: fresult type(C_PTR) :: farg1 integer(C_INT) :: farg2 -integer(C_INT) :: farg3 farg1 = c_loc(c) farg2 = p -farg3 = q -fresult = swigc_FSUNAdaptController_SetMethodOrder_ImpGus(farg1, farg2, farg3) +fresult = swigc_FSUNAdaptController_SetMethodOrder_ImpGus(farg1, farg2) swig_result = fresult end function diff --git a/src/sunadaptcontroller/impgus/sunadaptcontroller_impgus.c b/src/sunadaptcontroller/impgus/sunadaptcontroller_impgus.c index 06990894ef..bf4138eaad 100644 --- a/src/sunadaptcontroller/impgus/sunadaptcontroller_impgus.c +++ b/src/sunadaptcontroller/impgus/sunadaptcontroller_impgus.c @@ -32,7 +32,6 @@ #define SACIMPGUS_EP(C) ( SACIMPGUS_CONTENT(C)->ep ) #define SACIMPGUS_HP(C) ( SACIMPGUS_CONTENT(C)->hp ) #define SACIMPGUS_P(C) ( SACIMPGUS_CONTENT(C)->p ) -#define SACIMPGUS_PQ(C) ( SACIMPGUS_CONTENT(C)->pq ) #define SACIMPGUS_ADJ(C) ( SACIMPGUS_CONTENT(C)->adj ) #define SACIMPGUS_FIRSTSTEP(C) ( SACIMPGUS_CONTENT(C)->firststep ) @@ -43,9 +42,7 @@ #define DEFAULT_K1 RCONST(0.98) #define DEFAULT_K2 RCONST(0.95) #define DEFAULT_BIAS RCONST(1.5) -#define DEFAULT_PQ 0 #define DEFAULT_ADJ -1 -/* #define DEFAULT_PQ -1 */ /* #define DEFAULT_ADJ 0 */ #define TINY RCONST(1.0e-10) @@ -106,11 +103,10 @@ SUNAdaptController SUNAdaptController_ImpGus(SUNContext sunctx) * Function to set ImpGus parameters */ -int SUNAdaptController_SetParams_ImpGus(SUNAdaptController C, int pq, +int SUNAdaptController_SetParams_ImpGus(SUNAdaptController C, sunrealtype k1, sunrealtype k2) { /* store legal inputs, and return with success */ - SACIMPGUS_PQ(C) = pq; if (k1 >= RCONST(0.0)) { SACIMPGUS_K1(C) = k1; } if (k2 >= RCONST(0.0)) { SACIMPGUS_K2(C) = k2; } return SUNADAPTCONTROLLER_SUCCESS; @@ -171,7 +167,6 @@ int SUNAdaptController_SetDefaults_ImpGus(SUNAdaptController C) SACIMPGUS_K1(C) = DEFAULT_K1; SACIMPGUS_K2(C) = DEFAULT_K2; SACIMPGUS_BIAS(C) = DEFAULT_BIAS; - SACIMPGUS_PQ(C) = DEFAULT_PQ; SACIMPGUS_ADJ(C) = DEFAULT_ADJ; return SUNADAPTCONTROLLER_SUCCESS; } @@ -192,35 +187,15 @@ int SUNAdaptController_Write_ImpGus(SUNAdaptController C, FILE *fptr) fprintf(fptr, " previous error = %16g\n", SACIMPGUS_EP(C)); fprintf(fptr, " previous step = %16g\n", SACIMPGUS_HP(C)); #endif - if (SACIMPGUS_PQ(C) == 1) - { - fprintf(fptr, " p = %i (method order)\n", SACIMPGUS_P(C)); - } - else if (SACIMPGUS_PQ(C) == 0) - { - fprintf(fptr, " p = %i (embedding order)\n", SACIMPGUS_P(C)); - } - else - { - fprintf(fptr, " p = %i (minimum of method & embedding order)\n", SACIMPGUS_P(C)); - } - fprintf(fptr, " adj = %i\n", SACIMPGUS_ADJ(C)); + fprintf(fptr, " p = %i\n", SACIMPGUS_P(C)); return SUNADAPTCONTROLLER_SUCCESS; } -int SUNAdaptController_SetMethodOrder_ImpGus(SUNAdaptController C, int p, int q) +int SUNAdaptController_SetMethodOrder_ImpGus(SUNAdaptController C, int p) { /* check for legal inputs */ - if ((p <= 0) || (q <= 0)) { return SUNADAPTCONTROLLER_ILL_INPUT; } - - /* store appropriate value based on "pq" */ - if (SACIMPGUS_PQ(C) == 1) { - SACIMPGUS_P(C) = p; - } else if (SACIMPGUS_PQ(C) == 0) { - SACIMPGUS_P(C) = q; - } else { - SACIMPGUS_P(C) = SUNMIN(p,q); - } + if (p <= 0) { return SUNADAPTCONTROLLER_ILL_INPUT; } + SACIMPGUS_P(C) = p; return SUNADAPTCONTROLLER_SUCCESS; } diff --git a/src/sunadaptcontroller/pi/fmod/fsunadaptcontroller_pi_mod.c b/src/sunadaptcontroller/pi/fmod/fsunadaptcontroller_pi_mod.c index 2c0f585d3b..eb66617d8d 100644 --- a/src/sunadaptcontroller/pi/fmod/fsunadaptcontroller_pi_mod.c +++ b/src/sunadaptcontroller/pi/fmod/fsunadaptcontroller_pi_mod.c @@ -220,19 +220,17 @@ SWIGEXPORT SUNAdaptController _wrap_FSUNAdaptController_PI(void *farg1) { } -SWIGEXPORT int _wrap_FSUNAdaptController_SetParams_PI(SUNAdaptController farg1, int const *farg2, double const *farg3, double const *farg4) { +SWIGEXPORT int _wrap_FSUNAdaptController_SetParams_PI(SUNAdaptController farg1, double const *farg2, double const *farg3) { int fresult ; SUNAdaptController arg1 = (SUNAdaptController) 0 ; - int arg2 ; + sunrealtype arg2 ; sunrealtype arg3 ; - sunrealtype arg4 ; int result; arg1 = (SUNAdaptController)(farg1); - arg2 = (int)(*farg2); + arg2 = (sunrealtype)(*farg2); arg3 = (sunrealtype)(*farg3); - arg4 = (sunrealtype)(*farg4); - result = (int)SUNAdaptController_SetParams_PI(arg1,arg2,arg3,arg4); + result = (int)SUNAdaptController_SetParams_PI(arg1,arg2,arg3); fresult = (int)(result); return fresult; } @@ -306,17 +304,15 @@ SWIGEXPORT int _wrap_FSUNAdaptController_Write_PI(SUNAdaptController farg1, void } -SWIGEXPORT int _wrap_FSUNAdaptController_SetMethodOrder_PI(SUNAdaptController farg1, int const *farg2, int const *farg3) { +SWIGEXPORT int _wrap_FSUNAdaptController_SetMethodOrder_PI(SUNAdaptController farg1, int const *farg2) { int fresult ; SUNAdaptController arg1 = (SUNAdaptController) 0 ; int arg2 ; - int arg3 ; int result; arg1 = (SUNAdaptController)(farg1); arg2 = (int)(*farg2); - arg3 = (int)(*farg3); - result = (int)SUNAdaptController_SetMethodOrder_PI(arg1,arg2,arg3); + result = (int)SUNAdaptController_SetMethodOrder_PI(arg1,arg2); fresult = (int)(result); return fresult; } diff --git a/src/sunadaptcontroller/pi/fmod/fsunadaptcontroller_pi_mod.f90 b/src/sunadaptcontroller/pi/fmod/fsunadaptcontroller_pi_mod.f90 index 34be923c0b..69f81b629e 100644 --- a/src/sunadaptcontroller/pi/fmod/fsunadaptcontroller_pi_mod.f90 +++ b/src/sunadaptcontroller/pi/fmod/fsunadaptcontroller_pi_mod.f90 @@ -50,14 +50,13 @@ function swigc_FSUNAdaptController_PI(farg1) & type(C_PTR) :: fresult end function -function swigc_FSUNAdaptController_SetParams_PI(farg1, farg2, farg3, farg4) & +function swigc_FSUNAdaptController_SetParams_PI(farg1, farg2, farg3) & bind(C, name="_wrap_FSUNAdaptController_SetParams_PI") & 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 -real(C_DOUBLE), intent(in) :: farg4 integer(C_INT) :: fresult end function @@ -105,13 +104,12 @@ function swigc_FSUNAdaptController_Write_PI(farg1, farg2) & integer(C_INT) :: fresult end function -function swigc_FSUNAdaptController_SetMethodOrder_PI(farg1, farg2, farg3) & +function swigc_FSUNAdaptController_SetMethodOrder_PI(farg1, farg2) & bind(C, name="_wrap_FSUNAdaptController_SetMethodOrder_PI") & 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 @@ -171,25 +169,22 @@ function FSUNAdaptController_PI(sunctx) & call c_f_pointer(fresult, swig_result) end function -function FSUNAdaptController_SetParams_PI(c, pq, k1, k2) & +function FSUNAdaptController_SetParams_PI(c, k1, k2) & result(swig_result) use, intrinsic :: ISO_C_BINDING integer(C_INT) :: swig_result type(SUNAdaptController), target, intent(inout) :: c -integer(C_INT), intent(in) :: pq real(C_DOUBLE), intent(in) :: k1 real(C_DOUBLE), intent(in) :: k2 integer(C_INT) :: fresult type(C_PTR) :: farg1 -integer(C_INT) :: farg2 +real(C_DOUBLE) :: farg2 real(C_DOUBLE) :: farg3 -real(C_DOUBLE) :: farg4 farg1 = c_loc(c) -farg2 = pq -farg3 = k1 -farg4 = k2 -fresult = swigc_FSUNAdaptController_SetParams_PI(farg1, farg2, farg3, farg4) +farg2 = k1 +farg3 = k2 +fresult = swigc_FSUNAdaptController_SetParams_PI(farg1, farg2, farg3) swig_result = fresult end function @@ -270,22 +265,19 @@ function FSUNAdaptController_Write_PI(c, fptr) & swig_result = fresult end function -function FSUNAdaptController_SetMethodOrder_PI(c, p, q) & +function FSUNAdaptController_SetMethodOrder_PI(c, p) & result(swig_result) use, intrinsic :: ISO_C_BINDING integer(C_INT) :: swig_result type(SUNAdaptController), target, intent(inout) :: c integer(C_INT), intent(in) :: p -integer(C_INT), intent(in) :: q integer(C_INT) :: fresult type(C_PTR) :: farg1 integer(C_INT) :: farg2 -integer(C_INT) :: farg3 farg1 = c_loc(c) farg2 = p -farg3 = q -fresult = swigc_FSUNAdaptController_SetMethodOrder_PI(farg1, farg2, farg3) +fresult = swigc_FSUNAdaptController_SetMethodOrder_PI(farg1, farg2) swig_result = fresult end function diff --git a/src/sunadaptcontroller/pi/sunadaptcontroller_pi.c b/src/sunadaptcontroller/pi/sunadaptcontroller_pi.c index 391648c46d..34b61d1593 100644 --- a/src/sunadaptcontroller/pi/sunadaptcontroller_pi.c +++ b/src/sunadaptcontroller/pi/sunadaptcontroller_pi.c @@ -31,7 +31,6 @@ #define SACPI_BIAS(C) ( SACPI_CONTENT(C)->bias ) #define SACPI_EP(C) ( SACPI_CONTENT(C)->ep ) #define SACPI_P(C) ( SACPI_CONTENT(C)->p ) -#define SACPI_PQ(C) ( SACPI_CONTENT(C)->pq ) #define SACPI_ADJ(C) ( SACPI_CONTENT(C)->adj ) /* ------------------ @@ -41,9 +40,7 @@ #define DEFAULT_K1 RCONST(0.8) #define DEFAULT_K2 RCONST(0.31) #define DEFAULT_BIAS RCONST(1.5) -#define DEFAULT_PQ 0 #define DEFAULT_ADJ -1 -/* #define DEFAULT_PQ -1 */ /* #define DEFAULT_ADJ 0 */ #define TINY RCONST(1.0e-10) @@ -104,11 +101,10 @@ SUNAdaptController SUNAdaptController_PI(SUNContext sunctx) * Function to set PI parameters */ -int SUNAdaptController_SetParams_PI(SUNAdaptController C, int pq, +int SUNAdaptController_SetParams_PI(SUNAdaptController C, sunrealtype k1, sunrealtype k2) { /* store legal inputs, and return with success */ - SACPI_PQ(C) = pq; if (k1 >= RCONST(0.0)) { SACPI_K1(C) = k1; } if (k2 >= RCONST(0.0)) { SACPI_K2(C) = k2; } return SUNADAPTCONTROLLER_SUCCESS; @@ -149,7 +145,6 @@ int SUNAdaptController_SetDefaults_PI(SUNAdaptController C) SACPI_K1(C) = DEFAULT_K1; SACPI_K2(C) = DEFAULT_K2; SACPI_BIAS(C) = DEFAULT_BIAS; - SACPI_PQ(C) = DEFAULT_PQ; SACPI_ADJ(C) = DEFAULT_ADJ; return SUNADAPTCONTROLLER_SUCCESS; } @@ -168,35 +163,16 @@ int SUNAdaptController_Write_PI(SUNAdaptController C, FILE *fptr) fprintf(fptr, " bias factor = %16g\n", SACPI_BIAS(C)); fprintf(fptr, " previous error = %16g\n", SACPI_EP(C)); #endif - if (SACPI_PQ(C) == 1) - { - fprintf(fptr, " p = %i (method order)\n", SACPI_P(C)); - } - else if (SACPI_PQ(C) == 0) - { - fprintf(fptr, " p = %i (embedding order)\n", SACPI_P(C)); - } - else - { - fprintf(fptr, " p = %i (minimum of method & embedding order)\n", SACPI_P(C)); - } + fprintf(fptr, " p = %i\n", SACPI_P(C)); fprintf(fptr, " adj = %i\n", SACPI_ADJ(C)); return SUNADAPTCONTROLLER_SUCCESS; } -int SUNAdaptController_SetMethodOrder_PI(SUNAdaptController C, int p, int q) +int SUNAdaptController_SetMethodOrder_PI(SUNAdaptController C, int p) { /* check for legal inputs */ - if ((p <= 0) || (q <= 0)) { return SUNADAPTCONTROLLER_ILL_INPUT; } - - /* store appropriate value based on "pq" */ - if (SACPI_PQ(C) == 1) { - SACPI_P(C) = p; - } else if (SACPI_PQ(C) == 0) { - SACPI_P(C) = q; - } else { - SACPI_P(C) = SUNMIN(p,q); - } + if (p <= 0) { return SUNADAPTCONTROLLER_ILL_INPUT; } + SACPI_P(C) = p; return SUNADAPTCONTROLLER_SUCCESS; } diff --git a/src/sunadaptcontroller/pid/fmod/fsunadaptcontroller_pid_mod.c b/src/sunadaptcontroller/pid/fmod/fsunadaptcontroller_pid_mod.c index d3f48b5234..7459c96d63 100644 --- a/src/sunadaptcontroller/pid/fmod/fsunadaptcontroller_pid_mod.c +++ b/src/sunadaptcontroller/pid/fmod/fsunadaptcontroller_pid_mod.c @@ -220,21 +220,19 @@ SWIGEXPORT SUNAdaptController _wrap_FSUNAdaptController_PID(void *farg1) { } -SWIGEXPORT int _wrap_FSUNAdaptController_SetParams_PID(SUNAdaptController farg1, int const *farg2, double const *farg3, double const *farg4, double const *farg5) { +SWIGEXPORT int _wrap_FSUNAdaptController_SetParams_PID(SUNAdaptController farg1, double const *farg2, double const *farg3, double const *farg4) { int fresult ; SUNAdaptController arg1 = (SUNAdaptController) 0 ; - int arg2 ; + sunrealtype arg2 ; sunrealtype arg3 ; sunrealtype arg4 ; - sunrealtype arg5 ; int result; arg1 = (SUNAdaptController)(farg1); - arg2 = (int)(*farg2); + arg2 = (sunrealtype)(*farg2); arg3 = (sunrealtype)(*farg3); arg4 = (sunrealtype)(*farg4); - arg5 = (sunrealtype)(*farg5); - result = (int)SUNAdaptController_SetParams_PID(arg1,arg2,arg3,arg4,arg5); + result = (int)SUNAdaptController_SetParams_PID(arg1,arg2,arg3,arg4); fresult = (int)(result); return fresult; } @@ -308,17 +306,15 @@ SWIGEXPORT int _wrap_FSUNAdaptController_Write_PID(SUNAdaptController farg1, voi } -SWIGEXPORT int _wrap_FSUNAdaptController_SetMethodOrder_PID(SUNAdaptController farg1, int const *farg2, int const *farg3) { +SWIGEXPORT int _wrap_FSUNAdaptController_SetMethodOrder_PID(SUNAdaptController farg1, int const *farg2) { int fresult ; SUNAdaptController arg1 = (SUNAdaptController) 0 ; int arg2 ; - int arg3 ; int result; arg1 = (SUNAdaptController)(farg1); arg2 = (int)(*farg2); - arg3 = (int)(*farg3); - result = (int)SUNAdaptController_SetMethodOrder_PID(arg1,arg2,arg3); + result = (int)SUNAdaptController_SetMethodOrder_PID(arg1,arg2); fresult = (int)(result); return fresult; } diff --git a/src/sunadaptcontroller/pid/fmod/fsunadaptcontroller_pid_mod.f90 b/src/sunadaptcontroller/pid/fmod/fsunadaptcontroller_pid_mod.f90 index 288d474671..24ec52a76d 100644 --- a/src/sunadaptcontroller/pid/fmod/fsunadaptcontroller_pid_mod.f90 +++ b/src/sunadaptcontroller/pid/fmod/fsunadaptcontroller_pid_mod.f90 @@ -50,15 +50,14 @@ function swigc_FSUNAdaptController_PID(farg1) & type(C_PTR) :: fresult end function -function swigc_FSUNAdaptController_SetParams_PID(farg1, farg2, farg3, farg4, farg5) & +function swigc_FSUNAdaptController_SetParams_PID(farg1, farg2, farg3, farg4) & bind(C, name="_wrap_FSUNAdaptController_SetParams_PID") & 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 real(C_DOUBLE), intent(in) :: farg4 -real(C_DOUBLE), intent(in) :: farg5 integer(C_INT) :: fresult end function @@ -106,13 +105,12 @@ function swigc_FSUNAdaptController_Write_PID(farg1, farg2) & integer(C_INT) :: fresult end function -function swigc_FSUNAdaptController_SetMethodOrder_PID(farg1, farg2, farg3) & +function swigc_FSUNAdaptController_SetMethodOrder_PID(farg1, farg2) & bind(C, name="_wrap_FSUNAdaptController_SetMethodOrder_PID") & 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 @@ -172,28 +170,25 @@ function FSUNAdaptController_PID(sunctx) & call c_f_pointer(fresult, swig_result) end function -function FSUNAdaptController_SetParams_PID(c, pq, k1, k2, k3) & +function FSUNAdaptController_SetParams_PID(c, k1, k2, k3) & result(swig_result) use, intrinsic :: ISO_C_BINDING integer(C_INT) :: swig_result type(SUNAdaptController), target, intent(inout) :: c -integer(C_INT), intent(in) :: pq real(C_DOUBLE), intent(in) :: k1 real(C_DOUBLE), intent(in) :: k2 real(C_DOUBLE), intent(in) :: k3 integer(C_INT) :: fresult type(C_PTR) :: farg1 -integer(C_INT) :: farg2 +real(C_DOUBLE) :: farg2 real(C_DOUBLE) :: farg3 real(C_DOUBLE) :: farg4 -real(C_DOUBLE) :: farg5 farg1 = c_loc(c) -farg2 = pq -farg3 = k1 -farg4 = k2 -farg5 = k3 -fresult = swigc_FSUNAdaptController_SetParams_PID(farg1, farg2, farg3, farg4, farg5) +farg2 = k1 +farg3 = k2 +farg4 = k3 +fresult = swigc_FSUNAdaptController_SetParams_PID(farg1, farg2, farg3, farg4) swig_result = fresult end function @@ -274,22 +269,19 @@ function FSUNAdaptController_Write_PID(c, fptr) & swig_result = fresult end function -function FSUNAdaptController_SetMethodOrder_PID(c, p, q) & +function FSUNAdaptController_SetMethodOrder_PID(c, p) & result(swig_result) use, intrinsic :: ISO_C_BINDING integer(C_INT) :: swig_result type(SUNAdaptController), target, intent(inout) :: c integer(C_INT), intent(in) :: p -integer(C_INT), intent(in) :: q integer(C_INT) :: fresult type(C_PTR) :: farg1 integer(C_INT) :: farg2 -integer(C_INT) :: farg3 farg1 = c_loc(c) farg2 = p -farg3 = q -fresult = swigc_FSUNAdaptController_SetMethodOrder_PID(farg1, farg2, farg3) +fresult = swigc_FSUNAdaptController_SetMethodOrder_PID(farg1, farg2) swig_result = fresult end function diff --git a/src/sunadaptcontroller/pid/sunadaptcontroller_pid.c b/src/sunadaptcontroller/pid/sunadaptcontroller_pid.c index 4e63386e57..c8f068f7f1 100644 --- a/src/sunadaptcontroller/pid/sunadaptcontroller_pid.c +++ b/src/sunadaptcontroller/pid/sunadaptcontroller_pid.c @@ -33,7 +33,6 @@ #define SACPID_EP(C) ( SACPID_CONTENT(C)->ep ) #define SACPID_EPP(C) ( SACPID_CONTENT(C)->epp ) #define SACPID_P(C) ( SACPID_CONTENT(C)->p ) -#define SACPID_PQ(C) ( SACPID_CONTENT(C)->pq ) #define SACPID_ADJ(C) ( SACPID_CONTENT(C)->adj ) /* ------------------ @@ -44,9 +43,7 @@ #define DEFAULT_K2 RCONST(0.21) #define DEFAULT_K3 RCONST(0.1) #define DEFAULT_BIAS RCONST(1.5) -#define DEFAULT_PQ 0 #define DEFAULT_ADJ -1 -/* #define DEFAULT_PQ -1 */ /* #define DEFAULT_ADJ 0 */ #define TINY RCONST(1.0e-10) @@ -107,11 +104,10 @@ SUNAdaptController SUNAdaptController_PID(SUNContext sunctx) * Function to set PID parameters */ -int SUNAdaptController_SetParams_PID(SUNAdaptController C, int pq, - sunrealtype k1, sunrealtype k2, sunrealtype k3) +int SUNAdaptController_SetParams_PID(SUNAdaptController C, sunrealtype k1, + sunrealtype k2, sunrealtype k3) { /* store legal inputs, and return with success */ - SACPID_PQ(C) = pq; if (k1 >= RCONST(0.0)) { SACPID_K1(C) = k1; } if (k2 >= RCONST(0.0)) { SACPID_K2(C) = k2; } if (k3 >= RCONST(0.0)) { SACPID_K3(C) = k3; } @@ -157,7 +153,6 @@ int SUNAdaptController_SetDefaults_PID(SUNAdaptController C) SACPID_K2(C) = DEFAULT_K2; SACPID_K3(C) = DEFAULT_K3; SACPID_BIAS(C) = DEFAULT_BIAS; - SACPID_PQ(C) = DEFAULT_PQ; SACPID_ADJ(C) = DEFAULT_ADJ; return SUNADAPTCONTROLLER_SUCCESS; } @@ -178,35 +173,16 @@ int SUNAdaptController_Write_PID(SUNAdaptController C, FILE *fptr) fprintf(fptr, " bias factor = %16g\n", SACPID_BIAS(C)); fprintf(fptr, " previous errors = %16g %16g\n", SACPID_EP(C), SACPID_EPP(C)); #endif - if (SACPID_PQ(C) == 1) - { - fprintf(fptr, " p = %i (method order)\n", SACPID_P(C)); - } - else if (SACPID_PQ(C) == 0) - { - fprintf(fptr, " p = %i (embedding order)\n", SACPID_P(C)); - } - else - { - fprintf(fptr, " p = %i (minimum of method & embedding order)\n", SACPID_P(C)); - } + fprintf(fptr, " p = %i\n", SACPID_P(C)); fprintf(fptr, " adj = %i\n", SACPID_ADJ(C)); return SUNADAPTCONTROLLER_SUCCESS; } -int SUNAdaptController_SetMethodOrder_PID(SUNAdaptController C, int p, int q) +int SUNAdaptController_SetMethodOrder_PID(SUNAdaptController C, int p) { /* check for legal inputs */ - if ((p <= 0) || (q <= 0)) { return SUNADAPTCONTROLLER_ILL_INPUT; } - - /* store appropriate value based on "pq" */ - if (SACPID_PQ(C) == 1) { - SACPID_P(C) = p; - } else if (SACPID_PQ(C) == 0) { - SACPID_P(C) = q; - } else { - SACPID_P(C) = SUNMIN(p,q); - } + if (p <= 0) { return SUNADAPTCONTROLLER_ILL_INPUT; } + SACPID_P(C) = p; return SUNADAPTCONTROLLER_SUCCESS; } diff --git a/src/sundials/fmod/fsundials_adaptcontroller_mod.c b/src/sundials/fmod/fsundials_adaptcontroller_mod.c index 02f8b0710c..66486bdeb8 100644 --- a/src/sundials/fmod/fsundials_adaptcontroller_mod.c +++ b/src/sundials/fmod/fsundials_adaptcontroller_mod.c @@ -352,17 +352,15 @@ SWIGEXPORT int _wrap_FSUNAdaptController_Write(SUNAdaptController farg1, void *f } -SWIGEXPORT int _wrap_FSUNAdaptController_SetMethodOrder(SUNAdaptController farg1, int const *farg2, int const *farg3) { +SWIGEXPORT int _wrap_FSUNAdaptController_SetMethodOrder(SUNAdaptController farg1, int const *farg2) { int fresult ; SUNAdaptController arg1 = (SUNAdaptController) 0 ; int arg2 ; - int arg3 ; int result; arg1 = (SUNAdaptController)(farg1); arg2 = (int)(*farg2); - arg3 = (int)(*farg3); - result = (int)SUNAdaptController_SetMethodOrder(arg1,arg2,arg3); + result = (int)SUNAdaptController_SetMethodOrder(arg1,arg2); fresult = (int)(result); return fresult; } diff --git a/src/sundials/fmod/fsundials_adaptcontroller_mod.f90 b/src/sundials/fmod/fsundials_adaptcontroller_mod.f90 index de55e65e0a..fe49363fd0 100644 --- a/src/sundials/fmod/fsundials_adaptcontroller_mod.f90 +++ b/src/sundials/fmod/fsundials_adaptcontroller_mod.f90 @@ -173,13 +173,12 @@ function swigc_FSUNAdaptController_Write(farg1, farg2) & integer(C_INT) :: fresult end function -function swigc_FSUNAdaptController_SetMethodOrder(farg1, farg2, farg3) & +function swigc_FSUNAdaptController_SetMethodOrder(farg1, farg2) & bind(C, name="_wrap_FSUNAdaptController_SetMethodOrder") & 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 @@ -443,22 +442,19 @@ function FSUNAdaptController_Write(c, fptr) & swig_result = fresult end function -function FSUNAdaptController_SetMethodOrder(c, p, q) & +function FSUNAdaptController_SetMethodOrder(c, p) & result(swig_result) use, intrinsic :: ISO_C_BINDING integer(C_INT) :: swig_result type(SUNAdaptController), target, intent(inout) :: c integer(C_INT), intent(in) :: p -integer(C_INT), intent(in) :: q integer(C_INT) :: fresult type(C_PTR) :: farg1 integer(C_INT) :: farg2 -integer(C_INT) :: farg3 farg1 = c_loc(c) farg2 = p -farg3 = q -fresult = swigc_FSUNAdaptController_SetMethodOrder(farg1, farg2, farg3) +fresult = swigc_FSUNAdaptController_SetMethodOrder(farg1, farg2) swig_result = fresult end function diff --git a/src/sundials/sundials_adaptcontroller.c b/src/sundials/sundials_adaptcontroller.c index 153d5abea1..232a8f4e19 100644 --- a/src/sundials/sundials_adaptcontroller.c +++ b/src/sundials/sundials_adaptcontroller.c @@ -200,11 +200,11 @@ int SUNAdaptController_Write(SUNAdaptController C, FILE* fptr) return(ier); } -int SUNAdaptController_SetMethodOrder(SUNAdaptController C, int p, int q) +int SUNAdaptController_SetMethodOrder(SUNAdaptController C, int p) { int ier = 0; if (C == NULL) { return ier; } - if (C->ops->setmethodorder) { ier = C->ops->setmethodorder(C, p, q); } + if (C->ops->setmethodorder) { ier = C->ops->setmethodorder(C, p); } return(ier); } From b10c7bc1ad3b1e8600099cb3c18131607cb61ecd Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Thu, 19 Oct 2023 11:22:26 -0500 Subject: [PATCH 07/58] Moved order of accuracy adjustment factor into ARKodeHAdaptMem, simplifying SUNAdaptController API --- .../ARKStep_c_interface/User_callable.rst | 64 +++++++++----- .../ERKStep_c_interface/User_callable.rst | 87 ++++++++++++------- .../SUNAdaptController_Description.rst | 22 ----- .../SUNAdaptController_ExpGus.rst | 13 +-- .../SUNAdaptController_I.rst | 13 +-- .../SUNAdaptController_ImExGus.rst | 12 +-- .../SUNAdaptController_ImpGus.rst | 12 +-- .../SUNAdaptController_PI.rst | 12 +-- .../SUNAdaptController_PID.rst | 13 +-- include/arkode/arkode_arkstep.h | 1 + include/arkode/arkode_erkstep.h | 1 + .../sunadaptcontroller_expgus.h | 3 - .../sunadaptcontroller/sunadaptcontroller_i.h | 3 - .../sunadaptcontroller_imexgus.h | 3 - .../sunadaptcontroller_impgus.h | 3 - .../sunadaptcontroller_pi.h | 3 - .../sunadaptcontroller_pid.h | 3 - include/sundials/sundials_adaptcontroller.h | 5 -- src/arkode/arkode_adapt.c | 1 + src/arkode/arkode_adapt_impl.h | 3 + src/arkode/arkode_arkstep.c | 6 +- src/arkode/arkode_arkstep_io.c | 2 + src/arkode/arkode_erkstep.c | 6 +- src/arkode/arkode_erkstep_io.c | 2 + src/arkode/arkode_impl.h | 1 + src/arkode/arkode_io.c | 25 ++++++ src/arkode/fmod/farkode_arkstep_mod.c | 14 +++ src/arkode/fmod/farkode_arkstep_mod.f90 | 26 ++++++ src/arkode/fmod/farkode_erkstep_mod.c | 14 +++ src/arkode/fmod/farkode_erkstep_mod.f90 | 26 ++++++ .../fmod/fsunadaptcontroller_expgus_mod.c | 14 --- .../fmod/fsunadaptcontroller_expgus_mod.f90 | 26 ------ .../expgus/sunadaptcontroller_expgus.c | 38 +++----- .../i/fmod/fsunadaptcontroller_i_mod.c | 14 --- .../i/fmod/fsunadaptcontroller_i_mod.f90 | 26 ------ .../i/sunadaptcontroller_i.c | 34 +++----- .../fmod/fsunadaptcontroller_imexgus_mod.c | 14 --- .../fmod/fsunadaptcontroller_imexgus_mod.f90 | 26 ------ .../imexgus/sunadaptcontroller_imexgus.c | 38 +++----- .../fmod/fsunadaptcontroller_impgus_mod.c | 14 --- .../fmod/fsunadaptcontroller_impgus_mod.f90 | 26 ------ .../impgus/sunadaptcontroller_impgus.c | 43 ++++----- .../pi/fmod/fsunadaptcontroller_pi_mod.c | 14 --- .../pi/fmod/fsunadaptcontroller_pi_mod.f90 | 26 ------ .../pi/sunadaptcontroller_pi.c | 38 +++----- .../pid/fmod/fsunadaptcontroller_pid_mod.c | 14 --- .../pid/fmod/fsunadaptcontroller_pid_mod.f90 | 26 ------ .../pid/sunadaptcontroller_pid.c | 38 +++----- .../fmod/fsundials_adaptcontroller_mod.c | 14 --- .../fmod/fsundials_adaptcontroller_mod.f90 | 27 ------ src/sundials/sundials_adaptcontroller.c | 39 ++++----- 51 files changed, 337 insertions(+), 611 deletions(-) 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 050aef7507..379deb0d28 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 @@ -1110,8 +1110,9 @@ Set max number of constraint failures :c:func:`ARKStepSetMaxNumConst :c:func:`ARKStepSetMaxGrowth()`, :c:func:`ARKStepSetMinReduction()`, :c:func:`ARKStepSetSafetyFactor()`, - :c:func:`ARKStepSetSmallNumEFails()` and - :c:func:`ARKStepSetStabilityFn()` + :c:func:`ARKStepSetSmallNumEFails()`, + :c:func:`ARKStepSetStabilityFn()`, and + :c:func:`ARKStepSetAdaptController()` will be ignored, since temporal adaptivity is disabled. If both :c:func:`ARKStepSetFixedStep()` and @@ -1691,24 +1692,25 @@ 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 -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 -========================================================= ====================================== ======== +========================================================= ========================================== ======== +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 +========================================================= ========================================== ======== @@ -1793,6 +1795,28 @@ Explicit stability function :c:func:`ARKStepSetS +.. c:function:: int ARKStepSetAdaptivityAdjustment(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`. + + **Arguments:** + * *arkode_mem* -- pointer to the ARKStep memory block. + * *adjust* -- adjustment factor (default is -1). + + **Return value:** + * *ARK_SUCCESS* if successful + * *ARK_MEM_NULL* if the ARKStep memory is ``NULL`` + * *ARK_ILL_INPUT* if an argument has an illegal value + + **Notes:** + This should be called prior to calling :c:func:`ARKStepEvolve()`, and can only be + reset following a call to :c:func:`ARKStepReInit()`. + + + .. c:function:: int ARKStepSetCFLFraction(void* arkode_mem, realtype cfl_frac) Specifies the fraction of the estimated explicitly stable step to use. 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 fb61ad0c92..ad22622783 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 @@ -732,8 +732,9 @@ Optional inputs for ERKStep :c:func:`ERKStepSetMaxGrowth()`, :c:func:`ERKStepSetMinReduction()`, :c:func:`ERKStepSetSafetyFactor()`, - :c:func:`ERKStepSetSmallNumEFails()` and - :c:func:`ERKStepSetStabilityFn()` + :c:func:`ERKStepSetSmallNumEFails()`, + :c:func:`ERKStepSetStabilityFn()`, and + :c:func:`ERKStepSetAdaptController()` will be ignored, since temporal adaptivity is disabled. If both :c:func:`ERKStepSetFixedStep()` and @@ -1159,35 +1160,37 @@ 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 | - +-----------------------------------------------------------+----------------------------------------+-----------+ - | 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 | - +-----------------------------------------------------------+----------------------------------------+-----------+ + +-----------------------------------------------------------+--------------------------------------------+-----------+ + | 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 | + +-----------------------------------------------------------+--------------------------------------------+-----------+ @@ -1270,6 +1273,28 @@ the code, is provided in :numref:`ARKODE.Mathematics.Adaptivity`. Use the SUNAdaptController infrastructure instead (see :numref:`SUNAdaptController.Description`). +.. c:function:: int ERKStepSetAdaptivityAdjustment(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`. + + **Arguments:** + * *arkode_mem* -- pointer to the ERKStep memory block. + * *adjust* -- adjustment factor (default is -1). + + **Return value:** + * *ARK_SUCCESS* if successful + * *ARK_MEM_NULL* if the ERKStep memory is ``NULL`` + * *ARK_ILL_INPUT* if an argument has an illegal value + + **Notes:** + This should be called prior to calling :c:func:`ERKStepEvolve()`, and can only be + reset following a call to :c:func:`ERKStepReInit()`. + + + .. c:function:: int ERKStepSetCFLFraction(void* arkode_mem, realtype cfl_frac) Specifies the fraction of the estimated explicitly stable step to use. diff --git a/doc/shared/sunadaptcontroller/SUNAdaptController_Description.rst b/doc/shared/sunadaptcontroller/SUNAdaptController_Description.rst index fc58f1f65b..4cdedbe4c7 100644 --- a/doc/shared/sunadaptcontroller/SUNAdaptController_Description.rst +++ b/doc/shared/sunadaptcontroller/SUNAdaptController_Description.rst @@ -68,7 +68,6 @@ function pointers to the various controller operations, and is defined as int (*setdefaults)(SUNAdaptController C); int (*write)(SUNAdaptController C, FILE* fptr); int (*setmethodorder)(SUNAdaptController C, int p); - int (*adjustcontrollerorder)(SUNAdaptController C, int adj); int (*seterrorbias)(SUNAdaptController C, sunrealtype bias); int (*update)(SUNAdaptController C, sunrealtype h, sunrealtype dsm); int (*updatemrih)(SUNAdaptController C, sunrealtype H, sunrealtype h, sunrealtype DSM, sunrealtype dsm); @@ -326,27 +325,6 @@ routine, below. retval = SUNAdaptController_SetMethodOrder(C, 3, 2); -.. c:function:: int SUNAdaptController_AdjustControllerOrder(SUNAdaptController C, int adj) - - Called by a user to request that the controller adjust the order specified by the time - integration method when performing temporal adaptivity, e.g., 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:`adj < 0`. This - adjustment will apply to all subsequent time step adaptivity estimates used by the - controller, and may be undone by a call with :math:`adj = 0`. - - :param C: the :c:type:`SUNAdaptController` object. - :param p: the adjustment that will be applied to the values *p* and *q* from - :c:func:`SUNAdaptController_SetMethodOrder`. - :return: error code indicating success failure - (see :numref:`SUNAdaptController.Description.errorCodes`). - - Usage: - - .. code-block:: c - - retval = SUNAdaptController_AdjustControllerOrder(C, -1); - .. c:function:: int SUNAdaptController_SetErrorBias(SUNAdaptController C, sunrealtype bias) Sets an error bias factor for scaling the local error factors. This is diff --git a/doc/shared/sunadaptcontroller/SUNAdaptController_ExpGus.rst b/doc/shared/sunadaptcontroller/SUNAdaptController_ExpGus.rst index 18acb21267..6bea7f5365 100644 --- a/doc/shared/sunadaptcontroller/SUNAdaptController_ExpGus.rst +++ b/doc/shared/sunadaptcontroller/SUNAdaptController_ExpGus.rst @@ -30,9 +30,9 @@ form \quad\text{on subsequent steps}, \end{cases} -with default values :math:`k_1=0.367` and :math:`k_2=0.268`, and where :math:`ord = p+1+adj`, -with both :math:`p` and :math:`adj` described below. In this estimate, a floor of -:math:`\varepsilon > 10^{-10}` is enforced to avoid division-by-zero errors. +with default values :math:`k_1=0.367` and :math:`k_2=0.268`, and where :math:`ord = p+1`, +with :math:`p` is described below. In this estimate, a floor of :math:`\varepsilon > 10^{-10}` +is enforced to avoid division-by-zero errors. The SUNAdaptController_ExpGus controller is implemented as a derived SUNAdaptController class, and defines its *content* field as: @@ -45,7 +45,6 @@ and defines its *content* field as: sunrealtype bias; sunrealtype ep; int p; - int adj; sunbooleantype firststep; }; @@ -58,11 +57,7 @@ These entries of the *content* field contain the following information: * ``ep`` - storage for the previous error estimate, :math:`\varepsilon_{n-1}`. -* ``p`` - asymptotic order to use in error control. This is provided by - the time integrator, corresponding to the order of accuracy for the time - integration method, the embedding, or the minimum of the two. - -* ``adj`` - order of accuracy adjustment to use within the controller [default ``-1``]. +* ``p`` - asymptotic order to use in error control (provided by the time integrator). * ``firststep`` - flag indicating whether a step has successfully completed, in which case the formula above transitions from :math:`h_1` to :math:`h_n`. diff --git a/doc/shared/sunadaptcontroller/SUNAdaptController_I.rst b/doc/shared/sunadaptcontroller/SUNAdaptController_I.rst index e2b4ce0759..a843227229 100644 --- a/doc/shared/sunadaptcontroller/SUNAdaptController_I.rst +++ b/doc/shared/sunadaptcontroller/SUNAdaptController_I.rst @@ -26,9 +26,9 @@ estimate, .. math:: h' \;=\; h_n\; \varepsilon_n^{-k_1/ord}, -where :math:`ord = p+1+adj`, where both :math:`p` and :math:`adj` are -described below. In this estimate, a floor of :math:`\varepsilon > 10^{-10}` is enforced to -avoid division-by-zero errors. By default the constant :math:`k_1=1`. +where :math:`ord = p+1`, where :math:`p` is described below. In this estimate, a floor of +:math:`\varepsilon > 10^{-10}` is enforced to avoid division-by-zero errors. By default +the constant :math:`k_1=1`. This is implemented as a derived SUNAdaptController class, and defines its *content* field as: @@ -39,7 +39,6 @@ field as: sunrealtype k1; sunrealtype bias; int p; - int adj; }; These entries of the *content* field contain the following information: @@ -49,11 +48,7 @@ These entries of the *content* field contain the following information: * ``bias`` - error bias factor, that converts from an input temporal error estimate via :math:`\varepsilon = \text{bias}*\text{dsm}`. -* ``p`` - asymptotic order to use in error control. This is provided by - the time integrator, corresponding to the order of accuracy for the time - integration method, the embedding, or the minimum of the two. - -* ``adj`` - order of accuracy adjustment to use within the controller [default ``-1``]. +* ``p`` - asymptotic order to use in error control (provided by the time integrator). The header file to be included when using this module is diff --git a/doc/shared/sunadaptcontroller/SUNAdaptController_ImExGus.rst b/doc/shared/sunadaptcontroller/SUNAdaptController_ImExGus.rst index cdf97ae1bd..0e11bda66f 100644 --- a/doc/shared/sunadaptcontroller/SUNAdaptController_ImExGus.rst +++ b/doc/shared/sunadaptcontroller/SUNAdaptController_ImExGus.rst @@ -32,9 +32,8 @@ is primarily useful with explicit Runge--Kutta methods, and has the form :label: expGusController The default values of :math:`k_1` and :math:`k_2` are 0.367 and 0.268, -respectively, and :math:`ord = p+1+adj`, where both :math:`p` and :math:`adj` are -described below. In this estimate, a floor of :math:`\varepsilon > 10^{-10}` is enforced to -avoid division-by-zero errors. +respectively, and :math:`ord = p+1`, where :math:`p` is described below. In this estimate, +a floor of :math:`\varepsilon > 10^{-10}` is enforced to avoid division-by-zero errors. Gustafsson also proposed a controller for implicit Runge--Kutta methods in :cite:p:`Gust:94`, with the form @@ -66,7 +65,6 @@ class, and defines its *content* field as: sunrealtype ep; sunrealtype hp; int p; - int adj; sunbooleantype firststep; }; @@ -83,11 +81,7 @@ These entries of the *content* field contain the following information: * ``hp`` - storage for the previous step size, :math:`h_{n-1}`. -* ``p`` - asymptotic order to use in error control. This is provided by - the time integrator, corresponding to the order of accuracy for the time - integration method, the embedding, or the minimum of the two. - -* ``adj`` - order of accuracy adjustment to use within the controller [default ``-1``]. +* ``p`` - asymptotic order to use in error control (provided by the time integrator). * ``firststep`` - flag indicating whether a step has completed successfully, allowing the formulas above to transition between :math:`h_1` and :math:`h_n`. diff --git a/doc/shared/sunadaptcontroller/SUNAdaptController_ImpGus.rst b/doc/shared/sunadaptcontroller/SUNAdaptController_ImpGus.rst index 7fd5c5d0f1..a0be96c9fb 100644 --- a/doc/shared/sunadaptcontroller/SUNAdaptController_ImpGus.rst +++ b/doc/shared/sunadaptcontroller/SUNAdaptController_ImpGus.rst @@ -31,9 +31,8 @@ form \end{cases} with default parameter values :math:`k_1 = 0.98` and :math:`k_2 = 0.95`, and where -:math:`ord = p+1+adj`, where both :math:`p` and :math:`adj` are described below. In -this estimate, a floor of :math:`\varepsilon > 10^{-10}` is enforced to avoid -division-by-zero errors. +:math:`ord = p+1`, where :math:`p` is described below. In this estimate, a floor of +:math:`\varepsilon > 10^{-10}` is enforced to avoid division-by-zero errors. The SUNAdaptController_ImpGus controller is implemented as a derived SUNAdaptController class, and defines its *content* field as: @@ -47,7 +46,6 @@ and defines its *content* field as: sunrealtype ep; sunrealtype hp; int p; - int adj; sunbooleantype firststep; }; @@ -62,11 +60,7 @@ These entries of the *content* field contain the following information: * ``hp`` - storage for the previous step size, :math:`h_{n-1}`. -* ``p`` - asymptotic order to use in error control. This is provided by - the time integrator, corresponding to the order of accuracy for the time - integration method, the embedding, or the minimum of the two. - -* ``adj`` - order of accuracy adjustment to use within the controller [default ``-1``]. +* ``p`` - asymptotic order to use in error control (provided by the time integrator). * ``firststep`` - flag indicating whether any time steps have completed successfully (and thus to transition from :math:`h_1` to :math:`h_n` in diff --git a/doc/shared/sunadaptcontroller/SUNAdaptController_PI.rst b/doc/shared/sunadaptcontroller/SUNAdaptController_PI.rst index 773580ff91..791ab89b12 100644 --- a/doc/shared/sunadaptcontroller/SUNAdaptController_PI.rst +++ b/doc/shared/sunadaptcontroller/SUNAdaptController_PI.rst @@ -27,9 +27,8 @@ two most recent step sizes in its adaptivity algorithm, h' \;=\; h_n\; \varepsilon_n^{-k_1/ord}\; \varepsilon_{n-1}^{k_2/ord}. where the constants :math:`k_1` and :math:`k_2` default to 0.8 and 0.31, -respectively, and :math:`ord = p+1+adj`, where both :math:`p` and :math:`adj` are -described below. In this estimate, a floor of :math:`\varepsilon > 10^{-10}` is enforced to -avoid division-by-zero errors. +respectively, and :math:`ord = p+1`, where :math:`p` is described below. In this estimate, +a floor of :math:`\varepsilon > 10^{-10}` is enforced to avoid division-by-zero errors. This is implemented as a derived SUNAdaptController class, and defines its *content* field as: @@ -42,7 +41,6 @@ field as: sunrealtype bias; sunrealtype ep; int p; - int adj; }; These entries of the *content* field contain the following information: @@ -54,11 +52,7 @@ These entries of the *content* field contain the following information: * ``ep`` - storage for the previous error estimate, :math:`\varepsilon_{n-1}`. -* ``p`` - asymptotic order to use in error control. This is provided by - the time integrator, corresponding to the order of accuracy for the time - integration method, the embedding, or the minimum of the two. - -* ``adj`` - order of accuracy adjustment to use within the controller [default ``-1``]. +* ``p`` - asymptotic order to use in error control (provided by the time integrator). The header file to be included when using this module is diff --git a/doc/shared/sunadaptcontroller/SUNAdaptController_PID.rst b/doc/shared/sunadaptcontroller/SUNAdaptController_PID.rst index 961a1be9a4..298f93164b 100644 --- a/doc/shared/sunadaptcontroller/SUNAdaptController_PID.rst +++ b/doc/shared/sunadaptcontroller/SUNAdaptController_PID.rst @@ -29,9 +29,9 @@ prospective step size, \varepsilon_{n-2}^{-k_3/ord}, where the constants :math:`k_1`, :math:`k_2` and :math:`k_3` default to 0.58, -0.21 and 0.1, respectively, and :math:`ord = p+1+adj`, where both :math:`p` and :math:`adj` are -described below. In this estimate, a floor of :math:`\varepsilon > 10^{-10}` is enforced to -avoid division-by-zero errors. +0.21 and 0.1, respectively, and :math:`ord = p+1`, where :math:`p` is described below. +In this estimate, a floor of :math:`\varepsilon > 10^{-10}` is enforced to avoid +division-by-zero errors. This is implemented as a derived SUNAdaptController class, and defines its *content* field as: @@ -46,7 +46,6 @@ field as: sunrealtype ep; sunrealtype epp; int p; - int adj; }; These entries of the *content* field contain the following information: @@ -59,11 +58,7 @@ These entries of the *content* field contain the following information: * ``ep, epp`` - storage for the two previous error estimates, :math:`\varepsilon_{n-1}` and :math:`varepsilon_{n-2}`. -* ``p`` - asymptotic order to use in error control. This is provided by - the time integrator, corresponding to the order of accuracy for the time - integration method, the embedding, or the minimum of the two. - -* ``adj`` - order of accuracy adjustment to use within the controller [default ``-1``]. +* ``p`` - asymptotic order to use in error control (provided by the time integrator). The header file to be included when using this module is diff --git a/include/arkode/arkode_arkstep.h b/include/arkode/arkode_arkstep.h index 33f22cdc41..7c92a88a73 100644 --- a/include/arkode/arkode_arkstep.h +++ b/include/arkode/arkode_arkstep.h @@ -187,6 +187,7 @@ SUNDIALS_EXPORT int ARKStepSetTableNum(void *arkode_mem, 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, realtype cfl_frac); SUNDIALS_EXPORT int ARKStepSetSafetyFactor(void *arkode_mem, diff --git a/include/arkode/arkode_erkstep.h b/include/arkode/arkode_erkstep.h index ada9648a6a..4bcc37678b 100644 --- a/include/arkode/arkode_erkstep.h +++ b/include/arkode/arkode_erkstep.h @@ -118,6 +118,7 @@ SUNDIALS_EXPORT int ERKStepSetTable(void *arkode_mem, 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, realtype cfl_frac); SUNDIALS_EXPORT int ERKStepSetSafetyFactor(void *arkode_mem, diff --git a/include/sunadaptcontroller/sunadaptcontroller_expgus.h b/include/sunadaptcontroller/sunadaptcontroller_expgus.h index 324b9abf6a..a9ee827fd8 100644 --- a/include/sunadaptcontroller/sunadaptcontroller_expgus.h +++ b/include/sunadaptcontroller/sunadaptcontroller_expgus.h @@ -34,7 +34,6 @@ struct _SUNAdaptControllerContent_ExpGus { sunrealtype bias; /* error bias factor */ sunrealtype ep; /* error from previous step */ int p; /* method/embedding order of accuracy */ - int adj; /* order of accuracy adjustment to use for controller */ sunbooleantype firststep; /* flag indicating first step */ }; @@ -63,8 +62,6 @@ int SUNAdaptController_Write_ExpGus(SUNAdaptController C, FILE* fptr); SUNDIALS_EXPORT int SUNAdaptController_SetMethodOrder_ExpGus(SUNAdaptController C, int p); SUNDIALS_EXPORT -int SUNAdaptController_AdjustControllerOrder_ExpGus(SUNAdaptController C, int adj); -SUNDIALS_EXPORT int SUNAdaptController_SetErrorBias_ExpGus(SUNAdaptController C, sunrealtype bias); SUNDIALS_EXPORT int SUNAdaptController_Update_ExpGus(SUNAdaptController C, sunrealtype h, sunrealtype dsm); diff --git a/include/sunadaptcontroller/sunadaptcontroller_i.h b/include/sunadaptcontroller/sunadaptcontroller_i.h index 30488a892a..e4446c09ab 100644 --- a/include/sunadaptcontroller/sunadaptcontroller_i.h +++ b/include/sunadaptcontroller/sunadaptcontroller_i.h @@ -32,7 +32,6 @@ struct _SUNAdaptControllerContent_I { sunrealtype k1; /* internal controller parameters */ sunrealtype bias; /* error bias factor */ int p; /* method/embedding order of accuracy */ - int adj; /* order of accuracy adjustment to use for controller */ }; typedef struct _SUNAdaptControllerContent_I *SUNAdaptControllerContent_I; @@ -57,8 +56,6 @@ int SUNAdaptController_Write_I(SUNAdaptController C, FILE* fptr); SUNDIALS_EXPORT int SUNAdaptController_SetMethodOrder_I(SUNAdaptController C, int p); SUNDIALS_EXPORT -int SUNAdaptController_AdjustControllerOrder_I(SUNAdaptController C, int adj); -SUNDIALS_EXPORT int SUNAdaptController_SetErrorBias_I(SUNAdaptController C, sunrealtype bias); SUNDIALS_EXPORT int SUNAdaptController_Space_I(SUNAdaptController C, long int *lenrw, diff --git a/include/sunadaptcontroller/sunadaptcontroller_imexgus.h b/include/sunadaptcontroller/sunadaptcontroller_imexgus.h index 26121b2b76..322adc3c29 100644 --- a/include/sunadaptcontroller/sunadaptcontroller_imexgus.h +++ b/include/sunadaptcontroller/sunadaptcontroller_imexgus.h @@ -37,7 +37,6 @@ struct _SUNAdaptControllerContent_ImExGus { sunrealtype ep; /* error from previous step */ sunrealtype hp; /* previous step size */ int p; /* method/embedding order of accuracy */ - int adj; /* order of accuracy adjustment to use for controller */ sunbooleantype firststep; /* flag indicating first step */ }; @@ -67,8 +66,6 @@ int SUNAdaptController_Write_ImExGus(SUNAdaptController C, FILE* fptr); SUNDIALS_EXPORT int SUNAdaptController_SetMethodOrder_ImExGus(SUNAdaptController C, int p); SUNDIALS_EXPORT -int SUNAdaptController_AdjustControllerOrder_ImExGus(SUNAdaptController C, int adj); -SUNDIALS_EXPORT int SUNAdaptController_SetErrorBias_ImExGus(SUNAdaptController C, sunrealtype bias); SUNDIALS_EXPORT int SUNAdaptController_Update_ImExGus(SUNAdaptController C, sunrealtype h, sunrealtype dsm); diff --git a/include/sunadaptcontroller/sunadaptcontroller_impgus.h b/include/sunadaptcontroller/sunadaptcontroller_impgus.h index dc065ceb9d..21216145cd 100644 --- a/include/sunadaptcontroller/sunadaptcontroller_impgus.h +++ b/include/sunadaptcontroller/sunadaptcontroller_impgus.h @@ -35,7 +35,6 @@ struct _SUNAdaptControllerContent_ImpGus { sunrealtype ep; /* error from previous step */ sunrealtype hp; /* previous step size */ int p; /* method/embedding order of accuracy */ - int adj; /* order of accuracy adjustment to use for controller */ sunbooleantype firststep; /* flag indicating first step */ }; @@ -64,8 +63,6 @@ int SUNAdaptController_Write_ImpGus(SUNAdaptController C, FILE* fptr); SUNDIALS_EXPORT int SUNAdaptController_SetMethodOrder_ImpGus(SUNAdaptController C, int p); SUNDIALS_EXPORT -int SUNAdaptController_AdjustControllerOrder_ImpGus(SUNAdaptController C, int adj); -SUNDIALS_EXPORT int SUNAdaptController_SetErrorBias_ImpGus(SUNAdaptController C, sunrealtype bias); SUNDIALS_EXPORT int SUNAdaptController_Update_ImpGus(SUNAdaptController C, sunrealtype h, sunrealtype dsm); diff --git a/include/sunadaptcontroller/sunadaptcontroller_pi.h b/include/sunadaptcontroller/sunadaptcontroller_pi.h index 344db4c766..5c0d332988 100644 --- a/include/sunadaptcontroller/sunadaptcontroller_pi.h +++ b/include/sunadaptcontroller/sunadaptcontroller_pi.h @@ -34,7 +34,6 @@ struct _SUNAdaptControllerContent_PI { sunrealtype bias; /* error bias factor */ sunrealtype ep; /* error from previous step */ int p; /* method/embedding order of accuracy */ - int adj; /* order of accuracy adjustment to use for controller */ }; typedef struct _SUNAdaptControllerContent_PI *SUNAdaptControllerContent_PI; @@ -62,8 +61,6 @@ int SUNAdaptController_Write_PI(SUNAdaptController C, FILE* fptr); SUNDIALS_EXPORT int SUNAdaptController_SetMethodOrder_PI(SUNAdaptController C, int p); SUNDIALS_EXPORT -int SUNAdaptController_AdjustControllerOrder_PI(SUNAdaptController C, int adj); -SUNDIALS_EXPORT int SUNAdaptController_SetErrorBias_PI(SUNAdaptController C, sunrealtype bias); SUNDIALS_EXPORT int SUNAdaptController_Update_PI(SUNAdaptController C, sunrealtype h, sunrealtype dsm); diff --git a/include/sunadaptcontroller/sunadaptcontroller_pid.h b/include/sunadaptcontroller/sunadaptcontroller_pid.h index 5e8f0707c9..2e01264c43 100644 --- a/include/sunadaptcontroller/sunadaptcontroller_pid.h +++ b/include/sunadaptcontroller/sunadaptcontroller_pid.h @@ -36,7 +36,6 @@ struct _SUNAdaptControllerContent_PID { sunrealtype ep; /* error from previous step */ sunrealtype epp; /* error from 2 steps ago */ int p; /* method/embedding order of accuracy */ - int adj; /* order of accuracy adjustment to use for controller */ }; typedef struct _SUNAdaptControllerContent_PID *SUNAdaptControllerContent_PID; @@ -64,8 +63,6 @@ int SUNAdaptController_Write_PID(SUNAdaptController C, FILE* fptr); SUNDIALS_EXPORT int SUNAdaptController_SetMethodOrder_PID(SUNAdaptController C, int p); SUNDIALS_EXPORT -int SUNAdaptController_AdjustControllerOrder_PID(SUNAdaptController C, int adj); -SUNDIALS_EXPORT int SUNAdaptController_SetErrorBias_PID(SUNAdaptController C, sunrealtype bias); SUNDIALS_EXPORT int SUNAdaptController_Update_PID(SUNAdaptController C, sunrealtype h, sunrealtype dsm); diff --git a/include/sundials/sundials_adaptcontroller.h b/include/sundials/sundials_adaptcontroller.h index 6d94bdf191..11396e1b70 100644 --- a/include/sundials/sundials_adaptcontroller.h +++ b/include/sundials/sundials_adaptcontroller.h @@ -88,7 +88,6 @@ struct _generic_SUNAdaptController_Ops int (*setdefaults)(SUNAdaptController C); int (*write)(SUNAdaptController C, FILE* fptr); int (*setmethodorder)(SUNAdaptController C, int p); - int (*adjustcontrollerorder)(SUNAdaptController C, int adj); int (*seterrorbias)(SUNAdaptController C, sunrealtype bias); int (*update)(SUNAdaptController C, sunrealtype h, sunrealtype dsm); int (*updatemrih)(SUNAdaptController C, sunrealtype H, sunrealtype h, @@ -192,10 +191,6 @@ int SUNAdaptController_Write(SUNAdaptController C, FILE* fptr); SUNDIALS_EXPORT int SUNAdaptController_SetMethodOrder(SUNAdaptController C, int p); -/* Function to adjust the order of accuracy used within the controller. */ -SUNDIALS_EXPORT -int SUNAdaptController_AdjustControllerOrder(SUNAdaptController C, int adj); - /* Function to set an error bias factor to use for scaling the local error 'dsm' factors above. */ SUNDIALS_EXPORT diff --git a/src/arkode/arkode_adapt.c b/src/arkode/arkode_adapt.c index 68dfd57c78..e73437bd96 100644 --- a/src/arkode/arkode_adapt.c +++ b/src/arkode/arkode_adapt.c @@ -73,6 +73,7 @@ void arkPrintAdaptMem(ARKodeHAdaptMem hadapt_mem, FILE *outfile) fprintf(outfile, "ark_hadapt: pq = %i\n", hadapt_mem->pq); fprintf(outfile, "ark_hadapt: p = %i\n", hadapt_mem->p); fprintf(outfile, "ark_hadapt: q = %i\n", hadapt_mem->q); + fprintf(outfile, "ark_hadapt: adjust = %i\n", hadapt_mem->adjust); if (hadapt_mem->expstab == arkExpStab) { fprintf(outfile, " ark_hadapt: Default explicit stability function\n"); } else { diff --git a/src/arkode/arkode_adapt_impl.h b/src/arkode/arkode_adapt_impl.h index 2c26a957ce..fb0ce58912 100644 --- a/src/arkode/arkode_adapt_impl.h +++ b/src/arkode/arkode_adapt_impl.h @@ -54,6 +54,8 @@ extern "C" { #define PQ 0 /* order to use for controller: 0=embedding, 1=method, -1=min(method,embedding) REMOVE AT SAME TIME AS ARKStepSetAdaptivityMethod */ +#define ADJUST -1 /* adjustment to apply within controller to method + order of accuracy */ /*=============================================================== @@ -83,6 +85,7 @@ typedef struct ARKodeHAdaptMemRec { int p; /* embedding order */ int q; /* method order */ int pq; /* decision flag for controller order */ + int adjust; /* controller order adjustment factor */ SUNAdaptController hcontroller; /* temporal error controller */ booleantype owncontroller; /* flag indicating hcontroller ownership */ diff --git a/src/arkode/arkode_arkstep.c b/src/arkode/arkode_arkstep.c index fb0e6e8732..d7b9baf832 100644 --- a/src/arkode/arkode_arkstep.c +++ b/src/arkode/arkode_arkstep.c @@ -1141,11 +1141,11 @@ int arkStep_Init(void* arkode_mem, int init_type) step_mem->p = ark_mem->hadapt_mem->p = step_mem->Be->p; } if (ark_mem->hadapt_mem->pq == 0) { - controller_order = step_mem->p; + controller_order = step_mem->p + ark_mem->hadapt_mem->adjust; } else if (ark_mem->hadapt_mem->pq == 1) { - controller_order = step_mem->q; + controller_order = step_mem->q + ark_mem->hadapt_mem->adjust; } else { - controller_order = SUNMIN(step_mem->p, step_mem->q); + controller_order = SUNMIN(step_mem->p, step_mem->q) + ark_mem->hadapt_mem->adjust; } retval = SUNAdaptController_SetMethodOrder(ark_mem->hadapt_mem->hcontroller, controller_order); if (retval != SUNADAPTCONTROLLER_SUCCESS) { diff --git a/src/arkode/arkode_arkstep_io.c b/src/arkode/arkode_arkstep_io.c index 8edcacd6a2..5d41ba7a4e 100644 --- a/src/arkode/arkode_arkstep_io.c +++ b/src/arkode/arkode_arkstep_io.c @@ -77,6 +77,8 @@ int ARKStepSetPostprocessStepFn(void *arkode_mem, int ARKStepSetPostprocessStageFn(void *arkode_mem, ARKPostProcessFn ProcessStage) { return(arkSetPostprocessStageFn(arkode_mem, ProcessStage)); } +int ARKStepSetAdaptivityAdjustment(void *arkode_mem, int adjust) { + return(arkSetAdaptivityAdjustment(arkode_mem, adjust)); } int ARKStepSetCFLFraction(void *arkode_mem, realtype cfl_frac) { return(arkSetCFLFraction(arkode_mem, cfl_frac)); } int ARKStepSetSafetyFactor(void *arkode_mem, realtype safety) { diff --git a/src/arkode/arkode_erkstep.c b/src/arkode/arkode_erkstep.c index 9c4b65cdc7..caa72fd9e3 100644 --- a/src/arkode/arkode_erkstep.c +++ b/src/arkode/arkode_erkstep.c @@ -540,11 +540,11 @@ int erkStep_Init(void* arkode_mem, int init_type) step_mem->q = ark_mem->hadapt_mem->q = step_mem->B->q; step_mem->p = ark_mem->hadapt_mem->p = step_mem->B->p; if (ark_mem->hadapt_mem->pq == 0) { - controller_order = step_mem->p; + controller_order = step_mem->p + ark_mem->hadapt_mem->adjust; } else if (ark_mem->hadapt_mem->pq == 1) { - controller_order = step_mem->q; + controller_order = step_mem->q + ark_mem->hadapt_mem->adjust; } else { - controller_order = SUNMIN(step_mem->p, step_mem->q); + controller_order = SUNMIN(step_mem->p, step_mem->q) + ark_mem->hadapt_mem->adjust; } retval = SUNAdaptController_SetMethodOrder(ark_mem->hadapt_mem->hcontroller, controller_order); if (retval != SUNADAPTCONTROLLER_SUCCESS) { diff --git a/src/arkode/arkode_erkstep_io.c b/src/arkode/arkode_erkstep_io.c index ed9a9ccf9b..c0c5689db9 100644 --- a/src/arkode/arkode_erkstep_io.c +++ b/src/arkode/arkode_erkstep_io.c @@ -78,6 +78,8 @@ int ERKStepSetPostprocessStepFn(void *arkode_mem, int ERKStepSetPostprocessStageFn(void *arkode_mem, ARKPostProcessFn ProcessStage) { return(arkSetPostprocessStageFn(arkode_mem, ProcessStage)); } +int ERKStepSetAdaptivityAdjustment(void *arkode_mem, int adjust) { + return(arkSetAdaptivityAdjustment(arkode_mem, adjust)); } int ERKStepSetCFLFraction(void *arkode_mem, realtype cfl_frac) { return(arkSetCFLFraction(arkode_mem, cfl_frac)); } int ERKStepSetSafetyFactor(void *arkode_mem, realtype safety) { diff --git a/src/arkode/arkode_impl.h b/src/arkode/arkode_impl.h index df4ec49ee9..037c996d36 100644 --- a/src/arkode/arkode_impl.h +++ b/src/arkode/arkode_impl.h @@ -1009,6 +1009,7 @@ 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, realtype cfl_frac); int arkSetSafetyFactor(void *arkode_mem, realtype safety); int arkSetErrorBias(void *arkode_mem, realtype bias); diff --git a/src/arkode/arkode_io.c b/src/arkode/arkode_io.c index 363389be20..28a4f5c721 100644 --- a/src/arkode/arkode_io.c +++ b/src/arkode/arkode_io.c @@ -109,6 +109,7 @@ int arkSetDefaults(void *arkode_mem) ark_mem->hadapt_mem->pq = PQ; /* embedding order */ ark_mem->hadapt_mem->p = 0; /* no default embedding order */ ark_mem->hadapt_mem->q = 0; /* no default method order */ + ark_mem->hadapt_mem->adjust = ADJUST; /* controller order adjustment */ /* Set default values for controller object */ retval = SUNAdaptController_SetDefaults(ark_mem->hadapt_mem->hcontroller); @@ -1211,6 +1212,30 @@ int arkSetCFLFraction(void *arkode_mem, realtype cfl_frac) } +/*--------------------------------------------------------------- + arkSetAdaptivityAdjustment: + + 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 arkSetAdaptivityAdjustment(void *arkode_mem, int adjust) +{ + int retval; + ARKodeHAdaptMem hadapt_mem; + ARKodeMem ark_mem; + retval = arkAccessHAdaptMem(arkode_mem, "arkSetAdaptivityAdjustment", + &ark_mem, &hadapt_mem); + if (retval != ARK_SUCCESS) return(retval); + + /* store requested adjustment */ + hadapt_mem->adjust = adjust; + return(ARK_SUCCESS); +} + + /*--------------------------------------------------------------- arkSetSafetyFactor: diff --git a/src/arkode/fmod/farkode_arkstep_mod.c b/src/arkode/fmod/farkode_arkstep_mod.c index e8d6376eac..311cea273e 100644 --- a/src/arkode/fmod/farkode_arkstep_mod.c +++ b/src/arkode/fmod/farkode_arkstep_mod.c @@ -699,6 +699,20 @@ SWIGEXPORT int _wrap_FARKStepSetAdaptController(void *farg1, SUNAdaptController } +SWIGEXPORT int _wrap_FARKStepSetAdaptivityAdjustment(void *farg1, int const *farg2) { + int fresult ; + void *arg1 = (void *) 0 ; + int arg2 ; + int result; + + arg1 = (void *)(farg1); + arg2 = (int)(*farg2); + result = (int)ARKStepSetAdaptivityAdjustment(arg1,arg2); + fresult = (int)(result); + return fresult; +} + + SWIGEXPORT int _wrap_FARKStepSetCFLFraction(void *farg1, double const *farg2) { 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 04c72689b9..6388225f91 100644 --- a/src/arkode/fmod/farkode_arkstep_mod.f90 +++ b/src/arkode/fmod/farkode_arkstep_mod.f90 @@ -93,6 +93,7 @@ module farkode_arkstep_mod end type public :: FARKStepSetTableName public :: FARKStepSetAdaptController + public :: FARKStepSetAdaptivityAdjustment public :: FARKStepSetCFLFraction public :: FARKStepSetSafetyFactor public :: FARKStepSetErrorBias @@ -529,6 +530,15 @@ function swigc_FARKStepSetAdaptController(farg1, farg2) & integer(C_INT) :: fresult end function +function swigc_FARKStepSetAdaptivityAdjustment(farg1, farg2) & +bind(C, name="_wrap_FARKStepSetAdaptivityAdjustment") & +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_FARKStepSetCFLFraction(farg1, farg2) & bind(C, name="_wrap_FARKStepSetCFLFraction") & result(fresult) @@ -2372,6 +2382,22 @@ function FARKStepSetAdaptController(arkode_mem, c) & swig_result = fresult end function +function FARKStepSetAdaptivityAdjustment(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_FARKStepSetAdaptivityAdjustment(farg1, farg2) +swig_result = fresult +end function + function FARKStepSetCFLFraction(arkode_mem, cfl_frac) & 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 ab05b80df8..8a6be0ea0f 100644 --- a/src/arkode/fmod/farkode_erkstep_mod.c +++ b/src/arkode/fmod/farkode_erkstep_mod.c @@ -493,6 +493,20 @@ SWIGEXPORT int _wrap_FERKStepSetAdaptController(void *farg1, SUNAdaptController } +SWIGEXPORT int _wrap_FERKStepSetAdaptivityAdjustment(void *farg1, int const *farg2) { + int fresult ; + void *arg1 = (void *) 0 ; + int arg2 ; + int result; + + arg1 = (void *)(farg1); + arg2 = (int)(*farg2); + result = (int)ERKStepSetAdaptivityAdjustment(arg1,arg2); + fresult = (int)(result); + return fresult; +} + + SWIGEXPORT int _wrap_FERKStepSetCFLFraction(void *farg1, double const *farg2) { 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 208a84bdbc..168cfa5a87 100644 --- a/src/arkode/fmod/farkode_erkstep_mod.f90 +++ b/src/arkode/fmod/farkode_erkstep_mod.f90 @@ -67,6 +67,7 @@ module farkode_erkstep_mod end type public :: FERKStepSetTableName public :: FERKStepSetAdaptController + public :: FERKStepSetAdaptivityAdjustment public :: FERKStepSetCFLFraction public :: FERKStepSetSafetyFactor public :: FERKStepSetErrorBias @@ -311,6 +312,15 @@ function swigc_FERKStepSetAdaptController(farg1, farg2) & integer(C_INT) :: fresult end function +function swigc_FERKStepSetAdaptivityAdjustment(farg1, farg2) & +bind(C, name="_wrap_FERKStepSetAdaptivityAdjustment") & +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_FERKStepSetCFLFraction(farg1, farg2) & bind(C, name="_wrap_FERKStepSetCFLFraction") & result(fresult) @@ -1346,6 +1356,22 @@ function FERKStepSetAdaptController(arkode_mem, c) & swig_result = fresult end function +function FERKStepSetAdaptivityAdjustment(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_FERKStepSetAdaptivityAdjustment(farg1, farg2) +swig_result = fresult +end function + function FERKStepSetCFLFraction(arkode_mem, cfl_frac) & result(swig_result) use, intrinsic :: ISO_C_BINDING diff --git a/src/sunadaptcontroller/expgus/fmod/fsunadaptcontroller_expgus_mod.c b/src/sunadaptcontroller/expgus/fmod/fsunadaptcontroller_expgus_mod.c index ec975d5bc3..058558046e 100644 --- a/src/sunadaptcontroller/expgus/fmod/fsunadaptcontroller_expgus_mod.c +++ b/src/sunadaptcontroller/expgus/fmod/fsunadaptcontroller_expgus_mod.c @@ -318,20 +318,6 @@ SWIGEXPORT int _wrap_FSUNAdaptController_SetMethodOrder_ExpGus(SUNAdaptControlle } -SWIGEXPORT int _wrap_FSUNAdaptController_AdjustControllerOrder_ExpGus(SUNAdaptController farg1, int const *farg2) { - int fresult ; - SUNAdaptController arg1 = (SUNAdaptController) 0 ; - int arg2 ; - int result; - - arg1 = (SUNAdaptController)(farg1); - arg2 = (int)(*farg2); - result = (int)SUNAdaptController_AdjustControllerOrder_ExpGus(arg1,arg2); - fresult = (int)(result); - return fresult; -} - - SWIGEXPORT int _wrap_FSUNAdaptController_SetErrorBias_ExpGus(SUNAdaptController farg1, double const *farg2) { int fresult ; SUNAdaptController arg1 = (SUNAdaptController) 0 ; diff --git a/src/sunadaptcontroller/expgus/fmod/fsunadaptcontroller_expgus_mod.f90 b/src/sunadaptcontroller/expgus/fmod/fsunadaptcontroller_expgus_mod.f90 index 2a2c5433af..b81cba0632 100644 --- a/src/sunadaptcontroller/expgus/fmod/fsunadaptcontroller_expgus_mod.f90 +++ b/src/sunadaptcontroller/expgus/fmod/fsunadaptcontroller_expgus_mod.f90 @@ -35,7 +35,6 @@ module fsunadaptcontroller_expgus_mod public :: FSUNAdaptController_SetDefaults_ExpGus public :: FSUNAdaptController_Write_ExpGus public :: FSUNAdaptController_SetMethodOrder_ExpGus - public :: FSUNAdaptController_AdjustControllerOrder_ExpGus public :: FSUNAdaptController_SetErrorBias_ExpGus public :: FSUNAdaptController_Update_ExpGus public :: FSUNAdaptController_Space_ExpGus @@ -113,15 +112,6 @@ function swigc_FSUNAdaptController_SetMethodOrder_ExpGus(farg1, farg2) & integer(C_INT) :: fresult end function -function swigc_FSUNAdaptController_AdjustControllerOrder_ExpGus(farg1, farg2) & -bind(C, name="_wrap_FSUNAdaptController_AdjustControllerOrder_ExpGus") & -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_FSUNAdaptController_SetErrorBias_ExpGus(farg1, farg2) & bind(C, name="_wrap_FSUNAdaptController_SetErrorBias_ExpGus") & result(fresult) @@ -281,22 +271,6 @@ function FSUNAdaptController_SetMethodOrder_ExpGus(c, p) & swig_result = fresult end function -function FSUNAdaptController_AdjustControllerOrder_ExpGus(c, adj) & -result(swig_result) -use, intrinsic :: ISO_C_BINDING -integer(C_INT) :: swig_result -type(SUNAdaptController), target, intent(inout) :: c -integer(C_INT), intent(in) :: adj -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -integer(C_INT) :: farg2 - -farg1 = c_loc(c) -farg2 = adj -fresult = swigc_FSUNAdaptController_AdjustControllerOrder_ExpGus(farg1, farg2) -swig_result = fresult -end function - function FSUNAdaptController_SetErrorBias_ExpGus(c, bias) & result(swig_result) use, intrinsic :: ISO_C_BINDING diff --git a/src/sunadaptcontroller/expgus/sunadaptcontroller_expgus.c b/src/sunadaptcontroller/expgus/sunadaptcontroller_expgus.c index a51a272845..2cd711f12d 100644 --- a/src/sunadaptcontroller/expgus/sunadaptcontroller_expgus.c +++ b/src/sunadaptcontroller/expgus/sunadaptcontroller_expgus.c @@ -31,7 +31,6 @@ #define SACEXPGUS_BIAS(C) ( SACEXPGUS_CONTENT(C)->bias ) #define SACEXPGUS_EP(C) ( SACEXPGUS_CONTENT(C)->ep ) #define SACEXPGUS_P(C) ( SACEXPGUS_CONTENT(C)->p ) -#define SACEXPGUS_ADJ(C) ( SACEXPGUS_CONTENT(C)->adj ) #define SACEXPGUS_FIRSTSTEP(C) ( SACEXPGUS_CONTENT(C)->firststep ) /* ------------------ @@ -41,8 +40,6 @@ #define DEFAULT_K1 RCONST(0.367) #define DEFAULT_K2 RCONST(0.268) #define DEFAULT_BIAS RCONST(1.5) -#define DEFAULT_ADJ -1 -/* #define DEFAULT_ADJ 0 */ #define TINY RCONST(1.0e-10) @@ -65,16 +62,15 @@ SUNAdaptController SUNAdaptController_ExpGus(SUNContext sunctx) if (C == NULL) { return (NULL); } /* Attach operations */ - C->ops->gettype = SUNAdaptController_GetType_ExpGus; - C->ops->estimatestep = SUNAdaptController_EstimateStep_ExpGus; - C->ops->reset = SUNAdaptController_Reset_ExpGus; - C->ops->setdefaults = SUNAdaptController_SetDefaults_ExpGus; - C->ops->write = SUNAdaptController_Write_ExpGus; - C->ops->setmethodorder = SUNAdaptController_SetMethodOrder_ExpGus; - C->ops->adjustcontrollerorder = SUNAdaptController_AdjustControllerOrder_ExpGus; - C->ops->seterrorbias = SUNAdaptController_SetErrorBias_ExpGus; - C->ops->update = SUNAdaptController_Update_ExpGus; - C->ops->space = SUNAdaptController_Space_ExpGus; + C->ops->gettype = SUNAdaptController_GetType_ExpGus; + C->ops->estimatestep = SUNAdaptController_EstimateStep_ExpGus; + C->ops->reset = SUNAdaptController_Reset_ExpGus; + C->ops->setdefaults = SUNAdaptController_SetDefaults_ExpGus; + C->ops->write = SUNAdaptController_Write_ExpGus; + C->ops->setmethodorder = SUNAdaptController_SetMethodOrder_ExpGus; + C->ops->seterrorbias = SUNAdaptController_SetErrorBias_ExpGus; + C->ops->update = SUNAdaptController_Update_ExpGus; + C->ops->space = SUNAdaptController_Space_ExpGus; /* Create content */ content = NULL; @@ -124,7 +120,7 @@ int SUNAdaptController_EstimateStep_ExpGus(SUNAdaptController C, sunrealtype h, sunrealtype dsm, sunrealtype* hnew) { /* order parameter to use in controller */ - const int ord = SACEXPGUS_P(C) + SACEXPGUS_ADJ(C) + 1; + const int ord = SACEXPGUS_P(C) + 1; /* modified method for first step */ if (SACEXPGUS_FIRSTSTEP(C)) @@ -165,7 +161,6 @@ int SUNAdaptController_SetDefaults_ExpGus(SUNAdaptController C) SACEXPGUS_K1(C) = DEFAULT_K1; SACEXPGUS_K2(C) = DEFAULT_K2; SACEXPGUS_BIAS(C) = DEFAULT_BIAS; - SACEXPGUS_ADJ(C) = DEFAULT_ADJ; return SUNADAPTCONTROLLER_SUCCESS; } @@ -184,24 +179,17 @@ int SUNAdaptController_Write_ExpGus(SUNAdaptController C, FILE *fptr) fprintf(fptr, " previous error = %16g\n", SACEXPGUS_EP(C)); #endif fprintf(fptr, " p = %i\n", SACEXPGUS_P(C)); - fprintf(fptr, " adj = %i\n", SACEXPGUS_ADJ(C)); return SUNADAPTCONTROLLER_SUCCESS; } int SUNAdaptController_SetMethodOrder_ExpGus(SUNAdaptController C, int p) { /* check for legal inputs */ - if (p <= 0) { return SUNADAPTCONTROLLER_ILL_INPUT; } + if (p < 0) { return SUNADAPTCONTROLLER_ILL_INPUT; } SACEXPGUS_P(C) = p; return SUNADAPTCONTROLLER_SUCCESS; } -int SUNAdaptController_AdjustControllerOrder_ExpGus(SUNAdaptController C, int adj) -{ - SACEXPGUS_ADJ(C) = adj; - return SUNADAPTCONTROLLER_SUCCESS; -} - int SUNAdaptController_SetErrorBias_ExpGus(SUNAdaptController C, sunrealtype bias) { /* set allowed value, otherwise set default */ @@ -223,7 +211,7 @@ int SUNAdaptController_Update_ExpGus(SUNAdaptController C, sunrealtype h, sunrea int SUNAdaptController_Space_ExpGus(SUNAdaptController C, long int* lenrw, long int* leniw) { - *lenrw = 5; - *leniw = 4; + *lenrw = 4; + *leniw = 2; return SUNADAPTCONTROLLER_SUCCESS; } diff --git a/src/sunadaptcontroller/i/fmod/fsunadaptcontroller_i_mod.c b/src/sunadaptcontroller/i/fmod/fsunadaptcontroller_i_mod.c index 58f4da9061..c22e175cae 100644 --- a/src/sunadaptcontroller/i/fmod/fsunadaptcontroller_i_mod.c +++ b/src/sunadaptcontroller/i/fmod/fsunadaptcontroller_i_mod.c @@ -304,20 +304,6 @@ SWIGEXPORT int _wrap_FSUNAdaptController_SetMethodOrder_I(SUNAdaptController far } -SWIGEXPORT int _wrap_FSUNAdaptController_AdjustControllerOrder_I(SUNAdaptController farg1, int const *farg2) { - int fresult ; - SUNAdaptController arg1 = (SUNAdaptController) 0 ; - int arg2 ; - int result; - - arg1 = (SUNAdaptController)(farg1); - arg2 = (int)(*farg2); - result = (int)SUNAdaptController_AdjustControllerOrder_I(arg1,arg2); - fresult = (int)(result); - return fresult; -} - - SWIGEXPORT int _wrap_FSUNAdaptController_SetErrorBias_I(SUNAdaptController farg1, double const *farg2) { int fresult ; SUNAdaptController arg1 = (SUNAdaptController) 0 ; diff --git a/src/sunadaptcontroller/i/fmod/fsunadaptcontroller_i_mod.f90 b/src/sunadaptcontroller/i/fmod/fsunadaptcontroller_i_mod.f90 index a16c3513ff..eefe7f8281 100644 --- a/src/sunadaptcontroller/i/fmod/fsunadaptcontroller_i_mod.f90 +++ b/src/sunadaptcontroller/i/fmod/fsunadaptcontroller_i_mod.f90 @@ -34,7 +34,6 @@ module fsunadaptcontroller_i_mod public :: FSUNAdaptController_SetDefaults_I public :: FSUNAdaptController_Write_I public :: FSUNAdaptController_SetMethodOrder_I - public :: FSUNAdaptController_AdjustControllerOrder_I public :: FSUNAdaptController_SetErrorBias_I public :: FSUNAdaptController_Space_I @@ -102,15 +101,6 @@ function swigc_FSUNAdaptController_SetMethodOrder_I(farg1, farg2) & integer(C_INT) :: fresult end function -function swigc_FSUNAdaptController_AdjustControllerOrder_I(farg1, farg2) & -bind(C, name="_wrap_FSUNAdaptController_AdjustControllerOrder_I") & -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_FSUNAdaptController_SetErrorBias_I(farg1, farg2) & bind(C, name="_wrap_FSUNAdaptController_SetErrorBias_I") & result(fresult) @@ -244,22 +234,6 @@ function FSUNAdaptController_SetMethodOrder_I(c, p) & swig_result = fresult end function -function FSUNAdaptController_AdjustControllerOrder_I(c, adj) & -result(swig_result) -use, intrinsic :: ISO_C_BINDING -integer(C_INT) :: swig_result -type(SUNAdaptController), target, intent(inout) :: c -integer(C_INT), intent(in) :: adj -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -integer(C_INT) :: farg2 - -farg1 = c_loc(c) -farg2 = adj -fresult = swigc_FSUNAdaptController_AdjustControllerOrder_I(farg1, farg2) -swig_result = fresult -end function - function FSUNAdaptController_SetErrorBias_I(c, bias) & result(swig_result) use, intrinsic :: ISO_C_BINDING diff --git a/src/sunadaptcontroller/i/sunadaptcontroller_i.c b/src/sunadaptcontroller/i/sunadaptcontroller_i.c index 30ee6b0984..a7be43c228 100644 --- a/src/sunadaptcontroller/i/sunadaptcontroller_i.c +++ b/src/sunadaptcontroller/i/sunadaptcontroller_i.c @@ -29,7 +29,6 @@ #define SACI_K1(C) ( SACI_CONTENT(C)->k1 ) #define SACI_BIAS(C) ( SACI_CONTENT(C)->bias ) #define SACI_P(C) ( SACI_CONTENT(C)->p ) -#define SACI_ADJ(C) ( SACI_CONTENT(C)->adj ) /* ------------------ * Default parameters @@ -37,8 +36,6 @@ #define DEFAULT_K1 RCONST(1.0) #define DEFAULT_BIAS RCONST(1.5) -#define DEFAULT_ADJ -1 -/* #define DEFAULT_ADJ 0 */ #define TINY RCONST(1.0e-10) @@ -61,14 +58,13 @@ SUNAdaptController SUNAdaptController_I(SUNContext sunctx) if (C == NULL) { return (NULL); } /* Attach operations */ - C->ops->gettype = SUNAdaptController_GetType_I; - C->ops->estimatestep = SUNAdaptController_EstimateStep_I; - C->ops->setdefaults = SUNAdaptController_SetDefaults_I; - C->ops->write = SUNAdaptController_Write_I; - C->ops->setmethodorder = SUNAdaptController_SetMethodOrder_I; - C->ops->adjustcontrollerorder = SUNAdaptController_AdjustControllerOrder_I; - C->ops->seterrorbias = SUNAdaptController_SetErrorBias_I; - C->ops->space = SUNAdaptController_Space_I; + C->ops->gettype = SUNAdaptController_GetType_I; + C->ops->estimatestep = SUNAdaptController_EstimateStep_I; + C->ops->setdefaults = SUNAdaptController_SetDefaults_I; + C->ops->write = SUNAdaptController_Write_I; + C->ops->setmethodorder = SUNAdaptController_SetMethodOrder_I; + C->ops->seterrorbias = SUNAdaptController_SetErrorBias_I; + C->ops->space = SUNAdaptController_Space_I; /* Create content */ content = NULL; @@ -115,7 +111,7 @@ int SUNAdaptController_EstimateStep_I(SUNAdaptController C, sunrealtype h, sunrealtype dsm, sunrealtype* hnew) { /* set usable time-step adaptivity parameters */ - const int ord = SACI_P(C) + SACI_ADJ(C) + 1; + const int ord = SACI_P(C) + 1; const sunrealtype k1 = -SACI_K1(C) / ord; const sunrealtype ecur = SACI_BIAS(C) * dsm; const sunrealtype e1 = SUNMAX(ecur, TINY); @@ -129,7 +125,6 @@ int SUNAdaptController_SetDefaults_I(SUNAdaptController C) { SACI_K1(C) = DEFAULT_K1; SACI_BIAS(C) = DEFAULT_BIAS; - SACI_ADJ(C) = DEFAULT_ADJ; return SUNADAPTCONTROLLER_SUCCESS; } @@ -144,24 +139,17 @@ int SUNAdaptController_Write_I(SUNAdaptController C, FILE *fptr) fprintf(fptr, " bias factor = %16g\n", SACI_BIAS(C)); #endif fprintf(fptr, " p = %i\n", SACI_P(C)); - fprintf(fptr, " adj = %i\n", SACI_ADJ(C)); return SUNADAPTCONTROLLER_SUCCESS; } int SUNAdaptController_SetMethodOrder_I(SUNAdaptController C, int p) { /* check for legal inputs */ - if (p <= 0) { return SUNADAPTCONTROLLER_ILL_INPUT; } + if (p < 0) { return SUNADAPTCONTROLLER_ILL_INPUT; } SACI_P(C) = p; return SUNADAPTCONTROLLER_SUCCESS; } -int SUNAdaptController_AdjustControllerOrder_I(SUNAdaptController C, int adj) -{ - SACI_ADJ(C) = adj; - return SUNADAPTCONTROLLER_SUCCESS; -} - int SUNAdaptController_SetErrorBias_I(SUNAdaptController C, sunrealtype bias) { /* set allowed value, otherwise set default */ @@ -176,7 +164,7 @@ int SUNAdaptController_SetErrorBias_I(SUNAdaptController C, sunrealtype bias) int SUNAdaptController_Space_I(SUNAdaptController C, long int* lenrw, long int* leniw) { - *lenrw = 3; - *leniw = 3; + *lenrw = 2; + *leniw = 1; return SUNADAPTCONTROLLER_SUCCESS; } diff --git a/src/sunadaptcontroller/imexgus/fmod/fsunadaptcontroller_imexgus_mod.c b/src/sunadaptcontroller/imexgus/fmod/fsunadaptcontroller_imexgus_mod.c index 4b979b6575..2fc2dacb67 100644 --- a/src/sunadaptcontroller/imexgus/fmod/fsunadaptcontroller_imexgus_mod.c +++ b/src/sunadaptcontroller/imexgus/fmod/fsunadaptcontroller_imexgus_mod.c @@ -322,20 +322,6 @@ SWIGEXPORT int _wrap_FSUNAdaptController_SetMethodOrder_ImExGus(SUNAdaptControll } -SWIGEXPORT int _wrap_FSUNAdaptController_AdjustControllerOrder_ImExGus(SUNAdaptController farg1, int const *farg2) { - int fresult ; - SUNAdaptController arg1 = (SUNAdaptController) 0 ; - int arg2 ; - int result; - - arg1 = (SUNAdaptController)(farg1); - arg2 = (int)(*farg2); - result = (int)SUNAdaptController_AdjustControllerOrder_ImExGus(arg1,arg2); - fresult = (int)(result); - return fresult; -} - - SWIGEXPORT int _wrap_FSUNAdaptController_SetErrorBias_ImExGus(SUNAdaptController farg1, double const *farg2) { int fresult ; SUNAdaptController arg1 = (SUNAdaptController) 0 ; diff --git a/src/sunadaptcontroller/imexgus/fmod/fsunadaptcontroller_imexgus_mod.f90 b/src/sunadaptcontroller/imexgus/fmod/fsunadaptcontroller_imexgus_mod.f90 index a8c4b63280..06408a0e27 100644 --- a/src/sunadaptcontroller/imexgus/fmod/fsunadaptcontroller_imexgus_mod.f90 +++ b/src/sunadaptcontroller/imexgus/fmod/fsunadaptcontroller_imexgus_mod.f90 @@ -35,7 +35,6 @@ module fsunadaptcontroller_imexgus_mod public :: FSUNAdaptController_SetDefaults_ImExGus public :: FSUNAdaptController_Write_ImExGus public :: FSUNAdaptController_SetMethodOrder_ImExGus - public :: FSUNAdaptController_AdjustControllerOrder_ImExGus public :: FSUNAdaptController_SetErrorBias_ImExGus public :: FSUNAdaptController_Update_ImExGus public :: FSUNAdaptController_Space_ImExGus @@ -115,15 +114,6 @@ function swigc_FSUNAdaptController_SetMethodOrder_ImExGus(farg1, farg2) & integer(C_INT) :: fresult end function -function swigc_FSUNAdaptController_AdjustControllerOrder_ImExGus(farg1, farg2) & -bind(C, name="_wrap_FSUNAdaptController_AdjustControllerOrder_ImExGus") & -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_FSUNAdaptController_SetErrorBias_ImExGus(farg1, farg2) & bind(C, name="_wrap_FSUNAdaptController_SetErrorBias_ImExGus") & result(fresult) @@ -289,22 +279,6 @@ function FSUNAdaptController_SetMethodOrder_ImExGus(c, p) & swig_result = fresult end function -function FSUNAdaptController_AdjustControllerOrder_ImExGus(c, adj) & -result(swig_result) -use, intrinsic :: ISO_C_BINDING -integer(C_INT) :: swig_result -type(SUNAdaptController), target, intent(inout) :: c -integer(C_INT), intent(in) :: adj -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -integer(C_INT) :: farg2 - -farg1 = c_loc(c) -farg2 = adj -fresult = swigc_FSUNAdaptController_AdjustControllerOrder_ImExGus(farg1, farg2) -swig_result = fresult -end function - function FSUNAdaptController_SetErrorBias_ImExGus(c, bias) & result(swig_result) use, intrinsic :: ISO_C_BINDING diff --git a/src/sunadaptcontroller/imexgus/sunadaptcontroller_imexgus.c b/src/sunadaptcontroller/imexgus/sunadaptcontroller_imexgus.c index e67ceaa994..4933601d34 100644 --- a/src/sunadaptcontroller/imexgus/sunadaptcontroller_imexgus.c +++ b/src/sunadaptcontroller/imexgus/sunadaptcontroller_imexgus.c @@ -34,7 +34,6 @@ #define SACIMEXGUS_EP(C) ( SACIMEXGUS_CONTENT(C)->ep ) #define SACIMEXGUS_HP(C) ( SACIMEXGUS_CONTENT(C)->hp ) #define SACIMEXGUS_P(C) ( SACIMEXGUS_CONTENT(C)->p ) -#define SACIMEXGUS_ADJ(C) ( SACIMEXGUS_CONTENT(C)->adj ) #define SACIMEXGUS_FIRSTSTEP(C) ( SACIMEXGUS_CONTENT(C)->firststep ) /* ------------------ @@ -46,8 +45,6 @@ #define DEFAULT_K1I RCONST(0.95) #define DEFAULT_K2I RCONST(0.95) #define DEFAULT_BIAS RCONST(1.5) -#define DEFAULT_ADJ -1 -/* #define DEFAULT_ADJ 0 */ #define TINY RCONST(1.0e-10) @@ -70,16 +67,15 @@ SUNAdaptController SUNAdaptController_ImExGus(SUNContext sunctx) if (C == NULL) { return (NULL); } /* Attach operations */ - C->ops->gettype = SUNAdaptController_GetType_ImExGus; - C->ops->estimatestep = SUNAdaptController_EstimateStep_ImExGus; - C->ops->reset = SUNAdaptController_Reset_ImExGus; - C->ops->setdefaults = SUNAdaptController_SetDefaults_ImExGus; - C->ops->write = SUNAdaptController_Write_ImExGus; - C->ops->setmethodorder = SUNAdaptController_SetMethodOrder_ImExGus; - C->ops->adjustcontrollerorder = SUNAdaptController_AdjustControllerOrder_ImExGus; - C->ops->seterrorbias = SUNAdaptController_SetErrorBias_ImExGus; - C->ops->update = SUNAdaptController_Update_ImExGus; - C->ops->space = SUNAdaptController_Space_ImExGus; + C->ops->gettype = SUNAdaptController_GetType_ImExGus; + C->ops->estimatestep = SUNAdaptController_EstimateStep_ImExGus; + C->ops->reset = SUNAdaptController_Reset_ImExGus; + C->ops->setdefaults = SUNAdaptController_SetDefaults_ImExGus; + C->ops->write = SUNAdaptController_Write_ImExGus; + C->ops->setmethodorder = SUNAdaptController_SetMethodOrder_ImExGus; + C->ops->seterrorbias = SUNAdaptController_SetErrorBias_ImExGus; + C->ops->update = SUNAdaptController_Update_ImExGus; + C->ops->space = SUNAdaptController_Space_ImExGus; /* Create content */ content = NULL; @@ -132,7 +128,7 @@ int SUNAdaptController_EstimateStep_ImExGus(SUNAdaptController C, sunrealtype h, sunrealtype dsm, sunrealtype* hnew) { /* order parameter to use */ - const int ord = SACIMEXGUS_P(C) + SACIMEXGUS_ADJ(C) + 1; + const int ord = SACIMEXGUS_P(C) + 1; /* modified method for first step */ if (SACIMEXGUS_FIRSTSTEP(C)) @@ -178,7 +174,6 @@ int SUNAdaptController_SetDefaults_ImExGus(SUNAdaptController C) SACIMEXGUS_K1I(C) = DEFAULT_K1I; SACIMEXGUS_K2I(C) = DEFAULT_K2I; SACIMEXGUS_BIAS(C) = DEFAULT_BIAS; - SACIMEXGUS_ADJ(C) = DEFAULT_ADJ; return SUNADAPTCONTROLLER_SUCCESS; } @@ -203,24 +198,17 @@ int SUNAdaptController_Write_ImExGus(SUNAdaptController C, FILE *fptr) fprintf(fptr, " previous step = %16g\n", SACIMEXGUS_HP(C)); #endif fprintf(fptr, " p = %i\n", SACIMEXGUS_P(C)); - fprintf(fptr, " adj = %i\n", SACIMEXGUS_ADJ(C)); return SUNADAPTCONTROLLER_SUCCESS; } int SUNAdaptController_SetMethodOrder_ImExGus(SUNAdaptController C, int p) { /* check for legal inputs */ - if (p <= 0) { return SUNADAPTCONTROLLER_ILL_INPUT; } + if (p < 0) { return SUNADAPTCONTROLLER_ILL_INPUT; } SACIMEXGUS_P(C) = p; return SUNADAPTCONTROLLER_SUCCESS; } -int SUNAdaptController_AdjustControllerOrder_ImExGus(SUNAdaptController C, int adj) -{ - SACIMEXGUS_ADJ(C) = adj; - return SUNADAPTCONTROLLER_SUCCESS; -} - int SUNAdaptController_SetErrorBias_ImExGus(SUNAdaptController C, sunrealtype bias) { /* set allowed value, otherwise set default */ @@ -243,7 +231,7 @@ int SUNAdaptController_Update_ImExGus(SUNAdaptController C, sunrealtype h, sunre int SUNAdaptController_Space_ImExGus(SUNAdaptController C, long int* lenrw, long int* leniw) { - *lenrw = 8; - *leniw = 4; + *lenrw = 7; + *leniw = 2; return SUNADAPTCONTROLLER_SUCCESS; } diff --git a/src/sunadaptcontroller/impgus/fmod/fsunadaptcontroller_impgus_mod.c b/src/sunadaptcontroller/impgus/fmod/fsunadaptcontroller_impgus_mod.c index 0166d77a00..c94dfa1010 100644 --- a/src/sunadaptcontroller/impgus/fmod/fsunadaptcontroller_impgus_mod.c +++ b/src/sunadaptcontroller/impgus/fmod/fsunadaptcontroller_impgus_mod.c @@ -318,20 +318,6 @@ SWIGEXPORT int _wrap_FSUNAdaptController_SetMethodOrder_ImpGus(SUNAdaptControlle } -SWIGEXPORT int _wrap_FSUNAdaptController_AdjustControllerOrder_ImpGus(SUNAdaptController farg1, int const *farg2) { - int fresult ; - SUNAdaptController arg1 = (SUNAdaptController) 0 ; - int arg2 ; - int result; - - arg1 = (SUNAdaptController)(farg1); - arg2 = (int)(*farg2); - result = (int)SUNAdaptController_AdjustControllerOrder_ImpGus(arg1,arg2); - fresult = (int)(result); - return fresult; -} - - SWIGEXPORT int _wrap_FSUNAdaptController_SetErrorBias_ImpGus(SUNAdaptController farg1, double const *farg2) { int fresult ; SUNAdaptController arg1 = (SUNAdaptController) 0 ; diff --git a/src/sunadaptcontroller/impgus/fmod/fsunadaptcontroller_impgus_mod.f90 b/src/sunadaptcontroller/impgus/fmod/fsunadaptcontroller_impgus_mod.f90 index 3123b96a0b..3ebf8ab8ff 100644 --- a/src/sunadaptcontroller/impgus/fmod/fsunadaptcontroller_impgus_mod.f90 +++ b/src/sunadaptcontroller/impgus/fmod/fsunadaptcontroller_impgus_mod.f90 @@ -35,7 +35,6 @@ module fsunadaptcontroller_impgus_mod public :: FSUNAdaptController_SetDefaults_ImpGus public :: FSUNAdaptController_Write_ImpGus public :: FSUNAdaptController_SetMethodOrder_ImpGus - public :: FSUNAdaptController_AdjustControllerOrder_ImpGus public :: FSUNAdaptController_SetErrorBias_ImpGus public :: FSUNAdaptController_Update_ImpGus public :: FSUNAdaptController_Space_ImpGus @@ -113,15 +112,6 @@ function swigc_FSUNAdaptController_SetMethodOrder_ImpGus(farg1, farg2) & integer(C_INT) :: fresult end function -function swigc_FSUNAdaptController_AdjustControllerOrder_ImpGus(farg1, farg2) & -bind(C, name="_wrap_FSUNAdaptController_AdjustControllerOrder_ImpGus") & -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_FSUNAdaptController_SetErrorBias_ImpGus(farg1, farg2) & bind(C, name="_wrap_FSUNAdaptController_SetErrorBias_ImpGus") & result(fresult) @@ -281,22 +271,6 @@ function FSUNAdaptController_SetMethodOrder_ImpGus(c, p) & swig_result = fresult end function -function FSUNAdaptController_AdjustControllerOrder_ImpGus(c, adj) & -result(swig_result) -use, intrinsic :: ISO_C_BINDING -integer(C_INT) :: swig_result -type(SUNAdaptController), target, intent(inout) :: c -integer(C_INT), intent(in) :: adj -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -integer(C_INT) :: farg2 - -farg1 = c_loc(c) -farg2 = adj -fresult = swigc_FSUNAdaptController_AdjustControllerOrder_ImpGus(farg1, farg2) -swig_result = fresult -end function - function FSUNAdaptController_SetErrorBias_ImpGus(c, bias) & result(swig_result) use, intrinsic :: ISO_C_BINDING diff --git a/src/sunadaptcontroller/impgus/sunadaptcontroller_impgus.c b/src/sunadaptcontroller/impgus/sunadaptcontroller_impgus.c index bf4138eaad..8a59c2abab 100644 --- a/src/sunadaptcontroller/impgus/sunadaptcontroller_impgus.c +++ b/src/sunadaptcontroller/impgus/sunadaptcontroller_impgus.c @@ -32,7 +32,6 @@ #define SACIMPGUS_EP(C) ( SACIMPGUS_CONTENT(C)->ep ) #define SACIMPGUS_HP(C) ( SACIMPGUS_CONTENT(C)->hp ) #define SACIMPGUS_P(C) ( SACIMPGUS_CONTENT(C)->p ) -#define SACIMPGUS_ADJ(C) ( SACIMPGUS_CONTENT(C)->adj ) #define SACIMPGUS_FIRSTSTEP(C) ( SACIMPGUS_CONTENT(C)->firststep ) /* ------------------ @@ -42,8 +41,6 @@ #define DEFAULT_K1 RCONST(0.98) #define DEFAULT_K2 RCONST(0.95) #define DEFAULT_BIAS RCONST(1.5) -#define DEFAULT_ADJ -1 -/* #define DEFAULT_ADJ 0 */ #define TINY RCONST(1.0e-10) @@ -66,16 +63,15 @@ SUNAdaptController SUNAdaptController_ImpGus(SUNContext sunctx) if (C == NULL) { return (NULL); } /* Attach operations */ - C->ops->gettype = SUNAdaptController_GetType_ImpGus; - C->ops->estimatestep = SUNAdaptController_EstimateStep_ImpGus; - C->ops->reset = SUNAdaptController_Reset_ImpGus; - C->ops->setdefaults = SUNAdaptController_SetDefaults_ImpGus; - C->ops->write = SUNAdaptController_Write_ImpGus; - C->ops->setmethodorder = SUNAdaptController_SetMethodOrder_ImpGus; - C->ops->adjustcontrollerorder = SUNAdaptController_AdjustControllerOrder_ImpGus; - C->ops->seterrorbias = SUNAdaptController_SetErrorBias_ImpGus; - C->ops->update = SUNAdaptController_Update_ImpGus; - C->ops->space = SUNAdaptController_Space_ImpGus; + C->ops->gettype = SUNAdaptController_GetType_ImpGus; + C->ops->estimatestep = SUNAdaptController_EstimateStep_ImpGus; + C->ops->reset = SUNAdaptController_Reset_ImpGus; + C->ops->setdefaults = SUNAdaptController_SetDefaults_ImpGus; + C->ops->write = SUNAdaptController_Write_ImpGus; + C->ops->setmethodorder = SUNAdaptController_SetMethodOrder_ImpGus; + C->ops->seterrorbias = SUNAdaptController_SetErrorBias_ImpGus; + C->ops->update = SUNAdaptController_Update_ImpGus; + C->ops->space = SUNAdaptController_Space_ImpGus; /* Create content */ content = NULL; @@ -125,7 +121,7 @@ int SUNAdaptController_EstimateStep_ImpGus(SUNAdaptController C, sunrealtype h, sunrealtype dsm, sunrealtype* hnew) { /* order parameter to use */ - const int ord = SACIMPGUS_P(C) + SACIMPGUS_ADJ(C) + 1; + const int ord = SACIMPGUS_P(C) + 1; /* modified method for first step */ if (SACIMPGUS_FIRSTSTEP(C)) @@ -164,10 +160,9 @@ int SUNAdaptController_Reset_ImpGus(SUNAdaptController C) int SUNAdaptController_SetDefaults_ImpGus(SUNAdaptController C) { - SACIMPGUS_K1(C) = DEFAULT_K1; - SACIMPGUS_K2(C) = DEFAULT_K2; - SACIMPGUS_BIAS(C) = DEFAULT_BIAS; - SACIMPGUS_ADJ(C) = DEFAULT_ADJ; + SACIMPGUS_K1(C) = DEFAULT_K1; + SACIMPGUS_K2(C) = DEFAULT_K2; + SACIMPGUS_BIAS(C) = DEFAULT_BIAS; return SUNADAPTCONTROLLER_SUCCESS; } @@ -194,17 +189,11 @@ int SUNAdaptController_Write_ImpGus(SUNAdaptController C, FILE *fptr) int SUNAdaptController_SetMethodOrder_ImpGus(SUNAdaptController C, int p) { /* check for legal inputs */ - if (p <= 0) { return SUNADAPTCONTROLLER_ILL_INPUT; } + if (p < 0) { return SUNADAPTCONTROLLER_ILL_INPUT; } SACIMPGUS_P(C) = p; return SUNADAPTCONTROLLER_SUCCESS; } -int SUNAdaptController_AdjustControllerOrder_ImpGus(SUNAdaptController C, int adj) -{ - SACIMPGUS_ADJ(C) = adj; - return SUNADAPTCONTROLLER_SUCCESS; -} - int SUNAdaptController_SetErrorBias_ImpGus(SUNAdaptController C, sunrealtype bias) { /* set allowed value, otherwise set default */ @@ -227,7 +216,7 @@ int SUNAdaptController_Update_ImpGus(SUNAdaptController C, sunrealtype h, sunrea int SUNAdaptController_Space_ImpGus(SUNAdaptController C, long int* lenrw, long int* leniw) { - *lenrw = 6; - *leniw = 4; + *lenrw = 5; + *leniw = 2; return SUNADAPTCONTROLLER_SUCCESS; } diff --git a/src/sunadaptcontroller/pi/fmod/fsunadaptcontroller_pi_mod.c b/src/sunadaptcontroller/pi/fmod/fsunadaptcontroller_pi_mod.c index eb66617d8d..c0381f7594 100644 --- a/src/sunadaptcontroller/pi/fmod/fsunadaptcontroller_pi_mod.c +++ b/src/sunadaptcontroller/pi/fmod/fsunadaptcontroller_pi_mod.c @@ -318,20 +318,6 @@ SWIGEXPORT int _wrap_FSUNAdaptController_SetMethodOrder_PI(SUNAdaptController fa } -SWIGEXPORT int _wrap_FSUNAdaptController_AdjustControllerOrder_PI(SUNAdaptController farg1, int const *farg2) { - int fresult ; - SUNAdaptController arg1 = (SUNAdaptController) 0 ; - int arg2 ; - int result; - - arg1 = (SUNAdaptController)(farg1); - arg2 = (int)(*farg2); - result = (int)SUNAdaptController_AdjustControllerOrder_PI(arg1,arg2); - fresult = (int)(result); - return fresult; -} - - SWIGEXPORT int _wrap_FSUNAdaptController_SetErrorBias_PI(SUNAdaptController farg1, double const *farg2) { int fresult ; SUNAdaptController arg1 = (SUNAdaptController) 0 ; diff --git a/src/sunadaptcontroller/pi/fmod/fsunadaptcontroller_pi_mod.f90 b/src/sunadaptcontroller/pi/fmod/fsunadaptcontroller_pi_mod.f90 index 69f81b629e..dce45abb0d 100644 --- a/src/sunadaptcontroller/pi/fmod/fsunadaptcontroller_pi_mod.f90 +++ b/src/sunadaptcontroller/pi/fmod/fsunadaptcontroller_pi_mod.f90 @@ -35,7 +35,6 @@ module fsunadaptcontroller_pi_mod public :: FSUNAdaptController_SetDefaults_PI public :: FSUNAdaptController_Write_PI public :: FSUNAdaptController_SetMethodOrder_PI - public :: FSUNAdaptController_AdjustControllerOrder_PI public :: FSUNAdaptController_SetErrorBias_PI public :: FSUNAdaptController_Update_PI public :: FSUNAdaptController_Space_PI @@ -113,15 +112,6 @@ function swigc_FSUNAdaptController_SetMethodOrder_PI(farg1, farg2) & integer(C_INT) :: fresult end function -function swigc_FSUNAdaptController_AdjustControllerOrder_PI(farg1, farg2) & -bind(C, name="_wrap_FSUNAdaptController_AdjustControllerOrder_PI") & -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_FSUNAdaptController_SetErrorBias_PI(farg1, farg2) & bind(C, name="_wrap_FSUNAdaptController_SetErrorBias_PI") & result(fresult) @@ -281,22 +271,6 @@ function FSUNAdaptController_SetMethodOrder_PI(c, p) & swig_result = fresult end function -function FSUNAdaptController_AdjustControllerOrder_PI(c, adj) & -result(swig_result) -use, intrinsic :: ISO_C_BINDING -integer(C_INT) :: swig_result -type(SUNAdaptController), target, intent(inout) :: c -integer(C_INT), intent(in) :: adj -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -integer(C_INT) :: farg2 - -farg1 = c_loc(c) -farg2 = adj -fresult = swigc_FSUNAdaptController_AdjustControllerOrder_PI(farg1, farg2) -swig_result = fresult -end function - function FSUNAdaptController_SetErrorBias_PI(c, bias) & result(swig_result) use, intrinsic :: ISO_C_BINDING diff --git a/src/sunadaptcontroller/pi/sunadaptcontroller_pi.c b/src/sunadaptcontroller/pi/sunadaptcontroller_pi.c index 34b61d1593..29c700df15 100644 --- a/src/sunadaptcontroller/pi/sunadaptcontroller_pi.c +++ b/src/sunadaptcontroller/pi/sunadaptcontroller_pi.c @@ -31,7 +31,6 @@ #define SACPI_BIAS(C) ( SACPI_CONTENT(C)->bias ) #define SACPI_EP(C) ( SACPI_CONTENT(C)->ep ) #define SACPI_P(C) ( SACPI_CONTENT(C)->p ) -#define SACPI_ADJ(C) ( SACPI_CONTENT(C)->adj ) /* ------------------ * Default parameters @@ -40,8 +39,6 @@ #define DEFAULT_K1 RCONST(0.8) #define DEFAULT_K2 RCONST(0.31) #define DEFAULT_BIAS RCONST(1.5) -#define DEFAULT_ADJ -1 -/* #define DEFAULT_ADJ 0 */ #define TINY RCONST(1.0e-10) @@ -64,16 +61,15 @@ SUNAdaptController SUNAdaptController_PI(SUNContext sunctx) if (C == NULL) { return (NULL); } /* Attach operations */ - C->ops->gettype = SUNAdaptController_GetType_PI; - C->ops->estimatestep = SUNAdaptController_EstimateStep_PI; - C->ops->reset = SUNAdaptController_Reset_PI; - C->ops->setdefaults = SUNAdaptController_SetDefaults_PI; - C->ops->write = SUNAdaptController_Write_PI; - C->ops->setmethodorder = SUNAdaptController_SetMethodOrder_PI; - C->ops->adjustcontrollerorder = SUNAdaptController_AdjustControllerOrder_PI; - C->ops->seterrorbias = SUNAdaptController_SetErrorBias_PI; - C->ops->update = SUNAdaptController_Update_PI; - C->ops->space = SUNAdaptController_Space_PI; + C->ops->gettype = SUNAdaptController_GetType_PI; + C->ops->estimatestep = SUNAdaptController_EstimateStep_PI; + C->ops->reset = SUNAdaptController_Reset_PI; + C->ops->setdefaults = SUNAdaptController_SetDefaults_PI; + C->ops->write = SUNAdaptController_Write_PI; + C->ops->setmethodorder = SUNAdaptController_SetMethodOrder_PI; + C->ops->seterrorbias = SUNAdaptController_SetErrorBias_PI; + C->ops->update = SUNAdaptController_Update_PI; + C->ops->space = SUNAdaptController_Space_PI; /* Create content */ content = NULL; @@ -122,7 +118,7 @@ int SUNAdaptController_EstimateStep_PI(SUNAdaptController C, sunrealtype h, sunrealtype dsm, sunrealtype* hnew) { /* set usable time-step adaptivity parameters */ - const int ord = SACPI_P(C) + SACPI_ADJ(C) + 1; + const int ord = SACPI_P(C) + 1; const sunrealtype k1 = -SACPI_K1(C) / ord; const sunrealtype k2 = SACPI_K2(C) / ord; const sunrealtype ecur = SACPI_BIAS(C) * dsm; @@ -145,7 +141,6 @@ int SUNAdaptController_SetDefaults_PI(SUNAdaptController C) SACPI_K1(C) = DEFAULT_K1; SACPI_K2(C) = DEFAULT_K2; SACPI_BIAS(C) = DEFAULT_BIAS; - SACPI_ADJ(C) = DEFAULT_ADJ; return SUNADAPTCONTROLLER_SUCCESS; } @@ -164,24 +159,17 @@ int SUNAdaptController_Write_PI(SUNAdaptController C, FILE *fptr) fprintf(fptr, " previous error = %16g\n", SACPI_EP(C)); #endif fprintf(fptr, " p = %i\n", SACPI_P(C)); - fprintf(fptr, " adj = %i\n", SACPI_ADJ(C)); return SUNADAPTCONTROLLER_SUCCESS; } int SUNAdaptController_SetMethodOrder_PI(SUNAdaptController C, int p) { /* check for legal inputs */ - if (p <= 0) { return SUNADAPTCONTROLLER_ILL_INPUT; } + if (p < 0) { return SUNADAPTCONTROLLER_ILL_INPUT; } SACPI_P(C) = p; return SUNADAPTCONTROLLER_SUCCESS; } -int SUNAdaptController_AdjustControllerOrder_PI(SUNAdaptController C, int adj) -{ - SACPI_ADJ(C) = adj; - return SUNADAPTCONTROLLER_SUCCESS; -} - int SUNAdaptController_SetErrorBias_PI(SUNAdaptController C, sunrealtype bias) { /* set allowed value, otherwise set default */ @@ -202,7 +190,7 @@ int SUNAdaptController_Update_PI(SUNAdaptController C, sunrealtype h, sunrealtyp int SUNAdaptController_Space_PI(SUNAdaptController C, long int* lenrw, long int* leniw) { - *lenrw = 5; - *leniw = 3; + *lenrw = 4; + *leniw = 1; return SUNADAPTCONTROLLER_SUCCESS; } diff --git a/src/sunadaptcontroller/pid/fmod/fsunadaptcontroller_pid_mod.c b/src/sunadaptcontroller/pid/fmod/fsunadaptcontroller_pid_mod.c index 7459c96d63..c7c88b0477 100644 --- a/src/sunadaptcontroller/pid/fmod/fsunadaptcontroller_pid_mod.c +++ b/src/sunadaptcontroller/pid/fmod/fsunadaptcontroller_pid_mod.c @@ -320,20 +320,6 @@ SWIGEXPORT int _wrap_FSUNAdaptController_SetMethodOrder_PID(SUNAdaptController f } -SWIGEXPORT int _wrap_FSUNAdaptController_AdjustControllerOrder_PID(SUNAdaptController farg1, int const *farg2) { - int fresult ; - SUNAdaptController arg1 = (SUNAdaptController) 0 ; - int arg2 ; - int result; - - arg1 = (SUNAdaptController)(farg1); - arg2 = (int)(*farg2); - result = (int)SUNAdaptController_AdjustControllerOrder_PID(arg1,arg2); - fresult = (int)(result); - return fresult; -} - - SWIGEXPORT int _wrap_FSUNAdaptController_SetErrorBias_PID(SUNAdaptController farg1, double const *farg2) { int fresult ; SUNAdaptController arg1 = (SUNAdaptController) 0 ; diff --git a/src/sunadaptcontroller/pid/fmod/fsunadaptcontroller_pid_mod.f90 b/src/sunadaptcontroller/pid/fmod/fsunadaptcontroller_pid_mod.f90 index 24ec52a76d..0831ea8644 100644 --- a/src/sunadaptcontroller/pid/fmod/fsunadaptcontroller_pid_mod.f90 +++ b/src/sunadaptcontroller/pid/fmod/fsunadaptcontroller_pid_mod.f90 @@ -35,7 +35,6 @@ module fsunadaptcontroller_pid_mod public :: FSUNAdaptController_SetDefaults_PID public :: FSUNAdaptController_Write_PID public :: FSUNAdaptController_SetMethodOrder_PID - public :: FSUNAdaptController_AdjustControllerOrder_PID public :: FSUNAdaptController_SetErrorBias_PID public :: FSUNAdaptController_Update_PID public :: FSUNAdaptController_Space_PID @@ -114,15 +113,6 @@ function swigc_FSUNAdaptController_SetMethodOrder_PID(farg1, farg2) & integer(C_INT) :: fresult end function -function swigc_FSUNAdaptController_AdjustControllerOrder_PID(farg1, farg2) & -bind(C, name="_wrap_FSUNAdaptController_AdjustControllerOrder_PID") & -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_FSUNAdaptController_SetErrorBias_PID(farg1, farg2) & bind(C, name="_wrap_FSUNAdaptController_SetErrorBias_PID") & result(fresult) @@ -285,22 +275,6 @@ function FSUNAdaptController_SetMethodOrder_PID(c, p) & swig_result = fresult end function -function FSUNAdaptController_AdjustControllerOrder_PID(c, adj) & -result(swig_result) -use, intrinsic :: ISO_C_BINDING -integer(C_INT) :: swig_result -type(SUNAdaptController), target, intent(inout) :: c -integer(C_INT), intent(in) :: adj -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -integer(C_INT) :: farg2 - -farg1 = c_loc(c) -farg2 = adj -fresult = swigc_FSUNAdaptController_AdjustControllerOrder_PID(farg1, farg2) -swig_result = fresult -end function - function FSUNAdaptController_SetErrorBias_PID(c, bias) & result(swig_result) use, intrinsic :: ISO_C_BINDING diff --git a/src/sunadaptcontroller/pid/sunadaptcontroller_pid.c b/src/sunadaptcontroller/pid/sunadaptcontroller_pid.c index c8f068f7f1..4526d1e5eb 100644 --- a/src/sunadaptcontroller/pid/sunadaptcontroller_pid.c +++ b/src/sunadaptcontroller/pid/sunadaptcontroller_pid.c @@ -33,7 +33,6 @@ #define SACPID_EP(C) ( SACPID_CONTENT(C)->ep ) #define SACPID_EPP(C) ( SACPID_CONTENT(C)->epp ) #define SACPID_P(C) ( SACPID_CONTENT(C)->p ) -#define SACPID_ADJ(C) ( SACPID_CONTENT(C)->adj ) /* ------------------ * Default parameters @@ -43,8 +42,6 @@ #define DEFAULT_K2 RCONST(0.21) #define DEFAULT_K3 RCONST(0.1) #define DEFAULT_BIAS RCONST(1.5) -#define DEFAULT_ADJ -1 -/* #define DEFAULT_ADJ 0 */ #define TINY RCONST(1.0e-10) @@ -67,16 +64,15 @@ SUNAdaptController SUNAdaptController_PID(SUNContext sunctx) if (C == NULL) { return (NULL); } /* Attach operations */ - C->ops->gettype = SUNAdaptController_GetType_PID; - C->ops->estimatestep = SUNAdaptController_EstimateStep_PID; - C->ops->reset = SUNAdaptController_Reset_PID; - C->ops->setdefaults = SUNAdaptController_SetDefaults_PID; - C->ops->write = SUNAdaptController_Write_PID; - C->ops->setmethodorder = SUNAdaptController_SetMethodOrder_PID; - C->ops->adjustcontrollerorder = SUNAdaptController_AdjustControllerOrder_PID; - C->ops->seterrorbias = SUNAdaptController_SetErrorBias_PID; - C->ops->update = SUNAdaptController_Update_PID; - C->ops->space = SUNAdaptController_Space_PID; + C->ops->gettype = SUNAdaptController_GetType_PID; + C->ops->estimatestep = SUNAdaptController_EstimateStep_PID; + C->ops->reset = SUNAdaptController_Reset_PID; + C->ops->setdefaults = SUNAdaptController_SetDefaults_PID; + C->ops->write = SUNAdaptController_Write_PID; + C->ops->setmethodorder = SUNAdaptController_SetMethodOrder_PID; + C->ops->seterrorbias = SUNAdaptController_SetErrorBias_PID; + C->ops->update = SUNAdaptController_Update_PID; + C->ops->space = SUNAdaptController_Space_PID; /* Create content */ content = NULL; @@ -126,7 +122,7 @@ int SUNAdaptController_EstimateStep_PID(SUNAdaptController C, sunrealtype h, sunrealtype dsm, sunrealtype* hnew) { /* set usable time-step adaptivity parameters */ - const int ord = SACPID_P(C) + SACPID_ADJ(C) + 1; + const int ord = SACPID_P(C) + 1; const sunrealtype k1 = -SACPID_K1(C) / ord; const sunrealtype k2 = SACPID_K2(C) / ord; const sunrealtype k3 = -SACPID_K3(C) / ord; @@ -153,7 +149,6 @@ int SUNAdaptController_SetDefaults_PID(SUNAdaptController C) SACPID_K2(C) = DEFAULT_K2; SACPID_K3(C) = DEFAULT_K3; SACPID_BIAS(C) = DEFAULT_BIAS; - SACPID_ADJ(C) = DEFAULT_ADJ; return SUNADAPTCONTROLLER_SUCCESS; } @@ -174,24 +169,17 @@ int SUNAdaptController_Write_PID(SUNAdaptController C, FILE *fptr) fprintf(fptr, " previous errors = %16g %16g\n", SACPID_EP(C), SACPID_EPP(C)); #endif fprintf(fptr, " p = %i\n", SACPID_P(C)); - fprintf(fptr, " adj = %i\n", SACPID_ADJ(C)); return SUNADAPTCONTROLLER_SUCCESS; } int SUNAdaptController_SetMethodOrder_PID(SUNAdaptController C, int p) { /* check for legal inputs */ - if (p <= 0) { return SUNADAPTCONTROLLER_ILL_INPUT; } + if (p < 0) { return SUNADAPTCONTROLLER_ILL_INPUT; } SACPID_P(C) = p; return SUNADAPTCONTROLLER_SUCCESS; } -int SUNAdaptController_AdjustControllerOrder_PID(SUNAdaptController C, int adj) -{ - SACPID_ADJ(C) = adj; - return SUNADAPTCONTROLLER_SUCCESS; -} - int SUNAdaptController_SetErrorBias_PID(SUNAdaptController C, sunrealtype bias) { /* set allowed value, otherwise set default */ @@ -213,7 +201,7 @@ int SUNAdaptController_Update_PID(SUNAdaptController C, sunrealtype h, sunrealty int SUNAdaptController_Space_PID(SUNAdaptController C, long int* lenrw, long int* leniw) { - *lenrw = 7; - *leniw = 3; + *lenrw = 6; + *leniw = 1; return SUNADAPTCONTROLLER_SUCCESS; } diff --git a/src/sundials/fmod/fsundials_adaptcontroller_mod.c b/src/sundials/fmod/fsundials_adaptcontroller_mod.c index 66486bdeb8..0a3ff08517 100644 --- a/src/sundials/fmod/fsundials_adaptcontroller_mod.c +++ b/src/sundials/fmod/fsundials_adaptcontroller_mod.c @@ -366,20 +366,6 @@ SWIGEXPORT int _wrap_FSUNAdaptController_SetMethodOrder(SUNAdaptController farg1 } -SWIGEXPORT int _wrap_FSUNAdaptController_AdjustControllerOrder(SUNAdaptController farg1, int const *farg2) { - int fresult ; - SUNAdaptController arg1 = (SUNAdaptController) 0 ; - int arg2 ; - int result; - - arg1 = (SUNAdaptController)(farg1); - arg2 = (int)(*farg2); - result = (int)SUNAdaptController_AdjustControllerOrder(arg1,arg2); - fresult = (int)(result); - return fresult; -} - - SWIGEXPORT int _wrap_FSUNAdaptController_SetErrorBias(SUNAdaptController farg1, double const *farg2) { int fresult ; SUNAdaptController arg1 = (SUNAdaptController) 0 ; diff --git a/src/sundials/fmod/fsundials_adaptcontroller_mod.f90 b/src/sundials/fmod/fsundials_adaptcontroller_mod.f90 index fe49363fd0..32e9a0bf97 100644 --- a/src/sundials/fmod/fsundials_adaptcontroller_mod.f90 +++ b/src/sundials/fmod/fsundials_adaptcontroller_mod.f90 @@ -34,7 +34,6 @@ module fsundials_adaptcontroller_mod type(C_FUNPTR), public :: setdefaults type(C_FUNPTR), public :: write type(C_FUNPTR), public :: setmethodorder - type(C_FUNPTR), public :: adjustcontrollerorder type(C_FUNPTR), public :: seterrorbias type(C_FUNPTR), public :: update type(C_FUNPTR), public :: updatemrih @@ -58,7 +57,6 @@ module fsundials_adaptcontroller_mod public :: FSUNAdaptController_SetDefaults public :: FSUNAdaptController_Write public :: FSUNAdaptController_SetMethodOrder - public :: FSUNAdaptController_AdjustControllerOrder public :: FSUNAdaptController_SetErrorBias public :: FSUNAdaptController_Update public :: FSUNAdaptController_UpdateMRIH @@ -182,15 +180,6 @@ function swigc_FSUNAdaptController_SetMethodOrder(farg1, farg2) & integer(C_INT) :: fresult end function -function swigc_FSUNAdaptController_AdjustControllerOrder(farg1, farg2) & -bind(C, name="_wrap_FSUNAdaptController_AdjustControllerOrder") & -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_FSUNAdaptController_SetErrorBias(farg1, farg2) & bind(C, name="_wrap_FSUNAdaptController_SetErrorBias") & result(fresult) @@ -458,22 +447,6 @@ function FSUNAdaptController_SetMethodOrder(c, p) & swig_result = fresult end function -function FSUNAdaptController_AdjustControllerOrder(c, adj) & -result(swig_result) -use, intrinsic :: ISO_C_BINDING -integer(C_INT) :: swig_result -type(SUNAdaptController), target, intent(inout) :: c -integer(C_INT), intent(in) :: adj -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -integer(C_INT) :: farg2 - -farg1 = c_loc(c) -farg2 = adj -fresult = swigc_FSUNAdaptController_AdjustControllerOrder(farg1, farg2) -swig_result = fresult -end function - function FSUNAdaptController_SetErrorBias(c, bias) & result(swig_result) use, intrinsic :: ISO_C_BINDING diff --git a/src/sundials/sundials_adaptcontroller.c b/src/sundials/sundials_adaptcontroller.c index 232a8f4e19..5928bb0975 100644 --- a/src/sundials/sundials_adaptcontroller.c +++ b/src/sundials/sundials_adaptcontroller.c @@ -41,22 +41,21 @@ SUNAdaptController SUNAdaptController_NewEmpty(SUNContext sunctx) if (ops == NULL) { free(C); return(NULL); } /* initialize operations to NULL */ - ops->gettype = NULL; - ops->destroy = NULL; - ops->reset = NULL; - ops->estimatestep = NULL; - ops->estimatestepandorder = NULL; - ops->estimatemristeps = NULL; - ops->estimatesteptol = NULL; - ops->setdefaults = NULL; - ops->write = NULL; - ops->setmethodorder = NULL; - ops->adjustcontrollerorder = NULL; - ops->seterrorbias = NULL; - ops->update = NULL; - ops->updatemrih = NULL; - ops->updatemritol = NULL; - ops->space = NULL; + ops->gettype = NULL; + ops->destroy = NULL; + ops->reset = NULL; + ops->estimatestep = NULL; + ops->estimatestepandorder = NULL; + ops->estimatemristeps = NULL; + ops->estimatesteptol = NULL; + ops->setdefaults = NULL; + ops->write = NULL; + ops->setmethodorder = NULL; + ops->seterrorbias = NULL; + ops->update = NULL; + ops->updatemrih = NULL; + ops->updatemritol = NULL; + ops->space = NULL; /* attach ops and initialize content to NULL */ C->ops = ops; @@ -208,14 +207,6 @@ int SUNAdaptController_SetMethodOrder(SUNAdaptController C, int p) return(ier); } -int SUNAdaptController_AdjustControllerOrder(SUNAdaptController C, int adj) -{ - int ier = 0; - if (C == NULL) { return ier; } - if (C->ops->adjustcontrollerorder) { ier = C->ops->adjustcontrollerorder(C, adj); } - return(ier); -} - int SUNAdaptController_SetErrorBias(SUNAdaptController C, sunrealtype bias) { int ier = 0; From 61b24fb70e216f4caaa4505495585a4aabbf9355 Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Thu, 19 Oct 2023 11:28:17 -0500 Subject: [PATCH 08/58] Updated lenrw and leniw in .out files --- .../C_parallel/ark_diurnal_kry_bbd_p.out | 104 +-- .../arkode/C_parallel/ark_diurnal_kry_p.out | 53 +- .../arkode/C_parhyp/ark_diurnal_kry_ph.out | 53 +- .../arkode/C_serial/ark_KrylovDemo_prec.out | 652 +++++++++--------- .../arkode/C_serial/ark_KrylovDemo_prec_1.out | 652 +++++++++--------- .../arkode/C_serial/ark_KrylovDemo_prec_2.out | 650 ++++++++--------- 6 files changed, 1081 insertions(+), 1083 deletions(-) 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 5d53186f79..32243686c6 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 = 979 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 = 2738 stepsize = 6.94e+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 = 3535 stepsize = 1.05e+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 = 4683 stepsize = 4.46e+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 = 5959 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 = 7152 stepsize = 3.93e+02 -At bottom left: c1, c2 = -1.202e-09 3.382e+11 -At top right: c1, c2 = 1.624e-07 3.804e+11 +At bottom left: c1, c2 = -1.202e-09 3.382e+11 +At top right: c1, c2 = 1.624e-07 3.804e+11 t = 5.04e+04 no. steps = 7171 stepsize = 3.76e+02 -At bottom left: c1, c2 = 5.092e-08 3.358e+11 -At top right: c1, c2 = -4.835e-07 3.864e+11 +At bottom left: c1, c2 = 5.092e-08 3.358e+11 +At top right: c1, c2 = -4.835e-07 3.864e+11 t = 5.76e+04 no. steps = 7188 stepsize = 2.94e+02 -At bottom left: c1, c2 = -3.248e-10 3.320e+11 -At top right: c1, c2 = 7.269e-08 3.909e+11 +At bottom left: c1, c2 = -3.248e-10 3.320e+11 +At top right: c1, c2 = 7.269e-08 3.909e+11 t = 6.48e+04 no. steps = 7212 stepsize = 5.52e+02 -At bottom left: c1, c2 = -1.079e-09 3.313e+11 -At top right: c1, c2 = -2.660e-07 3.963e+11 +At bottom left: c1, c2 = -1.079e-09 3.313e+11 +At top right: c1, c2 = -2.660e-07 3.963e+11 t = 7.20e+04 no. steps = 7225 stepsize = 5.52e+02 -At bottom left: c1, c2 = 4.318e-08 3.330e+11 -At top right: c1, c2 = -4.973e-07 4.039e+11 +At bottom left: c1, c2 = 4.318e-08 3.330e+11 +At top right: c1, c2 = -4.973e-07 4.039e+11 t = 7.92e+04 no. steps = 7238 stepsize = 5.52e+02 -At bottom left: c1, c2 = -1.398e-08 3.334e+11 -At top right: c1, c2 = 7.657e-08 4.120e+11 +At bottom left: c1, c2 = -1.398e-08 3.334e+11 +At top right: c1, c2 = 7.657e-08 4.120e+11 t = 8.64e+04 no. steps = 7252 stepsize = 5.52e+02 -At bottom left: c1, c2 = 1.764e-07 3.352e+11 -At top right: c1, c2 = -4.190e-08 4.163e+11 +At bottom left: c1, c2 = 1.764e-07 3.352e+11 +At top right: c1, c2 = -4.190e-08 4.163e+11 -Final Statistics: +Final Statistics: -lenrw = 3901 leniw = 267 +lenrw = 3898 leniw = 267 lenrwls = 2455 leniwls = 126 nst = 7252 nfe = 0 nfe = 76109 nfels = 82856 @@ -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 = 981 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 = 2731 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 = 4692 stepsize = 3.80e+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 = 6087 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 = 7275 stepsize = 4.76e+02 -At bottom left: c1, c2 = 1.722e-10 3.382e+11 -At top right: c1, c2 = 1.593e-09 3.804e+11 +At bottom left: c1, c2 = 1.722e-10 3.382e+11 +At top right: c1, c2 = 1.593e-09 3.804e+11 t = 5.04e+04 no. steps = 7291 stepsize = 3.75e+02 -At bottom left: c1, c2 = 1.309e-09 3.358e+11 -At top right: c1, c2 = -1.367e-09 3.864e+11 +At bottom left: c1, c2 = 1.309e-09 3.358e+11 +At top right: c1, c2 = -1.367e-09 3.864e+11 t = 5.76e+04 no. steps = 7308 stepsize = 2.92e+02 -At bottom left: c1, c2 = -2.110e-07 3.320e+11 -At top right: c1, c2 = -3.069e-07 3.909e+11 +At bottom left: c1, c2 = -2.110e-07 3.320e+11 +At top right: c1, c2 = -3.069e-07 3.909e+11 t = 6.48e+04 no. steps = 7323 stepsize = 4.87e+02 -At bottom left: c1, c2 = 2.224e-07 3.313e+11 -At top right: c1, c2 = 2.684e-07 3.963e+11 +At bottom left: c1, c2 = 2.224e-07 3.313e+11 +At top right: c1, c2 = 2.684e-07 3.963e+11 t = 7.20e+04 no. steps = 7338 stepsize = 4.87e+02 -At bottom left: c1, c2 = 6.820e-08 3.330e+11 -At top right: c1, c2 = -2.132e-06 4.039e+11 +At bottom left: c1, c2 = 6.820e-08 3.330e+11 +At top right: c1, c2 = -2.132e-06 4.039e+11 t = 7.92e+04 no. steps = 7353 stepsize = 4.87e+02 -At bottom left: c1, c2 = 1.134e-09 3.334e+11 -At top right: c1, c2 = -2.341e-07 4.120e+11 +At bottom left: c1, c2 = 1.134e-09 3.334e+11 +At top right: c1, c2 = -2.341e-07 4.120e+11 t = 8.64e+04 no. steps = 7364 stepsize = 7.33e+02 -At bottom left: c1, c2 = 4.331e-07 3.352e+11 -At top right: c1, c2 = -6.607e-08 4.163e+11 +At bottom left: c1, c2 = 4.331e-07 3.352e+11 +At top right: c1, c2 = -6.607e-08 4.163e+11 -Final Statistics: +Final Statistics: -lenrw = 3901 leniw = 272 +lenrw = 3898 leniw = 267 lenrwls = 2455 leniwls = 126 nst = 7364 nfe = 0 nfe = 77457 nfels = 101131 diff --git a/examples/arkode/C_parallel/ark_diurnal_kry_p.out b/examples/arkode/C_parallel/ark_diurnal_kry_p.out index 97f07c3221..c083cb2b31 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 = 979 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 = 2733 stepsize = 6.92e+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 = 4559 stepsize = 4.56e+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 = 5822 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 = 7012 stepsize = 4.38e+02 -At bottom left: c1, c2 = -2.534e-08 3.382e+11 -At top right: c1, c2 = 2.458e-08 3.804e+11 +At bottom left: c1, c2 = -2.534e-08 3.382e+11 +At top right: c1, c2 = 2.458e-08 3.804e+11 t = 5.04e+04 no. steps = 7031 stepsize = 3.01e+02 -At bottom left: c1, c2 = 6.320e-07 3.358e+11 -At top right: c1, c2 = -7.802e-07 3.864e+11 +At bottom left: c1, c2 = 6.320e-07 3.358e+11 +At top right: c1, c2 = -7.802e-07 3.864e+11 t = 5.76e+04 no. steps = 7052 stepsize = 2.39e+02 -At bottom left: c1, c2 = -2.953e-15 3.320e+11 -At top right: c1, c2 = -6.467e-15 3.909e+11 +At bottom left: c1, c2 = -2.953e-15 3.320e+11 +At top right: c1, c2 = -6.467e-15 3.909e+11 t = 6.48e+04 no. steps = 7067 stepsize = 6.00e+02 -At bottom left: c1, c2 = -2.940e-18 3.313e+11 -At top right: c1, c2 = -9.232e-17 3.963e+11 +At bottom left: c1, c2 = -2.940e-18 3.313e+11 +At top right: c1, c2 = -9.232e-17 3.963e+11 t = 7.20e+04 no. steps = 7079 stepsize = 6.00e+02 -At bottom left: c1, c2 = 2.299e-17 3.330e+11 -At top right: c1, c2 = -1.240e-16 4.039e+11 +At bottom left: c1, c2 = 2.299e-17 3.330e+11 +At top right: c1, c2 = -1.240e-16 4.039e+11 t = 7.92e+04 no. steps = 7091 stepsize = 6.00e+02 -At bottom left: c1, c2 = 2.598e-17 3.334e+11 -At top right: c1, c2 = -6.124e-17 4.120e+11 +At bottom left: c1, c2 = 2.598e-17 3.334e+11 +At top right: c1, c2 = -6.124e-17 4.120e+11 t = 8.64e+04 no. steps = 7103 stepsize = 6.00e+02 -At bottom left: c1, c2 = 1.059e-27 3.352e+11 -At top right: c1, c2 = 1.567e-26 4.163e+11 +At bottom left: c1, c2 = 1.059e-27 3.352e+11 +At top right: c1, c2 = 1.567e-26 4.163e+11 -Final Statistics: +Final Statistics: -lenrw = 3301 leniw = 243 +lenrw = 3298 leniw = 243 lenrwls = 2455 leniwls = 126 nst = 7103 nfe = 0 nfi = 74602 nfels = 87206 @@ -60,4 +60,3 @@ nni = 38944 nli = 87206 nsetups = 431 netf = 28 npe = 120 nps = 123894 ncfn = 0 ncfl = 0 - diff --git a/examples/arkode/C_parhyp/ark_diurnal_kry_ph.out b/examples/arkode/C_parhyp/ark_diurnal_kry_ph.out index 411f0a09fc..43d41ae93a 100644 --- a/examples/arkode/C_parhyp/ark_diurnal_kry_ph.out +++ b/examples/arkode/C_parhyp/ark_diurnal_kry_ph.out @@ -2,57 +2,57 @@ 2-species diurnal advection-diffusion problem t = 7.20e+03 no. steps = 979 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 = 2733 stepsize = 6.92e+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 = 4558 stepsize = 3.77e+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 = 5961 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 = 7161 stepsize = 5.16e+02 -At bottom left: c1, c2 = 4.611e-12 3.382e+11 -At top right: c1, c2 = -1.475e-11 3.804e+11 +At bottom left: c1, c2 = 4.611e-12 3.382e+11 +At top right: c1, c2 = -1.475e-11 3.804e+11 t = 5.04e+04 no. steps = 7175 stepsize = 5.05e+02 -At bottom left: c1, c2 = 1.182e-11 3.358e+11 -At top right: c1, c2 = -2.617e-11 3.864e+11 +At bottom left: c1, c2 = 1.182e-11 3.358e+11 +At top right: c1, c2 = -2.617e-11 3.864e+11 t = 5.76e+04 no. steps = 7190 stepsize = 2.44e+02 -At bottom left: c1, c2 = -1.051e-11 3.320e+11 -At top right: c1, c2 = -9.200e-11 3.909e+11 +At bottom left: c1, c2 = -1.051e-11 3.320e+11 +At top right: c1, c2 = -9.200e-11 3.909e+11 t = 6.48e+04 no. steps = 7203 stepsize = 6.40e+02 -At bottom left: c1, c2 = 1.286e-10 3.313e+11 -At top right: c1, c2 = -4.357e-10 3.963e+11 +At bottom left: c1, c2 = 1.286e-10 3.313e+11 +At top right: c1, c2 = -4.357e-10 3.963e+11 t = 7.20e+04 no. steps = 7215 stepsize = 6.40e+02 -At bottom left: c1, c2 = -1.814e-11 3.330e+11 -At top right: c1, c2 = -9.120e-11 4.039e+11 +At bottom left: c1, c2 = -1.814e-11 3.330e+11 +At top right: c1, c2 = -9.120e-11 4.039e+11 t = 7.92e+04 no. steps = 7226 stepsize = 6.40e+02 -At bottom left: c1, c2 = -1.291e-21 3.334e+11 -At top right: c1, c2 = -1.937e-20 4.120e+11 +At bottom left: c1, c2 = -1.291e-21 3.334e+11 +At top right: c1, c2 = -1.937e-20 4.120e+11 t = 8.64e+04 no. steps = 7237 stepsize = 6.40e+02 -At bottom left: c1, c2 = -3.534e-21 3.352e+11 -At top right: c1, c2 = -4.442e-20 4.163e+11 +At bottom left: c1, c2 = -3.534e-21 3.352e+11 +At top right: c1, c2 = -4.442e-20 4.163e+11 -Final Statistics: +Final Statistics: -lenrw = 3301 leniw = 243 +lenrw = 3298 leniw = 243 lenrwls = 2455 leniwls = 126 nst = 7237 nfe = 0 nfi = 75881 nfels = 88695 @@ -60,4 +60,3 @@ nni = 39568 nli = 88695 nsetups = 431 netf = 25 npe = 121 nps = 126028 ncfn = 0 ncfl = 0 - diff --git a/examples/arkode/C_serial/ark_KrylovDemo_prec.out b/examples/arkode/C_serial/ark_KrylovDemo_prec.out index 3a63a46785..09364ad394 100644 --- a/examples/arkode/C_serial/ark_KrylovDemo_prec.out +++ b/examples/arkode/C_serial/ark_KrylovDemo_prec.out @@ -10,9 +10,9 @@ b parameter = 1 Diffusion coefficients: Dprey = 1 Dpred = 0.5 Rate parameter alpha = 1 -Mesh dimensions (mx,my) are 6, 6. Total system size is neq = 216 +Mesh dimensions (mx,my) are 6, 6. Total system size is neq = 216 -Tolerances: reltol = 1e-05, abstol = 1e-05 +Tolerances: reltol = 1e-05, abstol = 1e-05 Preconditioning uses a product of: (1) Gauss-Seidel iterations with itmax = 5 iterations, and @@ -31,52 +31,52 @@ Gram-Schmidt method type is gstype = SUN_MODIFIED_GS c values at t = 0: Species 1 -10 10 10 10 10 10 -10 10.1678 10.3775 10.3775 10.1678 10 -10 10.3775 10.8493 10.8493 10.3775 10 -10 10.3775 10.8493 10.8493 10.3775 10 -10 10.1678 10.3775 10.3775 10.1678 10 -10 10 10 10 10 10 +10 10 10 10 10 10 +10 10.1678 10.3775 10.3775 10.1678 10 +10 10.3775 10.8493 10.8493 10.3775 10 +10 10.3775 10.8493 10.8493 10.3775 10 +10 10.1678 10.3775 10.3775 10.1678 10 +10 10 10 10 10 10 Species 2 -10 10 10 10 10 10 -10 10.3355 10.755 10.755 10.3355 10 -10 10.755 11.6987 11.6987 10.755 10 -10 10.755 11.6987 11.6987 10.755 10 -10 10.3355 10.755 10.755 10.3355 10 -10 10 10 10 10 10 +10 10 10 10 10 10 +10 10.3355 10.755 10.755 10.3355 10 +10 10.755 11.6987 11.6987 10.755 10 +10 10.755 11.6987 11.6987 10.755 10 +10 10.3355 10.755 10.755 10.3355 10 +10 10 10 10 10 10 Species 3 -10 10 10 10 10 10 -10 10.5033 11.1325 11.1325 10.5033 10 -10 11.1325 12.548 12.548 11.1325 10 -10 11.1325 12.548 12.548 11.1325 10 -10 10.5033 11.1325 11.1325 10.5033 10 -10 10 10 10 10 10 +10 10 10 10 10 10 +10 10.5033 11.1325 11.1325 10.5033 10 +10 11.1325 12.548 12.548 11.1325 10 +10 11.1325 12.548 12.548 11.1325 10 +10 10.5033 11.1325 11.1325 10.5033 10 +10 10 10 10 10 10 Species 4 -10 10 10 10 10 10 -10 10.6711 11.5099 11.5099 10.6711 10 -10 11.5099 13.3974 13.3974 11.5099 10 -10 11.5099 13.3974 13.3974 11.5099 10 -10 10.6711 11.5099 11.5099 10.6711 10 -10 10 10 10 10 10 +10 10 10 10 10 10 +10 10.6711 11.5099 11.5099 10.6711 10 +10 11.5099 13.3974 13.3974 11.5099 10 +10 11.5099 13.3974 13.3974 11.5099 10 +10 10.6711 11.5099 11.5099 10.6711 10 +10 10 10 10 10 10 Species 5 -10 10 10 10 10 10 -10 10.8389 11.8874 11.8874 10.8389 10 -10 11.8874 14.2467 14.2467 11.8874 10 -10 11.8874 14.2467 14.2467 11.8874 10 -10 10.8389 11.8874 11.8874 10.8389 10 -10 10 10 10 10 10 +10 10 10 10 10 10 +10 10.8389 11.8874 11.8874 10.8389 10 +10 11.8874 14.2467 14.2467 11.8874 10 +10 11.8874 14.2467 14.2467 11.8874 10 +10 10.8389 11.8874 11.8874 10.8389 10 +10 10 10 10 10 10 Species 6 -10 10 10 10 10 10 -10 11.0066 12.2649 12.2649 11.0066 10 -10 12.2649 15.0961 15.0961 12.2649 10 -10 12.2649 15.0961 15.0961 12.2649 10 -10 11.0066 12.2649 12.2649 11.0066 10 -10 10 10 10 10 10 +10 10 10 10 10 10 +10 11.0066 12.2649 12.2649 11.0066 10 +10 12.2649 15.0961 15.0961 12.2649 10 +10 12.2649 15.0961 15.0961 12.2649 10 +10 11.0066 12.2649 12.2649 11.0066 10 +10 10 10 10 10 10 t = 1.00e-08 nst = 5 nfe = 0 nfi = 75 nni = 47 hu = 9.89e-08 @@ -87,52 +87,52 @@ t = 1.00e-06 nst = 8 nfe = 0 nfi = 120 nni = 77 hu = 4.79e-07 c values at t = 1e-06: Species 1 -9.99991 9.99992 9.99993 9.99993 9.99993 9.99992 -9.99992 10.1677 10.3774 10.3774 10.1677 9.99993 -9.99993 10.3774 10.8492 10.8492 10.3774 9.99993 -9.99993 10.3774 10.8492 10.8492 10.3774 9.99993 -9.99992 10.1677 10.3774 10.3774 10.1677 9.99992 -9.99991 9.99992 9.99993 9.99993 9.99992 9.99991 +9.99991 9.99992 9.99993 9.99993 9.99993 9.99992 +9.99992 10.1677 10.3774 10.3774 10.1677 9.99993 +9.99993 10.3774 10.8492 10.8492 10.3774 9.99993 +9.99993 10.3774 10.8492 10.8492 10.3774 9.99993 +9.99992 10.1677 10.3774 10.3774 10.1677 9.99992 +9.99991 9.99992 9.99993 9.99993 9.99992 9.99991 Species 2 -9.99991 9.99993 9.99995 9.99995 9.99993 9.99992 -9.99993 10.3355 10.7549 10.7549 10.3355 9.99993 -9.99995 10.7549 11.6985 11.6985 10.7549 9.99995 -9.99995 10.7549 11.6985 11.6985 10.7549 9.99995 -9.99993 10.3355 10.7549 10.7549 10.3355 9.99993 -9.99991 9.99993 9.99995 9.99995 9.99993 9.99991 +9.99991 9.99993 9.99995 9.99995 9.99993 9.99992 +9.99993 10.3355 10.7549 10.7549 10.3355 9.99993 +9.99995 10.7549 11.6985 11.6985 10.7549 9.99995 +9.99995 10.7549 11.6985 11.6985 10.7549 9.99995 +9.99993 10.3355 10.7549 10.7549 10.3355 9.99993 +9.99991 9.99993 9.99995 9.99995 9.99993 9.99991 Species 3 -9.99991 9.99994 9.99997 9.99997 9.99994 9.99992 -9.99994 10.5032 11.1323 11.1323 10.5032 9.99994 -9.99997 11.1323 12.5478 12.5478 11.1323 9.99997 -9.99997 11.1323 12.5478 12.5478 11.1323 9.99997 -9.99994 10.5032 11.1323 11.1323 10.5032 9.99994 -9.99991 9.99994 9.99997 9.99997 9.99994 9.99991 +9.99991 9.99994 9.99997 9.99997 9.99994 9.99992 +9.99994 10.5032 11.1323 11.1323 10.5032 9.99994 +9.99997 11.1323 12.5478 12.5478 11.1323 9.99997 +9.99997 11.1323 12.5478 12.5478 11.1323 9.99997 +9.99994 10.5032 11.1323 11.1323 10.5032 9.99994 +9.99991 9.99994 9.99997 9.99997 9.99994 9.99991 Species 4 -13.4984 13.4984 13.4984 13.4984 13.4984 13.4984 -13.4984 14.55 15.8924 15.8924 14.55 13.4984 -13.4984 15.8924 19.0296 19.0296 15.8924 13.4984 -13.4984 15.8924 19.0296 19.0296 15.8924 13.4984 -13.4984 14.55 15.8924 15.8924 14.55 13.4984 -13.4984 13.4984 13.4984 13.4984 13.4984 13.4984 +13.4984 13.4984 13.4984 13.4984 13.4984 13.4984 +13.4984 14.55 15.8924 15.8924 14.55 13.4984 +13.4984 15.8924 19.0296 19.0296 15.8924 13.4984 +13.4984 15.8924 19.0296 19.0296 15.8924 13.4984 +13.4984 14.55 15.8924 15.8924 14.55 13.4984 +13.4984 13.4984 13.4984 13.4984 13.4984 13.4984 Species 5 -13.4984 13.4984 13.4985 13.4985 13.4984 13.4984 -13.4984 14.7787 16.4136 16.4136 14.7787 13.4984 -13.4985 16.4136 20.236 20.236 16.4136 13.4985 -13.4985 16.4136 20.236 20.236 16.4136 13.4985 -13.4984 14.7787 16.4136 16.4136 14.7787 13.4984 -13.4984 13.4984 13.4985 13.4985 13.4984 13.4984 +13.4984 13.4984 13.4985 13.4985 13.4984 13.4984 +13.4984 14.7787 16.4136 16.4136 14.7787 13.4984 +13.4985 16.4136 20.236 20.236 16.4136 13.4985 +13.4985 16.4136 20.236 20.236 16.4136 13.4985 +13.4984 14.7787 16.4136 16.4136 14.7787 13.4984 +13.4984 13.4984 13.4985 13.4985 13.4984 13.4984 Species 6 -13.4984 13.4984 13.4985 13.4985 13.4984 13.4984 -13.4984 15.0075 16.9348 16.9348 15.0075 13.4984 -13.4985 16.9348 21.4423 21.4423 16.9348 13.4985 -13.4985 16.9348 21.4423 21.4423 16.9348 13.4985 -13.4984 15.0075 16.9348 16.9348 15.0075 13.4984 -13.4984 13.4984 13.4985 13.4985 13.4984 13.4984 +13.4984 13.4984 13.4985 13.4985 13.4984 13.4984 +13.4984 15.0075 16.9348 16.9348 15.0075 13.4984 +13.4985 16.9348 21.4423 21.4423 16.9348 13.4985 +13.4985 16.9348 21.4423 21.4423 16.9348 13.4985 +13.4984 15.0075 16.9348 16.9348 15.0075 13.4984 +13.4984 13.4984 13.4985 13.4985 13.4984 13.4984 t = 1.00e-05 nst = 27 nfe = 0 nfi = 407 nni = 269 hu = 4.79e-07 @@ -143,52 +143,52 @@ t = 1.00e-03 nst = 110 nfe = 0 nfi = 1750 nni = 1197 hu = 1.51e-03 c values at t = 0.001: Species 1 -9.90702 9.91664 9.92836 9.93033 9.92253 9.91674 -9.91472 10.0747 10.2769 10.2785 10.0795 9.92253 -9.92446 10.2748 10.7181 10.7194 10.2785 9.93033 -9.92445 10.2744 10.7173 10.7181 10.2769 9.92836 -9.91469 10.0734 10.2744 10.2748 10.0747 9.91664 -9.90698 9.91469 9.92445 9.92446 9.91472 9.90702 +9.90702 9.91664 9.92836 9.93033 9.92253 9.91674 +9.91472 10.0747 10.2769 10.2785 10.0795 9.92253 +9.92446 10.2748 10.7181 10.7194 10.2785 9.93033 +9.92445 10.2744 10.7173 10.7181 10.2769 9.92836 +9.91469 10.0734 10.2744 10.2748 10.0747 9.91664 +9.90698 9.91469 9.92445 9.92446 9.91472 9.90702 Species 2 -9.90742 9.92474 9.94622 9.94819 9.93064 9.91713 -9.92282 10.2412 10.644 10.6457 10.2461 9.93064 -9.94232 10.6419 11.5267 11.5281 10.6457 9.94819 -9.94231 10.6415 11.5258 11.5267 10.644 9.94622 -9.92279 10.24 10.6415 10.6419 10.2412 9.92474 -9.90737 9.92279 9.94231 9.94232 9.92282 9.90742 +9.90742 9.92474 9.94622 9.94819 9.93064 9.91713 +9.92282 10.2412 10.644 10.6457 10.2461 9.93064 +9.94232 10.6419 11.5267 11.5281 10.6457 9.94819 +9.94231 10.6415 11.5258 11.5267 10.644 9.94622 +9.92279 10.24 10.6415 10.6419 10.2412 9.92474 +9.90737 9.92279 9.94231 9.94232 9.92282 9.90742 Species 3 -9.90781 9.93284 9.96408 9.96605 9.93874 9.91753 -9.93092 10.4078 11.0109 11.0127 10.4127 9.93874 -9.96017 11.0088 12.3339 12.3354 11.0127 9.96605 -9.96016 11.0083 12.333 12.3339 11.0109 9.96408 -9.93088 10.4065 11.0083 11.0088 10.4078 9.93284 -9.90776 9.93088 9.96016 9.96017 9.93092 9.90781 +9.90781 9.93284 9.96408 9.96605 9.93874 9.91753 +9.93092 10.4078 11.0109 11.0127 10.4127 9.93874 +9.96017 11.0088 12.3339 12.3354 11.0127 9.96605 +9.96016 11.0083 12.333 12.3339 11.0109 9.96408 +9.93088 10.4065 11.0083 11.0088 10.4078 9.93284 +9.90776 9.93088 9.96016 9.96017 9.93092 9.90781 Species 4 -297231 297749 298392 298451 297925 297520 -297692 307245 319327 319378 307390 297925 -298276 319264 345799 345840 319378 298451 -298276 319252 345772 345799 319327 298392 -297691 307208 319252 319264 307245 297749 -297229 297691 298276 298276 297692 297231 +297231 297749 298392 298451 297925 297520 +297692 307245 319327 319378 307390 297925 +298276 319264 345799 345840 319378 298451 +298276 319252 345772 345799 319327 298392 +297691 307208 319252 319264 307245 297749 +297229 297691 298276 298276 297692 297231 Species 5 -297231 297749 298392 298451 297925 297520 -297692 307245 319327 319378 307390 297925 -298276 319264 345799 345840 319378 298451 -298276 319252 345772 345799 319327 298392 -297691 307208 319252 319264 307245 297749 -297229 297691 298276 298276 297692 297231 +297231 297749 298392 298451 297925 297520 +297692 307245 319327 319378 307390 297925 +298276 319264 345799 345840 319378 298451 +298276 319252 345772 345799 319327 298392 +297691 307208 319252 319264 307245 297749 +297229 297691 298276 298276 297692 297231 Species 6 -297231 297749 298392 298451 297925 297520 -297692 307245 319327 319378 307390 297925 -298276 319264 345799 345840 319378 298451 -298276 319252 345772 345799 319327 298392 -297691 307208 319252 319264 307245 297749 -297229 297691 298276 298276 297692 297231 +297231 297749 298392 298451 297925 297520 +297692 307245 319327 319378 307390 297925 +298276 319264 345799 345840 319378 298451 +298276 319252 345772 345799 319327 298392 +297691 307208 319252 319264 307245 297749 +297229 297691 298276 298276 297692 297231 t = 1.00e-02 nst = 113 nfe = 0 nfi = 1797 nni = 1229 hu = 3.46e-03 @@ -199,52 +199,52 @@ t = 1.00e+00 nst = 154 nfe = 0 nfi = 2489 nni = 1716 hu = 6.84e-02 c values at t = 1: Species 1 -1.58851 1.59924 1.62152 1.64764 1.67036 1.68149 -1.58533 1.59503 1.61548 1.63952 1.66033 1.67036 -1.57757 1.58547 1.60239 1.62235 1.63952 1.64764 -1.5682 1.57412 1.58706 1.60239 1.61548 1.62152 -1.56048 1.56463 1.57412 1.58547 1.59503 1.59924 -1.55733 1.56048 1.5682 1.57757 1.58533 1.58851 +1.58851 1.59924 1.62152 1.64764 1.67036 1.68149 +1.58533 1.59503 1.61548 1.63952 1.66033 1.67036 +1.57757 1.58547 1.60239 1.62235 1.63952 1.64764 +1.5682 1.57412 1.58706 1.60239 1.61548 1.62152 +1.56048 1.56463 1.57412 1.58547 1.59503 1.59924 +1.55733 1.56048 1.5682 1.57757 1.58533 1.58851 Species 2 -1.59067 1.60141 1.62371 1.64987 1.67261 1.68375 -1.58748 1.5972 1.61766 1.64173 1.66257 1.67261 -1.57971 1.58763 1.60457 1.62454 1.64173 1.64987 -1.57034 1.57626 1.58921 1.60457 1.61766 1.62371 -1.56261 1.56676 1.57626 1.58763 1.5972 1.60141 -1.55945 1.56261 1.57034 1.57971 1.58748 1.59067 +1.59067 1.60141 1.62371 1.64987 1.67261 1.68375 +1.58748 1.5972 1.61766 1.64173 1.66257 1.67261 +1.57971 1.58763 1.60457 1.62454 1.64173 1.64987 +1.57034 1.57626 1.58921 1.60457 1.61766 1.62371 +1.56261 1.56676 1.57626 1.58763 1.5972 1.60141 +1.55945 1.56261 1.57034 1.57971 1.58748 1.59067 Species 3 -1.5927 1.60346 1.62578 1.65197 1.67474 1.68589 -1.58951 1.59924 1.61973 1.64383 1.66468 1.67474 -1.58174 1.58966 1.60662 1.62662 1.64383 1.65197 -1.57236 1.57828 1.59125 1.60662 1.61973 1.62578 -1.56462 1.56878 1.57828 1.58966 1.59924 1.60346 -1.56146 1.56462 1.57236 1.58174 1.58951 1.5927 +1.5927 1.60346 1.62578 1.65197 1.67474 1.68589 +1.58951 1.59924 1.61973 1.64383 1.66468 1.67474 +1.58174 1.58966 1.60662 1.62662 1.64383 1.65197 +1.57236 1.57828 1.59125 1.60662 1.61973 1.62578 +1.56462 1.56878 1.57828 1.58966 1.59924 1.60346 +1.56146 1.56462 1.57236 1.58174 1.58951 1.5927 Species 4 -47718.3 48040.3 48709 49493.5 50175.5 50509.4 -47622.8 47914 48527.8 49249.6 49874.4 50175.5 -47389.7 47627 48134.9 48734.2 49249.6 49493.5 -47108.5 47286 47674.6 48134.9 48527.8 48709 -46876.6 47001.2 47286 47627 47914 48040.3 -46781.9 46876.6 47108.5 47389.7 47622.8 47718.3 +47718.3 48040.3 48709 49493.5 50175.5 50509.4 +47622.8 47914 48527.8 49249.6 49874.4 50175.5 +47389.7 47627 48134.9 48734.2 49249.6 49493.5 +47108.5 47286 47674.6 48134.9 48527.8 48709 +46876.6 47001.2 47286 47627 47914 48040.3 +46781.9 46876.6 47108.5 47389.7 47622.8 47718.3 Species 5 -47718.3 48040.3 48709 49493.5 50175.5 50509.4 -47622.8 47914 48527.8 49249.6 49874.4 50175.5 -47389.7 47627 48134.9 48734.2 49249.6 49493.5 -47108.5 47286 47674.6 48134.9 48527.8 48709 -46876.6 47001.2 47286 47627 47914 48040.3 -46781.9 46876.6 47108.5 47389.7 47622.8 47718.3 +47718.3 48040.3 48709 49493.5 50175.5 50509.4 +47622.8 47914 48527.8 49249.6 49874.4 50175.5 +47389.7 47627 48134.9 48734.2 49249.6 49493.5 +47108.5 47286 47674.6 48134.9 48527.8 48709 +46876.6 47001.2 47286 47627 47914 48040.3 +46781.9 46876.6 47108.5 47389.7 47622.8 47718.3 Species 6 -47718.3 48040.3 48709 49493.5 50175.5 50509.4 -47622.8 47914 48527.8 49249.6 49874.4 50175.5 -47389.7 47627 48134.9 48734.2 49249.6 49493.5 -47108.5 47286 47674.6 48134.9 48527.8 48709 -46876.6 47001.2 47286 47627 47914 48040.3 -46781.9 46876.6 47108.5 47389.7 47622.8 47718.3 +47718.3 48040.3 48709 49493.5 50175.5 50509.4 +47622.8 47914 48527.8 49249.6 49874.4 50175.5 +47389.7 47627 48134.9 48734.2 49249.6 49493.5 +47108.5 47286 47674.6 48134.9 48527.8 48709 +46876.6 47001.2 47286 47627 47914 48040.3 +46781.9 46876.6 47108.5 47389.7 47622.8 47718.3 t = 2.00e+00 nst = 165 nfe = 0 nfi = 2661 nni = 1833 hu = 4.14e-02 @@ -255,52 +255,52 @@ t = 4.00e+00 nst = 187 nfe = 0 nfi = 3013 nni = 2073 hu = 1.23e-01 c values at t = 4: Species 1 -1.19535 1.20368 1.2211 1.24157 1.25935 1.268 -1.1928 1.20035 1.21636 1.23523 1.25154 1.25935 -1.18657 1.19274 1.20602 1.22173 1.23523 1.24157 -1.17904 1.18368 1.19389 1.20602 1.21636 1.2211 -1.17284 1.17613 1.18368 1.19274 1.20035 1.20368 -1.17032 1.17284 1.17904 1.18657 1.1928 1.19535 +1.19535 1.20368 1.2211 1.24157 1.25935 1.268 +1.1928 1.20035 1.21636 1.23523 1.25154 1.25935 +1.18657 1.19274 1.20602 1.22173 1.23523 1.24157 +1.17904 1.18368 1.19389 1.20602 1.21636 1.2211 +1.17284 1.17613 1.18368 1.19274 1.20035 1.20368 +1.17032 1.17284 1.17904 1.18657 1.1928 1.19535 Species 2 -1.19538 1.20371 1.22113 1.24161 1.25938 1.26804 -1.19284 1.20038 1.21639 1.23526 1.25157 1.25938 -1.1866 1.19277 1.20606 1.22177 1.23526 1.24161 -1.17908 1.18371 1.19393 1.20606 1.21639 1.22113 -1.17288 1.17616 1.18371 1.19277 1.20038 1.20371 -1.17035 1.17288 1.17908 1.1866 1.19284 1.19538 +1.19538 1.20371 1.22113 1.24161 1.25938 1.26804 +1.19284 1.20038 1.21639 1.23526 1.25157 1.25938 +1.1866 1.19277 1.20606 1.22177 1.23526 1.24161 +1.17908 1.18371 1.19393 1.20606 1.21639 1.22113 +1.17288 1.17616 1.18371 1.19277 1.20038 1.20371 +1.17035 1.17288 1.17908 1.1866 1.19284 1.19538 Species 3 -1.19542 1.20374 1.22116 1.24164 1.25942 1.26807 -1.19287 1.20042 1.21642 1.2353 1.2516 1.25942 -1.18663 1.1928 1.20609 1.2218 1.2353 1.24164 -1.17911 1.18374 1.19396 1.20609 1.21642 1.22116 -1.17291 1.17619 1.18374 1.1928 1.20042 1.20374 -1.17039 1.17291 1.17911 1.18663 1.19287 1.19542 +1.19542 1.20374 1.22116 1.24164 1.25942 1.26807 +1.19287 1.20042 1.21642 1.2353 1.2516 1.25942 +1.18663 1.1928 1.20609 1.2218 1.2353 1.24164 +1.17911 1.18374 1.19396 1.20609 1.21642 1.22116 +1.17291 1.17619 1.18374 1.1928 1.20042 1.20374 +1.17039 1.17291 1.17911 1.18663 1.19287 1.19542 Species 4 -35860.6 36110.2 36632.4 37246.4 37779.5 38038.7 -35784.2 36010.4 36490.4 37056.3 37545.3 37779.5 -35597.2 35782 36180.5 36651.6 37056.3 37246.4 -35371.4 35510.4 35816.7 36180.5 36490.4 36632.4 -35185.4 35283.8 35510.4 35782 36010.4 36110.2 -35109.7 35185.4 35371.4 35597.2 35784.2 35860.6 +35860.6 36110.2 36632.4 37246.4 37779.5 38038.7 +35784.2 36010.4 36490.4 37056.3 37545.3 37779.5 +35597.2 35782 36180.5 36651.6 37056.3 37246.4 +35371.4 35510.4 35816.7 36180.5 36490.4 36632.4 +35185.4 35283.8 35510.4 35782 36010.4 36110.2 +35109.7 35185.4 35371.4 35597.2 35784.2 35860.6 Species 5 -35860.6 36110.2 36632.4 37246.4 37779.5 38038.7 -35784.2 36010.4 36490.4 37056.3 37545.3 37779.5 -35597.2 35782 36180.5 36651.6 37056.3 37246.4 -35371.4 35510.4 35816.7 36180.5 36490.4 36632.4 -35185.4 35283.8 35510.4 35782 36010.4 36110.2 -35109.7 35185.4 35371.4 35597.2 35784.2 35860.6 +35860.6 36110.2 36632.4 37246.4 37779.5 38038.7 +35784.2 36010.4 36490.4 37056.3 37545.3 37779.5 +35597.2 35782 36180.5 36651.6 37056.3 37246.4 +35371.4 35510.4 35816.7 36180.5 36490.4 36632.4 +35185.4 35283.8 35510.4 35782 36010.4 36110.2 +35109.7 35185.4 35371.4 35597.2 35784.2 35860.6 Species 6 -35860.6 36110.2 36632.4 37246.4 37779.5 38038.7 -35784.2 36010.4 36490.4 37056.3 37545.3 37779.5 -35597.2 35782 36180.5 36651.6 37056.3 37246.4 -35371.4 35510.4 35816.7 36180.5 36490.4 36632.4 -35185.4 35283.8 35510.4 35782 36010.4 36110.2 -35109.7 35185.4 35371.4 35597.2 35784.2 35860.6 +35860.6 36110.2 36632.4 37246.4 37779.5 38038.7 +35784.2 36010.4 36490.4 37056.3 37545.3 37779.5 +35597.2 35782 36180.5 36651.6 37056.3 37246.4 +35371.4 35510.4 35816.7 36180.5 36490.4 36632.4 +35185.4 35283.8 35510.4 35782 36010.4 36110.2 +35109.7 35185.4 35371.4 35597.2 35784.2 35860.6 t = 5.00e+00 nst = 198 nfe = 0 nfi = 3179 nni = 2182 hu = 9.99e-02 @@ -311,52 +311,52 @@ t = 7.00e+00 nst = 216 nfe = 0 nfi = 3477 nni = 2375 hu = 1.51e-01 c values at t = 7: Species 1 -1.18854 1.19682 1.21415 1.23453 1.25221 1.26082 -1.186 1.19351 1.20944 1.22822 1.24444 1.25221 -1.1798 1.18593 1.19916 1.21479 1.22822 1.23453 -1.17231 1.17692 1.18708 1.19916 1.20944 1.21415 -1.16614 1.1694 1.17692 1.18593 1.19351 1.19682 -1.16363 1.16614 1.17231 1.1798 1.186 1.18854 +1.18854 1.19682 1.21415 1.23453 1.25221 1.26082 +1.186 1.19351 1.20944 1.22822 1.24444 1.25221 +1.1798 1.18593 1.19916 1.21479 1.22822 1.23453 +1.17231 1.17692 1.18708 1.19916 1.20944 1.21415 +1.16614 1.1694 1.17692 1.18593 1.19351 1.19682 +1.16363 1.16614 1.17231 1.1798 1.186 1.18854 Species 2 -1.18854 1.19683 1.21415 1.23453 1.25222 1.26082 -1.186 1.19351 1.20944 1.22822 1.24444 1.25222 -1.1798 1.18594 1.19916 1.21479 1.22822 1.23453 -1.17231 1.17692 1.18709 1.19916 1.20944 1.21415 -1.16614 1.1694 1.17692 1.18594 1.19351 1.19683 -1.16363 1.16614 1.17231 1.1798 1.186 1.18854 +1.18854 1.19683 1.21415 1.23453 1.25222 1.26082 +1.186 1.19351 1.20944 1.22822 1.24444 1.25222 +1.1798 1.18594 1.19916 1.21479 1.22822 1.23453 +1.17231 1.17692 1.18709 1.19916 1.20944 1.21415 +1.16614 1.1694 1.17692 1.18594 1.19351 1.19683 +1.16363 1.16614 1.17231 1.1798 1.186 1.18854 Species 3 -1.18854 1.19683 1.21416 1.23453 1.25222 1.26082 -1.18601 1.19351 1.20944 1.22822 1.24444 1.25222 -1.1798 1.18594 1.19916 1.21479 1.22822 1.23453 -1.17231 1.17692 1.18709 1.19916 1.20944 1.21416 -1.16614 1.1694 1.17692 1.18594 1.19351 1.19683 -1.16363 1.16614 1.17231 1.1798 1.18601 1.18854 +1.18854 1.19683 1.21416 1.23453 1.25222 1.26082 +1.18601 1.19351 1.20944 1.22822 1.24444 1.25222 +1.1798 1.18594 1.19916 1.21479 1.22822 1.23453 +1.17231 1.17692 1.18709 1.19916 1.20944 1.21416 +1.16614 1.1694 1.17692 1.18594 1.19351 1.19683 +1.16363 1.16614 1.17231 1.1798 1.18601 1.18854 Species 4 -35656.3 35903.1 36424.2 37033.8 37564.6 37822.3 -35578.4 35804.9 36281.3 36845.5 37330.9 37564.6 -35393.9 35575.9 35974.4 36441.4 36845.5 37033.8 -35167.5 35307.4 35610.6 35974.4 36281.3 36424.2 -34984.3 35080.2 35307.4 35575.9 35804.9 35903.1 -34907.5 34984.3 35167.5 35393.9 35578.4 35656.3 +35656.3 35903.1 36424.2 37033.8 37564.6 37822.3 +35578.4 35804.9 36281.3 36845.5 37330.9 37564.6 +35393.9 35575.9 35974.4 36441.4 36845.5 37033.8 +35167.5 35307.4 35610.6 35974.4 36281.3 36424.2 +34984.3 35080.2 35307.4 35575.9 35804.9 35903.1 +34907.5 34984.3 35167.5 35393.9 35578.4 35656.3 Species 5 -35656.3 35903.1 36424.2 37033.8 37564.6 37822.3 -35578.4 35804.9 36281.3 36845.5 37330.9 37564.6 -35393.9 35575.9 35974.4 36441.4 36845.5 37033.8 -35167.5 35307.4 35610.6 35974.4 36281.3 36424.2 -34984.3 35080.2 35307.4 35575.9 35804.9 35903.1 -34907.5 34984.3 35167.5 35393.9 35578.4 35656.3 +35656.3 35903.1 36424.2 37033.8 37564.6 37822.3 +35578.4 35804.9 36281.3 36845.5 37330.9 37564.6 +35393.9 35575.9 35974.4 36441.4 36845.5 37033.8 +35167.5 35307.4 35610.6 35974.4 36281.3 36424.2 +34984.3 35080.2 35307.4 35575.9 35804.9 35903.1 +34907.5 34984.3 35167.5 35393.9 35578.4 35656.3 Species 6 -35656.3 35903.1 36424.2 37033.8 37564.6 37822.3 -35578.4 35804.9 36281.3 36845.5 37330.9 37564.6 -35393.9 35575.9 35974.4 36441.4 36845.5 37033.8 -35167.5 35307.4 35610.6 35974.4 36281.3 36424.2 -34984.3 35080.2 35307.4 35575.9 35804.9 35903.1 -34907.5 34984.3 35167.5 35393.9 35578.4 35656.3 +35656.3 35903.1 36424.2 37033.8 37564.6 37822.3 +35578.4 35804.9 36281.3 36845.5 37330.9 37564.6 +35393.9 35575.9 35974.4 36441.4 36845.5 37033.8 +35167.5 35307.4 35610.6 35974.4 36281.3 36424.2 +34984.3 35080.2 35307.4 35575.9 35804.9 35903.1 +34907.5 34984.3 35167.5 35393.9 35578.4 35656.3 t = 8.00e+00 nst = 232 nfe = 0 nfi = 3780 nni = 2567 hu = 1.06e-01 @@ -367,75 +367,75 @@ t = 1.00e+01 nst = 266 nfe = 0 nfi = 4394 nni = 2941 hu = 8.37e-02 c values at t = 10: Species 1 -1.18838 1.19667 1.21399 1.23437 1.25205 1.26066 -1.18585 1.19335 1.20928 1.22805 1.24428 1.25205 -1.17964 1.18578 1.199 1.21463 1.22805 1.23437 -1.17215 1.17676 1.18693 1.199 1.20928 1.21399 -1.16598 1.16925 1.17676 1.18578 1.19335 1.19667 -1.16347 1.16598 1.17215 1.17964 1.18585 1.18838 +1.18838 1.19667 1.21399 1.23437 1.25205 1.26066 +1.18585 1.19335 1.20928 1.22805 1.24428 1.25205 +1.17964 1.18578 1.199 1.21463 1.22805 1.23437 +1.17215 1.17676 1.18693 1.199 1.20928 1.21399 +1.16598 1.16925 1.17676 1.18578 1.19335 1.19667 +1.16347 1.16598 1.17215 1.17964 1.18585 1.18838 Species 2 -1.18838 1.19667 1.21399 1.23437 1.25205 1.26066 -1.18585 1.19335 1.20928 1.22805 1.24428 1.25205 -1.17964 1.18578 1.199 1.21463 1.22805 1.23437 -1.17215 1.17676 1.18693 1.199 1.20928 1.21399 -1.16598 1.16925 1.17676 1.18578 1.19335 1.19667 -1.16347 1.16598 1.17215 1.17964 1.18585 1.18838 +1.18838 1.19667 1.21399 1.23437 1.25205 1.26066 +1.18585 1.19335 1.20928 1.22805 1.24428 1.25205 +1.17964 1.18578 1.199 1.21463 1.22805 1.23437 +1.17215 1.17676 1.18693 1.199 1.20928 1.21399 +1.16598 1.16925 1.17676 1.18578 1.19335 1.19667 +1.16347 1.16598 1.17215 1.17964 1.18585 1.18838 Species 3 -1.18838 1.19667 1.21399 1.23437 1.25205 1.26066 -1.18585 1.19335 1.20928 1.22805 1.24428 1.25205 -1.17964 1.18578 1.199 1.21463 1.22805 1.23437 -1.17215 1.17676 1.18693 1.199 1.20928 1.21399 -1.16598 1.16925 1.17676 1.18578 1.19335 1.19667 -1.16347 1.16598 1.17215 1.17964 1.18585 1.18838 +1.18838 1.19667 1.21399 1.23437 1.25205 1.26066 +1.18585 1.19335 1.20928 1.22805 1.24428 1.25205 +1.17964 1.18578 1.199 1.21463 1.22805 1.23437 +1.17215 1.17676 1.18693 1.199 1.20928 1.21399 +1.16598 1.16925 1.17676 1.18578 1.19335 1.19667 +1.16347 1.16598 1.17215 1.17964 1.18585 1.18838 Species 4 -35650.6 35898.8 36418.4 37029.2 37559.5 37817.3 -35574.5 35799.5 36277.1 36840 37326.6 37559.5 -35388.4 35572.3 35968.8 36437.5 36840 37029.2 -35163.7 35302 35606.7 35968.8 36277.1 36418.4 -34978.6 35076.5 35302 35572.3 35799.5 35898.8 -34903.3 34978.6 35163.7 35388.4 35574.5 35650.6 +35650.6 35898.8 36418.4 37029.2 37559.5 37817.3 +35574.5 35799.5 36277.1 36840 37326.6 37559.5 +35388.4 35572.3 35968.8 36437.5 36840 37029.2 +35163.7 35302 35606.7 35968.8 36277.1 36418.4 +34978.6 35076.5 35302 35572.3 35799.5 35898.8 +34903.3 34978.6 35163.7 35388.4 35574.5 35650.6 Species 5 -35650.6 35898.8 36418.4 37029.2 37559.5 37817.3 -35574.5 35799.5 36277.1 36840 37326.6 37559.5 -35388.4 35572.3 35968.8 36437.5 36840 37029.2 -35163.7 35302 35606.7 35968.8 36277.1 36418.4 -34978.6 35076.5 35302 35572.3 35799.5 35898.8 -34903.3 34978.6 35163.7 35388.4 35574.5 35650.6 +35650.6 35898.8 36418.4 37029.2 37559.5 37817.3 +35574.5 35799.5 36277.1 36840 37326.6 37559.5 +35388.4 35572.3 35968.8 36437.5 36840 37029.2 +35163.7 35302 35606.7 35968.8 36277.1 36418.4 +34978.6 35076.5 35302 35572.3 35799.5 35898.8 +34903.3 34978.6 35163.7 35388.4 35574.5 35650.6 Species 6 -35650.6 35898.8 36418.4 37029.2 37559.5 37817.3 -35574.5 35799.5 36277.1 36840 37326.6 37559.5 -35388.4 35572.3 35968.8 36437.5 36840 37029.2 -35163.7 35302 35606.7 35968.8 36277.1 36418.4 -34978.6 35076.5 35302 35572.3 35799.5 35898.8 -34903.3 34978.6 35163.7 35388.4 35574.5 35650.6 +35650.6 35898.8 36418.4 37029.2 37559.5 37817.3 +35574.5 35799.5 36277.1 36840 37326.6 37559.5 +35388.4 35572.3 35968.8 36437.5 36840 37029.2 +35163.7 35302 35606.7 35968.8 36277.1 36418.4 +34978.6 35076.5 35302 35572.3 35799.5 35898.8 +34903.3 34978.6 35163.7 35388.4 35574.5 35650.6 Final statistics for this run: - ARKStep real workspace length = 3557 - ARKStep integer workspace length = 131 - ARKLS real workspace length = 2647 - ARKLS integer workspace length = 42 - Number of steps = 266 - Number of f-s (explicit) = 0 - Number of f-s (implicit) = 4394 - Number of f-s (SPGMR) = 8980 - Number of f-s (TOTAL) = 8980 - Number of setups = 121 - Number of nonlinear iterations = 2941 - Number of linear iterations = 8980 - Number of preconditioner evaluations = 121 - Number of preconditioner solves = 11819 - Number of error test failures = 23 - Number of nonlinear conv. failures = 17 - Number of linear convergence failures = 509 - Average Krylov subspace dimension = 3.053 + ARKStep real workspace length = 3554 + ARKStep integer workspace length = 131 + ARKLS real workspace length = 2647 + ARKLS integer workspace length = 42 + Number of steps = 266 + Number of f-s (explicit) = 0 + Number of f-s (implicit) = 4394 + Number of f-s (SPGMR) = 8980 + Number of f-s (TOTAL) = 8980 + Number of setups = 121 + Number of nonlinear iterations = 2941 + Number of linear iterations = 8980 + Number of preconditioner evaluations = 121 + Number of preconditioner solves = 11819 + Number of error test failures = 23 + Number of nonlinear conv. failures = 17 + Number of linear convergence failures = 509 + Average Krylov subspace dimension = 3.053 ---------------------------------------------------------------------------- @@ -487,24 +487,24 @@ t = 1.00e+01 nst = 251 nfe = 0 nfi = 4101 nni = 2746 hu = 7.09e-02 Final statistics for this run: - ARKStep real workspace length = 3557 - ARKStep integer workspace length = 136 - ARKLS real workspace length = 2647 - ARKLS integer workspace length = 42 - Number of steps = 251 - Number of f-s (explicit) = 0 - Number of f-s (implicit) = 4101 - Number of f-s (SPGMR) = 8880 - Number of f-s (TOTAL) = 8880 - Number of setups = 91 - Number of nonlinear iterations = 2746 - Number of linear iterations = 8880 - Number of preconditioner evaluations = 91 - Number of preconditioner solves = 11537 - Number of error test failures = 18 - Number of nonlinear conv. failures = 13 - Number of linear convergence failures = 597 - Average Krylov subspace dimension = 3.234 + ARKStep real workspace length = 3554 + ARKStep integer workspace length = 131 + ARKLS real workspace length = 2647 + ARKLS integer workspace length = 42 + Number of steps = 251 + Number of f-s (explicit) = 0 + Number of f-s (implicit) = 4101 + Number of f-s (SPGMR) = 8880 + Number of f-s (TOTAL) = 8880 + Number of setups = 91 + Number of nonlinear iterations = 2746 + Number of linear iterations = 8880 + Number of preconditioner evaluations = 91 + Number of preconditioner solves = 11537 + Number of error test failures = 18 + Number of nonlinear conv. failures = 13 + Number of linear convergence failures = 597 + Average Krylov subspace dimension = 3.234 ---------------------------------------------------------------------------- @@ -556,24 +556,24 @@ t = 1.00e+01 nst = 359 nfe = 0 nfi = 5722 nni = 3907 hu = 1.35e-01 Final statistics for this run: - ARKStep real workspace length = 3557 - ARKStep integer workspace length = 141 - ARKLS real workspace length = 2647 - ARKLS integer workspace length = 42 - Number of steps = 359 - Number of f-s (explicit) = 0 - Number of f-s (implicit) = 5722 - Number of f-s (SPGMR) = 12904 - Number of f-s (TOTAL) = 12904 - Number of setups = 253 - Number of nonlinear iterations = 3907 - Number of linear iterations = 12904 - Number of preconditioner evaluations = 253 - Number of preconditioner solves = 16594 - Number of error test failures = 0 - Number of nonlinear conv. failures = 117 - Number of linear convergence failures = 1072 - Average Krylov subspace dimension = 3.303 + ARKStep real workspace length = 3554 + ARKStep integer workspace length = 131 + ARKLS real workspace length = 2647 + ARKLS integer workspace length = 42 + Number of steps = 359 + Number of f-s (explicit) = 0 + Number of f-s (implicit) = 5722 + Number of f-s (SPGMR) = 12904 + Number of f-s (TOTAL) = 12904 + Number of setups = 253 + Number of nonlinear iterations = 3907 + Number of linear iterations = 12904 + Number of preconditioner evaluations = 253 + Number of preconditioner solves = 16594 + Number of error test failures = 0 + Number of nonlinear conv. failures = 117 + Number of linear convergence failures = 1072 + Average Krylov subspace dimension = 3.303 ---------------------------------------------------------------------------- @@ -625,24 +625,24 @@ t = 1.00e+01 nst = 359 nfe = 0 nfi = 5728 nni = 3912 hu = 1.31e-01 Final statistics for this run: - ARKStep real workspace length = 3557 - ARKStep integer workspace length = 146 - ARKLS real workspace length = 2647 - ARKLS integer workspace length = 42 - Number of steps = 359 - Number of f-s (explicit) = 0 - Number of f-s (implicit) = 5728 - Number of f-s (SPGMR) = 12934 - Number of f-s (TOTAL) = 12934 - Number of setups = 254 - Number of nonlinear iterations = 3912 - Number of linear iterations = 12934 - Number of preconditioner evaluations = 254 - Number of preconditioner solves = 16627 - Number of error test failures = 0 - Number of nonlinear conv. failures = 118 - Number of linear convergence failures = 1076 - Average Krylov subspace dimension = 3.306 + ARKStep real workspace length = 3554 + ARKStep integer workspace length = 131 + ARKLS real workspace length = 2647 + ARKLS integer workspace length = 42 + Number of steps = 359 + Number of f-s (explicit) = 0 + Number of f-s (implicit) = 5728 + Number of f-s (SPGMR) = 12934 + Number of f-s (TOTAL) = 12934 + Number of setups = 254 + Number of nonlinear iterations = 3912 + Number of linear iterations = 12934 + Number of preconditioner evaluations = 254 + Number of preconditioner solves = 16627 + Number of error test failures = 0 + Number of nonlinear conv. failures = 118 + Number of linear convergence failures = 1076 + Average Krylov subspace dimension = 3.306 ---------------------------------------------------------------------------- diff --git a/examples/arkode/C_serial/ark_KrylovDemo_prec_1.out b/examples/arkode/C_serial/ark_KrylovDemo_prec_1.out index 58b34e703d..09364ad394 100644 --- a/examples/arkode/C_serial/ark_KrylovDemo_prec_1.out +++ b/examples/arkode/C_serial/ark_KrylovDemo_prec_1.out @@ -10,9 +10,9 @@ b parameter = 1 Diffusion coefficients: Dprey = 1 Dpred = 0.5 Rate parameter alpha = 1 -Mesh dimensions (mx,my) are 6, 6. Total system size is neq = 216 +Mesh dimensions (mx,my) are 6, 6. Total system size is neq = 216 -Tolerances: reltol = 1e-05, abstol = 1e-05 +Tolerances: reltol = 1e-05, abstol = 1e-05 Preconditioning uses a product of: (1) Gauss-Seidel iterations with itmax = 5 iterations, and @@ -31,52 +31,52 @@ Gram-Schmidt method type is gstype = SUN_MODIFIED_GS c values at t = 0: Species 1 -10 10 10 10 10 10 -10 10.1678 10.3775 10.3775 10.1678 10 -10 10.3775 10.8493 10.8493 10.3775 10 -10 10.3775 10.8493 10.8493 10.3775 10 -10 10.1678 10.3775 10.3775 10.1678 10 -10 10 10 10 10 10 +10 10 10 10 10 10 +10 10.1678 10.3775 10.3775 10.1678 10 +10 10.3775 10.8493 10.8493 10.3775 10 +10 10.3775 10.8493 10.8493 10.3775 10 +10 10.1678 10.3775 10.3775 10.1678 10 +10 10 10 10 10 10 Species 2 -10 10 10 10 10 10 -10 10.3355 10.755 10.755 10.3355 10 -10 10.755 11.6987 11.6987 10.755 10 -10 10.755 11.6987 11.6987 10.755 10 -10 10.3355 10.755 10.755 10.3355 10 -10 10 10 10 10 10 +10 10 10 10 10 10 +10 10.3355 10.755 10.755 10.3355 10 +10 10.755 11.6987 11.6987 10.755 10 +10 10.755 11.6987 11.6987 10.755 10 +10 10.3355 10.755 10.755 10.3355 10 +10 10 10 10 10 10 Species 3 -10 10 10 10 10 10 -10 10.5033 11.1325 11.1325 10.5033 10 -10 11.1325 12.548 12.548 11.1325 10 -10 11.1325 12.548 12.548 11.1325 10 -10 10.5033 11.1325 11.1325 10.5033 10 -10 10 10 10 10 10 +10 10 10 10 10 10 +10 10.5033 11.1325 11.1325 10.5033 10 +10 11.1325 12.548 12.548 11.1325 10 +10 11.1325 12.548 12.548 11.1325 10 +10 10.5033 11.1325 11.1325 10.5033 10 +10 10 10 10 10 10 Species 4 -10 10 10 10 10 10 -10 10.6711 11.5099 11.5099 10.6711 10 -10 11.5099 13.3974 13.3974 11.5099 10 -10 11.5099 13.3974 13.3974 11.5099 10 -10 10.6711 11.5099 11.5099 10.6711 10 -10 10 10 10 10 10 +10 10 10 10 10 10 +10 10.6711 11.5099 11.5099 10.6711 10 +10 11.5099 13.3974 13.3974 11.5099 10 +10 11.5099 13.3974 13.3974 11.5099 10 +10 10.6711 11.5099 11.5099 10.6711 10 +10 10 10 10 10 10 Species 5 -10 10 10 10 10 10 -10 10.8389 11.8874 11.8874 10.8389 10 -10 11.8874 14.2467 14.2467 11.8874 10 -10 11.8874 14.2467 14.2467 11.8874 10 -10 10.8389 11.8874 11.8874 10.8389 10 -10 10 10 10 10 10 +10 10 10 10 10 10 +10 10.8389 11.8874 11.8874 10.8389 10 +10 11.8874 14.2467 14.2467 11.8874 10 +10 11.8874 14.2467 14.2467 11.8874 10 +10 10.8389 11.8874 11.8874 10.8389 10 +10 10 10 10 10 10 Species 6 -10 10 10 10 10 10 -10 11.0066 12.2649 12.2649 11.0066 10 -10 12.2649 15.0961 15.0961 12.2649 10 -10 12.2649 15.0961 15.0961 12.2649 10 -10 11.0066 12.2649 12.2649 11.0066 10 -10 10 10 10 10 10 +10 10 10 10 10 10 +10 11.0066 12.2649 12.2649 11.0066 10 +10 12.2649 15.0961 15.0961 12.2649 10 +10 12.2649 15.0961 15.0961 12.2649 10 +10 11.0066 12.2649 12.2649 11.0066 10 +10 10 10 10 10 10 t = 1.00e-08 nst = 5 nfe = 0 nfi = 75 nni = 47 hu = 9.89e-08 @@ -87,52 +87,52 @@ t = 1.00e-06 nst = 8 nfe = 0 nfi = 120 nni = 77 hu = 4.79e-07 c values at t = 1e-06: Species 1 -9.99991 9.99992 9.99993 9.99993 9.99993 9.99992 -9.99992 10.1677 10.3774 10.3774 10.1677 9.99993 -9.99993 10.3774 10.8492 10.8492 10.3774 9.99993 -9.99993 10.3774 10.8492 10.8492 10.3774 9.99993 -9.99992 10.1677 10.3774 10.3774 10.1677 9.99992 -9.99991 9.99992 9.99993 9.99993 9.99992 9.99991 +9.99991 9.99992 9.99993 9.99993 9.99993 9.99992 +9.99992 10.1677 10.3774 10.3774 10.1677 9.99993 +9.99993 10.3774 10.8492 10.8492 10.3774 9.99993 +9.99993 10.3774 10.8492 10.8492 10.3774 9.99993 +9.99992 10.1677 10.3774 10.3774 10.1677 9.99992 +9.99991 9.99992 9.99993 9.99993 9.99992 9.99991 Species 2 -9.99991 9.99993 9.99995 9.99995 9.99993 9.99992 -9.99993 10.3355 10.7549 10.7549 10.3355 9.99993 -9.99995 10.7549 11.6985 11.6985 10.7549 9.99995 -9.99995 10.7549 11.6985 11.6985 10.7549 9.99995 -9.99993 10.3355 10.7549 10.7549 10.3355 9.99993 -9.99991 9.99993 9.99995 9.99995 9.99993 9.99991 +9.99991 9.99993 9.99995 9.99995 9.99993 9.99992 +9.99993 10.3355 10.7549 10.7549 10.3355 9.99993 +9.99995 10.7549 11.6985 11.6985 10.7549 9.99995 +9.99995 10.7549 11.6985 11.6985 10.7549 9.99995 +9.99993 10.3355 10.7549 10.7549 10.3355 9.99993 +9.99991 9.99993 9.99995 9.99995 9.99993 9.99991 Species 3 -9.99991 9.99994 9.99997 9.99997 9.99994 9.99992 -9.99994 10.5032 11.1323 11.1323 10.5032 9.99994 -9.99997 11.1323 12.5478 12.5478 11.1323 9.99997 -9.99997 11.1323 12.5478 12.5478 11.1323 9.99997 -9.99994 10.5032 11.1323 11.1323 10.5032 9.99994 -9.99991 9.99994 9.99997 9.99997 9.99994 9.99991 +9.99991 9.99994 9.99997 9.99997 9.99994 9.99992 +9.99994 10.5032 11.1323 11.1323 10.5032 9.99994 +9.99997 11.1323 12.5478 12.5478 11.1323 9.99997 +9.99997 11.1323 12.5478 12.5478 11.1323 9.99997 +9.99994 10.5032 11.1323 11.1323 10.5032 9.99994 +9.99991 9.99994 9.99997 9.99997 9.99994 9.99991 Species 4 -13.4984 13.4984 13.4984 13.4984 13.4984 13.4984 -13.4984 14.55 15.8924 15.8924 14.55 13.4984 -13.4984 15.8924 19.0296 19.0296 15.8924 13.4984 -13.4984 15.8924 19.0296 19.0296 15.8924 13.4984 -13.4984 14.55 15.8924 15.8924 14.55 13.4984 -13.4984 13.4984 13.4984 13.4984 13.4984 13.4984 +13.4984 13.4984 13.4984 13.4984 13.4984 13.4984 +13.4984 14.55 15.8924 15.8924 14.55 13.4984 +13.4984 15.8924 19.0296 19.0296 15.8924 13.4984 +13.4984 15.8924 19.0296 19.0296 15.8924 13.4984 +13.4984 14.55 15.8924 15.8924 14.55 13.4984 +13.4984 13.4984 13.4984 13.4984 13.4984 13.4984 Species 5 -13.4984 13.4984 13.4985 13.4985 13.4984 13.4984 -13.4984 14.7787 16.4136 16.4136 14.7787 13.4984 -13.4985 16.4136 20.236 20.236 16.4136 13.4985 -13.4985 16.4136 20.236 20.236 16.4136 13.4985 -13.4984 14.7787 16.4136 16.4136 14.7787 13.4984 -13.4984 13.4984 13.4985 13.4985 13.4984 13.4984 +13.4984 13.4984 13.4985 13.4985 13.4984 13.4984 +13.4984 14.7787 16.4136 16.4136 14.7787 13.4984 +13.4985 16.4136 20.236 20.236 16.4136 13.4985 +13.4985 16.4136 20.236 20.236 16.4136 13.4985 +13.4984 14.7787 16.4136 16.4136 14.7787 13.4984 +13.4984 13.4984 13.4985 13.4985 13.4984 13.4984 Species 6 -13.4984 13.4984 13.4985 13.4985 13.4984 13.4984 -13.4984 15.0075 16.9348 16.9348 15.0075 13.4984 -13.4985 16.9348 21.4423 21.4423 16.9348 13.4985 -13.4985 16.9348 21.4423 21.4423 16.9348 13.4985 -13.4984 15.0075 16.9348 16.9348 15.0075 13.4984 -13.4984 13.4984 13.4985 13.4985 13.4984 13.4984 +13.4984 13.4984 13.4985 13.4985 13.4984 13.4984 +13.4984 15.0075 16.9348 16.9348 15.0075 13.4984 +13.4985 16.9348 21.4423 21.4423 16.9348 13.4985 +13.4985 16.9348 21.4423 21.4423 16.9348 13.4985 +13.4984 15.0075 16.9348 16.9348 15.0075 13.4984 +13.4984 13.4984 13.4985 13.4985 13.4984 13.4984 t = 1.00e-05 nst = 27 nfe = 0 nfi = 407 nni = 269 hu = 4.79e-07 @@ -143,52 +143,52 @@ t = 1.00e-03 nst = 110 nfe = 0 nfi = 1750 nni = 1197 hu = 1.51e-03 c values at t = 0.001: Species 1 -9.90702 9.91664 9.92836 9.93033 9.92253 9.91674 -9.91472 10.0747 10.2769 10.2785 10.0795 9.92253 -9.92446 10.2748 10.7181 10.7194 10.2785 9.93033 -9.92445 10.2744 10.7173 10.7181 10.2769 9.92836 -9.91469 10.0734 10.2744 10.2748 10.0747 9.91664 -9.90698 9.91469 9.92445 9.92446 9.91472 9.90702 +9.90702 9.91664 9.92836 9.93033 9.92253 9.91674 +9.91472 10.0747 10.2769 10.2785 10.0795 9.92253 +9.92446 10.2748 10.7181 10.7194 10.2785 9.93033 +9.92445 10.2744 10.7173 10.7181 10.2769 9.92836 +9.91469 10.0734 10.2744 10.2748 10.0747 9.91664 +9.90698 9.91469 9.92445 9.92446 9.91472 9.90702 Species 2 -9.90742 9.92474 9.94622 9.94819 9.93064 9.91713 -9.92282 10.2412 10.644 10.6457 10.2461 9.93064 -9.94232 10.6419 11.5267 11.5281 10.6457 9.94819 -9.94231 10.6415 11.5258 11.5267 10.644 9.94622 -9.92279 10.24 10.6415 10.6419 10.2412 9.92474 -9.90737 9.92279 9.94231 9.94232 9.92282 9.90742 +9.90742 9.92474 9.94622 9.94819 9.93064 9.91713 +9.92282 10.2412 10.644 10.6457 10.2461 9.93064 +9.94232 10.6419 11.5267 11.5281 10.6457 9.94819 +9.94231 10.6415 11.5258 11.5267 10.644 9.94622 +9.92279 10.24 10.6415 10.6419 10.2412 9.92474 +9.90737 9.92279 9.94231 9.94232 9.92282 9.90742 Species 3 -9.90781 9.93284 9.96408 9.96605 9.93874 9.91753 -9.93092 10.4078 11.0109 11.0127 10.4127 9.93874 -9.96017 11.0088 12.3339 12.3354 11.0127 9.96605 -9.96016 11.0083 12.333 12.3339 11.0109 9.96408 -9.93088 10.4065 11.0083 11.0088 10.4078 9.93284 -9.90776 9.93088 9.96016 9.96017 9.93092 9.90781 +9.90781 9.93284 9.96408 9.96605 9.93874 9.91753 +9.93092 10.4078 11.0109 11.0127 10.4127 9.93874 +9.96017 11.0088 12.3339 12.3354 11.0127 9.96605 +9.96016 11.0083 12.333 12.3339 11.0109 9.96408 +9.93088 10.4065 11.0083 11.0088 10.4078 9.93284 +9.90776 9.93088 9.96016 9.96017 9.93092 9.90781 Species 4 -297231 297749 298392 298451 297925 297520 -297692 307245 319327 319378 307390 297925 -298276 319264 345799 345840 319378 298451 -298276 319252 345772 345799 319327 298392 -297691 307208 319252 319264 307245 297749 -297229 297691 298276 298276 297692 297231 +297231 297749 298392 298451 297925 297520 +297692 307245 319327 319378 307390 297925 +298276 319264 345799 345840 319378 298451 +298276 319252 345772 345799 319327 298392 +297691 307208 319252 319264 307245 297749 +297229 297691 298276 298276 297692 297231 Species 5 -297231 297749 298392 298451 297925 297520 -297692 307245 319327 319378 307390 297925 -298276 319264 345799 345840 319378 298451 -298276 319252 345772 345799 319327 298392 -297691 307208 319252 319264 307245 297749 -297229 297691 298276 298276 297692 297231 +297231 297749 298392 298451 297925 297520 +297692 307245 319327 319378 307390 297925 +298276 319264 345799 345840 319378 298451 +298276 319252 345772 345799 319327 298392 +297691 307208 319252 319264 307245 297749 +297229 297691 298276 298276 297692 297231 Species 6 -297231 297749 298392 298451 297925 297520 -297692 307245 319327 319378 307390 297925 -298276 319264 345799 345840 319378 298451 -298276 319252 345772 345799 319327 298392 -297691 307208 319252 319264 307245 297749 -297229 297691 298276 298276 297692 297231 +297231 297749 298392 298451 297925 297520 +297692 307245 319327 319378 307390 297925 +298276 319264 345799 345840 319378 298451 +298276 319252 345772 345799 319327 298392 +297691 307208 319252 319264 307245 297749 +297229 297691 298276 298276 297692 297231 t = 1.00e-02 nst = 113 nfe = 0 nfi = 1797 nni = 1229 hu = 3.46e-03 @@ -199,52 +199,52 @@ t = 1.00e+00 nst = 154 nfe = 0 nfi = 2489 nni = 1716 hu = 6.84e-02 c values at t = 1: Species 1 -1.58851 1.59924 1.62152 1.64764 1.67036 1.68149 -1.58533 1.59503 1.61548 1.63952 1.66033 1.67036 -1.57757 1.58547 1.60239 1.62235 1.63952 1.64764 -1.5682 1.57412 1.58706 1.60239 1.61548 1.62152 -1.56048 1.56463 1.57412 1.58547 1.59503 1.59924 -1.55733 1.56048 1.5682 1.57757 1.58533 1.58851 +1.58851 1.59924 1.62152 1.64764 1.67036 1.68149 +1.58533 1.59503 1.61548 1.63952 1.66033 1.67036 +1.57757 1.58547 1.60239 1.62235 1.63952 1.64764 +1.5682 1.57412 1.58706 1.60239 1.61548 1.62152 +1.56048 1.56463 1.57412 1.58547 1.59503 1.59924 +1.55733 1.56048 1.5682 1.57757 1.58533 1.58851 Species 2 -1.59067 1.60141 1.62371 1.64987 1.67261 1.68375 -1.58748 1.5972 1.61766 1.64173 1.66257 1.67261 -1.57971 1.58763 1.60457 1.62454 1.64173 1.64987 -1.57034 1.57626 1.58921 1.60457 1.61766 1.62371 -1.56261 1.56676 1.57626 1.58763 1.5972 1.60141 -1.55945 1.56261 1.57034 1.57971 1.58748 1.59067 +1.59067 1.60141 1.62371 1.64987 1.67261 1.68375 +1.58748 1.5972 1.61766 1.64173 1.66257 1.67261 +1.57971 1.58763 1.60457 1.62454 1.64173 1.64987 +1.57034 1.57626 1.58921 1.60457 1.61766 1.62371 +1.56261 1.56676 1.57626 1.58763 1.5972 1.60141 +1.55945 1.56261 1.57034 1.57971 1.58748 1.59067 Species 3 -1.5927 1.60346 1.62578 1.65197 1.67474 1.68589 -1.58951 1.59924 1.61973 1.64383 1.66468 1.67474 -1.58174 1.58966 1.60662 1.62662 1.64383 1.65197 -1.57236 1.57828 1.59125 1.60662 1.61973 1.62578 -1.56462 1.56878 1.57828 1.58966 1.59924 1.60346 -1.56146 1.56462 1.57236 1.58174 1.58951 1.5927 +1.5927 1.60346 1.62578 1.65197 1.67474 1.68589 +1.58951 1.59924 1.61973 1.64383 1.66468 1.67474 +1.58174 1.58966 1.60662 1.62662 1.64383 1.65197 +1.57236 1.57828 1.59125 1.60662 1.61973 1.62578 +1.56462 1.56878 1.57828 1.58966 1.59924 1.60346 +1.56146 1.56462 1.57236 1.58174 1.58951 1.5927 Species 4 -47718.3 48040.3 48709 49493.5 50175.5 50509.4 -47622.8 47914 48527.8 49249.6 49874.4 50175.5 -47389.7 47627 48134.9 48734.2 49249.6 49493.5 -47108.5 47286 47674.6 48134.9 48527.8 48709 -46876.6 47001.2 47286 47627 47914 48040.3 -46781.9 46876.6 47108.5 47389.7 47622.8 47718.3 +47718.3 48040.3 48709 49493.5 50175.5 50509.4 +47622.8 47914 48527.8 49249.6 49874.4 50175.5 +47389.7 47627 48134.9 48734.2 49249.6 49493.5 +47108.5 47286 47674.6 48134.9 48527.8 48709 +46876.6 47001.2 47286 47627 47914 48040.3 +46781.9 46876.6 47108.5 47389.7 47622.8 47718.3 Species 5 -47718.3 48040.3 48709 49493.5 50175.5 50509.4 -47622.8 47914 48527.8 49249.6 49874.4 50175.5 -47389.7 47627 48134.9 48734.2 49249.6 49493.5 -47108.5 47286 47674.6 48134.9 48527.8 48709 -46876.6 47001.2 47286 47627 47914 48040.3 -46781.9 46876.6 47108.5 47389.7 47622.8 47718.3 +47718.3 48040.3 48709 49493.5 50175.5 50509.4 +47622.8 47914 48527.8 49249.6 49874.4 50175.5 +47389.7 47627 48134.9 48734.2 49249.6 49493.5 +47108.5 47286 47674.6 48134.9 48527.8 48709 +46876.6 47001.2 47286 47627 47914 48040.3 +46781.9 46876.6 47108.5 47389.7 47622.8 47718.3 Species 6 -47718.3 48040.3 48709 49493.5 50175.5 50509.4 -47622.8 47914 48527.8 49249.6 49874.4 50175.5 -47389.7 47627 48134.9 48734.2 49249.6 49493.5 -47108.5 47286 47674.6 48134.9 48527.8 48709 -46876.6 47001.2 47286 47627 47914 48040.3 -46781.9 46876.6 47108.5 47389.7 47622.8 47718.3 +47718.3 48040.3 48709 49493.5 50175.5 50509.4 +47622.8 47914 48527.8 49249.6 49874.4 50175.5 +47389.7 47627 48134.9 48734.2 49249.6 49493.5 +47108.5 47286 47674.6 48134.9 48527.8 48709 +46876.6 47001.2 47286 47627 47914 48040.3 +46781.9 46876.6 47108.5 47389.7 47622.8 47718.3 t = 2.00e+00 nst = 165 nfe = 0 nfi = 2661 nni = 1833 hu = 4.14e-02 @@ -255,52 +255,52 @@ t = 4.00e+00 nst = 187 nfe = 0 nfi = 3013 nni = 2073 hu = 1.23e-01 c values at t = 4: Species 1 -1.19535 1.20368 1.2211 1.24157 1.25935 1.268 -1.1928 1.20035 1.21636 1.23523 1.25154 1.25935 -1.18657 1.19274 1.20602 1.22173 1.23523 1.24157 -1.17904 1.18368 1.19389 1.20602 1.21636 1.2211 -1.17284 1.17613 1.18368 1.19274 1.20035 1.20368 -1.17032 1.17284 1.17904 1.18657 1.1928 1.19535 +1.19535 1.20368 1.2211 1.24157 1.25935 1.268 +1.1928 1.20035 1.21636 1.23523 1.25154 1.25935 +1.18657 1.19274 1.20602 1.22173 1.23523 1.24157 +1.17904 1.18368 1.19389 1.20602 1.21636 1.2211 +1.17284 1.17613 1.18368 1.19274 1.20035 1.20368 +1.17032 1.17284 1.17904 1.18657 1.1928 1.19535 Species 2 -1.19538 1.20371 1.22113 1.24161 1.25938 1.26804 -1.19284 1.20038 1.21639 1.23526 1.25157 1.25938 -1.1866 1.19277 1.20606 1.22177 1.23526 1.24161 -1.17908 1.18371 1.19393 1.20606 1.21639 1.22113 -1.17288 1.17616 1.18371 1.19277 1.20038 1.20371 -1.17035 1.17288 1.17908 1.1866 1.19284 1.19538 +1.19538 1.20371 1.22113 1.24161 1.25938 1.26804 +1.19284 1.20038 1.21639 1.23526 1.25157 1.25938 +1.1866 1.19277 1.20606 1.22177 1.23526 1.24161 +1.17908 1.18371 1.19393 1.20606 1.21639 1.22113 +1.17288 1.17616 1.18371 1.19277 1.20038 1.20371 +1.17035 1.17288 1.17908 1.1866 1.19284 1.19538 Species 3 -1.19542 1.20374 1.22116 1.24164 1.25942 1.26807 -1.19287 1.20042 1.21642 1.2353 1.2516 1.25942 -1.18663 1.1928 1.20609 1.2218 1.2353 1.24164 -1.17911 1.18374 1.19396 1.20609 1.21642 1.22116 -1.17291 1.17619 1.18374 1.1928 1.20042 1.20374 -1.17039 1.17291 1.17911 1.18663 1.19287 1.19542 +1.19542 1.20374 1.22116 1.24164 1.25942 1.26807 +1.19287 1.20042 1.21642 1.2353 1.2516 1.25942 +1.18663 1.1928 1.20609 1.2218 1.2353 1.24164 +1.17911 1.18374 1.19396 1.20609 1.21642 1.22116 +1.17291 1.17619 1.18374 1.1928 1.20042 1.20374 +1.17039 1.17291 1.17911 1.18663 1.19287 1.19542 Species 4 -35860.6 36110.2 36632.4 37246.4 37779.5 38038.7 -35784.2 36010.4 36490.4 37056.3 37545.3 37779.5 -35597.2 35782 36180.5 36651.6 37056.3 37246.4 -35371.4 35510.4 35816.7 36180.5 36490.4 36632.4 -35185.4 35283.8 35510.4 35782 36010.4 36110.2 -35109.7 35185.4 35371.4 35597.2 35784.2 35860.6 +35860.6 36110.2 36632.4 37246.4 37779.5 38038.7 +35784.2 36010.4 36490.4 37056.3 37545.3 37779.5 +35597.2 35782 36180.5 36651.6 37056.3 37246.4 +35371.4 35510.4 35816.7 36180.5 36490.4 36632.4 +35185.4 35283.8 35510.4 35782 36010.4 36110.2 +35109.7 35185.4 35371.4 35597.2 35784.2 35860.6 Species 5 -35860.6 36110.2 36632.4 37246.4 37779.5 38038.7 -35784.2 36010.4 36490.4 37056.3 37545.3 37779.5 -35597.2 35782 36180.5 36651.6 37056.3 37246.4 -35371.4 35510.4 35816.7 36180.5 36490.4 36632.4 -35185.4 35283.8 35510.4 35782 36010.4 36110.2 -35109.7 35185.4 35371.4 35597.2 35784.2 35860.6 +35860.6 36110.2 36632.4 37246.4 37779.5 38038.7 +35784.2 36010.4 36490.4 37056.3 37545.3 37779.5 +35597.2 35782 36180.5 36651.6 37056.3 37246.4 +35371.4 35510.4 35816.7 36180.5 36490.4 36632.4 +35185.4 35283.8 35510.4 35782 36010.4 36110.2 +35109.7 35185.4 35371.4 35597.2 35784.2 35860.6 Species 6 -35860.6 36110.2 36632.4 37246.4 37779.5 38038.7 -35784.2 36010.4 36490.4 37056.3 37545.3 37779.5 -35597.2 35782 36180.5 36651.6 37056.3 37246.4 -35371.4 35510.4 35816.7 36180.5 36490.4 36632.4 -35185.4 35283.8 35510.4 35782 36010.4 36110.2 -35109.7 35185.4 35371.4 35597.2 35784.2 35860.6 +35860.6 36110.2 36632.4 37246.4 37779.5 38038.7 +35784.2 36010.4 36490.4 37056.3 37545.3 37779.5 +35597.2 35782 36180.5 36651.6 37056.3 37246.4 +35371.4 35510.4 35816.7 36180.5 36490.4 36632.4 +35185.4 35283.8 35510.4 35782 36010.4 36110.2 +35109.7 35185.4 35371.4 35597.2 35784.2 35860.6 t = 5.00e+00 nst = 198 nfe = 0 nfi = 3179 nni = 2182 hu = 9.99e-02 @@ -311,52 +311,52 @@ t = 7.00e+00 nst = 216 nfe = 0 nfi = 3477 nni = 2375 hu = 1.51e-01 c values at t = 7: Species 1 -1.18854 1.19682 1.21415 1.23453 1.25221 1.26082 -1.186 1.19351 1.20944 1.22822 1.24444 1.25221 -1.1798 1.18593 1.19916 1.21479 1.22822 1.23453 -1.17231 1.17692 1.18708 1.19916 1.20944 1.21415 -1.16614 1.1694 1.17692 1.18593 1.19351 1.19682 -1.16363 1.16614 1.17231 1.1798 1.186 1.18854 +1.18854 1.19682 1.21415 1.23453 1.25221 1.26082 +1.186 1.19351 1.20944 1.22822 1.24444 1.25221 +1.1798 1.18593 1.19916 1.21479 1.22822 1.23453 +1.17231 1.17692 1.18708 1.19916 1.20944 1.21415 +1.16614 1.1694 1.17692 1.18593 1.19351 1.19682 +1.16363 1.16614 1.17231 1.1798 1.186 1.18854 Species 2 -1.18854 1.19683 1.21415 1.23453 1.25222 1.26082 -1.186 1.19351 1.20944 1.22822 1.24444 1.25222 -1.1798 1.18594 1.19916 1.21479 1.22822 1.23453 -1.17231 1.17692 1.18709 1.19916 1.20944 1.21415 -1.16614 1.1694 1.17692 1.18594 1.19351 1.19683 -1.16363 1.16614 1.17231 1.1798 1.186 1.18854 +1.18854 1.19683 1.21415 1.23453 1.25222 1.26082 +1.186 1.19351 1.20944 1.22822 1.24444 1.25222 +1.1798 1.18594 1.19916 1.21479 1.22822 1.23453 +1.17231 1.17692 1.18709 1.19916 1.20944 1.21415 +1.16614 1.1694 1.17692 1.18594 1.19351 1.19683 +1.16363 1.16614 1.17231 1.1798 1.186 1.18854 Species 3 -1.18854 1.19683 1.21416 1.23453 1.25222 1.26082 -1.18601 1.19351 1.20944 1.22822 1.24444 1.25222 -1.1798 1.18594 1.19916 1.21479 1.22822 1.23453 -1.17231 1.17692 1.18709 1.19916 1.20944 1.21416 -1.16614 1.1694 1.17692 1.18594 1.19351 1.19683 -1.16363 1.16614 1.17231 1.1798 1.18601 1.18854 +1.18854 1.19683 1.21416 1.23453 1.25222 1.26082 +1.18601 1.19351 1.20944 1.22822 1.24444 1.25222 +1.1798 1.18594 1.19916 1.21479 1.22822 1.23453 +1.17231 1.17692 1.18709 1.19916 1.20944 1.21416 +1.16614 1.1694 1.17692 1.18594 1.19351 1.19683 +1.16363 1.16614 1.17231 1.1798 1.18601 1.18854 Species 4 -35656.3 35903.1 36424.2 37033.8 37564.6 37822.3 -35578.4 35804.9 36281.3 36845.5 37330.9 37564.6 -35393.9 35575.9 35974.4 36441.4 36845.5 37033.8 -35167.5 35307.4 35610.6 35974.4 36281.3 36424.2 -34984.3 35080.2 35307.4 35575.9 35804.9 35903.1 -34907.5 34984.3 35167.5 35393.9 35578.4 35656.3 +35656.3 35903.1 36424.2 37033.8 37564.6 37822.3 +35578.4 35804.9 36281.3 36845.5 37330.9 37564.6 +35393.9 35575.9 35974.4 36441.4 36845.5 37033.8 +35167.5 35307.4 35610.6 35974.4 36281.3 36424.2 +34984.3 35080.2 35307.4 35575.9 35804.9 35903.1 +34907.5 34984.3 35167.5 35393.9 35578.4 35656.3 Species 5 -35656.3 35903.1 36424.2 37033.8 37564.6 37822.3 -35578.4 35804.9 36281.3 36845.5 37330.9 37564.6 -35393.9 35575.9 35974.4 36441.4 36845.5 37033.8 -35167.5 35307.4 35610.6 35974.4 36281.3 36424.2 -34984.3 35080.2 35307.4 35575.9 35804.9 35903.1 -34907.5 34984.3 35167.5 35393.9 35578.4 35656.3 +35656.3 35903.1 36424.2 37033.8 37564.6 37822.3 +35578.4 35804.9 36281.3 36845.5 37330.9 37564.6 +35393.9 35575.9 35974.4 36441.4 36845.5 37033.8 +35167.5 35307.4 35610.6 35974.4 36281.3 36424.2 +34984.3 35080.2 35307.4 35575.9 35804.9 35903.1 +34907.5 34984.3 35167.5 35393.9 35578.4 35656.3 Species 6 -35656.3 35903.1 36424.2 37033.8 37564.6 37822.3 -35578.4 35804.9 36281.3 36845.5 37330.9 37564.6 -35393.9 35575.9 35974.4 36441.4 36845.5 37033.8 -35167.5 35307.4 35610.6 35974.4 36281.3 36424.2 -34984.3 35080.2 35307.4 35575.9 35804.9 35903.1 -34907.5 34984.3 35167.5 35393.9 35578.4 35656.3 +35656.3 35903.1 36424.2 37033.8 37564.6 37822.3 +35578.4 35804.9 36281.3 36845.5 37330.9 37564.6 +35393.9 35575.9 35974.4 36441.4 36845.5 37033.8 +35167.5 35307.4 35610.6 35974.4 36281.3 36424.2 +34984.3 35080.2 35307.4 35575.9 35804.9 35903.1 +34907.5 34984.3 35167.5 35393.9 35578.4 35656.3 t = 8.00e+00 nst = 232 nfe = 0 nfi = 3780 nni = 2567 hu = 1.06e-01 @@ -367,75 +367,75 @@ t = 1.00e+01 nst = 266 nfe = 0 nfi = 4394 nni = 2941 hu = 8.37e-02 c values at t = 10: Species 1 -1.18838 1.19667 1.21399 1.23437 1.25205 1.26066 -1.18585 1.19335 1.20928 1.22805 1.24428 1.25205 -1.17964 1.18578 1.199 1.21463 1.22805 1.23437 -1.17215 1.17676 1.18693 1.199 1.20928 1.21399 -1.16598 1.16925 1.17676 1.18578 1.19335 1.19667 -1.16347 1.16598 1.17215 1.17964 1.18585 1.18838 +1.18838 1.19667 1.21399 1.23437 1.25205 1.26066 +1.18585 1.19335 1.20928 1.22805 1.24428 1.25205 +1.17964 1.18578 1.199 1.21463 1.22805 1.23437 +1.17215 1.17676 1.18693 1.199 1.20928 1.21399 +1.16598 1.16925 1.17676 1.18578 1.19335 1.19667 +1.16347 1.16598 1.17215 1.17964 1.18585 1.18838 Species 2 -1.18838 1.19667 1.21399 1.23437 1.25205 1.26066 -1.18585 1.19335 1.20928 1.22805 1.24428 1.25205 -1.17964 1.18578 1.199 1.21463 1.22805 1.23437 -1.17215 1.17676 1.18693 1.199 1.20928 1.21399 -1.16598 1.16925 1.17676 1.18578 1.19335 1.19667 -1.16347 1.16598 1.17215 1.17964 1.18585 1.18838 +1.18838 1.19667 1.21399 1.23437 1.25205 1.26066 +1.18585 1.19335 1.20928 1.22805 1.24428 1.25205 +1.17964 1.18578 1.199 1.21463 1.22805 1.23437 +1.17215 1.17676 1.18693 1.199 1.20928 1.21399 +1.16598 1.16925 1.17676 1.18578 1.19335 1.19667 +1.16347 1.16598 1.17215 1.17964 1.18585 1.18838 Species 3 -1.18838 1.19667 1.21399 1.23437 1.25205 1.26066 -1.18585 1.19335 1.20928 1.22805 1.24428 1.25205 -1.17964 1.18578 1.199 1.21463 1.22805 1.23437 -1.17215 1.17676 1.18693 1.199 1.20928 1.21399 -1.16598 1.16925 1.17676 1.18578 1.19335 1.19667 -1.16347 1.16598 1.17215 1.17964 1.18585 1.18838 +1.18838 1.19667 1.21399 1.23437 1.25205 1.26066 +1.18585 1.19335 1.20928 1.22805 1.24428 1.25205 +1.17964 1.18578 1.199 1.21463 1.22805 1.23437 +1.17215 1.17676 1.18693 1.199 1.20928 1.21399 +1.16598 1.16925 1.17676 1.18578 1.19335 1.19667 +1.16347 1.16598 1.17215 1.17964 1.18585 1.18838 Species 4 -35650.6 35898.8 36418.4 37029.2 37559.5 37817.3 -35574.5 35799.5 36277.1 36840 37326.6 37559.5 -35388.4 35572.3 35968.8 36437.5 36840 37029.2 -35163.7 35302 35606.7 35968.8 36277.1 36418.4 -34978.6 35076.5 35302 35572.3 35799.5 35898.8 -34903.3 34978.6 35163.7 35388.4 35574.5 35650.6 +35650.6 35898.8 36418.4 37029.2 37559.5 37817.3 +35574.5 35799.5 36277.1 36840 37326.6 37559.5 +35388.4 35572.3 35968.8 36437.5 36840 37029.2 +35163.7 35302 35606.7 35968.8 36277.1 36418.4 +34978.6 35076.5 35302 35572.3 35799.5 35898.8 +34903.3 34978.6 35163.7 35388.4 35574.5 35650.6 Species 5 -35650.6 35898.8 36418.4 37029.2 37559.5 37817.3 -35574.5 35799.5 36277.1 36840 37326.6 37559.5 -35388.4 35572.3 35968.8 36437.5 36840 37029.2 -35163.7 35302 35606.7 35968.8 36277.1 36418.4 -34978.6 35076.5 35302 35572.3 35799.5 35898.8 -34903.3 34978.6 35163.7 35388.4 35574.5 35650.6 +35650.6 35898.8 36418.4 37029.2 37559.5 37817.3 +35574.5 35799.5 36277.1 36840 37326.6 37559.5 +35388.4 35572.3 35968.8 36437.5 36840 37029.2 +35163.7 35302 35606.7 35968.8 36277.1 36418.4 +34978.6 35076.5 35302 35572.3 35799.5 35898.8 +34903.3 34978.6 35163.7 35388.4 35574.5 35650.6 Species 6 -35650.6 35898.8 36418.4 37029.2 37559.5 37817.3 -35574.5 35799.5 36277.1 36840 37326.6 37559.5 -35388.4 35572.3 35968.8 36437.5 36840 37029.2 -35163.7 35302 35606.7 35968.8 36277.1 36418.4 -34978.6 35076.5 35302 35572.3 35799.5 35898.8 -34903.3 34978.6 35163.7 35388.4 35574.5 35650.6 +35650.6 35898.8 36418.4 37029.2 37559.5 37817.3 +35574.5 35799.5 36277.1 36840 37326.6 37559.5 +35388.4 35572.3 35968.8 36437.5 36840 37029.2 +35163.7 35302 35606.7 35968.8 36277.1 36418.4 +34978.6 35076.5 35302 35572.3 35799.5 35898.8 +34903.3 34978.6 35163.7 35388.4 35574.5 35650.6 Final statistics for this run: - ARKStep real workspace length = 3557 - ARKStep integer workspace length = 131 - ARKLS real workspace length = 2647 - ARKLS integer workspace length = 42 - Number of steps = 266 - Number of f-s (explicit) = 0 - Number of f-s (implicit) = 4394 - Number of f-s (SPGMR) = 8980 - Number of f-s (TOTAL) = 8980 - Number of setups = 121 - Number of nonlinear iterations = 2941 - Number of linear iterations = 8980 - Number of preconditioner evaluations = 121 - Number of preconditioner solves = 11819 - Number of error test failures = 23 - Number of nonlinear conv. failures = 17 - Number of linear convergence failures = 509 - Average Krylov subspace dimension = 3.053 + ARKStep real workspace length = 3554 + ARKStep integer workspace length = 131 + ARKLS real workspace length = 2647 + ARKLS integer workspace length = 42 + Number of steps = 266 + Number of f-s (explicit) = 0 + Number of f-s (implicit) = 4394 + Number of f-s (SPGMR) = 8980 + Number of f-s (TOTAL) = 8980 + Number of setups = 121 + Number of nonlinear iterations = 2941 + Number of linear iterations = 8980 + Number of preconditioner evaluations = 121 + Number of preconditioner solves = 11819 + Number of error test failures = 23 + Number of nonlinear conv. failures = 17 + Number of linear convergence failures = 509 + Average Krylov subspace dimension = 3.053 ---------------------------------------------------------------------------- @@ -487,24 +487,24 @@ t = 1.00e+01 nst = 251 nfe = 0 nfi = 4101 nni = 2746 hu = 7.09e-02 Final statistics for this run: - ARKStep real workspace length = 3557 - ARKStep integer workspace length = 136 - ARKLS real workspace length = 2647 - ARKLS integer workspace length = 42 - Number of steps = 251 - Number of f-s (explicit) = 0 - Number of f-s (implicit) = 4101 - Number of f-s (SPGMR) = 8880 - Number of f-s (TOTAL) = 8880 - Number of setups = 91 - Number of nonlinear iterations = 2746 - Number of linear iterations = 8880 - Number of preconditioner evaluations = 91 - Number of preconditioner solves = 11537 - Number of error test failures = 18 - Number of nonlinear conv. failures = 13 - Number of linear convergence failures = 597 - Average Krylov subspace dimension = 3.234 + ARKStep real workspace length = 3554 + ARKStep integer workspace length = 131 + ARKLS real workspace length = 2647 + ARKLS integer workspace length = 42 + Number of steps = 251 + Number of f-s (explicit) = 0 + Number of f-s (implicit) = 4101 + Number of f-s (SPGMR) = 8880 + Number of f-s (TOTAL) = 8880 + Number of setups = 91 + Number of nonlinear iterations = 2746 + Number of linear iterations = 8880 + Number of preconditioner evaluations = 91 + Number of preconditioner solves = 11537 + Number of error test failures = 18 + Number of nonlinear conv. failures = 13 + Number of linear convergence failures = 597 + Average Krylov subspace dimension = 3.234 ---------------------------------------------------------------------------- @@ -556,24 +556,24 @@ t = 1.00e+01 nst = 359 nfe = 0 nfi = 5722 nni = 3907 hu = 1.35e-01 Final statistics for this run: - ARKStep real workspace length = 3557 - ARKStep integer workspace length = 141 - ARKLS real workspace length = 2647 - ARKLS integer workspace length = 42 - Number of steps = 359 - Number of f-s (explicit) = 0 - Number of f-s (implicit) = 5722 - Number of f-s (SPGMR) = 12904 - Number of f-s (TOTAL) = 12904 - Number of setups = 253 - Number of nonlinear iterations = 3907 - Number of linear iterations = 12904 - Number of preconditioner evaluations = 253 - Number of preconditioner solves = 16594 - Number of error test failures = 0 - Number of nonlinear conv. failures = 117 - Number of linear convergence failures = 1072 - Average Krylov subspace dimension = 3.303 + ARKStep real workspace length = 3554 + ARKStep integer workspace length = 131 + ARKLS real workspace length = 2647 + ARKLS integer workspace length = 42 + Number of steps = 359 + Number of f-s (explicit) = 0 + Number of f-s (implicit) = 5722 + Number of f-s (SPGMR) = 12904 + Number of f-s (TOTAL) = 12904 + Number of setups = 253 + Number of nonlinear iterations = 3907 + Number of linear iterations = 12904 + Number of preconditioner evaluations = 253 + Number of preconditioner solves = 16594 + Number of error test failures = 0 + Number of nonlinear conv. failures = 117 + Number of linear convergence failures = 1072 + Average Krylov subspace dimension = 3.303 ---------------------------------------------------------------------------- @@ -625,24 +625,24 @@ t = 1.00e+01 nst = 359 nfe = 0 nfi = 5728 nni = 3912 hu = 1.31e-01 Final statistics for this run: - ARKStep real workspace length = 3557 - ARKStep integer workspace length = 146 - ARKLS real workspace length = 2647 - ARKLS integer workspace length = 42 - Number of steps = 359 - Number of f-s (explicit) = 0 - Number of f-s (implicit) = 5728 - Number of f-s (SPGMR) = 12934 - Number of f-s (TOTAL) = 12934 - Number of setups = 254 - Number of nonlinear iterations = 3912 - Number of linear iterations = 12934 - Number of preconditioner evaluations = 254 - Number of preconditioner solves = 16627 - Number of error test failures = 0 - Number of nonlinear conv. failures = 118 - Number of linear convergence failures = 1076 - Average Krylov subspace dimension = 3.306 + ARKStep real workspace length = 3554 + ARKStep integer workspace length = 131 + ARKLS real workspace length = 2647 + ARKLS integer workspace length = 42 + Number of steps = 359 + Number of f-s (explicit) = 0 + Number of f-s (implicit) = 5728 + Number of f-s (SPGMR) = 12934 + Number of f-s (TOTAL) = 12934 + Number of setups = 254 + Number of nonlinear iterations = 3912 + Number of linear iterations = 12934 + Number of preconditioner evaluations = 254 + Number of preconditioner solves = 16627 + Number of error test failures = 0 + Number of nonlinear conv. failures = 118 + Number of linear convergence failures = 1076 + Average Krylov subspace dimension = 3.306 ---------------------------------------------------------------------------- diff --git a/examples/arkode/C_serial/ark_KrylovDemo_prec_2.out b/examples/arkode/C_serial/ark_KrylovDemo_prec_2.out index 1af6fb8046..09364ad394 100644 --- a/examples/arkode/C_serial/ark_KrylovDemo_prec_2.out +++ b/examples/arkode/C_serial/ark_KrylovDemo_prec_2.out @@ -10,9 +10,9 @@ b parameter = 1 Diffusion coefficients: Dprey = 1 Dpred = 0.5 Rate parameter alpha = 1 -Mesh dimensions (mx,my) are 6, 6. Total system size is neq = 216 +Mesh dimensions (mx,my) are 6, 6. Total system size is neq = 216 -Tolerances: reltol = 1e-05, abstol = 1e-05 +Tolerances: reltol = 1e-05, abstol = 1e-05 Preconditioning uses a product of: (1) Gauss-Seidel iterations with itmax = 5 iterations, and @@ -31,52 +31,52 @@ Gram-Schmidt method type is gstype = SUN_MODIFIED_GS c values at t = 0: Species 1 -10 10 10 10 10 10 -10 10.1678 10.3775 10.3775 10.1678 10 -10 10.3775 10.8493 10.8493 10.3775 10 -10 10.3775 10.8493 10.8493 10.3775 10 -10 10.1678 10.3775 10.3775 10.1678 10 -10 10 10 10 10 10 +10 10 10 10 10 10 +10 10.1678 10.3775 10.3775 10.1678 10 +10 10.3775 10.8493 10.8493 10.3775 10 +10 10.3775 10.8493 10.8493 10.3775 10 +10 10.1678 10.3775 10.3775 10.1678 10 +10 10 10 10 10 10 Species 2 -10 10 10 10 10 10 -10 10.3355 10.755 10.755 10.3355 10 -10 10.755 11.6987 11.6987 10.755 10 -10 10.755 11.6987 11.6987 10.755 10 -10 10.3355 10.755 10.755 10.3355 10 -10 10 10 10 10 10 +10 10 10 10 10 10 +10 10.3355 10.755 10.755 10.3355 10 +10 10.755 11.6987 11.6987 10.755 10 +10 10.755 11.6987 11.6987 10.755 10 +10 10.3355 10.755 10.755 10.3355 10 +10 10 10 10 10 10 Species 3 -10 10 10 10 10 10 -10 10.5033 11.1325 11.1325 10.5033 10 -10 11.1325 12.548 12.548 11.1325 10 -10 11.1325 12.548 12.548 11.1325 10 -10 10.5033 11.1325 11.1325 10.5033 10 -10 10 10 10 10 10 +10 10 10 10 10 10 +10 10.5033 11.1325 11.1325 10.5033 10 +10 11.1325 12.548 12.548 11.1325 10 +10 11.1325 12.548 12.548 11.1325 10 +10 10.5033 11.1325 11.1325 10.5033 10 +10 10 10 10 10 10 Species 4 -10 10 10 10 10 10 -10 10.6711 11.5099 11.5099 10.6711 10 -10 11.5099 13.3974 13.3974 11.5099 10 -10 11.5099 13.3974 13.3974 11.5099 10 -10 10.6711 11.5099 11.5099 10.6711 10 -10 10 10 10 10 10 +10 10 10 10 10 10 +10 10.6711 11.5099 11.5099 10.6711 10 +10 11.5099 13.3974 13.3974 11.5099 10 +10 11.5099 13.3974 13.3974 11.5099 10 +10 10.6711 11.5099 11.5099 10.6711 10 +10 10 10 10 10 10 Species 5 -10 10 10 10 10 10 -10 10.8389 11.8874 11.8874 10.8389 10 -10 11.8874 14.2467 14.2467 11.8874 10 -10 11.8874 14.2467 14.2467 11.8874 10 -10 10.8389 11.8874 11.8874 10.8389 10 -10 10 10 10 10 10 +10 10 10 10 10 10 +10 10.8389 11.8874 11.8874 10.8389 10 +10 11.8874 14.2467 14.2467 11.8874 10 +10 11.8874 14.2467 14.2467 11.8874 10 +10 10.8389 11.8874 11.8874 10.8389 10 +10 10 10 10 10 10 Species 6 -10 10 10 10 10 10 -10 11.0066 12.2649 12.2649 11.0066 10 -10 12.2649 15.0961 15.0961 12.2649 10 -10 12.2649 15.0961 15.0961 12.2649 10 -10 11.0066 12.2649 12.2649 11.0066 10 -10 10 10 10 10 10 +10 10 10 10 10 10 +10 11.0066 12.2649 12.2649 11.0066 10 +10 12.2649 15.0961 15.0961 12.2649 10 +10 12.2649 15.0961 15.0961 12.2649 10 +10 11.0066 12.2649 12.2649 11.0066 10 +10 10 10 10 10 10 t = 1.00e-08 nst = 5 nfe = 0 nfi = 75 nni = 47 hu = 9.89e-08 @@ -87,52 +87,52 @@ t = 1.00e-06 nst = 8 nfe = 0 nfi = 120 nni = 77 hu = 4.79e-07 c values at t = 1e-06: Species 1 -9.99991 9.99992 9.99993 9.99993 9.99993 9.99992 -9.99992 10.1677 10.3774 10.3774 10.1677 9.99993 -9.99993 10.3774 10.8492 10.8492 10.3774 9.99993 -9.99993 10.3774 10.8492 10.8492 10.3774 9.99993 -9.99992 10.1677 10.3774 10.3774 10.1677 9.99992 -9.99991 9.99992 9.99993 9.99993 9.99992 9.99991 +9.99991 9.99992 9.99993 9.99993 9.99993 9.99992 +9.99992 10.1677 10.3774 10.3774 10.1677 9.99993 +9.99993 10.3774 10.8492 10.8492 10.3774 9.99993 +9.99993 10.3774 10.8492 10.8492 10.3774 9.99993 +9.99992 10.1677 10.3774 10.3774 10.1677 9.99992 +9.99991 9.99992 9.99993 9.99993 9.99992 9.99991 Species 2 -9.99991 9.99993 9.99995 9.99995 9.99993 9.99992 -9.99993 10.3355 10.7549 10.7549 10.3355 9.99993 -9.99995 10.7549 11.6985 11.6985 10.7549 9.99995 -9.99995 10.7549 11.6985 11.6985 10.7549 9.99995 -9.99993 10.3355 10.7549 10.7549 10.3355 9.99993 -9.99991 9.99993 9.99995 9.99995 9.99993 9.99991 +9.99991 9.99993 9.99995 9.99995 9.99993 9.99992 +9.99993 10.3355 10.7549 10.7549 10.3355 9.99993 +9.99995 10.7549 11.6985 11.6985 10.7549 9.99995 +9.99995 10.7549 11.6985 11.6985 10.7549 9.99995 +9.99993 10.3355 10.7549 10.7549 10.3355 9.99993 +9.99991 9.99993 9.99995 9.99995 9.99993 9.99991 Species 3 -9.99991 9.99994 9.99997 9.99997 9.99994 9.99992 -9.99994 10.5032 11.1323 11.1323 10.5032 9.99994 -9.99997 11.1323 12.5478 12.5478 11.1323 9.99997 -9.99997 11.1323 12.5478 12.5478 11.1323 9.99997 -9.99994 10.5032 11.1323 11.1323 10.5032 9.99994 -9.99991 9.99994 9.99997 9.99997 9.99994 9.99991 +9.99991 9.99994 9.99997 9.99997 9.99994 9.99992 +9.99994 10.5032 11.1323 11.1323 10.5032 9.99994 +9.99997 11.1323 12.5478 12.5478 11.1323 9.99997 +9.99997 11.1323 12.5478 12.5478 11.1323 9.99997 +9.99994 10.5032 11.1323 11.1323 10.5032 9.99994 +9.99991 9.99994 9.99997 9.99997 9.99994 9.99991 Species 4 -13.4984 13.4984 13.4984 13.4984 13.4984 13.4984 -13.4984 14.55 15.8924 15.8924 14.55 13.4984 -13.4984 15.8924 19.0296 19.0296 15.8924 13.4984 -13.4984 15.8924 19.0296 19.0296 15.8924 13.4984 -13.4984 14.55 15.8924 15.8924 14.55 13.4984 -13.4984 13.4984 13.4984 13.4984 13.4984 13.4984 +13.4984 13.4984 13.4984 13.4984 13.4984 13.4984 +13.4984 14.55 15.8924 15.8924 14.55 13.4984 +13.4984 15.8924 19.0296 19.0296 15.8924 13.4984 +13.4984 15.8924 19.0296 19.0296 15.8924 13.4984 +13.4984 14.55 15.8924 15.8924 14.55 13.4984 +13.4984 13.4984 13.4984 13.4984 13.4984 13.4984 Species 5 -13.4984 13.4984 13.4985 13.4985 13.4984 13.4984 -13.4984 14.7787 16.4136 16.4136 14.7787 13.4984 -13.4985 16.4136 20.236 20.236 16.4136 13.4985 -13.4985 16.4136 20.236 20.236 16.4136 13.4985 -13.4984 14.7787 16.4136 16.4136 14.7787 13.4984 -13.4984 13.4984 13.4985 13.4985 13.4984 13.4984 +13.4984 13.4984 13.4985 13.4985 13.4984 13.4984 +13.4984 14.7787 16.4136 16.4136 14.7787 13.4984 +13.4985 16.4136 20.236 20.236 16.4136 13.4985 +13.4985 16.4136 20.236 20.236 16.4136 13.4985 +13.4984 14.7787 16.4136 16.4136 14.7787 13.4984 +13.4984 13.4984 13.4985 13.4985 13.4984 13.4984 Species 6 -13.4984 13.4984 13.4985 13.4985 13.4984 13.4984 -13.4984 15.0075 16.9348 16.9348 15.0075 13.4984 -13.4985 16.9348 21.4423 21.4423 16.9348 13.4985 -13.4985 16.9348 21.4423 21.4423 16.9348 13.4985 -13.4984 15.0075 16.9348 16.9348 15.0075 13.4984 -13.4984 13.4984 13.4985 13.4985 13.4984 13.4984 +13.4984 13.4984 13.4985 13.4985 13.4984 13.4984 +13.4984 15.0075 16.9348 16.9348 15.0075 13.4984 +13.4985 16.9348 21.4423 21.4423 16.9348 13.4985 +13.4985 16.9348 21.4423 21.4423 16.9348 13.4985 +13.4984 15.0075 16.9348 16.9348 15.0075 13.4984 +13.4984 13.4984 13.4985 13.4985 13.4984 13.4984 t = 1.00e-05 nst = 27 nfe = 0 nfi = 407 nni = 269 hu = 4.79e-07 @@ -143,52 +143,52 @@ t = 1.00e-03 nst = 110 nfe = 0 nfi = 1750 nni = 1197 hu = 1.51e-03 c values at t = 0.001: Species 1 -9.90702 9.91664 9.92836 9.93033 9.92253 9.91674 -9.91472 10.0747 10.2769 10.2785 10.0795 9.92253 -9.92446 10.2748 10.7181 10.7194 10.2785 9.93033 -9.92445 10.2744 10.7173 10.7181 10.2769 9.92836 -9.91469 10.0734 10.2744 10.2748 10.0747 9.91664 -9.90698 9.91469 9.92445 9.92446 9.91472 9.90702 +9.90702 9.91664 9.92836 9.93033 9.92253 9.91674 +9.91472 10.0747 10.2769 10.2785 10.0795 9.92253 +9.92446 10.2748 10.7181 10.7194 10.2785 9.93033 +9.92445 10.2744 10.7173 10.7181 10.2769 9.92836 +9.91469 10.0734 10.2744 10.2748 10.0747 9.91664 +9.90698 9.91469 9.92445 9.92446 9.91472 9.90702 Species 2 -9.90742 9.92474 9.94622 9.94819 9.93064 9.91713 -9.92282 10.2412 10.644 10.6457 10.2461 9.93064 -9.94232 10.6419 11.5267 11.5281 10.6457 9.94819 -9.94231 10.6415 11.5258 11.5267 10.644 9.94622 -9.92279 10.24 10.6415 10.6419 10.2412 9.92474 -9.90737 9.92279 9.94231 9.94232 9.92282 9.90742 +9.90742 9.92474 9.94622 9.94819 9.93064 9.91713 +9.92282 10.2412 10.644 10.6457 10.2461 9.93064 +9.94232 10.6419 11.5267 11.5281 10.6457 9.94819 +9.94231 10.6415 11.5258 11.5267 10.644 9.94622 +9.92279 10.24 10.6415 10.6419 10.2412 9.92474 +9.90737 9.92279 9.94231 9.94232 9.92282 9.90742 Species 3 -9.90781 9.93284 9.96408 9.96605 9.93874 9.91753 -9.93092 10.4078 11.0109 11.0127 10.4127 9.93874 -9.96017 11.0088 12.3339 12.3354 11.0127 9.96605 -9.96016 11.0083 12.333 12.3339 11.0109 9.96408 -9.93088 10.4065 11.0083 11.0088 10.4078 9.93284 -9.90776 9.93088 9.96016 9.96017 9.93092 9.90781 +9.90781 9.93284 9.96408 9.96605 9.93874 9.91753 +9.93092 10.4078 11.0109 11.0127 10.4127 9.93874 +9.96017 11.0088 12.3339 12.3354 11.0127 9.96605 +9.96016 11.0083 12.333 12.3339 11.0109 9.96408 +9.93088 10.4065 11.0083 11.0088 10.4078 9.93284 +9.90776 9.93088 9.96016 9.96017 9.93092 9.90781 Species 4 -297231 297749 298392 298451 297925 297520 -297692 307245 319327 319378 307390 297925 -298276 319264 345799 345840 319378 298451 -298276 319252 345772 345799 319327 298392 -297691 307208 319252 319264 307245 297749 -297229 297691 298276 298276 297692 297231 +297231 297749 298392 298451 297925 297520 +297692 307245 319327 319378 307390 297925 +298276 319264 345799 345840 319378 298451 +298276 319252 345772 345799 319327 298392 +297691 307208 319252 319264 307245 297749 +297229 297691 298276 298276 297692 297231 Species 5 -297231 297749 298392 298451 297925 297520 -297692 307245 319327 319378 307390 297925 -298276 319264 345799 345840 319378 298451 -298276 319252 345772 345799 319327 298392 -297691 307208 319252 319264 307245 297749 -297229 297691 298276 298276 297692 297231 +297231 297749 298392 298451 297925 297520 +297692 307245 319327 319378 307390 297925 +298276 319264 345799 345840 319378 298451 +298276 319252 345772 345799 319327 298392 +297691 307208 319252 319264 307245 297749 +297229 297691 298276 298276 297692 297231 Species 6 -297231 297749 298392 298451 297925 297520 -297692 307245 319327 319378 307390 297925 -298276 319264 345799 345840 319378 298451 -298276 319252 345772 345799 319327 298392 -297691 307208 319252 319264 307245 297749 -297229 297691 298276 298276 297692 297231 +297231 297749 298392 298451 297925 297520 +297692 307245 319327 319378 307390 297925 +298276 319264 345799 345840 319378 298451 +298276 319252 345772 345799 319327 298392 +297691 307208 319252 319264 307245 297749 +297229 297691 298276 298276 297692 297231 t = 1.00e-02 nst = 113 nfe = 0 nfi = 1797 nni = 1229 hu = 3.46e-03 @@ -199,52 +199,52 @@ t = 1.00e+00 nst = 154 nfe = 0 nfi = 2489 nni = 1716 hu = 6.84e-02 c values at t = 1: Species 1 -1.58851 1.59924 1.62152 1.64764 1.67036 1.68149 -1.58533 1.59503 1.61548 1.63952 1.66033 1.67036 -1.57757 1.58547 1.60239 1.62235 1.63952 1.64764 -1.5682 1.57412 1.58706 1.60239 1.61548 1.62152 -1.56048 1.56463 1.57412 1.58547 1.59503 1.59924 -1.55733 1.56048 1.5682 1.57757 1.58533 1.58851 +1.58851 1.59924 1.62152 1.64764 1.67036 1.68149 +1.58533 1.59503 1.61548 1.63952 1.66033 1.67036 +1.57757 1.58547 1.60239 1.62235 1.63952 1.64764 +1.5682 1.57412 1.58706 1.60239 1.61548 1.62152 +1.56048 1.56463 1.57412 1.58547 1.59503 1.59924 +1.55733 1.56048 1.5682 1.57757 1.58533 1.58851 Species 2 -1.59067 1.60141 1.62371 1.64987 1.67261 1.68375 -1.58748 1.5972 1.61766 1.64173 1.66257 1.67261 -1.57971 1.58763 1.60457 1.62454 1.64173 1.64987 -1.57034 1.57626 1.58921 1.60457 1.61766 1.62371 -1.56261 1.56676 1.57626 1.58763 1.5972 1.60141 -1.55945 1.56261 1.57034 1.57971 1.58748 1.59067 +1.59067 1.60141 1.62371 1.64987 1.67261 1.68375 +1.58748 1.5972 1.61766 1.64173 1.66257 1.67261 +1.57971 1.58763 1.60457 1.62454 1.64173 1.64987 +1.57034 1.57626 1.58921 1.60457 1.61766 1.62371 +1.56261 1.56676 1.57626 1.58763 1.5972 1.60141 +1.55945 1.56261 1.57034 1.57971 1.58748 1.59067 Species 3 -1.5927 1.60346 1.62578 1.65197 1.67474 1.68589 -1.58951 1.59924 1.61973 1.64383 1.66468 1.67474 -1.58174 1.58966 1.60662 1.62662 1.64383 1.65197 -1.57236 1.57828 1.59125 1.60662 1.61973 1.62578 -1.56462 1.56878 1.57828 1.58966 1.59924 1.60346 -1.56146 1.56462 1.57236 1.58174 1.58951 1.5927 +1.5927 1.60346 1.62578 1.65197 1.67474 1.68589 +1.58951 1.59924 1.61973 1.64383 1.66468 1.67474 +1.58174 1.58966 1.60662 1.62662 1.64383 1.65197 +1.57236 1.57828 1.59125 1.60662 1.61973 1.62578 +1.56462 1.56878 1.57828 1.58966 1.59924 1.60346 +1.56146 1.56462 1.57236 1.58174 1.58951 1.5927 Species 4 -47718.3 48040.3 48709 49493.5 50175.5 50509.4 -47622.8 47914 48527.8 49249.6 49874.4 50175.5 -47389.7 47627 48134.9 48734.2 49249.6 49493.5 -47108.5 47286 47674.6 48134.9 48527.8 48709 -46876.6 47001.2 47286 47627 47914 48040.3 -46781.9 46876.6 47108.5 47389.7 47622.8 47718.3 +47718.3 48040.3 48709 49493.5 50175.5 50509.4 +47622.8 47914 48527.8 49249.6 49874.4 50175.5 +47389.7 47627 48134.9 48734.2 49249.6 49493.5 +47108.5 47286 47674.6 48134.9 48527.8 48709 +46876.6 47001.2 47286 47627 47914 48040.3 +46781.9 46876.6 47108.5 47389.7 47622.8 47718.3 Species 5 -47718.3 48040.3 48709 49493.5 50175.5 50509.4 -47622.8 47914 48527.8 49249.6 49874.4 50175.5 -47389.7 47627 48134.9 48734.2 49249.6 49493.5 -47108.5 47286 47674.6 48134.9 48527.8 48709 -46876.6 47001.2 47286 47627 47914 48040.3 -46781.9 46876.6 47108.5 47389.7 47622.8 47718.3 +47718.3 48040.3 48709 49493.5 50175.5 50509.4 +47622.8 47914 48527.8 49249.6 49874.4 50175.5 +47389.7 47627 48134.9 48734.2 49249.6 49493.5 +47108.5 47286 47674.6 48134.9 48527.8 48709 +46876.6 47001.2 47286 47627 47914 48040.3 +46781.9 46876.6 47108.5 47389.7 47622.8 47718.3 Species 6 -47718.3 48040.3 48709 49493.5 50175.5 50509.4 -47622.8 47914 48527.8 49249.6 49874.4 50175.5 -47389.7 47627 48134.9 48734.2 49249.6 49493.5 -47108.5 47286 47674.6 48134.9 48527.8 48709 -46876.6 47001.2 47286 47627 47914 48040.3 -46781.9 46876.6 47108.5 47389.7 47622.8 47718.3 +47718.3 48040.3 48709 49493.5 50175.5 50509.4 +47622.8 47914 48527.8 49249.6 49874.4 50175.5 +47389.7 47627 48134.9 48734.2 49249.6 49493.5 +47108.5 47286 47674.6 48134.9 48527.8 48709 +46876.6 47001.2 47286 47627 47914 48040.3 +46781.9 46876.6 47108.5 47389.7 47622.8 47718.3 t = 2.00e+00 nst = 165 nfe = 0 nfi = 2661 nni = 1833 hu = 4.14e-02 @@ -255,52 +255,52 @@ t = 4.00e+00 nst = 187 nfe = 0 nfi = 3013 nni = 2073 hu = 1.23e-01 c values at t = 4: Species 1 -1.19535 1.20368 1.2211 1.24157 1.25935 1.268 -1.1928 1.20035 1.21636 1.23523 1.25154 1.25935 -1.18657 1.19274 1.20602 1.22173 1.23523 1.24157 -1.17904 1.18368 1.19389 1.20602 1.21636 1.2211 -1.17284 1.17613 1.18368 1.19274 1.20035 1.20368 -1.17032 1.17284 1.17904 1.18657 1.1928 1.19535 +1.19535 1.20368 1.2211 1.24157 1.25935 1.268 +1.1928 1.20035 1.21636 1.23523 1.25154 1.25935 +1.18657 1.19274 1.20602 1.22173 1.23523 1.24157 +1.17904 1.18368 1.19389 1.20602 1.21636 1.2211 +1.17284 1.17613 1.18368 1.19274 1.20035 1.20368 +1.17032 1.17284 1.17904 1.18657 1.1928 1.19535 Species 2 -1.19538 1.20371 1.22113 1.24161 1.25938 1.26804 -1.19284 1.20038 1.21639 1.23526 1.25157 1.25938 -1.1866 1.19277 1.20606 1.22177 1.23526 1.24161 -1.17908 1.18371 1.19393 1.20606 1.21639 1.22113 -1.17288 1.17616 1.18371 1.19277 1.20038 1.20371 -1.17035 1.17288 1.17908 1.1866 1.19284 1.19538 +1.19538 1.20371 1.22113 1.24161 1.25938 1.26804 +1.19284 1.20038 1.21639 1.23526 1.25157 1.25938 +1.1866 1.19277 1.20606 1.22177 1.23526 1.24161 +1.17908 1.18371 1.19393 1.20606 1.21639 1.22113 +1.17288 1.17616 1.18371 1.19277 1.20038 1.20371 +1.17035 1.17288 1.17908 1.1866 1.19284 1.19538 Species 3 -1.19542 1.20374 1.22116 1.24164 1.25942 1.26807 -1.19287 1.20042 1.21642 1.2353 1.2516 1.25942 -1.18663 1.1928 1.20609 1.2218 1.2353 1.24164 -1.17911 1.18374 1.19396 1.20609 1.21642 1.22116 -1.17291 1.17619 1.18374 1.1928 1.20042 1.20374 -1.17039 1.17291 1.17911 1.18663 1.19287 1.19542 +1.19542 1.20374 1.22116 1.24164 1.25942 1.26807 +1.19287 1.20042 1.21642 1.2353 1.2516 1.25942 +1.18663 1.1928 1.20609 1.2218 1.2353 1.24164 +1.17911 1.18374 1.19396 1.20609 1.21642 1.22116 +1.17291 1.17619 1.18374 1.1928 1.20042 1.20374 +1.17039 1.17291 1.17911 1.18663 1.19287 1.19542 Species 4 -35860.6 36110.2 36632.4 37246.4 37779.5 38038.7 -35784.2 36010.4 36490.4 37056.3 37545.3 37779.5 -35597.2 35782 36180.5 36651.6 37056.3 37246.4 -35371.4 35510.4 35816.7 36180.5 36490.4 36632.4 -35185.4 35283.8 35510.4 35782 36010.4 36110.2 -35109.7 35185.4 35371.4 35597.2 35784.2 35860.6 +35860.6 36110.2 36632.4 37246.4 37779.5 38038.7 +35784.2 36010.4 36490.4 37056.3 37545.3 37779.5 +35597.2 35782 36180.5 36651.6 37056.3 37246.4 +35371.4 35510.4 35816.7 36180.5 36490.4 36632.4 +35185.4 35283.8 35510.4 35782 36010.4 36110.2 +35109.7 35185.4 35371.4 35597.2 35784.2 35860.6 Species 5 -35860.6 36110.2 36632.4 37246.4 37779.5 38038.7 -35784.2 36010.4 36490.4 37056.3 37545.3 37779.5 -35597.2 35782 36180.5 36651.6 37056.3 37246.4 -35371.4 35510.4 35816.7 36180.5 36490.4 36632.4 -35185.4 35283.8 35510.4 35782 36010.4 36110.2 -35109.7 35185.4 35371.4 35597.2 35784.2 35860.6 +35860.6 36110.2 36632.4 37246.4 37779.5 38038.7 +35784.2 36010.4 36490.4 37056.3 37545.3 37779.5 +35597.2 35782 36180.5 36651.6 37056.3 37246.4 +35371.4 35510.4 35816.7 36180.5 36490.4 36632.4 +35185.4 35283.8 35510.4 35782 36010.4 36110.2 +35109.7 35185.4 35371.4 35597.2 35784.2 35860.6 Species 6 -35860.6 36110.2 36632.4 37246.4 37779.5 38038.7 -35784.2 36010.4 36490.4 37056.3 37545.3 37779.5 -35597.2 35782 36180.5 36651.6 37056.3 37246.4 -35371.4 35510.4 35816.7 36180.5 36490.4 36632.4 -35185.4 35283.8 35510.4 35782 36010.4 36110.2 -35109.7 35185.4 35371.4 35597.2 35784.2 35860.6 +35860.6 36110.2 36632.4 37246.4 37779.5 38038.7 +35784.2 36010.4 36490.4 37056.3 37545.3 37779.5 +35597.2 35782 36180.5 36651.6 37056.3 37246.4 +35371.4 35510.4 35816.7 36180.5 36490.4 36632.4 +35185.4 35283.8 35510.4 35782 36010.4 36110.2 +35109.7 35185.4 35371.4 35597.2 35784.2 35860.6 t = 5.00e+00 nst = 198 nfe = 0 nfi = 3179 nni = 2182 hu = 9.99e-02 @@ -311,52 +311,52 @@ t = 7.00e+00 nst = 216 nfe = 0 nfi = 3477 nni = 2375 hu = 1.51e-01 c values at t = 7: Species 1 -1.18854 1.19682 1.21415 1.23453 1.25221 1.26082 -1.186 1.19351 1.20944 1.22822 1.24444 1.25221 -1.1798 1.18593 1.19916 1.21479 1.22822 1.23453 -1.17231 1.17692 1.18708 1.19916 1.20944 1.21415 -1.16614 1.1694 1.17692 1.18593 1.19351 1.19682 -1.16363 1.16614 1.17231 1.1798 1.186 1.18854 +1.18854 1.19682 1.21415 1.23453 1.25221 1.26082 +1.186 1.19351 1.20944 1.22822 1.24444 1.25221 +1.1798 1.18593 1.19916 1.21479 1.22822 1.23453 +1.17231 1.17692 1.18708 1.19916 1.20944 1.21415 +1.16614 1.1694 1.17692 1.18593 1.19351 1.19682 +1.16363 1.16614 1.17231 1.1798 1.186 1.18854 Species 2 -1.18854 1.19683 1.21415 1.23453 1.25222 1.26082 -1.186 1.19351 1.20944 1.22822 1.24444 1.25222 -1.1798 1.18594 1.19916 1.21479 1.22822 1.23453 -1.17231 1.17692 1.18709 1.19916 1.20944 1.21415 -1.16614 1.1694 1.17692 1.18594 1.19351 1.19683 -1.16363 1.16614 1.17231 1.1798 1.186 1.18854 +1.18854 1.19683 1.21415 1.23453 1.25222 1.26082 +1.186 1.19351 1.20944 1.22822 1.24444 1.25222 +1.1798 1.18594 1.19916 1.21479 1.22822 1.23453 +1.17231 1.17692 1.18709 1.19916 1.20944 1.21415 +1.16614 1.1694 1.17692 1.18594 1.19351 1.19683 +1.16363 1.16614 1.17231 1.1798 1.186 1.18854 Species 3 -1.18854 1.19683 1.21416 1.23453 1.25222 1.26082 -1.18601 1.19351 1.20944 1.22822 1.24444 1.25222 -1.1798 1.18594 1.19916 1.21479 1.22822 1.23453 -1.17231 1.17692 1.18709 1.19916 1.20944 1.21416 -1.16614 1.1694 1.17692 1.18594 1.19351 1.19683 -1.16363 1.16614 1.17231 1.1798 1.18601 1.18854 +1.18854 1.19683 1.21416 1.23453 1.25222 1.26082 +1.18601 1.19351 1.20944 1.22822 1.24444 1.25222 +1.1798 1.18594 1.19916 1.21479 1.22822 1.23453 +1.17231 1.17692 1.18709 1.19916 1.20944 1.21416 +1.16614 1.1694 1.17692 1.18594 1.19351 1.19683 +1.16363 1.16614 1.17231 1.1798 1.18601 1.18854 Species 4 -35656.3 35903.1 36424.2 37033.8 37564.6 37822.3 -35578.4 35804.9 36281.3 36845.5 37330.9 37564.6 -35393.9 35575.9 35974.4 36441.4 36845.5 37033.8 -35167.5 35307.4 35610.6 35974.4 36281.3 36424.2 -34984.3 35080.2 35307.4 35575.9 35804.9 35903.1 -34907.5 34984.3 35167.5 35393.9 35578.4 35656.3 +35656.3 35903.1 36424.2 37033.8 37564.6 37822.3 +35578.4 35804.9 36281.3 36845.5 37330.9 37564.6 +35393.9 35575.9 35974.4 36441.4 36845.5 37033.8 +35167.5 35307.4 35610.6 35974.4 36281.3 36424.2 +34984.3 35080.2 35307.4 35575.9 35804.9 35903.1 +34907.5 34984.3 35167.5 35393.9 35578.4 35656.3 Species 5 -35656.3 35903.1 36424.2 37033.8 37564.6 37822.3 -35578.4 35804.9 36281.3 36845.5 37330.9 37564.6 -35393.9 35575.9 35974.4 36441.4 36845.5 37033.8 -35167.5 35307.4 35610.6 35974.4 36281.3 36424.2 -34984.3 35080.2 35307.4 35575.9 35804.9 35903.1 -34907.5 34984.3 35167.5 35393.9 35578.4 35656.3 +35656.3 35903.1 36424.2 37033.8 37564.6 37822.3 +35578.4 35804.9 36281.3 36845.5 37330.9 37564.6 +35393.9 35575.9 35974.4 36441.4 36845.5 37033.8 +35167.5 35307.4 35610.6 35974.4 36281.3 36424.2 +34984.3 35080.2 35307.4 35575.9 35804.9 35903.1 +34907.5 34984.3 35167.5 35393.9 35578.4 35656.3 Species 6 -35656.3 35903.1 36424.2 37033.8 37564.6 37822.3 -35578.4 35804.9 36281.3 36845.5 37330.9 37564.6 -35393.9 35575.9 35974.4 36441.4 36845.5 37033.8 -35167.5 35307.4 35610.6 35974.4 36281.3 36424.2 -34984.3 35080.2 35307.4 35575.9 35804.9 35903.1 -34907.5 34984.3 35167.5 35393.9 35578.4 35656.3 +35656.3 35903.1 36424.2 37033.8 37564.6 37822.3 +35578.4 35804.9 36281.3 36845.5 37330.9 37564.6 +35393.9 35575.9 35974.4 36441.4 36845.5 37033.8 +35167.5 35307.4 35610.6 35974.4 36281.3 36424.2 +34984.3 35080.2 35307.4 35575.9 35804.9 35903.1 +34907.5 34984.3 35167.5 35393.9 35578.4 35656.3 t = 8.00e+00 nst = 232 nfe = 0 nfi = 3780 nni = 2567 hu = 1.06e-01 @@ -367,75 +367,75 @@ t = 1.00e+01 nst = 266 nfe = 0 nfi = 4394 nni = 2941 hu = 8.37e-02 c values at t = 10: Species 1 -1.18838 1.19667 1.21399 1.23437 1.25205 1.26066 -1.18585 1.19335 1.20928 1.22805 1.24428 1.25205 -1.17964 1.18578 1.199 1.21463 1.22805 1.23437 -1.17215 1.17676 1.18693 1.199 1.20928 1.21399 -1.16598 1.16925 1.17676 1.18578 1.19335 1.19667 -1.16347 1.16598 1.17215 1.17964 1.18585 1.18838 +1.18838 1.19667 1.21399 1.23437 1.25205 1.26066 +1.18585 1.19335 1.20928 1.22805 1.24428 1.25205 +1.17964 1.18578 1.199 1.21463 1.22805 1.23437 +1.17215 1.17676 1.18693 1.199 1.20928 1.21399 +1.16598 1.16925 1.17676 1.18578 1.19335 1.19667 +1.16347 1.16598 1.17215 1.17964 1.18585 1.18838 Species 2 -1.18838 1.19667 1.21399 1.23437 1.25205 1.26066 -1.18585 1.19335 1.20928 1.22805 1.24428 1.25205 -1.17964 1.18578 1.199 1.21463 1.22805 1.23437 -1.17215 1.17676 1.18693 1.199 1.20928 1.21399 -1.16598 1.16925 1.17676 1.18578 1.19335 1.19667 -1.16347 1.16598 1.17215 1.17964 1.18585 1.18838 +1.18838 1.19667 1.21399 1.23437 1.25205 1.26066 +1.18585 1.19335 1.20928 1.22805 1.24428 1.25205 +1.17964 1.18578 1.199 1.21463 1.22805 1.23437 +1.17215 1.17676 1.18693 1.199 1.20928 1.21399 +1.16598 1.16925 1.17676 1.18578 1.19335 1.19667 +1.16347 1.16598 1.17215 1.17964 1.18585 1.18838 Species 3 -1.18838 1.19667 1.21399 1.23437 1.25205 1.26066 -1.18585 1.19335 1.20928 1.22805 1.24428 1.25205 -1.17964 1.18578 1.199 1.21463 1.22805 1.23437 -1.17215 1.17676 1.18693 1.199 1.20928 1.21399 -1.16598 1.16925 1.17676 1.18578 1.19335 1.19667 -1.16347 1.16598 1.17215 1.17964 1.18585 1.18838 +1.18838 1.19667 1.21399 1.23437 1.25205 1.26066 +1.18585 1.19335 1.20928 1.22805 1.24428 1.25205 +1.17964 1.18578 1.199 1.21463 1.22805 1.23437 +1.17215 1.17676 1.18693 1.199 1.20928 1.21399 +1.16598 1.16925 1.17676 1.18578 1.19335 1.19667 +1.16347 1.16598 1.17215 1.17964 1.18585 1.18838 Species 4 -35650.6 35898.8 36418.4 37029.2 37559.5 37817.3 -35574.5 35799.5 36277.1 36840 37326.6 37559.5 -35388.4 35572.3 35968.8 36437.5 36840 37029.2 -35163.7 35302 35606.7 35968.8 36277.1 36418.4 -34978.6 35076.5 35302 35572.3 35799.5 35898.8 -34903.3 34978.6 35163.7 35388.4 35574.5 35650.6 +35650.6 35898.8 36418.4 37029.2 37559.5 37817.3 +35574.5 35799.5 36277.1 36840 37326.6 37559.5 +35388.4 35572.3 35968.8 36437.5 36840 37029.2 +35163.7 35302 35606.7 35968.8 36277.1 36418.4 +34978.6 35076.5 35302 35572.3 35799.5 35898.8 +34903.3 34978.6 35163.7 35388.4 35574.5 35650.6 Species 5 -35650.6 35898.8 36418.4 37029.2 37559.5 37817.3 -35574.5 35799.5 36277.1 36840 37326.6 37559.5 -35388.4 35572.3 35968.8 36437.5 36840 37029.2 -35163.7 35302 35606.7 35968.8 36277.1 36418.4 -34978.6 35076.5 35302 35572.3 35799.5 35898.8 -34903.3 34978.6 35163.7 35388.4 35574.5 35650.6 +35650.6 35898.8 36418.4 37029.2 37559.5 37817.3 +35574.5 35799.5 36277.1 36840 37326.6 37559.5 +35388.4 35572.3 35968.8 36437.5 36840 37029.2 +35163.7 35302 35606.7 35968.8 36277.1 36418.4 +34978.6 35076.5 35302 35572.3 35799.5 35898.8 +34903.3 34978.6 35163.7 35388.4 35574.5 35650.6 Species 6 -35650.6 35898.8 36418.4 37029.2 37559.5 37817.3 -35574.5 35799.5 36277.1 36840 37326.6 37559.5 -35388.4 35572.3 35968.8 36437.5 36840 37029.2 -35163.7 35302 35606.7 35968.8 36277.1 36418.4 -34978.6 35076.5 35302 35572.3 35799.5 35898.8 -34903.3 34978.6 35163.7 35388.4 35574.5 35650.6 +35650.6 35898.8 36418.4 37029.2 37559.5 37817.3 +35574.5 35799.5 36277.1 36840 37326.6 37559.5 +35388.4 35572.3 35968.8 36437.5 36840 37029.2 +35163.7 35302 35606.7 35968.8 36277.1 36418.4 +34978.6 35076.5 35302 35572.3 35799.5 35898.8 +34903.3 34978.6 35163.7 35388.4 35574.5 35650.6 Final statistics for this run: - ARKStep real workspace length = 3557 + ARKStep real workspace length = 3554 ARKStep integer workspace length = 131 - ARKLS real workspace length = 2647 - ARKLS integer workspace length = 42 - Number of steps = 266 - Number of f-s (explicit) = 0 - Number of f-s (implicit) = 4394 - Number of f-s (SPGMR) = 8980 - Number of f-s (TOTAL) = 8980 - Number of setups = 121 - Number of nonlinear iterations = 2941 - Number of linear iterations = 8980 - Number of preconditioner evaluations = 121 - Number of preconditioner solves = 11819 - Number of error test failures = 23 - Number of nonlinear conv. failures = 17 - Number of linear convergence failures = 509 - Average Krylov subspace dimension = 3.053 + ARKLS real workspace length = 2647 + ARKLS integer workspace length = 42 + Number of steps = 266 + Number of f-s (explicit) = 0 + Number of f-s (implicit) = 4394 + Number of f-s (SPGMR) = 8980 + Number of f-s (TOTAL) = 8980 + Number of setups = 121 + Number of nonlinear iterations = 2941 + Number of linear iterations = 8980 + Number of preconditioner evaluations = 121 + Number of preconditioner solves = 11819 + Number of error test failures = 23 + Number of nonlinear conv. failures = 17 + Number of linear convergence failures = 509 + Average Krylov subspace dimension = 3.053 ---------------------------------------------------------------------------- @@ -487,24 +487,24 @@ t = 1.00e+01 nst = 251 nfe = 0 nfi = 4101 nni = 2746 hu = 7.09e-02 Final statistics for this run: - ARKStep real workspace length = 3557 - ARKStep integer workspace length = 136 - ARKLS real workspace length = 2647 - ARKLS integer workspace length = 42 - Number of steps = 251 - Number of f-s (explicit) = 0 - Number of f-s (implicit) = 4101 - Number of f-s (SPGMR) = 8880 - Number of f-s (TOTAL) = 8880 - Number of setups = 91 - Number of nonlinear iterations = 2746 - Number of linear iterations = 8880 - Number of preconditioner evaluations = 91 - Number of preconditioner solves = 11537 - Number of error test failures = 18 - Number of nonlinear conv. failures = 13 - Number of linear convergence failures = 597 - Average Krylov subspace dimension = 3.234 + ARKStep real workspace length = 3554 + ARKStep integer workspace length = 131 + ARKLS real workspace length = 2647 + ARKLS integer workspace length = 42 + Number of steps = 251 + Number of f-s (explicit) = 0 + Number of f-s (implicit) = 4101 + Number of f-s (SPGMR) = 8880 + Number of f-s (TOTAL) = 8880 + Number of setups = 91 + Number of nonlinear iterations = 2746 + Number of linear iterations = 8880 + Number of preconditioner evaluations = 91 + Number of preconditioner solves = 11537 + Number of error test failures = 18 + Number of nonlinear conv. failures = 13 + Number of linear convergence failures = 597 + Average Krylov subspace dimension = 3.234 ---------------------------------------------------------------------------- @@ -556,24 +556,24 @@ t = 1.00e+01 nst = 359 nfe = 0 nfi = 5722 nni = 3907 hu = 1.35e-01 Final statistics for this run: - ARKStep real workspace length = 3557 - ARKStep integer workspace length = 141 - ARKLS real workspace length = 2647 - ARKLS integer workspace length = 42 - Number of steps = 359 - Number of f-s (explicit) = 0 - Number of f-s (implicit) = 5722 - Number of f-s (SPGMR) = 12904 - Number of f-s (TOTAL) = 12904 - Number of setups = 253 - Number of nonlinear iterations = 3907 - Number of linear iterations = 12904 - Number of preconditioner evaluations = 253 - Number of preconditioner solves = 16594 - Number of error test failures = 0 - Number of nonlinear conv. failures = 117 - Number of linear convergence failures = 1072 - Average Krylov subspace dimension = 3.303 + ARKStep real workspace length = 3554 + ARKStep integer workspace length = 131 + ARKLS real workspace length = 2647 + ARKLS integer workspace length = 42 + Number of steps = 359 + Number of f-s (explicit) = 0 + Number of f-s (implicit) = 5722 + Number of f-s (SPGMR) = 12904 + Number of f-s (TOTAL) = 12904 + Number of setups = 253 + Number of nonlinear iterations = 3907 + Number of linear iterations = 12904 + Number of preconditioner evaluations = 253 + Number of preconditioner solves = 16594 + Number of error test failures = 0 + Number of nonlinear conv. failures = 117 + Number of linear convergence failures = 1072 + Average Krylov subspace dimension = 3.303 ---------------------------------------------------------------------------- @@ -625,24 +625,24 @@ t = 1.00e+01 nst = 359 nfe = 0 nfi = 5728 nni = 3912 hu = 1.31e-01 Final statistics for this run: - ARKStep real workspace length = 3557 - ARKStep integer workspace length = 146 - ARKLS real workspace length = 2647 - ARKLS integer workspace length = 42 - Number of steps = 359 - Number of f-s (explicit) = 0 - Number of f-s (implicit) = 5728 - Number of f-s (SPGMR) = 12934 - Number of f-s (TOTAL) = 12934 - Number of setups = 254 - Number of nonlinear iterations = 3912 - Number of linear iterations = 12934 - Number of preconditioner evaluations = 254 - Number of preconditioner solves = 16627 - Number of error test failures = 0 - Number of nonlinear conv. failures = 118 - Number of linear convergence failures = 1076 - Average Krylov subspace dimension = 3.306 + ARKStep real workspace length = 3554 + ARKStep integer workspace length = 131 + ARKLS real workspace length = 2647 + ARKLS integer workspace length = 42 + Number of steps = 359 + Number of f-s (explicit) = 0 + Number of f-s (implicit) = 5728 + Number of f-s (SPGMR) = 12934 + Number of f-s (TOTAL) = 12934 + Number of setups = 254 + Number of nonlinear iterations = 3912 + Number of linear iterations = 12934 + Number of preconditioner evaluations = 254 + Number of preconditioner solves = 16627 + Number of error test failures = 0 + Number of nonlinear conv. failures = 118 + Number of linear convergence failures = 1076 + Average Krylov subspace dimension = 3.306 ---------------------------------------------------------------------------- From 7311e5c444d230aa5ff9cb10e8d904f81406b2d1 Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Thu, 19 Oct 2023 13:37:08 -0500 Subject: [PATCH 09/58] Cleaned up documentation regarding time adaptivity controllers --- doc/arkode/guide/source/Mathematics.rst | 141 ++---------------------- 1 file changed, 8 insertions(+), 133 deletions(-) diff --git a/doc/arkode/guide/source/Mathematics.rst b/doc/arkode/guide/source/Mathematics.rst index ec66f9838b..a236f5b8c6 100644 --- a/doc/arkode/guide/source/Mathematics.rst +++ b/doc/arkode/guide/source/Mathematics.rst @@ -902,146 +902,21 @@ steps, :math:`t_{n-3} \to t_{n-2} \to t_{n-1} \to t_n`. These local error history values are all initialized to 1 upon program initialization, to accommodate the few initial time steps of a calculation where some of these error estimates have not yet been -computed. With these estimates, ARKODE supports a variety of error -control algorithms, as specified in the subsections below. +computed. With these estimates, ARKODE supports one of two approaches +for temporal error control. +First, any valid implementation of the SUNAdaptController class +:numref:`SUNAdaptController.Description` may be used by ARKODE's adaptive +time-stepping modules to provide a candidate error-based prospective step +size :math:`h'`. -.. _ARKODE.Mathematics.Adaptivity.ErrorControl.PID: - -PID controller ------------------ - -This is the default time adaptivity controller used by the ARKStep and -ERKStep modules. It derives from those found in :cite:p:`KenCarp:03`, :cite:p:`Sod:98`, :cite:p:`Sod:03` and -:cite:p:`Sod:06`, and uses all three of the local error estimates -:math:`\varepsilon_n`, :math:`\varepsilon_{n-1}` and -:math:`\varepsilon_{n-2}` in determination of a prospective step size, - -.. math:: - h' \;=\; h_n\; \varepsilon_n^{-k_1/p}\; \varepsilon_{n-1}^{k_2/p}\; - \varepsilon_{n-2}^{-k_3/p}, - -where the constants :math:`k_1`, :math:`k_2` and :math:`k_3` default -to 0.58, 0.21 and 0.1, respectively, and may be modified by the user. -In this estimate, a floor of :math:`\varepsilon > 10^{-10}` is -enforced to avoid division-by-zero errors. - - - -.. _ARKODE.Mathematics.Adaptivity.ErrorControl.PI: - -PI controller ----------------------- - -Like with the previous method, the PI controller derives from those -found in :cite:p:`KenCarp:03`, :cite:p:`Sod:98`, :cite:p:`Sod:03` and :cite:p:`Sod:06`, but it differs in -that it only uses the two most recent step sizes in its adaptivity -algorithm, - -.. math:: - h' \;=\; h_n\; \varepsilon_n^{-k_1/p}\; \varepsilon_{n-1}^{k_2/p}. - -Here, the default values of :math:`k_1` and :math:`k_2` default -to 0.8 and 0.31, respectively, though they may be changed by the user. - - - -.. _ARKODE.Mathematics.Adaptivity.ErrorControl.I: - -I controller ----------------------- - -This is the standard time adaptivity control algorithm in use by most -publicly-available ODE solver codes. It bases the prospective time step -estimate entirely off of the current local error estimate, - -.. math:: - h' \;=\; h_n\; \varepsilon_n^{-k_1/p}. - -By default, :math:`k_1=1`, but that may be modified by the user. - - - - -.. _ARKODE.Mathematics.Adaptivity.ErrorControl.eGus: - -Explicit Gustafsson controller ---------------------------------- - -This step adaptivity algorithm was proposed in :cite:p:`Gust:91`, and -is primarily useful with explicit Runge--Kutta methods. -In the notation of our earlier controllers, it has the form - -.. math:: - h' \;=\; \begin{cases} - h_1\; \varepsilon_1^{-1/p}, &\quad\text{on the first step}, \\ - h_n\; \varepsilon_n^{-k_1/p}\; - \left(\dfrac{\varepsilon_n}{\varepsilon_{n-1}}\right)^{k_2/p}, & - \quad\text{on subsequent steps}. - \end{cases} - :label: ARKODE_expGus - -The default values of :math:`k_1` and :math:`k_2` are 0.367 and 0.268, -respectively, and may be modified by the user. - - - - -.. _ARKODE.Mathematics.Adaptivity.ErrorControl.iGus: - -Implicit Gustafsson controller ---------------------------------- - -A version of the above controller suitable for implicit Runge--Kutta -methods was introduced in :cite:p:`Gust:94`, and has the form - -.. math:: - h' = \begin{cases} - h_1 \varepsilon_1^{-1/p}, &\quad\text{on the first step}, \\ - h_n \left(\dfrac{h_n}{h_{n-1}}\right) \varepsilon_n^{-k_1/p} - \left(\dfrac{\varepsilon_n}{\varepsilon_{n-1}}\right)^{-k_2/p}, & - \quad\text{on subsequent steps}. - \end{cases} - :label: ARKODE_impGus - -The algorithm parameters default to :math:`k_1 = 0.98` and -:math:`k_2 = 0.95`, but may be modified by the user. - - - - -.. _ARKODE.Mathematics.Adaptivity.ErrorControl.ieGus: - -ImEx Gustafsson controller ---------------------------------- - -An ImEx version of these two preceding controllers is also available. -This approach computes the estimates :math:`h'_1` arising from -equation :eq:`ARKODE_expGus` and the estimate :math:`h'_2` arising from -equation :eq:`ARKODE_impGus`, and selects - -.. math:: - h' = \frac{h}{|h|}\min\left\{|h'_1|, |h'_2|\right\}. - -Here, equation :eq:`ARKODE_expGus` uses :math:`k_1` and -:math:`k_2` with default values of 0.367 and 0.268, while equation -:eq:`ARKODE_impGus` sets both parameters to the input :math:`k_3` that -defaults to 0.95. All of these values may be modified by the user. - - - -.. _ARKODE.Mathematics.Adaptivity.ErrorControl.User: - -User-supplied controller ---------------------------------- - -Finally, ARKODE's time-stepping modules allow the user to define their +Second, ARKODE's adaptive time-stepping modules allow the user to define their own time step adaptivity function, .. math:: h' = H(y, t, h_n, h_{n-1}, h_{n-2}, \varepsilon_n, \varepsilon_{n-1}, \varepsilon_{n-2}, q, p), -to allow for problem-specific choices, or for continued +allowing for problem-specific choices, or for continued experimentation with temporal error controllers. From c63ac0382533d84c16d1e1ebfc521a74772033f6 Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Thu, 19 Oct 2023 13:37:29 -0500 Subject: [PATCH 10/58] Cleaned up documentation regarding time adaptivity controllers --- .../SUNAdaptController_ExpGus.rst | 10 +++++----- .../sunadaptcontroller/SUNAdaptController_I.rst | 4 ++-- .../SUNAdaptController_ImExGus.rst | 14 +++++++------- .../SUNAdaptController_ImpGus.rst | 8 ++++---- .../sunadaptcontroller/SUNAdaptController_PI.rst | 4 ++-- .../sunadaptcontroller/SUNAdaptController_PID.rst | 6 +++--- 6 files changed, 23 insertions(+), 23 deletions(-) diff --git a/doc/shared/sunadaptcontroller/SUNAdaptController_ExpGus.rst b/doc/shared/sunadaptcontroller/SUNAdaptController_ExpGus.rst index 6bea7f5365..0d224c04f4 100644 --- a/doc/shared/sunadaptcontroller/SUNAdaptController_ExpGus.rst +++ b/doc/shared/sunadaptcontroller/SUNAdaptController_ExpGus.rst @@ -24,14 +24,14 @@ form .. math:: h' \;=\; \begin{cases} - h_1\; \varepsilon_1^{-1/ord}, &\quad\text{on the first step}, \\ - h_n\; \varepsilon_n^{-k_1/ord}\; - \left(\dfrac{\varepsilon_n}{\varepsilon_{n-1}}\right)^{k_2/ord}, & + h_1\; \varepsilon_1^{-1/(p+1)}, &\quad\text{on the first step}, \\ + h_n\; \varepsilon_n^{-k_1/(p+1)}\; + \left(\dfrac{\varepsilon_n}{\varepsilon_{n-1}}\right)^{k_2/(p+1)}, & \quad\text{on subsequent steps}, \end{cases} -with default values :math:`k_1=0.367` and :math:`k_2=0.268`, and where :math:`ord = p+1`, -with :math:`p` is described below. In this estimate, a floor of :math:`\varepsilon > 10^{-10}` +with default values :math:`k_1=0.367` and :math:`k_2=0.268`, and where :math:`p` is +described below. In this estimate, a floor of :math:`\varepsilon > 10^{-10}` is enforced to avoid division-by-zero errors. The SUNAdaptController_ExpGus controller is implemented as a derived SUNAdaptController class, diff --git a/doc/shared/sunadaptcontroller/SUNAdaptController_I.rst b/doc/shared/sunadaptcontroller/SUNAdaptController_I.rst index a843227229..20fd04997e 100644 --- a/doc/shared/sunadaptcontroller/SUNAdaptController_I.rst +++ b/doc/shared/sunadaptcontroller/SUNAdaptController_I.rst @@ -24,9 +24,9 @@ the prospective time step estimate entirely off of the current local error estimate, .. math:: - h' \;=\; h_n\; \varepsilon_n^{-k_1/ord}, + h' \;=\; h_n\; \varepsilon_n^{-k_1/(p+1)}, -where :math:`ord = p+1`, where :math:`p` is described below. In this estimate, a floor of +where :math:`p` is described below. In this estimate, a floor of :math:`\varepsilon > 10^{-10}` is enforced to avoid division-by-zero errors. By default the constant :math:`k_1=1`. diff --git a/doc/shared/sunadaptcontroller/SUNAdaptController_ImExGus.rst b/doc/shared/sunadaptcontroller/SUNAdaptController_ImExGus.rst index 0e11bda66f..5389e8c3a9 100644 --- a/doc/shared/sunadaptcontroller/SUNAdaptController_ImExGus.rst +++ b/doc/shared/sunadaptcontroller/SUNAdaptController_ImExGus.rst @@ -24,15 +24,15 @@ is primarily useful with explicit Runge--Kutta methods, and has the form .. math:: h' \;=\; \begin{cases} - h_1\; \varepsilon_1^{-1/ord}, &\quad\text{on the first step}, \\ - h_n\; \varepsilon_n^{-k_1/ord}\; - \left(\dfrac{\varepsilon_n}{\varepsilon_{n-1}}\right)^{k_2/ord}, & + h_1\; \varepsilon_1^{-1/(p+1)}, &\quad\text{on the first step}, \\ + h_n\; \varepsilon_n^{-k_1/(p+1)}\; + \left(\dfrac{\varepsilon_n}{\varepsilon_{n-1}}\right)^{k_2/(p+1)}, & \quad\text{on subsequent steps}. \end{cases} :label: expGusController The default values of :math:`k_1` and :math:`k_2` are 0.367 and 0.268, -respectively, and :math:`ord = p+1`, where :math:`p` is described below. In this estimate, +respectively, and :math:`p` is described below. In this estimate, a floor of :math:`\varepsilon > 10^{-10}` is enforced to avoid division-by-zero errors. Gustafsson also proposed a controller for implicit Runge--Kutta methods in :cite:p:`Gust:94`, @@ -40,9 +40,9 @@ with the form .. math:: h' = \begin{cases} - h_1 \varepsilon_1^{-1/ord}, &\quad\text{on the first step}, \\ - h_n \left(\dfrac{h_n}{h_{n-1}}\right) \varepsilon_n^{-k_1/ord} - \left(\dfrac{\varepsilon_n}{\varepsilon_{n-1}}\right)^{-k_2/ord}, & + h_1 \varepsilon_1^{-1/(p+1)}, &\quad\text{on the first step}, \\ + h_n \left(\dfrac{h_n}{h_{n-1}}\right) \varepsilon_n^{-k_1/(p+1)} + \left(\dfrac{\varepsilon_n}{\varepsilon_{n-1}}\right)^{-k_2/(p+1)}, & \quad\text{on subsequent steps}, \end{cases} :label: impGusController diff --git a/doc/shared/sunadaptcontroller/SUNAdaptController_ImpGus.rst b/doc/shared/sunadaptcontroller/SUNAdaptController_ImpGus.rst index a0be96c9fb..3050b27be3 100644 --- a/doc/shared/sunadaptcontroller/SUNAdaptController_ImpGus.rst +++ b/doc/shared/sunadaptcontroller/SUNAdaptController_ImpGus.rst @@ -24,14 +24,14 @@ form .. math:: h' = \begin{cases} - h_1 \varepsilon_1^{-1/ord}, &\quad\text{on the first step}, \\ - h_n \left(\dfrac{h_n}{h_{n-1}}\right) \varepsilon_n^{-k_1/ord} - \left(\dfrac{\varepsilon_n}{\varepsilon_{n-1}}\right)^{-k_2/ord}, & + h_1 \varepsilon_1^{-1/(p+1)}, &\quad\text{on the first step}, \\ + h_n \left(\dfrac{h_n}{h_{n-1}}\right) \varepsilon_n^{-k_1/(p+1)} + \left(\dfrac{\varepsilon_n}{\varepsilon_{n-1}}\right)^{-k_2/(p+1)}, & \quad\text{on subsequent steps}, \end{cases} with default parameter values :math:`k_1 = 0.98` and :math:`k_2 = 0.95`, and where -:math:`ord = p+1`, where :math:`p` is described below. In this estimate, a floor of +:math:`p` is described below. In this estimate, a floor of :math:`\varepsilon > 10^{-10}` is enforced to avoid division-by-zero errors. The SUNAdaptController_ImpGus controller is implemented as a derived SUNAdaptController class, diff --git a/doc/shared/sunadaptcontroller/SUNAdaptController_PI.rst b/doc/shared/sunadaptcontroller/SUNAdaptController_PI.rst index 791ab89b12..ad421925b1 100644 --- a/doc/shared/sunadaptcontroller/SUNAdaptController_PI.rst +++ b/doc/shared/sunadaptcontroller/SUNAdaptController_PI.rst @@ -24,10 +24,10 @@ controller derives from those found in :cite:p:`KenCarp:03`, :cite:p:`Sod:98`, two most recent step sizes in its adaptivity algorithm, .. math:: - h' \;=\; h_n\; \varepsilon_n^{-k_1/ord}\; \varepsilon_{n-1}^{k_2/ord}. + h' \;=\; h_n\; \varepsilon_n^{-k_1/(p+1)}\; \varepsilon_{n-1}^{k_2/(p+1)}. where the constants :math:`k_1` and :math:`k_2` default to 0.8 and 0.31, -respectively, and :math:`ord = p+1`, where :math:`p` is described below. In this estimate, +respectively, and :math:`p` is described below. In this estimate, a floor of :math:`\varepsilon > 10^{-10}` is enforced to avoid division-by-zero errors. This is implemented as a derived SUNAdaptController class, and defines its *content* diff --git a/doc/shared/sunadaptcontroller/SUNAdaptController_PID.rst b/doc/shared/sunadaptcontroller/SUNAdaptController_PID.rst index 298f93164b..ddf25d77f6 100644 --- a/doc/shared/sunadaptcontroller/SUNAdaptController_PID.rst +++ b/doc/shared/sunadaptcontroller/SUNAdaptController_PID.rst @@ -25,11 +25,11 @@ and uses three temporal error estimates, :math:`\varepsilon_n`, prospective step size, .. math:: - h' \;=\; h_n\; \varepsilon_n^{-k_1/ord}\; \varepsilon_{n-1}^{k_2/ord}\; - \varepsilon_{n-2}^{-k_3/ord}, + h' \;=\; h_n\; \varepsilon_n^{-k_1/(p+1)}\; \varepsilon_{n-1}^{k_2/(p+1)}\; + \varepsilon_{n-2}^{-k_3/(p+1)}, where the constants :math:`k_1`, :math:`k_2` and :math:`k_3` default to 0.58, -0.21 and 0.1, respectively, and :math:`ord = p+1`, where :math:`p` is described below. +0.21 and 0.1, respectively, and :math:`p` is described below. In this estimate, a floor of :math:`\varepsilon > 10^{-10}` is enforced to avoid division-by-zero errors. From 6b306052da3471f3a9dc1e956a7f20b08660ea74 Mon Sep 17 00:00:00 2001 From: "David J. Gardner" Date: Thu, 19 Oct 2023 15:19:40 -0700 Subject: [PATCH 11/58] update workspace sizes in output files --- .../C_parallel/ark_diurnal_kry_bbd_p.out | 102 +-- .../arkode/C_serial/ark_KrylovDemo_prec.out | 652 +++++++++--------- .../arkode/C_serial/ark_KrylovDemo_prec_1.out | 652 +++++++++--------- .../arkode/C_serial/ark_KrylovDemo_prec_2.out | 652 +++++++++--------- 4 files changed, 1029 insertions(+), 1029 deletions(-) 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 32243686c6..4ab235b940 100644 --- a/examples/arkode/C_parallel/ark_diurnal_kry_bbd_p.out +++ b/examples/arkode/C_parallel/ark_diurnal_kry_bbd_p.out @@ -8,55 +8,55 @@ Preconditioner type is: jpre = SUN_PREC_LEFT t = 7.20e+03 no. steps = 979 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 = 2738 stepsize = 6.94e+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 = 3535 stepsize = 1.05e+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 = 4683 stepsize = 4.46e+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 = 5959 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 = 7152 stepsize = 3.93e+02 -At bottom left: c1, c2 = -1.202e-09 3.382e+11 -At top right: c1, c2 = 1.624e-07 3.804e+11 +At bottom left: c1, c2 = -1.202e-09 3.382e+11 +At top right: c1, c2 = 1.624e-07 3.804e+11 t = 5.04e+04 no. steps = 7171 stepsize = 3.76e+02 -At bottom left: c1, c2 = 5.092e-08 3.358e+11 -At top right: c1, c2 = -4.835e-07 3.864e+11 +At bottom left: c1, c2 = 5.092e-08 3.358e+11 +At top right: c1, c2 = -4.835e-07 3.864e+11 t = 5.76e+04 no. steps = 7188 stepsize = 2.94e+02 -At bottom left: c1, c2 = -3.248e-10 3.320e+11 -At top right: c1, c2 = 7.269e-08 3.909e+11 +At bottom left: c1, c2 = -3.248e-10 3.320e+11 +At top right: c1, c2 = 7.269e-08 3.909e+11 t = 6.48e+04 no. steps = 7212 stepsize = 5.52e+02 -At bottom left: c1, c2 = -1.079e-09 3.313e+11 -At top right: c1, c2 = -2.660e-07 3.963e+11 +At bottom left: c1, c2 = -1.079e-09 3.313e+11 +At top right: c1, c2 = -2.660e-07 3.963e+11 t = 7.20e+04 no. steps = 7225 stepsize = 5.52e+02 -At bottom left: c1, c2 = 4.318e-08 3.330e+11 -At top right: c1, c2 = -4.973e-07 4.039e+11 +At bottom left: c1, c2 = 4.318e-08 3.330e+11 +At top right: c1, c2 = -4.973e-07 4.039e+11 t = 7.92e+04 no. steps = 7238 stepsize = 5.52e+02 -At bottom left: c1, c2 = -1.398e-08 3.334e+11 -At top right: c1, c2 = 7.657e-08 4.120e+11 +At bottom left: c1, c2 = -1.398e-08 3.334e+11 +At top right: c1, c2 = 7.657e-08 4.120e+11 t = 8.64e+04 no. steps = 7252 stepsize = 5.52e+02 -At bottom left: c1, c2 = 1.764e-07 3.352e+11 -At top right: c1, c2 = -4.190e-08 4.163e+11 +At bottom left: c1, c2 = 1.764e-07 3.352e+11 +At top right: c1, c2 = -4.190e-08 4.163e+11 -Final Statistics: +Final Statistics: lenrw = 3898 leniw = 267 lenrwls = 2455 leniwls = 126 @@ -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 = 981 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 = 2731 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 = 4692 stepsize = 3.80e+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 = 6087 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 = 7275 stepsize = 4.76e+02 -At bottom left: c1, c2 = 1.722e-10 3.382e+11 -At top right: c1, c2 = 1.593e-09 3.804e+11 +At bottom left: c1, c2 = 1.722e-10 3.382e+11 +At top right: c1, c2 = 1.593e-09 3.804e+11 t = 5.04e+04 no. steps = 7291 stepsize = 3.75e+02 -At bottom left: c1, c2 = 1.309e-09 3.358e+11 -At top right: c1, c2 = -1.367e-09 3.864e+11 +At bottom left: c1, c2 = 1.309e-09 3.358e+11 +At top right: c1, c2 = -1.367e-09 3.864e+11 t = 5.76e+04 no. steps = 7308 stepsize = 2.92e+02 -At bottom left: c1, c2 = -2.110e-07 3.320e+11 -At top right: c1, c2 = -3.069e-07 3.909e+11 +At bottom left: c1, c2 = -2.110e-07 3.320e+11 +At top right: c1, c2 = -3.069e-07 3.909e+11 t = 6.48e+04 no. steps = 7323 stepsize = 4.87e+02 -At bottom left: c1, c2 = 2.224e-07 3.313e+11 -At top right: c1, c2 = 2.684e-07 3.963e+11 +At bottom left: c1, c2 = 2.224e-07 3.313e+11 +At top right: c1, c2 = 2.684e-07 3.963e+11 t = 7.20e+04 no. steps = 7338 stepsize = 4.87e+02 -At bottom left: c1, c2 = 6.820e-08 3.330e+11 -At top right: c1, c2 = -2.132e-06 4.039e+11 +At bottom left: c1, c2 = 6.820e-08 3.330e+11 +At top right: c1, c2 = -2.132e-06 4.039e+11 t = 7.92e+04 no. steps = 7353 stepsize = 4.87e+02 -At bottom left: c1, c2 = 1.134e-09 3.334e+11 -At top right: c1, c2 = -2.341e-07 4.120e+11 +At bottom left: c1, c2 = 1.134e-09 3.334e+11 +At top right: c1, c2 = -2.341e-07 4.120e+11 t = 8.64e+04 no. steps = 7364 stepsize = 7.33e+02 -At bottom left: c1, c2 = 4.331e-07 3.352e+11 -At top right: c1, c2 = -6.607e-08 4.163e+11 +At bottom left: c1, c2 = 4.331e-07 3.352e+11 +At top right: c1, c2 = -6.607e-08 4.163e+11 -Final Statistics: +Final Statistics: -lenrw = 3898 leniw = 267 +lenrw = 3898 leniw = 272 lenrwls = 2455 leniwls = 126 nst = 7364 nfe = 0 nfe = 77457 nfels = 101131 diff --git a/examples/arkode/C_serial/ark_KrylovDemo_prec.out b/examples/arkode/C_serial/ark_KrylovDemo_prec.out index 09364ad394..a2564a38ee 100644 --- a/examples/arkode/C_serial/ark_KrylovDemo_prec.out +++ b/examples/arkode/C_serial/ark_KrylovDemo_prec.out @@ -10,9 +10,9 @@ b parameter = 1 Diffusion coefficients: Dprey = 1 Dpred = 0.5 Rate parameter alpha = 1 -Mesh dimensions (mx,my) are 6, 6. Total system size is neq = 216 +Mesh dimensions (mx,my) are 6, 6. Total system size is neq = 216 -Tolerances: reltol = 1e-05, abstol = 1e-05 +Tolerances: reltol = 1e-05, abstol = 1e-05 Preconditioning uses a product of: (1) Gauss-Seidel iterations with itmax = 5 iterations, and @@ -31,52 +31,52 @@ Gram-Schmidt method type is gstype = SUN_MODIFIED_GS c values at t = 0: Species 1 -10 10 10 10 10 10 -10 10.1678 10.3775 10.3775 10.1678 10 -10 10.3775 10.8493 10.8493 10.3775 10 -10 10.3775 10.8493 10.8493 10.3775 10 -10 10.1678 10.3775 10.3775 10.1678 10 -10 10 10 10 10 10 +10 10 10 10 10 10 +10 10.1678 10.3775 10.3775 10.1678 10 +10 10.3775 10.8493 10.8493 10.3775 10 +10 10.3775 10.8493 10.8493 10.3775 10 +10 10.1678 10.3775 10.3775 10.1678 10 +10 10 10 10 10 10 Species 2 -10 10 10 10 10 10 -10 10.3355 10.755 10.755 10.3355 10 -10 10.755 11.6987 11.6987 10.755 10 -10 10.755 11.6987 11.6987 10.755 10 -10 10.3355 10.755 10.755 10.3355 10 -10 10 10 10 10 10 +10 10 10 10 10 10 +10 10.3355 10.755 10.755 10.3355 10 +10 10.755 11.6987 11.6987 10.755 10 +10 10.755 11.6987 11.6987 10.755 10 +10 10.3355 10.755 10.755 10.3355 10 +10 10 10 10 10 10 Species 3 -10 10 10 10 10 10 -10 10.5033 11.1325 11.1325 10.5033 10 -10 11.1325 12.548 12.548 11.1325 10 -10 11.1325 12.548 12.548 11.1325 10 -10 10.5033 11.1325 11.1325 10.5033 10 -10 10 10 10 10 10 +10 10 10 10 10 10 +10 10.5033 11.1325 11.1325 10.5033 10 +10 11.1325 12.548 12.548 11.1325 10 +10 11.1325 12.548 12.548 11.1325 10 +10 10.5033 11.1325 11.1325 10.5033 10 +10 10 10 10 10 10 Species 4 -10 10 10 10 10 10 -10 10.6711 11.5099 11.5099 10.6711 10 -10 11.5099 13.3974 13.3974 11.5099 10 -10 11.5099 13.3974 13.3974 11.5099 10 -10 10.6711 11.5099 11.5099 10.6711 10 -10 10 10 10 10 10 +10 10 10 10 10 10 +10 10.6711 11.5099 11.5099 10.6711 10 +10 11.5099 13.3974 13.3974 11.5099 10 +10 11.5099 13.3974 13.3974 11.5099 10 +10 10.6711 11.5099 11.5099 10.6711 10 +10 10 10 10 10 10 Species 5 -10 10 10 10 10 10 -10 10.8389 11.8874 11.8874 10.8389 10 -10 11.8874 14.2467 14.2467 11.8874 10 -10 11.8874 14.2467 14.2467 11.8874 10 -10 10.8389 11.8874 11.8874 10.8389 10 -10 10 10 10 10 10 +10 10 10 10 10 10 +10 10.8389 11.8874 11.8874 10.8389 10 +10 11.8874 14.2467 14.2467 11.8874 10 +10 11.8874 14.2467 14.2467 11.8874 10 +10 10.8389 11.8874 11.8874 10.8389 10 +10 10 10 10 10 10 Species 6 -10 10 10 10 10 10 -10 11.0066 12.2649 12.2649 11.0066 10 -10 12.2649 15.0961 15.0961 12.2649 10 -10 12.2649 15.0961 15.0961 12.2649 10 -10 11.0066 12.2649 12.2649 11.0066 10 -10 10 10 10 10 10 +10 10 10 10 10 10 +10 11.0066 12.2649 12.2649 11.0066 10 +10 12.2649 15.0961 15.0961 12.2649 10 +10 12.2649 15.0961 15.0961 12.2649 10 +10 11.0066 12.2649 12.2649 11.0066 10 +10 10 10 10 10 10 t = 1.00e-08 nst = 5 nfe = 0 nfi = 75 nni = 47 hu = 9.89e-08 @@ -87,52 +87,52 @@ t = 1.00e-06 nst = 8 nfe = 0 nfi = 120 nni = 77 hu = 4.79e-07 c values at t = 1e-06: Species 1 -9.99991 9.99992 9.99993 9.99993 9.99993 9.99992 -9.99992 10.1677 10.3774 10.3774 10.1677 9.99993 -9.99993 10.3774 10.8492 10.8492 10.3774 9.99993 -9.99993 10.3774 10.8492 10.8492 10.3774 9.99993 -9.99992 10.1677 10.3774 10.3774 10.1677 9.99992 -9.99991 9.99992 9.99993 9.99993 9.99992 9.99991 +9.99991 9.99992 9.99993 9.99993 9.99993 9.99992 +9.99992 10.1677 10.3774 10.3774 10.1677 9.99993 +9.99993 10.3774 10.8492 10.8492 10.3774 9.99993 +9.99993 10.3774 10.8492 10.8492 10.3774 9.99993 +9.99992 10.1677 10.3774 10.3774 10.1677 9.99992 +9.99991 9.99992 9.99993 9.99993 9.99992 9.99991 Species 2 -9.99991 9.99993 9.99995 9.99995 9.99993 9.99992 -9.99993 10.3355 10.7549 10.7549 10.3355 9.99993 -9.99995 10.7549 11.6985 11.6985 10.7549 9.99995 -9.99995 10.7549 11.6985 11.6985 10.7549 9.99995 -9.99993 10.3355 10.7549 10.7549 10.3355 9.99993 -9.99991 9.99993 9.99995 9.99995 9.99993 9.99991 +9.99991 9.99993 9.99995 9.99995 9.99993 9.99992 +9.99993 10.3355 10.7549 10.7549 10.3355 9.99993 +9.99995 10.7549 11.6985 11.6985 10.7549 9.99995 +9.99995 10.7549 11.6985 11.6985 10.7549 9.99995 +9.99993 10.3355 10.7549 10.7549 10.3355 9.99993 +9.99991 9.99993 9.99995 9.99995 9.99993 9.99991 Species 3 -9.99991 9.99994 9.99997 9.99997 9.99994 9.99992 -9.99994 10.5032 11.1323 11.1323 10.5032 9.99994 -9.99997 11.1323 12.5478 12.5478 11.1323 9.99997 -9.99997 11.1323 12.5478 12.5478 11.1323 9.99997 -9.99994 10.5032 11.1323 11.1323 10.5032 9.99994 -9.99991 9.99994 9.99997 9.99997 9.99994 9.99991 +9.99991 9.99994 9.99997 9.99997 9.99994 9.99992 +9.99994 10.5032 11.1323 11.1323 10.5032 9.99994 +9.99997 11.1323 12.5478 12.5478 11.1323 9.99997 +9.99997 11.1323 12.5478 12.5478 11.1323 9.99997 +9.99994 10.5032 11.1323 11.1323 10.5032 9.99994 +9.99991 9.99994 9.99997 9.99997 9.99994 9.99991 Species 4 -13.4984 13.4984 13.4984 13.4984 13.4984 13.4984 -13.4984 14.55 15.8924 15.8924 14.55 13.4984 -13.4984 15.8924 19.0296 19.0296 15.8924 13.4984 -13.4984 15.8924 19.0296 19.0296 15.8924 13.4984 -13.4984 14.55 15.8924 15.8924 14.55 13.4984 -13.4984 13.4984 13.4984 13.4984 13.4984 13.4984 +13.4984 13.4984 13.4984 13.4984 13.4984 13.4984 +13.4984 14.55 15.8924 15.8924 14.55 13.4984 +13.4984 15.8924 19.0296 19.0296 15.8924 13.4984 +13.4984 15.8924 19.0296 19.0296 15.8924 13.4984 +13.4984 14.55 15.8924 15.8924 14.55 13.4984 +13.4984 13.4984 13.4984 13.4984 13.4984 13.4984 Species 5 -13.4984 13.4984 13.4985 13.4985 13.4984 13.4984 -13.4984 14.7787 16.4136 16.4136 14.7787 13.4984 -13.4985 16.4136 20.236 20.236 16.4136 13.4985 -13.4985 16.4136 20.236 20.236 16.4136 13.4985 -13.4984 14.7787 16.4136 16.4136 14.7787 13.4984 -13.4984 13.4984 13.4985 13.4985 13.4984 13.4984 +13.4984 13.4984 13.4985 13.4985 13.4984 13.4984 +13.4984 14.7787 16.4136 16.4136 14.7787 13.4984 +13.4985 16.4136 20.236 20.236 16.4136 13.4985 +13.4985 16.4136 20.236 20.236 16.4136 13.4985 +13.4984 14.7787 16.4136 16.4136 14.7787 13.4984 +13.4984 13.4984 13.4985 13.4985 13.4984 13.4984 Species 6 -13.4984 13.4984 13.4985 13.4985 13.4984 13.4984 -13.4984 15.0075 16.9348 16.9348 15.0075 13.4984 -13.4985 16.9348 21.4423 21.4423 16.9348 13.4985 -13.4985 16.9348 21.4423 21.4423 16.9348 13.4985 -13.4984 15.0075 16.9348 16.9348 15.0075 13.4984 -13.4984 13.4984 13.4985 13.4985 13.4984 13.4984 +13.4984 13.4984 13.4985 13.4985 13.4984 13.4984 +13.4984 15.0075 16.9348 16.9348 15.0075 13.4984 +13.4985 16.9348 21.4423 21.4423 16.9348 13.4985 +13.4985 16.9348 21.4423 21.4423 16.9348 13.4985 +13.4984 15.0075 16.9348 16.9348 15.0075 13.4984 +13.4984 13.4984 13.4985 13.4985 13.4984 13.4984 t = 1.00e-05 nst = 27 nfe = 0 nfi = 407 nni = 269 hu = 4.79e-07 @@ -143,52 +143,52 @@ t = 1.00e-03 nst = 110 nfe = 0 nfi = 1750 nni = 1197 hu = 1.51e-03 c values at t = 0.001: Species 1 -9.90702 9.91664 9.92836 9.93033 9.92253 9.91674 -9.91472 10.0747 10.2769 10.2785 10.0795 9.92253 -9.92446 10.2748 10.7181 10.7194 10.2785 9.93033 -9.92445 10.2744 10.7173 10.7181 10.2769 9.92836 -9.91469 10.0734 10.2744 10.2748 10.0747 9.91664 -9.90698 9.91469 9.92445 9.92446 9.91472 9.90702 +9.90702 9.91664 9.92836 9.93033 9.92253 9.91674 +9.91472 10.0747 10.2769 10.2785 10.0795 9.92253 +9.92446 10.2748 10.7181 10.7194 10.2785 9.93033 +9.92445 10.2744 10.7173 10.7181 10.2769 9.92836 +9.91469 10.0734 10.2744 10.2748 10.0747 9.91664 +9.90698 9.91469 9.92445 9.92446 9.91472 9.90702 Species 2 -9.90742 9.92474 9.94622 9.94819 9.93064 9.91713 -9.92282 10.2412 10.644 10.6457 10.2461 9.93064 -9.94232 10.6419 11.5267 11.5281 10.6457 9.94819 -9.94231 10.6415 11.5258 11.5267 10.644 9.94622 -9.92279 10.24 10.6415 10.6419 10.2412 9.92474 -9.90737 9.92279 9.94231 9.94232 9.92282 9.90742 +9.90742 9.92474 9.94622 9.94819 9.93064 9.91713 +9.92282 10.2412 10.644 10.6457 10.2461 9.93064 +9.94232 10.6419 11.5267 11.5281 10.6457 9.94819 +9.94231 10.6415 11.5258 11.5267 10.644 9.94622 +9.92279 10.24 10.6415 10.6419 10.2412 9.92474 +9.90737 9.92279 9.94231 9.94232 9.92282 9.90742 Species 3 -9.90781 9.93284 9.96408 9.96605 9.93874 9.91753 -9.93092 10.4078 11.0109 11.0127 10.4127 9.93874 -9.96017 11.0088 12.3339 12.3354 11.0127 9.96605 -9.96016 11.0083 12.333 12.3339 11.0109 9.96408 -9.93088 10.4065 11.0083 11.0088 10.4078 9.93284 -9.90776 9.93088 9.96016 9.96017 9.93092 9.90781 +9.90781 9.93284 9.96408 9.96605 9.93874 9.91753 +9.93092 10.4078 11.0109 11.0127 10.4127 9.93874 +9.96017 11.0088 12.3339 12.3354 11.0127 9.96605 +9.96016 11.0083 12.333 12.3339 11.0109 9.96408 +9.93088 10.4065 11.0083 11.0088 10.4078 9.93284 +9.90776 9.93088 9.96016 9.96017 9.93092 9.90781 Species 4 -297231 297749 298392 298451 297925 297520 -297692 307245 319327 319378 307390 297925 -298276 319264 345799 345840 319378 298451 -298276 319252 345772 345799 319327 298392 -297691 307208 319252 319264 307245 297749 -297229 297691 298276 298276 297692 297231 +297231 297749 298392 298451 297925 297520 +297692 307245 319327 319378 307390 297925 +298276 319264 345799 345840 319378 298451 +298276 319252 345772 345799 319327 298392 +297691 307208 319252 319264 307245 297749 +297229 297691 298276 298276 297692 297231 Species 5 -297231 297749 298392 298451 297925 297520 -297692 307245 319327 319378 307390 297925 -298276 319264 345799 345840 319378 298451 -298276 319252 345772 345799 319327 298392 -297691 307208 319252 319264 307245 297749 -297229 297691 298276 298276 297692 297231 +297231 297749 298392 298451 297925 297520 +297692 307245 319327 319378 307390 297925 +298276 319264 345799 345840 319378 298451 +298276 319252 345772 345799 319327 298392 +297691 307208 319252 319264 307245 297749 +297229 297691 298276 298276 297692 297231 Species 6 -297231 297749 298392 298451 297925 297520 -297692 307245 319327 319378 307390 297925 -298276 319264 345799 345840 319378 298451 -298276 319252 345772 345799 319327 298392 -297691 307208 319252 319264 307245 297749 -297229 297691 298276 298276 297692 297231 +297231 297749 298392 298451 297925 297520 +297692 307245 319327 319378 307390 297925 +298276 319264 345799 345840 319378 298451 +298276 319252 345772 345799 319327 298392 +297691 307208 319252 319264 307245 297749 +297229 297691 298276 298276 297692 297231 t = 1.00e-02 nst = 113 nfe = 0 nfi = 1797 nni = 1229 hu = 3.46e-03 @@ -199,52 +199,52 @@ t = 1.00e+00 nst = 154 nfe = 0 nfi = 2489 nni = 1716 hu = 6.84e-02 c values at t = 1: Species 1 -1.58851 1.59924 1.62152 1.64764 1.67036 1.68149 -1.58533 1.59503 1.61548 1.63952 1.66033 1.67036 -1.57757 1.58547 1.60239 1.62235 1.63952 1.64764 -1.5682 1.57412 1.58706 1.60239 1.61548 1.62152 -1.56048 1.56463 1.57412 1.58547 1.59503 1.59924 -1.55733 1.56048 1.5682 1.57757 1.58533 1.58851 +1.58851 1.59924 1.62152 1.64764 1.67036 1.68149 +1.58533 1.59503 1.61548 1.63952 1.66033 1.67036 +1.57757 1.58547 1.60239 1.62235 1.63952 1.64764 +1.5682 1.57412 1.58706 1.60239 1.61548 1.62152 +1.56048 1.56463 1.57412 1.58547 1.59503 1.59924 +1.55733 1.56048 1.5682 1.57757 1.58533 1.58851 Species 2 -1.59067 1.60141 1.62371 1.64987 1.67261 1.68375 -1.58748 1.5972 1.61766 1.64173 1.66257 1.67261 -1.57971 1.58763 1.60457 1.62454 1.64173 1.64987 -1.57034 1.57626 1.58921 1.60457 1.61766 1.62371 -1.56261 1.56676 1.57626 1.58763 1.5972 1.60141 -1.55945 1.56261 1.57034 1.57971 1.58748 1.59067 +1.59067 1.60141 1.62371 1.64987 1.67261 1.68375 +1.58748 1.5972 1.61766 1.64173 1.66257 1.67261 +1.57971 1.58763 1.60457 1.62454 1.64173 1.64987 +1.57034 1.57626 1.58921 1.60457 1.61766 1.62371 +1.56261 1.56676 1.57626 1.58763 1.5972 1.60141 +1.55945 1.56261 1.57034 1.57971 1.58748 1.59067 Species 3 -1.5927 1.60346 1.62578 1.65197 1.67474 1.68589 -1.58951 1.59924 1.61973 1.64383 1.66468 1.67474 -1.58174 1.58966 1.60662 1.62662 1.64383 1.65197 -1.57236 1.57828 1.59125 1.60662 1.61973 1.62578 -1.56462 1.56878 1.57828 1.58966 1.59924 1.60346 -1.56146 1.56462 1.57236 1.58174 1.58951 1.5927 +1.5927 1.60346 1.62578 1.65197 1.67474 1.68589 +1.58951 1.59924 1.61973 1.64383 1.66468 1.67474 +1.58174 1.58966 1.60662 1.62662 1.64383 1.65197 +1.57236 1.57828 1.59125 1.60662 1.61973 1.62578 +1.56462 1.56878 1.57828 1.58966 1.59924 1.60346 +1.56146 1.56462 1.57236 1.58174 1.58951 1.5927 Species 4 -47718.3 48040.3 48709 49493.5 50175.5 50509.4 -47622.8 47914 48527.8 49249.6 49874.4 50175.5 -47389.7 47627 48134.9 48734.2 49249.6 49493.5 -47108.5 47286 47674.6 48134.9 48527.8 48709 -46876.6 47001.2 47286 47627 47914 48040.3 -46781.9 46876.6 47108.5 47389.7 47622.8 47718.3 +47718.3 48040.3 48709 49493.5 50175.5 50509.4 +47622.8 47914 48527.8 49249.6 49874.4 50175.5 +47389.7 47627 48134.9 48734.2 49249.6 49493.5 +47108.5 47286 47674.6 48134.9 48527.8 48709 +46876.6 47001.2 47286 47627 47914 48040.3 +46781.9 46876.6 47108.5 47389.7 47622.8 47718.3 Species 5 -47718.3 48040.3 48709 49493.5 50175.5 50509.4 -47622.8 47914 48527.8 49249.6 49874.4 50175.5 -47389.7 47627 48134.9 48734.2 49249.6 49493.5 -47108.5 47286 47674.6 48134.9 48527.8 48709 -46876.6 47001.2 47286 47627 47914 48040.3 -46781.9 46876.6 47108.5 47389.7 47622.8 47718.3 +47718.3 48040.3 48709 49493.5 50175.5 50509.4 +47622.8 47914 48527.8 49249.6 49874.4 50175.5 +47389.7 47627 48134.9 48734.2 49249.6 49493.5 +47108.5 47286 47674.6 48134.9 48527.8 48709 +46876.6 47001.2 47286 47627 47914 48040.3 +46781.9 46876.6 47108.5 47389.7 47622.8 47718.3 Species 6 -47718.3 48040.3 48709 49493.5 50175.5 50509.4 -47622.8 47914 48527.8 49249.6 49874.4 50175.5 -47389.7 47627 48134.9 48734.2 49249.6 49493.5 -47108.5 47286 47674.6 48134.9 48527.8 48709 -46876.6 47001.2 47286 47627 47914 48040.3 -46781.9 46876.6 47108.5 47389.7 47622.8 47718.3 +47718.3 48040.3 48709 49493.5 50175.5 50509.4 +47622.8 47914 48527.8 49249.6 49874.4 50175.5 +47389.7 47627 48134.9 48734.2 49249.6 49493.5 +47108.5 47286 47674.6 48134.9 48527.8 48709 +46876.6 47001.2 47286 47627 47914 48040.3 +46781.9 46876.6 47108.5 47389.7 47622.8 47718.3 t = 2.00e+00 nst = 165 nfe = 0 nfi = 2661 nni = 1833 hu = 4.14e-02 @@ -255,52 +255,52 @@ t = 4.00e+00 nst = 187 nfe = 0 nfi = 3013 nni = 2073 hu = 1.23e-01 c values at t = 4: Species 1 -1.19535 1.20368 1.2211 1.24157 1.25935 1.268 -1.1928 1.20035 1.21636 1.23523 1.25154 1.25935 -1.18657 1.19274 1.20602 1.22173 1.23523 1.24157 -1.17904 1.18368 1.19389 1.20602 1.21636 1.2211 -1.17284 1.17613 1.18368 1.19274 1.20035 1.20368 -1.17032 1.17284 1.17904 1.18657 1.1928 1.19535 +1.19535 1.20368 1.2211 1.24157 1.25935 1.268 +1.1928 1.20035 1.21636 1.23523 1.25154 1.25935 +1.18657 1.19274 1.20602 1.22173 1.23523 1.24157 +1.17904 1.18368 1.19389 1.20602 1.21636 1.2211 +1.17284 1.17613 1.18368 1.19274 1.20035 1.20368 +1.17032 1.17284 1.17904 1.18657 1.1928 1.19535 Species 2 -1.19538 1.20371 1.22113 1.24161 1.25938 1.26804 -1.19284 1.20038 1.21639 1.23526 1.25157 1.25938 -1.1866 1.19277 1.20606 1.22177 1.23526 1.24161 -1.17908 1.18371 1.19393 1.20606 1.21639 1.22113 -1.17288 1.17616 1.18371 1.19277 1.20038 1.20371 -1.17035 1.17288 1.17908 1.1866 1.19284 1.19538 +1.19538 1.20371 1.22113 1.24161 1.25938 1.26804 +1.19284 1.20038 1.21639 1.23526 1.25157 1.25938 +1.1866 1.19277 1.20606 1.22177 1.23526 1.24161 +1.17908 1.18371 1.19393 1.20606 1.21639 1.22113 +1.17288 1.17616 1.18371 1.19277 1.20038 1.20371 +1.17035 1.17288 1.17908 1.1866 1.19284 1.19538 Species 3 -1.19542 1.20374 1.22116 1.24164 1.25942 1.26807 -1.19287 1.20042 1.21642 1.2353 1.2516 1.25942 -1.18663 1.1928 1.20609 1.2218 1.2353 1.24164 -1.17911 1.18374 1.19396 1.20609 1.21642 1.22116 -1.17291 1.17619 1.18374 1.1928 1.20042 1.20374 -1.17039 1.17291 1.17911 1.18663 1.19287 1.19542 +1.19542 1.20374 1.22116 1.24164 1.25942 1.26807 +1.19287 1.20042 1.21642 1.2353 1.2516 1.25942 +1.18663 1.1928 1.20609 1.2218 1.2353 1.24164 +1.17911 1.18374 1.19396 1.20609 1.21642 1.22116 +1.17291 1.17619 1.18374 1.1928 1.20042 1.20374 +1.17039 1.17291 1.17911 1.18663 1.19287 1.19542 Species 4 -35860.6 36110.2 36632.4 37246.4 37779.5 38038.7 -35784.2 36010.4 36490.4 37056.3 37545.3 37779.5 -35597.2 35782 36180.5 36651.6 37056.3 37246.4 -35371.4 35510.4 35816.7 36180.5 36490.4 36632.4 -35185.4 35283.8 35510.4 35782 36010.4 36110.2 -35109.7 35185.4 35371.4 35597.2 35784.2 35860.6 +35860.6 36110.2 36632.4 37246.4 37779.5 38038.7 +35784.2 36010.4 36490.4 37056.3 37545.3 37779.5 +35597.2 35782 36180.5 36651.6 37056.3 37246.4 +35371.4 35510.4 35816.7 36180.5 36490.4 36632.4 +35185.4 35283.8 35510.4 35782 36010.4 36110.2 +35109.7 35185.4 35371.4 35597.2 35784.2 35860.6 Species 5 -35860.6 36110.2 36632.4 37246.4 37779.5 38038.7 -35784.2 36010.4 36490.4 37056.3 37545.3 37779.5 -35597.2 35782 36180.5 36651.6 37056.3 37246.4 -35371.4 35510.4 35816.7 36180.5 36490.4 36632.4 -35185.4 35283.8 35510.4 35782 36010.4 36110.2 -35109.7 35185.4 35371.4 35597.2 35784.2 35860.6 +35860.6 36110.2 36632.4 37246.4 37779.5 38038.7 +35784.2 36010.4 36490.4 37056.3 37545.3 37779.5 +35597.2 35782 36180.5 36651.6 37056.3 37246.4 +35371.4 35510.4 35816.7 36180.5 36490.4 36632.4 +35185.4 35283.8 35510.4 35782 36010.4 36110.2 +35109.7 35185.4 35371.4 35597.2 35784.2 35860.6 Species 6 -35860.6 36110.2 36632.4 37246.4 37779.5 38038.7 -35784.2 36010.4 36490.4 37056.3 37545.3 37779.5 -35597.2 35782 36180.5 36651.6 37056.3 37246.4 -35371.4 35510.4 35816.7 36180.5 36490.4 36632.4 -35185.4 35283.8 35510.4 35782 36010.4 36110.2 -35109.7 35185.4 35371.4 35597.2 35784.2 35860.6 +35860.6 36110.2 36632.4 37246.4 37779.5 38038.7 +35784.2 36010.4 36490.4 37056.3 37545.3 37779.5 +35597.2 35782 36180.5 36651.6 37056.3 37246.4 +35371.4 35510.4 35816.7 36180.5 36490.4 36632.4 +35185.4 35283.8 35510.4 35782 36010.4 36110.2 +35109.7 35185.4 35371.4 35597.2 35784.2 35860.6 t = 5.00e+00 nst = 198 nfe = 0 nfi = 3179 nni = 2182 hu = 9.99e-02 @@ -311,52 +311,52 @@ t = 7.00e+00 nst = 216 nfe = 0 nfi = 3477 nni = 2375 hu = 1.51e-01 c values at t = 7: Species 1 -1.18854 1.19682 1.21415 1.23453 1.25221 1.26082 -1.186 1.19351 1.20944 1.22822 1.24444 1.25221 -1.1798 1.18593 1.19916 1.21479 1.22822 1.23453 -1.17231 1.17692 1.18708 1.19916 1.20944 1.21415 -1.16614 1.1694 1.17692 1.18593 1.19351 1.19682 -1.16363 1.16614 1.17231 1.1798 1.186 1.18854 +1.18854 1.19682 1.21415 1.23453 1.25221 1.26082 +1.186 1.19351 1.20944 1.22822 1.24444 1.25221 +1.1798 1.18593 1.19916 1.21479 1.22822 1.23453 +1.17231 1.17692 1.18708 1.19916 1.20944 1.21415 +1.16614 1.1694 1.17692 1.18593 1.19351 1.19682 +1.16363 1.16614 1.17231 1.1798 1.186 1.18854 Species 2 -1.18854 1.19683 1.21415 1.23453 1.25222 1.26082 -1.186 1.19351 1.20944 1.22822 1.24444 1.25222 -1.1798 1.18594 1.19916 1.21479 1.22822 1.23453 -1.17231 1.17692 1.18709 1.19916 1.20944 1.21415 -1.16614 1.1694 1.17692 1.18594 1.19351 1.19683 -1.16363 1.16614 1.17231 1.1798 1.186 1.18854 +1.18854 1.19683 1.21415 1.23453 1.25222 1.26082 +1.186 1.19351 1.20944 1.22822 1.24444 1.25222 +1.1798 1.18594 1.19916 1.21479 1.22822 1.23453 +1.17231 1.17692 1.18709 1.19916 1.20944 1.21415 +1.16614 1.1694 1.17692 1.18594 1.19351 1.19683 +1.16363 1.16614 1.17231 1.1798 1.186 1.18854 Species 3 -1.18854 1.19683 1.21416 1.23453 1.25222 1.26082 -1.18601 1.19351 1.20944 1.22822 1.24444 1.25222 -1.1798 1.18594 1.19916 1.21479 1.22822 1.23453 -1.17231 1.17692 1.18709 1.19916 1.20944 1.21416 -1.16614 1.1694 1.17692 1.18594 1.19351 1.19683 -1.16363 1.16614 1.17231 1.1798 1.18601 1.18854 +1.18854 1.19683 1.21416 1.23453 1.25222 1.26082 +1.18601 1.19351 1.20944 1.22822 1.24444 1.25222 +1.1798 1.18594 1.19916 1.21479 1.22822 1.23453 +1.17231 1.17692 1.18709 1.19916 1.20944 1.21416 +1.16614 1.1694 1.17692 1.18594 1.19351 1.19683 +1.16363 1.16614 1.17231 1.1798 1.18601 1.18854 Species 4 -35656.3 35903.1 36424.2 37033.8 37564.6 37822.3 -35578.4 35804.9 36281.3 36845.5 37330.9 37564.6 -35393.9 35575.9 35974.4 36441.4 36845.5 37033.8 -35167.5 35307.4 35610.6 35974.4 36281.3 36424.2 -34984.3 35080.2 35307.4 35575.9 35804.9 35903.1 -34907.5 34984.3 35167.5 35393.9 35578.4 35656.3 +35656.3 35903.1 36424.2 37033.8 37564.6 37822.3 +35578.4 35804.9 36281.3 36845.5 37330.9 37564.6 +35393.9 35575.9 35974.4 36441.4 36845.5 37033.8 +35167.5 35307.4 35610.6 35974.4 36281.3 36424.2 +34984.3 35080.2 35307.4 35575.9 35804.9 35903.1 +34907.5 34984.3 35167.5 35393.9 35578.4 35656.3 Species 5 -35656.3 35903.1 36424.2 37033.8 37564.6 37822.3 -35578.4 35804.9 36281.3 36845.5 37330.9 37564.6 -35393.9 35575.9 35974.4 36441.4 36845.5 37033.8 -35167.5 35307.4 35610.6 35974.4 36281.3 36424.2 -34984.3 35080.2 35307.4 35575.9 35804.9 35903.1 -34907.5 34984.3 35167.5 35393.9 35578.4 35656.3 +35656.3 35903.1 36424.2 37033.8 37564.6 37822.3 +35578.4 35804.9 36281.3 36845.5 37330.9 37564.6 +35393.9 35575.9 35974.4 36441.4 36845.5 37033.8 +35167.5 35307.4 35610.6 35974.4 36281.3 36424.2 +34984.3 35080.2 35307.4 35575.9 35804.9 35903.1 +34907.5 34984.3 35167.5 35393.9 35578.4 35656.3 Species 6 -35656.3 35903.1 36424.2 37033.8 37564.6 37822.3 -35578.4 35804.9 36281.3 36845.5 37330.9 37564.6 -35393.9 35575.9 35974.4 36441.4 36845.5 37033.8 -35167.5 35307.4 35610.6 35974.4 36281.3 36424.2 -34984.3 35080.2 35307.4 35575.9 35804.9 35903.1 -34907.5 34984.3 35167.5 35393.9 35578.4 35656.3 +35656.3 35903.1 36424.2 37033.8 37564.6 37822.3 +35578.4 35804.9 36281.3 36845.5 37330.9 37564.6 +35393.9 35575.9 35974.4 36441.4 36845.5 37033.8 +35167.5 35307.4 35610.6 35974.4 36281.3 36424.2 +34984.3 35080.2 35307.4 35575.9 35804.9 35903.1 +34907.5 34984.3 35167.5 35393.9 35578.4 35656.3 t = 8.00e+00 nst = 232 nfe = 0 nfi = 3780 nni = 2567 hu = 1.06e-01 @@ -367,75 +367,75 @@ t = 1.00e+01 nst = 266 nfe = 0 nfi = 4394 nni = 2941 hu = 8.37e-02 c values at t = 10: Species 1 -1.18838 1.19667 1.21399 1.23437 1.25205 1.26066 -1.18585 1.19335 1.20928 1.22805 1.24428 1.25205 -1.17964 1.18578 1.199 1.21463 1.22805 1.23437 -1.17215 1.17676 1.18693 1.199 1.20928 1.21399 -1.16598 1.16925 1.17676 1.18578 1.19335 1.19667 -1.16347 1.16598 1.17215 1.17964 1.18585 1.18838 +1.18838 1.19667 1.21399 1.23437 1.25205 1.26066 +1.18585 1.19335 1.20928 1.22805 1.24428 1.25205 +1.17964 1.18578 1.199 1.21463 1.22805 1.23437 +1.17215 1.17676 1.18693 1.199 1.20928 1.21399 +1.16598 1.16925 1.17676 1.18578 1.19335 1.19667 +1.16347 1.16598 1.17215 1.17964 1.18585 1.18838 Species 2 -1.18838 1.19667 1.21399 1.23437 1.25205 1.26066 -1.18585 1.19335 1.20928 1.22805 1.24428 1.25205 -1.17964 1.18578 1.199 1.21463 1.22805 1.23437 -1.17215 1.17676 1.18693 1.199 1.20928 1.21399 -1.16598 1.16925 1.17676 1.18578 1.19335 1.19667 -1.16347 1.16598 1.17215 1.17964 1.18585 1.18838 +1.18838 1.19667 1.21399 1.23437 1.25205 1.26066 +1.18585 1.19335 1.20928 1.22805 1.24428 1.25205 +1.17964 1.18578 1.199 1.21463 1.22805 1.23437 +1.17215 1.17676 1.18693 1.199 1.20928 1.21399 +1.16598 1.16925 1.17676 1.18578 1.19335 1.19667 +1.16347 1.16598 1.17215 1.17964 1.18585 1.18838 Species 3 -1.18838 1.19667 1.21399 1.23437 1.25205 1.26066 -1.18585 1.19335 1.20928 1.22805 1.24428 1.25205 -1.17964 1.18578 1.199 1.21463 1.22805 1.23437 -1.17215 1.17676 1.18693 1.199 1.20928 1.21399 -1.16598 1.16925 1.17676 1.18578 1.19335 1.19667 -1.16347 1.16598 1.17215 1.17964 1.18585 1.18838 +1.18838 1.19667 1.21399 1.23437 1.25205 1.26066 +1.18585 1.19335 1.20928 1.22805 1.24428 1.25205 +1.17964 1.18578 1.199 1.21463 1.22805 1.23437 +1.17215 1.17676 1.18693 1.199 1.20928 1.21399 +1.16598 1.16925 1.17676 1.18578 1.19335 1.19667 +1.16347 1.16598 1.17215 1.17964 1.18585 1.18838 Species 4 -35650.6 35898.8 36418.4 37029.2 37559.5 37817.3 -35574.5 35799.5 36277.1 36840 37326.6 37559.5 -35388.4 35572.3 35968.8 36437.5 36840 37029.2 -35163.7 35302 35606.7 35968.8 36277.1 36418.4 -34978.6 35076.5 35302 35572.3 35799.5 35898.8 -34903.3 34978.6 35163.7 35388.4 35574.5 35650.6 +35650.6 35898.8 36418.4 37029.2 37559.5 37817.3 +35574.5 35799.5 36277.1 36840 37326.6 37559.5 +35388.4 35572.3 35968.8 36437.5 36840 37029.2 +35163.7 35302 35606.7 35968.8 36277.1 36418.4 +34978.6 35076.5 35302 35572.3 35799.5 35898.8 +34903.3 34978.6 35163.7 35388.4 35574.5 35650.6 Species 5 -35650.6 35898.8 36418.4 37029.2 37559.5 37817.3 -35574.5 35799.5 36277.1 36840 37326.6 37559.5 -35388.4 35572.3 35968.8 36437.5 36840 37029.2 -35163.7 35302 35606.7 35968.8 36277.1 36418.4 -34978.6 35076.5 35302 35572.3 35799.5 35898.8 -34903.3 34978.6 35163.7 35388.4 35574.5 35650.6 +35650.6 35898.8 36418.4 37029.2 37559.5 37817.3 +35574.5 35799.5 36277.1 36840 37326.6 37559.5 +35388.4 35572.3 35968.8 36437.5 36840 37029.2 +35163.7 35302 35606.7 35968.8 36277.1 36418.4 +34978.6 35076.5 35302 35572.3 35799.5 35898.8 +34903.3 34978.6 35163.7 35388.4 35574.5 35650.6 Species 6 -35650.6 35898.8 36418.4 37029.2 37559.5 37817.3 -35574.5 35799.5 36277.1 36840 37326.6 37559.5 -35388.4 35572.3 35968.8 36437.5 36840 37029.2 -35163.7 35302 35606.7 35968.8 36277.1 36418.4 -34978.6 35076.5 35302 35572.3 35799.5 35898.8 -34903.3 34978.6 35163.7 35388.4 35574.5 35650.6 +35650.6 35898.8 36418.4 37029.2 37559.5 37817.3 +35574.5 35799.5 36277.1 36840 37326.6 37559.5 +35388.4 35572.3 35968.8 36437.5 36840 37029.2 +35163.7 35302 35606.7 35968.8 36277.1 36418.4 +34978.6 35076.5 35302 35572.3 35799.5 35898.8 +34903.3 34978.6 35163.7 35388.4 35574.5 35650.6 Final statistics for this run: - ARKStep real workspace length = 3554 - ARKStep integer workspace length = 131 - ARKLS real workspace length = 2647 - ARKLS integer workspace length = 42 - Number of steps = 266 - Number of f-s (explicit) = 0 - Number of f-s (implicit) = 4394 - Number of f-s (SPGMR) = 8980 - Number of f-s (TOTAL) = 8980 - Number of setups = 121 - Number of nonlinear iterations = 2941 - Number of linear iterations = 8980 - Number of preconditioner evaluations = 121 - Number of preconditioner solves = 11819 - Number of error test failures = 23 - Number of nonlinear conv. failures = 17 - Number of linear convergence failures = 509 - Average Krylov subspace dimension = 3.053 + ARKStep real workspace length = 3554 + ARKStep integer workspace length = 131 + ARKLS real workspace length = 2647 + ARKLS integer workspace length = 42 + Number of steps = 266 + Number of f-s (explicit) = 0 + Number of f-s (implicit) = 4394 + Number of f-s (SPGMR) = 8980 + Number of f-s (TOTAL) = 8980 + Number of setups = 121 + Number of nonlinear iterations = 2941 + Number of linear iterations = 8980 + Number of preconditioner evaluations = 121 + Number of preconditioner solves = 11819 + Number of error test failures = 23 + Number of nonlinear conv. failures = 17 + Number of linear convergence failures = 509 + Average Krylov subspace dimension = 3.053 ---------------------------------------------------------------------------- @@ -487,24 +487,24 @@ t = 1.00e+01 nst = 251 nfe = 0 nfi = 4101 nni = 2746 hu = 7.09e-02 Final statistics for this run: - ARKStep real workspace length = 3554 - ARKStep integer workspace length = 131 - ARKLS real workspace length = 2647 - ARKLS integer workspace length = 42 - Number of steps = 251 - Number of f-s (explicit) = 0 - Number of f-s (implicit) = 4101 - Number of f-s (SPGMR) = 8880 - Number of f-s (TOTAL) = 8880 - Number of setups = 91 - Number of nonlinear iterations = 2746 - Number of linear iterations = 8880 - Number of preconditioner evaluations = 91 - Number of preconditioner solves = 11537 - Number of error test failures = 18 - Number of nonlinear conv. failures = 13 - Number of linear convergence failures = 597 - Average Krylov subspace dimension = 3.234 + ARKStep real workspace length = 3554 + ARKStep integer workspace length = 136 + ARKLS real workspace length = 2647 + ARKLS integer workspace length = 42 + Number of steps = 251 + Number of f-s (explicit) = 0 + Number of f-s (implicit) = 4101 + Number of f-s (SPGMR) = 8880 + Number of f-s (TOTAL) = 8880 + Number of setups = 91 + Number of nonlinear iterations = 2746 + Number of linear iterations = 8880 + Number of preconditioner evaluations = 91 + Number of preconditioner solves = 11537 + Number of error test failures = 18 + Number of nonlinear conv. failures = 13 + Number of linear convergence failures = 597 + Average Krylov subspace dimension = 3.234 ---------------------------------------------------------------------------- @@ -556,24 +556,24 @@ t = 1.00e+01 nst = 359 nfe = 0 nfi = 5722 nni = 3907 hu = 1.35e-01 Final statistics for this run: - ARKStep real workspace length = 3554 - ARKStep integer workspace length = 131 - ARKLS real workspace length = 2647 - ARKLS integer workspace length = 42 - Number of steps = 359 - Number of f-s (explicit) = 0 - Number of f-s (implicit) = 5722 - Number of f-s (SPGMR) = 12904 - Number of f-s (TOTAL) = 12904 - Number of setups = 253 - Number of nonlinear iterations = 3907 - Number of linear iterations = 12904 - Number of preconditioner evaluations = 253 - Number of preconditioner solves = 16594 - Number of error test failures = 0 - Number of nonlinear conv. failures = 117 - Number of linear convergence failures = 1072 - Average Krylov subspace dimension = 3.303 + ARKStep real workspace length = 3554 + ARKStep integer workspace length = 141 + ARKLS real workspace length = 2647 + ARKLS integer workspace length = 42 + Number of steps = 359 + Number of f-s (explicit) = 0 + Number of f-s (implicit) = 5722 + Number of f-s (SPGMR) = 12904 + Number of f-s (TOTAL) = 12904 + Number of setups = 253 + Number of nonlinear iterations = 3907 + Number of linear iterations = 12904 + Number of preconditioner evaluations = 253 + Number of preconditioner solves = 16594 + Number of error test failures = 0 + Number of nonlinear conv. failures = 117 + Number of linear convergence failures = 1072 + Average Krylov subspace dimension = 3.303 ---------------------------------------------------------------------------- @@ -625,24 +625,24 @@ t = 1.00e+01 nst = 359 nfe = 0 nfi = 5728 nni = 3912 hu = 1.31e-01 Final statistics for this run: - ARKStep real workspace length = 3554 - ARKStep integer workspace length = 131 - ARKLS real workspace length = 2647 - ARKLS integer workspace length = 42 - Number of steps = 359 - Number of f-s (explicit) = 0 - Number of f-s (implicit) = 5728 - Number of f-s (SPGMR) = 12934 - Number of f-s (TOTAL) = 12934 - Number of setups = 254 - Number of nonlinear iterations = 3912 - Number of linear iterations = 12934 - Number of preconditioner evaluations = 254 - Number of preconditioner solves = 16627 - Number of error test failures = 0 - Number of nonlinear conv. failures = 118 - Number of linear convergence failures = 1076 - Average Krylov subspace dimension = 3.306 + ARKStep real workspace length = 3554 + ARKStep integer workspace length = 146 + ARKLS real workspace length = 2647 + ARKLS integer workspace length = 42 + Number of steps = 359 + Number of f-s (explicit) = 0 + Number of f-s (implicit) = 5728 + Number of f-s (SPGMR) = 12934 + Number of f-s (TOTAL) = 12934 + Number of setups = 254 + Number of nonlinear iterations = 3912 + Number of linear iterations = 12934 + Number of preconditioner evaluations = 254 + Number of preconditioner solves = 16627 + Number of error test failures = 0 + Number of nonlinear conv. failures = 118 + Number of linear convergence failures = 1076 + Average Krylov subspace dimension = 3.306 ---------------------------------------------------------------------------- diff --git a/examples/arkode/C_serial/ark_KrylovDemo_prec_1.out b/examples/arkode/C_serial/ark_KrylovDemo_prec_1.out index 09364ad394..a2564a38ee 100644 --- a/examples/arkode/C_serial/ark_KrylovDemo_prec_1.out +++ b/examples/arkode/C_serial/ark_KrylovDemo_prec_1.out @@ -10,9 +10,9 @@ b parameter = 1 Diffusion coefficients: Dprey = 1 Dpred = 0.5 Rate parameter alpha = 1 -Mesh dimensions (mx,my) are 6, 6. Total system size is neq = 216 +Mesh dimensions (mx,my) are 6, 6. Total system size is neq = 216 -Tolerances: reltol = 1e-05, abstol = 1e-05 +Tolerances: reltol = 1e-05, abstol = 1e-05 Preconditioning uses a product of: (1) Gauss-Seidel iterations with itmax = 5 iterations, and @@ -31,52 +31,52 @@ Gram-Schmidt method type is gstype = SUN_MODIFIED_GS c values at t = 0: Species 1 -10 10 10 10 10 10 -10 10.1678 10.3775 10.3775 10.1678 10 -10 10.3775 10.8493 10.8493 10.3775 10 -10 10.3775 10.8493 10.8493 10.3775 10 -10 10.1678 10.3775 10.3775 10.1678 10 -10 10 10 10 10 10 +10 10 10 10 10 10 +10 10.1678 10.3775 10.3775 10.1678 10 +10 10.3775 10.8493 10.8493 10.3775 10 +10 10.3775 10.8493 10.8493 10.3775 10 +10 10.1678 10.3775 10.3775 10.1678 10 +10 10 10 10 10 10 Species 2 -10 10 10 10 10 10 -10 10.3355 10.755 10.755 10.3355 10 -10 10.755 11.6987 11.6987 10.755 10 -10 10.755 11.6987 11.6987 10.755 10 -10 10.3355 10.755 10.755 10.3355 10 -10 10 10 10 10 10 +10 10 10 10 10 10 +10 10.3355 10.755 10.755 10.3355 10 +10 10.755 11.6987 11.6987 10.755 10 +10 10.755 11.6987 11.6987 10.755 10 +10 10.3355 10.755 10.755 10.3355 10 +10 10 10 10 10 10 Species 3 -10 10 10 10 10 10 -10 10.5033 11.1325 11.1325 10.5033 10 -10 11.1325 12.548 12.548 11.1325 10 -10 11.1325 12.548 12.548 11.1325 10 -10 10.5033 11.1325 11.1325 10.5033 10 -10 10 10 10 10 10 +10 10 10 10 10 10 +10 10.5033 11.1325 11.1325 10.5033 10 +10 11.1325 12.548 12.548 11.1325 10 +10 11.1325 12.548 12.548 11.1325 10 +10 10.5033 11.1325 11.1325 10.5033 10 +10 10 10 10 10 10 Species 4 -10 10 10 10 10 10 -10 10.6711 11.5099 11.5099 10.6711 10 -10 11.5099 13.3974 13.3974 11.5099 10 -10 11.5099 13.3974 13.3974 11.5099 10 -10 10.6711 11.5099 11.5099 10.6711 10 -10 10 10 10 10 10 +10 10 10 10 10 10 +10 10.6711 11.5099 11.5099 10.6711 10 +10 11.5099 13.3974 13.3974 11.5099 10 +10 11.5099 13.3974 13.3974 11.5099 10 +10 10.6711 11.5099 11.5099 10.6711 10 +10 10 10 10 10 10 Species 5 -10 10 10 10 10 10 -10 10.8389 11.8874 11.8874 10.8389 10 -10 11.8874 14.2467 14.2467 11.8874 10 -10 11.8874 14.2467 14.2467 11.8874 10 -10 10.8389 11.8874 11.8874 10.8389 10 -10 10 10 10 10 10 +10 10 10 10 10 10 +10 10.8389 11.8874 11.8874 10.8389 10 +10 11.8874 14.2467 14.2467 11.8874 10 +10 11.8874 14.2467 14.2467 11.8874 10 +10 10.8389 11.8874 11.8874 10.8389 10 +10 10 10 10 10 10 Species 6 -10 10 10 10 10 10 -10 11.0066 12.2649 12.2649 11.0066 10 -10 12.2649 15.0961 15.0961 12.2649 10 -10 12.2649 15.0961 15.0961 12.2649 10 -10 11.0066 12.2649 12.2649 11.0066 10 -10 10 10 10 10 10 +10 10 10 10 10 10 +10 11.0066 12.2649 12.2649 11.0066 10 +10 12.2649 15.0961 15.0961 12.2649 10 +10 12.2649 15.0961 15.0961 12.2649 10 +10 11.0066 12.2649 12.2649 11.0066 10 +10 10 10 10 10 10 t = 1.00e-08 nst = 5 nfe = 0 nfi = 75 nni = 47 hu = 9.89e-08 @@ -87,52 +87,52 @@ t = 1.00e-06 nst = 8 nfe = 0 nfi = 120 nni = 77 hu = 4.79e-07 c values at t = 1e-06: Species 1 -9.99991 9.99992 9.99993 9.99993 9.99993 9.99992 -9.99992 10.1677 10.3774 10.3774 10.1677 9.99993 -9.99993 10.3774 10.8492 10.8492 10.3774 9.99993 -9.99993 10.3774 10.8492 10.8492 10.3774 9.99993 -9.99992 10.1677 10.3774 10.3774 10.1677 9.99992 -9.99991 9.99992 9.99993 9.99993 9.99992 9.99991 +9.99991 9.99992 9.99993 9.99993 9.99993 9.99992 +9.99992 10.1677 10.3774 10.3774 10.1677 9.99993 +9.99993 10.3774 10.8492 10.8492 10.3774 9.99993 +9.99993 10.3774 10.8492 10.8492 10.3774 9.99993 +9.99992 10.1677 10.3774 10.3774 10.1677 9.99992 +9.99991 9.99992 9.99993 9.99993 9.99992 9.99991 Species 2 -9.99991 9.99993 9.99995 9.99995 9.99993 9.99992 -9.99993 10.3355 10.7549 10.7549 10.3355 9.99993 -9.99995 10.7549 11.6985 11.6985 10.7549 9.99995 -9.99995 10.7549 11.6985 11.6985 10.7549 9.99995 -9.99993 10.3355 10.7549 10.7549 10.3355 9.99993 -9.99991 9.99993 9.99995 9.99995 9.99993 9.99991 +9.99991 9.99993 9.99995 9.99995 9.99993 9.99992 +9.99993 10.3355 10.7549 10.7549 10.3355 9.99993 +9.99995 10.7549 11.6985 11.6985 10.7549 9.99995 +9.99995 10.7549 11.6985 11.6985 10.7549 9.99995 +9.99993 10.3355 10.7549 10.7549 10.3355 9.99993 +9.99991 9.99993 9.99995 9.99995 9.99993 9.99991 Species 3 -9.99991 9.99994 9.99997 9.99997 9.99994 9.99992 -9.99994 10.5032 11.1323 11.1323 10.5032 9.99994 -9.99997 11.1323 12.5478 12.5478 11.1323 9.99997 -9.99997 11.1323 12.5478 12.5478 11.1323 9.99997 -9.99994 10.5032 11.1323 11.1323 10.5032 9.99994 -9.99991 9.99994 9.99997 9.99997 9.99994 9.99991 +9.99991 9.99994 9.99997 9.99997 9.99994 9.99992 +9.99994 10.5032 11.1323 11.1323 10.5032 9.99994 +9.99997 11.1323 12.5478 12.5478 11.1323 9.99997 +9.99997 11.1323 12.5478 12.5478 11.1323 9.99997 +9.99994 10.5032 11.1323 11.1323 10.5032 9.99994 +9.99991 9.99994 9.99997 9.99997 9.99994 9.99991 Species 4 -13.4984 13.4984 13.4984 13.4984 13.4984 13.4984 -13.4984 14.55 15.8924 15.8924 14.55 13.4984 -13.4984 15.8924 19.0296 19.0296 15.8924 13.4984 -13.4984 15.8924 19.0296 19.0296 15.8924 13.4984 -13.4984 14.55 15.8924 15.8924 14.55 13.4984 -13.4984 13.4984 13.4984 13.4984 13.4984 13.4984 +13.4984 13.4984 13.4984 13.4984 13.4984 13.4984 +13.4984 14.55 15.8924 15.8924 14.55 13.4984 +13.4984 15.8924 19.0296 19.0296 15.8924 13.4984 +13.4984 15.8924 19.0296 19.0296 15.8924 13.4984 +13.4984 14.55 15.8924 15.8924 14.55 13.4984 +13.4984 13.4984 13.4984 13.4984 13.4984 13.4984 Species 5 -13.4984 13.4984 13.4985 13.4985 13.4984 13.4984 -13.4984 14.7787 16.4136 16.4136 14.7787 13.4984 -13.4985 16.4136 20.236 20.236 16.4136 13.4985 -13.4985 16.4136 20.236 20.236 16.4136 13.4985 -13.4984 14.7787 16.4136 16.4136 14.7787 13.4984 -13.4984 13.4984 13.4985 13.4985 13.4984 13.4984 +13.4984 13.4984 13.4985 13.4985 13.4984 13.4984 +13.4984 14.7787 16.4136 16.4136 14.7787 13.4984 +13.4985 16.4136 20.236 20.236 16.4136 13.4985 +13.4985 16.4136 20.236 20.236 16.4136 13.4985 +13.4984 14.7787 16.4136 16.4136 14.7787 13.4984 +13.4984 13.4984 13.4985 13.4985 13.4984 13.4984 Species 6 -13.4984 13.4984 13.4985 13.4985 13.4984 13.4984 -13.4984 15.0075 16.9348 16.9348 15.0075 13.4984 -13.4985 16.9348 21.4423 21.4423 16.9348 13.4985 -13.4985 16.9348 21.4423 21.4423 16.9348 13.4985 -13.4984 15.0075 16.9348 16.9348 15.0075 13.4984 -13.4984 13.4984 13.4985 13.4985 13.4984 13.4984 +13.4984 13.4984 13.4985 13.4985 13.4984 13.4984 +13.4984 15.0075 16.9348 16.9348 15.0075 13.4984 +13.4985 16.9348 21.4423 21.4423 16.9348 13.4985 +13.4985 16.9348 21.4423 21.4423 16.9348 13.4985 +13.4984 15.0075 16.9348 16.9348 15.0075 13.4984 +13.4984 13.4984 13.4985 13.4985 13.4984 13.4984 t = 1.00e-05 nst = 27 nfe = 0 nfi = 407 nni = 269 hu = 4.79e-07 @@ -143,52 +143,52 @@ t = 1.00e-03 nst = 110 nfe = 0 nfi = 1750 nni = 1197 hu = 1.51e-03 c values at t = 0.001: Species 1 -9.90702 9.91664 9.92836 9.93033 9.92253 9.91674 -9.91472 10.0747 10.2769 10.2785 10.0795 9.92253 -9.92446 10.2748 10.7181 10.7194 10.2785 9.93033 -9.92445 10.2744 10.7173 10.7181 10.2769 9.92836 -9.91469 10.0734 10.2744 10.2748 10.0747 9.91664 -9.90698 9.91469 9.92445 9.92446 9.91472 9.90702 +9.90702 9.91664 9.92836 9.93033 9.92253 9.91674 +9.91472 10.0747 10.2769 10.2785 10.0795 9.92253 +9.92446 10.2748 10.7181 10.7194 10.2785 9.93033 +9.92445 10.2744 10.7173 10.7181 10.2769 9.92836 +9.91469 10.0734 10.2744 10.2748 10.0747 9.91664 +9.90698 9.91469 9.92445 9.92446 9.91472 9.90702 Species 2 -9.90742 9.92474 9.94622 9.94819 9.93064 9.91713 -9.92282 10.2412 10.644 10.6457 10.2461 9.93064 -9.94232 10.6419 11.5267 11.5281 10.6457 9.94819 -9.94231 10.6415 11.5258 11.5267 10.644 9.94622 -9.92279 10.24 10.6415 10.6419 10.2412 9.92474 -9.90737 9.92279 9.94231 9.94232 9.92282 9.90742 +9.90742 9.92474 9.94622 9.94819 9.93064 9.91713 +9.92282 10.2412 10.644 10.6457 10.2461 9.93064 +9.94232 10.6419 11.5267 11.5281 10.6457 9.94819 +9.94231 10.6415 11.5258 11.5267 10.644 9.94622 +9.92279 10.24 10.6415 10.6419 10.2412 9.92474 +9.90737 9.92279 9.94231 9.94232 9.92282 9.90742 Species 3 -9.90781 9.93284 9.96408 9.96605 9.93874 9.91753 -9.93092 10.4078 11.0109 11.0127 10.4127 9.93874 -9.96017 11.0088 12.3339 12.3354 11.0127 9.96605 -9.96016 11.0083 12.333 12.3339 11.0109 9.96408 -9.93088 10.4065 11.0083 11.0088 10.4078 9.93284 -9.90776 9.93088 9.96016 9.96017 9.93092 9.90781 +9.90781 9.93284 9.96408 9.96605 9.93874 9.91753 +9.93092 10.4078 11.0109 11.0127 10.4127 9.93874 +9.96017 11.0088 12.3339 12.3354 11.0127 9.96605 +9.96016 11.0083 12.333 12.3339 11.0109 9.96408 +9.93088 10.4065 11.0083 11.0088 10.4078 9.93284 +9.90776 9.93088 9.96016 9.96017 9.93092 9.90781 Species 4 -297231 297749 298392 298451 297925 297520 -297692 307245 319327 319378 307390 297925 -298276 319264 345799 345840 319378 298451 -298276 319252 345772 345799 319327 298392 -297691 307208 319252 319264 307245 297749 -297229 297691 298276 298276 297692 297231 +297231 297749 298392 298451 297925 297520 +297692 307245 319327 319378 307390 297925 +298276 319264 345799 345840 319378 298451 +298276 319252 345772 345799 319327 298392 +297691 307208 319252 319264 307245 297749 +297229 297691 298276 298276 297692 297231 Species 5 -297231 297749 298392 298451 297925 297520 -297692 307245 319327 319378 307390 297925 -298276 319264 345799 345840 319378 298451 -298276 319252 345772 345799 319327 298392 -297691 307208 319252 319264 307245 297749 -297229 297691 298276 298276 297692 297231 +297231 297749 298392 298451 297925 297520 +297692 307245 319327 319378 307390 297925 +298276 319264 345799 345840 319378 298451 +298276 319252 345772 345799 319327 298392 +297691 307208 319252 319264 307245 297749 +297229 297691 298276 298276 297692 297231 Species 6 -297231 297749 298392 298451 297925 297520 -297692 307245 319327 319378 307390 297925 -298276 319264 345799 345840 319378 298451 -298276 319252 345772 345799 319327 298392 -297691 307208 319252 319264 307245 297749 -297229 297691 298276 298276 297692 297231 +297231 297749 298392 298451 297925 297520 +297692 307245 319327 319378 307390 297925 +298276 319264 345799 345840 319378 298451 +298276 319252 345772 345799 319327 298392 +297691 307208 319252 319264 307245 297749 +297229 297691 298276 298276 297692 297231 t = 1.00e-02 nst = 113 nfe = 0 nfi = 1797 nni = 1229 hu = 3.46e-03 @@ -199,52 +199,52 @@ t = 1.00e+00 nst = 154 nfe = 0 nfi = 2489 nni = 1716 hu = 6.84e-02 c values at t = 1: Species 1 -1.58851 1.59924 1.62152 1.64764 1.67036 1.68149 -1.58533 1.59503 1.61548 1.63952 1.66033 1.67036 -1.57757 1.58547 1.60239 1.62235 1.63952 1.64764 -1.5682 1.57412 1.58706 1.60239 1.61548 1.62152 -1.56048 1.56463 1.57412 1.58547 1.59503 1.59924 -1.55733 1.56048 1.5682 1.57757 1.58533 1.58851 +1.58851 1.59924 1.62152 1.64764 1.67036 1.68149 +1.58533 1.59503 1.61548 1.63952 1.66033 1.67036 +1.57757 1.58547 1.60239 1.62235 1.63952 1.64764 +1.5682 1.57412 1.58706 1.60239 1.61548 1.62152 +1.56048 1.56463 1.57412 1.58547 1.59503 1.59924 +1.55733 1.56048 1.5682 1.57757 1.58533 1.58851 Species 2 -1.59067 1.60141 1.62371 1.64987 1.67261 1.68375 -1.58748 1.5972 1.61766 1.64173 1.66257 1.67261 -1.57971 1.58763 1.60457 1.62454 1.64173 1.64987 -1.57034 1.57626 1.58921 1.60457 1.61766 1.62371 -1.56261 1.56676 1.57626 1.58763 1.5972 1.60141 -1.55945 1.56261 1.57034 1.57971 1.58748 1.59067 +1.59067 1.60141 1.62371 1.64987 1.67261 1.68375 +1.58748 1.5972 1.61766 1.64173 1.66257 1.67261 +1.57971 1.58763 1.60457 1.62454 1.64173 1.64987 +1.57034 1.57626 1.58921 1.60457 1.61766 1.62371 +1.56261 1.56676 1.57626 1.58763 1.5972 1.60141 +1.55945 1.56261 1.57034 1.57971 1.58748 1.59067 Species 3 -1.5927 1.60346 1.62578 1.65197 1.67474 1.68589 -1.58951 1.59924 1.61973 1.64383 1.66468 1.67474 -1.58174 1.58966 1.60662 1.62662 1.64383 1.65197 -1.57236 1.57828 1.59125 1.60662 1.61973 1.62578 -1.56462 1.56878 1.57828 1.58966 1.59924 1.60346 -1.56146 1.56462 1.57236 1.58174 1.58951 1.5927 +1.5927 1.60346 1.62578 1.65197 1.67474 1.68589 +1.58951 1.59924 1.61973 1.64383 1.66468 1.67474 +1.58174 1.58966 1.60662 1.62662 1.64383 1.65197 +1.57236 1.57828 1.59125 1.60662 1.61973 1.62578 +1.56462 1.56878 1.57828 1.58966 1.59924 1.60346 +1.56146 1.56462 1.57236 1.58174 1.58951 1.5927 Species 4 -47718.3 48040.3 48709 49493.5 50175.5 50509.4 -47622.8 47914 48527.8 49249.6 49874.4 50175.5 -47389.7 47627 48134.9 48734.2 49249.6 49493.5 -47108.5 47286 47674.6 48134.9 48527.8 48709 -46876.6 47001.2 47286 47627 47914 48040.3 -46781.9 46876.6 47108.5 47389.7 47622.8 47718.3 +47718.3 48040.3 48709 49493.5 50175.5 50509.4 +47622.8 47914 48527.8 49249.6 49874.4 50175.5 +47389.7 47627 48134.9 48734.2 49249.6 49493.5 +47108.5 47286 47674.6 48134.9 48527.8 48709 +46876.6 47001.2 47286 47627 47914 48040.3 +46781.9 46876.6 47108.5 47389.7 47622.8 47718.3 Species 5 -47718.3 48040.3 48709 49493.5 50175.5 50509.4 -47622.8 47914 48527.8 49249.6 49874.4 50175.5 -47389.7 47627 48134.9 48734.2 49249.6 49493.5 -47108.5 47286 47674.6 48134.9 48527.8 48709 -46876.6 47001.2 47286 47627 47914 48040.3 -46781.9 46876.6 47108.5 47389.7 47622.8 47718.3 +47718.3 48040.3 48709 49493.5 50175.5 50509.4 +47622.8 47914 48527.8 49249.6 49874.4 50175.5 +47389.7 47627 48134.9 48734.2 49249.6 49493.5 +47108.5 47286 47674.6 48134.9 48527.8 48709 +46876.6 47001.2 47286 47627 47914 48040.3 +46781.9 46876.6 47108.5 47389.7 47622.8 47718.3 Species 6 -47718.3 48040.3 48709 49493.5 50175.5 50509.4 -47622.8 47914 48527.8 49249.6 49874.4 50175.5 -47389.7 47627 48134.9 48734.2 49249.6 49493.5 -47108.5 47286 47674.6 48134.9 48527.8 48709 -46876.6 47001.2 47286 47627 47914 48040.3 -46781.9 46876.6 47108.5 47389.7 47622.8 47718.3 +47718.3 48040.3 48709 49493.5 50175.5 50509.4 +47622.8 47914 48527.8 49249.6 49874.4 50175.5 +47389.7 47627 48134.9 48734.2 49249.6 49493.5 +47108.5 47286 47674.6 48134.9 48527.8 48709 +46876.6 47001.2 47286 47627 47914 48040.3 +46781.9 46876.6 47108.5 47389.7 47622.8 47718.3 t = 2.00e+00 nst = 165 nfe = 0 nfi = 2661 nni = 1833 hu = 4.14e-02 @@ -255,52 +255,52 @@ t = 4.00e+00 nst = 187 nfe = 0 nfi = 3013 nni = 2073 hu = 1.23e-01 c values at t = 4: Species 1 -1.19535 1.20368 1.2211 1.24157 1.25935 1.268 -1.1928 1.20035 1.21636 1.23523 1.25154 1.25935 -1.18657 1.19274 1.20602 1.22173 1.23523 1.24157 -1.17904 1.18368 1.19389 1.20602 1.21636 1.2211 -1.17284 1.17613 1.18368 1.19274 1.20035 1.20368 -1.17032 1.17284 1.17904 1.18657 1.1928 1.19535 +1.19535 1.20368 1.2211 1.24157 1.25935 1.268 +1.1928 1.20035 1.21636 1.23523 1.25154 1.25935 +1.18657 1.19274 1.20602 1.22173 1.23523 1.24157 +1.17904 1.18368 1.19389 1.20602 1.21636 1.2211 +1.17284 1.17613 1.18368 1.19274 1.20035 1.20368 +1.17032 1.17284 1.17904 1.18657 1.1928 1.19535 Species 2 -1.19538 1.20371 1.22113 1.24161 1.25938 1.26804 -1.19284 1.20038 1.21639 1.23526 1.25157 1.25938 -1.1866 1.19277 1.20606 1.22177 1.23526 1.24161 -1.17908 1.18371 1.19393 1.20606 1.21639 1.22113 -1.17288 1.17616 1.18371 1.19277 1.20038 1.20371 -1.17035 1.17288 1.17908 1.1866 1.19284 1.19538 +1.19538 1.20371 1.22113 1.24161 1.25938 1.26804 +1.19284 1.20038 1.21639 1.23526 1.25157 1.25938 +1.1866 1.19277 1.20606 1.22177 1.23526 1.24161 +1.17908 1.18371 1.19393 1.20606 1.21639 1.22113 +1.17288 1.17616 1.18371 1.19277 1.20038 1.20371 +1.17035 1.17288 1.17908 1.1866 1.19284 1.19538 Species 3 -1.19542 1.20374 1.22116 1.24164 1.25942 1.26807 -1.19287 1.20042 1.21642 1.2353 1.2516 1.25942 -1.18663 1.1928 1.20609 1.2218 1.2353 1.24164 -1.17911 1.18374 1.19396 1.20609 1.21642 1.22116 -1.17291 1.17619 1.18374 1.1928 1.20042 1.20374 -1.17039 1.17291 1.17911 1.18663 1.19287 1.19542 +1.19542 1.20374 1.22116 1.24164 1.25942 1.26807 +1.19287 1.20042 1.21642 1.2353 1.2516 1.25942 +1.18663 1.1928 1.20609 1.2218 1.2353 1.24164 +1.17911 1.18374 1.19396 1.20609 1.21642 1.22116 +1.17291 1.17619 1.18374 1.1928 1.20042 1.20374 +1.17039 1.17291 1.17911 1.18663 1.19287 1.19542 Species 4 -35860.6 36110.2 36632.4 37246.4 37779.5 38038.7 -35784.2 36010.4 36490.4 37056.3 37545.3 37779.5 -35597.2 35782 36180.5 36651.6 37056.3 37246.4 -35371.4 35510.4 35816.7 36180.5 36490.4 36632.4 -35185.4 35283.8 35510.4 35782 36010.4 36110.2 -35109.7 35185.4 35371.4 35597.2 35784.2 35860.6 +35860.6 36110.2 36632.4 37246.4 37779.5 38038.7 +35784.2 36010.4 36490.4 37056.3 37545.3 37779.5 +35597.2 35782 36180.5 36651.6 37056.3 37246.4 +35371.4 35510.4 35816.7 36180.5 36490.4 36632.4 +35185.4 35283.8 35510.4 35782 36010.4 36110.2 +35109.7 35185.4 35371.4 35597.2 35784.2 35860.6 Species 5 -35860.6 36110.2 36632.4 37246.4 37779.5 38038.7 -35784.2 36010.4 36490.4 37056.3 37545.3 37779.5 -35597.2 35782 36180.5 36651.6 37056.3 37246.4 -35371.4 35510.4 35816.7 36180.5 36490.4 36632.4 -35185.4 35283.8 35510.4 35782 36010.4 36110.2 -35109.7 35185.4 35371.4 35597.2 35784.2 35860.6 +35860.6 36110.2 36632.4 37246.4 37779.5 38038.7 +35784.2 36010.4 36490.4 37056.3 37545.3 37779.5 +35597.2 35782 36180.5 36651.6 37056.3 37246.4 +35371.4 35510.4 35816.7 36180.5 36490.4 36632.4 +35185.4 35283.8 35510.4 35782 36010.4 36110.2 +35109.7 35185.4 35371.4 35597.2 35784.2 35860.6 Species 6 -35860.6 36110.2 36632.4 37246.4 37779.5 38038.7 -35784.2 36010.4 36490.4 37056.3 37545.3 37779.5 -35597.2 35782 36180.5 36651.6 37056.3 37246.4 -35371.4 35510.4 35816.7 36180.5 36490.4 36632.4 -35185.4 35283.8 35510.4 35782 36010.4 36110.2 -35109.7 35185.4 35371.4 35597.2 35784.2 35860.6 +35860.6 36110.2 36632.4 37246.4 37779.5 38038.7 +35784.2 36010.4 36490.4 37056.3 37545.3 37779.5 +35597.2 35782 36180.5 36651.6 37056.3 37246.4 +35371.4 35510.4 35816.7 36180.5 36490.4 36632.4 +35185.4 35283.8 35510.4 35782 36010.4 36110.2 +35109.7 35185.4 35371.4 35597.2 35784.2 35860.6 t = 5.00e+00 nst = 198 nfe = 0 nfi = 3179 nni = 2182 hu = 9.99e-02 @@ -311,52 +311,52 @@ t = 7.00e+00 nst = 216 nfe = 0 nfi = 3477 nni = 2375 hu = 1.51e-01 c values at t = 7: Species 1 -1.18854 1.19682 1.21415 1.23453 1.25221 1.26082 -1.186 1.19351 1.20944 1.22822 1.24444 1.25221 -1.1798 1.18593 1.19916 1.21479 1.22822 1.23453 -1.17231 1.17692 1.18708 1.19916 1.20944 1.21415 -1.16614 1.1694 1.17692 1.18593 1.19351 1.19682 -1.16363 1.16614 1.17231 1.1798 1.186 1.18854 +1.18854 1.19682 1.21415 1.23453 1.25221 1.26082 +1.186 1.19351 1.20944 1.22822 1.24444 1.25221 +1.1798 1.18593 1.19916 1.21479 1.22822 1.23453 +1.17231 1.17692 1.18708 1.19916 1.20944 1.21415 +1.16614 1.1694 1.17692 1.18593 1.19351 1.19682 +1.16363 1.16614 1.17231 1.1798 1.186 1.18854 Species 2 -1.18854 1.19683 1.21415 1.23453 1.25222 1.26082 -1.186 1.19351 1.20944 1.22822 1.24444 1.25222 -1.1798 1.18594 1.19916 1.21479 1.22822 1.23453 -1.17231 1.17692 1.18709 1.19916 1.20944 1.21415 -1.16614 1.1694 1.17692 1.18594 1.19351 1.19683 -1.16363 1.16614 1.17231 1.1798 1.186 1.18854 +1.18854 1.19683 1.21415 1.23453 1.25222 1.26082 +1.186 1.19351 1.20944 1.22822 1.24444 1.25222 +1.1798 1.18594 1.19916 1.21479 1.22822 1.23453 +1.17231 1.17692 1.18709 1.19916 1.20944 1.21415 +1.16614 1.1694 1.17692 1.18594 1.19351 1.19683 +1.16363 1.16614 1.17231 1.1798 1.186 1.18854 Species 3 -1.18854 1.19683 1.21416 1.23453 1.25222 1.26082 -1.18601 1.19351 1.20944 1.22822 1.24444 1.25222 -1.1798 1.18594 1.19916 1.21479 1.22822 1.23453 -1.17231 1.17692 1.18709 1.19916 1.20944 1.21416 -1.16614 1.1694 1.17692 1.18594 1.19351 1.19683 -1.16363 1.16614 1.17231 1.1798 1.18601 1.18854 +1.18854 1.19683 1.21416 1.23453 1.25222 1.26082 +1.18601 1.19351 1.20944 1.22822 1.24444 1.25222 +1.1798 1.18594 1.19916 1.21479 1.22822 1.23453 +1.17231 1.17692 1.18709 1.19916 1.20944 1.21416 +1.16614 1.1694 1.17692 1.18594 1.19351 1.19683 +1.16363 1.16614 1.17231 1.1798 1.18601 1.18854 Species 4 -35656.3 35903.1 36424.2 37033.8 37564.6 37822.3 -35578.4 35804.9 36281.3 36845.5 37330.9 37564.6 -35393.9 35575.9 35974.4 36441.4 36845.5 37033.8 -35167.5 35307.4 35610.6 35974.4 36281.3 36424.2 -34984.3 35080.2 35307.4 35575.9 35804.9 35903.1 -34907.5 34984.3 35167.5 35393.9 35578.4 35656.3 +35656.3 35903.1 36424.2 37033.8 37564.6 37822.3 +35578.4 35804.9 36281.3 36845.5 37330.9 37564.6 +35393.9 35575.9 35974.4 36441.4 36845.5 37033.8 +35167.5 35307.4 35610.6 35974.4 36281.3 36424.2 +34984.3 35080.2 35307.4 35575.9 35804.9 35903.1 +34907.5 34984.3 35167.5 35393.9 35578.4 35656.3 Species 5 -35656.3 35903.1 36424.2 37033.8 37564.6 37822.3 -35578.4 35804.9 36281.3 36845.5 37330.9 37564.6 -35393.9 35575.9 35974.4 36441.4 36845.5 37033.8 -35167.5 35307.4 35610.6 35974.4 36281.3 36424.2 -34984.3 35080.2 35307.4 35575.9 35804.9 35903.1 -34907.5 34984.3 35167.5 35393.9 35578.4 35656.3 +35656.3 35903.1 36424.2 37033.8 37564.6 37822.3 +35578.4 35804.9 36281.3 36845.5 37330.9 37564.6 +35393.9 35575.9 35974.4 36441.4 36845.5 37033.8 +35167.5 35307.4 35610.6 35974.4 36281.3 36424.2 +34984.3 35080.2 35307.4 35575.9 35804.9 35903.1 +34907.5 34984.3 35167.5 35393.9 35578.4 35656.3 Species 6 -35656.3 35903.1 36424.2 37033.8 37564.6 37822.3 -35578.4 35804.9 36281.3 36845.5 37330.9 37564.6 -35393.9 35575.9 35974.4 36441.4 36845.5 37033.8 -35167.5 35307.4 35610.6 35974.4 36281.3 36424.2 -34984.3 35080.2 35307.4 35575.9 35804.9 35903.1 -34907.5 34984.3 35167.5 35393.9 35578.4 35656.3 +35656.3 35903.1 36424.2 37033.8 37564.6 37822.3 +35578.4 35804.9 36281.3 36845.5 37330.9 37564.6 +35393.9 35575.9 35974.4 36441.4 36845.5 37033.8 +35167.5 35307.4 35610.6 35974.4 36281.3 36424.2 +34984.3 35080.2 35307.4 35575.9 35804.9 35903.1 +34907.5 34984.3 35167.5 35393.9 35578.4 35656.3 t = 8.00e+00 nst = 232 nfe = 0 nfi = 3780 nni = 2567 hu = 1.06e-01 @@ -367,75 +367,75 @@ t = 1.00e+01 nst = 266 nfe = 0 nfi = 4394 nni = 2941 hu = 8.37e-02 c values at t = 10: Species 1 -1.18838 1.19667 1.21399 1.23437 1.25205 1.26066 -1.18585 1.19335 1.20928 1.22805 1.24428 1.25205 -1.17964 1.18578 1.199 1.21463 1.22805 1.23437 -1.17215 1.17676 1.18693 1.199 1.20928 1.21399 -1.16598 1.16925 1.17676 1.18578 1.19335 1.19667 -1.16347 1.16598 1.17215 1.17964 1.18585 1.18838 +1.18838 1.19667 1.21399 1.23437 1.25205 1.26066 +1.18585 1.19335 1.20928 1.22805 1.24428 1.25205 +1.17964 1.18578 1.199 1.21463 1.22805 1.23437 +1.17215 1.17676 1.18693 1.199 1.20928 1.21399 +1.16598 1.16925 1.17676 1.18578 1.19335 1.19667 +1.16347 1.16598 1.17215 1.17964 1.18585 1.18838 Species 2 -1.18838 1.19667 1.21399 1.23437 1.25205 1.26066 -1.18585 1.19335 1.20928 1.22805 1.24428 1.25205 -1.17964 1.18578 1.199 1.21463 1.22805 1.23437 -1.17215 1.17676 1.18693 1.199 1.20928 1.21399 -1.16598 1.16925 1.17676 1.18578 1.19335 1.19667 -1.16347 1.16598 1.17215 1.17964 1.18585 1.18838 +1.18838 1.19667 1.21399 1.23437 1.25205 1.26066 +1.18585 1.19335 1.20928 1.22805 1.24428 1.25205 +1.17964 1.18578 1.199 1.21463 1.22805 1.23437 +1.17215 1.17676 1.18693 1.199 1.20928 1.21399 +1.16598 1.16925 1.17676 1.18578 1.19335 1.19667 +1.16347 1.16598 1.17215 1.17964 1.18585 1.18838 Species 3 -1.18838 1.19667 1.21399 1.23437 1.25205 1.26066 -1.18585 1.19335 1.20928 1.22805 1.24428 1.25205 -1.17964 1.18578 1.199 1.21463 1.22805 1.23437 -1.17215 1.17676 1.18693 1.199 1.20928 1.21399 -1.16598 1.16925 1.17676 1.18578 1.19335 1.19667 -1.16347 1.16598 1.17215 1.17964 1.18585 1.18838 +1.18838 1.19667 1.21399 1.23437 1.25205 1.26066 +1.18585 1.19335 1.20928 1.22805 1.24428 1.25205 +1.17964 1.18578 1.199 1.21463 1.22805 1.23437 +1.17215 1.17676 1.18693 1.199 1.20928 1.21399 +1.16598 1.16925 1.17676 1.18578 1.19335 1.19667 +1.16347 1.16598 1.17215 1.17964 1.18585 1.18838 Species 4 -35650.6 35898.8 36418.4 37029.2 37559.5 37817.3 -35574.5 35799.5 36277.1 36840 37326.6 37559.5 -35388.4 35572.3 35968.8 36437.5 36840 37029.2 -35163.7 35302 35606.7 35968.8 36277.1 36418.4 -34978.6 35076.5 35302 35572.3 35799.5 35898.8 -34903.3 34978.6 35163.7 35388.4 35574.5 35650.6 +35650.6 35898.8 36418.4 37029.2 37559.5 37817.3 +35574.5 35799.5 36277.1 36840 37326.6 37559.5 +35388.4 35572.3 35968.8 36437.5 36840 37029.2 +35163.7 35302 35606.7 35968.8 36277.1 36418.4 +34978.6 35076.5 35302 35572.3 35799.5 35898.8 +34903.3 34978.6 35163.7 35388.4 35574.5 35650.6 Species 5 -35650.6 35898.8 36418.4 37029.2 37559.5 37817.3 -35574.5 35799.5 36277.1 36840 37326.6 37559.5 -35388.4 35572.3 35968.8 36437.5 36840 37029.2 -35163.7 35302 35606.7 35968.8 36277.1 36418.4 -34978.6 35076.5 35302 35572.3 35799.5 35898.8 -34903.3 34978.6 35163.7 35388.4 35574.5 35650.6 +35650.6 35898.8 36418.4 37029.2 37559.5 37817.3 +35574.5 35799.5 36277.1 36840 37326.6 37559.5 +35388.4 35572.3 35968.8 36437.5 36840 37029.2 +35163.7 35302 35606.7 35968.8 36277.1 36418.4 +34978.6 35076.5 35302 35572.3 35799.5 35898.8 +34903.3 34978.6 35163.7 35388.4 35574.5 35650.6 Species 6 -35650.6 35898.8 36418.4 37029.2 37559.5 37817.3 -35574.5 35799.5 36277.1 36840 37326.6 37559.5 -35388.4 35572.3 35968.8 36437.5 36840 37029.2 -35163.7 35302 35606.7 35968.8 36277.1 36418.4 -34978.6 35076.5 35302 35572.3 35799.5 35898.8 -34903.3 34978.6 35163.7 35388.4 35574.5 35650.6 +35650.6 35898.8 36418.4 37029.2 37559.5 37817.3 +35574.5 35799.5 36277.1 36840 37326.6 37559.5 +35388.4 35572.3 35968.8 36437.5 36840 37029.2 +35163.7 35302 35606.7 35968.8 36277.1 36418.4 +34978.6 35076.5 35302 35572.3 35799.5 35898.8 +34903.3 34978.6 35163.7 35388.4 35574.5 35650.6 Final statistics for this run: - ARKStep real workspace length = 3554 - ARKStep integer workspace length = 131 - ARKLS real workspace length = 2647 - ARKLS integer workspace length = 42 - Number of steps = 266 - Number of f-s (explicit) = 0 - Number of f-s (implicit) = 4394 - Number of f-s (SPGMR) = 8980 - Number of f-s (TOTAL) = 8980 - Number of setups = 121 - Number of nonlinear iterations = 2941 - Number of linear iterations = 8980 - Number of preconditioner evaluations = 121 - Number of preconditioner solves = 11819 - Number of error test failures = 23 - Number of nonlinear conv. failures = 17 - Number of linear convergence failures = 509 - Average Krylov subspace dimension = 3.053 + ARKStep real workspace length = 3554 + ARKStep integer workspace length = 131 + ARKLS real workspace length = 2647 + ARKLS integer workspace length = 42 + Number of steps = 266 + Number of f-s (explicit) = 0 + Number of f-s (implicit) = 4394 + Number of f-s (SPGMR) = 8980 + Number of f-s (TOTAL) = 8980 + Number of setups = 121 + Number of nonlinear iterations = 2941 + Number of linear iterations = 8980 + Number of preconditioner evaluations = 121 + Number of preconditioner solves = 11819 + Number of error test failures = 23 + Number of nonlinear conv. failures = 17 + Number of linear convergence failures = 509 + Average Krylov subspace dimension = 3.053 ---------------------------------------------------------------------------- @@ -487,24 +487,24 @@ t = 1.00e+01 nst = 251 nfe = 0 nfi = 4101 nni = 2746 hu = 7.09e-02 Final statistics for this run: - ARKStep real workspace length = 3554 - ARKStep integer workspace length = 131 - ARKLS real workspace length = 2647 - ARKLS integer workspace length = 42 - Number of steps = 251 - Number of f-s (explicit) = 0 - Number of f-s (implicit) = 4101 - Number of f-s (SPGMR) = 8880 - Number of f-s (TOTAL) = 8880 - Number of setups = 91 - Number of nonlinear iterations = 2746 - Number of linear iterations = 8880 - Number of preconditioner evaluations = 91 - Number of preconditioner solves = 11537 - Number of error test failures = 18 - Number of nonlinear conv. failures = 13 - Number of linear convergence failures = 597 - Average Krylov subspace dimension = 3.234 + ARKStep real workspace length = 3554 + ARKStep integer workspace length = 136 + ARKLS real workspace length = 2647 + ARKLS integer workspace length = 42 + Number of steps = 251 + Number of f-s (explicit) = 0 + Number of f-s (implicit) = 4101 + Number of f-s (SPGMR) = 8880 + Number of f-s (TOTAL) = 8880 + Number of setups = 91 + Number of nonlinear iterations = 2746 + Number of linear iterations = 8880 + Number of preconditioner evaluations = 91 + Number of preconditioner solves = 11537 + Number of error test failures = 18 + Number of nonlinear conv. failures = 13 + Number of linear convergence failures = 597 + Average Krylov subspace dimension = 3.234 ---------------------------------------------------------------------------- @@ -556,24 +556,24 @@ t = 1.00e+01 nst = 359 nfe = 0 nfi = 5722 nni = 3907 hu = 1.35e-01 Final statistics for this run: - ARKStep real workspace length = 3554 - ARKStep integer workspace length = 131 - ARKLS real workspace length = 2647 - ARKLS integer workspace length = 42 - Number of steps = 359 - Number of f-s (explicit) = 0 - Number of f-s (implicit) = 5722 - Number of f-s (SPGMR) = 12904 - Number of f-s (TOTAL) = 12904 - Number of setups = 253 - Number of nonlinear iterations = 3907 - Number of linear iterations = 12904 - Number of preconditioner evaluations = 253 - Number of preconditioner solves = 16594 - Number of error test failures = 0 - Number of nonlinear conv. failures = 117 - Number of linear convergence failures = 1072 - Average Krylov subspace dimension = 3.303 + ARKStep real workspace length = 3554 + ARKStep integer workspace length = 141 + ARKLS real workspace length = 2647 + ARKLS integer workspace length = 42 + Number of steps = 359 + Number of f-s (explicit) = 0 + Number of f-s (implicit) = 5722 + Number of f-s (SPGMR) = 12904 + Number of f-s (TOTAL) = 12904 + Number of setups = 253 + Number of nonlinear iterations = 3907 + Number of linear iterations = 12904 + Number of preconditioner evaluations = 253 + Number of preconditioner solves = 16594 + Number of error test failures = 0 + Number of nonlinear conv. failures = 117 + Number of linear convergence failures = 1072 + Average Krylov subspace dimension = 3.303 ---------------------------------------------------------------------------- @@ -625,24 +625,24 @@ t = 1.00e+01 nst = 359 nfe = 0 nfi = 5728 nni = 3912 hu = 1.31e-01 Final statistics for this run: - ARKStep real workspace length = 3554 - ARKStep integer workspace length = 131 - ARKLS real workspace length = 2647 - ARKLS integer workspace length = 42 - Number of steps = 359 - Number of f-s (explicit) = 0 - Number of f-s (implicit) = 5728 - Number of f-s (SPGMR) = 12934 - Number of f-s (TOTAL) = 12934 - Number of setups = 254 - Number of nonlinear iterations = 3912 - Number of linear iterations = 12934 - Number of preconditioner evaluations = 254 - Number of preconditioner solves = 16627 - Number of error test failures = 0 - Number of nonlinear conv. failures = 118 - Number of linear convergence failures = 1076 - Average Krylov subspace dimension = 3.306 + ARKStep real workspace length = 3554 + ARKStep integer workspace length = 146 + ARKLS real workspace length = 2647 + ARKLS integer workspace length = 42 + Number of steps = 359 + Number of f-s (explicit) = 0 + Number of f-s (implicit) = 5728 + Number of f-s (SPGMR) = 12934 + Number of f-s (TOTAL) = 12934 + Number of setups = 254 + Number of nonlinear iterations = 3912 + Number of linear iterations = 12934 + Number of preconditioner evaluations = 254 + Number of preconditioner solves = 16627 + Number of error test failures = 0 + Number of nonlinear conv. failures = 118 + Number of linear convergence failures = 1076 + Average Krylov subspace dimension = 3.306 ---------------------------------------------------------------------------- diff --git a/examples/arkode/C_serial/ark_KrylovDemo_prec_2.out b/examples/arkode/C_serial/ark_KrylovDemo_prec_2.out index 09364ad394..a2564a38ee 100644 --- a/examples/arkode/C_serial/ark_KrylovDemo_prec_2.out +++ b/examples/arkode/C_serial/ark_KrylovDemo_prec_2.out @@ -10,9 +10,9 @@ b parameter = 1 Diffusion coefficients: Dprey = 1 Dpred = 0.5 Rate parameter alpha = 1 -Mesh dimensions (mx,my) are 6, 6. Total system size is neq = 216 +Mesh dimensions (mx,my) are 6, 6. Total system size is neq = 216 -Tolerances: reltol = 1e-05, abstol = 1e-05 +Tolerances: reltol = 1e-05, abstol = 1e-05 Preconditioning uses a product of: (1) Gauss-Seidel iterations with itmax = 5 iterations, and @@ -31,52 +31,52 @@ Gram-Schmidt method type is gstype = SUN_MODIFIED_GS c values at t = 0: Species 1 -10 10 10 10 10 10 -10 10.1678 10.3775 10.3775 10.1678 10 -10 10.3775 10.8493 10.8493 10.3775 10 -10 10.3775 10.8493 10.8493 10.3775 10 -10 10.1678 10.3775 10.3775 10.1678 10 -10 10 10 10 10 10 +10 10 10 10 10 10 +10 10.1678 10.3775 10.3775 10.1678 10 +10 10.3775 10.8493 10.8493 10.3775 10 +10 10.3775 10.8493 10.8493 10.3775 10 +10 10.1678 10.3775 10.3775 10.1678 10 +10 10 10 10 10 10 Species 2 -10 10 10 10 10 10 -10 10.3355 10.755 10.755 10.3355 10 -10 10.755 11.6987 11.6987 10.755 10 -10 10.755 11.6987 11.6987 10.755 10 -10 10.3355 10.755 10.755 10.3355 10 -10 10 10 10 10 10 +10 10 10 10 10 10 +10 10.3355 10.755 10.755 10.3355 10 +10 10.755 11.6987 11.6987 10.755 10 +10 10.755 11.6987 11.6987 10.755 10 +10 10.3355 10.755 10.755 10.3355 10 +10 10 10 10 10 10 Species 3 -10 10 10 10 10 10 -10 10.5033 11.1325 11.1325 10.5033 10 -10 11.1325 12.548 12.548 11.1325 10 -10 11.1325 12.548 12.548 11.1325 10 -10 10.5033 11.1325 11.1325 10.5033 10 -10 10 10 10 10 10 +10 10 10 10 10 10 +10 10.5033 11.1325 11.1325 10.5033 10 +10 11.1325 12.548 12.548 11.1325 10 +10 11.1325 12.548 12.548 11.1325 10 +10 10.5033 11.1325 11.1325 10.5033 10 +10 10 10 10 10 10 Species 4 -10 10 10 10 10 10 -10 10.6711 11.5099 11.5099 10.6711 10 -10 11.5099 13.3974 13.3974 11.5099 10 -10 11.5099 13.3974 13.3974 11.5099 10 -10 10.6711 11.5099 11.5099 10.6711 10 -10 10 10 10 10 10 +10 10 10 10 10 10 +10 10.6711 11.5099 11.5099 10.6711 10 +10 11.5099 13.3974 13.3974 11.5099 10 +10 11.5099 13.3974 13.3974 11.5099 10 +10 10.6711 11.5099 11.5099 10.6711 10 +10 10 10 10 10 10 Species 5 -10 10 10 10 10 10 -10 10.8389 11.8874 11.8874 10.8389 10 -10 11.8874 14.2467 14.2467 11.8874 10 -10 11.8874 14.2467 14.2467 11.8874 10 -10 10.8389 11.8874 11.8874 10.8389 10 -10 10 10 10 10 10 +10 10 10 10 10 10 +10 10.8389 11.8874 11.8874 10.8389 10 +10 11.8874 14.2467 14.2467 11.8874 10 +10 11.8874 14.2467 14.2467 11.8874 10 +10 10.8389 11.8874 11.8874 10.8389 10 +10 10 10 10 10 10 Species 6 -10 10 10 10 10 10 -10 11.0066 12.2649 12.2649 11.0066 10 -10 12.2649 15.0961 15.0961 12.2649 10 -10 12.2649 15.0961 15.0961 12.2649 10 -10 11.0066 12.2649 12.2649 11.0066 10 -10 10 10 10 10 10 +10 10 10 10 10 10 +10 11.0066 12.2649 12.2649 11.0066 10 +10 12.2649 15.0961 15.0961 12.2649 10 +10 12.2649 15.0961 15.0961 12.2649 10 +10 11.0066 12.2649 12.2649 11.0066 10 +10 10 10 10 10 10 t = 1.00e-08 nst = 5 nfe = 0 nfi = 75 nni = 47 hu = 9.89e-08 @@ -87,52 +87,52 @@ t = 1.00e-06 nst = 8 nfe = 0 nfi = 120 nni = 77 hu = 4.79e-07 c values at t = 1e-06: Species 1 -9.99991 9.99992 9.99993 9.99993 9.99993 9.99992 -9.99992 10.1677 10.3774 10.3774 10.1677 9.99993 -9.99993 10.3774 10.8492 10.8492 10.3774 9.99993 -9.99993 10.3774 10.8492 10.8492 10.3774 9.99993 -9.99992 10.1677 10.3774 10.3774 10.1677 9.99992 -9.99991 9.99992 9.99993 9.99993 9.99992 9.99991 +9.99991 9.99992 9.99993 9.99993 9.99993 9.99992 +9.99992 10.1677 10.3774 10.3774 10.1677 9.99993 +9.99993 10.3774 10.8492 10.8492 10.3774 9.99993 +9.99993 10.3774 10.8492 10.8492 10.3774 9.99993 +9.99992 10.1677 10.3774 10.3774 10.1677 9.99992 +9.99991 9.99992 9.99993 9.99993 9.99992 9.99991 Species 2 -9.99991 9.99993 9.99995 9.99995 9.99993 9.99992 -9.99993 10.3355 10.7549 10.7549 10.3355 9.99993 -9.99995 10.7549 11.6985 11.6985 10.7549 9.99995 -9.99995 10.7549 11.6985 11.6985 10.7549 9.99995 -9.99993 10.3355 10.7549 10.7549 10.3355 9.99993 -9.99991 9.99993 9.99995 9.99995 9.99993 9.99991 +9.99991 9.99993 9.99995 9.99995 9.99993 9.99992 +9.99993 10.3355 10.7549 10.7549 10.3355 9.99993 +9.99995 10.7549 11.6985 11.6985 10.7549 9.99995 +9.99995 10.7549 11.6985 11.6985 10.7549 9.99995 +9.99993 10.3355 10.7549 10.7549 10.3355 9.99993 +9.99991 9.99993 9.99995 9.99995 9.99993 9.99991 Species 3 -9.99991 9.99994 9.99997 9.99997 9.99994 9.99992 -9.99994 10.5032 11.1323 11.1323 10.5032 9.99994 -9.99997 11.1323 12.5478 12.5478 11.1323 9.99997 -9.99997 11.1323 12.5478 12.5478 11.1323 9.99997 -9.99994 10.5032 11.1323 11.1323 10.5032 9.99994 -9.99991 9.99994 9.99997 9.99997 9.99994 9.99991 +9.99991 9.99994 9.99997 9.99997 9.99994 9.99992 +9.99994 10.5032 11.1323 11.1323 10.5032 9.99994 +9.99997 11.1323 12.5478 12.5478 11.1323 9.99997 +9.99997 11.1323 12.5478 12.5478 11.1323 9.99997 +9.99994 10.5032 11.1323 11.1323 10.5032 9.99994 +9.99991 9.99994 9.99997 9.99997 9.99994 9.99991 Species 4 -13.4984 13.4984 13.4984 13.4984 13.4984 13.4984 -13.4984 14.55 15.8924 15.8924 14.55 13.4984 -13.4984 15.8924 19.0296 19.0296 15.8924 13.4984 -13.4984 15.8924 19.0296 19.0296 15.8924 13.4984 -13.4984 14.55 15.8924 15.8924 14.55 13.4984 -13.4984 13.4984 13.4984 13.4984 13.4984 13.4984 +13.4984 13.4984 13.4984 13.4984 13.4984 13.4984 +13.4984 14.55 15.8924 15.8924 14.55 13.4984 +13.4984 15.8924 19.0296 19.0296 15.8924 13.4984 +13.4984 15.8924 19.0296 19.0296 15.8924 13.4984 +13.4984 14.55 15.8924 15.8924 14.55 13.4984 +13.4984 13.4984 13.4984 13.4984 13.4984 13.4984 Species 5 -13.4984 13.4984 13.4985 13.4985 13.4984 13.4984 -13.4984 14.7787 16.4136 16.4136 14.7787 13.4984 -13.4985 16.4136 20.236 20.236 16.4136 13.4985 -13.4985 16.4136 20.236 20.236 16.4136 13.4985 -13.4984 14.7787 16.4136 16.4136 14.7787 13.4984 -13.4984 13.4984 13.4985 13.4985 13.4984 13.4984 +13.4984 13.4984 13.4985 13.4985 13.4984 13.4984 +13.4984 14.7787 16.4136 16.4136 14.7787 13.4984 +13.4985 16.4136 20.236 20.236 16.4136 13.4985 +13.4985 16.4136 20.236 20.236 16.4136 13.4985 +13.4984 14.7787 16.4136 16.4136 14.7787 13.4984 +13.4984 13.4984 13.4985 13.4985 13.4984 13.4984 Species 6 -13.4984 13.4984 13.4985 13.4985 13.4984 13.4984 -13.4984 15.0075 16.9348 16.9348 15.0075 13.4984 -13.4985 16.9348 21.4423 21.4423 16.9348 13.4985 -13.4985 16.9348 21.4423 21.4423 16.9348 13.4985 -13.4984 15.0075 16.9348 16.9348 15.0075 13.4984 -13.4984 13.4984 13.4985 13.4985 13.4984 13.4984 +13.4984 13.4984 13.4985 13.4985 13.4984 13.4984 +13.4984 15.0075 16.9348 16.9348 15.0075 13.4984 +13.4985 16.9348 21.4423 21.4423 16.9348 13.4985 +13.4985 16.9348 21.4423 21.4423 16.9348 13.4985 +13.4984 15.0075 16.9348 16.9348 15.0075 13.4984 +13.4984 13.4984 13.4985 13.4985 13.4984 13.4984 t = 1.00e-05 nst = 27 nfe = 0 nfi = 407 nni = 269 hu = 4.79e-07 @@ -143,52 +143,52 @@ t = 1.00e-03 nst = 110 nfe = 0 nfi = 1750 nni = 1197 hu = 1.51e-03 c values at t = 0.001: Species 1 -9.90702 9.91664 9.92836 9.93033 9.92253 9.91674 -9.91472 10.0747 10.2769 10.2785 10.0795 9.92253 -9.92446 10.2748 10.7181 10.7194 10.2785 9.93033 -9.92445 10.2744 10.7173 10.7181 10.2769 9.92836 -9.91469 10.0734 10.2744 10.2748 10.0747 9.91664 -9.90698 9.91469 9.92445 9.92446 9.91472 9.90702 +9.90702 9.91664 9.92836 9.93033 9.92253 9.91674 +9.91472 10.0747 10.2769 10.2785 10.0795 9.92253 +9.92446 10.2748 10.7181 10.7194 10.2785 9.93033 +9.92445 10.2744 10.7173 10.7181 10.2769 9.92836 +9.91469 10.0734 10.2744 10.2748 10.0747 9.91664 +9.90698 9.91469 9.92445 9.92446 9.91472 9.90702 Species 2 -9.90742 9.92474 9.94622 9.94819 9.93064 9.91713 -9.92282 10.2412 10.644 10.6457 10.2461 9.93064 -9.94232 10.6419 11.5267 11.5281 10.6457 9.94819 -9.94231 10.6415 11.5258 11.5267 10.644 9.94622 -9.92279 10.24 10.6415 10.6419 10.2412 9.92474 -9.90737 9.92279 9.94231 9.94232 9.92282 9.90742 +9.90742 9.92474 9.94622 9.94819 9.93064 9.91713 +9.92282 10.2412 10.644 10.6457 10.2461 9.93064 +9.94232 10.6419 11.5267 11.5281 10.6457 9.94819 +9.94231 10.6415 11.5258 11.5267 10.644 9.94622 +9.92279 10.24 10.6415 10.6419 10.2412 9.92474 +9.90737 9.92279 9.94231 9.94232 9.92282 9.90742 Species 3 -9.90781 9.93284 9.96408 9.96605 9.93874 9.91753 -9.93092 10.4078 11.0109 11.0127 10.4127 9.93874 -9.96017 11.0088 12.3339 12.3354 11.0127 9.96605 -9.96016 11.0083 12.333 12.3339 11.0109 9.96408 -9.93088 10.4065 11.0083 11.0088 10.4078 9.93284 -9.90776 9.93088 9.96016 9.96017 9.93092 9.90781 +9.90781 9.93284 9.96408 9.96605 9.93874 9.91753 +9.93092 10.4078 11.0109 11.0127 10.4127 9.93874 +9.96017 11.0088 12.3339 12.3354 11.0127 9.96605 +9.96016 11.0083 12.333 12.3339 11.0109 9.96408 +9.93088 10.4065 11.0083 11.0088 10.4078 9.93284 +9.90776 9.93088 9.96016 9.96017 9.93092 9.90781 Species 4 -297231 297749 298392 298451 297925 297520 -297692 307245 319327 319378 307390 297925 -298276 319264 345799 345840 319378 298451 -298276 319252 345772 345799 319327 298392 -297691 307208 319252 319264 307245 297749 -297229 297691 298276 298276 297692 297231 +297231 297749 298392 298451 297925 297520 +297692 307245 319327 319378 307390 297925 +298276 319264 345799 345840 319378 298451 +298276 319252 345772 345799 319327 298392 +297691 307208 319252 319264 307245 297749 +297229 297691 298276 298276 297692 297231 Species 5 -297231 297749 298392 298451 297925 297520 -297692 307245 319327 319378 307390 297925 -298276 319264 345799 345840 319378 298451 -298276 319252 345772 345799 319327 298392 -297691 307208 319252 319264 307245 297749 -297229 297691 298276 298276 297692 297231 +297231 297749 298392 298451 297925 297520 +297692 307245 319327 319378 307390 297925 +298276 319264 345799 345840 319378 298451 +298276 319252 345772 345799 319327 298392 +297691 307208 319252 319264 307245 297749 +297229 297691 298276 298276 297692 297231 Species 6 -297231 297749 298392 298451 297925 297520 -297692 307245 319327 319378 307390 297925 -298276 319264 345799 345840 319378 298451 -298276 319252 345772 345799 319327 298392 -297691 307208 319252 319264 307245 297749 -297229 297691 298276 298276 297692 297231 +297231 297749 298392 298451 297925 297520 +297692 307245 319327 319378 307390 297925 +298276 319264 345799 345840 319378 298451 +298276 319252 345772 345799 319327 298392 +297691 307208 319252 319264 307245 297749 +297229 297691 298276 298276 297692 297231 t = 1.00e-02 nst = 113 nfe = 0 nfi = 1797 nni = 1229 hu = 3.46e-03 @@ -199,52 +199,52 @@ t = 1.00e+00 nst = 154 nfe = 0 nfi = 2489 nni = 1716 hu = 6.84e-02 c values at t = 1: Species 1 -1.58851 1.59924 1.62152 1.64764 1.67036 1.68149 -1.58533 1.59503 1.61548 1.63952 1.66033 1.67036 -1.57757 1.58547 1.60239 1.62235 1.63952 1.64764 -1.5682 1.57412 1.58706 1.60239 1.61548 1.62152 -1.56048 1.56463 1.57412 1.58547 1.59503 1.59924 -1.55733 1.56048 1.5682 1.57757 1.58533 1.58851 +1.58851 1.59924 1.62152 1.64764 1.67036 1.68149 +1.58533 1.59503 1.61548 1.63952 1.66033 1.67036 +1.57757 1.58547 1.60239 1.62235 1.63952 1.64764 +1.5682 1.57412 1.58706 1.60239 1.61548 1.62152 +1.56048 1.56463 1.57412 1.58547 1.59503 1.59924 +1.55733 1.56048 1.5682 1.57757 1.58533 1.58851 Species 2 -1.59067 1.60141 1.62371 1.64987 1.67261 1.68375 -1.58748 1.5972 1.61766 1.64173 1.66257 1.67261 -1.57971 1.58763 1.60457 1.62454 1.64173 1.64987 -1.57034 1.57626 1.58921 1.60457 1.61766 1.62371 -1.56261 1.56676 1.57626 1.58763 1.5972 1.60141 -1.55945 1.56261 1.57034 1.57971 1.58748 1.59067 +1.59067 1.60141 1.62371 1.64987 1.67261 1.68375 +1.58748 1.5972 1.61766 1.64173 1.66257 1.67261 +1.57971 1.58763 1.60457 1.62454 1.64173 1.64987 +1.57034 1.57626 1.58921 1.60457 1.61766 1.62371 +1.56261 1.56676 1.57626 1.58763 1.5972 1.60141 +1.55945 1.56261 1.57034 1.57971 1.58748 1.59067 Species 3 -1.5927 1.60346 1.62578 1.65197 1.67474 1.68589 -1.58951 1.59924 1.61973 1.64383 1.66468 1.67474 -1.58174 1.58966 1.60662 1.62662 1.64383 1.65197 -1.57236 1.57828 1.59125 1.60662 1.61973 1.62578 -1.56462 1.56878 1.57828 1.58966 1.59924 1.60346 -1.56146 1.56462 1.57236 1.58174 1.58951 1.5927 +1.5927 1.60346 1.62578 1.65197 1.67474 1.68589 +1.58951 1.59924 1.61973 1.64383 1.66468 1.67474 +1.58174 1.58966 1.60662 1.62662 1.64383 1.65197 +1.57236 1.57828 1.59125 1.60662 1.61973 1.62578 +1.56462 1.56878 1.57828 1.58966 1.59924 1.60346 +1.56146 1.56462 1.57236 1.58174 1.58951 1.5927 Species 4 -47718.3 48040.3 48709 49493.5 50175.5 50509.4 -47622.8 47914 48527.8 49249.6 49874.4 50175.5 -47389.7 47627 48134.9 48734.2 49249.6 49493.5 -47108.5 47286 47674.6 48134.9 48527.8 48709 -46876.6 47001.2 47286 47627 47914 48040.3 -46781.9 46876.6 47108.5 47389.7 47622.8 47718.3 +47718.3 48040.3 48709 49493.5 50175.5 50509.4 +47622.8 47914 48527.8 49249.6 49874.4 50175.5 +47389.7 47627 48134.9 48734.2 49249.6 49493.5 +47108.5 47286 47674.6 48134.9 48527.8 48709 +46876.6 47001.2 47286 47627 47914 48040.3 +46781.9 46876.6 47108.5 47389.7 47622.8 47718.3 Species 5 -47718.3 48040.3 48709 49493.5 50175.5 50509.4 -47622.8 47914 48527.8 49249.6 49874.4 50175.5 -47389.7 47627 48134.9 48734.2 49249.6 49493.5 -47108.5 47286 47674.6 48134.9 48527.8 48709 -46876.6 47001.2 47286 47627 47914 48040.3 -46781.9 46876.6 47108.5 47389.7 47622.8 47718.3 +47718.3 48040.3 48709 49493.5 50175.5 50509.4 +47622.8 47914 48527.8 49249.6 49874.4 50175.5 +47389.7 47627 48134.9 48734.2 49249.6 49493.5 +47108.5 47286 47674.6 48134.9 48527.8 48709 +46876.6 47001.2 47286 47627 47914 48040.3 +46781.9 46876.6 47108.5 47389.7 47622.8 47718.3 Species 6 -47718.3 48040.3 48709 49493.5 50175.5 50509.4 -47622.8 47914 48527.8 49249.6 49874.4 50175.5 -47389.7 47627 48134.9 48734.2 49249.6 49493.5 -47108.5 47286 47674.6 48134.9 48527.8 48709 -46876.6 47001.2 47286 47627 47914 48040.3 -46781.9 46876.6 47108.5 47389.7 47622.8 47718.3 +47718.3 48040.3 48709 49493.5 50175.5 50509.4 +47622.8 47914 48527.8 49249.6 49874.4 50175.5 +47389.7 47627 48134.9 48734.2 49249.6 49493.5 +47108.5 47286 47674.6 48134.9 48527.8 48709 +46876.6 47001.2 47286 47627 47914 48040.3 +46781.9 46876.6 47108.5 47389.7 47622.8 47718.3 t = 2.00e+00 nst = 165 nfe = 0 nfi = 2661 nni = 1833 hu = 4.14e-02 @@ -255,52 +255,52 @@ t = 4.00e+00 nst = 187 nfe = 0 nfi = 3013 nni = 2073 hu = 1.23e-01 c values at t = 4: Species 1 -1.19535 1.20368 1.2211 1.24157 1.25935 1.268 -1.1928 1.20035 1.21636 1.23523 1.25154 1.25935 -1.18657 1.19274 1.20602 1.22173 1.23523 1.24157 -1.17904 1.18368 1.19389 1.20602 1.21636 1.2211 -1.17284 1.17613 1.18368 1.19274 1.20035 1.20368 -1.17032 1.17284 1.17904 1.18657 1.1928 1.19535 +1.19535 1.20368 1.2211 1.24157 1.25935 1.268 +1.1928 1.20035 1.21636 1.23523 1.25154 1.25935 +1.18657 1.19274 1.20602 1.22173 1.23523 1.24157 +1.17904 1.18368 1.19389 1.20602 1.21636 1.2211 +1.17284 1.17613 1.18368 1.19274 1.20035 1.20368 +1.17032 1.17284 1.17904 1.18657 1.1928 1.19535 Species 2 -1.19538 1.20371 1.22113 1.24161 1.25938 1.26804 -1.19284 1.20038 1.21639 1.23526 1.25157 1.25938 -1.1866 1.19277 1.20606 1.22177 1.23526 1.24161 -1.17908 1.18371 1.19393 1.20606 1.21639 1.22113 -1.17288 1.17616 1.18371 1.19277 1.20038 1.20371 -1.17035 1.17288 1.17908 1.1866 1.19284 1.19538 +1.19538 1.20371 1.22113 1.24161 1.25938 1.26804 +1.19284 1.20038 1.21639 1.23526 1.25157 1.25938 +1.1866 1.19277 1.20606 1.22177 1.23526 1.24161 +1.17908 1.18371 1.19393 1.20606 1.21639 1.22113 +1.17288 1.17616 1.18371 1.19277 1.20038 1.20371 +1.17035 1.17288 1.17908 1.1866 1.19284 1.19538 Species 3 -1.19542 1.20374 1.22116 1.24164 1.25942 1.26807 -1.19287 1.20042 1.21642 1.2353 1.2516 1.25942 -1.18663 1.1928 1.20609 1.2218 1.2353 1.24164 -1.17911 1.18374 1.19396 1.20609 1.21642 1.22116 -1.17291 1.17619 1.18374 1.1928 1.20042 1.20374 -1.17039 1.17291 1.17911 1.18663 1.19287 1.19542 +1.19542 1.20374 1.22116 1.24164 1.25942 1.26807 +1.19287 1.20042 1.21642 1.2353 1.2516 1.25942 +1.18663 1.1928 1.20609 1.2218 1.2353 1.24164 +1.17911 1.18374 1.19396 1.20609 1.21642 1.22116 +1.17291 1.17619 1.18374 1.1928 1.20042 1.20374 +1.17039 1.17291 1.17911 1.18663 1.19287 1.19542 Species 4 -35860.6 36110.2 36632.4 37246.4 37779.5 38038.7 -35784.2 36010.4 36490.4 37056.3 37545.3 37779.5 -35597.2 35782 36180.5 36651.6 37056.3 37246.4 -35371.4 35510.4 35816.7 36180.5 36490.4 36632.4 -35185.4 35283.8 35510.4 35782 36010.4 36110.2 -35109.7 35185.4 35371.4 35597.2 35784.2 35860.6 +35860.6 36110.2 36632.4 37246.4 37779.5 38038.7 +35784.2 36010.4 36490.4 37056.3 37545.3 37779.5 +35597.2 35782 36180.5 36651.6 37056.3 37246.4 +35371.4 35510.4 35816.7 36180.5 36490.4 36632.4 +35185.4 35283.8 35510.4 35782 36010.4 36110.2 +35109.7 35185.4 35371.4 35597.2 35784.2 35860.6 Species 5 -35860.6 36110.2 36632.4 37246.4 37779.5 38038.7 -35784.2 36010.4 36490.4 37056.3 37545.3 37779.5 -35597.2 35782 36180.5 36651.6 37056.3 37246.4 -35371.4 35510.4 35816.7 36180.5 36490.4 36632.4 -35185.4 35283.8 35510.4 35782 36010.4 36110.2 -35109.7 35185.4 35371.4 35597.2 35784.2 35860.6 +35860.6 36110.2 36632.4 37246.4 37779.5 38038.7 +35784.2 36010.4 36490.4 37056.3 37545.3 37779.5 +35597.2 35782 36180.5 36651.6 37056.3 37246.4 +35371.4 35510.4 35816.7 36180.5 36490.4 36632.4 +35185.4 35283.8 35510.4 35782 36010.4 36110.2 +35109.7 35185.4 35371.4 35597.2 35784.2 35860.6 Species 6 -35860.6 36110.2 36632.4 37246.4 37779.5 38038.7 -35784.2 36010.4 36490.4 37056.3 37545.3 37779.5 -35597.2 35782 36180.5 36651.6 37056.3 37246.4 -35371.4 35510.4 35816.7 36180.5 36490.4 36632.4 -35185.4 35283.8 35510.4 35782 36010.4 36110.2 -35109.7 35185.4 35371.4 35597.2 35784.2 35860.6 +35860.6 36110.2 36632.4 37246.4 37779.5 38038.7 +35784.2 36010.4 36490.4 37056.3 37545.3 37779.5 +35597.2 35782 36180.5 36651.6 37056.3 37246.4 +35371.4 35510.4 35816.7 36180.5 36490.4 36632.4 +35185.4 35283.8 35510.4 35782 36010.4 36110.2 +35109.7 35185.4 35371.4 35597.2 35784.2 35860.6 t = 5.00e+00 nst = 198 nfe = 0 nfi = 3179 nni = 2182 hu = 9.99e-02 @@ -311,52 +311,52 @@ t = 7.00e+00 nst = 216 nfe = 0 nfi = 3477 nni = 2375 hu = 1.51e-01 c values at t = 7: Species 1 -1.18854 1.19682 1.21415 1.23453 1.25221 1.26082 -1.186 1.19351 1.20944 1.22822 1.24444 1.25221 -1.1798 1.18593 1.19916 1.21479 1.22822 1.23453 -1.17231 1.17692 1.18708 1.19916 1.20944 1.21415 -1.16614 1.1694 1.17692 1.18593 1.19351 1.19682 -1.16363 1.16614 1.17231 1.1798 1.186 1.18854 +1.18854 1.19682 1.21415 1.23453 1.25221 1.26082 +1.186 1.19351 1.20944 1.22822 1.24444 1.25221 +1.1798 1.18593 1.19916 1.21479 1.22822 1.23453 +1.17231 1.17692 1.18708 1.19916 1.20944 1.21415 +1.16614 1.1694 1.17692 1.18593 1.19351 1.19682 +1.16363 1.16614 1.17231 1.1798 1.186 1.18854 Species 2 -1.18854 1.19683 1.21415 1.23453 1.25222 1.26082 -1.186 1.19351 1.20944 1.22822 1.24444 1.25222 -1.1798 1.18594 1.19916 1.21479 1.22822 1.23453 -1.17231 1.17692 1.18709 1.19916 1.20944 1.21415 -1.16614 1.1694 1.17692 1.18594 1.19351 1.19683 -1.16363 1.16614 1.17231 1.1798 1.186 1.18854 +1.18854 1.19683 1.21415 1.23453 1.25222 1.26082 +1.186 1.19351 1.20944 1.22822 1.24444 1.25222 +1.1798 1.18594 1.19916 1.21479 1.22822 1.23453 +1.17231 1.17692 1.18709 1.19916 1.20944 1.21415 +1.16614 1.1694 1.17692 1.18594 1.19351 1.19683 +1.16363 1.16614 1.17231 1.1798 1.186 1.18854 Species 3 -1.18854 1.19683 1.21416 1.23453 1.25222 1.26082 -1.18601 1.19351 1.20944 1.22822 1.24444 1.25222 -1.1798 1.18594 1.19916 1.21479 1.22822 1.23453 -1.17231 1.17692 1.18709 1.19916 1.20944 1.21416 -1.16614 1.1694 1.17692 1.18594 1.19351 1.19683 -1.16363 1.16614 1.17231 1.1798 1.18601 1.18854 +1.18854 1.19683 1.21416 1.23453 1.25222 1.26082 +1.18601 1.19351 1.20944 1.22822 1.24444 1.25222 +1.1798 1.18594 1.19916 1.21479 1.22822 1.23453 +1.17231 1.17692 1.18709 1.19916 1.20944 1.21416 +1.16614 1.1694 1.17692 1.18594 1.19351 1.19683 +1.16363 1.16614 1.17231 1.1798 1.18601 1.18854 Species 4 -35656.3 35903.1 36424.2 37033.8 37564.6 37822.3 -35578.4 35804.9 36281.3 36845.5 37330.9 37564.6 -35393.9 35575.9 35974.4 36441.4 36845.5 37033.8 -35167.5 35307.4 35610.6 35974.4 36281.3 36424.2 -34984.3 35080.2 35307.4 35575.9 35804.9 35903.1 -34907.5 34984.3 35167.5 35393.9 35578.4 35656.3 +35656.3 35903.1 36424.2 37033.8 37564.6 37822.3 +35578.4 35804.9 36281.3 36845.5 37330.9 37564.6 +35393.9 35575.9 35974.4 36441.4 36845.5 37033.8 +35167.5 35307.4 35610.6 35974.4 36281.3 36424.2 +34984.3 35080.2 35307.4 35575.9 35804.9 35903.1 +34907.5 34984.3 35167.5 35393.9 35578.4 35656.3 Species 5 -35656.3 35903.1 36424.2 37033.8 37564.6 37822.3 -35578.4 35804.9 36281.3 36845.5 37330.9 37564.6 -35393.9 35575.9 35974.4 36441.4 36845.5 37033.8 -35167.5 35307.4 35610.6 35974.4 36281.3 36424.2 -34984.3 35080.2 35307.4 35575.9 35804.9 35903.1 -34907.5 34984.3 35167.5 35393.9 35578.4 35656.3 +35656.3 35903.1 36424.2 37033.8 37564.6 37822.3 +35578.4 35804.9 36281.3 36845.5 37330.9 37564.6 +35393.9 35575.9 35974.4 36441.4 36845.5 37033.8 +35167.5 35307.4 35610.6 35974.4 36281.3 36424.2 +34984.3 35080.2 35307.4 35575.9 35804.9 35903.1 +34907.5 34984.3 35167.5 35393.9 35578.4 35656.3 Species 6 -35656.3 35903.1 36424.2 37033.8 37564.6 37822.3 -35578.4 35804.9 36281.3 36845.5 37330.9 37564.6 -35393.9 35575.9 35974.4 36441.4 36845.5 37033.8 -35167.5 35307.4 35610.6 35974.4 36281.3 36424.2 -34984.3 35080.2 35307.4 35575.9 35804.9 35903.1 -34907.5 34984.3 35167.5 35393.9 35578.4 35656.3 +35656.3 35903.1 36424.2 37033.8 37564.6 37822.3 +35578.4 35804.9 36281.3 36845.5 37330.9 37564.6 +35393.9 35575.9 35974.4 36441.4 36845.5 37033.8 +35167.5 35307.4 35610.6 35974.4 36281.3 36424.2 +34984.3 35080.2 35307.4 35575.9 35804.9 35903.1 +34907.5 34984.3 35167.5 35393.9 35578.4 35656.3 t = 8.00e+00 nst = 232 nfe = 0 nfi = 3780 nni = 2567 hu = 1.06e-01 @@ -367,75 +367,75 @@ t = 1.00e+01 nst = 266 nfe = 0 nfi = 4394 nni = 2941 hu = 8.37e-02 c values at t = 10: Species 1 -1.18838 1.19667 1.21399 1.23437 1.25205 1.26066 -1.18585 1.19335 1.20928 1.22805 1.24428 1.25205 -1.17964 1.18578 1.199 1.21463 1.22805 1.23437 -1.17215 1.17676 1.18693 1.199 1.20928 1.21399 -1.16598 1.16925 1.17676 1.18578 1.19335 1.19667 -1.16347 1.16598 1.17215 1.17964 1.18585 1.18838 +1.18838 1.19667 1.21399 1.23437 1.25205 1.26066 +1.18585 1.19335 1.20928 1.22805 1.24428 1.25205 +1.17964 1.18578 1.199 1.21463 1.22805 1.23437 +1.17215 1.17676 1.18693 1.199 1.20928 1.21399 +1.16598 1.16925 1.17676 1.18578 1.19335 1.19667 +1.16347 1.16598 1.17215 1.17964 1.18585 1.18838 Species 2 -1.18838 1.19667 1.21399 1.23437 1.25205 1.26066 -1.18585 1.19335 1.20928 1.22805 1.24428 1.25205 -1.17964 1.18578 1.199 1.21463 1.22805 1.23437 -1.17215 1.17676 1.18693 1.199 1.20928 1.21399 -1.16598 1.16925 1.17676 1.18578 1.19335 1.19667 -1.16347 1.16598 1.17215 1.17964 1.18585 1.18838 +1.18838 1.19667 1.21399 1.23437 1.25205 1.26066 +1.18585 1.19335 1.20928 1.22805 1.24428 1.25205 +1.17964 1.18578 1.199 1.21463 1.22805 1.23437 +1.17215 1.17676 1.18693 1.199 1.20928 1.21399 +1.16598 1.16925 1.17676 1.18578 1.19335 1.19667 +1.16347 1.16598 1.17215 1.17964 1.18585 1.18838 Species 3 -1.18838 1.19667 1.21399 1.23437 1.25205 1.26066 -1.18585 1.19335 1.20928 1.22805 1.24428 1.25205 -1.17964 1.18578 1.199 1.21463 1.22805 1.23437 -1.17215 1.17676 1.18693 1.199 1.20928 1.21399 -1.16598 1.16925 1.17676 1.18578 1.19335 1.19667 -1.16347 1.16598 1.17215 1.17964 1.18585 1.18838 +1.18838 1.19667 1.21399 1.23437 1.25205 1.26066 +1.18585 1.19335 1.20928 1.22805 1.24428 1.25205 +1.17964 1.18578 1.199 1.21463 1.22805 1.23437 +1.17215 1.17676 1.18693 1.199 1.20928 1.21399 +1.16598 1.16925 1.17676 1.18578 1.19335 1.19667 +1.16347 1.16598 1.17215 1.17964 1.18585 1.18838 Species 4 -35650.6 35898.8 36418.4 37029.2 37559.5 37817.3 -35574.5 35799.5 36277.1 36840 37326.6 37559.5 -35388.4 35572.3 35968.8 36437.5 36840 37029.2 -35163.7 35302 35606.7 35968.8 36277.1 36418.4 -34978.6 35076.5 35302 35572.3 35799.5 35898.8 -34903.3 34978.6 35163.7 35388.4 35574.5 35650.6 +35650.6 35898.8 36418.4 37029.2 37559.5 37817.3 +35574.5 35799.5 36277.1 36840 37326.6 37559.5 +35388.4 35572.3 35968.8 36437.5 36840 37029.2 +35163.7 35302 35606.7 35968.8 36277.1 36418.4 +34978.6 35076.5 35302 35572.3 35799.5 35898.8 +34903.3 34978.6 35163.7 35388.4 35574.5 35650.6 Species 5 -35650.6 35898.8 36418.4 37029.2 37559.5 37817.3 -35574.5 35799.5 36277.1 36840 37326.6 37559.5 -35388.4 35572.3 35968.8 36437.5 36840 37029.2 -35163.7 35302 35606.7 35968.8 36277.1 36418.4 -34978.6 35076.5 35302 35572.3 35799.5 35898.8 -34903.3 34978.6 35163.7 35388.4 35574.5 35650.6 +35650.6 35898.8 36418.4 37029.2 37559.5 37817.3 +35574.5 35799.5 36277.1 36840 37326.6 37559.5 +35388.4 35572.3 35968.8 36437.5 36840 37029.2 +35163.7 35302 35606.7 35968.8 36277.1 36418.4 +34978.6 35076.5 35302 35572.3 35799.5 35898.8 +34903.3 34978.6 35163.7 35388.4 35574.5 35650.6 Species 6 -35650.6 35898.8 36418.4 37029.2 37559.5 37817.3 -35574.5 35799.5 36277.1 36840 37326.6 37559.5 -35388.4 35572.3 35968.8 36437.5 36840 37029.2 -35163.7 35302 35606.7 35968.8 36277.1 36418.4 -34978.6 35076.5 35302 35572.3 35799.5 35898.8 -34903.3 34978.6 35163.7 35388.4 35574.5 35650.6 +35650.6 35898.8 36418.4 37029.2 37559.5 37817.3 +35574.5 35799.5 36277.1 36840 37326.6 37559.5 +35388.4 35572.3 35968.8 36437.5 36840 37029.2 +35163.7 35302 35606.7 35968.8 36277.1 36418.4 +34978.6 35076.5 35302 35572.3 35799.5 35898.8 +34903.3 34978.6 35163.7 35388.4 35574.5 35650.6 Final statistics for this run: - ARKStep real workspace length = 3554 - ARKStep integer workspace length = 131 - ARKLS real workspace length = 2647 - ARKLS integer workspace length = 42 - Number of steps = 266 - Number of f-s (explicit) = 0 - Number of f-s (implicit) = 4394 - Number of f-s (SPGMR) = 8980 - Number of f-s (TOTAL) = 8980 - Number of setups = 121 - Number of nonlinear iterations = 2941 - Number of linear iterations = 8980 - Number of preconditioner evaluations = 121 - Number of preconditioner solves = 11819 - Number of error test failures = 23 - Number of nonlinear conv. failures = 17 - Number of linear convergence failures = 509 - Average Krylov subspace dimension = 3.053 + ARKStep real workspace length = 3554 + ARKStep integer workspace length = 131 + ARKLS real workspace length = 2647 + ARKLS integer workspace length = 42 + Number of steps = 266 + Number of f-s (explicit) = 0 + Number of f-s (implicit) = 4394 + Number of f-s (SPGMR) = 8980 + Number of f-s (TOTAL) = 8980 + Number of setups = 121 + Number of nonlinear iterations = 2941 + Number of linear iterations = 8980 + Number of preconditioner evaluations = 121 + Number of preconditioner solves = 11819 + Number of error test failures = 23 + Number of nonlinear conv. failures = 17 + Number of linear convergence failures = 509 + Average Krylov subspace dimension = 3.053 ---------------------------------------------------------------------------- @@ -487,24 +487,24 @@ t = 1.00e+01 nst = 251 nfe = 0 nfi = 4101 nni = 2746 hu = 7.09e-02 Final statistics for this run: - ARKStep real workspace length = 3554 - ARKStep integer workspace length = 131 - ARKLS real workspace length = 2647 - ARKLS integer workspace length = 42 - Number of steps = 251 - Number of f-s (explicit) = 0 - Number of f-s (implicit) = 4101 - Number of f-s (SPGMR) = 8880 - Number of f-s (TOTAL) = 8880 - Number of setups = 91 - Number of nonlinear iterations = 2746 - Number of linear iterations = 8880 - Number of preconditioner evaluations = 91 - Number of preconditioner solves = 11537 - Number of error test failures = 18 - Number of nonlinear conv. failures = 13 - Number of linear convergence failures = 597 - Average Krylov subspace dimension = 3.234 + ARKStep real workspace length = 3554 + ARKStep integer workspace length = 136 + ARKLS real workspace length = 2647 + ARKLS integer workspace length = 42 + Number of steps = 251 + Number of f-s (explicit) = 0 + Number of f-s (implicit) = 4101 + Number of f-s (SPGMR) = 8880 + Number of f-s (TOTAL) = 8880 + Number of setups = 91 + Number of nonlinear iterations = 2746 + Number of linear iterations = 8880 + Number of preconditioner evaluations = 91 + Number of preconditioner solves = 11537 + Number of error test failures = 18 + Number of nonlinear conv. failures = 13 + Number of linear convergence failures = 597 + Average Krylov subspace dimension = 3.234 ---------------------------------------------------------------------------- @@ -556,24 +556,24 @@ t = 1.00e+01 nst = 359 nfe = 0 nfi = 5722 nni = 3907 hu = 1.35e-01 Final statistics for this run: - ARKStep real workspace length = 3554 - ARKStep integer workspace length = 131 - ARKLS real workspace length = 2647 - ARKLS integer workspace length = 42 - Number of steps = 359 - Number of f-s (explicit) = 0 - Number of f-s (implicit) = 5722 - Number of f-s (SPGMR) = 12904 - Number of f-s (TOTAL) = 12904 - Number of setups = 253 - Number of nonlinear iterations = 3907 - Number of linear iterations = 12904 - Number of preconditioner evaluations = 253 - Number of preconditioner solves = 16594 - Number of error test failures = 0 - Number of nonlinear conv. failures = 117 - Number of linear convergence failures = 1072 - Average Krylov subspace dimension = 3.303 + ARKStep real workspace length = 3554 + ARKStep integer workspace length = 141 + ARKLS real workspace length = 2647 + ARKLS integer workspace length = 42 + Number of steps = 359 + Number of f-s (explicit) = 0 + Number of f-s (implicit) = 5722 + Number of f-s (SPGMR) = 12904 + Number of f-s (TOTAL) = 12904 + Number of setups = 253 + Number of nonlinear iterations = 3907 + Number of linear iterations = 12904 + Number of preconditioner evaluations = 253 + Number of preconditioner solves = 16594 + Number of error test failures = 0 + Number of nonlinear conv. failures = 117 + Number of linear convergence failures = 1072 + Average Krylov subspace dimension = 3.303 ---------------------------------------------------------------------------- @@ -625,24 +625,24 @@ t = 1.00e+01 nst = 359 nfe = 0 nfi = 5728 nni = 3912 hu = 1.31e-01 Final statistics for this run: - ARKStep real workspace length = 3554 - ARKStep integer workspace length = 131 - ARKLS real workspace length = 2647 - ARKLS integer workspace length = 42 - Number of steps = 359 - Number of f-s (explicit) = 0 - Number of f-s (implicit) = 5728 - Number of f-s (SPGMR) = 12934 - Number of f-s (TOTAL) = 12934 - Number of setups = 254 - Number of nonlinear iterations = 3912 - Number of linear iterations = 12934 - Number of preconditioner evaluations = 254 - Number of preconditioner solves = 16627 - Number of error test failures = 0 - Number of nonlinear conv. failures = 118 - Number of linear convergence failures = 1076 - Average Krylov subspace dimension = 3.306 + ARKStep real workspace length = 3554 + ARKStep integer workspace length = 146 + ARKLS real workspace length = 2647 + ARKLS integer workspace length = 42 + Number of steps = 359 + Number of f-s (explicit) = 0 + Number of f-s (implicit) = 5728 + Number of f-s (SPGMR) = 12934 + Number of f-s (TOTAL) = 12934 + Number of setups = 254 + Number of nonlinear iterations = 3912 + Number of linear iterations = 12934 + Number of preconditioner evaluations = 254 + Number of preconditioner solves = 16627 + Number of error test failures = 0 + Number of nonlinear conv. failures = 118 + Number of linear convergence failures = 1076 + Average Krylov subspace dimension = 3.306 ---------------------------------------------------------------------------- From 04dcf8f1aad94094f412e402db300e668c3bbf2b Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Fri, 20 Oct 2023 15:17:38 -0500 Subject: [PATCH 12/58] Removed method order storage from SUNController implementations, and instead pass that in as argument to EstimateStep --- .../SUNAdaptController_Description.rst | 47 +- .../SUNAdaptController_ExpGus.rst | 9 +- .../SUNAdaptController_I.rst | 9 +- .../SUNAdaptController_ImExGus.rst | 8 +- .../SUNAdaptController_ImpGus.rst | 10 +- .../SUNAdaptController_PI.rst | 8 +- .../SUNAdaptController_PID.rst | 9 +- .../arkode/C_serial/ark_KrylovDemo_prec.out | 652 +++++++++--------- .../arkode/C_serial/ark_KrylovDemo_prec_1.out | 652 +++++++++--------- .../arkode/C_serial/ark_KrylovDemo_prec_2.out | 652 +++++++++--------- .../sunadaptcontroller_expgus.h | 5 +- .../sunadaptcontroller/sunadaptcontroller_i.h | 5 +- .../sunadaptcontroller_imexgus.h | 5 +- .../sunadaptcontroller_impgus.h | 5 +- .../sunadaptcontroller_pi.h | 5 +- .../sunadaptcontroller_pid.h | 5 +- include/sundials/sundials_adaptcontroller.h | 40 +- src/arkode/arkode_adapt.c | 12 +- src/arkode/arkode_arkstep.c | 15 +- src/arkode/arkode_erkstep.c | 15 +- src/arkode/arkode_user_controller.c | 8 +- src/arkode/arkode_user_controller.h | 4 +- .../fmod/fsunadaptcontroller_expgus_mod.c | 28 +- .../fmod/fsunadaptcontroller_expgus_mod.f90 | 48 +- .../expgus/sunadaptcontroller_expgus.c | 20 +- .../i/fmod/fsunadaptcontroller_i_mod.c | 28 +- .../i/fmod/fsunadaptcontroller_i_mod.f90 | 48 +- .../i/sunadaptcontroller_i.c | 18 +- .../fmod/fsunadaptcontroller_imexgus_mod.c | 28 +- .../fmod/fsunadaptcontroller_imexgus_mod.f90 | 48 +- .../imexgus/sunadaptcontroller_imexgus.c | 20 +- .../fmod/fsunadaptcontroller_impgus_mod.c | 28 +- .../fmod/fsunadaptcontroller_impgus_mod.f90 | 48 +- .../impgus/sunadaptcontroller_impgus.c | 18 +- .../pi/fmod/fsunadaptcontroller_pi_mod.c | 28 +- .../pi/fmod/fsunadaptcontroller_pi_mod.f90 | 48 +- .../pi/sunadaptcontroller_pi.c | 18 +- .../pid/fmod/fsunadaptcontroller_pid_mod.c | 28 +- .../pid/fmod/fsunadaptcontroller_pid_mod.f90 | 48 +- .../pid/sunadaptcontroller_pid.c | 18 +- .../fmod/fsundials_adaptcontroller_mod.c | 66 +- .../fmod/fsundials_adaptcontroller_mod.f90 | 135 ++-- src/sundials/sundials_adaptcontroller.c | 38 +- 43 files changed, 1300 insertions(+), 1687 deletions(-) diff --git a/doc/shared/sunadaptcontroller/SUNAdaptController_Description.rst b/doc/shared/sunadaptcontroller/SUNAdaptController_Description.rst index 4cdedbe4c7..1c045b953d 100644 --- a/doc/shared/sunadaptcontroller/SUNAdaptController_Description.rst +++ b/doc/shared/sunadaptcontroller/SUNAdaptController_Description.rst @@ -60,14 +60,13 @@ function pointers to the various controller operations, and is defined as struct _generic_SUNAdaptController_Ops { SUNAdaptController_Type (*getid)(SUNAdaptController C); int (*destroy)(SUNAdaptController C); - int (*estimatestep)(SUNAdaptController C, sunrealtype h, sunrealtype dsm, sunrealtype* hnew); - int (*estimatestepandorder)(SUNAdaptController C, sunrealtype h, int q, sunrealtype dsm, sunrealtype* hnew, int *qnew); - int (*estimatemristeps)(SUNAdaptController C, sunrealtype H, sunrealtype h, sunrealtype DSM, sunrealtype dsm, sunrealtype* Hnew, sunrealtype *hnew); - int (*estimatesteptol)(SUNAdaptController C, sunrealtype H, sunrealtype tolfac, sunrealtype DSM, sunrealtype dsm, sunrealtype *Hnew, sunrealtype* tolfacnew); + int (*estimatestep)(SUNAdaptController C, sunrealtype h, int p, sunrealtype dsm, sunrealtype* hnew); + int (*estimatestepandorder)(SUNAdaptController C, sunrealtype h, int p, sunrealtype dsm, sunrealtype* hnew, int *pnew); + int (*estimatemristeps)(SUNAdaptController C, sunrealtype H, sunrealtype h, int P, int p, sunrealtype DSM, sunrealtype dsm, sunrealtype* Hnew, sunrealtype *hnew); + int (*estimatesteptol)(SUNAdaptController C, sunrealtype H, int P, sunrealtype tolfac, sunrealtype DSM, sunrealtype dsm, sunrealtype *Hnew, sunrealtype* tolfacnew); int (*reset)(SUNAdaptController C); int (*setdefaults)(SUNAdaptController C); int (*write)(SUNAdaptController C, FILE* fptr); - int (*setmethodorder)(SUNAdaptController C, int p); int (*seterrorbias)(SUNAdaptController C, sunrealtype bias); int (*update)(SUNAdaptController C, sunrealtype h, sunrealtype dsm); int (*updatemrih)(SUNAdaptController C, sunrealtype H, sunrealtype h, sunrealtype DSM, sunrealtype dsm); @@ -100,7 +99,7 @@ following set of SUNAdaptController types: Controls a single-rate step size. -.. c:enumerator:: SUN_ADAPTCONTROLLER_HQ +.. c:enumerator:: SUN_ADAPTCONTROLLER_HP Controls a single-rate step size and method order. @@ -175,13 +174,14 @@ routine, below. retval = SUNAdaptController_Destroy(C); -.. c:function:: int SUNAdaptController_EstimateStep(SUNAdaptController C, sunrealtype h, sunrealtype dsm, sunrealtype* hnew) +.. c:function:: int SUNAdaptController_EstimateStep(SUNAdaptController C, sunrealtype h, int p, sunrealtype dsm, sunrealtype* hnew) Estimates a single-rate step size. This routine is required for controllers of type ``SUN_ADAPTCONTROLLER_H``. :param C: the :c:type:`SUNAdaptController` object. :param h: the step size from the previous step attempt. + :param p: the current order of accuracy for the time integration method. :param dsm: the local temporal estimate from the previous step attempt. :param hnew: (output) pointer to the estimated step size. :return: error code indicating success failure @@ -193,17 +193,17 @@ routine, below. retval = SUNAdaptController_EstimateStep(C, hcur, dsm, &hnew); -.. c:function:: int SUNAdaptController_EstimateStepAndOrder(SUNAdaptController C, sunrealtype h, int q, sunrealtype dsm, sunrealtype* hnew, int* qnew) +.. c:function:: int SUNAdaptController_EstimateStepAndOrder(SUNAdaptController C, sunrealtype h, int p, sunrealtype dsm, sunrealtype* hnew, int* pnew) Estimates a single-rate step size and corresponding method order. This - routine is required for controllers of type ``SUN_ADAPTCONTROLLER_HQ``. + routine is required for controllers of type ``SUN_ADAPTCONTROLLER_HP``. :param C: the :c:type:`SUNAdaptController` object. :param h: the step size from the previous step attempt. - :param q: the method order from the previous step attempt. + :param p: the order of accuracy for the time integration method from the previous step attempt. :param dsm: the local temporal estimate from the previous step attempt. :param hnew: (output) pointer to the estimated step size. - :param qnew: (output) pointer to the estimated method order. + :param pnew: (output) pointer to the estimated method order. :return: error code indicating success failure (see :numref:`SUNAdaptController.Description.errorCodes`). @@ -211,9 +211,9 @@ routine, below. .. code-block:: c - retval = SUNAdaptController_EstimateStepAndOrder(C, hcur, qcur, dsm, &hnew, &qnew); + retval = SUNAdaptController_EstimateStepAndOrder(C, hcur, pcur, dsm, &hnew, &pnew); -.. c:function:: int SUNAdaptController_EstimateMRISteps(SUNAdaptController C, sunrealtype H, sunrealtype h, sunrealtype DSM, sunrealtype dsm, sunrealtype* Hnew, sunrealtype *hnew) +.. c:function:: int SUNAdaptController_EstimateMRISteps(SUNAdaptController C, sunrealtype H, sunrealtype h, int P, int p, sunrealtype DSM, sunrealtype dsm, sunrealtype* Hnew, sunrealtype *hnew) Estimates the slow and fast multirate step sizes. This routine is required for controllers of type ``SUN_ADAPTCONTROLLER_MRI_H``. @@ -221,6 +221,8 @@ routine, below. :param C: the :c:type:`SUNAdaptController` object. :param H: the slow step size from the previous multirate step attempt. :param h: the fast step size from the previous multirate step attempt. + :param P: the current order of accuracy for the slow time integration method. + :param p: the current order of accuracy for the fast time integration method. :param DSM: the local slow temporal error estimate from the previous step attempt. :param dsm: the local fast temporal error estimate from the previous step @@ -236,7 +238,7 @@ routine, below. retval = SUNAdaptController_EstimateMRISteps(C, Hcur, hcur, DSM, &Hnew, &hnew); -.. c:function:: int SUNAdaptController_EstimateStepTol(SUNAdaptController C, sunrealtype H, sunrealtype tolfac, sunrealtype DSM, sunrealtype *Hnew, sunrealtype* tolfacnew) +.. c:function:: int SUNAdaptController_EstimateStepTol(SUNAdaptController C, sunrealtype H, int P, sunrealtype tolfac, sunrealtype DSM, sunrealtype *Hnew, sunrealtype* tolfacnew) Estimates the slow step size and recommended fast relative tolerance factor for a multirate step. This routine is required for controllers of type @@ -244,6 +246,7 @@ routine, below. :param C: the :c:type:`SUNAdaptController` object. :param H: the slow step size from the previous multirate step attempt. + :param P: the current order of accuracy for the slow time integration method. :param tolfac: the ratio of fast/slow relative tolerances, :math:`\text{reltol}/\text{RELTOL}`, from the previous multirate step attempt. @@ -309,22 +312,6 @@ routine, below. retval = SUNAdaptController_Write(C, stdout); -.. c:function:: int SUNAdaptController_SetMethodOrder(SUNAdaptController C, int p) - - Called by the time integrator to inform the controller of the asymptotic - order of accuracy for the method. - - :param C: the :c:type:`SUNAdaptController` object. - :param p: the asymptotic method order of accuracy to use. - :return: error code indicating success failure - (see :numref:`SUNAdaptController.Description.errorCodes`). - - Usage: - - .. code-block:: c - - retval = SUNAdaptController_SetMethodOrder(C, 3, 2); - .. c:function:: int SUNAdaptController_SetErrorBias(SUNAdaptController C, sunrealtype bias) Sets an error bias factor for scaling the local error factors. This is diff --git a/doc/shared/sunadaptcontroller/SUNAdaptController_ExpGus.rst b/doc/shared/sunadaptcontroller/SUNAdaptController_ExpGus.rst index 0d224c04f4..1443be890d 100644 --- a/doc/shared/sunadaptcontroller/SUNAdaptController_ExpGus.rst +++ b/doc/shared/sunadaptcontroller/SUNAdaptController_ExpGus.rst @@ -30,9 +30,9 @@ form \quad\text{on subsequent steps}, \end{cases} -with default values :math:`k_1=0.367` and :math:`k_2=0.268`, and where :math:`p` is -described below. In this estimate, a floor of :math:`\varepsilon > 10^{-10}` -is enforced to avoid division-by-zero errors. +with default values :math:`k_1=0.367` and :math:`k_2=0.268`, and where :math:`p` +is the global order of the time integration method. In this estimate, a floor of +:math:`\varepsilon > 10^{-10}` is enforced to avoid division-by-zero errors. The SUNAdaptController_ExpGus controller is implemented as a derived SUNAdaptController class, and defines its *content* field as: @@ -44,7 +44,6 @@ and defines its *content* field as: sunrealtype k2; sunrealtype bias; sunrealtype ep; - int p; sunbooleantype firststep; }; @@ -57,8 +56,6 @@ These entries of the *content* field contain the following information: * ``ep`` - storage for the previous error estimate, :math:`\varepsilon_{n-1}`. -* ``p`` - asymptotic order to use in error control (provided by the time integrator). - * ``firststep`` - flag indicating whether a step has successfully completed, in which case the formula above transitions from :math:`h_1` to :math:`h_n`. diff --git a/doc/shared/sunadaptcontroller/SUNAdaptController_I.rst b/doc/shared/sunadaptcontroller/SUNAdaptController_I.rst index 20fd04997e..60a45972cf 100644 --- a/doc/shared/sunadaptcontroller/SUNAdaptController_I.rst +++ b/doc/shared/sunadaptcontroller/SUNAdaptController_I.rst @@ -26,9 +26,9 @@ estimate, .. math:: h' \;=\; h_n\; \varepsilon_n^{-k_1/(p+1)}, -where :math:`p` is described below. In this estimate, a floor of -:math:`\varepsilon > 10^{-10}` is enforced to avoid division-by-zero errors. By default -the constant :math:`k_1=1`. +where :math:`p` is the global order of the time integration method. In this estimate, +a floor of :math:`\varepsilon > 10^{-10}` is enforced to avoid division-by-zero errors. +By default the constant :math:`k_1=1`. This is implemented as a derived SUNAdaptController class, and defines its *content* field as: @@ -38,7 +38,6 @@ field as: struct _SUNAdaptControllerContent_I { sunrealtype k1; sunrealtype bias; - int p; }; These entries of the *content* field contain the following information: @@ -48,8 +47,6 @@ These entries of the *content* field contain the following information: * ``bias`` - error bias factor, that converts from an input temporal error estimate via :math:`\varepsilon = \text{bias}*\text{dsm}`. -* ``p`` - asymptotic order to use in error control (provided by the time integrator). - The header file to be included when using this module is ``sunadaptcontroller/sunadaptcontroller_i.h``. diff --git a/doc/shared/sunadaptcontroller/SUNAdaptController_ImExGus.rst b/doc/shared/sunadaptcontroller/SUNAdaptController_ImExGus.rst index 5389e8c3a9..3bff348a59 100644 --- a/doc/shared/sunadaptcontroller/SUNAdaptController_ImExGus.rst +++ b/doc/shared/sunadaptcontroller/SUNAdaptController_ImExGus.rst @@ -32,8 +32,9 @@ is primarily useful with explicit Runge--Kutta methods, and has the form :label: expGusController The default values of :math:`k_1` and :math:`k_2` are 0.367 and 0.268, -respectively, and :math:`p` is described below. In this estimate, -a floor of :math:`\varepsilon > 10^{-10}` is enforced to avoid division-by-zero errors. +respectively, and :math:`p` is the global order of the time +integration method. In this estimate, a floor of :math:`\varepsilon > 10^{-10}` +is enforced to avoid division-by-zero errors. Gustafsson also proposed a controller for implicit Runge--Kutta methods in :cite:p:`Gust:94`, with the form @@ -64,7 +65,6 @@ class, and defines its *content* field as: sunrealtype bias; sunrealtype ep; sunrealtype hp; - int p; sunbooleantype firststep; }; @@ -81,8 +81,6 @@ These entries of the *content* field contain the following information: * ``hp`` - storage for the previous step size, :math:`h_{n-1}`. -* ``p`` - asymptotic order to use in error control (provided by the time integrator). - * ``firststep`` - flag indicating whether a step has completed successfully, allowing the formulas above to transition between :math:`h_1` and :math:`h_n`. diff --git a/doc/shared/sunadaptcontroller/SUNAdaptController_ImpGus.rst b/doc/shared/sunadaptcontroller/SUNAdaptController_ImpGus.rst index 3050b27be3..7eef22c829 100644 --- a/doc/shared/sunadaptcontroller/SUNAdaptController_ImpGus.rst +++ b/doc/shared/sunadaptcontroller/SUNAdaptController_ImpGus.rst @@ -30,9 +30,10 @@ form \quad\text{on subsequent steps}, \end{cases} -with default parameter values :math:`k_1 = 0.98` and :math:`k_2 = 0.95`, and where -:math:`p` is described below. In this estimate, a floor of -:math:`\varepsilon > 10^{-10}` is enforced to avoid division-by-zero errors. +with default parameter values :math:`k_1 = 0.98` and :math:`k_2 = 0.95`, and +:math:`p` is the global order of the time integration method. In this estimate, +a floor of :math:`\varepsilon > 10^{-10}` is enforced to avoid division-by-zero +errors. The SUNAdaptController_ImpGus controller is implemented as a derived SUNAdaptController class, and defines its *content* field as: @@ -45,7 +46,6 @@ and defines its *content* field as: sunrealtype bias; sunrealtype ep; sunrealtype hp; - int p; sunbooleantype firststep; }; @@ -60,8 +60,6 @@ These entries of the *content* field contain the following information: * ``hp`` - storage for the previous step size, :math:`h_{n-1}`. -* ``p`` - asymptotic order to use in error control (provided by the time integrator). - * ``firststep`` - flag indicating whether any time steps have completed successfully (and thus to transition from :math:`h_1` to :math:`h_n` in the formula above). diff --git a/doc/shared/sunadaptcontroller/SUNAdaptController_PI.rst b/doc/shared/sunadaptcontroller/SUNAdaptController_PI.rst index ad421925b1..b8c55ae3e9 100644 --- a/doc/shared/sunadaptcontroller/SUNAdaptController_PI.rst +++ b/doc/shared/sunadaptcontroller/SUNAdaptController_PI.rst @@ -27,8 +27,9 @@ two most recent step sizes in its adaptivity algorithm, h' \;=\; h_n\; \varepsilon_n^{-k_1/(p+1)}\; \varepsilon_{n-1}^{k_2/(p+1)}. where the constants :math:`k_1` and :math:`k_2` default to 0.8 and 0.31, -respectively, and :math:`p` is described below. In this estimate, -a floor of :math:`\varepsilon > 10^{-10}` is enforced to avoid division-by-zero errors. +respectively, and :math:`p` is the global order of the time +integration method. In this estimate, a floor of :math:`\varepsilon > 10^{-10}` +is enforced to avoid division-by-zero errors. This is implemented as a derived SUNAdaptController class, and defines its *content* field as: @@ -40,7 +41,6 @@ field as: sunrealtype k2; sunrealtype bias; sunrealtype ep; - int p; }; These entries of the *content* field contain the following information: @@ -52,8 +52,6 @@ These entries of the *content* field contain the following information: * ``ep`` - storage for the previous error estimate, :math:`\varepsilon_{n-1}`. -* ``p`` - asymptotic order to use in error control (provided by the time integrator). - The header file to be included when using this module is ``sunadaptcontroller/sunadaptcontroller_pi.h``. diff --git a/doc/shared/sunadaptcontroller/SUNAdaptController_PID.rst b/doc/shared/sunadaptcontroller/SUNAdaptController_PID.rst index ddf25d77f6..7db5d77aff 100644 --- a/doc/shared/sunadaptcontroller/SUNAdaptController_PID.rst +++ b/doc/shared/sunadaptcontroller/SUNAdaptController_PID.rst @@ -29,9 +29,9 @@ prospective step size, \varepsilon_{n-2}^{-k_3/(p+1)}, where the constants :math:`k_1`, :math:`k_2` and :math:`k_3` default to 0.58, -0.21 and 0.1, respectively, and :math:`p` is described below. -In this estimate, a floor of :math:`\varepsilon > 10^{-10}` is enforced to avoid -division-by-zero errors. +0.21 and 0.1, respectively, and :math:`p` is the global order of the time +integration method. In this estimate, a floor of :math:`\varepsilon > 10^{-10}` +is enforced to avoid division-by-zero errors. This is implemented as a derived SUNAdaptController class, and defines its *content* field as: @@ -45,7 +45,6 @@ field as: sunrealtype bias; sunrealtype ep; sunrealtype epp; - int p; }; These entries of the *content* field contain the following information: @@ -58,8 +57,6 @@ These entries of the *content* field contain the following information: * ``ep, epp`` - storage for the two previous error estimates, :math:`\varepsilon_{n-1}` and :math:`varepsilon_{n-2}`. -* ``p`` - asymptotic order to use in error control (provided by the time integrator). - The header file to be included when using this module is ``sunadaptcontroller/sunadaptcontroller_pid.h``. diff --git a/examples/arkode/C_serial/ark_KrylovDemo_prec.out b/examples/arkode/C_serial/ark_KrylovDemo_prec.out index 09364ad394..a2564a38ee 100644 --- a/examples/arkode/C_serial/ark_KrylovDemo_prec.out +++ b/examples/arkode/C_serial/ark_KrylovDemo_prec.out @@ -10,9 +10,9 @@ b parameter = 1 Diffusion coefficients: Dprey = 1 Dpred = 0.5 Rate parameter alpha = 1 -Mesh dimensions (mx,my) are 6, 6. Total system size is neq = 216 +Mesh dimensions (mx,my) are 6, 6. Total system size is neq = 216 -Tolerances: reltol = 1e-05, abstol = 1e-05 +Tolerances: reltol = 1e-05, abstol = 1e-05 Preconditioning uses a product of: (1) Gauss-Seidel iterations with itmax = 5 iterations, and @@ -31,52 +31,52 @@ Gram-Schmidt method type is gstype = SUN_MODIFIED_GS c values at t = 0: Species 1 -10 10 10 10 10 10 -10 10.1678 10.3775 10.3775 10.1678 10 -10 10.3775 10.8493 10.8493 10.3775 10 -10 10.3775 10.8493 10.8493 10.3775 10 -10 10.1678 10.3775 10.3775 10.1678 10 -10 10 10 10 10 10 +10 10 10 10 10 10 +10 10.1678 10.3775 10.3775 10.1678 10 +10 10.3775 10.8493 10.8493 10.3775 10 +10 10.3775 10.8493 10.8493 10.3775 10 +10 10.1678 10.3775 10.3775 10.1678 10 +10 10 10 10 10 10 Species 2 -10 10 10 10 10 10 -10 10.3355 10.755 10.755 10.3355 10 -10 10.755 11.6987 11.6987 10.755 10 -10 10.755 11.6987 11.6987 10.755 10 -10 10.3355 10.755 10.755 10.3355 10 -10 10 10 10 10 10 +10 10 10 10 10 10 +10 10.3355 10.755 10.755 10.3355 10 +10 10.755 11.6987 11.6987 10.755 10 +10 10.755 11.6987 11.6987 10.755 10 +10 10.3355 10.755 10.755 10.3355 10 +10 10 10 10 10 10 Species 3 -10 10 10 10 10 10 -10 10.5033 11.1325 11.1325 10.5033 10 -10 11.1325 12.548 12.548 11.1325 10 -10 11.1325 12.548 12.548 11.1325 10 -10 10.5033 11.1325 11.1325 10.5033 10 -10 10 10 10 10 10 +10 10 10 10 10 10 +10 10.5033 11.1325 11.1325 10.5033 10 +10 11.1325 12.548 12.548 11.1325 10 +10 11.1325 12.548 12.548 11.1325 10 +10 10.5033 11.1325 11.1325 10.5033 10 +10 10 10 10 10 10 Species 4 -10 10 10 10 10 10 -10 10.6711 11.5099 11.5099 10.6711 10 -10 11.5099 13.3974 13.3974 11.5099 10 -10 11.5099 13.3974 13.3974 11.5099 10 -10 10.6711 11.5099 11.5099 10.6711 10 -10 10 10 10 10 10 +10 10 10 10 10 10 +10 10.6711 11.5099 11.5099 10.6711 10 +10 11.5099 13.3974 13.3974 11.5099 10 +10 11.5099 13.3974 13.3974 11.5099 10 +10 10.6711 11.5099 11.5099 10.6711 10 +10 10 10 10 10 10 Species 5 -10 10 10 10 10 10 -10 10.8389 11.8874 11.8874 10.8389 10 -10 11.8874 14.2467 14.2467 11.8874 10 -10 11.8874 14.2467 14.2467 11.8874 10 -10 10.8389 11.8874 11.8874 10.8389 10 -10 10 10 10 10 10 +10 10 10 10 10 10 +10 10.8389 11.8874 11.8874 10.8389 10 +10 11.8874 14.2467 14.2467 11.8874 10 +10 11.8874 14.2467 14.2467 11.8874 10 +10 10.8389 11.8874 11.8874 10.8389 10 +10 10 10 10 10 10 Species 6 -10 10 10 10 10 10 -10 11.0066 12.2649 12.2649 11.0066 10 -10 12.2649 15.0961 15.0961 12.2649 10 -10 12.2649 15.0961 15.0961 12.2649 10 -10 11.0066 12.2649 12.2649 11.0066 10 -10 10 10 10 10 10 +10 10 10 10 10 10 +10 11.0066 12.2649 12.2649 11.0066 10 +10 12.2649 15.0961 15.0961 12.2649 10 +10 12.2649 15.0961 15.0961 12.2649 10 +10 11.0066 12.2649 12.2649 11.0066 10 +10 10 10 10 10 10 t = 1.00e-08 nst = 5 nfe = 0 nfi = 75 nni = 47 hu = 9.89e-08 @@ -87,52 +87,52 @@ t = 1.00e-06 nst = 8 nfe = 0 nfi = 120 nni = 77 hu = 4.79e-07 c values at t = 1e-06: Species 1 -9.99991 9.99992 9.99993 9.99993 9.99993 9.99992 -9.99992 10.1677 10.3774 10.3774 10.1677 9.99993 -9.99993 10.3774 10.8492 10.8492 10.3774 9.99993 -9.99993 10.3774 10.8492 10.8492 10.3774 9.99993 -9.99992 10.1677 10.3774 10.3774 10.1677 9.99992 -9.99991 9.99992 9.99993 9.99993 9.99992 9.99991 +9.99991 9.99992 9.99993 9.99993 9.99993 9.99992 +9.99992 10.1677 10.3774 10.3774 10.1677 9.99993 +9.99993 10.3774 10.8492 10.8492 10.3774 9.99993 +9.99993 10.3774 10.8492 10.8492 10.3774 9.99993 +9.99992 10.1677 10.3774 10.3774 10.1677 9.99992 +9.99991 9.99992 9.99993 9.99993 9.99992 9.99991 Species 2 -9.99991 9.99993 9.99995 9.99995 9.99993 9.99992 -9.99993 10.3355 10.7549 10.7549 10.3355 9.99993 -9.99995 10.7549 11.6985 11.6985 10.7549 9.99995 -9.99995 10.7549 11.6985 11.6985 10.7549 9.99995 -9.99993 10.3355 10.7549 10.7549 10.3355 9.99993 -9.99991 9.99993 9.99995 9.99995 9.99993 9.99991 +9.99991 9.99993 9.99995 9.99995 9.99993 9.99992 +9.99993 10.3355 10.7549 10.7549 10.3355 9.99993 +9.99995 10.7549 11.6985 11.6985 10.7549 9.99995 +9.99995 10.7549 11.6985 11.6985 10.7549 9.99995 +9.99993 10.3355 10.7549 10.7549 10.3355 9.99993 +9.99991 9.99993 9.99995 9.99995 9.99993 9.99991 Species 3 -9.99991 9.99994 9.99997 9.99997 9.99994 9.99992 -9.99994 10.5032 11.1323 11.1323 10.5032 9.99994 -9.99997 11.1323 12.5478 12.5478 11.1323 9.99997 -9.99997 11.1323 12.5478 12.5478 11.1323 9.99997 -9.99994 10.5032 11.1323 11.1323 10.5032 9.99994 -9.99991 9.99994 9.99997 9.99997 9.99994 9.99991 +9.99991 9.99994 9.99997 9.99997 9.99994 9.99992 +9.99994 10.5032 11.1323 11.1323 10.5032 9.99994 +9.99997 11.1323 12.5478 12.5478 11.1323 9.99997 +9.99997 11.1323 12.5478 12.5478 11.1323 9.99997 +9.99994 10.5032 11.1323 11.1323 10.5032 9.99994 +9.99991 9.99994 9.99997 9.99997 9.99994 9.99991 Species 4 -13.4984 13.4984 13.4984 13.4984 13.4984 13.4984 -13.4984 14.55 15.8924 15.8924 14.55 13.4984 -13.4984 15.8924 19.0296 19.0296 15.8924 13.4984 -13.4984 15.8924 19.0296 19.0296 15.8924 13.4984 -13.4984 14.55 15.8924 15.8924 14.55 13.4984 -13.4984 13.4984 13.4984 13.4984 13.4984 13.4984 +13.4984 13.4984 13.4984 13.4984 13.4984 13.4984 +13.4984 14.55 15.8924 15.8924 14.55 13.4984 +13.4984 15.8924 19.0296 19.0296 15.8924 13.4984 +13.4984 15.8924 19.0296 19.0296 15.8924 13.4984 +13.4984 14.55 15.8924 15.8924 14.55 13.4984 +13.4984 13.4984 13.4984 13.4984 13.4984 13.4984 Species 5 -13.4984 13.4984 13.4985 13.4985 13.4984 13.4984 -13.4984 14.7787 16.4136 16.4136 14.7787 13.4984 -13.4985 16.4136 20.236 20.236 16.4136 13.4985 -13.4985 16.4136 20.236 20.236 16.4136 13.4985 -13.4984 14.7787 16.4136 16.4136 14.7787 13.4984 -13.4984 13.4984 13.4985 13.4985 13.4984 13.4984 +13.4984 13.4984 13.4985 13.4985 13.4984 13.4984 +13.4984 14.7787 16.4136 16.4136 14.7787 13.4984 +13.4985 16.4136 20.236 20.236 16.4136 13.4985 +13.4985 16.4136 20.236 20.236 16.4136 13.4985 +13.4984 14.7787 16.4136 16.4136 14.7787 13.4984 +13.4984 13.4984 13.4985 13.4985 13.4984 13.4984 Species 6 -13.4984 13.4984 13.4985 13.4985 13.4984 13.4984 -13.4984 15.0075 16.9348 16.9348 15.0075 13.4984 -13.4985 16.9348 21.4423 21.4423 16.9348 13.4985 -13.4985 16.9348 21.4423 21.4423 16.9348 13.4985 -13.4984 15.0075 16.9348 16.9348 15.0075 13.4984 -13.4984 13.4984 13.4985 13.4985 13.4984 13.4984 +13.4984 13.4984 13.4985 13.4985 13.4984 13.4984 +13.4984 15.0075 16.9348 16.9348 15.0075 13.4984 +13.4985 16.9348 21.4423 21.4423 16.9348 13.4985 +13.4985 16.9348 21.4423 21.4423 16.9348 13.4985 +13.4984 15.0075 16.9348 16.9348 15.0075 13.4984 +13.4984 13.4984 13.4985 13.4985 13.4984 13.4984 t = 1.00e-05 nst = 27 nfe = 0 nfi = 407 nni = 269 hu = 4.79e-07 @@ -143,52 +143,52 @@ t = 1.00e-03 nst = 110 nfe = 0 nfi = 1750 nni = 1197 hu = 1.51e-03 c values at t = 0.001: Species 1 -9.90702 9.91664 9.92836 9.93033 9.92253 9.91674 -9.91472 10.0747 10.2769 10.2785 10.0795 9.92253 -9.92446 10.2748 10.7181 10.7194 10.2785 9.93033 -9.92445 10.2744 10.7173 10.7181 10.2769 9.92836 -9.91469 10.0734 10.2744 10.2748 10.0747 9.91664 -9.90698 9.91469 9.92445 9.92446 9.91472 9.90702 +9.90702 9.91664 9.92836 9.93033 9.92253 9.91674 +9.91472 10.0747 10.2769 10.2785 10.0795 9.92253 +9.92446 10.2748 10.7181 10.7194 10.2785 9.93033 +9.92445 10.2744 10.7173 10.7181 10.2769 9.92836 +9.91469 10.0734 10.2744 10.2748 10.0747 9.91664 +9.90698 9.91469 9.92445 9.92446 9.91472 9.90702 Species 2 -9.90742 9.92474 9.94622 9.94819 9.93064 9.91713 -9.92282 10.2412 10.644 10.6457 10.2461 9.93064 -9.94232 10.6419 11.5267 11.5281 10.6457 9.94819 -9.94231 10.6415 11.5258 11.5267 10.644 9.94622 -9.92279 10.24 10.6415 10.6419 10.2412 9.92474 -9.90737 9.92279 9.94231 9.94232 9.92282 9.90742 +9.90742 9.92474 9.94622 9.94819 9.93064 9.91713 +9.92282 10.2412 10.644 10.6457 10.2461 9.93064 +9.94232 10.6419 11.5267 11.5281 10.6457 9.94819 +9.94231 10.6415 11.5258 11.5267 10.644 9.94622 +9.92279 10.24 10.6415 10.6419 10.2412 9.92474 +9.90737 9.92279 9.94231 9.94232 9.92282 9.90742 Species 3 -9.90781 9.93284 9.96408 9.96605 9.93874 9.91753 -9.93092 10.4078 11.0109 11.0127 10.4127 9.93874 -9.96017 11.0088 12.3339 12.3354 11.0127 9.96605 -9.96016 11.0083 12.333 12.3339 11.0109 9.96408 -9.93088 10.4065 11.0083 11.0088 10.4078 9.93284 -9.90776 9.93088 9.96016 9.96017 9.93092 9.90781 +9.90781 9.93284 9.96408 9.96605 9.93874 9.91753 +9.93092 10.4078 11.0109 11.0127 10.4127 9.93874 +9.96017 11.0088 12.3339 12.3354 11.0127 9.96605 +9.96016 11.0083 12.333 12.3339 11.0109 9.96408 +9.93088 10.4065 11.0083 11.0088 10.4078 9.93284 +9.90776 9.93088 9.96016 9.96017 9.93092 9.90781 Species 4 -297231 297749 298392 298451 297925 297520 -297692 307245 319327 319378 307390 297925 -298276 319264 345799 345840 319378 298451 -298276 319252 345772 345799 319327 298392 -297691 307208 319252 319264 307245 297749 -297229 297691 298276 298276 297692 297231 +297231 297749 298392 298451 297925 297520 +297692 307245 319327 319378 307390 297925 +298276 319264 345799 345840 319378 298451 +298276 319252 345772 345799 319327 298392 +297691 307208 319252 319264 307245 297749 +297229 297691 298276 298276 297692 297231 Species 5 -297231 297749 298392 298451 297925 297520 -297692 307245 319327 319378 307390 297925 -298276 319264 345799 345840 319378 298451 -298276 319252 345772 345799 319327 298392 -297691 307208 319252 319264 307245 297749 -297229 297691 298276 298276 297692 297231 +297231 297749 298392 298451 297925 297520 +297692 307245 319327 319378 307390 297925 +298276 319264 345799 345840 319378 298451 +298276 319252 345772 345799 319327 298392 +297691 307208 319252 319264 307245 297749 +297229 297691 298276 298276 297692 297231 Species 6 -297231 297749 298392 298451 297925 297520 -297692 307245 319327 319378 307390 297925 -298276 319264 345799 345840 319378 298451 -298276 319252 345772 345799 319327 298392 -297691 307208 319252 319264 307245 297749 -297229 297691 298276 298276 297692 297231 +297231 297749 298392 298451 297925 297520 +297692 307245 319327 319378 307390 297925 +298276 319264 345799 345840 319378 298451 +298276 319252 345772 345799 319327 298392 +297691 307208 319252 319264 307245 297749 +297229 297691 298276 298276 297692 297231 t = 1.00e-02 nst = 113 nfe = 0 nfi = 1797 nni = 1229 hu = 3.46e-03 @@ -199,52 +199,52 @@ t = 1.00e+00 nst = 154 nfe = 0 nfi = 2489 nni = 1716 hu = 6.84e-02 c values at t = 1: Species 1 -1.58851 1.59924 1.62152 1.64764 1.67036 1.68149 -1.58533 1.59503 1.61548 1.63952 1.66033 1.67036 -1.57757 1.58547 1.60239 1.62235 1.63952 1.64764 -1.5682 1.57412 1.58706 1.60239 1.61548 1.62152 -1.56048 1.56463 1.57412 1.58547 1.59503 1.59924 -1.55733 1.56048 1.5682 1.57757 1.58533 1.58851 +1.58851 1.59924 1.62152 1.64764 1.67036 1.68149 +1.58533 1.59503 1.61548 1.63952 1.66033 1.67036 +1.57757 1.58547 1.60239 1.62235 1.63952 1.64764 +1.5682 1.57412 1.58706 1.60239 1.61548 1.62152 +1.56048 1.56463 1.57412 1.58547 1.59503 1.59924 +1.55733 1.56048 1.5682 1.57757 1.58533 1.58851 Species 2 -1.59067 1.60141 1.62371 1.64987 1.67261 1.68375 -1.58748 1.5972 1.61766 1.64173 1.66257 1.67261 -1.57971 1.58763 1.60457 1.62454 1.64173 1.64987 -1.57034 1.57626 1.58921 1.60457 1.61766 1.62371 -1.56261 1.56676 1.57626 1.58763 1.5972 1.60141 -1.55945 1.56261 1.57034 1.57971 1.58748 1.59067 +1.59067 1.60141 1.62371 1.64987 1.67261 1.68375 +1.58748 1.5972 1.61766 1.64173 1.66257 1.67261 +1.57971 1.58763 1.60457 1.62454 1.64173 1.64987 +1.57034 1.57626 1.58921 1.60457 1.61766 1.62371 +1.56261 1.56676 1.57626 1.58763 1.5972 1.60141 +1.55945 1.56261 1.57034 1.57971 1.58748 1.59067 Species 3 -1.5927 1.60346 1.62578 1.65197 1.67474 1.68589 -1.58951 1.59924 1.61973 1.64383 1.66468 1.67474 -1.58174 1.58966 1.60662 1.62662 1.64383 1.65197 -1.57236 1.57828 1.59125 1.60662 1.61973 1.62578 -1.56462 1.56878 1.57828 1.58966 1.59924 1.60346 -1.56146 1.56462 1.57236 1.58174 1.58951 1.5927 +1.5927 1.60346 1.62578 1.65197 1.67474 1.68589 +1.58951 1.59924 1.61973 1.64383 1.66468 1.67474 +1.58174 1.58966 1.60662 1.62662 1.64383 1.65197 +1.57236 1.57828 1.59125 1.60662 1.61973 1.62578 +1.56462 1.56878 1.57828 1.58966 1.59924 1.60346 +1.56146 1.56462 1.57236 1.58174 1.58951 1.5927 Species 4 -47718.3 48040.3 48709 49493.5 50175.5 50509.4 -47622.8 47914 48527.8 49249.6 49874.4 50175.5 -47389.7 47627 48134.9 48734.2 49249.6 49493.5 -47108.5 47286 47674.6 48134.9 48527.8 48709 -46876.6 47001.2 47286 47627 47914 48040.3 -46781.9 46876.6 47108.5 47389.7 47622.8 47718.3 +47718.3 48040.3 48709 49493.5 50175.5 50509.4 +47622.8 47914 48527.8 49249.6 49874.4 50175.5 +47389.7 47627 48134.9 48734.2 49249.6 49493.5 +47108.5 47286 47674.6 48134.9 48527.8 48709 +46876.6 47001.2 47286 47627 47914 48040.3 +46781.9 46876.6 47108.5 47389.7 47622.8 47718.3 Species 5 -47718.3 48040.3 48709 49493.5 50175.5 50509.4 -47622.8 47914 48527.8 49249.6 49874.4 50175.5 -47389.7 47627 48134.9 48734.2 49249.6 49493.5 -47108.5 47286 47674.6 48134.9 48527.8 48709 -46876.6 47001.2 47286 47627 47914 48040.3 -46781.9 46876.6 47108.5 47389.7 47622.8 47718.3 +47718.3 48040.3 48709 49493.5 50175.5 50509.4 +47622.8 47914 48527.8 49249.6 49874.4 50175.5 +47389.7 47627 48134.9 48734.2 49249.6 49493.5 +47108.5 47286 47674.6 48134.9 48527.8 48709 +46876.6 47001.2 47286 47627 47914 48040.3 +46781.9 46876.6 47108.5 47389.7 47622.8 47718.3 Species 6 -47718.3 48040.3 48709 49493.5 50175.5 50509.4 -47622.8 47914 48527.8 49249.6 49874.4 50175.5 -47389.7 47627 48134.9 48734.2 49249.6 49493.5 -47108.5 47286 47674.6 48134.9 48527.8 48709 -46876.6 47001.2 47286 47627 47914 48040.3 -46781.9 46876.6 47108.5 47389.7 47622.8 47718.3 +47718.3 48040.3 48709 49493.5 50175.5 50509.4 +47622.8 47914 48527.8 49249.6 49874.4 50175.5 +47389.7 47627 48134.9 48734.2 49249.6 49493.5 +47108.5 47286 47674.6 48134.9 48527.8 48709 +46876.6 47001.2 47286 47627 47914 48040.3 +46781.9 46876.6 47108.5 47389.7 47622.8 47718.3 t = 2.00e+00 nst = 165 nfe = 0 nfi = 2661 nni = 1833 hu = 4.14e-02 @@ -255,52 +255,52 @@ t = 4.00e+00 nst = 187 nfe = 0 nfi = 3013 nni = 2073 hu = 1.23e-01 c values at t = 4: Species 1 -1.19535 1.20368 1.2211 1.24157 1.25935 1.268 -1.1928 1.20035 1.21636 1.23523 1.25154 1.25935 -1.18657 1.19274 1.20602 1.22173 1.23523 1.24157 -1.17904 1.18368 1.19389 1.20602 1.21636 1.2211 -1.17284 1.17613 1.18368 1.19274 1.20035 1.20368 -1.17032 1.17284 1.17904 1.18657 1.1928 1.19535 +1.19535 1.20368 1.2211 1.24157 1.25935 1.268 +1.1928 1.20035 1.21636 1.23523 1.25154 1.25935 +1.18657 1.19274 1.20602 1.22173 1.23523 1.24157 +1.17904 1.18368 1.19389 1.20602 1.21636 1.2211 +1.17284 1.17613 1.18368 1.19274 1.20035 1.20368 +1.17032 1.17284 1.17904 1.18657 1.1928 1.19535 Species 2 -1.19538 1.20371 1.22113 1.24161 1.25938 1.26804 -1.19284 1.20038 1.21639 1.23526 1.25157 1.25938 -1.1866 1.19277 1.20606 1.22177 1.23526 1.24161 -1.17908 1.18371 1.19393 1.20606 1.21639 1.22113 -1.17288 1.17616 1.18371 1.19277 1.20038 1.20371 -1.17035 1.17288 1.17908 1.1866 1.19284 1.19538 +1.19538 1.20371 1.22113 1.24161 1.25938 1.26804 +1.19284 1.20038 1.21639 1.23526 1.25157 1.25938 +1.1866 1.19277 1.20606 1.22177 1.23526 1.24161 +1.17908 1.18371 1.19393 1.20606 1.21639 1.22113 +1.17288 1.17616 1.18371 1.19277 1.20038 1.20371 +1.17035 1.17288 1.17908 1.1866 1.19284 1.19538 Species 3 -1.19542 1.20374 1.22116 1.24164 1.25942 1.26807 -1.19287 1.20042 1.21642 1.2353 1.2516 1.25942 -1.18663 1.1928 1.20609 1.2218 1.2353 1.24164 -1.17911 1.18374 1.19396 1.20609 1.21642 1.22116 -1.17291 1.17619 1.18374 1.1928 1.20042 1.20374 -1.17039 1.17291 1.17911 1.18663 1.19287 1.19542 +1.19542 1.20374 1.22116 1.24164 1.25942 1.26807 +1.19287 1.20042 1.21642 1.2353 1.2516 1.25942 +1.18663 1.1928 1.20609 1.2218 1.2353 1.24164 +1.17911 1.18374 1.19396 1.20609 1.21642 1.22116 +1.17291 1.17619 1.18374 1.1928 1.20042 1.20374 +1.17039 1.17291 1.17911 1.18663 1.19287 1.19542 Species 4 -35860.6 36110.2 36632.4 37246.4 37779.5 38038.7 -35784.2 36010.4 36490.4 37056.3 37545.3 37779.5 -35597.2 35782 36180.5 36651.6 37056.3 37246.4 -35371.4 35510.4 35816.7 36180.5 36490.4 36632.4 -35185.4 35283.8 35510.4 35782 36010.4 36110.2 -35109.7 35185.4 35371.4 35597.2 35784.2 35860.6 +35860.6 36110.2 36632.4 37246.4 37779.5 38038.7 +35784.2 36010.4 36490.4 37056.3 37545.3 37779.5 +35597.2 35782 36180.5 36651.6 37056.3 37246.4 +35371.4 35510.4 35816.7 36180.5 36490.4 36632.4 +35185.4 35283.8 35510.4 35782 36010.4 36110.2 +35109.7 35185.4 35371.4 35597.2 35784.2 35860.6 Species 5 -35860.6 36110.2 36632.4 37246.4 37779.5 38038.7 -35784.2 36010.4 36490.4 37056.3 37545.3 37779.5 -35597.2 35782 36180.5 36651.6 37056.3 37246.4 -35371.4 35510.4 35816.7 36180.5 36490.4 36632.4 -35185.4 35283.8 35510.4 35782 36010.4 36110.2 -35109.7 35185.4 35371.4 35597.2 35784.2 35860.6 +35860.6 36110.2 36632.4 37246.4 37779.5 38038.7 +35784.2 36010.4 36490.4 37056.3 37545.3 37779.5 +35597.2 35782 36180.5 36651.6 37056.3 37246.4 +35371.4 35510.4 35816.7 36180.5 36490.4 36632.4 +35185.4 35283.8 35510.4 35782 36010.4 36110.2 +35109.7 35185.4 35371.4 35597.2 35784.2 35860.6 Species 6 -35860.6 36110.2 36632.4 37246.4 37779.5 38038.7 -35784.2 36010.4 36490.4 37056.3 37545.3 37779.5 -35597.2 35782 36180.5 36651.6 37056.3 37246.4 -35371.4 35510.4 35816.7 36180.5 36490.4 36632.4 -35185.4 35283.8 35510.4 35782 36010.4 36110.2 -35109.7 35185.4 35371.4 35597.2 35784.2 35860.6 +35860.6 36110.2 36632.4 37246.4 37779.5 38038.7 +35784.2 36010.4 36490.4 37056.3 37545.3 37779.5 +35597.2 35782 36180.5 36651.6 37056.3 37246.4 +35371.4 35510.4 35816.7 36180.5 36490.4 36632.4 +35185.4 35283.8 35510.4 35782 36010.4 36110.2 +35109.7 35185.4 35371.4 35597.2 35784.2 35860.6 t = 5.00e+00 nst = 198 nfe = 0 nfi = 3179 nni = 2182 hu = 9.99e-02 @@ -311,52 +311,52 @@ t = 7.00e+00 nst = 216 nfe = 0 nfi = 3477 nni = 2375 hu = 1.51e-01 c values at t = 7: Species 1 -1.18854 1.19682 1.21415 1.23453 1.25221 1.26082 -1.186 1.19351 1.20944 1.22822 1.24444 1.25221 -1.1798 1.18593 1.19916 1.21479 1.22822 1.23453 -1.17231 1.17692 1.18708 1.19916 1.20944 1.21415 -1.16614 1.1694 1.17692 1.18593 1.19351 1.19682 -1.16363 1.16614 1.17231 1.1798 1.186 1.18854 +1.18854 1.19682 1.21415 1.23453 1.25221 1.26082 +1.186 1.19351 1.20944 1.22822 1.24444 1.25221 +1.1798 1.18593 1.19916 1.21479 1.22822 1.23453 +1.17231 1.17692 1.18708 1.19916 1.20944 1.21415 +1.16614 1.1694 1.17692 1.18593 1.19351 1.19682 +1.16363 1.16614 1.17231 1.1798 1.186 1.18854 Species 2 -1.18854 1.19683 1.21415 1.23453 1.25222 1.26082 -1.186 1.19351 1.20944 1.22822 1.24444 1.25222 -1.1798 1.18594 1.19916 1.21479 1.22822 1.23453 -1.17231 1.17692 1.18709 1.19916 1.20944 1.21415 -1.16614 1.1694 1.17692 1.18594 1.19351 1.19683 -1.16363 1.16614 1.17231 1.1798 1.186 1.18854 +1.18854 1.19683 1.21415 1.23453 1.25222 1.26082 +1.186 1.19351 1.20944 1.22822 1.24444 1.25222 +1.1798 1.18594 1.19916 1.21479 1.22822 1.23453 +1.17231 1.17692 1.18709 1.19916 1.20944 1.21415 +1.16614 1.1694 1.17692 1.18594 1.19351 1.19683 +1.16363 1.16614 1.17231 1.1798 1.186 1.18854 Species 3 -1.18854 1.19683 1.21416 1.23453 1.25222 1.26082 -1.18601 1.19351 1.20944 1.22822 1.24444 1.25222 -1.1798 1.18594 1.19916 1.21479 1.22822 1.23453 -1.17231 1.17692 1.18709 1.19916 1.20944 1.21416 -1.16614 1.1694 1.17692 1.18594 1.19351 1.19683 -1.16363 1.16614 1.17231 1.1798 1.18601 1.18854 +1.18854 1.19683 1.21416 1.23453 1.25222 1.26082 +1.18601 1.19351 1.20944 1.22822 1.24444 1.25222 +1.1798 1.18594 1.19916 1.21479 1.22822 1.23453 +1.17231 1.17692 1.18709 1.19916 1.20944 1.21416 +1.16614 1.1694 1.17692 1.18594 1.19351 1.19683 +1.16363 1.16614 1.17231 1.1798 1.18601 1.18854 Species 4 -35656.3 35903.1 36424.2 37033.8 37564.6 37822.3 -35578.4 35804.9 36281.3 36845.5 37330.9 37564.6 -35393.9 35575.9 35974.4 36441.4 36845.5 37033.8 -35167.5 35307.4 35610.6 35974.4 36281.3 36424.2 -34984.3 35080.2 35307.4 35575.9 35804.9 35903.1 -34907.5 34984.3 35167.5 35393.9 35578.4 35656.3 +35656.3 35903.1 36424.2 37033.8 37564.6 37822.3 +35578.4 35804.9 36281.3 36845.5 37330.9 37564.6 +35393.9 35575.9 35974.4 36441.4 36845.5 37033.8 +35167.5 35307.4 35610.6 35974.4 36281.3 36424.2 +34984.3 35080.2 35307.4 35575.9 35804.9 35903.1 +34907.5 34984.3 35167.5 35393.9 35578.4 35656.3 Species 5 -35656.3 35903.1 36424.2 37033.8 37564.6 37822.3 -35578.4 35804.9 36281.3 36845.5 37330.9 37564.6 -35393.9 35575.9 35974.4 36441.4 36845.5 37033.8 -35167.5 35307.4 35610.6 35974.4 36281.3 36424.2 -34984.3 35080.2 35307.4 35575.9 35804.9 35903.1 -34907.5 34984.3 35167.5 35393.9 35578.4 35656.3 +35656.3 35903.1 36424.2 37033.8 37564.6 37822.3 +35578.4 35804.9 36281.3 36845.5 37330.9 37564.6 +35393.9 35575.9 35974.4 36441.4 36845.5 37033.8 +35167.5 35307.4 35610.6 35974.4 36281.3 36424.2 +34984.3 35080.2 35307.4 35575.9 35804.9 35903.1 +34907.5 34984.3 35167.5 35393.9 35578.4 35656.3 Species 6 -35656.3 35903.1 36424.2 37033.8 37564.6 37822.3 -35578.4 35804.9 36281.3 36845.5 37330.9 37564.6 -35393.9 35575.9 35974.4 36441.4 36845.5 37033.8 -35167.5 35307.4 35610.6 35974.4 36281.3 36424.2 -34984.3 35080.2 35307.4 35575.9 35804.9 35903.1 -34907.5 34984.3 35167.5 35393.9 35578.4 35656.3 +35656.3 35903.1 36424.2 37033.8 37564.6 37822.3 +35578.4 35804.9 36281.3 36845.5 37330.9 37564.6 +35393.9 35575.9 35974.4 36441.4 36845.5 37033.8 +35167.5 35307.4 35610.6 35974.4 36281.3 36424.2 +34984.3 35080.2 35307.4 35575.9 35804.9 35903.1 +34907.5 34984.3 35167.5 35393.9 35578.4 35656.3 t = 8.00e+00 nst = 232 nfe = 0 nfi = 3780 nni = 2567 hu = 1.06e-01 @@ -367,75 +367,75 @@ t = 1.00e+01 nst = 266 nfe = 0 nfi = 4394 nni = 2941 hu = 8.37e-02 c values at t = 10: Species 1 -1.18838 1.19667 1.21399 1.23437 1.25205 1.26066 -1.18585 1.19335 1.20928 1.22805 1.24428 1.25205 -1.17964 1.18578 1.199 1.21463 1.22805 1.23437 -1.17215 1.17676 1.18693 1.199 1.20928 1.21399 -1.16598 1.16925 1.17676 1.18578 1.19335 1.19667 -1.16347 1.16598 1.17215 1.17964 1.18585 1.18838 +1.18838 1.19667 1.21399 1.23437 1.25205 1.26066 +1.18585 1.19335 1.20928 1.22805 1.24428 1.25205 +1.17964 1.18578 1.199 1.21463 1.22805 1.23437 +1.17215 1.17676 1.18693 1.199 1.20928 1.21399 +1.16598 1.16925 1.17676 1.18578 1.19335 1.19667 +1.16347 1.16598 1.17215 1.17964 1.18585 1.18838 Species 2 -1.18838 1.19667 1.21399 1.23437 1.25205 1.26066 -1.18585 1.19335 1.20928 1.22805 1.24428 1.25205 -1.17964 1.18578 1.199 1.21463 1.22805 1.23437 -1.17215 1.17676 1.18693 1.199 1.20928 1.21399 -1.16598 1.16925 1.17676 1.18578 1.19335 1.19667 -1.16347 1.16598 1.17215 1.17964 1.18585 1.18838 +1.18838 1.19667 1.21399 1.23437 1.25205 1.26066 +1.18585 1.19335 1.20928 1.22805 1.24428 1.25205 +1.17964 1.18578 1.199 1.21463 1.22805 1.23437 +1.17215 1.17676 1.18693 1.199 1.20928 1.21399 +1.16598 1.16925 1.17676 1.18578 1.19335 1.19667 +1.16347 1.16598 1.17215 1.17964 1.18585 1.18838 Species 3 -1.18838 1.19667 1.21399 1.23437 1.25205 1.26066 -1.18585 1.19335 1.20928 1.22805 1.24428 1.25205 -1.17964 1.18578 1.199 1.21463 1.22805 1.23437 -1.17215 1.17676 1.18693 1.199 1.20928 1.21399 -1.16598 1.16925 1.17676 1.18578 1.19335 1.19667 -1.16347 1.16598 1.17215 1.17964 1.18585 1.18838 +1.18838 1.19667 1.21399 1.23437 1.25205 1.26066 +1.18585 1.19335 1.20928 1.22805 1.24428 1.25205 +1.17964 1.18578 1.199 1.21463 1.22805 1.23437 +1.17215 1.17676 1.18693 1.199 1.20928 1.21399 +1.16598 1.16925 1.17676 1.18578 1.19335 1.19667 +1.16347 1.16598 1.17215 1.17964 1.18585 1.18838 Species 4 -35650.6 35898.8 36418.4 37029.2 37559.5 37817.3 -35574.5 35799.5 36277.1 36840 37326.6 37559.5 -35388.4 35572.3 35968.8 36437.5 36840 37029.2 -35163.7 35302 35606.7 35968.8 36277.1 36418.4 -34978.6 35076.5 35302 35572.3 35799.5 35898.8 -34903.3 34978.6 35163.7 35388.4 35574.5 35650.6 +35650.6 35898.8 36418.4 37029.2 37559.5 37817.3 +35574.5 35799.5 36277.1 36840 37326.6 37559.5 +35388.4 35572.3 35968.8 36437.5 36840 37029.2 +35163.7 35302 35606.7 35968.8 36277.1 36418.4 +34978.6 35076.5 35302 35572.3 35799.5 35898.8 +34903.3 34978.6 35163.7 35388.4 35574.5 35650.6 Species 5 -35650.6 35898.8 36418.4 37029.2 37559.5 37817.3 -35574.5 35799.5 36277.1 36840 37326.6 37559.5 -35388.4 35572.3 35968.8 36437.5 36840 37029.2 -35163.7 35302 35606.7 35968.8 36277.1 36418.4 -34978.6 35076.5 35302 35572.3 35799.5 35898.8 -34903.3 34978.6 35163.7 35388.4 35574.5 35650.6 +35650.6 35898.8 36418.4 37029.2 37559.5 37817.3 +35574.5 35799.5 36277.1 36840 37326.6 37559.5 +35388.4 35572.3 35968.8 36437.5 36840 37029.2 +35163.7 35302 35606.7 35968.8 36277.1 36418.4 +34978.6 35076.5 35302 35572.3 35799.5 35898.8 +34903.3 34978.6 35163.7 35388.4 35574.5 35650.6 Species 6 -35650.6 35898.8 36418.4 37029.2 37559.5 37817.3 -35574.5 35799.5 36277.1 36840 37326.6 37559.5 -35388.4 35572.3 35968.8 36437.5 36840 37029.2 -35163.7 35302 35606.7 35968.8 36277.1 36418.4 -34978.6 35076.5 35302 35572.3 35799.5 35898.8 -34903.3 34978.6 35163.7 35388.4 35574.5 35650.6 +35650.6 35898.8 36418.4 37029.2 37559.5 37817.3 +35574.5 35799.5 36277.1 36840 37326.6 37559.5 +35388.4 35572.3 35968.8 36437.5 36840 37029.2 +35163.7 35302 35606.7 35968.8 36277.1 36418.4 +34978.6 35076.5 35302 35572.3 35799.5 35898.8 +34903.3 34978.6 35163.7 35388.4 35574.5 35650.6 Final statistics for this run: - ARKStep real workspace length = 3554 - ARKStep integer workspace length = 131 - ARKLS real workspace length = 2647 - ARKLS integer workspace length = 42 - Number of steps = 266 - Number of f-s (explicit) = 0 - Number of f-s (implicit) = 4394 - Number of f-s (SPGMR) = 8980 - Number of f-s (TOTAL) = 8980 - Number of setups = 121 - Number of nonlinear iterations = 2941 - Number of linear iterations = 8980 - Number of preconditioner evaluations = 121 - Number of preconditioner solves = 11819 - Number of error test failures = 23 - Number of nonlinear conv. failures = 17 - Number of linear convergence failures = 509 - Average Krylov subspace dimension = 3.053 + ARKStep real workspace length = 3554 + ARKStep integer workspace length = 131 + ARKLS real workspace length = 2647 + ARKLS integer workspace length = 42 + Number of steps = 266 + Number of f-s (explicit) = 0 + Number of f-s (implicit) = 4394 + Number of f-s (SPGMR) = 8980 + Number of f-s (TOTAL) = 8980 + Number of setups = 121 + Number of nonlinear iterations = 2941 + Number of linear iterations = 8980 + Number of preconditioner evaluations = 121 + Number of preconditioner solves = 11819 + Number of error test failures = 23 + Number of nonlinear conv. failures = 17 + Number of linear convergence failures = 509 + Average Krylov subspace dimension = 3.053 ---------------------------------------------------------------------------- @@ -487,24 +487,24 @@ t = 1.00e+01 nst = 251 nfe = 0 nfi = 4101 nni = 2746 hu = 7.09e-02 Final statistics for this run: - ARKStep real workspace length = 3554 - ARKStep integer workspace length = 131 - ARKLS real workspace length = 2647 - ARKLS integer workspace length = 42 - Number of steps = 251 - Number of f-s (explicit) = 0 - Number of f-s (implicit) = 4101 - Number of f-s (SPGMR) = 8880 - Number of f-s (TOTAL) = 8880 - Number of setups = 91 - Number of nonlinear iterations = 2746 - Number of linear iterations = 8880 - Number of preconditioner evaluations = 91 - Number of preconditioner solves = 11537 - Number of error test failures = 18 - Number of nonlinear conv. failures = 13 - Number of linear convergence failures = 597 - Average Krylov subspace dimension = 3.234 + ARKStep real workspace length = 3554 + ARKStep integer workspace length = 136 + ARKLS real workspace length = 2647 + ARKLS integer workspace length = 42 + Number of steps = 251 + Number of f-s (explicit) = 0 + Number of f-s (implicit) = 4101 + Number of f-s (SPGMR) = 8880 + Number of f-s (TOTAL) = 8880 + Number of setups = 91 + Number of nonlinear iterations = 2746 + Number of linear iterations = 8880 + Number of preconditioner evaluations = 91 + Number of preconditioner solves = 11537 + Number of error test failures = 18 + Number of nonlinear conv. failures = 13 + Number of linear convergence failures = 597 + Average Krylov subspace dimension = 3.234 ---------------------------------------------------------------------------- @@ -556,24 +556,24 @@ t = 1.00e+01 nst = 359 nfe = 0 nfi = 5722 nni = 3907 hu = 1.35e-01 Final statistics for this run: - ARKStep real workspace length = 3554 - ARKStep integer workspace length = 131 - ARKLS real workspace length = 2647 - ARKLS integer workspace length = 42 - Number of steps = 359 - Number of f-s (explicit) = 0 - Number of f-s (implicit) = 5722 - Number of f-s (SPGMR) = 12904 - Number of f-s (TOTAL) = 12904 - Number of setups = 253 - Number of nonlinear iterations = 3907 - Number of linear iterations = 12904 - Number of preconditioner evaluations = 253 - Number of preconditioner solves = 16594 - Number of error test failures = 0 - Number of nonlinear conv. failures = 117 - Number of linear convergence failures = 1072 - Average Krylov subspace dimension = 3.303 + ARKStep real workspace length = 3554 + ARKStep integer workspace length = 141 + ARKLS real workspace length = 2647 + ARKLS integer workspace length = 42 + Number of steps = 359 + Number of f-s (explicit) = 0 + Number of f-s (implicit) = 5722 + Number of f-s (SPGMR) = 12904 + Number of f-s (TOTAL) = 12904 + Number of setups = 253 + Number of nonlinear iterations = 3907 + Number of linear iterations = 12904 + Number of preconditioner evaluations = 253 + Number of preconditioner solves = 16594 + Number of error test failures = 0 + Number of nonlinear conv. failures = 117 + Number of linear convergence failures = 1072 + Average Krylov subspace dimension = 3.303 ---------------------------------------------------------------------------- @@ -625,24 +625,24 @@ t = 1.00e+01 nst = 359 nfe = 0 nfi = 5728 nni = 3912 hu = 1.31e-01 Final statistics for this run: - ARKStep real workspace length = 3554 - ARKStep integer workspace length = 131 - ARKLS real workspace length = 2647 - ARKLS integer workspace length = 42 - Number of steps = 359 - Number of f-s (explicit) = 0 - Number of f-s (implicit) = 5728 - Number of f-s (SPGMR) = 12934 - Number of f-s (TOTAL) = 12934 - Number of setups = 254 - Number of nonlinear iterations = 3912 - Number of linear iterations = 12934 - Number of preconditioner evaluations = 254 - Number of preconditioner solves = 16627 - Number of error test failures = 0 - Number of nonlinear conv. failures = 118 - Number of linear convergence failures = 1076 - Average Krylov subspace dimension = 3.306 + ARKStep real workspace length = 3554 + ARKStep integer workspace length = 146 + ARKLS real workspace length = 2647 + ARKLS integer workspace length = 42 + Number of steps = 359 + Number of f-s (explicit) = 0 + Number of f-s (implicit) = 5728 + Number of f-s (SPGMR) = 12934 + Number of f-s (TOTAL) = 12934 + Number of setups = 254 + Number of nonlinear iterations = 3912 + Number of linear iterations = 12934 + Number of preconditioner evaluations = 254 + Number of preconditioner solves = 16627 + Number of error test failures = 0 + Number of nonlinear conv. failures = 118 + Number of linear convergence failures = 1076 + Average Krylov subspace dimension = 3.306 ---------------------------------------------------------------------------- diff --git a/examples/arkode/C_serial/ark_KrylovDemo_prec_1.out b/examples/arkode/C_serial/ark_KrylovDemo_prec_1.out index 09364ad394..a2564a38ee 100644 --- a/examples/arkode/C_serial/ark_KrylovDemo_prec_1.out +++ b/examples/arkode/C_serial/ark_KrylovDemo_prec_1.out @@ -10,9 +10,9 @@ b parameter = 1 Diffusion coefficients: Dprey = 1 Dpred = 0.5 Rate parameter alpha = 1 -Mesh dimensions (mx,my) are 6, 6. Total system size is neq = 216 +Mesh dimensions (mx,my) are 6, 6. Total system size is neq = 216 -Tolerances: reltol = 1e-05, abstol = 1e-05 +Tolerances: reltol = 1e-05, abstol = 1e-05 Preconditioning uses a product of: (1) Gauss-Seidel iterations with itmax = 5 iterations, and @@ -31,52 +31,52 @@ Gram-Schmidt method type is gstype = SUN_MODIFIED_GS c values at t = 0: Species 1 -10 10 10 10 10 10 -10 10.1678 10.3775 10.3775 10.1678 10 -10 10.3775 10.8493 10.8493 10.3775 10 -10 10.3775 10.8493 10.8493 10.3775 10 -10 10.1678 10.3775 10.3775 10.1678 10 -10 10 10 10 10 10 +10 10 10 10 10 10 +10 10.1678 10.3775 10.3775 10.1678 10 +10 10.3775 10.8493 10.8493 10.3775 10 +10 10.3775 10.8493 10.8493 10.3775 10 +10 10.1678 10.3775 10.3775 10.1678 10 +10 10 10 10 10 10 Species 2 -10 10 10 10 10 10 -10 10.3355 10.755 10.755 10.3355 10 -10 10.755 11.6987 11.6987 10.755 10 -10 10.755 11.6987 11.6987 10.755 10 -10 10.3355 10.755 10.755 10.3355 10 -10 10 10 10 10 10 +10 10 10 10 10 10 +10 10.3355 10.755 10.755 10.3355 10 +10 10.755 11.6987 11.6987 10.755 10 +10 10.755 11.6987 11.6987 10.755 10 +10 10.3355 10.755 10.755 10.3355 10 +10 10 10 10 10 10 Species 3 -10 10 10 10 10 10 -10 10.5033 11.1325 11.1325 10.5033 10 -10 11.1325 12.548 12.548 11.1325 10 -10 11.1325 12.548 12.548 11.1325 10 -10 10.5033 11.1325 11.1325 10.5033 10 -10 10 10 10 10 10 +10 10 10 10 10 10 +10 10.5033 11.1325 11.1325 10.5033 10 +10 11.1325 12.548 12.548 11.1325 10 +10 11.1325 12.548 12.548 11.1325 10 +10 10.5033 11.1325 11.1325 10.5033 10 +10 10 10 10 10 10 Species 4 -10 10 10 10 10 10 -10 10.6711 11.5099 11.5099 10.6711 10 -10 11.5099 13.3974 13.3974 11.5099 10 -10 11.5099 13.3974 13.3974 11.5099 10 -10 10.6711 11.5099 11.5099 10.6711 10 -10 10 10 10 10 10 +10 10 10 10 10 10 +10 10.6711 11.5099 11.5099 10.6711 10 +10 11.5099 13.3974 13.3974 11.5099 10 +10 11.5099 13.3974 13.3974 11.5099 10 +10 10.6711 11.5099 11.5099 10.6711 10 +10 10 10 10 10 10 Species 5 -10 10 10 10 10 10 -10 10.8389 11.8874 11.8874 10.8389 10 -10 11.8874 14.2467 14.2467 11.8874 10 -10 11.8874 14.2467 14.2467 11.8874 10 -10 10.8389 11.8874 11.8874 10.8389 10 -10 10 10 10 10 10 +10 10 10 10 10 10 +10 10.8389 11.8874 11.8874 10.8389 10 +10 11.8874 14.2467 14.2467 11.8874 10 +10 11.8874 14.2467 14.2467 11.8874 10 +10 10.8389 11.8874 11.8874 10.8389 10 +10 10 10 10 10 10 Species 6 -10 10 10 10 10 10 -10 11.0066 12.2649 12.2649 11.0066 10 -10 12.2649 15.0961 15.0961 12.2649 10 -10 12.2649 15.0961 15.0961 12.2649 10 -10 11.0066 12.2649 12.2649 11.0066 10 -10 10 10 10 10 10 +10 10 10 10 10 10 +10 11.0066 12.2649 12.2649 11.0066 10 +10 12.2649 15.0961 15.0961 12.2649 10 +10 12.2649 15.0961 15.0961 12.2649 10 +10 11.0066 12.2649 12.2649 11.0066 10 +10 10 10 10 10 10 t = 1.00e-08 nst = 5 nfe = 0 nfi = 75 nni = 47 hu = 9.89e-08 @@ -87,52 +87,52 @@ t = 1.00e-06 nst = 8 nfe = 0 nfi = 120 nni = 77 hu = 4.79e-07 c values at t = 1e-06: Species 1 -9.99991 9.99992 9.99993 9.99993 9.99993 9.99992 -9.99992 10.1677 10.3774 10.3774 10.1677 9.99993 -9.99993 10.3774 10.8492 10.8492 10.3774 9.99993 -9.99993 10.3774 10.8492 10.8492 10.3774 9.99993 -9.99992 10.1677 10.3774 10.3774 10.1677 9.99992 -9.99991 9.99992 9.99993 9.99993 9.99992 9.99991 +9.99991 9.99992 9.99993 9.99993 9.99993 9.99992 +9.99992 10.1677 10.3774 10.3774 10.1677 9.99993 +9.99993 10.3774 10.8492 10.8492 10.3774 9.99993 +9.99993 10.3774 10.8492 10.8492 10.3774 9.99993 +9.99992 10.1677 10.3774 10.3774 10.1677 9.99992 +9.99991 9.99992 9.99993 9.99993 9.99992 9.99991 Species 2 -9.99991 9.99993 9.99995 9.99995 9.99993 9.99992 -9.99993 10.3355 10.7549 10.7549 10.3355 9.99993 -9.99995 10.7549 11.6985 11.6985 10.7549 9.99995 -9.99995 10.7549 11.6985 11.6985 10.7549 9.99995 -9.99993 10.3355 10.7549 10.7549 10.3355 9.99993 -9.99991 9.99993 9.99995 9.99995 9.99993 9.99991 +9.99991 9.99993 9.99995 9.99995 9.99993 9.99992 +9.99993 10.3355 10.7549 10.7549 10.3355 9.99993 +9.99995 10.7549 11.6985 11.6985 10.7549 9.99995 +9.99995 10.7549 11.6985 11.6985 10.7549 9.99995 +9.99993 10.3355 10.7549 10.7549 10.3355 9.99993 +9.99991 9.99993 9.99995 9.99995 9.99993 9.99991 Species 3 -9.99991 9.99994 9.99997 9.99997 9.99994 9.99992 -9.99994 10.5032 11.1323 11.1323 10.5032 9.99994 -9.99997 11.1323 12.5478 12.5478 11.1323 9.99997 -9.99997 11.1323 12.5478 12.5478 11.1323 9.99997 -9.99994 10.5032 11.1323 11.1323 10.5032 9.99994 -9.99991 9.99994 9.99997 9.99997 9.99994 9.99991 +9.99991 9.99994 9.99997 9.99997 9.99994 9.99992 +9.99994 10.5032 11.1323 11.1323 10.5032 9.99994 +9.99997 11.1323 12.5478 12.5478 11.1323 9.99997 +9.99997 11.1323 12.5478 12.5478 11.1323 9.99997 +9.99994 10.5032 11.1323 11.1323 10.5032 9.99994 +9.99991 9.99994 9.99997 9.99997 9.99994 9.99991 Species 4 -13.4984 13.4984 13.4984 13.4984 13.4984 13.4984 -13.4984 14.55 15.8924 15.8924 14.55 13.4984 -13.4984 15.8924 19.0296 19.0296 15.8924 13.4984 -13.4984 15.8924 19.0296 19.0296 15.8924 13.4984 -13.4984 14.55 15.8924 15.8924 14.55 13.4984 -13.4984 13.4984 13.4984 13.4984 13.4984 13.4984 +13.4984 13.4984 13.4984 13.4984 13.4984 13.4984 +13.4984 14.55 15.8924 15.8924 14.55 13.4984 +13.4984 15.8924 19.0296 19.0296 15.8924 13.4984 +13.4984 15.8924 19.0296 19.0296 15.8924 13.4984 +13.4984 14.55 15.8924 15.8924 14.55 13.4984 +13.4984 13.4984 13.4984 13.4984 13.4984 13.4984 Species 5 -13.4984 13.4984 13.4985 13.4985 13.4984 13.4984 -13.4984 14.7787 16.4136 16.4136 14.7787 13.4984 -13.4985 16.4136 20.236 20.236 16.4136 13.4985 -13.4985 16.4136 20.236 20.236 16.4136 13.4985 -13.4984 14.7787 16.4136 16.4136 14.7787 13.4984 -13.4984 13.4984 13.4985 13.4985 13.4984 13.4984 +13.4984 13.4984 13.4985 13.4985 13.4984 13.4984 +13.4984 14.7787 16.4136 16.4136 14.7787 13.4984 +13.4985 16.4136 20.236 20.236 16.4136 13.4985 +13.4985 16.4136 20.236 20.236 16.4136 13.4985 +13.4984 14.7787 16.4136 16.4136 14.7787 13.4984 +13.4984 13.4984 13.4985 13.4985 13.4984 13.4984 Species 6 -13.4984 13.4984 13.4985 13.4985 13.4984 13.4984 -13.4984 15.0075 16.9348 16.9348 15.0075 13.4984 -13.4985 16.9348 21.4423 21.4423 16.9348 13.4985 -13.4985 16.9348 21.4423 21.4423 16.9348 13.4985 -13.4984 15.0075 16.9348 16.9348 15.0075 13.4984 -13.4984 13.4984 13.4985 13.4985 13.4984 13.4984 +13.4984 13.4984 13.4985 13.4985 13.4984 13.4984 +13.4984 15.0075 16.9348 16.9348 15.0075 13.4984 +13.4985 16.9348 21.4423 21.4423 16.9348 13.4985 +13.4985 16.9348 21.4423 21.4423 16.9348 13.4985 +13.4984 15.0075 16.9348 16.9348 15.0075 13.4984 +13.4984 13.4984 13.4985 13.4985 13.4984 13.4984 t = 1.00e-05 nst = 27 nfe = 0 nfi = 407 nni = 269 hu = 4.79e-07 @@ -143,52 +143,52 @@ t = 1.00e-03 nst = 110 nfe = 0 nfi = 1750 nni = 1197 hu = 1.51e-03 c values at t = 0.001: Species 1 -9.90702 9.91664 9.92836 9.93033 9.92253 9.91674 -9.91472 10.0747 10.2769 10.2785 10.0795 9.92253 -9.92446 10.2748 10.7181 10.7194 10.2785 9.93033 -9.92445 10.2744 10.7173 10.7181 10.2769 9.92836 -9.91469 10.0734 10.2744 10.2748 10.0747 9.91664 -9.90698 9.91469 9.92445 9.92446 9.91472 9.90702 +9.90702 9.91664 9.92836 9.93033 9.92253 9.91674 +9.91472 10.0747 10.2769 10.2785 10.0795 9.92253 +9.92446 10.2748 10.7181 10.7194 10.2785 9.93033 +9.92445 10.2744 10.7173 10.7181 10.2769 9.92836 +9.91469 10.0734 10.2744 10.2748 10.0747 9.91664 +9.90698 9.91469 9.92445 9.92446 9.91472 9.90702 Species 2 -9.90742 9.92474 9.94622 9.94819 9.93064 9.91713 -9.92282 10.2412 10.644 10.6457 10.2461 9.93064 -9.94232 10.6419 11.5267 11.5281 10.6457 9.94819 -9.94231 10.6415 11.5258 11.5267 10.644 9.94622 -9.92279 10.24 10.6415 10.6419 10.2412 9.92474 -9.90737 9.92279 9.94231 9.94232 9.92282 9.90742 +9.90742 9.92474 9.94622 9.94819 9.93064 9.91713 +9.92282 10.2412 10.644 10.6457 10.2461 9.93064 +9.94232 10.6419 11.5267 11.5281 10.6457 9.94819 +9.94231 10.6415 11.5258 11.5267 10.644 9.94622 +9.92279 10.24 10.6415 10.6419 10.2412 9.92474 +9.90737 9.92279 9.94231 9.94232 9.92282 9.90742 Species 3 -9.90781 9.93284 9.96408 9.96605 9.93874 9.91753 -9.93092 10.4078 11.0109 11.0127 10.4127 9.93874 -9.96017 11.0088 12.3339 12.3354 11.0127 9.96605 -9.96016 11.0083 12.333 12.3339 11.0109 9.96408 -9.93088 10.4065 11.0083 11.0088 10.4078 9.93284 -9.90776 9.93088 9.96016 9.96017 9.93092 9.90781 +9.90781 9.93284 9.96408 9.96605 9.93874 9.91753 +9.93092 10.4078 11.0109 11.0127 10.4127 9.93874 +9.96017 11.0088 12.3339 12.3354 11.0127 9.96605 +9.96016 11.0083 12.333 12.3339 11.0109 9.96408 +9.93088 10.4065 11.0083 11.0088 10.4078 9.93284 +9.90776 9.93088 9.96016 9.96017 9.93092 9.90781 Species 4 -297231 297749 298392 298451 297925 297520 -297692 307245 319327 319378 307390 297925 -298276 319264 345799 345840 319378 298451 -298276 319252 345772 345799 319327 298392 -297691 307208 319252 319264 307245 297749 -297229 297691 298276 298276 297692 297231 +297231 297749 298392 298451 297925 297520 +297692 307245 319327 319378 307390 297925 +298276 319264 345799 345840 319378 298451 +298276 319252 345772 345799 319327 298392 +297691 307208 319252 319264 307245 297749 +297229 297691 298276 298276 297692 297231 Species 5 -297231 297749 298392 298451 297925 297520 -297692 307245 319327 319378 307390 297925 -298276 319264 345799 345840 319378 298451 -298276 319252 345772 345799 319327 298392 -297691 307208 319252 319264 307245 297749 -297229 297691 298276 298276 297692 297231 +297231 297749 298392 298451 297925 297520 +297692 307245 319327 319378 307390 297925 +298276 319264 345799 345840 319378 298451 +298276 319252 345772 345799 319327 298392 +297691 307208 319252 319264 307245 297749 +297229 297691 298276 298276 297692 297231 Species 6 -297231 297749 298392 298451 297925 297520 -297692 307245 319327 319378 307390 297925 -298276 319264 345799 345840 319378 298451 -298276 319252 345772 345799 319327 298392 -297691 307208 319252 319264 307245 297749 -297229 297691 298276 298276 297692 297231 +297231 297749 298392 298451 297925 297520 +297692 307245 319327 319378 307390 297925 +298276 319264 345799 345840 319378 298451 +298276 319252 345772 345799 319327 298392 +297691 307208 319252 319264 307245 297749 +297229 297691 298276 298276 297692 297231 t = 1.00e-02 nst = 113 nfe = 0 nfi = 1797 nni = 1229 hu = 3.46e-03 @@ -199,52 +199,52 @@ t = 1.00e+00 nst = 154 nfe = 0 nfi = 2489 nni = 1716 hu = 6.84e-02 c values at t = 1: Species 1 -1.58851 1.59924 1.62152 1.64764 1.67036 1.68149 -1.58533 1.59503 1.61548 1.63952 1.66033 1.67036 -1.57757 1.58547 1.60239 1.62235 1.63952 1.64764 -1.5682 1.57412 1.58706 1.60239 1.61548 1.62152 -1.56048 1.56463 1.57412 1.58547 1.59503 1.59924 -1.55733 1.56048 1.5682 1.57757 1.58533 1.58851 +1.58851 1.59924 1.62152 1.64764 1.67036 1.68149 +1.58533 1.59503 1.61548 1.63952 1.66033 1.67036 +1.57757 1.58547 1.60239 1.62235 1.63952 1.64764 +1.5682 1.57412 1.58706 1.60239 1.61548 1.62152 +1.56048 1.56463 1.57412 1.58547 1.59503 1.59924 +1.55733 1.56048 1.5682 1.57757 1.58533 1.58851 Species 2 -1.59067 1.60141 1.62371 1.64987 1.67261 1.68375 -1.58748 1.5972 1.61766 1.64173 1.66257 1.67261 -1.57971 1.58763 1.60457 1.62454 1.64173 1.64987 -1.57034 1.57626 1.58921 1.60457 1.61766 1.62371 -1.56261 1.56676 1.57626 1.58763 1.5972 1.60141 -1.55945 1.56261 1.57034 1.57971 1.58748 1.59067 +1.59067 1.60141 1.62371 1.64987 1.67261 1.68375 +1.58748 1.5972 1.61766 1.64173 1.66257 1.67261 +1.57971 1.58763 1.60457 1.62454 1.64173 1.64987 +1.57034 1.57626 1.58921 1.60457 1.61766 1.62371 +1.56261 1.56676 1.57626 1.58763 1.5972 1.60141 +1.55945 1.56261 1.57034 1.57971 1.58748 1.59067 Species 3 -1.5927 1.60346 1.62578 1.65197 1.67474 1.68589 -1.58951 1.59924 1.61973 1.64383 1.66468 1.67474 -1.58174 1.58966 1.60662 1.62662 1.64383 1.65197 -1.57236 1.57828 1.59125 1.60662 1.61973 1.62578 -1.56462 1.56878 1.57828 1.58966 1.59924 1.60346 -1.56146 1.56462 1.57236 1.58174 1.58951 1.5927 +1.5927 1.60346 1.62578 1.65197 1.67474 1.68589 +1.58951 1.59924 1.61973 1.64383 1.66468 1.67474 +1.58174 1.58966 1.60662 1.62662 1.64383 1.65197 +1.57236 1.57828 1.59125 1.60662 1.61973 1.62578 +1.56462 1.56878 1.57828 1.58966 1.59924 1.60346 +1.56146 1.56462 1.57236 1.58174 1.58951 1.5927 Species 4 -47718.3 48040.3 48709 49493.5 50175.5 50509.4 -47622.8 47914 48527.8 49249.6 49874.4 50175.5 -47389.7 47627 48134.9 48734.2 49249.6 49493.5 -47108.5 47286 47674.6 48134.9 48527.8 48709 -46876.6 47001.2 47286 47627 47914 48040.3 -46781.9 46876.6 47108.5 47389.7 47622.8 47718.3 +47718.3 48040.3 48709 49493.5 50175.5 50509.4 +47622.8 47914 48527.8 49249.6 49874.4 50175.5 +47389.7 47627 48134.9 48734.2 49249.6 49493.5 +47108.5 47286 47674.6 48134.9 48527.8 48709 +46876.6 47001.2 47286 47627 47914 48040.3 +46781.9 46876.6 47108.5 47389.7 47622.8 47718.3 Species 5 -47718.3 48040.3 48709 49493.5 50175.5 50509.4 -47622.8 47914 48527.8 49249.6 49874.4 50175.5 -47389.7 47627 48134.9 48734.2 49249.6 49493.5 -47108.5 47286 47674.6 48134.9 48527.8 48709 -46876.6 47001.2 47286 47627 47914 48040.3 -46781.9 46876.6 47108.5 47389.7 47622.8 47718.3 +47718.3 48040.3 48709 49493.5 50175.5 50509.4 +47622.8 47914 48527.8 49249.6 49874.4 50175.5 +47389.7 47627 48134.9 48734.2 49249.6 49493.5 +47108.5 47286 47674.6 48134.9 48527.8 48709 +46876.6 47001.2 47286 47627 47914 48040.3 +46781.9 46876.6 47108.5 47389.7 47622.8 47718.3 Species 6 -47718.3 48040.3 48709 49493.5 50175.5 50509.4 -47622.8 47914 48527.8 49249.6 49874.4 50175.5 -47389.7 47627 48134.9 48734.2 49249.6 49493.5 -47108.5 47286 47674.6 48134.9 48527.8 48709 -46876.6 47001.2 47286 47627 47914 48040.3 -46781.9 46876.6 47108.5 47389.7 47622.8 47718.3 +47718.3 48040.3 48709 49493.5 50175.5 50509.4 +47622.8 47914 48527.8 49249.6 49874.4 50175.5 +47389.7 47627 48134.9 48734.2 49249.6 49493.5 +47108.5 47286 47674.6 48134.9 48527.8 48709 +46876.6 47001.2 47286 47627 47914 48040.3 +46781.9 46876.6 47108.5 47389.7 47622.8 47718.3 t = 2.00e+00 nst = 165 nfe = 0 nfi = 2661 nni = 1833 hu = 4.14e-02 @@ -255,52 +255,52 @@ t = 4.00e+00 nst = 187 nfe = 0 nfi = 3013 nni = 2073 hu = 1.23e-01 c values at t = 4: Species 1 -1.19535 1.20368 1.2211 1.24157 1.25935 1.268 -1.1928 1.20035 1.21636 1.23523 1.25154 1.25935 -1.18657 1.19274 1.20602 1.22173 1.23523 1.24157 -1.17904 1.18368 1.19389 1.20602 1.21636 1.2211 -1.17284 1.17613 1.18368 1.19274 1.20035 1.20368 -1.17032 1.17284 1.17904 1.18657 1.1928 1.19535 +1.19535 1.20368 1.2211 1.24157 1.25935 1.268 +1.1928 1.20035 1.21636 1.23523 1.25154 1.25935 +1.18657 1.19274 1.20602 1.22173 1.23523 1.24157 +1.17904 1.18368 1.19389 1.20602 1.21636 1.2211 +1.17284 1.17613 1.18368 1.19274 1.20035 1.20368 +1.17032 1.17284 1.17904 1.18657 1.1928 1.19535 Species 2 -1.19538 1.20371 1.22113 1.24161 1.25938 1.26804 -1.19284 1.20038 1.21639 1.23526 1.25157 1.25938 -1.1866 1.19277 1.20606 1.22177 1.23526 1.24161 -1.17908 1.18371 1.19393 1.20606 1.21639 1.22113 -1.17288 1.17616 1.18371 1.19277 1.20038 1.20371 -1.17035 1.17288 1.17908 1.1866 1.19284 1.19538 +1.19538 1.20371 1.22113 1.24161 1.25938 1.26804 +1.19284 1.20038 1.21639 1.23526 1.25157 1.25938 +1.1866 1.19277 1.20606 1.22177 1.23526 1.24161 +1.17908 1.18371 1.19393 1.20606 1.21639 1.22113 +1.17288 1.17616 1.18371 1.19277 1.20038 1.20371 +1.17035 1.17288 1.17908 1.1866 1.19284 1.19538 Species 3 -1.19542 1.20374 1.22116 1.24164 1.25942 1.26807 -1.19287 1.20042 1.21642 1.2353 1.2516 1.25942 -1.18663 1.1928 1.20609 1.2218 1.2353 1.24164 -1.17911 1.18374 1.19396 1.20609 1.21642 1.22116 -1.17291 1.17619 1.18374 1.1928 1.20042 1.20374 -1.17039 1.17291 1.17911 1.18663 1.19287 1.19542 +1.19542 1.20374 1.22116 1.24164 1.25942 1.26807 +1.19287 1.20042 1.21642 1.2353 1.2516 1.25942 +1.18663 1.1928 1.20609 1.2218 1.2353 1.24164 +1.17911 1.18374 1.19396 1.20609 1.21642 1.22116 +1.17291 1.17619 1.18374 1.1928 1.20042 1.20374 +1.17039 1.17291 1.17911 1.18663 1.19287 1.19542 Species 4 -35860.6 36110.2 36632.4 37246.4 37779.5 38038.7 -35784.2 36010.4 36490.4 37056.3 37545.3 37779.5 -35597.2 35782 36180.5 36651.6 37056.3 37246.4 -35371.4 35510.4 35816.7 36180.5 36490.4 36632.4 -35185.4 35283.8 35510.4 35782 36010.4 36110.2 -35109.7 35185.4 35371.4 35597.2 35784.2 35860.6 +35860.6 36110.2 36632.4 37246.4 37779.5 38038.7 +35784.2 36010.4 36490.4 37056.3 37545.3 37779.5 +35597.2 35782 36180.5 36651.6 37056.3 37246.4 +35371.4 35510.4 35816.7 36180.5 36490.4 36632.4 +35185.4 35283.8 35510.4 35782 36010.4 36110.2 +35109.7 35185.4 35371.4 35597.2 35784.2 35860.6 Species 5 -35860.6 36110.2 36632.4 37246.4 37779.5 38038.7 -35784.2 36010.4 36490.4 37056.3 37545.3 37779.5 -35597.2 35782 36180.5 36651.6 37056.3 37246.4 -35371.4 35510.4 35816.7 36180.5 36490.4 36632.4 -35185.4 35283.8 35510.4 35782 36010.4 36110.2 -35109.7 35185.4 35371.4 35597.2 35784.2 35860.6 +35860.6 36110.2 36632.4 37246.4 37779.5 38038.7 +35784.2 36010.4 36490.4 37056.3 37545.3 37779.5 +35597.2 35782 36180.5 36651.6 37056.3 37246.4 +35371.4 35510.4 35816.7 36180.5 36490.4 36632.4 +35185.4 35283.8 35510.4 35782 36010.4 36110.2 +35109.7 35185.4 35371.4 35597.2 35784.2 35860.6 Species 6 -35860.6 36110.2 36632.4 37246.4 37779.5 38038.7 -35784.2 36010.4 36490.4 37056.3 37545.3 37779.5 -35597.2 35782 36180.5 36651.6 37056.3 37246.4 -35371.4 35510.4 35816.7 36180.5 36490.4 36632.4 -35185.4 35283.8 35510.4 35782 36010.4 36110.2 -35109.7 35185.4 35371.4 35597.2 35784.2 35860.6 +35860.6 36110.2 36632.4 37246.4 37779.5 38038.7 +35784.2 36010.4 36490.4 37056.3 37545.3 37779.5 +35597.2 35782 36180.5 36651.6 37056.3 37246.4 +35371.4 35510.4 35816.7 36180.5 36490.4 36632.4 +35185.4 35283.8 35510.4 35782 36010.4 36110.2 +35109.7 35185.4 35371.4 35597.2 35784.2 35860.6 t = 5.00e+00 nst = 198 nfe = 0 nfi = 3179 nni = 2182 hu = 9.99e-02 @@ -311,52 +311,52 @@ t = 7.00e+00 nst = 216 nfe = 0 nfi = 3477 nni = 2375 hu = 1.51e-01 c values at t = 7: Species 1 -1.18854 1.19682 1.21415 1.23453 1.25221 1.26082 -1.186 1.19351 1.20944 1.22822 1.24444 1.25221 -1.1798 1.18593 1.19916 1.21479 1.22822 1.23453 -1.17231 1.17692 1.18708 1.19916 1.20944 1.21415 -1.16614 1.1694 1.17692 1.18593 1.19351 1.19682 -1.16363 1.16614 1.17231 1.1798 1.186 1.18854 +1.18854 1.19682 1.21415 1.23453 1.25221 1.26082 +1.186 1.19351 1.20944 1.22822 1.24444 1.25221 +1.1798 1.18593 1.19916 1.21479 1.22822 1.23453 +1.17231 1.17692 1.18708 1.19916 1.20944 1.21415 +1.16614 1.1694 1.17692 1.18593 1.19351 1.19682 +1.16363 1.16614 1.17231 1.1798 1.186 1.18854 Species 2 -1.18854 1.19683 1.21415 1.23453 1.25222 1.26082 -1.186 1.19351 1.20944 1.22822 1.24444 1.25222 -1.1798 1.18594 1.19916 1.21479 1.22822 1.23453 -1.17231 1.17692 1.18709 1.19916 1.20944 1.21415 -1.16614 1.1694 1.17692 1.18594 1.19351 1.19683 -1.16363 1.16614 1.17231 1.1798 1.186 1.18854 +1.18854 1.19683 1.21415 1.23453 1.25222 1.26082 +1.186 1.19351 1.20944 1.22822 1.24444 1.25222 +1.1798 1.18594 1.19916 1.21479 1.22822 1.23453 +1.17231 1.17692 1.18709 1.19916 1.20944 1.21415 +1.16614 1.1694 1.17692 1.18594 1.19351 1.19683 +1.16363 1.16614 1.17231 1.1798 1.186 1.18854 Species 3 -1.18854 1.19683 1.21416 1.23453 1.25222 1.26082 -1.18601 1.19351 1.20944 1.22822 1.24444 1.25222 -1.1798 1.18594 1.19916 1.21479 1.22822 1.23453 -1.17231 1.17692 1.18709 1.19916 1.20944 1.21416 -1.16614 1.1694 1.17692 1.18594 1.19351 1.19683 -1.16363 1.16614 1.17231 1.1798 1.18601 1.18854 +1.18854 1.19683 1.21416 1.23453 1.25222 1.26082 +1.18601 1.19351 1.20944 1.22822 1.24444 1.25222 +1.1798 1.18594 1.19916 1.21479 1.22822 1.23453 +1.17231 1.17692 1.18709 1.19916 1.20944 1.21416 +1.16614 1.1694 1.17692 1.18594 1.19351 1.19683 +1.16363 1.16614 1.17231 1.1798 1.18601 1.18854 Species 4 -35656.3 35903.1 36424.2 37033.8 37564.6 37822.3 -35578.4 35804.9 36281.3 36845.5 37330.9 37564.6 -35393.9 35575.9 35974.4 36441.4 36845.5 37033.8 -35167.5 35307.4 35610.6 35974.4 36281.3 36424.2 -34984.3 35080.2 35307.4 35575.9 35804.9 35903.1 -34907.5 34984.3 35167.5 35393.9 35578.4 35656.3 +35656.3 35903.1 36424.2 37033.8 37564.6 37822.3 +35578.4 35804.9 36281.3 36845.5 37330.9 37564.6 +35393.9 35575.9 35974.4 36441.4 36845.5 37033.8 +35167.5 35307.4 35610.6 35974.4 36281.3 36424.2 +34984.3 35080.2 35307.4 35575.9 35804.9 35903.1 +34907.5 34984.3 35167.5 35393.9 35578.4 35656.3 Species 5 -35656.3 35903.1 36424.2 37033.8 37564.6 37822.3 -35578.4 35804.9 36281.3 36845.5 37330.9 37564.6 -35393.9 35575.9 35974.4 36441.4 36845.5 37033.8 -35167.5 35307.4 35610.6 35974.4 36281.3 36424.2 -34984.3 35080.2 35307.4 35575.9 35804.9 35903.1 -34907.5 34984.3 35167.5 35393.9 35578.4 35656.3 +35656.3 35903.1 36424.2 37033.8 37564.6 37822.3 +35578.4 35804.9 36281.3 36845.5 37330.9 37564.6 +35393.9 35575.9 35974.4 36441.4 36845.5 37033.8 +35167.5 35307.4 35610.6 35974.4 36281.3 36424.2 +34984.3 35080.2 35307.4 35575.9 35804.9 35903.1 +34907.5 34984.3 35167.5 35393.9 35578.4 35656.3 Species 6 -35656.3 35903.1 36424.2 37033.8 37564.6 37822.3 -35578.4 35804.9 36281.3 36845.5 37330.9 37564.6 -35393.9 35575.9 35974.4 36441.4 36845.5 37033.8 -35167.5 35307.4 35610.6 35974.4 36281.3 36424.2 -34984.3 35080.2 35307.4 35575.9 35804.9 35903.1 -34907.5 34984.3 35167.5 35393.9 35578.4 35656.3 +35656.3 35903.1 36424.2 37033.8 37564.6 37822.3 +35578.4 35804.9 36281.3 36845.5 37330.9 37564.6 +35393.9 35575.9 35974.4 36441.4 36845.5 37033.8 +35167.5 35307.4 35610.6 35974.4 36281.3 36424.2 +34984.3 35080.2 35307.4 35575.9 35804.9 35903.1 +34907.5 34984.3 35167.5 35393.9 35578.4 35656.3 t = 8.00e+00 nst = 232 nfe = 0 nfi = 3780 nni = 2567 hu = 1.06e-01 @@ -367,75 +367,75 @@ t = 1.00e+01 nst = 266 nfe = 0 nfi = 4394 nni = 2941 hu = 8.37e-02 c values at t = 10: Species 1 -1.18838 1.19667 1.21399 1.23437 1.25205 1.26066 -1.18585 1.19335 1.20928 1.22805 1.24428 1.25205 -1.17964 1.18578 1.199 1.21463 1.22805 1.23437 -1.17215 1.17676 1.18693 1.199 1.20928 1.21399 -1.16598 1.16925 1.17676 1.18578 1.19335 1.19667 -1.16347 1.16598 1.17215 1.17964 1.18585 1.18838 +1.18838 1.19667 1.21399 1.23437 1.25205 1.26066 +1.18585 1.19335 1.20928 1.22805 1.24428 1.25205 +1.17964 1.18578 1.199 1.21463 1.22805 1.23437 +1.17215 1.17676 1.18693 1.199 1.20928 1.21399 +1.16598 1.16925 1.17676 1.18578 1.19335 1.19667 +1.16347 1.16598 1.17215 1.17964 1.18585 1.18838 Species 2 -1.18838 1.19667 1.21399 1.23437 1.25205 1.26066 -1.18585 1.19335 1.20928 1.22805 1.24428 1.25205 -1.17964 1.18578 1.199 1.21463 1.22805 1.23437 -1.17215 1.17676 1.18693 1.199 1.20928 1.21399 -1.16598 1.16925 1.17676 1.18578 1.19335 1.19667 -1.16347 1.16598 1.17215 1.17964 1.18585 1.18838 +1.18838 1.19667 1.21399 1.23437 1.25205 1.26066 +1.18585 1.19335 1.20928 1.22805 1.24428 1.25205 +1.17964 1.18578 1.199 1.21463 1.22805 1.23437 +1.17215 1.17676 1.18693 1.199 1.20928 1.21399 +1.16598 1.16925 1.17676 1.18578 1.19335 1.19667 +1.16347 1.16598 1.17215 1.17964 1.18585 1.18838 Species 3 -1.18838 1.19667 1.21399 1.23437 1.25205 1.26066 -1.18585 1.19335 1.20928 1.22805 1.24428 1.25205 -1.17964 1.18578 1.199 1.21463 1.22805 1.23437 -1.17215 1.17676 1.18693 1.199 1.20928 1.21399 -1.16598 1.16925 1.17676 1.18578 1.19335 1.19667 -1.16347 1.16598 1.17215 1.17964 1.18585 1.18838 +1.18838 1.19667 1.21399 1.23437 1.25205 1.26066 +1.18585 1.19335 1.20928 1.22805 1.24428 1.25205 +1.17964 1.18578 1.199 1.21463 1.22805 1.23437 +1.17215 1.17676 1.18693 1.199 1.20928 1.21399 +1.16598 1.16925 1.17676 1.18578 1.19335 1.19667 +1.16347 1.16598 1.17215 1.17964 1.18585 1.18838 Species 4 -35650.6 35898.8 36418.4 37029.2 37559.5 37817.3 -35574.5 35799.5 36277.1 36840 37326.6 37559.5 -35388.4 35572.3 35968.8 36437.5 36840 37029.2 -35163.7 35302 35606.7 35968.8 36277.1 36418.4 -34978.6 35076.5 35302 35572.3 35799.5 35898.8 -34903.3 34978.6 35163.7 35388.4 35574.5 35650.6 +35650.6 35898.8 36418.4 37029.2 37559.5 37817.3 +35574.5 35799.5 36277.1 36840 37326.6 37559.5 +35388.4 35572.3 35968.8 36437.5 36840 37029.2 +35163.7 35302 35606.7 35968.8 36277.1 36418.4 +34978.6 35076.5 35302 35572.3 35799.5 35898.8 +34903.3 34978.6 35163.7 35388.4 35574.5 35650.6 Species 5 -35650.6 35898.8 36418.4 37029.2 37559.5 37817.3 -35574.5 35799.5 36277.1 36840 37326.6 37559.5 -35388.4 35572.3 35968.8 36437.5 36840 37029.2 -35163.7 35302 35606.7 35968.8 36277.1 36418.4 -34978.6 35076.5 35302 35572.3 35799.5 35898.8 -34903.3 34978.6 35163.7 35388.4 35574.5 35650.6 +35650.6 35898.8 36418.4 37029.2 37559.5 37817.3 +35574.5 35799.5 36277.1 36840 37326.6 37559.5 +35388.4 35572.3 35968.8 36437.5 36840 37029.2 +35163.7 35302 35606.7 35968.8 36277.1 36418.4 +34978.6 35076.5 35302 35572.3 35799.5 35898.8 +34903.3 34978.6 35163.7 35388.4 35574.5 35650.6 Species 6 -35650.6 35898.8 36418.4 37029.2 37559.5 37817.3 -35574.5 35799.5 36277.1 36840 37326.6 37559.5 -35388.4 35572.3 35968.8 36437.5 36840 37029.2 -35163.7 35302 35606.7 35968.8 36277.1 36418.4 -34978.6 35076.5 35302 35572.3 35799.5 35898.8 -34903.3 34978.6 35163.7 35388.4 35574.5 35650.6 +35650.6 35898.8 36418.4 37029.2 37559.5 37817.3 +35574.5 35799.5 36277.1 36840 37326.6 37559.5 +35388.4 35572.3 35968.8 36437.5 36840 37029.2 +35163.7 35302 35606.7 35968.8 36277.1 36418.4 +34978.6 35076.5 35302 35572.3 35799.5 35898.8 +34903.3 34978.6 35163.7 35388.4 35574.5 35650.6 Final statistics for this run: - ARKStep real workspace length = 3554 - ARKStep integer workspace length = 131 - ARKLS real workspace length = 2647 - ARKLS integer workspace length = 42 - Number of steps = 266 - Number of f-s (explicit) = 0 - Number of f-s (implicit) = 4394 - Number of f-s (SPGMR) = 8980 - Number of f-s (TOTAL) = 8980 - Number of setups = 121 - Number of nonlinear iterations = 2941 - Number of linear iterations = 8980 - Number of preconditioner evaluations = 121 - Number of preconditioner solves = 11819 - Number of error test failures = 23 - Number of nonlinear conv. failures = 17 - Number of linear convergence failures = 509 - Average Krylov subspace dimension = 3.053 + ARKStep real workspace length = 3554 + ARKStep integer workspace length = 131 + ARKLS real workspace length = 2647 + ARKLS integer workspace length = 42 + Number of steps = 266 + Number of f-s (explicit) = 0 + Number of f-s (implicit) = 4394 + Number of f-s (SPGMR) = 8980 + Number of f-s (TOTAL) = 8980 + Number of setups = 121 + Number of nonlinear iterations = 2941 + Number of linear iterations = 8980 + Number of preconditioner evaluations = 121 + Number of preconditioner solves = 11819 + Number of error test failures = 23 + Number of nonlinear conv. failures = 17 + Number of linear convergence failures = 509 + Average Krylov subspace dimension = 3.053 ---------------------------------------------------------------------------- @@ -487,24 +487,24 @@ t = 1.00e+01 nst = 251 nfe = 0 nfi = 4101 nni = 2746 hu = 7.09e-02 Final statistics for this run: - ARKStep real workspace length = 3554 - ARKStep integer workspace length = 131 - ARKLS real workspace length = 2647 - ARKLS integer workspace length = 42 - Number of steps = 251 - Number of f-s (explicit) = 0 - Number of f-s (implicit) = 4101 - Number of f-s (SPGMR) = 8880 - Number of f-s (TOTAL) = 8880 - Number of setups = 91 - Number of nonlinear iterations = 2746 - Number of linear iterations = 8880 - Number of preconditioner evaluations = 91 - Number of preconditioner solves = 11537 - Number of error test failures = 18 - Number of nonlinear conv. failures = 13 - Number of linear convergence failures = 597 - Average Krylov subspace dimension = 3.234 + ARKStep real workspace length = 3554 + ARKStep integer workspace length = 136 + ARKLS real workspace length = 2647 + ARKLS integer workspace length = 42 + Number of steps = 251 + Number of f-s (explicit) = 0 + Number of f-s (implicit) = 4101 + Number of f-s (SPGMR) = 8880 + Number of f-s (TOTAL) = 8880 + Number of setups = 91 + Number of nonlinear iterations = 2746 + Number of linear iterations = 8880 + Number of preconditioner evaluations = 91 + Number of preconditioner solves = 11537 + Number of error test failures = 18 + Number of nonlinear conv. failures = 13 + Number of linear convergence failures = 597 + Average Krylov subspace dimension = 3.234 ---------------------------------------------------------------------------- @@ -556,24 +556,24 @@ t = 1.00e+01 nst = 359 nfe = 0 nfi = 5722 nni = 3907 hu = 1.35e-01 Final statistics for this run: - ARKStep real workspace length = 3554 - ARKStep integer workspace length = 131 - ARKLS real workspace length = 2647 - ARKLS integer workspace length = 42 - Number of steps = 359 - Number of f-s (explicit) = 0 - Number of f-s (implicit) = 5722 - Number of f-s (SPGMR) = 12904 - Number of f-s (TOTAL) = 12904 - Number of setups = 253 - Number of nonlinear iterations = 3907 - Number of linear iterations = 12904 - Number of preconditioner evaluations = 253 - Number of preconditioner solves = 16594 - Number of error test failures = 0 - Number of nonlinear conv. failures = 117 - Number of linear convergence failures = 1072 - Average Krylov subspace dimension = 3.303 + ARKStep real workspace length = 3554 + ARKStep integer workspace length = 141 + ARKLS real workspace length = 2647 + ARKLS integer workspace length = 42 + Number of steps = 359 + Number of f-s (explicit) = 0 + Number of f-s (implicit) = 5722 + Number of f-s (SPGMR) = 12904 + Number of f-s (TOTAL) = 12904 + Number of setups = 253 + Number of nonlinear iterations = 3907 + Number of linear iterations = 12904 + Number of preconditioner evaluations = 253 + Number of preconditioner solves = 16594 + Number of error test failures = 0 + Number of nonlinear conv. failures = 117 + Number of linear convergence failures = 1072 + Average Krylov subspace dimension = 3.303 ---------------------------------------------------------------------------- @@ -625,24 +625,24 @@ t = 1.00e+01 nst = 359 nfe = 0 nfi = 5728 nni = 3912 hu = 1.31e-01 Final statistics for this run: - ARKStep real workspace length = 3554 - ARKStep integer workspace length = 131 - ARKLS real workspace length = 2647 - ARKLS integer workspace length = 42 - Number of steps = 359 - Number of f-s (explicit) = 0 - Number of f-s (implicit) = 5728 - Number of f-s (SPGMR) = 12934 - Number of f-s (TOTAL) = 12934 - Number of setups = 254 - Number of nonlinear iterations = 3912 - Number of linear iterations = 12934 - Number of preconditioner evaluations = 254 - Number of preconditioner solves = 16627 - Number of error test failures = 0 - Number of nonlinear conv. failures = 118 - Number of linear convergence failures = 1076 - Average Krylov subspace dimension = 3.306 + ARKStep real workspace length = 3554 + ARKStep integer workspace length = 146 + ARKLS real workspace length = 2647 + ARKLS integer workspace length = 42 + Number of steps = 359 + Number of f-s (explicit) = 0 + Number of f-s (implicit) = 5728 + Number of f-s (SPGMR) = 12934 + Number of f-s (TOTAL) = 12934 + Number of setups = 254 + Number of nonlinear iterations = 3912 + Number of linear iterations = 12934 + Number of preconditioner evaluations = 254 + Number of preconditioner solves = 16627 + Number of error test failures = 0 + Number of nonlinear conv. failures = 118 + Number of linear convergence failures = 1076 + Average Krylov subspace dimension = 3.306 ---------------------------------------------------------------------------- diff --git a/examples/arkode/C_serial/ark_KrylovDemo_prec_2.out b/examples/arkode/C_serial/ark_KrylovDemo_prec_2.out index 09364ad394..a2564a38ee 100644 --- a/examples/arkode/C_serial/ark_KrylovDemo_prec_2.out +++ b/examples/arkode/C_serial/ark_KrylovDemo_prec_2.out @@ -10,9 +10,9 @@ b parameter = 1 Diffusion coefficients: Dprey = 1 Dpred = 0.5 Rate parameter alpha = 1 -Mesh dimensions (mx,my) are 6, 6. Total system size is neq = 216 +Mesh dimensions (mx,my) are 6, 6. Total system size is neq = 216 -Tolerances: reltol = 1e-05, abstol = 1e-05 +Tolerances: reltol = 1e-05, abstol = 1e-05 Preconditioning uses a product of: (1) Gauss-Seidel iterations with itmax = 5 iterations, and @@ -31,52 +31,52 @@ Gram-Schmidt method type is gstype = SUN_MODIFIED_GS c values at t = 0: Species 1 -10 10 10 10 10 10 -10 10.1678 10.3775 10.3775 10.1678 10 -10 10.3775 10.8493 10.8493 10.3775 10 -10 10.3775 10.8493 10.8493 10.3775 10 -10 10.1678 10.3775 10.3775 10.1678 10 -10 10 10 10 10 10 +10 10 10 10 10 10 +10 10.1678 10.3775 10.3775 10.1678 10 +10 10.3775 10.8493 10.8493 10.3775 10 +10 10.3775 10.8493 10.8493 10.3775 10 +10 10.1678 10.3775 10.3775 10.1678 10 +10 10 10 10 10 10 Species 2 -10 10 10 10 10 10 -10 10.3355 10.755 10.755 10.3355 10 -10 10.755 11.6987 11.6987 10.755 10 -10 10.755 11.6987 11.6987 10.755 10 -10 10.3355 10.755 10.755 10.3355 10 -10 10 10 10 10 10 +10 10 10 10 10 10 +10 10.3355 10.755 10.755 10.3355 10 +10 10.755 11.6987 11.6987 10.755 10 +10 10.755 11.6987 11.6987 10.755 10 +10 10.3355 10.755 10.755 10.3355 10 +10 10 10 10 10 10 Species 3 -10 10 10 10 10 10 -10 10.5033 11.1325 11.1325 10.5033 10 -10 11.1325 12.548 12.548 11.1325 10 -10 11.1325 12.548 12.548 11.1325 10 -10 10.5033 11.1325 11.1325 10.5033 10 -10 10 10 10 10 10 +10 10 10 10 10 10 +10 10.5033 11.1325 11.1325 10.5033 10 +10 11.1325 12.548 12.548 11.1325 10 +10 11.1325 12.548 12.548 11.1325 10 +10 10.5033 11.1325 11.1325 10.5033 10 +10 10 10 10 10 10 Species 4 -10 10 10 10 10 10 -10 10.6711 11.5099 11.5099 10.6711 10 -10 11.5099 13.3974 13.3974 11.5099 10 -10 11.5099 13.3974 13.3974 11.5099 10 -10 10.6711 11.5099 11.5099 10.6711 10 -10 10 10 10 10 10 +10 10 10 10 10 10 +10 10.6711 11.5099 11.5099 10.6711 10 +10 11.5099 13.3974 13.3974 11.5099 10 +10 11.5099 13.3974 13.3974 11.5099 10 +10 10.6711 11.5099 11.5099 10.6711 10 +10 10 10 10 10 10 Species 5 -10 10 10 10 10 10 -10 10.8389 11.8874 11.8874 10.8389 10 -10 11.8874 14.2467 14.2467 11.8874 10 -10 11.8874 14.2467 14.2467 11.8874 10 -10 10.8389 11.8874 11.8874 10.8389 10 -10 10 10 10 10 10 +10 10 10 10 10 10 +10 10.8389 11.8874 11.8874 10.8389 10 +10 11.8874 14.2467 14.2467 11.8874 10 +10 11.8874 14.2467 14.2467 11.8874 10 +10 10.8389 11.8874 11.8874 10.8389 10 +10 10 10 10 10 10 Species 6 -10 10 10 10 10 10 -10 11.0066 12.2649 12.2649 11.0066 10 -10 12.2649 15.0961 15.0961 12.2649 10 -10 12.2649 15.0961 15.0961 12.2649 10 -10 11.0066 12.2649 12.2649 11.0066 10 -10 10 10 10 10 10 +10 10 10 10 10 10 +10 11.0066 12.2649 12.2649 11.0066 10 +10 12.2649 15.0961 15.0961 12.2649 10 +10 12.2649 15.0961 15.0961 12.2649 10 +10 11.0066 12.2649 12.2649 11.0066 10 +10 10 10 10 10 10 t = 1.00e-08 nst = 5 nfe = 0 nfi = 75 nni = 47 hu = 9.89e-08 @@ -87,52 +87,52 @@ t = 1.00e-06 nst = 8 nfe = 0 nfi = 120 nni = 77 hu = 4.79e-07 c values at t = 1e-06: Species 1 -9.99991 9.99992 9.99993 9.99993 9.99993 9.99992 -9.99992 10.1677 10.3774 10.3774 10.1677 9.99993 -9.99993 10.3774 10.8492 10.8492 10.3774 9.99993 -9.99993 10.3774 10.8492 10.8492 10.3774 9.99993 -9.99992 10.1677 10.3774 10.3774 10.1677 9.99992 -9.99991 9.99992 9.99993 9.99993 9.99992 9.99991 +9.99991 9.99992 9.99993 9.99993 9.99993 9.99992 +9.99992 10.1677 10.3774 10.3774 10.1677 9.99993 +9.99993 10.3774 10.8492 10.8492 10.3774 9.99993 +9.99993 10.3774 10.8492 10.8492 10.3774 9.99993 +9.99992 10.1677 10.3774 10.3774 10.1677 9.99992 +9.99991 9.99992 9.99993 9.99993 9.99992 9.99991 Species 2 -9.99991 9.99993 9.99995 9.99995 9.99993 9.99992 -9.99993 10.3355 10.7549 10.7549 10.3355 9.99993 -9.99995 10.7549 11.6985 11.6985 10.7549 9.99995 -9.99995 10.7549 11.6985 11.6985 10.7549 9.99995 -9.99993 10.3355 10.7549 10.7549 10.3355 9.99993 -9.99991 9.99993 9.99995 9.99995 9.99993 9.99991 +9.99991 9.99993 9.99995 9.99995 9.99993 9.99992 +9.99993 10.3355 10.7549 10.7549 10.3355 9.99993 +9.99995 10.7549 11.6985 11.6985 10.7549 9.99995 +9.99995 10.7549 11.6985 11.6985 10.7549 9.99995 +9.99993 10.3355 10.7549 10.7549 10.3355 9.99993 +9.99991 9.99993 9.99995 9.99995 9.99993 9.99991 Species 3 -9.99991 9.99994 9.99997 9.99997 9.99994 9.99992 -9.99994 10.5032 11.1323 11.1323 10.5032 9.99994 -9.99997 11.1323 12.5478 12.5478 11.1323 9.99997 -9.99997 11.1323 12.5478 12.5478 11.1323 9.99997 -9.99994 10.5032 11.1323 11.1323 10.5032 9.99994 -9.99991 9.99994 9.99997 9.99997 9.99994 9.99991 +9.99991 9.99994 9.99997 9.99997 9.99994 9.99992 +9.99994 10.5032 11.1323 11.1323 10.5032 9.99994 +9.99997 11.1323 12.5478 12.5478 11.1323 9.99997 +9.99997 11.1323 12.5478 12.5478 11.1323 9.99997 +9.99994 10.5032 11.1323 11.1323 10.5032 9.99994 +9.99991 9.99994 9.99997 9.99997 9.99994 9.99991 Species 4 -13.4984 13.4984 13.4984 13.4984 13.4984 13.4984 -13.4984 14.55 15.8924 15.8924 14.55 13.4984 -13.4984 15.8924 19.0296 19.0296 15.8924 13.4984 -13.4984 15.8924 19.0296 19.0296 15.8924 13.4984 -13.4984 14.55 15.8924 15.8924 14.55 13.4984 -13.4984 13.4984 13.4984 13.4984 13.4984 13.4984 +13.4984 13.4984 13.4984 13.4984 13.4984 13.4984 +13.4984 14.55 15.8924 15.8924 14.55 13.4984 +13.4984 15.8924 19.0296 19.0296 15.8924 13.4984 +13.4984 15.8924 19.0296 19.0296 15.8924 13.4984 +13.4984 14.55 15.8924 15.8924 14.55 13.4984 +13.4984 13.4984 13.4984 13.4984 13.4984 13.4984 Species 5 -13.4984 13.4984 13.4985 13.4985 13.4984 13.4984 -13.4984 14.7787 16.4136 16.4136 14.7787 13.4984 -13.4985 16.4136 20.236 20.236 16.4136 13.4985 -13.4985 16.4136 20.236 20.236 16.4136 13.4985 -13.4984 14.7787 16.4136 16.4136 14.7787 13.4984 -13.4984 13.4984 13.4985 13.4985 13.4984 13.4984 +13.4984 13.4984 13.4985 13.4985 13.4984 13.4984 +13.4984 14.7787 16.4136 16.4136 14.7787 13.4984 +13.4985 16.4136 20.236 20.236 16.4136 13.4985 +13.4985 16.4136 20.236 20.236 16.4136 13.4985 +13.4984 14.7787 16.4136 16.4136 14.7787 13.4984 +13.4984 13.4984 13.4985 13.4985 13.4984 13.4984 Species 6 -13.4984 13.4984 13.4985 13.4985 13.4984 13.4984 -13.4984 15.0075 16.9348 16.9348 15.0075 13.4984 -13.4985 16.9348 21.4423 21.4423 16.9348 13.4985 -13.4985 16.9348 21.4423 21.4423 16.9348 13.4985 -13.4984 15.0075 16.9348 16.9348 15.0075 13.4984 -13.4984 13.4984 13.4985 13.4985 13.4984 13.4984 +13.4984 13.4984 13.4985 13.4985 13.4984 13.4984 +13.4984 15.0075 16.9348 16.9348 15.0075 13.4984 +13.4985 16.9348 21.4423 21.4423 16.9348 13.4985 +13.4985 16.9348 21.4423 21.4423 16.9348 13.4985 +13.4984 15.0075 16.9348 16.9348 15.0075 13.4984 +13.4984 13.4984 13.4985 13.4985 13.4984 13.4984 t = 1.00e-05 nst = 27 nfe = 0 nfi = 407 nni = 269 hu = 4.79e-07 @@ -143,52 +143,52 @@ t = 1.00e-03 nst = 110 nfe = 0 nfi = 1750 nni = 1197 hu = 1.51e-03 c values at t = 0.001: Species 1 -9.90702 9.91664 9.92836 9.93033 9.92253 9.91674 -9.91472 10.0747 10.2769 10.2785 10.0795 9.92253 -9.92446 10.2748 10.7181 10.7194 10.2785 9.93033 -9.92445 10.2744 10.7173 10.7181 10.2769 9.92836 -9.91469 10.0734 10.2744 10.2748 10.0747 9.91664 -9.90698 9.91469 9.92445 9.92446 9.91472 9.90702 +9.90702 9.91664 9.92836 9.93033 9.92253 9.91674 +9.91472 10.0747 10.2769 10.2785 10.0795 9.92253 +9.92446 10.2748 10.7181 10.7194 10.2785 9.93033 +9.92445 10.2744 10.7173 10.7181 10.2769 9.92836 +9.91469 10.0734 10.2744 10.2748 10.0747 9.91664 +9.90698 9.91469 9.92445 9.92446 9.91472 9.90702 Species 2 -9.90742 9.92474 9.94622 9.94819 9.93064 9.91713 -9.92282 10.2412 10.644 10.6457 10.2461 9.93064 -9.94232 10.6419 11.5267 11.5281 10.6457 9.94819 -9.94231 10.6415 11.5258 11.5267 10.644 9.94622 -9.92279 10.24 10.6415 10.6419 10.2412 9.92474 -9.90737 9.92279 9.94231 9.94232 9.92282 9.90742 +9.90742 9.92474 9.94622 9.94819 9.93064 9.91713 +9.92282 10.2412 10.644 10.6457 10.2461 9.93064 +9.94232 10.6419 11.5267 11.5281 10.6457 9.94819 +9.94231 10.6415 11.5258 11.5267 10.644 9.94622 +9.92279 10.24 10.6415 10.6419 10.2412 9.92474 +9.90737 9.92279 9.94231 9.94232 9.92282 9.90742 Species 3 -9.90781 9.93284 9.96408 9.96605 9.93874 9.91753 -9.93092 10.4078 11.0109 11.0127 10.4127 9.93874 -9.96017 11.0088 12.3339 12.3354 11.0127 9.96605 -9.96016 11.0083 12.333 12.3339 11.0109 9.96408 -9.93088 10.4065 11.0083 11.0088 10.4078 9.93284 -9.90776 9.93088 9.96016 9.96017 9.93092 9.90781 +9.90781 9.93284 9.96408 9.96605 9.93874 9.91753 +9.93092 10.4078 11.0109 11.0127 10.4127 9.93874 +9.96017 11.0088 12.3339 12.3354 11.0127 9.96605 +9.96016 11.0083 12.333 12.3339 11.0109 9.96408 +9.93088 10.4065 11.0083 11.0088 10.4078 9.93284 +9.90776 9.93088 9.96016 9.96017 9.93092 9.90781 Species 4 -297231 297749 298392 298451 297925 297520 -297692 307245 319327 319378 307390 297925 -298276 319264 345799 345840 319378 298451 -298276 319252 345772 345799 319327 298392 -297691 307208 319252 319264 307245 297749 -297229 297691 298276 298276 297692 297231 +297231 297749 298392 298451 297925 297520 +297692 307245 319327 319378 307390 297925 +298276 319264 345799 345840 319378 298451 +298276 319252 345772 345799 319327 298392 +297691 307208 319252 319264 307245 297749 +297229 297691 298276 298276 297692 297231 Species 5 -297231 297749 298392 298451 297925 297520 -297692 307245 319327 319378 307390 297925 -298276 319264 345799 345840 319378 298451 -298276 319252 345772 345799 319327 298392 -297691 307208 319252 319264 307245 297749 -297229 297691 298276 298276 297692 297231 +297231 297749 298392 298451 297925 297520 +297692 307245 319327 319378 307390 297925 +298276 319264 345799 345840 319378 298451 +298276 319252 345772 345799 319327 298392 +297691 307208 319252 319264 307245 297749 +297229 297691 298276 298276 297692 297231 Species 6 -297231 297749 298392 298451 297925 297520 -297692 307245 319327 319378 307390 297925 -298276 319264 345799 345840 319378 298451 -298276 319252 345772 345799 319327 298392 -297691 307208 319252 319264 307245 297749 -297229 297691 298276 298276 297692 297231 +297231 297749 298392 298451 297925 297520 +297692 307245 319327 319378 307390 297925 +298276 319264 345799 345840 319378 298451 +298276 319252 345772 345799 319327 298392 +297691 307208 319252 319264 307245 297749 +297229 297691 298276 298276 297692 297231 t = 1.00e-02 nst = 113 nfe = 0 nfi = 1797 nni = 1229 hu = 3.46e-03 @@ -199,52 +199,52 @@ t = 1.00e+00 nst = 154 nfe = 0 nfi = 2489 nni = 1716 hu = 6.84e-02 c values at t = 1: Species 1 -1.58851 1.59924 1.62152 1.64764 1.67036 1.68149 -1.58533 1.59503 1.61548 1.63952 1.66033 1.67036 -1.57757 1.58547 1.60239 1.62235 1.63952 1.64764 -1.5682 1.57412 1.58706 1.60239 1.61548 1.62152 -1.56048 1.56463 1.57412 1.58547 1.59503 1.59924 -1.55733 1.56048 1.5682 1.57757 1.58533 1.58851 +1.58851 1.59924 1.62152 1.64764 1.67036 1.68149 +1.58533 1.59503 1.61548 1.63952 1.66033 1.67036 +1.57757 1.58547 1.60239 1.62235 1.63952 1.64764 +1.5682 1.57412 1.58706 1.60239 1.61548 1.62152 +1.56048 1.56463 1.57412 1.58547 1.59503 1.59924 +1.55733 1.56048 1.5682 1.57757 1.58533 1.58851 Species 2 -1.59067 1.60141 1.62371 1.64987 1.67261 1.68375 -1.58748 1.5972 1.61766 1.64173 1.66257 1.67261 -1.57971 1.58763 1.60457 1.62454 1.64173 1.64987 -1.57034 1.57626 1.58921 1.60457 1.61766 1.62371 -1.56261 1.56676 1.57626 1.58763 1.5972 1.60141 -1.55945 1.56261 1.57034 1.57971 1.58748 1.59067 +1.59067 1.60141 1.62371 1.64987 1.67261 1.68375 +1.58748 1.5972 1.61766 1.64173 1.66257 1.67261 +1.57971 1.58763 1.60457 1.62454 1.64173 1.64987 +1.57034 1.57626 1.58921 1.60457 1.61766 1.62371 +1.56261 1.56676 1.57626 1.58763 1.5972 1.60141 +1.55945 1.56261 1.57034 1.57971 1.58748 1.59067 Species 3 -1.5927 1.60346 1.62578 1.65197 1.67474 1.68589 -1.58951 1.59924 1.61973 1.64383 1.66468 1.67474 -1.58174 1.58966 1.60662 1.62662 1.64383 1.65197 -1.57236 1.57828 1.59125 1.60662 1.61973 1.62578 -1.56462 1.56878 1.57828 1.58966 1.59924 1.60346 -1.56146 1.56462 1.57236 1.58174 1.58951 1.5927 +1.5927 1.60346 1.62578 1.65197 1.67474 1.68589 +1.58951 1.59924 1.61973 1.64383 1.66468 1.67474 +1.58174 1.58966 1.60662 1.62662 1.64383 1.65197 +1.57236 1.57828 1.59125 1.60662 1.61973 1.62578 +1.56462 1.56878 1.57828 1.58966 1.59924 1.60346 +1.56146 1.56462 1.57236 1.58174 1.58951 1.5927 Species 4 -47718.3 48040.3 48709 49493.5 50175.5 50509.4 -47622.8 47914 48527.8 49249.6 49874.4 50175.5 -47389.7 47627 48134.9 48734.2 49249.6 49493.5 -47108.5 47286 47674.6 48134.9 48527.8 48709 -46876.6 47001.2 47286 47627 47914 48040.3 -46781.9 46876.6 47108.5 47389.7 47622.8 47718.3 +47718.3 48040.3 48709 49493.5 50175.5 50509.4 +47622.8 47914 48527.8 49249.6 49874.4 50175.5 +47389.7 47627 48134.9 48734.2 49249.6 49493.5 +47108.5 47286 47674.6 48134.9 48527.8 48709 +46876.6 47001.2 47286 47627 47914 48040.3 +46781.9 46876.6 47108.5 47389.7 47622.8 47718.3 Species 5 -47718.3 48040.3 48709 49493.5 50175.5 50509.4 -47622.8 47914 48527.8 49249.6 49874.4 50175.5 -47389.7 47627 48134.9 48734.2 49249.6 49493.5 -47108.5 47286 47674.6 48134.9 48527.8 48709 -46876.6 47001.2 47286 47627 47914 48040.3 -46781.9 46876.6 47108.5 47389.7 47622.8 47718.3 +47718.3 48040.3 48709 49493.5 50175.5 50509.4 +47622.8 47914 48527.8 49249.6 49874.4 50175.5 +47389.7 47627 48134.9 48734.2 49249.6 49493.5 +47108.5 47286 47674.6 48134.9 48527.8 48709 +46876.6 47001.2 47286 47627 47914 48040.3 +46781.9 46876.6 47108.5 47389.7 47622.8 47718.3 Species 6 -47718.3 48040.3 48709 49493.5 50175.5 50509.4 -47622.8 47914 48527.8 49249.6 49874.4 50175.5 -47389.7 47627 48134.9 48734.2 49249.6 49493.5 -47108.5 47286 47674.6 48134.9 48527.8 48709 -46876.6 47001.2 47286 47627 47914 48040.3 -46781.9 46876.6 47108.5 47389.7 47622.8 47718.3 +47718.3 48040.3 48709 49493.5 50175.5 50509.4 +47622.8 47914 48527.8 49249.6 49874.4 50175.5 +47389.7 47627 48134.9 48734.2 49249.6 49493.5 +47108.5 47286 47674.6 48134.9 48527.8 48709 +46876.6 47001.2 47286 47627 47914 48040.3 +46781.9 46876.6 47108.5 47389.7 47622.8 47718.3 t = 2.00e+00 nst = 165 nfe = 0 nfi = 2661 nni = 1833 hu = 4.14e-02 @@ -255,52 +255,52 @@ t = 4.00e+00 nst = 187 nfe = 0 nfi = 3013 nni = 2073 hu = 1.23e-01 c values at t = 4: Species 1 -1.19535 1.20368 1.2211 1.24157 1.25935 1.268 -1.1928 1.20035 1.21636 1.23523 1.25154 1.25935 -1.18657 1.19274 1.20602 1.22173 1.23523 1.24157 -1.17904 1.18368 1.19389 1.20602 1.21636 1.2211 -1.17284 1.17613 1.18368 1.19274 1.20035 1.20368 -1.17032 1.17284 1.17904 1.18657 1.1928 1.19535 +1.19535 1.20368 1.2211 1.24157 1.25935 1.268 +1.1928 1.20035 1.21636 1.23523 1.25154 1.25935 +1.18657 1.19274 1.20602 1.22173 1.23523 1.24157 +1.17904 1.18368 1.19389 1.20602 1.21636 1.2211 +1.17284 1.17613 1.18368 1.19274 1.20035 1.20368 +1.17032 1.17284 1.17904 1.18657 1.1928 1.19535 Species 2 -1.19538 1.20371 1.22113 1.24161 1.25938 1.26804 -1.19284 1.20038 1.21639 1.23526 1.25157 1.25938 -1.1866 1.19277 1.20606 1.22177 1.23526 1.24161 -1.17908 1.18371 1.19393 1.20606 1.21639 1.22113 -1.17288 1.17616 1.18371 1.19277 1.20038 1.20371 -1.17035 1.17288 1.17908 1.1866 1.19284 1.19538 +1.19538 1.20371 1.22113 1.24161 1.25938 1.26804 +1.19284 1.20038 1.21639 1.23526 1.25157 1.25938 +1.1866 1.19277 1.20606 1.22177 1.23526 1.24161 +1.17908 1.18371 1.19393 1.20606 1.21639 1.22113 +1.17288 1.17616 1.18371 1.19277 1.20038 1.20371 +1.17035 1.17288 1.17908 1.1866 1.19284 1.19538 Species 3 -1.19542 1.20374 1.22116 1.24164 1.25942 1.26807 -1.19287 1.20042 1.21642 1.2353 1.2516 1.25942 -1.18663 1.1928 1.20609 1.2218 1.2353 1.24164 -1.17911 1.18374 1.19396 1.20609 1.21642 1.22116 -1.17291 1.17619 1.18374 1.1928 1.20042 1.20374 -1.17039 1.17291 1.17911 1.18663 1.19287 1.19542 +1.19542 1.20374 1.22116 1.24164 1.25942 1.26807 +1.19287 1.20042 1.21642 1.2353 1.2516 1.25942 +1.18663 1.1928 1.20609 1.2218 1.2353 1.24164 +1.17911 1.18374 1.19396 1.20609 1.21642 1.22116 +1.17291 1.17619 1.18374 1.1928 1.20042 1.20374 +1.17039 1.17291 1.17911 1.18663 1.19287 1.19542 Species 4 -35860.6 36110.2 36632.4 37246.4 37779.5 38038.7 -35784.2 36010.4 36490.4 37056.3 37545.3 37779.5 -35597.2 35782 36180.5 36651.6 37056.3 37246.4 -35371.4 35510.4 35816.7 36180.5 36490.4 36632.4 -35185.4 35283.8 35510.4 35782 36010.4 36110.2 -35109.7 35185.4 35371.4 35597.2 35784.2 35860.6 +35860.6 36110.2 36632.4 37246.4 37779.5 38038.7 +35784.2 36010.4 36490.4 37056.3 37545.3 37779.5 +35597.2 35782 36180.5 36651.6 37056.3 37246.4 +35371.4 35510.4 35816.7 36180.5 36490.4 36632.4 +35185.4 35283.8 35510.4 35782 36010.4 36110.2 +35109.7 35185.4 35371.4 35597.2 35784.2 35860.6 Species 5 -35860.6 36110.2 36632.4 37246.4 37779.5 38038.7 -35784.2 36010.4 36490.4 37056.3 37545.3 37779.5 -35597.2 35782 36180.5 36651.6 37056.3 37246.4 -35371.4 35510.4 35816.7 36180.5 36490.4 36632.4 -35185.4 35283.8 35510.4 35782 36010.4 36110.2 -35109.7 35185.4 35371.4 35597.2 35784.2 35860.6 +35860.6 36110.2 36632.4 37246.4 37779.5 38038.7 +35784.2 36010.4 36490.4 37056.3 37545.3 37779.5 +35597.2 35782 36180.5 36651.6 37056.3 37246.4 +35371.4 35510.4 35816.7 36180.5 36490.4 36632.4 +35185.4 35283.8 35510.4 35782 36010.4 36110.2 +35109.7 35185.4 35371.4 35597.2 35784.2 35860.6 Species 6 -35860.6 36110.2 36632.4 37246.4 37779.5 38038.7 -35784.2 36010.4 36490.4 37056.3 37545.3 37779.5 -35597.2 35782 36180.5 36651.6 37056.3 37246.4 -35371.4 35510.4 35816.7 36180.5 36490.4 36632.4 -35185.4 35283.8 35510.4 35782 36010.4 36110.2 -35109.7 35185.4 35371.4 35597.2 35784.2 35860.6 +35860.6 36110.2 36632.4 37246.4 37779.5 38038.7 +35784.2 36010.4 36490.4 37056.3 37545.3 37779.5 +35597.2 35782 36180.5 36651.6 37056.3 37246.4 +35371.4 35510.4 35816.7 36180.5 36490.4 36632.4 +35185.4 35283.8 35510.4 35782 36010.4 36110.2 +35109.7 35185.4 35371.4 35597.2 35784.2 35860.6 t = 5.00e+00 nst = 198 nfe = 0 nfi = 3179 nni = 2182 hu = 9.99e-02 @@ -311,52 +311,52 @@ t = 7.00e+00 nst = 216 nfe = 0 nfi = 3477 nni = 2375 hu = 1.51e-01 c values at t = 7: Species 1 -1.18854 1.19682 1.21415 1.23453 1.25221 1.26082 -1.186 1.19351 1.20944 1.22822 1.24444 1.25221 -1.1798 1.18593 1.19916 1.21479 1.22822 1.23453 -1.17231 1.17692 1.18708 1.19916 1.20944 1.21415 -1.16614 1.1694 1.17692 1.18593 1.19351 1.19682 -1.16363 1.16614 1.17231 1.1798 1.186 1.18854 +1.18854 1.19682 1.21415 1.23453 1.25221 1.26082 +1.186 1.19351 1.20944 1.22822 1.24444 1.25221 +1.1798 1.18593 1.19916 1.21479 1.22822 1.23453 +1.17231 1.17692 1.18708 1.19916 1.20944 1.21415 +1.16614 1.1694 1.17692 1.18593 1.19351 1.19682 +1.16363 1.16614 1.17231 1.1798 1.186 1.18854 Species 2 -1.18854 1.19683 1.21415 1.23453 1.25222 1.26082 -1.186 1.19351 1.20944 1.22822 1.24444 1.25222 -1.1798 1.18594 1.19916 1.21479 1.22822 1.23453 -1.17231 1.17692 1.18709 1.19916 1.20944 1.21415 -1.16614 1.1694 1.17692 1.18594 1.19351 1.19683 -1.16363 1.16614 1.17231 1.1798 1.186 1.18854 +1.18854 1.19683 1.21415 1.23453 1.25222 1.26082 +1.186 1.19351 1.20944 1.22822 1.24444 1.25222 +1.1798 1.18594 1.19916 1.21479 1.22822 1.23453 +1.17231 1.17692 1.18709 1.19916 1.20944 1.21415 +1.16614 1.1694 1.17692 1.18594 1.19351 1.19683 +1.16363 1.16614 1.17231 1.1798 1.186 1.18854 Species 3 -1.18854 1.19683 1.21416 1.23453 1.25222 1.26082 -1.18601 1.19351 1.20944 1.22822 1.24444 1.25222 -1.1798 1.18594 1.19916 1.21479 1.22822 1.23453 -1.17231 1.17692 1.18709 1.19916 1.20944 1.21416 -1.16614 1.1694 1.17692 1.18594 1.19351 1.19683 -1.16363 1.16614 1.17231 1.1798 1.18601 1.18854 +1.18854 1.19683 1.21416 1.23453 1.25222 1.26082 +1.18601 1.19351 1.20944 1.22822 1.24444 1.25222 +1.1798 1.18594 1.19916 1.21479 1.22822 1.23453 +1.17231 1.17692 1.18709 1.19916 1.20944 1.21416 +1.16614 1.1694 1.17692 1.18594 1.19351 1.19683 +1.16363 1.16614 1.17231 1.1798 1.18601 1.18854 Species 4 -35656.3 35903.1 36424.2 37033.8 37564.6 37822.3 -35578.4 35804.9 36281.3 36845.5 37330.9 37564.6 -35393.9 35575.9 35974.4 36441.4 36845.5 37033.8 -35167.5 35307.4 35610.6 35974.4 36281.3 36424.2 -34984.3 35080.2 35307.4 35575.9 35804.9 35903.1 -34907.5 34984.3 35167.5 35393.9 35578.4 35656.3 +35656.3 35903.1 36424.2 37033.8 37564.6 37822.3 +35578.4 35804.9 36281.3 36845.5 37330.9 37564.6 +35393.9 35575.9 35974.4 36441.4 36845.5 37033.8 +35167.5 35307.4 35610.6 35974.4 36281.3 36424.2 +34984.3 35080.2 35307.4 35575.9 35804.9 35903.1 +34907.5 34984.3 35167.5 35393.9 35578.4 35656.3 Species 5 -35656.3 35903.1 36424.2 37033.8 37564.6 37822.3 -35578.4 35804.9 36281.3 36845.5 37330.9 37564.6 -35393.9 35575.9 35974.4 36441.4 36845.5 37033.8 -35167.5 35307.4 35610.6 35974.4 36281.3 36424.2 -34984.3 35080.2 35307.4 35575.9 35804.9 35903.1 -34907.5 34984.3 35167.5 35393.9 35578.4 35656.3 +35656.3 35903.1 36424.2 37033.8 37564.6 37822.3 +35578.4 35804.9 36281.3 36845.5 37330.9 37564.6 +35393.9 35575.9 35974.4 36441.4 36845.5 37033.8 +35167.5 35307.4 35610.6 35974.4 36281.3 36424.2 +34984.3 35080.2 35307.4 35575.9 35804.9 35903.1 +34907.5 34984.3 35167.5 35393.9 35578.4 35656.3 Species 6 -35656.3 35903.1 36424.2 37033.8 37564.6 37822.3 -35578.4 35804.9 36281.3 36845.5 37330.9 37564.6 -35393.9 35575.9 35974.4 36441.4 36845.5 37033.8 -35167.5 35307.4 35610.6 35974.4 36281.3 36424.2 -34984.3 35080.2 35307.4 35575.9 35804.9 35903.1 -34907.5 34984.3 35167.5 35393.9 35578.4 35656.3 +35656.3 35903.1 36424.2 37033.8 37564.6 37822.3 +35578.4 35804.9 36281.3 36845.5 37330.9 37564.6 +35393.9 35575.9 35974.4 36441.4 36845.5 37033.8 +35167.5 35307.4 35610.6 35974.4 36281.3 36424.2 +34984.3 35080.2 35307.4 35575.9 35804.9 35903.1 +34907.5 34984.3 35167.5 35393.9 35578.4 35656.3 t = 8.00e+00 nst = 232 nfe = 0 nfi = 3780 nni = 2567 hu = 1.06e-01 @@ -367,75 +367,75 @@ t = 1.00e+01 nst = 266 nfe = 0 nfi = 4394 nni = 2941 hu = 8.37e-02 c values at t = 10: Species 1 -1.18838 1.19667 1.21399 1.23437 1.25205 1.26066 -1.18585 1.19335 1.20928 1.22805 1.24428 1.25205 -1.17964 1.18578 1.199 1.21463 1.22805 1.23437 -1.17215 1.17676 1.18693 1.199 1.20928 1.21399 -1.16598 1.16925 1.17676 1.18578 1.19335 1.19667 -1.16347 1.16598 1.17215 1.17964 1.18585 1.18838 +1.18838 1.19667 1.21399 1.23437 1.25205 1.26066 +1.18585 1.19335 1.20928 1.22805 1.24428 1.25205 +1.17964 1.18578 1.199 1.21463 1.22805 1.23437 +1.17215 1.17676 1.18693 1.199 1.20928 1.21399 +1.16598 1.16925 1.17676 1.18578 1.19335 1.19667 +1.16347 1.16598 1.17215 1.17964 1.18585 1.18838 Species 2 -1.18838 1.19667 1.21399 1.23437 1.25205 1.26066 -1.18585 1.19335 1.20928 1.22805 1.24428 1.25205 -1.17964 1.18578 1.199 1.21463 1.22805 1.23437 -1.17215 1.17676 1.18693 1.199 1.20928 1.21399 -1.16598 1.16925 1.17676 1.18578 1.19335 1.19667 -1.16347 1.16598 1.17215 1.17964 1.18585 1.18838 +1.18838 1.19667 1.21399 1.23437 1.25205 1.26066 +1.18585 1.19335 1.20928 1.22805 1.24428 1.25205 +1.17964 1.18578 1.199 1.21463 1.22805 1.23437 +1.17215 1.17676 1.18693 1.199 1.20928 1.21399 +1.16598 1.16925 1.17676 1.18578 1.19335 1.19667 +1.16347 1.16598 1.17215 1.17964 1.18585 1.18838 Species 3 -1.18838 1.19667 1.21399 1.23437 1.25205 1.26066 -1.18585 1.19335 1.20928 1.22805 1.24428 1.25205 -1.17964 1.18578 1.199 1.21463 1.22805 1.23437 -1.17215 1.17676 1.18693 1.199 1.20928 1.21399 -1.16598 1.16925 1.17676 1.18578 1.19335 1.19667 -1.16347 1.16598 1.17215 1.17964 1.18585 1.18838 +1.18838 1.19667 1.21399 1.23437 1.25205 1.26066 +1.18585 1.19335 1.20928 1.22805 1.24428 1.25205 +1.17964 1.18578 1.199 1.21463 1.22805 1.23437 +1.17215 1.17676 1.18693 1.199 1.20928 1.21399 +1.16598 1.16925 1.17676 1.18578 1.19335 1.19667 +1.16347 1.16598 1.17215 1.17964 1.18585 1.18838 Species 4 -35650.6 35898.8 36418.4 37029.2 37559.5 37817.3 -35574.5 35799.5 36277.1 36840 37326.6 37559.5 -35388.4 35572.3 35968.8 36437.5 36840 37029.2 -35163.7 35302 35606.7 35968.8 36277.1 36418.4 -34978.6 35076.5 35302 35572.3 35799.5 35898.8 -34903.3 34978.6 35163.7 35388.4 35574.5 35650.6 +35650.6 35898.8 36418.4 37029.2 37559.5 37817.3 +35574.5 35799.5 36277.1 36840 37326.6 37559.5 +35388.4 35572.3 35968.8 36437.5 36840 37029.2 +35163.7 35302 35606.7 35968.8 36277.1 36418.4 +34978.6 35076.5 35302 35572.3 35799.5 35898.8 +34903.3 34978.6 35163.7 35388.4 35574.5 35650.6 Species 5 -35650.6 35898.8 36418.4 37029.2 37559.5 37817.3 -35574.5 35799.5 36277.1 36840 37326.6 37559.5 -35388.4 35572.3 35968.8 36437.5 36840 37029.2 -35163.7 35302 35606.7 35968.8 36277.1 36418.4 -34978.6 35076.5 35302 35572.3 35799.5 35898.8 -34903.3 34978.6 35163.7 35388.4 35574.5 35650.6 +35650.6 35898.8 36418.4 37029.2 37559.5 37817.3 +35574.5 35799.5 36277.1 36840 37326.6 37559.5 +35388.4 35572.3 35968.8 36437.5 36840 37029.2 +35163.7 35302 35606.7 35968.8 36277.1 36418.4 +34978.6 35076.5 35302 35572.3 35799.5 35898.8 +34903.3 34978.6 35163.7 35388.4 35574.5 35650.6 Species 6 -35650.6 35898.8 36418.4 37029.2 37559.5 37817.3 -35574.5 35799.5 36277.1 36840 37326.6 37559.5 -35388.4 35572.3 35968.8 36437.5 36840 37029.2 -35163.7 35302 35606.7 35968.8 36277.1 36418.4 -34978.6 35076.5 35302 35572.3 35799.5 35898.8 -34903.3 34978.6 35163.7 35388.4 35574.5 35650.6 +35650.6 35898.8 36418.4 37029.2 37559.5 37817.3 +35574.5 35799.5 36277.1 36840 37326.6 37559.5 +35388.4 35572.3 35968.8 36437.5 36840 37029.2 +35163.7 35302 35606.7 35968.8 36277.1 36418.4 +34978.6 35076.5 35302 35572.3 35799.5 35898.8 +34903.3 34978.6 35163.7 35388.4 35574.5 35650.6 Final statistics for this run: - ARKStep real workspace length = 3554 - ARKStep integer workspace length = 131 - ARKLS real workspace length = 2647 - ARKLS integer workspace length = 42 - Number of steps = 266 - Number of f-s (explicit) = 0 - Number of f-s (implicit) = 4394 - Number of f-s (SPGMR) = 8980 - Number of f-s (TOTAL) = 8980 - Number of setups = 121 - Number of nonlinear iterations = 2941 - Number of linear iterations = 8980 - Number of preconditioner evaluations = 121 - Number of preconditioner solves = 11819 - Number of error test failures = 23 - Number of nonlinear conv. failures = 17 - Number of linear convergence failures = 509 - Average Krylov subspace dimension = 3.053 + ARKStep real workspace length = 3554 + ARKStep integer workspace length = 131 + ARKLS real workspace length = 2647 + ARKLS integer workspace length = 42 + Number of steps = 266 + Number of f-s (explicit) = 0 + Number of f-s (implicit) = 4394 + Number of f-s (SPGMR) = 8980 + Number of f-s (TOTAL) = 8980 + Number of setups = 121 + Number of nonlinear iterations = 2941 + Number of linear iterations = 8980 + Number of preconditioner evaluations = 121 + Number of preconditioner solves = 11819 + Number of error test failures = 23 + Number of nonlinear conv. failures = 17 + Number of linear convergence failures = 509 + Average Krylov subspace dimension = 3.053 ---------------------------------------------------------------------------- @@ -487,24 +487,24 @@ t = 1.00e+01 nst = 251 nfe = 0 nfi = 4101 nni = 2746 hu = 7.09e-02 Final statistics for this run: - ARKStep real workspace length = 3554 - ARKStep integer workspace length = 131 - ARKLS real workspace length = 2647 - ARKLS integer workspace length = 42 - Number of steps = 251 - Number of f-s (explicit) = 0 - Number of f-s (implicit) = 4101 - Number of f-s (SPGMR) = 8880 - Number of f-s (TOTAL) = 8880 - Number of setups = 91 - Number of nonlinear iterations = 2746 - Number of linear iterations = 8880 - Number of preconditioner evaluations = 91 - Number of preconditioner solves = 11537 - Number of error test failures = 18 - Number of nonlinear conv. failures = 13 - Number of linear convergence failures = 597 - Average Krylov subspace dimension = 3.234 + ARKStep real workspace length = 3554 + ARKStep integer workspace length = 136 + ARKLS real workspace length = 2647 + ARKLS integer workspace length = 42 + Number of steps = 251 + Number of f-s (explicit) = 0 + Number of f-s (implicit) = 4101 + Number of f-s (SPGMR) = 8880 + Number of f-s (TOTAL) = 8880 + Number of setups = 91 + Number of nonlinear iterations = 2746 + Number of linear iterations = 8880 + Number of preconditioner evaluations = 91 + Number of preconditioner solves = 11537 + Number of error test failures = 18 + Number of nonlinear conv. failures = 13 + Number of linear convergence failures = 597 + Average Krylov subspace dimension = 3.234 ---------------------------------------------------------------------------- @@ -556,24 +556,24 @@ t = 1.00e+01 nst = 359 nfe = 0 nfi = 5722 nni = 3907 hu = 1.35e-01 Final statistics for this run: - ARKStep real workspace length = 3554 - ARKStep integer workspace length = 131 - ARKLS real workspace length = 2647 - ARKLS integer workspace length = 42 - Number of steps = 359 - Number of f-s (explicit) = 0 - Number of f-s (implicit) = 5722 - Number of f-s (SPGMR) = 12904 - Number of f-s (TOTAL) = 12904 - Number of setups = 253 - Number of nonlinear iterations = 3907 - Number of linear iterations = 12904 - Number of preconditioner evaluations = 253 - Number of preconditioner solves = 16594 - Number of error test failures = 0 - Number of nonlinear conv. failures = 117 - Number of linear convergence failures = 1072 - Average Krylov subspace dimension = 3.303 + ARKStep real workspace length = 3554 + ARKStep integer workspace length = 141 + ARKLS real workspace length = 2647 + ARKLS integer workspace length = 42 + Number of steps = 359 + Number of f-s (explicit) = 0 + Number of f-s (implicit) = 5722 + Number of f-s (SPGMR) = 12904 + Number of f-s (TOTAL) = 12904 + Number of setups = 253 + Number of nonlinear iterations = 3907 + Number of linear iterations = 12904 + Number of preconditioner evaluations = 253 + Number of preconditioner solves = 16594 + Number of error test failures = 0 + Number of nonlinear conv. failures = 117 + Number of linear convergence failures = 1072 + Average Krylov subspace dimension = 3.303 ---------------------------------------------------------------------------- @@ -625,24 +625,24 @@ t = 1.00e+01 nst = 359 nfe = 0 nfi = 5728 nni = 3912 hu = 1.31e-01 Final statistics for this run: - ARKStep real workspace length = 3554 - ARKStep integer workspace length = 131 - ARKLS real workspace length = 2647 - ARKLS integer workspace length = 42 - Number of steps = 359 - Number of f-s (explicit) = 0 - Number of f-s (implicit) = 5728 - Number of f-s (SPGMR) = 12934 - Number of f-s (TOTAL) = 12934 - Number of setups = 254 - Number of nonlinear iterations = 3912 - Number of linear iterations = 12934 - Number of preconditioner evaluations = 254 - Number of preconditioner solves = 16627 - Number of error test failures = 0 - Number of nonlinear conv. failures = 118 - Number of linear convergence failures = 1076 - Average Krylov subspace dimension = 3.306 + ARKStep real workspace length = 3554 + ARKStep integer workspace length = 146 + ARKLS real workspace length = 2647 + ARKLS integer workspace length = 42 + Number of steps = 359 + Number of f-s (explicit) = 0 + Number of f-s (implicit) = 5728 + Number of f-s (SPGMR) = 12934 + Number of f-s (TOTAL) = 12934 + Number of setups = 254 + Number of nonlinear iterations = 3912 + Number of linear iterations = 12934 + Number of preconditioner evaluations = 254 + Number of preconditioner solves = 16627 + Number of error test failures = 0 + Number of nonlinear conv. failures = 118 + Number of linear convergence failures = 1076 + Average Krylov subspace dimension = 3.306 ---------------------------------------------------------------------------- diff --git a/include/sunadaptcontroller/sunadaptcontroller_expgus.h b/include/sunadaptcontroller/sunadaptcontroller_expgus.h index a9ee827fd8..ce1a5bffeb 100644 --- a/include/sunadaptcontroller/sunadaptcontroller_expgus.h +++ b/include/sunadaptcontroller/sunadaptcontroller_expgus.h @@ -33,7 +33,6 @@ struct _SUNAdaptControllerContent_ExpGus { sunrealtype k2; sunrealtype bias; /* error bias factor */ sunrealtype ep; /* error from previous step */ - int p; /* method/embedding order of accuracy */ sunbooleantype firststep; /* flag indicating first step */ }; @@ -52,7 +51,7 @@ SUNDIALS_EXPORT SUNAdaptController_Type SUNAdaptController_GetType_ExpGus(SUNAdaptController C); SUNDIALS_EXPORT int SUNAdaptController_EstimateStep_ExpGus(SUNAdaptController C, sunrealtype h, - sunrealtype dsm, sunrealtype* hnew); + int p, sunrealtype dsm, sunrealtype* hnew); SUNDIALS_EXPORT int SUNAdaptController_Reset_ExpGus(SUNAdaptController C); SUNDIALS_EXPORT @@ -60,8 +59,6 @@ int SUNAdaptController_SetDefaults_ExpGus(SUNAdaptController C); SUNDIALS_EXPORT int SUNAdaptController_Write_ExpGus(SUNAdaptController C, FILE* fptr); SUNDIALS_EXPORT -int SUNAdaptController_SetMethodOrder_ExpGus(SUNAdaptController C, int p); -SUNDIALS_EXPORT int SUNAdaptController_SetErrorBias_ExpGus(SUNAdaptController C, sunrealtype bias); SUNDIALS_EXPORT int SUNAdaptController_Update_ExpGus(SUNAdaptController C, sunrealtype h, sunrealtype dsm); diff --git a/include/sunadaptcontroller/sunadaptcontroller_i.h b/include/sunadaptcontroller/sunadaptcontroller_i.h index e4446c09ab..1dda7b0a74 100644 --- a/include/sunadaptcontroller/sunadaptcontroller_i.h +++ b/include/sunadaptcontroller/sunadaptcontroller_i.h @@ -31,7 +31,6 @@ extern "C" { struct _SUNAdaptControllerContent_I { sunrealtype k1; /* internal controller parameters */ sunrealtype bias; /* error bias factor */ - int p; /* method/embedding order of accuracy */ }; typedef struct _SUNAdaptControllerContent_I *SUNAdaptControllerContent_I; @@ -48,14 +47,12 @@ SUNDIALS_EXPORT SUNAdaptController_Type SUNAdaptController_GetType_I(SUNAdaptController C); SUNDIALS_EXPORT int SUNAdaptController_EstimateStep_I(SUNAdaptController C, sunrealtype h, - sunrealtype dsm, sunrealtype* hnew); + int p, sunrealtype dsm, sunrealtype* hnew); SUNDIALS_EXPORT int SUNAdaptController_SetDefaults_I(SUNAdaptController C); SUNDIALS_EXPORT int SUNAdaptController_Write_I(SUNAdaptController C, FILE* fptr); SUNDIALS_EXPORT -int SUNAdaptController_SetMethodOrder_I(SUNAdaptController C, int p); -SUNDIALS_EXPORT int SUNAdaptController_SetErrorBias_I(SUNAdaptController C, sunrealtype bias); SUNDIALS_EXPORT int SUNAdaptController_Space_I(SUNAdaptController C, long int *lenrw, diff --git a/include/sunadaptcontroller/sunadaptcontroller_imexgus.h b/include/sunadaptcontroller/sunadaptcontroller_imexgus.h index 322adc3c29..c1fed3044f 100644 --- a/include/sunadaptcontroller/sunadaptcontroller_imexgus.h +++ b/include/sunadaptcontroller/sunadaptcontroller_imexgus.h @@ -36,7 +36,6 @@ struct _SUNAdaptControllerContent_ImExGus { sunrealtype bias; /* error bias factor */ sunrealtype ep; /* error from previous step */ sunrealtype hp; /* previous step size */ - int p; /* method/embedding order of accuracy */ sunbooleantype firststep; /* flag indicating first step */ }; @@ -56,7 +55,7 @@ SUNDIALS_EXPORT SUNAdaptController_Type SUNAdaptController_GetType_ImExGus(SUNAdaptController C); SUNDIALS_EXPORT int SUNAdaptController_EstimateStep_ImExGus(SUNAdaptController C, sunrealtype h, - sunrealtype dsm, sunrealtype* hnew); + int p, sunrealtype dsm, sunrealtype* hnew); SUNDIALS_EXPORT int SUNAdaptController_Reset_ImExGus(SUNAdaptController C); SUNDIALS_EXPORT @@ -64,8 +63,6 @@ int SUNAdaptController_SetDefaults_ImExGus(SUNAdaptController C); SUNDIALS_EXPORT int SUNAdaptController_Write_ImExGus(SUNAdaptController C, FILE* fptr); SUNDIALS_EXPORT -int SUNAdaptController_SetMethodOrder_ImExGus(SUNAdaptController C, int p); -SUNDIALS_EXPORT int SUNAdaptController_SetErrorBias_ImExGus(SUNAdaptController C, sunrealtype bias); SUNDIALS_EXPORT int SUNAdaptController_Update_ImExGus(SUNAdaptController C, sunrealtype h, sunrealtype dsm); diff --git a/include/sunadaptcontroller/sunadaptcontroller_impgus.h b/include/sunadaptcontroller/sunadaptcontroller_impgus.h index 21216145cd..79832c7bfb 100644 --- a/include/sunadaptcontroller/sunadaptcontroller_impgus.h +++ b/include/sunadaptcontroller/sunadaptcontroller_impgus.h @@ -34,7 +34,6 @@ struct _SUNAdaptControllerContent_ImpGus { sunrealtype bias; /* error bias factor */ sunrealtype ep; /* error from previous step */ sunrealtype hp; /* previous step size */ - int p; /* method/embedding order of accuracy */ sunbooleantype firststep; /* flag indicating first step */ }; @@ -53,7 +52,7 @@ SUNDIALS_EXPORT SUNAdaptController_Type SUNAdaptController_GetType_ImpGus(SUNAdaptController C); SUNDIALS_EXPORT int SUNAdaptController_EstimateStep_ImpGus(SUNAdaptController C, sunrealtype h, - sunrealtype dsm, sunrealtype* hnew); + int p, sunrealtype dsm, sunrealtype* hnew); SUNDIALS_EXPORT int SUNAdaptController_Reset_ImpGus(SUNAdaptController C); SUNDIALS_EXPORT @@ -61,8 +60,6 @@ int SUNAdaptController_SetDefaults_ImpGus(SUNAdaptController C); SUNDIALS_EXPORT int SUNAdaptController_Write_ImpGus(SUNAdaptController C, FILE* fptr); SUNDIALS_EXPORT -int SUNAdaptController_SetMethodOrder_ImpGus(SUNAdaptController C, int p); -SUNDIALS_EXPORT int SUNAdaptController_SetErrorBias_ImpGus(SUNAdaptController C, sunrealtype bias); SUNDIALS_EXPORT int SUNAdaptController_Update_ImpGus(SUNAdaptController C, sunrealtype h, sunrealtype dsm); diff --git a/include/sunadaptcontroller/sunadaptcontroller_pi.h b/include/sunadaptcontroller/sunadaptcontroller_pi.h index 5c0d332988..0e71ae6ab6 100644 --- a/include/sunadaptcontroller/sunadaptcontroller_pi.h +++ b/include/sunadaptcontroller/sunadaptcontroller_pi.h @@ -33,7 +33,6 @@ struct _SUNAdaptControllerContent_PI { sunrealtype k2; sunrealtype bias; /* error bias factor */ sunrealtype ep; /* error from previous step */ - int p; /* method/embedding order of accuracy */ }; typedef struct _SUNAdaptControllerContent_PI *SUNAdaptControllerContent_PI; @@ -51,7 +50,7 @@ SUNDIALS_EXPORT SUNAdaptController_Type SUNAdaptController_GetType_PI(SUNAdaptController C); SUNDIALS_EXPORT int SUNAdaptController_EstimateStep_PI(SUNAdaptController C, sunrealtype h, - sunrealtype dsm, sunrealtype* hnew); + int p, sunrealtype dsm, sunrealtype* hnew); SUNDIALS_EXPORT int SUNAdaptController_Reset_PI(SUNAdaptController C); SUNDIALS_EXPORT @@ -59,8 +58,6 @@ int SUNAdaptController_SetDefaults_PI(SUNAdaptController C); SUNDIALS_EXPORT int SUNAdaptController_Write_PI(SUNAdaptController C, FILE* fptr); SUNDIALS_EXPORT -int SUNAdaptController_SetMethodOrder_PI(SUNAdaptController C, int p); -SUNDIALS_EXPORT int SUNAdaptController_SetErrorBias_PI(SUNAdaptController C, sunrealtype bias); SUNDIALS_EXPORT int SUNAdaptController_Update_PI(SUNAdaptController C, sunrealtype h, sunrealtype dsm); diff --git a/include/sunadaptcontroller/sunadaptcontroller_pid.h b/include/sunadaptcontroller/sunadaptcontroller_pid.h index 2e01264c43..674e81bc0e 100644 --- a/include/sunadaptcontroller/sunadaptcontroller_pid.h +++ b/include/sunadaptcontroller/sunadaptcontroller_pid.h @@ -35,7 +35,6 @@ struct _SUNAdaptControllerContent_PID { sunrealtype bias; /* error bias factor */ sunrealtype ep; /* error from previous step */ sunrealtype epp; /* error from 2 steps ago */ - int p; /* method/embedding order of accuracy */ }; typedef struct _SUNAdaptControllerContent_PID *SUNAdaptControllerContent_PID; @@ -53,7 +52,7 @@ SUNDIALS_EXPORT SUNAdaptController_Type SUNAdaptController_GetType_PID(SUNAdaptController C); SUNDIALS_EXPORT int SUNAdaptController_EstimateStep_PID(SUNAdaptController C, sunrealtype h, - sunrealtype dsm, sunrealtype* hnew); + int p, sunrealtype dsm, sunrealtype* hnew); SUNDIALS_EXPORT int SUNAdaptController_Reset_PID(SUNAdaptController C); SUNDIALS_EXPORT @@ -61,8 +60,6 @@ int SUNAdaptController_SetDefaults_PID(SUNAdaptController C); SUNDIALS_EXPORT int SUNAdaptController_Write_PID(SUNAdaptController C, FILE* fptr); SUNDIALS_EXPORT -int SUNAdaptController_SetMethodOrder_PID(SUNAdaptController C, int p); -SUNDIALS_EXPORT int SUNAdaptController_SetErrorBias_PID(SUNAdaptController C, sunrealtype bias); SUNDIALS_EXPORT int SUNAdaptController_Update_PID(SUNAdaptController C, sunrealtype h, sunrealtype dsm); diff --git a/include/sundials/sundials_adaptcontroller.h b/include/sundials/sundials_adaptcontroller.h index 11396e1b70..604b239ae6 100644 --- a/include/sundials/sundials_adaptcontroller.h +++ b/include/sundials/sundials_adaptcontroller.h @@ -34,7 +34,7 @@ extern "C" { * others are planned): * NONE - empty controller (does nothing) * H - controls a single-rate step size - * HQ - controls a single-rate step size and method order + * HP - controls a single-rate step size and method order * MRI_H - controls two multirate step sizes * MRI_TOL - controls slow and fast relative tolerances * ----------------------------------------------------------------- */ @@ -43,7 +43,7 @@ typedef enum { SUN_ADAPTCONTROLLER_NONE, SUN_ADAPTCONTROLLER_H, - SUN_ADAPTCONTROLLER_HQ, + SUN_ADAPTCONTROLLER_HP, SUN_ADAPTCONTROLLER_MRI_H, SUN_ADAPTCONTROLLER_MRI_TOL } SUNAdaptController_Type; @@ -65,21 +65,22 @@ struct _generic_SUNAdaptController_Ops SUNAdaptController_Type (*gettype)(SUNAdaptController C); /* REQUIRED for controllers of SUN_ADAPTCONTROLLER_H type. */ - int (*estimatestep)(SUNAdaptController C, sunrealtype h, + int (*estimatestep)(SUNAdaptController C, sunrealtype h, int p, sunrealtype dsm, sunrealtype* hnew); - /* REQUIRED for controllers of SUN_ADAPTCONTROLLER_HQ type. */ - int (*estimatestepandorder)(SUNAdaptController C, sunrealtype h, int q, - sunrealtype dsm, sunrealtype* hnew, int *qnew); + /* REQUIRED for controllers of SUN_ADAPTCONTROLLER_HP type. */ + int (*estimatestepandorder)(SUNAdaptController C, sunrealtype h, int p, + sunrealtype dsm, sunrealtype* hnew, int *pnew); /* REQUIRED for controllers of SUN_ADAPTCONTROLLER_MRI_H type. */ int (*estimatemristeps)(SUNAdaptController C, sunrealtype H, sunrealtype h, - sunrealtype DSM, sunrealtype dsm, + int P, int p, sunrealtype DSM, sunrealtype dsm, sunrealtype* Hnew, sunrealtype *hnew); /* REQUIRED for controllers of SUN_ADAPTCONTROLLER_MRI_TOL type. */ - int (*estimatesteptol)(SUNAdaptController C, sunrealtype H, sunrealtype tolfac, - sunrealtype DSM, sunrealtype dsm, sunrealtype *Hnew, + int (*estimatesteptol)(SUNAdaptController C, sunrealtype H, int P, + sunrealtype tolfac, sunrealtype DSM, + sunrealtype dsm, sunrealtype *Hnew, sunrealtype* tolfacnew); /* OPTIONAL for all SUNAdaptController implementations. */ @@ -87,7 +88,6 @@ struct _generic_SUNAdaptController_Ops int (*reset)(SUNAdaptController C); int (*setdefaults)(SUNAdaptController C); int (*write)(SUNAdaptController C, FILE* fptr); - int (*setmethodorder)(SUNAdaptController C, int p); int (*seterrorbias)(SUNAdaptController C, sunrealtype bias); int (*update)(SUNAdaptController C, sunrealtype h, sunrealtype dsm); int (*updatemrih)(SUNAdaptController C, sunrealtype H, sunrealtype h, @@ -135,17 +135,17 @@ int SUNAdaptController_Destroy(SUNAdaptController C); an unrecoverable failure. */ SUNDIALS_EXPORT int SUNAdaptController_EstimateStep(SUNAdaptController C, sunrealtype h, - sunrealtype dsm, sunrealtype* hnew); + int p, sunrealtype dsm, sunrealtype* hnew); /* Combined step size + order controller function. This is called - following a time step with size 'h' and order 'q' that has local + following a time step with size 'h' and order 'p' that has local error factor 'dsm'. The controller should estimate 'hnew' and - 'qnew' so that the ensuing step will have 'dsm' value JUST BELOW 1 + 'pnew' so that the ensuing step will have 'dsm' value JUST BELOW 1 with minimal computational effort. */ SUNDIALS_EXPORT int SUNAdaptController_EstimateStepAndOrder(SUNAdaptController C, sunrealtype h, - int q, sunrealtype dsm, - sunrealtype* hnew, int *qnew); + int p, sunrealtype dsm, + sunrealtype* hnew, int *pnew); /* Combined slow/fast multirate step size controller function. This is called following a slow multirate time step with sizes 'H' and @@ -156,7 +156,8 @@ int SUNAdaptController_EstimateStepAndOrder(SUNAdaptController C, sunrealtype h, effort. */ SUNDIALS_EXPORT int SUNAdaptController_EstimateMRISteps(SUNAdaptController C, sunrealtype H, - sunrealtype h, sunrealtype DSM, sunrealtype dsm, + sunrealtype h, int P, int p, + sunrealtype DSM, sunrealtype dsm, sunrealtype* Hnew, sunrealtype *hnew); /* Combined slow step/fast tolerance multirate controller function. @@ -168,7 +169,7 @@ int SUNAdaptController_EstimateMRISteps(SUNAdaptController C, sunrealtype H, values JUST BELOW 1 with minimal computational effort. */ SUNDIALS_EXPORT int SUNAdaptController_EstimateStepTol(SUNAdaptController C, sunrealtype H, - sunrealtype tolfac, sunrealtype DSM, + int P, sunrealtype tolfac, sunrealtype DSM, sunrealtype dsm, sunrealtype *Hnew, sunrealtype* tolfacnew); @@ -186,11 +187,6 @@ int SUNAdaptController_SetDefaults(SUNAdaptController C); SUNDIALS_EXPORT int SUNAdaptController_Write(SUNAdaptController C, FILE* fptr); -/* Function to set the asymptotic order of accuracy for the method and - its embedding. */ -SUNDIALS_EXPORT -int SUNAdaptController_SetMethodOrder(SUNAdaptController C, int p); - /* Function to set an error bias factor to use for scaling the local error 'dsm' factors above. */ SUNDIALS_EXPORT diff --git a/src/arkode/arkode_adapt.c b/src/arkode/arkode_adapt.c index e73437bd96..afe0dfe61b 100644 --- a/src/arkode/arkode_adapt.c +++ b/src/arkode/arkode_adapt.c @@ -100,6 +100,7 @@ int arkAdapt(void* arkode_mem, ARKodeHAdaptMem hadapt_mem, int retval; realtype h_acc, h_cfl, int_dir; ARKodeMem ark_mem; + int controller_order; if (arkode_mem == NULL) { arkProcessError(NULL, ARK_MEM_NULL, "ARKODE", "arkAdapt", MSG_ARK_NO_MEM); @@ -108,8 +109,15 @@ int arkAdapt(void* arkode_mem, ARKodeHAdaptMem hadapt_mem, ark_mem = (ARKodeMem) arkode_mem; /* Request error-based step size from adaptivity controller */ - retval = SUNAdaptController_EstimateStep(hadapt_mem->hcontroller, - hcur, dsm, &h_acc); + if (hadapt_mem->pq == 0) { + controller_order = hadapt_mem->p + hadapt_mem->adjust; + } else if (hadapt_mem->pq == 1) { + controller_order = hadapt_mem->q + hadapt_mem->adjust; + } else { + controller_order = SUNMIN(hadapt_mem->p, hadapt_mem->q) + hadapt_mem->adjust; + } + retval = SUNAdaptController_EstimateStep(hadapt_mem->hcontroller, hcur, + controller_order, dsm, &h_acc); if (retval != SUNADAPTCONTROLLER_SUCCESS) { arkProcessError(ark_mem, ARK_CONTROLLER_ERR, "ARKODE", "arkAdapt", "SUNAdaptController_EstimateStep failure."); diff --git a/src/arkode/arkode_arkstep.c b/src/arkode/arkode_arkstep.c index d7b9baf832..e1245168e0 100644 --- a/src/arkode/arkode_arkstep.c +++ b/src/arkode/arkode_arkstep.c @@ -1085,7 +1085,7 @@ int arkStep_Init(void* arkode_mem, int init_type) { ARKodeMem ark_mem; ARKodeARKStepMem step_mem; - int j, retval, controller_order; + int j, retval; booleantype reset_efun; /* access ARKodeARKStepMem structure */ @@ -1140,19 +1140,6 @@ int arkStep_Init(void* arkode_mem, int init_type) step_mem->q = ark_mem->hadapt_mem->q = step_mem->Be->q; step_mem->p = ark_mem->hadapt_mem->p = step_mem->Be->p; } - if (ark_mem->hadapt_mem->pq == 0) { - controller_order = step_mem->p + ark_mem->hadapt_mem->adjust; - } else if (ark_mem->hadapt_mem->pq == 1) { - controller_order = step_mem->q + ark_mem->hadapt_mem->adjust; - } else { - controller_order = SUNMIN(step_mem->p, step_mem->q) + ark_mem->hadapt_mem->adjust; - } - retval = SUNAdaptController_SetMethodOrder(ark_mem->hadapt_mem->hcontroller, controller_order); - if (retval != SUNADAPTCONTROLLER_SUCCESS) { - arkProcessError(ark_mem, ARK_CONTROLLER_ERR, "ARKODE::ARKStep", - "arkStep_Init", "SUNAdaptController_SetMethodOrder error"); - return(ARK_CONTROLLER_ERR); - } /* Ensure that if adaptivity is enabled, then method includes embedding coefficients */ if (!ark_mem->fixedstep && (step_mem->p == 0)) { diff --git a/src/arkode/arkode_erkstep.c b/src/arkode/arkode_erkstep.c index caa72fd9e3..f21aa2602b 100644 --- a/src/arkode/arkode_erkstep.c +++ b/src/arkode/arkode_erkstep.c @@ -501,7 +501,7 @@ int erkStep_Init(void* arkode_mem, int init_type) { ARKodeMem ark_mem; ARKodeERKStepMem step_mem; - int retval, j, controller_order; + int retval, j; /* access ARKodeERKStepMem structure */ retval = erkStep_AccessStepMem(arkode_mem, "erkStep_Init", @@ -539,19 +539,6 @@ int erkStep_Init(void* arkode_mem, int init_type) /* Retrieve/store method and embedding orders now that table is finalized */ step_mem->q = ark_mem->hadapt_mem->q = step_mem->B->q; step_mem->p = ark_mem->hadapt_mem->p = step_mem->B->p; - if (ark_mem->hadapt_mem->pq == 0) { - controller_order = step_mem->p + ark_mem->hadapt_mem->adjust; - } else if (ark_mem->hadapt_mem->pq == 1) { - controller_order = step_mem->q + ark_mem->hadapt_mem->adjust; - } else { - controller_order = SUNMIN(step_mem->p, step_mem->q) + ark_mem->hadapt_mem->adjust; - } - retval = SUNAdaptController_SetMethodOrder(ark_mem->hadapt_mem->hcontroller, controller_order); - if (retval != SUNADAPTCONTROLLER_SUCCESS) { - arkProcessError(ark_mem, ARK_CONTROLLER_ERR, "ARKODE::ERKStep", - "erkStep_Init", "SUNAdaptControllerSetMethodOrder error"); - return(ARK_CONTROLLER_ERR); - } /* Ensure that if adaptivity is enabled, then method includes embedding coefficients */ if (!ark_mem->fixedstep && (step_mem->p == 0)) { diff --git a/src/arkode/arkode_user_controller.c b/src/arkode/arkode_user_controller.c index c24dd599b8..48013d28bf 100644 --- a/src/arkode/arkode_user_controller.c +++ b/src/arkode/arkode_user_controller.c @@ -83,10 +83,6 @@ SUNAdaptController ARKUserControl(SUNContext sunctx, void* arkode_mem, content->hadapt = hadapt; content->hadapt_data = hadapt_data; - /* Initialize method and embedding orders */ - content->p = 1; - content->q = 1; - /* Fill content with default/reset values */ SUNAdaptController_Reset_ARKUserControl(C); @@ -102,7 +98,7 @@ SUNAdaptController_Type SUNAdaptController_GetType_ARKUserControl(SUNAdaptContro { return SUN_ADAPTCONTROLLER_H; } int SUNAdaptController_EstimateStep_ARKUserControl(SUNAdaptController C, realtype h, - realtype dsm, realtype* hnew) + int p, realtype dsm, realtype* hnew) { /* call user-provided function to compute new step */ sunrealtype ttmp = (dsm <= ONE) ? SC_ARKMEM(C)->tn + SC_ARKMEM(C)->h : SC_ARKMEM(C)->tn; @@ -154,6 +150,6 @@ int SUNAdaptController_Space_ARKUserControl(SUNAdaptController C, long int* lenr long int* leniw) { *lenrw = 4; - *leniw = 5; + *leniw = 2; return SUNADAPTCONTROLLER_SUCCESS; } diff --git a/src/arkode/arkode_user_controller.h b/src/arkode/arkode_user_controller.h index b348fdeb7b..a435331dde 100644 --- a/src/arkode/arkode_user_controller.h +++ b/src/arkode/arkode_user_controller.h @@ -36,8 +36,6 @@ struct _ARKUserControlContent { realtype hpp; /* h from 2 steps ago */ realtype ep; /* error from previous step */ realtype epp; /* error from 2 steps ago */ - int p; /* embedding order of accuracy */ - int q; /* method order of accuracy */ ARKodeMem ark_mem; /* main ARKODE memory structure */ ARKAdaptFn hadapt; /* user-provided adaptivity fn */ void* hadapt_data; /* user-provided data pointer */ @@ -56,7 +54,7 @@ SUNDIALS_EXPORT SUNAdaptController_Type SUNAdaptController_GetType_ARKUserControl(SUNAdaptController C); SUNDIALS_EXPORT int SUNAdaptController_EstimateStep_ARKUserControl(SUNAdaptController C, realtype h, - realtype dsm, realtype* hnew); + int p, realtype dsm, realtype* hnew); SUNDIALS_EXPORT int SUNAdaptController_Reset_ARKUserControl(SUNAdaptController C); SUNDIALS_EXPORT diff --git a/src/sunadaptcontroller/expgus/fmod/fsunadaptcontroller_expgus_mod.c b/src/sunadaptcontroller/expgus/fmod/fsunadaptcontroller_expgus_mod.c index 058558046e..1243240dde 100644 --- a/src/sunadaptcontroller/expgus/fmod/fsunadaptcontroller_expgus_mod.c +++ b/src/sunadaptcontroller/expgus/fmod/fsunadaptcontroller_expgus_mod.c @@ -248,19 +248,21 @@ SWIGEXPORT int _wrap_FSUNAdaptController_GetType_ExpGus(SUNAdaptController farg1 } -SWIGEXPORT int _wrap_FSUNAdaptController_EstimateStep_ExpGus(SUNAdaptController farg1, double const *farg2, double const *farg3, double *farg4) { +SWIGEXPORT int _wrap_FSUNAdaptController_EstimateStep_ExpGus(SUNAdaptController farg1, double const *farg2, int const *farg3, double const *farg4, double *farg5) { int fresult ; SUNAdaptController arg1 = (SUNAdaptController) 0 ; sunrealtype arg2 ; - sunrealtype arg3 ; - sunrealtype *arg4 = (sunrealtype *) 0 ; + int arg3 ; + sunrealtype arg4 ; + sunrealtype *arg5 = (sunrealtype *) 0 ; int result; arg1 = (SUNAdaptController)(farg1); arg2 = (sunrealtype)(*farg2); - arg3 = (sunrealtype)(*farg3); - arg4 = (sunrealtype *)(farg4); - result = (int)SUNAdaptController_EstimateStep_ExpGus(arg1,arg2,arg3,arg4); + arg3 = (int)(*farg3); + arg4 = (sunrealtype)(*farg4); + arg5 = (sunrealtype *)(farg5); + result = (int)SUNAdaptController_EstimateStep_ExpGus(arg1,arg2,arg3,arg4,arg5); fresult = (int)(result); return fresult; } @@ -304,20 +306,6 @@ SWIGEXPORT int _wrap_FSUNAdaptController_Write_ExpGus(SUNAdaptController farg1, } -SWIGEXPORT int _wrap_FSUNAdaptController_SetMethodOrder_ExpGus(SUNAdaptController farg1, int const *farg2) { - int fresult ; - SUNAdaptController arg1 = (SUNAdaptController) 0 ; - int arg2 ; - int result; - - arg1 = (SUNAdaptController)(farg1); - arg2 = (int)(*farg2); - result = (int)SUNAdaptController_SetMethodOrder_ExpGus(arg1,arg2); - fresult = (int)(result); - return fresult; -} - - SWIGEXPORT int _wrap_FSUNAdaptController_SetErrorBias_ExpGus(SUNAdaptController farg1, double const *farg2) { int fresult ; SUNAdaptController arg1 = (SUNAdaptController) 0 ; diff --git a/src/sunadaptcontroller/expgus/fmod/fsunadaptcontroller_expgus_mod.f90 b/src/sunadaptcontroller/expgus/fmod/fsunadaptcontroller_expgus_mod.f90 index b81cba0632..9271342406 100644 --- a/src/sunadaptcontroller/expgus/fmod/fsunadaptcontroller_expgus_mod.f90 +++ b/src/sunadaptcontroller/expgus/fmod/fsunadaptcontroller_expgus_mod.f90 @@ -34,7 +34,6 @@ module fsunadaptcontroller_expgus_mod public :: FSUNAdaptController_Reset_ExpGus public :: FSUNAdaptController_SetDefaults_ExpGus public :: FSUNAdaptController_Write_ExpGus - public :: FSUNAdaptController_SetMethodOrder_ExpGus public :: FSUNAdaptController_SetErrorBias_ExpGus public :: FSUNAdaptController_Update_ExpGus public :: FSUNAdaptController_Space_ExpGus @@ -67,14 +66,15 @@ function swigc_FSUNAdaptController_GetType_ExpGus(farg1) & integer(C_INT) :: fresult end function -function swigc_FSUNAdaptController_EstimateStep_ExpGus(farg1, farg2, farg3, farg4) & +function swigc_FSUNAdaptController_EstimateStep_ExpGus(farg1, farg2, farg3, farg4, farg5) & bind(C, name="_wrap_FSUNAdaptController_EstimateStep_ExpGus") & 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_PTR), value :: farg4 +integer(C_INT), intent(in) :: farg3 +real(C_DOUBLE), intent(in) :: farg4 +type(C_PTR), value :: farg5 integer(C_INT) :: fresult end function @@ -103,15 +103,6 @@ function swigc_FSUNAdaptController_Write_ExpGus(farg1, farg2) & integer(C_INT) :: fresult end function -function swigc_FSUNAdaptController_SetMethodOrder_ExpGus(farg1, farg2) & -bind(C, name="_wrap_FSUNAdaptController_SetMethodOrder_ExpGus") & -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_FSUNAdaptController_SetErrorBias_ExpGus(farg1, farg2) & bind(C, name="_wrap_FSUNAdaptController_SetErrorBias_ExpGus") & result(fresult) @@ -191,25 +182,28 @@ function FSUNAdaptController_GetType_ExpGus(c) & swig_result = fresult end function -function FSUNAdaptController_EstimateStep_ExpGus(c, h, dsm, hnew) & +function FSUNAdaptController_EstimateStep_ExpGus(c, h, p, dsm, hnew) & result(swig_result) use, intrinsic :: ISO_C_BINDING integer(C_INT) :: swig_result type(SUNAdaptController), target, intent(inout) :: c real(C_DOUBLE), intent(in) :: h +integer(C_INT), intent(in) :: p real(C_DOUBLE), intent(in) :: dsm real(C_DOUBLE), target, intent(inout) :: hnew integer(C_INT) :: fresult type(C_PTR) :: farg1 real(C_DOUBLE) :: farg2 -real(C_DOUBLE) :: farg3 -type(C_PTR) :: farg4 +integer(C_INT) :: farg3 +real(C_DOUBLE) :: farg4 +type(C_PTR) :: farg5 farg1 = c_loc(c) farg2 = h -farg3 = dsm -farg4 = c_loc(hnew) -fresult = swigc_FSUNAdaptController_EstimateStep_ExpGus(farg1, farg2, farg3, farg4) +farg3 = p +farg4 = dsm +farg5 = c_loc(hnew) +fresult = swigc_FSUNAdaptController_EstimateStep_ExpGus(farg1, farg2, farg3, farg4, farg5) swig_result = fresult end function @@ -255,22 +249,6 @@ function FSUNAdaptController_Write_ExpGus(c, fptr) & swig_result = fresult end function -function FSUNAdaptController_SetMethodOrder_ExpGus(c, p) & -result(swig_result) -use, intrinsic :: ISO_C_BINDING -integer(C_INT) :: swig_result -type(SUNAdaptController), target, intent(inout) :: c -integer(C_INT), intent(in) :: p -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -integer(C_INT) :: farg2 - -farg1 = c_loc(c) -farg2 = p -fresult = swigc_FSUNAdaptController_SetMethodOrder_ExpGus(farg1, farg2) -swig_result = fresult -end function - function FSUNAdaptController_SetErrorBias_ExpGus(c, bias) & result(swig_result) use, intrinsic :: ISO_C_BINDING diff --git a/src/sunadaptcontroller/expgus/sunadaptcontroller_expgus.c b/src/sunadaptcontroller/expgus/sunadaptcontroller_expgus.c index 2cd711f12d..1f6c7875e2 100644 --- a/src/sunadaptcontroller/expgus/sunadaptcontroller_expgus.c +++ b/src/sunadaptcontroller/expgus/sunadaptcontroller_expgus.c @@ -30,7 +30,6 @@ #define SACEXPGUS_K2(C) ( SACEXPGUS_CONTENT(C)->k2 ) #define SACEXPGUS_BIAS(C) ( SACEXPGUS_CONTENT(C)->bias ) #define SACEXPGUS_EP(C) ( SACEXPGUS_CONTENT(C)->ep ) -#define SACEXPGUS_P(C) ( SACEXPGUS_CONTENT(C)->p ) #define SACEXPGUS_FIRSTSTEP(C) ( SACEXPGUS_CONTENT(C)->firststep ) /* ------------------ @@ -67,7 +66,6 @@ SUNAdaptController SUNAdaptController_ExpGus(SUNContext sunctx) C->ops->reset = SUNAdaptController_Reset_ExpGus; C->ops->setdefaults = SUNAdaptController_SetDefaults_ExpGus; C->ops->write = SUNAdaptController_Write_ExpGus; - C->ops->setmethodorder = SUNAdaptController_SetMethodOrder_ExpGus; C->ops->seterrorbias = SUNAdaptController_SetErrorBias_ExpGus; C->ops->update = SUNAdaptController_Update_ExpGus; C->ops->space = SUNAdaptController_Space_ExpGus; @@ -84,9 +82,6 @@ SUNAdaptController SUNAdaptController_ExpGus(SUNContext sunctx) /* Attach content */ C->content = content; - /* Initialize method order */ - content->p = 1; - /* Fill content with default/reset values */ SUNAdaptController_SetDefaults_ExpGus(C); SUNAdaptController_Reset_ExpGus(C); @@ -117,10 +112,10 @@ SUNAdaptController_Type SUNAdaptController_GetType_ExpGus(SUNAdaptController C) { return SUN_ADAPTCONTROLLER_H; } int SUNAdaptController_EstimateStep_ExpGus(SUNAdaptController C, sunrealtype h, - sunrealtype dsm, sunrealtype* hnew) + int p, sunrealtype dsm, sunrealtype* hnew) { /* order parameter to use in controller */ - const int ord = SACEXPGUS_P(C) + 1; + const int ord = p + 1; /* modified method for first step */ if (SACEXPGUS_FIRSTSTEP(C)) @@ -178,15 +173,6 @@ int SUNAdaptController_Write_ExpGus(SUNAdaptController C, FILE *fptr) fprintf(fptr, " bias factor = %16g\n", SACEXPGUS_BIAS(C)); fprintf(fptr, " previous error = %16g\n", SACEXPGUS_EP(C)); #endif - fprintf(fptr, " p = %i\n", SACEXPGUS_P(C)); - return SUNADAPTCONTROLLER_SUCCESS; -} - -int SUNAdaptController_SetMethodOrder_ExpGus(SUNAdaptController C, int p) -{ - /* check for legal inputs */ - if (p < 0) { return SUNADAPTCONTROLLER_ILL_INPUT; } - SACEXPGUS_P(C) = p; return SUNADAPTCONTROLLER_SUCCESS; } @@ -212,6 +198,6 @@ int SUNAdaptController_Update_ExpGus(SUNAdaptController C, sunrealtype h, sunrea int SUNAdaptController_Space_ExpGus(SUNAdaptController C, long int* lenrw, long int* leniw) { *lenrw = 4; - *leniw = 2; + *leniw = 1; return SUNADAPTCONTROLLER_SUCCESS; } diff --git a/src/sunadaptcontroller/i/fmod/fsunadaptcontroller_i_mod.c b/src/sunadaptcontroller/i/fmod/fsunadaptcontroller_i_mod.c index c22e175cae..bae2663a6e 100644 --- a/src/sunadaptcontroller/i/fmod/fsunadaptcontroller_i_mod.c +++ b/src/sunadaptcontroller/i/fmod/fsunadaptcontroller_i_mod.c @@ -246,19 +246,21 @@ SWIGEXPORT int _wrap_FSUNAdaptController_GetType_I(SUNAdaptController farg1) { } -SWIGEXPORT int _wrap_FSUNAdaptController_EstimateStep_I(SUNAdaptController farg1, double const *farg2, double const *farg3, double *farg4) { +SWIGEXPORT int _wrap_FSUNAdaptController_EstimateStep_I(SUNAdaptController farg1, double const *farg2, int const *farg3, double const *farg4, double *farg5) { int fresult ; SUNAdaptController arg1 = (SUNAdaptController) 0 ; sunrealtype arg2 ; - sunrealtype arg3 ; - sunrealtype *arg4 = (sunrealtype *) 0 ; + int arg3 ; + sunrealtype arg4 ; + sunrealtype *arg5 = (sunrealtype *) 0 ; int result; arg1 = (SUNAdaptController)(farg1); arg2 = (sunrealtype)(*farg2); - arg3 = (sunrealtype)(*farg3); - arg4 = (sunrealtype *)(farg4); - result = (int)SUNAdaptController_EstimateStep_I(arg1,arg2,arg3,arg4); + arg3 = (int)(*farg3); + arg4 = (sunrealtype)(*farg4); + arg5 = (sunrealtype *)(farg5); + result = (int)SUNAdaptController_EstimateStep_I(arg1,arg2,arg3,arg4,arg5); fresult = (int)(result); return fresult; } @@ -290,20 +292,6 @@ SWIGEXPORT int _wrap_FSUNAdaptController_Write_I(SUNAdaptController farg1, void } -SWIGEXPORT int _wrap_FSUNAdaptController_SetMethodOrder_I(SUNAdaptController farg1, int const *farg2) { - int fresult ; - SUNAdaptController arg1 = (SUNAdaptController) 0 ; - int arg2 ; - int result; - - arg1 = (SUNAdaptController)(farg1); - arg2 = (int)(*farg2); - result = (int)SUNAdaptController_SetMethodOrder_I(arg1,arg2); - fresult = (int)(result); - return fresult; -} - - SWIGEXPORT int _wrap_FSUNAdaptController_SetErrorBias_I(SUNAdaptController farg1, double const *farg2) { int fresult ; SUNAdaptController arg1 = (SUNAdaptController) 0 ; diff --git a/src/sunadaptcontroller/i/fmod/fsunadaptcontroller_i_mod.f90 b/src/sunadaptcontroller/i/fmod/fsunadaptcontroller_i_mod.f90 index eefe7f8281..df439405fb 100644 --- a/src/sunadaptcontroller/i/fmod/fsunadaptcontroller_i_mod.f90 +++ b/src/sunadaptcontroller/i/fmod/fsunadaptcontroller_i_mod.f90 @@ -33,7 +33,6 @@ module fsunadaptcontroller_i_mod public :: FSUNAdaptController_EstimateStep_I public :: FSUNAdaptController_SetDefaults_I public :: FSUNAdaptController_Write_I - public :: FSUNAdaptController_SetMethodOrder_I public :: FSUNAdaptController_SetErrorBias_I public :: FSUNAdaptController_Space_I @@ -64,14 +63,15 @@ function swigc_FSUNAdaptController_GetType_I(farg1) & integer(C_INT) :: fresult end function -function swigc_FSUNAdaptController_EstimateStep_I(farg1, farg2, farg3, farg4) & +function swigc_FSUNAdaptController_EstimateStep_I(farg1, farg2, farg3, farg4, farg5) & bind(C, name="_wrap_FSUNAdaptController_EstimateStep_I") & 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_PTR), value :: farg4 +integer(C_INT), intent(in) :: farg3 +real(C_DOUBLE), intent(in) :: farg4 +type(C_PTR), value :: farg5 integer(C_INT) :: fresult end function @@ -92,15 +92,6 @@ function swigc_FSUNAdaptController_Write_I(farg1, farg2) & integer(C_INT) :: fresult end function -function swigc_FSUNAdaptController_SetMethodOrder_I(farg1, farg2) & -bind(C, name="_wrap_FSUNAdaptController_SetMethodOrder_I") & -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_FSUNAdaptController_SetErrorBias_I(farg1, farg2) & bind(C, name="_wrap_FSUNAdaptController_SetErrorBias_I") & result(fresult) @@ -167,25 +158,28 @@ function FSUNAdaptController_GetType_I(c) & swig_result = fresult end function -function FSUNAdaptController_EstimateStep_I(c, h, dsm, hnew) & +function FSUNAdaptController_EstimateStep_I(c, h, p, dsm, hnew) & result(swig_result) use, intrinsic :: ISO_C_BINDING integer(C_INT) :: swig_result type(SUNAdaptController), target, intent(inout) :: c real(C_DOUBLE), intent(in) :: h +integer(C_INT), intent(in) :: p real(C_DOUBLE), intent(in) :: dsm real(C_DOUBLE), target, intent(inout) :: hnew integer(C_INT) :: fresult type(C_PTR) :: farg1 real(C_DOUBLE) :: farg2 -real(C_DOUBLE) :: farg3 -type(C_PTR) :: farg4 +integer(C_INT) :: farg3 +real(C_DOUBLE) :: farg4 +type(C_PTR) :: farg5 farg1 = c_loc(c) farg2 = h -farg3 = dsm -farg4 = c_loc(hnew) -fresult = swigc_FSUNAdaptController_EstimateStep_I(farg1, farg2, farg3, farg4) +farg3 = p +farg4 = dsm +farg5 = c_loc(hnew) +fresult = swigc_FSUNAdaptController_EstimateStep_I(farg1, farg2, farg3, farg4, farg5) swig_result = fresult end function @@ -218,22 +212,6 @@ function FSUNAdaptController_Write_I(c, fptr) & swig_result = fresult end function -function FSUNAdaptController_SetMethodOrder_I(c, p) & -result(swig_result) -use, intrinsic :: ISO_C_BINDING -integer(C_INT) :: swig_result -type(SUNAdaptController), target, intent(inout) :: c -integer(C_INT), intent(in) :: p -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -integer(C_INT) :: farg2 - -farg1 = c_loc(c) -farg2 = p -fresult = swigc_FSUNAdaptController_SetMethodOrder_I(farg1, farg2) -swig_result = fresult -end function - function FSUNAdaptController_SetErrorBias_I(c, bias) & result(swig_result) use, intrinsic :: ISO_C_BINDING diff --git a/src/sunadaptcontroller/i/sunadaptcontroller_i.c b/src/sunadaptcontroller/i/sunadaptcontroller_i.c index a7be43c228..f551a8f12d 100644 --- a/src/sunadaptcontroller/i/sunadaptcontroller_i.c +++ b/src/sunadaptcontroller/i/sunadaptcontroller_i.c @@ -28,7 +28,6 @@ #define SACI_CONTENT(C) ( (SUNAdaptControllerContent_I)(C->content) ) #define SACI_K1(C) ( SACI_CONTENT(C)->k1 ) #define SACI_BIAS(C) ( SACI_CONTENT(C)->bias ) -#define SACI_P(C) ( SACI_CONTENT(C)->p ) /* ------------------ * Default parameters @@ -62,7 +61,6 @@ SUNAdaptController SUNAdaptController_I(SUNContext sunctx) C->ops->estimatestep = SUNAdaptController_EstimateStep_I; C->ops->setdefaults = SUNAdaptController_SetDefaults_I; C->ops->write = SUNAdaptController_Write_I; - C->ops->setmethodorder = SUNAdaptController_SetMethodOrder_I; C->ops->seterrorbias = SUNAdaptController_SetErrorBias_I; C->ops->space = SUNAdaptController_Space_I; @@ -78,9 +76,6 @@ SUNAdaptController SUNAdaptController_I(SUNContext sunctx) /* Attach content */ C->content = content; - /* Initialize method order */ - content->p = 1; - /* Fill content with default values */ SUNAdaptController_SetDefaults_I(C); @@ -108,10 +103,10 @@ SUNAdaptController_Type SUNAdaptController_GetType_I(SUNAdaptController C) { return SUN_ADAPTCONTROLLER_H; } int SUNAdaptController_EstimateStep_I(SUNAdaptController C, sunrealtype h, - sunrealtype dsm, sunrealtype* hnew) + int p, sunrealtype dsm, sunrealtype* hnew) { /* set usable time-step adaptivity parameters */ - const int ord = SACI_P(C) + 1; + const int ord = p + 1; const sunrealtype k1 = -SACI_K1(C) / ord; const sunrealtype ecur = SACI_BIAS(C) * dsm; const sunrealtype e1 = SUNMAX(ecur, TINY); @@ -138,15 +133,6 @@ int SUNAdaptController_Write_I(SUNAdaptController C, FILE *fptr) fprintf(fptr, " k1 = %16g\n", SACI_K1(C)); fprintf(fptr, " bias factor = %16g\n", SACI_BIAS(C)); #endif - fprintf(fptr, " p = %i\n", SACI_P(C)); - return SUNADAPTCONTROLLER_SUCCESS; -} - -int SUNAdaptController_SetMethodOrder_I(SUNAdaptController C, int p) -{ - /* check for legal inputs */ - if (p < 0) { return SUNADAPTCONTROLLER_ILL_INPUT; } - SACI_P(C) = p; return SUNADAPTCONTROLLER_SUCCESS; } diff --git a/src/sunadaptcontroller/imexgus/fmod/fsunadaptcontroller_imexgus_mod.c b/src/sunadaptcontroller/imexgus/fmod/fsunadaptcontroller_imexgus_mod.c index 2fc2dacb67..d08b5811a1 100644 --- a/src/sunadaptcontroller/imexgus/fmod/fsunadaptcontroller_imexgus_mod.c +++ b/src/sunadaptcontroller/imexgus/fmod/fsunadaptcontroller_imexgus_mod.c @@ -252,19 +252,21 @@ SWIGEXPORT int _wrap_FSUNAdaptController_GetType_ImExGus(SUNAdaptController farg } -SWIGEXPORT int _wrap_FSUNAdaptController_EstimateStep_ImExGus(SUNAdaptController farg1, double const *farg2, double const *farg3, double *farg4) { +SWIGEXPORT int _wrap_FSUNAdaptController_EstimateStep_ImExGus(SUNAdaptController farg1, double const *farg2, int const *farg3, double const *farg4, double *farg5) { int fresult ; SUNAdaptController arg1 = (SUNAdaptController) 0 ; sunrealtype arg2 ; - sunrealtype arg3 ; - sunrealtype *arg4 = (sunrealtype *) 0 ; + int arg3 ; + sunrealtype arg4 ; + sunrealtype *arg5 = (sunrealtype *) 0 ; int result; arg1 = (SUNAdaptController)(farg1); arg2 = (sunrealtype)(*farg2); - arg3 = (sunrealtype)(*farg3); - arg4 = (sunrealtype *)(farg4); - result = (int)SUNAdaptController_EstimateStep_ImExGus(arg1,arg2,arg3,arg4); + arg3 = (int)(*farg3); + arg4 = (sunrealtype)(*farg4); + arg5 = (sunrealtype *)(farg5); + result = (int)SUNAdaptController_EstimateStep_ImExGus(arg1,arg2,arg3,arg4,arg5); fresult = (int)(result); return fresult; } @@ -308,20 +310,6 @@ SWIGEXPORT int _wrap_FSUNAdaptController_Write_ImExGus(SUNAdaptController farg1, } -SWIGEXPORT int _wrap_FSUNAdaptController_SetMethodOrder_ImExGus(SUNAdaptController farg1, int const *farg2) { - int fresult ; - SUNAdaptController arg1 = (SUNAdaptController) 0 ; - int arg2 ; - int result; - - arg1 = (SUNAdaptController)(farg1); - arg2 = (int)(*farg2); - result = (int)SUNAdaptController_SetMethodOrder_ImExGus(arg1,arg2); - fresult = (int)(result); - return fresult; -} - - SWIGEXPORT int _wrap_FSUNAdaptController_SetErrorBias_ImExGus(SUNAdaptController farg1, double const *farg2) { int fresult ; SUNAdaptController arg1 = (SUNAdaptController) 0 ; diff --git a/src/sunadaptcontroller/imexgus/fmod/fsunadaptcontroller_imexgus_mod.f90 b/src/sunadaptcontroller/imexgus/fmod/fsunadaptcontroller_imexgus_mod.f90 index 06408a0e27..8ebe512def 100644 --- a/src/sunadaptcontroller/imexgus/fmod/fsunadaptcontroller_imexgus_mod.f90 +++ b/src/sunadaptcontroller/imexgus/fmod/fsunadaptcontroller_imexgus_mod.f90 @@ -34,7 +34,6 @@ module fsunadaptcontroller_imexgus_mod public :: FSUNAdaptController_Reset_ImExGus public :: FSUNAdaptController_SetDefaults_ImExGus public :: FSUNAdaptController_Write_ImExGus - public :: FSUNAdaptController_SetMethodOrder_ImExGus public :: FSUNAdaptController_SetErrorBias_ImExGus public :: FSUNAdaptController_Update_ImExGus public :: FSUNAdaptController_Space_ImExGus @@ -69,14 +68,15 @@ function swigc_FSUNAdaptController_GetType_ImExGus(farg1) & integer(C_INT) :: fresult end function -function swigc_FSUNAdaptController_EstimateStep_ImExGus(farg1, farg2, farg3, farg4) & +function swigc_FSUNAdaptController_EstimateStep_ImExGus(farg1, farg2, farg3, farg4, farg5) & bind(C, name="_wrap_FSUNAdaptController_EstimateStep_ImExGus") & 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_PTR), value :: farg4 +integer(C_INT), intent(in) :: farg3 +real(C_DOUBLE), intent(in) :: farg4 +type(C_PTR), value :: farg5 integer(C_INT) :: fresult end function @@ -105,15 +105,6 @@ function swigc_FSUNAdaptController_Write_ImExGus(farg1, farg2) & integer(C_INT) :: fresult end function -function swigc_FSUNAdaptController_SetMethodOrder_ImExGus(farg1, farg2) & -bind(C, name="_wrap_FSUNAdaptController_SetMethodOrder_ImExGus") & -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_FSUNAdaptController_SetErrorBias_ImExGus(farg1, farg2) & bind(C, name="_wrap_FSUNAdaptController_SetErrorBias_ImExGus") & result(fresult) @@ -199,25 +190,28 @@ function FSUNAdaptController_GetType_ImExGus(c) & swig_result = fresult end function -function FSUNAdaptController_EstimateStep_ImExGus(c, h, dsm, hnew) & +function FSUNAdaptController_EstimateStep_ImExGus(c, h, p, dsm, hnew) & result(swig_result) use, intrinsic :: ISO_C_BINDING integer(C_INT) :: swig_result type(SUNAdaptController), target, intent(inout) :: c real(C_DOUBLE), intent(in) :: h +integer(C_INT), intent(in) :: p real(C_DOUBLE), intent(in) :: dsm real(C_DOUBLE), target, intent(inout) :: hnew integer(C_INT) :: fresult type(C_PTR) :: farg1 real(C_DOUBLE) :: farg2 -real(C_DOUBLE) :: farg3 -type(C_PTR) :: farg4 +integer(C_INT) :: farg3 +real(C_DOUBLE) :: farg4 +type(C_PTR) :: farg5 farg1 = c_loc(c) farg2 = h -farg3 = dsm -farg4 = c_loc(hnew) -fresult = swigc_FSUNAdaptController_EstimateStep_ImExGus(farg1, farg2, farg3, farg4) +farg3 = p +farg4 = dsm +farg5 = c_loc(hnew) +fresult = swigc_FSUNAdaptController_EstimateStep_ImExGus(farg1, farg2, farg3, farg4, farg5) swig_result = fresult end function @@ -263,22 +257,6 @@ function FSUNAdaptController_Write_ImExGus(c, fptr) & swig_result = fresult end function -function FSUNAdaptController_SetMethodOrder_ImExGus(c, p) & -result(swig_result) -use, intrinsic :: ISO_C_BINDING -integer(C_INT) :: swig_result -type(SUNAdaptController), target, intent(inout) :: c -integer(C_INT), intent(in) :: p -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -integer(C_INT) :: farg2 - -farg1 = c_loc(c) -farg2 = p -fresult = swigc_FSUNAdaptController_SetMethodOrder_ImExGus(farg1, farg2) -swig_result = fresult -end function - function FSUNAdaptController_SetErrorBias_ImExGus(c, bias) & result(swig_result) use, intrinsic :: ISO_C_BINDING diff --git a/src/sunadaptcontroller/imexgus/sunadaptcontroller_imexgus.c b/src/sunadaptcontroller/imexgus/sunadaptcontroller_imexgus.c index 4933601d34..8e78911107 100644 --- a/src/sunadaptcontroller/imexgus/sunadaptcontroller_imexgus.c +++ b/src/sunadaptcontroller/imexgus/sunadaptcontroller_imexgus.c @@ -33,7 +33,6 @@ #define SACIMEXGUS_BIAS(C) ( SACIMEXGUS_CONTENT(C)->bias ) #define SACIMEXGUS_EP(C) ( SACIMEXGUS_CONTENT(C)->ep ) #define SACIMEXGUS_HP(C) ( SACIMEXGUS_CONTENT(C)->hp ) -#define SACIMEXGUS_P(C) ( SACIMEXGUS_CONTENT(C)->p ) #define SACIMEXGUS_FIRSTSTEP(C) ( SACIMEXGUS_CONTENT(C)->firststep ) /* ------------------ @@ -72,7 +71,6 @@ SUNAdaptController SUNAdaptController_ImExGus(SUNContext sunctx) C->ops->reset = SUNAdaptController_Reset_ImExGus; C->ops->setdefaults = SUNAdaptController_SetDefaults_ImExGus; C->ops->write = SUNAdaptController_Write_ImExGus; - C->ops->setmethodorder = SUNAdaptController_SetMethodOrder_ImExGus; C->ops->seterrorbias = SUNAdaptController_SetErrorBias_ImExGus; C->ops->update = SUNAdaptController_Update_ImExGus; C->ops->space = SUNAdaptController_Space_ImExGus; @@ -89,9 +87,6 @@ SUNAdaptController SUNAdaptController_ImExGus(SUNContext sunctx) /* Attach content */ C->content = content; - /* Initialize method order */ - content->p = 1; - /* Fill content with default/reset values */ SUNAdaptController_SetDefaults_ImExGus(C); SUNAdaptController_Reset_ImExGus(C); @@ -125,10 +120,10 @@ SUNAdaptController_Type SUNAdaptController_GetType_ImExGus(SUNAdaptController C) { return SUN_ADAPTCONTROLLER_H; } int SUNAdaptController_EstimateStep_ImExGus(SUNAdaptController C, sunrealtype h, - sunrealtype dsm, sunrealtype* hnew) + int p, sunrealtype dsm, sunrealtype* hnew) { /* order parameter to use */ - const int ord = SACIMEXGUS_P(C) + 1; + const int ord = p + 1; /* modified method for first step */ if (SACIMEXGUS_FIRSTSTEP(C)) @@ -197,15 +192,6 @@ int SUNAdaptController_Write_ImExGus(SUNAdaptController C, FILE *fptr) fprintf(fptr, " previous error = %16g\n", SACIMEXGUS_EP(C)); fprintf(fptr, " previous step = %16g\n", SACIMEXGUS_HP(C)); #endif - fprintf(fptr, " p = %i\n", SACIMEXGUS_P(C)); - return SUNADAPTCONTROLLER_SUCCESS; -} - -int SUNAdaptController_SetMethodOrder_ImExGus(SUNAdaptController C, int p) -{ - /* check for legal inputs */ - if (p < 0) { return SUNADAPTCONTROLLER_ILL_INPUT; } - SACIMEXGUS_P(C) = p; return SUNADAPTCONTROLLER_SUCCESS; } @@ -232,6 +218,6 @@ int SUNAdaptController_Update_ImExGus(SUNAdaptController C, sunrealtype h, sunre int SUNAdaptController_Space_ImExGus(SUNAdaptController C, long int* lenrw, long int* leniw) { *lenrw = 7; - *leniw = 2; + *leniw = 1; return SUNADAPTCONTROLLER_SUCCESS; } diff --git a/src/sunadaptcontroller/impgus/fmod/fsunadaptcontroller_impgus_mod.c b/src/sunadaptcontroller/impgus/fmod/fsunadaptcontroller_impgus_mod.c index c94dfa1010..dac6ed176e 100644 --- a/src/sunadaptcontroller/impgus/fmod/fsunadaptcontroller_impgus_mod.c +++ b/src/sunadaptcontroller/impgus/fmod/fsunadaptcontroller_impgus_mod.c @@ -248,19 +248,21 @@ SWIGEXPORT int _wrap_FSUNAdaptController_GetType_ImpGus(SUNAdaptController farg1 } -SWIGEXPORT int _wrap_FSUNAdaptController_EstimateStep_ImpGus(SUNAdaptController farg1, double const *farg2, double const *farg3, double *farg4) { +SWIGEXPORT int _wrap_FSUNAdaptController_EstimateStep_ImpGus(SUNAdaptController farg1, double const *farg2, int const *farg3, double const *farg4, double *farg5) { int fresult ; SUNAdaptController arg1 = (SUNAdaptController) 0 ; sunrealtype arg2 ; - sunrealtype arg3 ; - sunrealtype *arg4 = (sunrealtype *) 0 ; + int arg3 ; + sunrealtype arg4 ; + sunrealtype *arg5 = (sunrealtype *) 0 ; int result; arg1 = (SUNAdaptController)(farg1); arg2 = (sunrealtype)(*farg2); - arg3 = (sunrealtype)(*farg3); - arg4 = (sunrealtype *)(farg4); - result = (int)SUNAdaptController_EstimateStep_ImpGus(arg1,arg2,arg3,arg4); + arg3 = (int)(*farg3); + arg4 = (sunrealtype)(*farg4); + arg5 = (sunrealtype *)(farg5); + result = (int)SUNAdaptController_EstimateStep_ImpGus(arg1,arg2,arg3,arg4,arg5); fresult = (int)(result); return fresult; } @@ -304,20 +306,6 @@ SWIGEXPORT int _wrap_FSUNAdaptController_Write_ImpGus(SUNAdaptController farg1, } -SWIGEXPORT int _wrap_FSUNAdaptController_SetMethodOrder_ImpGus(SUNAdaptController farg1, int const *farg2) { - int fresult ; - SUNAdaptController arg1 = (SUNAdaptController) 0 ; - int arg2 ; - int result; - - arg1 = (SUNAdaptController)(farg1); - arg2 = (int)(*farg2); - result = (int)SUNAdaptController_SetMethodOrder_ImpGus(arg1,arg2); - fresult = (int)(result); - return fresult; -} - - SWIGEXPORT int _wrap_FSUNAdaptController_SetErrorBias_ImpGus(SUNAdaptController farg1, double const *farg2) { int fresult ; SUNAdaptController arg1 = (SUNAdaptController) 0 ; diff --git a/src/sunadaptcontroller/impgus/fmod/fsunadaptcontroller_impgus_mod.f90 b/src/sunadaptcontroller/impgus/fmod/fsunadaptcontroller_impgus_mod.f90 index 3ebf8ab8ff..48d8b238b6 100644 --- a/src/sunadaptcontroller/impgus/fmod/fsunadaptcontroller_impgus_mod.f90 +++ b/src/sunadaptcontroller/impgus/fmod/fsunadaptcontroller_impgus_mod.f90 @@ -34,7 +34,6 @@ module fsunadaptcontroller_impgus_mod public :: FSUNAdaptController_Reset_ImpGus public :: FSUNAdaptController_SetDefaults_ImpGus public :: FSUNAdaptController_Write_ImpGus - public :: FSUNAdaptController_SetMethodOrder_ImpGus public :: FSUNAdaptController_SetErrorBias_ImpGus public :: FSUNAdaptController_Update_ImpGus public :: FSUNAdaptController_Space_ImpGus @@ -67,14 +66,15 @@ function swigc_FSUNAdaptController_GetType_ImpGus(farg1) & integer(C_INT) :: fresult end function -function swigc_FSUNAdaptController_EstimateStep_ImpGus(farg1, farg2, farg3, farg4) & +function swigc_FSUNAdaptController_EstimateStep_ImpGus(farg1, farg2, farg3, farg4, farg5) & bind(C, name="_wrap_FSUNAdaptController_EstimateStep_ImpGus") & 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_PTR), value :: farg4 +integer(C_INT), intent(in) :: farg3 +real(C_DOUBLE), intent(in) :: farg4 +type(C_PTR), value :: farg5 integer(C_INT) :: fresult end function @@ -103,15 +103,6 @@ function swigc_FSUNAdaptController_Write_ImpGus(farg1, farg2) & integer(C_INT) :: fresult end function -function swigc_FSUNAdaptController_SetMethodOrder_ImpGus(farg1, farg2) & -bind(C, name="_wrap_FSUNAdaptController_SetMethodOrder_ImpGus") & -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_FSUNAdaptController_SetErrorBias_ImpGus(farg1, farg2) & bind(C, name="_wrap_FSUNAdaptController_SetErrorBias_ImpGus") & result(fresult) @@ -191,25 +182,28 @@ function FSUNAdaptController_GetType_ImpGus(c) & swig_result = fresult end function -function FSUNAdaptController_EstimateStep_ImpGus(c, h, dsm, hnew) & +function FSUNAdaptController_EstimateStep_ImpGus(c, h, p, dsm, hnew) & result(swig_result) use, intrinsic :: ISO_C_BINDING integer(C_INT) :: swig_result type(SUNAdaptController), target, intent(inout) :: c real(C_DOUBLE), intent(in) :: h +integer(C_INT), intent(in) :: p real(C_DOUBLE), intent(in) :: dsm real(C_DOUBLE), target, intent(inout) :: hnew integer(C_INT) :: fresult type(C_PTR) :: farg1 real(C_DOUBLE) :: farg2 -real(C_DOUBLE) :: farg3 -type(C_PTR) :: farg4 +integer(C_INT) :: farg3 +real(C_DOUBLE) :: farg4 +type(C_PTR) :: farg5 farg1 = c_loc(c) farg2 = h -farg3 = dsm -farg4 = c_loc(hnew) -fresult = swigc_FSUNAdaptController_EstimateStep_ImpGus(farg1, farg2, farg3, farg4) +farg3 = p +farg4 = dsm +farg5 = c_loc(hnew) +fresult = swigc_FSUNAdaptController_EstimateStep_ImpGus(farg1, farg2, farg3, farg4, farg5) swig_result = fresult end function @@ -255,22 +249,6 @@ function FSUNAdaptController_Write_ImpGus(c, fptr) & swig_result = fresult end function -function FSUNAdaptController_SetMethodOrder_ImpGus(c, p) & -result(swig_result) -use, intrinsic :: ISO_C_BINDING -integer(C_INT) :: swig_result -type(SUNAdaptController), target, intent(inout) :: c -integer(C_INT), intent(in) :: p -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -integer(C_INT) :: farg2 - -farg1 = c_loc(c) -farg2 = p -fresult = swigc_FSUNAdaptController_SetMethodOrder_ImpGus(farg1, farg2) -swig_result = fresult -end function - function FSUNAdaptController_SetErrorBias_ImpGus(c, bias) & result(swig_result) use, intrinsic :: ISO_C_BINDING diff --git a/src/sunadaptcontroller/impgus/sunadaptcontroller_impgus.c b/src/sunadaptcontroller/impgus/sunadaptcontroller_impgus.c index 8a59c2abab..ea9c29c551 100644 --- a/src/sunadaptcontroller/impgus/sunadaptcontroller_impgus.c +++ b/src/sunadaptcontroller/impgus/sunadaptcontroller_impgus.c @@ -31,7 +31,6 @@ #define SACIMPGUS_BIAS(C) ( SACIMPGUS_CONTENT(C)->bias ) #define SACIMPGUS_EP(C) ( SACIMPGUS_CONTENT(C)->ep ) #define SACIMPGUS_HP(C) ( SACIMPGUS_CONTENT(C)->hp ) -#define SACIMPGUS_P(C) ( SACIMPGUS_CONTENT(C)->p ) #define SACIMPGUS_FIRSTSTEP(C) ( SACIMPGUS_CONTENT(C)->firststep ) /* ------------------ @@ -68,7 +67,6 @@ SUNAdaptController SUNAdaptController_ImpGus(SUNContext sunctx) C->ops->reset = SUNAdaptController_Reset_ImpGus; C->ops->setdefaults = SUNAdaptController_SetDefaults_ImpGus; C->ops->write = SUNAdaptController_Write_ImpGus; - C->ops->setmethodorder = SUNAdaptController_SetMethodOrder_ImpGus; C->ops->seterrorbias = SUNAdaptController_SetErrorBias_ImpGus; C->ops->update = SUNAdaptController_Update_ImpGus; C->ops->space = SUNAdaptController_Space_ImpGus; @@ -85,9 +83,6 @@ SUNAdaptController SUNAdaptController_ImpGus(SUNContext sunctx) /* Attach content */ C->content = content; - /* Initialize method order */ - content->p = 1; - /* Fill content with default/reset values */ SUNAdaptController_SetDefaults_ImpGus(C); SUNAdaptController_Reset_ImpGus(C); @@ -118,10 +113,10 @@ SUNAdaptController_Type SUNAdaptController_GetType_ImpGus(SUNAdaptController C) { return SUN_ADAPTCONTROLLER_H; } int SUNAdaptController_EstimateStep_ImpGus(SUNAdaptController C, sunrealtype h, - sunrealtype dsm, sunrealtype* hnew) + int p, sunrealtype dsm, sunrealtype* hnew) { /* order parameter to use */ - const int ord = SACIMPGUS_P(C) + 1; + const int ord = p + 1; /* modified method for first step */ if (SACIMPGUS_FIRSTSTEP(C)) @@ -182,15 +177,6 @@ int SUNAdaptController_Write_ImpGus(SUNAdaptController C, FILE *fptr) fprintf(fptr, " previous error = %16g\n", SACIMPGUS_EP(C)); fprintf(fptr, " previous step = %16g\n", SACIMPGUS_HP(C)); #endif - fprintf(fptr, " p = %i\n", SACIMPGUS_P(C)); - return SUNADAPTCONTROLLER_SUCCESS; -} - -int SUNAdaptController_SetMethodOrder_ImpGus(SUNAdaptController C, int p) -{ - /* check for legal inputs */ - if (p < 0) { return SUNADAPTCONTROLLER_ILL_INPUT; } - SACIMPGUS_P(C) = p; return SUNADAPTCONTROLLER_SUCCESS; } diff --git a/src/sunadaptcontroller/pi/fmod/fsunadaptcontroller_pi_mod.c b/src/sunadaptcontroller/pi/fmod/fsunadaptcontroller_pi_mod.c index c0381f7594..6226ca358b 100644 --- a/src/sunadaptcontroller/pi/fmod/fsunadaptcontroller_pi_mod.c +++ b/src/sunadaptcontroller/pi/fmod/fsunadaptcontroller_pi_mod.c @@ -248,19 +248,21 @@ SWIGEXPORT int _wrap_FSUNAdaptController_GetType_PI(SUNAdaptController farg1) { } -SWIGEXPORT int _wrap_FSUNAdaptController_EstimateStep_PI(SUNAdaptController farg1, double const *farg2, double const *farg3, double *farg4) { +SWIGEXPORT int _wrap_FSUNAdaptController_EstimateStep_PI(SUNAdaptController farg1, double const *farg2, int const *farg3, double const *farg4, double *farg5) { int fresult ; SUNAdaptController arg1 = (SUNAdaptController) 0 ; sunrealtype arg2 ; - sunrealtype arg3 ; - sunrealtype *arg4 = (sunrealtype *) 0 ; + int arg3 ; + sunrealtype arg4 ; + sunrealtype *arg5 = (sunrealtype *) 0 ; int result; arg1 = (SUNAdaptController)(farg1); arg2 = (sunrealtype)(*farg2); - arg3 = (sunrealtype)(*farg3); - arg4 = (sunrealtype *)(farg4); - result = (int)SUNAdaptController_EstimateStep_PI(arg1,arg2,arg3,arg4); + arg3 = (int)(*farg3); + arg4 = (sunrealtype)(*farg4); + arg5 = (sunrealtype *)(farg5); + result = (int)SUNAdaptController_EstimateStep_PI(arg1,arg2,arg3,arg4,arg5); fresult = (int)(result); return fresult; } @@ -304,20 +306,6 @@ SWIGEXPORT int _wrap_FSUNAdaptController_Write_PI(SUNAdaptController farg1, void } -SWIGEXPORT int _wrap_FSUNAdaptController_SetMethodOrder_PI(SUNAdaptController farg1, int const *farg2) { - int fresult ; - SUNAdaptController arg1 = (SUNAdaptController) 0 ; - int arg2 ; - int result; - - arg1 = (SUNAdaptController)(farg1); - arg2 = (int)(*farg2); - result = (int)SUNAdaptController_SetMethodOrder_PI(arg1,arg2); - fresult = (int)(result); - return fresult; -} - - SWIGEXPORT int _wrap_FSUNAdaptController_SetErrorBias_PI(SUNAdaptController farg1, double const *farg2) { int fresult ; SUNAdaptController arg1 = (SUNAdaptController) 0 ; diff --git a/src/sunadaptcontroller/pi/fmod/fsunadaptcontroller_pi_mod.f90 b/src/sunadaptcontroller/pi/fmod/fsunadaptcontroller_pi_mod.f90 index dce45abb0d..2db14dd2ba 100644 --- a/src/sunadaptcontroller/pi/fmod/fsunadaptcontroller_pi_mod.f90 +++ b/src/sunadaptcontroller/pi/fmod/fsunadaptcontroller_pi_mod.f90 @@ -34,7 +34,6 @@ module fsunadaptcontroller_pi_mod public :: FSUNAdaptController_Reset_PI public :: FSUNAdaptController_SetDefaults_PI public :: FSUNAdaptController_Write_PI - public :: FSUNAdaptController_SetMethodOrder_PI public :: FSUNAdaptController_SetErrorBias_PI public :: FSUNAdaptController_Update_PI public :: FSUNAdaptController_Space_PI @@ -67,14 +66,15 @@ function swigc_FSUNAdaptController_GetType_PI(farg1) & integer(C_INT) :: fresult end function -function swigc_FSUNAdaptController_EstimateStep_PI(farg1, farg2, farg3, farg4) & +function swigc_FSUNAdaptController_EstimateStep_PI(farg1, farg2, farg3, farg4, farg5) & bind(C, name="_wrap_FSUNAdaptController_EstimateStep_PI") & 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_PTR), value :: farg4 +integer(C_INT), intent(in) :: farg3 +real(C_DOUBLE), intent(in) :: farg4 +type(C_PTR), value :: farg5 integer(C_INT) :: fresult end function @@ -103,15 +103,6 @@ function swigc_FSUNAdaptController_Write_PI(farg1, farg2) & integer(C_INT) :: fresult end function -function swigc_FSUNAdaptController_SetMethodOrder_PI(farg1, farg2) & -bind(C, name="_wrap_FSUNAdaptController_SetMethodOrder_PI") & -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_FSUNAdaptController_SetErrorBias_PI(farg1, farg2) & bind(C, name="_wrap_FSUNAdaptController_SetErrorBias_PI") & result(fresult) @@ -191,25 +182,28 @@ function FSUNAdaptController_GetType_PI(c) & swig_result = fresult end function -function FSUNAdaptController_EstimateStep_PI(c, h, dsm, hnew) & +function FSUNAdaptController_EstimateStep_PI(c, h, p, dsm, hnew) & result(swig_result) use, intrinsic :: ISO_C_BINDING integer(C_INT) :: swig_result type(SUNAdaptController), target, intent(inout) :: c real(C_DOUBLE), intent(in) :: h +integer(C_INT), intent(in) :: p real(C_DOUBLE), intent(in) :: dsm real(C_DOUBLE), target, intent(inout) :: hnew integer(C_INT) :: fresult type(C_PTR) :: farg1 real(C_DOUBLE) :: farg2 -real(C_DOUBLE) :: farg3 -type(C_PTR) :: farg4 +integer(C_INT) :: farg3 +real(C_DOUBLE) :: farg4 +type(C_PTR) :: farg5 farg1 = c_loc(c) farg2 = h -farg3 = dsm -farg4 = c_loc(hnew) -fresult = swigc_FSUNAdaptController_EstimateStep_PI(farg1, farg2, farg3, farg4) +farg3 = p +farg4 = dsm +farg5 = c_loc(hnew) +fresult = swigc_FSUNAdaptController_EstimateStep_PI(farg1, farg2, farg3, farg4, farg5) swig_result = fresult end function @@ -255,22 +249,6 @@ function FSUNAdaptController_Write_PI(c, fptr) & swig_result = fresult end function -function FSUNAdaptController_SetMethodOrder_PI(c, p) & -result(swig_result) -use, intrinsic :: ISO_C_BINDING -integer(C_INT) :: swig_result -type(SUNAdaptController), target, intent(inout) :: c -integer(C_INT), intent(in) :: p -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -integer(C_INT) :: farg2 - -farg1 = c_loc(c) -farg2 = p -fresult = swigc_FSUNAdaptController_SetMethodOrder_PI(farg1, farg2) -swig_result = fresult -end function - function FSUNAdaptController_SetErrorBias_PI(c, bias) & result(swig_result) use, intrinsic :: ISO_C_BINDING diff --git a/src/sunadaptcontroller/pi/sunadaptcontroller_pi.c b/src/sunadaptcontroller/pi/sunadaptcontroller_pi.c index 29c700df15..416bea4b1b 100644 --- a/src/sunadaptcontroller/pi/sunadaptcontroller_pi.c +++ b/src/sunadaptcontroller/pi/sunadaptcontroller_pi.c @@ -30,7 +30,6 @@ #define SACPI_K2(C) ( SACPI_CONTENT(C)->k2 ) #define SACPI_BIAS(C) ( SACPI_CONTENT(C)->bias ) #define SACPI_EP(C) ( SACPI_CONTENT(C)->ep ) -#define SACPI_P(C) ( SACPI_CONTENT(C)->p ) /* ------------------ * Default parameters @@ -66,7 +65,6 @@ SUNAdaptController SUNAdaptController_PI(SUNContext sunctx) C->ops->reset = SUNAdaptController_Reset_PI; C->ops->setdefaults = SUNAdaptController_SetDefaults_PI; C->ops->write = SUNAdaptController_Write_PI; - C->ops->setmethodorder = SUNAdaptController_SetMethodOrder_PI; C->ops->seterrorbias = SUNAdaptController_SetErrorBias_PI; C->ops->update = SUNAdaptController_Update_PI; C->ops->space = SUNAdaptController_Space_PI; @@ -83,9 +81,6 @@ SUNAdaptController SUNAdaptController_PI(SUNContext sunctx) /* Attach content */ C->content = content; - /* Initialize method order */ - content->p = 1; - /* Fill content with default/reset values */ SUNAdaptController_SetDefaults_PI(C); SUNAdaptController_Reset_PI(C); @@ -115,10 +110,10 @@ SUNAdaptController_Type SUNAdaptController_GetType_PI(SUNAdaptController C) { return SUN_ADAPTCONTROLLER_H; } int SUNAdaptController_EstimateStep_PI(SUNAdaptController C, sunrealtype h, - sunrealtype dsm, sunrealtype* hnew) + int p, sunrealtype dsm, sunrealtype* hnew) { /* set usable time-step adaptivity parameters */ - const int ord = SACPI_P(C) + 1; + const int ord = p + 1; const sunrealtype k1 = -SACPI_K1(C) / ord; const sunrealtype k2 = SACPI_K2(C) / ord; const sunrealtype ecur = SACPI_BIAS(C) * dsm; @@ -158,15 +153,6 @@ int SUNAdaptController_Write_PI(SUNAdaptController C, FILE *fptr) fprintf(fptr, " bias factor = %16g\n", SACPI_BIAS(C)); fprintf(fptr, " previous error = %16g\n", SACPI_EP(C)); #endif - fprintf(fptr, " p = %i\n", SACPI_P(C)); - return SUNADAPTCONTROLLER_SUCCESS; -} - -int SUNAdaptController_SetMethodOrder_PI(SUNAdaptController C, int p) -{ - /* check for legal inputs */ - if (p < 0) { return SUNADAPTCONTROLLER_ILL_INPUT; } - SACPI_P(C) = p; return SUNADAPTCONTROLLER_SUCCESS; } diff --git a/src/sunadaptcontroller/pid/fmod/fsunadaptcontroller_pid_mod.c b/src/sunadaptcontroller/pid/fmod/fsunadaptcontroller_pid_mod.c index c7c88b0477..cd8c5c01bf 100644 --- a/src/sunadaptcontroller/pid/fmod/fsunadaptcontroller_pid_mod.c +++ b/src/sunadaptcontroller/pid/fmod/fsunadaptcontroller_pid_mod.c @@ -250,19 +250,21 @@ SWIGEXPORT int _wrap_FSUNAdaptController_GetType_PID(SUNAdaptController farg1) { } -SWIGEXPORT int _wrap_FSUNAdaptController_EstimateStep_PID(SUNAdaptController farg1, double const *farg2, double const *farg3, double *farg4) { +SWIGEXPORT int _wrap_FSUNAdaptController_EstimateStep_PID(SUNAdaptController farg1, double const *farg2, int const *farg3, double const *farg4, double *farg5) { int fresult ; SUNAdaptController arg1 = (SUNAdaptController) 0 ; sunrealtype arg2 ; - sunrealtype arg3 ; - sunrealtype *arg4 = (sunrealtype *) 0 ; + int arg3 ; + sunrealtype arg4 ; + sunrealtype *arg5 = (sunrealtype *) 0 ; int result; arg1 = (SUNAdaptController)(farg1); arg2 = (sunrealtype)(*farg2); - arg3 = (sunrealtype)(*farg3); - arg4 = (sunrealtype *)(farg4); - result = (int)SUNAdaptController_EstimateStep_PID(arg1,arg2,arg3,arg4); + arg3 = (int)(*farg3); + arg4 = (sunrealtype)(*farg4); + arg5 = (sunrealtype *)(farg5); + result = (int)SUNAdaptController_EstimateStep_PID(arg1,arg2,arg3,arg4,arg5); fresult = (int)(result); return fresult; } @@ -306,20 +308,6 @@ SWIGEXPORT int _wrap_FSUNAdaptController_Write_PID(SUNAdaptController farg1, voi } -SWIGEXPORT int _wrap_FSUNAdaptController_SetMethodOrder_PID(SUNAdaptController farg1, int const *farg2) { - int fresult ; - SUNAdaptController arg1 = (SUNAdaptController) 0 ; - int arg2 ; - int result; - - arg1 = (SUNAdaptController)(farg1); - arg2 = (int)(*farg2); - result = (int)SUNAdaptController_SetMethodOrder_PID(arg1,arg2); - fresult = (int)(result); - return fresult; -} - - SWIGEXPORT int _wrap_FSUNAdaptController_SetErrorBias_PID(SUNAdaptController farg1, double const *farg2) { int fresult ; SUNAdaptController arg1 = (SUNAdaptController) 0 ; diff --git a/src/sunadaptcontroller/pid/fmod/fsunadaptcontroller_pid_mod.f90 b/src/sunadaptcontroller/pid/fmod/fsunadaptcontroller_pid_mod.f90 index 0831ea8644..6cda933b5f 100644 --- a/src/sunadaptcontroller/pid/fmod/fsunadaptcontroller_pid_mod.f90 +++ b/src/sunadaptcontroller/pid/fmod/fsunadaptcontroller_pid_mod.f90 @@ -34,7 +34,6 @@ module fsunadaptcontroller_pid_mod public :: FSUNAdaptController_Reset_PID public :: FSUNAdaptController_SetDefaults_PID public :: FSUNAdaptController_Write_PID - public :: FSUNAdaptController_SetMethodOrder_PID public :: FSUNAdaptController_SetErrorBias_PID public :: FSUNAdaptController_Update_PID public :: FSUNAdaptController_Space_PID @@ -68,14 +67,15 @@ function swigc_FSUNAdaptController_GetType_PID(farg1) & integer(C_INT) :: fresult end function -function swigc_FSUNAdaptController_EstimateStep_PID(farg1, farg2, farg3, farg4) & +function swigc_FSUNAdaptController_EstimateStep_PID(farg1, farg2, farg3, farg4, farg5) & bind(C, name="_wrap_FSUNAdaptController_EstimateStep_PID") & 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_PTR), value :: farg4 +integer(C_INT), intent(in) :: farg3 +real(C_DOUBLE), intent(in) :: farg4 +type(C_PTR), value :: farg5 integer(C_INT) :: fresult end function @@ -104,15 +104,6 @@ function swigc_FSUNAdaptController_Write_PID(farg1, farg2) & integer(C_INT) :: fresult end function -function swigc_FSUNAdaptController_SetMethodOrder_PID(farg1, farg2) & -bind(C, name="_wrap_FSUNAdaptController_SetMethodOrder_PID") & -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_FSUNAdaptController_SetErrorBias_PID(farg1, farg2) & bind(C, name="_wrap_FSUNAdaptController_SetErrorBias_PID") & result(fresult) @@ -195,25 +186,28 @@ function FSUNAdaptController_GetType_PID(c) & swig_result = fresult end function -function FSUNAdaptController_EstimateStep_PID(c, h, dsm, hnew) & +function FSUNAdaptController_EstimateStep_PID(c, h, p, dsm, hnew) & result(swig_result) use, intrinsic :: ISO_C_BINDING integer(C_INT) :: swig_result type(SUNAdaptController), target, intent(inout) :: c real(C_DOUBLE), intent(in) :: h +integer(C_INT), intent(in) :: p real(C_DOUBLE), intent(in) :: dsm real(C_DOUBLE), target, intent(inout) :: hnew integer(C_INT) :: fresult type(C_PTR) :: farg1 real(C_DOUBLE) :: farg2 -real(C_DOUBLE) :: farg3 -type(C_PTR) :: farg4 +integer(C_INT) :: farg3 +real(C_DOUBLE) :: farg4 +type(C_PTR) :: farg5 farg1 = c_loc(c) farg2 = h -farg3 = dsm -farg4 = c_loc(hnew) -fresult = swigc_FSUNAdaptController_EstimateStep_PID(farg1, farg2, farg3, farg4) +farg3 = p +farg4 = dsm +farg5 = c_loc(hnew) +fresult = swigc_FSUNAdaptController_EstimateStep_PID(farg1, farg2, farg3, farg4, farg5) swig_result = fresult end function @@ -259,22 +253,6 @@ function FSUNAdaptController_Write_PID(c, fptr) & swig_result = fresult end function -function FSUNAdaptController_SetMethodOrder_PID(c, p) & -result(swig_result) -use, intrinsic :: ISO_C_BINDING -integer(C_INT) :: swig_result -type(SUNAdaptController), target, intent(inout) :: c -integer(C_INT), intent(in) :: p -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -integer(C_INT) :: farg2 - -farg1 = c_loc(c) -farg2 = p -fresult = swigc_FSUNAdaptController_SetMethodOrder_PID(farg1, farg2) -swig_result = fresult -end function - function FSUNAdaptController_SetErrorBias_PID(c, bias) & result(swig_result) use, intrinsic :: ISO_C_BINDING diff --git a/src/sunadaptcontroller/pid/sunadaptcontroller_pid.c b/src/sunadaptcontroller/pid/sunadaptcontroller_pid.c index 4526d1e5eb..ec2cd4dbe8 100644 --- a/src/sunadaptcontroller/pid/sunadaptcontroller_pid.c +++ b/src/sunadaptcontroller/pid/sunadaptcontroller_pid.c @@ -32,7 +32,6 @@ #define SACPID_BIAS(C) ( SACPID_CONTENT(C)->bias ) #define SACPID_EP(C) ( SACPID_CONTENT(C)->ep ) #define SACPID_EPP(C) ( SACPID_CONTENT(C)->epp ) -#define SACPID_P(C) ( SACPID_CONTENT(C)->p ) /* ------------------ * Default parameters @@ -69,7 +68,6 @@ SUNAdaptController SUNAdaptController_PID(SUNContext sunctx) C->ops->reset = SUNAdaptController_Reset_PID; C->ops->setdefaults = SUNAdaptController_SetDefaults_PID; C->ops->write = SUNAdaptController_Write_PID; - C->ops->setmethodorder = SUNAdaptController_SetMethodOrder_PID; C->ops->seterrorbias = SUNAdaptController_SetErrorBias_PID; C->ops->update = SUNAdaptController_Update_PID; C->ops->space = SUNAdaptController_Space_PID; @@ -86,9 +84,6 @@ SUNAdaptController SUNAdaptController_PID(SUNContext sunctx) /* Attach content */ C->content = content; - /* Initialize method order */ - content->p = 1; - /* Fill content with default/reset values */ SUNAdaptController_SetDefaults_PID(C); SUNAdaptController_Reset_PID(C); @@ -119,10 +114,10 @@ SUNAdaptController_Type SUNAdaptController_GetType_PID(SUNAdaptController C) { return SUN_ADAPTCONTROLLER_H; } int SUNAdaptController_EstimateStep_PID(SUNAdaptController C, sunrealtype h, - sunrealtype dsm, sunrealtype* hnew) + int p, sunrealtype dsm, sunrealtype* hnew) { /* set usable time-step adaptivity parameters */ - const int ord = SACPID_P(C) + 1; + const int ord = p + 1; const sunrealtype k1 = -SACPID_K1(C) / ord; const sunrealtype k2 = SACPID_K2(C) / ord; const sunrealtype k3 = -SACPID_K3(C) / ord; @@ -168,15 +163,6 @@ int SUNAdaptController_Write_PID(SUNAdaptController C, FILE *fptr) fprintf(fptr, " bias factor = %16g\n", SACPID_BIAS(C)); fprintf(fptr, " previous errors = %16g %16g\n", SACPID_EP(C), SACPID_EPP(C)); #endif - fprintf(fptr, " p = %i\n", SACPID_P(C)); - return SUNADAPTCONTROLLER_SUCCESS; -} - -int SUNAdaptController_SetMethodOrder_PID(SUNAdaptController C, int p) -{ - /* check for legal inputs */ - if (p < 0) { return SUNADAPTCONTROLLER_ILL_INPUT; } - SACPID_P(C) = p; return SUNADAPTCONTROLLER_SUCCESS; } diff --git a/src/sundials/fmod/fsundials_adaptcontroller_mod.c b/src/sundials/fmod/fsundials_adaptcontroller_mod.c index 0a3ff08517..e106fa2f7f 100644 --- a/src/sundials/fmod/fsundials_adaptcontroller_mod.c +++ b/src/sundials/fmod/fsundials_adaptcontroller_mod.c @@ -226,19 +226,21 @@ SWIGEXPORT int _wrap_FSUNAdaptController_Destroy(SUNAdaptController farg1) { } -SWIGEXPORT int _wrap_FSUNAdaptController_EstimateStep(SUNAdaptController farg1, double const *farg2, double const *farg3, double *farg4) { +SWIGEXPORT int _wrap_FSUNAdaptController_EstimateStep(SUNAdaptController farg1, double const *farg2, int const *farg3, double const *farg4, double *farg5) { int fresult ; SUNAdaptController arg1 = (SUNAdaptController) 0 ; sunrealtype arg2 ; - sunrealtype arg3 ; - sunrealtype *arg4 = (sunrealtype *) 0 ; + int arg3 ; + sunrealtype arg4 ; + sunrealtype *arg5 = (sunrealtype *) 0 ; int result; arg1 = (SUNAdaptController)(farg1); arg2 = (sunrealtype)(*farg2); - arg3 = (sunrealtype)(*farg3); - arg4 = (sunrealtype *)(farg4); - result = (int)SUNAdaptController_EstimateStep(arg1,arg2,arg3,arg4); + arg3 = (int)(*farg3); + arg4 = (sunrealtype)(*farg4); + arg5 = (sunrealtype *)(farg5); + result = (int)SUNAdaptController_EstimateStep(arg1,arg2,arg3,arg4,arg5); fresult = (int)(result); return fresult; } @@ -266,49 +268,55 @@ SWIGEXPORT int _wrap_FSUNAdaptController_EstimateStepAndOrder(SUNAdaptController } -SWIGEXPORT int _wrap_FSUNAdaptController_EstimateMRISteps(SUNAdaptController farg1, double const *farg2, double const *farg3, double const *farg4, double const *farg5, double *farg6, double *farg7) { +SWIGEXPORT int _wrap_FSUNAdaptController_EstimateMRISteps(SUNAdaptController farg1, double const *farg2, double const *farg3, int const *farg4, int const *farg5, double const *farg6, double const *farg7, double *farg8, double *farg9) { int fresult ; SUNAdaptController arg1 = (SUNAdaptController) 0 ; sunrealtype arg2 ; sunrealtype arg3 ; - sunrealtype arg4 ; - sunrealtype arg5 ; - sunrealtype *arg6 = (sunrealtype *) 0 ; - sunrealtype *arg7 = (sunrealtype *) 0 ; + int arg4 ; + int arg5 ; + sunrealtype arg6 ; + sunrealtype arg7 ; + sunrealtype *arg8 = (sunrealtype *) 0 ; + sunrealtype *arg9 = (sunrealtype *) 0 ; int result; arg1 = (SUNAdaptController)(farg1); arg2 = (sunrealtype)(*farg2); arg3 = (sunrealtype)(*farg3); - arg4 = (sunrealtype)(*farg4); - arg5 = (sunrealtype)(*farg5); - arg6 = (sunrealtype *)(farg6); - arg7 = (sunrealtype *)(farg7); - result = (int)SUNAdaptController_EstimateMRISteps(arg1,arg2,arg3,arg4,arg5,arg6,arg7); + arg4 = (int)(*farg4); + arg5 = (int)(*farg5); + arg6 = (sunrealtype)(*farg6); + arg7 = (sunrealtype)(*farg7); + arg8 = (sunrealtype *)(farg8); + arg9 = (sunrealtype *)(farg9); + result = (int)SUNAdaptController_EstimateMRISteps(arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9); fresult = (int)(result); return fresult; } -SWIGEXPORT int _wrap_FSUNAdaptController_EstimateStepTol(SUNAdaptController farg1, double const *farg2, double const *farg3, double const *farg4, double const *farg5, double *farg6, double *farg7) { +SWIGEXPORT int _wrap_FSUNAdaptController_EstimateStepTol(SUNAdaptController farg1, double const *farg2, int const *farg3, double const *farg4, double const *farg5, double const *farg6, double *farg7, double *farg8) { int fresult ; SUNAdaptController arg1 = (SUNAdaptController) 0 ; sunrealtype arg2 ; - sunrealtype arg3 ; + int arg3 ; sunrealtype arg4 ; sunrealtype arg5 ; - sunrealtype *arg6 = (sunrealtype *) 0 ; + sunrealtype arg6 ; sunrealtype *arg7 = (sunrealtype *) 0 ; + sunrealtype *arg8 = (sunrealtype *) 0 ; int result; arg1 = (SUNAdaptController)(farg1); arg2 = (sunrealtype)(*farg2); - arg3 = (sunrealtype)(*farg3); + arg3 = (int)(*farg3); arg4 = (sunrealtype)(*farg4); arg5 = (sunrealtype)(*farg5); - arg6 = (sunrealtype *)(farg6); + arg6 = (sunrealtype)(*farg6); arg7 = (sunrealtype *)(farg7); - result = (int)SUNAdaptController_EstimateStepTol(arg1,arg2,arg3,arg4,arg5,arg6,arg7); + arg8 = (sunrealtype *)(farg8); + result = (int)SUNAdaptController_EstimateStepTol(arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8); fresult = (int)(result); return fresult; } @@ -352,20 +360,6 @@ SWIGEXPORT int _wrap_FSUNAdaptController_Write(SUNAdaptController farg1, void *f } -SWIGEXPORT int _wrap_FSUNAdaptController_SetMethodOrder(SUNAdaptController farg1, int const *farg2) { - int fresult ; - SUNAdaptController arg1 = (SUNAdaptController) 0 ; - int arg2 ; - int result; - - arg1 = (SUNAdaptController)(farg1); - arg2 = (int)(*farg2); - result = (int)SUNAdaptController_SetMethodOrder(arg1,arg2); - fresult = (int)(result); - return fresult; -} - - SWIGEXPORT int _wrap_FSUNAdaptController_SetErrorBias(SUNAdaptController farg1, double const *farg2) { int fresult ; SUNAdaptController arg1 = (SUNAdaptController) 0 ; diff --git a/src/sundials/fmod/fsundials_adaptcontroller_mod.f90 b/src/sundials/fmod/fsundials_adaptcontroller_mod.f90 index 32e9a0bf97..c8a73eea38 100644 --- a/src/sundials/fmod/fsundials_adaptcontroller_mod.f90 +++ b/src/sundials/fmod/fsundials_adaptcontroller_mod.f90 @@ -15,12 +15,12 @@ module fsundials_adaptcontroller_mod enum, bind(c) enumerator :: SUN_ADAPTCONTROLLER_NONE enumerator :: SUN_ADAPTCONTROLLER_H - enumerator :: SUN_ADAPTCONTROLLER_HQ + enumerator :: SUN_ADAPTCONTROLLER_HP enumerator :: SUN_ADAPTCONTROLLER_MRI_H enumerator :: SUN_ADAPTCONTROLLER_MRI_TOL end enum integer, parameter, public :: SUNAdaptController_Type = kind(SUN_ADAPTCONTROLLER_NONE) - public :: SUN_ADAPTCONTROLLER_NONE, SUN_ADAPTCONTROLLER_H, SUN_ADAPTCONTROLLER_HQ, SUN_ADAPTCONTROLLER_MRI_H, & + public :: SUN_ADAPTCONTROLLER_NONE, SUN_ADAPTCONTROLLER_H, SUN_ADAPTCONTROLLER_HP, SUN_ADAPTCONTROLLER_MRI_H, & SUN_ADAPTCONTROLLER_MRI_TOL ! struct struct _generic_SUNAdaptController_Ops type, bind(C), public :: SUNAdaptController_Ops @@ -33,7 +33,6 @@ module fsundials_adaptcontroller_mod type(C_FUNPTR), public :: reset type(C_FUNPTR), public :: setdefaults type(C_FUNPTR), public :: write - type(C_FUNPTR), public :: setmethodorder type(C_FUNPTR), public :: seterrorbias type(C_FUNPTR), public :: update type(C_FUNPTR), public :: updatemrih @@ -56,7 +55,6 @@ module fsundials_adaptcontroller_mod public :: FSUNAdaptController_Reset public :: FSUNAdaptController_SetDefaults public :: FSUNAdaptController_Write - public :: FSUNAdaptController_SetMethodOrder public :: FSUNAdaptController_SetErrorBias public :: FSUNAdaptController_Update public :: FSUNAdaptController_UpdateMRIH @@ -94,14 +92,15 @@ function swigc_FSUNAdaptController_Destroy(farg1) & integer(C_INT) :: fresult end function -function swigc_FSUNAdaptController_EstimateStep(farg1, farg2, farg3, farg4) & +function swigc_FSUNAdaptController_EstimateStep(farg1, farg2, farg3, farg4, farg5) & bind(C, name="_wrap_FSUNAdaptController_EstimateStep") & 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_PTR), value :: farg4 +integer(C_INT), intent(in) :: farg3 +real(C_DOUBLE), intent(in) :: farg4 +type(C_PTR), value :: farg5 integer(C_INT) :: fresult end function @@ -118,31 +117,34 @@ function swigc_FSUNAdaptController_EstimateStepAndOrder(farg1, farg2, farg3, far integer(C_INT) :: fresult end function -function swigc_FSUNAdaptController_EstimateMRISteps(farg1, farg2, farg3, farg4, farg5, farg6, farg7) & +function swigc_FSUNAdaptController_EstimateMRISteps(farg1, farg2, farg3, farg4, farg5, farg6, farg7, farg8, farg9) & bind(C, name="_wrap_FSUNAdaptController_EstimateMRISteps") & result(fresult) use, intrinsic :: ISO_C_BINDING type(C_PTR), value :: farg1 real(C_DOUBLE), intent(in) :: farg2 real(C_DOUBLE), intent(in) :: farg3 -real(C_DOUBLE), intent(in) :: farg4 -real(C_DOUBLE), intent(in) :: farg5 -type(C_PTR), value :: farg6 -type(C_PTR), value :: farg7 +integer(C_INT), intent(in) :: farg4 +integer(C_INT), intent(in) :: farg5 +real(C_DOUBLE), intent(in) :: farg6 +real(C_DOUBLE), intent(in) :: farg7 +type(C_PTR), value :: farg8 +type(C_PTR), value :: farg9 integer(C_INT) :: fresult end function -function swigc_FSUNAdaptController_EstimateStepTol(farg1, farg2, farg3, farg4, farg5, farg6, farg7) & +function swigc_FSUNAdaptController_EstimateStepTol(farg1, farg2, farg3, farg4, farg5, farg6, farg7, farg8) & bind(C, name="_wrap_FSUNAdaptController_EstimateStepTol") & 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), intent(in) :: farg3 real(C_DOUBLE), intent(in) :: farg4 real(C_DOUBLE), intent(in) :: farg5 -type(C_PTR), value :: farg6 +real(C_DOUBLE), intent(in) :: farg6 type(C_PTR), value :: farg7 +type(C_PTR), value :: farg8 integer(C_INT) :: fresult end function @@ -171,15 +173,6 @@ function swigc_FSUNAdaptController_Write(farg1, farg2) & integer(C_INT) :: fresult end function -function swigc_FSUNAdaptController_SetMethodOrder(farg1, farg2) & -bind(C, name="_wrap_FSUNAdaptController_SetMethodOrder") & -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_FSUNAdaptController_SetErrorBias(farg1, farg2) & bind(C, name="_wrap_FSUNAdaptController_SetErrorBias") & result(fresult) @@ -277,38 +270,41 @@ function FSUNAdaptController_Destroy(c) & swig_result = fresult end function -function FSUNAdaptController_EstimateStep(c, h, dsm, hnew) & +function FSUNAdaptController_EstimateStep(c, h, p, dsm, hnew) & result(swig_result) use, intrinsic :: ISO_C_BINDING integer(C_INT) :: swig_result type(SUNAdaptController), target, intent(inout) :: c real(C_DOUBLE), intent(in) :: h +integer(C_INT), intent(in) :: p real(C_DOUBLE), intent(in) :: dsm real(C_DOUBLE), target, intent(inout) :: hnew integer(C_INT) :: fresult type(C_PTR) :: farg1 real(C_DOUBLE) :: farg2 -real(C_DOUBLE) :: farg3 -type(C_PTR) :: farg4 +integer(C_INT) :: farg3 +real(C_DOUBLE) :: farg4 +type(C_PTR) :: farg5 farg1 = c_loc(c) farg2 = h -farg3 = dsm -farg4 = c_loc(hnew) -fresult = swigc_FSUNAdaptController_EstimateStep(farg1, farg2, farg3, farg4) +farg3 = p +farg4 = dsm +farg5 = c_loc(hnew) +fresult = swigc_FSUNAdaptController_EstimateStep(farg1, farg2, farg3, farg4, farg5) swig_result = fresult end function -function FSUNAdaptController_EstimateStepAndOrder(c, h, q, dsm, hnew, qnew) & +function FSUNAdaptController_EstimateStepAndOrder(c, h, p, dsm, hnew, pnew) & result(swig_result) use, intrinsic :: ISO_C_BINDING integer(C_INT) :: swig_result type(SUNAdaptController), target, intent(inout) :: c real(C_DOUBLE), intent(in) :: h -integer(C_INT), intent(in) :: q +integer(C_INT), intent(in) :: p real(C_DOUBLE), intent(in) :: dsm real(C_DOUBLE), target, intent(inout) :: hnew -integer(C_INT), dimension(*), target, intent(inout) :: qnew +integer(C_INT), dimension(*), target, intent(inout) :: pnew integer(C_INT) :: fresult type(C_PTR) :: farg1 real(C_DOUBLE) :: farg2 @@ -319,73 +315,82 @@ function FSUNAdaptController_EstimateStepAndOrder(c, h, q, dsm, hnew, qnew) & farg1 = c_loc(c) farg2 = h -farg3 = q +farg3 = p farg4 = dsm farg5 = c_loc(hnew) -farg6 = c_loc(qnew(1)) +farg6 = c_loc(pnew(1)) fresult = swigc_FSUNAdaptController_EstimateStepAndOrder(farg1, farg2, farg3, farg4, farg5, farg6) swig_result = fresult end function -function FSUNAdaptController_EstimateMRISteps(c, h, h2, dsm, dsm4, hnew, hnew6) & +function FSUNAdaptController_EstimateMRISteps(c, h, h2, p, p4, dsm, dsm6, hnew, hnew8) & result(swig_result) use, intrinsic :: ISO_C_BINDING integer(C_INT) :: swig_result type(SUNAdaptController), target, intent(inout) :: c real(C_DOUBLE), intent(in) :: h real(C_DOUBLE), intent(in) :: h2 +integer(C_INT), intent(in) :: p +integer(C_INT), intent(in) :: p4 real(C_DOUBLE), intent(in) :: dsm -real(C_DOUBLE), intent(in) :: dsm4 +real(C_DOUBLE), intent(in) :: dsm6 real(C_DOUBLE), target, intent(inout) :: hnew -real(C_DOUBLE), target, intent(inout) :: hnew6 +real(C_DOUBLE), target, intent(inout) :: hnew8 integer(C_INT) :: fresult type(C_PTR) :: farg1 real(C_DOUBLE) :: farg2 real(C_DOUBLE) :: farg3 -real(C_DOUBLE) :: farg4 -real(C_DOUBLE) :: farg5 -type(C_PTR) :: farg6 -type(C_PTR) :: farg7 +integer(C_INT) :: farg4 +integer(C_INT) :: farg5 +real(C_DOUBLE) :: farg6 +real(C_DOUBLE) :: farg7 +type(C_PTR) :: farg8 +type(C_PTR) :: farg9 farg1 = c_loc(c) farg2 = h farg3 = h2 -farg4 = dsm -farg5 = dsm4 -farg6 = c_loc(hnew) -farg7 = c_loc(hnew6) -fresult = swigc_FSUNAdaptController_EstimateMRISteps(farg1, farg2, farg3, farg4, farg5, farg6, farg7) +farg4 = p +farg5 = p4 +farg6 = dsm +farg7 = dsm6 +farg8 = c_loc(hnew) +farg9 = c_loc(hnew8) +fresult = swigc_FSUNAdaptController_EstimateMRISteps(farg1, farg2, farg3, farg4, farg5, farg6, farg7, farg8, farg9) swig_result = fresult end function -function FSUNAdaptController_EstimateStepTol(c, h, tolfac, dsm, dsm4, hnew, tolfacnew) & +function FSUNAdaptController_EstimateStepTol(c, h, p, tolfac, dsm, dsm5, hnew, tolfacnew) & result(swig_result) use, intrinsic :: ISO_C_BINDING integer(C_INT) :: swig_result type(SUNAdaptController), target, intent(inout) :: c real(C_DOUBLE), intent(in) :: h +integer(C_INT), intent(in) :: p real(C_DOUBLE), intent(in) :: tolfac real(C_DOUBLE), intent(in) :: dsm -real(C_DOUBLE), intent(in) :: dsm4 +real(C_DOUBLE), intent(in) :: dsm5 real(C_DOUBLE), target, intent(inout) :: hnew real(C_DOUBLE), target, intent(inout) :: tolfacnew integer(C_INT) :: fresult type(C_PTR) :: farg1 real(C_DOUBLE) :: farg2 -real(C_DOUBLE) :: farg3 +integer(C_INT) :: farg3 real(C_DOUBLE) :: farg4 real(C_DOUBLE) :: farg5 -type(C_PTR) :: farg6 +real(C_DOUBLE) :: farg6 type(C_PTR) :: farg7 +type(C_PTR) :: farg8 farg1 = c_loc(c) farg2 = h -farg3 = tolfac -farg4 = dsm -farg5 = dsm4 -farg6 = c_loc(hnew) -farg7 = c_loc(tolfacnew) -fresult = swigc_FSUNAdaptController_EstimateStepTol(farg1, farg2, farg3, farg4, farg5, farg6, farg7) +farg3 = p +farg4 = tolfac +farg5 = dsm +farg6 = dsm5 +farg7 = c_loc(hnew) +farg8 = c_loc(tolfacnew) +fresult = swigc_FSUNAdaptController_EstimateStepTol(farg1, farg2, farg3, farg4, farg5, farg6, farg7, farg8) swig_result = fresult end function @@ -431,22 +436,6 @@ function FSUNAdaptController_Write(c, fptr) & swig_result = fresult end function -function FSUNAdaptController_SetMethodOrder(c, p) & -result(swig_result) -use, intrinsic :: ISO_C_BINDING -integer(C_INT) :: swig_result -type(SUNAdaptController), target, intent(inout) :: c -integer(C_INT), intent(in) :: p -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -integer(C_INT) :: farg2 - -farg1 = c_loc(c) -farg2 = p -fresult = swigc_FSUNAdaptController_SetMethodOrder(farg1, farg2) -swig_result = fresult -end function - function FSUNAdaptController_SetErrorBias(c, bias) & result(swig_result) use, intrinsic :: ISO_C_BINDING diff --git a/src/sundials/sundials_adaptcontroller.c b/src/sundials/sundials_adaptcontroller.c index 5928bb0975..346b47889d 100644 --- a/src/sundials/sundials_adaptcontroller.c +++ b/src/sundials/sundials_adaptcontroller.c @@ -50,7 +50,6 @@ SUNAdaptController SUNAdaptController_NewEmpty(SUNContext sunctx) ops->estimatesteptol = NULL; ops->setdefaults = NULL; ops->write = NULL; - ops->setmethodorder = NULL; ops->seterrorbias = NULL; ops->update = NULL; ops->updatemrih = NULL; @@ -115,36 +114,37 @@ int SUNAdaptController_Destroy(SUNAdaptController C) return(SUNADAPTCONTROLLER_SUCCESS); } -int SUNAdaptController_EstimateStep(SUNAdaptController C, sunrealtype h, sunrealtype dsm, - sunrealtype* hnew) +int SUNAdaptController_EstimateStep(SUNAdaptController C, sunrealtype h, int p, + sunrealtype dsm, sunrealtype* hnew) { int ier = 0; *hnew = h; /* initialize output with identity */ if (C == NULL) { return ier; } if (C->ops->estimatestep) { - ier = C->ops->estimatestep(C, h, dsm, hnew); + ier = C->ops->estimatestep(C, h, p, dsm, hnew); } return(ier); } -int SUNAdaptController_EstimateStepAndOrder(SUNAdaptController C, sunrealtype h, int q, - sunrealtype dsm, sunrealtype* hnew, - int *qnew) +int SUNAdaptController_EstimateStepAndOrder(SUNAdaptController C, sunrealtype h, + int p, sunrealtype dsm, + sunrealtype* hnew, int *pnew) { int ier = 0; *hnew = h; /* initialize outputs with identity */ - *qnew = q; + *pnew = p; if (C == NULL) { return ier; } if (C->ops->estimatestepandorder) { - ier = C->ops->estimatestepandorder(C, h, q, dsm, hnew, qnew); + ier = C->ops->estimatestepandorder(C, h, p, dsm, hnew, pnew); } return(ier); } -int SUNAdaptController_EstimateMRISteps(SUNAdaptController C, sunrealtype H, sunrealtype h, +int SUNAdaptController_EstimateMRISteps(SUNAdaptController C, sunrealtype H, + sunrealtype h, int P, int p, sunrealtype DSM, sunrealtype dsm, sunrealtype* Hnew, sunrealtype *hnew) { @@ -154,15 +154,15 @@ int SUNAdaptController_EstimateMRISteps(SUNAdaptController C, sunrealtype H, sun if (C == NULL) { return ier; } if (C->ops->estimatemristeps) { - ier = C->ops->estimatemristeps(C, H, DSM, dsm, h, Hnew, hnew); + ier = C->ops->estimatemristeps(C, H, h, P, p, DSM, dsm, Hnew, hnew); } return(ier); } int SUNAdaptController_EstimateStepTol(SUNAdaptController C, sunrealtype H, - sunrealtype tolfac, sunrealtype DSM, - sunrealtype dsm, sunrealtype *Hnew, - sunrealtype* tolfacnew) + int P, sunrealtype tolfac, + sunrealtype DSM, sunrealtype dsm, + sunrealtype *Hnew, sunrealtype* tolfacnew) { int ier = 0; *Hnew = H; /* initialize outputs with identity */ @@ -170,7 +170,7 @@ int SUNAdaptController_EstimateStepTol(SUNAdaptController C, sunrealtype H, if (C == NULL) { return ier; } if (C->ops->estimatesteptol) { - ier = C->ops->estimatesteptol(C, H, tolfac, DSM, dsm, + ier = C->ops->estimatesteptol(C, H, P, tolfac, DSM, dsm, Hnew, tolfacnew); } return(ier); @@ -199,14 +199,6 @@ int SUNAdaptController_Write(SUNAdaptController C, FILE* fptr) return(ier); } -int SUNAdaptController_SetMethodOrder(SUNAdaptController C, int p) -{ - int ier = 0; - if (C == NULL) { return ier; } - if (C->ops->setmethodorder) { ier = C->ops->setmethodorder(C, p); } - return(ier); -} - int SUNAdaptController_SetErrorBias(SUNAdaptController C, sunrealtype bias) { int ier = 0; From 7b31a0d373a6b884e45f21d44538e9178085fe8e Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Mon, 23 Oct 2023 13:54:17 -0500 Subject: [PATCH 13/58] Added Soderlind SUNAdaptController implementation --- doc/arkode/guide/source/Introduction.rst | 14 +- .../SUNAdaptController_links.rst | 1 + .../SUNAdaptController_ExpGus.rst | 4 +- .../SUNAdaptController_I.rst | 2 +- .../SUNAdaptController_ImExGus.rst | 8 +- .../SUNAdaptController_ImpGus.rst | 4 +- .../SUNAdaptController_PI.rst | 4 +- .../SUNAdaptController_PID.rst | 6 +- .../SUNAdaptController_Soderlind.rst | 118 ++++++ .../SUNAdaptController_links.rst | 1 + .../sunadaptcontroller_soderlind.h | 82 ++++ src/arkode/CMakeLists.txt | 1 + src/sunadaptcontroller/CMakeLists.txt | 1 + .../expgus/sunadaptcontroller_expgus.c | 5 +- .../i/sunadaptcontroller_i.c | 3 +- .../imexgus/sunadaptcontroller_imexgus.c | 9 +- .../impgus/sunadaptcontroller_impgus.c | 5 +- .../pi/sunadaptcontroller_pi.c | 5 +- .../pid/sunadaptcontroller_pid.c | 7 +- .../soderlind/CMakeLists.txt | 29 ++ .../soderlind/fmod/CMakeLists.txt | 25 ++ .../fmod/fsunadaptcontroller_soderlind_mod.c | 361 ++++++++++++++++++ .../fsunadaptcontroller_soderlind_mod.f90 | 319 ++++++++++++++++ .../soderlind/sunadaptcontroller_soderlind.c | 239 ++++++++++++ swig/Makefile | 2 +- .../fsunadaptcontroller_soderlind_mod.i | 29 ++ 26 files changed, 1246 insertions(+), 38 deletions(-) create mode 100644 doc/shared/sunadaptcontroller/SUNAdaptController_Soderlind.rst create mode 100644 include/sunadaptcontroller/sunadaptcontroller_soderlind.h create mode 100644 src/sunadaptcontroller/soderlind/CMakeLists.txt create mode 100644 src/sunadaptcontroller/soderlind/fmod/CMakeLists.txt create mode 100644 src/sunadaptcontroller/soderlind/fmod/fsunadaptcontroller_soderlind_mod.c create mode 100644 src/sunadaptcontroller/soderlind/fmod/fsunadaptcontroller_soderlind_mod.f90 create mode 100644 src/sunadaptcontroller/soderlind/sunadaptcontroller_soderlind.c create mode 100644 swig/sunadaptcontroller/fsunadaptcontroller_soderlind_mod.i diff --git a/doc/arkode/guide/source/Introduction.rst b/doc/arkode/guide/source/Introduction.rst index 7861e08b27..5763cc8086 100644 --- a/doc/arkode/guide/source/Introduction.rst +++ b/doc/arkode/guide/source/Introduction.rst @@ -133,13 +133,21 @@ Changes from previous versions Changes in vX.X.X ----------------- -Added the :c:type:`SUNAdaptController` base class, ported ARKODE's internal -implementations of time step controllers into implementations of this class, +Added the :c:type:`SUNAdaptController` base class, ported ARKODE's internal +implementations of time step controllers into implementations of this class, and updated ARKODE to use these objects instead of its own implementations. Added :c:func:`ARKStepSetAdaptController` and :c:func:`ERKStepSetAdaptController` -routines so that users can modify controller parameters, or even provide custom +routines so that users can modify controller parameters, or even provide custom implementations. +Added the routines :c:func:`ARKStepSetAdaptivityAdjustment` and +:c:func:`ERKStepSetAdaptivityAdjustment`, that allow users to adjust the +value for the method order supplied to the temporal adaptivity controllers. +The ARKODE default for this adjustment has been :math:`-1` since its initial +release, but for some applications a value of :math:`0` is more appropriate. +Users who notice that their simulations encounter a large number of +temporal error test failures may want to experiment with adjusting this value. + Fixed a regression introduced by the stop time bug fix in v6.6.1 where ARKODE steppers would return at the stop time rather than the requested output time if the stop time was reached in the same step in which the output time was passed. diff --git a/doc/arkode/guide/source/sunadaptcontroller/SUNAdaptController_links.rst b/doc/arkode/guide/source/sunadaptcontroller/SUNAdaptController_links.rst index 0f340d6917..4439c63a92 100644 --- a/doc/arkode/guide/source/sunadaptcontroller/SUNAdaptController_links.rst +++ b/doc/arkode/guide/source/sunadaptcontroller/SUNAdaptController_links.rst @@ -17,3 +17,4 @@ .. include:: ../../../../shared/sunadaptcontroller/SUNAdaptController_ExpGus.rst .. include:: ../../../../shared/sunadaptcontroller/SUNAdaptController_ImpGus.rst .. include:: ../../../../shared/sunadaptcontroller/SUNAdaptController_ImExGus.rst +.. include:: ../../../../shared/sunadaptcontroller/SUNAdaptController_Soderlind.rst diff --git a/doc/shared/sunadaptcontroller/SUNAdaptController_ExpGus.rst b/doc/shared/sunadaptcontroller/SUNAdaptController_ExpGus.rst index 1443be890d..ebb69eab41 100644 --- a/doc/shared/sunadaptcontroller/SUNAdaptController_ExpGus.rst +++ b/doc/shared/sunadaptcontroller/SUNAdaptController_ExpGus.rst @@ -87,8 +87,8 @@ routines: .. c:function:: int SUNAdaptController_SetParams_ExpGus(SUNAdaptController C, sunrealtype k1, sunrealtype k2) :param C: the SUNAdaptController_ExpGus object. - :param k1: parameter used within the controller time step estimate (only stored if non-negative). - :param k2: parameter used within the controller time step estimate (only stored if non-negative). + :param k1: parameter used within the controller time step estimate. + :param k2: parameter used within the controller time step estimate. :return: error code indication success or failure (see :numref:`SUNAdaptController.Description.errorCodes`). Usage: diff --git a/doc/shared/sunadaptcontroller/SUNAdaptController_I.rst b/doc/shared/sunadaptcontroller/SUNAdaptController_I.rst index 60a45972cf..16d15cb233 100644 --- a/doc/shared/sunadaptcontroller/SUNAdaptController_I.rst +++ b/doc/shared/sunadaptcontroller/SUNAdaptController_I.rst @@ -78,7 +78,7 @@ also provides the following additional user-callable routines: the problem. :param C: the SUNAdaptController_I object. - :param k1: parameter used within the controller time step estimate (only stored if non-negative). + :param k1: parameter used within the controller time step estimate. :return: error code indication success or failure (see :numref:`SUNAdaptController.Description.errorCodes`). Usage: diff --git a/doc/shared/sunadaptcontroller/SUNAdaptController_ImExGus.rst b/doc/shared/sunadaptcontroller/SUNAdaptController_ImExGus.rst index 3bff348a59..822db31106 100644 --- a/doc/shared/sunadaptcontroller/SUNAdaptController_ImExGus.rst +++ b/doc/shared/sunadaptcontroller/SUNAdaptController_ImExGus.rst @@ -116,10 +116,10 @@ routines: the problem. :param C: the SUNAdaptController_ImExGus object. - :param k1e: parameter used within the controller time step estimate (only stored if non-negative). - :param k2e: parameter used within the controller time step estimate (only stored if non-negative). - :param k1i: parameter used within the controller time step estimate (only stored if non-negative). - :param k2i: parameter used within the controller time step estimate (only stored if non-negative). + :param k1e: parameter used within the controller time step estimate. + :param k2e: parameter used within the controller time step estimate. + :param k1i: parameter used within the controller time step estimate. + :param k2i: parameter used within the controller time step estimate. :return: error code indication success or failure (see :numref:`SUNAdaptController.Description.errorCodes`). Usage: diff --git a/doc/shared/sunadaptcontroller/SUNAdaptController_ImpGus.rst b/doc/shared/sunadaptcontroller/SUNAdaptController_ImpGus.rst index 7eef22c829..3e2c019dca 100644 --- a/doc/shared/sunadaptcontroller/SUNAdaptController_ImpGus.rst +++ b/doc/shared/sunadaptcontroller/SUNAdaptController_ImpGus.rst @@ -95,8 +95,8 @@ also provides the following additional user-callable routines: the problem. :param C: the SUNAdaptController_ImpGus object. - :param k1: parameter used within the controller time step estimate (only stored if non-negative). - :param k2: parameter used within the controller time step estimate (only stored if non-negative). + :param k1: parameter used within the controller time step estimate. + :param k2: parameter used within the controller time step estimate. :return: error code indication success or failure (see :numref:`SUNAdaptController.Description.errorCodes`). Usage: diff --git a/doc/shared/sunadaptcontroller/SUNAdaptController_PI.rst b/doc/shared/sunadaptcontroller/SUNAdaptController_PI.rst index b8c55ae3e9..bfb9c1e881 100644 --- a/doc/shared/sunadaptcontroller/SUNAdaptController_PI.rst +++ b/doc/shared/sunadaptcontroller/SUNAdaptController_PI.rst @@ -83,8 +83,8 @@ also provides the following additional user-callable routines: the problem. :param C: the SUNAdaptController_PI object. - :param k1: parameter used within the controller time step estimate (only stored if non-negative). - :param k2: parameter used within the controller time step estimate (only stored if non-negative). + :param k1: parameter used within the controller time step estimate. + :param k2: parameter used within the controller time step estimate. :return: error code indication success or failure (see :numref:`SUNAdaptController.Description.errorCodes`). Usage: diff --git a/doc/shared/sunadaptcontroller/SUNAdaptController_PID.rst b/doc/shared/sunadaptcontroller/SUNAdaptController_PID.rst index 7db5d77aff..bc410b554f 100644 --- a/doc/shared/sunadaptcontroller/SUNAdaptController_PID.rst +++ b/doc/shared/sunadaptcontroller/SUNAdaptController_PID.rst @@ -89,9 +89,9 @@ also provides the following additional user-callable routines: the problem. :param C: the SUNAdaptController_PID object. - :param k1: parameter used within the controller time step estimate (only stored if non-negative). - :param k2: parameter used within the controller time step estimate (only stored if non-negative). - :param k3: parameter used within the controller time step estimate (only stored if non-negative). + :param k1: parameter used within the controller time step estimate. + :param k2: parameter used within the controller time step estimate. + :param k3: parameter used within the controller time step estimate. :return: error code indication success or failure (see :numref:`SUNAdaptController.Description.errorCodes`). Usage: diff --git a/doc/shared/sunadaptcontroller/SUNAdaptController_Soderlind.rst b/doc/shared/sunadaptcontroller/SUNAdaptController_Soderlind.rst new file mode 100644 index 0000000000..c53e0102ae --- /dev/null +++ b/doc/shared/sunadaptcontroller/SUNAdaptController_Soderlind.rst @@ -0,0 +1,118 @@ +.. + Programmer(s): Daniel R. Reynolds @ SMU + ---------------------------------------------------------------- + SUNDIALS Copyright Start + Copyright (c) 2002-2023, 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 + ---------------------------------------------------------------- + +.. _SUNAdaptController.Soderlind: + +The SUNAdaptController_Soderlind Module +====================================== + +The Soderlind implementation of the SUNAdaptController class, +SUNAdaptController_Soderlind, implements a general structure for temporal +control proposed by G. Söderlind in :cite:p:`Sod:98`, :cite:p:`Sod:03` +and :cite:p:`Sod:06`. This controller has the form + +.. math:: + h' = h_n \varepsilon_n^{-k_1/(p+1)} \varepsilon_{n-1}^{-k_2/(p+1)} \varepsilon_{n-2}^{-k_3/(p+1)} \left(\dfrac{h_n}{h_{n-1}}\right)^{k_4} \left(\dfrac{h_{n-1}}{h_{n-2}}\right)^{k_5} + +with default parameter values :math:`k_1 = 1.25`, :math:`k_2 = 0.5`, +:math:`k_3 = -0.75`, :math:`k_4 = 0.25` and :math:`k_5 = 0.75`, where +:math:`p` is the global order of the time integration method. In this estimate, +a floor of :math:`\varepsilon > 10^{-10}` is enforced to avoid division-by-zero +errors. During the first two steps (when :math:`\varepsilon_{n-2}`, +:math:`\varepsilon_{n-1}`, :math:`h_{n-2}` and :math:`h_{n-2}` may be unavailable), +the corresponding terms are merely omitted during estimation of :math:`h'`. + +The SUNAdaptController_Soderlind controller is implemented as a derived +SUNAdaptController class, and defines its *content* field as: + +.. code-block:: c + + struct _SUNAdaptControllerContent_Soderlind { + sunrealtype k1; + sunrealtype k2; + sunrealtype k3; + sunrealtype k4; + sunrealtype k5; + sunrealtype bias; + sunrealtype ep; + sunrealtype epp; + sunrealtype hp; + sunrealtype hpp; + int firststeps; + }; + +These entries of the *content* field contain the following information: + +* ``k1, k2, k3, k4, k5`` - controller parameters above. + +* ``bias`` - error bias factor, that converts from an input temporal error + estimate via :math:`\varepsilon = \text{bias}*\text{dsm}`. + +* ``ep, epp`` - storage for the two previous error estimates, + :math:`\varepsilon_{n-1}` and :math:`varepsilon_{n-2}`. + +* ``hp, hpp`` - storage for the previous two step sizes, :math:`h_{n-1}` + and :math:`h_{n-2}`. + +* ``firststeps`` - counter to handle first two steps (where previous + step sizes and errors are unavailable). + +The header file to be included when using this module is +``sunadaptcontroller/sunadaptcontroller_soderlind.h``. + +We note that through appropriate selection of the parameters :math:`k_1 - k_5`, +this controller may replicate the behavior of each of the PID, PI and I +SUNController implementations. + +The SUNAdaptController_Soderlind class provides implementations of all operations +relevant to a `SUN_ADAPTCONTROLLER_H` controller listed in +:numref:`SUNAdaptController.Description.operations`. This class +also provides the following additional user-callable routines: + + +.. c:function:: SUNAdaptController SUNAdaptController_Soderlind(SUNContext sunctx) + + This constructor function creates and allocates memory for a SUNAdaptController_Soderlind + object, and inserts its default parameters. + + :param sunctx: the current :c:type:`SUNContext` object. + :return: if successful, a usable :c:type:`SUNAdaptController` object; + otherwise it will return ``NULL``. + + Usage: + + .. code-block:: c + + SUNAdaptController C = SUNAdaptController_Soderlind(sunctx); + +.. c:function:: int SUNAdaptController_SetParams_Soderlind(SUNAdaptController C, sunrealtype k1, sunrealtype k2, sunrealtype k3, sunrealtype k4, sunrealtype k5) + + This user-callable function provides control over the relevant parameters + above. This should be called *before* the time integrator is called to evolve + the problem. + + :param C: the SUNAdaptController_Soderlind object. + :param k1: parameter used within the controller time step estimate. + :param k2: parameter used within the controller time step estimate. + :param k3: parameter used within the controller time step estimate. + :param k4: parameter used within the controller time step estimate. + :param k5: parameter used within the controller time step estimate. + :return: error code indication success or failure (see :numref:`SUNAdaptController.Description.errorCodes`). + + Usage: + + .. code-block:: c + + /* Specify parameters for Soderlind's H_{0}312 controller */ + retval = SUNAdaptController_SetParams_Soderlind(C, 0.25, 0.5, 0.25, -0.75, -0.25); diff --git a/doc/superbuild/source/sunadaptcontroller/SUNAdaptController_links.rst b/doc/superbuild/source/sunadaptcontroller/SUNAdaptController_links.rst index 644d07639e..15172d99d3 100644 --- a/doc/superbuild/source/sunadaptcontroller/SUNAdaptController_links.rst +++ b/doc/superbuild/source/sunadaptcontroller/SUNAdaptController_links.rst @@ -16,3 +16,4 @@ .. include:: ../../../shared/sunadaptcontroller/SUNAdaptController_ExpGus.rst .. include:: ../../../shared/sunadaptcontroller/SUNAdaptController_ImpGus.rst .. include:: ../../../shared/sunadaptcontroller/SUNAdaptController_ImExGus.rst +.. include:: ../../../shared/sunadaptcontroller/SUNAdaptController_Soderlind.rst diff --git a/include/sunadaptcontroller/sunadaptcontroller_soderlind.h b/include/sunadaptcontroller/sunadaptcontroller_soderlind.h new file mode 100644 index 0000000000..e7af60f7aa --- /dev/null +++ b/include/sunadaptcontroller/sunadaptcontroller_soderlind.h @@ -0,0 +1,82 @@ +/* ----------------------------------------------------------------- + * Programmer(s): Daniel R. Reynolds @ SMU + * ----------------------------------------------------------------- + * SUNDIALS Copyright Start + * Copyright (c) 2002-2023, Lawrence Livermore National Security + * and Southern Methodist University. + * All rights reserved. + * + * See the top-level LICENSE and NOTICE files for details. + * + * SPDX-License-Identifier: BSD-3-Clause + * SUNDIALS Copyright End + * ----------------------------------------------------------------- + * This is the header file for the SUNAdaptController_Soderlind + * module. + * -----------------------------------------------------------------*/ + +#ifndef _SUNADAPTCONTROLLER_SODERLIND_H +#define _SUNADAPTCONTROLLER_SODERLIND_H + +#include +#include + +#ifdef __cplusplus /* wrapper to enable C++ usage */ +extern "C" { +#endif + +/* ---------------------------------------------------- + * Soderlind implementation of SUNAdaptController + * ---------------------------------------------------- */ + +struct _SUNAdaptControllerContent_Soderlind { + sunrealtype k1; /* internal controller parameters */ + sunrealtype k2; + sunrealtype k3; + sunrealtype k4; + sunrealtype k5; + sunrealtype bias; /* error bias factor */ + sunrealtype ep; /* error from previous step */ + sunrealtype epp; /* error from 2 steps ago */ + sunrealtype hp; /* previous step size */ + sunrealtype hpp; /* step size from 2 steps ago */ + int firststeps; /* flag to handle first few steps */ +}; + +typedef struct _SUNAdaptControllerContent_Soderlind *SUNAdaptControllerContent_Soderlind; + +/* ------------------ + * Exported Functions + * ------------------ */ + +SUNDIALS_EXPORT +SUNAdaptController SUNAdaptController_Soderlind(SUNContext sunctx); +SUNDIALS_EXPORT +int SUNAdaptController_SetParams_Soderlind(SUNAdaptController C, + sunrealtype k1, sunrealtype k2, + sunrealtype k3, sunrealtype k4, + sunrealtype k5); +SUNDIALS_EXPORT +SUNAdaptController_Type SUNAdaptController_GetType_Soderlind(SUNAdaptController C); +SUNDIALS_EXPORT +int SUNAdaptController_EstimateStep_Soderlind(SUNAdaptController C, sunrealtype h, + int p, sunrealtype dsm, sunrealtype* hnew); +SUNDIALS_EXPORT +int SUNAdaptController_Reset_Soderlind(SUNAdaptController C); +SUNDIALS_EXPORT +int SUNAdaptController_SetDefaults_Soderlind(SUNAdaptController C); +SUNDIALS_EXPORT +int SUNAdaptController_Write_Soderlind(SUNAdaptController C, FILE* fptr); +SUNDIALS_EXPORT +int SUNAdaptController_SetErrorBias_Soderlind(SUNAdaptController C, sunrealtype bias); +SUNDIALS_EXPORT +int SUNAdaptController_Update_Soderlind(SUNAdaptController C, sunrealtype h, sunrealtype dsm); +SUNDIALS_EXPORT +int SUNAdaptController_Space_Soderlind(SUNAdaptController C, long int *lenrw, + long int *leniw); + +#ifdef __cplusplus +} +#endif + +#endif /* _SUNADAPTCONTROLLER_SODERLIND_H */ diff --git a/src/arkode/CMakeLists.txt b/src/arkode/CMakeLists.txt index c8888ccd08..c817398eaf 100644 --- a/src/arkode/CMakeLists.txt +++ b/src/arkode/CMakeLists.txt @@ -83,6 +83,7 @@ sundials_add_library(sundials_arkode sundials_sunadaptcontrollerpi_obj sundials_sunadaptcontrollerimexgus_obj sundials_sunadaptcontrollernoop_obj + sundials_sunadaptcontrollersoderlind_obj sundials_sunmatrixband_obj sundials_sunmatrixdense_obj sundials_sunmatrixsparse_obj diff --git a/src/sunadaptcontroller/CMakeLists.txt b/src/sunadaptcontroller/CMakeLists.txt index bb3a248f70..3094cf4882 100644 --- a/src/sunadaptcontroller/CMakeLists.txt +++ b/src/sunadaptcontroller/CMakeLists.txt @@ -22,3 +22,4 @@ add_subdirectory(impgus) add_subdirectory(noop) add_subdirectory(pi) add_subdirectory(pid) +add_subdirectory(soderlind) diff --git a/src/sunadaptcontroller/expgus/sunadaptcontroller_expgus.c b/src/sunadaptcontroller/expgus/sunadaptcontroller_expgus.c index 1f6c7875e2..df1a47efac 100644 --- a/src/sunadaptcontroller/expgus/sunadaptcontroller_expgus.c +++ b/src/sunadaptcontroller/expgus/sunadaptcontroller_expgus.c @@ -96,9 +96,8 @@ SUNAdaptController SUNAdaptController_ExpGus(SUNContext sunctx) int SUNAdaptController_SetParams_ExpGus(SUNAdaptController C, sunrealtype k1, sunrealtype k2) { - /* store legal inputs, and return with success */ - if (k1 >= RCONST(0.0)) { SACEXPGUS_K1(C) = k1; } - if (k2 >= RCONST(0.0)) { SACEXPGUS_K2(C) = k2; } + SACEXPGUS_K1(C) = k1; + SACEXPGUS_K2(C) = k2; return SUNADAPTCONTROLLER_SUCCESS; } diff --git a/src/sunadaptcontroller/i/sunadaptcontroller_i.c b/src/sunadaptcontroller/i/sunadaptcontroller_i.c index f551a8f12d..d959fee193 100644 --- a/src/sunadaptcontroller/i/sunadaptcontroller_i.c +++ b/src/sunadaptcontroller/i/sunadaptcontroller_i.c @@ -88,8 +88,7 @@ SUNAdaptController SUNAdaptController_I(SUNContext sunctx) int SUNAdaptController_SetParams_I(SUNAdaptController C, sunrealtype k1) { - /* store legal inputs, and return with success */ - if (k1 >= RCONST(0.0)) { SACI_K1(C) = k1; } + SACI_K1(C) = k1; return SUNADAPTCONTROLLER_SUCCESS; } diff --git a/src/sunadaptcontroller/imexgus/sunadaptcontroller_imexgus.c b/src/sunadaptcontroller/imexgus/sunadaptcontroller_imexgus.c index 8e78911107..6d1e6deec8 100644 --- a/src/sunadaptcontroller/imexgus/sunadaptcontroller_imexgus.c +++ b/src/sunadaptcontroller/imexgus/sunadaptcontroller_imexgus.c @@ -102,11 +102,10 @@ int SUNAdaptController_SetParams_ImExGus(SUNAdaptController C, sunrealtype k1e, sunrealtype k2e, sunrealtype k1i, sunrealtype k2i) { - /* store legal inputs, and return with success */ - if (k1e >= RCONST(0.0)) { SACIMEXGUS_K1E(C) = k1e; } - if (k2e >= RCONST(0.0)) { SACIMEXGUS_K2E(C) = k2e; } - if (k1i >= RCONST(0.0)) { SACIMEXGUS_K1I(C) = k1i; } - if (k2i >= RCONST(0.0)) { SACIMEXGUS_K2I(C) = k2i; } + SACIMEXGUS_K1E(C) = k1e; + SACIMEXGUS_K2E(C) = k2e; + SACIMEXGUS_K1I(C) = k1i; + SACIMEXGUS_K2I(C) = k2i; return SUNADAPTCONTROLLER_SUCCESS; } diff --git a/src/sunadaptcontroller/impgus/sunadaptcontroller_impgus.c b/src/sunadaptcontroller/impgus/sunadaptcontroller_impgus.c index ea9c29c551..44e2329fce 100644 --- a/src/sunadaptcontroller/impgus/sunadaptcontroller_impgus.c +++ b/src/sunadaptcontroller/impgus/sunadaptcontroller_impgus.c @@ -97,9 +97,8 @@ SUNAdaptController SUNAdaptController_ImpGus(SUNContext sunctx) int SUNAdaptController_SetParams_ImpGus(SUNAdaptController C, sunrealtype k1, sunrealtype k2) { - /* store legal inputs, and return with success */ - if (k1 >= RCONST(0.0)) { SACIMPGUS_K1(C) = k1; } - if (k2 >= RCONST(0.0)) { SACIMPGUS_K2(C) = k2; } + SACIMPGUS_K1(C) = k1; + SACIMPGUS_K2(C) = k2; return SUNADAPTCONTROLLER_SUCCESS; } diff --git a/src/sunadaptcontroller/pi/sunadaptcontroller_pi.c b/src/sunadaptcontroller/pi/sunadaptcontroller_pi.c index 416bea4b1b..c5e2104dd6 100644 --- a/src/sunadaptcontroller/pi/sunadaptcontroller_pi.c +++ b/src/sunadaptcontroller/pi/sunadaptcontroller_pi.c @@ -95,9 +95,8 @@ SUNAdaptController SUNAdaptController_PI(SUNContext sunctx) int SUNAdaptController_SetParams_PI(SUNAdaptController C, sunrealtype k1, sunrealtype k2) { - /* store legal inputs, and return with success */ - if (k1 >= RCONST(0.0)) { SACPI_K1(C) = k1; } - if (k2 >= RCONST(0.0)) { SACPI_K2(C) = k2; } + SACPI_K1(C) = k1; + SACPI_K2(C) = k2; return SUNADAPTCONTROLLER_SUCCESS; } diff --git a/src/sunadaptcontroller/pid/sunadaptcontroller_pid.c b/src/sunadaptcontroller/pid/sunadaptcontroller_pid.c index ec2cd4dbe8..229b04a6d8 100644 --- a/src/sunadaptcontroller/pid/sunadaptcontroller_pid.c +++ b/src/sunadaptcontroller/pid/sunadaptcontroller_pid.c @@ -98,10 +98,9 @@ SUNAdaptController SUNAdaptController_PID(SUNContext sunctx) int SUNAdaptController_SetParams_PID(SUNAdaptController C, sunrealtype k1, sunrealtype k2, sunrealtype k3) { - /* store legal inputs, and return with success */ - if (k1 >= RCONST(0.0)) { SACPID_K1(C) = k1; } - if (k2 >= RCONST(0.0)) { SACPID_K2(C) = k2; } - if (k3 >= RCONST(0.0)) { SACPID_K3(C) = k3; } + SACPID_K1(C) = k1; + SACPID_K2(C) = k2; + SACPID_K3(C) = k3; return SUNADAPTCONTROLLER_SUCCESS; } diff --git a/src/sunadaptcontroller/soderlind/CMakeLists.txt b/src/sunadaptcontroller/soderlind/CMakeLists.txt new file mode 100644 index 0000000000..ef8ed40df0 --- /dev/null +++ b/src/sunadaptcontroller/soderlind/CMakeLists.txt @@ -0,0 +1,29 @@ +# --------------------------------------------------------------- +# Programmer(s): Daniel R. Reynolds @ SMU +# --------------------------------------------------------------- +# SUNDIALS Copyright Start +# Copyright (c) 2002-2023, 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 +# --------------------------------------------------------------- + +# Create a library out of the generic sundials modules +sundials_add_library(sundials_sunadaptcontrollersoderlind + SOURCES + sunadaptcontroller_soderlind.c + HEADERS + ${SUNDIALS_SOURCE_DIR}/include/sunadaptcontroller/sunadaptcontroller_soderlind.h + INCLUDE_SUBDIR + sunadaptcontroller + OBJECT_LIB_ONLY +) + +# Add F2003 module if the interface is enabled +if(BUILD_FORTRAN_MODULE_INTERFACE) + add_subdirectory(fmod) +endif() diff --git a/src/sunadaptcontroller/soderlind/fmod/CMakeLists.txt b/src/sunadaptcontroller/soderlind/fmod/CMakeLists.txt new file mode 100644 index 0000000000..99cfdcbc0f --- /dev/null +++ b/src/sunadaptcontroller/soderlind/fmod/CMakeLists.txt @@ -0,0 +1,25 @@ +# --------------------------------------------------------------- +# Programmer(s): Daniel R. Reynolds @ SMU +# --------------------------------------------------------------- +# SUNDIALS Copyright Start +# Copyright (c) 2002-2023, 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 +# --------------------------------------------------------------- + +sundials_add_f2003_library(sundials_fsunadaptcontrollersoderlind_mod + SOURCES + fsunadaptcontroller_soderlind_mod.f90 fsunadaptcontroller_soderlind_mod.c + OBJECT_LIBRARIES + sundials_fgeneric_mod_obj + OUTPUT_NAME + sundials_fsunadaptcontrollersoderlind_mod + OBJECT_LIB_ONLY +) + +message(STATUS "Added SUNAdaptController_Soderlind F2003 interface") diff --git a/src/sunadaptcontroller/soderlind/fmod/fsunadaptcontroller_soderlind_mod.c b/src/sunadaptcontroller/soderlind/fmod/fsunadaptcontroller_soderlind_mod.c new file mode 100644 index 0000000000..4d920d36c2 --- /dev/null +++ b/src/sunadaptcontroller/soderlind/fmod/fsunadaptcontroller_soderlind_mod.c @@ -0,0 +1,361 @@ +/* ---------------------------------------------------------------------------- + * This file was automatically generated by SWIG (http://www.swig.org). + * Version 4.0.0 + * + * This file is not intended to be easily readable and contains a number of + * coding conventions designed to improve portability and efficiency. Do not make + * changes to this file unless you know what you are doing--modify the SWIG + * interface file instead. + * ----------------------------------------------------------------------------- */ + +/* --------------------------------------------------------------- + * Programmer(s): Auto-generated by swig. + * --------------------------------------------------------------- + * SUNDIALS Copyright Start + * Copyright (c) 2002-2023, Lawrence Livermore National Security + * and Southern Methodist University. + * All rights reserved. + * + * See the top-level LICENSE and NOTICE files for details. + * + * SPDX-License-Identifier: BSD-3-Clause + * SUNDIALS Copyright End + * -------------------------------------------------------------*/ + +/* ----------------------------------------------------------------------------- + * This section contains generic SWIG labels for method/variable + * declarations/attributes, and other compiler dependent labels. + * ----------------------------------------------------------------------------- */ + +/* template workaround for compilers that cannot correctly implement the C++ standard */ +#ifndef SWIGTEMPLATEDISAMBIGUATOR +# if defined(__SUNPRO_CC) && (__SUNPRO_CC <= 0x560) +# define SWIGTEMPLATEDISAMBIGUATOR template +# elif defined(__HP_aCC) +/* Needed even with `aCC -AA' when `aCC -V' reports HP ANSI C++ B3910B A.03.55 */ +/* If we find a maximum version that requires this, the test would be __HP_aCC <= 35500 for A.03.55 */ +# define SWIGTEMPLATEDISAMBIGUATOR template +# else +# define SWIGTEMPLATEDISAMBIGUATOR +# endif +#endif + +/* inline attribute */ +#ifndef SWIGINLINE +# if defined(__cplusplus) || (defined(__GNUC__) && !defined(__STRICT_ANSI__)) +# define SWIGINLINE inline +# else +# define SWIGINLINE +# endif +#endif + +/* attribute recognised by some compilers to avoid 'unused' warnings */ +#ifndef SWIGUNUSED +# if defined(__GNUC__) +# if !(defined(__cplusplus)) || (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)) +# define SWIGUNUSED __attribute__ ((__unused__)) +# else +# define SWIGUNUSED +# endif +# elif defined(__ICC) +# define SWIGUNUSED __attribute__ ((__unused__)) +# else +# define SWIGUNUSED +# endif +#endif + +#ifndef SWIG_MSC_UNSUPPRESS_4505 +# if defined(_MSC_VER) +# pragma warning(disable : 4505) /* unreferenced local function has been removed */ +# endif +#endif + +#ifndef SWIGUNUSEDPARM +# ifdef __cplusplus +# define SWIGUNUSEDPARM(p) +# else +# define SWIGUNUSEDPARM(p) p SWIGUNUSED +# endif +#endif + +/* internal SWIG method */ +#ifndef SWIGINTERN +# define SWIGINTERN static SWIGUNUSED +#endif + +/* internal inline SWIG method */ +#ifndef SWIGINTERNINLINE +# define SWIGINTERNINLINE SWIGINTERN SWIGINLINE +#endif + +/* qualifier for exported *const* global data variables*/ +#ifndef SWIGEXTERN +# ifdef __cplusplus +# define SWIGEXTERN extern +# else +# define SWIGEXTERN +# endif +#endif + +/* exporting methods */ +#if defined(__GNUC__) +# if (__GNUC__ >= 4) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) +# ifndef GCC_HASCLASSVISIBILITY +# define GCC_HASCLASSVISIBILITY +# endif +# endif +#endif + +#ifndef SWIGEXPORT +# if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__) +# if defined(STATIC_LINKED) +# define SWIGEXPORT +# else +# define SWIGEXPORT __declspec(dllexport) +# endif +# else +# if defined(__GNUC__) && defined(GCC_HASCLASSVISIBILITY) +# define SWIGEXPORT __attribute__ ((visibility("default"))) +# else +# define SWIGEXPORT +# endif +# endif +#endif + +/* calling conventions for Windows */ +#ifndef SWIGSTDCALL +# if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__) +# define SWIGSTDCALL __stdcall +# else +# define SWIGSTDCALL +# endif +#endif + +/* Deal with Microsoft's attempt at deprecating C standard runtime functions */ +#if !defined(SWIG_NO_CRT_SECURE_NO_DEPRECATE) && defined(_MSC_VER) && !defined(_CRT_SECURE_NO_DEPRECATE) +# define _CRT_SECURE_NO_DEPRECATE +#endif + +/* Deal with Microsoft's attempt at deprecating methods in the standard C++ library */ +#if !defined(SWIG_NO_SCL_SECURE_NO_DEPRECATE) && defined(_MSC_VER) && !defined(_SCL_SECURE_NO_DEPRECATE) +# define _SCL_SECURE_NO_DEPRECATE +#endif + +/* Deal with Apple's deprecated 'AssertMacros.h' from Carbon-framework */ +#if defined(__APPLE__) && !defined(__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES) +# define __ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES 0 +#endif + +/* Intel's compiler complains if a variable which was never initialised is + * cast to void, which is a common idiom which we use to indicate that we + * are aware a variable isn't used. So we just silence that warning. + * See: https://github.com/swig/swig/issues/192 for more discussion. + */ +#ifdef __INTEL_COMPILER +# pragma warning disable 592 +#endif + +/* Errors in SWIG */ +#define SWIG_UnknownError -1 +#define SWIG_IOError -2 +#define SWIG_RuntimeError -3 +#define SWIG_IndexError -4 +#define SWIG_TypeError -5 +#define SWIG_DivisionByZero -6 +#define SWIG_OverflowError -7 +#define SWIG_SyntaxError -8 +#define SWIG_ValueError -9 +#define SWIG_SystemError -10 +#define SWIG_AttributeError -11 +#define SWIG_MemoryError -12 +#define SWIG_NullReferenceError -13 + + + + +#include +#define SWIG_exception_impl(DECL, CODE, MSG, RETURNNULL) \ + { printf("In " DECL ": " MSG); assert(0); RETURNNULL; } + + +#include +#if defined(_MSC_VER) || defined(__BORLANDC__) || defined(_WATCOM) +# ifndef snprintf +# define snprintf _snprintf +# endif +#endif + + +/* Support for the `contract` feature. + * + * Note that RETURNNULL is first because it's inserted via a 'Replaceall' in + * the fortran.cxx file. + */ +#define SWIG_contract_assert(RETURNNULL, EXPR, MSG) \ + if (!(EXPR)) { SWIG_exception_impl("$decl", SWIG_ValueError, MSG, RETURNNULL); } + + +#define SWIGVERSION 0x040000 +#define SWIG_VERSION SWIGVERSION + + +#define SWIG_as_voidptr(a) (void *)((const void *)(a)) +#define SWIG_as_voidptrptr(a) ((void)SWIG_as_voidptr(*a),(void**)(a)) + + +#include "sundials/sundials_adaptcontroller.h" + + +#include "sunadaptcontroller/sunadaptcontroller_soderlind.h" + +SWIGEXPORT SUNAdaptController _wrap_FSUNAdaptController_Soderlind(void *farg1) { + SUNAdaptController fresult ; + SUNContext arg1 = (SUNContext) 0 ; + SUNAdaptController result; + + arg1 = (SUNContext)(farg1); + result = (SUNAdaptController)SUNAdaptController_Soderlind(arg1); + fresult = result; + return fresult; +} + + +SWIGEXPORT int _wrap_FSUNAdaptController_SetParams_Soderlind(SUNAdaptController farg1, double const *farg2, double const *farg3, double const *farg4, double const *farg5, double const *farg6) { + int fresult ; + SUNAdaptController arg1 = (SUNAdaptController) 0 ; + sunrealtype arg2 ; + sunrealtype arg3 ; + sunrealtype arg4 ; + sunrealtype arg5 ; + sunrealtype arg6 ; + int result; + + arg1 = (SUNAdaptController)(farg1); + arg2 = (sunrealtype)(*farg2); + arg3 = (sunrealtype)(*farg3); + arg4 = (sunrealtype)(*farg4); + arg5 = (sunrealtype)(*farg5); + arg6 = (sunrealtype)(*farg6); + result = (int)SUNAdaptController_SetParams_Soderlind(arg1,arg2,arg3,arg4,arg5,arg6); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FSUNAdaptController_GetType_Soderlind(SUNAdaptController farg1) { + int fresult ; + SUNAdaptController arg1 = (SUNAdaptController) 0 ; + SUNAdaptController_Type result; + + arg1 = (SUNAdaptController)(farg1); + result = (SUNAdaptController_Type)SUNAdaptController_GetType_Soderlind(arg1); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FSUNAdaptController_EstimateStep_Soderlind(SUNAdaptController farg1, double const *farg2, int const *farg3, double const *farg4, double *farg5) { + int fresult ; + SUNAdaptController arg1 = (SUNAdaptController) 0 ; + sunrealtype arg2 ; + int arg3 ; + sunrealtype arg4 ; + sunrealtype *arg5 = (sunrealtype *) 0 ; + int result; + + arg1 = (SUNAdaptController)(farg1); + arg2 = (sunrealtype)(*farg2); + arg3 = (int)(*farg3); + arg4 = (sunrealtype)(*farg4); + arg5 = (sunrealtype *)(farg5); + result = (int)SUNAdaptController_EstimateStep_Soderlind(arg1,arg2,arg3,arg4,arg5); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FSUNAdaptController_Reset_Soderlind(SUNAdaptController farg1) { + int fresult ; + SUNAdaptController arg1 = (SUNAdaptController) 0 ; + int result; + + arg1 = (SUNAdaptController)(farg1); + result = (int)SUNAdaptController_Reset_Soderlind(arg1); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FSUNAdaptController_SetDefaults_Soderlind(SUNAdaptController farg1) { + int fresult ; + SUNAdaptController arg1 = (SUNAdaptController) 0 ; + int result; + + arg1 = (SUNAdaptController)(farg1); + result = (int)SUNAdaptController_SetDefaults_Soderlind(arg1); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FSUNAdaptController_Write_Soderlind(SUNAdaptController farg1, void *farg2) { + int fresult ; + SUNAdaptController arg1 = (SUNAdaptController) 0 ; + FILE *arg2 = (FILE *) 0 ; + int result; + + arg1 = (SUNAdaptController)(farg1); + arg2 = (FILE *)(farg2); + result = (int)SUNAdaptController_Write_Soderlind(arg1,arg2); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FSUNAdaptController_SetErrorBias_Soderlind(SUNAdaptController farg1, double const *farg2) { + int fresult ; + SUNAdaptController arg1 = (SUNAdaptController) 0 ; + sunrealtype arg2 ; + int result; + + arg1 = (SUNAdaptController)(farg1); + arg2 = (sunrealtype)(*farg2); + result = (int)SUNAdaptController_SetErrorBias_Soderlind(arg1,arg2); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FSUNAdaptController_Update_Soderlind(SUNAdaptController farg1, double const *farg2, double const *farg3) { + int fresult ; + SUNAdaptController arg1 = (SUNAdaptController) 0 ; + sunrealtype arg2 ; + sunrealtype arg3 ; + int result; + + arg1 = (SUNAdaptController)(farg1); + arg2 = (sunrealtype)(*farg2); + arg3 = (sunrealtype)(*farg3); + result = (int)SUNAdaptController_Update_Soderlind(arg1,arg2,arg3); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FSUNAdaptController_Space_Soderlind(SUNAdaptController farg1, long *farg2, long *farg3) { + int fresult ; + SUNAdaptController arg1 = (SUNAdaptController) 0 ; + long *arg2 = (long *) 0 ; + long *arg3 = (long *) 0 ; + int result; + + arg1 = (SUNAdaptController)(farg1); + arg2 = (long *)(farg2); + arg3 = (long *)(farg3); + result = (int)SUNAdaptController_Space_Soderlind(arg1,arg2,arg3); + fresult = (int)(result); + return fresult; +} + + + diff --git a/src/sunadaptcontroller/soderlind/fmod/fsunadaptcontroller_soderlind_mod.f90 b/src/sunadaptcontroller/soderlind/fmod/fsunadaptcontroller_soderlind_mod.f90 new file mode 100644 index 0000000000..d9a56332cd --- /dev/null +++ b/src/sunadaptcontroller/soderlind/fmod/fsunadaptcontroller_soderlind_mod.f90 @@ -0,0 +1,319 @@ +! This file was automatically generated by SWIG (http://www.swig.org). +! Version 4.0.0 +! +! Do not make changes to this file unless you know what you are doing--modify +! the SWIG interface file instead. + +! --------------------------------------------------------------- +! Programmer(s): Auto-generated by swig. +! --------------------------------------------------------------- +! SUNDIALS Copyright Start +! Copyright (c) 2002-2023, 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 +! --------------------------------------------------------------- + +module fsunadaptcontroller_soderlind_mod + use, intrinsic :: ISO_C_BINDING + use fsundials_adaptcontroller_mod + use fsundials_types_mod + use fsundials_context_mod + implicit none + private + + ! DECLARATION CONSTRUCTS + public :: FSUNAdaptController_Soderlind + public :: FSUNAdaptController_SetParams_Soderlind + public :: FSUNAdaptController_GetType_Soderlind + public :: FSUNAdaptController_EstimateStep_Soderlind + public :: FSUNAdaptController_Reset_Soderlind + public :: FSUNAdaptController_SetDefaults_Soderlind + public :: FSUNAdaptController_Write_Soderlind + public :: FSUNAdaptController_SetErrorBias_Soderlind + public :: FSUNAdaptController_Update_Soderlind + public :: FSUNAdaptController_Space_Soderlind + +! WRAPPER DECLARATIONS +interface +function swigc_FSUNAdaptController_Soderlind(farg1) & +bind(C, name="_wrap_FSUNAdaptController_Soderlind") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +type(C_PTR), value :: farg1 +type(C_PTR) :: fresult +end function + +function swigc_FSUNAdaptController_SetParams_Soderlind(farg1, farg2, farg3, farg4, farg5, farg6) & +bind(C, name="_wrap_FSUNAdaptController_SetParams_Soderlind") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +type(C_PTR), value :: farg1 +real(C_DOUBLE), intent(in) :: farg2 +real(C_DOUBLE), intent(in) :: farg3 +real(C_DOUBLE), intent(in) :: farg4 +real(C_DOUBLE), intent(in) :: farg5 +real(C_DOUBLE), intent(in) :: farg6 +integer(C_INT) :: fresult +end function + +function swigc_FSUNAdaptController_GetType_Soderlind(farg1) & +bind(C, name="_wrap_FSUNAdaptController_GetType_Soderlind") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +type(C_PTR), value :: farg1 +integer(C_INT) :: fresult +end function + +function swigc_FSUNAdaptController_EstimateStep_Soderlind(farg1, farg2, farg3, farg4, farg5) & +bind(C, name="_wrap_FSUNAdaptController_EstimateStep_Soderlind") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +type(C_PTR), value :: farg1 +real(C_DOUBLE), intent(in) :: farg2 +integer(C_INT), intent(in) :: farg3 +real(C_DOUBLE), intent(in) :: farg4 +type(C_PTR), value :: farg5 +integer(C_INT) :: fresult +end function + +function swigc_FSUNAdaptController_Reset_Soderlind(farg1) & +bind(C, name="_wrap_FSUNAdaptController_Reset_Soderlind") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +type(C_PTR), value :: farg1 +integer(C_INT) :: fresult +end function + +function swigc_FSUNAdaptController_SetDefaults_Soderlind(farg1) & +bind(C, name="_wrap_FSUNAdaptController_SetDefaults_Soderlind") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +type(C_PTR), value :: farg1 +integer(C_INT) :: fresult +end function + +function swigc_FSUNAdaptController_Write_Soderlind(farg1, farg2) & +bind(C, name="_wrap_FSUNAdaptController_Write_Soderlind") & +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_FSUNAdaptController_SetErrorBias_Soderlind(farg1, farg2) & +bind(C, name="_wrap_FSUNAdaptController_SetErrorBias_Soderlind") & +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_FSUNAdaptController_Update_Soderlind(farg1, farg2, farg3) & +bind(C, name="_wrap_FSUNAdaptController_Update_Soderlind") & +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_FSUNAdaptController_Space_Soderlind(farg1, farg2, farg3) & +bind(C, name="_wrap_FSUNAdaptController_Space_Soderlind") & +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 + +end interface + + +contains + ! MODULE SUBPROGRAMS +function FSUNAdaptController_Soderlind(sunctx) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +type(SUNAdaptController), pointer :: swig_result +type(C_PTR) :: sunctx +type(C_PTR) :: fresult +type(C_PTR) :: farg1 + +farg1 = sunctx +fresult = swigc_FSUNAdaptController_Soderlind(farg1) +call c_f_pointer(fresult, swig_result) +end function + +function FSUNAdaptController_SetParams_Soderlind(c, k1, k2, k3, k4, k5) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(SUNAdaptController), target, intent(inout) :: c +real(C_DOUBLE), intent(in) :: k1 +real(C_DOUBLE), intent(in) :: k2 +real(C_DOUBLE), intent(in) :: k3 +real(C_DOUBLE), intent(in) :: k4 +real(C_DOUBLE), intent(in) :: k5 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +real(C_DOUBLE) :: farg2 +real(C_DOUBLE) :: farg3 +real(C_DOUBLE) :: farg4 +real(C_DOUBLE) :: farg5 +real(C_DOUBLE) :: farg6 + +farg1 = c_loc(c) +farg2 = k1 +farg3 = k2 +farg4 = k3 +farg5 = k4 +farg6 = k5 +fresult = swigc_FSUNAdaptController_SetParams_Soderlind(farg1, farg2, farg3, farg4, farg5, farg6) +swig_result = fresult +end function + +function FSUNAdaptController_GetType_Soderlind(c) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(SUNAdaptController_Type) :: swig_result +type(SUNAdaptController), target, intent(inout) :: c +integer(C_INT) :: fresult +type(C_PTR) :: farg1 + +farg1 = c_loc(c) +fresult = swigc_FSUNAdaptController_GetType_Soderlind(farg1) +swig_result = fresult +end function + +function FSUNAdaptController_EstimateStep_Soderlind(c, h, p, dsm, hnew) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(SUNAdaptController), target, intent(inout) :: c +real(C_DOUBLE), intent(in) :: h +integer(C_INT), intent(in) :: p +real(C_DOUBLE), intent(in) :: dsm +real(C_DOUBLE), target, intent(inout) :: hnew +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +real(C_DOUBLE) :: farg2 +integer(C_INT) :: farg3 +real(C_DOUBLE) :: farg4 +type(C_PTR) :: farg5 + +farg1 = c_loc(c) +farg2 = h +farg3 = p +farg4 = dsm +farg5 = c_loc(hnew) +fresult = swigc_FSUNAdaptController_EstimateStep_Soderlind(farg1, farg2, farg3, farg4, farg5) +swig_result = fresult +end function + +function FSUNAdaptController_Reset_Soderlind(c) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(SUNAdaptController), target, intent(inout) :: c +integer(C_INT) :: fresult +type(C_PTR) :: farg1 + +farg1 = c_loc(c) +fresult = swigc_FSUNAdaptController_Reset_Soderlind(farg1) +swig_result = fresult +end function + +function FSUNAdaptController_SetDefaults_Soderlind(c) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(SUNAdaptController), target, intent(inout) :: c +integer(C_INT) :: fresult +type(C_PTR) :: farg1 + +farg1 = c_loc(c) +fresult = swigc_FSUNAdaptController_SetDefaults_Soderlind(farg1) +swig_result = fresult +end function + +function FSUNAdaptController_Write_Soderlind(c, fptr) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(SUNAdaptController), target, intent(inout) :: c +type(C_PTR) :: fptr +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 + +farg1 = c_loc(c) +farg2 = fptr +fresult = swigc_FSUNAdaptController_Write_Soderlind(farg1, farg2) +swig_result = fresult +end function + +function FSUNAdaptController_SetErrorBias_Soderlind(c, bias) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(SUNAdaptController), target, intent(inout) :: c +real(C_DOUBLE), intent(in) :: bias +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +real(C_DOUBLE) :: farg2 + +farg1 = c_loc(c) +farg2 = bias +fresult = swigc_FSUNAdaptController_SetErrorBias_Soderlind(farg1, farg2) +swig_result = fresult +end function + +function FSUNAdaptController_Update_Soderlind(c, h, dsm) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(SUNAdaptController), target, intent(inout) :: c +real(C_DOUBLE), intent(in) :: h +real(C_DOUBLE), intent(in) :: dsm +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +real(C_DOUBLE) :: farg2 +real(C_DOUBLE) :: farg3 + +farg1 = c_loc(c) +farg2 = h +farg3 = dsm +fresult = swigc_FSUNAdaptController_Update_Soderlind(farg1, farg2, farg3) +swig_result = fresult +end function + +function FSUNAdaptController_Space_Soderlind(c, lenrw, leniw) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(SUNAdaptController), target, intent(inout) :: c +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 = c_loc(c) +farg2 = c_loc(lenrw(1)) +farg3 = c_loc(leniw(1)) +fresult = swigc_FSUNAdaptController_Space_Soderlind(farg1, farg2, farg3) +swig_result = fresult +end function + + +end module diff --git a/src/sunadaptcontroller/soderlind/sunadaptcontroller_soderlind.c b/src/sunadaptcontroller/soderlind/sunadaptcontroller_soderlind.c new file mode 100644 index 0000000000..d2cecf2fd6 --- /dev/null +++ b/src/sunadaptcontroller/soderlind/sunadaptcontroller_soderlind.c @@ -0,0 +1,239 @@ +/* ----------------------------------------------------------------- + * Programmer(s): Daniel R. Reynolds @ SMU + * ----------------------------------------------------------------- + * SUNDIALS Copyright Start + * Copyright (c) 2002-2023, Lawrence Livermore National Security + * and Southern Methodist University. + * All rights reserved. + * + * See the top-level LICENSE and NOTICE files for details. + * + * SPDX-License-Identifier: BSD-3-Clause + * SUNDIALS Copyright End + * ----------------------------------------------------------------- + * This is the implementation file for the + * SUNAdaptController_Soderlind module. + * -----------------------------------------------------------------*/ + +#include +#include +#include +#include + + +/* --------------- + * Macro accessors + * --------------- */ + +#define SODERLIND_CONTENT(C) ( (SUNAdaptControllerContent_Soderlind)(C->content) ) +#define SODERLIND_K1(C) ( SODERLIND_CONTENT(C)->k1 ) +#define SODERLIND_K2(C) ( SODERLIND_CONTENT(C)->k2 ) +#define SODERLIND_K3(C) ( SODERLIND_CONTENT(C)->k3 ) +#define SODERLIND_K4(C) ( SODERLIND_CONTENT(C)->k4 ) +#define SODERLIND_K5(C) ( SODERLIND_CONTENT(C)->k5 ) +#define SODERLIND_BIAS(C) ( SODERLIND_CONTENT(C)->bias ) +#define SODERLIND_EP(C) ( SODERLIND_CONTENT(C)->ep ) +#define SODERLIND_EPP(C) ( SODERLIND_CONTENT(C)->epp ) +#define SODERLIND_HP(C) ( SODERLIND_CONTENT(C)->hp ) +#define SODERLIND_HPP(C) ( SODERLIND_CONTENT(C)->hpp ) +#define SODERLIND_FIRSTSTEPS(C) ( SODERLIND_CONTENT(C)->firststeps ) + +/* ------------------ + * Default parameters + * ------------------ */ + +#define DEFAULT_K1 RCONST(1.25) /* H_{0}321 parameters */ +#define DEFAULT_K2 RCONST(0.5) +#define DEFAULT_K3 RCONST(-0.75) +#define DEFAULT_K4 RCONST(0.25) +#define DEFAULT_K5 RCONST(0.75) +#define DEFAULT_BIAS RCONST(1.5) +#define TINY RCONST(1.0e-10) + + +/* ----------------------------------------------------------------- + * exported functions + * ----------------------------------------------------------------- */ + +/* ----------------------------------------------------------------- + * Function to create a new Soderlind controller + */ + +SUNAdaptController SUNAdaptController_Soderlind(SUNContext sunctx) +{ + SUNAdaptController C; + SUNAdaptControllerContent_Soderlind content; + + /* Create an empty controller object */ + C = NULL; + C = SUNAdaptController_NewEmpty(sunctx); + if (C == NULL) { return (NULL); } + + /* Attach operations */ + C->ops->gettype = SUNAdaptController_GetType_Soderlind; + C->ops->estimatestep = SUNAdaptController_EstimateStep_Soderlind; + C->ops->reset = SUNAdaptController_Reset_Soderlind; + C->ops->setdefaults = SUNAdaptController_SetDefaults_Soderlind; + C->ops->write = SUNAdaptController_Write_Soderlind; + C->ops->seterrorbias = SUNAdaptController_SetErrorBias_Soderlind; + C->ops->update = SUNAdaptController_Update_Soderlind; + C->ops->space = SUNAdaptController_Space_Soderlind; + + /* Create content */ + content = NULL; + content = (SUNAdaptControllerContent_Soderlind)malloc(sizeof *content); + if (content == NULL) + { + (void) SUNAdaptController_Destroy(C); + return (NULL); + } + + /* Attach content */ + C->content = content; + + /* Fill content with default/reset values */ + SUNAdaptController_SetDefaults_Soderlind(C); + SUNAdaptController_Reset_Soderlind(C); + + return (C); +} + +/* ----------------------------------------------------------------- + * Function to set Soderlind parameters + */ + +int SUNAdaptController_SetParams_Soderlind(SUNAdaptController C, + sunrealtype k1, sunrealtype k2, + sunrealtype k3, sunrealtype k4, + sunrealtype k5) +{ + SODERLIND_K1(C) = k1; + SODERLIND_K2(C) = k2; + SODERLIND_K3(C) = k3; + SODERLIND_K4(C) = k4; + SODERLIND_K5(C) = k5; + return SUNADAPTCONTROLLER_SUCCESS; +} + + + +/* ----------------------------------------------------------------- + * implementation of controller operations + * ----------------------------------------------------------------- */ + +SUNAdaptController_Type SUNAdaptController_GetType_Soderlind(SUNAdaptController C) +{ return SUN_ADAPTCONTROLLER_H; } + +int SUNAdaptController_EstimateStep_Soderlind(SUNAdaptController C, sunrealtype h, + int p, sunrealtype dsm, sunrealtype* hnew) +{ + /* order parameter to use */ + const int ord = p + 1; + + /* set usable time-step adaptivity parameters */ + const sunrealtype k1 = -SODERLIND_K1(C) / ord; + const sunrealtype k2 = -SODERLIND_K2(C) / ord; + const sunrealtype k3 = -SODERLIND_K3(C) / ord; + const sunrealtype k4 = SODERLIND_K4(C); + const sunrealtype k5 = SODERLIND_K5(C); + const sunrealtype e1 = SUNMAX(SODERLIND_BIAS(C) * dsm, TINY); + const sunrealtype e2 = SUNMAX(SODERLIND_EP(C), TINY); + const sunrealtype e3 = SUNMAX(SODERLIND_EPP(C), TINY); + const sunrealtype hrat = h / SODERLIND_HP(C); + const sunrealtype hrat2 = SODERLIND_HP(C) / SODERLIND_HPP(C); + + /* compute estimated optimal time step size */ + if (SODERLIND_FIRSTSTEPS(C) < 1) { + *hnew = h * SUNRpowerR(e1,k1); + } else if (SODERLIND_FIRSTSTEPS(C) < 2) { + *hnew = h * SUNRpowerR(e1,k1) * SUNRpowerR(e2,k2) * SUNRpowerR(hrat,k4); + } else { + *hnew = h * SUNRpowerR(e1,k1) * SUNRpowerR(e2,k2) * SUNRpowerR(e3,k3) + * SUNRpowerR(hrat,k4) * SUNRpowerR(hrat2,k5); + } + + /* return with success */ + return SUNADAPTCONTROLLER_SUCCESS; +} + +int SUNAdaptController_Reset_Soderlind(SUNAdaptController C) +{ + SODERLIND_EP(C) = RCONST(1.0); + SODERLIND_EPP(C) = RCONST(1.0); + SODERLIND_HP(C) = RCONST(1.0); + SODERLIND_HPP(C) = RCONST(1.0); + SODERLIND_FIRSTSTEPS(C) = 0; + return SUNADAPTCONTROLLER_SUCCESS; +} + +int SUNAdaptController_SetDefaults_Soderlind(SUNAdaptController C) +{ + SODERLIND_K1(C) = DEFAULT_K1; + SODERLIND_K2(C) = DEFAULT_K2; + SODERLIND_K3(C) = DEFAULT_K3; + SODERLIND_K4(C) = DEFAULT_K4; + SODERLIND_K5(C) = DEFAULT_K5; + SODERLIND_BIAS(C) = DEFAULT_BIAS; + return SUNADAPTCONTROLLER_SUCCESS; +} + +int SUNAdaptController_Write_Soderlind(SUNAdaptController C, FILE *fptr) +{ + fprintf(fptr, "Soderlind SUNAdaptController module:\n"); +#if defined(SUNDIALS_EXTENDED_PRECISION) + fprintf(fptr, " k1 = %32Lg\n", SODERLIND_K1(C)); + fprintf(fptr, " k2 = %32Lg\n", SODERLIND_K2(C)); + fprintf(fptr, " k3 = %32Lg\n", SODERLIND_K3(C)); + fprintf(fptr, " k4 = %32Lg\n", SODERLIND_K4(C)); + fprintf(fptr, " k5 = %32Lg\n", SODERLIND_K5(C)); + fprintf(fptr, " bias factor = %22Lg\n", SODERLIND_BIAS(C)); + fprintf(fptr, " previous error = %22Lg\n", SODERLIND_EP(C)); + fprintf(fptr, " previous-previous error = %22Lg\n", SODERLIND_EPP(C)); + fprintf(fptr, " previous step = %22Lg\n", SODERLIND_HP(C)); + fprintf(fptr, " previous-previous step = %22Lg\n", SODERLIND_HPP(C)); +#else + fprintf(fptr, " k1 = %16g\n", SODERLIND_K1(C)); + fprintf(fptr, " k2 = %16g\n", SODERLIND_K2(C)); + fprintf(fptr, " k3 = %16g\n", SODERLIND_K3(C)); + fprintf(fptr, " k4 = %16g\n", SODERLIND_K4(C)); + fprintf(fptr, " k5 = %16g\n", SODERLIND_K5(C)); + fprintf(fptr, " bias factor = %16g\n", SODERLIND_BIAS(C)); + fprintf(fptr, " previous error = %16g\n", SODERLIND_EP(C)); + fprintf(fptr, " previous-previous error = %16g\n", SODERLIND_EPP(C)); + fprintf(fptr, " previous step = %16g\n", SODERLIND_HP(C)); + fprintf(fptr, " previous-previous step = %16g\n", SODERLIND_HPP(C)); +#endif + fprintf(fptr, " firststeps = %i\n", SODERLIND_FIRSTSTEPS(C)); + return SUNADAPTCONTROLLER_SUCCESS; +} + +int SUNAdaptController_SetErrorBias_Soderlind(SUNAdaptController C, sunrealtype bias) +{ + /* set allowed value, otherwise set default */ + if (bias <= RCONST(0.0)) { + SODERLIND_BIAS(C) = DEFAULT_BIAS; + } else { + SODERLIND_BIAS(C) = bias; + } + + return SUNADAPTCONTROLLER_SUCCESS; +} + +int SUNAdaptController_Update_Soderlind(SUNAdaptController C, sunrealtype h, sunrealtype dsm) +{ + SODERLIND_EPP(C) = SODERLIND_EP(C); + SODERLIND_EP(C) = SODERLIND_BIAS(C) * dsm; + SODERLIND_HPP(C) = SODERLIND_HP(C); + SODERLIND_HP(C) = h; + if (SODERLIND_FIRSTSTEPS(C) < 2) { + SODERLIND_FIRSTSTEPS(C) += 1; + } + return SUNADAPTCONTROLLER_SUCCESS; +} + +int SUNAdaptController_Space_Soderlind(SUNAdaptController C, long int* lenrw, long int* leniw) +{ + *lenrw = 10; + *leniw = 1; + return SUNADAPTCONTROLLER_SUCCESS; +} diff --git a/swig/Makefile b/swig/Makefile index 7811ad296a..ebf7e30189 100644 --- a/swig/Makefile +++ b/swig/Makefile @@ -25,7 +25,7 @@ NVECTOR=openmp pthreads serial parallel manyvector mpiplusx SUNMATRIX=band dense sparse SUNLINSOL=band dense klu spbcgs spfgmr spgmr sptfqmr pcg SUNNONLINSOL=newton fixedpoint -SUNADAPTCONTROLLER=expgus imexgus i impgus pid pi noop +SUNADAPTCONTROLLER=expgus imexgus i impgus noop pid pi soderlind INCLUDES=-I../include diff --git a/swig/sunadaptcontroller/fsunadaptcontroller_soderlind_mod.i b/swig/sunadaptcontroller/fsunadaptcontroller_soderlind_mod.i new file mode 100644 index 0000000000..cb9ab8ccbf --- /dev/null +++ b/swig/sunadaptcontroller/fsunadaptcontroller_soderlind_mod.i @@ -0,0 +1,29 @@ +// --------------------------------------------------------------- +// Programmer: Daniel R. Reynolds @ SMU +// --------------------------------------------------------------- +// SUNDIALS Copyright Start +// Copyright (c) 2002-2023, 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 +// --------------------------------------------------------------- +// Swig interface file +// --------------------------------------------------------------- + +%module fsunadaptcontroller_soderlind_mod + +// include code common to all implementations +%include "fsunadaptcontroller.i" + +%{ +#include "sunadaptcontroller/sunadaptcontroller_soderlind.h" +%} + +%sunadaptcontroller_impl(Soderlind) + +// Process and wrap functions in the following files +%include "sunadaptcontroller/sunadaptcontroller_soderlind.h" From e78c7ee99fbe1847d7dafdd1c684290495185d78 Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Mon, 23 Oct 2023 14:47:13 -0500 Subject: [PATCH 14/58] Removed PID, PI and I SUNAdaptController implementations, and instead created SUNAdaptController_Soderlind utility routines for these modules --- .../SUNAdaptController_links.rst | 5 +- .../SUNAdaptController_I.rst | 88 ----- .../SUNAdaptController_PI.rst | 94 ----- .../SUNAdaptController_PID.rst | 101 ----- .../SUNAdaptController_Soderlind.rst | 108 +++++- .../SUNAdaptController_links.rst | 5 +- include/arkode/arkode_arkstep.h | 4 +- include/arkode/arkode_erkstep.h | 4 +- .../sunadaptcontroller/sunadaptcontroller_i.h | 65 ---- .../sunadaptcontroller_pi.h | 72 ---- .../sunadaptcontroller_pid.h | 74 ---- .../sunadaptcontroller_soderlind.h | 17 + src/arkode/CMakeLists.txt | 3 - src/arkode/arkode.c | 2 +- src/arkode/arkode_arkstep_io.c | 12 +- src/arkode/arkode_erkstep_io.c | 2 +- src/arkode/arkode_io.c | 90 ++--- src/sunadaptcontroller/CMakeLists.txt | 3 - src/sunadaptcontroller/i/CMakeLists.txt | 29 -- src/sunadaptcontroller/i/fmod/CMakeLists.txt | 25 -- .../i/fmod/fsunadaptcontroller_i_mod.c | 325 ---------------- .../i/fmod/fsunadaptcontroller_i_mod.f90 | 251 ------------ .../i/sunadaptcontroller_i.c | 155 -------- src/sunadaptcontroller/pi/CMakeLists.txt | 29 -- src/sunadaptcontroller/pi/fmod/CMakeLists.txt | 25 -- .../pi/fmod/fsunadaptcontroller_pi_mod.c | 355 ----------------- .../pi/fmod/fsunadaptcontroller_pi_mod.f90 | 307 --------------- .../pi/sunadaptcontroller_pi.c | 181 --------- src/sunadaptcontroller/pid/CMakeLists.txt | 29 -- .../pid/fmod/CMakeLists.txt | 25 -- .../pid/fmod/fsunadaptcontroller_pid_mod.c | 357 ------------------ .../pid/fmod/fsunadaptcontroller_pid_mod.f90 | 311 --------------- .../pid/sunadaptcontroller_pid.c | 192 ---------- .../fmod/fsunadaptcontroller_soderlind_mod.c | 84 +++++ .../fsunadaptcontroller_soderlind_mod.f90 | 156 ++++++++ .../soderlind/sunadaptcontroller_soderlind.c | 122 +++++- swig/Makefile | 2 +- .../fsunadaptcontroller_i_mod.i | 29 -- .../fsunadaptcontroller_pi_mod.i | 29 -- .../fsunadaptcontroller_pid_mod.i | 29 -- 40 files changed, 529 insertions(+), 3267 deletions(-) delete mode 100644 doc/shared/sunadaptcontroller/SUNAdaptController_I.rst delete mode 100644 doc/shared/sunadaptcontroller/SUNAdaptController_PI.rst delete mode 100644 doc/shared/sunadaptcontroller/SUNAdaptController_PID.rst delete mode 100644 include/sunadaptcontroller/sunadaptcontroller_i.h delete mode 100644 include/sunadaptcontroller/sunadaptcontroller_pi.h delete mode 100644 include/sunadaptcontroller/sunadaptcontroller_pid.h delete mode 100644 src/sunadaptcontroller/i/CMakeLists.txt delete mode 100644 src/sunadaptcontroller/i/fmod/CMakeLists.txt delete mode 100644 src/sunadaptcontroller/i/fmod/fsunadaptcontroller_i_mod.c delete mode 100644 src/sunadaptcontroller/i/fmod/fsunadaptcontroller_i_mod.f90 delete mode 100644 src/sunadaptcontroller/i/sunadaptcontroller_i.c delete mode 100644 src/sunadaptcontroller/pi/CMakeLists.txt delete mode 100644 src/sunadaptcontroller/pi/fmod/CMakeLists.txt delete mode 100644 src/sunadaptcontroller/pi/fmod/fsunadaptcontroller_pi_mod.c delete mode 100644 src/sunadaptcontroller/pi/fmod/fsunadaptcontroller_pi_mod.f90 delete mode 100644 src/sunadaptcontroller/pi/sunadaptcontroller_pi.c delete mode 100644 src/sunadaptcontroller/pid/CMakeLists.txt delete mode 100644 src/sunadaptcontroller/pid/fmod/CMakeLists.txt delete mode 100644 src/sunadaptcontroller/pid/fmod/fsunadaptcontroller_pid_mod.c delete mode 100644 src/sunadaptcontroller/pid/fmod/fsunadaptcontroller_pid_mod.f90 delete mode 100644 src/sunadaptcontroller/pid/sunadaptcontroller_pid.c delete mode 100644 swig/sunadaptcontroller/fsunadaptcontroller_i_mod.i delete mode 100644 swig/sunadaptcontroller/fsunadaptcontroller_pi_mod.i delete mode 100644 swig/sunadaptcontroller/fsunadaptcontroller_pid_mod.i diff --git a/doc/arkode/guide/source/sunadaptcontroller/SUNAdaptController_links.rst b/doc/arkode/guide/source/sunadaptcontroller/SUNAdaptController_links.rst index 4439c63a92..abc5a6f308 100644 --- a/doc/arkode/guide/source/sunadaptcontroller/SUNAdaptController_links.rst +++ b/doc/arkode/guide/source/sunadaptcontroller/SUNAdaptController_links.rst @@ -11,10 +11,7 @@ ---------------------------------------------------------------- .. include:: ../../../../shared/sunadaptcontroller/SUNAdaptController_Description.rst -.. include:: ../../../../shared/sunadaptcontroller/SUNAdaptController_PID.rst -.. include:: ../../../../shared/sunadaptcontroller/SUNAdaptController_PI.rst -.. include:: ../../../../shared/sunadaptcontroller/SUNAdaptController_I.rst +.. include:: ../../../../shared/sunadaptcontroller/SUNAdaptController_Soderlind.rst .. include:: ../../../../shared/sunadaptcontroller/SUNAdaptController_ExpGus.rst .. include:: ../../../../shared/sunadaptcontroller/SUNAdaptController_ImpGus.rst .. include:: ../../../../shared/sunadaptcontroller/SUNAdaptController_ImExGus.rst -.. include:: ../../../../shared/sunadaptcontroller/SUNAdaptController_Soderlind.rst diff --git a/doc/shared/sunadaptcontroller/SUNAdaptController_I.rst b/doc/shared/sunadaptcontroller/SUNAdaptController_I.rst deleted file mode 100644 index 16d15cb233..0000000000 --- a/doc/shared/sunadaptcontroller/SUNAdaptController_I.rst +++ /dev/null @@ -1,88 +0,0 @@ -.. - Programmer(s): Daniel R. Reynolds @ SMU - ---------------------------------------------------------------- - SUNDIALS Copyright Start - Copyright (c) 2002-2023, 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 - ---------------------------------------------------------------- - -.. _SUNAdaptController.I: - -The SUNAdaptController_I Module -====================================== - -The I implementation of the SUNAdaptController class, SUNAdaptController_I, implements a -standard I temporal adaptivity controller. This is the standard time adaptivity -control algorithm in use by most publicly-available ODE solver codes. It bases -the prospective time step estimate entirely off of the current local error -estimate, - -.. math:: - h' \;=\; h_n\; \varepsilon_n^{-k_1/(p+1)}, - -where :math:`p` is the global order of the time integration method. In this estimate, -a floor of :math:`\varepsilon > 10^{-10}` is enforced to avoid division-by-zero errors. -By default the constant :math:`k_1=1`. - -This is implemented as a derived SUNAdaptController class, and defines its *content* -field as: - -.. code-block:: c - - struct _SUNAdaptControllerContent_I { - sunrealtype k1; - sunrealtype bias; - }; - -These entries of the *content* field contain the following information: - -* ``k1`` - controller parameter above. - -* ``bias`` - error bias factor, that converts from an input temporal error - estimate via :math:`\varepsilon = \text{bias}*\text{dsm}`. - - -The header file to be included when using this module is -``sunadaptcontroller/sunadaptcontroller_i.h``. - -The SUNAdaptController_I class provides implementations of all operations -relevant to a `SUN_ADAPTCONTROLLER_H` controller listed in -:numref:`SUNAdaptController.Description.operations`. The SUNAdaptController_I class -also provides the following additional user-callable routines: - - -.. c:function:: SUNAdaptController SUNAdaptController_I(SUNContext sunctx) - - This constructor function creates and allocates memory for a SUNAdaptController_I - object, and inserts its default parameters. - - :param sunctx: the current :c:type:`SUNContext` object. - :return: if successful, a usable :c:type:`SUNAdaptController` object; otherwise it will return ``NULL``. - - Usage: - - .. code-block:: c - - SUNAdaptController C = SUNAdaptController_I(sunctx); - -.. c:function:: int SUNAdaptController_SetParams_I(SUNAdaptController C, sunrealtype k1) - - This user-callable function provides control over the relevant parameters - above. This should be called *before* the time integrator is called to evolve - the problem. - - :param C: the SUNAdaptController_I object. - :param k1: parameter used within the controller time step estimate. - :return: error code indication success or failure (see :numref:`SUNAdaptController.Description.errorCodes`). - - Usage: - - .. code-block:: c - - retval = SUNAdaptController_SetParams_I(C, 0.95); diff --git a/doc/shared/sunadaptcontroller/SUNAdaptController_PI.rst b/doc/shared/sunadaptcontroller/SUNAdaptController_PI.rst deleted file mode 100644 index bfb9c1e881..0000000000 --- a/doc/shared/sunadaptcontroller/SUNAdaptController_PI.rst +++ /dev/null @@ -1,94 +0,0 @@ -.. - Programmer(s): Daniel R. Reynolds @ SMU - ---------------------------------------------------------------- - SUNDIALS Copyright Start - Copyright (c) 2002-2023, 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 - ---------------------------------------------------------------- - -.. _SUNAdaptController.PI: - -The SUNAdaptController_PI Module -====================================== - -The PI implementation of the SUNAdaptController class, SUNAdaptController_PI, implements a -standard PI temporal adaptivity controller. Like with SUNAdaptController_PID, the PI -controller derives from those found in :cite:p:`KenCarp:03`, :cite:p:`Sod:98`, -:cite:p:`Sod:03` and :cite:p:`Sod:06`, but it differs in that it only uses the -two most recent step sizes in its adaptivity algorithm, - -.. math:: - h' \;=\; h_n\; \varepsilon_n^{-k_1/(p+1)}\; \varepsilon_{n-1}^{k_2/(p+1)}. - -where the constants :math:`k_1` and :math:`k_2` default to 0.8 and 0.31, -respectively, and :math:`p` is the global order of the time -integration method. In this estimate, a floor of :math:`\varepsilon > 10^{-10}` -is enforced to avoid division-by-zero errors. - -This is implemented as a derived SUNAdaptController class, and defines its *content* -field as: - -.. code-block:: c - - struct _SUNAdaptControllerContent_PI { - sunrealtype k1; - sunrealtype k2; - sunrealtype bias; - sunrealtype ep; - }; - -These entries of the *content* field contain the following information: - -* ``k1, k2`` - controller parameters above. - -* ``bias`` - error bias factor, that converts from an input temporal error - estimate via :math:`\varepsilon = \text{bias}*\text{dsm}`. - -* ``ep`` - storage for the previous error estimate, :math:`\varepsilon_{n-1}`. - - -The header file to be included when using this module is -``sunadaptcontroller/sunadaptcontroller_pi.h``. - -The SUNAdaptController_PI class provides implementations of all operations -relevant to a `SUN_ADAPTCONTROLLER_H` controller listed in -:numref:`SUNAdaptController.Description.operations`. The SUNAdaptController_PI class -also provides the following additional user-callable routines: - - -.. c:function:: SUNAdaptController SUNAdaptController_PI(SUNContext sunctx) - - This constructor function creates and allocates memory for a SUNAdaptController_PI - object, and inserts its default parameters. - - :param sunctx: the current :c:type:`SUNContext` object. - :return: if successful, a usable :c:type:`SUNAdaptController` object; otherwise it will return ``NULL``. - - Usage: - - .. code-block:: c - - SUNAdaptController C = SUNAdaptController_PI(sunctx); - -.. c:function:: int SUNAdaptController_SetParams_PI(SUNAdaptController C, sunrealtype k1, sunrealtype k2) - - This user-callable function provides control over the relevant parameters - above. This should be called *before* the time integrator is called to evolve - the problem. - - :param C: the SUNAdaptController_PI object. - :param k1: parameter used within the controller time step estimate. - :param k2: parameter used within the controller time step estimate. - :return: error code indication success or failure (see :numref:`SUNAdaptController.Description.errorCodes`). - - Usage: - - .. code-block:: c - - retval = SUNAdaptController_SetParams_PI(C, 0.9, 0.3); diff --git a/doc/shared/sunadaptcontroller/SUNAdaptController_PID.rst b/doc/shared/sunadaptcontroller/SUNAdaptController_PID.rst deleted file mode 100644 index bc410b554f..0000000000 --- a/doc/shared/sunadaptcontroller/SUNAdaptController_PID.rst +++ /dev/null @@ -1,101 +0,0 @@ -.. - Programmer(s): Daniel R. Reynolds @ SMU - ---------------------------------------------------------------- - SUNDIALS Copyright Start - Copyright (c) 2002-2023, 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 - ---------------------------------------------------------------- - -.. _SUNAdaptController.PID: - -The SUNAdaptController_PID Module -====================================== - -The PID implementation of the SUNAdaptController class, SUNAdaptController_PID, implements a -standard PID temporal adaptivity controller. It derives from those found in -:cite:p:`KenCarp:03`, :cite:p:`Sod:98`, :cite:p:`Sod:03` and :cite:p:`Sod:06`, -and uses three temporal error estimates, :math:`\varepsilon_n`, -:math:`\varepsilon_{n-1}` and :math:`\varepsilon_{n-2}` in determination of a -prospective step size, - -.. math:: - h' \;=\; h_n\; \varepsilon_n^{-k_1/(p+1)}\; \varepsilon_{n-1}^{k_2/(p+1)}\; - \varepsilon_{n-2}^{-k_3/(p+1)}, - -where the constants :math:`k_1`, :math:`k_2` and :math:`k_3` default to 0.58, -0.21 and 0.1, respectively, and :math:`p` is the global order of the time -integration method. In this estimate, a floor of :math:`\varepsilon > 10^{-10}` -is enforced to avoid division-by-zero errors. - -This is implemented as a derived SUNAdaptController class, and defines its *content* -field as: - -.. code-block:: c - - struct _SUNAdaptControllerContent_PID { - sunrealtype k1; - sunrealtype k2; - sunrealtype k3; - sunrealtype bias; - sunrealtype ep; - sunrealtype epp; - }; - -These entries of the *content* field contain the following information: - -* ``k1, k2, k3`` - controller parameters above. - -* ``bias`` - error bias factor, that converts from an input temporal error - estimate via :math:`\varepsilon = \text{bias}*\text{dsm}`. - -* ``ep, epp`` - storage for the two previous error estimates, - :math:`\varepsilon_{n-1}` and :math:`varepsilon_{n-2}`. - - -The header file to be included when using this module is -``sunadaptcontroller/sunadaptcontroller_pid.h``. - - -The SUNAdaptController_PID class provides implementations of all operations -relevant to a `SUN_ADAPTCONTROLLER_H` controller listed in -:numref:`SUNAdaptController.Description.operations`. The SUNAdaptController_PID class -also provides the following additional user-callable routines: - - -.. c:function:: SUNAdaptController SUNAdaptController_PID(SUNContext sunctx) - - This constructor function creates and allocates memory for a SUNAdaptController_PID - object, and inserts its default parameters. - - :param sunctx: the current :c:type:`SUNContext` object. - :return: if successful, a usable :c:type:`SUNAdaptController` object; otherwise it will return ``NULL``. - - Usage: - - .. code-block:: c - - SUNAdaptController C = SUNAdaptController_PID(sunctx); - -.. c:function:: int SUNAdaptController_SetParams_PID(SUNAdaptController C, sunrealtype k1, sunrealtype k2, sunrealtype k3) - - This user-callable function provides control over the relevant parameters - above. This should be called *before* the time integrator is called to evolve - the problem. - - :param C: the SUNAdaptController_PID object. - :param k1: parameter used within the controller time step estimate. - :param k2: parameter used within the controller time step estimate. - :param k3: parameter used within the controller time step estimate. - :return: error code indication success or failure (see :numref:`SUNAdaptController.Description.errorCodes`). - - Usage: - - .. code-block:: c - - retval = SUNAdaptController_SetParams_PID(C, 0.6, 0.2, -1.0); diff --git a/doc/shared/sunadaptcontroller/SUNAdaptController_Soderlind.rst b/doc/shared/sunadaptcontroller/SUNAdaptController_Soderlind.rst index c53e0102ae..31eca43b9a 100644 --- a/doc/shared/sunadaptcontroller/SUNAdaptController_Soderlind.rst +++ b/doc/shared/sunadaptcontroller/SUNAdaptController_Soderlind.rst @@ -72,8 +72,10 @@ The header file to be included when using this module is ``sunadaptcontroller/sunadaptcontroller_soderlind.h``. We note that through appropriate selection of the parameters :math:`k_1 - k_5`, -this controller may replicate the behavior of each of the PID, PI and I -SUNController implementations. +this controller may create a wide range of proposed temporal adaptivity controllers, +including the PID, PI and I controllers. As a convenience, utility routines to +create these controllers and set their parameters (as special cases of the +SUNAdaptController_Soderlind) are provided. The SUNAdaptController_Soderlind class provides implementations of all operations relevant to a `SUN_ADAPTCONTROLLER_H` controller listed in @@ -116,3 +118,105 @@ also provides the following additional user-callable routines: /* Specify parameters for Soderlind's H_{0}312 controller */ retval = SUNAdaptController_SetParams_Soderlind(C, 0.25, 0.5, 0.25, -0.75, -0.25); + + +.. c:function:: SUNAdaptController SUNAdaptController_PID(SUNContext sunctx) + + This constructor function creates and allocates memory for a SUNAdaptController_Soderlind + object, set up to replicate a PID controller, and inserts its default parameters + (:math:`k_1=0.58`, :math:`k_2=-0.21`, :math:`k_3=0.1`, and :math:`k_4=k_5=0`). + + :param sunctx: the current :c:type:`SUNContext` object. + :return: if successful, a usable :c:type:`SUNAdaptController` object; + otherwise it will return ``NULL``. + + Usage: + + .. code-block:: c + + SUNAdaptController C = SUNAdaptController_PID(sunctx); + +.. c:function:: int SUNAdaptController_SetParams_PID(SUNAdaptController C, sunrealtype k1, sunrealtype k2, sunrealtype k3) + + This user-callable function provides control over the relevant parameters + above, setting :math:`k_4 = k_5 = 0`. This should be called *before* the + time integrator is called to evolve the problem. + + :param C: the SUNAdaptController_Soderlind object. + :param k1: parameter used within the controller time step estimate. + :param k2: parameter used within the controller time step estimate. + :param k3: parameter used within the controller time step estimate. + :return: error code indication success or failure (see :numref:`SUNAdaptController.Description.errorCodes`). + + Usage: + + .. code-block:: c + + retval = SUNAdaptController_SetParams_PID(C, 0.58, -0.21, 0.1); + + +.. c:function:: SUNAdaptController SUNAdaptController_PI(SUNContext sunctx) + + This constructor function creates and allocates memory for a SUNAdaptController_Soderlind + object, set up to replicate a PI controller, and inserts its default parameters + (:math:`k_1=0.8`, :math:`k_2=-0.31`, and :math:`k_3=k_4=k_5=0`). + + :param sunctx: the current :c:type:`SUNContext` object. + :return: if successful, a usable :c:type:`SUNAdaptController` object; + otherwise it will return ``NULL``. + + Usage: + + .. code-block:: c + + SUNAdaptController C = SUNAdaptController_PI(sunctx); + +.. c:function:: int SUNAdaptController_SetParams_PI(SUNAdaptController C, sunrealtype k1, sunrealtype k2) + + This user-callable function provides control over the relevant parameters + above, setting :math:`k_3 = k_4 = k_5 = 0`. This should be called *before* the + time integrator is called to evolve the problem. + + :param C: the SUNAdaptController_Soderlind object. + :param k1: parameter used within the controller time step estimate. + :param k2: parameter used within the controller time step estimate. + :return: error code indication success or failure (see :numref:`SUNAdaptController.Description.errorCodes`). + + Usage: + + .. code-block:: c + + retval = SUNAdaptController_SetParams_PI(C, 0.8, -0.31); + + +.. c:function:: SUNAdaptController SUNAdaptController_I(SUNContext sunctx) + + This constructor function creates and allocates memory for a SUNAdaptController_Soderlind + object, set up to replicate an I controller, and inserts its default parameters + (:math:`k_1=1.0` and :math:`k_2=k_3=k_4=k_5=0`). + + :param sunctx: the current :c:type:`SUNContext` object. + :return: if successful, a usable :c:type:`SUNAdaptController` object; + otherwise it will return ``NULL``. + + Usage: + + .. code-block:: c + + SUNAdaptController C = SUNAdaptController_I(sunctx); + +.. c:function:: int SUNAdaptController_SetParams_I(SUNAdaptController C, sunrealtype k1) + + This user-callable function provides control over the relevant parameters + above, setting :math:`k_2 = k_3 = k_4 = k_5 = 0`. This should be called *before* the + time integrator is called to evolve the problem. + + :param C: the SUNAdaptController_Soderlind object. + :param k1: parameter used within the controller time step estimate. + :return: error code indication success or failure (see :numref:`SUNAdaptController.Description.errorCodes`). + + Usage: + + .. code-block:: c + + retval = SUNAdaptController_SetParams_I(C, 1.0); diff --git a/doc/superbuild/source/sunadaptcontroller/SUNAdaptController_links.rst b/doc/superbuild/source/sunadaptcontroller/SUNAdaptController_links.rst index 15172d99d3..df597f0861 100644 --- a/doc/superbuild/source/sunadaptcontroller/SUNAdaptController_links.rst +++ b/doc/superbuild/source/sunadaptcontroller/SUNAdaptController_links.rst @@ -10,10 +10,7 @@ SUNDIALS Copyright End ---------------------------------------------------------------- -.. include:: ../../../shared/sunadaptcontroller/SUNAdaptController_PID.rst -.. include:: ../../../shared/sunadaptcontroller/SUNAdaptController_PI.rst -.. include:: ../../../shared/sunadaptcontroller/SUNAdaptController_I.rst +.. include:: ../../../shared/sunadaptcontroller/SUNAdaptController_Soderlind.rst .. include:: ../../../shared/sunadaptcontroller/SUNAdaptController_ExpGus.rst .. include:: ../../../shared/sunadaptcontroller/SUNAdaptController_ImpGus.rst .. include:: ../../../shared/sunadaptcontroller/SUNAdaptController_ImExGus.rst -.. include:: ../../../shared/sunadaptcontroller/SUNAdaptController_Soderlind.rst diff --git a/include/arkode/arkode_arkstep.h b/include/arkode/arkode_arkstep.h index 7c92a88a73..08ee56b265 100644 --- a/include/arkode/arkode_arkstep.h +++ b/include/arkode/arkode_arkstep.h @@ -20,9 +20,7 @@ #include #include #include -#include -#include -#include +#include #include #include #include diff --git a/include/arkode/arkode_erkstep.h b/include/arkode/arkode_erkstep.h index 4bcc37678b..ac3b256852 100644 --- a/include/arkode/arkode_erkstep.h +++ b/include/arkode/arkode_erkstep.h @@ -18,9 +18,7 @@ #define _ERKSTEP_H #include -#include -#include -#include +#include #include #include #include diff --git a/include/sunadaptcontroller/sunadaptcontroller_i.h b/include/sunadaptcontroller/sunadaptcontroller_i.h deleted file mode 100644 index 1dda7b0a74..0000000000 --- a/include/sunadaptcontroller/sunadaptcontroller_i.h +++ /dev/null @@ -1,65 +0,0 @@ -/* ----------------------------------------------------------------- - * Programmer(s): Daniel R. Reynolds @ SMU - * ----------------------------------------------------------------- - * SUNDIALS Copyright Start - * Copyright (c) 2002-2023, Lawrence Livermore National Security - * and Southern Methodist University. - * All rights reserved. - * - * See the top-level LICENSE and NOTICE files for details. - * - * SPDX-License-Identifier: BSD-3-Clause - * SUNDIALS Copyright End - * ----------------------------------------------------------------- - * This is the header file for the SUNAdaptController_I module. - * -----------------------------------------------------------------*/ - -#ifndef _SUNADAPTCONTROLLER_I_H -#define _SUNADAPTCONTROLLER_I_H - -#include -#include - -#ifdef __cplusplus /* wrapper to enable C++ usage */ -extern "C" { -#endif - -/* -------------------------------------- - * I implementation of SUNAdaptController - * -------------------------------------- */ - -struct _SUNAdaptControllerContent_I { - sunrealtype k1; /* internal controller parameters */ - sunrealtype bias; /* error bias factor */ -}; - -typedef struct _SUNAdaptControllerContent_I *SUNAdaptControllerContent_I; - -/* ------------------ - * Exported Functions - * ------------------ */ - -SUNDIALS_EXPORT -SUNAdaptController SUNAdaptController_I(SUNContext sunctx); -SUNDIALS_EXPORT -int SUNAdaptController_SetParams_I(SUNAdaptController C, sunrealtype k1); -SUNDIALS_EXPORT -SUNAdaptController_Type SUNAdaptController_GetType_I(SUNAdaptController C); -SUNDIALS_EXPORT -int SUNAdaptController_EstimateStep_I(SUNAdaptController C, sunrealtype h, - int p, sunrealtype dsm, sunrealtype* hnew); -SUNDIALS_EXPORT -int SUNAdaptController_SetDefaults_I(SUNAdaptController C); -SUNDIALS_EXPORT -int SUNAdaptController_Write_I(SUNAdaptController C, FILE* fptr); -SUNDIALS_EXPORT -int SUNAdaptController_SetErrorBias_I(SUNAdaptController C, sunrealtype bias); -SUNDIALS_EXPORT -int SUNAdaptController_Space_I(SUNAdaptController C, long int *lenrw, - long int *leniw); - -#ifdef __cplusplus -} -#endif - -#endif /* _SUNADAPTCONTROLLER_I_H */ diff --git a/include/sunadaptcontroller/sunadaptcontroller_pi.h b/include/sunadaptcontroller/sunadaptcontroller_pi.h deleted file mode 100644 index 0e71ae6ab6..0000000000 --- a/include/sunadaptcontroller/sunadaptcontroller_pi.h +++ /dev/null @@ -1,72 +0,0 @@ -/* ----------------------------------------------------------------- - * Programmer(s): Daniel R. Reynolds @ SMU - * ----------------------------------------------------------------- - * SUNDIALS Copyright Start - * Copyright (c) 2002-2023, Lawrence Livermore National Security - * and Southern Methodist University. - * All rights reserved. - * - * See the top-level LICENSE and NOTICE files for details. - * - * SPDX-License-Identifier: BSD-3-Clause - * SUNDIALS Copyright End - * ----------------------------------------------------------------- - * This is the header file for the SUNAdaptController_PI module. - * -----------------------------------------------------------------*/ - -#ifndef _SUNADAPTCONTROLLER_PI_H -#define _SUNADAPTCONTROLLER_PI_H - -#include -#include - -#ifdef __cplusplus /* wrapper to enable C++ usage */ -extern "C" { -#endif - -/* --------------------------------------- - * PI implementation of SUNAdaptController - * --------------------------------------- */ - -struct _SUNAdaptControllerContent_PI { - sunrealtype k1; /* internal controller parameters */ - sunrealtype k2; - sunrealtype bias; /* error bias factor */ - sunrealtype ep; /* error from previous step */ -}; - -typedef struct _SUNAdaptControllerContent_PI *SUNAdaptControllerContent_PI; - -/* ------------------ - * Exported Functions - * ------------------ */ - -SUNDIALS_EXPORT -SUNAdaptController SUNAdaptController_PI(SUNContext sunctx); -SUNDIALS_EXPORT -int SUNAdaptController_SetParams_PI(SUNAdaptController C, - sunrealtype k1, sunrealtype k2); -SUNDIALS_EXPORT -SUNAdaptController_Type SUNAdaptController_GetType_PI(SUNAdaptController C); -SUNDIALS_EXPORT -int SUNAdaptController_EstimateStep_PI(SUNAdaptController C, sunrealtype h, - int p, sunrealtype dsm, sunrealtype* hnew); -SUNDIALS_EXPORT -int SUNAdaptController_Reset_PI(SUNAdaptController C); -SUNDIALS_EXPORT -int SUNAdaptController_SetDefaults_PI(SUNAdaptController C); -SUNDIALS_EXPORT -int SUNAdaptController_Write_PI(SUNAdaptController C, FILE* fptr); -SUNDIALS_EXPORT -int SUNAdaptController_SetErrorBias_PI(SUNAdaptController C, sunrealtype bias); -SUNDIALS_EXPORT -int SUNAdaptController_Update_PI(SUNAdaptController C, sunrealtype h, sunrealtype dsm); -SUNDIALS_EXPORT -int SUNAdaptController_Space_PI(SUNAdaptController C, long int *lenrw, - long int *leniw); - -#ifdef __cplusplus -} -#endif - -#endif /* _SUNADAPTCONTROLLER_PI_H */ diff --git a/include/sunadaptcontroller/sunadaptcontroller_pid.h b/include/sunadaptcontroller/sunadaptcontroller_pid.h deleted file mode 100644 index 674e81bc0e..0000000000 --- a/include/sunadaptcontroller/sunadaptcontroller_pid.h +++ /dev/null @@ -1,74 +0,0 @@ -/* ----------------------------------------------------------------- - * Programmer(s): Daniel R. Reynolds @ SMU - * ----------------------------------------------------------------- - * SUNDIALS Copyright Start - * Copyright (c) 2002-2023, Lawrence Livermore National Security - * and Southern Methodist University. - * All rights reserved. - * - * See the top-level LICENSE and NOTICE files for details. - * - * SPDX-License-Identifier: BSD-3-Clause - * SUNDIALS Copyright End - * ----------------------------------------------------------------- - * This is the header file for the SUNAdaptController_PID module. - * -----------------------------------------------------------------*/ - -#ifndef _SUNADAPTCONTROLLER_PID_H -#define _SUNADAPTCONTROLLER_PID_H - -#include -#include - -#ifdef __cplusplus /* wrapper to enable C++ usage */ -extern "C" { -#endif - -/* ---------------------------------------- - * PID implementation of SUNAdaptController - * ---------------------------------------- */ - -struct _SUNAdaptControllerContent_PID { - sunrealtype k1; /* internal controller parameters */ - sunrealtype k2; - sunrealtype k3; - sunrealtype bias; /* error bias factor */ - sunrealtype ep; /* error from previous step */ - sunrealtype epp; /* error from 2 steps ago */ -}; - -typedef struct _SUNAdaptControllerContent_PID *SUNAdaptControllerContent_PID; - -/* ------------------ - * Exported Functions - * ------------------ */ - -SUNDIALS_EXPORT -SUNAdaptController SUNAdaptController_PID(SUNContext sunctx); -SUNDIALS_EXPORT -int SUNAdaptController_SetParams_PID(SUNAdaptController C, sunrealtype k1, - sunrealtype k2, sunrealtype k3); -SUNDIALS_EXPORT -SUNAdaptController_Type SUNAdaptController_GetType_PID(SUNAdaptController C); -SUNDIALS_EXPORT -int SUNAdaptController_EstimateStep_PID(SUNAdaptController C, sunrealtype h, - int p, sunrealtype dsm, sunrealtype* hnew); -SUNDIALS_EXPORT -int SUNAdaptController_Reset_PID(SUNAdaptController C); -SUNDIALS_EXPORT -int SUNAdaptController_SetDefaults_PID(SUNAdaptController C); -SUNDIALS_EXPORT -int SUNAdaptController_Write_PID(SUNAdaptController C, FILE* fptr); -SUNDIALS_EXPORT -int SUNAdaptController_SetErrorBias_PID(SUNAdaptController C, sunrealtype bias); -SUNDIALS_EXPORT -int SUNAdaptController_Update_PID(SUNAdaptController C, sunrealtype h, sunrealtype dsm); -SUNDIALS_EXPORT -int SUNAdaptController_Space_PID(SUNAdaptController C, long int *lenrw, - long int *leniw); - -#ifdef __cplusplus -} -#endif - -#endif /* _SUNADAPTCONTROLLER_PID_H */ diff --git a/include/sunadaptcontroller/sunadaptcontroller_soderlind.h b/include/sunadaptcontroller/sunadaptcontroller_soderlind.h index e7af60f7aa..df31c11f7b 100644 --- a/include/sunadaptcontroller/sunadaptcontroller_soderlind.h +++ b/include/sunadaptcontroller/sunadaptcontroller_soderlind.h @@ -75,6 +75,23 @@ SUNDIALS_EXPORT int SUNAdaptController_Space_Soderlind(SUNAdaptController C, long int *lenrw, long int *leniw); +/* Convenience routines to construct subsidiary controllers */ +SUNDIALS_EXPORT +SUNAdaptController SUNAdaptController_PID(SUNContext sunctx); +SUNDIALS_EXPORT +int SUNAdaptController_SetParams_PID(SUNAdaptController C, + sunrealtype k1, sunrealtype k2, + sunrealtype k3); +SUNDIALS_EXPORT +SUNAdaptController SUNAdaptController_PI(SUNContext sunctx); +SUNDIALS_EXPORT +int SUNAdaptController_SetParams_PI(SUNAdaptController C, + sunrealtype k1, sunrealtype k2); +SUNDIALS_EXPORT +SUNAdaptController SUNAdaptController_I(SUNContext sunctx); +SUNDIALS_EXPORT +int SUNAdaptController_SetParams_I(SUNAdaptController C, sunrealtype k1); + #ifdef __cplusplus } #endif diff --git a/src/arkode/CMakeLists.txt b/src/arkode/CMakeLists.txt index c817398eaf..913aec197c 100644 --- a/src/arkode/CMakeLists.txt +++ b/src/arkode/CMakeLists.txt @@ -77,10 +77,7 @@ sundials_add_library(sundials_arkode sundials_sunmemsys_obj sundials_nvecserial_obj sundials_sunadaptcontrollerexpgus_obj - sundials_sunadaptcontrolleri_obj - sundials_sunadaptcontrollerpid_obj sundials_sunadaptcontrollerimpgus_obj - sundials_sunadaptcontrollerpi_obj sundials_sunadaptcontrollerimexgus_obj sundials_sunadaptcontrollernoop_obj sundials_sunadaptcontrollersoderlind_obj diff --git a/src/arkode/arkode.c b/src/arkode/arkode.c index 6d3d7ce8a1..8d9d83f52b 100644 --- a/src/arkode/arkode.c +++ b/src/arkode/arkode.c @@ -31,7 +31,7 @@ #include #include #include -#include +#include /*=============================================================== diff --git a/src/arkode/arkode_arkstep_io.c b/src/arkode/arkode_arkstep_io.c index 5d41ba7a4e..c36febb152 100644 --- a/src/arkode/arkode_arkstep_io.c +++ b/src/arkode/arkode_arkstep_io.c @@ -523,7 +523,7 @@ int ARKStepSetOptimalParams(void *arkode_mem) } (void) SUNAdaptController_SetErrorBias(hadapt_mem->hcontroller, RCONST(1.2)); (void) SUNAdaptController_SetParams_PI(hadapt_mem->hcontroller, RCONST(0.8), - RCONST(0.31)); + -RCONST(0.31)); hadapt_mem->safety = RCONST(0.99); hadapt_mem->growth = RCONST(25.0); hadapt_mem->etamxf = RCONST(0.3); @@ -584,7 +584,7 @@ int ARKStepSetOptimalParams(void *arkode_mem) } (void) SUNAdaptController_SetErrorBias(hadapt_mem->hcontroller, RCONST(1.2)); (void) SUNAdaptController_SetParams_PID(hadapt_mem->hcontroller, RCONST(0.535), - RCONST(0.209), RCONST(0.148)); + -RCONST(0.209), RCONST(0.148)); hadapt_mem->safety = RCONST(0.988); hadapt_mem->growth = RCONST(31.5); hadapt_mem->etamxf = RCONST(0.33); @@ -607,7 +607,7 @@ int ARKStepSetOptimalParams(void *arkode_mem) } (void) SUNAdaptController_SetErrorBias(hadapt_mem->hcontroller, RCONST(3.3)); (void) SUNAdaptController_SetParams_PID(hadapt_mem->hcontroller, RCONST(0.56), - RCONST(0.338), RCONST(0.14)); + -RCONST(0.338), RCONST(0.14)); hadapt_mem->safety = RCONST(0.937); hadapt_mem->growth = RCONST(22.0); hadapt_mem->etamxf = RCONST(0.44); @@ -656,7 +656,7 @@ int ARKStepSetOptimalParams(void *arkode_mem) } (void) SUNAdaptController_SetErrorBias(hadapt_mem->hcontroller, RCONST(1.42)); (void) SUNAdaptController_SetParams_PID(hadapt_mem->hcontroller, RCONST(0.54), - RCONST(0.36), RCONST(0.14)); + -RCONST(0.36), RCONST(0.14)); hadapt_mem->safety = RCONST(0.965); hadapt_mem->growth = RCONST(28.7); hadapt_mem->etamxf = RCONST(0.46); @@ -679,7 +679,7 @@ int ARKStepSetOptimalParams(void *arkode_mem) } (void) SUNAdaptController_SetErrorBias(hadapt_mem->hcontroller, RCONST(1.35)); (void) SUNAdaptController_SetParams_PID(hadapt_mem->hcontroller, RCONST(0.543), - RCONST(0.297), RCONST(0.14)); + -RCONST(0.297), RCONST(0.14)); hadapt_mem->safety = RCONST(0.97); hadapt_mem->growth = RCONST(25.0); hadapt_mem->etamxf = RCONST(0.47); @@ -702,7 +702,7 @@ int ARKStepSetOptimalParams(void *arkode_mem) } (void) SUNAdaptController_SetErrorBias(hadapt_mem->hcontroller, RCONST(1.15)); (void) SUNAdaptController_SetParams_PI(hadapt_mem->hcontroller, RCONST(0.8), - RCONST(0.35)); + -RCONST(0.35)); hadapt_mem->safety = RCONST(0.993); hadapt_mem->growth = RCONST(28.5); hadapt_mem->etamxf = RCONST(0.3); diff --git a/src/arkode/arkode_erkstep_io.c b/src/arkode/arkode_erkstep_io.c index c0c5689db9..23483a956c 100644 --- a/src/arkode/arkode_erkstep_io.c +++ b/src/arkode/arkode_erkstep_io.c @@ -326,7 +326,7 @@ int ERKStepSetDefaults(void* arkode_mem) ark_mem->hadapt_mem->growth = RCONST(25.0); /* step adaptivity growth factor */ (void) SUNAdaptController_SetErrorBias(ark_mem->hadapt_mem->hcontroller, RCONST(1.2)); (void) SUNAdaptController_SetParams_PI(ark_mem->hadapt_mem->hcontroller, - RCONST(0.8), RCONST(0.31)); + RCONST(0.8), -RCONST(0.31)); return(ARK_SUCCESS); } diff --git a/src/arkode/arkode_io.c b/src/arkode/arkode_io.c index 28a4f5c721..2aa24f646b 100644 --- a/src/arkode/arkode_io.c +++ b/src/arkode/arkode_io.c @@ -26,9 +26,7 @@ #include "arkode_user_controller.h" #include #include -#include -#include -#include +#include #include #include #include @@ -110,11 +108,6 @@ int arkSetDefaults(void *arkode_mem) ark_mem->hadapt_mem->p = 0; /* no default embedding order */ ark_mem->hadapt_mem->q = 0; /* no default method order */ ark_mem->hadapt_mem->adjust = ADJUST; /* controller order adjustment */ - - /* Set default values for controller object */ - retval = SUNAdaptController_SetDefaults(ark_mem->hadapt_mem->hcontroller); - if (retval != SUNADAPTCONTROLLER_SUCCESS) { return(ARK_CONTROLLER_ERR); } - return(ARK_SUCCESS); } @@ -987,12 +980,9 @@ int arkSetAdaptivityMethod(void *arkode_mem, int imethod, int idefault, } ark_mem->hadapt_mem->hcontroller = NULL; - /* set adaptivity parameters from inputs or signal use of defaults */ - if (idefault == 1) { - k1 = -RCONST(1.0); - k2 = -RCONST(1.0); - k3 = -RCONST(1.0); - } else { + /* set adaptivity parameters from inputs */ + k1 = k2 = k3 = ZERO; + if (idefault != 1) { k1 = adapt_params[0]; k2 = adapt_params[1]; k3 = adapt_params[2]; @@ -1010,11 +1000,13 @@ int arkSetAdaptivityMethod(void *arkode_mem, int imethod, int idefault, "SUNAdaptController_PID allocation failure"); return(ARK_MEM_FAIL); } - retval = SUNAdaptController_SetParams_PID(C, k1, k2, k3); - if (retval != SUNADAPTCONTROLLER_SUCCESS) { - arkProcessError(ark_mem, ARK_CONTROLLER_ERR, "ARKODE", - "arkSetAdaptivityMethod", "SUNAdaptController_SetParams_PID failure"); - return(ARK_CONTROLLER_ERR); + if (idefault != 1) { + retval = SUNAdaptController_SetParams_PID(C, k1, -k2, k3); + if (retval != SUNADAPTCONTROLLER_SUCCESS) { + arkProcessError(ark_mem, ARK_CONTROLLER_ERR, "ARKODE", + "arkSetAdaptivityMethod", "SUNAdaptController_SetParams_PID failure"); + return(ARK_CONTROLLER_ERR); + } } break; case (ARK_ADAPT_PI): @@ -1024,11 +1016,13 @@ int arkSetAdaptivityMethod(void *arkode_mem, int imethod, int idefault, "SUNAdaptController_PI allocation failure"); return(ARK_MEM_FAIL); } - retval = SUNAdaptController_SetParams_PI(C, k1, k2); - if (retval != SUNADAPTCONTROLLER_SUCCESS) { - arkProcessError(ark_mem, ARK_CONTROLLER_ERR, "ARKODE", - "arkSetAdaptivityMethod", "SUNAdaptController_SetParams_PI failure"); - return(ARK_CONTROLLER_ERR); + if (idefault != 1) { + retval = SUNAdaptController_SetParams_PI(C, k1, -k2); + if (retval != SUNADAPTCONTROLLER_SUCCESS) { + arkProcessError(ark_mem, ARK_CONTROLLER_ERR, "ARKODE", + "arkSetAdaptivityMethod", "SUNAdaptController_SetParams_PI failure"); + return(ARK_CONTROLLER_ERR); + } } break; case (ARK_ADAPT_I): @@ -1038,11 +1032,13 @@ int arkSetAdaptivityMethod(void *arkode_mem, int imethod, int idefault, "SUNAdaptController_I allocation failure"); return(ARK_MEM_FAIL); } - retval = SUNAdaptController_SetParams_I(C, k1); - if (retval != SUNADAPTCONTROLLER_SUCCESS) { - arkProcessError(ark_mem, ARK_CONTROLLER_ERR, "ARKODE", - "arkSetAdaptivityMethod", "SUNAdaptController_SetParams_I failure"); - return(ARK_CONTROLLER_ERR); + if (idefault != 1) { + retval = SUNAdaptController_SetParams_I(C, k1); + if (retval != SUNADAPTCONTROLLER_SUCCESS) { + arkProcessError(ark_mem, ARK_CONTROLLER_ERR, "ARKODE", + "arkSetAdaptivityMethod", "SUNAdaptController_SetParams_I failure"); + return(ARK_CONTROLLER_ERR); + } } break; case (ARK_ADAPT_EXP_GUS): @@ -1052,11 +1048,13 @@ int arkSetAdaptivityMethod(void *arkode_mem, int imethod, int idefault, "SUNAdaptController_ExpGus allocation failure"); return(ARK_MEM_FAIL); } - retval = SUNAdaptController_SetParams_ExpGus(C, k1, k2); - if (retval != SUNADAPTCONTROLLER_SUCCESS) { - arkProcessError(ark_mem, ARK_CONTROLLER_ERR, "ARKODE", - "arkSetAdaptivityMethod", "SUNAdaptController_SetParams_ExpGus failure"); - return(ARK_CONTROLLER_ERR); + if (idefault != 1) { + retval = SUNAdaptController_SetParams_ExpGus(C, k1, k2); + if (retval != SUNADAPTCONTROLLER_SUCCESS) { + arkProcessError(ark_mem, ARK_CONTROLLER_ERR, "ARKODE", + "arkSetAdaptivityMethod", "SUNAdaptController_SetParams_ExpGus failure"); + return(ARK_CONTROLLER_ERR); + } } break; case (ARK_ADAPT_IMP_GUS): @@ -1066,11 +1064,13 @@ int arkSetAdaptivityMethod(void *arkode_mem, int imethod, int idefault, "SUNAdaptController_ImpGus allocation failure"); return(ARK_MEM_FAIL); } - retval = SUNAdaptController_SetParams_ImpGus(C, k1, k2); - if (retval != SUNADAPTCONTROLLER_SUCCESS) { - arkProcessError(ark_mem, ARK_CONTROLLER_ERR, "ARKODE", - "arkSetAdaptivityMethod", "SUNAdaptController_SetParams_ImpGus failure"); - return(ARK_CONTROLLER_ERR); + if (idefault != 1) { + retval = SUNAdaptController_SetParams_ImpGus(C, k1, k2); + if (retval != SUNADAPTCONTROLLER_SUCCESS) { + arkProcessError(ark_mem, ARK_CONTROLLER_ERR, "ARKODE", + "arkSetAdaptivityMethod", "SUNAdaptController_SetParams_ImpGus failure"); + return(ARK_CONTROLLER_ERR); + } } break; case (ARK_ADAPT_IMEX_GUS): @@ -1080,11 +1080,13 @@ int arkSetAdaptivityMethod(void *arkode_mem, int imethod, int idefault, "SUNAdaptController_ImExGus allocation failure"); return(ARK_MEM_FAIL); } - retval = SUNAdaptController_SetParams_ImExGus(C, k1, k2, k3, k3); - if (retval != SUNADAPTCONTROLLER_SUCCESS) { - arkProcessError(ark_mem, ARK_CONTROLLER_ERR, "ARKODE", - "arkSetAdaptivityMethod", "SUNAdaptController_SetParams_ImExGus failure"); - return(ARK_CONTROLLER_ERR); + if (idefault != 1) { + retval = SUNAdaptController_SetParams_ImExGus(C, k1, k2, k3, k3); + if (retval != SUNADAPTCONTROLLER_SUCCESS) { + arkProcessError(ark_mem, ARK_CONTROLLER_ERR, "ARKODE", + "arkSetAdaptivityMethod", "SUNAdaptController_SetParams_ImExGus failure"); + return(ARK_CONTROLLER_ERR); + } } break; default: diff --git a/src/sunadaptcontroller/CMakeLists.txt b/src/sunadaptcontroller/CMakeLists.txt index 3094cf4882..483d73ecb0 100644 --- a/src/sunadaptcontroller/CMakeLists.txt +++ b/src/sunadaptcontroller/CMakeLists.txt @@ -16,10 +16,7 @@ # required native matrices add_subdirectory(expgus) -add_subdirectory(i) add_subdirectory(imexgus) add_subdirectory(impgus) add_subdirectory(noop) -add_subdirectory(pi) -add_subdirectory(pid) add_subdirectory(soderlind) diff --git a/src/sunadaptcontroller/i/CMakeLists.txt b/src/sunadaptcontroller/i/CMakeLists.txt deleted file mode 100644 index 85a3fb019b..0000000000 --- a/src/sunadaptcontroller/i/CMakeLists.txt +++ /dev/null @@ -1,29 +0,0 @@ -# --------------------------------------------------------------- -# Programmer(s): Daniel R. Reynolds @ SMU -# --------------------------------------------------------------- -# SUNDIALS Copyright Start -# Copyright (c) 2002-2023, 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 -# --------------------------------------------------------------- - -# Create a library out of the generic sundials modules -sundials_add_library(sundials_sunadaptcontrolleri - SOURCES - sunadaptcontroller_i.c - HEADERS - ${SUNDIALS_SOURCE_DIR}/include/sunadaptcontroller/sunadaptcontroller_i.h - INCLUDE_SUBDIR - sunadaptcontroller - OBJECT_LIB_ONLY -) - -# Add F2003 module if the interface is enabled -if(BUILD_FORTRAN_MODULE_INTERFACE) - add_subdirectory(fmod) -endif() diff --git a/src/sunadaptcontroller/i/fmod/CMakeLists.txt b/src/sunadaptcontroller/i/fmod/CMakeLists.txt deleted file mode 100644 index 32dc30f4e5..0000000000 --- a/src/sunadaptcontroller/i/fmod/CMakeLists.txt +++ /dev/null @@ -1,25 +0,0 @@ -# --------------------------------------------------------------- -# Programmer(s): Daniel R. Reynolds @ SMU -# --------------------------------------------------------------- -# SUNDIALS Copyright Start -# Copyright (c) 2002-2023, 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 -# --------------------------------------------------------------- - -sundials_add_f2003_library(sundials_fsunadaptcontrolleri_mod - SOURCES - fsunadaptcontroller_i_mod.f90 fsunadaptcontroller_i_mod.c - OBJECT_LIBRARIES - sundials_fgeneric_mod_obj - OUTPUT_NAME - sundials_fsunadaptcontrolleri_mod - OBJECT_LIB_ONLY -) - -message(STATUS "Added SUNAdaptController_I F2003 interface") diff --git a/src/sunadaptcontroller/i/fmod/fsunadaptcontroller_i_mod.c b/src/sunadaptcontroller/i/fmod/fsunadaptcontroller_i_mod.c deleted file mode 100644 index bae2663a6e..0000000000 --- a/src/sunadaptcontroller/i/fmod/fsunadaptcontroller_i_mod.c +++ /dev/null @@ -1,325 +0,0 @@ -/* ---------------------------------------------------------------------------- - * This file was automatically generated by SWIG (http://www.swig.org). - * Version 4.0.0 - * - * This file is not intended to be easily readable and contains a number of - * coding conventions designed to improve portability and efficiency. Do not make - * changes to this file unless you know what you are doing--modify the SWIG - * interface file instead. - * ----------------------------------------------------------------------------- */ - -/* --------------------------------------------------------------- - * Programmer(s): Auto-generated by swig. - * --------------------------------------------------------------- - * SUNDIALS Copyright Start - * Copyright (c) 2002-2023, Lawrence Livermore National Security - * and Southern Methodist University. - * All rights reserved. - * - * See the top-level LICENSE and NOTICE files for details. - * - * SPDX-License-Identifier: BSD-3-Clause - * SUNDIALS Copyright End - * -------------------------------------------------------------*/ - -/* ----------------------------------------------------------------------------- - * This section contains generic SWIG labels for method/variable - * declarations/attributes, and other compiler dependent labels. - * ----------------------------------------------------------------------------- */ - -/* template workaround for compilers that cannot correctly implement the C++ standard */ -#ifndef SWIGTEMPLATEDISAMBIGUATOR -# if defined(__SUNPRO_CC) && (__SUNPRO_CC <= 0x560) -# define SWIGTEMPLATEDISAMBIGUATOR template -# elif defined(__HP_aCC) -/* Needed even with `aCC -AA' when `aCC -V' reports HP ANSI C++ B3910B A.03.55 */ -/* If we find a maximum version that requires this, the test would be __HP_aCC <= 35500 for A.03.55 */ -# define SWIGTEMPLATEDISAMBIGUATOR template -# else -# define SWIGTEMPLATEDISAMBIGUATOR -# endif -#endif - -/* inline attribute */ -#ifndef SWIGINLINE -# if defined(__cplusplus) || (defined(__GNUC__) && !defined(__STRICT_ANSI__)) -# define SWIGINLINE inline -# else -# define SWIGINLINE -# endif -#endif - -/* attribute recognised by some compilers to avoid 'unused' warnings */ -#ifndef SWIGUNUSED -# if defined(__GNUC__) -# if !(defined(__cplusplus)) || (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)) -# define SWIGUNUSED __attribute__ ((__unused__)) -# else -# define SWIGUNUSED -# endif -# elif defined(__ICC) -# define SWIGUNUSED __attribute__ ((__unused__)) -# else -# define SWIGUNUSED -# endif -#endif - -#ifndef SWIG_MSC_UNSUPPRESS_4505 -# if defined(_MSC_VER) -# pragma warning(disable : 4505) /* unreferenced local function has been removed */ -# endif -#endif - -#ifndef SWIGUNUSEDPARM -# ifdef __cplusplus -# define SWIGUNUSEDPARM(p) -# else -# define SWIGUNUSEDPARM(p) p SWIGUNUSED -# endif -#endif - -/* internal SWIG method */ -#ifndef SWIGINTERN -# define SWIGINTERN static SWIGUNUSED -#endif - -/* internal inline SWIG method */ -#ifndef SWIGINTERNINLINE -# define SWIGINTERNINLINE SWIGINTERN SWIGINLINE -#endif - -/* qualifier for exported *const* global data variables*/ -#ifndef SWIGEXTERN -# ifdef __cplusplus -# define SWIGEXTERN extern -# else -# define SWIGEXTERN -# endif -#endif - -/* exporting methods */ -#if defined(__GNUC__) -# if (__GNUC__ >= 4) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) -# ifndef GCC_HASCLASSVISIBILITY -# define GCC_HASCLASSVISIBILITY -# endif -# endif -#endif - -#ifndef SWIGEXPORT -# if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__) -# if defined(STATIC_LINKED) -# define SWIGEXPORT -# else -# define SWIGEXPORT __declspec(dllexport) -# endif -# else -# if defined(__GNUC__) && defined(GCC_HASCLASSVISIBILITY) -# define SWIGEXPORT __attribute__ ((visibility("default"))) -# else -# define SWIGEXPORT -# endif -# endif -#endif - -/* calling conventions for Windows */ -#ifndef SWIGSTDCALL -# if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__) -# define SWIGSTDCALL __stdcall -# else -# define SWIGSTDCALL -# endif -#endif - -/* Deal with Microsoft's attempt at deprecating C standard runtime functions */ -#if !defined(SWIG_NO_CRT_SECURE_NO_DEPRECATE) && defined(_MSC_VER) && !defined(_CRT_SECURE_NO_DEPRECATE) -# define _CRT_SECURE_NO_DEPRECATE -#endif - -/* Deal with Microsoft's attempt at deprecating methods in the standard C++ library */ -#if !defined(SWIG_NO_SCL_SECURE_NO_DEPRECATE) && defined(_MSC_VER) && !defined(_SCL_SECURE_NO_DEPRECATE) -# define _SCL_SECURE_NO_DEPRECATE -#endif - -/* Deal with Apple's deprecated 'AssertMacros.h' from Carbon-framework */ -#if defined(__APPLE__) && !defined(__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES) -# define __ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES 0 -#endif - -/* Intel's compiler complains if a variable which was never initialised is - * cast to void, which is a common idiom which we use to indicate that we - * are aware a variable isn't used. So we just silence that warning. - * See: https://github.com/swig/swig/issues/192 for more discussion. - */ -#ifdef __INTEL_COMPILER -# pragma warning disable 592 -#endif - -/* Errors in SWIG */ -#define SWIG_UnknownError -1 -#define SWIG_IOError -2 -#define SWIG_RuntimeError -3 -#define SWIG_IndexError -4 -#define SWIG_TypeError -5 -#define SWIG_DivisionByZero -6 -#define SWIG_OverflowError -7 -#define SWIG_SyntaxError -8 -#define SWIG_ValueError -9 -#define SWIG_SystemError -10 -#define SWIG_AttributeError -11 -#define SWIG_MemoryError -12 -#define SWIG_NullReferenceError -13 - - - - -#include -#define SWIG_exception_impl(DECL, CODE, MSG, RETURNNULL) \ - { printf("In " DECL ": " MSG); assert(0); RETURNNULL; } - - -#include -#if defined(_MSC_VER) || defined(__BORLANDC__) || defined(_WATCOM) -# ifndef snprintf -# define snprintf _snprintf -# endif -#endif - - -/* Support for the `contract` feature. - * - * Note that RETURNNULL is first because it's inserted via a 'Replaceall' in - * the fortran.cxx file. - */ -#define SWIG_contract_assert(RETURNNULL, EXPR, MSG) \ - if (!(EXPR)) { SWIG_exception_impl("$decl", SWIG_ValueError, MSG, RETURNNULL); } - - -#define SWIGVERSION 0x040000 -#define SWIG_VERSION SWIGVERSION - - -#define SWIG_as_voidptr(a) (void *)((const void *)(a)) -#define SWIG_as_voidptrptr(a) ((void)SWIG_as_voidptr(*a),(void**)(a)) - - -#include "sundials/sundials_adaptcontroller.h" - - -#include "sunadaptcontroller/sunadaptcontroller_i.h" - -SWIGEXPORT SUNAdaptController _wrap_FSUNAdaptController_I(void *farg1) { - SUNAdaptController fresult ; - SUNContext arg1 = (SUNContext) 0 ; - SUNAdaptController result; - - arg1 = (SUNContext)(farg1); - result = (SUNAdaptController)SUNAdaptController_I(arg1); - fresult = result; - return fresult; -} - - -SWIGEXPORT int _wrap_FSUNAdaptController_SetParams_I(SUNAdaptController farg1, double const *farg2) { - int fresult ; - SUNAdaptController arg1 = (SUNAdaptController) 0 ; - sunrealtype arg2 ; - int result; - - arg1 = (SUNAdaptController)(farg1); - arg2 = (sunrealtype)(*farg2); - result = (int)SUNAdaptController_SetParams_I(arg1,arg2); - fresult = (int)(result); - return fresult; -} - - -SWIGEXPORT int _wrap_FSUNAdaptController_GetType_I(SUNAdaptController farg1) { - int fresult ; - SUNAdaptController arg1 = (SUNAdaptController) 0 ; - SUNAdaptController_Type result; - - arg1 = (SUNAdaptController)(farg1); - result = (SUNAdaptController_Type)SUNAdaptController_GetType_I(arg1); - fresult = (int)(result); - return fresult; -} - - -SWIGEXPORT int _wrap_FSUNAdaptController_EstimateStep_I(SUNAdaptController farg1, double const *farg2, int const *farg3, double const *farg4, double *farg5) { - int fresult ; - SUNAdaptController arg1 = (SUNAdaptController) 0 ; - sunrealtype arg2 ; - int arg3 ; - sunrealtype arg4 ; - sunrealtype *arg5 = (sunrealtype *) 0 ; - int result; - - arg1 = (SUNAdaptController)(farg1); - arg2 = (sunrealtype)(*farg2); - arg3 = (int)(*farg3); - arg4 = (sunrealtype)(*farg4); - arg5 = (sunrealtype *)(farg5); - result = (int)SUNAdaptController_EstimateStep_I(arg1,arg2,arg3,arg4,arg5); - fresult = (int)(result); - return fresult; -} - - -SWIGEXPORT int _wrap_FSUNAdaptController_SetDefaults_I(SUNAdaptController farg1) { - int fresult ; - SUNAdaptController arg1 = (SUNAdaptController) 0 ; - int result; - - arg1 = (SUNAdaptController)(farg1); - result = (int)SUNAdaptController_SetDefaults_I(arg1); - fresult = (int)(result); - return fresult; -} - - -SWIGEXPORT int _wrap_FSUNAdaptController_Write_I(SUNAdaptController farg1, void *farg2) { - int fresult ; - SUNAdaptController arg1 = (SUNAdaptController) 0 ; - FILE *arg2 = (FILE *) 0 ; - int result; - - arg1 = (SUNAdaptController)(farg1); - arg2 = (FILE *)(farg2); - result = (int)SUNAdaptController_Write_I(arg1,arg2); - fresult = (int)(result); - return fresult; -} - - -SWIGEXPORT int _wrap_FSUNAdaptController_SetErrorBias_I(SUNAdaptController farg1, double const *farg2) { - int fresult ; - SUNAdaptController arg1 = (SUNAdaptController) 0 ; - sunrealtype arg2 ; - int result; - - arg1 = (SUNAdaptController)(farg1); - arg2 = (sunrealtype)(*farg2); - result = (int)SUNAdaptController_SetErrorBias_I(arg1,arg2); - fresult = (int)(result); - return fresult; -} - - -SWIGEXPORT int _wrap_FSUNAdaptController_Space_I(SUNAdaptController farg1, long *farg2, long *farg3) { - int fresult ; - SUNAdaptController arg1 = (SUNAdaptController) 0 ; - long *arg2 = (long *) 0 ; - long *arg3 = (long *) 0 ; - int result; - - arg1 = (SUNAdaptController)(farg1); - arg2 = (long *)(farg2); - arg3 = (long *)(farg3); - result = (int)SUNAdaptController_Space_I(arg1,arg2,arg3); - fresult = (int)(result); - return fresult; -} - - - diff --git a/src/sunadaptcontroller/i/fmod/fsunadaptcontroller_i_mod.f90 b/src/sunadaptcontroller/i/fmod/fsunadaptcontroller_i_mod.f90 deleted file mode 100644 index df439405fb..0000000000 --- a/src/sunadaptcontroller/i/fmod/fsunadaptcontroller_i_mod.f90 +++ /dev/null @@ -1,251 +0,0 @@ -! This file was automatically generated by SWIG (http://www.swig.org). -! Version 4.0.0 -! -! Do not make changes to this file unless you know what you are doing--modify -! the SWIG interface file instead. - -! --------------------------------------------------------------- -! Programmer(s): Auto-generated by swig. -! --------------------------------------------------------------- -! SUNDIALS Copyright Start -! Copyright (c) 2002-2023, 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 -! --------------------------------------------------------------- - -module fsunadaptcontroller_i_mod - use, intrinsic :: ISO_C_BINDING - use fsundials_adaptcontroller_mod - use fsundials_types_mod - use fsundials_context_mod - implicit none - private - - ! DECLARATION CONSTRUCTS - public :: FSUNAdaptController_I - public :: FSUNAdaptController_SetParams_I - public :: FSUNAdaptController_GetType_I - public :: FSUNAdaptController_EstimateStep_I - public :: FSUNAdaptController_SetDefaults_I - public :: FSUNAdaptController_Write_I - public :: FSUNAdaptController_SetErrorBias_I - public :: FSUNAdaptController_Space_I - -! WRAPPER DECLARATIONS -interface -function swigc_FSUNAdaptController_I(farg1) & -bind(C, name="_wrap_FSUNAdaptController_I") & -result(fresult) -use, intrinsic :: ISO_C_BINDING -type(C_PTR), value :: farg1 -type(C_PTR) :: fresult -end function - -function swigc_FSUNAdaptController_SetParams_I(farg1, farg2) & -bind(C, name="_wrap_FSUNAdaptController_SetParams_I") & -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_FSUNAdaptController_GetType_I(farg1) & -bind(C, name="_wrap_FSUNAdaptController_GetType_I") & -result(fresult) -use, intrinsic :: ISO_C_BINDING -type(C_PTR), value :: farg1 -integer(C_INT) :: fresult -end function - -function swigc_FSUNAdaptController_EstimateStep_I(farg1, farg2, farg3, farg4, farg5) & -bind(C, name="_wrap_FSUNAdaptController_EstimateStep_I") & -result(fresult) -use, intrinsic :: ISO_C_BINDING -type(C_PTR), value :: farg1 -real(C_DOUBLE), intent(in) :: farg2 -integer(C_INT), intent(in) :: farg3 -real(C_DOUBLE), intent(in) :: farg4 -type(C_PTR), value :: farg5 -integer(C_INT) :: fresult -end function - -function swigc_FSUNAdaptController_SetDefaults_I(farg1) & -bind(C, name="_wrap_FSUNAdaptController_SetDefaults_I") & -result(fresult) -use, intrinsic :: ISO_C_BINDING -type(C_PTR), value :: farg1 -integer(C_INT) :: fresult -end function - -function swigc_FSUNAdaptController_Write_I(farg1, farg2) & -bind(C, name="_wrap_FSUNAdaptController_Write_I") & -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_FSUNAdaptController_SetErrorBias_I(farg1, farg2) & -bind(C, name="_wrap_FSUNAdaptController_SetErrorBias_I") & -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_FSUNAdaptController_Space_I(farg1, farg2, farg3) & -bind(C, name="_wrap_FSUNAdaptController_Space_I") & -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 - -end interface - - -contains - ! MODULE SUBPROGRAMS -function FSUNAdaptController_I(sunctx) & -result(swig_result) -use, intrinsic :: ISO_C_BINDING -type(SUNAdaptController), pointer :: swig_result -type(C_PTR) :: sunctx -type(C_PTR) :: fresult -type(C_PTR) :: farg1 - -farg1 = sunctx -fresult = swigc_FSUNAdaptController_I(farg1) -call c_f_pointer(fresult, swig_result) -end function - -function FSUNAdaptController_SetParams_I(c, k1) & -result(swig_result) -use, intrinsic :: ISO_C_BINDING -integer(C_INT) :: swig_result -type(SUNAdaptController), target, intent(inout) :: c -real(C_DOUBLE), intent(in) :: k1 -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -real(C_DOUBLE) :: farg2 - -farg1 = c_loc(c) -farg2 = k1 -fresult = swigc_FSUNAdaptController_SetParams_I(farg1, farg2) -swig_result = fresult -end function - -function FSUNAdaptController_GetType_I(c) & -result(swig_result) -use, intrinsic :: ISO_C_BINDING -integer(SUNAdaptController_Type) :: swig_result -type(SUNAdaptController), target, intent(inout) :: c -integer(C_INT) :: fresult -type(C_PTR) :: farg1 - -farg1 = c_loc(c) -fresult = swigc_FSUNAdaptController_GetType_I(farg1) -swig_result = fresult -end function - -function FSUNAdaptController_EstimateStep_I(c, h, p, dsm, hnew) & -result(swig_result) -use, intrinsic :: ISO_C_BINDING -integer(C_INT) :: swig_result -type(SUNAdaptController), target, intent(inout) :: c -real(C_DOUBLE), intent(in) :: h -integer(C_INT), intent(in) :: p -real(C_DOUBLE), intent(in) :: dsm -real(C_DOUBLE), target, intent(inout) :: hnew -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -real(C_DOUBLE) :: farg2 -integer(C_INT) :: farg3 -real(C_DOUBLE) :: farg4 -type(C_PTR) :: farg5 - -farg1 = c_loc(c) -farg2 = h -farg3 = p -farg4 = dsm -farg5 = c_loc(hnew) -fresult = swigc_FSUNAdaptController_EstimateStep_I(farg1, farg2, farg3, farg4, farg5) -swig_result = fresult -end function - -function FSUNAdaptController_SetDefaults_I(c) & -result(swig_result) -use, intrinsic :: ISO_C_BINDING -integer(C_INT) :: swig_result -type(SUNAdaptController), target, intent(inout) :: c -integer(C_INT) :: fresult -type(C_PTR) :: farg1 - -farg1 = c_loc(c) -fresult = swigc_FSUNAdaptController_SetDefaults_I(farg1) -swig_result = fresult -end function - -function FSUNAdaptController_Write_I(c, fptr) & -result(swig_result) -use, intrinsic :: ISO_C_BINDING -integer(C_INT) :: swig_result -type(SUNAdaptController), target, intent(inout) :: c -type(C_PTR) :: fptr -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 - -farg1 = c_loc(c) -farg2 = fptr -fresult = swigc_FSUNAdaptController_Write_I(farg1, farg2) -swig_result = fresult -end function - -function FSUNAdaptController_SetErrorBias_I(c, bias) & -result(swig_result) -use, intrinsic :: ISO_C_BINDING -integer(C_INT) :: swig_result -type(SUNAdaptController), target, intent(inout) :: c -real(C_DOUBLE), intent(in) :: bias -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -real(C_DOUBLE) :: farg2 - -farg1 = c_loc(c) -farg2 = bias -fresult = swigc_FSUNAdaptController_SetErrorBias_I(farg1, farg2) -swig_result = fresult -end function - -function FSUNAdaptController_Space_I(c, lenrw, leniw) & -result(swig_result) -use, intrinsic :: ISO_C_BINDING -integer(C_INT) :: swig_result -type(SUNAdaptController), target, intent(inout) :: c -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 = c_loc(c) -farg2 = c_loc(lenrw(1)) -farg3 = c_loc(leniw(1)) -fresult = swigc_FSUNAdaptController_Space_I(farg1, farg2, farg3) -swig_result = fresult -end function - - -end module diff --git a/src/sunadaptcontroller/i/sunadaptcontroller_i.c b/src/sunadaptcontroller/i/sunadaptcontroller_i.c deleted file mode 100644 index d959fee193..0000000000 --- a/src/sunadaptcontroller/i/sunadaptcontroller_i.c +++ /dev/null @@ -1,155 +0,0 @@ -/* ----------------------------------------------------------------- - * Programmer(s): Daniel R. Reynolds @ SMU - * ----------------------------------------------------------------- - * SUNDIALS Copyright Start - * Copyright (c) 2002-2023, Lawrence Livermore National Security - * and Southern Methodist University. - * All rights reserved. - * - * See the top-level LICENSE and NOTICE files for details. - * - * SPDX-License-Identifier: BSD-3-Clause - * SUNDIALS Copyright End - * ----------------------------------------------------------------- - * This is the implementation file for the SUNAdaptController_I - * module. - * -----------------------------------------------------------------*/ - -#include -#include -#include -#include - - -/* --------------- - * Macro accessors - * --------------- */ - -#define SACI_CONTENT(C) ( (SUNAdaptControllerContent_I)(C->content) ) -#define SACI_K1(C) ( SACI_CONTENT(C)->k1 ) -#define SACI_BIAS(C) ( SACI_CONTENT(C)->bias ) - -/* ------------------ - * Default parameters - * ------------------ */ - -#define DEFAULT_K1 RCONST(1.0) -#define DEFAULT_BIAS RCONST(1.5) -#define TINY RCONST(1.0e-10) - - -/* ----------------------------------------------------------------- - * exported functions - * ----------------------------------------------------------------- */ - -/* ----------------------------------------------------------------- - * Function to create a new I controller - */ - -SUNAdaptController SUNAdaptController_I(SUNContext sunctx) -{ - SUNAdaptController C; - SUNAdaptControllerContent_I content; - - /* Create an empty controller object */ - C = NULL; - C = SUNAdaptController_NewEmpty(sunctx); - if (C == NULL) { return (NULL); } - - /* Attach operations */ - C->ops->gettype = SUNAdaptController_GetType_I; - C->ops->estimatestep = SUNAdaptController_EstimateStep_I; - C->ops->setdefaults = SUNAdaptController_SetDefaults_I; - C->ops->write = SUNAdaptController_Write_I; - C->ops->seterrorbias = SUNAdaptController_SetErrorBias_I; - C->ops->space = SUNAdaptController_Space_I; - - /* Create content */ - content = NULL; - content = (SUNAdaptControllerContent_I)malloc(sizeof *content); - if (content == NULL) - { - (void) SUNAdaptController_Destroy(C); - return (NULL); - } - - /* Attach content */ - C->content = content; - - /* Fill content with default values */ - SUNAdaptController_SetDefaults_I(C); - - return (C); -} - -/* ----------------------------------------------------------------- - * Function to set I parameters - */ - -int SUNAdaptController_SetParams_I(SUNAdaptController C, sunrealtype k1) -{ - SACI_K1(C) = k1; - return SUNADAPTCONTROLLER_SUCCESS; -} - - - -/* ----------------------------------------------------------------- - * implementation of controller operations - * ----------------------------------------------------------------- */ - -SUNAdaptController_Type SUNAdaptController_GetType_I(SUNAdaptController C) -{ return SUN_ADAPTCONTROLLER_H; } - -int SUNAdaptController_EstimateStep_I(SUNAdaptController C, sunrealtype h, - int p, sunrealtype dsm, sunrealtype* hnew) -{ - /* set usable time-step adaptivity parameters */ - const int ord = p + 1; - const sunrealtype k1 = -SACI_K1(C) / ord; - const sunrealtype ecur = SACI_BIAS(C) * dsm; - const sunrealtype e1 = SUNMAX(ecur, TINY); - - /* compute estimated optimal time step size and return with success */ - *hnew = h * SUNRpowerR(e1,k1); - return SUNADAPTCONTROLLER_SUCCESS; -} - -int SUNAdaptController_SetDefaults_I(SUNAdaptController C) -{ - SACI_K1(C) = DEFAULT_K1; - SACI_BIAS(C) = DEFAULT_BIAS; - return SUNADAPTCONTROLLER_SUCCESS; -} - -int SUNAdaptController_Write_I(SUNAdaptController C, FILE *fptr) -{ - fprintf(fptr, "I SUNAdaptController module:\n"); -#if defined(SUNDIALS_EXTENDED_PRECISION) - fprintf(fptr, " k1 = %32Lg\n", SACI_K1(C)); - fprintf(fptr, " bias factor = %32Lg\n", SACI_BIAS(C)); -#else - fprintf(fptr, " k1 = %16g\n", SACI_K1(C)); - fprintf(fptr, " bias factor = %16g\n", SACI_BIAS(C)); -#endif - return SUNADAPTCONTROLLER_SUCCESS; -} - -int SUNAdaptController_SetErrorBias_I(SUNAdaptController C, sunrealtype bias) -{ - /* set allowed value, otherwise set default */ - if (bias <= RCONST(0.0)) { - SACI_BIAS(C) = DEFAULT_BIAS; - } else { - SACI_BIAS(C) = bias; - } - - return SUNADAPTCONTROLLER_SUCCESS; -} - -int SUNAdaptController_Space_I(SUNAdaptController C, long int* lenrw, long int* leniw) -{ - *lenrw = 2; - *leniw = 1; - return SUNADAPTCONTROLLER_SUCCESS; -} diff --git a/src/sunadaptcontroller/pi/CMakeLists.txt b/src/sunadaptcontroller/pi/CMakeLists.txt deleted file mode 100644 index c520871959..0000000000 --- a/src/sunadaptcontroller/pi/CMakeLists.txt +++ /dev/null @@ -1,29 +0,0 @@ -# --------------------------------------------------------------- -# Programmer(s): Daniel R. Reynolds @ SMU -# --------------------------------------------------------------- -# SUNDIALS Copyright Start -# Copyright (c) 2002-2023, 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 -# --------------------------------------------------------------- - -# Create a library out of the generic sundials modules -sundials_add_library(sundials_sunadaptcontrollerpi - SOURCES - sunadaptcontroller_pi.c - HEADERS - ${SUNDIALS_SOURCE_DIR}/include/sunadaptcontroller/sunadaptcontroller_pi.h - INCLUDE_SUBDIR - sunadaptcontroller - OBJECT_LIB_ONLY -) - -# Add F2003 module if the interface is enabled -if(BUILD_FORTRAN_MODULE_INTERFACE) - add_subdirectory(fmod) -endif() diff --git a/src/sunadaptcontroller/pi/fmod/CMakeLists.txt b/src/sunadaptcontroller/pi/fmod/CMakeLists.txt deleted file mode 100644 index ad55783ce6..0000000000 --- a/src/sunadaptcontroller/pi/fmod/CMakeLists.txt +++ /dev/null @@ -1,25 +0,0 @@ -# --------------------------------------------------------------- -# Programmer(s): Daniel R. Reynolds @ SMU -# --------------------------------------------------------------- -# SUNDIALS Copyright Start -# Copyright (c) 2002-2023, 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 -# --------------------------------------------------------------- - -sundials_add_f2003_library(sundials_fsunadaptcontrollerpi_mod - SOURCES - fsunadaptcontroller_pi_mod.f90 fsunadaptcontroller_pi_mod.c - OBJECT_LIBRARIES - sundials_fgeneric_mod_obj - OUTPUT_NAME - sundials_fsunadaptcontrollerpi_mod - OBJECT_LIB_ONLY -) - -message(STATUS "Added SUNAdaptController_PI F2003 interface") diff --git a/src/sunadaptcontroller/pi/fmod/fsunadaptcontroller_pi_mod.c b/src/sunadaptcontroller/pi/fmod/fsunadaptcontroller_pi_mod.c deleted file mode 100644 index 6226ca358b..0000000000 --- a/src/sunadaptcontroller/pi/fmod/fsunadaptcontroller_pi_mod.c +++ /dev/null @@ -1,355 +0,0 @@ -/* ---------------------------------------------------------------------------- - * This file was automatically generated by SWIG (http://www.swig.org). - * Version 4.0.0 - * - * This file is not intended to be easily readable and contains a number of - * coding conventions designed to improve portability and efficiency. Do not make - * changes to this file unless you know what you are doing--modify the SWIG - * interface file instead. - * ----------------------------------------------------------------------------- */ - -/* --------------------------------------------------------------- - * Programmer(s): Auto-generated by swig. - * --------------------------------------------------------------- - * SUNDIALS Copyright Start - * Copyright (c) 2002-2023, Lawrence Livermore National Security - * and Southern Methodist University. - * All rights reserved. - * - * See the top-level LICENSE and NOTICE files for details. - * - * SPDX-License-Identifier: BSD-3-Clause - * SUNDIALS Copyright End - * -------------------------------------------------------------*/ - -/* ----------------------------------------------------------------------------- - * This section contains generic SWIG labels for method/variable - * declarations/attributes, and other compiler dependent labels. - * ----------------------------------------------------------------------------- */ - -/* template workaround for compilers that cannot correctly implement the C++ standard */ -#ifndef SWIGTEMPLATEDISAMBIGUATOR -# if defined(__SUNPRO_CC) && (__SUNPRO_CC <= 0x560) -# define SWIGTEMPLATEDISAMBIGUATOR template -# elif defined(__HP_aCC) -/* Needed even with `aCC -AA' when `aCC -V' reports HP ANSI C++ B3910B A.03.55 */ -/* If we find a maximum version that requires this, the test would be __HP_aCC <= 35500 for A.03.55 */ -# define SWIGTEMPLATEDISAMBIGUATOR template -# else -# define SWIGTEMPLATEDISAMBIGUATOR -# endif -#endif - -/* inline attribute */ -#ifndef SWIGINLINE -# if defined(__cplusplus) || (defined(__GNUC__) && !defined(__STRICT_ANSI__)) -# define SWIGINLINE inline -# else -# define SWIGINLINE -# endif -#endif - -/* attribute recognised by some compilers to avoid 'unused' warnings */ -#ifndef SWIGUNUSED -# if defined(__GNUC__) -# if !(defined(__cplusplus)) || (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)) -# define SWIGUNUSED __attribute__ ((__unused__)) -# else -# define SWIGUNUSED -# endif -# elif defined(__ICC) -# define SWIGUNUSED __attribute__ ((__unused__)) -# else -# define SWIGUNUSED -# endif -#endif - -#ifndef SWIG_MSC_UNSUPPRESS_4505 -# if defined(_MSC_VER) -# pragma warning(disable : 4505) /* unreferenced local function has been removed */ -# endif -#endif - -#ifndef SWIGUNUSEDPARM -# ifdef __cplusplus -# define SWIGUNUSEDPARM(p) -# else -# define SWIGUNUSEDPARM(p) p SWIGUNUSED -# endif -#endif - -/* internal SWIG method */ -#ifndef SWIGINTERN -# define SWIGINTERN static SWIGUNUSED -#endif - -/* internal inline SWIG method */ -#ifndef SWIGINTERNINLINE -# define SWIGINTERNINLINE SWIGINTERN SWIGINLINE -#endif - -/* qualifier for exported *const* global data variables*/ -#ifndef SWIGEXTERN -# ifdef __cplusplus -# define SWIGEXTERN extern -# else -# define SWIGEXTERN -# endif -#endif - -/* exporting methods */ -#if defined(__GNUC__) -# if (__GNUC__ >= 4) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) -# ifndef GCC_HASCLASSVISIBILITY -# define GCC_HASCLASSVISIBILITY -# endif -# endif -#endif - -#ifndef SWIGEXPORT -# if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__) -# if defined(STATIC_LINKED) -# define SWIGEXPORT -# else -# define SWIGEXPORT __declspec(dllexport) -# endif -# else -# if defined(__GNUC__) && defined(GCC_HASCLASSVISIBILITY) -# define SWIGEXPORT __attribute__ ((visibility("default"))) -# else -# define SWIGEXPORT -# endif -# endif -#endif - -/* calling conventions for Windows */ -#ifndef SWIGSTDCALL -# if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__) -# define SWIGSTDCALL __stdcall -# else -# define SWIGSTDCALL -# endif -#endif - -/* Deal with Microsoft's attempt at deprecating C standard runtime functions */ -#if !defined(SWIG_NO_CRT_SECURE_NO_DEPRECATE) && defined(_MSC_VER) && !defined(_CRT_SECURE_NO_DEPRECATE) -# define _CRT_SECURE_NO_DEPRECATE -#endif - -/* Deal with Microsoft's attempt at deprecating methods in the standard C++ library */ -#if !defined(SWIG_NO_SCL_SECURE_NO_DEPRECATE) && defined(_MSC_VER) && !defined(_SCL_SECURE_NO_DEPRECATE) -# define _SCL_SECURE_NO_DEPRECATE -#endif - -/* Deal with Apple's deprecated 'AssertMacros.h' from Carbon-framework */ -#if defined(__APPLE__) && !defined(__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES) -# define __ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES 0 -#endif - -/* Intel's compiler complains if a variable which was never initialised is - * cast to void, which is a common idiom which we use to indicate that we - * are aware a variable isn't used. So we just silence that warning. - * See: https://github.com/swig/swig/issues/192 for more discussion. - */ -#ifdef __INTEL_COMPILER -# pragma warning disable 592 -#endif - -/* Errors in SWIG */ -#define SWIG_UnknownError -1 -#define SWIG_IOError -2 -#define SWIG_RuntimeError -3 -#define SWIG_IndexError -4 -#define SWIG_TypeError -5 -#define SWIG_DivisionByZero -6 -#define SWIG_OverflowError -7 -#define SWIG_SyntaxError -8 -#define SWIG_ValueError -9 -#define SWIG_SystemError -10 -#define SWIG_AttributeError -11 -#define SWIG_MemoryError -12 -#define SWIG_NullReferenceError -13 - - - - -#include -#define SWIG_exception_impl(DECL, CODE, MSG, RETURNNULL) \ - { printf("In " DECL ": " MSG); assert(0); RETURNNULL; } - - -#include -#if defined(_MSC_VER) || defined(__BORLANDC__) || defined(_WATCOM) -# ifndef snprintf -# define snprintf _snprintf -# endif -#endif - - -/* Support for the `contract` feature. - * - * Note that RETURNNULL is first because it's inserted via a 'Replaceall' in - * the fortran.cxx file. - */ -#define SWIG_contract_assert(RETURNNULL, EXPR, MSG) \ - if (!(EXPR)) { SWIG_exception_impl("$decl", SWIG_ValueError, MSG, RETURNNULL); } - - -#define SWIGVERSION 0x040000 -#define SWIG_VERSION SWIGVERSION - - -#define SWIG_as_voidptr(a) (void *)((const void *)(a)) -#define SWIG_as_voidptrptr(a) ((void)SWIG_as_voidptr(*a),(void**)(a)) - - -#include "sundials/sundials_adaptcontroller.h" - - -#include "sunadaptcontroller/sunadaptcontroller_pi.h" - -SWIGEXPORT SUNAdaptController _wrap_FSUNAdaptController_PI(void *farg1) { - SUNAdaptController fresult ; - SUNContext arg1 = (SUNContext) 0 ; - SUNAdaptController result; - - arg1 = (SUNContext)(farg1); - result = (SUNAdaptController)SUNAdaptController_PI(arg1); - fresult = result; - return fresult; -} - - -SWIGEXPORT int _wrap_FSUNAdaptController_SetParams_PI(SUNAdaptController farg1, double const *farg2, double const *farg3) { - int fresult ; - SUNAdaptController arg1 = (SUNAdaptController) 0 ; - sunrealtype arg2 ; - sunrealtype arg3 ; - int result; - - arg1 = (SUNAdaptController)(farg1); - arg2 = (sunrealtype)(*farg2); - arg3 = (sunrealtype)(*farg3); - result = (int)SUNAdaptController_SetParams_PI(arg1,arg2,arg3); - fresult = (int)(result); - return fresult; -} - - -SWIGEXPORT int _wrap_FSUNAdaptController_GetType_PI(SUNAdaptController farg1) { - int fresult ; - SUNAdaptController arg1 = (SUNAdaptController) 0 ; - SUNAdaptController_Type result; - - arg1 = (SUNAdaptController)(farg1); - result = (SUNAdaptController_Type)SUNAdaptController_GetType_PI(arg1); - fresult = (int)(result); - return fresult; -} - - -SWIGEXPORT int _wrap_FSUNAdaptController_EstimateStep_PI(SUNAdaptController farg1, double const *farg2, int const *farg3, double const *farg4, double *farg5) { - int fresult ; - SUNAdaptController arg1 = (SUNAdaptController) 0 ; - sunrealtype arg2 ; - int arg3 ; - sunrealtype arg4 ; - sunrealtype *arg5 = (sunrealtype *) 0 ; - int result; - - arg1 = (SUNAdaptController)(farg1); - arg2 = (sunrealtype)(*farg2); - arg3 = (int)(*farg3); - arg4 = (sunrealtype)(*farg4); - arg5 = (sunrealtype *)(farg5); - result = (int)SUNAdaptController_EstimateStep_PI(arg1,arg2,arg3,arg4,arg5); - fresult = (int)(result); - return fresult; -} - - -SWIGEXPORT int _wrap_FSUNAdaptController_Reset_PI(SUNAdaptController farg1) { - int fresult ; - SUNAdaptController arg1 = (SUNAdaptController) 0 ; - int result; - - arg1 = (SUNAdaptController)(farg1); - result = (int)SUNAdaptController_Reset_PI(arg1); - fresult = (int)(result); - return fresult; -} - - -SWIGEXPORT int _wrap_FSUNAdaptController_SetDefaults_PI(SUNAdaptController farg1) { - int fresult ; - SUNAdaptController arg1 = (SUNAdaptController) 0 ; - int result; - - arg1 = (SUNAdaptController)(farg1); - result = (int)SUNAdaptController_SetDefaults_PI(arg1); - fresult = (int)(result); - return fresult; -} - - -SWIGEXPORT int _wrap_FSUNAdaptController_Write_PI(SUNAdaptController farg1, void *farg2) { - int fresult ; - SUNAdaptController arg1 = (SUNAdaptController) 0 ; - FILE *arg2 = (FILE *) 0 ; - int result; - - arg1 = (SUNAdaptController)(farg1); - arg2 = (FILE *)(farg2); - result = (int)SUNAdaptController_Write_PI(arg1,arg2); - fresult = (int)(result); - return fresult; -} - - -SWIGEXPORT int _wrap_FSUNAdaptController_SetErrorBias_PI(SUNAdaptController farg1, double const *farg2) { - int fresult ; - SUNAdaptController arg1 = (SUNAdaptController) 0 ; - sunrealtype arg2 ; - int result; - - arg1 = (SUNAdaptController)(farg1); - arg2 = (sunrealtype)(*farg2); - result = (int)SUNAdaptController_SetErrorBias_PI(arg1,arg2); - fresult = (int)(result); - return fresult; -} - - -SWIGEXPORT int _wrap_FSUNAdaptController_Update_PI(SUNAdaptController farg1, double const *farg2, double const *farg3) { - int fresult ; - SUNAdaptController arg1 = (SUNAdaptController) 0 ; - sunrealtype arg2 ; - sunrealtype arg3 ; - int result; - - arg1 = (SUNAdaptController)(farg1); - arg2 = (sunrealtype)(*farg2); - arg3 = (sunrealtype)(*farg3); - result = (int)SUNAdaptController_Update_PI(arg1,arg2,arg3); - fresult = (int)(result); - return fresult; -} - - -SWIGEXPORT int _wrap_FSUNAdaptController_Space_PI(SUNAdaptController farg1, long *farg2, long *farg3) { - int fresult ; - SUNAdaptController arg1 = (SUNAdaptController) 0 ; - long *arg2 = (long *) 0 ; - long *arg3 = (long *) 0 ; - int result; - - arg1 = (SUNAdaptController)(farg1); - arg2 = (long *)(farg2); - arg3 = (long *)(farg3); - result = (int)SUNAdaptController_Space_PI(arg1,arg2,arg3); - fresult = (int)(result); - return fresult; -} - - - diff --git a/src/sunadaptcontroller/pi/fmod/fsunadaptcontroller_pi_mod.f90 b/src/sunadaptcontroller/pi/fmod/fsunadaptcontroller_pi_mod.f90 deleted file mode 100644 index 2db14dd2ba..0000000000 --- a/src/sunadaptcontroller/pi/fmod/fsunadaptcontroller_pi_mod.f90 +++ /dev/null @@ -1,307 +0,0 @@ -! This file was automatically generated by SWIG (http://www.swig.org). -! Version 4.0.0 -! -! Do not make changes to this file unless you know what you are doing--modify -! the SWIG interface file instead. - -! --------------------------------------------------------------- -! Programmer(s): Auto-generated by swig. -! --------------------------------------------------------------- -! SUNDIALS Copyright Start -! Copyright (c) 2002-2023, 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 -! --------------------------------------------------------------- - -module fsunadaptcontroller_pi_mod - use, intrinsic :: ISO_C_BINDING - use fsundials_adaptcontroller_mod - use fsundials_types_mod - use fsundials_context_mod - implicit none - private - - ! DECLARATION CONSTRUCTS - public :: FSUNAdaptController_PI - public :: FSUNAdaptController_SetParams_PI - public :: FSUNAdaptController_GetType_PI - public :: FSUNAdaptController_EstimateStep_PI - public :: FSUNAdaptController_Reset_PI - public :: FSUNAdaptController_SetDefaults_PI - public :: FSUNAdaptController_Write_PI - public :: FSUNAdaptController_SetErrorBias_PI - public :: FSUNAdaptController_Update_PI - public :: FSUNAdaptController_Space_PI - -! WRAPPER DECLARATIONS -interface -function swigc_FSUNAdaptController_PI(farg1) & -bind(C, name="_wrap_FSUNAdaptController_PI") & -result(fresult) -use, intrinsic :: ISO_C_BINDING -type(C_PTR), value :: farg1 -type(C_PTR) :: fresult -end function - -function swigc_FSUNAdaptController_SetParams_PI(farg1, farg2, farg3) & -bind(C, name="_wrap_FSUNAdaptController_SetParams_PI") & -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_FSUNAdaptController_GetType_PI(farg1) & -bind(C, name="_wrap_FSUNAdaptController_GetType_PI") & -result(fresult) -use, intrinsic :: ISO_C_BINDING -type(C_PTR), value :: farg1 -integer(C_INT) :: fresult -end function - -function swigc_FSUNAdaptController_EstimateStep_PI(farg1, farg2, farg3, farg4, farg5) & -bind(C, name="_wrap_FSUNAdaptController_EstimateStep_PI") & -result(fresult) -use, intrinsic :: ISO_C_BINDING -type(C_PTR), value :: farg1 -real(C_DOUBLE), intent(in) :: farg2 -integer(C_INT), intent(in) :: farg3 -real(C_DOUBLE), intent(in) :: farg4 -type(C_PTR), value :: farg5 -integer(C_INT) :: fresult -end function - -function swigc_FSUNAdaptController_Reset_PI(farg1) & -bind(C, name="_wrap_FSUNAdaptController_Reset_PI") & -result(fresult) -use, intrinsic :: ISO_C_BINDING -type(C_PTR), value :: farg1 -integer(C_INT) :: fresult -end function - -function swigc_FSUNAdaptController_SetDefaults_PI(farg1) & -bind(C, name="_wrap_FSUNAdaptController_SetDefaults_PI") & -result(fresult) -use, intrinsic :: ISO_C_BINDING -type(C_PTR), value :: farg1 -integer(C_INT) :: fresult -end function - -function swigc_FSUNAdaptController_Write_PI(farg1, farg2) & -bind(C, name="_wrap_FSUNAdaptController_Write_PI") & -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_FSUNAdaptController_SetErrorBias_PI(farg1, farg2) & -bind(C, name="_wrap_FSUNAdaptController_SetErrorBias_PI") & -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_FSUNAdaptController_Update_PI(farg1, farg2, farg3) & -bind(C, name="_wrap_FSUNAdaptController_Update_PI") & -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_FSUNAdaptController_Space_PI(farg1, farg2, farg3) & -bind(C, name="_wrap_FSUNAdaptController_Space_PI") & -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 - -end interface - - -contains - ! MODULE SUBPROGRAMS -function FSUNAdaptController_PI(sunctx) & -result(swig_result) -use, intrinsic :: ISO_C_BINDING -type(SUNAdaptController), pointer :: swig_result -type(C_PTR) :: sunctx -type(C_PTR) :: fresult -type(C_PTR) :: farg1 - -farg1 = sunctx -fresult = swigc_FSUNAdaptController_PI(farg1) -call c_f_pointer(fresult, swig_result) -end function - -function FSUNAdaptController_SetParams_PI(c, k1, k2) & -result(swig_result) -use, intrinsic :: ISO_C_BINDING -integer(C_INT) :: swig_result -type(SUNAdaptController), target, intent(inout) :: c -real(C_DOUBLE), intent(in) :: k1 -real(C_DOUBLE), intent(in) :: k2 -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -real(C_DOUBLE) :: farg2 -real(C_DOUBLE) :: farg3 - -farg1 = c_loc(c) -farg2 = k1 -farg3 = k2 -fresult = swigc_FSUNAdaptController_SetParams_PI(farg1, farg2, farg3) -swig_result = fresult -end function - -function FSUNAdaptController_GetType_PI(c) & -result(swig_result) -use, intrinsic :: ISO_C_BINDING -integer(SUNAdaptController_Type) :: swig_result -type(SUNAdaptController), target, intent(inout) :: c -integer(C_INT) :: fresult -type(C_PTR) :: farg1 - -farg1 = c_loc(c) -fresult = swigc_FSUNAdaptController_GetType_PI(farg1) -swig_result = fresult -end function - -function FSUNAdaptController_EstimateStep_PI(c, h, p, dsm, hnew) & -result(swig_result) -use, intrinsic :: ISO_C_BINDING -integer(C_INT) :: swig_result -type(SUNAdaptController), target, intent(inout) :: c -real(C_DOUBLE), intent(in) :: h -integer(C_INT), intent(in) :: p -real(C_DOUBLE), intent(in) :: dsm -real(C_DOUBLE), target, intent(inout) :: hnew -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -real(C_DOUBLE) :: farg2 -integer(C_INT) :: farg3 -real(C_DOUBLE) :: farg4 -type(C_PTR) :: farg5 - -farg1 = c_loc(c) -farg2 = h -farg3 = p -farg4 = dsm -farg5 = c_loc(hnew) -fresult = swigc_FSUNAdaptController_EstimateStep_PI(farg1, farg2, farg3, farg4, farg5) -swig_result = fresult -end function - -function FSUNAdaptController_Reset_PI(c) & -result(swig_result) -use, intrinsic :: ISO_C_BINDING -integer(C_INT) :: swig_result -type(SUNAdaptController), target, intent(inout) :: c -integer(C_INT) :: fresult -type(C_PTR) :: farg1 - -farg1 = c_loc(c) -fresult = swigc_FSUNAdaptController_Reset_PI(farg1) -swig_result = fresult -end function - -function FSUNAdaptController_SetDefaults_PI(c) & -result(swig_result) -use, intrinsic :: ISO_C_BINDING -integer(C_INT) :: swig_result -type(SUNAdaptController), target, intent(inout) :: c -integer(C_INT) :: fresult -type(C_PTR) :: farg1 - -farg1 = c_loc(c) -fresult = swigc_FSUNAdaptController_SetDefaults_PI(farg1) -swig_result = fresult -end function - -function FSUNAdaptController_Write_PI(c, fptr) & -result(swig_result) -use, intrinsic :: ISO_C_BINDING -integer(C_INT) :: swig_result -type(SUNAdaptController), target, intent(inout) :: c -type(C_PTR) :: fptr -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 - -farg1 = c_loc(c) -farg2 = fptr -fresult = swigc_FSUNAdaptController_Write_PI(farg1, farg2) -swig_result = fresult -end function - -function FSUNAdaptController_SetErrorBias_PI(c, bias) & -result(swig_result) -use, intrinsic :: ISO_C_BINDING -integer(C_INT) :: swig_result -type(SUNAdaptController), target, intent(inout) :: c -real(C_DOUBLE), intent(in) :: bias -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -real(C_DOUBLE) :: farg2 - -farg1 = c_loc(c) -farg2 = bias -fresult = swigc_FSUNAdaptController_SetErrorBias_PI(farg1, farg2) -swig_result = fresult -end function - -function FSUNAdaptController_Update_PI(c, h, dsm) & -result(swig_result) -use, intrinsic :: ISO_C_BINDING -integer(C_INT) :: swig_result -type(SUNAdaptController), target, intent(inout) :: c -real(C_DOUBLE), intent(in) :: h -real(C_DOUBLE), intent(in) :: dsm -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -real(C_DOUBLE) :: farg2 -real(C_DOUBLE) :: farg3 - -farg1 = c_loc(c) -farg2 = h -farg3 = dsm -fresult = swigc_FSUNAdaptController_Update_PI(farg1, farg2, farg3) -swig_result = fresult -end function - -function FSUNAdaptController_Space_PI(c, lenrw, leniw) & -result(swig_result) -use, intrinsic :: ISO_C_BINDING -integer(C_INT) :: swig_result -type(SUNAdaptController), target, intent(inout) :: c -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 = c_loc(c) -farg2 = c_loc(lenrw(1)) -farg3 = c_loc(leniw(1)) -fresult = swigc_FSUNAdaptController_Space_PI(farg1, farg2, farg3) -swig_result = fresult -end function - - -end module diff --git a/src/sunadaptcontroller/pi/sunadaptcontroller_pi.c b/src/sunadaptcontroller/pi/sunadaptcontroller_pi.c deleted file mode 100644 index c5e2104dd6..0000000000 --- a/src/sunadaptcontroller/pi/sunadaptcontroller_pi.c +++ /dev/null @@ -1,181 +0,0 @@ -/* ----------------------------------------------------------------- - * Programmer(s): Daniel R. Reynolds @ SMU - * ----------------------------------------------------------------- - * SUNDIALS Copyright Start - * Copyright (c) 2002-2023, Lawrence Livermore National Security - * and Southern Methodist University. - * All rights reserved. - * - * See the top-level LICENSE and NOTICE files for details. - * - * SPDX-License-Identifier: BSD-3-Clause - * SUNDIALS Copyright End - * ----------------------------------------------------------------- - * This is the implementation file for the SUNAdaptController_PI - * module. - * -----------------------------------------------------------------*/ - -#include -#include -#include -#include - - -/* --------------- - * Macro accessors - * --------------- */ - -#define SACPI_CONTENT(C) ( (SUNAdaptControllerContent_PI)(C->content) ) -#define SACPI_K1(C) ( SACPI_CONTENT(C)->k1 ) -#define SACPI_K2(C) ( SACPI_CONTENT(C)->k2 ) -#define SACPI_BIAS(C) ( SACPI_CONTENT(C)->bias ) -#define SACPI_EP(C) ( SACPI_CONTENT(C)->ep ) - -/* ------------------ - * Default parameters - * ------------------ */ - -#define DEFAULT_K1 RCONST(0.8) -#define DEFAULT_K2 RCONST(0.31) -#define DEFAULT_BIAS RCONST(1.5) -#define TINY RCONST(1.0e-10) - - -/* ----------------------------------------------------------------- - * exported functions - * ----------------------------------------------------------------- */ - -/* ----------------------------------------------------------------- - * Function to create a new PI controller - */ - -SUNAdaptController SUNAdaptController_PI(SUNContext sunctx) -{ - SUNAdaptController C; - SUNAdaptControllerContent_PI content; - - /* Create an empty controller object */ - C = NULL; - C = SUNAdaptController_NewEmpty(sunctx); - if (C == NULL) { return (NULL); } - - /* Attach operations */ - C->ops->gettype = SUNAdaptController_GetType_PI; - C->ops->estimatestep = SUNAdaptController_EstimateStep_PI; - C->ops->reset = SUNAdaptController_Reset_PI; - C->ops->setdefaults = SUNAdaptController_SetDefaults_PI; - C->ops->write = SUNAdaptController_Write_PI; - C->ops->seterrorbias = SUNAdaptController_SetErrorBias_PI; - C->ops->update = SUNAdaptController_Update_PI; - C->ops->space = SUNAdaptController_Space_PI; - - /* Create content */ - content = NULL; - content = (SUNAdaptControllerContent_PI)malloc(sizeof *content); - if (content == NULL) - { - (void) SUNAdaptController_Destroy(C); - return (NULL); - } - - /* Attach content */ - C->content = content; - - /* Fill content with default/reset values */ - SUNAdaptController_SetDefaults_PI(C); - SUNAdaptController_Reset_PI(C); - - return (C); -} - -/* ----------------------------------------------------------------- - * Function to set PI parameters - */ - -int SUNAdaptController_SetParams_PI(SUNAdaptController C, - sunrealtype k1, sunrealtype k2) -{ - SACPI_K1(C) = k1; - SACPI_K2(C) = k2; - return SUNADAPTCONTROLLER_SUCCESS; -} - - -/* ----------------------------------------------------------------- - * implementation of controller operations - * ----------------------------------------------------------------- */ - -SUNAdaptController_Type SUNAdaptController_GetType_PI(SUNAdaptController C) -{ return SUN_ADAPTCONTROLLER_H; } - -int SUNAdaptController_EstimateStep_PI(SUNAdaptController C, sunrealtype h, - int p, sunrealtype dsm, sunrealtype* hnew) -{ - /* set usable time-step adaptivity parameters */ - const int ord = p + 1; - const sunrealtype k1 = -SACPI_K1(C) / ord; - const sunrealtype k2 = SACPI_K2(C) / ord; - const sunrealtype ecur = SACPI_BIAS(C) * dsm; - const sunrealtype e1 = SUNMAX(ecur, TINY); - const sunrealtype e2 = SUNMAX(SACPI_EP(C), TINY); - - /* compute estimated optimal time step size and return with success */ - *hnew = h * SUNRpowerR(e1,k1) * SUNRpowerR(e2,k2); - return SUNADAPTCONTROLLER_SUCCESS; -} - -int SUNAdaptController_Reset_PI(SUNAdaptController C) -{ - SACPI_EP(C) = RCONST(1.0); - return SUNADAPTCONTROLLER_SUCCESS; -} - -int SUNAdaptController_SetDefaults_PI(SUNAdaptController C) -{ - SACPI_K1(C) = DEFAULT_K1; - SACPI_K2(C) = DEFAULT_K2; - SACPI_BIAS(C) = DEFAULT_BIAS; - return SUNADAPTCONTROLLER_SUCCESS; -} - -int SUNAdaptController_Write_PI(SUNAdaptController C, FILE *fptr) -{ - fprintf(fptr, "PI SUNAdaptController module:\n"); -#if defined(SUNDIALS_EXTENDED_PRECISION) - fprintf(fptr, " k1 = %32Lg\n", SACPI_K1(C)); - fprintf(fptr, " k2 = %32Lg\n", SACPI_K2(C)); - fprintf(fptr, " bias factor = %32Lg\n", SACPI_BIAS(C)); - fprintf(fptr, " previous error = %32Lg\n", SACPI_EP(C)); -#else - fprintf(fptr, " k1 = %16g\n", SACPI_K1(C)); - fprintf(fptr, " k2 = %16g\n", SACPI_K2(C)); - fprintf(fptr, " bias factor = %16g\n", SACPI_BIAS(C)); - fprintf(fptr, " previous error = %16g\n", SACPI_EP(C)); -#endif - return SUNADAPTCONTROLLER_SUCCESS; -} - -int SUNAdaptController_SetErrorBias_PI(SUNAdaptController C, sunrealtype bias) -{ - /* set allowed value, otherwise set default */ - if (bias <= RCONST(0.0)) { - SACPI_BIAS(C) = DEFAULT_BIAS; - } else { - SACPI_BIAS(C) = bias; - } - - return SUNADAPTCONTROLLER_SUCCESS; -} - -int SUNAdaptController_Update_PI(SUNAdaptController C, sunrealtype h, sunrealtype dsm) -{ - SACPI_EP(C) = SACPI_BIAS(C) * dsm; - return SUNADAPTCONTROLLER_SUCCESS; -} - -int SUNAdaptController_Space_PI(SUNAdaptController C, long int* lenrw, long int* leniw) -{ - *lenrw = 4; - *leniw = 1; - return SUNADAPTCONTROLLER_SUCCESS; -} diff --git a/src/sunadaptcontroller/pid/CMakeLists.txt b/src/sunadaptcontroller/pid/CMakeLists.txt deleted file mode 100644 index 6a048371e6..0000000000 --- a/src/sunadaptcontroller/pid/CMakeLists.txt +++ /dev/null @@ -1,29 +0,0 @@ -# --------------------------------------------------------------- -# Programmer(s): Daniel R. Reynolds @ SMU -# --------------------------------------------------------------- -# SUNDIALS Copyright Start -# Copyright (c) 2002-2023, 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 -# --------------------------------------------------------------- - -# Create a library out of the generic sundials modules -sundials_add_library(sundials_sunadaptcontrollerpid - SOURCES - sunadaptcontroller_pid.c - HEADERS - ${SUNDIALS_SOURCE_DIR}/include/sunadaptcontroller/sunadaptcontroller_pid.h - INCLUDE_SUBDIR - sunadaptcontroller - OBJECT_LIB_ONLY -) - -# Add F2003 module if the interface is enabled -if(BUILD_FORTRAN_MODULE_INTERFACE) - add_subdirectory(fmod) -endif() diff --git a/src/sunadaptcontroller/pid/fmod/CMakeLists.txt b/src/sunadaptcontroller/pid/fmod/CMakeLists.txt deleted file mode 100644 index b8e62c2d00..0000000000 --- a/src/sunadaptcontroller/pid/fmod/CMakeLists.txt +++ /dev/null @@ -1,25 +0,0 @@ -# --------------------------------------------------------------- -# Programmer(s): Daniel R. Reynolds @ SMU -# --------------------------------------------------------------- -# SUNDIALS Copyright Start -# Copyright (c) 2002-2023, 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 -# --------------------------------------------------------------- - -sundials_add_f2003_library(sundials_fsunadaptcontrollerpid_mod - SOURCES - fsunadaptcontroller_pid_mod.f90 fsunadaptcontroller_pid_mod.c - OBJECT_LIBRARIES - sundials_fgeneric_mod_obj - OUTPUT_NAME - sundials_fsunadaptcontrollerpid_mod - OBJECT_LIB_ONLY -) - -message(STATUS "Added SUNAdaptController_PID F2003 interface") diff --git a/src/sunadaptcontroller/pid/fmod/fsunadaptcontroller_pid_mod.c b/src/sunadaptcontroller/pid/fmod/fsunadaptcontroller_pid_mod.c deleted file mode 100644 index cd8c5c01bf..0000000000 --- a/src/sunadaptcontroller/pid/fmod/fsunadaptcontroller_pid_mod.c +++ /dev/null @@ -1,357 +0,0 @@ -/* ---------------------------------------------------------------------------- - * This file was automatically generated by SWIG (http://www.swig.org). - * Version 4.0.0 - * - * This file is not intended to be easily readable and contains a number of - * coding conventions designed to improve portability and efficiency. Do not make - * changes to this file unless you know what you are doing--modify the SWIG - * interface file instead. - * ----------------------------------------------------------------------------- */ - -/* --------------------------------------------------------------- - * Programmer(s): Auto-generated by swig. - * --------------------------------------------------------------- - * SUNDIALS Copyright Start - * Copyright (c) 2002-2023, Lawrence Livermore National Security - * and Southern Methodist University. - * All rights reserved. - * - * See the top-level LICENSE and NOTICE files for details. - * - * SPDX-License-Identifier: BSD-3-Clause - * SUNDIALS Copyright End - * -------------------------------------------------------------*/ - -/* ----------------------------------------------------------------------------- - * This section contains generic SWIG labels for method/variable - * declarations/attributes, and other compiler dependent labels. - * ----------------------------------------------------------------------------- */ - -/* template workaround for compilers that cannot correctly implement the C++ standard */ -#ifndef SWIGTEMPLATEDISAMBIGUATOR -# if defined(__SUNPRO_CC) && (__SUNPRO_CC <= 0x560) -# define SWIGTEMPLATEDISAMBIGUATOR template -# elif defined(__HP_aCC) -/* Needed even with `aCC -AA' when `aCC -V' reports HP ANSI C++ B3910B A.03.55 */ -/* If we find a maximum version that requires this, the test would be __HP_aCC <= 35500 for A.03.55 */ -# define SWIGTEMPLATEDISAMBIGUATOR template -# else -# define SWIGTEMPLATEDISAMBIGUATOR -# endif -#endif - -/* inline attribute */ -#ifndef SWIGINLINE -# if defined(__cplusplus) || (defined(__GNUC__) && !defined(__STRICT_ANSI__)) -# define SWIGINLINE inline -# else -# define SWIGINLINE -# endif -#endif - -/* attribute recognised by some compilers to avoid 'unused' warnings */ -#ifndef SWIGUNUSED -# if defined(__GNUC__) -# if !(defined(__cplusplus)) || (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)) -# define SWIGUNUSED __attribute__ ((__unused__)) -# else -# define SWIGUNUSED -# endif -# elif defined(__ICC) -# define SWIGUNUSED __attribute__ ((__unused__)) -# else -# define SWIGUNUSED -# endif -#endif - -#ifndef SWIG_MSC_UNSUPPRESS_4505 -# if defined(_MSC_VER) -# pragma warning(disable : 4505) /* unreferenced local function has been removed */ -# endif -#endif - -#ifndef SWIGUNUSEDPARM -# ifdef __cplusplus -# define SWIGUNUSEDPARM(p) -# else -# define SWIGUNUSEDPARM(p) p SWIGUNUSED -# endif -#endif - -/* internal SWIG method */ -#ifndef SWIGINTERN -# define SWIGINTERN static SWIGUNUSED -#endif - -/* internal inline SWIG method */ -#ifndef SWIGINTERNINLINE -# define SWIGINTERNINLINE SWIGINTERN SWIGINLINE -#endif - -/* qualifier for exported *const* global data variables*/ -#ifndef SWIGEXTERN -# ifdef __cplusplus -# define SWIGEXTERN extern -# else -# define SWIGEXTERN -# endif -#endif - -/* exporting methods */ -#if defined(__GNUC__) -# if (__GNUC__ >= 4) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) -# ifndef GCC_HASCLASSVISIBILITY -# define GCC_HASCLASSVISIBILITY -# endif -# endif -#endif - -#ifndef SWIGEXPORT -# if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__) -# if defined(STATIC_LINKED) -# define SWIGEXPORT -# else -# define SWIGEXPORT __declspec(dllexport) -# endif -# else -# if defined(__GNUC__) && defined(GCC_HASCLASSVISIBILITY) -# define SWIGEXPORT __attribute__ ((visibility("default"))) -# else -# define SWIGEXPORT -# endif -# endif -#endif - -/* calling conventions for Windows */ -#ifndef SWIGSTDCALL -# if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__) -# define SWIGSTDCALL __stdcall -# else -# define SWIGSTDCALL -# endif -#endif - -/* Deal with Microsoft's attempt at deprecating C standard runtime functions */ -#if !defined(SWIG_NO_CRT_SECURE_NO_DEPRECATE) && defined(_MSC_VER) && !defined(_CRT_SECURE_NO_DEPRECATE) -# define _CRT_SECURE_NO_DEPRECATE -#endif - -/* Deal with Microsoft's attempt at deprecating methods in the standard C++ library */ -#if !defined(SWIG_NO_SCL_SECURE_NO_DEPRECATE) && defined(_MSC_VER) && !defined(_SCL_SECURE_NO_DEPRECATE) -# define _SCL_SECURE_NO_DEPRECATE -#endif - -/* Deal with Apple's deprecated 'AssertMacros.h' from Carbon-framework */ -#if defined(__APPLE__) && !defined(__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES) -# define __ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES 0 -#endif - -/* Intel's compiler complains if a variable which was never initialised is - * cast to void, which is a common idiom which we use to indicate that we - * are aware a variable isn't used. So we just silence that warning. - * See: https://github.com/swig/swig/issues/192 for more discussion. - */ -#ifdef __INTEL_COMPILER -# pragma warning disable 592 -#endif - -/* Errors in SWIG */ -#define SWIG_UnknownError -1 -#define SWIG_IOError -2 -#define SWIG_RuntimeError -3 -#define SWIG_IndexError -4 -#define SWIG_TypeError -5 -#define SWIG_DivisionByZero -6 -#define SWIG_OverflowError -7 -#define SWIG_SyntaxError -8 -#define SWIG_ValueError -9 -#define SWIG_SystemError -10 -#define SWIG_AttributeError -11 -#define SWIG_MemoryError -12 -#define SWIG_NullReferenceError -13 - - - - -#include -#define SWIG_exception_impl(DECL, CODE, MSG, RETURNNULL) \ - { printf("In " DECL ": " MSG); assert(0); RETURNNULL; } - - -#include -#if defined(_MSC_VER) || defined(__BORLANDC__) || defined(_WATCOM) -# ifndef snprintf -# define snprintf _snprintf -# endif -#endif - - -/* Support for the `contract` feature. - * - * Note that RETURNNULL is first because it's inserted via a 'Replaceall' in - * the fortran.cxx file. - */ -#define SWIG_contract_assert(RETURNNULL, EXPR, MSG) \ - if (!(EXPR)) { SWIG_exception_impl("$decl", SWIG_ValueError, MSG, RETURNNULL); } - - -#define SWIGVERSION 0x040000 -#define SWIG_VERSION SWIGVERSION - - -#define SWIG_as_voidptr(a) (void *)((const void *)(a)) -#define SWIG_as_voidptrptr(a) ((void)SWIG_as_voidptr(*a),(void**)(a)) - - -#include "sundials/sundials_adaptcontroller.h" - - -#include "sunadaptcontroller/sunadaptcontroller_pid.h" - -SWIGEXPORT SUNAdaptController _wrap_FSUNAdaptController_PID(void *farg1) { - SUNAdaptController fresult ; - SUNContext arg1 = (SUNContext) 0 ; - SUNAdaptController result; - - arg1 = (SUNContext)(farg1); - result = (SUNAdaptController)SUNAdaptController_PID(arg1); - fresult = result; - return fresult; -} - - -SWIGEXPORT int _wrap_FSUNAdaptController_SetParams_PID(SUNAdaptController farg1, double const *farg2, double const *farg3, double const *farg4) { - int fresult ; - SUNAdaptController arg1 = (SUNAdaptController) 0 ; - sunrealtype arg2 ; - sunrealtype arg3 ; - sunrealtype arg4 ; - int result; - - arg1 = (SUNAdaptController)(farg1); - arg2 = (sunrealtype)(*farg2); - arg3 = (sunrealtype)(*farg3); - arg4 = (sunrealtype)(*farg4); - result = (int)SUNAdaptController_SetParams_PID(arg1,arg2,arg3,arg4); - fresult = (int)(result); - return fresult; -} - - -SWIGEXPORT int _wrap_FSUNAdaptController_GetType_PID(SUNAdaptController farg1) { - int fresult ; - SUNAdaptController arg1 = (SUNAdaptController) 0 ; - SUNAdaptController_Type result; - - arg1 = (SUNAdaptController)(farg1); - result = (SUNAdaptController_Type)SUNAdaptController_GetType_PID(arg1); - fresult = (int)(result); - return fresult; -} - - -SWIGEXPORT int _wrap_FSUNAdaptController_EstimateStep_PID(SUNAdaptController farg1, double const *farg2, int const *farg3, double const *farg4, double *farg5) { - int fresult ; - SUNAdaptController arg1 = (SUNAdaptController) 0 ; - sunrealtype arg2 ; - int arg3 ; - sunrealtype arg4 ; - sunrealtype *arg5 = (sunrealtype *) 0 ; - int result; - - arg1 = (SUNAdaptController)(farg1); - arg2 = (sunrealtype)(*farg2); - arg3 = (int)(*farg3); - arg4 = (sunrealtype)(*farg4); - arg5 = (sunrealtype *)(farg5); - result = (int)SUNAdaptController_EstimateStep_PID(arg1,arg2,arg3,arg4,arg5); - fresult = (int)(result); - return fresult; -} - - -SWIGEXPORT int _wrap_FSUNAdaptController_Reset_PID(SUNAdaptController farg1) { - int fresult ; - SUNAdaptController arg1 = (SUNAdaptController) 0 ; - int result; - - arg1 = (SUNAdaptController)(farg1); - result = (int)SUNAdaptController_Reset_PID(arg1); - fresult = (int)(result); - return fresult; -} - - -SWIGEXPORT int _wrap_FSUNAdaptController_SetDefaults_PID(SUNAdaptController farg1) { - int fresult ; - SUNAdaptController arg1 = (SUNAdaptController) 0 ; - int result; - - arg1 = (SUNAdaptController)(farg1); - result = (int)SUNAdaptController_SetDefaults_PID(arg1); - fresult = (int)(result); - return fresult; -} - - -SWIGEXPORT int _wrap_FSUNAdaptController_Write_PID(SUNAdaptController farg1, void *farg2) { - int fresult ; - SUNAdaptController arg1 = (SUNAdaptController) 0 ; - FILE *arg2 = (FILE *) 0 ; - int result; - - arg1 = (SUNAdaptController)(farg1); - arg2 = (FILE *)(farg2); - result = (int)SUNAdaptController_Write_PID(arg1,arg2); - fresult = (int)(result); - return fresult; -} - - -SWIGEXPORT int _wrap_FSUNAdaptController_SetErrorBias_PID(SUNAdaptController farg1, double const *farg2) { - int fresult ; - SUNAdaptController arg1 = (SUNAdaptController) 0 ; - sunrealtype arg2 ; - int result; - - arg1 = (SUNAdaptController)(farg1); - arg2 = (sunrealtype)(*farg2); - result = (int)SUNAdaptController_SetErrorBias_PID(arg1,arg2); - fresult = (int)(result); - return fresult; -} - - -SWIGEXPORT int _wrap_FSUNAdaptController_Update_PID(SUNAdaptController farg1, double const *farg2, double const *farg3) { - int fresult ; - SUNAdaptController arg1 = (SUNAdaptController) 0 ; - sunrealtype arg2 ; - sunrealtype arg3 ; - int result; - - arg1 = (SUNAdaptController)(farg1); - arg2 = (sunrealtype)(*farg2); - arg3 = (sunrealtype)(*farg3); - result = (int)SUNAdaptController_Update_PID(arg1,arg2,arg3); - fresult = (int)(result); - return fresult; -} - - -SWIGEXPORT int _wrap_FSUNAdaptController_Space_PID(SUNAdaptController farg1, long *farg2, long *farg3) { - int fresult ; - SUNAdaptController arg1 = (SUNAdaptController) 0 ; - long *arg2 = (long *) 0 ; - long *arg3 = (long *) 0 ; - int result; - - arg1 = (SUNAdaptController)(farg1); - arg2 = (long *)(farg2); - arg3 = (long *)(farg3); - result = (int)SUNAdaptController_Space_PID(arg1,arg2,arg3); - fresult = (int)(result); - return fresult; -} - - - diff --git a/src/sunadaptcontroller/pid/fmod/fsunadaptcontroller_pid_mod.f90 b/src/sunadaptcontroller/pid/fmod/fsunadaptcontroller_pid_mod.f90 deleted file mode 100644 index 6cda933b5f..0000000000 --- a/src/sunadaptcontroller/pid/fmod/fsunadaptcontroller_pid_mod.f90 +++ /dev/null @@ -1,311 +0,0 @@ -! This file was automatically generated by SWIG (http://www.swig.org). -! Version 4.0.0 -! -! Do not make changes to this file unless you know what you are doing--modify -! the SWIG interface file instead. - -! --------------------------------------------------------------- -! Programmer(s): Auto-generated by swig. -! --------------------------------------------------------------- -! SUNDIALS Copyright Start -! Copyright (c) 2002-2023, 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 -! --------------------------------------------------------------- - -module fsunadaptcontroller_pid_mod - use, intrinsic :: ISO_C_BINDING - use fsundials_adaptcontroller_mod - use fsundials_types_mod - use fsundials_context_mod - implicit none - private - - ! DECLARATION CONSTRUCTS - public :: FSUNAdaptController_PID - public :: FSUNAdaptController_SetParams_PID - public :: FSUNAdaptController_GetType_PID - public :: FSUNAdaptController_EstimateStep_PID - public :: FSUNAdaptController_Reset_PID - public :: FSUNAdaptController_SetDefaults_PID - public :: FSUNAdaptController_Write_PID - public :: FSUNAdaptController_SetErrorBias_PID - public :: FSUNAdaptController_Update_PID - public :: FSUNAdaptController_Space_PID - -! WRAPPER DECLARATIONS -interface -function swigc_FSUNAdaptController_PID(farg1) & -bind(C, name="_wrap_FSUNAdaptController_PID") & -result(fresult) -use, intrinsic :: ISO_C_BINDING -type(C_PTR), value :: farg1 -type(C_PTR) :: fresult -end function - -function swigc_FSUNAdaptController_SetParams_PID(farg1, farg2, farg3, farg4) & -bind(C, name="_wrap_FSUNAdaptController_SetParams_PID") & -result(fresult) -use, intrinsic :: ISO_C_BINDING -type(C_PTR), value :: farg1 -real(C_DOUBLE), intent(in) :: farg2 -real(C_DOUBLE), intent(in) :: farg3 -real(C_DOUBLE), intent(in) :: farg4 -integer(C_INT) :: fresult -end function - -function swigc_FSUNAdaptController_GetType_PID(farg1) & -bind(C, name="_wrap_FSUNAdaptController_GetType_PID") & -result(fresult) -use, intrinsic :: ISO_C_BINDING -type(C_PTR), value :: farg1 -integer(C_INT) :: fresult -end function - -function swigc_FSUNAdaptController_EstimateStep_PID(farg1, farg2, farg3, farg4, farg5) & -bind(C, name="_wrap_FSUNAdaptController_EstimateStep_PID") & -result(fresult) -use, intrinsic :: ISO_C_BINDING -type(C_PTR), value :: farg1 -real(C_DOUBLE), intent(in) :: farg2 -integer(C_INT), intent(in) :: farg3 -real(C_DOUBLE), intent(in) :: farg4 -type(C_PTR), value :: farg5 -integer(C_INT) :: fresult -end function - -function swigc_FSUNAdaptController_Reset_PID(farg1) & -bind(C, name="_wrap_FSUNAdaptController_Reset_PID") & -result(fresult) -use, intrinsic :: ISO_C_BINDING -type(C_PTR), value :: farg1 -integer(C_INT) :: fresult -end function - -function swigc_FSUNAdaptController_SetDefaults_PID(farg1) & -bind(C, name="_wrap_FSUNAdaptController_SetDefaults_PID") & -result(fresult) -use, intrinsic :: ISO_C_BINDING -type(C_PTR), value :: farg1 -integer(C_INT) :: fresult -end function - -function swigc_FSUNAdaptController_Write_PID(farg1, farg2) & -bind(C, name="_wrap_FSUNAdaptController_Write_PID") & -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_FSUNAdaptController_SetErrorBias_PID(farg1, farg2) & -bind(C, name="_wrap_FSUNAdaptController_SetErrorBias_PID") & -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_FSUNAdaptController_Update_PID(farg1, farg2, farg3) & -bind(C, name="_wrap_FSUNAdaptController_Update_PID") & -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_FSUNAdaptController_Space_PID(farg1, farg2, farg3) & -bind(C, name="_wrap_FSUNAdaptController_Space_PID") & -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 - -end interface - - -contains - ! MODULE SUBPROGRAMS -function FSUNAdaptController_PID(sunctx) & -result(swig_result) -use, intrinsic :: ISO_C_BINDING -type(SUNAdaptController), pointer :: swig_result -type(C_PTR) :: sunctx -type(C_PTR) :: fresult -type(C_PTR) :: farg1 - -farg1 = sunctx -fresult = swigc_FSUNAdaptController_PID(farg1) -call c_f_pointer(fresult, swig_result) -end function - -function FSUNAdaptController_SetParams_PID(c, k1, k2, k3) & -result(swig_result) -use, intrinsic :: ISO_C_BINDING -integer(C_INT) :: swig_result -type(SUNAdaptController), target, intent(inout) :: c -real(C_DOUBLE), intent(in) :: k1 -real(C_DOUBLE), intent(in) :: k2 -real(C_DOUBLE), intent(in) :: k3 -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -real(C_DOUBLE) :: farg2 -real(C_DOUBLE) :: farg3 -real(C_DOUBLE) :: farg4 - -farg1 = c_loc(c) -farg2 = k1 -farg3 = k2 -farg4 = k3 -fresult = swigc_FSUNAdaptController_SetParams_PID(farg1, farg2, farg3, farg4) -swig_result = fresult -end function - -function FSUNAdaptController_GetType_PID(c) & -result(swig_result) -use, intrinsic :: ISO_C_BINDING -integer(SUNAdaptController_Type) :: swig_result -type(SUNAdaptController), target, intent(inout) :: c -integer(C_INT) :: fresult -type(C_PTR) :: farg1 - -farg1 = c_loc(c) -fresult = swigc_FSUNAdaptController_GetType_PID(farg1) -swig_result = fresult -end function - -function FSUNAdaptController_EstimateStep_PID(c, h, p, dsm, hnew) & -result(swig_result) -use, intrinsic :: ISO_C_BINDING -integer(C_INT) :: swig_result -type(SUNAdaptController), target, intent(inout) :: c -real(C_DOUBLE), intent(in) :: h -integer(C_INT), intent(in) :: p -real(C_DOUBLE), intent(in) :: dsm -real(C_DOUBLE), target, intent(inout) :: hnew -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -real(C_DOUBLE) :: farg2 -integer(C_INT) :: farg3 -real(C_DOUBLE) :: farg4 -type(C_PTR) :: farg5 - -farg1 = c_loc(c) -farg2 = h -farg3 = p -farg4 = dsm -farg5 = c_loc(hnew) -fresult = swigc_FSUNAdaptController_EstimateStep_PID(farg1, farg2, farg3, farg4, farg5) -swig_result = fresult -end function - -function FSUNAdaptController_Reset_PID(c) & -result(swig_result) -use, intrinsic :: ISO_C_BINDING -integer(C_INT) :: swig_result -type(SUNAdaptController), target, intent(inout) :: c -integer(C_INT) :: fresult -type(C_PTR) :: farg1 - -farg1 = c_loc(c) -fresult = swigc_FSUNAdaptController_Reset_PID(farg1) -swig_result = fresult -end function - -function FSUNAdaptController_SetDefaults_PID(c) & -result(swig_result) -use, intrinsic :: ISO_C_BINDING -integer(C_INT) :: swig_result -type(SUNAdaptController), target, intent(inout) :: c -integer(C_INT) :: fresult -type(C_PTR) :: farg1 - -farg1 = c_loc(c) -fresult = swigc_FSUNAdaptController_SetDefaults_PID(farg1) -swig_result = fresult -end function - -function FSUNAdaptController_Write_PID(c, fptr) & -result(swig_result) -use, intrinsic :: ISO_C_BINDING -integer(C_INT) :: swig_result -type(SUNAdaptController), target, intent(inout) :: c -type(C_PTR) :: fptr -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 - -farg1 = c_loc(c) -farg2 = fptr -fresult = swigc_FSUNAdaptController_Write_PID(farg1, farg2) -swig_result = fresult -end function - -function FSUNAdaptController_SetErrorBias_PID(c, bias) & -result(swig_result) -use, intrinsic :: ISO_C_BINDING -integer(C_INT) :: swig_result -type(SUNAdaptController), target, intent(inout) :: c -real(C_DOUBLE), intent(in) :: bias -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -real(C_DOUBLE) :: farg2 - -farg1 = c_loc(c) -farg2 = bias -fresult = swigc_FSUNAdaptController_SetErrorBias_PID(farg1, farg2) -swig_result = fresult -end function - -function FSUNAdaptController_Update_PID(c, h, dsm) & -result(swig_result) -use, intrinsic :: ISO_C_BINDING -integer(C_INT) :: swig_result -type(SUNAdaptController), target, intent(inout) :: c -real(C_DOUBLE), intent(in) :: h -real(C_DOUBLE), intent(in) :: dsm -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -real(C_DOUBLE) :: farg2 -real(C_DOUBLE) :: farg3 - -farg1 = c_loc(c) -farg2 = h -farg3 = dsm -fresult = swigc_FSUNAdaptController_Update_PID(farg1, farg2, farg3) -swig_result = fresult -end function - -function FSUNAdaptController_Space_PID(c, lenrw, leniw) & -result(swig_result) -use, intrinsic :: ISO_C_BINDING -integer(C_INT) :: swig_result -type(SUNAdaptController), target, intent(inout) :: c -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 = c_loc(c) -farg2 = c_loc(lenrw(1)) -farg3 = c_loc(leniw(1)) -fresult = swigc_FSUNAdaptController_Space_PID(farg1, farg2, farg3) -swig_result = fresult -end function - - -end module diff --git a/src/sunadaptcontroller/pid/sunadaptcontroller_pid.c b/src/sunadaptcontroller/pid/sunadaptcontroller_pid.c deleted file mode 100644 index 229b04a6d8..0000000000 --- a/src/sunadaptcontroller/pid/sunadaptcontroller_pid.c +++ /dev/null @@ -1,192 +0,0 @@ -/* ----------------------------------------------------------------- - * Programmer(s): Daniel R. Reynolds @ SMU - * ----------------------------------------------------------------- - * SUNDIALS Copyright Start - * Copyright (c) 2002-2023, Lawrence Livermore National Security - * and Southern Methodist University. - * All rights reserved. - * - * See the top-level LICENSE and NOTICE files for details. - * - * SPDX-License-Identifier: BSD-3-Clause - * SUNDIALS Copyright End - * ----------------------------------------------------------------- - * This is the implementation file for the SUNAdaptController_PID - * module. - * -----------------------------------------------------------------*/ - -#include -#include -#include -#include - - -/* --------------- - * Macro accessors - * --------------- */ - -#define SACPID_CONTENT(C) ( (SUNAdaptControllerContent_PID)(C->content) ) -#define SACPID_K1(C) ( SACPID_CONTENT(C)->k1 ) -#define SACPID_K2(C) ( SACPID_CONTENT(C)->k2 ) -#define SACPID_K3(C) ( SACPID_CONTENT(C)->k3 ) -#define SACPID_BIAS(C) ( SACPID_CONTENT(C)->bias ) -#define SACPID_EP(C) ( SACPID_CONTENT(C)->ep ) -#define SACPID_EPP(C) ( SACPID_CONTENT(C)->epp ) - -/* ------------------ - * Default parameters - * ------------------ */ - -#define DEFAULT_K1 RCONST(0.58) -#define DEFAULT_K2 RCONST(0.21) -#define DEFAULT_K3 RCONST(0.1) -#define DEFAULT_BIAS RCONST(1.5) -#define TINY RCONST(1.0e-10) - - -/* ----------------------------------------------------------------- - * exported functions - * ----------------------------------------------------------------- */ - -/* ----------------------------------------------------------------- - * Function to create a new PID controller - */ - -SUNAdaptController SUNAdaptController_PID(SUNContext sunctx) -{ - SUNAdaptController C; - SUNAdaptControllerContent_PID content; - - /* Create an empty controller object */ - C = NULL; - C = SUNAdaptController_NewEmpty(sunctx); - if (C == NULL) { return (NULL); } - - /* Attach operations */ - C->ops->gettype = SUNAdaptController_GetType_PID; - C->ops->estimatestep = SUNAdaptController_EstimateStep_PID; - C->ops->reset = SUNAdaptController_Reset_PID; - C->ops->setdefaults = SUNAdaptController_SetDefaults_PID; - C->ops->write = SUNAdaptController_Write_PID; - C->ops->seterrorbias = SUNAdaptController_SetErrorBias_PID; - C->ops->update = SUNAdaptController_Update_PID; - C->ops->space = SUNAdaptController_Space_PID; - - /* Create content */ - content = NULL; - content = (SUNAdaptControllerContent_PID)malloc(sizeof *content); - if (content == NULL) - { - (void) SUNAdaptController_Destroy(C); - return (NULL); - } - - /* Attach content */ - C->content = content; - - /* Fill content with default/reset values */ - SUNAdaptController_SetDefaults_PID(C); - SUNAdaptController_Reset_PID(C); - - return (C); -} - -/* ----------------------------------------------------------------- - * Function to set PID parameters - */ - -int SUNAdaptController_SetParams_PID(SUNAdaptController C, sunrealtype k1, - sunrealtype k2, sunrealtype k3) -{ - SACPID_K1(C) = k1; - SACPID_K2(C) = k2; - SACPID_K3(C) = k3; - return SUNADAPTCONTROLLER_SUCCESS; -} - - -/* ----------------------------------------------------------------- - * implementation of controller operations - * ----------------------------------------------------------------- */ - -SUNAdaptController_Type SUNAdaptController_GetType_PID(SUNAdaptController C) -{ return SUN_ADAPTCONTROLLER_H; } - -int SUNAdaptController_EstimateStep_PID(SUNAdaptController C, sunrealtype h, - int p, sunrealtype dsm, sunrealtype* hnew) -{ - /* set usable time-step adaptivity parameters */ - const int ord = p + 1; - const sunrealtype k1 = -SACPID_K1(C) / ord; - const sunrealtype k2 = SACPID_K2(C) / ord; - const sunrealtype k3 = -SACPID_K3(C) / ord; - const sunrealtype ecur = SACPID_BIAS(C) * dsm; - const sunrealtype e1 = SUNMAX(ecur, TINY); - const sunrealtype e2 = SUNMAX(SACPID_EP(C), TINY); - const sunrealtype e3 = SUNMAX(SACPID_EPP(C), TINY); - - /* compute estimated optimal time step size and return with success */ - *hnew = h * SUNRpowerR(e1,k1) * SUNRpowerR(e2,k2) * SUNRpowerR(e3,k3); - return SUNADAPTCONTROLLER_SUCCESS; -} - -int SUNAdaptController_Reset_PID(SUNAdaptController C) -{ - SACPID_EP(C) = RCONST(1.0); - SACPID_EPP(C) = RCONST(1.0); - return SUNADAPTCONTROLLER_SUCCESS; -} - -int SUNAdaptController_SetDefaults_PID(SUNAdaptController C) -{ - SACPID_K1(C) = DEFAULT_K1; - SACPID_K2(C) = DEFAULT_K2; - SACPID_K3(C) = DEFAULT_K3; - SACPID_BIAS(C) = DEFAULT_BIAS; - return SUNADAPTCONTROLLER_SUCCESS; -} - -int SUNAdaptController_Write_PID(SUNAdaptController C, FILE *fptr) -{ - fprintf(fptr, "PID SUNAdaptController module:\n"); -#if defined(SUNDIALS_EXTENDED_PRECISION) - fprintf(fptr, " k1 = %32Lg\n", SACPID_K1(C)); - fprintf(fptr, " k2 = %32Lg\n", SACPID_K2(C)); - fprintf(fptr, " k3 = %32Lg\n", SACPID_K3(C)); - fprintf(fptr, " bias factor = %32Lg\n", SACPID_BIAS(C)); - fprintf(fptr, " previous errors = %32Lg %32Lg\n", SACPID_EP(C), SACPID_EPP(C)); -#else - fprintf(fptr, " k1 = %16g\n", SACPID_K1(C)); - fprintf(fptr, " k2 = %16g\n", SACPID_K2(C)); - fprintf(fptr, " k3 = %16g\n", SACPID_K3(C)); - fprintf(fptr, " bias factor = %16g\n", SACPID_BIAS(C)); - fprintf(fptr, " previous errors = %16g %16g\n", SACPID_EP(C), SACPID_EPP(C)); -#endif - return SUNADAPTCONTROLLER_SUCCESS; -} - -int SUNAdaptController_SetErrorBias_PID(SUNAdaptController C, sunrealtype bias) -{ - /* set allowed value, otherwise set default */ - if (bias <= RCONST(0.0)) { - SACPID_BIAS(C) = DEFAULT_BIAS; - } else { - SACPID_BIAS(C) = bias; - } - - return SUNADAPTCONTROLLER_SUCCESS; -} - -int SUNAdaptController_Update_PID(SUNAdaptController C, sunrealtype h, sunrealtype dsm) -{ - SACPID_EPP(C) = SACPID_EP(C); - SACPID_EP(C) = SACPID_BIAS(C) * dsm; - return SUNADAPTCONTROLLER_SUCCESS; -} - -int SUNAdaptController_Space_PID(SUNAdaptController C, long int* lenrw, long int* leniw) -{ - *lenrw = 6; - *leniw = 1; - return SUNADAPTCONTROLLER_SUCCESS; -} diff --git a/src/sunadaptcontroller/soderlind/fmod/fsunadaptcontroller_soderlind_mod.c b/src/sunadaptcontroller/soderlind/fmod/fsunadaptcontroller_soderlind_mod.c index 4d920d36c2..89d0d4407b 100644 --- a/src/sunadaptcontroller/soderlind/fmod/fsunadaptcontroller_soderlind_mod.c +++ b/src/sunadaptcontroller/soderlind/fmod/fsunadaptcontroller_soderlind_mod.c @@ -358,4 +358,88 @@ SWIGEXPORT int _wrap_FSUNAdaptController_Space_Soderlind(SUNAdaptController farg } +SWIGEXPORT SUNAdaptController _wrap_FSUNAdaptController_PID(void *farg1) { + SUNAdaptController fresult ; + SUNContext arg1 = (SUNContext) 0 ; + SUNAdaptController result; + + arg1 = (SUNContext)(farg1); + result = (SUNAdaptController)SUNAdaptController_PID(arg1); + fresult = result; + return fresult; +} + + +SWIGEXPORT int _wrap_FSUNAdaptController_SetParams_PID(SUNAdaptController farg1, double const *farg2, double const *farg3, double const *farg4) { + int fresult ; + SUNAdaptController arg1 = (SUNAdaptController) 0 ; + sunrealtype arg2 ; + sunrealtype arg3 ; + sunrealtype arg4 ; + int result; + + arg1 = (SUNAdaptController)(farg1); + arg2 = (sunrealtype)(*farg2); + arg3 = (sunrealtype)(*farg3); + arg4 = (sunrealtype)(*farg4); + result = (int)SUNAdaptController_SetParams_PID(arg1,arg2,arg3,arg4); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT SUNAdaptController _wrap_FSUNAdaptController_PI(void *farg1) { + SUNAdaptController fresult ; + SUNContext arg1 = (SUNContext) 0 ; + SUNAdaptController result; + + arg1 = (SUNContext)(farg1); + result = (SUNAdaptController)SUNAdaptController_PI(arg1); + fresult = result; + return fresult; +} + + +SWIGEXPORT int _wrap_FSUNAdaptController_SetParams_PI(SUNAdaptController farg1, double const *farg2, double const *farg3) { + int fresult ; + SUNAdaptController arg1 = (SUNAdaptController) 0 ; + sunrealtype arg2 ; + sunrealtype arg3 ; + int result; + + arg1 = (SUNAdaptController)(farg1); + arg2 = (sunrealtype)(*farg2); + arg3 = (sunrealtype)(*farg3); + result = (int)SUNAdaptController_SetParams_PI(arg1,arg2,arg3); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT SUNAdaptController _wrap_FSUNAdaptController_I(void *farg1) { + SUNAdaptController fresult ; + SUNContext arg1 = (SUNContext) 0 ; + SUNAdaptController result; + + arg1 = (SUNContext)(farg1); + result = (SUNAdaptController)SUNAdaptController_I(arg1); + fresult = result; + return fresult; +} + + +SWIGEXPORT int _wrap_FSUNAdaptController_SetParams_I(SUNAdaptController farg1, double const *farg2) { + int fresult ; + SUNAdaptController arg1 = (SUNAdaptController) 0 ; + sunrealtype arg2 ; + int result; + + arg1 = (SUNAdaptController)(farg1); + arg2 = (sunrealtype)(*farg2); + result = (int)SUNAdaptController_SetParams_I(arg1,arg2); + fresult = (int)(result); + return fresult; +} + + diff --git a/src/sunadaptcontroller/soderlind/fmod/fsunadaptcontroller_soderlind_mod.f90 b/src/sunadaptcontroller/soderlind/fmod/fsunadaptcontroller_soderlind_mod.f90 index d9a56332cd..bfee74fdf1 100644 --- a/src/sunadaptcontroller/soderlind/fmod/fsunadaptcontroller_soderlind_mod.f90 +++ b/src/sunadaptcontroller/soderlind/fmod/fsunadaptcontroller_soderlind_mod.f90 @@ -37,6 +37,12 @@ module fsunadaptcontroller_soderlind_mod public :: FSUNAdaptController_SetErrorBias_Soderlind public :: FSUNAdaptController_Update_Soderlind public :: FSUNAdaptController_Space_Soderlind + public :: FSUNAdaptController_PID + public :: FSUNAdaptController_SetParams_PID + public :: FSUNAdaptController_PI + public :: FSUNAdaptController_SetParams_PI + public :: FSUNAdaptController_I + public :: FSUNAdaptController_SetParams_I ! WRAPPER DECLARATIONS interface @@ -135,6 +141,60 @@ function swigc_FSUNAdaptController_Space_Soderlind(farg1, farg2, farg3) & integer(C_INT) :: fresult end function +function swigc_FSUNAdaptController_PID(farg1) & +bind(C, name="_wrap_FSUNAdaptController_PID") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +type(C_PTR), value :: farg1 +type(C_PTR) :: fresult +end function + +function swigc_FSUNAdaptController_SetParams_PID(farg1, farg2, farg3, farg4) & +bind(C, name="_wrap_FSUNAdaptController_SetParams_PID") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +type(C_PTR), value :: farg1 +real(C_DOUBLE), intent(in) :: farg2 +real(C_DOUBLE), intent(in) :: farg3 +real(C_DOUBLE), intent(in) :: farg4 +integer(C_INT) :: fresult +end function + +function swigc_FSUNAdaptController_PI(farg1) & +bind(C, name="_wrap_FSUNAdaptController_PI") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +type(C_PTR), value :: farg1 +type(C_PTR) :: fresult +end function + +function swigc_FSUNAdaptController_SetParams_PI(farg1, farg2, farg3) & +bind(C, name="_wrap_FSUNAdaptController_SetParams_PI") & +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_FSUNAdaptController_I(farg1) & +bind(C, name="_wrap_FSUNAdaptController_I") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +type(C_PTR), value :: farg1 +type(C_PTR) :: fresult +end function + +function swigc_FSUNAdaptController_SetParams_I(farg1, farg2) & +bind(C, name="_wrap_FSUNAdaptController_SetParams_I") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +type(C_PTR), value :: farg1 +real(C_DOUBLE), intent(in) :: farg2 +integer(C_INT) :: fresult +end function + end interface @@ -315,5 +375,101 @@ function FSUNAdaptController_Space_Soderlind(c, lenrw, leniw) & swig_result = fresult end function +function FSUNAdaptController_PID(sunctx) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +type(SUNAdaptController), pointer :: swig_result +type(C_PTR) :: sunctx +type(C_PTR) :: fresult +type(C_PTR) :: farg1 + +farg1 = sunctx +fresult = swigc_FSUNAdaptController_PID(farg1) +call c_f_pointer(fresult, swig_result) +end function + +function FSUNAdaptController_SetParams_PID(c, k1, k2, k3) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(SUNAdaptController), target, intent(inout) :: c +real(C_DOUBLE), intent(in) :: k1 +real(C_DOUBLE), intent(in) :: k2 +real(C_DOUBLE), intent(in) :: k3 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +real(C_DOUBLE) :: farg2 +real(C_DOUBLE) :: farg3 +real(C_DOUBLE) :: farg4 + +farg1 = c_loc(c) +farg2 = k1 +farg3 = k2 +farg4 = k3 +fresult = swigc_FSUNAdaptController_SetParams_PID(farg1, farg2, farg3, farg4) +swig_result = fresult +end function + +function FSUNAdaptController_PI(sunctx) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +type(SUNAdaptController), pointer :: swig_result +type(C_PTR) :: sunctx +type(C_PTR) :: fresult +type(C_PTR) :: farg1 + +farg1 = sunctx +fresult = swigc_FSUNAdaptController_PI(farg1) +call c_f_pointer(fresult, swig_result) +end function + +function FSUNAdaptController_SetParams_PI(c, k1, k2) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(SUNAdaptController), target, intent(inout) :: c +real(C_DOUBLE), intent(in) :: k1 +real(C_DOUBLE), intent(in) :: k2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +real(C_DOUBLE) :: farg2 +real(C_DOUBLE) :: farg3 + +farg1 = c_loc(c) +farg2 = k1 +farg3 = k2 +fresult = swigc_FSUNAdaptController_SetParams_PI(farg1, farg2, farg3) +swig_result = fresult +end function + +function FSUNAdaptController_I(sunctx) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +type(SUNAdaptController), pointer :: swig_result +type(C_PTR) :: sunctx +type(C_PTR) :: fresult +type(C_PTR) :: farg1 + +farg1 = sunctx +fresult = swigc_FSUNAdaptController_I(farg1) +call c_f_pointer(fresult, swig_result) +end function + +function FSUNAdaptController_SetParams_I(c, k1) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(SUNAdaptController), target, intent(inout) :: c +real(C_DOUBLE), intent(in) :: k1 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +real(C_DOUBLE) :: farg2 + +farg1 = c_loc(c) +farg2 = k1 +fresult = swigc_FSUNAdaptController_SetParams_I(farg1, farg2) +swig_result = fresult +end function + end module diff --git a/src/sunadaptcontroller/soderlind/sunadaptcontroller_soderlind.c b/src/sunadaptcontroller/soderlind/sunadaptcontroller_soderlind.c index d2cecf2fd6..b848d5ad1f 100644 --- a/src/sunadaptcontroller/soderlind/sunadaptcontroller_soderlind.c +++ b/src/sunadaptcontroller/soderlind/sunadaptcontroller_soderlind.c @@ -42,13 +42,19 @@ * Default parameters * ------------------ */ -#define DEFAULT_K1 RCONST(1.25) /* H_{0}321 parameters */ -#define DEFAULT_K2 RCONST(0.5) -#define DEFAULT_K3 RCONST(-0.75) -#define DEFAULT_K4 RCONST(0.25) -#define DEFAULT_K5 RCONST(0.75) -#define DEFAULT_BIAS RCONST(1.5) -#define TINY RCONST(1.0e-10) +#define DEFAULT_K1 RCONST(1.25) /* H_{0}321 parameters */ +#define DEFAULT_K2 RCONST(0.5) +#define DEFAULT_K3 RCONST(-0.75) +#define DEFAULT_K4 RCONST(0.25) +#define DEFAULT_K5 RCONST(0.75) +#define DEFAULT_PID_K1 RCONST(0.58) /* PID parameters */ +#define DEFAULT_PID_K2 -RCONST(0.21) +#define DEFAULT_PID_K3 RCONST(0.1) +#define DEFAULT_PI_K1 RCONST(0.8) /* PI parameters */ +#define DEFAULT_PI_K2 -RCONST(0.31) +#define DEFAULT_I_K1 RCONST(1.0) +#define DEFAULT_BIAS RCONST(1.5) /* I parameter */ +#define TINY RCONST(1.0e-10) /* ----------------------------------------------------------------- @@ -70,14 +76,14 @@ SUNAdaptController SUNAdaptController_Soderlind(SUNContext sunctx) if (C == NULL) { return (NULL); } /* Attach operations */ - C->ops->gettype = SUNAdaptController_GetType_Soderlind; - C->ops->estimatestep = SUNAdaptController_EstimateStep_Soderlind; - C->ops->reset = SUNAdaptController_Reset_Soderlind; - C->ops->setdefaults = SUNAdaptController_SetDefaults_Soderlind; - C->ops->write = SUNAdaptController_Write_Soderlind; - C->ops->seterrorbias = SUNAdaptController_SetErrorBias_Soderlind; - C->ops->update = SUNAdaptController_Update_Soderlind; - C->ops->space = SUNAdaptController_Space_Soderlind; + C->ops->gettype = SUNAdaptController_GetType_Soderlind; + C->ops->estimatestep = SUNAdaptController_EstimateStep_Soderlind; + C->ops->reset = SUNAdaptController_Reset_Soderlind; + C->ops->setdefaults = SUNAdaptController_SetDefaults_Soderlind; + C->ops->write = SUNAdaptController_Write_Soderlind; + C->ops->seterrorbias = SUNAdaptController_SetErrorBias_Soderlind; + C->ops->update = SUNAdaptController_Update_Soderlind; + C->ops->space = SUNAdaptController_Space_Soderlind; /* Create content */ content = NULL; @@ -115,6 +121,92 @@ int SUNAdaptController_SetParams_Soderlind(SUNAdaptController C, return SUNADAPTCONTROLLER_SUCCESS; } +/* ----------------------------------------------------------------- + * Function to create a PID controller (subset of Soderlind) + */ + +SUNAdaptController SUNAdaptController_PID(SUNContext sunctx) +{ + SUNAdaptController C; + C = SUNAdaptController_Soderlind(sunctx); + (void) SUNAdaptController_SetParams_PID(C, + DEFAULT_PID_K1, + DEFAULT_PID_K2, + DEFAULT_PID_K3); + return (C); +} + +/* ----------------------------------------------------------------- + * Function to set PID parameters + */ + +int SUNAdaptController_SetParams_PID(SUNAdaptController C, + sunrealtype k1, sunrealtype k2, + sunrealtype k3) +{ + SODERLIND_K1(C) = k1; + SODERLIND_K2(C) = k2; + SODERLIND_K3(C) = k3; + SODERLIND_K4(C) = RCONST(0.0); + SODERLIND_K5(C) = RCONST(0.0); + return SUNADAPTCONTROLLER_SUCCESS; +} + +/* ----------------------------------------------------------------- + * Function to create a PI controller (subset of Soderlind) + */ + +SUNAdaptController SUNAdaptController_PI(SUNContext sunctx) +{ + SUNAdaptController C; + C = SUNAdaptController_Soderlind(sunctx); + (void) SUNAdaptController_SetParams_PI(C, + DEFAULT_PI_K1, + DEFAULT_PI_K2); + return (C); +} + +/* ----------------------------------------------------------------- + * Function to set PI parameters + */ + +int SUNAdaptController_SetParams_PI(SUNAdaptController C, + sunrealtype k1, sunrealtype k2) +{ + SODERLIND_K1(C) = k1; + SODERLIND_K2(C) = k2; + SODERLIND_K3(C) = RCONST(0.0); + SODERLIND_K4(C) = RCONST(0.0); + SODERLIND_K5(C) = RCONST(0.0); + return SUNADAPTCONTROLLER_SUCCESS; +} + +/* ----------------------------------------------------------------- + * Function to create an I controller (subset of Soderlind) + */ + +SUNAdaptController SUNAdaptController_I(SUNContext sunctx) +{ + SUNAdaptController C; + C = SUNAdaptController_Soderlind(sunctx); + (void) SUNAdaptController_SetParams_I(C, DEFAULT_I_K1); + return (C); +} + +/* ----------------------------------------------------------------- + * Function to set PI parameters + */ + +int SUNAdaptController_SetParams_I(SUNAdaptController C, sunrealtype k1) +{ + SODERLIND_K1(C) = k1; + SODERLIND_K2(C) = RCONST(0.0); + SODERLIND_K3(C) = RCONST(0.0); + SODERLIND_K4(C) = RCONST(0.0); + SODERLIND_K5(C) = RCONST(0.0); + return SUNADAPTCONTROLLER_SUCCESS; +} + /* ----------------------------------------------------------------- diff --git a/swig/Makefile b/swig/Makefile index ebf7e30189..0451c69d25 100644 --- a/swig/Makefile +++ b/swig/Makefile @@ -25,7 +25,7 @@ NVECTOR=openmp pthreads serial parallel manyvector mpiplusx SUNMATRIX=band dense sparse SUNLINSOL=band dense klu spbcgs spfgmr spgmr sptfqmr pcg SUNNONLINSOL=newton fixedpoint -SUNADAPTCONTROLLER=expgus imexgus i impgus noop pid pi soderlind +SUNADAPTCONTROLLER=expgus imexgus impgus noop soderlind INCLUDES=-I../include diff --git a/swig/sunadaptcontroller/fsunadaptcontroller_i_mod.i b/swig/sunadaptcontroller/fsunadaptcontroller_i_mod.i deleted file mode 100644 index 25e4a61797..0000000000 --- a/swig/sunadaptcontroller/fsunadaptcontroller_i_mod.i +++ /dev/null @@ -1,29 +0,0 @@ -// --------------------------------------------------------------- -// Programmer: Daniel R. Reynolds @ SMU -// --------------------------------------------------------------- -// SUNDIALS Copyright Start -// Copyright (c) 2002-2023, 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 -// --------------------------------------------------------------- -// Swig interface file -// --------------------------------------------------------------- - -%module fsunadaptcontroller_i_mod - -// include code common to all implementations -%include "fsunadaptcontroller.i" - -%{ -#include "sunadaptcontroller/sunadaptcontroller_i.h" -%} - -%sunadaptcontroller_impl(I) - -// Process and wrap functions in the following files -%include "sunadaptcontroller/sunadaptcontroller_i.h" diff --git a/swig/sunadaptcontroller/fsunadaptcontroller_pi_mod.i b/swig/sunadaptcontroller/fsunadaptcontroller_pi_mod.i deleted file mode 100644 index e715b80356..0000000000 --- a/swig/sunadaptcontroller/fsunadaptcontroller_pi_mod.i +++ /dev/null @@ -1,29 +0,0 @@ -// --------------------------------------------------------------- -// Programmer: Daniel R. Reynolds @ SMU -// --------------------------------------------------------------- -// SUNDIALS Copyright Start -// Copyright (c) 2002-2023, 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 -// --------------------------------------------------------------- -// Swig interface file -// --------------------------------------------------------------- - -%module fsunadaptcontroller_pi_mod - -// include code common to all implementations -%include "fsunadaptcontroller.i" - -%{ -#include "sunadaptcontroller/sunadaptcontroller_pi.h" -%} - -%sunadaptcontroller_impl(PI) - -// Process and wrap functions in the following files -%include "sunadaptcontroller/sunadaptcontroller_pi.h" diff --git a/swig/sunadaptcontroller/fsunadaptcontroller_pid_mod.i b/swig/sunadaptcontroller/fsunadaptcontroller_pid_mod.i deleted file mode 100644 index 67e04144e2..0000000000 --- a/swig/sunadaptcontroller/fsunadaptcontroller_pid_mod.i +++ /dev/null @@ -1,29 +0,0 @@ -// --------------------------------------------------------------- -// Programmer: Daniel R. Reynolds @ SMU -// --------------------------------------------------------------- -// SUNDIALS Copyright Start -// Copyright (c) 2002-2023, 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 -// --------------------------------------------------------------- -// Swig interface file -// --------------------------------------------------------------- - -%module fsunadaptcontroller_pid_mod - -// include code common to all implementations -%include "fsunadaptcontroller.i" - -%{ -#include "sunadaptcontroller/sunadaptcontroller_pid.h" -%} - -%sunadaptcontroller_impl(PID) - -// Process and wrap functions in the following files -%include "sunadaptcontroller/sunadaptcontroller_pid.h" From 2fca7951cead3875b4e09f3cef308bb744f371ad Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Tue, 24 Oct 2023 09:50:54 -0500 Subject: [PATCH 15/58] Fixed CMakeLists.txt for removed SUNAdaptController modules --- src/arkode/fmod/CMakeLists.txt | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/arkode/fmod/CMakeLists.txt b/src/arkode/fmod/CMakeLists.txt index ffc8784929..6de617454a 100644 --- a/src/arkode/fmod/CMakeLists.txt +++ b/src/arkode/fmod/CMakeLists.txt @@ -33,12 +33,10 @@ sundials_add_f2003_library(sundials_farkode_mod OBJECT_LIBRARIES sundials_fgeneric_mod_obj sundials_fnvecserial_mod_obj + sundials_fsunadaptcontrollersoderlind_mod_obj sundials_fsunadaptcontrollerexpgus_mod_obj - sundials_fsunadaptcontrolleri_mod_obj sundials_fsunadaptcontrollerimexgus_mod_obj sundials_fsunadaptcontrollerimpgus_mod_obj - sundials_fsunadaptcontrollerpi_mod_obj - sundials_fsunadaptcontrollerpid_mod_obj sundials_fsunmatrixband_mod_obj sundials_fsunmatrixdense_mod_obj sundials_fsunmatrixsparse_mod_obj From 791170f0cb2283a9536403490b892719ea088778 Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Tue, 24 Oct 2023 10:16:30 -0500 Subject: [PATCH 16/58] Fixed unused variable error --- src/arkode/arkode_io.c | 1 - 1 file changed, 1 deletion(-) diff --git a/src/arkode/arkode_io.c b/src/arkode/arkode_io.c index 2aa24f646b..cb2f41b577 100644 --- a/src/arkode/arkode_io.c +++ b/src/arkode/arkode_io.c @@ -49,7 +49,6 @@ int arkSetDefaults(void *arkode_mem) { ARKodeMem ark_mem; - int retval; if (arkode_mem==NULL) { arkProcessError(NULL, ARK_MEM_NULL, "ARKODE", "arkSetDefaults", MSG_ARK_NO_MEM); From 833ef70a32304fab8c435e229e4e81d47eef9c9c Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Wed, 25 Oct 2023 18:12:46 -0500 Subject: [PATCH 17/58] Removed ExpGus and ImpGus SUNAdaptController implementations, absorbing them into the Soderlind controller --- .../SUNAdaptController_links.rst | 2 - .../SUNAdaptController_ExpGus.rst | 98 ----- .../SUNAdaptController_ImpGus.rst | 106 ------ .../SUNAdaptController_Soderlind.rst | 91 ++++- .../SUNAdaptController_links.rst | 2 - .../F2003_serial/ark_analytic_f2003.f90 | 2 +- .../F2003_serial/ark_analytic_f2003.out | 16 +- include/arkode/arkode_arkstep.h | 2 - include/arkode/arkode_erkstep.h | 2 - .../sunadaptcontroller_expgus.h | 73 ---- .../sunadaptcontroller_impgus.h | 74 ---- .../sunadaptcontroller_soderlind.h | 12 + src/arkode/CMakeLists.txt | 2 - src/arkode/arkode_io.c | 2 - src/arkode/fmod/CMakeLists.txt | 2 - src/sunadaptcontroller/CMakeLists.txt | 2 - src/sunadaptcontroller/expgus/CMakeLists.txt | 29 -- .../expgus/fmod/CMakeLists.txt | 25 -- .../fmod/fsunadaptcontroller_expgus_mod.c | 355 ------------------ .../fmod/fsunadaptcontroller_expgus_mod.f90 | 307 --------------- .../expgus/sunadaptcontroller_expgus.c | 202 ---------- src/sunadaptcontroller/impgus/CMakeLists.txt | 29 -- .../impgus/fmod/CMakeLists.txt | 25 -- .../fmod/fsunadaptcontroller_impgus_mod.c | 355 ------------------ .../fmod/fsunadaptcontroller_impgus_mod.f90 | 307 --------------- .../impgus/sunadaptcontroller_impgus.c | 207 ---------- .../fmod/fsunadaptcontroller_soderlind_mod.c | 56 +++ .../fsunadaptcontroller_soderlind_mod.f90 | 104 +++++ .../soderlind/sunadaptcontroller_soderlind.c | 88 ++++- swig/Makefile | 2 +- .../fsunadaptcontroller_expgus_mod.i | 29 -- .../fsunadaptcontroller_impgus_mod.i | 29 -- 32 files changed, 347 insertions(+), 2290 deletions(-) delete mode 100644 doc/shared/sunadaptcontroller/SUNAdaptController_ExpGus.rst delete mode 100644 doc/shared/sunadaptcontroller/SUNAdaptController_ImpGus.rst delete mode 100644 include/sunadaptcontroller/sunadaptcontroller_expgus.h delete mode 100644 include/sunadaptcontroller/sunadaptcontroller_impgus.h delete mode 100644 src/sunadaptcontroller/expgus/CMakeLists.txt delete mode 100644 src/sunadaptcontroller/expgus/fmod/CMakeLists.txt delete mode 100644 src/sunadaptcontroller/expgus/fmod/fsunadaptcontroller_expgus_mod.c delete mode 100644 src/sunadaptcontroller/expgus/fmod/fsunadaptcontroller_expgus_mod.f90 delete mode 100644 src/sunadaptcontroller/expgus/sunadaptcontroller_expgus.c delete mode 100644 src/sunadaptcontroller/impgus/CMakeLists.txt delete mode 100644 src/sunadaptcontroller/impgus/fmod/CMakeLists.txt delete mode 100644 src/sunadaptcontroller/impgus/fmod/fsunadaptcontroller_impgus_mod.c delete mode 100644 src/sunadaptcontroller/impgus/fmod/fsunadaptcontroller_impgus_mod.f90 delete mode 100644 src/sunadaptcontroller/impgus/sunadaptcontroller_impgus.c delete mode 100644 swig/sunadaptcontroller/fsunadaptcontroller_expgus_mod.i delete mode 100644 swig/sunadaptcontroller/fsunadaptcontroller_impgus_mod.i diff --git a/doc/arkode/guide/source/sunadaptcontroller/SUNAdaptController_links.rst b/doc/arkode/guide/source/sunadaptcontroller/SUNAdaptController_links.rst index abc5a6f308..949d84196f 100644 --- a/doc/arkode/guide/source/sunadaptcontroller/SUNAdaptController_links.rst +++ b/doc/arkode/guide/source/sunadaptcontroller/SUNAdaptController_links.rst @@ -12,6 +12,4 @@ .. include:: ../../../../shared/sunadaptcontroller/SUNAdaptController_Description.rst .. include:: ../../../../shared/sunadaptcontroller/SUNAdaptController_Soderlind.rst -.. include:: ../../../../shared/sunadaptcontroller/SUNAdaptController_ExpGus.rst -.. include:: ../../../../shared/sunadaptcontroller/SUNAdaptController_ImpGus.rst .. include:: ../../../../shared/sunadaptcontroller/SUNAdaptController_ImExGus.rst diff --git a/doc/shared/sunadaptcontroller/SUNAdaptController_ExpGus.rst b/doc/shared/sunadaptcontroller/SUNAdaptController_ExpGus.rst deleted file mode 100644 index ebb69eab41..0000000000 --- a/doc/shared/sunadaptcontroller/SUNAdaptController_ExpGus.rst +++ /dev/null @@ -1,98 +0,0 @@ -.. - Programmer(s): Daniel R. Reynolds @ SMU - ---------------------------------------------------------------- - SUNDIALS Copyright Start - Copyright (c) 2002-2023, 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 - ---------------------------------------------------------------- - -.. _SUNAdaptController.ExpGus: - -The SUNAdaptController_ExpGus Module -====================================== - -The explicit Gustafsson implementation of the SUNAdaptController class, -SUNAdaptController_ExpGus, implements a controller proposed by K. Gustafsson for -explicit Runge--Kutta methods in :cite:p:`Gust:91`. This controller has the -form - -.. math:: - h' \;=\; \begin{cases} - h_1\; \varepsilon_1^{-1/(p+1)}, &\quad\text{on the first step}, \\ - h_n\; \varepsilon_n^{-k_1/(p+1)}\; - \left(\dfrac{\varepsilon_n}{\varepsilon_{n-1}}\right)^{k_2/(p+1)}, & - \quad\text{on subsequent steps}, - \end{cases} - -with default values :math:`k_1=0.367` and :math:`k_2=0.268`, and where :math:`p` -is the global order of the time integration method. In this estimate, a floor of -:math:`\varepsilon > 10^{-10}` is enforced to avoid division-by-zero errors. - -The SUNAdaptController_ExpGus controller is implemented as a derived SUNAdaptController class, -and defines its *content* field as: - -.. code-block:: c - - struct _SUNAdaptControllerContent_ExpGus { - sunrealtype k1; - sunrealtype k2; - sunrealtype bias; - sunrealtype ep; - sunbooleantype firststep; - }; - -These entries of the *content* field contain the following information: - -* ``k1, k2`` - controller parameters above. - -* ``bias`` - error bias factor, that converts from an input temporal error - estimate via :math:`\varepsilon = \text{bias}*\text{dsm}`. - -* ``ep`` - storage for the previous error estimate, :math:`\varepsilon_{n-1}`. - -* ``firststep`` - flag indicating whether a step has successfully completed, in which - case the formula above transitions from :math:`h_1` to :math:`h_n`. - -The header file to be included when using this module is -``sunadaptcontroller/sunadaptcontroller_expgus.h``. - - -The SUNAdaptController_ExpGus class provides implementations of all operations -relevant to a `SUN_ADAPTCONTROLLER_H` controller listed in -:numref:`SUNAdaptController.Description.operations`. The -SUNAdaptController_ExpGus class also provides the following additional user-callable -routines: - - -.. c:function:: SUNAdaptController SUNAdaptController_ExpGus(SUNContext sunctx) - - This constructor function creates and allocates memory for a SUNAdaptController_ExpGus - object, and inserts its default parameters. - - :param sunctx: the current :c:type:`SUNContext` object. - :return: if successful, a usable :c:type:`SUNAdaptController` object; otherwise it will return ``NULL``. - - Usage: - - .. code-block:: c - - SUNAdaptController C = SUNAdaptController_ExpGus(sunctx); - -.. c:function:: int SUNAdaptController_SetParams_ExpGus(SUNAdaptController C, sunrealtype k1, sunrealtype k2) - - :param C: the SUNAdaptController_ExpGus object. - :param k1: parameter used within the controller time step estimate. - :param k2: parameter used within the controller time step estimate. - :return: error code indication success or failure (see :numref:`SUNAdaptController.Description.errorCodes`). - - Usage: - - .. code-block:: c - - retval = SUNAdaptController_SetParams_ExpGus(C, 0.4, 0.25); diff --git a/doc/shared/sunadaptcontroller/SUNAdaptController_ImpGus.rst b/doc/shared/sunadaptcontroller/SUNAdaptController_ImpGus.rst deleted file mode 100644 index 3e2c019dca..0000000000 --- a/doc/shared/sunadaptcontroller/SUNAdaptController_ImpGus.rst +++ /dev/null @@ -1,106 +0,0 @@ -.. - Programmer(s): Daniel R. Reynolds @ SMU - ---------------------------------------------------------------- - SUNDIALS Copyright Start - Copyright (c) 2002-2023, 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 - ---------------------------------------------------------------- - -.. _SUNAdaptController.ImpGus: - -The SUNAdaptController_ImpGus Module -====================================== - -The implicit Gustafsson implementation of the SUNAdaptController class, -SUNAdaptController_ImpGus, implements a controller proposed by K. Gustafsson for -implicit Runge--Kutta methods in :cite:p:`Gust:94`. This controller has the -form - -.. math:: - h' = \begin{cases} - h_1 \varepsilon_1^{-1/(p+1)}, &\quad\text{on the first step}, \\ - h_n \left(\dfrac{h_n}{h_{n-1}}\right) \varepsilon_n^{-k_1/(p+1)} - \left(\dfrac{\varepsilon_n}{\varepsilon_{n-1}}\right)^{-k_2/(p+1)}, & - \quad\text{on subsequent steps}, - \end{cases} - -with default parameter values :math:`k_1 = 0.98` and :math:`k_2 = 0.95`, and -:math:`p` is the global order of the time integration method. In this estimate, -a floor of :math:`\varepsilon > 10^{-10}` is enforced to avoid division-by-zero -errors. - -The SUNAdaptController_ImpGus controller is implemented as a derived SUNAdaptController class, -and defines its *content* field as: - -.. code-block:: c - - struct _SUNAdaptControllerContent_ImpGus { - sunrealtype k1; - sunrealtype k2; - sunrealtype bias; - sunrealtype ep; - sunrealtype hp; - sunbooleantype firststep; - }; - -These entries of the *content* field contain the following information: - -* ``k1, k2`` - controller parameters above. - -* ``bias`` - error bias factor, that converts from an input temporal error - estimate via :math:`\varepsilon = \text{bias}*\text{dsm}`. - -* ``ep`` - storage for the previous error estimate, :math:`\varepsilon_{n-1}`. - -* ``hp`` - storage for the previous step size, :math:`h_{n-1}`. - -* ``firststep`` - flag indicating whether any time steps have completed - successfully (and thus to transition from :math:`h_1` to :math:`h_n` in - the formula above). - -The header file to be included when using this module is -``sunadaptcontroller/sunadaptcontroller_impgus.h``. - - -The SUNAdaptController_ImpGus class provides implementations of all operations -relevant to a `SUN_ADAPTCONTROLLER_H` controller listed in -:numref:`SUNAdaptController.Description.operations`. This class -also provides the following additional user-callable routines: - - -.. c:function:: SUNAdaptController SUNAdaptController_ImpGus(SUNContext sunctx) - - This constructor function creates and allocates memory for a SUNAdaptController_ImpGus - object, and inserts its default parameters. - - :param sunctx: the current :c:type:`SUNContext` object. - :return: if successful, a usable :c:type:`SUNAdaptController` object; otherwise it will return ``NULL``. - - Usage: - - .. code-block:: c - - SUNAdaptController C = SUNAdaptController_ImpGus(sunctx); - -.. c:function:: int SUNAdaptController_SetParams_ImpGus(SUNAdaptController C, sunrealtype k1, sunrealtype k2) - - This user-callable function provides control over the relevant parameters - above. This should be called *before* the time integrator is called to evolve - the problem. - - :param C: the SUNAdaptController_ImpGus object. - :param k1: parameter used within the controller time step estimate. - :param k2: parameter used within the controller time step estimate. - :return: error code indication success or failure (see :numref:`SUNAdaptController.Description.errorCodes`). - - Usage: - - .. code-block:: c - - retval = SUNAdaptController_SetParams_ImpGus(C, 1.0, 0.9); diff --git a/doc/shared/sunadaptcontroller/SUNAdaptController_Soderlind.rst b/doc/shared/sunadaptcontroller/SUNAdaptController_Soderlind.rst index 31eca43b9a..ed2fd867ed 100644 --- a/doc/shared/sunadaptcontroller/SUNAdaptController_Soderlind.rst +++ b/doc/shared/sunadaptcontroller/SUNAdaptController_Soderlind.rst @@ -73,7 +73,8 @@ The header file to be included when using this module is We note that through appropriate selection of the parameters :math:`k_1 - k_5`, this controller may create a wide range of proposed temporal adaptivity controllers, -including the PID, PI and I controllers. As a convenience, utility routines to +including the PID, PI, I, as well as Gustafsson's explicit and implicit controllers, +:cite:p:`Gust:91` and :cite:p:`Gust:94`. As a convenience, utility routines to create these controllers and set their parameters (as special cases of the SUNAdaptController_Soderlind) are provided. @@ -220,3 +221,91 @@ also provides the following additional user-callable routines: .. code-block:: c retval = SUNAdaptController_SetParams_I(C, 1.0); + + +.. c:function:: SUNAdaptController SUNAdaptController_ExpGus(SUNContext sunctx) + + This constructor function creates and allocates memory for a SUNAdaptController_Soderlind + object, set up to replicate Gustafsson's explicit controller :cite:p:`Gust:91`, and + inserts its default parameters (:math:`k_1=0.635`, :math:`k_2=-0.268`, and + :math:`k_3=k_4=k_5=0`). + + :param sunctx: the current :c:type:`SUNContext` object. + :return: if successful, a usable :c:type:`SUNAdaptController` object; + otherwise it will return ``NULL``. + + Usage: + + .. code-block:: c + + SUNAdaptController C = SUNAdaptController_ExpGus(sunctx); + +.. c:function:: int SUNAdaptController_SetParams_ExpGus(SUNAdaptController C, sunrealtype k1, sunrealtype k2) + + This user-callable function provides control over the relevant parameters + above, setting :math:`k_3 = k_4 = k_5 = 0`. This should be called *before* the + time integrator is called to evolve the problem. + + Note that the Gustafsson's explicit controller has the form + + .. math:: + h' = h_n \varepsilon_n^{-\hat{k}_1/(p+1)} \left(\frac{\varepsilon_n}{\varepsilon_{n-1}}\right)^{-\hat{k}_2/(p+1)}. + + The inputs to this function correspond to the values of :math:`\hat{k}_1` and :math:`\hat{k}_2`, + which are internally transformed into the Soderlind coeficients :math:`k_1 = \hat{k}_1+\hat{k}_2` + and :math:`k_2 = -\hat{k}_2`. + + :param C: the SUNAdaptController_Soderlind object. + :param k1: parameter used within the explicit Gustafsson controller time step estimate. + :param k2: parameter used within the explicit Gustafsson controller time step estimate. + :return: error code indication success or failure (see :numref:`SUNAdaptController.Description.errorCodes`). + + Usage: + + .. code-block:: c + + retval = SUNAdaptController_SetParams_ExpGus(C, 0.367, 0.268); + + +.. c:function:: SUNAdaptController SUNAdaptController_ImpGus(SUNContext sunctx) + + This constructor function creates and allocates memory for a SUNAdaptController_Soderlind + object, set up to replicate Gustafsson's implicit controller :cite:p:`Gust:94`, and + inserts its default parameters (:math:`k_1=1.93`, :math:`k_2=-0.95`, :math:`k_4=1`, and + :math:`k_3=k_5=0`). + + :param sunctx: the current :c:type:`SUNContext` object. + :return: if successful, a usable :c:type:`SUNAdaptController` object; + otherwise it will return ``NULL``. + + Usage: + + .. code-block:: c + + SUNAdaptController C = SUNAdaptController_ImpGus(sunctx); + +.. c:function:: int SUNAdaptController_SetParams_ImpGus(SUNAdaptController C, sunrealtype k1, sunrealtype k2) + + This user-callable function provides control over the relevant parameters + above, setting :math:`k_3 = k_4 = k_5 = 0`. This should be called *before* the + time integrator is called to evolve the problem. + + Note that the Gustafsson's implicit controller has the form + + .. math:: + h' = h_n \varepsilon_n^{-\hat{k}_1/(p+1)} \left(\frac{\varepsilon_n}{\varepsilon_{n-1}}\right)^{-\hat{k}_2/(p+1)} \left(\frac{h_n}{h_{n-1}}\right). + + The inputs to this function correspond to the values of :math:`\hat{k}_1` and :math:`\hat{k}_2`, + which are internally transformed into the Soderlind coeficients :math:`k_1 = \hat{k}_1+\hat{k}_2`, + :math:`k_2 = -\hat{k}_2`, and :math:`k_4=1`. + + :param C: the SUNAdaptController_Soderlind object. + :param k1: parameter used within the implicit Gustafsson controller time step estimate. + :param k2: parameter used within the implicit Gustafsson controller time step estimate. + :return: error code indication success or failure (see :numref:`SUNAdaptController.Description.errorCodes`). + + Usage: + + .. code-block:: c + + retval = SUNAdaptController_SetParams_ImpGus(C, 0.98, 0.95); diff --git a/doc/superbuild/source/sunadaptcontroller/SUNAdaptController_links.rst b/doc/superbuild/source/sunadaptcontroller/SUNAdaptController_links.rst index df597f0861..9b404ff420 100644 --- a/doc/superbuild/source/sunadaptcontroller/SUNAdaptController_links.rst +++ b/doc/superbuild/source/sunadaptcontroller/SUNAdaptController_links.rst @@ -11,6 +11,4 @@ ---------------------------------------------------------------- .. include:: ../../../shared/sunadaptcontroller/SUNAdaptController_Soderlind.rst -.. include:: ../../../shared/sunadaptcontroller/SUNAdaptController_ExpGus.rst -.. include:: ../../../shared/sunadaptcontroller/SUNAdaptController_ImpGus.rst .. include:: ../../../shared/sunadaptcontroller/SUNAdaptController_ImExGus.rst diff --git a/examples/arkode/F2003_serial/ark_analytic_f2003.f90 b/examples/arkode/F2003_serial/ark_analytic_f2003.f90 index 8a2eaff61e..353a262bb4 100644 --- a/examples/arkode/F2003_serial/ark_analytic_f2003.f90 +++ b/examples/arkode/F2003_serial/ark_analytic_f2003.f90 @@ -102,7 +102,7 @@ program main use fsunlinsol_dense_mod ! Fortran interface to dense SUNLinearSolver use fsundials_context_mod ! Fortran interface to SUNContext use fsundials_adaptcontroller_mod ! Fortran interface to the generic SUNAdaptController - use fsunadaptcontroller_impgus_mod ! Fortran interface to ImpGus controller + use fsunadaptcontroller_soderlind_mod ! Fortran interface to Soderlind controller use ode_mod ! ODE functions !======= Declarations ========= diff --git a/examples/arkode/F2003_serial/ark_analytic_f2003.out b/examples/arkode/F2003_serial/ark_analytic_f2003.out index fa22d69806..59a3cda655 100644 --- a/examples/arkode/F2003_serial/ark_analytic_f2003.out +++ b/examples/arkode/F2003_serial/ark_analytic_f2003.out @@ -16,15 +16,15 @@ 1.00000E+01 1.47113E+00 General Solver Stats: - Total internal steps taken = 412 - Total internal steps attempts = 416 - Total rhs function calls = 4944 - Num lin solver setup calls = 38 + Total internal steps taken = 414 + Total internal steps attempts = 418 + Total rhs function calls = 4912 + Num lin solver setup calls = 42 Num error test failures = 4 First internal step size = 6.10352E-12 - Last internal step size = 7.85712E-02 - Next internal step size = 7.85712E-02 - Current internal time = 1.00544E+01 - Num nonlinear solver iters = 2861 + Last internal step size = 8.41689E-02 + Next internal step size = 8.39146E-02 + Current internal time = 1.00647E+01 + Num nonlinear solver iters = 2819 Num nonlinear solver fails = 3 diff --git a/include/arkode/arkode_arkstep.h b/include/arkode/arkode_arkstep.h index 08ee56b265..b5feb6a6f9 100644 --- a/include/arkode/arkode_arkstep.h +++ b/include/arkode/arkode_arkstep.h @@ -21,8 +21,6 @@ #include #include #include -#include -#include #include #include #include diff --git a/include/arkode/arkode_erkstep.h b/include/arkode/arkode_erkstep.h index ac3b256852..9939d77637 100644 --- a/include/arkode/arkode_erkstep.h +++ b/include/arkode/arkode_erkstep.h @@ -19,8 +19,6 @@ #include #include -#include -#include #include #include #include diff --git a/include/sunadaptcontroller/sunadaptcontroller_expgus.h b/include/sunadaptcontroller/sunadaptcontroller_expgus.h deleted file mode 100644 index ce1a5bffeb..0000000000 --- a/include/sunadaptcontroller/sunadaptcontroller_expgus.h +++ /dev/null @@ -1,73 +0,0 @@ -/* ----------------------------------------------------------------- - * Programmer(s): Daniel R. Reynolds @ SMU - * ----------------------------------------------------------------- - * SUNDIALS Copyright Start - * Copyright (c) 2002-2023, Lawrence Livermore National Security - * and Southern Methodist University. - * All rights reserved. - * - * See the top-level LICENSE and NOTICE files for details. - * - * SPDX-License-Identifier: BSD-3-Clause - * SUNDIALS Copyright End - * ----------------------------------------------------------------- - * This is the header file for the SUNAdaptController_ExpGus module. - * -----------------------------------------------------------------*/ - -#ifndef _SUNADAPTCONTROLLER_EXPGUS_H -#define _SUNADAPTCONTROLLER_EXPGUS_H - -#include -#include - -#ifdef __cplusplus /* wrapper to enable C++ usage */ -extern "C" { -#endif - -/* -------------------------------------------------------- - * Explicit Gustafsson implementation of SUNAdaptController - * -------------------------------------------------------- */ - -struct _SUNAdaptControllerContent_ExpGus { - sunrealtype k1; /* internal controller parameters */ - sunrealtype k2; - sunrealtype bias; /* error bias factor */ - sunrealtype ep; /* error from previous step */ - sunbooleantype firststep; /* flag indicating first step */ -}; - -typedef struct _SUNAdaptControllerContent_ExpGus *SUNAdaptControllerContent_ExpGus; - -/* ------------------ - * Exported Functions - * ------------------ */ - -SUNDIALS_EXPORT -SUNAdaptController SUNAdaptController_ExpGus(SUNContext sunctx); -SUNDIALS_EXPORT -int SUNAdaptController_SetParams_ExpGus(SUNAdaptController C, - sunrealtype k1, sunrealtype k2); -SUNDIALS_EXPORT -SUNAdaptController_Type SUNAdaptController_GetType_ExpGus(SUNAdaptController C); -SUNDIALS_EXPORT -int SUNAdaptController_EstimateStep_ExpGus(SUNAdaptController C, sunrealtype h, - int p, sunrealtype dsm, sunrealtype* hnew); -SUNDIALS_EXPORT -int SUNAdaptController_Reset_ExpGus(SUNAdaptController C); -SUNDIALS_EXPORT -int SUNAdaptController_SetDefaults_ExpGus(SUNAdaptController C); -SUNDIALS_EXPORT -int SUNAdaptController_Write_ExpGus(SUNAdaptController C, FILE* fptr); -SUNDIALS_EXPORT -int SUNAdaptController_SetErrorBias_ExpGus(SUNAdaptController C, sunrealtype bias); -SUNDIALS_EXPORT -int SUNAdaptController_Update_ExpGus(SUNAdaptController C, sunrealtype h, sunrealtype dsm); -SUNDIALS_EXPORT -int SUNAdaptController_Space_ExpGus(SUNAdaptController C, long int *lenrw, - long int *leniw); - -#ifdef __cplusplus -} -#endif - -#endif /* _SUNADAPTCONTROLLER_EXPGUS_H */ diff --git a/include/sunadaptcontroller/sunadaptcontroller_impgus.h b/include/sunadaptcontroller/sunadaptcontroller_impgus.h deleted file mode 100644 index 79832c7bfb..0000000000 --- a/include/sunadaptcontroller/sunadaptcontroller_impgus.h +++ /dev/null @@ -1,74 +0,0 @@ -/* ----------------------------------------------------------------- - * Programmer(s): Daniel R. Reynolds @ SMU - * ----------------------------------------------------------------- - * SUNDIALS Copyright Start - * Copyright (c) 2002-2023, Lawrence Livermore National Security - * and Southern Methodist University. - * All rights reserved. - * - * See the top-level LICENSE and NOTICE files for details. - * - * SPDX-License-Identifier: BSD-3-Clause - * SUNDIALS Copyright End - * ----------------------------------------------------------------- - * This is the header file for the SUNAdaptController_ImpGus module. - * -----------------------------------------------------------------*/ - -#ifndef _SUNADAPTCONTROLLER_IMPGUS_H -#define _SUNADAPTCONTROLLER_IMPGUS_H - -#include -#include - -#ifdef __cplusplus /* wrapper to enable C++ usage */ -extern "C" { -#endif - -/* -------------------------------------------------------- - * Implicit Gustafsson implementation of SUNAdaptController - * -------------------------------------------------------- */ - -struct _SUNAdaptControllerContent_ImpGus { - sunrealtype k1; /* internal controller parameters */ - sunrealtype k2; - sunrealtype bias; /* error bias factor */ - sunrealtype ep; /* error from previous step */ - sunrealtype hp; /* previous step size */ - sunbooleantype firststep; /* flag indicating first step */ -}; - -typedef struct _SUNAdaptControllerContent_ImpGus *SUNAdaptControllerContent_ImpGus; - -/* ------------------ - * Exported Functions - * ------------------ */ - -SUNDIALS_EXPORT -SUNAdaptController SUNAdaptController_ImpGus(SUNContext sunctx); -SUNDIALS_EXPORT -int SUNAdaptController_SetParams_ImpGus(SUNAdaptController C, - sunrealtype k1, sunrealtype k2); -SUNDIALS_EXPORT -SUNAdaptController_Type SUNAdaptController_GetType_ImpGus(SUNAdaptController C); -SUNDIALS_EXPORT -int SUNAdaptController_EstimateStep_ImpGus(SUNAdaptController C, sunrealtype h, - int p, sunrealtype dsm, sunrealtype* hnew); -SUNDIALS_EXPORT -int SUNAdaptController_Reset_ImpGus(SUNAdaptController C); -SUNDIALS_EXPORT -int SUNAdaptController_SetDefaults_ImpGus(SUNAdaptController C); -SUNDIALS_EXPORT -int SUNAdaptController_Write_ImpGus(SUNAdaptController C, FILE* fptr); -SUNDIALS_EXPORT -int SUNAdaptController_SetErrorBias_ImpGus(SUNAdaptController C, sunrealtype bias); -SUNDIALS_EXPORT -int SUNAdaptController_Update_ImpGus(SUNAdaptController C, sunrealtype h, sunrealtype dsm); -SUNDIALS_EXPORT -int SUNAdaptController_Space_ImpGus(SUNAdaptController C, long int *lenrw, - long int *leniw); - -#ifdef __cplusplus -} -#endif - -#endif /* _SUNADAPTCONTROLLER_IMPGUS_H */ diff --git a/include/sunadaptcontroller/sunadaptcontroller_soderlind.h b/include/sunadaptcontroller/sunadaptcontroller_soderlind.h index df31c11f7b..c876cdc32c 100644 --- a/include/sunadaptcontroller/sunadaptcontroller_soderlind.h +++ b/include/sunadaptcontroller/sunadaptcontroller_soderlind.h @@ -92,6 +92,18 @@ SUNAdaptController SUNAdaptController_I(SUNContext sunctx); SUNDIALS_EXPORT int SUNAdaptController_SetParams_I(SUNAdaptController C, sunrealtype k1); +SUNDIALS_EXPORT +SUNAdaptController SUNAdaptController_ExpGus(SUNContext sunctx); +SUNDIALS_EXPORT +int SUNAdaptController_SetParams_ExpGus(SUNAdaptController C, + sunrealtype k1, sunrealtype k2); + +SUNDIALS_EXPORT +SUNAdaptController SUNAdaptController_ImpGus(SUNContext sunctx); +SUNDIALS_EXPORT +int SUNAdaptController_SetParams_ImpGus(SUNAdaptController C, + sunrealtype k1, sunrealtype k2); + #ifdef __cplusplus } #endif diff --git a/src/arkode/CMakeLists.txt b/src/arkode/CMakeLists.txt index 913aec197c..c516eabdd2 100644 --- a/src/arkode/CMakeLists.txt +++ b/src/arkode/CMakeLists.txt @@ -76,8 +76,6 @@ sundials_add_library(sundials_arkode sundials_generic_obj sundials_sunmemsys_obj sundials_nvecserial_obj - sundials_sunadaptcontrollerexpgus_obj - sundials_sunadaptcontrollerimpgus_obj sundials_sunadaptcontrollerimexgus_obj sundials_sunadaptcontrollernoop_obj sundials_sunadaptcontrollersoderlind_obj diff --git a/src/arkode/arkode_io.c b/src/arkode/arkode_io.c index cb2f41b577..d64fe22e66 100644 --- a/src/arkode/arkode_io.c +++ b/src/arkode/arkode_io.c @@ -27,8 +27,6 @@ #include #include #include -#include -#include #include #include diff --git a/src/arkode/fmod/CMakeLists.txt b/src/arkode/fmod/CMakeLists.txt index 6de617454a..840dfb2591 100644 --- a/src/arkode/fmod/CMakeLists.txt +++ b/src/arkode/fmod/CMakeLists.txt @@ -34,9 +34,7 @@ sundials_add_f2003_library(sundials_farkode_mod sundials_fgeneric_mod_obj sundials_fnvecserial_mod_obj sundials_fsunadaptcontrollersoderlind_mod_obj - sundials_fsunadaptcontrollerexpgus_mod_obj sundials_fsunadaptcontrollerimexgus_mod_obj - sundials_fsunadaptcontrollerimpgus_mod_obj sundials_fsunmatrixband_mod_obj sundials_fsunmatrixdense_mod_obj sundials_fsunmatrixsparse_mod_obj diff --git a/src/sunadaptcontroller/CMakeLists.txt b/src/sunadaptcontroller/CMakeLists.txt index 483d73ecb0..91f16bbcdb 100644 --- a/src/sunadaptcontroller/CMakeLists.txt +++ b/src/sunadaptcontroller/CMakeLists.txt @@ -15,8 +15,6 @@ # ------------------------------------------------------------------------------ # required native matrices -add_subdirectory(expgus) add_subdirectory(imexgus) -add_subdirectory(impgus) add_subdirectory(noop) add_subdirectory(soderlind) diff --git a/src/sunadaptcontroller/expgus/CMakeLists.txt b/src/sunadaptcontroller/expgus/CMakeLists.txt deleted file mode 100644 index f4a38aae0d..0000000000 --- a/src/sunadaptcontroller/expgus/CMakeLists.txt +++ /dev/null @@ -1,29 +0,0 @@ -# --------------------------------------------------------------- -# Programmer(s): Daniel R. Reynolds @ SMU -# --------------------------------------------------------------- -# SUNDIALS Copyright Start -# Copyright (c) 2002-2023, 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 -# --------------------------------------------------------------- - -# Create a library out of the generic sundials modules -sundials_add_library(sundials_sunadaptcontrollerexpgus - SOURCES - sunadaptcontroller_expgus.c - HEADERS - ${SUNDIALS_SOURCE_DIR}/include/sunadaptcontroller/sunadaptcontroller_expgus.h - INCLUDE_SUBDIR - sunadaptcontroller - OBJECT_LIB_ONLY -) - -# Add F2003 module if the interface is enabled -if(BUILD_FORTRAN_MODULE_INTERFACE) - add_subdirectory(fmod) -endif() diff --git a/src/sunadaptcontroller/expgus/fmod/CMakeLists.txt b/src/sunadaptcontroller/expgus/fmod/CMakeLists.txt deleted file mode 100644 index a8edd5426d..0000000000 --- a/src/sunadaptcontroller/expgus/fmod/CMakeLists.txt +++ /dev/null @@ -1,25 +0,0 @@ -# --------------------------------------------------------------- -# Programmer(s): Daniel R. Reynolds @ SMU -# --------------------------------------------------------------- -# SUNDIALS Copyright Start -# Copyright (c) 2002-2023, 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 -# --------------------------------------------------------------- - -sundials_add_f2003_library(sundials_fsunadaptcontrollerexpgus_mod - SOURCES - fsunadaptcontroller_expgus_mod.f90 fsunadaptcontroller_expgus_mod.c - OBJECT_LIBRARIES - sundials_fgeneric_mod_obj - OUTPUT_NAME - sundials_fsunadaptcontrollerexpgus_mod - OBJECT_LIB_ONLY -) - -message(STATUS "Added SUNAdaptController_ExpGus F2003 interface") diff --git a/src/sunadaptcontroller/expgus/fmod/fsunadaptcontroller_expgus_mod.c b/src/sunadaptcontroller/expgus/fmod/fsunadaptcontroller_expgus_mod.c deleted file mode 100644 index 1243240dde..0000000000 --- a/src/sunadaptcontroller/expgus/fmod/fsunadaptcontroller_expgus_mod.c +++ /dev/null @@ -1,355 +0,0 @@ -/* ---------------------------------------------------------------------------- - * This file was automatically generated by SWIG (http://www.swig.org). - * Version 4.0.0 - * - * This file is not intended to be easily readable and contains a number of - * coding conventions designed to improve portability and efficiency. Do not make - * changes to this file unless you know what you are doing--modify the SWIG - * interface file instead. - * ----------------------------------------------------------------------------- */ - -/* --------------------------------------------------------------- - * Programmer(s): Auto-generated by swig. - * --------------------------------------------------------------- - * SUNDIALS Copyright Start - * Copyright (c) 2002-2023, Lawrence Livermore National Security - * and Southern Methodist University. - * All rights reserved. - * - * See the top-level LICENSE and NOTICE files for details. - * - * SPDX-License-Identifier: BSD-3-Clause - * SUNDIALS Copyright End - * -------------------------------------------------------------*/ - -/* ----------------------------------------------------------------------------- - * This section contains generic SWIG labels for method/variable - * declarations/attributes, and other compiler dependent labels. - * ----------------------------------------------------------------------------- */ - -/* template workaround for compilers that cannot correctly implement the C++ standard */ -#ifndef SWIGTEMPLATEDISAMBIGUATOR -# if defined(__SUNPRO_CC) && (__SUNPRO_CC <= 0x560) -# define SWIGTEMPLATEDISAMBIGUATOR template -# elif defined(__HP_aCC) -/* Needed even with `aCC -AA' when `aCC -V' reports HP ANSI C++ B3910B A.03.55 */ -/* If we find a maximum version that requires this, the test would be __HP_aCC <= 35500 for A.03.55 */ -# define SWIGTEMPLATEDISAMBIGUATOR template -# else -# define SWIGTEMPLATEDISAMBIGUATOR -# endif -#endif - -/* inline attribute */ -#ifndef SWIGINLINE -# if defined(__cplusplus) || (defined(__GNUC__) && !defined(__STRICT_ANSI__)) -# define SWIGINLINE inline -# else -# define SWIGINLINE -# endif -#endif - -/* attribute recognised by some compilers to avoid 'unused' warnings */ -#ifndef SWIGUNUSED -# if defined(__GNUC__) -# if !(defined(__cplusplus)) || (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)) -# define SWIGUNUSED __attribute__ ((__unused__)) -# else -# define SWIGUNUSED -# endif -# elif defined(__ICC) -# define SWIGUNUSED __attribute__ ((__unused__)) -# else -# define SWIGUNUSED -# endif -#endif - -#ifndef SWIG_MSC_UNSUPPRESS_4505 -# if defined(_MSC_VER) -# pragma warning(disable : 4505) /* unreferenced local function has been removed */ -# endif -#endif - -#ifndef SWIGUNUSEDPARM -# ifdef __cplusplus -# define SWIGUNUSEDPARM(p) -# else -# define SWIGUNUSEDPARM(p) p SWIGUNUSED -# endif -#endif - -/* internal SWIG method */ -#ifndef SWIGINTERN -# define SWIGINTERN static SWIGUNUSED -#endif - -/* internal inline SWIG method */ -#ifndef SWIGINTERNINLINE -# define SWIGINTERNINLINE SWIGINTERN SWIGINLINE -#endif - -/* qualifier for exported *const* global data variables*/ -#ifndef SWIGEXTERN -# ifdef __cplusplus -# define SWIGEXTERN extern -# else -# define SWIGEXTERN -# endif -#endif - -/* exporting methods */ -#if defined(__GNUC__) -# if (__GNUC__ >= 4) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) -# ifndef GCC_HASCLASSVISIBILITY -# define GCC_HASCLASSVISIBILITY -# endif -# endif -#endif - -#ifndef SWIGEXPORT -# if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__) -# if defined(STATIC_LINKED) -# define SWIGEXPORT -# else -# define SWIGEXPORT __declspec(dllexport) -# endif -# else -# if defined(__GNUC__) && defined(GCC_HASCLASSVISIBILITY) -# define SWIGEXPORT __attribute__ ((visibility("default"))) -# else -# define SWIGEXPORT -# endif -# endif -#endif - -/* calling conventions for Windows */ -#ifndef SWIGSTDCALL -# if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__) -# define SWIGSTDCALL __stdcall -# else -# define SWIGSTDCALL -# endif -#endif - -/* Deal with Microsoft's attempt at deprecating C standard runtime functions */ -#if !defined(SWIG_NO_CRT_SECURE_NO_DEPRECATE) && defined(_MSC_VER) && !defined(_CRT_SECURE_NO_DEPRECATE) -# define _CRT_SECURE_NO_DEPRECATE -#endif - -/* Deal with Microsoft's attempt at deprecating methods in the standard C++ library */ -#if !defined(SWIG_NO_SCL_SECURE_NO_DEPRECATE) && defined(_MSC_VER) && !defined(_SCL_SECURE_NO_DEPRECATE) -# define _SCL_SECURE_NO_DEPRECATE -#endif - -/* Deal with Apple's deprecated 'AssertMacros.h' from Carbon-framework */ -#if defined(__APPLE__) && !defined(__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES) -# define __ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES 0 -#endif - -/* Intel's compiler complains if a variable which was never initialised is - * cast to void, which is a common idiom which we use to indicate that we - * are aware a variable isn't used. So we just silence that warning. - * See: https://github.com/swig/swig/issues/192 for more discussion. - */ -#ifdef __INTEL_COMPILER -# pragma warning disable 592 -#endif - -/* Errors in SWIG */ -#define SWIG_UnknownError -1 -#define SWIG_IOError -2 -#define SWIG_RuntimeError -3 -#define SWIG_IndexError -4 -#define SWIG_TypeError -5 -#define SWIG_DivisionByZero -6 -#define SWIG_OverflowError -7 -#define SWIG_SyntaxError -8 -#define SWIG_ValueError -9 -#define SWIG_SystemError -10 -#define SWIG_AttributeError -11 -#define SWIG_MemoryError -12 -#define SWIG_NullReferenceError -13 - - - - -#include -#define SWIG_exception_impl(DECL, CODE, MSG, RETURNNULL) \ - { printf("In " DECL ": " MSG); assert(0); RETURNNULL; } - - -#include -#if defined(_MSC_VER) || defined(__BORLANDC__) || defined(_WATCOM) -# ifndef snprintf -# define snprintf _snprintf -# endif -#endif - - -/* Support for the `contract` feature. - * - * Note that RETURNNULL is first because it's inserted via a 'Replaceall' in - * the fortran.cxx file. - */ -#define SWIG_contract_assert(RETURNNULL, EXPR, MSG) \ - if (!(EXPR)) { SWIG_exception_impl("$decl", SWIG_ValueError, MSG, RETURNNULL); } - - -#define SWIGVERSION 0x040000 -#define SWIG_VERSION SWIGVERSION - - -#define SWIG_as_voidptr(a) (void *)((const void *)(a)) -#define SWIG_as_voidptrptr(a) ((void)SWIG_as_voidptr(*a),(void**)(a)) - - -#include "sundials/sundials_adaptcontroller.h" - - -#include "sunadaptcontroller/sunadaptcontroller_expgus.h" - -SWIGEXPORT SUNAdaptController _wrap_FSUNAdaptController_ExpGus(void *farg1) { - SUNAdaptController fresult ; - SUNContext arg1 = (SUNContext) 0 ; - SUNAdaptController result; - - arg1 = (SUNContext)(farg1); - result = (SUNAdaptController)SUNAdaptController_ExpGus(arg1); - fresult = result; - return fresult; -} - - -SWIGEXPORT int _wrap_FSUNAdaptController_SetParams_ExpGus(SUNAdaptController farg1, double const *farg2, double const *farg3) { - int fresult ; - SUNAdaptController arg1 = (SUNAdaptController) 0 ; - sunrealtype arg2 ; - sunrealtype arg3 ; - int result; - - arg1 = (SUNAdaptController)(farg1); - arg2 = (sunrealtype)(*farg2); - arg3 = (sunrealtype)(*farg3); - result = (int)SUNAdaptController_SetParams_ExpGus(arg1,arg2,arg3); - fresult = (int)(result); - return fresult; -} - - -SWIGEXPORT int _wrap_FSUNAdaptController_GetType_ExpGus(SUNAdaptController farg1) { - int fresult ; - SUNAdaptController arg1 = (SUNAdaptController) 0 ; - SUNAdaptController_Type result; - - arg1 = (SUNAdaptController)(farg1); - result = (SUNAdaptController_Type)SUNAdaptController_GetType_ExpGus(arg1); - fresult = (int)(result); - return fresult; -} - - -SWIGEXPORT int _wrap_FSUNAdaptController_EstimateStep_ExpGus(SUNAdaptController farg1, double const *farg2, int const *farg3, double const *farg4, double *farg5) { - int fresult ; - SUNAdaptController arg1 = (SUNAdaptController) 0 ; - sunrealtype arg2 ; - int arg3 ; - sunrealtype arg4 ; - sunrealtype *arg5 = (sunrealtype *) 0 ; - int result; - - arg1 = (SUNAdaptController)(farg1); - arg2 = (sunrealtype)(*farg2); - arg3 = (int)(*farg3); - arg4 = (sunrealtype)(*farg4); - arg5 = (sunrealtype *)(farg5); - result = (int)SUNAdaptController_EstimateStep_ExpGus(arg1,arg2,arg3,arg4,arg5); - fresult = (int)(result); - return fresult; -} - - -SWIGEXPORT int _wrap_FSUNAdaptController_Reset_ExpGus(SUNAdaptController farg1) { - int fresult ; - SUNAdaptController arg1 = (SUNAdaptController) 0 ; - int result; - - arg1 = (SUNAdaptController)(farg1); - result = (int)SUNAdaptController_Reset_ExpGus(arg1); - fresult = (int)(result); - return fresult; -} - - -SWIGEXPORT int _wrap_FSUNAdaptController_SetDefaults_ExpGus(SUNAdaptController farg1) { - int fresult ; - SUNAdaptController arg1 = (SUNAdaptController) 0 ; - int result; - - arg1 = (SUNAdaptController)(farg1); - result = (int)SUNAdaptController_SetDefaults_ExpGus(arg1); - fresult = (int)(result); - return fresult; -} - - -SWIGEXPORT int _wrap_FSUNAdaptController_Write_ExpGus(SUNAdaptController farg1, void *farg2) { - int fresult ; - SUNAdaptController arg1 = (SUNAdaptController) 0 ; - FILE *arg2 = (FILE *) 0 ; - int result; - - arg1 = (SUNAdaptController)(farg1); - arg2 = (FILE *)(farg2); - result = (int)SUNAdaptController_Write_ExpGus(arg1,arg2); - fresult = (int)(result); - return fresult; -} - - -SWIGEXPORT int _wrap_FSUNAdaptController_SetErrorBias_ExpGus(SUNAdaptController farg1, double const *farg2) { - int fresult ; - SUNAdaptController arg1 = (SUNAdaptController) 0 ; - sunrealtype arg2 ; - int result; - - arg1 = (SUNAdaptController)(farg1); - arg2 = (sunrealtype)(*farg2); - result = (int)SUNAdaptController_SetErrorBias_ExpGus(arg1,arg2); - fresult = (int)(result); - return fresult; -} - - -SWIGEXPORT int _wrap_FSUNAdaptController_Update_ExpGus(SUNAdaptController farg1, double const *farg2, double const *farg3) { - int fresult ; - SUNAdaptController arg1 = (SUNAdaptController) 0 ; - sunrealtype arg2 ; - sunrealtype arg3 ; - int result; - - arg1 = (SUNAdaptController)(farg1); - arg2 = (sunrealtype)(*farg2); - arg3 = (sunrealtype)(*farg3); - result = (int)SUNAdaptController_Update_ExpGus(arg1,arg2,arg3); - fresult = (int)(result); - return fresult; -} - - -SWIGEXPORT int _wrap_FSUNAdaptController_Space_ExpGus(SUNAdaptController farg1, long *farg2, long *farg3) { - int fresult ; - SUNAdaptController arg1 = (SUNAdaptController) 0 ; - long *arg2 = (long *) 0 ; - long *arg3 = (long *) 0 ; - int result; - - arg1 = (SUNAdaptController)(farg1); - arg2 = (long *)(farg2); - arg3 = (long *)(farg3); - result = (int)SUNAdaptController_Space_ExpGus(arg1,arg2,arg3); - fresult = (int)(result); - return fresult; -} - - - diff --git a/src/sunadaptcontroller/expgus/fmod/fsunadaptcontroller_expgus_mod.f90 b/src/sunadaptcontroller/expgus/fmod/fsunadaptcontroller_expgus_mod.f90 deleted file mode 100644 index 9271342406..0000000000 --- a/src/sunadaptcontroller/expgus/fmod/fsunadaptcontroller_expgus_mod.f90 +++ /dev/null @@ -1,307 +0,0 @@ -! This file was automatically generated by SWIG (http://www.swig.org). -! Version 4.0.0 -! -! Do not make changes to this file unless you know what you are doing--modify -! the SWIG interface file instead. - -! --------------------------------------------------------------- -! Programmer(s): Auto-generated by swig. -! --------------------------------------------------------------- -! SUNDIALS Copyright Start -! Copyright (c) 2002-2023, 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 -! --------------------------------------------------------------- - -module fsunadaptcontroller_expgus_mod - use, intrinsic :: ISO_C_BINDING - use fsundials_adaptcontroller_mod - use fsundials_types_mod - use fsundials_context_mod - implicit none - private - - ! DECLARATION CONSTRUCTS - public :: FSUNAdaptController_ExpGus - public :: FSUNAdaptController_SetParams_ExpGus - public :: FSUNAdaptController_GetType_ExpGus - public :: FSUNAdaptController_EstimateStep_ExpGus - public :: FSUNAdaptController_Reset_ExpGus - public :: FSUNAdaptController_SetDefaults_ExpGus - public :: FSUNAdaptController_Write_ExpGus - public :: FSUNAdaptController_SetErrorBias_ExpGus - public :: FSUNAdaptController_Update_ExpGus - public :: FSUNAdaptController_Space_ExpGus - -! WRAPPER DECLARATIONS -interface -function swigc_FSUNAdaptController_ExpGus(farg1) & -bind(C, name="_wrap_FSUNAdaptController_ExpGus") & -result(fresult) -use, intrinsic :: ISO_C_BINDING -type(C_PTR), value :: farg1 -type(C_PTR) :: fresult -end function - -function swigc_FSUNAdaptController_SetParams_ExpGus(farg1, farg2, farg3) & -bind(C, name="_wrap_FSUNAdaptController_SetParams_ExpGus") & -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_FSUNAdaptController_GetType_ExpGus(farg1) & -bind(C, name="_wrap_FSUNAdaptController_GetType_ExpGus") & -result(fresult) -use, intrinsic :: ISO_C_BINDING -type(C_PTR), value :: farg1 -integer(C_INT) :: fresult -end function - -function swigc_FSUNAdaptController_EstimateStep_ExpGus(farg1, farg2, farg3, farg4, farg5) & -bind(C, name="_wrap_FSUNAdaptController_EstimateStep_ExpGus") & -result(fresult) -use, intrinsic :: ISO_C_BINDING -type(C_PTR), value :: farg1 -real(C_DOUBLE), intent(in) :: farg2 -integer(C_INT), intent(in) :: farg3 -real(C_DOUBLE), intent(in) :: farg4 -type(C_PTR), value :: farg5 -integer(C_INT) :: fresult -end function - -function swigc_FSUNAdaptController_Reset_ExpGus(farg1) & -bind(C, name="_wrap_FSUNAdaptController_Reset_ExpGus") & -result(fresult) -use, intrinsic :: ISO_C_BINDING -type(C_PTR), value :: farg1 -integer(C_INT) :: fresult -end function - -function swigc_FSUNAdaptController_SetDefaults_ExpGus(farg1) & -bind(C, name="_wrap_FSUNAdaptController_SetDefaults_ExpGus") & -result(fresult) -use, intrinsic :: ISO_C_BINDING -type(C_PTR), value :: farg1 -integer(C_INT) :: fresult -end function - -function swigc_FSUNAdaptController_Write_ExpGus(farg1, farg2) & -bind(C, name="_wrap_FSUNAdaptController_Write_ExpGus") & -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_FSUNAdaptController_SetErrorBias_ExpGus(farg1, farg2) & -bind(C, name="_wrap_FSUNAdaptController_SetErrorBias_ExpGus") & -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_FSUNAdaptController_Update_ExpGus(farg1, farg2, farg3) & -bind(C, name="_wrap_FSUNAdaptController_Update_ExpGus") & -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_FSUNAdaptController_Space_ExpGus(farg1, farg2, farg3) & -bind(C, name="_wrap_FSUNAdaptController_Space_ExpGus") & -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 - -end interface - - -contains - ! MODULE SUBPROGRAMS -function FSUNAdaptController_ExpGus(sunctx) & -result(swig_result) -use, intrinsic :: ISO_C_BINDING -type(SUNAdaptController), pointer :: swig_result -type(C_PTR) :: sunctx -type(C_PTR) :: fresult -type(C_PTR) :: farg1 - -farg1 = sunctx -fresult = swigc_FSUNAdaptController_ExpGus(farg1) -call c_f_pointer(fresult, swig_result) -end function - -function FSUNAdaptController_SetParams_ExpGus(c, k1, k2) & -result(swig_result) -use, intrinsic :: ISO_C_BINDING -integer(C_INT) :: swig_result -type(SUNAdaptController), target, intent(inout) :: c -real(C_DOUBLE), intent(in) :: k1 -real(C_DOUBLE), intent(in) :: k2 -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -real(C_DOUBLE) :: farg2 -real(C_DOUBLE) :: farg3 - -farg1 = c_loc(c) -farg2 = k1 -farg3 = k2 -fresult = swigc_FSUNAdaptController_SetParams_ExpGus(farg1, farg2, farg3) -swig_result = fresult -end function - -function FSUNAdaptController_GetType_ExpGus(c) & -result(swig_result) -use, intrinsic :: ISO_C_BINDING -integer(SUNAdaptController_Type) :: swig_result -type(SUNAdaptController), target, intent(inout) :: c -integer(C_INT) :: fresult -type(C_PTR) :: farg1 - -farg1 = c_loc(c) -fresult = swigc_FSUNAdaptController_GetType_ExpGus(farg1) -swig_result = fresult -end function - -function FSUNAdaptController_EstimateStep_ExpGus(c, h, p, dsm, hnew) & -result(swig_result) -use, intrinsic :: ISO_C_BINDING -integer(C_INT) :: swig_result -type(SUNAdaptController), target, intent(inout) :: c -real(C_DOUBLE), intent(in) :: h -integer(C_INT), intent(in) :: p -real(C_DOUBLE), intent(in) :: dsm -real(C_DOUBLE), target, intent(inout) :: hnew -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -real(C_DOUBLE) :: farg2 -integer(C_INT) :: farg3 -real(C_DOUBLE) :: farg4 -type(C_PTR) :: farg5 - -farg1 = c_loc(c) -farg2 = h -farg3 = p -farg4 = dsm -farg5 = c_loc(hnew) -fresult = swigc_FSUNAdaptController_EstimateStep_ExpGus(farg1, farg2, farg3, farg4, farg5) -swig_result = fresult -end function - -function FSUNAdaptController_Reset_ExpGus(c) & -result(swig_result) -use, intrinsic :: ISO_C_BINDING -integer(C_INT) :: swig_result -type(SUNAdaptController), target, intent(inout) :: c -integer(C_INT) :: fresult -type(C_PTR) :: farg1 - -farg1 = c_loc(c) -fresult = swigc_FSUNAdaptController_Reset_ExpGus(farg1) -swig_result = fresult -end function - -function FSUNAdaptController_SetDefaults_ExpGus(c) & -result(swig_result) -use, intrinsic :: ISO_C_BINDING -integer(C_INT) :: swig_result -type(SUNAdaptController), target, intent(inout) :: c -integer(C_INT) :: fresult -type(C_PTR) :: farg1 - -farg1 = c_loc(c) -fresult = swigc_FSUNAdaptController_SetDefaults_ExpGus(farg1) -swig_result = fresult -end function - -function FSUNAdaptController_Write_ExpGus(c, fptr) & -result(swig_result) -use, intrinsic :: ISO_C_BINDING -integer(C_INT) :: swig_result -type(SUNAdaptController), target, intent(inout) :: c -type(C_PTR) :: fptr -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 - -farg1 = c_loc(c) -farg2 = fptr -fresult = swigc_FSUNAdaptController_Write_ExpGus(farg1, farg2) -swig_result = fresult -end function - -function FSUNAdaptController_SetErrorBias_ExpGus(c, bias) & -result(swig_result) -use, intrinsic :: ISO_C_BINDING -integer(C_INT) :: swig_result -type(SUNAdaptController), target, intent(inout) :: c -real(C_DOUBLE), intent(in) :: bias -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -real(C_DOUBLE) :: farg2 - -farg1 = c_loc(c) -farg2 = bias -fresult = swigc_FSUNAdaptController_SetErrorBias_ExpGus(farg1, farg2) -swig_result = fresult -end function - -function FSUNAdaptController_Update_ExpGus(c, h, dsm) & -result(swig_result) -use, intrinsic :: ISO_C_BINDING -integer(C_INT) :: swig_result -type(SUNAdaptController), target, intent(inout) :: c -real(C_DOUBLE), intent(in) :: h -real(C_DOUBLE), intent(in) :: dsm -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -real(C_DOUBLE) :: farg2 -real(C_DOUBLE) :: farg3 - -farg1 = c_loc(c) -farg2 = h -farg3 = dsm -fresult = swigc_FSUNAdaptController_Update_ExpGus(farg1, farg2, farg3) -swig_result = fresult -end function - -function FSUNAdaptController_Space_ExpGus(c, lenrw, leniw) & -result(swig_result) -use, intrinsic :: ISO_C_BINDING -integer(C_INT) :: swig_result -type(SUNAdaptController), target, intent(inout) :: c -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 = c_loc(c) -farg2 = c_loc(lenrw(1)) -farg3 = c_loc(leniw(1)) -fresult = swigc_FSUNAdaptController_Space_ExpGus(farg1, farg2, farg3) -swig_result = fresult -end function - - -end module diff --git a/src/sunadaptcontroller/expgus/sunadaptcontroller_expgus.c b/src/sunadaptcontroller/expgus/sunadaptcontroller_expgus.c deleted file mode 100644 index df1a47efac..0000000000 --- a/src/sunadaptcontroller/expgus/sunadaptcontroller_expgus.c +++ /dev/null @@ -1,202 +0,0 @@ -/* ----------------------------------------------------------------- - * Programmer(s): Daniel R. Reynolds @ SMU - * ----------------------------------------------------------------- - * SUNDIALS Copyright Start - * Copyright (c) 2002-2023, Lawrence Livermore National Security - * and Southern Methodist University. - * All rights reserved. - * - * See the top-level LICENSE and NOTICE files for details. - * - * SPDX-License-Identifier: BSD-3-Clause - * SUNDIALS Copyright End - * ----------------------------------------------------------------- - * This is the implementation file for the SUNAdaptController_ExpGus - * module. - * -----------------------------------------------------------------*/ - -#include -#include -#include -#include - - -/* --------------- - * Macro accessors - * --------------- */ - -#define SACEXPGUS_CONTENT(C) ( (SUNAdaptControllerContent_ExpGus)(C->content) ) -#define SACEXPGUS_K1(C) ( SACEXPGUS_CONTENT(C)->k1 ) -#define SACEXPGUS_K2(C) ( SACEXPGUS_CONTENT(C)->k2 ) -#define SACEXPGUS_BIAS(C) ( SACEXPGUS_CONTENT(C)->bias ) -#define SACEXPGUS_EP(C) ( SACEXPGUS_CONTENT(C)->ep ) -#define SACEXPGUS_FIRSTSTEP(C) ( SACEXPGUS_CONTENT(C)->firststep ) - -/* ------------------ - * Default parameters - * ------------------ */ - -#define DEFAULT_K1 RCONST(0.367) -#define DEFAULT_K2 RCONST(0.268) -#define DEFAULT_BIAS RCONST(1.5) -#define TINY RCONST(1.0e-10) - - -/* ----------------------------------------------------------------- - * exported functions - * ----------------------------------------------------------------- */ - -/* ----------------------------------------------------------------- - * Function to create a new ExpGus controller - */ - -SUNAdaptController SUNAdaptController_ExpGus(SUNContext sunctx) -{ - SUNAdaptController C; - SUNAdaptControllerContent_ExpGus content; - - /* Create an empty controller object */ - C = NULL; - C = SUNAdaptController_NewEmpty(sunctx); - if (C == NULL) { return (NULL); } - - /* Attach operations */ - C->ops->gettype = SUNAdaptController_GetType_ExpGus; - C->ops->estimatestep = SUNAdaptController_EstimateStep_ExpGus; - C->ops->reset = SUNAdaptController_Reset_ExpGus; - C->ops->setdefaults = SUNAdaptController_SetDefaults_ExpGus; - C->ops->write = SUNAdaptController_Write_ExpGus; - C->ops->seterrorbias = SUNAdaptController_SetErrorBias_ExpGus; - C->ops->update = SUNAdaptController_Update_ExpGus; - C->ops->space = SUNAdaptController_Space_ExpGus; - - /* Create content */ - content = NULL; - content = (SUNAdaptControllerContent_ExpGus)malloc(sizeof *content); - if (content == NULL) - { - (void) SUNAdaptController_Destroy(C); - return (NULL); - } - - /* Attach content */ - C->content = content; - - /* Fill content with default/reset values */ - SUNAdaptController_SetDefaults_ExpGus(C); - SUNAdaptController_Reset_ExpGus(C); - - return (C); -} - -/* ----------------------------------------------------------------- - * Function to set ExpGus parameters - */ - -int SUNAdaptController_SetParams_ExpGus(SUNAdaptController C, - sunrealtype k1, sunrealtype k2) -{ - SACEXPGUS_K1(C) = k1; - SACEXPGUS_K2(C) = k2; - return SUNADAPTCONTROLLER_SUCCESS; -} - - - -/* ----------------------------------------------------------------- - * implementation of controller operations - * ----------------------------------------------------------------- */ - -SUNAdaptController_Type SUNAdaptController_GetType_ExpGus(SUNAdaptController C) -{ return SUN_ADAPTCONTROLLER_H; } - -int SUNAdaptController_EstimateStep_ExpGus(SUNAdaptController C, sunrealtype h, - int p, sunrealtype dsm, sunrealtype* hnew) -{ - /* order parameter to use in controller */ - const int ord = p + 1; - - /* modified method for first step */ - if (SACEXPGUS_FIRSTSTEP(C)) - { - /* set usable time-step adaptivity parameters */ - const sunrealtype k = -RCONST(1.0) / ord; - const sunrealtype e = SUNMAX(SACEXPGUS_BIAS(C) * dsm, TINY); - - /* compute estimated optimal time step size */ - *hnew = h * SUNRpowerR(e,k); - } - else - { - /* set usable time-step adaptivity parameters */ - const sunrealtype k1 = -SACEXPGUS_K1(C) / ord; - const sunrealtype k2 = -SACEXPGUS_K2(C) / ord; - const sunrealtype ecur = SACEXPGUS_BIAS(C) * dsm; - const sunrealtype e1 = SUNMAX(ecur, TINY); - const sunrealtype e2 = e1 / SUNMAX(SACEXPGUS_EP(C), TINY); - - /* compute estimated optimal time step size */ - *hnew = h * SUNRpowerR(e1,k1) * SUNRpowerR(e2,k2); - } - - /* return with success */ - return SUNADAPTCONTROLLER_SUCCESS; -} - -int SUNAdaptController_Reset_ExpGus(SUNAdaptController C) -{ - SACEXPGUS_EP(C) = RCONST(1.0); - SACEXPGUS_FIRSTSTEP(C) = SUNTRUE; - return SUNADAPTCONTROLLER_SUCCESS; -} - -int SUNAdaptController_SetDefaults_ExpGus(SUNAdaptController C) -{ - SACEXPGUS_K1(C) = DEFAULT_K1; - SACEXPGUS_K2(C) = DEFAULT_K2; - SACEXPGUS_BIAS(C) = DEFAULT_BIAS; - return SUNADAPTCONTROLLER_SUCCESS; -} - -int SUNAdaptController_Write_ExpGus(SUNAdaptController C, FILE *fptr) -{ - fprintf(fptr, "Explicit Gustafsson SUNAdaptController module:\n"); -#if defined(SUNDIALS_EXTENDED_PRECISION) - fprintf(fptr, " k1 = %32Lg\n", SACEXPGUS_K1(C)); - fprintf(fptr, " k2 = %32Lg\n", SACEXPGUS_K2(C)); - fprintf(fptr, " bias factor = %32Lg\n", SACEXPGUS_BIAS(C)); - fprintf(fptr, " previous error = %32g\n", SACEXPGUS_EP(C)); -#else - fprintf(fptr, " k1 = %16g\n", SACEXPGUS_K1(C)); - fprintf(fptr, " k2 = %16g\n", SACEXPGUS_K2(C)); - fprintf(fptr, " bias factor = %16g\n", SACEXPGUS_BIAS(C)); - fprintf(fptr, " previous error = %16g\n", SACEXPGUS_EP(C)); -#endif - return SUNADAPTCONTROLLER_SUCCESS; -} - -int SUNAdaptController_SetErrorBias_ExpGus(SUNAdaptController C, sunrealtype bias) -{ - /* set allowed value, otherwise set default */ - if (bias <= RCONST(0.0)) { - SACEXPGUS_BIAS(C) = DEFAULT_BIAS; - } else { - SACEXPGUS_BIAS(C) = bias; - } - - return SUNADAPTCONTROLLER_SUCCESS; -} - -int SUNAdaptController_Update_ExpGus(SUNAdaptController C, sunrealtype h, sunrealtype dsm) -{ - SACEXPGUS_EP(C) = SACEXPGUS_BIAS(C) * dsm; - SACEXPGUS_FIRSTSTEP(C) = SUNFALSE; - return SUNADAPTCONTROLLER_SUCCESS; -} - -int SUNAdaptController_Space_ExpGus(SUNAdaptController C, long int* lenrw, long int* leniw) -{ - *lenrw = 4; - *leniw = 1; - return SUNADAPTCONTROLLER_SUCCESS; -} diff --git a/src/sunadaptcontroller/impgus/CMakeLists.txt b/src/sunadaptcontroller/impgus/CMakeLists.txt deleted file mode 100644 index 0cd952c05f..0000000000 --- a/src/sunadaptcontroller/impgus/CMakeLists.txt +++ /dev/null @@ -1,29 +0,0 @@ -# --------------------------------------------------------------- -# Programmer(s): Daniel R. Reynolds @ SMU -# --------------------------------------------------------------- -# SUNDIALS Copyright Start -# Copyright (c) 2002-2023, 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 -# --------------------------------------------------------------- - -# Create a library out of the generic sundials modules -sundials_add_library(sundials_sunadaptcontrollerimpgus - SOURCES - sunadaptcontroller_impgus.c - HEADERS - ${SUNDIALS_SOURCE_DIR}/include/sunadaptcontroller/sunadaptcontroller_impgus.h - INCLUDE_SUBDIR - sunadaptcontroller - OBJECT_LIB_ONLY -) - -# Add F2003 module if the interface is enabled -if(BUILD_FORTRAN_MODULE_INTERFACE) - add_subdirectory(fmod) -endif() diff --git a/src/sunadaptcontroller/impgus/fmod/CMakeLists.txt b/src/sunadaptcontroller/impgus/fmod/CMakeLists.txt deleted file mode 100644 index ed5ff03515..0000000000 --- a/src/sunadaptcontroller/impgus/fmod/CMakeLists.txt +++ /dev/null @@ -1,25 +0,0 @@ -# --------------------------------------------------------------- -# Programmer(s): Daniel R. Reynolds @ SMU -# --------------------------------------------------------------- -# SUNDIALS Copyright Start -# Copyright (c) 2002-2023, 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 -# --------------------------------------------------------------- - -sundials_add_f2003_library(sundials_fsunadaptcontrollerimpgus_mod - SOURCES - fsunadaptcontroller_impgus_mod.f90 fsunadaptcontroller_impgus_mod.c - OBJECT_LIBRARIES - sundials_fgeneric_mod_obj - OUTPUT_NAME - sundials_fsunadaptcontrollerimpgus_mod - OBJECT_LIB_ONLY -) - -message(STATUS "Added SUNAdaptController_ImpGus F2003 interface") diff --git a/src/sunadaptcontroller/impgus/fmod/fsunadaptcontroller_impgus_mod.c b/src/sunadaptcontroller/impgus/fmod/fsunadaptcontroller_impgus_mod.c deleted file mode 100644 index dac6ed176e..0000000000 --- a/src/sunadaptcontroller/impgus/fmod/fsunadaptcontroller_impgus_mod.c +++ /dev/null @@ -1,355 +0,0 @@ -/* ---------------------------------------------------------------------------- - * This file was automatically generated by SWIG (http://www.swig.org). - * Version 4.0.0 - * - * This file is not intended to be easily readable and contains a number of - * coding conventions designed to improve portability and efficiency. Do not make - * changes to this file unless you know what you are doing--modify the SWIG - * interface file instead. - * ----------------------------------------------------------------------------- */ - -/* --------------------------------------------------------------- - * Programmer(s): Auto-generated by swig. - * --------------------------------------------------------------- - * SUNDIALS Copyright Start - * Copyright (c) 2002-2023, Lawrence Livermore National Security - * and Southern Methodist University. - * All rights reserved. - * - * See the top-level LICENSE and NOTICE files for details. - * - * SPDX-License-Identifier: BSD-3-Clause - * SUNDIALS Copyright End - * -------------------------------------------------------------*/ - -/* ----------------------------------------------------------------------------- - * This section contains generic SWIG labels for method/variable - * declarations/attributes, and other compiler dependent labels. - * ----------------------------------------------------------------------------- */ - -/* template workaround for compilers that cannot correctly implement the C++ standard */ -#ifndef SWIGTEMPLATEDISAMBIGUATOR -# if defined(__SUNPRO_CC) && (__SUNPRO_CC <= 0x560) -# define SWIGTEMPLATEDISAMBIGUATOR template -# elif defined(__HP_aCC) -/* Needed even with `aCC -AA' when `aCC -V' reports HP ANSI C++ B3910B A.03.55 */ -/* If we find a maximum version that requires this, the test would be __HP_aCC <= 35500 for A.03.55 */ -# define SWIGTEMPLATEDISAMBIGUATOR template -# else -# define SWIGTEMPLATEDISAMBIGUATOR -# endif -#endif - -/* inline attribute */ -#ifndef SWIGINLINE -# if defined(__cplusplus) || (defined(__GNUC__) && !defined(__STRICT_ANSI__)) -# define SWIGINLINE inline -# else -# define SWIGINLINE -# endif -#endif - -/* attribute recognised by some compilers to avoid 'unused' warnings */ -#ifndef SWIGUNUSED -# if defined(__GNUC__) -# if !(defined(__cplusplus)) || (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)) -# define SWIGUNUSED __attribute__ ((__unused__)) -# else -# define SWIGUNUSED -# endif -# elif defined(__ICC) -# define SWIGUNUSED __attribute__ ((__unused__)) -# else -# define SWIGUNUSED -# endif -#endif - -#ifndef SWIG_MSC_UNSUPPRESS_4505 -# if defined(_MSC_VER) -# pragma warning(disable : 4505) /* unreferenced local function has been removed */ -# endif -#endif - -#ifndef SWIGUNUSEDPARM -# ifdef __cplusplus -# define SWIGUNUSEDPARM(p) -# else -# define SWIGUNUSEDPARM(p) p SWIGUNUSED -# endif -#endif - -/* internal SWIG method */ -#ifndef SWIGINTERN -# define SWIGINTERN static SWIGUNUSED -#endif - -/* internal inline SWIG method */ -#ifndef SWIGINTERNINLINE -# define SWIGINTERNINLINE SWIGINTERN SWIGINLINE -#endif - -/* qualifier for exported *const* global data variables*/ -#ifndef SWIGEXTERN -# ifdef __cplusplus -# define SWIGEXTERN extern -# else -# define SWIGEXTERN -# endif -#endif - -/* exporting methods */ -#if defined(__GNUC__) -# if (__GNUC__ >= 4) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) -# ifndef GCC_HASCLASSVISIBILITY -# define GCC_HASCLASSVISIBILITY -# endif -# endif -#endif - -#ifndef SWIGEXPORT -# if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__) -# if defined(STATIC_LINKED) -# define SWIGEXPORT -# else -# define SWIGEXPORT __declspec(dllexport) -# endif -# else -# if defined(__GNUC__) && defined(GCC_HASCLASSVISIBILITY) -# define SWIGEXPORT __attribute__ ((visibility("default"))) -# else -# define SWIGEXPORT -# endif -# endif -#endif - -/* calling conventions for Windows */ -#ifndef SWIGSTDCALL -# if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__) -# define SWIGSTDCALL __stdcall -# else -# define SWIGSTDCALL -# endif -#endif - -/* Deal with Microsoft's attempt at deprecating C standard runtime functions */ -#if !defined(SWIG_NO_CRT_SECURE_NO_DEPRECATE) && defined(_MSC_VER) && !defined(_CRT_SECURE_NO_DEPRECATE) -# define _CRT_SECURE_NO_DEPRECATE -#endif - -/* Deal with Microsoft's attempt at deprecating methods in the standard C++ library */ -#if !defined(SWIG_NO_SCL_SECURE_NO_DEPRECATE) && defined(_MSC_VER) && !defined(_SCL_SECURE_NO_DEPRECATE) -# define _SCL_SECURE_NO_DEPRECATE -#endif - -/* Deal with Apple's deprecated 'AssertMacros.h' from Carbon-framework */ -#if defined(__APPLE__) && !defined(__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES) -# define __ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES 0 -#endif - -/* Intel's compiler complains if a variable which was never initialised is - * cast to void, which is a common idiom which we use to indicate that we - * are aware a variable isn't used. So we just silence that warning. - * See: https://github.com/swig/swig/issues/192 for more discussion. - */ -#ifdef __INTEL_COMPILER -# pragma warning disable 592 -#endif - -/* Errors in SWIG */ -#define SWIG_UnknownError -1 -#define SWIG_IOError -2 -#define SWIG_RuntimeError -3 -#define SWIG_IndexError -4 -#define SWIG_TypeError -5 -#define SWIG_DivisionByZero -6 -#define SWIG_OverflowError -7 -#define SWIG_SyntaxError -8 -#define SWIG_ValueError -9 -#define SWIG_SystemError -10 -#define SWIG_AttributeError -11 -#define SWIG_MemoryError -12 -#define SWIG_NullReferenceError -13 - - - - -#include -#define SWIG_exception_impl(DECL, CODE, MSG, RETURNNULL) \ - { printf("In " DECL ": " MSG); assert(0); RETURNNULL; } - - -#include -#if defined(_MSC_VER) || defined(__BORLANDC__) || defined(_WATCOM) -# ifndef snprintf -# define snprintf _snprintf -# endif -#endif - - -/* Support for the `contract` feature. - * - * Note that RETURNNULL is first because it's inserted via a 'Replaceall' in - * the fortran.cxx file. - */ -#define SWIG_contract_assert(RETURNNULL, EXPR, MSG) \ - if (!(EXPR)) { SWIG_exception_impl("$decl", SWIG_ValueError, MSG, RETURNNULL); } - - -#define SWIGVERSION 0x040000 -#define SWIG_VERSION SWIGVERSION - - -#define SWIG_as_voidptr(a) (void *)((const void *)(a)) -#define SWIG_as_voidptrptr(a) ((void)SWIG_as_voidptr(*a),(void**)(a)) - - -#include "sundials/sundials_adaptcontroller.h" - - -#include "sunadaptcontroller/sunadaptcontroller_impgus.h" - -SWIGEXPORT SUNAdaptController _wrap_FSUNAdaptController_ImpGus(void *farg1) { - SUNAdaptController fresult ; - SUNContext arg1 = (SUNContext) 0 ; - SUNAdaptController result; - - arg1 = (SUNContext)(farg1); - result = (SUNAdaptController)SUNAdaptController_ImpGus(arg1); - fresult = result; - return fresult; -} - - -SWIGEXPORT int _wrap_FSUNAdaptController_SetParams_ImpGus(SUNAdaptController farg1, double const *farg2, double const *farg3) { - int fresult ; - SUNAdaptController arg1 = (SUNAdaptController) 0 ; - sunrealtype arg2 ; - sunrealtype arg3 ; - int result; - - arg1 = (SUNAdaptController)(farg1); - arg2 = (sunrealtype)(*farg2); - arg3 = (sunrealtype)(*farg3); - result = (int)SUNAdaptController_SetParams_ImpGus(arg1,arg2,arg3); - fresult = (int)(result); - return fresult; -} - - -SWIGEXPORT int _wrap_FSUNAdaptController_GetType_ImpGus(SUNAdaptController farg1) { - int fresult ; - SUNAdaptController arg1 = (SUNAdaptController) 0 ; - SUNAdaptController_Type result; - - arg1 = (SUNAdaptController)(farg1); - result = (SUNAdaptController_Type)SUNAdaptController_GetType_ImpGus(arg1); - fresult = (int)(result); - return fresult; -} - - -SWIGEXPORT int _wrap_FSUNAdaptController_EstimateStep_ImpGus(SUNAdaptController farg1, double const *farg2, int const *farg3, double const *farg4, double *farg5) { - int fresult ; - SUNAdaptController arg1 = (SUNAdaptController) 0 ; - sunrealtype arg2 ; - int arg3 ; - sunrealtype arg4 ; - sunrealtype *arg5 = (sunrealtype *) 0 ; - int result; - - arg1 = (SUNAdaptController)(farg1); - arg2 = (sunrealtype)(*farg2); - arg3 = (int)(*farg3); - arg4 = (sunrealtype)(*farg4); - arg5 = (sunrealtype *)(farg5); - result = (int)SUNAdaptController_EstimateStep_ImpGus(arg1,arg2,arg3,arg4,arg5); - fresult = (int)(result); - return fresult; -} - - -SWIGEXPORT int _wrap_FSUNAdaptController_Reset_ImpGus(SUNAdaptController farg1) { - int fresult ; - SUNAdaptController arg1 = (SUNAdaptController) 0 ; - int result; - - arg1 = (SUNAdaptController)(farg1); - result = (int)SUNAdaptController_Reset_ImpGus(arg1); - fresult = (int)(result); - return fresult; -} - - -SWIGEXPORT int _wrap_FSUNAdaptController_SetDefaults_ImpGus(SUNAdaptController farg1) { - int fresult ; - SUNAdaptController arg1 = (SUNAdaptController) 0 ; - int result; - - arg1 = (SUNAdaptController)(farg1); - result = (int)SUNAdaptController_SetDefaults_ImpGus(arg1); - fresult = (int)(result); - return fresult; -} - - -SWIGEXPORT int _wrap_FSUNAdaptController_Write_ImpGus(SUNAdaptController farg1, void *farg2) { - int fresult ; - SUNAdaptController arg1 = (SUNAdaptController) 0 ; - FILE *arg2 = (FILE *) 0 ; - int result; - - arg1 = (SUNAdaptController)(farg1); - arg2 = (FILE *)(farg2); - result = (int)SUNAdaptController_Write_ImpGus(arg1,arg2); - fresult = (int)(result); - return fresult; -} - - -SWIGEXPORT int _wrap_FSUNAdaptController_SetErrorBias_ImpGus(SUNAdaptController farg1, double const *farg2) { - int fresult ; - SUNAdaptController arg1 = (SUNAdaptController) 0 ; - sunrealtype arg2 ; - int result; - - arg1 = (SUNAdaptController)(farg1); - arg2 = (sunrealtype)(*farg2); - result = (int)SUNAdaptController_SetErrorBias_ImpGus(arg1,arg2); - fresult = (int)(result); - return fresult; -} - - -SWIGEXPORT int _wrap_FSUNAdaptController_Update_ImpGus(SUNAdaptController farg1, double const *farg2, double const *farg3) { - int fresult ; - SUNAdaptController arg1 = (SUNAdaptController) 0 ; - sunrealtype arg2 ; - sunrealtype arg3 ; - int result; - - arg1 = (SUNAdaptController)(farg1); - arg2 = (sunrealtype)(*farg2); - arg3 = (sunrealtype)(*farg3); - result = (int)SUNAdaptController_Update_ImpGus(arg1,arg2,arg3); - fresult = (int)(result); - return fresult; -} - - -SWIGEXPORT int _wrap_FSUNAdaptController_Space_ImpGus(SUNAdaptController farg1, long *farg2, long *farg3) { - int fresult ; - SUNAdaptController arg1 = (SUNAdaptController) 0 ; - long *arg2 = (long *) 0 ; - long *arg3 = (long *) 0 ; - int result; - - arg1 = (SUNAdaptController)(farg1); - arg2 = (long *)(farg2); - arg3 = (long *)(farg3); - result = (int)SUNAdaptController_Space_ImpGus(arg1,arg2,arg3); - fresult = (int)(result); - return fresult; -} - - - diff --git a/src/sunadaptcontroller/impgus/fmod/fsunadaptcontroller_impgus_mod.f90 b/src/sunadaptcontroller/impgus/fmod/fsunadaptcontroller_impgus_mod.f90 deleted file mode 100644 index 48d8b238b6..0000000000 --- a/src/sunadaptcontroller/impgus/fmod/fsunadaptcontroller_impgus_mod.f90 +++ /dev/null @@ -1,307 +0,0 @@ -! This file was automatically generated by SWIG (http://www.swig.org). -! Version 4.0.0 -! -! Do not make changes to this file unless you know what you are doing--modify -! the SWIG interface file instead. - -! --------------------------------------------------------------- -! Programmer(s): Auto-generated by swig. -! --------------------------------------------------------------- -! SUNDIALS Copyright Start -! Copyright (c) 2002-2023, 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 -! --------------------------------------------------------------- - -module fsunadaptcontroller_impgus_mod - use, intrinsic :: ISO_C_BINDING - use fsundials_adaptcontroller_mod - use fsundials_types_mod - use fsundials_context_mod - implicit none - private - - ! DECLARATION CONSTRUCTS - public :: FSUNAdaptController_ImpGus - public :: FSUNAdaptController_SetParams_ImpGus - public :: FSUNAdaptController_GetType_ImpGus - public :: FSUNAdaptController_EstimateStep_ImpGus - public :: FSUNAdaptController_Reset_ImpGus - public :: FSUNAdaptController_SetDefaults_ImpGus - public :: FSUNAdaptController_Write_ImpGus - public :: FSUNAdaptController_SetErrorBias_ImpGus - public :: FSUNAdaptController_Update_ImpGus - public :: FSUNAdaptController_Space_ImpGus - -! WRAPPER DECLARATIONS -interface -function swigc_FSUNAdaptController_ImpGus(farg1) & -bind(C, name="_wrap_FSUNAdaptController_ImpGus") & -result(fresult) -use, intrinsic :: ISO_C_BINDING -type(C_PTR), value :: farg1 -type(C_PTR) :: fresult -end function - -function swigc_FSUNAdaptController_SetParams_ImpGus(farg1, farg2, farg3) & -bind(C, name="_wrap_FSUNAdaptController_SetParams_ImpGus") & -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_FSUNAdaptController_GetType_ImpGus(farg1) & -bind(C, name="_wrap_FSUNAdaptController_GetType_ImpGus") & -result(fresult) -use, intrinsic :: ISO_C_BINDING -type(C_PTR), value :: farg1 -integer(C_INT) :: fresult -end function - -function swigc_FSUNAdaptController_EstimateStep_ImpGus(farg1, farg2, farg3, farg4, farg5) & -bind(C, name="_wrap_FSUNAdaptController_EstimateStep_ImpGus") & -result(fresult) -use, intrinsic :: ISO_C_BINDING -type(C_PTR), value :: farg1 -real(C_DOUBLE), intent(in) :: farg2 -integer(C_INT), intent(in) :: farg3 -real(C_DOUBLE), intent(in) :: farg4 -type(C_PTR), value :: farg5 -integer(C_INT) :: fresult -end function - -function swigc_FSUNAdaptController_Reset_ImpGus(farg1) & -bind(C, name="_wrap_FSUNAdaptController_Reset_ImpGus") & -result(fresult) -use, intrinsic :: ISO_C_BINDING -type(C_PTR), value :: farg1 -integer(C_INT) :: fresult -end function - -function swigc_FSUNAdaptController_SetDefaults_ImpGus(farg1) & -bind(C, name="_wrap_FSUNAdaptController_SetDefaults_ImpGus") & -result(fresult) -use, intrinsic :: ISO_C_BINDING -type(C_PTR), value :: farg1 -integer(C_INT) :: fresult -end function - -function swigc_FSUNAdaptController_Write_ImpGus(farg1, farg2) & -bind(C, name="_wrap_FSUNAdaptController_Write_ImpGus") & -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_FSUNAdaptController_SetErrorBias_ImpGus(farg1, farg2) & -bind(C, name="_wrap_FSUNAdaptController_SetErrorBias_ImpGus") & -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_FSUNAdaptController_Update_ImpGus(farg1, farg2, farg3) & -bind(C, name="_wrap_FSUNAdaptController_Update_ImpGus") & -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_FSUNAdaptController_Space_ImpGus(farg1, farg2, farg3) & -bind(C, name="_wrap_FSUNAdaptController_Space_ImpGus") & -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 - -end interface - - -contains - ! MODULE SUBPROGRAMS -function FSUNAdaptController_ImpGus(sunctx) & -result(swig_result) -use, intrinsic :: ISO_C_BINDING -type(SUNAdaptController), pointer :: swig_result -type(C_PTR) :: sunctx -type(C_PTR) :: fresult -type(C_PTR) :: farg1 - -farg1 = sunctx -fresult = swigc_FSUNAdaptController_ImpGus(farg1) -call c_f_pointer(fresult, swig_result) -end function - -function FSUNAdaptController_SetParams_ImpGus(c, k1, k2) & -result(swig_result) -use, intrinsic :: ISO_C_BINDING -integer(C_INT) :: swig_result -type(SUNAdaptController), target, intent(inout) :: c -real(C_DOUBLE), intent(in) :: k1 -real(C_DOUBLE), intent(in) :: k2 -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -real(C_DOUBLE) :: farg2 -real(C_DOUBLE) :: farg3 - -farg1 = c_loc(c) -farg2 = k1 -farg3 = k2 -fresult = swigc_FSUNAdaptController_SetParams_ImpGus(farg1, farg2, farg3) -swig_result = fresult -end function - -function FSUNAdaptController_GetType_ImpGus(c) & -result(swig_result) -use, intrinsic :: ISO_C_BINDING -integer(SUNAdaptController_Type) :: swig_result -type(SUNAdaptController), target, intent(inout) :: c -integer(C_INT) :: fresult -type(C_PTR) :: farg1 - -farg1 = c_loc(c) -fresult = swigc_FSUNAdaptController_GetType_ImpGus(farg1) -swig_result = fresult -end function - -function FSUNAdaptController_EstimateStep_ImpGus(c, h, p, dsm, hnew) & -result(swig_result) -use, intrinsic :: ISO_C_BINDING -integer(C_INT) :: swig_result -type(SUNAdaptController), target, intent(inout) :: c -real(C_DOUBLE), intent(in) :: h -integer(C_INT), intent(in) :: p -real(C_DOUBLE), intent(in) :: dsm -real(C_DOUBLE), target, intent(inout) :: hnew -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -real(C_DOUBLE) :: farg2 -integer(C_INT) :: farg3 -real(C_DOUBLE) :: farg4 -type(C_PTR) :: farg5 - -farg1 = c_loc(c) -farg2 = h -farg3 = p -farg4 = dsm -farg5 = c_loc(hnew) -fresult = swigc_FSUNAdaptController_EstimateStep_ImpGus(farg1, farg2, farg3, farg4, farg5) -swig_result = fresult -end function - -function FSUNAdaptController_Reset_ImpGus(c) & -result(swig_result) -use, intrinsic :: ISO_C_BINDING -integer(C_INT) :: swig_result -type(SUNAdaptController), target, intent(inout) :: c -integer(C_INT) :: fresult -type(C_PTR) :: farg1 - -farg1 = c_loc(c) -fresult = swigc_FSUNAdaptController_Reset_ImpGus(farg1) -swig_result = fresult -end function - -function FSUNAdaptController_SetDefaults_ImpGus(c) & -result(swig_result) -use, intrinsic :: ISO_C_BINDING -integer(C_INT) :: swig_result -type(SUNAdaptController), target, intent(inout) :: c -integer(C_INT) :: fresult -type(C_PTR) :: farg1 - -farg1 = c_loc(c) -fresult = swigc_FSUNAdaptController_SetDefaults_ImpGus(farg1) -swig_result = fresult -end function - -function FSUNAdaptController_Write_ImpGus(c, fptr) & -result(swig_result) -use, intrinsic :: ISO_C_BINDING -integer(C_INT) :: swig_result -type(SUNAdaptController), target, intent(inout) :: c -type(C_PTR) :: fptr -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 - -farg1 = c_loc(c) -farg2 = fptr -fresult = swigc_FSUNAdaptController_Write_ImpGus(farg1, farg2) -swig_result = fresult -end function - -function FSUNAdaptController_SetErrorBias_ImpGus(c, bias) & -result(swig_result) -use, intrinsic :: ISO_C_BINDING -integer(C_INT) :: swig_result -type(SUNAdaptController), target, intent(inout) :: c -real(C_DOUBLE), intent(in) :: bias -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -real(C_DOUBLE) :: farg2 - -farg1 = c_loc(c) -farg2 = bias -fresult = swigc_FSUNAdaptController_SetErrorBias_ImpGus(farg1, farg2) -swig_result = fresult -end function - -function FSUNAdaptController_Update_ImpGus(c, h, dsm) & -result(swig_result) -use, intrinsic :: ISO_C_BINDING -integer(C_INT) :: swig_result -type(SUNAdaptController), target, intent(inout) :: c -real(C_DOUBLE), intent(in) :: h -real(C_DOUBLE), intent(in) :: dsm -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -real(C_DOUBLE) :: farg2 -real(C_DOUBLE) :: farg3 - -farg1 = c_loc(c) -farg2 = h -farg3 = dsm -fresult = swigc_FSUNAdaptController_Update_ImpGus(farg1, farg2, farg3) -swig_result = fresult -end function - -function FSUNAdaptController_Space_ImpGus(c, lenrw, leniw) & -result(swig_result) -use, intrinsic :: ISO_C_BINDING -integer(C_INT) :: swig_result -type(SUNAdaptController), target, intent(inout) :: c -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 = c_loc(c) -farg2 = c_loc(lenrw(1)) -farg3 = c_loc(leniw(1)) -fresult = swigc_FSUNAdaptController_Space_ImpGus(farg1, farg2, farg3) -swig_result = fresult -end function - - -end module diff --git a/src/sunadaptcontroller/impgus/sunadaptcontroller_impgus.c b/src/sunadaptcontroller/impgus/sunadaptcontroller_impgus.c deleted file mode 100644 index 44e2329fce..0000000000 --- a/src/sunadaptcontroller/impgus/sunadaptcontroller_impgus.c +++ /dev/null @@ -1,207 +0,0 @@ -/* ----------------------------------------------------------------- - * Programmer(s): Daniel R. Reynolds @ SMU - * ----------------------------------------------------------------- - * SUNDIALS Copyright Start - * Copyright (c) 2002-2023, Lawrence Livermore National Security - * and Southern Methodist University. - * All rights reserved. - * - * See the top-level LICENSE and NOTICE files for details. - * - * SPDX-License-Identifier: BSD-3-Clause - * SUNDIALS Copyright End - * ----------------------------------------------------------------- - * This is the implementation file for the SUNAdaptController_ImpGus - * module. - * -----------------------------------------------------------------*/ - -#include -#include -#include -#include - - -/* --------------- - * Macro accessors - * --------------- */ - -#define SACIMPGUS_CONTENT(C) ( (SUNAdaptControllerContent_ImpGus)(C->content) ) -#define SACIMPGUS_K1(C) ( SACIMPGUS_CONTENT(C)->k1 ) -#define SACIMPGUS_K2(C) ( SACIMPGUS_CONTENT(C)->k2 ) -#define SACIMPGUS_BIAS(C) ( SACIMPGUS_CONTENT(C)->bias ) -#define SACIMPGUS_EP(C) ( SACIMPGUS_CONTENT(C)->ep ) -#define SACIMPGUS_HP(C) ( SACIMPGUS_CONTENT(C)->hp ) -#define SACIMPGUS_FIRSTSTEP(C) ( SACIMPGUS_CONTENT(C)->firststep ) - -/* ------------------ - * Default parameters - * ------------------ */ - -#define DEFAULT_K1 RCONST(0.98) -#define DEFAULT_K2 RCONST(0.95) -#define DEFAULT_BIAS RCONST(1.5) -#define TINY RCONST(1.0e-10) - - -/* ----------------------------------------------------------------- - * exported functions - * ----------------------------------------------------------------- */ - -/* ----------------------------------------------------------------- - * Function to create a new ImpGus controller - */ - -SUNAdaptController SUNAdaptController_ImpGus(SUNContext sunctx) -{ - SUNAdaptController C; - SUNAdaptControllerContent_ImpGus content; - - /* Create an empty controller object */ - C = NULL; - C = SUNAdaptController_NewEmpty(sunctx); - if (C == NULL) { return (NULL); } - - /* Attach operations */ - C->ops->gettype = SUNAdaptController_GetType_ImpGus; - C->ops->estimatestep = SUNAdaptController_EstimateStep_ImpGus; - C->ops->reset = SUNAdaptController_Reset_ImpGus; - C->ops->setdefaults = SUNAdaptController_SetDefaults_ImpGus; - C->ops->write = SUNAdaptController_Write_ImpGus; - C->ops->seterrorbias = SUNAdaptController_SetErrorBias_ImpGus; - C->ops->update = SUNAdaptController_Update_ImpGus; - C->ops->space = SUNAdaptController_Space_ImpGus; - - /* Create content */ - content = NULL; - content = (SUNAdaptControllerContent_ImpGus)malloc(sizeof *content); - if (content == NULL) - { - (void) SUNAdaptController_Destroy(C); - return (NULL); - } - - /* Attach content */ - C->content = content; - - /* Fill content with default/reset values */ - SUNAdaptController_SetDefaults_ImpGus(C); - SUNAdaptController_Reset_ImpGus(C); - - return (C); -} - -/* ----------------------------------------------------------------- - * Function to set ImpGus parameters - */ - -int SUNAdaptController_SetParams_ImpGus(SUNAdaptController C, - sunrealtype k1, sunrealtype k2) -{ - SACIMPGUS_K1(C) = k1; - SACIMPGUS_K2(C) = k2; - return SUNADAPTCONTROLLER_SUCCESS; -} - - - -/* ----------------------------------------------------------------- - * implementation of controller operations - * ----------------------------------------------------------------- */ - -SUNAdaptController_Type SUNAdaptController_GetType_ImpGus(SUNAdaptController C) -{ return SUN_ADAPTCONTROLLER_H; } - -int SUNAdaptController_EstimateStep_ImpGus(SUNAdaptController C, sunrealtype h, - int p, sunrealtype dsm, sunrealtype* hnew) -{ - /* order parameter to use */ - const int ord = p + 1; - - /* modified method for first step */ - if (SACIMPGUS_FIRSTSTEP(C)) - { - /* set usable time-step adaptivity parameters */ - const sunrealtype k = -RCONST(1.0) / ord; - const sunrealtype e = SUNMAX(SACIMPGUS_BIAS(C) * dsm, TINY); - - /* compute estimated optimal time step size */ - *hnew = h * SUNRpowerR(e,k); - } - else - { - /* set usable time-step adaptivity parameters */ - const sunrealtype k1 = -SACIMPGUS_K1(C) / ord; - const sunrealtype k2 = -SACIMPGUS_K2(C) / ord; - const sunrealtype ecur = SACIMPGUS_BIAS(C) * dsm; - const sunrealtype e1 = SUNMAX(ecur, TINY); - const sunrealtype e2 = e1 / SUNMAX(SACIMPGUS_EP(C), TINY); - const sunrealtype hrat = h / SACIMPGUS_HP(C); - - /* compute estimated optimal time step size */ - *hnew = h * hrat * SUNRpowerR(e1,k1) * SUNRpowerR(e2,k2); - } - - /* return with success */ - return SUNADAPTCONTROLLER_SUCCESS; -} - -int SUNAdaptController_Reset_ImpGus(SUNAdaptController C) -{ - SACIMPGUS_EP(C) = RCONST(1.0); - SACIMPGUS_FIRSTSTEP(C) = SUNTRUE; - return SUNADAPTCONTROLLER_SUCCESS; -} - -int SUNAdaptController_SetDefaults_ImpGus(SUNAdaptController C) -{ - SACIMPGUS_K1(C) = DEFAULT_K1; - SACIMPGUS_K2(C) = DEFAULT_K2; - SACIMPGUS_BIAS(C) = DEFAULT_BIAS; - return SUNADAPTCONTROLLER_SUCCESS; -} - -int SUNAdaptController_Write_ImpGus(SUNAdaptController C, FILE *fptr) -{ - fprintf(fptr, "Implicit Gustafsson SUNAdaptController module:\n"); -#if defined(SUNDIALS_EXTENDED_PRECISION) - fprintf(fptr, " k1 = %32Lg\n", SACIMPGUS_K1(C)); - fprintf(fptr, " k2 = %32Lg\n", SACIMPGUS_K2(C)); - fprintf(fptr, " bias factor = %32Lg\n", SACIMPGUS_BIAS(C)); - fprintf(fptr, " previous error = %32Lg\n", SACIMPGUS_EP(C)); - fprintf(fptr, " previous step = %32Lg\n", SACIMPGUS_HP(C)); -#else - fprintf(fptr, " k1 = %16g\n", SACIMPGUS_K1(C)); - fprintf(fptr, " k2 = %16g\n", SACIMPGUS_K2(C)); - fprintf(fptr, " bias factor = %16g\n", SACIMPGUS_BIAS(C)); - fprintf(fptr, " previous error = %16g\n", SACIMPGUS_EP(C)); - fprintf(fptr, " previous step = %16g\n", SACIMPGUS_HP(C)); -#endif - return SUNADAPTCONTROLLER_SUCCESS; -} - -int SUNAdaptController_SetErrorBias_ImpGus(SUNAdaptController C, sunrealtype bias) -{ - /* set allowed value, otherwise set default */ - if (bias <= RCONST(0.0)) { - SACIMPGUS_BIAS(C) = DEFAULT_BIAS; - } else { - SACIMPGUS_BIAS(C) = bias; - } - - return SUNADAPTCONTROLLER_SUCCESS; -} - -int SUNAdaptController_Update_ImpGus(SUNAdaptController C, sunrealtype h, sunrealtype dsm) -{ - SACIMPGUS_EP(C) = SACIMPGUS_BIAS(C) * dsm; - SACIMPGUS_HP(C) = h; - SACIMPGUS_FIRSTSTEP(C) = SUNFALSE; - return SUNADAPTCONTROLLER_SUCCESS; -} - -int SUNAdaptController_Space_ImpGus(SUNAdaptController C, long int* lenrw, long int* leniw) -{ - *lenrw = 5; - *leniw = 2; - return SUNADAPTCONTROLLER_SUCCESS; -} diff --git a/src/sunadaptcontroller/soderlind/fmod/fsunadaptcontroller_soderlind_mod.c b/src/sunadaptcontroller/soderlind/fmod/fsunadaptcontroller_soderlind_mod.c index 89d0d4407b..ab30541d28 100644 --- a/src/sunadaptcontroller/soderlind/fmod/fsunadaptcontroller_soderlind_mod.c +++ b/src/sunadaptcontroller/soderlind/fmod/fsunadaptcontroller_soderlind_mod.c @@ -442,4 +442,60 @@ SWIGEXPORT int _wrap_FSUNAdaptController_SetParams_I(SUNAdaptController farg1, d } +SWIGEXPORT SUNAdaptController _wrap_FSUNAdaptController_ExpGus(void *farg1) { + SUNAdaptController fresult ; + SUNContext arg1 = (SUNContext) 0 ; + SUNAdaptController result; + + arg1 = (SUNContext)(farg1); + result = (SUNAdaptController)SUNAdaptController_ExpGus(arg1); + fresult = result; + return fresult; +} + + +SWIGEXPORT int _wrap_FSUNAdaptController_SetParams_ExpGus(SUNAdaptController farg1, double const *farg2, double const *farg3) { + int fresult ; + SUNAdaptController arg1 = (SUNAdaptController) 0 ; + sunrealtype arg2 ; + sunrealtype arg3 ; + int result; + + arg1 = (SUNAdaptController)(farg1); + arg2 = (sunrealtype)(*farg2); + arg3 = (sunrealtype)(*farg3); + result = (int)SUNAdaptController_SetParams_ExpGus(arg1,arg2,arg3); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT SUNAdaptController _wrap_FSUNAdaptController_ImpGus(void *farg1) { + SUNAdaptController fresult ; + SUNContext arg1 = (SUNContext) 0 ; + SUNAdaptController result; + + arg1 = (SUNContext)(farg1); + result = (SUNAdaptController)SUNAdaptController_ImpGus(arg1); + fresult = result; + return fresult; +} + + +SWIGEXPORT int _wrap_FSUNAdaptController_SetParams_ImpGus(SUNAdaptController farg1, double const *farg2, double const *farg3) { + int fresult ; + SUNAdaptController arg1 = (SUNAdaptController) 0 ; + sunrealtype arg2 ; + sunrealtype arg3 ; + int result; + + arg1 = (SUNAdaptController)(farg1); + arg2 = (sunrealtype)(*farg2); + arg3 = (sunrealtype)(*farg3); + result = (int)SUNAdaptController_SetParams_ImpGus(arg1,arg2,arg3); + fresult = (int)(result); + return fresult; +} + + diff --git a/src/sunadaptcontroller/soderlind/fmod/fsunadaptcontroller_soderlind_mod.f90 b/src/sunadaptcontroller/soderlind/fmod/fsunadaptcontroller_soderlind_mod.f90 index bfee74fdf1..ea0c79b688 100644 --- a/src/sunadaptcontroller/soderlind/fmod/fsunadaptcontroller_soderlind_mod.f90 +++ b/src/sunadaptcontroller/soderlind/fmod/fsunadaptcontroller_soderlind_mod.f90 @@ -43,6 +43,10 @@ module fsunadaptcontroller_soderlind_mod public :: FSUNAdaptController_SetParams_PI public :: FSUNAdaptController_I public :: FSUNAdaptController_SetParams_I + public :: FSUNAdaptController_ExpGus + public :: FSUNAdaptController_SetParams_ExpGus + public :: FSUNAdaptController_ImpGus + public :: FSUNAdaptController_SetParams_ImpGus ! WRAPPER DECLARATIONS interface @@ -195,6 +199,42 @@ function swigc_FSUNAdaptController_SetParams_I(farg1, farg2) & integer(C_INT) :: fresult end function +function swigc_FSUNAdaptController_ExpGus(farg1) & +bind(C, name="_wrap_FSUNAdaptController_ExpGus") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +type(C_PTR), value :: farg1 +type(C_PTR) :: fresult +end function + +function swigc_FSUNAdaptController_SetParams_ExpGus(farg1, farg2, farg3) & +bind(C, name="_wrap_FSUNAdaptController_SetParams_ExpGus") & +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_FSUNAdaptController_ImpGus(farg1) & +bind(C, name="_wrap_FSUNAdaptController_ImpGus") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +type(C_PTR), value :: farg1 +type(C_PTR) :: fresult +end function + +function swigc_FSUNAdaptController_SetParams_ImpGus(farg1, farg2, farg3) & +bind(C, name="_wrap_FSUNAdaptController_SetParams_ImpGus") & +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 + end interface @@ -471,5 +511,69 @@ function FSUNAdaptController_SetParams_I(c, k1) & swig_result = fresult end function +function FSUNAdaptController_ExpGus(sunctx) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +type(SUNAdaptController), pointer :: swig_result +type(C_PTR) :: sunctx +type(C_PTR) :: fresult +type(C_PTR) :: farg1 + +farg1 = sunctx +fresult = swigc_FSUNAdaptController_ExpGus(farg1) +call c_f_pointer(fresult, swig_result) +end function + +function FSUNAdaptController_SetParams_ExpGus(c, k1, k2) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(SUNAdaptController), target, intent(inout) :: c +real(C_DOUBLE), intent(in) :: k1 +real(C_DOUBLE), intent(in) :: k2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +real(C_DOUBLE) :: farg2 +real(C_DOUBLE) :: farg3 + +farg1 = c_loc(c) +farg2 = k1 +farg3 = k2 +fresult = swigc_FSUNAdaptController_SetParams_ExpGus(farg1, farg2, farg3) +swig_result = fresult +end function + +function FSUNAdaptController_ImpGus(sunctx) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +type(SUNAdaptController), pointer :: swig_result +type(C_PTR) :: sunctx +type(C_PTR) :: fresult +type(C_PTR) :: farg1 + +farg1 = sunctx +fresult = swigc_FSUNAdaptController_ImpGus(farg1) +call c_f_pointer(fresult, swig_result) +end function + +function FSUNAdaptController_SetParams_ImpGus(c, k1, k2) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(SUNAdaptController), target, intent(inout) :: c +real(C_DOUBLE), intent(in) :: k1 +real(C_DOUBLE), intent(in) :: k2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +real(C_DOUBLE) :: farg2 +real(C_DOUBLE) :: farg3 + +farg1 = c_loc(c) +farg2 = k1 +farg3 = k2 +fresult = swigc_FSUNAdaptController_SetParams_ImpGus(farg1, farg2, farg3) +swig_result = fresult +end function + end module diff --git a/src/sunadaptcontroller/soderlind/sunadaptcontroller_soderlind.c b/src/sunadaptcontroller/soderlind/sunadaptcontroller_soderlind.c index b848d5ad1f..588c7fa04b 100644 --- a/src/sunadaptcontroller/soderlind/sunadaptcontroller_soderlind.c +++ b/src/sunadaptcontroller/soderlind/sunadaptcontroller_soderlind.c @@ -42,19 +42,23 @@ * Default parameters * ------------------ */ -#define DEFAULT_K1 RCONST(1.25) /* H_{0}321 parameters */ -#define DEFAULT_K2 RCONST(0.5) -#define DEFAULT_K3 RCONST(-0.75) -#define DEFAULT_K4 RCONST(0.25) -#define DEFAULT_K5 RCONST(0.75) -#define DEFAULT_PID_K1 RCONST(0.58) /* PID parameters */ -#define DEFAULT_PID_K2 -RCONST(0.21) -#define DEFAULT_PID_K3 RCONST(0.1) -#define DEFAULT_PI_K1 RCONST(0.8) /* PI parameters */ -#define DEFAULT_PI_K2 -RCONST(0.31) -#define DEFAULT_I_K1 RCONST(1.0) -#define DEFAULT_BIAS RCONST(1.5) /* I parameter */ -#define TINY RCONST(1.0e-10) +#define DEFAULT_K1 RCONST(1.25) /* H_{0}321 parameters */ +#define DEFAULT_K2 RCONST(0.5) +#define DEFAULT_K3 RCONST(-0.75) +#define DEFAULT_K4 RCONST(0.25) +#define DEFAULT_K5 RCONST(0.75) +#define DEFAULT_PID_K1 RCONST(0.58) /* PID parameters */ +#define DEFAULT_PID_K2 -RCONST(0.21) +#define DEFAULT_PID_K3 RCONST(0.1) +#define DEFAULT_PI_K1 RCONST(0.8) /* PI parameters */ +#define DEFAULT_PI_K2 -RCONST(0.31) +#define DEFAULT_I_K1 RCONST(1.0) /* I parameters */ +#define DEFAULT_EXPGUS_K1 RCONST(0.367) /* Explicit Gustafsson parameters */ +#define DEFAULT_EXPGUS_K2 RCONST(0.268) +#define DEFAULT_IMPGUS_K1 RCONST(0.98) /* Implicit Gustafsson parameters */ +#define DEFAULT_IMPGUS_K2 RCONST(0.95) +#define DEFAULT_BIAS RCONST(1.5) +#define TINY RCONST(1.0e-10) /* ----------------------------------------------------------------- @@ -207,6 +211,64 @@ int SUNAdaptController_SetParams_I(SUNAdaptController C, sunrealtype k1) return SUNADAPTCONTROLLER_SUCCESS; } +/* ----------------------------------------------------------------- + * Function to create an explicit Gustafsson controller + */ + +SUNAdaptController SUNAdaptController_ExpGus(SUNContext sunctx) +{ + SUNAdaptController C; + C = SUNAdaptController_Soderlind(sunctx); + (void) SUNAdaptController_SetParams_ExpGus(C, + DEFAULT_EXPGUS_K1, + DEFAULT_EXPGUS_K2); + return (C); +} + +/* ----------------------------------------------------------------- + * Function to set explicit Gustafsson parameters + */ + +int SUNAdaptController_SetParams_ExpGus(SUNAdaptController C, + sunrealtype k1, sunrealtype k2) +{ + SODERLIND_K1(C) = k1+k2; + SODERLIND_K2(C) = -k2; + SODERLIND_K3(C) = RCONST(0.0); + SODERLIND_K4(C) = RCONST(0.0); + SODERLIND_K5(C) = RCONST(0.0); + return SUNADAPTCONTROLLER_SUCCESS; +} + +/* ----------------------------------------------------------------- + * Function to create an implicit Gustafsson controller + */ + +SUNAdaptController SUNAdaptController_ImpGus(SUNContext sunctx) +{ + SUNAdaptController C; + C = SUNAdaptController_Soderlind(sunctx); + (void) SUNAdaptController_SetParams_ImpGus(C, + DEFAULT_IMPGUS_K1, + DEFAULT_IMPGUS_K2); + return (C); +} + +/* ----------------------------------------------------------------- + * Function to set explicit Gustafsson parameters + */ + +int SUNAdaptController_SetParams_ImpGus(SUNAdaptController C, + sunrealtype k1, sunrealtype k2) +{ + SODERLIND_K1(C) = k1+k2; + SODERLIND_K2(C) = -k2; + SODERLIND_K3(C) = RCONST(0.0); + SODERLIND_K4(C) = RCONST(1.0); + SODERLIND_K5(C) = RCONST(0.0); + return SUNADAPTCONTROLLER_SUCCESS; +} + /* ----------------------------------------------------------------- diff --git a/swig/Makefile b/swig/Makefile index 0451c69d25..23952614b4 100644 --- a/swig/Makefile +++ b/swig/Makefile @@ -25,7 +25,7 @@ NVECTOR=openmp pthreads serial parallel manyvector mpiplusx SUNMATRIX=band dense sparse SUNLINSOL=band dense klu spbcgs spfgmr spgmr sptfqmr pcg SUNNONLINSOL=newton fixedpoint -SUNADAPTCONTROLLER=expgus imexgus impgus noop soderlind +SUNADAPTCONTROLLER=imexgus noop soderlind INCLUDES=-I../include diff --git a/swig/sunadaptcontroller/fsunadaptcontroller_expgus_mod.i b/swig/sunadaptcontroller/fsunadaptcontroller_expgus_mod.i deleted file mode 100644 index b3644741e2..0000000000 --- a/swig/sunadaptcontroller/fsunadaptcontroller_expgus_mod.i +++ /dev/null @@ -1,29 +0,0 @@ -// --------------------------------------------------------------- -// Programmer: Daniel R. Reynolds @ SMU -// --------------------------------------------------------------- -// SUNDIALS Copyright Start -// Copyright (c) 2002-2023, 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 -// --------------------------------------------------------------- -// Swig interface file -// --------------------------------------------------------------- - -%module fsunadaptcontroller_expgus_mod - -// include code common to all implementations -%include "fsunadaptcontroller.i" - -%{ -#include "sunadaptcontroller/sunadaptcontroller_expgus.h" -%} - -%sunadaptcontroller_impl(ExpGus) - -// Process and wrap functions in the following files -%include "sunadaptcontroller/sunadaptcontroller_expgus.h" diff --git a/swig/sunadaptcontroller/fsunadaptcontroller_impgus_mod.i b/swig/sunadaptcontroller/fsunadaptcontroller_impgus_mod.i deleted file mode 100644 index e9f693c861..0000000000 --- a/swig/sunadaptcontroller/fsunadaptcontroller_impgus_mod.i +++ /dev/null @@ -1,29 +0,0 @@ -// --------------------------------------------------------------- -// Programmer: Daniel R. Reynolds @ SMU -// --------------------------------------------------------------- -// SUNDIALS Copyright Start -// Copyright (c) 2002-2023, 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 -// --------------------------------------------------------------- -// Swig interface file -// --------------------------------------------------------------- - -%module fsunadaptcontroller_impgus_mod - -// include code common to all implementations -%include "fsunadaptcontroller.i" - -%{ -#include "sunadaptcontroller/sunadaptcontroller_impgus.h" -%} - -%sunadaptcontroller_impl(ImpGus) - -// Process and wrap functions in the following files -%include "sunadaptcontroller/sunadaptcontroller_impgus.h" From 0d3589894c9c1e5812a36bba9a358f6721a26982 Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Thu, 26 Oct 2023 08:59:23 -0500 Subject: [PATCH 18/58] Updated real/integer workspace sizes in some .out files; updated test/answers to point to corresponding PR commit --- examples/arkode/C_serial/ark_KrylovDemo_prec.out | 8 ++++---- examples/arkode/C_serial/ark_KrylovDemo_prec_1.out | 8 ++++---- examples/arkode/C_serial/ark_KrylovDemo_prec_2.out | 8 ++++---- test/answers | 2 +- 4 files changed, 13 insertions(+), 13 deletions(-) diff --git a/examples/arkode/C_serial/ark_KrylovDemo_prec.out b/examples/arkode/C_serial/ark_KrylovDemo_prec.out index a2564a38ee..7004ffd6f4 100644 --- a/examples/arkode/C_serial/ark_KrylovDemo_prec.out +++ b/examples/arkode/C_serial/ark_KrylovDemo_prec.out @@ -418,7 +418,7 @@ Species 6 Final statistics for this run: - ARKStep real workspace length = 3554 + ARKStep real workspace length = 3558 ARKStep integer workspace length = 131 ARKLS real workspace length = 2647 ARKLS integer workspace length = 42 @@ -487,7 +487,7 @@ t = 1.00e+01 nst = 251 nfe = 0 nfi = 4101 nni = 2746 hu = 7.09e-02 Final statistics for this run: - ARKStep real workspace length = 3554 + ARKStep real workspace length = 3558 ARKStep integer workspace length = 136 ARKLS real workspace length = 2647 ARKLS integer workspace length = 42 @@ -556,7 +556,7 @@ t = 1.00e+01 nst = 359 nfe = 0 nfi = 5722 nni = 3907 hu = 1.35e-01 Final statistics for this run: - ARKStep real workspace length = 3554 + ARKStep real workspace length = 3558 ARKStep integer workspace length = 141 ARKLS real workspace length = 2647 ARKLS integer workspace length = 42 @@ -625,7 +625,7 @@ t = 1.00e+01 nst = 359 nfe = 0 nfi = 5728 nni = 3912 hu = 1.31e-01 Final statistics for this run: - ARKStep real workspace length = 3554 + ARKStep real workspace length = 3558 ARKStep integer workspace length = 146 ARKLS real workspace length = 2647 ARKLS integer workspace length = 42 diff --git a/examples/arkode/C_serial/ark_KrylovDemo_prec_1.out b/examples/arkode/C_serial/ark_KrylovDemo_prec_1.out index a2564a38ee..7004ffd6f4 100644 --- a/examples/arkode/C_serial/ark_KrylovDemo_prec_1.out +++ b/examples/arkode/C_serial/ark_KrylovDemo_prec_1.out @@ -418,7 +418,7 @@ Species 6 Final statistics for this run: - ARKStep real workspace length = 3554 + ARKStep real workspace length = 3558 ARKStep integer workspace length = 131 ARKLS real workspace length = 2647 ARKLS integer workspace length = 42 @@ -487,7 +487,7 @@ t = 1.00e+01 nst = 251 nfe = 0 nfi = 4101 nni = 2746 hu = 7.09e-02 Final statistics for this run: - ARKStep real workspace length = 3554 + ARKStep real workspace length = 3558 ARKStep integer workspace length = 136 ARKLS real workspace length = 2647 ARKLS integer workspace length = 42 @@ -556,7 +556,7 @@ t = 1.00e+01 nst = 359 nfe = 0 nfi = 5722 nni = 3907 hu = 1.35e-01 Final statistics for this run: - ARKStep real workspace length = 3554 + ARKStep real workspace length = 3558 ARKStep integer workspace length = 141 ARKLS real workspace length = 2647 ARKLS integer workspace length = 42 @@ -625,7 +625,7 @@ t = 1.00e+01 nst = 359 nfe = 0 nfi = 5728 nni = 3912 hu = 1.31e-01 Final statistics for this run: - ARKStep real workspace length = 3554 + ARKStep real workspace length = 3558 ARKStep integer workspace length = 146 ARKLS real workspace length = 2647 ARKLS integer workspace length = 42 diff --git a/examples/arkode/C_serial/ark_KrylovDemo_prec_2.out b/examples/arkode/C_serial/ark_KrylovDemo_prec_2.out index a2564a38ee..7004ffd6f4 100644 --- a/examples/arkode/C_serial/ark_KrylovDemo_prec_2.out +++ b/examples/arkode/C_serial/ark_KrylovDemo_prec_2.out @@ -418,7 +418,7 @@ Species 6 Final statistics for this run: - ARKStep real workspace length = 3554 + ARKStep real workspace length = 3558 ARKStep integer workspace length = 131 ARKLS real workspace length = 2647 ARKLS integer workspace length = 42 @@ -487,7 +487,7 @@ t = 1.00e+01 nst = 251 nfe = 0 nfi = 4101 nni = 2746 hu = 7.09e-02 Final statistics for this run: - ARKStep real workspace length = 3554 + ARKStep real workspace length = 3558 ARKStep integer workspace length = 136 ARKLS real workspace length = 2647 ARKLS integer workspace length = 42 @@ -556,7 +556,7 @@ t = 1.00e+01 nst = 359 nfe = 0 nfi = 5722 nni = 3907 hu = 1.35e-01 Final statistics for this run: - ARKStep real workspace length = 3554 + ARKStep real workspace length = 3558 ARKStep integer workspace length = 141 ARKLS real workspace length = 2647 ARKLS integer workspace length = 42 @@ -625,7 +625,7 @@ t = 1.00e+01 nst = 359 nfe = 0 nfi = 5728 nni = 3912 hu = 1.31e-01 Final statistics for this run: - ARKStep real workspace length = 3554 + ARKStep real workspace length = 3558 ARKStep integer workspace length = 146 ARKLS real workspace length = 2647 ARKLS integer workspace length = 42 diff --git a/test/answers b/test/answers index 8f1d469a42..a7864e00c9 160000 --- a/test/answers +++ b/test/answers @@ -1 +1 @@ -Subproject commit 8f1d469a426ffb562361ab2aa1702ad15194cb2c +Subproject commit a7864e00c9591dbebdad0cb474fbc75cc6193ee7 From 4ac5928005fc13cb8ce4571837f505457bdb7469 Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Thu, 26 Oct 2023 09:32:28 -0500 Subject: [PATCH 19/58] Updated lenrw and leniw in some more .out files --- examples/arkode/C_parallel/ark_diurnal_kry_bbd_p.out | 4 ++-- examples/arkode/C_parallel/ark_diurnal_kry_p.out | 2 +- examples/arkode/C_parhyp/ark_diurnal_kry_ph.out | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) 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 4ab235b940..37ae8ed10a 100644 --- a/examples/arkode/C_parallel/ark_diurnal_kry_bbd_p.out +++ b/examples/arkode/C_parallel/ark_diurnal_kry_bbd_p.out @@ -58,7 +58,7 @@ At top right: c1, c2 = -4.190e-08 4.163e+11 Final Statistics: -lenrw = 3898 leniw = 267 +lenrw = 3902 leniw = 267 lenrwls = 2455 leniwls = 126 nst = 7252 nfe = 0 nfe = 76109 nfels = 82856 @@ -127,7 +127,7 @@ At top right: c1, c2 = -6.607e-08 4.163e+11 Final Statistics: -lenrw = 3898 leniw = 272 +lenrw = 3902 leniw = 272 lenrwls = 2455 leniwls = 126 nst = 7364 nfe = 0 nfe = 77457 nfels = 101131 diff --git a/examples/arkode/C_parallel/ark_diurnal_kry_p.out b/examples/arkode/C_parallel/ark_diurnal_kry_p.out index c083cb2b31..04f0615d17 100644 --- a/examples/arkode/C_parallel/ark_diurnal_kry_p.out +++ b/examples/arkode/C_parallel/ark_diurnal_kry_p.out @@ -52,7 +52,7 @@ At top right: c1, c2 = 1.567e-26 4.163e+11 Final Statistics: -lenrw = 3298 leniw = 243 +lenrw = 3302 leniw = 243 lenrwls = 2455 leniwls = 126 nst = 7103 nfe = 0 nfi = 74602 nfels = 87206 diff --git a/examples/arkode/C_parhyp/ark_diurnal_kry_ph.out b/examples/arkode/C_parhyp/ark_diurnal_kry_ph.out index 43d41ae93a..dd10c31ddf 100644 --- a/examples/arkode/C_parhyp/ark_diurnal_kry_ph.out +++ b/examples/arkode/C_parhyp/ark_diurnal_kry_ph.out @@ -52,7 +52,7 @@ At top right: c1, c2 = -4.442e-20 4.163e+11 Final Statistics: -lenrw = 3298 leniw = 243 +lenrw = 3302 leniw = 243 lenrwls = 2455 leniwls = 126 nst = 7237 nfe = 0 nfi = 75881 nfels = 88695 From ac70b4140d183e6cf3e23423adcaef082450f0e6 Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Fri, 27 Oct 2023 10:31:21 -0500 Subject: [PATCH 20/58] Fixed broken reference --- .../guide/source/Usage/ARKStep_c_interface/User_callable.rst | 2 +- .../guide/source/Usage/ERKStep_c_interface/User_callable.rst | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) 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 379deb0d28..57488f4b3c 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 @@ -1720,7 +1720,7 @@ Explicit stability function :c:func:`ARKStepSetS **Arguments:** * *arkode_mem* -- pointer to the ARKStep memory block. - * *C* -- user-supplied time adaptivity controller. If ``NULL`` then the PID controller will be created (see :numref:`SUNAdaptController.PID`). + * *C* -- user-supplied time adaptivity controller. If ``NULL`` then the PID controller will be created (see :numref:`SUNAdaptController.Soderlind`). **Return value:** * *ARK_SUCCESS* if successful 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 ad22622783..3dfd49867e 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 @@ -1200,7 +1200,7 @@ the code, is provided in :numref:`ARKODE.Mathematics.Adaptivity`. **Arguments:** * *arkode_mem* -- pointer to the ERKStep memory block. - * *C* -- user-supplied time adaptivity controller. If ``NULL`` then the PID controller will be created (see :numref:`SUNAdaptController.PID`). + * *C* -- user-supplied time adaptivity controller. If ``NULL`` then the PID controller will be created (see :numref:`SUNAdaptController.Soderlind`). **Return value:** * *ARK_SUCCESS* if successful From 992f22d1bba756d98965aa87eb8d5030ad83356a Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Fri, 27 Oct 2023 10:32:23 -0500 Subject: [PATCH 21/58] Removed unicode character to satisfy Jenkins --- doc/shared/sunadaptcontroller/SUNAdaptController_Soderlind.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/shared/sunadaptcontroller/SUNAdaptController_Soderlind.rst b/doc/shared/sunadaptcontroller/SUNAdaptController_Soderlind.rst index ed2fd867ed..6d5ffa510f 100644 --- a/doc/shared/sunadaptcontroller/SUNAdaptController_Soderlind.rst +++ b/doc/shared/sunadaptcontroller/SUNAdaptController_Soderlind.rst @@ -19,7 +19,7 @@ The SUNAdaptController_Soderlind Module The Soderlind implementation of the SUNAdaptController class, SUNAdaptController_Soderlind, implements a general structure for temporal -control proposed by G. Söderlind in :cite:p:`Sod:98`, :cite:p:`Sod:03` +control proposed by G. Soderlind in :cite:p:`Sod:98`, :cite:p:`Sod:03` and :cite:p:`Sod:06`. This controller has the form .. math:: From 799efbeae6ba2a81451d9d0a69253f743585ef9e Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Fri, 27 Oct 2023 10:43:07 -0500 Subject: [PATCH 22/58] Fixed too-short title underline --- doc/shared/sunadaptcontroller/SUNAdaptController_Soderlind.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/shared/sunadaptcontroller/SUNAdaptController_Soderlind.rst b/doc/shared/sunadaptcontroller/SUNAdaptController_Soderlind.rst index 6d5ffa510f..1af37e5538 100644 --- a/doc/shared/sunadaptcontroller/SUNAdaptController_Soderlind.rst +++ b/doc/shared/sunadaptcontroller/SUNAdaptController_Soderlind.rst @@ -15,7 +15,7 @@ .. _SUNAdaptController.Soderlind: The SUNAdaptController_Soderlind Module -====================================== +======================================= The Soderlind implementation of the SUNAdaptController class, SUNAdaptController_Soderlind, implements a general structure for temporal From 4d9d966551d732647589a5f62cb41f0d6f7b5c1e Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Fri, 27 Oct 2023 13:32:58 -0500 Subject: [PATCH 23/58] Fixed errors in tar script --- scripts/shared | 48 ++++++++++++------------------------------------ 1 file changed, 12 insertions(+), 36 deletions(-) diff --git a/scripts/shared b/scripts/shared index 7d9c1d6d3e..b868df359f 100755 --- a/scripts/shared +++ b/scripts/shared @@ -177,12 +177,9 @@ $tar $tarfile $distrobase/include/nvector/nvector_trilinos.h $tar $tarfile $distrobase/include/nvector/trilinos/SundialsTpetraVectorInterface.hpp $tar $tarfile $distrobase/include/nvector/trilinos/SundialsTpetraVectorKernels.hpp -$tar $tarfile $distrobase/include/sunadaptcontroller/sunadaptcontroller_expgus.h -$tar $tarfile $distrobase/include/sunadaptcontroller/sunadaptcontroller_i.h $tar $tarfile $distrobase/include/sunadaptcontroller/sunadaptcontroller_imexgus.h -$tar $tarfile $distrobase/include/sunadaptcontroller/sunadaptcontroller_impgus.h -$tar $tarfile $distrobase/include/sunadaptcontroller/sunadaptcontroller_pi.h -$tar $tarfile $distrobase/include/sunadaptcontroller/sunadaptcontroller_pid.h +$tar $tarfile $distrobase/include/sunadaptcontroller/sunadaptcontroller_noop.h +$tar $tarfile $distrobase/include/sunadaptcontroller/sunadaptcontroller_soderlind.h $tar $tarfile $distrobase/include/sunmatrix/sunmatrix_band.h $tar $tarfile $distrobase/include/sunmatrix/sunmatrix_cusparse.h @@ -388,20 +385,6 @@ echo " --- Add sunadaptcontroller modules to $tarfile" $tar $tarfile $distrobase/src/sunadaptcontroller/CMakeLists.txt -echo " --- Add sunadaptcontroller/exp_gus module to $tarfile" - -$tar $tarfile $distrobase/src/sunadaptcontroller/expgus/CMakeLists.txt -$tar $tarfile $distrobase/src/sunadaptcontroller/expgus/sunadaptcontroller_expgus.c -$tar $tarfile $distrobase/src/sunadaptcontroller/expgus/fmod/fsunadaptcontroller_expgus_mod.c -$tar $tarfile $distrobase/src/sunadaptcontroller/expgus/fmod/fsunadaptcontroller_expgus_mod.f90 - -echo " --- Add sunadaptcontroller/i_control module to $tarfile" - -$tar $tarfile $distrobase/src/sunadaptcontroller/i/CMakeLists.txt -$tar $tarfile $distrobase/src/sunadaptcontroller/i/sunadaptcontroller_i.c -$tar $tarfile $distrobase/src/sunadaptcontroller/i/fmod/fsunadaptcontroller_i_mod.c -$tar $tarfile $distrobase/src/sunadaptcontroller/i/fmod/fsunadaptcontroller_i_mod.f90 - echo " --- Add sunadaptcontroller/imex_gus module to $tarfile" $tar $tarfile $distrobase/src/sunadaptcontroller/imexgus/CMakeLists.txt @@ -409,26 +392,19 @@ $tar $tarfile $distrobase/src/sunadaptcontroller/imexgus/sunadaptcontroller_imex $tar $tarfile $distrobase/src/sunadaptcontroller/imexgus/fmod/fsunadaptcontroller_imexgus_mod.c $tar $tarfile $distrobase/src/sunadaptcontroller/imexgus/fmod/fsunadaptcontroller_imexgus_mod.f90 -echo " --- Add sunadaptcontroller/imp_gus module to $tarfile" - -$tar $tarfile $distrobase/src/sunadaptcontroller/impgus/CMakeLists.txt -$tar $tarfile $distrobase/src/sunadaptcontroller/impgus/sunadaptcontroller_impgus.c -$tar $tarfile $distrobase/src/sunadaptcontroller/impgus/fmod/fsunadaptcontroller_impgus_mod.c -$tar $tarfile $distrobase/src/sunadaptcontroller/impgus/fmod/fsunadaptcontroller_impgus_mod.f90 - -echo " --- Add sunadaptcontroller/pi_control module to $tarfile" +echo " --- Add sunadaptcontroller/noop module to $tarfile" -$tar $tarfile $distrobase/src/sunadaptcontroller/pi/CMakeLists.txt -$tar $tarfile $distrobase/src/sunadaptcontroller/pi/sunadaptcontroller_pi.c -$tar $tarfile $distrobase/src/sunadaptcontroller/pi/fmod/fsunadaptcontroller_pi_mod.c -$tar $tarfile $distrobase/src/sunadaptcontroller/pi/fmod/fsunadaptcontroller_pi_mod.f90 +$tar $tarfile $distrobase/src/sunadaptcontroller/noop/CMakeLists.txt +$tar $tarfile $distrobase/src/sunadaptcontroller/noop/sunadaptcontroller_noop.c +$tar $tarfile $distrobase/src/sunadaptcontroller/noop/fmod/fsunadaptcontroller_noop_mod.c +$tar $tarfile $distrobase/src/sunadaptcontroller/noop/fmod/fsunadaptcontroller_noop_mod.f90 -echo " --- Add sunadaptcontroller/pid_control module to $tarfile" +echo " --- Add sunadaptcontroller/soderlind module to $tarfile" -$tar $tarfile $distrobase/src/sunadaptcontroller/pid/CMakeLists.txt -$tar $tarfile $distrobase/src/sunadaptcontroller/pid/sunadaptcontroller_pid.c -$tar $tarfile $distrobase/src/sunadaptcontroller/pid/fmod/fsunadaptcontroller_pid_mod.c -$tar $tarfile $distrobase/src/sunadaptcontroller/pid/fmod/fsunadaptcontroller_pid_mod.f90 +$tar $tarfile $distrobase/src/sunadaptcontroller/soderlind/CMakeLists.txt +$tar $tarfile $distrobase/src/sunadaptcontroller/soderlind/sunadaptcontroller_soderlind.c +$tar $tarfile $distrobase/src/sunadaptcontroller/soderlind/fmod/fsunadaptcontroller_soderlind_mod.c +$tar $tarfile $distrobase/src/sunadaptcontroller/soderlind/fmod/fsunadaptcontroller_soderlind_mod.f90 echo " --- Add sunmatrix modules to $tarfile" From 7615a60d933d89e52c01b35e6d3fa856284546ce Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Fri, 27 Oct 2023 14:38:42 -0500 Subject: [PATCH 24/58] Minor comment fix --- include/sunadaptcontroller/sunadaptcontroller_imexgus.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/sunadaptcontroller/sunadaptcontroller_imexgus.h b/include/sunadaptcontroller/sunadaptcontroller_imexgus.h index c1fed3044f..d039c82cce 100644 --- a/include/sunadaptcontroller/sunadaptcontroller_imexgus.h +++ b/include/sunadaptcontroller/sunadaptcontroller_imexgus.h @@ -74,4 +74,4 @@ int SUNAdaptController_Space_ImExGus(SUNAdaptController C, long int *lenrw, } #endif -#endif /* _SUNADAPTCONTROLLER_IMPGUS_H */ +#endif /* _SUNADAPTCONTROLLER_IMEXGUS_H */ From addd539f62d6daaa044d6db7a0cc8c73788f9945 Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Fri, 27 Oct 2023 14:48:06 -0500 Subject: [PATCH 25/58] Added include/sunadaptcontroller folder --- scripts/tarscript | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/tarscript b/scripts/tarscript index d0cfd79f78..60fcb19aa1 100755 --- a/scripts/tarscript +++ b/scripts/tarscript @@ -251,6 +251,7 @@ cp -r $sundialsdir/include/sunmatrix $tmpdir/include/ cp -r $sundialsdir/include/sunmemory $tmpdir/include/ cp -r $sundialsdir/include/sunlinsol $tmpdir/include/ cp -r $sundialsdir/include/sunnonlinsol $tmpdir/include/ +cp -r $sundialsdir/include/sunadaptcontroller $tmpdir/include/ cp -r $sundialsdir/scripts $tmpdir/ From 2b891578140453c9f05bbb929975fe30793df31f Mon Sep 17 00:00:00 2001 From: "David J. Gardner" Date: Fri, 27 Oct 2023 21:34:10 -0700 Subject: [PATCH 26/58] add src/sunadaptcontroller to tarscript --- scripts/tarscript | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/tarscript b/scripts/tarscript index 60fcb19aa1..c4252322c5 100755 --- a/scripts/tarscript +++ b/scripts/tarscript @@ -262,6 +262,7 @@ cp -r $sundialsdir/src/sunmatrix $tmpdir/src/ cp -r $sundialsdir/src/sunmemory $tmpdir/src/ cp -r $sundialsdir/src/sunlinsol $tmpdir/src/ cp -r $sundialsdir/src/sunnonlinsol $tmpdir/src/ +cp -r $sundialsdir/src/sunadaptcontroller $tmpdir/src/ cp $sundialsdir/test/testRunner $tmpdir/test/ cp -r $sundialsdir/test/unit_tests $tmpdir/test/ From d959c28dd350ab747f694a1e07a08ffd26865349 Mon Sep 17 00:00:00 2001 From: "David J. Gardner" Date: Sat, 28 Oct 2023 03:51:19 -0700 Subject: [PATCH 27/58] add fmod CMakeLists.txt to tarscript --- scripts/shared | 3 +++ 1 file changed, 3 insertions(+) diff --git a/scripts/shared b/scripts/shared index 8c1aa013e6..f34641328d 100755 --- a/scripts/shared +++ b/scripts/shared @@ -389,6 +389,7 @@ echo " --- Add sunadaptcontroller/imex_gus module to $tarfile" $tar $tarfile $distrobase/src/sunadaptcontroller/imexgus/CMakeLists.txt $tar $tarfile $distrobase/src/sunadaptcontroller/imexgus/sunadaptcontroller_imexgus.c +$tar $tarfile $distrobase/src/sunadaptcontroller/imexgus/fmod/CMakeLists.txt $tar $tarfile $distrobase/src/sunadaptcontroller/imexgus/fmod/fsunadaptcontroller_imexgus_mod.c $tar $tarfile $distrobase/src/sunadaptcontroller/imexgus/fmod/fsunadaptcontroller_imexgus_mod.f90 @@ -396,6 +397,7 @@ echo " --- Add sunadaptcontroller/noop module to $tarfile" $tar $tarfile $distrobase/src/sunadaptcontroller/noop/CMakeLists.txt $tar $tarfile $distrobase/src/sunadaptcontroller/noop/sunadaptcontroller_noop.c +$tar $tarfile $distrobase/src/sunadaptcontroller/noop/fmod/CMakeLists.txt $tar $tarfile $distrobase/src/sunadaptcontroller/noop/fmod/fsunadaptcontroller_noop_mod.c $tar $tarfile $distrobase/src/sunadaptcontroller/noop/fmod/fsunadaptcontroller_noop_mod.f90 @@ -403,6 +405,7 @@ echo " --- Add sunadaptcontroller/soderlind module to $tarfile" $tar $tarfile $distrobase/src/sunadaptcontroller/soderlind/CMakeLists.txt $tar $tarfile $distrobase/src/sunadaptcontroller/soderlind/sunadaptcontroller_soderlind.c +$tar $tarfile $distrobase/src/sunadaptcontroller/soderlind/fmod/CMakeLists.txt $tar $tarfile $distrobase/src/sunadaptcontroller/soderlind/fmod/fsunadaptcontroller_soderlind_mod.c $tar $tarfile $distrobase/src/sunadaptcontroller/soderlind/fmod/fsunadaptcontroller_soderlind_mod.f90 From f84cf4fb27adb822a960ac2743a601899513b0df Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Mon, 30 Oct 2023 21:10:56 -0500 Subject: [PATCH 28/58] Updates from code review --- CHANGELOG.md | 18 +++++++++++++----- doc/arkode/guide/source/Mathematics.rst | 8 +++++--- 2 files changed, 18 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2e0ae3c2d6..9087161a82 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,13 +3,21 @@ ## Changes to SUNDIALS in release X.X.X -Added the `SUNAdaptController` base class, ported ARKODE's internal -implementations of time step controllers into implementations of this class, -and updated ARKODE to use these objects instead of its own implementations. -Added `ARKStepSetAdaptController` and `ERKStepSetAdaptController` routines -so that users can modify controller parameters, or even provide custom +Added the `SUNAdaptController` base class, ported ARKODE's internal +implementations of time step controllers into implementations of this class, +and updated ARKODE to use these objects instead of its own implementations. +Added `ARKStepSetAdaptController` and `ERKStepSetAdaptController` routines +so that users can modify controller parameters, or even provide custom implementations. +Added the routines `ARKStepSetAdaptivityAdjustment` and +`ERKStepSetAdaptivityAdjustment`, that allow users to adjust the +value for the method order supplied to the temporal adaptivity controllers. +The ARKODE default for this adjustment has been :math:`-1` since its initial +release, but for some applications a value of :math:`0` is more appropriate. +Users who notice that their simulations encounter a large number of +temporal error test failures may want to experiment with adjusting this value. + Fixed a regression introduced by the stop time bug fix in v6.6.1 where ARKODE, CVODE, CVODES, IDA, and IDAS would return at the stop time rather than the requested output time if the stop time was reached in the same step in which the diff --git a/doc/arkode/guide/source/Mathematics.rst b/doc/arkode/guide/source/Mathematics.rst index 0d986d056a..7031fd072d 100644 --- a/doc/arkode/guide/source/Mathematics.rst +++ b/doc/arkode/guide/source/Mathematics.rst @@ -911,14 +911,16 @@ First, any valid implementation of the SUNAdaptController class time-stepping modules to provide a candidate error-based prospective step size :math:`h'`. -Second, ARKODE's adaptive time-stepping modules allow the user to define their -own time step adaptivity function, +Second, ARKODE's adaptive time-stepping modules currently still allow the +user to define their own time step adaptivity function, .. math:: h' = H(y, t, h_n, h_{n-1}, h_{n-2}, \varepsilon_n, \varepsilon_{n-1}, \varepsilon_{n-2}, q, p), allowing for problem-specific choices, or for continued -experimentation with temporal error controllers. +experimentation with temporal error controllers. We note that this +support has been deprecated in favor of the SUNAdaptController class, +and will be removed in a future release. From a4594631738a5c95680f7405c8025e7d731f7265 Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Mon, 30 Oct 2023 21:56:11 -0500 Subject: [PATCH 29/58] Updates from code review --- .../ARKStep_c_interface/User_callable.rst | 3 + .../ERKStep_c_interface/User_callable.rst | 9 ++ .../SUNAdaptController_Description.rst | 139 +----------------- .../SUNAdaptController_ImExGus.rst | 23 ++- .../SUNAdaptController_Soderlind.rst | 40 ++--- .../SUNAdaptController_links.rst | 1 + .../source/sunadaptcontroller/index.rst | 13 +- 7 files changed, 61 insertions(+), 167 deletions(-) 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 57488f4b3c..7b23cf149e 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 @@ -1858,6 +1858,9 @@ Explicit stability function :c:func:`ARKStepSetS :c:func:`ARKStepSetAdaptController` will be called, then this routine must be called *second*. + .. deprecated:: x.x.x + + Use the SUNAdaptController infrastructure instead (see :numref:`SUNAdaptController.Description`). .. c:function:: int ARKStepSetFixedStepBounds(void* arkode_mem, realtype lb, realtype ub) 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 3dfd49867e..a3bf27c191 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 @@ -1207,6 +1207,11 @@ the code, is provided in :numref:`ARKODE.Mathematics.Adaptivity`. * *ARK_MEM_NULL* if the ERKStep memory is ``NULL`` * *ARK_MEM_FAIL* if *C* was ``NULL`` and the PID controller could not be allocated. + **Notes:** + When *C* is ``NULL``, the PID controller that is created is not the same as the ERKStep default (PI). + To reset ERKStep to its default behavior after a non-default controller has been used, users should either + specifically create the PI controller *C* and attach it here, or call :c:func:`ERKStepSetDefaults()`. + .. versionadded:: x.x.x @@ -1336,6 +1341,10 @@ the code, is provided in :numref:`ARKODE.Mathematics.Adaptivity`. :c:func:`ERKStepSetAdaptController` will be called, then this routine must be called *second*. + .. deprecated:: x.x.x + + Use the SUNAdaptController infrastructure instead (see :numref:`SUNAdaptController.Description`). + .. c:function:: int ERKStepSetFixedStepBounds(void* arkode_mem, realtype lb, realtype ub) diff --git a/doc/shared/sunadaptcontroller/SUNAdaptController_Description.rst b/doc/shared/sunadaptcontroller/SUNAdaptController_Description.rst index 1c045b953d..c1b88c837b 100644 --- a/doc/shared/sunadaptcontroller/SUNAdaptController_Description.rst +++ b/doc/shared/sunadaptcontroller/SUNAdaptController_Description.rst @@ -22,7 +22,7 @@ The SUNAdaptController base class provides a common API for accuracy-based adapt controllers to be used by SUNDIALS integrators. These controllers estimate step sizes (among other things) such that the next step solution satisfies a desired temporal accuracy, while striving to maximize computational efficiency. We note -that in the descriptions below, we frequently use the object *dsm* to represent +that in the descriptions below, we frequently use *dsm* to represent temporal error. This is **not** the raw temporal error estimate; instead, it is a norm of the temporal error estimate after scaling by the user-supplied accuracy tolerances (the SUNDIALS WRMS-norm), @@ -61,16 +61,11 @@ function pointers to the various controller operations, and is defined as SUNAdaptController_Type (*getid)(SUNAdaptController C); int (*destroy)(SUNAdaptController C); int (*estimatestep)(SUNAdaptController C, sunrealtype h, int p, sunrealtype dsm, sunrealtype* hnew); - int (*estimatestepandorder)(SUNAdaptController C, sunrealtype h, int p, sunrealtype dsm, sunrealtype* hnew, int *pnew); - int (*estimatemristeps)(SUNAdaptController C, sunrealtype H, sunrealtype h, int P, int p, sunrealtype DSM, sunrealtype dsm, sunrealtype* Hnew, sunrealtype *hnew); - int (*estimatesteptol)(SUNAdaptController C, sunrealtype H, int P, sunrealtype tolfac, sunrealtype DSM, sunrealtype dsm, sunrealtype *Hnew, sunrealtype* tolfacnew); int (*reset)(SUNAdaptController C); int (*setdefaults)(SUNAdaptController C); int (*write)(SUNAdaptController C, FILE* fptr); int (*seterrorbias)(SUNAdaptController C, sunrealtype bias); int (*update)(SUNAdaptController C, sunrealtype h, sunrealtype dsm); - int (*updatemrih)(SUNAdaptController C, sunrealtype H, sunrealtype h, sunrealtype DSM, sunrealtype dsm); - int (*updatemritol)(SUNAdaptController C, sunrealtype H, sunrealtype tolfac, sunrealtype DSM, sunrealtype dsm); int (*space)(SUNAdaptController C, long int *lenrw, long int *leniw); }; @@ -99,18 +94,6 @@ following set of SUNAdaptController types: Controls a single-rate step size. -.. c:enumerator:: SUN_ADAPTCONTROLLER_HP - - Controls a single-rate step size and method order. - -.. c:enumerator:: SUN_ADAPTCONTROLLER_MRI_H - - Controls two multirate step sizes. - -.. c:enumerator:: SUN_ADAPTCONTROLLER_MRI_TOL - - Controls slow multirate step size and fast tolerance. - .. _SUNAdaptController.Description.operations: @@ -177,7 +160,8 @@ routine, below. .. c:function:: int SUNAdaptController_EstimateStep(SUNAdaptController C, sunrealtype h, int p, sunrealtype dsm, sunrealtype* hnew) Estimates a single-rate step size. This routine is required for controllers - of type ``SUN_ADAPTCONTROLLER_H``. + of type ``SUN_ADAPTCONTROLLER_H``. If this is not provided by the + implementation, the base wrapper routine will set ``*hnew = h`` and return. :param C: the :c:type:`SUNAdaptController` object. :param h: the step size from the previous step attempt. @@ -193,79 +177,6 @@ routine, below. retval = SUNAdaptController_EstimateStep(C, hcur, dsm, &hnew); -.. c:function:: int SUNAdaptController_EstimateStepAndOrder(SUNAdaptController C, sunrealtype h, int p, sunrealtype dsm, sunrealtype* hnew, int* pnew) - - Estimates a single-rate step size and corresponding method order. This - routine is required for controllers of type ``SUN_ADAPTCONTROLLER_HP``. - - :param C: the :c:type:`SUNAdaptController` object. - :param h: the step size from the previous step attempt. - :param p: the order of accuracy for the time integration method from the previous step attempt. - :param dsm: the local temporal estimate from the previous step attempt. - :param hnew: (output) pointer to the estimated step size. - :param pnew: (output) pointer to the estimated method order. - :return: error code indicating success failure - (see :numref:`SUNAdaptController.Description.errorCodes`). - - Usage: - - .. code-block:: c - - retval = SUNAdaptController_EstimateStepAndOrder(C, hcur, pcur, dsm, &hnew, &pnew); - -.. c:function:: int SUNAdaptController_EstimateMRISteps(SUNAdaptController C, sunrealtype H, sunrealtype h, int P, int p, sunrealtype DSM, sunrealtype dsm, sunrealtype* Hnew, sunrealtype *hnew) - - Estimates the slow and fast multirate step sizes. This routine is required - for controllers of type ``SUN_ADAPTCONTROLLER_MRI_H``. - - :param C: the :c:type:`SUNAdaptController` object. - :param H: the slow step size from the previous multirate step attempt. - :param h: the fast step size from the previous multirate step attempt. - :param P: the current order of accuracy for the slow time integration method. - :param p: the current order of accuracy for the fast time integration method. - :param DSM: the local slow temporal error estimate from the previous step - attempt. - :param dsm: the local fast temporal error estimate from the previous step - attempt. - :param Hnew: (output) pointer to the estimated slow step size. - :param hnew: (output) pointer to the estimated fast step size. - :return: error code indicating success failure - (see :numref:`SUNAdaptController.Description.errorCodes`). - - Usage: - - .. code-block:: c - - retval = SUNAdaptController_EstimateMRISteps(C, Hcur, hcur, DSM, &Hnew, &hnew); - -.. c:function:: int SUNAdaptController_EstimateStepTol(SUNAdaptController C, sunrealtype H, int P, sunrealtype tolfac, sunrealtype DSM, sunrealtype *Hnew, sunrealtype* tolfacnew) - - Estimates the slow step size and recommended fast relative tolerance factor - for a multirate step. This routine is required for controllers of type - ``SUN_ADAPTCONTROLLER_MRI_TOL``. - - :param C: the :c:type:`SUNAdaptController` object. - :param H: the slow step size from the previous multirate step attempt. - :param P: the current order of accuracy for the slow time integration method. - :param tolfac: the ratio of fast/slow relative tolerances, - :math:`\text{reltol}/\text{RELTOL}`, from the previous - multirate step attempt. - :param DSM: the local slow temporal error estimate from the previous step - attempt. - :param dsm: the local fast temporal error estimate from the previous step - attempt. - :param Hnew: (output) pointer to the estimated slow step size. - :param tolfacnew: (output) pointer to the estimated relative tolerance - ratio. - :return: error code indicating success failure - (see :numref:`SUNAdaptController.Description.errorCodes`). - - Usage: - - .. code-block:: c - - retval = SUNAdaptController_EstimateStepTol(C, Hcur, tolfaccur, DSM, &Hnew, &tolfacnew); - .. c:function:: int SUNAdaptController_Reset(SUNAdaptController C) Resets the controller to its initial state, e.g., if it stores a small number @@ -349,50 +260,6 @@ routine, below. retval = SUNAdaptController_Update(C, h, dsm); -.. c:function:: int SUNAdaptController_UpdateMRIH(SUNAdaptController C, sunrealtype H, sunrealtype h, sunrealtype DSM, sunrealtype dsm) - - Notifies the controller of a successful multirate time step of sizes *H* and - *h*, and with temporal error estimates *DSM* and *dsm*. This is used for - controllers of type *SUN_ADAPTCONTROLLER_MRI_H* that store a history of either - step size inputs or resulting error estimates for performing the estimation - process. - - :param C: the :c:type:`SUNAdaptController` object. - :param H: the successful slow step size. - :param h: the successful fast step size. - :param DSM: the successful slow temporal error estimate. - :param dsm: the successful fast temporal error estimate. - :return: error code indicating success failure - (see :numref:`SUNAdaptController.Description.errorCodes`). - - Usage: - - .. code-block:: c - - retval = SUNAdaptController_UpdateMRIH(C, H, h, DSM, dsm); - -.. c:function:: int SUNAdaptController_UpdateMRITol(SUNAdaptController C, sunrealtype H, sunrealtype tolfac, sunrealtype DSM, sunrealtype dsm) - - Notifies the controller of a successful multirate time step of size *H* and - fast tolerance factor *tolfac*, that resulted in temporal error estimates - *DSM* and *dsm*. This is typically used for controllers of type - *SUN_ADAPTCONTROLLER_MRI_TOL* that store a history of either control inputs or - resulting error estimates for performing the estimation process. - - :param C: the :c:type:`SUNAdaptController` object. - :param H: the successful slow step size. - :param tolfac: the successful fast relative tolerance factor. - :param DSM: the successful slow temporal error estimate. - :param dsm: the successful fast temporal error estimate. - :return: error code indicating success failure - (see :numref:`SUNAdaptController.Description.errorCodes`). - - Usage: - - .. code-block:: c - - retval = SUNAdaptController_Update(C, h, dsm); - .. c:function:: int SUNAdaptController_Space(SUNAdaptController C, long int *lenrw, long int *leniw) Informative routine that returns the memory requirements of the diff --git a/doc/shared/sunadaptcontroller/SUNAdaptController_ImExGus.rst b/doc/shared/sunadaptcontroller/SUNAdaptController_ImExGus.rst index 822db31106..3af855ae5b 100644 --- a/doc/shared/sunadaptcontroller/SUNAdaptController_ImExGus.rst +++ b/doc/shared/sunadaptcontroller/SUNAdaptController_ImExGus.rst @@ -25,30 +25,29 @@ is primarily useful with explicit Runge--Kutta methods, and has the form .. math:: h' \;=\; \begin{cases} h_1\; \varepsilon_1^{-1/(p+1)}, &\quad\text{on the first step}, \\ - h_n\; \varepsilon_n^{-k_1/(p+1)}\; - \left(\dfrac{\varepsilon_n}{\varepsilon_{n-1}}\right)^{k_2/(p+1)}, & + h_n\; \varepsilon_n^{-k_1^E/(p+1)}\; + \left(\dfrac{\varepsilon_n}{\varepsilon_{n-1}}\right)^{k_2^E/(p+1)}, & \quad\text{on subsequent steps}. \end{cases} :label: expGusController -The default values of :math:`k_1` and :math:`k_2` are 0.367 and 0.268, -respectively, and :math:`p` is the global order of the time -integration method. In this estimate, a floor of :math:`\varepsilon > 10^{-10}` -is enforced to avoid division-by-zero errors. - -Gustafsson also proposed a controller for implicit Runge--Kutta methods in :cite:p:`Gust:94`, +Similarly, Gustafsson's "implicit" controller was proposed in :cite:p:`Gust:94` with the form .. math:: h' = \begin{cases} h_1 \varepsilon_1^{-1/(p+1)}, &\quad\text{on the first step}, \\ - h_n \left(\dfrac{h_n}{h_{n-1}}\right) \varepsilon_n^{-k_1/(p+1)} - \left(\dfrac{\varepsilon_n}{\varepsilon_{n-1}}\right)^{-k_2/(p+1)}, & - \quad\text{on subsequent steps}, + h_n \left(\dfrac{h_n}{h_{n-1}}\right) \varepsilon_n^{-k_1^I/(p+1)} + \left(\dfrac{\varepsilon_n}{\varepsilon_{n-1}}\right)^{-k_2^I/(p+1)}, & + \quad\text{on subsequent steps}. \end{cases} :label: impGusController -where the default parameter values are :math:`k_1 = 0.98` and :math:`k_2 = 0.95`. +In the above formulas, the default values of :math:`k_1^E`, :math:`k_2^E`, +:math:`k_1^I`, and :math:`k_2^I` are 0.367, 0.268, 0.98, and 0.95, respectively, +and :math:`p` is the global order of the time integration method. In these +estimates, a floor of :math:`\varepsilon_* > 10^{-10}` is enforced to avoid +division-by-zero errors. The SUNAdaptController_ImExGus controller implements both formulas :eq:`expGusController` and :eq:`impGusController`, and sets its recommended step diff --git a/doc/shared/sunadaptcontroller/SUNAdaptController_Soderlind.rst b/doc/shared/sunadaptcontroller/SUNAdaptController_Soderlind.rst index 1af37e5538..a3d49f24fd 100644 --- a/doc/shared/sunadaptcontroller/SUNAdaptController_Soderlind.rst +++ b/doc/shared/sunadaptcontroller/SUNAdaptController_Soderlind.rst @@ -240,24 +240,26 @@ also provides the following additional user-callable routines: SUNAdaptController C = SUNAdaptController_ExpGus(sunctx); -.. c:function:: int SUNAdaptController_SetParams_ExpGus(SUNAdaptController C, sunrealtype k1, sunrealtype k2) +.. c:function:: int SUNAdaptController_SetParams_ExpGus(SUNAdaptController C, sunrealtype k1_hat, sunrealtype k2_hat) This user-callable function provides control over the relevant parameters above, setting :math:`k_3 = k_4 = k_5 = 0`. This should be called *before* the time integrator is called to evolve the problem. - Note that the Gustafsson's explicit controller has the form + .. note:: - .. math:: - h' = h_n \varepsilon_n^{-\hat{k}_1/(p+1)} \left(\frac{\varepsilon_n}{\varepsilon_{n-1}}\right)^{-\hat{k}_2/(p+1)}. + Gustafsson's explicit controller has the form - The inputs to this function correspond to the values of :math:`\hat{k}_1` and :math:`\hat{k}_2`, - which are internally transformed into the Soderlind coeficients :math:`k_1 = \hat{k}_1+\hat{k}_2` - and :math:`k_2 = -\hat{k}_2`. + .. math:: + h' = h_n \varepsilon_n^{-\hat{k}_1/(p+1)} \left(\frac{\varepsilon_n}{\varepsilon_{n-1}}\right)^{-\hat{k}_2/(p+1)}. + + The inputs to this function correspond to the values of :math:`\hat{k}_1` and :math:`\hat{k}_2`, + which are internally transformed into the Soderlind coeficients :math:`k_1 = \hat{k}_1+\hat{k}_2` + and :math:`k_2 = -\hat{k}_2`. :param C: the SUNAdaptController_Soderlind object. - :param k1: parameter used within the explicit Gustafsson controller time step estimate. - :param k2: parameter used within the explicit Gustafsson controller time step estimate. + :param k1_hat: parameter used within the explicit Gustafsson controller time step estimate. + :param k2_hat: parameter used within the explicit Gustafsson controller time step estimate. :return: error code indication success or failure (see :numref:`SUNAdaptController.Description.errorCodes`). Usage: @@ -284,24 +286,26 @@ also provides the following additional user-callable routines: SUNAdaptController C = SUNAdaptController_ImpGus(sunctx); -.. c:function:: int SUNAdaptController_SetParams_ImpGus(SUNAdaptController C, sunrealtype k1, sunrealtype k2) +.. c:function:: int SUNAdaptController_SetParams_ImpGus(SUNAdaptController C, sunrealtype k1_hat, sunrealtype k2_hat) This user-callable function provides control over the relevant parameters above, setting :math:`k_3 = k_4 = k_5 = 0`. This should be called *before* the time integrator is called to evolve the problem. - Note that the Gustafsson's implicit controller has the form + .. note:: + + Gustafsson's implicit controller has the form - .. math:: - h' = h_n \varepsilon_n^{-\hat{k}_1/(p+1)} \left(\frac{\varepsilon_n}{\varepsilon_{n-1}}\right)^{-\hat{k}_2/(p+1)} \left(\frac{h_n}{h_{n-1}}\right). + .. math:: + h' = h_n \varepsilon_n^{-\hat{k}_1/(p+1)} \left(\frac{\varepsilon_n}{\varepsilon_{n-1}}\right)^{-\hat{k}_2/(p+1)} \left(\frac{h_n}{h_{n-1}}\right). - The inputs to this function correspond to the values of :math:`\hat{k}_1` and :math:`\hat{k}_2`, - which are internally transformed into the Soderlind coeficients :math:`k_1 = \hat{k}_1+\hat{k}_2`, - :math:`k_2 = -\hat{k}_2`, and :math:`k_4=1`. + The inputs to this function correspond to the values of :math:`\hat{k}_1` and :math:`\hat{k}_2`, + which are internally transformed into the Soderlind coeficients :math:`k_1 = \hat{k}_1+\hat{k}_2`, + :math:`k_2 = -\hat{k}_2`, and :math:`k_4=1`. :param C: the SUNAdaptController_Soderlind object. - :param k1: parameter used within the implicit Gustafsson controller time step estimate. - :param k2: parameter used within the implicit Gustafsson controller time step estimate. + :param k1_hat: parameter used within the implicit Gustafsson controller time step estimate. + :param k2_hat: parameter used within the implicit Gustafsson controller time step estimate. :return: error code indication success or failure (see :numref:`SUNAdaptController.Description.errorCodes`). Usage: diff --git a/doc/superbuild/source/sunadaptcontroller/SUNAdaptController_links.rst b/doc/superbuild/source/sunadaptcontroller/SUNAdaptController_links.rst index 9b404ff420..ee94a630b1 100644 --- a/doc/superbuild/source/sunadaptcontroller/SUNAdaptController_links.rst +++ b/doc/superbuild/source/sunadaptcontroller/SUNAdaptController_links.rst @@ -10,5 +10,6 @@ SUNDIALS Copyright End ---------------------------------------------------------------- +.. include:: ../../../shared/sunadaptcontroller/SUNAdaptController_Description.rst .. include:: ../../../shared/sunadaptcontroller/SUNAdaptController_Soderlind.rst .. include:: ../../../shared/sunadaptcontroller/SUNAdaptController_ImExGus.rst diff --git a/doc/superbuild/source/sunadaptcontroller/index.rst b/doc/superbuild/source/sunadaptcontroller/index.rst index 34cb523c96..0b5336f55f 100644 --- a/doc/superbuild/source/sunadaptcontroller/index.rst +++ b/doc/superbuild/source/sunadaptcontroller/index.rst @@ -12,7 +12,18 @@ SUNDIALS Copyright End ---------------------------------------------------------------- -.. include:: ../../../shared/sunadaptcontroller/SUNAdaptController_Description.rst +.. _SUNAdaptController: + +##################################### +Time Step Adaptivity Controllers +##################################### + +The SUNDIALS library comes packaged with a variety of :c:type:`SUNAdaptController` +implementations, designed to support various forms of error-based time step +adaptivity within SUNDIALS time integrators. To support applications that may +want to adjust or disable these heuristic controls, SUNDIALS provides a +:c:type:`SUNAdaptController` base class, along with a variety of default +implementations. .. toctree:: :maxdepth: 1 From e6a671f3617001cb09f23c8036919d35bc1c6943 Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Mon, 30 Oct 2023 22:05:26 -0500 Subject: [PATCH 30/58] Apply suggestions from code review Co-authored-by: David Gardner --- .../ARKStep_c_interface/User_callable.rst | 2 +- .../ERKStep_c_interface/User_callable.rst | 2 +- .../guide/source/sunadaptcontroller/index.rst | 6 +- .../SUNAdaptController_Description.rst | 41 ++++++------- .../SUNAdaptController_ImExGus.rst | 4 +- .../SUNAdaptController_Soderlind.rst | 60 +++++++++---------- 6 files changed, 56 insertions(+), 59 deletions(-) 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 7b23cf149e..36a6472cca 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 @@ -1815,7 +1815,7 @@ Explicit stability function :c:func:`ARKStepSetS This should be called prior to calling :c:func:`ARKStepEvolve()`, and can only be reset following a call to :c:func:`ARKStepReInit()`. - + .. versionadded:: x.x.x .. c:function:: int ARKStepSetCFLFraction(void* arkode_mem, realtype cfl_frac) 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 a3bf27c191..adae5325f0 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 @@ -1298,7 +1298,7 @@ the code, is provided in :numref:`ARKODE.Mathematics.Adaptivity`. This should be called prior to calling :c:func:`ERKStepEvolve()`, and can only be reset following a call to :c:func:`ERKStepReInit()`. - + .. versionadded:: x.x.x .. c:function:: int ERKStepSetCFLFraction(void* arkode_mem, realtype cfl_frac) diff --git a/doc/arkode/guide/source/sunadaptcontroller/index.rst b/doc/arkode/guide/source/sunadaptcontroller/index.rst index c4d88d5ba2..bd4ab38d7b 100644 --- a/doc/arkode/guide/source/sunadaptcontroller/index.rst +++ b/doc/arkode/guide/source/sunadaptcontroller/index.rst @@ -19,9 +19,9 @@ Time Step Adaptivity Controllers The SUNDIALS library comes packaged with a variety of :c:type:`SUNAdaptController` implementations, designed to support various forms of error-based time step adaptivity within SUNDIALS time integrators. To support applications that may -want to adjust or disable these heuristic controls, SUNDIALS provides a -:c:type:`SUNAdaptController` base class, along with a variety of default -implementations. +want to adjust the controller parameters or provide their own implementations, +SUNDIALS defines the :c:type:`SUNAdaptController` base class, along with a +variety of default implementations. .. toctree:: :maxdepth: 1 diff --git a/doc/shared/sunadaptcontroller/SUNAdaptController_Description.rst b/doc/shared/sunadaptcontroller/SUNAdaptController_Description.rst index c1b88c837b..6199e802c0 100644 --- a/doc/shared/sunadaptcontroller/SUNAdaptController_Description.rst +++ b/doc/shared/sunadaptcontroller/SUNAdaptController_Description.rst @@ -25,7 +25,7 @@ temporal accuracy, while striving to maximize computational efficiency. We note that in the descriptions below, we frequently use *dsm* to represent temporal error. This is **not** the raw temporal error estimate; instead, it is a norm of the temporal error estimate after scaling by the user-supplied -accuracy tolerances (the SUNDIALS WRMS-norm), +accuracy tolerances (see :eq:`ARKODE_WRMS_NORM`), .. math:: \text{dsm} = \left( \frac{1}{N} \sum_{i=1}^N @@ -48,7 +48,7 @@ and the base class structure is defined as struct _generic_SUNAdaptController { void* content; - generic_SUNAdaptController_Ops_* ops; + generic_SUNAdaptController_Ops* ops; SUNContext sunctx; }; @@ -104,8 +104,8 @@ SUNAdaptController Operations The base SUNAdaptController class defines and implements all SUNAdaptController functions. Most of these routines are merely wrappers for the operations defined by a particular SUNAdaptController implementation, which are accessed through the *ops* field of the -``SUNAdaptController`` structure. However, the base SUNAdaptController class also provides the -convenience routine +``SUNAdaptController`` structure. The base SUNAdaptController class provides the +constructor .. c:function:: SUNAdaptController SUNAdaptController_NewEmpty(SUNContext sunctx) @@ -118,11 +118,10 @@ convenience routine :returns: If successful, a generic :c:type:`SUNAdaptController` object. If unsuccessful, a ``NULL`` pointer will be returned. -Each of the following routines are *optional* for any specific SUNAdaptController +Each of the following methods are *optional* for any specific SUNAdaptController implementation, however some may be required based on the implementation's :c:type:`SUNAdaptController_Type` (see Section :numref:`SUNAdaptController.Description.controllerTypes`). We -note these requirements, as well as the behavior of the base SUNAdaptController wrapper -routine, below. +note these requirements below. Additionally, we note the behavior of the base SUNAdaptController methods when they perform an action other than only a successful return. .. c:function:: SUNAdaptController_Type SUNAdaptController_GetType(SUNAdaptController C) @@ -140,8 +139,8 @@ routine, below. .. c:function:: int SUNAdaptController_Destroy(SUNAdaptController C) - Deallocates the controller *C*. If this is not provided by the - implementation, the base wrapper routine will free both the *content* and + Deallocates the controller *C*. If this method is not provided by the + implementation, the base class method will free both the *content* and *ops* objects -- this should be sufficient unless a controller implementation performs dynamic memory allocation of its own (note that the SUNDIALS-provided SUNAdaptController implementations do not need to supply this @@ -167,7 +166,7 @@ routine, below. :param h: the step size from the previous step attempt. :param p: the current order of accuracy for the time integration method. :param dsm: the local temporal estimate from the previous step attempt. - :param hnew: (output) pointer to the estimated step size. + :param hnew: (output) the estimated step size. :return: error code indicating success failure (see :numref:`SUNAdaptController.Description.errorCodes`). @@ -175,14 +174,12 @@ routine, below. .. code-block:: c - retval = SUNAdaptController_EstimateStep(C, hcur, dsm, &hnew); + retval = SUNAdaptController_EstimateStep(C, hcur, p, dsm, &hnew); .. c:function:: int SUNAdaptController_Reset(SUNAdaptController C) Resets the controller to its initial state, e.g., if it stores a small number - of previous *dsm* or *h* values. The return value is an integer flag denoting - success/failure of the routine (see - :numref:`SUNAdaptController.Description.errorCodes`). + of previous *dsm* or *h* values. :param C: the :c:type:`SUNAdaptController` object. :return: error code indicating success failure @@ -198,7 +195,7 @@ routine, below. Sets the controller parameters to their default values. - :param C: the :c:type:`SUNAdaptController` object.. + :param C: the :c:type:`SUNAdaptController` object. :return: error code indicating success failure (see :numref:`SUNAdaptController.Description.errorCodes`). @@ -213,7 +210,7 @@ routine, below. Writes all controller parameters to the indicated file pointer. :param C: the :c:type:`SUNAdaptController` object. - :param fptr: the output stream to write the parameters. + :param fptr: the output stream to write the parameters to. :return: error code indicating success failure (see :numref:`SUNAdaptController.Description.errorCodes`). @@ -301,18 +298,18 @@ SUNAdaptController functions return one of the following set of error codes: .. note:: The SUNDIALS time integrators do not rely on these specific return values (only - on whether the returned values are 0 (successful) or negative (failure). Thus, + on whether the returned values are 0 (successful) or non-zero (failure). Thus, user-defined implementations are not required to use these specific error codes, - so long as the zero/negative structure is followed. + so long as the zero/non-zero convention is followed. C/C++ API Usage --------------- Specific SUNDIALS adaptivity controller modules can be used in C and C++ programs by including -the corresponding header file for that module, e.g. ``sunadaptcontroller/sunadaptcontrollerXYZ.h``. +the corresponding header file for that module, e.g. ``sunadaptcontroller/sunadaptcontroller_XYZ.h``. -Example usage (here ``SUNAdaptControllerXYZ`` is a placeholder for an actual SUNAdaptController +Example usage (here ``SUNAdaptController_XYZ`` is a placeholder for an actual SUNAdaptController constructor): .. code-block:: c @@ -321,7 +318,7 @@ constructor): #include #include #include - #include + #include int main() { @@ -329,7 +326,7 @@ constructor): SUNContext sunctx = ...; /* Create a SUNAdaptController object */ - SUNAdaptController C = SUNAdaptControllerXYZ(sunctx); + SUNAdaptController C = SUNAdaptController_XYZ(sunctx); /* Use the control object */ diff --git a/doc/shared/sunadaptcontroller/SUNAdaptController_ImExGus.rst b/doc/shared/sunadaptcontroller/SUNAdaptController_ImExGus.rst index 3af855ae5b..c0a54fddf8 100644 --- a/doc/shared/sunadaptcontroller/SUNAdaptController_ImExGus.rst +++ b/doc/shared/sunadaptcontroller/SUNAdaptController_ImExGus.rst @@ -88,7 +88,7 @@ The header file to be included when using this module is The SUNAdaptController_ImExGus class provides implementations of all operations -relevant to a `SUN_ADAPTCONTROLLER_H` controller listed in +relevant to a ``SUN_ADAPTCONTROLLER_H`` controller listed in :numref:`SUNAdaptController.Description.operations`. The SUNAdaptController_ImExGus class also provides the following additional user-callable routines: @@ -96,7 +96,7 @@ routines: .. c:function:: SUNAdaptController SUNAdaptController_ImExGus(SUNContext sunctx) - This constructor function creates and allocates memory for a SUNAdaptController_ImExGus + This constructor creates and allocates memory for a SUNAdaptController_ImExGus object, and inserts its default parameters. :param sunctx: the current :c:type:`SUNContext` object. diff --git a/doc/shared/sunadaptcontroller/SUNAdaptController_Soderlind.rst b/doc/shared/sunadaptcontroller/SUNAdaptController_Soderlind.rst index a3d49f24fd..525ca7e3c1 100644 --- a/doc/shared/sunadaptcontroller/SUNAdaptController_Soderlind.rst +++ b/doc/shared/sunadaptcontroller/SUNAdaptController_Soderlind.rst @@ -19,18 +19,18 @@ The SUNAdaptController_Soderlind Module The Soderlind implementation of the SUNAdaptController class, SUNAdaptController_Soderlind, implements a general structure for temporal -control proposed by G. Soderlind in :cite:p:`Sod:98`, :cite:p:`Sod:03` +control proposed by G. Soderlind in :cite:p:`Sod:98`, :cite:p:`Sod:03`, and :cite:p:`Sod:06`. This controller has the form .. math:: h' = h_n \varepsilon_n^{-k_1/(p+1)} \varepsilon_{n-1}^{-k_2/(p+1)} \varepsilon_{n-2}^{-k_3/(p+1)} \left(\dfrac{h_n}{h_{n-1}}\right)^{k_4} \left(\dfrac{h_{n-1}}{h_{n-2}}\right)^{k_5} with default parameter values :math:`k_1 = 1.25`, :math:`k_2 = 0.5`, -:math:`k_3 = -0.75`, :math:`k_4 = 0.25` and :math:`k_5 = 0.75`, where +:math:`k_3 = -0.75`, :math:`k_4 = 0.25`, and :math:`k_5 = 0.75`, where :math:`p` is the global order of the time integration method. In this estimate, -a floor of :math:`\varepsilon > 10^{-10}` is enforced to avoid division-by-zero +a floor of :math:`\varepsilon_* > 10^{-10}` is enforced to avoid division-by-zero errors. During the first two steps (when :math:`\varepsilon_{n-2}`, -:math:`\varepsilon_{n-1}`, :math:`h_{n-2}` and :math:`h_{n-2}` may be unavailable), +:math:`\varepsilon_{n-1}`, :math:`h_{n-2}`, and :math:`h_{n-2}` may be unavailable), the corresponding terms are merely omitted during estimation of :math:`h'`. The SUNAdaptController_Soderlind controller is implemented as a derived @@ -60,7 +60,7 @@ These entries of the *content* field contain the following information: estimate via :math:`\varepsilon = \text{bias}*\text{dsm}`. * ``ep, epp`` - storage for the two previous error estimates, - :math:`\varepsilon_{n-1}` and :math:`varepsilon_{n-2}`. + :math:`\varepsilon_{n-1}` and :math:`\varepsilon_{n-2}`. * ``hp, hpp`` - storage for the previous two step sizes, :math:`h_{n-1}` and :math:`h_{n-2}`. @@ -71,7 +71,7 @@ These entries of the *content* field contain the following information: The header file to be included when using this module is ``sunadaptcontroller/sunadaptcontroller_soderlind.h``. -We note that through appropriate selection of the parameters :math:`k_1 - k_5`, +We note that through appropriate selection of the parameters :math:`k_*`, this controller may create a wide range of proposed temporal adaptivity controllers, including the PID, PI, I, as well as Gustafsson's explicit and implicit controllers, :cite:p:`Gust:91` and :cite:p:`Gust:94`. As a convenience, utility routines to @@ -79,14 +79,14 @@ create these controllers and set their parameters (as special cases of the SUNAdaptController_Soderlind) are provided. The SUNAdaptController_Soderlind class provides implementations of all operations -relevant to a `SUN_ADAPTCONTROLLER_H` controller listed in +relevant to a ``SUN_ADAPTCONTROLLER_H`` controller listed in :numref:`SUNAdaptController.Description.operations`. This class also provides the following additional user-callable routines: .. c:function:: SUNAdaptController SUNAdaptController_Soderlind(SUNContext sunctx) - This constructor function creates and allocates memory for a SUNAdaptController_Soderlind + This constructor creates and allocates memory for a SUNAdaptController_Soderlind object, and inserts its default parameters. :param sunctx: the current :c:type:`SUNContext` object. @@ -123,9 +123,9 @@ also provides the following additional user-callable routines: .. c:function:: SUNAdaptController SUNAdaptController_PID(SUNContext sunctx) - This constructor function creates and allocates memory for a SUNAdaptController_Soderlind + This constructor creates and allocates memory for a SUNAdaptController_Soderlind object, set up to replicate a PID controller, and inserts its default parameters - (:math:`k_1=0.58`, :math:`k_2=-0.21`, :math:`k_3=0.1`, and :math:`k_4=k_5=0`). + :math:`k_1=0.58`, :math:`k_2=-0.21`, :math:`k_3=0.1`, and :math:`k_4=k_5=0`. :param sunctx: the current :c:type:`SUNContext` object. :return: if successful, a usable :c:type:`SUNAdaptController` object; @@ -140,8 +140,8 @@ also provides the following additional user-callable routines: .. c:function:: int SUNAdaptController_SetParams_PID(SUNAdaptController C, sunrealtype k1, sunrealtype k2, sunrealtype k3) This user-callable function provides control over the relevant parameters - above, setting :math:`k_4 = k_5 = 0`. This should be called *before* the - time integrator is called to evolve the problem. + above for a PID controller, setting :math:`k_4 = k_5 = 0`. This should be + called *before* the time integrator is called to evolve the problem. :param C: the SUNAdaptController_Soderlind object. :param k1: parameter used within the controller time step estimate. @@ -158,9 +158,9 @@ also provides the following additional user-callable routines: .. c:function:: SUNAdaptController SUNAdaptController_PI(SUNContext sunctx) - This constructor function creates and allocates memory for a SUNAdaptController_Soderlind + This constructor creates and allocates memory for a SUNAdaptController_Soderlind object, set up to replicate a PI controller, and inserts its default parameters - (:math:`k_1=0.8`, :math:`k_2=-0.31`, and :math:`k_3=k_4=k_5=0`). + :math:`k_1=0.8`, :math:`k_2=-0.31`, and :math:`k_3=k_4=k_5=0`. :param sunctx: the current :c:type:`SUNContext` object. :return: if successful, a usable :c:type:`SUNAdaptController` object; @@ -175,8 +175,8 @@ also provides the following additional user-callable routines: .. c:function:: int SUNAdaptController_SetParams_PI(SUNAdaptController C, sunrealtype k1, sunrealtype k2) This user-callable function provides control over the relevant parameters - above, setting :math:`k_3 = k_4 = k_5 = 0`. This should be called *before* the - time integrator is called to evolve the problem. + above for a PI controller, setting :math:`k_3 = k_4 = k_5 = 0`. This should + be called *before* the time integrator is called to evolve the problem. :param C: the SUNAdaptController_Soderlind object. :param k1: parameter used within the controller time step estimate. @@ -192,9 +192,9 @@ also provides the following additional user-callable routines: .. c:function:: SUNAdaptController SUNAdaptController_I(SUNContext sunctx) - This constructor function creates and allocates memory for a SUNAdaptController_Soderlind + This constructor creates and allocates memory for a SUNAdaptController_Soderlind object, set up to replicate an I controller, and inserts its default parameters - (:math:`k_1=1.0` and :math:`k_2=k_3=k_4=k_5=0`). + :math:`k_1=1.0` and :math:`k_2=k_3=k_4=k_5=0`. :param sunctx: the current :c:type:`SUNContext` object. :return: if successful, a usable :c:type:`SUNAdaptController` object; @@ -209,8 +209,8 @@ also provides the following additional user-callable routines: .. c:function:: int SUNAdaptController_SetParams_I(SUNAdaptController C, sunrealtype k1) This user-callable function provides control over the relevant parameters - above, setting :math:`k_2 = k_3 = k_4 = k_5 = 0`. This should be called *before* the - time integrator is called to evolve the problem. + above for an I controller, setting :math:`k_2 = k_3 = k_4 = k_5 = 0`. This + should be called *before* the time integrator is called to evolve the problem. :param C: the SUNAdaptController_Soderlind object. :param k1: parameter used within the controller time step estimate. @@ -225,10 +225,10 @@ also provides the following additional user-callable routines: .. c:function:: SUNAdaptController SUNAdaptController_ExpGus(SUNContext sunctx) - This constructor function creates and allocates memory for a SUNAdaptController_Soderlind + This constructor creates and allocates memory for a SUNAdaptController_Soderlind object, set up to replicate Gustafsson's explicit controller :cite:p:`Gust:91`, and - inserts its default parameters (:math:`k_1=0.635`, :math:`k_2=-0.268`, and - :math:`k_3=k_4=k_5=0`). + inserts its default parameters :math:`k_1=0.635`, :math:`k_2=-0.268`, and + :math:`k_3=k_4=k_5=0`. :param sunctx: the current :c:type:`SUNContext` object. :return: if successful, a usable :c:type:`SUNAdaptController` object; @@ -243,8 +243,8 @@ also provides the following additional user-callable routines: .. c:function:: int SUNAdaptController_SetParams_ExpGus(SUNAdaptController C, sunrealtype k1_hat, sunrealtype k2_hat) This user-callable function provides control over the relevant parameters - above, setting :math:`k_3 = k_4 = k_5 = 0`. This should be called *before* the - time integrator is called to evolve the problem. + above for the explicit Gustafsson controller, setting :math:`k_3 = k_4 = k_5 = 0`. + This should be called *before* the time integrator is called to evolve the problem. .. note:: @@ -271,10 +271,10 @@ also provides the following additional user-callable routines: .. c:function:: SUNAdaptController SUNAdaptController_ImpGus(SUNContext sunctx) - This constructor function creates and allocates memory for a SUNAdaptController_Soderlind + This constructor creates and allocates memory for a SUNAdaptController_Soderlind object, set up to replicate Gustafsson's implicit controller :cite:p:`Gust:94`, and - inserts its default parameters (:math:`k_1=1.93`, :math:`k_2=-0.95`, :math:`k_4=1`, and - :math:`k_3=k_5=0`). + inserts its default parameters :math:`k_1=1.93`, :math:`k_2=-0.95`, :math:`k_4=1`, and + :math:`k_3=k_5=0`. :param sunctx: the current :c:type:`SUNContext` object. :return: if successful, a usable :c:type:`SUNAdaptController` object; @@ -289,8 +289,8 @@ also provides the following additional user-callable routines: .. c:function:: int SUNAdaptController_SetParams_ImpGus(SUNAdaptController C, sunrealtype k1_hat, sunrealtype k2_hat) This user-callable function provides control over the relevant parameters - above, setting :math:`k_3 = k_4 = k_5 = 0`. This should be called *before* the - time integrator is called to evolve the problem. + above for the implicit Gustafsson controller, setting :math:`k_3 = k_4 = k_5 = 0`. + This should be called *before* the time integrator is called to evolve the problem. .. note:: From fa97587dc0b9922d04b5ac6c9871db0d7d4e461c Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Mon, 30 Oct 2023 22:05:53 -0500 Subject: [PATCH 31/58] Updates from code review --- doc/superbuild/source/sunadaptcontroller/index.rst | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/doc/superbuild/source/sunadaptcontroller/index.rst b/doc/superbuild/source/sunadaptcontroller/index.rst index 0b5336f55f..6ba75858a6 100644 --- a/doc/superbuild/source/sunadaptcontroller/index.rst +++ b/doc/superbuild/source/sunadaptcontroller/index.rst @@ -21,9 +21,9 @@ Time Step Adaptivity Controllers The SUNDIALS library comes packaged with a variety of :c:type:`SUNAdaptController` implementations, designed to support various forms of error-based time step adaptivity within SUNDIALS time integrators. To support applications that may -want to adjust or disable these heuristic controls, SUNDIALS provides a -:c:type:`SUNAdaptController` base class, along with a variety of default -implementations. +want to adjust the controller parameters or provide their own implementations, +SUNDIALS defines the :c:type:`SUNAdaptController` base class, along with a +variety of default implementations. .. toctree:: :maxdepth: 1 From a054a613e5eb445c065c70c7f803ffdd27bcf4a9 Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Tue, 31 Oct 2023 08:36:19 -0500 Subject: [PATCH 32/58] Removed ops function pointers and SUNAdaptController types for yet-to-be-implemented multirate and step/order controllers --- .../SUNAdaptController_Description.rst | 15 +- .../sunadaptcontroller_imexgus.h | 2 +- .../sunadaptcontroller_soderlind.h | 2 +- include/sundials/sundials_adaptcontroller.h | 91 +------ src/arkode/arkode.c | 2 +- src/arkode/arkode_user_controller.c | 4 +- src/arkode/arkode_user_controller.h | 2 +- src/arkode/fmod/farkode_arkstep_mod.f90 | 2 + src/arkode/fmod/farkode_erkstep_mod.f90 | 2 + src/arkode/fmod/farkode_mod.f90 | 13 +- .../fmod/fsunadaptcontroller_imexgus_mod.c | 4 +- .../fmod/fsunadaptcontroller_imexgus_mod.f90 | 10 +- .../imexgus/sunadaptcontroller_imexgus.c | 4 +- .../fmod/fsunadaptcontroller_soderlind_mod.c | 4 +- .../fsunadaptcontroller_soderlind_mod.f90 | 10 +- .../soderlind/sunadaptcontroller_soderlind.c | 4 +- .../fmod/fsundials_adaptcontroller_mod.c | 120 +-------- .../fmod/fsundials_adaptcontroller_mod.f90 | 245 +----------------- src/sundials/sundials_adaptcontroller.c | 77 +----- 19 files changed, 65 insertions(+), 548 deletions(-) diff --git a/doc/shared/sunadaptcontroller/SUNAdaptController_Description.rst b/doc/shared/sunadaptcontroller/SUNAdaptController_Description.rst index 6199e802c0..60674b71bf 100644 --- a/doc/shared/sunadaptcontroller/SUNAdaptController_Description.rst +++ b/doc/shared/sunadaptcontroller/SUNAdaptController_Description.rst @@ -65,7 +65,7 @@ function pointers to the various controller operations, and is defined as int (*setdefaults)(SUNAdaptController C); int (*write)(SUNAdaptController C, FILE* fptr); int (*seterrorbias)(SUNAdaptController C, sunrealtype bias); - int (*update)(SUNAdaptController C, sunrealtype h, sunrealtype dsm); + int (*updateh)(SUNAdaptController C, sunrealtype h, sunrealtype dsm); int (*space)(SUNAdaptController C, long int *lenrw, long int *leniw); }; @@ -238,12 +238,13 @@ note these requirements below. Additionally, we note the behavior of the base SU retval = SUNAdaptController_SetErrorBias(C, 1.2); -.. c:function:: int SUNAdaptController_Update(SUNAdaptController C, sunrealtype h, sunrealtype dsm) +.. c:function:: int SUNAdaptController_UpdateH(SUNAdaptController C, sunrealtype h, sunrealtype dsm) - Notifies the controller of a successful time step of size *h* and with - temporal error estimate *dsm*. This is typically used for controllers that - store a history of either step sizes or error estimates for performing the - estimation process. + Notifies a controller of type SUN_ADAPTCONTROLLER_H that a successful time step + was taken with stepsize *h* and local error factor *dsm*, indicating that these + can be saved for subsequent controller functions. This is typically relevant for + controllers that store a history of either step sizes or error estimates for + performing the estimation process. :param C: the :c:type:`SUNAdaptController` object. :param h: the successful step size. @@ -255,7 +256,7 @@ note these requirements below. Additionally, we note the behavior of the base SU .. code-block:: c - retval = SUNAdaptController_Update(C, h, dsm); + retval = SUNAdaptController_UpdateH(C, h, dsm); .. c:function:: int SUNAdaptController_Space(SUNAdaptController C, long int *lenrw, long int *leniw) diff --git a/include/sunadaptcontroller/sunadaptcontroller_imexgus.h b/include/sunadaptcontroller/sunadaptcontroller_imexgus.h index d039c82cce..a5d547934b 100644 --- a/include/sunadaptcontroller/sunadaptcontroller_imexgus.h +++ b/include/sunadaptcontroller/sunadaptcontroller_imexgus.h @@ -65,7 +65,7 @@ int SUNAdaptController_Write_ImExGus(SUNAdaptController C, FILE* fptr); SUNDIALS_EXPORT int SUNAdaptController_SetErrorBias_ImExGus(SUNAdaptController C, sunrealtype bias); SUNDIALS_EXPORT -int SUNAdaptController_Update_ImExGus(SUNAdaptController C, sunrealtype h, sunrealtype dsm); +int SUNAdaptController_UpdateH_ImExGus(SUNAdaptController C, sunrealtype h, sunrealtype dsm); SUNDIALS_EXPORT int SUNAdaptController_Space_ImExGus(SUNAdaptController C, long int *lenrw, long int *leniw); diff --git a/include/sunadaptcontroller/sunadaptcontroller_soderlind.h b/include/sunadaptcontroller/sunadaptcontroller_soderlind.h index c876cdc32c..8ab530d1e1 100644 --- a/include/sunadaptcontroller/sunadaptcontroller_soderlind.h +++ b/include/sunadaptcontroller/sunadaptcontroller_soderlind.h @@ -70,7 +70,7 @@ int SUNAdaptController_Write_Soderlind(SUNAdaptController C, FILE* fptr); SUNDIALS_EXPORT int SUNAdaptController_SetErrorBias_Soderlind(SUNAdaptController C, sunrealtype bias); SUNDIALS_EXPORT -int SUNAdaptController_Update_Soderlind(SUNAdaptController C, sunrealtype h, sunrealtype dsm); +int SUNAdaptController_UpdateH_Soderlind(SUNAdaptController C, sunrealtype h, sunrealtype dsm); SUNDIALS_EXPORT int SUNAdaptController_Space_Soderlind(SUNAdaptController C, long int *lenrw, long int *leniw); diff --git a/include/sundials/sundials_adaptcontroller.h b/include/sundials/sundials_adaptcontroller.h index 604b239ae6..c228f1847b 100644 --- a/include/sundials/sundials_adaptcontroller.h +++ b/include/sundials/sundials_adaptcontroller.h @@ -32,20 +32,14 @@ extern "C" { /* ----------------------------------------------------------------- * SUNAdaptController types (currently, only "H" is implemented; * others are planned): - * NONE - empty controller (does nothing) - * H - controls a single-rate step size - * HP - controls a single-rate step size and method order - * MRI_H - controls two multirate step sizes - * MRI_TOL - controls slow and fast relative tolerances + * NONE - empty controller (does nothing) + * H - controls a single-rate step size * ----------------------------------------------------------------- */ typedef enum { SUN_ADAPTCONTROLLER_NONE, SUN_ADAPTCONTROLLER_H, - SUN_ADAPTCONTROLLER_HP, - SUN_ADAPTCONTROLLER_MRI_H, - SUN_ADAPTCONTROLLER_MRI_TOL } SUNAdaptController_Type; /* ----------------------------------------------------------------- @@ -68,32 +62,13 @@ struct _generic_SUNAdaptController_Ops int (*estimatestep)(SUNAdaptController C, sunrealtype h, int p, sunrealtype dsm, sunrealtype* hnew); - /* REQUIRED for controllers of SUN_ADAPTCONTROLLER_HP type. */ - int (*estimatestepandorder)(SUNAdaptController C, sunrealtype h, int p, - sunrealtype dsm, sunrealtype* hnew, int *pnew); - - /* REQUIRED for controllers of SUN_ADAPTCONTROLLER_MRI_H type. */ - int (*estimatemristeps)(SUNAdaptController C, sunrealtype H, sunrealtype h, - int P, int p, sunrealtype DSM, sunrealtype dsm, - sunrealtype* Hnew, sunrealtype *hnew); - - /* REQUIRED for controllers of SUN_ADAPTCONTROLLER_MRI_TOL type. */ - int (*estimatesteptol)(SUNAdaptController C, sunrealtype H, int P, - sunrealtype tolfac, sunrealtype DSM, - sunrealtype dsm, sunrealtype *Hnew, - sunrealtype* tolfacnew); - /* OPTIONAL for all SUNAdaptController implementations. */ int (*destroy)(SUNAdaptController C); int (*reset)(SUNAdaptController C); int (*setdefaults)(SUNAdaptController C); int (*write)(SUNAdaptController C, FILE* fptr); int (*seterrorbias)(SUNAdaptController C, sunrealtype bias); - int (*update)(SUNAdaptController C, sunrealtype h, sunrealtype dsm); - int (*updatemrih)(SUNAdaptController C, sunrealtype H, sunrealtype h, - sunrealtype DSM, sunrealtype dsm); - int (*updatemritol)(SUNAdaptController C, sunrealtype H, sunrealtype tolfac, - sunrealtype DSM, sunrealtype dsm); + int (*updateh)(SUNAdaptController C, sunrealtype h, sunrealtype dsm); int (*space)(SUNAdaptController C, long int *lenrw, long int *leniw); }; @@ -137,42 +112,6 @@ SUNDIALS_EXPORT int SUNAdaptController_EstimateStep(SUNAdaptController C, sunrealtype h, int p, sunrealtype dsm, sunrealtype* hnew); -/* Combined step size + order controller function. This is called - following a time step with size 'h' and order 'p' that has local - error factor 'dsm'. The controller should estimate 'hnew' and - 'pnew' so that the ensuing step will have 'dsm' value JUST BELOW 1 - with minimal computational effort. */ -SUNDIALS_EXPORT -int SUNAdaptController_EstimateStepAndOrder(SUNAdaptController C, sunrealtype h, - int p, sunrealtype dsm, - sunrealtype* hnew, int *pnew); - -/* Combined slow/fast multirate step size controller function. This - is called following a slow multirate time step with sizes 'H' and - 'h' (slow and fast, resp.), and error factors 'DSM' and 'dsm' - (slow and fast, resp.). The controller should estimate slow and - fast steps 'Hnew' and 'hnew', resp., so that the ensuing step will - have 'DSM' and 'dsm' values JUST BELOW 1 with minimal computational - effort. */ -SUNDIALS_EXPORT -int SUNAdaptController_EstimateMRISteps(SUNAdaptController C, sunrealtype H, - sunrealtype h, int P, int p, - sunrealtype DSM, sunrealtype dsm, - sunrealtype* Hnew, sunrealtype *hnew); - -/* Combined slow step/fast tolerance multirate controller function. - This is called following a slow multirate time step with size 'H' - and fast/slow relative tolerance ratio 'tolfac', and error factors - 'DSM' and 'dsm' (slow and fast, resp.). The controller should - estimate slow stepsize 'Hnew' and updated relative tolerance ratio - 'tolfacnew', so that the ensuing step will have 'DSM' and 'dsm' - values JUST BELOW 1 with minimal computational effort. */ -SUNDIALS_EXPORT -int SUNAdaptController_EstimateStepTol(SUNAdaptController C, sunrealtype H, - int P, sunrealtype tolfac, sunrealtype DSM, - sunrealtype dsm, sunrealtype *Hnew, - sunrealtype* tolfacnew); - /* Function to reset the controller to its initial state, e.g., if it stores a small number of previous dsm or step size values. */ SUNDIALS_EXPORT @@ -192,27 +131,11 @@ int SUNAdaptController_Write(SUNAdaptController C, FILE* fptr); SUNDIALS_EXPORT int SUNAdaptController_SetErrorBias(SUNAdaptController C, sunrealtype bias); -/* Function to notify the controller of a successful time step with size - h and local error factor dsm, indicating that the step size or local - error factor can be saved for subsequent controller functions. */ -SUNDIALS_EXPORT -int SUNAdaptController_Update(SUNAdaptController C, sunrealtype h, sunrealtype dsm); - -/* Function to notify the controller of a successful multirate time step - with sizes H and h, and local error factors DSM and dsm, indicating that - the step sizes or local error factors can be saved for subsequent - controller functions. */ -SUNDIALS_EXPORT -int SUNAdaptController_UpdateMRIH(SUNAdaptController C, sunrealtype H, sunrealtype h, - sunrealtype DSM, sunrealtype dsm); - -/* Function to notify the controller of a successful multirate time step - with size H and fast tolerance factor tolfac, and local error factors - DSM and dsm, indicating that the step size, tolerance factor, or local - error factors can be saved for subsequent controller functions. */ +/* Function to notify a controller of type SUN_ADAPTCONTROLLER_H that + a successful time step was taken with stepsize h and local error factor + dsm, indicating that these can be saved for subsequent controller functions. */ SUNDIALS_EXPORT -int SUNAdaptController_UpdateMRITol(SUNAdaptController C, sunrealtype H, sunrealtype tolfac, - sunrealtype DSM, sunrealtype dsm); +int SUNAdaptController_UpdateH(SUNAdaptController C, sunrealtype h, sunrealtype dsm); /* Function to return the memory requirements of the controller object. */ SUNDIALS_EXPORT diff --git a/src/arkode/arkode.c b/src/arkode/arkode.c index 8d9d83f52b..48b1cc995a 100644 --- a/src/arkode/arkode.c +++ b/src/arkode/arkode.c @@ -2470,7 +2470,7 @@ int arkCompleteStep(ARKodeMem ark_mem, realtype dsm) N_VScale(ONE, ark_mem->ycur, ark_mem->yn); /* Notify time step controller object of successful step */ - retval = SUNAdaptController_Update(ark_mem->hadapt_mem->hcontroller, ark_mem->h, dsm); + retval = SUNAdaptController_UpdateH(ark_mem->hadapt_mem->hcontroller, ark_mem->h, dsm); if (retval != SUNADAPTCONTROLLER_SUCCESS) { arkProcessError(ark_mem, ARK_CONTROLLER_ERR, "ARKODE", "arkCompleteStep", "Failure updating controller object"); diff --git a/src/arkode/arkode_user_controller.c b/src/arkode/arkode_user_controller.c index 48013d28bf..8b9d2e3862 100644 --- a/src/arkode/arkode_user_controller.c +++ b/src/arkode/arkode_user_controller.c @@ -61,7 +61,7 @@ SUNAdaptController ARKUserControl(SUNContext sunctx, void* arkode_mem, C->ops->estimatestep = SUNAdaptController_EstimateStep_ARKUserControl; C->ops->reset = SUNAdaptController_Reset_ARKUserControl; C->ops->write = SUNAdaptController_Write_ARKUserControl; - C->ops->update = SUNAdaptController_Update_ARKUserControl; + C->ops->updateh = SUNAdaptController_UpdateH_ARKUserControl; C->ops->space = SUNAdaptController_Space_ARKUserControl; /* Create content */ @@ -137,7 +137,7 @@ int SUNAdaptController_Write_ARKUserControl(SUNAdaptController C, FILE *fptr) return SUNADAPTCONTROLLER_SUCCESS; } -int SUNAdaptController_Update_ARKUserControl(SUNAdaptController C, realtype h, realtype dsm) +int SUNAdaptController_UpdateH_ARKUserControl(SUNAdaptController C, realtype h, realtype dsm) { SC_HPP(C) = SC_HP(C); SC_HP(C) = h; diff --git a/src/arkode/arkode_user_controller.h b/src/arkode/arkode_user_controller.h index a435331dde..201e622b70 100644 --- a/src/arkode/arkode_user_controller.h +++ b/src/arkode/arkode_user_controller.h @@ -60,7 +60,7 @@ int SUNAdaptController_Reset_ARKUserControl(SUNAdaptController C); SUNDIALS_EXPORT int SUNAdaptController_Write_ARKUserControl(SUNAdaptController C, FILE* fptr); SUNDIALS_EXPORT -int SUNAdaptController_Update_ARKUserControl(SUNAdaptController C, realtype h, realtype dsm); +int SUNAdaptController_UpdateH_ARKUserControl(SUNAdaptController C, realtype h, realtype dsm); SUNDIALS_EXPORT int SUNAdaptController_Space_ARKUserControl(SUNAdaptController C, long int *lenrw, long int *leniw); diff --git a/src/arkode/fmod/farkode_arkstep_mod.f90 b/src/arkode/fmod/farkode_arkstep_mod.f90 index 6388225f91..08ee14cc0a 100644 --- a/src/arkode/fmod/farkode_arkstep_mod.f90 +++ b/src/arkode/fmod/farkode_arkstep_mod.f90 @@ -45,7 +45,9 @@ module farkode_arkstep_mod integer(C_INT), parameter, public :: ARKSTEP_DEFAULT_ERK_4 = ARKODE_ZONNEVELD_5_3_4 integer(C_INT), parameter, public :: ARKSTEP_DEFAULT_ERK_5 = ARKODE_CASH_KARP_6_4_5 integer(C_INT), parameter, public :: ARKSTEP_DEFAULT_ERK_6 = ARKODE_VERNER_8_5_6 + integer(C_INT), parameter, public :: ARKSTEP_DEFAULT_ERK_7 = ARKODE_VERNER_10_6_7 integer(C_INT), parameter, public :: ARKSTEP_DEFAULT_ERK_8 = ARKODE_FEHLBERG_13_7_8 + integer(C_INT), parameter, public :: ARKSTEP_DEFAULT_ERK_9 = ARKODE_VERNER_16_8_9 integer(C_INT), parameter, public :: ARKSTEP_DEFAULT_DIRK_2 = ARKODE_SDIRK_2_1_2 integer(C_INT), parameter, public :: ARKSTEP_DEFAULT_DIRK_3 = ARKODE_ARK324L2SA_DIRK_4_2_3 integer(C_INT), parameter, public :: ARKSTEP_DEFAULT_DIRK_4 = ARKODE_SDIRK_5_3_4 diff --git a/src/arkode/fmod/farkode_erkstep_mod.f90 b/src/arkode/fmod/farkode_erkstep_mod.f90 index 168cfa5a87..d7f2b4fa8b 100644 --- a/src/arkode/fmod/farkode_erkstep_mod.f90 +++ b/src/arkode/fmod/farkode_erkstep_mod.f90 @@ -45,7 +45,9 @@ module farkode_erkstep_mod integer(C_INT), parameter, public :: ERKSTEP_DEFAULT_4 = ARKODE_ZONNEVELD_5_3_4 integer(C_INT), parameter, public :: ERKSTEP_DEFAULT_5 = ARKODE_CASH_KARP_6_4_5 integer(C_INT), parameter, public :: ERKSTEP_DEFAULT_6 = ARKODE_VERNER_8_5_6 + integer(C_INT), parameter, public :: ERKSTEP_DEFAULT_7 = ARKODE_VERNER_10_6_7 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 diff --git a/src/arkode/fmod/farkode_mod.f90 b/src/arkode/fmod/farkode_mod.f90 index e8c3b9dbd2..31610f9ac4 100644 --- a/src/arkode/fmod/farkode_mod.f90 +++ b/src/arkode/fmod/farkode_mod.f90 @@ -238,7 +238,7 @@ module farkode_mod integer(C_INT), parameter, public :: ARK437L2SA_ERK_7_3_4 = 13_C_INT integer(C_INT), parameter, public :: ARK548L2SAb_ERK_8_4_5 = 14_C_INT integer(C_INT), parameter, public :: MIN_ERK_NUM = 0_C_INT - integer(C_INT), parameter, public :: MAX_ERK_NUM = 14_C_INT + integer(C_INT), parameter, public :: MAX_ERK_NUM = 21_C_INT ! typedef enum ARKODE_ERKTableID enum, bind(c) enumerator :: ARKODE_ERK_NONE = -1 @@ -259,14 +259,21 @@ module farkode_mod enumerator :: ARKODE_ARK437L2SA_ERK_7_3_4 enumerator :: ARKODE_ARK548L2SAb_ERK_8_4_5 enumerator :: ARKODE_ARK2_ERK_3_1_2 - enumerator :: ARKODE_MAX_ERK_NUM = ARKODE_ARK2_ERK_3_1_2 + enumerator :: ARKODE_SOFRONIOU_SPALETTA_5_3_4 + enumerator :: ARKODE_SHU_OSHER_3_2_3 + enumerator :: ARKODE_VERNER_9_5_6 + enumerator :: ARKODE_VERNER_10_6_7 + enumerator :: ARKODE_VERNER_13_7_8 + enumerator :: ARKODE_VERNER_16_8_9 + enumerator :: ARKODE_MAX_ERK_NUM = ARKODE_VERNER_16_8_9 end enum integer, parameter, public :: ARKODE_ERKTableID = kind(ARKODE_ERK_NONE) public :: ARKODE_ERK_NONE, ARKODE_MIN_ERK_NUM, ARKODE_HEUN_EULER_2_1_2, ARKODE_BOGACKI_SHAMPINE_4_2_3, & ARKODE_ARK324L2SA_ERK_4_2_3, ARKODE_ZONNEVELD_5_3_4, ARKODE_ARK436L2SA_ERK_6_3_4, ARKODE_SAYFY_ABURUB_6_3_4, & ARKODE_CASH_KARP_6_4_5, ARKODE_FEHLBERG_6_4_5, ARKODE_DORMAND_PRINCE_7_4_5, ARKODE_ARK548L2SA_ERK_8_4_5, & ARKODE_VERNER_8_5_6, ARKODE_FEHLBERG_13_7_8, ARKODE_KNOTH_WOLKE_3_3, ARKODE_ARK437L2SA_ERK_7_3_4, & - ARKODE_ARK548L2SAb_ERK_8_4_5, ARKODE_ARK2_ERK_3_1_2, ARKODE_MAX_ERK_NUM + ARKODE_ARK548L2SAb_ERK_8_4_5, ARKODE_ARK2_ERK_3_1_2, ARKODE_SOFRONIOU_SPALETTA_5_3_4, ARKODE_SHU_OSHER_3_2_3, & + ARKODE_VERNER_9_5_6, ARKODE_VERNER_10_6_7, ARKODE_VERNER_13_7_8, ARKODE_VERNER_16_8_9, ARKODE_MAX_ERK_NUM public :: FARKodeButcherTable_LoadERK public :: FARKodeButcherTable_LoadERKByName ! typedef enum ARKODE_SPRKMethodID diff --git a/src/sunadaptcontroller/imexgus/fmod/fsunadaptcontroller_imexgus_mod.c b/src/sunadaptcontroller/imexgus/fmod/fsunadaptcontroller_imexgus_mod.c index d08b5811a1..18ab594868 100644 --- a/src/sunadaptcontroller/imexgus/fmod/fsunadaptcontroller_imexgus_mod.c +++ b/src/sunadaptcontroller/imexgus/fmod/fsunadaptcontroller_imexgus_mod.c @@ -324,7 +324,7 @@ SWIGEXPORT int _wrap_FSUNAdaptController_SetErrorBias_ImExGus(SUNAdaptController } -SWIGEXPORT int _wrap_FSUNAdaptController_Update_ImExGus(SUNAdaptController farg1, double const *farg2, double const *farg3) { +SWIGEXPORT int _wrap_FSUNAdaptController_UpdateH_ImExGus(SUNAdaptController farg1, double const *farg2, double const *farg3) { int fresult ; SUNAdaptController arg1 = (SUNAdaptController) 0 ; sunrealtype arg2 ; @@ -334,7 +334,7 @@ SWIGEXPORT int _wrap_FSUNAdaptController_Update_ImExGus(SUNAdaptController farg1 arg1 = (SUNAdaptController)(farg1); arg2 = (sunrealtype)(*farg2); arg3 = (sunrealtype)(*farg3); - result = (int)SUNAdaptController_Update_ImExGus(arg1,arg2,arg3); + result = (int)SUNAdaptController_UpdateH_ImExGus(arg1,arg2,arg3); fresult = (int)(result); return fresult; } diff --git a/src/sunadaptcontroller/imexgus/fmod/fsunadaptcontroller_imexgus_mod.f90 b/src/sunadaptcontroller/imexgus/fmod/fsunadaptcontroller_imexgus_mod.f90 index 8ebe512def..11443858ac 100644 --- a/src/sunadaptcontroller/imexgus/fmod/fsunadaptcontroller_imexgus_mod.f90 +++ b/src/sunadaptcontroller/imexgus/fmod/fsunadaptcontroller_imexgus_mod.f90 @@ -35,7 +35,7 @@ module fsunadaptcontroller_imexgus_mod public :: FSUNAdaptController_SetDefaults_ImExGus public :: FSUNAdaptController_Write_ImExGus public :: FSUNAdaptController_SetErrorBias_ImExGus - public :: FSUNAdaptController_Update_ImExGus + public :: FSUNAdaptController_UpdateH_ImExGus public :: FSUNAdaptController_Space_ImExGus ! WRAPPER DECLARATIONS @@ -114,8 +114,8 @@ function swigc_FSUNAdaptController_SetErrorBias_ImExGus(farg1, farg2) & integer(C_INT) :: fresult end function -function swigc_FSUNAdaptController_Update_ImExGus(farg1, farg2, farg3) & -bind(C, name="_wrap_FSUNAdaptController_Update_ImExGus") & +function swigc_FSUNAdaptController_UpdateH_ImExGus(farg1, farg2, farg3) & +bind(C, name="_wrap_FSUNAdaptController_UpdateH_ImExGus") & result(fresult) use, intrinsic :: ISO_C_BINDING type(C_PTR), value :: farg1 @@ -273,7 +273,7 @@ function FSUNAdaptController_SetErrorBias_ImExGus(c, bias) & swig_result = fresult end function -function FSUNAdaptController_Update_ImExGus(c, h, dsm) & +function FSUNAdaptController_UpdateH_ImExGus(c, h, dsm) & result(swig_result) use, intrinsic :: ISO_C_BINDING integer(C_INT) :: swig_result @@ -288,7 +288,7 @@ function FSUNAdaptController_Update_ImExGus(c, h, dsm) & farg1 = c_loc(c) farg2 = h farg3 = dsm -fresult = swigc_FSUNAdaptController_Update_ImExGus(farg1, farg2, farg3) +fresult = swigc_FSUNAdaptController_UpdateH_ImExGus(farg1, farg2, farg3) swig_result = fresult end function diff --git a/src/sunadaptcontroller/imexgus/sunadaptcontroller_imexgus.c b/src/sunadaptcontroller/imexgus/sunadaptcontroller_imexgus.c index 6d1e6deec8..d8baea0ceb 100644 --- a/src/sunadaptcontroller/imexgus/sunadaptcontroller_imexgus.c +++ b/src/sunadaptcontroller/imexgus/sunadaptcontroller_imexgus.c @@ -72,7 +72,7 @@ SUNAdaptController SUNAdaptController_ImExGus(SUNContext sunctx) C->ops->setdefaults = SUNAdaptController_SetDefaults_ImExGus; C->ops->write = SUNAdaptController_Write_ImExGus; C->ops->seterrorbias = SUNAdaptController_SetErrorBias_ImExGus; - C->ops->update = SUNAdaptController_Update_ImExGus; + C->ops->updateh = SUNAdaptController_UpdateH_ImExGus; C->ops->space = SUNAdaptController_Space_ImExGus; /* Create content */ @@ -206,7 +206,7 @@ int SUNAdaptController_SetErrorBias_ImExGus(SUNAdaptController C, sunrealtype bi return SUNADAPTCONTROLLER_SUCCESS; } -int SUNAdaptController_Update_ImExGus(SUNAdaptController C, sunrealtype h, sunrealtype dsm) +int SUNAdaptController_UpdateH_ImExGus(SUNAdaptController C, sunrealtype h, sunrealtype dsm) { SACIMEXGUS_EP(C) = SACIMEXGUS_BIAS(C) * dsm; SACIMEXGUS_HP(C) = h; diff --git a/src/sunadaptcontroller/soderlind/fmod/fsunadaptcontroller_soderlind_mod.c b/src/sunadaptcontroller/soderlind/fmod/fsunadaptcontroller_soderlind_mod.c index ab30541d28..394e83cd3e 100644 --- a/src/sunadaptcontroller/soderlind/fmod/fsunadaptcontroller_soderlind_mod.c +++ b/src/sunadaptcontroller/soderlind/fmod/fsunadaptcontroller_soderlind_mod.c @@ -326,7 +326,7 @@ SWIGEXPORT int _wrap_FSUNAdaptController_SetErrorBias_Soderlind(SUNAdaptControll } -SWIGEXPORT int _wrap_FSUNAdaptController_Update_Soderlind(SUNAdaptController farg1, double const *farg2, double const *farg3) { +SWIGEXPORT int _wrap_FSUNAdaptController_UpdateH_Soderlind(SUNAdaptController farg1, double const *farg2, double const *farg3) { int fresult ; SUNAdaptController arg1 = (SUNAdaptController) 0 ; sunrealtype arg2 ; @@ -336,7 +336,7 @@ SWIGEXPORT int _wrap_FSUNAdaptController_Update_Soderlind(SUNAdaptController far arg1 = (SUNAdaptController)(farg1); arg2 = (sunrealtype)(*farg2); arg3 = (sunrealtype)(*farg3); - result = (int)SUNAdaptController_Update_Soderlind(arg1,arg2,arg3); + result = (int)SUNAdaptController_UpdateH_Soderlind(arg1,arg2,arg3); fresult = (int)(result); return fresult; } diff --git a/src/sunadaptcontroller/soderlind/fmod/fsunadaptcontroller_soderlind_mod.f90 b/src/sunadaptcontroller/soderlind/fmod/fsunadaptcontroller_soderlind_mod.f90 index ea0c79b688..720482cd6f 100644 --- a/src/sunadaptcontroller/soderlind/fmod/fsunadaptcontroller_soderlind_mod.f90 +++ b/src/sunadaptcontroller/soderlind/fmod/fsunadaptcontroller_soderlind_mod.f90 @@ -35,7 +35,7 @@ module fsunadaptcontroller_soderlind_mod public :: FSUNAdaptController_SetDefaults_Soderlind public :: FSUNAdaptController_Write_Soderlind public :: FSUNAdaptController_SetErrorBias_Soderlind - public :: FSUNAdaptController_Update_Soderlind + public :: FSUNAdaptController_UpdateH_Soderlind public :: FSUNAdaptController_Space_Soderlind public :: FSUNAdaptController_PID public :: FSUNAdaptController_SetParams_PID @@ -125,8 +125,8 @@ function swigc_FSUNAdaptController_SetErrorBias_Soderlind(farg1, farg2) & integer(C_INT) :: fresult end function -function swigc_FSUNAdaptController_Update_Soderlind(farg1, farg2, farg3) & -bind(C, name="_wrap_FSUNAdaptController_Update_Soderlind") & +function swigc_FSUNAdaptController_UpdateH_Soderlind(farg1, farg2, farg3) & +bind(C, name="_wrap_FSUNAdaptController_UpdateH_Soderlind") & result(fresult) use, intrinsic :: ISO_C_BINDING type(C_PTR), value :: farg1 @@ -377,7 +377,7 @@ function FSUNAdaptController_SetErrorBias_Soderlind(c, bias) & swig_result = fresult end function -function FSUNAdaptController_Update_Soderlind(c, h, dsm) & +function FSUNAdaptController_UpdateH_Soderlind(c, h, dsm) & result(swig_result) use, intrinsic :: ISO_C_BINDING integer(C_INT) :: swig_result @@ -392,7 +392,7 @@ function FSUNAdaptController_Update_Soderlind(c, h, dsm) & farg1 = c_loc(c) farg2 = h farg3 = dsm -fresult = swigc_FSUNAdaptController_Update_Soderlind(farg1, farg2, farg3) +fresult = swigc_FSUNAdaptController_UpdateH_Soderlind(farg1, farg2, farg3) swig_result = fresult end function diff --git a/src/sunadaptcontroller/soderlind/sunadaptcontroller_soderlind.c b/src/sunadaptcontroller/soderlind/sunadaptcontroller_soderlind.c index 588c7fa04b..314a2e2cd8 100644 --- a/src/sunadaptcontroller/soderlind/sunadaptcontroller_soderlind.c +++ b/src/sunadaptcontroller/soderlind/sunadaptcontroller_soderlind.c @@ -86,7 +86,7 @@ SUNAdaptController SUNAdaptController_Soderlind(SUNContext sunctx) C->ops->setdefaults = SUNAdaptController_SetDefaults_Soderlind; C->ops->write = SUNAdaptController_Write_Soderlind; C->ops->seterrorbias = SUNAdaptController_SetErrorBias_Soderlind; - C->ops->update = SUNAdaptController_Update_Soderlind; + C->ops->updateh = SUNAdaptController_UpdateH_Soderlind; C->ops->space = SUNAdaptController_Space_Soderlind; /* Create content */ @@ -373,7 +373,7 @@ int SUNAdaptController_SetErrorBias_Soderlind(SUNAdaptController C, sunrealtype return SUNADAPTCONTROLLER_SUCCESS; } -int SUNAdaptController_Update_Soderlind(SUNAdaptController C, sunrealtype h, sunrealtype dsm) +int SUNAdaptController_UpdateH_Soderlind(SUNAdaptController C, sunrealtype h, sunrealtype dsm) { SODERLIND_EPP(C) = SODERLIND_EP(C); SODERLIND_EP(C) = SODERLIND_BIAS(C) * dsm; diff --git a/src/sundials/fmod/fsundials_adaptcontroller_mod.c b/src/sundials/fmod/fsundials_adaptcontroller_mod.c index e106fa2f7f..9ece239fdc 100644 --- a/src/sundials/fmod/fsundials_adaptcontroller_mod.c +++ b/src/sundials/fmod/fsundials_adaptcontroller_mod.c @@ -246,82 +246,6 @@ SWIGEXPORT int _wrap_FSUNAdaptController_EstimateStep(SUNAdaptController farg1, } -SWIGEXPORT int _wrap_FSUNAdaptController_EstimateStepAndOrder(SUNAdaptController farg1, double const *farg2, int const *farg3, double const *farg4, double *farg5, int *farg6) { - int fresult ; - SUNAdaptController arg1 = (SUNAdaptController) 0 ; - sunrealtype arg2 ; - int arg3 ; - sunrealtype arg4 ; - sunrealtype *arg5 = (sunrealtype *) 0 ; - int *arg6 = (int *) 0 ; - int result; - - arg1 = (SUNAdaptController)(farg1); - arg2 = (sunrealtype)(*farg2); - arg3 = (int)(*farg3); - arg4 = (sunrealtype)(*farg4); - arg5 = (sunrealtype *)(farg5); - arg6 = (int *)(farg6); - result = (int)SUNAdaptController_EstimateStepAndOrder(arg1,arg2,arg3,arg4,arg5,arg6); - fresult = (int)(result); - return fresult; -} - - -SWIGEXPORT int _wrap_FSUNAdaptController_EstimateMRISteps(SUNAdaptController farg1, double const *farg2, double const *farg3, int const *farg4, int const *farg5, double const *farg6, double const *farg7, double *farg8, double *farg9) { - int fresult ; - SUNAdaptController arg1 = (SUNAdaptController) 0 ; - sunrealtype arg2 ; - sunrealtype arg3 ; - int arg4 ; - int arg5 ; - sunrealtype arg6 ; - sunrealtype arg7 ; - sunrealtype *arg8 = (sunrealtype *) 0 ; - sunrealtype *arg9 = (sunrealtype *) 0 ; - int result; - - arg1 = (SUNAdaptController)(farg1); - arg2 = (sunrealtype)(*farg2); - arg3 = (sunrealtype)(*farg3); - arg4 = (int)(*farg4); - arg5 = (int)(*farg5); - arg6 = (sunrealtype)(*farg6); - arg7 = (sunrealtype)(*farg7); - arg8 = (sunrealtype *)(farg8); - arg9 = (sunrealtype *)(farg9); - result = (int)SUNAdaptController_EstimateMRISteps(arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9); - fresult = (int)(result); - return fresult; -} - - -SWIGEXPORT int _wrap_FSUNAdaptController_EstimateStepTol(SUNAdaptController farg1, double const *farg2, int const *farg3, double const *farg4, double const *farg5, double const *farg6, double *farg7, double *farg8) { - int fresult ; - SUNAdaptController arg1 = (SUNAdaptController) 0 ; - sunrealtype arg2 ; - int arg3 ; - sunrealtype arg4 ; - sunrealtype arg5 ; - sunrealtype arg6 ; - sunrealtype *arg7 = (sunrealtype *) 0 ; - sunrealtype *arg8 = (sunrealtype *) 0 ; - int result; - - arg1 = (SUNAdaptController)(farg1); - arg2 = (sunrealtype)(*farg2); - arg3 = (int)(*farg3); - arg4 = (sunrealtype)(*farg4); - arg5 = (sunrealtype)(*farg5); - arg6 = (sunrealtype)(*farg6); - arg7 = (sunrealtype *)(farg7); - arg8 = (sunrealtype *)(farg8); - result = (int)SUNAdaptController_EstimateStepTol(arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8); - fresult = (int)(result); - return fresult; -} - - SWIGEXPORT int _wrap_FSUNAdaptController_Reset(SUNAdaptController farg1) { int fresult ; SUNAdaptController arg1 = (SUNAdaptController) 0 ; @@ -374,57 +298,17 @@ SWIGEXPORT int _wrap_FSUNAdaptController_SetErrorBias(SUNAdaptController farg1, } -SWIGEXPORT int _wrap_FSUNAdaptController_Update(SUNAdaptController farg1, double const *farg2, double const *farg3) { - int fresult ; - SUNAdaptController arg1 = (SUNAdaptController) 0 ; - sunrealtype arg2 ; - sunrealtype arg3 ; - int result; - - arg1 = (SUNAdaptController)(farg1); - arg2 = (sunrealtype)(*farg2); - arg3 = (sunrealtype)(*farg3); - result = (int)SUNAdaptController_Update(arg1,arg2,arg3); - fresult = (int)(result); - return fresult; -} - - -SWIGEXPORT int _wrap_FSUNAdaptController_UpdateMRIH(SUNAdaptController farg1, double const *farg2, double const *farg3, double const *farg4, double const *farg5) { - int fresult ; - SUNAdaptController arg1 = (SUNAdaptController) 0 ; - sunrealtype arg2 ; - sunrealtype arg3 ; - sunrealtype arg4 ; - sunrealtype arg5 ; - int result; - - arg1 = (SUNAdaptController)(farg1); - arg2 = (sunrealtype)(*farg2); - arg3 = (sunrealtype)(*farg3); - arg4 = (sunrealtype)(*farg4); - arg5 = (sunrealtype)(*farg5); - result = (int)SUNAdaptController_UpdateMRIH(arg1,arg2,arg3,arg4,arg5); - fresult = (int)(result); - return fresult; -} - - -SWIGEXPORT int _wrap_FSUNAdaptController_UpdateMRITol(SUNAdaptController farg1, double const *farg2, double const *farg3, double const *farg4, double const *farg5) { +SWIGEXPORT int _wrap_FSUNAdaptController_UpdateH(SUNAdaptController farg1, double const *farg2, double const *farg3) { int fresult ; SUNAdaptController arg1 = (SUNAdaptController) 0 ; sunrealtype arg2 ; sunrealtype arg3 ; - sunrealtype arg4 ; - sunrealtype arg5 ; int result; arg1 = (SUNAdaptController)(farg1); arg2 = (sunrealtype)(*farg2); arg3 = (sunrealtype)(*farg3); - arg4 = (sunrealtype)(*farg4); - arg5 = (sunrealtype)(*farg5); - result = (int)SUNAdaptController_UpdateMRITol(arg1,arg2,arg3,arg4,arg5); + result = (int)SUNAdaptController_UpdateH(arg1,arg2,arg3); fresult = (int)(result); return fresult; } diff --git a/src/sundials/fmod/fsundials_adaptcontroller_mod.f90 b/src/sundials/fmod/fsundials_adaptcontroller_mod.f90 index c8a73eea38..c804548d50 100644 --- a/src/sundials/fmod/fsundials_adaptcontroller_mod.f90 +++ b/src/sundials/fmod/fsundials_adaptcontroller_mod.f90 @@ -15,28 +15,19 @@ module fsundials_adaptcontroller_mod enum, bind(c) enumerator :: SUN_ADAPTCONTROLLER_NONE enumerator :: SUN_ADAPTCONTROLLER_H - enumerator :: SUN_ADAPTCONTROLLER_HP - enumerator :: SUN_ADAPTCONTROLLER_MRI_H - enumerator :: SUN_ADAPTCONTROLLER_MRI_TOL end enum integer, parameter, public :: SUNAdaptController_Type = kind(SUN_ADAPTCONTROLLER_NONE) - public :: SUN_ADAPTCONTROLLER_NONE, SUN_ADAPTCONTROLLER_H, SUN_ADAPTCONTROLLER_HP, SUN_ADAPTCONTROLLER_MRI_H, & - SUN_ADAPTCONTROLLER_MRI_TOL + public :: SUN_ADAPTCONTROLLER_NONE, SUN_ADAPTCONTROLLER_H ! struct struct _generic_SUNAdaptController_Ops type, bind(C), public :: SUNAdaptController_Ops type(C_FUNPTR), public :: gettype type(C_FUNPTR), public :: estimatestep - type(C_FUNPTR), public :: estimatestepandorder - type(C_FUNPTR), public :: estimatemristeps - type(C_FUNPTR), public :: estimatesteptol type(C_FUNPTR), public :: destroy type(C_FUNPTR), public :: reset type(C_FUNPTR), public :: setdefaults type(C_FUNPTR), public :: write type(C_FUNPTR), public :: seterrorbias - type(C_FUNPTR), public :: update - type(C_FUNPTR), public :: updatemrih - type(C_FUNPTR), public :: updatemritol + type(C_FUNPTR), public :: updateh type(C_FUNPTR), public :: space end type SUNAdaptController_Ops ! struct struct _generic_SUNAdaptController @@ -49,16 +40,11 @@ module fsundials_adaptcontroller_mod public :: FSUNAdaptController_GetType public :: FSUNAdaptController_Destroy public :: FSUNAdaptController_EstimateStep - public :: FSUNAdaptController_EstimateStepAndOrder - public :: FSUNAdaptController_EstimateMRISteps - public :: FSUNAdaptController_EstimateStepTol public :: FSUNAdaptController_Reset public :: FSUNAdaptController_SetDefaults public :: FSUNAdaptController_Write public :: FSUNAdaptController_SetErrorBias - public :: FSUNAdaptController_Update - public :: FSUNAdaptController_UpdateMRIH - public :: FSUNAdaptController_UpdateMRITol + public :: FSUNAdaptController_UpdateH public :: FSUNAdaptController_Space integer(C_INT), parameter, public :: SUNADAPTCONTROLLER_SUCCESS = 0_C_INT integer(C_INT), parameter, public :: SUNADAPTCONTROLLER_ILL_INPUT = -1001_C_INT @@ -104,50 +90,6 @@ function swigc_FSUNAdaptController_EstimateStep(farg1, farg2, farg3, farg4, farg integer(C_INT) :: fresult end function -function swigc_FSUNAdaptController_EstimateStepAndOrder(farg1, farg2, farg3, farg4, farg5, farg6) & -bind(C, name="_wrap_FSUNAdaptController_EstimateStepAndOrder") & -result(fresult) -use, intrinsic :: ISO_C_BINDING -type(C_PTR), value :: farg1 -real(C_DOUBLE), intent(in) :: farg2 -integer(C_INT), intent(in) :: farg3 -real(C_DOUBLE), intent(in) :: farg4 -type(C_PTR), value :: farg5 -type(C_PTR), value :: farg6 -integer(C_INT) :: fresult -end function - -function swigc_FSUNAdaptController_EstimateMRISteps(farg1, farg2, farg3, farg4, farg5, farg6, farg7, farg8, farg9) & -bind(C, name="_wrap_FSUNAdaptController_EstimateMRISteps") & -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), intent(in) :: farg4 -integer(C_INT), intent(in) :: farg5 -real(C_DOUBLE), intent(in) :: farg6 -real(C_DOUBLE), intent(in) :: farg7 -type(C_PTR), value :: farg8 -type(C_PTR), value :: farg9 -integer(C_INT) :: fresult -end function - -function swigc_FSUNAdaptController_EstimateStepTol(farg1, farg2, farg3, farg4, farg5, farg6, farg7, farg8) & -bind(C, name="_wrap_FSUNAdaptController_EstimateStepTol") & -result(fresult) -use, intrinsic :: ISO_C_BINDING -type(C_PTR), value :: farg1 -real(C_DOUBLE), intent(in) :: farg2 -integer(C_INT), intent(in) :: farg3 -real(C_DOUBLE), intent(in) :: farg4 -real(C_DOUBLE), intent(in) :: farg5 -real(C_DOUBLE), intent(in) :: farg6 -type(C_PTR), value :: farg7 -type(C_PTR), value :: farg8 -integer(C_INT) :: fresult -end function - function swigc_FSUNAdaptController_Reset(farg1) & bind(C, name="_wrap_FSUNAdaptController_Reset") & result(fresult) @@ -182,8 +124,8 @@ function swigc_FSUNAdaptController_SetErrorBias(farg1, farg2) & integer(C_INT) :: fresult end function -function swigc_FSUNAdaptController_Update(farg1, farg2, farg3) & -bind(C, name="_wrap_FSUNAdaptController_Update") & +function swigc_FSUNAdaptController_UpdateH(farg1, farg2, farg3) & +bind(C, name="_wrap_FSUNAdaptController_UpdateH") & result(fresult) use, intrinsic :: ISO_C_BINDING type(C_PTR), value :: farg1 @@ -192,30 +134,6 @@ function swigc_FSUNAdaptController_Update(farg1, farg2, farg3) & integer(C_INT) :: fresult end function -function swigc_FSUNAdaptController_UpdateMRIH(farg1, farg2, farg3, farg4, farg5) & -bind(C, name="_wrap_FSUNAdaptController_UpdateMRIH") & -result(fresult) -use, intrinsic :: ISO_C_BINDING -type(C_PTR), value :: farg1 -real(C_DOUBLE), intent(in) :: farg2 -real(C_DOUBLE), intent(in) :: farg3 -real(C_DOUBLE), intent(in) :: farg4 -real(C_DOUBLE), intent(in) :: farg5 -integer(C_INT) :: fresult -end function - -function swigc_FSUNAdaptController_UpdateMRITol(farg1, farg2, farg3, farg4, farg5) & -bind(C, name="_wrap_FSUNAdaptController_UpdateMRITol") & -result(fresult) -use, intrinsic :: ISO_C_BINDING -type(C_PTR), value :: farg1 -real(C_DOUBLE), intent(in) :: farg2 -real(C_DOUBLE), intent(in) :: farg3 -real(C_DOUBLE), intent(in) :: farg4 -real(C_DOUBLE), intent(in) :: farg5 -integer(C_INT) :: fresult -end function - function swigc_FSUNAdaptController_Space(farg1, farg2, farg3) & bind(C, name="_wrap_FSUNAdaptController_Space") & result(fresult) @@ -295,105 +213,6 @@ function FSUNAdaptController_EstimateStep(c, h, p, dsm, hnew) & swig_result = fresult end function -function FSUNAdaptController_EstimateStepAndOrder(c, h, p, dsm, hnew, pnew) & -result(swig_result) -use, intrinsic :: ISO_C_BINDING -integer(C_INT) :: swig_result -type(SUNAdaptController), target, intent(inout) :: c -real(C_DOUBLE), intent(in) :: h -integer(C_INT), intent(in) :: p -real(C_DOUBLE), intent(in) :: dsm -real(C_DOUBLE), target, intent(inout) :: hnew -integer(C_INT), dimension(*), target, intent(inout) :: pnew -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -real(C_DOUBLE) :: farg2 -integer(C_INT) :: farg3 -real(C_DOUBLE) :: farg4 -type(C_PTR) :: farg5 -type(C_PTR) :: farg6 - -farg1 = c_loc(c) -farg2 = h -farg3 = p -farg4 = dsm -farg5 = c_loc(hnew) -farg6 = c_loc(pnew(1)) -fresult = swigc_FSUNAdaptController_EstimateStepAndOrder(farg1, farg2, farg3, farg4, farg5, farg6) -swig_result = fresult -end function - -function FSUNAdaptController_EstimateMRISteps(c, h, h2, p, p4, dsm, dsm6, hnew, hnew8) & -result(swig_result) -use, intrinsic :: ISO_C_BINDING -integer(C_INT) :: swig_result -type(SUNAdaptController), target, intent(inout) :: c -real(C_DOUBLE), intent(in) :: h -real(C_DOUBLE), intent(in) :: h2 -integer(C_INT), intent(in) :: p -integer(C_INT), intent(in) :: p4 -real(C_DOUBLE), intent(in) :: dsm -real(C_DOUBLE), intent(in) :: dsm6 -real(C_DOUBLE), target, intent(inout) :: hnew -real(C_DOUBLE), target, intent(inout) :: hnew8 -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -real(C_DOUBLE) :: farg2 -real(C_DOUBLE) :: farg3 -integer(C_INT) :: farg4 -integer(C_INT) :: farg5 -real(C_DOUBLE) :: farg6 -real(C_DOUBLE) :: farg7 -type(C_PTR) :: farg8 -type(C_PTR) :: farg9 - -farg1 = c_loc(c) -farg2 = h -farg3 = h2 -farg4 = p -farg5 = p4 -farg6 = dsm -farg7 = dsm6 -farg8 = c_loc(hnew) -farg9 = c_loc(hnew8) -fresult = swigc_FSUNAdaptController_EstimateMRISteps(farg1, farg2, farg3, farg4, farg5, farg6, farg7, farg8, farg9) -swig_result = fresult -end function - -function FSUNAdaptController_EstimateStepTol(c, h, p, tolfac, dsm, dsm5, hnew, tolfacnew) & -result(swig_result) -use, intrinsic :: ISO_C_BINDING -integer(C_INT) :: swig_result -type(SUNAdaptController), target, intent(inout) :: c -real(C_DOUBLE), intent(in) :: h -integer(C_INT), intent(in) :: p -real(C_DOUBLE), intent(in) :: tolfac -real(C_DOUBLE), intent(in) :: dsm -real(C_DOUBLE), intent(in) :: dsm5 -real(C_DOUBLE), target, intent(inout) :: hnew -real(C_DOUBLE), target, intent(inout) :: tolfacnew -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -real(C_DOUBLE) :: farg2 -integer(C_INT) :: farg3 -real(C_DOUBLE) :: farg4 -real(C_DOUBLE) :: farg5 -real(C_DOUBLE) :: farg6 -type(C_PTR) :: farg7 -type(C_PTR) :: farg8 - -farg1 = c_loc(c) -farg2 = h -farg3 = p -farg4 = tolfac -farg5 = dsm -farg6 = dsm5 -farg7 = c_loc(hnew) -farg8 = c_loc(tolfacnew) -fresult = swigc_FSUNAdaptController_EstimateStepTol(farg1, farg2, farg3, farg4, farg5, farg6, farg7, farg8) -swig_result = fresult -end function - function FSUNAdaptController_Reset(c) & result(swig_result) use, intrinsic :: ISO_C_BINDING @@ -452,7 +271,7 @@ function FSUNAdaptController_SetErrorBias(c, bias) & swig_result = fresult end function -function FSUNAdaptController_Update(c, h, dsm) & +function FSUNAdaptController_UpdateH(c, h, dsm) & result(swig_result) use, intrinsic :: ISO_C_BINDING integer(C_INT) :: swig_result @@ -467,57 +286,7 @@ function FSUNAdaptController_Update(c, h, dsm) & farg1 = c_loc(c) farg2 = h farg3 = dsm -fresult = swigc_FSUNAdaptController_Update(farg1, farg2, farg3) -swig_result = fresult -end function - -function FSUNAdaptController_UpdateMRIH(c, h, h2, dsm, dsm4) & -result(swig_result) -use, intrinsic :: ISO_C_BINDING -integer(C_INT) :: swig_result -type(SUNAdaptController), target, intent(inout) :: c -real(C_DOUBLE), intent(in) :: h -real(C_DOUBLE), intent(in) :: h2 -real(C_DOUBLE), intent(in) :: dsm -real(C_DOUBLE), intent(in) :: dsm4 -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -real(C_DOUBLE) :: farg2 -real(C_DOUBLE) :: farg3 -real(C_DOUBLE) :: farg4 -real(C_DOUBLE) :: farg5 - -farg1 = c_loc(c) -farg2 = h -farg3 = h2 -farg4 = dsm -farg5 = dsm4 -fresult = swigc_FSUNAdaptController_UpdateMRIH(farg1, farg2, farg3, farg4, farg5) -swig_result = fresult -end function - -function FSUNAdaptController_UpdateMRITol(c, h, tolfac, dsm, dsm4) & -result(swig_result) -use, intrinsic :: ISO_C_BINDING -integer(C_INT) :: swig_result -type(SUNAdaptController), target, intent(inout) :: c -real(C_DOUBLE), intent(in) :: h -real(C_DOUBLE), intent(in) :: tolfac -real(C_DOUBLE), intent(in) :: dsm -real(C_DOUBLE), intent(in) :: dsm4 -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -real(C_DOUBLE) :: farg2 -real(C_DOUBLE) :: farg3 -real(C_DOUBLE) :: farg4 -real(C_DOUBLE) :: farg5 - -farg1 = c_loc(c) -farg2 = h -farg3 = tolfac -farg4 = dsm -farg5 = dsm4 -fresult = swigc_FSUNAdaptController_UpdateMRITol(farg1, farg2, farg3, farg4, farg5) +fresult = swigc_FSUNAdaptController_UpdateH(farg1, farg2, farg3) swig_result = fresult end function diff --git a/src/sundials/sundials_adaptcontroller.c b/src/sundials/sundials_adaptcontroller.c index 346b47889d..1e0357064a 100644 --- a/src/sundials/sundials_adaptcontroller.c +++ b/src/sundials/sundials_adaptcontroller.c @@ -45,15 +45,10 @@ SUNAdaptController SUNAdaptController_NewEmpty(SUNContext sunctx) ops->destroy = NULL; ops->reset = NULL; ops->estimatestep = NULL; - ops->estimatestepandorder = NULL; - ops->estimatemristeps = NULL; - ops->estimatesteptol = NULL; ops->setdefaults = NULL; ops->write = NULL; ops->seterrorbias = NULL; - ops->update = NULL; - ops->updatemrih = NULL; - ops->updatemritol = NULL; + ops->updateh = NULL; ops->space = NULL; /* attach ops and initialize content to NULL */ @@ -128,54 +123,6 @@ int SUNAdaptController_EstimateStep(SUNAdaptController C, sunrealtype h, int p, } -int SUNAdaptController_EstimateStepAndOrder(SUNAdaptController C, sunrealtype h, - int p, sunrealtype dsm, - sunrealtype* hnew, int *pnew) -{ - int ier = 0; - *hnew = h; /* initialize outputs with identity */ - *pnew = p; - if (C == NULL) { return ier; } - if (C->ops->estimatestepandorder) - { - ier = C->ops->estimatestepandorder(C, h, p, dsm, hnew, pnew); - } - return(ier); -} - -int SUNAdaptController_EstimateMRISteps(SUNAdaptController C, sunrealtype H, - sunrealtype h, int P, int p, - sunrealtype DSM, sunrealtype dsm, - sunrealtype* Hnew, sunrealtype *hnew) -{ - int ier = 0; - *Hnew = H; /* initialize outputs with identity */ - *hnew = h; - if (C == NULL) { return ier; } - if (C->ops->estimatemristeps) - { - ier = C->ops->estimatemristeps(C, H, h, P, p, DSM, dsm, Hnew, hnew); - } - return(ier); -} - -int SUNAdaptController_EstimateStepTol(SUNAdaptController C, sunrealtype H, - int P, sunrealtype tolfac, - sunrealtype DSM, sunrealtype dsm, - sunrealtype *Hnew, sunrealtype* tolfacnew) -{ - int ier = 0; - *Hnew = H; /* initialize outputs with identity */ - *tolfacnew = tolfac; - if (C == NULL) { return ier; } - if (C->ops->estimatesteptol) - { - ier = C->ops->estimatesteptol(C, H, P, tolfac, DSM, dsm, - Hnew, tolfacnew); - } - return(ier); -} - int SUNAdaptController_Reset(SUNAdaptController C) { int ier = 0; @@ -207,29 +154,11 @@ int SUNAdaptController_SetErrorBias(SUNAdaptController C, sunrealtype bias) return(ier); } -int SUNAdaptController_Update(SUNAdaptController C, sunrealtype h, sunrealtype dsm) -{ - int ier = 0; - if (C == NULL) { return ier; } - if (C->ops->update) { ier = C->ops->update(C, h, dsm); } - return(ier); -} - -int SUNAdaptController_UpdateMRIH(SUNAdaptController C, sunrealtype H, sunrealtype h, - sunrealtype DSM, sunrealtype dsm) -{ - int ier = 0; - if (C == NULL) { return ier; } - if (C->ops->updatemrih) { ier = C->ops->updatemrih(C, H, h, DSM, dsm); } - return(ier); -} - -int SUNAdaptController_UpdateMRITol(SUNAdaptController C, sunrealtype H, sunrealtype tolfac, - sunrealtype DSM, sunrealtype dsm) +int SUNAdaptController_UpdateH(SUNAdaptController C, sunrealtype h, sunrealtype dsm) { int ier = 0; if (C == NULL) { return ier; } - if (C->ops->updatemritol) { ier = C->ops->updatemritol(C, H, tolfac, DSM, dsm); } + if (C->ops->updateh) { ier = C->ops->updateh(C, h, dsm); } return(ier); } From f1432665fd998530fb82e2f2357512cc99fd6290 Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Tue, 31 Oct 2023 09:10:59 -0500 Subject: [PATCH 33/58] Fix for C90 compliance --- include/sundials/sundials_adaptcontroller.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/sundials/sundials_adaptcontroller.h b/include/sundials/sundials_adaptcontroller.h index c228f1847b..55c65eac6c 100644 --- a/include/sundials/sundials_adaptcontroller.h +++ b/include/sundials/sundials_adaptcontroller.h @@ -39,7 +39,7 @@ extern "C" { typedef enum { SUN_ADAPTCONTROLLER_NONE, - SUN_ADAPTCONTROLLER_H, + SUN_ADAPTCONTROLLER_H } SUNAdaptController_Type; /* ----------------------------------------------------------------- From 1d4a24feb23b3cd8bd2b1f06150a3f606f84debe Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Wed, 1 Nov 2023 11:16:30 -0500 Subject: [PATCH 34/58] Apply suggestions from code review Co-authored-by: David Gardner --- CHANGELOG.md | 4 ++-- .../SUNAdaptController_Description.rst | 4 ++-- .../SUNAdaptController_Soderlind.rst | 6 +++--- src/arkode/arkode_adapt_impl.h | 2 +- src/arkode/arkode_io.c | 15 +++++++++++++-- src/arkode/arkode_user_controller.c | 4 ++-- 6 files changed, 23 insertions(+), 12 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9087161a82..c3b5392c3a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,8 +13,8 @@ implementations. Added the routines `ARKStepSetAdaptivityAdjustment` and `ERKStepSetAdaptivityAdjustment`, that allow users to adjust the value for the method order supplied to the temporal adaptivity controllers. -The ARKODE default for this adjustment has been :math:`-1` since its initial -release, but for some applications a value of :math:`0` is more appropriate. +The ARKODE default for this adjustment has been -1 since its initial +release, but for some applications a value of 0 is more appropriate. Users who notice that their simulations encounter a large number of temporal error test failures may want to experiment with adjusting this value. diff --git a/doc/shared/sunadaptcontroller/SUNAdaptController_Description.rst b/doc/shared/sunadaptcontroller/SUNAdaptController_Description.rst index 60674b71bf..da4b5a5eda 100644 --- a/doc/shared/sunadaptcontroller/SUNAdaptController_Description.rst +++ b/doc/shared/sunadaptcontroller/SUNAdaptController_Description.rst @@ -160,7 +160,7 @@ note these requirements below. Additionally, we note the behavior of the base SU Estimates a single-rate step size. This routine is required for controllers of type ``SUN_ADAPTCONTROLLER_H``. If this is not provided by the - implementation, the base wrapper routine will set ``*hnew = h`` and return. + implementation, the class method will set ``*hnew = h`` and return. :param C: the :c:type:`SUNAdaptController` object. :param h: the step size from the previous step attempt. @@ -298,7 +298,7 @@ SUNAdaptController functions return one of the following set of error codes: * ``SUNADAPTCONTROLLER_OPERATION_FAIL`` (-1004) -- catch-all for errors not in the above list. .. note:: - The SUNDIALS time integrators do not rely on these specific return values (only + The SUNDIALS time integrators do not rely on these specific return values and only on whether the returned values are 0 (successful) or non-zero (failure). Thus, user-defined implementations are not required to use these specific error codes, so long as the zero/non-zero convention is followed. diff --git a/doc/shared/sunadaptcontroller/SUNAdaptController_Soderlind.rst b/doc/shared/sunadaptcontroller/SUNAdaptController_Soderlind.rst index 525ca7e3c1..e7bf4867f2 100644 --- a/doc/shared/sunadaptcontroller/SUNAdaptController_Soderlind.rst +++ b/doc/shared/sunadaptcontroller/SUNAdaptController_Soderlind.rst @@ -299,9 +299,9 @@ also provides the following additional user-callable routines: .. math:: h' = h_n \varepsilon_n^{-\hat{k}_1/(p+1)} \left(\frac{\varepsilon_n}{\varepsilon_{n-1}}\right)^{-\hat{k}_2/(p+1)} \left(\frac{h_n}{h_{n-1}}\right). - The inputs to this function correspond to the values of :math:`\hat{k}_1` and :math:`\hat{k}_2`, - which are internally transformed into the Soderlind coeficients :math:`k_1 = \hat{k}_1+\hat{k}_2`, - :math:`k_2 = -\hat{k}_2`, and :math:`k_4=1`. + The inputs to this function correspond to the values of :math:`\hat{k}_1` and :math:`\hat{k}_2`, + which are internally transformed into the Soderlind coeficients :math:`k_1 = \hat{k}_1+\hat{k}_2`, + :math:`k_2 = -\hat{k}_2`, and :math:`k_4=1`. :param C: the SUNAdaptController_Soderlind object. :param k1_hat: parameter used within the implicit Gustafsson controller time step estimate. diff --git a/src/arkode/arkode_adapt_impl.h b/src/arkode/arkode_adapt_impl.h index fb0ce58912..53303dcb21 100644 --- a/src/arkode/arkode_adapt_impl.h +++ b/src/arkode/arkode_adapt_impl.h @@ -52,7 +52,7 @@ extern "C" { #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, -1=min(method,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 */ diff --git a/src/arkode/arkode_io.c b/src/arkode/arkode_io.c index d64fe22e66..71f48dac91 100644 --- a/src/arkode/arkode_io.c +++ b/src/arkode/arkode_io.c @@ -357,6 +357,7 @@ int arkSetAdaptController(void *arkode_mem, SUNAdaptController C) } if (ark_mem->hadapt_mem->owncontroller) { retval = SUNAdaptController_Destroy(ark_mem->hadapt_mem->hcontroller); + ark_mem->hadapt_mem->owncontroller = SUNFALSE; if (retval != SUNADAPTCONTROLLER_SUCCESS) { arkProcessError(ark_mem, ARK_MEM_FAIL, "ARKODE", "arkSetAdaptController", "SUNAdaptController_Destroy failure"); @@ -658,6 +659,7 @@ int arkSetFixedStep(void *arkode_mem, realtype hfixed) } if (ark_mem->hadapt_mem->owncontroller) { retval = SUNAdaptController_Destroy(ark_mem->hadapt_mem->hcontroller); + ark_mem->hadapt_mem->owncontroller = SUNFALSE; if (retval != SUNADAPTCONTROLLER_SUCCESS) { arkProcessError(ark_mem, ARK_MEM_FAIL, "ARKODE", "arkSetFixedStep", "SUNAdaptController_Destroy failure"); @@ -703,7 +705,7 @@ int arkSetFixedStep(void *arkode_mem, realtype hfixed) if (retval != ARK_SUCCESS) return(retval); } - /* set ark_mem "fixedstep" entry entry */ + /* set ark_mem "fixedstep" entry */ if (hfixed != ZERO) { ark_mem->fixedstep = SUNTRUE; ark_mem->hin = hfixed; @@ -713,6 +715,7 @@ int arkSetFixedStep(void *arkode_mem, realtype hfixed) /* Notify ARKODE to use hfixed as the initial step size, and return */ retval = arkSetInitStep(arkode_mem, hfixed); + return(ARK_SUCCESS); } @@ -969,6 +972,7 @@ int arkSetAdaptivityMethod(void *arkode_mem, int imethod, int idefault, } if (ark_mem->hadapt_mem->owncontroller) { retval = SUNAdaptController_Destroy(ark_mem->hadapt_mem->hcontroller); + ark_mem->hadapt_mem->owncontroller = SUNFALSE; if (retval != SUNADAPTCONTROLLER_SUCCESS) { arkProcessError(ark_mem, ARK_MEM_FAIL, "ARKODE", "arkSetAdaptivityMethod", "SUNAdaptController_Destroy failure"); @@ -1000,6 +1004,7 @@ int arkSetAdaptivityMethod(void *arkode_mem, int imethod, int idefault, if (idefault != 1) { retval = SUNAdaptController_SetParams_PID(C, k1, -k2, k3); if (retval != SUNADAPTCONTROLLER_SUCCESS) { + (void) SUNAdaptController_Destroy(C); arkProcessError(ark_mem, ARK_CONTROLLER_ERR, "ARKODE", "arkSetAdaptivityMethod", "SUNAdaptController_SetParams_PID failure"); return(ARK_CONTROLLER_ERR); @@ -1016,6 +1021,7 @@ int arkSetAdaptivityMethod(void *arkode_mem, int imethod, int idefault, if (idefault != 1) { retval = SUNAdaptController_SetParams_PI(C, k1, -k2); if (retval != SUNADAPTCONTROLLER_SUCCESS) { + (void) SUNAdaptController_Destroy(C); arkProcessError(ark_mem, ARK_CONTROLLER_ERR, "ARKODE", "arkSetAdaptivityMethod", "SUNAdaptController_SetParams_PI failure"); return(ARK_CONTROLLER_ERR); @@ -1032,6 +1038,7 @@ int arkSetAdaptivityMethod(void *arkode_mem, int imethod, int idefault, if (idefault != 1) { retval = SUNAdaptController_SetParams_I(C, k1); if (retval != SUNADAPTCONTROLLER_SUCCESS) { + (void) SUNAdaptController_Destroy(C); arkProcessError(ark_mem, ARK_CONTROLLER_ERR, "ARKODE", "arkSetAdaptivityMethod", "SUNAdaptController_SetParams_I failure"); return(ARK_CONTROLLER_ERR); @@ -1048,6 +1055,7 @@ int arkSetAdaptivityMethod(void *arkode_mem, int imethod, int idefault, if (idefault != 1) { retval = SUNAdaptController_SetParams_ExpGus(C, k1, k2); if (retval != SUNADAPTCONTROLLER_SUCCESS) { + (void) SUNAdaptController_Destroy(C); arkProcessError(ark_mem, ARK_CONTROLLER_ERR, "ARKODE", "arkSetAdaptivityMethod", "SUNAdaptController_SetParams_ExpGus failure"); return(ARK_CONTROLLER_ERR); @@ -1064,6 +1072,7 @@ int arkSetAdaptivityMethod(void *arkode_mem, int imethod, int idefault, if (idefault != 1) { retval = SUNAdaptController_SetParams_ImpGus(C, k1, k2); if (retval != SUNADAPTCONTROLLER_SUCCESS) { + (void) SUNAdaptController_Destroy(C); arkProcessError(ark_mem, ARK_CONTROLLER_ERR, "ARKODE", "arkSetAdaptivityMethod", "SUNAdaptController_SetParams_ImpGus failure"); return(ARK_CONTROLLER_ERR); @@ -1080,6 +1089,7 @@ int arkSetAdaptivityMethod(void *arkode_mem, int imethod, int idefault, if (idefault != 1) { retval = SUNAdaptController_SetParams_ImExGus(C, k1, k2, k3, k3); if (retval != SUNADAPTCONTROLLER_SUCCESS) { + (void) SUNAdaptController_Destroy(C); arkProcessError(ark_mem, ARK_CONTROLLER_ERR, "ARKODE", "arkSetAdaptivityMethod", "SUNAdaptController_SetParams_ImExGus failure"); return(ARK_CONTROLLER_ERR); @@ -1138,6 +1148,7 @@ int arkSetAdaptivityFn(void *arkode_mem, ARKAdaptFn hfun, void *h_data) } if (ark_mem->hadapt_mem->owncontroller) { retval = SUNAdaptController_Destroy(ark_mem->hadapt_mem->hcontroller); + ark_mem->hadapt_mem->owncontroller = SUNFALSE; if (retval != SUNADAPTCONTROLLER_SUCCESS) { arkProcessError(ark_mem, ARK_MEM_FAIL, "ARKODE", "arkSetAdaptivityFn", "SUNAdaptController_Destroy failure"); @@ -1296,7 +1307,7 @@ int arkSetErrorBias(void *arkode_mem, realtype bias) arkProcessError(ark_mem, ARK_CONTROLLER_ERR, "ARKODE", "arkSetErrorBias", "SUNAdaptController_SetErrorBias failure"); return(ARK_CONTROLLER_ERR); - } + } return(ARK_SUCCESS); } diff --git a/src/arkode/arkode_user_controller.c b/src/arkode/arkode_user_controller.c index 8b9d2e3862..ddf3cbd262 100644 --- a/src/arkode/arkode_user_controller.c +++ b/src/arkode/arkode_user_controller.c @@ -48,8 +48,8 @@ SUNAdaptController ARKUserControl(SUNContext sunctx, void* arkode_mem, SUNAdaptController C; ARKUserControlContent content; - /* Return with failure if hadapt or arkode_mem are NULL */ - if ((hadapt == NULL) || (arkode_mem == NULL)) { return (NULL); } + /* Return with failure if hadapt, arkode_mem, or context are NULL */ + if ((hadapt == NULL) || (arkode_mem == NULL) || (sunctx == NULL)) { return (NULL); } /* Create an empty controller object */ C = NULL; From 5ae4b42ce113f50c76a13394f43018a3b91ddb0f Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Wed, 1 Nov 2023 11:17:24 -0500 Subject: [PATCH 35/58] Documentation updates --- .../source/Usage/ARKStep_c_interface/User_callable.rst | 6 +++++- .../source/Usage/ERKStep_c_interface/User_callable.rst | 5 ++++- 2 files changed, 9 insertions(+), 2 deletions(-) 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 36a6472cca..a272cf299e 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 @@ -1771,7 +1771,8 @@ Explicit stability function :c:func:`ARKStepSetS parameters (1), or that they will be supplied in the *adapt_params* argument (0). * *pq* -- flag denoting whether to use the embedding order of - accuracy *p* (0) or the method order of accuracy *q* (1) + accuracy *p* (0), the method order of accuracy *q* (1), or the + minimum of the two (any input not equal to 0 or 1) within the adaptivity algorithm. *p* is the default. * *adapt_params[0]* -- :math:`k_1` parameter within accuracy-based adaptivity algorithms. * *adapt_params[1]* -- :math:`k_2` parameter within accuracy-based adaptivity algorithms. @@ -1788,6 +1789,9 @@ Explicit stability function :c:func:`ARKStepSetS parameter values are desired, it is recommended to instead provide a custom function through a call to :c:func:`ARKStepSetAdaptivityFn()`. + Prior to version x.x.x, any nonzero value for *pq* would result in use of the + embedding order of accuracy. + .. deprecated:: x.x.x 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 adae5325f0..8f44f79ec7 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 @@ -1255,7 +1255,8 @@ the code, is provided in :numref:`ARKODE.Mathematics.Adaptivity`. parameters (1), or that they will be supplied in the *adapt_params* argument (0). * *pq* -- flag denoting whether to use the embedding order of - accuracy *p* (0) or the method order of accuracy *q* (1) + accuracy *p* (0), the method order of accuracy *q* (1), or the + minimum of the two (any input not equal to 0 or 1) within the adaptivity algorithm. *p* is the default. * *adapt_params[0]* -- :math:`k_1` parameter within accuracy-based adaptivity algorithms. * *adapt_params[1]* -- :math:`k_2` parameter within accuracy-based adaptivity algorithms. @@ -1272,6 +1273,8 @@ the code, is provided in :numref:`ARKODE.Mathematics.Adaptivity`. parameter values are desired, it is recommended to instead provide a custom function through a call to :c:func:`ERKStepSetAdaptivityFn()`. + Prior to version x.x.x, any nonzero value for *pq* would result in use of the + embedding order of accuracy. .. deprecated:: x.x.x From 5e099bf91e1744d5ffabc07fcc2f19da698cb96b Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Wed, 1 Nov 2023 11:20:47 -0500 Subject: [PATCH 36/58] Apply suggestions from code review Co-authored-by: David Gardner --- src/arkode/arkode.c | 1 + src/arkode/arkode_arkstep_io.c | 1 + src/arkode/arkode_erkstep_io.c | 1 + 3 files changed, 3 insertions(+) diff --git a/src/arkode/arkode.c b/src/arkode/arkode.c index 48b1cc995a..28f73d609b 100644 --- a/src/arkode/arkode.c +++ b/src/arkode/arkode.c @@ -1119,6 +1119,7 @@ void arkFree(void **arkode_mem) if (ark_mem->hadapt_mem != NULL) { if (ark_mem->hadapt_mem->owncontroller) { (void) SUNAdaptController_Destroy(ark_mem->hadapt_mem->hcontroller); + ark_mem->hadapt_mem->owncontroller = SUNFALSE; } free(ark_mem->hadapt_mem); ark_mem->hadapt_mem = NULL; diff --git a/src/arkode/arkode_arkstep_io.c b/src/arkode/arkode_arkstep_io.c index c36febb152..58a5b6ce01 100644 --- a/src/arkode/arkode_arkstep_io.c +++ b/src/arkode/arkode_arkstep_io.c @@ -502,6 +502,7 @@ int ARKStepSetOptimalParams(void *arkode_mem) } if (hadapt_mem->owncontroller) { retval = SUNAdaptController_Destroy(hadapt_mem->hcontroller); + ark_mem->hadapt_mem->owncontroller = SUNFALSE; if (retval != SUNADAPTCONTROLLER_SUCCESS) { arkProcessError(ark_mem, ARK_MEM_FAIL, "ARKODE", "ARKStepSetOptimalParams", "SUNAdaptController_Destroy failure"); diff --git a/src/arkode/arkode_erkstep_io.c b/src/arkode/arkode_erkstep_io.c index 23483a956c..6c1b71a851 100644 --- a/src/arkode/arkode_erkstep_io.c +++ b/src/arkode/arkode_erkstep_io.c @@ -294,6 +294,7 @@ int ERKStepSetDefaults(void* arkode_mem) } if (ark_mem->hadapt_mem->owncontroller) { retval = SUNAdaptController_Destroy(ark_mem->hadapt_mem->hcontroller); + ark_mem->hadapt_mem->owncontroller = SUNFALSE; if (retval != SUNADAPTCONTROLLER_SUCCESS) { arkProcessError(ark_mem, ARK_MEM_FAIL, "ARKODE", "ERKStepSetDefaults", "SUNAdaptController_Destroy failure"); From a97dec6deda545b658484b0889f87c5e00320498 Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Thu, 2 Nov 2023 09:16:05 -0500 Subject: [PATCH 37/58] Apply suggestions from code review Co-authored-by: David Gardner --- .../ARKStep_c_interface/User_callable.rst | 6 ++-- .../ERKStep_c_interface/User_callable.rst | 6 ++-- .../SUNAdaptController_Description.rst | 2 +- src/arkode/arkode_io.c | 12 +++---- .../imexgus/sunadaptcontroller_imexgus.c | 1 + .../soderlind/sunadaptcontroller_soderlind.c | 12 +++++++ src/sundials/sundials_adaptcontroller.c | 32 ++++++++++--------- 7 files changed, 45 insertions(+), 26 deletions(-) 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 a272cf299e..3cfa045300 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 @@ -1789,8 +1789,10 @@ Explicit stability function :c:func:`ARKStepSetS parameter values are desired, it is recommended to instead provide a custom function through a call to :c:func:`ARKStepSetAdaptivityFn()`. - Prior to version x.x.x, any nonzero value for *pq* would result in use of the - embedding order of accuracy. + .. versionchanged:: x.x.x + + Prior to version x.x.x, any nonzero value for *pq* would result in use of the + embedding order of accuracy. .. deprecated:: x.x.x 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 8f44f79ec7..d97e2b5a8b 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 @@ -1273,8 +1273,10 @@ the code, is provided in :numref:`ARKODE.Mathematics.Adaptivity`. parameter values are desired, it is recommended to instead provide a custom function through a call to :c:func:`ERKStepSetAdaptivityFn()`. - Prior to version x.x.x, any nonzero value for *pq* would result in use of the - embedding order of accuracy. + .. versionchanged:: x.x.x + + Prior to version x.x.x, any nonzero value for *pq* would result in use of the + embedding order of accuracy. .. deprecated:: x.x.x diff --git a/doc/shared/sunadaptcontroller/SUNAdaptController_Description.rst b/doc/shared/sunadaptcontroller/SUNAdaptController_Description.rst index da4b5a5eda..acea4a0790 100644 --- a/doc/shared/sunadaptcontroller/SUNAdaptController_Description.rst +++ b/doc/shared/sunadaptcontroller/SUNAdaptController_Description.rst @@ -160,7 +160,7 @@ note these requirements below. Additionally, we note the behavior of the base SU Estimates a single-rate step size. This routine is required for controllers of type ``SUN_ADAPTCONTROLLER_H``. If this is not provided by the - implementation, the class method will set ``*hnew = h`` and return. + implementation, the base class method will set ``*hnew = h`` and return. :param C: the :c:type:`SUNAdaptController` object. :param h: the step size from the previous step attempt. diff --git a/src/arkode/arkode_io.c b/src/arkode/arkode_io.c index 71f48dac91..1b6ab19ecd 100644 --- a/src/arkode/arkode_io.c +++ b/src/arkode/arkode_io.c @@ -1004,7 +1004,7 @@ int arkSetAdaptivityMethod(void *arkode_mem, int imethod, int idefault, if (idefault != 1) { retval = SUNAdaptController_SetParams_PID(C, k1, -k2, k3); if (retval != SUNADAPTCONTROLLER_SUCCESS) { - (void) SUNAdaptController_Destroy(C); + (void) SUNAdaptController_Destroy(C); arkProcessError(ark_mem, ARK_CONTROLLER_ERR, "ARKODE", "arkSetAdaptivityMethod", "SUNAdaptController_SetParams_PID failure"); return(ARK_CONTROLLER_ERR); @@ -1021,7 +1021,7 @@ int arkSetAdaptivityMethod(void *arkode_mem, int imethod, int idefault, if (idefault != 1) { retval = SUNAdaptController_SetParams_PI(C, k1, -k2); if (retval != SUNADAPTCONTROLLER_SUCCESS) { - (void) SUNAdaptController_Destroy(C); + (void) SUNAdaptController_Destroy(C); arkProcessError(ark_mem, ARK_CONTROLLER_ERR, "ARKODE", "arkSetAdaptivityMethod", "SUNAdaptController_SetParams_PI failure"); return(ARK_CONTROLLER_ERR); @@ -1038,7 +1038,7 @@ int arkSetAdaptivityMethod(void *arkode_mem, int imethod, int idefault, if (idefault != 1) { retval = SUNAdaptController_SetParams_I(C, k1); if (retval != SUNADAPTCONTROLLER_SUCCESS) { - (void) SUNAdaptController_Destroy(C); + (void) SUNAdaptController_Destroy(C); arkProcessError(ark_mem, ARK_CONTROLLER_ERR, "ARKODE", "arkSetAdaptivityMethod", "SUNAdaptController_SetParams_I failure"); return(ARK_CONTROLLER_ERR); @@ -1055,7 +1055,7 @@ int arkSetAdaptivityMethod(void *arkode_mem, int imethod, int idefault, if (idefault != 1) { retval = SUNAdaptController_SetParams_ExpGus(C, k1, k2); if (retval != SUNADAPTCONTROLLER_SUCCESS) { - (void) SUNAdaptController_Destroy(C); + (void) SUNAdaptController_Destroy(C); arkProcessError(ark_mem, ARK_CONTROLLER_ERR, "ARKODE", "arkSetAdaptivityMethod", "SUNAdaptController_SetParams_ExpGus failure"); return(ARK_CONTROLLER_ERR); @@ -1072,7 +1072,7 @@ int arkSetAdaptivityMethod(void *arkode_mem, int imethod, int idefault, if (idefault != 1) { retval = SUNAdaptController_SetParams_ImpGus(C, k1, k2); if (retval != SUNADAPTCONTROLLER_SUCCESS) { - (void) SUNAdaptController_Destroy(C); + (void) SUNAdaptController_Destroy(C); arkProcessError(ark_mem, ARK_CONTROLLER_ERR, "ARKODE", "arkSetAdaptivityMethod", "SUNAdaptController_SetParams_ImpGus failure"); return(ARK_CONTROLLER_ERR); @@ -1089,7 +1089,7 @@ int arkSetAdaptivityMethod(void *arkode_mem, int imethod, int idefault, if (idefault != 1) { retval = SUNAdaptController_SetParams_ImExGus(C, k1, k2, k3, k3); if (retval != SUNADAPTCONTROLLER_SUCCESS) { - (void) SUNAdaptController_Destroy(C); + (void) SUNAdaptController_Destroy(C); arkProcessError(ark_mem, ARK_CONTROLLER_ERR, "ARKODE", "arkSetAdaptivityMethod", "SUNAdaptController_SetParams_ImExGus failure"); return(ARK_CONTROLLER_ERR); diff --git a/src/sunadaptcontroller/imexgus/sunadaptcontroller_imexgus.c b/src/sunadaptcontroller/imexgus/sunadaptcontroller_imexgus.c index d8baea0ceb..67f9aacabe 100644 --- a/src/sunadaptcontroller/imexgus/sunadaptcontroller_imexgus.c +++ b/src/sunadaptcontroller/imexgus/sunadaptcontroller_imexgus.c @@ -102,6 +102,7 @@ int SUNAdaptController_SetParams_ImExGus(SUNAdaptController C, sunrealtype k1e, sunrealtype k2e, sunrealtype k1i, sunrealtype k2i) { + if (C == NULL) { return SUNADAPTCONTROLLER_ILL_INPUT; } SACIMEXGUS_K1E(C) = k1e; SACIMEXGUS_K2E(C) = k2e; SACIMEXGUS_K1I(C) = k1i; diff --git a/src/sunadaptcontroller/soderlind/sunadaptcontroller_soderlind.c b/src/sunadaptcontroller/soderlind/sunadaptcontroller_soderlind.c index 314a2e2cd8..dca8dec159 100644 --- a/src/sunadaptcontroller/soderlind/sunadaptcontroller_soderlind.c +++ b/src/sunadaptcontroller/soderlind/sunadaptcontroller_soderlind.c @@ -117,6 +117,7 @@ int SUNAdaptController_SetParams_Soderlind(SUNAdaptController C, sunrealtype k3, sunrealtype k4, sunrealtype k5) { + if (C == NULL) { return SUNADAPTCONTROLLER_ILL_INPUT; } SODERLIND_K1(C) = k1; SODERLIND_K2(C) = k2; SODERLIND_K3(C) = k3; @@ -133,6 +134,7 @@ SUNAdaptController SUNAdaptController_PID(SUNContext sunctx) { SUNAdaptController C; C = SUNAdaptController_Soderlind(sunctx); + if (C == NULL) { return NULL; } (void) SUNAdaptController_SetParams_PID(C, DEFAULT_PID_K1, DEFAULT_PID_K2, @@ -148,6 +150,7 @@ int SUNAdaptController_SetParams_PID(SUNAdaptController C, sunrealtype k1, sunrealtype k2, sunrealtype k3) { + if (C == NULL) { return SUNADAPTCONTROLLER_ILL_INPUT; } SODERLIND_K1(C) = k1; SODERLIND_K2(C) = k2; SODERLIND_K3(C) = k3; @@ -164,6 +167,7 @@ SUNAdaptController SUNAdaptController_PI(SUNContext sunctx) { SUNAdaptController C; C = SUNAdaptController_Soderlind(sunctx); + if (C == NULL) { return NULL; } (void) SUNAdaptController_SetParams_PI(C, DEFAULT_PI_K1, DEFAULT_PI_K2); @@ -177,6 +181,7 @@ SUNAdaptController SUNAdaptController_PI(SUNContext sunctx) int SUNAdaptController_SetParams_PI(SUNAdaptController C, sunrealtype k1, sunrealtype k2) { + if (C == NULL) { return SUNADAPTCONTROLLER_ILL_INPUT; } SODERLIND_K1(C) = k1; SODERLIND_K2(C) = k2; SODERLIND_K3(C) = RCONST(0.0); @@ -193,6 +198,7 @@ SUNAdaptController SUNAdaptController_I(SUNContext sunctx) { SUNAdaptController C; C = SUNAdaptController_Soderlind(sunctx); + if (C == NULL) { return NULL; } (void) SUNAdaptController_SetParams_I(C, DEFAULT_I_K1); return (C); } @@ -203,6 +209,7 @@ SUNAdaptController SUNAdaptController_I(SUNContext sunctx) int SUNAdaptController_SetParams_I(SUNAdaptController C, sunrealtype k1) { + if (C == NULL) { return SUNADAPTCONTROLLER_ILL_INPUT; } SODERLIND_K1(C) = k1; SODERLIND_K2(C) = RCONST(0.0); SODERLIND_K3(C) = RCONST(0.0); @@ -219,6 +226,7 @@ SUNAdaptController SUNAdaptController_ExpGus(SUNContext sunctx) { SUNAdaptController C; C = SUNAdaptController_Soderlind(sunctx); + if (C == NULL) { return NULL; } (void) SUNAdaptController_SetParams_ExpGus(C, DEFAULT_EXPGUS_K1, DEFAULT_EXPGUS_K2); @@ -232,6 +240,7 @@ SUNAdaptController SUNAdaptController_ExpGus(SUNContext sunctx) int SUNAdaptController_SetParams_ExpGus(SUNAdaptController C, sunrealtype k1, sunrealtype k2) { + if (C == NULL) { return SUNADAPTCONTROLLER_ILL_INPUT; } SODERLIND_K1(C) = k1+k2; SODERLIND_K2(C) = -k2; SODERLIND_K3(C) = RCONST(0.0); @@ -248,6 +257,7 @@ SUNAdaptController SUNAdaptController_ImpGus(SUNContext sunctx) { SUNAdaptController C; C = SUNAdaptController_Soderlind(sunctx); + if (C == NULL) { return NULL; } (void) SUNAdaptController_SetParams_ImpGus(C, DEFAULT_IMPGUS_K1, DEFAULT_IMPGUS_K2); @@ -261,6 +271,7 @@ SUNAdaptController SUNAdaptController_ImpGus(SUNContext sunctx) int SUNAdaptController_SetParams_ImpGus(SUNAdaptController C, sunrealtype k1, sunrealtype k2) { + if (C == NULL) { return SUNADAPTCONTROLLER_ILL_INPUT; } SODERLIND_K1(C) = k1+k2; SODERLIND_K2(C) = -k2; SODERLIND_K3(C) = RCONST(0.0); @@ -322,6 +333,7 @@ int SUNAdaptController_Reset_Soderlind(SUNAdaptController C) int SUNAdaptController_SetDefaults_Soderlind(SUNAdaptController C) { + if (C == NULL) { return SUNADAPTCONTROLLER_ILL_INPUT; } SODERLIND_K1(C) = DEFAULT_K1; SODERLIND_K2(C) = DEFAULT_K2; SODERLIND_K3(C) = DEFAULT_K3; diff --git a/src/sundials/sundials_adaptcontroller.c b/src/sundials/sundials_adaptcontroller.c index 1e0357064a..e39a02afec 100644 --- a/src/sundials/sundials_adaptcontroller.c +++ b/src/sundials/sundials_adaptcontroller.c @@ -64,7 +64,7 @@ SUNAdaptController SUNAdaptController_NewEmpty(SUNContext sunctx) * Free a generic SUNAdaptController (assumes content is already empty) * ----------------------------------------------------------------- */ -void SUNAdaptController_FreeEmpty(SUNAdaptController C) +void SUNAdaptController_DestroyEmpty(SUNAdaptController C) { if (C == NULL) return; @@ -85,7 +85,8 @@ void SUNAdaptController_FreeEmpty(SUNAdaptController C) SUNAdaptController_Type SUNAdaptController_GetType(SUNAdaptController C) { if (C == NULL) { return SUN_ADAPTCONTROLLER_NONE; } - return(C->ops->gettype(C)); + if (C->ops->gettype) { return C->ops->gettype(C); } + return SUN_ADAPTCONTROLLER_NONE; } /* ----------------------------------------------------------------- @@ -112,9 +113,9 @@ int SUNAdaptController_Destroy(SUNAdaptController C) int SUNAdaptController_EstimateStep(SUNAdaptController C, sunrealtype h, int p, sunrealtype dsm, sunrealtype* hnew) { - int ier = 0; + int ier = SUNADAPTCONTROLLER_SUCCESS; *hnew = h; /* initialize output with identity */ - if (C == NULL) { return ier; } + if (C == NULL || hnew == NULL) { return SUNADAPTCONTROLLER_ILL_INPUT; } if (C->ops->estimatestep) { ier = C->ops->estimatestep(C, h, p, dsm, hnew); @@ -125,49 +126,50 @@ int SUNAdaptController_EstimateStep(SUNAdaptController C, sunrealtype h, int p, int SUNAdaptController_Reset(SUNAdaptController C) { - int ier = 0; - if (C == NULL) { return ier; } + int ier = SUNADAPTCONTROLLER_SUCCESS; + if (C == NULL) { return SUNADAPTCONTROLLER_ILL_INPUT; } if (C->ops->reset) { ier = C->ops->reset(C); } return(ier); } int SUNAdaptController_SetDefaults(SUNAdaptController C) { - int ier = 0; + int ier = SUNADAPTCONTROLLER_SUCCESS; + if (C == NULL) { return SUNADAPTCONTROLLER_ILL_INPUT; } if (C->ops->setdefaults) { ier = C->ops->setdefaults(C); } return(ier); } int SUNAdaptController_Write(SUNAdaptController C, FILE* fptr) { - int ier = 0; - if (C == NULL) { return ier; } + int ier = SUNADAPTCONTROLLER_SUCCESS; + if (C == NULL || fptr == NULL) { return SUNADAPTCONTROLLER_ILL_INPUT; } if (C->ops->write) { ier = C->ops->write(C, fptr); } return(ier); } int SUNAdaptController_SetErrorBias(SUNAdaptController C, sunrealtype bias) { - int ier = 0; - if (C == NULL) { return ier; } + int ier = SUNADAPTCONTROLLER_SUCCESS; + if (C == NULL) { return SUNADAPTCONTROLLER_ILL_INPUT; } if (C->ops->seterrorbias) { ier = C->ops->seterrorbias(C, bias); } return(ier); } int SUNAdaptController_UpdateH(SUNAdaptController C, sunrealtype h, sunrealtype dsm) { - int ier = 0; - if (C == NULL) { return ier; } + int ier = SUNADAPTCONTROLLER_SUCCESS; + if (C == NULL) { return SUNADAPTCONTROLLER_ILL_INPUT; } if (C->ops->updateh) { ier = C->ops->updateh(C, h, dsm); } return(ier); } int SUNAdaptController_Space(SUNAdaptController C, long int *lenrw, long int *leniw) { - int ier = 0; + int ier = SUNADAPTCONTROLLER_SUCCESS; + if (C == NULL || lenrw == NULL || leniw == NULL) { return SUNADAPTCONTROLLER_ILL_INPUT; } *lenrw = 0; /* initialize outputs with identity */ *leniw = 0; - if (C == NULL) { return ier; } if (C->ops->space) { ier = C->ops->space(C, lenrw, leniw); } return(ier); } From 9d6fc7c245bd456acf13697ff8a17485b2a59bbb Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Thu, 2 Nov 2023 10:24:50 -0500 Subject: [PATCH 38/58] Apply suggestions from code review Co-authored-by: David Gardner --- .../imexgus/sunadaptcontroller_imexgus.c | 8 ++++++++ .../noop/sunadaptcontroller_noop.c | 6 +++++- .../soderlind/sunadaptcontroller_soderlind.c | 13 +++++++++++++ 3 files changed, 26 insertions(+), 1 deletion(-) diff --git a/src/sunadaptcontroller/imexgus/sunadaptcontroller_imexgus.c b/src/sunadaptcontroller/imexgus/sunadaptcontroller_imexgus.c index 67f9aacabe..e949df24d2 100644 --- a/src/sunadaptcontroller/imexgus/sunadaptcontroller_imexgus.c +++ b/src/sunadaptcontroller/imexgus/sunadaptcontroller_imexgus.c @@ -60,6 +60,8 @@ SUNAdaptController SUNAdaptController_ImExGus(SUNContext sunctx) SUNAdaptController C; SUNAdaptControllerContent_ImExGus content; + if (sunctx == NULL) { return NULL; } + /* Create an empty controller object */ C = NULL; C = SUNAdaptController_NewEmpty(sunctx); @@ -122,6 +124,7 @@ SUNAdaptController_Type SUNAdaptController_GetType_ImExGus(SUNAdaptController C) int SUNAdaptController_EstimateStep_ImExGus(SUNAdaptController C, sunrealtype h, int p, sunrealtype dsm, sunrealtype* hnew) { + if (C == NULL || hnew == NULL) { return SUNADAPTCONTROLLER_ILL_INPUT; } /* order parameter to use */ const int ord = p + 1; @@ -164,6 +167,7 @@ int SUNAdaptController_Reset_ImExGus(SUNAdaptController C) int SUNAdaptController_SetDefaults_ImExGus(SUNAdaptController C) { + if (C == NULL) { return SUNADAPTCONTROLLER_ILL_INPUT; } SACIMEXGUS_K1E(C) = DEFAULT_K1E; SACIMEXGUS_K2E(C) = DEFAULT_K2E; SACIMEXGUS_K1I(C) = DEFAULT_K1I; @@ -174,6 +178,7 @@ int SUNAdaptController_SetDefaults_ImExGus(SUNAdaptController C) int SUNAdaptController_Write_ImExGus(SUNAdaptController C, FILE *fptr) { + if (C == NULL || fptr == NULL) { return SUNADAPTCONTROLLER_ILL_INPUT; } fprintf(fptr, "ImEx Gustafsson SUNAdaptController module:\n"); #if defined(SUNDIALS_EXTENDED_PRECISION) fprintf(fptr, " k1e = %32Lg\n", SACIMEXGUS_K1E(C)); @@ -197,6 +202,7 @@ int SUNAdaptController_Write_ImExGus(SUNAdaptController C, FILE *fptr) int SUNAdaptController_SetErrorBias_ImExGus(SUNAdaptController C, sunrealtype bias) { + if (C == NULL) { return SUNADAPTCONTROLLER_ILL_INPUT; } /* set allowed value, otherwise set default */ if (bias <= RCONST(0.0)) { SACIMEXGUS_BIAS(C) = DEFAULT_BIAS; @@ -209,6 +215,7 @@ int SUNAdaptController_SetErrorBias_ImExGus(SUNAdaptController C, sunrealtype bi int SUNAdaptController_UpdateH_ImExGus(SUNAdaptController C, sunrealtype h, sunrealtype dsm) { + if (C == NULL) { return SUNADAPTCONTROLLER_ILL_INPUT; } SACIMEXGUS_EP(C) = SACIMEXGUS_BIAS(C) * dsm; SACIMEXGUS_HP(C) = h; SACIMEXGUS_FIRSTSTEP(C) = SUNFALSE; @@ -217,6 +224,7 @@ int SUNAdaptController_UpdateH_ImExGus(SUNAdaptController C, sunrealtype h, sunr int SUNAdaptController_Space_ImExGus(SUNAdaptController C, long int* lenrw, long int* leniw) { + if (C == NULL || lenrw == NULL || leniw == NULL) { return SUNADAPTCONTROLLER_ILL_INPUT; } *lenrw = 7; *leniw = 1; return SUNADAPTCONTROLLER_SUCCESS; diff --git a/src/sunadaptcontroller/noop/sunadaptcontroller_noop.c b/src/sunadaptcontroller/noop/sunadaptcontroller_noop.c index 88aea62181..6bef3313e3 100644 --- a/src/sunadaptcontroller/noop/sunadaptcontroller_noop.c +++ b/src/sunadaptcontroller/noop/sunadaptcontroller_noop.c @@ -31,8 +31,12 @@ SUNAdaptController SUNAdaptController_NoOp(SUNContext sunctx) { + SUNAdaptController C; + + if (sunctx == NULL) { return NULL; } + /* Create an empty controller object */ - SUNAdaptController C = NULL; + C = NULL; C = SUNAdaptController_NewEmpty(sunctx); if (C == NULL) { return (NULL); } diff --git a/src/sunadaptcontroller/soderlind/sunadaptcontroller_soderlind.c b/src/sunadaptcontroller/soderlind/sunadaptcontroller_soderlind.c index dca8dec159..02af5994a9 100644 --- a/src/sunadaptcontroller/soderlind/sunadaptcontroller_soderlind.c +++ b/src/sunadaptcontroller/soderlind/sunadaptcontroller_soderlind.c @@ -74,6 +74,8 @@ SUNAdaptController SUNAdaptController_Soderlind(SUNContext sunctx) SUNAdaptController C; SUNAdaptControllerContent_Soderlind content; + if (sunctx == NULL) { return NULL; } + /* Create an empty controller object */ C = NULL; C = SUNAdaptController_NewEmpty(sunctx); @@ -133,6 +135,7 @@ int SUNAdaptController_SetParams_Soderlind(SUNAdaptController C, SUNAdaptController SUNAdaptController_PID(SUNContext sunctx) { SUNAdaptController C; + if (sunctx == NULL) { return NULL; } C = SUNAdaptController_Soderlind(sunctx); if (C == NULL) { return NULL; } (void) SUNAdaptController_SetParams_PID(C, @@ -166,6 +169,7 @@ int SUNAdaptController_SetParams_PID(SUNAdaptController C, SUNAdaptController SUNAdaptController_PI(SUNContext sunctx) { SUNAdaptController C; + if (sunctx == NULL) { return NULL; } C = SUNAdaptController_Soderlind(sunctx); if (C == NULL) { return NULL; } (void) SUNAdaptController_SetParams_PI(C, @@ -197,6 +201,7 @@ int SUNAdaptController_SetParams_PI(SUNAdaptController C, SUNAdaptController SUNAdaptController_I(SUNContext sunctx) { SUNAdaptController C; + if (sunctx == NULL) { return NULL; } C = SUNAdaptController_Soderlind(sunctx); if (C == NULL) { return NULL; } (void) SUNAdaptController_SetParams_I(C, DEFAULT_I_K1); @@ -225,6 +230,7 @@ int SUNAdaptController_SetParams_I(SUNAdaptController C, sunrealtype k1) SUNAdaptController SUNAdaptController_ExpGus(SUNContext sunctx) { SUNAdaptController C; + if (sunctx == NULL) { return NULL; } C = SUNAdaptController_Soderlind(sunctx); if (C == NULL) { return NULL; } (void) SUNAdaptController_SetParams_ExpGus(C, @@ -256,6 +262,7 @@ int SUNAdaptController_SetParams_ExpGus(SUNAdaptController C, SUNAdaptController SUNAdaptController_ImpGus(SUNContext sunctx) { SUNAdaptController C; + if (sunctx == NULL) { return NULL; } C = SUNAdaptController_Soderlind(sunctx); if (C == NULL) { return NULL; } (void) SUNAdaptController_SetParams_ImpGus(C, @@ -292,6 +299,7 @@ SUNAdaptController_Type SUNAdaptController_GetType_Soderlind(SUNAdaptController int SUNAdaptController_EstimateStep_Soderlind(SUNAdaptController C, sunrealtype h, int p, sunrealtype dsm, sunrealtype* hnew) { + if (C == NULL || hnew == NULL) { return SUNADAPTCONTROLLER_ILL_INPUT; } /* order parameter to use */ const int ord = p + 1; @@ -323,6 +331,7 @@ int SUNAdaptController_EstimateStep_Soderlind(SUNAdaptController C, sunrealtype int SUNAdaptController_Reset_Soderlind(SUNAdaptController C) { + if (C == NULL) { return SUNADAPTCONTROLLER_ILL_INPUT; } SODERLIND_EP(C) = RCONST(1.0); SODERLIND_EPP(C) = RCONST(1.0); SODERLIND_HP(C) = RCONST(1.0); @@ -345,6 +354,7 @@ int SUNAdaptController_SetDefaults_Soderlind(SUNAdaptController C) int SUNAdaptController_Write_Soderlind(SUNAdaptController C, FILE *fptr) { + if (C == NULL || fptr == NULL) { return SUNADAPTCONTROLLER_ILL_INPUT; } fprintf(fptr, "Soderlind SUNAdaptController module:\n"); #if defined(SUNDIALS_EXTENDED_PRECISION) fprintf(fptr, " k1 = %32Lg\n", SODERLIND_K1(C)); @@ -375,6 +385,7 @@ int SUNAdaptController_Write_Soderlind(SUNAdaptController C, FILE *fptr) int SUNAdaptController_SetErrorBias_Soderlind(SUNAdaptController C, sunrealtype bias) { + if (C == NULL) { return SUNADAPTCONTROLLER_ILL_INPUT; } /* set allowed value, otherwise set default */ if (bias <= RCONST(0.0)) { SODERLIND_BIAS(C) = DEFAULT_BIAS; @@ -387,6 +398,7 @@ int SUNAdaptController_SetErrorBias_Soderlind(SUNAdaptController C, sunrealtype int SUNAdaptController_UpdateH_Soderlind(SUNAdaptController C, sunrealtype h, sunrealtype dsm) { + if (C == NULL) { return SUNADAPTCONTROLLER_ILL_INPUT; } SODERLIND_EPP(C) = SODERLIND_EP(C); SODERLIND_EP(C) = SODERLIND_BIAS(C) * dsm; SODERLIND_HPP(C) = SODERLIND_HP(C); @@ -399,6 +411,7 @@ int SUNAdaptController_UpdateH_Soderlind(SUNAdaptController C, sunrealtype h, su int SUNAdaptController_Space_Soderlind(SUNAdaptController C, long int* lenrw, long int* leniw) { + if (C == NULL || lenrw == NULL || leniw == NULL) { return SUNADAPTCONTROLLER_ILL_INPUT; } *lenrw = 10; *leniw = 1; return SUNADAPTCONTROLLER_SUCCESS; From 752e3a9ca9544c904a7b68578e61163d0e0e16f6 Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Thu, 2 Nov 2023 10:28:22 -0500 Subject: [PATCH 39/58] Incorporated changes from PR review --- .../soderlind/sunadaptcontroller_soderlind.c | 53 ++++++++++++++----- 1 file changed, 39 insertions(+), 14 deletions(-) diff --git a/src/sunadaptcontroller/soderlind/sunadaptcontroller_soderlind.c b/src/sunadaptcontroller/soderlind/sunadaptcontroller_soderlind.c index 02af5994a9..ef3bd57527 100644 --- a/src/sunadaptcontroller/soderlind/sunadaptcontroller_soderlind.c +++ b/src/sunadaptcontroller/soderlind/sunadaptcontroller_soderlind.c @@ -135,13 +135,18 @@ int SUNAdaptController_SetParams_Soderlind(SUNAdaptController C, SUNAdaptController SUNAdaptController_PID(SUNContext sunctx) { SUNAdaptController C; + int retval; if (sunctx == NULL) { return NULL; } C = SUNAdaptController_Soderlind(sunctx); if (C == NULL) { return NULL; } - (void) SUNAdaptController_SetParams_PID(C, - DEFAULT_PID_K1, - DEFAULT_PID_K2, - DEFAULT_PID_K3); + retval = SUNAdaptController_SetParams_PID(C, + DEFAULT_PID_K1, + DEFAULT_PID_K2, + DEFAULT_PID_K3); + if (retval != SUNADAPTCONTROLLER_SUCCESS) { + (void) SUNAdaptController_Destroy(C); + C = NULL; + } return (C); } @@ -169,12 +174,17 @@ int SUNAdaptController_SetParams_PID(SUNAdaptController C, SUNAdaptController SUNAdaptController_PI(SUNContext sunctx) { SUNAdaptController C; + int retval; if (sunctx == NULL) { return NULL; } C = SUNAdaptController_Soderlind(sunctx); if (C == NULL) { return NULL; } - (void) SUNAdaptController_SetParams_PI(C, - DEFAULT_PI_K1, - DEFAULT_PI_K2); + retval = SUNAdaptController_SetParams_PI(C, + DEFAULT_PI_K1, + DEFAULT_PI_K2); + if (retval != SUNADAPTCONTROLLER_SUCCESS) { + (void) SUNAdaptController_Destroy(C); + C = NULL; + } return (C); } @@ -201,10 +211,15 @@ int SUNAdaptController_SetParams_PI(SUNAdaptController C, SUNAdaptController SUNAdaptController_I(SUNContext sunctx) { SUNAdaptController C; + int retval; if (sunctx == NULL) { return NULL; } C = SUNAdaptController_Soderlind(sunctx); if (C == NULL) { return NULL; } - (void) SUNAdaptController_SetParams_I(C, DEFAULT_I_K1); + retval = SUNAdaptController_SetParams_I(C, DEFAULT_I_K1); + if (retval != SUNADAPTCONTROLLER_SUCCESS) { + (void) SUNAdaptController_Destroy(C); + C = NULL; + } return (C); } @@ -230,12 +245,17 @@ int SUNAdaptController_SetParams_I(SUNAdaptController C, sunrealtype k1) SUNAdaptController SUNAdaptController_ExpGus(SUNContext sunctx) { SUNAdaptController C; + int retval; if (sunctx == NULL) { return NULL; } C = SUNAdaptController_Soderlind(sunctx); if (C == NULL) { return NULL; } - (void) SUNAdaptController_SetParams_ExpGus(C, - DEFAULT_EXPGUS_K1, - DEFAULT_EXPGUS_K2); + retval = SUNAdaptController_SetParams_ExpGus(C, + DEFAULT_EXPGUS_K1, + DEFAULT_EXPGUS_K2); + if (retval != SUNADAPTCONTROLLER_SUCCESS) { + (void) SUNAdaptController_Destroy(C); + C = NULL; + } return (C); } @@ -262,12 +282,17 @@ int SUNAdaptController_SetParams_ExpGus(SUNAdaptController C, SUNAdaptController SUNAdaptController_ImpGus(SUNContext sunctx) { SUNAdaptController C; + int retval; if (sunctx == NULL) { return NULL; } C = SUNAdaptController_Soderlind(sunctx); if (C == NULL) { return NULL; } - (void) SUNAdaptController_SetParams_ImpGus(C, - DEFAULT_IMPGUS_K1, - DEFAULT_IMPGUS_K2); + retval = SUNAdaptController_SetParams_ImpGus(C, + DEFAULT_IMPGUS_K1, + DEFAULT_IMPGUS_K2); + if (retval != SUNADAPTCONTROLLER_SUCCESS) { + (void) SUNAdaptController_Destroy(C); + C = NULL; + } return (C); } From 27515207d1960c6ffaf0ab075c1964635f8bdb5f Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Thu, 2 Nov 2023 11:15:26 -0500 Subject: [PATCH 40/58] Fixed ARKODE unit test builds --- test/unit_tests/arkode/CXX_serial/CMakeLists.txt | 5 ++++- test/unit_tests/arkode/C_serial/CMakeLists.txt | 3 +++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/test/unit_tests/arkode/CXX_serial/CMakeLists.txt b/test/unit_tests/arkode/CXX_serial/CMakeLists.txt index b0ea386c44..d92ef87659 100644 --- a/test/unit_tests/arkode/CXX_serial/CMakeLists.txt +++ b/test/unit_tests/arkode/CXX_serial/CMakeLists.txt @@ -52,7 +52,7 @@ foreach(test_tuple ${unit_tests}) # We explicitly choose which object libraries to link to and link in the # arkode objects so that we have access to private functions w/o changing - # their visibility in the installed libraries. + # their visibility in the installed libraries. target_link_libraries(${test_target} $ sundials_sunmemsys_obj @@ -61,6 +61,9 @@ foreach(test_tuple ${unit_tests}) sundials_sunlinsoldense_obj sundials_sunnonlinsolnewton_obj sundials_sunnonlinsolfixedpoint_obj + sundials_sunadaptcontrollerimexgus_obj + sundials_sunadaptcontrollernoop_obj + sundials_sunadaptcontrollersoderlind_obj ${EXE_EXTRA_LINK_LIBS}) # Tell CMake that we depend on the ARKODE library since it does not pick diff --git a/test/unit_tests/arkode/C_serial/CMakeLists.txt b/test/unit_tests/arkode/C_serial/CMakeLists.txt index bddff54d88..2330175dc8 100644 --- a/test/unit_tests/arkode/C_serial/CMakeLists.txt +++ b/test/unit_tests/arkode/C_serial/CMakeLists.txt @@ -65,6 +65,9 @@ foreach(test_tuple ${ARKODE_unit_tests}) sundials_sunlinsolband_obj sundials_sunlinsoldense_obj sundials_sunnonlinsolnewton_obj + sundials_sunadaptcontrollerimexgus_obj + sundials_sunadaptcontrollernoop_obj + sundials_sunadaptcontrollersoderlind_obj ${EXE_EXTRA_LINK_LIBS}) # Tell CMake that we depend on the ARKODE library since it does not pick From da3fda8cd494e62f4d3a6adad16f44b3469d9b96 Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Thu, 2 Nov 2023 12:40:56 -0500 Subject: [PATCH 41/58] Replaced extended-precision answer test files --- test/answers | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/answers b/test/answers index f203cac4b8..91c2fa9692 160000 --- a/test/answers +++ b/test/answers @@ -1 +1 @@ -Subproject commit f203cac4b82b9c9ea57aa2d98278e074e3ff28cb +Subproject commit 91c2fa96929cd016e8428ec5025f1a6eb8d9483f From 6c2787d135208c8e710084d32b612cd998d62dc2 Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Thu, 2 Nov 2023 12:46:03 -0500 Subject: [PATCH 42/58] Updated answers repository commit --- test/answers | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/answers b/test/answers index 91c2fa9692..8410ac981d 160000 --- a/test/answers +++ b/test/answers @@ -1 +1 @@ -Subproject commit 91c2fa96929cd016e8428ec5025f1a6eb8d9483f +Subproject commit 8410ac981d29c02494b977def00b100b966bebc1 From 1af95a9259c964fd518ae9ace1caed763d0515fb Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Thu, 2 Nov 2023 15:45:13 -0500 Subject: [PATCH 43/58] removed NoOp SUNAdaptController --- .../sunadaptcontroller_noop.h | 44 ---- scripts/shared | 9 - src/arkode/CMakeLists.txt | 1 - src/arkode/arkode_io.c | 47 ---- src/sunadaptcontroller/CMakeLists.txt | 1 - src/sunadaptcontroller/noop/CMakeLists.txt | 29 --- .../noop/fmod/CMakeLists.txt | 25 -- .../noop/fmod/fsunadaptcontroller_noop_mod.c | 235 ------------------ .../fmod/fsunadaptcontroller_noop_mod.f90 | 83 ------- .../noop/sunadaptcontroller_noop.c | 56 ----- src/sundials/fmod/fsundials_profiler_mod.c | 30 +++ src/sundials/fmod/fsundials_profiler_mod.f90 | 58 +++++ swig/Makefile | 2 +- .../fsunadaptcontroller_noop_mod.i | 29 --- .../arkode/CXX_serial/CMakeLists.txt | 1 - .../unit_tests/arkode/C_serial/CMakeLists.txt | 1 - 16 files changed, 89 insertions(+), 562 deletions(-) delete mode 100644 include/sunadaptcontroller/sunadaptcontroller_noop.h delete mode 100644 src/sunadaptcontroller/noop/CMakeLists.txt delete mode 100644 src/sunadaptcontroller/noop/fmod/CMakeLists.txt delete mode 100644 src/sunadaptcontroller/noop/fmod/fsunadaptcontroller_noop_mod.c delete mode 100644 src/sunadaptcontroller/noop/fmod/fsunadaptcontroller_noop_mod.f90 delete mode 100644 src/sunadaptcontroller/noop/sunadaptcontroller_noop.c delete mode 100644 swig/sunadaptcontroller/fsunadaptcontroller_noop_mod.i diff --git a/include/sunadaptcontroller/sunadaptcontroller_noop.h b/include/sunadaptcontroller/sunadaptcontroller_noop.h deleted file mode 100644 index 8dd61cce74..0000000000 --- a/include/sunadaptcontroller/sunadaptcontroller_noop.h +++ /dev/null @@ -1,44 +0,0 @@ -/* ----------------------------------------------------------------- - * Programmer(s): Daniel R. Reynolds @ SMU - * ----------------------------------------------------------------- - * SUNDIALS Copyright Start - * Copyright (c) 2002-2023, Lawrence Livermore National Security - * and Southern Methodist University. - * All rights reserved. - * - * See the top-level LICENSE and NOTICE files for details. - * - * SPDX-License-Identifier: BSD-3-Clause - * SUNDIALS Copyright End - * ----------------------------------------------------------------- - * This is the header file for the SUNAdaptController_NOOP module. - * -----------------------------------------------------------------*/ - -#ifndef _SUNADAPTCONTROLLER_NOOP_H -#define _SUNADAPTCONTROLLER_NOOP_H - -#include -#include - -#ifdef __cplusplus /* wrapper to enable C++ usage */ -extern "C" { -#endif - -/* ------------------------------------------ - * No-op implementation of SUNAdaptController - * ------------------------------------------ */ - -/* ------------------ - * Exported Functions - * ------------------ */ - -SUNDIALS_EXPORT -SUNAdaptController SUNAdaptController_NoOp(SUNContext sunctx); -SUNDIALS_EXPORT -SUNAdaptController_Type SUNAdaptController_GetType_NoOp(SUNAdaptController C); - -#ifdef __cplusplus -} -#endif - -#endif /* _SUNADAPTCONTROLLER_PID_H */ diff --git a/scripts/shared b/scripts/shared index a45cfee462..a8815a2b3e 100755 --- a/scripts/shared +++ b/scripts/shared @@ -179,7 +179,6 @@ $tar $tarfile $distrobase/include/nvector/trilinos/SundialsTpetraVectorInterface $tar $tarfile $distrobase/include/nvector/trilinos/SundialsTpetraVectorKernels.hpp $tar $tarfile $distrobase/include/sunadaptcontroller/sunadaptcontroller_imexgus.h -$tar $tarfile $distrobase/include/sunadaptcontroller/sunadaptcontroller_noop.h $tar $tarfile $distrobase/include/sunadaptcontroller/sunadaptcontroller_soderlind.h $tar $tarfile $distrobase/include/sunmatrix/sunmatrix_band.h @@ -394,14 +393,6 @@ $tar $tarfile $distrobase/src/sunadaptcontroller/imexgus/fmod/CMakeLists.txt $tar $tarfile $distrobase/src/sunadaptcontroller/imexgus/fmod/fsunadaptcontroller_imexgus_mod.c $tar $tarfile $distrobase/src/sunadaptcontroller/imexgus/fmod/fsunadaptcontroller_imexgus_mod.f90 -echo " --- Add sunadaptcontroller/noop module to $tarfile" - -$tar $tarfile $distrobase/src/sunadaptcontroller/noop/CMakeLists.txt -$tar $tarfile $distrobase/src/sunadaptcontroller/noop/sunadaptcontroller_noop.c -$tar $tarfile $distrobase/src/sunadaptcontroller/noop/fmod/CMakeLists.txt -$tar $tarfile $distrobase/src/sunadaptcontroller/noop/fmod/fsunadaptcontroller_noop_mod.c -$tar $tarfile $distrobase/src/sunadaptcontroller/noop/fmod/fsunadaptcontroller_noop_mod.f90 - echo " --- Add sunadaptcontroller/soderlind module to $tarfile" $tar $tarfile $distrobase/src/sunadaptcontroller/soderlind/CMakeLists.txt diff --git a/src/arkode/CMakeLists.txt b/src/arkode/CMakeLists.txt index c516eabdd2..7b50ba325f 100644 --- a/src/arkode/CMakeLists.txt +++ b/src/arkode/CMakeLists.txt @@ -77,7 +77,6 @@ sundials_add_library(sundials_arkode sundials_sunmemsys_obj sundials_nvecserial_obj sundials_sunadaptcontrollerimexgus_obj - sundials_sunadaptcontrollernoop_obj sundials_sunadaptcontrollersoderlind_obj sundials_sunmatrixband_obj sundials_sunmatrixdense_obj diff --git a/src/arkode/arkode_io.c b/src/arkode/arkode_io.c index 1b6ab19ecd..979b9e90d4 100644 --- a/src/arkode/arkode_io.c +++ b/src/arkode/arkode_io.c @@ -28,7 +28,6 @@ #include #include #include -#include /*=============================================================== @@ -650,52 +649,6 @@ int arkSetFixedStep(void *arkode_mem, realtype hfixed) } 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 == SUNADAPTCONTROLLER_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 != SUNADAPTCONTROLLER_SUCCESS) { - arkProcessError(ark_mem, ARK_MEM_FAIL, "ARKODE", "arkSetFixedStep", - "SUNAdaptController_Destroy failure"); - return(ARK_MEM_FAIL); - } - } - ark_mem->hadapt_mem->hcontroller = NULL; - - /* If re-enabling time adaptivity, create default PID controller - and attach object to ARKODE. - Otherwise, create No-op controller and attach to ARKODE. */ - C = NULL; - if (hfixed == ZERO) - { - C = SUNAdaptController_PID(ark_mem->sunctx); - if (C == NULL) { - arkProcessError(ark_mem, ARK_MEM_FAIL, "ARKODE", "arkSetFixedStep", - "SUNAdaptController_PID allocation failure"); - return(ARK_MEM_FAIL); - } - } else { - C = SUNAdaptController_NoOp(ark_mem->sunctx); - if (C == NULL) { - arkProcessError(ark_mem, ARK_MEM_FAIL, "ARKODE", "arkSetFixedStep", - "SUNAdaptController_NoOp allocation failure"); - return(ARK_MEM_FAIL); - } - } - retval = SUNAdaptController_Space(C, &lenrw, &leniw); - if (retval == SUNADAPTCONTROLLER_SUCCESS) { - ark_mem->liw += leniw; - ark_mem->lrw += lenrw; - } - ark_mem->hadapt_mem->hcontroller = C; - ark_mem->hadapt_mem->owncontroller = SUNTRUE; - /* re-attach internal error weight functions if necessary */ if ((hfixed == ZERO) && (!ark_mem->user_efun)) { if (ark_mem->itol == ARK_SV && ark_mem->Vabstol != NULL) diff --git a/src/sunadaptcontroller/CMakeLists.txt b/src/sunadaptcontroller/CMakeLists.txt index 91f16bbcdb..8287f3da3d 100644 --- a/src/sunadaptcontroller/CMakeLists.txt +++ b/src/sunadaptcontroller/CMakeLists.txt @@ -16,5 +16,4 @@ # required native matrices add_subdirectory(imexgus) -add_subdirectory(noop) add_subdirectory(soderlind) diff --git a/src/sunadaptcontroller/noop/CMakeLists.txt b/src/sunadaptcontroller/noop/CMakeLists.txt deleted file mode 100644 index 0941825c54..0000000000 --- a/src/sunadaptcontroller/noop/CMakeLists.txt +++ /dev/null @@ -1,29 +0,0 @@ -# --------------------------------------------------------------- -# Programmer(s): Daniel R. Reynolds @ SMU -# --------------------------------------------------------------- -# SUNDIALS Copyright Start -# Copyright (c) 2002-2023, 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 -# --------------------------------------------------------------- - -# Create a library out of the generic sundials modules -sundials_add_library(sundials_sunadaptcontrollernoop - SOURCES - sunadaptcontroller_noop.c - HEADERS - ${SUNDIALS_SOURCE_DIR}/include/sunadaptcontroller/sunadaptcontroller_noop.h - INCLUDE_SUBDIR - sunadaptcontroller - OBJECT_LIB_ONLY -) - -# Add F2003 module if the interface is enabled -if(BUILD_FORTRAN_MODULE_INTERFACE) - add_subdirectory(fmod) -endif() diff --git a/src/sunadaptcontroller/noop/fmod/CMakeLists.txt b/src/sunadaptcontroller/noop/fmod/CMakeLists.txt deleted file mode 100644 index 57f2a4e7fd..0000000000 --- a/src/sunadaptcontroller/noop/fmod/CMakeLists.txt +++ /dev/null @@ -1,25 +0,0 @@ -# --------------------------------------------------------------- -# Programmer(s): Daniel R. Reynolds @ SMU -# --------------------------------------------------------------- -# SUNDIALS Copyright Start -# Copyright (c) 2002-2023, 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 -# --------------------------------------------------------------- - -sundials_add_f2003_library(sundials_fsunadaptcontrollernoop_mod - SOURCES - fsunadaptcontroller_noop_mod.f90 fsunadaptcontroller_noop_mod.c - OBJECT_LIBRARIES - sundials_fgeneric_mod_obj - OUTPUT_NAME - sundials_fsunadaptcontrollernoop_mod - OBJECT_LIB_ONLY -) - -message(STATUS "Added SUNAdaptController_NOOP F2003 interface") diff --git a/src/sunadaptcontroller/noop/fmod/fsunadaptcontroller_noop_mod.c b/src/sunadaptcontroller/noop/fmod/fsunadaptcontroller_noop_mod.c deleted file mode 100644 index ad0c233426..0000000000 --- a/src/sunadaptcontroller/noop/fmod/fsunadaptcontroller_noop_mod.c +++ /dev/null @@ -1,235 +0,0 @@ -/* ---------------------------------------------------------------------------- - * This file was automatically generated by SWIG (http://www.swig.org). - * Version 4.0.0 - * - * This file is not intended to be easily readable and contains a number of - * coding conventions designed to improve portability and efficiency. Do not make - * changes to this file unless you know what you are doing--modify the SWIG - * interface file instead. - * ----------------------------------------------------------------------------- */ - -/* --------------------------------------------------------------- - * Programmer(s): Auto-generated by swig. - * --------------------------------------------------------------- - * SUNDIALS Copyright Start - * Copyright (c) 2002-2023, Lawrence Livermore National Security - * and Southern Methodist University. - * All rights reserved. - * - * See the top-level LICENSE and NOTICE files for details. - * - * SPDX-License-Identifier: BSD-3-Clause - * SUNDIALS Copyright End - * -------------------------------------------------------------*/ - -/* ----------------------------------------------------------------------------- - * This section contains generic SWIG labels for method/variable - * declarations/attributes, and other compiler dependent labels. - * ----------------------------------------------------------------------------- */ - -/* template workaround for compilers that cannot correctly implement the C++ standard */ -#ifndef SWIGTEMPLATEDISAMBIGUATOR -# if defined(__SUNPRO_CC) && (__SUNPRO_CC <= 0x560) -# define SWIGTEMPLATEDISAMBIGUATOR template -# elif defined(__HP_aCC) -/* Needed even with `aCC -AA' when `aCC -V' reports HP ANSI C++ B3910B A.03.55 */ -/* If we find a maximum version that requires this, the test would be __HP_aCC <= 35500 for A.03.55 */ -# define SWIGTEMPLATEDISAMBIGUATOR template -# else -# define SWIGTEMPLATEDISAMBIGUATOR -# endif -#endif - -/* inline attribute */ -#ifndef SWIGINLINE -# if defined(__cplusplus) || (defined(__GNUC__) && !defined(__STRICT_ANSI__)) -# define SWIGINLINE inline -# else -# define SWIGINLINE -# endif -#endif - -/* attribute recognised by some compilers to avoid 'unused' warnings */ -#ifndef SWIGUNUSED -# if defined(__GNUC__) -# if !(defined(__cplusplus)) || (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)) -# define SWIGUNUSED __attribute__ ((__unused__)) -# else -# define SWIGUNUSED -# endif -# elif defined(__ICC) -# define SWIGUNUSED __attribute__ ((__unused__)) -# else -# define SWIGUNUSED -# endif -#endif - -#ifndef SWIG_MSC_UNSUPPRESS_4505 -# if defined(_MSC_VER) -# pragma warning(disable : 4505) /* unreferenced local function has been removed */ -# endif -#endif - -#ifndef SWIGUNUSEDPARM -# ifdef __cplusplus -# define SWIGUNUSEDPARM(p) -# else -# define SWIGUNUSEDPARM(p) p SWIGUNUSED -# endif -#endif - -/* internal SWIG method */ -#ifndef SWIGINTERN -# define SWIGINTERN static SWIGUNUSED -#endif - -/* internal inline SWIG method */ -#ifndef SWIGINTERNINLINE -# define SWIGINTERNINLINE SWIGINTERN SWIGINLINE -#endif - -/* qualifier for exported *const* global data variables*/ -#ifndef SWIGEXTERN -# ifdef __cplusplus -# define SWIGEXTERN extern -# else -# define SWIGEXTERN -# endif -#endif - -/* exporting methods */ -#if defined(__GNUC__) -# if (__GNUC__ >= 4) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) -# ifndef GCC_HASCLASSVISIBILITY -# define GCC_HASCLASSVISIBILITY -# endif -# endif -#endif - -#ifndef SWIGEXPORT -# if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__) -# if defined(STATIC_LINKED) -# define SWIGEXPORT -# else -# define SWIGEXPORT __declspec(dllexport) -# endif -# else -# if defined(__GNUC__) && defined(GCC_HASCLASSVISIBILITY) -# define SWIGEXPORT __attribute__ ((visibility("default"))) -# else -# define SWIGEXPORT -# endif -# endif -#endif - -/* calling conventions for Windows */ -#ifndef SWIGSTDCALL -# if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__) -# define SWIGSTDCALL __stdcall -# else -# define SWIGSTDCALL -# endif -#endif - -/* Deal with Microsoft's attempt at deprecating C standard runtime functions */ -#if !defined(SWIG_NO_CRT_SECURE_NO_DEPRECATE) && defined(_MSC_VER) && !defined(_CRT_SECURE_NO_DEPRECATE) -# define _CRT_SECURE_NO_DEPRECATE -#endif - -/* Deal with Microsoft's attempt at deprecating methods in the standard C++ library */ -#if !defined(SWIG_NO_SCL_SECURE_NO_DEPRECATE) && defined(_MSC_VER) && !defined(_SCL_SECURE_NO_DEPRECATE) -# define _SCL_SECURE_NO_DEPRECATE -#endif - -/* Deal with Apple's deprecated 'AssertMacros.h' from Carbon-framework */ -#if defined(__APPLE__) && !defined(__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES) -# define __ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES 0 -#endif - -/* Intel's compiler complains if a variable which was never initialised is - * cast to void, which is a common idiom which we use to indicate that we - * are aware a variable isn't used. So we just silence that warning. - * See: https://github.com/swig/swig/issues/192 for more discussion. - */ -#ifdef __INTEL_COMPILER -# pragma warning disable 592 -#endif - -/* Errors in SWIG */ -#define SWIG_UnknownError -1 -#define SWIG_IOError -2 -#define SWIG_RuntimeError -3 -#define SWIG_IndexError -4 -#define SWIG_TypeError -5 -#define SWIG_DivisionByZero -6 -#define SWIG_OverflowError -7 -#define SWIG_SyntaxError -8 -#define SWIG_ValueError -9 -#define SWIG_SystemError -10 -#define SWIG_AttributeError -11 -#define SWIG_MemoryError -12 -#define SWIG_NullReferenceError -13 - - - - -#include -#define SWIG_exception_impl(DECL, CODE, MSG, RETURNNULL) \ - { printf("In " DECL ": " MSG); assert(0); RETURNNULL; } - - -#include -#if defined(_MSC_VER) || defined(__BORLANDC__) || defined(_WATCOM) -# ifndef snprintf -# define snprintf _snprintf -# endif -#endif - - -/* Support for the `contract` feature. - * - * Note that RETURNNULL is first because it's inserted via a 'Replaceall' in - * the fortran.cxx file. - */ -#define SWIG_contract_assert(RETURNNULL, EXPR, MSG) \ - if (!(EXPR)) { SWIG_exception_impl("$decl", SWIG_ValueError, MSG, RETURNNULL); } - - -#define SWIGVERSION 0x040000 -#define SWIG_VERSION SWIGVERSION - - -#define SWIG_as_voidptr(a) (void *)((const void *)(a)) -#define SWIG_as_voidptrptr(a) ((void)SWIG_as_voidptr(*a),(void**)(a)) - - -#include "sundials/sundials_adaptcontroller.h" - - -#include "sunadaptcontroller/sunadaptcontroller_noop.h" - -SWIGEXPORT SUNAdaptController _wrap_FSUNAdaptController_NoOp(void *farg1) { - SUNAdaptController fresult ; - SUNContext arg1 = (SUNContext) 0 ; - SUNAdaptController result; - - arg1 = (SUNContext)(farg1); - result = (SUNAdaptController)SUNAdaptController_NoOp(arg1); - fresult = result; - return fresult; -} - - -SWIGEXPORT int _wrap_FSUNAdaptController_GetType_NoOp(SUNAdaptController farg1) { - int fresult ; - SUNAdaptController arg1 = (SUNAdaptController) 0 ; - SUNAdaptController_Type result; - - arg1 = (SUNAdaptController)(farg1); - result = (SUNAdaptController_Type)SUNAdaptController_GetType_NoOp(arg1); - fresult = (int)(result); - return fresult; -} - - - diff --git a/src/sunadaptcontroller/noop/fmod/fsunadaptcontroller_noop_mod.f90 b/src/sunadaptcontroller/noop/fmod/fsunadaptcontroller_noop_mod.f90 deleted file mode 100644 index 5084c8fef3..0000000000 --- a/src/sunadaptcontroller/noop/fmod/fsunadaptcontroller_noop_mod.f90 +++ /dev/null @@ -1,83 +0,0 @@ -! This file was automatically generated by SWIG (http://www.swig.org). -! Version 4.0.0 -! -! Do not make changes to this file unless you know what you are doing--modify -! the SWIG interface file instead. - -! --------------------------------------------------------------- -! Programmer(s): Auto-generated by swig. -! --------------------------------------------------------------- -! SUNDIALS Copyright Start -! Copyright (c) 2002-2023, 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 -! --------------------------------------------------------------- - -module fsunadaptcontroller_noop_mod - use, intrinsic :: ISO_C_BINDING - use fsundials_adaptcontroller_mod - use fsundials_types_mod - use fsundials_context_mod - implicit none - private - - ! DECLARATION CONSTRUCTS - public :: FSUNAdaptController_NoOp - public :: FSUNAdaptController_GetType_NoOp - -! WRAPPER DECLARATIONS -interface -function swigc_FSUNAdaptController_NoOp(farg1) & -bind(C, name="_wrap_FSUNAdaptController_NoOp") & -result(fresult) -use, intrinsic :: ISO_C_BINDING -type(C_PTR), value :: farg1 -type(C_PTR) :: fresult -end function - -function swigc_FSUNAdaptController_GetType_NoOp(farg1) & -bind(C, name="_wrap_FSUNAdaptController_GetType_NoOp") & -result(fresult) -use, intrinsic :: ISO_C_BINDING -type(C_PTR), value :: farg1 -integer(C_INT) :: fresult -end function - -end interface - - -contains - ! MODULE SUBPROGRAMS -function FSUNAdaptController_NoOp(sunctx) & -result(swig_result) -use, intrinsic :: ISO_C_BINDING -type(SUNAdaptController), pointer :: swig_result -type(C_PTR) :: sunctx -type(C_PTR) :: fresult -type(C_PTR) :: farg1 - -farg1 = sunctx -fresult = swigc_FSUNAdaptController_NoOp(farg1) -call c_f_pointer(fresult, swig_result) -end function - -function FSUNAdaptController_GetType_NoOp(c) & -result(swig_result) -use, intrinsic :: ISO_C_BINDING -integer(SUNAdaptController_Type) :: swig_result -type(SUNAdaptController), target, intent(inout) :: c -integer(C_INT) :: fresult -type(C_PTR) :: farg1 - -farg1 = c_loc(c) -fresult = swigc_FSUNAdaptController_GetType_NoOp(farg1) -swig_result = fresult -end function - - -end module diff --git a/src/sunadaptcontroller/noop/sunadaptcontroller_noop.c b/src/sunadaptcontroller/noop/sunadaptcontroller_noop.c deleted file mode 100644 index 6bef3313e3..0000000000 --- a/src/sunadaptcontroller/noop/sunadaptcontroller_noop.c +++ /dev/null @@ -1,56 +0,0 @@ -/* ----------------------------------------------------------------- - * Programmer(s): Daniel R. Reynolds @ SMU - * ----------------------------------------------------------------- - * SUNDIALS Copyright Start - * Copyright (c) 2002-2023, Lawrence Livermore National Security - * and Southern Methodist University. - * All rights reserved. - * - * See the top-level LICENSE and NOTICE files for details. - * - * SPDX-License-Identifier: BSD-3-Clause - * SUNDIALS Copyright End - * ----------------------------------------------------------------- - * This is the implementation file for the SUNAdaptController_NOOP - * module. - * -----------------------------------------------------------------*/ - -#include -#include -#include -#include - - -/* ----------------------------------------------------------------- - * exported functions - * ----------------------------------------------------------------- */ - -/* ----------------------------------------------------------------- - * Function to create a new No-op controller - */ - -SUNAdaptController SUNAdaptController_NoOp(SUNContext sunctx) -{ - SUNAdaptController C; - - if (sunctx == NULL) { return NULL; } - - /* Create an empty controller object */ - C = NULL; - C = SUNAdaptController_NewEmpty(sunctx); - if (C == NULL) { return (NULL); } - - /* Attach operations */ - C->ops->gettype = SUNAdaptController_GetType_NoOp; - - /* Set NULL-valued content and return */ - C->content = NULL; - return (C); -} - -/* ----------------------------------------------------------------- - * implementation of controller operations - * ----------------------------------------------------------------- */ - -SUNAdaptController_Type SUNAdaptController_GetType_NoOp(SUNAdaptController C) -{ return SUN_ADAPTCONTROLLER_NONE; } diff --git a/src/sundials/fmod/fsundials_profiler_mod.c b/src/sundials/fmod/fsundials_profiler_mod.c index f352495a34..75599fa693 100644 --- a/src/sundials/fmod/fsundials_profiler_mod.c +++ b/src/sundials/fmod/fsundials_profiler_mod.c @@ -273,6 +273,36 @@ SWIGEXPORT int _wrap_FSUNProfiler_End(void *farg1, SwigArrayWrapper *farg2) { } +SWIGEXPORT int _wrap_FSUNProfiler_GetTimerResolution(void *farg1, double *farg2) { + int fresult ; + SUNProfiler arg1 = (SUNProfiler) 0 ; + double *arg2 = (double *) 0 ; + int result; + + arg1 = (SUNProfiler)(farg1); + arg2 = (double *)(farg2); + result = (int)SUNProfiler_GetTimerResolution(arg1,arg2); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FSUNProfiler_GetElapsedTime(void *farg1, SwigArrayWrapper *farg2, double *farg3) { + int fresult ; + SUNProfiler arg1 = (SUNProfiler) 0 ; + char *arg2 = (char *) 0 ; + double *arg3 = (double *) 0 ; + int result; + + arg1 = (SUNProfiler)(farg1); + arg2 = (char *)(farg2->data); + arg3 = (double *)(farg3); + result = (int)SUNProfiler_GetElapsedTime(arg1,(char const *)arg2,arg3); + fresult = (int)(result); + return fresult; +} + + SWIGEXPORT int _wrap_FSUNProfiler_Print(void *farg1, void *farg2) { int fresult ; SUNProfiler arg1 = (SUNProfiler) 0 ; diff --git a/src/sundials/fmod/fsundials_profiler_mod.f90 b/src/sundials/fmod/fsundials_profiler_mod.f90 index b1b6c74dc5..328243e3a3 100644 --- a/src/sundials/fmod/fsundials_profiler_mod.f90 +++ b/src/sundials/fmod/fsundials_profiler_mod.f90 @@ -31,6 +31,8 @@ module fsundials_profiler_mod end type public :: FSUNProfiler_Begin public :: FSUNProfiler_End + public :: FSUNProfiler_GetTimerResolution + public :: FSUNProfiler_GetElapsedTime public :: FSUNProfiler_Print public :: FSUNProfiler_Reset @@ -67,6 +69,26 @@ function swigc_FSUNProfiler_End(farg1, farg2) & integer(C_INT) :: fresult end function +function swigc_FSUNProfiler_GetTimerResolution(farg1, farg2) & +bind(C, name="_wrap_FSUNProfiler_GetTimerResolution") & +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_FSUNProfiler_GetElapsedTime(farg1, farg2, farg3) & +bind(C, name="_wrap_FSUNProfiler_GetElapsedTime") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +import :: swigarraywrapper +type(C_PTR), value :: farg1 +type(SwigArrayWrapper) :: farg2 +type(C_PTR), value :: farg3 +integer(C_INT) :: fresult +end function + function swigc_FSUNProfiler_Print(farg1, farg2) & bind(C, name="_wrap_FSUNProfiler_Print") & result(fresult) @@ -166,6 +188,42 @@ function FSUNProfiler_End(p, name) & swig_result = fresult end function +function FSUNProfiler_GetTimerResolution(p, resolution) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(C_PTR) :: p +real(C_DOUBLE), target, intent(inout) :: resolution +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 + +farg1 = p +farg2 = c_loc(resolution) +fresult = swigc_FSUNProfiler_GetTimerResolution(farg1, farg2) +swig_result = fresult +end function + +function FSUNProfiler_GetElapsedTime(p, name, time) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(C_PTR) :: p +character(kind=C_CHAR, len=*), target :: name +character(kind=C_CHAR), dimension(:), allocatable, target :: farg2_chars +real(C_DOUBLE), target, intent(inout) :: time +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(SwigArrayWrapper) :: farg2 +type(C_PTR) :: farg3 + +farg1 = p +call SWIG_string_to_chararray(name, farg2_chars, farg2) +farg3 = c_loc(time) +fresult = swigc_FSUNProfiler_GetElapsedTime(farg1, farg2, farg3) +swig_result = fresult +end function + function FSUNProfiler_Print(p, fp) & result(swig_result) use, intrinsic :: ISO_C_BINDING diff --git a/swig/Makefile b/swig/Makefile index 362efad12d..1948ecfd74 100644 --- a/swig/Makefile +++ b/swig/Makefile @@ -25,7 +25,7 @@ NVECTOR=openmp pthreads serial parallel manyvector mpiplusx SUNMATRIX=band dense sparse SUNLINSOL=band dense lapackdense klu spbcgs spfgmr spgmr sptfqmr pcg SUNNONLINSOL=newton fixedpoint -SUNADAPTCONTROLLER=imexgus noop soderlind +SUNADAPTCONTROLLER=imexgus soderlind INCLUDES=-I../include diff --git a/swig/sunadaptcontroller/fsunadaptcontroller_noop_mod.i b/swig/sunadaptcontroller/fsunadaptcontroller_noop_mod.i deleted file mode 100644 index b86c9cfb17..0000000000 --- a/swig/sunadaptcontroller/fsunadaptcontroller_noop_mod.i +++ /dev/null @@ -1,29 +0,0 @@ -// --------------------------------------------------------------- -// Programmer: Daniel R. Reynolds @ SMU -// --------------------------------------------------------------- -// SUNDIALS Copyright Start -// Copyright (c) 2002-2023, 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 -// --------------------------------------------------------------- -// Swig interface file -// --------------------------------------------------------------- - -%module fsunadaptcontroller_noop_mod - -// include code common to all implementations -%include "fsunadaptcontroller.i" - -%{ -#include "sunadaptcontroller/sunadaptcontroller_noop.h" -%} - -%sunadaptcontroller_impl(NoOp) - -// Process and wrap functions in the following files -%include "sunadaptcontroller/sunadaptcontroller_noop.h" diff --git a/test/unit_tests/arkode/CXX_serial/CMakeLists.txt b/test/unit_tests/arkode/CXX_serial/CMakeLists.txt index d92ef87659..c000087c10 100644 --- a/test/unit_tests/arkode/CXX_serial/CMakeLists.txt +++ b/test/unit_tests/arkode/CXX_serial/CMakeLists.txt @@ -62,7 +62,6 @@ foreach(test_tuple ${unit_tests}) sundials_sunnonlinsolnewton_obj sundials_sunnonlinsolfixedpoint_obj sundials_sunadaptcontrollerimexgus_obj - sundials_sunadaptcontrollernoop_obj sundials_sunadaptcontrollersoderlind_obj ${EXE_EXTRA_LINK_LIBS}) diff --git a/test/unit_tests/arkode/C_serial/CMakeLists.txt b/test/unit_tests/arkode/C_serial/CMakeLists.txt index 2330175dc8..13715f6054 100644 --- a/test/unit_tests/arkode/C_serial/CMakeLists.txt +++ b/test/unit_tests/arkode/C_serial/CMakeLists.txt @@ -66,7 +66,6 @@ foreach(test_tuple ${ARKODE_unit_tests}) sundials_sunlinsoldense_obj sundials_sunnonlinsolnewton_obj sundials_sunadaptcontrollerimexgus_obj - sundials_sunadaptcontrollernoop_obj sundials_sunadaptcontrollersoderlind_obj ${EXE_EXTRA_LINK_LIBS}) From 4ea726b4f242a1bc53dcb4c021e98c8294a03718 Mon Sep 17 00:00:00 2001 From: "Balos, Cody, J" Date: Thu, 2 Nov 2023 16:17:56 -0600 Subject: [PATCH 44/58] link caliper to object libraries within sundials_add_library macro --- cmake/macros/SundialsAddLibrary.cmake | 9 +++++++++ src/sundials/CMakeLists.txt | 10 +--------- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/cmake/macros/SundialsAddLibrary.cmake b/cmake/macros/SundialsAddLibrary.cmake index 5bf25ab4b8..2717e66bf8 100644 --- a/cmake/macros/SundialsAddLibrary.cmake +++ b/cmake/macros/SundialsAddLibrary.cmake @@ -176,6 +176,15 @@ macro(sundials_add_library target) target_link_libraries(${obj_target} ${_all_libs}) endif() + if(SUNDIALS_BUILD_WITH_PROFILING) + if(ENABLE_CALIPER) + target_link_libraries(${obj_target} PUBLIC caliper) + endif() + if(ENABLE_ADIAK) + target_link_libraries(${obj_target} PUBLIC adiak::adiak ${CMAKE_DL_LIBS}) + endif() + endif() + # add includes to object library target_include_directories(${obj_target} PUBLIC diff --git a/src/sundials/CMakeLists.txt b/src/sundials/CMakeLists.txt index 148ac2ee09..df5af04cd6 100644 --- a/src/sundials/CMakeLists.txt +++ b/src/sundials/CMakeLists.txt @@ -108,18 +108,12 @@ endif() # Add prefix with complete path to the source files add_prefix(${SUNDIALS_SOURCE_DIR}/src/sundials/ sundials_SOURCES) -if(SUNDIALS_BUILD_WITH_PROFILING OR SUNDIALS_LOGGING_ENABLE_MPI) +if(SUNDIALS_LOGGING_ENABLE_MPI) if(ENABLE_MPI AND MPI_C_FOUND) # Workaround bug in CMake < 3.17.3 when using MPI::MPI_CXX and CUDA set(_include_mpi_if_needed PUBLIC ${MPI_C_INCLUDE_DIRS}) set(_link_mpi_if_needed PUBLIC ${MPI_C_LIBRARIES}) endif() - if(ENABLE_CALIPER) - set(_link_caliper_if_needed PUBLIC caliper) - endif() - if(ENABLE_ADIAK) - set(_link_adiak_if_needed PUBLIC adiak::adiak ${CMAKE_DL_LIBS}) - endif() endif() # Create a library out of the generic sundials modules @@ -134,8 +128,6 @@ sundials_add_library(sundials_generic ${_include_mpi_if_needed} LINK_LIBRARIES ${_link_mpi_if_needed} - ${_link_caliper_if_needed} - ${_link_adiak_if_needed} OUTPUT_NAME sundials_generic VERSION From 8f0ca2297880f7a40b7b063cf2683dd2812dc0a2 Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Thu, 2 Nov 2023 23:38:24 -0500 Subject: [PATCH 45/58] Updated answers repository commit --- test/answers | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/answers b/test/answers index 8410ac981d..a65cbc2ff8 160000 --- a/test/answers +++ b/test/answers @@ -1 +1 @@ -Subproject commit 8410ac981d29c02494b977def00b100b966bebc1 +Subproject commit a65cbc2ff8a8531557a538a1bab8e86d1d5b9ec4 From dd8b1a459a2a8787fef8d98ebfc9ae6d0cd2f59d Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Mon, 6 Nov 2023 12:42:28 -0600 Subject: [PATCH 46/58] Fixed C90 build issues arising from PR suggestions --- .../imexgus/sunadaptcontroller_imexgus.c | 33 +++++++++---------- .../soderlind/sunadaptcontroller_soderlind.c | 3 +- 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/src/sunadaptcontroller/imexgus/sunadaptcontroller_imexgus.c b/src/sunadaptcontroller/imexgus/sunadaptcontroller_imexgus.c index e949df24d2..9f9f1d39ab 100644 --- a/src/sunadaptcontroller/imexgus/sunadaptcontroller_imexgus.c +++ b/src/sunadaptcontroller/imexgus/sunadaptcontroller_imexgus.c @@ -124,32 +124,31 @@ SUNAdaptController_Type SUNAdaptController_GetType_ImExGus(SUNAdaptController C) int SUNAdaptController_EstimateStep_ImExGus(SUNAdaptController C, sunrealtype h, int p, sunrealtype dsm, sunrealtype* hnew) { - if (C == NULL || hnew == NULL) { return SUNADAPTCONTROLLER_ILL_INPUT; } /* order parameter to use */ const int ord = p + 1; - /* modified method for first step */ + /* set usable time-step adaptivity parameters -- first step */ + const sunrealtype k = -RCONST(1.0) / ord; + const sunrealtype e = SUNMAX(SACIMEXGUS_BIAS(C) * dsm, TINY); + + /* set usable time-step adaptivity parameters -- subsequent steps */ + const sunrealtype k1e = -SACIMEXGUS_K1E(C) / ord; + const sunrealtype k2e = -SACIMEXGUS_K2E(C) / ord; + const sunrealtype k1i = -SACIMEXGUS_K1I(C) / ord; + const sunrealtype k2i = -SACIMEXGUS_K2I(C) / ord; + const sunrealtype e1 = SUNMAX(SACIMEXGUS_BIAS(C) * dsm, TINY); + const sunrealtype e2 = e1 / SUNMAX(SACIMEXGUS_EP(C), TINY); + const sunrealtype hrat = h / SACIMEXGUS_HP(C); + + if (C == NULL || hnew == NULL) { return SUNADAPTCONTROLLER_ILL_INPUT; } + + /* compute estimated time step size, modifying the first step formula */ if (SACIMEXGUS_FIRSTSTEP(C)) { - /* set usable time-step adaptivity parameters */ - const sunrealtype k = -RCONST(1.0) / ord; - const sunrealtype e = SUNMAX(SACIMEXGUS_BIAS(C) * dsm, TINY); - - /* compute estimated optimal time step size */ *hnew = h * SUNRpowerR(e,k); } else { - /* set usable time-step adaptivity parameters */ - const sunrealtype k1e = -SACIMEXGUS_K1E(C) / ord; - const sunrealtype k2e = -SACIMEXGUS_K2E(C) / ord; - const sunrealtype k1i = -SACIMEXGUS_K1I(C) / ord; - const sunrealtype k2i = -SACIMEXGUS_K2I(C) / ord; - const sunrealtype e1 = SUNMAX(SACIMEXGUS_BIAS(C) * dsm, TINY); - const sunrealtype e2 = e1 / SUNMAX(SACIMEXGUS_EP(C), TINY); - const sunrealtype hrat = h / SACIMEXGUS_HP(C); - - /* compute estimated optimal time step size */ *hnew = h * SUNMIN(hrat * SUNRpowerR(e1,k1i) * SUNRpowerR(e2,k2i), SUNRpowerR(e1,k1e) * SUNRpowerR(e2,k2e)); } diff --git a/src/sunadaptcontroller/soderlind/sunadaptcontroller_soderlind.c b/src/sunadaptcontroller/soderlind/sunadaptcontroller_soderlind.c index ef3bd57527..4d16ac8f09 100644 --- a/src/sunadaptcontroller/soderlind/sunadaptcontroller_soderlind.c +++ b/src/sunadaptcontroller/soderlind/sunadaptcontroller_soderlind.c @@ -324,7 +324,6 @@ SUNAdaptController_Type SUNAdaptController_GetType_Soderlind(SUNAdaptController int SUNAdaptController_EstimateStep_Soderlind(SUNAdaptController C, sunrealtype h, int p, sunrealtype dsm, sunrealtype* hnew) { - if (C == NULL || hnew == NULL) { return SUNADAPTCONTROLLER_ILL_INPUT; } /* order parameter to use */ const int ord = p + 1; @@ -340,6 +339,8 @@ int SUNAdaptController_EstimateStep_Soderlind(SUNAdaptController C, sunrealtype const sunrealtype hrat = h / SODERLIND_HP(C); const sunrealtype hrat2 = SODERLIND_HP(C) / SODERLIND_HPP(C); + if (C == NULL || hnew == NULL) { return SUNADAPTCONTROLLER_ILL_INPUT; } + /* compute estimated optimal time step size */ if (SODERLIND_FIRSTSTEPS(C) < 1) { *hnew = h * SUNRpowerR(e1,k1); From f0e521c4917b4b999af1518ed65e9b49da498f1d Mon Sep 17 00:00:00 2001 From: Cody Balos Date: Mon, 6 Nov 2023 16:56:38 -0800 Subject: [PATCH 47/58] add sunadaptcontroller back to tarscript (merge fix) --- scripts/shared | 2 ++ 1 file changed, 2 insertions(+) diff --git a/scripts/shared b/scripts/shared index 11634ec73f..d0197358ba 100755 --- a/scripts/shared +++ b/scripts/shared @@ -69,6 +69,7 @@ $tar $tarfile $distrobase/include/sunlinsol $tar $tarfile $distrobase/include/sunmatrix $tar $tarfile $distrobase/include/sunmemory $tar $tarfile $distrobase/include/sunnonlinsol +$tar $tarfile $distrobase/include/sunadaptcontroller echo " --- Add scripts to $tarfile" $tar $tarfile $distrobase/scripts/sundials_csv.py @@ -81,6 +82,7 @@ $tar $tarfile $distrobase/src/sunlinsol $tar $tarfile $distrobase/src/sunmatrix $tar $tarfile $distrobase/src/sunmemory $tar $tarfile $distrobase/src/sunnonlinsol +$tar $tarfile $distrobase/src/sunadaptcontroller echo " --- Add examples to $tarfile" $tar $tarfile $distrobase/examples/CMakeLists.txt From e365c82003b5ec5e5c31ad7ad86e09b80f3f244f Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Tue, 7 Nov 2023 11:07:25 -0600 Subject: [PATCH 48/58] fixed another C90 build issue --- src/arkode/arkode_io.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/arkode/arkode_io.c b/src/arkode/arkode_io.c index 979b9e90d4..4651834ea0 100644 --- a/src/arkode/arkode_io.c +++ b/src/arkode/arkode_io.c @@ -639,9 +639,7 @@ int arkClearStopTime(void *arkode_mem) int arkSetFixedStep(void *arkode_mem, realtype hfixed) { int retval; - long int lenrw, leniw; ARKodeMem ark_mem; - SUNAdaptController C; if (arkode_mem==NULL) { arkProcessError(NULL, ARK_MEM_NULL, "ARKODE", "arkSetFixedStep", MSG_ARK_NO_MEM); @@ -668,7 +666,7 @@ int arkSetFixedStep(void *arkode_mem, realtype hfixed) /* Notify ARKODE to use hfixed as the initial step size, and return */ retval = arkSetInitStep(arkode_mem, hfixed); - + return(ARK_SUCCESS); } From 59d7e16c64e4244cf550dc08290553356a81c495 Mon Sep 17 00:00:00 2001 From: "Balos, Cody, J" Date: Tue, 7 Nov 2023 12:18:33 -0800 Subject: [PATCH 49/58] update answers commit --- test/answers | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/answers b/test/answers index a65cbc2ff8..d3651dc380 160000 --- a/test/answers +++ b/test/answers @@ -1 +1 @@ -Subproject commit a65cbc2ff8a8531557a538a1bab8e86d1d5b9ec4 +Subproject commit d3651dc380658af17f3c5a534369e379406a47b8 From 0b665ee5de1df09b6257ac1fa41fef75a31060a2 Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Wed, 8 Nov 2023 08:41:36 -0600 Subject: [PATCH 50/58] Marked *StepSetErrorBias as deprecated in header, and moved implementation to appropriate location in arkstep_*step_io.c --- include/arkode/arkode_arkstep.h | 4 ++-- include/arkode/arkode_erkstep.h | 4 ++-- src/arkode/arkode_arkstep_io.c | 8 ++++++-- src/arkode/arkode_erkstep_io.c | 9 +++++++-- 4 files changed, 17 insertions(+), 8 deletions(-) diff --git a/include/arkode/arkode_arkstep.h b/include/arkode/arkode_arkstep.h index ea1252cc94..666318568c 100644 --- a/include/arkode/arkode_arkstep.h +++ b/include/arkode/arkode_arkstep.h @@ -190,8 +190,8 @@ SUNDIALS_EXPORT int ARKStepSetCFLFraction(void *arkode_mem, realtype cfl_frac); SUNDIALS_EXPORT int ARKStepSetSafetyFactor(void *arkode_mem, realtype safety); -SUNDIALS_EXPORT int ARKStepSetErrorBias(void *arkode_mem, - realtype bias); +SUNDIALS_DEPRECATED_EXPORT_MSG("use SUNAdaptController instead") +int ARKStepSetErrorBias(void *arkode_mem, realtype bias); SUNDIALS_EXPORT int ARKStepSetMaxGrowth(void *arkode_mem, realtype mx_growth); SUNDIALS_EXPORT int ARKStepSetMinReduction(void *arkode_mem, diff --git a/include/arkode/arkode_erkstep.h b/include/arkode/arkode_erkstep.h index e7e5c3be72..304c1925c2 100644 --- a/include/arkode/arkode_erkstep.h +++ b/include/arkode/arkode_erkstep.h @@ -121,8 +121,8 @@ SUNDIALS_EXPORT int ERKStepSetCFLFraction(void *arkode_mem, realtype cfl_frac); SUNDIALS_EXPORT int ERKStepSetSafetyFactor(void *arkode_mem, realtype safety); -SUNDIALS_EXPORT int ERKStepSetErrorBias(void *arkode_mem, - realtype bias); +SUNDIALS_DEPRECATED_EXPORT_MSG("use SUNAdaptController instead") +int ERKStepSetErrorBias(void *arkode_mem, realtype bias); SUNDIALS_EXPORT int ERKStepSetMaxGrowth(void *arkode_mem, realtype mx_growth); SUNDIALS_EXPORT int ERKStepSetMinReduction(void *arkode_mem, diff --git a/src/arkode/arkode_arkstep_io.c b/src/arkode/arkode_arkstep_io.c index 184781ca89..5925b29582 100644 --- a/src/arkode/arkode_arkstep_io.c +++ b/src/arkode/arkode_arkstep_io.c @@ -83,8 +83,6 @@ int ARKStepSetCFLFraction(void *arkode_mem, realtype cfl_frac) { return(arkSetCFLFraction(arkode_mem, cfl_frac)); } int ARKStepSetSafetyFactor(void *arkode_mem, realtype safety) { return(arkSetSafetyFactor(arkode_mem, safety)); } -int ARKStepSetErrorBias(void *arkode_mem, realtype bias) { - return(arkSetErrorBias(arkode_mem, bias)); } int ARKStepSetMaxGrowth(void *arkode_mem, realtype mx_growth) { return(arkSetMaxGrowth(arkode_mem, mx_growth)); } int ARKStepSetMinReduction(void *arkode_mem, realtype eta_min) { @@ -363,6 +361,12 @@ int ARKStepSetAdaptivityMethod(void *arkode_mem, int imethod, int idefault, int ARKStepSetAdaptivityFn(void *arkode_mem, ARKAdaptFn hfun, void *h_data) { return(arkSetAdaptivityFn(arkode_mem, hfun, h_data)); } +/*--------------------------------------------------------------- + ARKStepSetErrorBias: user should set this value directly in the + SUNAdaptController object. + ---------------------------------------------------------------*/ +int ARKStepSetErrorBias(void *arkode_mem, realtype bias) { + return(arkSetErrorBias(arkode_mem, bias)); } /*=============================================================== diff --git a/src/arkode/arkode_erkstep_io.c b/src/arkode/arkode_erkstep_io.c index 108dfe6a4b..bfdf929f3e 100644 --- a/src/arkode/arkode_erkstep_io.c +++ b/src/arkode/arkode_erkstep_io.c @@ -84,8 +84,6 @@ int ERKStepSetCFLFraction(void *arkode_mem, realtype cfl_frac) { return(arkSetCFLFraction(arkode_mem, cfl_frac)); } int ERKStepSetSafetyFactor(void *arkode_mem, realtype safety) { return(arkSetSafetyFactor(arkode_mem, safety)); } -int ERKStepSetErrorBias(void *arkode_mem, realtype bias) { - return(arkSetErrorBias(arkode_mem, bias)); } int ERKStepSetMaxGrowth(void *arkode_mem, realtype mx_growth) { return(arkSetMaxGrowth(arkode_mem, mx_growth)); } int ERKStepSetMinReduction(void *arkode_mem, realtype eta_min) { @@ -253,6 +251,13 @@ int ERKStepSetAdaptivityMethod(void *arkode_mem, int imethod, int idefault, int ERKStepSetAdaptivityFn(void *arkode_mem, ARKAdaptFn hfun, void *h_data) { return(arkSetAdaptivityFn(arkode_mem, hfun, h_data)); } +/*--------------------------------------------------------------- + ERKStepSetErrorBias: user should set this value directly in the + SUNAdaptController object. + ---------------------------------------------------------------*/ +int ERKStepSetErrorBias(void *arkode_mem, realtype bias) { + return(arkSetErrorBias(arkode_mem, bias)); } + /*=============================================================== ERKStep optional input functions -- stepper-specific From 871ab2dc7ed77b78732ee51bb41a8e0a0987ec35 Mon Sep 17 00:00:00 2001 From: "David J. Gardner" Date: Wed, 8 Nov 2023 06:40:22 -0800 Subject: [PATCH 51/58] update answers submodule --- test/answers | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/answers b/test/answers index e44b6b670f..565d888d29 160000 --- a/test/answers +++ b/test/answers @@ -1 +1 @@ -Subproject commit e44b6b670f6b3dde1cb2a22c901e6c9f9c0b4bb3 +Subproject commit 565d888d29059f3436d447c0416bcdab94511a3d From aac7c0ecad1dba8a552e01f08977badbb5ff95ab Mon Sep 17 00:00:00 2001 From: "David J. Gardner" Date: Wed, 8 Nov 2023 06:41:38 -0800 Subject: [PATCH 52/58] update output files --- .../C_parallel/ark_diurnal_kry_bbd_p.out | 71 +------------------ .../arkode/C_serial/ark_KrylovDemo_prec.out | 2 +- .../arkode/C_serial/ark_KrylovDemo_prec_1.out | 6 +- .../arkode/C_serial/ark_KrylovDemo_prec_2.out | 8 +-- 4 files changed, 9 insertions(+), 78 deletions(-) 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 19f3cabb3a..df7478fcae 100644 --- a/examples/arkode/C_parallel/ark_diurnal_kry_bbd_p.out +++ b/examples/arkode/C_parallel/ark_diurnal_kry_bbd_p.out @@ -11,75 +11,6 @@ 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 -t = 1.44e+04 no. steps = 2738 stepsize = 6.94e+00 -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 = 3535 stepsize = 1.05e+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 = 4683 stepsize = 4.46e+00 -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 = 5959 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 - -t = 4.32e+04 no. steps = 7152 stepsize = 3.93e+02 -At bottom left: c1, c2 = -1.202e-09 3.382e+11 -At top right: c1, c2 = 1.624e-07 3.804e+11 - -t = 5.04e+04 no. steps = 7171 stepsize = 3.76e+02 -At bottom left: c1, c2 = 5.092e-08 3.358e+11 -At top right: c1, c2 = -4.835e-07 3.864e+11 - -t = 5.76e+04 no. steps = 7188 stepsize = 2.94e+02 -At bottom left: c1, c2 = -3.248e-10 3.320e+11 -At top right: c1, c2 = 7.269e-08 3.909e+11 - -t = 6.48e+04 no. steps = 7212 stepsize = 5.52e+02 -At bottom left: c1, c2 = -1.079e-09 3.313e+11 -At top right: c1, c2 = -2.660e-07 3.963e+11 - -t = 7.20e+04 no. steps = 7225 stepsize = 5.52e+02 -At bottom left: c1, c2 = 4.318e-08 3.330e+11 -At top right: c1, c2 = -4.973e-07 4.039e+11 - -t = 7.92e+04 no. steps = 7238 stepsize = 5.52e+02 -At bottom left: c1, c2 = -1.398e-08 3.334e+11 -At top right: c1, c2 = 7.657e-08 4.120e+11 - -t = 8.64e+04 no. steps = 7252 stepsize = 5.52e+02 -At bottom left: c1, c2 = 1.764e-07 3.352e+11 -At top right: c1, c2 = -4.190e-08 4.163e+11 - - -Final Statistics: - -lenrw = 3902 leniw = 267 -lenrwls = 2455 leniwls = 126 -nst = 7252 nfe = 0 -nfe = 76109 nfels = 82856 -nni = 39711 nli = 82856 -nsetups = 437 netf = 27 -npe = 121 nps = 120385 -ncfn = 0 ncfl = 0 - -In ARKBBDPRE: real/integer local work space sizes = 1300, 192 - no. flocal evals. = 2662 - - -------------------------------------------------------------------- - - -Preconditioner type is: jpre = SUN_PREC_RIGHT - -t = 7.20e+03 no. steps = 981 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 - 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 @@ -127,7 +58,7 @@ At top right: c1, c2 = -2.537e-27 4.163e+11 Final Statistics: -lenrw = 3901 leniw = 267 +lenrw = 3902 leniw = 267 lenrwls = 2455 leniwls = 126 nst = 7252 nfe = 0 nfe = 76929 nfels = 102816 diff --git a/examples/arkode/C_serial/ark_KrylovDemo_prec.out b/examples/arkode/C_serial/ark_KrylovDemo_prec.out index 55ee67974f..79d7c4a86f 100644 --- a/examples/arkode/C_serial/ark_KrylovDemo_prec.out +++ b/examples/arkode/C_serial/ark_KrylovDemo_prec.out @@ -625,7 +625,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 = 3557 + ARKStep real workspace length = 3558 ARKStep integer workspace length = 146 ARKLS real workspace length = 2647 ARKLS integer workspace length = 42 diff --git a/examples/arkode/C_serial/ark_KrylovDemo_prec_1.out b/examples/arkode/C_serial/ark_KrylovDemo_prec_1.out index 63324c4773..79d7c4a86f 100644 --- a/examples/arkode/C_serial/ark_KrylovDemo_prec_1.out +++ b/examples/arkode/C_serial/ark_KrylovDemo_prec_1.out @@ -487,7 +487,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 = 3557 + ARKStep real workspace length = 3558 ARKStep integer workspace length = 136 ARKLS real workspace length = 2647 ARKLS integer workspace length = 42 @@ -556,7 +556,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 = 3557 + ARKStep real workspace length = 3558 ARKStep integer workspace length = 141 ARKLS real workspace length = 2647 ARKLS integer workspace length = 42 @@ -625,7 +625,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 = 3557 + ARKStep real workspace length = 3558 ARKStep integer workspace length = 146 ARKLS real workspace length = 2647 ARKLS integer workspace length = 42 diff --git a/examples/arkode/C_serial/ark_KrylovDemo_prec_2.out b/examples/arkode/C_serial/ark_KrylovDemo_prec_2.out index a3f589f739..79d7c4a86f 100644 --- a/examples/arkode/C_serial/ark_KrylovDemo_prec_2.out +++ b/examples/arkode/C_serial/ark_KrylovDemo_prec_2.out @@ -418,7 +418,7 @@ Species 6 Final statistics for this run: - ARKStep real workspace length = 3557 + ARKStep real workspace length = 3558 ARKStep integer workspace length = 131 ARKLS real workspace length = 2647 ARKLS integer workspace length = 42 @@ -487,7 +487,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 = 3557 + ARKStep real workspace length = 3558 ARKStep integer workspace length = 136 ARKLS real workspace length = 2647 ARKLS integer workspace length = 42 @@ -556,7 +556,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 = 3557 + ARKStep real workspace length = 3558 ARKStep integer workspace length = 141 ARKLS real workspace length = 2647 ARKLS integer workspace length = 42 @@ -625,7 +625,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 = 3557 + ARKStep real workspace length = 3558 ARKStep integer workspace length = 146 ARKLS real workspace length = 2647 ARKLS integer workspace length = 42 From ef971843dde79ccad000a028169e0bc4ff45568a Mon Sep 17 00:00:00 2001 From: "David J. Gardner" Date: Wed, 8 Nov 2023 08:31:38 -0800 Subject: [PATCH 53/58] update f2003 output --- .../arkode/F2003_serial/ark_analytic_f2003.out | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/examples/arkode/F2003_serial/ark_analytic_f2003.out b/examples/arkode/F2003_serial/ark_analytic_f2003.out index 6bd9ca6971..c5c64ac439 100644 --- a/examples/arkode/F2003_serial/ark_analytic_f2003.out +++ b/examples/arkode/F2003_serial/ark_analytic_f2003.out @@ -16,15 +16,15 @@ 1.00000E+01 1.47113E+00 General Solver Stats: - Total internal steps taken = 413 - Total internal steps attempts = 419 - Total rhs function calls = 4983 + Total internal steps taken = 419 + Total internal steps attempts = 424 + Total rhs function calls = 5090 Num lin solver setup calls = 43 - Num error test failures = 6 + Num error test failures = 5 First internal step size = 6.10352E-12 - Last internal step size = 5.69650E-02 - Next internal step size = 5.69650E-02 - Current internal time = 1.00344E+01 - Num nonlinear solver iters = 2885 + Last internal step size = 6.85164E-02 + Next internal step size = 6.85164E-02 + Current internal time = 1.00642E+01 + Num nonlinear solver iters = 2967 Num nonlinear solver fails = 4 From 1677e7d818ea960f0bc6b32b13b0367243084608 Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Wed, 8 Nov 2023 11:54:34 -0600 Subject: [PATCH 54/58] Updatd answers submodule commit --- test/answers | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/answers b/test/answers index 565d888d29..27147a242d 160000 --- a/test/answers +++ b/test/answers @@ -1 +1 @@ -Subproject commit 565d888d29059f3436d447c0416bcdab94511a3d +Subproject commit 27147a242d26db7bd1092331c9fdd1d2dcab561d From 4eec81592484ae327f9e25a701040071b60513dd Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Wed, 8 Nov 2023 12:30:49 -0600 Subject: [PATCH 55/58] Updatd answers submodule commit --- test/answers | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/answers b/test/answers index 27147a242d..cada4d84a1 160000 --- a/test/answers +++ b/test/answers @@ -1 +1 @@ -Subproject commit 27147a242d26db7bd1092331c9fdd1d2dcab561d +Subproject commit cada4d84a1953b68a94ed1e01e035a944357e1dc From e574ca71ab77c53ad2bffc84f3bf796d5c9e9bfc Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Wed, 8 Nov 2023 12:34:28 -0600 Subject: [PATCH 56/58] Updated answers submodule commit --- test/answers | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/answers b/test/answers index cada4d84a1..a28820aa19 160000 --- a/test/answers +++ b/test/answers @@ -1 +1 @@ -Subproject commit cada4d84a1953b68a94ed1e01e035a944357e1dc +Subproject commit a28820aa19405e6d542fcc59705c031db6adb824 From 34a1f1961368fd03b89650077783e5fda757dbe5 Mon Sep 17 00:00:00 2001 From: "David J. Gardner" Date: Wed, 8 Nov 2023 17:46:57 -0500 Subject: [PATCH 57/58] update answers commit --- test/answers | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/answers b/test/answers index a28820aa19..64b59c8101 160000 --- a/test/answers +++ b/test/answers @@ -1 +1 @@ -Subproject commit a28820aa19405e6d542fcc59705c031db6adb824 +Subproject commit 64b59c8101041bd58835c9b78d087054d5e77a6a From 1268a1c96ba5c908c65aa5389820aa1fcdee7df4 Mon Sep 17 00:00:00 2001 From: "Balos, Cody, J" Date: Wed, 8 Nov 2023 15:21:49 -0800 Subject: [PATCH 58/58] bump answers commit one last time (hopefully) --- test/answers | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/answers b/test/answers index 64b59c8101..1ff407f621 160000 --- a/test/answers +++ b/test/answers @@ -1 +1 @@ -Subproject commit 64b59c8101041bd58835c9b78d087054d5e77a6a +Subproject commit 1ff407f621fd49addea544af650362bf190ff9dd