diff --git a/CHANGELOG.md b/CHANGELOG.md index 0854c78ebe..d94c75da4c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,14 @@ ## Changes to SUNDIALS in release X.X.X +Added `SUNAdaptController` and `SUNTimestepHeuristics` base classes. Ported +ARKODE's internal implementations of time step control and heuristic constraints +into implementations of these classes, and updated ARKODE to use these objects +instead of its own implementations. Added `ARKStepSetAdaptController`, +`ARKStepSetTimestepHeuristics`, `ERKStepSetAdaptController`, and +`ERKStepSetTimestepHeuristics` routines so that users can modify +controller/heuristic parameters, or even provide custom implementations. + Fixed a bug in `ARKStepSetTableNum` wherein it did not recognize `ARKODE_ARK2_ERK_3_1_2` and `ARKODE_ARK2_DIRK_3_1_2` as a valid additive Runge--Kutta Butcher table pair. @@ -13,6 +21,14 @@ Improved computational complexity of `SUNMatScaleAddI_Sparse` from `O(M*N)` to Fixed scaling bug in `SUNMatScaleAddI_Sparse` for non-square matrices. +Changed the default fourth order DIRK method to `ARKODE_ARK436L2SA_DIRK_6_3_4` +for improved accuracy and embedded stability. To revert to the previous default, +use `ARKStepSetTableNum(arkode_mem, ARKODE_SDIRK_5_3_4, ARKODE_ERK_NONE)`. + +Added the ERK method `ARKODE_SOFRONIOU_SPALETTA_5_3_4` which is now the default +fourth order ERK method. To revert to the previous default, use +`ERKStepSetTableNum(arkode_mem, ARKODE_ZONNEVELD_5_3_4)`. + Fixed missing soversions in some `SUNLinearSolver` CMake targets. ## Changes to SUNDIALS in release 6.6.1 diff --git a/cmake/macros/SundialsAddLibrary.cmake b/cmake/macros/SundialsAddLibrary.cmake index 96d71765ec..4dd28ca719 100644 --- a/cmake/macros/SundialsAddLibrary.cmake +++ b/cmake/macros/SundialsAddLibrary.cmake @@ -165,6 +165,14 @@ macro(sundials_add_library target) if(SUNDIALS_RT_LIBRARY) target_link_libraries(${obj_target} PRIVATE "${SUNDIALS_RT_LIBRARY}") 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() if(sundials_add_library_LINK_LIBRARIES) if(${_libtype} MATCHES "STATIC") append_static_suffix(sundials_add_library_LINK_LIBRARIES _all_libs) diff --git a/doc/arkode/guide/source/Butcher.rst b/doc/arkode/guide/source/Butcher.rst index ecafdab263..673bad8162 100644 --- a/doc/arkode/guide/source/Butcher.rst +++ b/doc/arkode/guide/source/Butcher.rst @@ -331,6 +331,43 @@ This is the default 3th order slow and fast MRIStep method (from Linear stability region for the Knoth-Wolke method +.. _Butcher.Sofroniou_Spaletta: + +Sofroniou-Spaletta-5-3-4 +^^^^^^^^^^^^^^^^^^^^^^^^ + +.. index:: Sofroniou-Spaletta-5-3-4 ERK method + +Accessible via the constant ``ARKODE_SOFRONIOU_SPALETTA_5_3_4`` to +:c:func:`ARKStepSetTableNum`, :c:func:`ERKStepSetTableNum` +or :c:func:`ARKodeButcherTable_LoadERK`. +Accessible via the string ``"ARKODE_SOFRONIOU_SPALETTA_5_3_4"`` to +:c:func:`ARKStepSetTableName`, :c:func:`ERKStepSetTableName` or +:c:func:`ARKodeButcherTable_LoadERKByName`. +This is the default 4th order explicit method +(from :cite:p:`SoSp:04`). + +.. math:: + + \renewcommand{\arraystretch}{1.5} + 0 & 0 & 0 & 0 & 0 & 0 \\ + \frac{2}{5} & \frac{2}{5} & 0 & 0 & 0 & 0 \\ + \frac{3}{5} & -\frac{3}{20} & \frac{3}{4} & 0 & 0 & 0 \\ + 1 & \frac{19}{44} & -\frac{15}{44} & \frac{10}{11} & 0 & 0 \\ + 1 & \frac{11}{72} & \frac{25}{72} & \frac{25}{72} & \frac{11}{72} & 0 \\ + 4 & \frac{11}{72} & \frac{25}{72} & \frac{25}{72} & \frac{11}{72} & 0 \\ + 3 & \frac{1251515}{8970912} & \frac{3710105}{8970912} & \frac{2519695}{8970912} & \frac{61105}{8970912} & \frac{119041}{747576} \\ + \end{array} + +.. figure:: /figs/arkode/sofroniou_spaletta_erk_stab_region.png + :scale: 50 % + :align: center + + Linear stability region for the Sofroniou-Spaletta method. The method's + region is outlined in blue; the embedding's region is in red. + + + .. _Butcher.Zonneveld: @@ -345,7 +382,6 @@ or :c:func:`ARKodeButcherTable_LoadERK`. Accessible via the string ``"ARKODE_ZONNEVELD_5_3_4"`` to :c:func:`ARKStepSetTableName`, :c:func:`ERKStepSetTableName` or :c:func:`ARKodeButcherTable_LoadERKByName`. -This is the default 4th order explicit method (from :cite:p:`Zon:63`). .. math:: diff --git a/doc/arkode/guide/source/Constants.rst b/doc/arkode/guide/source/Constants.rst index 9a3e6600ac..f4ada6e899 100644 --- a/doc/arkode/guide/source/Constants.rst +++ b/doc/arkode/guide/source/Constants.rst @@ -80,6 +80,8 @@ contains the ARKODE output constants. +-----------------------------------------------+------------------------------------------------------------+ | :index:`ARKODE_ARK324L2SA_ERK_4_2_3` | Use the ARK-4-2-3 ERK method. | +-----------------------------------------------+------------------------------------------------------------+ + | :index:`ARKODE_SOFRONIOU_SPALETTA_5_3_4` | Use the Sofroniou-Spaletta-5-3-4 ERK method. | + +-----------------------------------------------+------------------------------------------------------------+ | :index:`ARKODE_ZONNEVELD_5_3_4` | Use the Zonneveld-5-3-4 ERK method. | +-----------------------------------------------+------------------------------------------------------------+ | :index:`ARKODE_ARK436L2SA_ERK_6_3_4` | Use the ARK-6-3-4 ERK method. | @@ -111,7 +113,7 @@ contains the ARKODE output constants. | | (ARKODE_BOGACKI_SHAMPINE_4_2_3). | +-----------------------------------------------+------------------------------------------------------------+ | :index:`ARKSTEP_DEFAULT_ERK_4` | Use ARKStep's default fourth-order ERK method | - | | (ARKODE_ZONNEVELD_5_3_4). | + | | (ARKODE_SOFRONIOU_SPALETTA_5_3_4). | +-----------------------------------------------+------------------------------------------------------------+ | :index:`ARKSTEP_DEFAULT_ERK_5` | Use ARKStep's default fifth-order ERK method | | | (ARKODE_CASH_KARP_6_4_5). | @@ -129,7 +131,7 @@ contains the ARKODE output constants. | | (ARKODE_BOGACKI_SHAMPINE_4_2_3). | +-----------------------------------------------+------------------------------------------------------------+ | :index:`ERKSTEP_DEFAULT_4` | Use ERKStep's default fourth-order ERK method | - | | (ARKODE_ZONNEVELD_5_3_4). | + | | (ARKODE_SOFRONIOU_SPALETTA_5_3_4). | +-----------------------------------------------+------------------------------------------------------------+ | :index:`ERKSTEP_DEFAULT_5` | Use ERKStep's default fifth-order ERK method | | | (ARKODE_CASH_KARP_6_4_5). | @@ -433,7 +435,7 @@ contains the ARKODE output constants. +-------------------------------------+------+------------------------------------------------------------+ | :index:`ARK_INVALID_TABLE` | -41 | An invalid Butcher or MRI table was encountered. | +-------------------------------------+------+------------------------------------------------------------+ - | :index:`ARK_CONTEXT_ERR` | -42 | An error occurred with the SUNDIALS context object | + | :index:`ARK_CONTEXT_ERR` | -42 | An error with the SUNContext object was encountered. | +-------------------------------------+------+------------------------------------------------------------+ | :index:`ARK_RELAX_FAIL` | -43 | An error occurred in computing the relaxation parameter | +-------------------------------------+------+------------------------------------------------------------+ @@ -444,6 +446,11 @@ 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_HEURISTICS_ERR` | -48 | An error with the SUNTimestepHeuristics 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 18bccb9935..9ffc407ba5 100644 --- a/doc/arkode/guide/source/Introduction.rst +++ b/doc/arkode/guide/source/Introduction.rst @@ -133,6 +133,15 @@ Changes from previous versions Changes in vX.X.X ----------------- +Added :c:type:`SUNAdaptController` and :c:type:`SUNTimestepHeuristics` base classes. +Ported ARKODE's internal implementations of time step control and heuristic +constraints into implementations of these classes, and updated ARKODE to use +these objects instead of its own implementations. Added +:c:func:`ARKStepSetAdaptController`, :c:func:`ARKStepSetTimestepHeuristics`, +:c:func:`ERKStepSetAdaptController`, and :c:func:`ERKStepSetTimestepHeuristics` +routines so that users can modify controller/heuristic parameters, or even provide +custom implementations. + Fixed a bug in :c:func:`ARKStepSetTableNum` wherein it did not recognize `ARKODE_ARK2_ERK_3_1_2` and `ARKODE_ARK2_DIRK_3_1_2` as a valid additive Runge--Kutta Butcher table pair. @@ -144,6 +153,14 @@ Fixed scaling bug in ``SUNMatScaleAddI_Sparse`` for non-square matrices. Fixed missing soversions in some ``SUNLinearSolver`` CMake targets. +Changed the default fourth order DIRK method to `ARKODE_ARK436L2SA_DIRK_6_3_4` +for improved accuracy and embedded stability. To revert to the previous default, +use `ARKStepSetTableNum(arkode_mem, ARKODE_SDIRK_5_3_4, ARKODE_ERK_NONE)`. + +Added the ERK method `ARKODE_SOFRONIOU_SPALETTA_5_3_4` which is now the default +fourth order ERK method. To revert to the previous default, use +`ERKStepSetTableNum(arkode_mem, ARKODE_ZONNEVELD_5_3_4)`. + Changes in v5.6.1 ----------------- 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..3b954f7778 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 @@ -1222,6 +1222,13 @@ Set max number of constraint failures :c:func:`ARKStepSetMaxNumConst **Notes:** Pass *hmax* :math:`\le 0.0` to set the default value of :math:`\infty`. + If both this and :c:func:`ARKStepSetTimestepHeuristics` will be called, then this + routine must be called *second*. + + .. deprecated:: x.x.x + + Use the SUNTimestepHeuristics infrastructure instead (see :numref:`SUNTimestepHeuristics.Description`). + .. c:function:: int ARKStepSetMinStep(void* arkode_mem, realtype hmin) @@ -1240,6 +1247,13 @@ Set max number of constraint failures :c:func:`ARKStepSetMaxNumConst **Notes:** Pass *hmin* :math:`\le 0.0` to set the default value of 0. + If both this and :c:func:`ARKStepSetTimestepHeuristics` will be called, then this + routine must be called *second*. + + .. deprecated:: x.x.x + + Use the SUNTimestepHeuristics infrastructure instead (see :numref:`SUNTimestepHeuristics.Description`). + .. c:function:: int ARKStepSetStopTime(void* arkode_mem, realtype tstop) @@ -1691,23 +1705,59 @@ 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 +Provide a :c:type:`SUNTimestepHeuristics` for ARKStep to use :c:func:`ARKStepSetTimestepHeuristics()` 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 +============================================================ ======================================== ======== + + + +.. 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 ARKStepSetTimestepHeuristics(void* arkode_mem, SUNTimestepHeuristics H) + + Sets a user-supplied time-step heuristics constraint object. + + **Arguments:** + * *arkode_mem* -- pointer to the ARKStep memory block. + * *H* -- user-supplied time step heuristic constraint object. If ``NULL`` then the default heuristics object will be created (see :numref:`SUNTimestepHeuristics.Default`). + + **Return value:** + * *ARK_SUCCESS* if successful + * *ARK_MEM_NULL* if the ARKStep memory is ``NULL`` + * *ARK_MEM_FAIL* if *H* was ``NULL`` and the default heuristics object could not be allocated. + + .. versionadded:: x.x.x @@ -1732,6 +1782,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 +1820,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) @@ -1783,6 +1843,13 @@ Explicit stability function :c:func:`ARKStepSetSt Any non-positive parameter will imply a reset to the default value. + If both this and :c:func:`ARKStepSetTimestepHeuristics` will be called, then this + routine must be called *second*. + + .. deprecated:: x.x.x + + Use the SUNTimestepHeuristics infrastructure instead (see :numref:`SUNTimestepHeuristics.Description`). + .. c:function:: int ARKStepSetErrorBias(void* arkode_mem, realtype bias) @@ -1803,6 +1870,14 @@ 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*. + + .. deprecated:: x.x.x + + Use the SUNAdaptController infrastructure instead (see :numref:`SUNAdaptController.Description`). + .. c:function:: int ARKStepSetFixedStepBounds(void* arkode_mem, realtype lb, realtype ub) @@ -1822,6 +1897,13 @@ Explicit stability function :c:func:`ARKStepSetSt **Notes:** Any interval *not* containing 1.0 will imply a reset to the default values. + If both this and :c:func:`ARKStepSetTimestepHeuristics` will be called, then this + routine must be called *second*. + + .. deprecated:: x.x.x + + Use the SUNTimestepHeuristics infrastructure instead (see :numref:`SUNTimestepHeuristics.Description`). + .. c:function:: int ARKStepSetMaxCFailGrowth(void* arkode_mem, realtype etacf) @@ -1843,6 +1925,13 @@ Explicit stability function :c:func:`ARKStepSetSt **Notes:** Any value outside the interval :math:`(0,1]` will imply a reset to the default value. + If both this and :c:func:`ARKStepSetTimestepHeuristics` will be called, then this + routine must be called *second*. + + .. deprecated:: x.x.x + + Use the SUNTimestepHeuristics infrastructure instead (see :numref:`SUNTimestepHeuristics.Description`). + .. c:function:: int ARKStepSetMaxEFailGrowth(void* arkode_mem, realtype etamxf) @@ -1882,6 +1971,13 @@ Explicit stability function :c:func:`ARKStepSetSt **Notes:** Any value :math:`\le 1.0` will imply a reset to the default value. + If both this and :c:func:`ARKStepSetTimestepHeuristics` will be called, then this + routine must be called *second*. + + .. deprecated:: x.x.x + + Use the SUNTimestepHeuristics infrastructure instead (see :numref:`SUNTimestepHeuristics.Description`). + .. c:function:: int ARKStepSetMaxGrowth(void* arkode_mem, realtype mx_growth) @@ -1902,6 +1998,13 @@ Explicit stability function :c:func:`ARKStepSetSt Any value :math:`\le 1.0` will imply a reset to the default value. + If both this and :c:func:`ARKStepSetTimestepHeuristics` will be called, then this + routine must be called *second*. + + .. deprecated:: x.x.x + + Use the SUNTimestepHeuristics infrastructure instead (see :numref:`SUNTimestepHeuristics.Description`). + .. c:function:: int ARKStepSetMinReduction(void* arkode_mem, realtype eta_min) @@ -1924,6 +2027,13 @@ Explicit stability function :c:func:`ARKStepSetSt Any value outside the interval :math:`(0,1)` will imply a reset to the default value. + If both this and :c:func:`ARKStepSetTimestepHeuristics` will be called, then this + routine must be called *second*. + + .. deprecated:: x.x.x + + Use the SUNTimestepHeuristics infrastructure instead (see :numref:`SUNTimestepHeuristics.Description`). + .. c:function:: int ARKStepSetSafetyFactor(void* arkode_mem, realtype safety) @@ -1944,6 +2054,13 @@ Explicit stability function :c:func:`ARKStepSetSt Any value :math:`\le 0` will imply a reset to the default value. + If both this and :c:func:`ARKStepSetTimestepHeuristics` will be called, then this + routine must be called *second*. + + .. deprecated:: x.x.x + + Use the SUNTimestepHeuristics infrastructure instead (see :numref:`SUNTimestepHeuristics.Description`). + .. c:function:: int ARKStepSetSmallNumEFails(void* arkode_mem, int small_nef) @@ -1964,6 +2081,13 @@ Explicit stability function :c:func:`ARKStepSetSt **Notes:** Any value :math:`\le 0` will imply a reset to the default value. + If both this and :c:func:`ARKStepSetTimestepHeuristics` will be called, then this + routine must be called *second*. + + .. deprecated:: x.x.x + + Use the SUNTimestepHeuristics infrastructure instead (see :numref:`SUNTimestepHeuristics.Description`). + .. c:function:: int ARKStepSetStabilityFn(void* arkode_mem, ARKExpStabFn EStab, void* estab_data) @@ -1990,6 +2114,13 @@ Explicit stability function :c:func:`ARKStepSetSt be quite useful for problems where the explicit right-hand side function :math:`f^E(t,y)` contains stiff terms. + If both this and :c:func:`ARKStepSetTimestepHeuristics` will be called, then this + routine must be called *second*. + + .. deprecated:: x.x.x + + Use the SUNTimestepHeuristics infrastructure instead (see :numref:`SUNTimestepHeuristics.Description`). + 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..a15c1665eb 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 @@ -842,6 +842,12 @@ Optional inputs for ERKStep **Notes:** Pass *hmax* :math:`\le 0.0` to set the default value of :math:`\infty`. + If both this and :c:func:`ERKStepSetTimestepHeuristics` will be called, then this + routine must be called *second*. + + .. deprecated:: x.x.x + + Use the SUNTimestepHeuristics infrastructure instead (see :numref:`SUNTimestepHeuristics.Description`). .. c:function:: int ERKStepSetMinStep(void* arkode_mem, realtype hmin) @@ -860,6 +866,12 @@ Optional inputs for ERKStep **Notes:** Pass *hmin* :math:`\le 0.0` to set the default value of 0. + If both this and :c:func:`ERKStepSetTimestepHeuristics` will be called, then this + routine must be called *second*. + + .. deprecated:: x.x.x + + Use the SUNTimestepHeuristics infrastructure instead (see :numref:`SUNTimestepHeuristics.Description`). .. c:function:: int ERKStepSetStopTime(void* arkode_mem, realtype tstop) @@ -1159,33 +1171,72 @@ 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 | - +-----------------------------------------------------------+----------------------------------------+-----------+ - | 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 | + +-----------------------------------------------------------+------------------------------------------+-----------+ + | Provide a :c:type:`SUNTimestepHeuristics` for ERKStep to | :c:func:`ERKStepSetTimestepHeuristics()` | Default | + | use | | | + +-----------------------------------------------------------+------------------------------------------+-----------+ + | 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 | + +-----------------------------------------------------------+------------------------------------------+-----------+ + + + +.. 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 ERKStepSetTimestepHeuristics(void* arkode_mem, SUNTimestepHeuristics H) + + Sets a user-supplied time-step heuristics constraint object. + + **Arguments:** + * *arkode_mem* -- pointer to the ERKStep memory block. + * *H* -- user-supplied time step heuristic constraint object. If ``NULL`` then the default heuristics object will be created (see :numref:`SUNTimestepHeuristics.Default`). + + **Return value:** + * *ARK_SUCCESS* if successful + * *ARK_MEM_NULL* if the ERKStep memory is ``NULL`` + * *ARK_MEM_FAIL* if *H* was ``NULL`` and the default heuristics object could not be allocated. + + .. versionadded:: x.x.x @@ -1210,6 +1261,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 +1298,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) @@ -1261,6 +1320,12 @@ the code, is provided in :numref:`ARKODE.Mathematics.Adaptivity`. Any non-positive parameter will imply a reset to the default value. + If both this and :c:func:`ERKStepSetTimestepHeuristics` will be called, then this + routine must be called *second*. + + .. deprecated:: x.x.x + + Use the SUNTimestepHeuristics infrastructure instead (see :numref:`SUNTimestepHeuristics.Description`). .. c:function:: int ERKStepSetErrorBias(void* arkode_mem, realtype bias) @@ -1281,6 +1346,13 @@ 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*. + + .. deprecated:: x.x.x + + Use the SUNAdaptController infrastructure instead (see :numref:`SUNAdaptController.Description`). .. c:function:: int ERKStepSetFixedStepBounds(void* arkode_mem, realtype lb, realtype ub) @@ -1300,6 +1372,12 @@ the code, is provided in :numref:`ARKODE.Mathematics.Adaptivity`. **Notes:** Any interval *not* containing 1.0 will imply a reset to the default values. + If both this and :c:func:`ERKStepSetTimestepHeuristics` will be called, then this + routine must be called *second*. + + .. deprecated:: x.x.x + + Use the SUNTimestepHeuristics infrastructure instead (see :numref:`SUNTimestepHeuristics.Description`). .. c:function:: int ERKStepSetMaxEFailGrowth(void* arkode_mem, realtype etamxf) @@ -1319,6 +1397,12 @@ the code, is provided in :numref:`ARKODE.Mathematics.Adaptivity`. **Notes:** Any value outside the interval :math:`(0,1]` will imply a reset to the default value. + If both this and :c:func:`ERKStepSetTimestepHeuristics` will be called, then this + routine must be called *second*. + + .. deprecated:: x.x.x + + Use the SUNTimestepHeuristics infrastructure instead (see :numref:`SUNTimestepHeuristics.Description`). .. c:function:: int ERKStepSetMaxFirstGrowth(void* arkode_mem, realtype etamx1) @@ -1339,6 +1423,12 @@ the code, is provided in :numref:`ARKODE.Mathematics.Adaptivity`. **Notes:** Any value :math:`\le 1.0` will imply a reset to the default value. + If both this and :c:func:`ERKStepSetTimestepHeuristics` will be called, then this + routine must be called *second*. + + .. deprecated:: x.x.x + + Use the SUNTimestepHeuristics infrastructure instead (see :numref:`SUNTimestepHeuristics.Description`). .. c:function:: int ERKStepSetMaxGrowth(void* arkode_mem, realtype mx_growth) @@ -1359,6 +1449,12 @@ the code, is provided in :numref:`ARKODE.Mathematics.Adaptivity`. Any value :math:`\le 1.0` will imply a reset to the default value. + If both this and :c:func:`ERKStepSetTimestepHeuristics` will be called, then this + routine must be called *second*. + + .. deprecated:: x.x.x + + Use the SUNTimestepHeuristics infrastructure instead (see :numref:`SUNTimestepHeuristics.Description`). .. c:function:: int ERKStepSetMinReduction(void* arkode_mem, realtype eta_min) @@ -1381,6 +1477,12 @@ the code, is provided in :numref:`ARKODE.Mathematics.Adaptivity`. Any value :math:`\ge 1.0` or :math:`\le 0.0` will imply a reset to the default value. + If both this and :c:func:`ERKStepSetTimestepHeuristics` will be called, then this + routine must be called *second*. + + .. deprecated:: x.x.x + + Use the SUNTimestepHeuristics infrastructure instead (see :numref:`SUNTimestepHeuristics.Description`). .. c:function:: int ERKStepSetSafetyFactor(void* arkode_mem, realtype safety) @@ -1401,6 +1503,12 @@ the code, is provided in :numref:`ARKODE.Mathematics.Adaptivity`. Any non-positive parameter will imply a reset to the default value. + If both this and :c:func:`ERKStepSetTimestepHeuristics` will be called, then this + routine must be called *second*. + + .. deprecated:: x.x.x + + Use the SUNTimestepHeuristics infrastructure instead (see :numref:`SUNTimestepHeuristics.Description`). .. c:function:: int ERKStepSetSmallNumEFails(void* arkode_mem, int small_nef) @@ -1421,6 +1529,12 @@ the code, is provided in :numref:`ARKODE.Mathematics.Adaptivity`. **Notes:** Any non-positive parameter will imply a reset to the default value. + If both this and :c:func:`ERKStepSetTimestepHeuristics` will be called, then this + routine must be called *second*. + + .. deprecated:: x.x.x + + Use the SUNTimestepHeuristics infrastructure instead (see :numref:`SUNTimestepHeuristics.Description`). .. c:function:: int ERKStepSetStabilityFn(void* arkode_mem, ARKExpStabFn EStab, void* estab_data) @@ -1447,6 +1561,12 @@ the code, is provided in :numref:`ARKODE.Mathematics.Adaptivity`. where the right-hand side function :math:`f(t,y)` contains stiff terms. + If both this and :c:func:`ERKStepSetTimestepHeuristics` will be called, then this + routine must be called *second*. + + .. deprecated:: x.x.x + + Use the SUNTimestepHeuristics infrastructure instead (see :numref:`SUNTimestepHeuristics.Description`). diff --git a/doc/arkode/guide/source/index.rst b/doc/arkode/guide/source/index.rst index fd61ab5981..241cac7c41 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,8 @@ with support by the `US Department of Energy `_, sunmatrix/index.rst sunlinsol/index.rst sunnonlinsol/index.rst + sunadaptcontroller/index.rst + suntimestepheuristics/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/arkode/guide/source/suntimestepheuristics/SUNTimestepHeuristics_links.rst b/doc/arkode/guide/source/suntimestepheuristics/SUNTimestepHeuristics_links.rst new file mode 100644 index 0000000000..a0091b994e --- /dev/null +++ b/doc/arkode/guide/source/suntimestepheuristics/SUNTimestepHeuristics_links.rst @@ -0,0 +1,15 @@ +.. ---------------------------------------------------------------- + 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/suntimestepheuristics/SUNTimestepHeuristics_Description.rst +.. include:: ../../../../shared/suntimestepheuristics/SUNTimestepHeuristics_Default.rst +.. include:: ../../../../shared/suntimestepheuristics/SUNTimestepHeuristics_Unconstrained.rst diff --git a/doc/arkode/guide/source/suntimestepheuristics/index.rst b/doc/arkode/guide/source/suntimestepheuristics/index.rst new file mode 100644 index 0000000000..7919bb1fea --- /dev/null +++ b/doc/arkode/guide/source/suntimestepheuristics/index.rst @@ -0,0 +1,30 @@ +.. ---------------------------------------------------------------- + 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 + ---------------------------------------------------------------- + +.. _SUNTimestepHeuristics: + +##################################### +Heuristic Time Step Constraints +##################################### + +The SUNDIALS library comes packaged with a variety of :c:type:`SUNTimestepHeuristics` +implementations, designed to support various forms of heuristic time step +constraints within SUNDIALS time integrators. To support applications that may +want to adjust or disable these heuristic controls, SUNDIALS provides a +:c:type:`SUNTimestepHeuristics` base class, along with two default implementations: a +"default" heuristics control module that encodes standard SUNDIALS heuristic +controls, and an "unconstrained" module that disables these. + +.. toctree:: + :maxdepth: 1 + + SUNTimestepHeuristics_links.rst diff --git a/doc/shared/figs/arkode/sofroniou_spaletta_erk_stab_region.png b/doc/shared/figs/arkode/sofroniou_spaletta_erk_stab_region.png new file mode 100644 index 0000000000..78bd107329 Binary files /dev/null and b/doc/shared/figs/arkode/sofroniou_spaletta_erk_stab_region.png differ diff --git a/doc/shared/sunadaptcontroller/SUNAdaptController_Description.rst b/doc/shared/sunadaptcontroller/SUNAdaptController_Description.rst new file mode 100644 index 0000000000..ae9d17c358 --- /dev/null +++ b/doc/shared/sunadaptcontroller/SUNAdaptController_Description.rst @@ -0,0 +1,502 @@ +.. + ---------------------------------------------------------------- + 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. + :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/shared/sundials/Fortran.rst b/doc/shared/sundials/Fortran.rst index bef4eb5aca..efad018406 100644 --- a/doc/shared/sundials/Fortran.rst +++ b/doc/shared/sundials/Fortran.rst @@ -146,7 +146,7 @@ team. SUNLINSOL_SPFGMR ``fsunlinsol_spfgmr_mod`` SUNLINSOL_SPBCGS ``fsunlinsol_spbcgs_mod`` SUNLINSOL_SPTFQMR ``fsunlinsol_sptfqmr_mod`` - SUNLINSOL_PCG ``fsunlinsol_pcg_mof`` + SUNLINSOL_PCG ``fsunlinsol_pcg_mod`` SUNNONLINSOL ``fsundials_nonlinearsolver_mod`` SUNNONLINSOL_NEWTON ``fsunnonlinsol_newton_mod`` SUNNONLINSOL_FIXEDPOINT ``fsunnonlinsol_fixedpoint_mod`` diff --git a/doc/shared/suntimestepheuristics/SUNTimestepHeuristics_Default.rst b/doc/shared/suntimestepheuristics/SUNTimestepHeuristics_Default.rst new file mode 100644 index 0000000000..2e306a43a7 --- /dev/null +++ b/doc/shared/suntimestepheuristics/SUNTimestepHeuristics_Default.rst @@ -0,0 +1,75 @@ +.. + 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 + ---------------------------------------------------------------- + +.. _SUNTimestepHeuristics.Default: + +The SUNTimestepHeuristics_Default Module +======================================== + +The default implementation of the SUNTimestepHeuristics class, SUNTimestepHeuristics_Default, +implements a myriad of heuristics control features used throughout SUNDIALS +integrators. + +This is implemented as a derived SUNTimestepHeuristics class, and defines its *content* +field as: + +.. code-block:: c + + struct _SUNTimestepHeuristicsContent_Default { + sunrealtype hmax_inv; + sunrealtype hmin; + sunrealtype etamax; + sunrealtype etamx1; + sunrealtype etamxf; + sunrealtype etamin; + int small_nef; + sunrealtype etacf; + SUNExpStabFn expstab; + void* estab_data; + sunrealtype cfl; + sunrealtype safety; + sunrealtype growth; + sunrealtype lbound; + sunrealtype ubound; + long int nst_acc; + long int nst_exp; + }; + +These entries of the *content* field contain parameters to store all options +specified by "set" routines in the base SUNTimestepHeuristics class. The one +non-obvious of these parameters is ``etamax``, that is changed dynamically +throughout the course of a calculation: + +.. math:: + \text{etamax} = \begin{cases} + \text{etamx1 before the first internal step},\\ + \text{growth following each successful internal step},\\ + \text{1 following either a convergence or error test failure}, + \end{cases} + +The header file to be included when using this module is +``suntimestepheuristics/suntimestepheuristics_default.h``. + +The SUNTimestepHeuristics_Default class provides implementations of all controller +operations listed in :numref:`SUNTimestepHeuristics.Description.operations`. The +SUNTimestepHeuristics_Default class also provides the following constructor routine: + +.. c:function:: SUNTimestepHeuristics SUNTimestepHeuristics_Default(SUNContext sunctx) + + This constructor function creates and allocates memory for a + SUNTimestepHeuristics_Default object, and inserts its default parameters. + + :param sunctx: the :c:type:`SUNContext` object (see :numref:`SUNDIALS.SUNContext`). + :returns: If successful, a SUNTimestepHeuristics_Default object. If + unsuccessful, a ``NULL`` pointer will be returned. diff --git a/doc/shared/suntimestepheuristics/SUNTimestepHeuristics_Description.rst b/doc/shared/suntimestepheuristics/SUNTimestepHeuristics_Description.rst new file mode 100644 index 0000000000..b8b2f2d186 --- /dev/null +++ b/doc/shared/suntimestepheuristics/SUNTimestepHeuristics_Description.rst @@ -0,0 +1,655 @@ +.. + ---------------------------------------------------------------- + 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 + ---------------------------------------------------------------- + +.. _SUNTimestepHeuristics.Description: + +The SUNTimestepHeuristics API +============================= + +.. versionadded:: x.x.x + +The SUNTimestepHeuristics base class provides a common API for time step heuristic +constraints that may be applied to step sizes by SUNDIALS integrators. These +heuristics can include a variety of things, including bounds on how much the +time step size can grow or shrink in a single step, absolute maximum and minimum +allowable step sizes, stability-limitations (e.g., CFL) on explicit steps, etc. + +The base ``SUNTimestepHeuristics`` 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 heuristics +operations, and a :c:type:`SUNContext` object. Specifically, the type +``SUNTimestepHeuristics`` is defined as: + +.. c:type:: struct _generic_SUNTimestepHeuristics *SUNTimestepHeuristics + +and the base class structure is defined as + +.. code-block:: C + + struct _generic_SUNTimestepHeuristics { + void* content; + generic_SUNTimestepHeuristics_Ops_* ops; + SUNContext sunctx; + }; + +Here, ``_generic_SUNTimestepHeuristics_Ops`` is the pointer to a structure containing +function pointers to the various heuristics operations, and is defined as + +.. code-block:: c + + struct _generic_SUNTimestepHeuristics_Ops { + + SUNTimestepHeuristics_ID (*getid)(SUNTimestepHeuristics H); + int (*destroy)(SUNTimestepHeuristics H); + int (*constrainstep)(SUNTimestepHeuristics H, sunrealtype hcur, + sunrealtype hnew, sunrealtype *hconstr); + int (*etestfail)(SUNTimestepHeuristics H, sunrealtype hcur, + sunrealtype hnew, int nef, sunrealtype *hconstr); + int (*convfail)(SUNTimestepHeuristics H, sunrealtype hcur, sunrealtype *hconstr); + int (*boundreduction)(SUNTimestepHeuristics H, sunrealtype hcur, + sunrealtype hnew, sunrealtype *hconstr); + int (*boundfirststep)(SUNTimestepHeuristics H, sunrealtype h0, + sunrealtype *h0constr); + int (*reset)(SUNTimestepHeuristics H); + int (*update)(SUNTimestepHeuristics H); + int (*setdefaults)(SUNTimestepHeuristics H); + int (*write)(SUNTimestepHeuristics H, FILE* fptr); + int (*setmaxstep)(SUNTimestepHeuristics H, sunrealtype hmax); + int (*setminstep)(SUNTimestepHeuristics H, sunrealtype hmin); + int (*setexpstabfn)(SUNTimestepHeuristics H, SUNExpStabFn EStab, + void* estab_data); + int (*setcflfraction)(SUNTimestepHeuristics H, sunrealtype cfl_frac); + int (*setsafetyfactor)(SUNTimestepHeuristics H, sunrealtype safety); + int (*setmaxgrowth)(SUNTimestepHeuristics H, sunrealtype mx_growth); + int (*setminreduction)(SUNTimestepHeuristics H, sunrealtype eta_min); + int (*setfixedstepbounds)(SUNTimestepHeuristics H, sunrealtype lb, sunrealtype ub); + int (*setmaxfirstgrowth)(SUNTimestepHeuristics H, sunrealtype etamx1); + int (*setmaxefailgrowth)(SUNTimestepHeuristics H, sunrealtype etamxf); + int (*setsmallnumefails)(SUNTimestepHeuristics H, int small_nef); + int (*setmaxcfailgrowth)(SUNTimestepHeuristics H, sunrealtype etacf); + int (*getnumexpsteps)(SUNTimestepHeuristics H, long int* expsteps); + int (*getnumaccsteps)(SUNTimestepHeuristics H, long int* accsteps); + int (*space)(SUNTimestepHeuristics H, long int *lenrw, long int *leniw); + }; + +.. _SUNTimestepHeuristics.Description.heuristicsIDs: + +SUNTimestepHeuristics Type Definitions +-------------------------------------- + +The time integrators in SUNDIALS leverage a myriad of heuristics to achieve +accurate and efficient computations; however, most follow a rather standard +pattern, or request no heuristic control whatsoever. Therefore, each +SUNTimestepHeuristics implementation should indicate its type, informing the integrators +of whether they perform heuristic control or not: + +.. c:enum:: SUNTimestepHeuristics_ID + + The enumerated type :c:type:`SUNTimestepHeuristics_ID` defines the enumeration + constants for SUNDIALS heuristics implementations + +.. c:enumerator:: SUN_TIMESTEPHEURISTICS_STD + + Performs "standard" heuristic stepsize constraints. + +.. c:enumerator:: SUN_TIMESTEPHEURISTICS_NULL + + Performs no heuristic constraints. + + + +Additionally, if the heuristics object can be used to limit stepsizes based on +explicit stability, then we define the following user-supplied function type: + +.. c:type:: int (*SUNExpStabFn)(sunrealtype *hstab, void *user_data) + + This function predicts a maximum stable step size. + + :param hstab: (output) the absolute value of the maximum stable step size. + :param user_data: a pointer to user data for evaluation. + :return: a *SUNExpStabFn* function should return 0 if it is successful, and a + non-zero value otherwise. + + + + +.. _SUNTimestepHeuristics.Description.operations: + +SUNTimestepHeuristics Operations +-------------------------------- + +The base SUNTimestepHeuristics class defines and implements all SUNTimestepHeuristics functions. +Most of these routines are merely wrappers for the operations defined by a +particular SUNTimestepHeuristics implementation, which are accessed through the *ops* +field of the ``SUNTimestepHeuristics`` structure. However, the base SUNTimestepHeuristics class +also provides the convenience routine + +.. c:function:: SUNTimestepHeuristics SUNTimestepHeuristics_NewEmpty(SUNContext sunctx) + + This function allocates a new generic ``SUNTimestepHeuristics`` 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:`SUNTimestepHeuristics` object. If + unsuccessful, a ``NULL`` pointer will be returned. + + +Each of the following routines are *optional* for any specific SUNTimestepHeuristics implementation. + + +.. c:function:: SUNTimestepHeuristics_ID SUNTimestepHeuristics_GetID(SUNTimestepHeuristics H) + + Returns the type identifier for the heuristics object *H*. Returned values + are given in Section :numref:`SUNTimestepHeuristics.Description.heuristicsIDs` + + :param H: the :c:type:`SUNTimestepHeuristics` object. + :return: :c:type:`SUNTimestepHeuristics_ID` type identifier. + + Usage: + + .. code-block:: c + + SUNTimestepHeuristics_ID id = SUNTimestepHeuristics_GetID(H); + +.. c:function:: int SUNTimestepHeuristics_Destroy(SUNTimestepHeuristics H) + + Deallocates the heuristics object *H*. 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 an heuristic implementation + performs dynamic memory allocation of its own (note that the + SUNDIALS-provided SUNTimestepHeuristics implementations do not need to supply this + routine). + + :param H: the :c:type:`SUNTimestepHeuristics` object. + :return: error code indicating success failure (see + :numref:`SUNTimestepHeuristics.Description.errorCodes`). + + Usage: + + .. code-block:: c + + retval = SUNTimestepHeuristics_Destroy(H); + +.. c:function:: int SUNTimestepHeuristics_ConstrainStep(SUNTimestepHeuristics H, sunrealtype hcur, sunrealtype hnew, sunrealtype* hconstr) + + Main constraint-application function. This will attempt to change the step + *hcur* to *hnew*, applying any heuristic bounds on the step size adjustments. + + :param H: the :c:type:`SUNTimestepHeuristics` object. + :param H: the heuristics object. + :param hcur: the step size from the previous step attempt. + :param hnew: the requested step size for the upcoming step attempt. + :param hconstr: (output) pointer to the constrained step size. + :return: error code indicating success failure (see + :numref:`SUNTimestepHeuristics.Description.errorCodes`). + + Usage: + + .. code-block:: c + + retval = SUNTimestepHeuristics_ConstrainStep(H, hcur, hnew, &hnew); + +.. c:function:: int SUNTimestepHeuristics_ETestFail(SUNTimestepHeuristics H, sunrealtype hcur, sunrealtype hnew, int nef, sunrealtype* hconstr) + + Function to apply constraints following a step with unacceptable temporal + error. + + :param H: the heuristics object. + :param hcur: the step size that led to the error test failure. + :param hnew: the requested step size for the upcoming step attempt (e.g., + from a :c:type:`SUNAdaptController` object). + :param nef: the integrator-provided counter of how many temporal error test + failures have occurred on this time step. + :param hconstr: (output) pointer to the constrained step size. + :return: error code indicating success failure (see + :numref:`SUNTimestepHeuristics.Description.errorCodes`). + + Usage: + + .. code-block:: c + + retval = SUNTimestepHeuristics_ETestFail(H, hcur, hnew, nef, &hnew); + +.. c:function:: int SUNTimestepHeuristics_BoundReduction(SUNTimestepHeuristics H, sunrealtype hcur, sunrealtype hnew, sunrealtype *hconstr) + + This ensures that a step size reduction is within user-prescribed bounds. + + :param H: the heuristics object. + :param hcur: the step size from the previous step attempt. + :param hnew: the requested step size for the upcoming step attempt (e.g., + from a :c:type:`SUNAdaptController` object). + :param hconstr: (output) pointer to the constrained step size. + :return: + * *SUNTIMESTEPHEURISTICS_SUCCESS* if successful + * *SUNTIMESTEPHEURISTICS_CANNOT_DECREASE* if a reduction is requested but no + reduction is possible + + Usage: + + .. code-block:: c + + retval = SUNTimestepHeuristics_BoundReduction(H, hcur, hnew, &hnew); + +.. c:function:: int SUNTimestepHeuristics_BoundFirstStep(SUNTimestepHeuristics H, sunrealtype h0, sunrealtype *h0constr) + + This bounds the initial step by user-provided min/max step values. + + :param H: the heuristics object. + :param h0: the requested initial step size. + :param h0constr: (output) pointer to the constrained initial step size. + :return: error code indicating success failure (see + :numref:`SUNTimestepHeuristics.Description.errorCodes`). + + Usage: + + .. code-block:: c + + retval = SUNTimestepHeuristics_BoundFirstStep(H, h0, &h0); + +.. c:function:: int SUNTimestepHeuristics_ConvFail(SUNTimestepHeuristics H, sunrealtype hcur, sunrealtype *hconstr) + + Function to apply constraints following a step with an algebraic solver + convergence failure. + + :param H: the heuristics object. + :param hcur: the step size that led to the convergence failure. + :param hconstr: (output) pointer to the constrained step size. + :return: error code indicating success failure (see + :numref:`SUNTimestepHeuristics.Description.errorCodes`). + + Usage: + + .. code-block:: c + + retval = SUNTimestepHeuristics_ConvFail(H, hcur, &hnew); + +.. c:function::int SUNTimestepHeuristics_Reset(SUNTimestepHeuristics H) + + Function to reset the heuristics to its initial state: zeros any internal + counters, and resets any stepsize growth factor bounds. + + :param H: the heuristics object. + :return: error code indicating success failure (see + :numref:`SUNTimestepHeuristics.Description.errorCodes`). + + Usage: + + .. code-block:: c + + retval = SUNTimestepHeuristics_Reset(H); + +.. c:function::int SUNTimestepHeuristics_Update(SUNTimestepHeuristics H) + + Function to notify the heuristics object that a time step has succeeded, + indicating e.g. that the stepsize growh factor should should be set to its + "default" state. + + :param H: the heuristics object. + :return: error code indicating success failure (see + :numref:`SUNTimestepHeuristics.Description.errorCodes`). + + Usage: + + .. code-block:: c + + retval = SUNTimestepHeuristics_Update(H); + +.. c:function::int SUNTimestepHeuristics_SetDefaults(SUNTimestepHeuristics H) + + Function to set the heuristics parameters to their default values. + + :param H: the heuristics object. + :return: error code indicating success failure (see + :numref:`SUNTimestepHeuristics.Description.errorCodes`). + + Usage: + + .. code-block:: c + + retval = SUNTimestepHeuristics_SetDefaults(H); + +.. c:function::int SUNTimestepHeuristics_Write(SUNTimestepHeuristics H, FILE* fptr) + + Writes all controller parameters to the indicated file pointer. + + :param H: the heuristics object. + :param fptr: the output stream to write the parameters. + :return: error code indicating success failure (see + :numref:`SUNTimestepHeuristics.Description.errorCodes`). + + Usage: + + .. code-block:: c + + retval = SUNTimestepHeuristics_Write(H, stdout); + +.. c:function::int SUNTimestepHeuristics_SetMaxStep(SUNTimestepHeuristics H, sunrealtype hmax) + + Function to inform the heuristics object about a maximum allowed absolute + step size. + + :param H: the heuristics object. + :param hmax: maximum absolute step size allowed (:math:`\text{hmax} \le 0` + implies :math:`\text{hmax}=\infty`). + :return: error code indicating success failure (see + :numref:`SUNTimestepHeuristics.Description.errorCodes`). + + Usage: + + .. code-block:: c + + retval = SUNTimestepHeuristics_SetMaxStep(H, 1.0e-2); + +.. c:function::int SUNTimestepHeuristics_SetMinStep(SUNTimestepHeuristics H, sunrealtype hmin) + + Function to inform the heuristics object about a minimum allowed absolute + step size. + + :param H: the heuristics object. + :param hmin: minimum absolute step size allowed (:math:`\text{hmin} \le 0` + implies no minimum). + :return: error code indicating success failure (see + :numref:`SUNTimestepHeuristics.Description.errorCodes`). + + Usage: + + .. code-block:: c + + retval = SUNTimestepHeuristics_SetMinStep(H, 1.0e-5); + +.. c:function::int SUNTimestepHeuristics_SetExpStabFn(SUNTimestepHeuristics H, SUNExpStabFn EStab, void* estab_data) + + Function to provide a user-supplied function for the maximum stable step + size. + + :param H: the heuristics object. + :param EStab: user-supplied function specifying the maximum stable step size + (``EStab == NULL`` disables). + :param estab_data: user-supplied data pointer that should be provided on all + calls to *EStab*. + :return: error code indicating success failure (see + :numref:`SUNTimestepHeuristics.Description.errorCodes`). + + Usage: + + .. code-block:: c + + retval = SUNTimestepHeuristics_SetExpStabFn(H, CFLStabilityBound, (void*) (&mystruct)); + +.. c:function::int SUNTimestepHeuristics_SetCFLFraction(SUNTimestepHeuristics H, sunrealtype cfl_frac) + + Function to set a CFL safety factor that should be applied to the outputs of + *EStab*, above. + + :param H: the heuristics object. + :param cfl_frac: safety factor. Allowable values must be within the open + interval (0,1), :math:`\text{cfl\_frac} \le 0` implies a + reset to the default value. + :return: error code indicating success failure (see + :numref:`SUNTimestepHeuristics.Description.errorCodes`). + + Usage: + + .. code-block:: c + + retval = SUNTimestepHeuristics_SetCFLFraction(H, 0.5); + +.. c:function::int SUNTimestepHeuristics_SetSafetyFactor(SUNTimestepHeuristics C, sunrealtype safety) + + Function to set a step size safety factor that should be used to constrain an + error-controller-recommended step size. + + :param H: the heuristics object. + :param safety: safety factor. Allowable values must be within the open + interval (0,1), :math:`\text{safety} \le 0` implies a reset + to the default value. + :return: error code indicating success failure (see + :numref:`SUNTimestepHeuristics.Description.errorCodes`). + + Usage: + + .. code-block:: c + + retval = SUNTimestepHeuristics_SetSafetyFactor(H, 0.95); + +.. c:function::int SUNTimestepHeuristics_SetMaxGrowth(SUNTimestepHeuristics H, sunrealtype mx_growth) + + Function to set maximum stepsize growth factor for general steps. + + :param H: the heuristics object. + :param mx_growth: maximum step size growth factor. Allowable values must be + greater than 1; illegal values imply a reset to the + default. + :return: error code indicating success failure (see + :numref:`SUNTimestepHeuristics.Description.errorCodes`). + + **Notes:** + The first step uses a separate maximum growth factor. + + .. code-block:: c + + retval = SUNTimestepHeuristics_SetMaxGrowth(H, 20.0); + +.. c:function::int SUNTimestepHeuristics_SetMaxFirstGrowth(SUNTimestepHeuristics H, sunrealtype etamx1) + + Function to set maximum stepsize growth factor for the first internal time + step. + + :param H: the heuristics object. + :param etamx1: maximum first step size growth factor. Allowable values must + be greater than 1; illegal values imply a reset to the + default. + :return: error code indicating success failure (see + :numref:`SUNTimestepHeuristics.Description.errorCodes`). + + Usage: + + .. code-block:: c + + retval = SUNTimestepHeuristics_SetMaxFirstGrowth(H, 10000.0); + +.. c:function::int SUNTimestepHeuristics_SetFixedStepBounds(SUNTimestepHeuristics H, sunrealtype lb, sunrealtype ub) + + Function to specify the step size growth interval within which the step size + will remain unchanged. Allowable values must enclose the value 1.0. Any + illegal interval implies a reset to the default. + + :param H: the heuristics object. + :param lb: interval lower bound. + :param ub: interval upper bound. + :return: error code indicating success failure (see + :numref:`SUNTimestepHeuristics.Description.errorCodes`). + + Usage: + + .. code-block:: c + + retval = SUNTimestepHeuristics_SetFixedStepBounds(H, 1.0, 1.5); + +.. c:function::int SUNTimestepHeuristics_SetMinReduction(SUNTimestepHeuristics H, sunrealtype eta_min) + + Function to set a lower bound for the stepsize adjustment factor following a + temporal error failure. + + :param H: the heuristics object. + :param eta_min: minimum step size reduction factor. Allowable values must be + in the open interval (0,1); illegal values imply a reset to + the default. + :return: error code indicating success failure (see + :numref:`SUNTimestepHeuristics.Description.errorCodes`). + + Usage: + + .. code-block:: c + + retval = SUNTimestepHeuristics_SetMinReduction(H, 1.0e-2); + +.. c:function::int SUNTimestepHeuristics_SetMaxEFailGrowth(SUNTimestepHeuristics H, sunrealtype etamxf) + + Function to set an upper bound for the stepsize adjustment factor following a + temporal error failure (once at least *small_nef* failures have occurred, see + :c:func:`SUNTimestepHeuristics_SetSmallNumEFails`). + + :param H: the heuristics object. + :param etamxf: temporal error failure step size reduction factor. Allowable + values must be in the interval (0,1]; illegal values imply a + reset to the default. + :return: error code indicating success failure (see + :numref:`SUNTimestepHeuristics.Description.errorCodes`). + + Usage: + + .. code-block:: c + + retval = SUNTimestepHeuristics_SetMaxEFailGrowth(H, 0.8); + +.. c:function::int SUNTimestepHeuristics_SetSmallNumEFails(SUNTimestepHeuristics H, int small_nef) + + Function to specify the step adaptivity constant *small_nef* (see + :c:func:`SUNTimestepHeuristics_SetMaxEFailGrowth`). + + :param H: the heuristics object. + :param small_nef: minimum number of error test failures before *etamxf* takes + effect. Allowable values are greater than 0. Illegal + values imply a reset to the default. + :return: error code indicating success failure (see + :numref:`SUNTimestepHeuristics.Description.errorCodes`). + + Usage: + + .. code-block:: c + + retval = SUNTimestepHeuristics_SetSmallNumEFails(H, 3); + +.. c:function::int SUNTimestepHeuristics_SetMaxCFailGrowth(SUNTimestepHeuristics H, sunrealtype etacf) + + Function to specify an upper bound for the stepsize adjustment factor + following an algebraic solver convergence failure. + + :param H: the heuristics object. + :param etacf: convergence failure step adjustment factor. Allowable values + must be in the interval (0,1]; illegal values imply a reset to + the default. + :return: error code indicating success failure (see + :numref:`SUNTimestepHeuristics.Description.errorCodes`). + + Usage: + + .. code-block:: c + + retval = SUNTimestepHeuristics_SetMaxCFailGrowth(H, 0.3); + +.. c:function::int SUNTimestepHeuristics_GetNumExpSteps(SUNTimestepHeuristics H, long int* expsteps) + + Function to return the current number of stability-limited steps. + + :param H: the heuristics object. + :param expsteps: (output) pointer to hold the stability-limited step counter. + :return: error code indicating success failure (see + :numref:`SUNTimestepHeuristics.Description.errorCodes`). + + Usage: + + .. code-block:: c + + retval = SUNTimestepHeuristics_GetNumExpSteps(H, &expsteps); + +.. c:function::int SUNTimestepHeuristics_GetNumAccSteps(SUNTimestepHeuristics H, long int* accsteps) + + Function to return the current number of accuracy-limited steps. + + :param H: the heuristics object. + :param expsteps: (output) pointer to hold the accuracy-limited step counter. + :return: error code indicating success failure (see + :numref:`SUNTimestepHeuristics.Description.errorCodes`). + + Usage: + + .. code-block:: c + + retval = SUNTimestepHeuristics_GetNumAccSteps(H, &accsteps); + +.. c:function:: int SUNTimestepHeuristics_Space(SUNTimestepHeuristics H, long int *lenrw, long int *leniw) + + Informative routine that returns the memory requirements of the heuristics object. + + :param H: the heuristics object. + :param lenrw: (output) number of ``sunrealtype`` words stored in the + heuristics object. + :param leniw: (output) number of ``sunindextype`` words stored in the + heuristics object. This may also include pointers, `int` and + `long int` words. + :return: error code indicating success failure (see + :numref:`SUNTimestepHeuristics.Description.errorCodes`). + + Usage: + + .. code-block:: c + + retval = SUNTimestepHeuristics_Space(H, &lenrw, &leniw); + + + +.. _SUNTimestepHeuristics.Description.errorCodes: + +SUNTimestepHeuristics Error Codes +------------------------- + +SUNTimestepHeuristics functions return one of the following set of error codes: + +* ``SUNTIMESTEPHEURISTICS_SUCCESS`` (0) -- successful call. + +* ``SUNTIMESTEPHEURISTICS_ILL_INPUT`` (-1101) -- an illegal input has been provided to + the function. + +* ``SUNTIMESTEPHEURISTICS_CANNOT_DECREASE`` (-1102) -- a step reduction was required but + was not possible (already at minimum). + +* ``SUNTIMESTEPHEURISTICS_USER_FCN_FAIL`` (-1103) -- a user-supplied function returned a + nonzero [error] value. + + +C/C++ API Usage +--------------- + +The SUNDIALS Heuristics module can be used in C and C++ programs by including +the header file ``sundials/sundials_timestepheuristics.h``. + +Example usage (here ``SUNTimestepHeuristicsXYZ`` is a placeholder for an actual +SUNTimestepHeuristics implementation constructor): + +.. code-block:: c + + #include + #include + #include + #include + #include + + int main() + { + /* Create a SUNContext object */ + SUNContext sunctx = ...; + + /* Create a SUNTimestepHeuristics object */ + SUNTimestepHeuristics H = SUNTimestepHeuristicsXYZ(sunctx); + + /* Use the heuristics object */ + + /* Destroy the heuristics object */ + retval = SUNTimestepHeuristics_Destroy(C); + + return 0; + } diff --git a/doc/shared/suntimestepheuristics/SUNTimestepHeuristics_Unconstrained.rst b/doc/shared/suntimestepheuristics/SUNTimestepHeuristics_Unconstrained.rst new file mode 100644 index 0000000000..f07a84356e --- /dev/null +++ b/doc/shared/suntimestepheuristics/SUNTimestepHeuristics_Unconstrained.rst @@ -0,0 +1,68 @@ +.. + 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 + ---------------------------------------------------------------- + +.. _SUNTimestepHeuristics.Unconstrained: + +The SUNTimestepHeuristics_Unconstrained Module +============================================== + +We provide an "unconstrained" implementation of the SUNTimestepHeuristics class, +SUNTimestepHeuristics_Unconstrained. While this object may indeed be called by +integrators, it implements essentially no heuristics constraints on the step +size. + +This is implemented as a derived SUNTimestepHeuristics class, and defines its *content* +field as: + +.. code-block:: c + + struct _SUNTimestepHeuristicsContent_Unconstrained { long int nst_acc; }; + +Note that the only entry in the *content* field is a counter, that keeps track +of the number of calls made to its :c:func:`SUNTimestepHeuristicsConstrainStep` routine. +Since this class implements essentially no heuristic time step control, it +relies on the base class implementation for most of the operations from +:numref:`SUNTimestepHeuristics.Description.operations`, with a few notable exceptions. + +* It self-identifies as having :c:type:`SUNTimestepHeuristics_ID` type as + ``SUN_TIMESTEPHEURISTICS_NULL``. + +* At each call to :c:func:`SUNTimestepHeuristics_ConstrainStep` it updates the + ``nst_acc`` counter and sets the "constrained" step to be the same value as + what was requested. + +* Its :c:func:`SUNTimestepHeuristics_ConvFail` routine does not adjust the input step + size, and returns the failure code ``SUNTIMESTEPHEURISTICS_CANNOT_DECREASE``. + +* Its :c:func:`SUNTimestepHeuristics_Reset` routine resets ``nst_acc`` to zero. + +* Its :c:func:`SUNTimestepHeuristics_Write`, :c:func:`SUNTimestepHeuristics_GetNumAccSteps` and + :c:func:`SUNTimestepHeuristics_Space` routines perform as expected, given the class' + storage of the ``nst_acc`` counter. + +The header file to be included when using this module is +``suntimestepheuristics/suntimestepheuristics_unconstrained.h``. + +In addition to the routines mentioned above, the SUNTimestepHeuristics_Unconstrained +class provides the following constructor routine: + +.. c:function:: SUNTimestepHeuristics SUNTimestepHeuristics_Unconstrained(SUNContext sunctx) + + This constructor function creates and allocates memory for a + SUNTimestepHeuristics_Unconstrained object, and initializes its ``nst_acc`` counter + to zero. + + :param sunctx: the :c:type:`SUNContext` object (see :numref:`SUNDIALS.SUNContext`). + :returns: If successful, a SUNTimestepHeuristics_Unconstrained object. If + unsuccessful, a ``NULL`` pointer will be returned. 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..438214e623 100644 --- a/doc/superbuild/source/index.rst +++ b/doc/superbuild/source/index.rst @@ -39,6 +39,8 @@ SUNDIALS is developed on `GitHub `_. sunmatrix/index.rst sunlinsol/index.rst sunnonlinsol/index.rst + sunadaptcontroller/index.rst + suntimestepheuristics/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..e305ca98f7 --- /dev/null +++ b/doc/superbuild/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/superbuild/source/sunadaptcontroller/index.rst b/doc/superbuild/source/sunadaptcontroller/index.rst new file mode 100644 index 0000000000..3f1cc77539 --- /dev/null +++ b/doc/superbuild/source/sunadaptcontroller/index.rst @@ -0,0 +1,18 @@ +.. + 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 + ---------------------------------------------------------------- + +.. toctree:: + :maxdepth: 1 + + SUNAdaptController_links.rst diff --git a/doc/superbuild/source/suntimestepheuristics/SUNTimestepHeuristics_links.rst b/doc/superbuild/source/suntimestepheuristics/SUNTimestepHeuristics_links.rst new file mode 100644 index 0000000000..32f6936b4a --- /dev/null +++ b/doc/superbuild/source/suntimestepheuristics/SUNTimestepHeuristics_links.rst @@ -0,0 +1,15 @@ +.. ---------------------------------------------------------------- + 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/suntimestepheuristics/SUNTimestepHeuristics_Description.rst +.. include:: ../../../shared/suntimestepheuristics/SUNTimestepHeuristics_Default.rst +.. include:: ../../../shared/suntimestepheuristics/SUNTimestepHeuristics_Unconstrained.rst diff --git a/doc/superbuild/source/suntimestepheuristics/index.rst b/doc/superbuild/source/suntimestepheuristics/index.rst new file mode 100644 index 0000000000..617523f2ae --- /dev/null +++ b/doc/superbuild/source/suntimestepheuristics/index.rst @@ -0,0 +1,18 @@ +.. + 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 + ---------------------------------------------------------------- + +.. toctree:: + :maxdepth: 1 + + SUNTimestepHeuristics_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..b8583a325a 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): @@ -714,7 +718,7 @@ int main(int argc, char* argv[]) { case(0): ARKStepFree(&arkode_mem); - break; + break; case(1): { void* inner_arkode_mem = NULL; @@ -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..1af562b53f 100644 --- a/examples/arkode/CXX_parallel/ark_heat2D_p.cpp +++ b/examples/arkode/CXX_parallel/ark_heat2D_p.cpp @@ -273,12 +273,13 @@ 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 + 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 + 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 @@ -574,13 +582,14 @@ int main(int argc, char* argv[]) if ((udata->diagnostics || udata->lsinfo) && outproc) 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; - SUNContext_Free(&ctx); // Free context - flag = MPI_Finalize(); // Finalize MPI + (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..2be680371c 100644 --- a/examples/arkode/CXX_parhyp/ark_heat2D_hypre_ls.cpp +++ b/examples/arkode/CXX_parhyp/ark_heat2D_hypre_ls.cpp @@ -356,13 +356,14 @@ 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 - SUNMatrix A = NULL; // matrix for Jacobian - SUNLinearSolver LS = NULL; // linear solver memory structure - void *arkode_mem = NULL; // ARKODE memory structure - FILE *diagfp = NULL; // diagnostics output file + int flag; // reusable error-checking flag + UserData *udata = NULL; // user data structure + N_Vector u = NULL; // vector for storing solution + SUNMatrix A = NULL; // matrix for Jacobian + 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 @@ -624,14 +632,15 @@ int main(int argc, char* argv[]) if (udata->diagnostics && outproc) fclose(diagfp); - ARKStepFree(&arkode_mem); // Free integrator memory - SUNLinSolFree(LS); // Free linear solver - SUNMatDestroy(A); // Free matrix - N_VDestroy(u); // Free vectors - FreeUserData(udata); // Free user data + ARKStepFree(&arkode_mem); // Free integrator memory + SUNLinSolFree(LS); // Free linear solver + SUNMatDestroy(A); // Free matrix + N_VDestroy(u); // Free vectors + FreeUserData(udata); // Free user data delete udata; - SUNContext_Free(&ctx); // Free context - flag = MPI_Finalize(); // Finalize MPI + (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..4219f9b597 100644 --- a/examples/arkode/CXX_parhyp/ark_heat2D_hypre_pfmg.cpp +++ b/examples/arkode/CXX_parhyp/ark_heat2D_hypre_pfmg.cpp @@ -316,12 +316,13 @@ 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 + 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 + 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 @@ -627,13 +635,14 @@ int main(int argc, char* argv[]) if ((udata->diagnostics || udata->lsinfo) && outproc) 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; - SUNContext_Free(&ctx); // Free context - flag = MPI_Finalize(); // Finalize MPI + (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..f602646bda 100644 --- a/examples/arkode/CXX_parhyp/ark_heat2D_hypre_pfmg_imex.cpp +++ b/examples/arkode/CXX_parhyp/ark_heat2D_hypre_pfmg_imex.cpp @@ -315,9 +315,10 @@ static int check_flag(void *flagvalue, const string funcname, int opt); int main(int argc, char* argv[]) { int flag; // reusable error-checking flag - N_Vector u = NULL; // vector for storing solution - SUNLinearSolver LS = NULL; // linear solver memory structure - void *arkode_mem = NULL; // ARKode memory structure + 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 @@ -534,10 +542,11 @@ int main(int argc, char* argv[]) // Clean up and return // -------------------- - ARKStepFree(&arkode_mem); // Free integrator memory - SUNLinSolFree(LS); // Free linear solver - N_VDestroy(u); // Free vectors - FreeUserData(&udata); // Free user data + ARKStepFree(&arkode_mem); // Free integrator memory + 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_analytic_sys.out b/examples/arkode/CXX_serial/ark_analytic_sys.out index 5ac8dbdf0d..92476fe472 100644 --- a/examples/arkode/CXX_serial/ark_analytic_sys.out +++ b/examples/arkode/CXX_serial/ark_analytic_sys.out @@ -6,9 +6,9 @@ Analytical ODE test problem: t y0 y1 y2 -------------------------------------- - 0.0050 0.70328 0.70627 0.41005 + 0.0050 0.70327 0.70627 0.41004 0.0100 0.52267 0.52865 0.05232 - 0.0150 0.41249 0.42145 -0.16456 + 0.0150 0.41249 0.42145 -0.16455 0.0200 0.34504 0.35697 -0.29600 0.0250 0.30350 0.31838 -0.37562 0.0300 0.27767 0.29551 -0.42382 @@ -19,12 +19,12 @@ Analytical ODE test problem: -------------------------------------- Final Solver Statistics: - Internal solver steps = 67 (attempted = 69) - Total RHS evals: Fe = 0, Fi = 693 - Total linear solver setups = 22 + Internal solver steps = 31 (attempted = 33) + Total RHS evals: Fe = 0, Fi = 366 + Total linear solver setups = 14 Total RHS evals for setting up the linear system = 0 Total number of Jacobian evaluations = 3 - Total number of Newton iterations = 345 + Total number of Newton iterations = 165 Total number of linear solver convergence failures = 0 Total number of error test failures = 2 diff --git a/examples/arkode/CXX_serial/ark_heat2D.cpp b/examples/arkode/CXX_serial/ark_heat2D.cpp index 3a78042a25..178523f6bb 100644 --- a/examples/arkode/CXX_serial/ark_heat2D.cpp +++ b/examples/arkode/CXX_serial/ark_heat2D.cpp @@ -202,12 +202,13 @@ 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 + 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 + SUNAdaptController C = NULL; // Adaptivity controller + FILE *diagfp = NULL; // diagnostics output file // Timing variables chrono::time_point t1; @@ -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 @@ -479,12 +487,13 @@ 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; - SUNContext_Free(&ctx); // Free context + (void) SUNAdaptController_Destroy(C); // Free time adaptivity controller + SUNContext_Free(&ctx); // Free context return 0; } diff --git a/examples/arkode/CXX_serial/ark_kpr_Mt.cpp b/examples/arkode/CXX_serial/ark_kpr_Mt.cpp index 53a6e56ec5..251a06163f 100644 --- a/examples/arkode/CXX_serial/ark_kpr_Mt.cpp +++ b/examples/arkode/CXX_serial/ark_kpr_Mt.cpp @@ -84,6 +84,7 @@ #include // def. math fcns, 'realtype' #include // Newton nonlinear solver #include // fixed-point nonlinear solver +#include // heuristic stepsize constraints #if defined(SUNDIALS_EXTENDED_PRECISION) #define GSYM "Lg" @@ -162,6 +163,7 @@ int main(int argc, char *argv[]) SUNLinearSolver LS = NULL; // empty system linear solver object SUNLinearSolver MLS = NULL; // empty mass linear solver object SUNNonlinearSolver NLS = NULL; // empty nonlinear solver object + SUNTimestepHeuristics H = NULL; // empty heuristics object UserData udata; // user-data structure udata.G = RCONST(-100.0); // stiffness parameter udata.g = RCONST(10.0); // mass matrix parameter @@ -291,8 +293,12 @@ int main(int argc, char *argv[]) // Set maximum stepsize for ERK run if (rk_type == 2) { - retval = ARKStepSetMaxStep(arkode_mem, ONE/SUNRabs(udata.G)); - if (check_retval(&retval, "ARKStepSetMaxStep", 1)) return(1); + H = SUNTimestepHeuristics_Default(ctx); + if (check_retval((void *)H, "SUNTimestepHeuristics_Default", 0)) return 1; + retval = SUNTimestepHeuristics_SetMaxStep(H, ONE/SUNRabs(udata.G)); + if (check_retval(&retval, "SUNTimestepHeuristics_SetMaxStep", 1)) return(1); + retval = ARKStepSetTimestepHeuristics(arkode_mem, H); + if (check_retval(&retval, "ARKStepSetTimestepHeuristics", 1)) return(1); } // Initialize/attach mass matrix solver @@ -328,13 +334,14 @@ int main(int argc, char *argv[]) // Clean up and return - ARKStepFree(&arkode_mem); // Free integrator memory - SUNLinSolFree(LS); // free system linear solver - SUNLinSolFree(MLS); // free mass linear solver - SUNNonlinSolFree(NLS); // free nonlinear solver - SUNMatDestroy(A); // free system matrix - SUNMatDestroy(M); // free mass matrix - N_VDestroy(y); // Free y vector + ARKStepFree(&arkode_mem); // Free integrator memory + SUNLinSolFree(LS); // free system linear solver + SUNLinSolFree(MLS); // free mass linear solver + SUNNonlinSolFree(NLS); // free nonlinear solver + SUNMatDestroy(A); // free system matrix + SUNMatDestroy(M); // free mass matrix + N_VDestroy(y); // Free y vector + (void) SUNTimestepHeuristics_Destroy(H); // Free timestep heuristics object return 0; } diff --git a/examples/arkode/CXX_serial/ark_kpr_Mt_1_4.out b/examples/arkode/CXX_serial/ark_kpr_Mt_1_4.out index f50c73b72e..c798c20c38 100644 --- a/examples/arkode/CXX_serial/ark_kpr_Mt_1_4.out +++ b/examples/arkode/CXX_serial/ark_kpr_Mt_1_4.out @@ -12,117 +12,117 @@ Nonlinear Kvaerno-Prothero-Robinson test problem with mass matrix: t u v uerr verr ------------------------------------------------------ -3.000000 0.710636 1.363407 0.00e+00 0.00e+00 - -2.900000 0.717208 1.327305 9.30e-05 3.72e-04 - -2.800000 0.727268 1.290371 2.03e-05 1.72e-05 - -2.700000 0.740425 1.253644 1.79e-04 3.98e-04 - -2.600000 0.755801 1.218831 2.12e-04 4.31e-04 - -2.500000 0.774699 1.183143 4.72e-04 7.18e-04 - -2.400000 0.794073 1.151533 4.73e-04 6.47e-04 - -2.300000 0.817175 1.119339 5.59e-04 6.14e-04 - -2.200000 0.839499 1.092138 5.90e-04 5.78e-04 - -2.100000 0.864212 1.066598 4.13e-04 3.94e-04 - -2.000000 0.889032 1.044976 8.71e-04 6.09e-04 - -1.900000 0.914718 1.026973 9.00e-04 4.74e-04 - -1.800000 0.940179 1.013455 1.31e-03 4.63e-04 - -1.700000 0.968083 1.004047 8.31e-04 1.12e-04 - -1.600000 0.993909 1.000388 1.24e-03 1.75e-04 - -1.500000 1.017654 1.001477 1.23e-04 2.25e-04 - -1.400000 1.040934 1.007085 6.92e-04 1.64e-04 - -1.300000 1.063961 1.017604 8.15e-04 4.54e-04 - -1.200000 1.086272 1.033016 5.49e-04 4.06e-04 - -1.100000 1.107659 1.053203 4.94e-05 2.11e-04 - -1.000000 1.127623 1.077435 6.13e-04 1.08e-03 - -0.900000 1.144846 1.102917 5.76e-05 1.13e-04 - -0.800000 1.161002 1.132205 1.85e-04 3.34e-04 - -0.700000 1.176043 1.165234 2.79e-04 8.53e-04 - -0.600000 1.188410 1.197657 1.47e-04 4.07e-04 - -0.500000 1.199588 1.233521 9.12e-05 4.05e-04 - -0.400000 1.208528 1.269280 4.29e-06 1.93e-04 - -0.300000 1.215451 1.304558 1.42e-04 9.99e-04 - -0.200000 1.220755 1.343310 8.63e-05 1.17e-03 - -0.100000 1.223670 1.377830 5.45e-05 6.35e-04 - 0.000000 1.224746 1.413828 1.30e-06 3.86e-04 - 0.100000 1.223656 1.450033 6.83e-05 9.53e-04 - 0.200000 1.220713 1.482092 4.42e-05 6.99e-04 - 0.300000 1.215653 1.514717 5.94e-05 3.81e-04 - 0.400000 1.208303 1.546650 2.21e-04 8.76e-04 - 0.500000 1.199626 1.574073 1.30e-04 5.46e-04 - 0.600000 1.188765 1.600906 2.08e-04 5.44e-04 - 0.700000 1.175362 1.626884 4.02e-04 7.79e-04 - 0.800000 1.160968 1.648722 2.18e-04 2.81e-04 - 0.900000 1.145114 1.667998 2.10e-04 3.33e-04 - 1.000000 1.127514 1.685113 5.04e-04 5.53e-04 - 1.100000 1.108159 1.699899 5.49e-04 4.56e-04 - 1.200000 1.087142 1.712119 3.22e-04 2.01e-04 - 1.300000 1.064531 1.721612 2.45e-04 1.13e-04 - 1.400000 1.040958 1.728047 6.67e-04 2.01e-04 - 1.500000 1.016725 1.731456 8.05e-04 1.29e-04 - 1.600000 0.991983 1.731941 6.91e-04 1.35e-05 - 1.700000 0.966874 1.729586 3.79e-04 5.72e-05 - 1.800000 0.940784 1.724279 7.04e-04 2.06e-04 - 1.900000 0.915877 1.716442 2.59e-04 3.71e-05 - 2.000000 0.890471 1.705877 5.68e-04 2.10e-04 - 2.100000 0.863219 1.691310 1.41e-03 7.92e-04 - 2.200000 0.840201 1.675797 1.12e-04 5.96e-05 - 2.300000 0.816737 1.657004 1.21e-04 1.31e-05 - 2.400000 0.793668 1.634786 8.78e-04 8.98e-04 - 2.500000 0.774939 1.612776 7.11e-04 7.98e-04 - 2.600000 0.755378 1.585094 6.35e-04 9.39e-04 - 2.700000 0.739812 1.557192 4.34e-04 8.13e-04 - 2.800000 0.727481 1.528628 2.34e-04 5.61e-04 - 2.900000 0.717491 1.496927 1.90e-04 5.15e-04 - 3.000000 0.710508 1.462255 1.29e-04 1.00e-03 - 3.100000 0.707466 1.429783 5.39e-05 9.44e-04 - 3.200000 0.707793 1.392653 8.38e-05 7.69e-04 - 3.300000 0.711356 1.358368 1.64e-04 1.07e-03 - 3.400000 0.719043 1.319780 2.93e-04 9.99e-04 - 3.500000 0.728867 1.285263 3.60e-04 1.04e-03 - 3.600000 0.743163 1.247040 4.51e-04 9.50e-04 - 3.700000 0.759125 1.212182 2.12e-04 3.21e-04 - 3.800000 0.777005 1.178985 5.01e-04 7.90e-04 - 3.900000 0.797903 1.145840 2.41e-04 3.12e-04 - 4.000000 0.821085 1.114325 6.11e-04 6.63e-04 - 4.100000 0.844766 1.086520 6.17e-04 5.50e-04 - 4.200000 0.869296 1.061916 4.64e-04 3.57e-04 - 4.300000 0.894280 1.041111 7.58e-05 3.77e-05 - 4.400000 0.919226 1.024310 7.38e-04 3.97e-04 - 4.500000 0.947241 1.010826 1.41e-03 3.47e-04 - 4.600000 0.972517 1.003182 9.60e-04 3.27e-05 - 4.700000 0.996899 1.000222 6.87e-07 1.84e-04 - 4.800000 1.020790 1.001834 8.50e-04 8.23e-05 - 4.900000 1.044488 1.008269 1.10e-03 4.67e-04 - 5.000000 1.067577 1.019650 9.88e-04 6.81e-04 - 5.100000 1.089592 1.035682 8.16e-04 7.47e-04 - 5.200000 1.110689 1.056427 2.83e-04 2.40e-04 - 5.300000 1.130590 1.081510 4.63e-04 8.94e-04 - 5.400000 1.148014 1.108349 2.57e-04 5.43e-04 - 5.500000 1.163471 1.137100 2.88e-04 6.43e-04 - 5.600000 1.178297 1.170732 2.55e-04 8.03e-04 - 5.700000 1.190803 1.204950 2.75e-04 1.08e-03 - 5.800000 1.201254 1.239702 1.04e-04 5.91e-04 - 5.900000 1.209788 1.274961 6.34e-05 2.35e-04 - 6.000000 1.216453 1.310771 1.35e-04 9.40e-04 - 6.100000 1.221238 1.347205 8.70e-05 1.07e-03 - 6.200000 1.224075 1.385740 3.64e-05 1.21e-03 - 6.300000 1.224694 1.421145 2.19e-05 9.99e-04 - 6.400000 1.223290 1.455612 6.29e-05 7.75e-04 - 6.500000 1.219880 1.488778 7.64e-05 4.50e-04 - 6.600000 1.214417 1.521008 1.26e-04 6.32e-04 - 6.700000 1.206981 1.551430 1.61e-04 6.72e-04 - 6.800000 1.197968 1.578698 1.79e-04 5.78e-04 - 6.900000 1.186755 1.605158 2.21e-04 5.94e-04 - 7.000000 1.173344 1.630149 9.14e-05 1.23e-04 + -2.900000 0.717252 1.327131 4.95e-05 1.98e-04 + -2.800000 0.729431 1.285450 2.18e-03 4.90e-03 + -2.700000 0.741045 1.254119 7.99e-04 7.70e-05 + -2.600000 0.753866 1.223223 2.15e-03 4.82e-03 + -2.500000 0.773945 1.184304 2.83e-04 4.42e-04 + -2.400000 0.797930 1.147024 3.38e-03 3.86e-03 + -2.300000 0.816215 1.120409 4.01e-04 4.56e-04 + -2.200000 0.839752 1.092546 3.37e-04 9.86e-04 + -2.100000 0.862994 1.068104 1.63e-03 1.90e-03 + -2.000000 0.891060 1.043666 1.16e-03 7.01e-04 + -1.900000 0.914807 1.027525 8.10e-04 1.03e-03 + -1.800000 0.939849 1.014125 1.64e-03 1.13e-03 + -1.700000 0.968390 1.004048 1.14e-03 1.11e-04 + -1.600000 0.991006 1.000892 1.67e-03 6.79e-04 + -1.500000 1.014885 1.001114 2.65e-03 1.37e-04 + -1.400000 1.040767 1.006968 8.58e-04 2.81e-04 + -1.300000 1.062597 1.016725 2.18e-03 1.33e-03 + -1.200000 1.085633 1.032297 1.19e-03 1.13e-03 + -1.100000 1.108024 1.053534 4.14e-04 5.42e-04 + -1.000000 1.127452 1.077295 4.42e-04 9.45e-04 + -0.900000 1.146006 1.105833 1.10e-03 2.80e-03 + -0.800000 1.159109 1.129574 2.08e-03 2.96e-03 + -0.700000 1.177130 1.168812 1.37e-03 4.43e-03 + -0.600000 1.187322 1.196322 1.24e-03 1.74e-03 + -0.500000 1.199933 1.235119 4.37e-04 2.00e-03 + -0.400000 1.205985 1.261600 2.54e-03 7.49e-03 + -0.300000 1.215289 1.312607 3.05e-04 7.05e-03 + -0.200000 1.220599 1.341349 7.05e-05 7.87e-04 + -0.100000 1.222135 1.371529 1.59e-03 6.94e-03 + 0.000000 1.223623 1.421336 1.12e-03 7.12e-03 + 0.100000 1.223841 1.445865 1.16e-04 3.21e-03 + 0.200000 1.219689 1.476939 9.81e-04 5.85e-03 + 0.300000 1.213360 1.521824 2.23e-03 6.73e-03 + 0.400000 1.209423 1.541118 8.99e-04 4.66e-03 + 0.500000 1.198775 1.570000 7.22e-04 4.62e-03 + 0.600000 1.185014 1.607250 3.54e-03 5.80e-03 + 0.700000 1.175994 1.625315 2.30e-04 7.90e-04 + 0.800000 1.160239 1.649840 9.47e-04 1.40e-03 + 0.900000 1.143420 1.669364 1.48e-03 1.03e-03 + 1.000000 1.126051 1.686584 9.59e-04 9.17e-04 + 1.100000 1.109639 1.698356 2.03e-03 2.00e-03 + 1.200000 1.087101 1.712145 2.81e-04 1.75e-04 + 1.300000 1.064592 1.721583 1.84e-04 8.45e-05 + 1.400000 1.038649 1.728439 2.98e-03 5.94e-04 + 1.500000 1.016789 1.730838 7.42e-04 4.89e-04 + 1.600000 0.991450 1.731933 1.22e-03 5.49e-06 + 1.700000 0.969896 1.729498 2.64e-03 1.45e-04 + 1.800000 0.944193 1.724781 2.70e-03 2.97e-04 + 1.900000 0.916905 1.716803 1.29e-03 3.24e-04 + 2.000000 0.888437 1.705095 1.47e-03 5.71e-04 + 2.100000 0.865598 1.692570 9.73e-04 4.68e-04 + 2.200000 0.842222 1.677092 2.13e-03 1.23e-03 + 2.300000 0.816188 1.656635 4.28e-04 3.82e-04 + 2.400000 0.793885 1.635057 6.61e-04 6.27e-04 + 2.500000 0.776031 1.613957 1.80e-03 1.98e-03 + 2.600000 0.753622 1.581884 2.39e-03 4.15e-03 + 2.700000 0.741077 1.557509 8.31e-04 4.96e-04 + 2.800000 0.729471 1.532344 2.22e-03 4.28e-03 + 2.900000 0.716517 1.493290 7.84e-04 3.12e-03 + 3.000000 0.710992 1.459723 3.56e-04 3.53e-03 + 3.100000 0.708434 1.432411 1.02e-03 3.57e-03 + 3.200000 0.707580 1.396243 1.29e-04 2.82e-03 + 3.300000 0.713998 1.359106 2.48e-03 1.81e-03 + 3.400000 0.721241 1.313281 2.49e-03 7.50e-03 + 3.500000 0.728499 1.286436 7.28e-04 2.22e-03 + 3.600000 0.743210 1.246929 4.98e-04 1.06e-03 + 3.700000 0.761189 1.208752 2.28e-03 3.75e-03 + 3.800000 0.780113 1.174880 2.61e-03 3.31e-03 + 3.900000 0.799720 1.144269 1.58e-03 1.26e-03 + 4.000000 0.820182 1.116065 2.93e-04 1.08e-03 + 4.100000 0.841981 1.089688 2.17e-03 2.62e-03 + 4.200000 0.865735 1.065013 3.10e-03 2.74e-03 + 4.300000 0.892023 1.042510 2.18e-03 1.44e-03 + 4.400000 0.921002 1.023447 1.04e-03 4.66e-04 + 4.500000 0.948675 1.010559 2.84e-03 6.14e-04 + 4.600000 0.974066 1.003392 2.51e-03 2.43e-04 + 4.700000 0.997896 1.000892 9.98e-04 8.54e-04 + 4.800000 1.020648 1.001692 9.93e-04 2.24e-04 + 4.900000 1.047276 1.009997 1.69e-03 1.26e-03 + 5.000000 1.068023 1.021379 5.42e-04 1.05e-03 + 5.100000 1.087670 1.034049 2.74e-03 2.38e-03 + 5.200000 1.113085 1.059905 2.11e-03 3.24e-03 + 5.300000 1.129982 1.081867 1.45e-04 1.25e-03 + 5.400000 1.145640 1.104051 2.12e-03 3.76e-03 + 5.500000 1.165064 1.141307 1.31e-03 3.56e-03 + 5.600000 1.178084 1.171667 4.19e-05 1.74e-03 + 5.700000 1.188488 1.197402 2.04e-03 6.47e-03 + 5.800000 1.201101 1.243139 4.87e-05 4.03e-03 + 5.900000 1.209228 1.271752 6.23e-04 3.44e-03 + 6.000000 1.215685 1.311733 9.02e-04 2.23e-05 + 6.100000 1.221545 1.351321 2.20e-04 3.05e-03 + 6.200000 1.222355 1.373621 1.68e-03 1.09e-02 + 6.300000 1.222541 1.421729 2.17e-03 1.58e-03 + 6.400000 1.222182 1.464077 1.17e-03 9.24e-03 + 6.500000 1.220415 1.479295 4.59e-04 9.03e-03 + 6.600000 1.212924 1.514933 1.62e-03 5.44e-03 + 6.700000 1.203640 1.557597 3.50e-03 6.84e-03 + 6.800000 1.197964 1.578711 1.75e-04 5.65e-04 + 6.900000 1.187272 1.603721 7.38e-04 2.03e-03 + 7.000000 1.174817 1.626730 1.38e-03 3.30e-03 ------------------------------------------------------ Final Solver Statistics: - Internal solver steps = 286 (attempted = 289) - Total number of error test failures = 3 - Total RHS evals: Fe = 0, Fi = 5808 - Total mass matrix setups = 1448 - Total mass matrix solves = 1734 - Total mass times evals = 4646 - Total number of Jacobian evaluations = 154 - Total linear solver setups = 167 - Total number of Nonlinear iterations = 4360 - Total number of Nonlinear convergence failures = 153 - Errors: u = 0.000511077, v = 0.000617033, total = 0.000566538 + Internal solver steps = 90 (attempted = 104) + Total number of error test failures = 0 + Total RHS evals: Fe = 0, Fi = 2586 + Total mass matrix setups = 524 + Total mass matrix solves = 689 + Total mass times evals = 2077 + Total number of Jacobian evaluations = 222 + Total linear solver setups = 222 + Total number of Nonlinear iterations = 1987 + Total number of Nonlinear convergence failures = 186 + Errors: u = 0.00162488, v = 0.00347168, total = 0.00271043 diff --git a/examples/arkode/CXX_serial/ark_kpr_Mt_2_4_0_-10_0.out b/examples/arkode/CXX_serial/ark_kpr_Mt_2_4_0_-10_0.out index 0cb940ef35..32617b5dfc 100644 --- a/examples/arkode/CXX_serial/ark_kpr_Mt_2_4_0_-10_0.out +++ b/examples/arkode/CXX_serial/ark_kpr_Mt_2_4_0_-10_0.out @@ -11,113 +11,113 @@ Nonlinear Kvaerno-Prothero-Robinson test problem with mass matrix: t u v uerr verr ------------------------------------------------------ -3.000000 0.710636 1.363407 0.00e+00 0.00e+00 - -2.900000 0.717302 1.326933 7.09e-07 3.80e-08 - -2.800000 0.727248 1.290353 8.19e-07 4.40e-08 - -2.700000 0.740247 1.254041 8.79e-07 4.56e-08 - -2.600000 0.756014 1.218400 7.89e-07 4.19e-08 - -2.500000 0.774228 1.183861 7.00e-07 3.54e-08 - -2.400000 0.794546 1.150885 6.04e-07 3.08e-08 - -2.300000 0.816617 1.119953 4.92e-07 2.38e-08 - -2.200000 0.840090 1.091560 1.42e-06 6.87e-08 - -2.100000 0.864627 1.066204 1.20e-06 4.56e-08 - -2.000000 0.889903 1.044367 7.76e-07 2.25e-08 - -1.900000 0.915617 1.026499 4.55e-08 1.78e-07 - -1.800000 0.941485 1.012992 2.28e-06 3.37e-07 - -1.700000 0.967249 1.004159 3.53e-06 3.11e-07 - -1.600000 0.992669 1.000214 4.20e-06 3.33e-07 - -1.500000 1.017526 1.001252 4.27e-06 4.27e-07 - -1.400000 1.041621 1.007249 4.51e-06 3.79e-07 - -1.300000 1.064773 1.018058 4.08e-06 3.79e-07 - -1.200000 1.086816 1.033422 4.62e-06 3.91e-07 - -1.100000 1.107605 1.052993 4.16e-06 3.67e-07 - -1.000000 1.127005 1.076350 4.74e-06 3.85e-07 - -0.900000 1.144900 1.103029 4.41e-06 3.61e-07 - -0.800000 1.161181 1.132539 4.83e-06 3.77e-07 - -0.700000 1.175759 1.164381 4.69e-06 3.53e-07 - -0.600000 1.188552 1.198064 4.70e-06 3.54e-07 - -0.500000 1.199491 1.233116 4.96e-06 3.48e-07 - -0.400000 1.208519 1.269087 4.61e-06 3.28e-07 - -0.300000 1.215589 1.305558 5.17e-06 3.43e-07 - -0.200000 1.220665 1.342137 4.62e-06 3.06e-07 - -0.100000 1.223719 1.378466 5.22e-06 3.32e-07 - 0.000000 1.224740 1.414214 4.66e-06 2.88e-07 - 0.100000 1.223720 1.449081 5.07e-06 3.12e-07 - 0.200000 1.220665 1.482791 4.68e-06 2.74e-07 - 0.300000 1.215589 1.515098 4.69e-06 2.78e-07 - 0.400000 1.208519 1.545775 4.63e-06 2.59e-07 - 0.500000 1.199492 1.574619 4.23e-06 2.39e-07 - 0.600000 1.188553 1.601450 4.45e-06 2.40e-07 - 0.700000 1.175760 1.626105 3.86e-06 2.06e-07 - 0.800000 1.161182 1.648441 4.12e-06 2.16e-07 - 0.900000 1.144900 1.668331 3.49e-06 1.76e-07 - 1.000000 1.127006 1.685667 3.60e-06 1.83e-07 - 1.100000 1.107606 1.700355 3.06e-06 1.45e-07 - 1.200000 1.086818 1.712320 2.90e-06 1.40e-07 - 1.300000 1.064774 1.721499 2.52e-06 1.10e-07 - 1.400000 1.041623 1.727845 2.09e-06 9.17e-08 - 1.500000 1.017529 1.731328 1.80e-06 6.82e-08 - 1.600000 0.992672 1.731928 1.28e-06 4.21e-08 - 1.700000 0.967252 1.729643 8.76e-07 1.68e-08 - 1.800000 0.941487 1.724485 2.49e-07 2.94e-08 - 1.900000 0.915619 1.716479 1.32e-06 1.26e-07 - 2.000000 0.889906 1.705666 3.18e-06 2.37e-07 - 2.100000 0.864630 1.692102 4.43e-06 3.13e-07 - 2.200000 0.840094 1.675857 4.92e-06 3.24e-07 - 2.300000 0.816621 1.657017 4.45e-06 2.97e-07 - 2.400000 0.794551 1.635684 4.77e-06 3.10e-07 - 2.500000 0.774232 1.611977 4.18e-06 2.76e-07 - 2.600000 0.756017 1.586033 4.01e-06 2.57e-07 - 2.700000 0.740250 1.558005 4.25e-06 2.68e-07 - 2.800000 0.727251 1.528067 4.06e-06 2.57e-07 - 2.900000 0.717305 1.496412 3.81e-06 2.39e-07 - 3.000000 0.710640 1.463256 3.62e-06 2.25e-07 - 3.100000 0.707416 1.428839 3.49e-06 2.14e-07 - 3.200000 0.707713 1.393422 3.41e-06 2.05e-07 - 3.300000 0.711523 1.357296 3.38e-06 2.00e-07 - 3.400000 0.718753 1.320779 3.35e-06 1.95e-07 - 3.500000 0.729230 1.284218 3.28e-06 1.89e-07 - 3.600000 0.742715 1.247990 3.08e-06 1.76e-07 - 3.700000 0.758916 1.212503 2.77e-06 1.59e-07 - 3.800000 0.777509 1.178194 2.40e-06 1.38e-07 - 3.900000 0.798146 1.145528 2.00e-06 1.15e-07 - 4.000000 0.820476 1.114988 1.58e-06 8.91e-08 - 4.100000 0.844150 1.087071 1.18e-06 6.29e-08 - 4.200000 0.868833 1.062273 8.01e-07 3.72e-08 - 4.300000 0.894204 1.041074 4.96e-07 1.30e-08 - 4.400000 0.919964 1.023913 8.07e-08 1.12e-07 - 4.500000 0.945832 1.011173 1.59e-06 2.22e-07 - 4.600000 0.971554 1.003150 3.36e-06 2.66e-07 - 4.700000 0.996894 1.000039 3.70e-06 3.06e-07 - 4.800000 1.021636 1.001916 4.34e-06 4.07e-07 - 4.900000 1.045585 1.008736 4.41e-06 3.42e-07 - 5.000000 1.068561 1.020332 4.18e-06 3.77e-07 - 5.100000 1.090403 1.036429 4.51e-06 3.59e-07 - 5.200000 1.110967 1.056667 4.32e-06 3.65e-07 - 5.300000 1.130122 1.080617 4.60e-06 3.62e-07 - 5.400000 1.147753 1.107807 4.59e-06 3.59e-07 - 5.500000 1.163754 1.137744 4.55e-06 3.50e-07 - 5.600000 1.178037 1.169929 4.87e-06 3.54e-07 - 5.700000 1.190523 1.203875 4.52e-06 3.32e-07 - 5.800000 1.201144 1.239112 5.11e-06 3.51e-07 - 5.900000 1.209846 1.275196 4.59e-06 3.15e-07 - 6.000000 1.216582 1.311711 5.23e-06 3.44e-07 - 6.100000 1.221320 1.348272 4.71e-06 3.01e-07 - 6.200000 1.224034 1.384526 5.15e-06 3.27e-07 - 6.300000 1.224711 1.420146 4.81e-06 2.90e-07 - 6.400000 1.223348 1.454837 4.82e-06 2.95e-07 - 6.500000 1.219952 1.488328 4.84e-06 2.78e-07 - 6.600000 1.214539 1.520376 4.44e-06 2.59e-07 - 6.700000 1.207137 1.550758 4.74e-06 2.64e-07 - 6.800000 1.197785 1.579276 4.14e-06 2.29e-07 - 6.900000 1.186529 1.605752 4.49e-06 2.43e-07 - 7.000000 1.173432 1.630027 3.87e-06 2.02e-07 + -2.900000 0.717597 1.325196 2.96e-04 1.74e-03 + -2.800000 0.727055 1.291201 1.92e-04 8.48e-04 + -2.700000 0.739973 1.255085 2.73e-04 1.04e-03 + -2.600000 0.756418 1.217518 4.05e-04 8.82e-04 + -2.500000 0.774692 1.182899 4.64e-04 9.62e-04 + -2.400000 0.793831 1.152211 7.15e-04 1.33e-03 + -2.300000 0.816530 1.120195 8.67e-05 2.42e-04 + -2.200000 0.840948 1.090496 8.59e-04 1.06e-03 + -2.100000 0.864359 1.066500 2.66e-04 2.96e-04 + -2.000000 0.891288 1.043175 1.39e-03 1.19e-03 + -1.900000 0.913438 1.028314 2.18e-03 1.82e-03 + -1.800000 0.939262 1.014419 2.23e-03 1.43e-03 + -1.700000 0.965152 1.005107 2.10e-03 9.48e-04 + -1.600000 0.990984 1.000778 1.69e-03 5.65e-04 + -1.500000 1.017309 1.001622 2.22e-04 3.70e-04 + -1.400000 1.043230 1.007884 1.60e-03 6.36e-04 + -1.300000 1.063617 1.017540 1.16e-03 5.18e-04 + -1.200000 1.086799 1.033696 2.14e-05 2.74e-04 + -1.100000 1.108327 1.053673 7.18e-04 6.80e-04 + -1.000000 1.126269 1.075743 7.41e-04 6.06e-04 + -0.900000 1.145935 1.104537 1.03e-03 1.51e-03 + -0.800000 1.160316 1.131311 8.70e-04 1.23e-03 + -0.700000 1.176677 1.166273 9.13e-04 1.89e-03 + -0.600000 1.187776 1.196487 7.81e-04 1.58e-03 + -0.500000 1.200206 1.235189 7.09e-04 2.07e-03 + -0.400000 1.207908 1.267337 6.16e-04 1.75e-03 + -0.300000 1.216074 1.307696 4.81e-04 2.14e-03 + -0.200000 1.220244 1.340317 4.26e-04 1.82e-03 + -0.100000 1.223963 1.380584 2.38e-04 2.12e-03 + 0.000000 1.224525 1.412398 2.20e-04 1.82e-03 + 0.100000 1.223712 1.451105 1.29e-05 2.02e-03 + 0.200000 1.220664 1.481043 4.75e-06 1.75e-03 + 0.300000 1.215328 1.516967 2.66e-04 1.87e-03 + 0.400000 1.208740 1.544149 2.15e-04 1.63e-03 + 0.500000 1.198981 1.576283 5.15e-04 1.66e-03 + 0.600000 1.188992 1.599994 4.35e-04 1.46e-03 + 0.700000 1.175010 1.627521 7.54e-04 1.42e-03 + 0.800000 1.161836 1.647192 6.49e-04 1.25e-03 + 0.900000 1.143927 1.669466 9.77e-04 1.14e-03 + 1.000000 1.127862 1.684658 8.52e-04 1.01e-03 + 1.100000 1.106433 1.701184 1.18e-03 8.29e-04 + 1.200000 1.087858 1.711577 1.04e-03 7.42e-04 + 1.300000 1.063431 1.722004 1.35e-03 5.05e-04 + 1.400000 1.042823 1.727389 1.20e-03 4.57e-04 + 1.500000 1.016054 1.731497 1.48e-03 1.69e-04 + 1.600000 0.993998 1.731771 1.33e-03 1.57e-04 + 1.700000 0.965692 1.729472 1.56e-03 1.71e-04 + 1.800000 0.943815 1.724768 2.33e-03 2.83e-04 + 1.900000 0.917975 1.717015 2.36e-03 5.36e-04 + 2.000000 0.892202 1.706429 2.30e-03 7.62e-04 + 2.100000 0.866416 1.692846 1.79e-03 7.44e-04 + 2.200000 0.839985 1.675553 1.04e-04 3.04e-04 + 2.300000 0.815183 1.655878 1.43e-03 1.14e-03 + 2.400000 0.795811 1.636696 1.27e-03 1.01e-03 + 2.500000 0.773104 1.610672 1.12e-03 1.31e-03 + 2.600000 0.756245 1.586119 2.32e-04 8.61e-05 + 2.700000 0.741121 1.559378 8.76e-04 1.37e-03 + 2.800000 0.727019 1.527561 2.28e-04 5.06e-04 + 2.900000 0.716828 1.494857 4.73e-04 1.55e-03 + 3.000000 0.710427 1.461921 2.09e-04 1.34e-03 + 3.100000 0.707420 1.428004 7.89e-06 8.35e-04 + 3.200000 0.707812 1.393090 1.03e-04 3.32e-04 + 3.300000 0.711612 1.357460 9.29e-05 1.63e-04 + 3.400000 0.718738 1.321437 1.13e-05 6.57e-04 + 3.500000 0.729038 1.285320 1.89e-04 1.10e-03 + 3.600000 0.742308 1.249432 4.04e-04 1.44e-03 + 3.700000 0.758303 1.214133 6.11e-04 1.63e-03 + 3.800000 0.776750 1.179823 7.57e-04 1.63e-03 + 3.900000 0.797355 1.146945 7.89e-04 1.42e-03 + 4.000000 0.819816 1.115988 6.59e-04 1.00e-03 + 4.100000 0.843829 1.087481 3.20e-04 4.11e-04 + 4.200000 0.869064 1.062027 2.31e-04 2.46e-04 + 4.300000 0.894905 1.040470 7.02e-04 6.04e-04 + 4.400000 0.918213 1.025261 1.75e-03 1.35e-03 + 4.500000 0.945400 1.011740 4.34e-04 5.67e-04 + 4.600000 0.973135 1.002933 1.58e-03 2.17e-04 + 4.700000 0.997652 0.999974 7.54e-04 6.42e-05 + 4.800000 1.019924 1.001904 1.72e-03 1.15e-05 + 4.900000 1.045828 1.009136 2.39e-04 4.00e-04 + 5.000000 1.069724 1.020978 1.16e-03 6.47e-04 + 5.100000 1.089137 1.035699 1.27e-03 7.30e-04 + 5.200000 1.112209 1.058020 1.24e-03 1.35e-03 + 5.300000 1.128861 1.079217 1.27e-03 1.40e-03 + 5.400000 1.148573 1.109197 8.16e-04 1.39e-03 + 5.500000 1.162768 1.136120 9.91e-04 1.62e-03 + 5.600000 1.178581 1.171263 5.39e-04 1.33e-03 + 5.700000 1.189774 1.202150 7.54e-04 1.73e-03 + 5.800000 1.201508 1.240423 3.59e-04 1.31e-03 + 5.900000 1.209300 1.273401 5.51e-04 1.79e-03 + 6.000000 1.216793 1.313000 2.06e-04 1.29e-03 + 6.100000 1.220978 1.346470 3.47e-04 1.80e-03 + 6.200000 1.224093 1.385751 5.37e-05 1.23e-03 + 6.300000 1.224578 1.418404 1.38e-04 1.74e-03 + 6.400000 1.223258 1.455961 9.54e-05 1.12e-03 + 6.500000 1.220027 1.486703 7.03e-05 1.62e-03 + 6.600000 1.214306 1.521371 2.38e-04 9.95e-04 + 6.700000 1.207416 1.549295 2.74e-04 1.46e-03 + 6.800000 1.197418 1.580121 3.71e-04 8.45e-04 + 6.900000 1.187001 1.604485 4.67e-04 1.27e-03 + 7.000000 1.172945 1.630705 4.91e-04 6.79e-04 ------------------------------------------------------ Final Solver Statistics: - Internal solver steps = 165 (attempted = 168) - Total number of error test failures = 3 - Total RHS evals: Fe = 1008, Fi = 0 - Total mass matrix setups = 676 - Total mass matrix solves = 1008 - Total mass times evals = 165 - Errors: u = 3.7533e-06, v = 2.61601e-07, total = 2.66042e-06 + Internal solver steps = 160 (attempted = 161) + Total number of error test failures = 1 + Total RHS evals: Fe = 808, Fi = 0 + Total mass matrix setups = 488 + Total mass matrix solves = 968 + Total mass times evals = 160 + Errors: u = 0.0009669, v = 0.00120007, total = 0.00108974 diff --git a/examples/arkode/CXX_superludist/ark_brusselator1D_FEM_sludist.out b/examples/arkode/CXX_superludist/ark_brusselator1D_FEM_sludist.out index 1cf56e4da4..4a409a5d09 100644 --- a/examples/arkode/CXX_superludist/ark_brusselator1D_FEM_sludist.out +++ b/examples/arkode/CXX_superludist/ark_brusselator1D_FEM_sludist.out @@ -9,114 +9,114 @@ ---------------------------------------------- 0.100000 0.637854 3.356025 1.999989 0.200000 0.643035 3.345751 1.999989 - 0.300000 0.648532 3.334867 1.999989 - 0.400000 0.654362 3.323350 1.999989 - 0.500000 0.660542 3.311172 1.999988 - 0.600000 0.667093 3.298310 1.999988 - 0.700000 0.674031 3.284739 1.999988 - 0.800000 0.681370 3.270442 1.999988 - 0.900000 0.689121 3.255404 1.999988 - 1.000000 0.697285 3.239620 1.999988 - 1.100000 0.705854 3.223093 1.999987 - 1.200000 0.714805 3.205842 1.999987 - 1.300000 0.724099 3.187902 1.999987 - 1.400000 0.733671 3.169332 1.999987 - 1.500000 0.743429 3.150211 1.999987 - 1.600000 0.753249 3.130653 1.999987 - 1.700000 0.762974 3.110800 1.999986 - 1.800000 0.772412 3.090827 1.999986 - 1.900000 0.781337 3.070944 1.999986 - 2.000000 0.789501 3.051388 1.999986 - 2.100000 0.796639 3.032420 1.999986 - 2.200000 0.802490 3.014317 1.999986 - 2.300000 0.806810 2.997358 1.999986 - 2.400000 0.809386 2.981818 1.999986 - 2.500000 0.810060 2.967949 1.999986 - 2.600000 0.808729 2.955977 1.999986 - 2.700000 0.805360 2.946085 1.999986 - 2.800000 0.799989 2.938410 1.999986 - 2.900000 0.792711 2.933039 1.999986 - 3.000000 0.783680 2.930010 1.999986 - 3.100000 0.773095 2.929307 1.999986 - 3.200000 0.761187 2.930873 1.999986 - 3.300000 0.748207 2.934612 1.999987 - 3.400000 0.734416 2.940393 1.999987 - 3.500000 0.720073 2.948062 1.999987 - 3.600000 0.705429 2.957444 1.999987 + 0.300000 0.648532 3.334868 1.999989 + 0.400000 0.654362 3.323350 1.999988 + 0.500000 0.660543 3.311172 1.999988 + 0.600000 0.667094 3.298309 1.999988 + 0.700000 0.674032 3.284738 1.999988 + 0.800000 0.681371 3.270441 1.999988 + 0.900000 0.689123 3.255402 1.999988 + 1.000000 0.697286 3.239618 1.999988 + 1.100000 0.705855 3.223091 1.999987 + 1.200000 0.714810 3.205837 1.999987 + 1.300000 0.724101 3.187900 1.999987 + 1.400000 0.733673 3.169328 1.999987 + 1.500000 0.743434 3.150205 1.999987 + 1.600000 0.753251 3.130651 1.999987 + 1.700000 0.762976 3.110798 1.999986 + 1.800000 0.772414 3.090825 1.999986 + 1.900000 0.781339 3.070942 1.999986 + 2.000000 0.789502 3.051385 1.999986 + 2.100000 0.796640 3.032418 1.999986 + 2.200000 0.802492 3.014314 1.999986 + 2.300000 0.806810 2.997356 1.999986 + 2.400000 0.809388 2.981815 1.999986 + 2.500000 0.810060 2.967947 1.999986 + 2.600000 0.808729 2.955975 1.999986 + 2.700000 0.805361 2.946083 1.999986 + 2.800000 0.799988 2.938409 1.999986 + 2.900000 0.792711 2.933038 1.999986 + 3.000000 0.783680 2.930008 1.999986 + 3.100000 0.773094 2.929308 1.999986 + 3.200000 0.761185 2.930875 1.999986 + 3.300000 0.748206 2.934611 1.999987 + 3.400000 0.734415 2.940393 1.999987 + 3.500000 0.720072 2.948062 1.999987 + 3.600000 0.705427 2.957444 1.999987 3.700000 0.690714 2.968354 1.999988 - 3.800000 0.676141 2.980600 1.999988 - 3.900000 0.661891 2.993989 1.999988 + 3.800000 0.676140 2.980600 1.999988 + 3.900000 0.661890 2.993989 1.999988 4.000000 0.648122 3.008331 1.999989 - 4.100000 0.634961 3.023445 1.999989 + 4.100000 0.634960 3.023446 1.999989 4.200000 0.622506 3.039157 1.999989 - 4.300000 0.610828 3.055308 1.999989 - 4.400000 0.599972 3.071752 1.999989 - 4.500000 0.589962 3.088356 1.999990 - 4.600000 0.580801 3.105007 1.999990 - 4.700000 0.572477 3.121603 1.999990 - 4.800000 0.564964 3.138059 1.999990 - 4.900000 0.558227 3.154303 1.999990 - 5.000000 0.552224 3.170278 1.999990 - 5.100000 0.546907 3.185935 1.999991 - 5.200000 0.542228 3.201239 1.999991 - 5.300000 0.538137 3.216162 1.999991 - 5.400000 0.534585 3.230683 1.999991 - 5.500000 0.531525 3.244788 1.999991 - 5.600000 0.528910 3.258469 1.999991 - 5.700000 0.526699 3.271720 1.999991 - 5.800000 0.524852 3.284539 1.999991 - 5.900000 0.523334 3.296928 1.999991 - 6.000000 0.522111 3.308889 1.999991 - 6.100000 0.521154 3.320427 1.999991 - 6.200000 0.520436 3.331545 1.999991 - 6.300000 0.519932 3.342251 1.999991 - 6.400000 0.519621 3.352549 1.999991 - 6.500000 0.519484 3.362447 1.999991 - 6.600000 0.519503 3.371950 1.999991 - 6.700000 0.519664 3.381065 1.999991 - 6.800000 0.519953 3.389797 1.999991 - 6.900000 0.520358 3.398153 1.999991 - 7.000000 0.520869 3.406139 1.999991 - 7.100000 0.521477 3.413759 1.999991 - 7.200000 0.522174 3.421020 1.999991 - 7.300000 0.522953 3.427926 1.999991 - 7.400000 0.523807 3.434482 1.999991 - 7.500000 0.524732 3.440692 1.999991 - 7.600000 0.525723 3.446560 1.999991 - 7.700000 0.526775 3.452091 1.999991 - 7.800000 0.527887 3.457288 1.999991 - 7.900000 0.529055 3.462154 1.999991 + 4.300000 0.610826 3.055309 1.999989 + 4.400000 0.599971 3.071752 1.999989 + 4.500000 0.589960 3.088358 1.999990 + 4.600000 0.580800 3.105008 1.999990 + 4.700000 0.572476 3.121604 1.999990 + 4.800000 0.564963 3.138060 1.999990 + 4.900000 0.558226 3.154305 1.999990 + 5.000000 0.552223 3.170279 1.999990 + 5.100000 0.546906 3.185936 1.999991 + 5.200000 0.542228 3.201241 1.999991 + 5.300000 0.538137 3.216163 1.999991 + 5.400000 0.534585 3.230684 1.999991 + 5.500000 0.531524 3.244789 1.999991 + 5.600000 0.528909 3.258470 1.999991 + 5.700000 0.526698 3.271721 1.999991 + 5.800000 0.524852 3.284540 1.999991 + 5.900000 0.523333 3.296929 1.999991 + 6.000000 0.522110 3.308890 1.999991 + 6.100000 0.521154 3.320428 1.999991 + 6.200000 0.520436 3.331547 1.999991 + 6.300000 0.519931 3.342252 1.999991 + 6.400000 0.519620 3.352550 1.999991 + 6.500000 0.519484 3.362448 1.999991 + 6.600000 0.519503 3.371951 1.999991 + 6.700000 0.519663 3.381066 1.999991 + 6.800000 0.519953 3.389798 1.999991 + 6.900000 0.520358 3.398154 1.999991 + 7.000000 0.520869 3.406140 1.999991 + 7.100000 0.521477 3.413761 1.999991 + 7.200000 0.522174 3.421021 1.999991 + 7.300000 0.522953 3.427927 1.999991 + 7.400000 0.523807 3.434483 1.999991 + 7.500000 0.524732 3.440693 1.999991 + 7.600000 0.525723 3.446561 1.999991 + 7.700000 0.526775 3.452092 1.999991 + 7.800000 0.527887 3.457289 1.999991 + 7.900000 0.529055 3.462155 1.999991 8.000000 0.530276 3.466693 1.999991 8.100000 0.531549 3.470907 1.999991 - 8.200000 0.532872 3.474798 1.999991 - 8.300000 0.534244 3.478370 1.999991 - 8.400000 0.535665 3.481625 1.999991 - 8.500000 0.537133 3.484563 1.999991 - 8.600000 0.538649 3.487188 1.999991 + 8.200000 0.532872 3.474799 1.999991 + 8.300000 0.534244 3.478371 1.999991 + 8.400000 0.535665 3.481626 1.999991 + 8.500000 0.537133 3.484564 1.999991 + 8.600000 0.538650 3.487188 1.999991 8.700000 0.540213 3.489499 1.999991 - 8.800000 0.541825 3.491497 1.999991 - 8.900000 0.543486 3.493184 1.999991 - 9.000000 0.545196 3.494560 1.999991 - 9.100000 0.546957 3.495624 1.999991 + 8.800000 0.541825 3.491498 1.999991 + 8.900000 0.543486 3.493185 1.999991 + 9.000000 0.545197 3.494560 1.999991 + 9.100000 0.546958 3.495624 1.999991 9.200000 0.548771 3.496375 1.999991 - 9.300000 0.550638 3.496814 1.999990 + 9.300000 0.550639 3.496814 1.999990 9.400000 0.552562 3.496938 1.999990 9.500000 0.554543 3.496746 1.999990 - 9.600000 0.556585 3.496235 1.999990 - 9.700000 0.558691 3.495404 1.999990 - 9.800000 0.560864 3.494247 1.999990 + 9.600000 0.556586 3.496236 1.999990 + 9.700000 0.558692 3.495404 1.999990 + 9.800000 0.560865 3.494247 1.999990 9.900000 0.563108 3.492763 1.999990 - 10.000000 0.565426 3.490945 1.999990 + 10.000000 0.565426 3.490944 1.999990 ---------------------------------------------- Final Solver Statistics: - Internal solver steps = 95 (attempted = 95) - Total RHS evals: Fe = 0, Fi = 1605 + Internal solver steps = 60 (attempted = 62) + Total RHS evals: Fe = 0, Fi = 1173 Total mass matrix setups = 1 - Total mass matrix solves = 288 - Total mass times evals = 1697 - Total linear solver setups = 31 - Total number of Jacobian evaluations = 11 - Total number of Newton iterations = 1127 - Total number of nonlinear solver convergence failures = 10 + Total mass matrix solves = 245 + Total mass times evals = 1170 + Total linear solver setups = 34 + Total number of Jacobian evaluations = 34 + Total number of Newton iterations = 802 + Total number of nonlinear solver convergence failures = 14 Total number of error test failures = 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..9783b3f97f 100644 --- a/examples/arkode/CXX_xbraid/ark_heat2D_hypre_pfmg_xbraid.cpp +++ b/examples/arkode/CXX_xbraid/ark_heat2D_hypre_pfmg_xbraid.cpp @@ -350,14 +350,16 @@ 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 step adaptivity controller + SUNTimestepHeuristics H = NULL; // time step heuristics // Timing variables double t1 = 0.0; @@ -559,17 +561,23 @@ 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; - - // Set the step size reduction factor limit (1 / refinement factor limit) - flag = ARKStepSetMinReduction(arkode_mem, ONE / udata->x_rfactor_limit); - if (check_flag(&flag, "ARKStepSetMinReduction", 1)) return 1; - - // Set the failed solve step size reduction factor (1 / refinement factor) - flag = ARKStepSetMaxCFailGrowth(arkode_mem, ONE / udata->x_rfactor_fail); - if (check_flag(&flag, "ARKStepSetMaxCFailGrowth", 1)) return 1; + // 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; + + // Use default heuristics constraints with some options + H = SUNTimestepHeuristics_Default(ctx); + if (check_flag((void*) H, "SUNTimestepHeuristics_Default", 0)) return 1; + // Set the step size reduction factor limit (1 / refinement factor limit) + flag = SUNTimestepHeuristics_SetMinReduction(H, ONE / udata->x_rfactor_limit); + if (check_flag(&flag, "SUNTimestepHeuristics_SetMinReduction", 1)) return 1; + // Set the failed solve step size reduction factor (1 / refinement factor) + flag = SUNTimestepHeuristics_SetMaxCFailGrowth(H, ONE / udata->x_rfactor_fail); + if (check_flag(&flag, "SUNTimestepHeuristics_SetMaxCFailGrowth", 1)) return 1; + flag = ARKStepSetTimestepHeuristics(arkode_mem, H); + if (check_flag(&flag, "ARKStepSetTimestepHeuristics", 1)) return 1; } // Set diagnostics output file @@ -741,15 +749,17 @@ 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 + (void) SUNTimestepHeuristics_Destroy(H); // Free timestep heuristics object + 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..62c4594dc8 100644 --- a/examples/arkode/CXX_xbraid/ark_heat2D_p_xbraid.cpp +++ b/examples/arkode/CXX_xbraid/ark_heat2D_p_xbraid.cpp @@ -307,14 +307,16 @@ 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 step adaptivity controller + SUNTimestepHeuristics H = NULL; // time step heuristics object // Timing variables double t1 = 0.0; @@ -506,17 +508,23 @@ 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; - - // Set the step size reduction factor limit (1 / refinement factor limit) - flag = ARKStepSetMinReduction(arkode_mem, ONE / udata->x_rfactor_limit); - if (check_flag(&flag, "ARKStepSetMinReduction", 1)) return 1; - - // Set the failed solve step size reduction factor (1 / refinement factor) - flag = ARKStepSetMaxCFailGrowth(arkode_mem, ONE / udata->x_rfactor_fail); - if (check_flag(&flag, "ARKStepSetMaxCFailGrowth", 1)) return 1; + // 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; + + // Use default heuristics constraints with some options + H = SUNTimestepHeuristics_Default(ctx); + if (check_flag((void*) H, "SUNTimestepHeuristics_Default", 0)) return 1; + // Set the step size reduction factor limit (1 / refinement factor limit) + flag = SUNTimestepHeuristics_SetMinReduction(H, ONE / udata->x_rfactor_limit); + if (check_flag(&flag, "SUNTimestepHeuristics_SetMinReduction", 1)) return 1; + // Set the failed solve step size reduction factor (1 / refinement factor) + flag = SUNTimestepHeuristics_SetMaxCFailGrowth(H, ONE / udata->x_rfactor_fail); + if (check_flag(&flag, "SUNTimestepHeuristics_SetMaxCFailGrowth", 1)) return 1; + flag = ARKStepSetTimestepHeuristics(arkode_mem, H); + if (check_flag(&flag, "ARKStepSetTimestepHeuristics", 1)) return 1; } // Set diagnostics output file @@ -688,15 +696,17 @@ 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) SUNTimestepHeuristics_Destroy(H); // Free timestep heuristics object + (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..958688aa6b 100644 --- a/examples/arkode/CXX_xbraid/ark_heat2D_xbraid.cpp +++ b/examples/arkode/CXX_xbraid/ark_heat2D_xbraid.cpp @@ -239,14 +239,16 @@ 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 + SUNTimestepHeuristics H = NULL; // timestep heuristics // Timing variables chrono::time_point t1; @@ -444,17 +446,23 @@ 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; - - // Set the step size reduction factor limit (1 / refinement factor limit) - flag = ARKStepSetMinReduction(arkode_mem, ONE / udata->x_rfactor_limit); - if (check_flag(&flag, "ARKStepSetMinReduction", 1)) return 1; - - // Set the failed solve step size reduction factor (1 / refinement factor) - flag = ARKStepSetMaxCFailGrowth(arkode_mem, ONE / udata->x_rfactor_fail); - if (check_flag(&flag, "ARKStepSetMaxCFailGrowth", 1)) return 1; + // 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; + + // Use default heuristics constraints with some options + H = SUNTimestepHeuristics_Default(ctx); + if (check_flag((void*) H, "SUNTimestepHeuristics_Default", 0)) return 1; + // Set the step size reduction factor limit (1 / refinement factor limit) + flag = SUNTimestepHeuristics_SetMinReduction(H, ONE / udata->x_rfactor_limit); + if (check_flag(&flag, "SUNTimestepHeuristics_SetMinReduction", 1)) return 1; + // Set the failed solve step size reduction factor (1 / refinement factor) + flag = SUNTimestepHeuristics_SetMaxCFailGrowth(H, ONE / udata->x_rfactor_fail); + if (check_flag(&flag, "SUNTimestepHeuristics_SetMaxCFailGrowth", 1)) return 1; + flag = ARKStepSetTimestepHeuristics(arkode_mem, H); + if (check_flag(&flag, "ARKStepSetTimestepHeuristics", 1)) return 1; } // Set diagnostics output file @@ -626,15 +634,17 @@ 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 + (void) SUNTimestepHeuristics_Destroy(H); // Free timestep heuristics object + SUNContext_Free(&ctx); // Free context + flag = MPI_Finalize(); // Finalize MPI return 0; } diff --git a/examples/arkode/C_openmp/ark_brusselator1D_omp.out b/examples/arkode/C_openmp/ark_brusselator1D_omp.out index 1c209cc20f..16734f689d 100644 --- a/examples/arkode/C_openmp/ark_brusselator1D_omp.out +++ b/examples/arkode/C_openmp/ark_brusselator1D_omp.out @@ -9,85 +9,85 @@ t ||u||_rms ||v||_rms ||w||_rms ---------------------------------------------- 0.100000 0.673914 3.377329 1.999987 - 0.200000 0.684316 3.356619 1.999987 + 0.200000 0.684316 3.356619 1.999986 0.300000 0.695306 3.334633 1.999986 0.400000 0.706918 3.311313 1.999986 0.500000 0.719185 3.286601 1.999986 - 0.600000 0.732137 3.260442 1.999986 + 0.600000 0.732138 3.260441 1.999986 0.700000 0.745798 3.232787 1.999985 - 0.800000 0.760185 3.203596 1.999985 - 0.900000 0.775303 3.172839 1.999985 - 1.000000 0.791135 3.140510 1.999984 - 1.100000 0.807648 3.106624 1.999984 - 1.200000 0.824771 3.071233 1.999984 - 1.300000 0.842402 3.034426 1.999983 - 1.400000 0.860384 2.996350 1.999983 - 1.500000 0.878514 2.957206 1.999983 - 1.600000 0.896525 2.917266 1.999982 - 1.700000 0.914089 2.876873 1.999982 - 1.800000 0.930823 2.836438 1.999982 - 1.900000 0.946292 2.796446 1.999982 - 2.000000 0.960033 2.757430 1.999981 - 2.100000 0.971576 2.719962 1.999981 - 2.200000 0.980475 2.684623 1.999981 - 2.300000 0.986338 2.651980 1.999981 - 2.400000 0.988852 2.622560 1.999981 - 2.500000 0.987815 2.596818 1.999981 - 2.600000 0.983141 2.575128 1.999981 - 2.700000 0.974858 2.557766 1.999981 - 2.800000 0.963114 2.544903 1.999981 - 2.900000 0.948154 2.536611 1.999981 - 3.000000 0.930299 2.532868 1.999982 - 3.100000 0.909930 2.533567 1.999982 - 3.200000 0.887464 2.538529 1.999983 - 3.300000 0.863335 2.547515 1.999983 + 0.800000 0.760187 3.203594 1.999985 + 0.900000 0.775304 3.172838 1.999985 + 1.000000 0.791136 3.140509 1.999984 + 1.100000 0.807652 3.106620 1.999984 + 1.200000 0.824772 3.071232 1.999984 + 1.300000 0.842405 3.034422 1.999983 + 1.400000 0.860387 2.996346 1.999983 + 1.500000 0.878515 2.957204 1.999983 + 1.600000 0.896529 2.917259 1.999982 + 1.700000 0.914090 2.876870 1.999982 + 1.800000 0.930824 2.836436 1.999982 + 1.900000 0.946293 2.796443 1.999982 + 2.000000 0.960035 2.757427 1.999981 + 2.100000 0.971577 2.719959 1.999981 + 2.200000 0.980476 2.684620 1.999981 + 2.300000 0.986337 2.651979 1.999981 + 2.400000 0.988854 2.622557 1.999981 + 2.500000 0.987814 2.596817 1.999981 + 2.600000 0.983141 2.575126 1.999981 + 2.700000 0.974857 2.557765 1.999981 + 2.800000 0.963114 2.544902 1.999981 + 2.900000 0.948154 2.536610 1.999981 + 3.000000 0.930298 2.532869 1.999982 + 3.100000 0.909930 2.533566 1.999982 + 3.200000 0.887463 2.538529 1.999983 + 3.300000 0.863334 2.547514 1.999983 3.400000 0.837978 2.560241 1.999983 3.500000 0.811818 2.576391 1.999984 - 3.600000 0.785255 2.595624 1.999984 - 3.700000 0.758659 2.617587 1.999985 - 3.800000 0.732363 2.641922 1.999986 - 3.900000 0.706662 2.668274 1.999986 - 4.000000 0.681809 2.696300 1.999986 - 4.100000 0.658012 2.725670 1.999987 + 3.600000 0.785254 2.595624 1.999984 + 3.700000 0.758658 2.617587 1.999985 + 3.800000 0.732362 2.641922 1.999986 + 3.900000 0.706662 2.668275 1.999986 + 4.000000 0.681808 2.696301 1.999986 + 4.100000 0.658010 2.725671 1.999987 4.200000 0.635435 2.756075 1.999987 - 4.300000 0.614205 2.787228 1.999988 + 4.300000 0.614204 2.787229 1.999988 4.400000 0.594404 2.818869 1.999988 - 4.500000 0.576082 2.850764 1.999989 - 4.600000 0.559255 2.882710 1.999989 - 4.700000 0.543909 2.914529 1.999989 - 4.800000 0.530011 2.946071 1.999990 - 4.900000 0.517506 2.977209 1.999990 - 5.000000 0.506326 3.007843 1.999990 - 5.100000 0.496394 3.037889 1.999990 - 5.200000 0.487626 3.067283 1.999990 - 5.300000 0.479935 3.095976 1.999991 - 5.400000 0.473237 3.123932 1.999991 - 5.500000 0.467445 3.151125 1.999991 - 5.600000 0.462480 3.177540 1.999991 - 5.700000 0.458264 3.203165 1.999991 - 5.800000 0.454726 3.227997 1.999991 - 5.900000 0.451800 3.252035 1.999991 - 6.000000 0.449425 3.275283 1.999991 - 6.100000 0.447546 3.297744 1.999991 - 6.200000 0.446115 3.319428 1.999991 - 6.300000 0.445086 3.340340 1.999991 - 6.400000 0.444419 3.360491 1.999991 - 6.500000 0.444079 3.379890 1.999991 + 4.500000 0.576081 2.850765 1.999989 + 4.600000 0.559254 2.882711 1.999989 + 4.700000 0.543909 2.914530 1.999989 + 4.800000 0.530010 2.946072 1.999990 + 4.900000 0.517505 2.977210 1.999990 + 5.000000 0.506325 3.007844 1.999990 + 5.100000 0.496393 3.037890 1.999990 + 5.200000 0.487625 3.067284 1.999990 + 5.300000 0.479935 3.095977 1.999991 + 5.400000 0.473236 3.123933 1.999991 + 5.500000 0.467445 3.151126 1.999991 + 5.600000 0.462480 3.177541 1.999991 + 5.700000 0.458264 3.203166 1.999991 + 5.800000 0.454725 3.227998 1.999991 + 5.900000 0.451799 3.252036 1.999991 + 6.000000 0.449424 3.275284 1.999991 + 6.100000 0.447546 3.297745 1.999991 + 6.200000 0.446115 3.319429 1.999991 + 6.300000 0.445085 3.340341 1.999991 + 6.400000 0.444418 3.360492 1.999991 + 6.500000 0.444079 3.379891 1.999991 6.600000 0.444034 3.398547 1.999991 - 6.700000 0.444257 3.416470 1.999991 - 6.800000 0.444722 3.433669 1.999991 - 6.900000 0.445409 3.450154 1.999991 - 7.000000 0.446297 3.465934 1.999991 - 7.100000 0.447370 3.481018 1.999991 - 7.200000 0.448614 3.495414 1.999991 - 7.300000 0.450016 3.509131 1.999991 - 7.400000 0.451564 3.522176 1.999991 + 6.700000 0.444256 3.416470 1.999991 + 6.800000 0.444722 3.433670 1.999991 + 6.900000 0.445408 3.450155 1.999991 + 7.000000 0.446297 3.465935 1.999991 + 7.100000 0.447370 3.481019 1.999991 + 7.200000 0.448614 3.495415 1.999991 + 7.300000 0.450016 3.509132 1.999991 + 7.400000 0.451564 3.522177 1.999991 7.500000 0.453249 3.534557 1.999991 - 7.600000 0.455064 3.546280 1.999991 - 7.700000 0.457000 3.557353 1.999991 - 7.800000 0.459052 3.567781 1.999991 - 7.900000 0.461216 3.577571 1.999991 - 8.000000 0.463486 3.586728 1.999991 + 7.600000 0.455064 3.546281 1.999991 + 7.700000 0.457000 3.557354 1.999991 + 7.800000 0.459052 3.567782 1.999991 + 7.900000 0.461216 3.577572 1.999991 + 8.000000 0.463486 3.586729 1.999991 8.100000 0.465860 3.595257 1.999991 8.200000 0.468335 3.603162 1.999991 8.300000 0.470909 3.610447 1.999991 @@ -95,28 +95,28 @@ 8.500000 0.476352 3.623171 1.999991 8.600000 0.479220 3.628616 1.999991 8.700000 0.482186 3.633451 1.999991 - 8.800000 0.485250 3.637679 1.999990 + 8.800000 0.485251 3.637679 1.999990 8.900000 0.488416 3.641299 1.999990 9.000000 0.491684 3.644311 1.999990 9.100000 0.495058 3.646715 1.999990 9.200000 0.498540 3.648509 1.999990 9.300000 0.502134 3.649691 1.999990 - 9.400000 0.505844 3.650257 1.999990 + 9.400000 0.505844 3.650256 1.999990 9.500000 0.509675 3.650202 1.999990 9.600000 0.513632 3.649521 1.999990 9.700000 0.517722 3.648209 1.999990 9.800000 0.521951 3.646257 1.999990 - 9.900000 0.526326 3.643656 1.999990 + 9.900000 0.526327 3.643656 1.999990 10.000000 0.530857 3.640396 1.999990 ---------------------------------------------- Final Solver Statistics: - Internal solver steps = 99 (attempted = 99) - Total RHS evals: Fe = 0, Fi = 1694 - Total linear solver setups = 35 + Internal solver steps = 66 (attempted = 67) + Total RHS evals: Fe = 0, Fi = 1302 + Total linear solver setups = 33 Total RHS evals for setting up the linear system = 0 - Total number of Jacobian evaluations = 14 - Total number of Newton iterations = 1196 - Total number of nonlinear solver convergence failures = 13 + Total number of Jacobian evaluations = 16 + Total number of Newton iterations = 899 + Total number of nonlinear solver convergence failures = 15 Total number of error test failures = 0 diff --git a/examples/arkode/C_openmp/ark_heat1D_omp.out b/examples/arkode/C_openmp/ark_heat1D_omp.out index 89e65575dd..33dfb82321 100644 --- a/examples/arkode/C_openmp/ark_heat1D_omp.out +++ b/examples/arkode/C_openmp/ark_heat1D_omp.out @@ -18,12 +18,12 @@ ------------------------- Final Solver Statistics: - Internal solver steps = 191 (attempted = 191) - Total RHS evals: Fe = 0, Fi = 1913 + Internal solver steps = 81 (attempted = 81) + Total RHS evals: Fe = 0, Fi = 894 Total linear solver setups = 0 - Total linear iterations = 18388 - Total number of Jacobian-vector products = 18388 + Total linear iterations = 11461 + Total number of Jacobian-vector products = 11461 Total number of linear solver convergence failures = 0 - Total number of Newton iterations = 955 + Total number of Newton iterations = 405 Total number of nonlinear solver convergence failures = 0 Total number of error test failures = 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..9b59849ad1 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; @@ -184,11 +185,15 @@ int main() { if (check_flag(&flag, "ARKStepSetMaxNumSteps", 1)) return 1; flag = ARKStepSStolerances(arkode_mem, rtol, atol); /* Specify tolerances */ if (check_flag(&flag, "ARKStepSStolerances", 1)) return 1; - flag = ARKStepSetAdaptivityMethod(arkode_mem, 2, 1, 0, NULL); /* Set adaptivity method */ - if (check_flag(&flag, "ARKStepSetAdaptivityMethod", 1)) return 1; flag = ARKStepSetPredictorMethod(arkode_mem, 0); /* Set predictor method */ if (check_flag(&flag, "ARKStepSetPredictorMethod", 1)) return 1; + /* 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; @@ -309,13 +314,14 @@ int main() { /* Clean up and return with successful completion */ fclose(UFID); fclose(XFID); - N_VDestroy(y); /* Free vectors */ - free(udata->x_host); /* Free user data */ + N_VDestroy(y); /* Free vectors */ + free(udata->x_host); /* Free user data */ omp_target_free(udata->x_dev, dev); free(udata); - ARKStepFree(&arkode_mem); /* Free integrator memory */ - SUNLinSolFree(LS); /* Free linear solver */ - SUNContext_Free(&ctx); /* Free context */ + 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_parallel/ark_diurnal_kry_bbd_p.out b/examples/arkode/C_parallel/ark_diurnal_kry_bbd_p.out index 5d53186f79..8b997a01ec 100644 --- a/examples/arkode/C_parallel/ark_diurnal_kry_bbd_p.out +++ b/examples/arkode/C_parallel/ark_diurnal_kry_bbd_p.out @@ -7,68 +7,68 @@ Preconditioner type is: jpre = SUN_PREC_LEFT -t = 7.20e+03 no. steps = 979 stepsize = 3.07e+00 +t = 7.20e+03 no. steps = 92 stepsize = 6.86e+01 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 +t = 1.44e+04 no. steps = 143 stepsize = 3.61e+02 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 +t = 2.16e+04 no. steps = 167 stepsize = 4.81e+02 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 +t = 2.88e+04 no. steps = 190 stepsize = 1.74e+02 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 +t = 3.60e+04 no. steps = 235 stepsize = 7.82e+01 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 = 4.32e+04 no. steps = 288 stepsize = 1.38e+03 +At bottom left: c1, c2 = -3.383e-07 3.382e+11 +At top right: c1, c2 = 1.166e-06 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.04e+04 no. steps = 293 stepsize = 1.38e+03 +At bottom left: c1, c2 = 1.906e-06 3.358e+11 +At top right: c1, c2 = -3.074e-06 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 = 5.76e+04 no. steps = 299 stepsize = 2.78e+02 +At bottom left: c1, c2 = -1.808e-07 3.320e+11 +At top right: c1, c2 = -1.903e-07 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 = 6.48e+04 no. steps = 306 stepsize = 1.66e+03 +At bottom left: c1, c2 = -6.480e-06 3.313e+11 +At top right: c1, c2 = -2.126e-05 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.20e+04 no. steps = 311 stepsize = 1.66e+03 +At bottom left: c1, c2 = -4.534e-06 3.330e+11 +At top right: c1, c2 = -4.308e-05 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 = 7.92e+04 no. steps = 315 stepsize = 1.66e+03 +At bottom left: c1, c2 = -4.458e-07 3.334e+11 +At top right: c1, c2 = -3.945e-06 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 +t = 8.64e+04 no. steps = 319 stepsize = 1.66e+03 +At bottom left: c1, c2 = -1.792e-05 3.352e+11 +At top right: c1, c2 = -9.966e-06 4.163e+11 Final Statistics: -lenrw = 3901 leniw = 267 +lenrw = 4117 leniw = 278 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 +nst = 319 nfe = 0 +nfe = 4136 nfels = 7052 +nni = 2141 nli = 7052 +nsetups = 56 netf = 13 +npe = 6 nps = 9110 +ncfn = 0 ncfl = 145 In ARKBBDPRE: real/integer local work space sizes = 1300, 192 - no. flocal evals. = 2662 + no. flocal evals. = 132 ------------------------------------------------------------------- @@ -76,65 +76,65 @@ 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 +t = 7.20e+03 no. steps = 85 stepsize = 6.86e+01 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 +t = 1.44e+04 no. steps = 136 stepsize = 3.62e+02 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 +t = 2.16e+04 no. steps = 159 stepsize = 5.04e+02 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 +t = 2.88e+04 no. steps = 177 stepsize = 1.75e+02 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 +t = 3.60e+04 no. steps = 222 stepsize = 7.64e+01 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 +t = 4.32e+04 no. steps = 276 stepsize = 1.46e+03 +At bottom left: c1, c2 = 1.990e-08 3.382e+11 +At top right: c1, c2 = -2.506e-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 +t = 5.04e+04 no. steps = 281 stepsize = 1.46e+03 +At bottom left: c1, c2 = -3.995e-08 3.358e+11 +At top right: c1, c2 = -5.331e-13 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 +t = 5.76e+04 no. steps = 286 stepsize = 1.38e+03 +At bottom left: c1, c2 = -1.422e-07 3.320e+11 +At top right: c1, c2 = 1.218e-12 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 +t = 6.48e+04 no. steps = 292 stepsize = 1.24e+03 +At bottom left: c1, c2 = 3.867e-08 3.313e+11 +At top right: c1, c2 = -2.803e-11 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 +t = 7.20e+04 no. steps = 298 stepsize = 1.24e+03 +At bottom left: c1, c2 = 4.374e-08 3.330e+11 +At top right: c1, c2 = 2.249e-13 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 +t = 7.92e+04 no. steps = 304 stepsize = 1.24e+03 +At bottom left: c1, c2 = 3.558e-09 3.334e+11 +At top right: c1, c2 = 3.987e-12 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 +t = 8.64e+04 no. steps = 310 stepsize = 1.24e+03 +At bottom left: c1, c2 = -7.793e-08 3.352e+11 +At top right: c1, c2 = -7.031e-13 4.163e+11 Final Statistics: -lenrw = 3901 leniw = 272 +lenrw = 4117 leniw = 284 lenrwls = 2455 leniwls = 126 -nst = 7364 nfe = 0 -nfe = 77457 nfels = 101131 -nni = 40469 nli = 101131 -nsetups = 457 netf = 33 -npe = 124 nps = 138172 -ncfn = 0 ncfl = 0 +nst = 310 nfe = 0 +nfe = 4008 nfels = 7908 +nni = 2073 nli = 7908 +nsetups = 52 netf = 12 +npe = 6 nps = 9879 +ncfn = 0 ncfl = 660 In ARKBBDPRE: real/integer local work space sizes = 1300, 192 - no. flocal evals. = 2728 + no. flocal evals. = 132 diff --git a/examples/arkode/C_parallel/ark_diurnal_kry_p.out b/examples/arkode/C_parallel/ark_diurnal_kry_p.out index 97f07c3221..81c01387f1 100644 --- a/examples/arkode/C_parallel/ark_diurnal_kry_p.out +++ b/examples/arkode/C_parallel/ark_diurnal_kry_p.out @@ -1,63 +1,63 @@ 2-species diurnal advection-diffusion problem -t = 7.20e+03 no. steps = 979 stepsize = 3.07e+00 +t = 7.20e+03 no. steps = 91 stepsize = 6.86e+01 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 +t = 1.44e+04 no. steps = 142 stepsize = 3.58e+02 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 +t = 2.16e+04 no. steps = 165 stepsize = 4.84e+02 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 +t = 2.88e+04 no. steps = 183 stepsize = 1.94e+02 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 +t = 3.60e+04 no. steps = 224 stepsize = 6.74e+01 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 +t = 4.32e+04 no. steps = 280 stepsize = 1.46e+03 +At bottom left: c1, c2 = -1.635e-05 3.382e+11 +At top right: c1, c2 = 7.592e-05 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 +t = 5.04e+04 no. steps = 285 stepsize = 1.13e+03 +At bottom left: c1, c2 = -1.617e-05 3.358e+11 +At top right: c1, c2 = 2.484e-05 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 +t = 5.76e+04 no. steps = 294 stepsize = 2.51e+02 +At bottom left: c1, c2 = -3.858e-06 3.320e+11 +At top right: c1, c2 = -5.592e-05 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 +t = 6.48e+04 no. steps = 301 stepsize = 1.39e+03 +At bottom left: c1, c2 = -1.681e-14 3.313e+11 +At top right: c1, c2 = -2.246e-13 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 +t = 7.20e+04 no. steps = 307 stepsize = 1.39e+03 +At bottom left: c1, c2 = 3.768e-15 3.330e+11 +At top right: c1, c2 = -7.424e-14 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 +t = 7.92e+04 no. steps = 312 stepsize = 1.39e+03 +At bottom left: c1, c2 = 4.934e-15 3.334e+11 +At top right: c1, c2 = -1.683e-14 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 +t = 8.64e+04 no. steps = 317 stepsize = 1.39e+03 +At bottom left: c1, c2 = 1.368e-14 3.352e+11 +At top right: c1, c2 = -8.561e-14 4.163e+11 Final Statistics: -lenrw = 3301 leniw = 243 +lenrw = 3517 leniw = 254 lenrwls = 2455 leniwls = 126 -nst = 7103 nfe = 0 -nfi = 74602 nfels = 87206 -nni = 38944 nli = 87206 -nsetups = 431 netf = 28 -npe = 120 nps = 123894 -ncfn = 0 ncfl = 0 +nst = 317 nfe = 0 +nfi = 4164 nfels = 7564 +nni = 2181 nli = 7564 +nsetups = 57 netf = 13 +npe = 6 nps = 9655 +ncfn = 0 ncfl = 394 diff --git a/examples/arkode/C_parhyp/ark_diurnal_kry_ph.out b/examples/arkode/C_parhyp/ark_diurnal_kry_ph.out index 411f0a09fc..5bc28510c2 100644 --- a/examples/arkode/C_parhyp/ark_diurnal_kry_ph.out +++ b/examples/arkode/C_parhyp/ark_diurnal_kry_ph.out @@ -1,63 +1,63 @@ 2-species diurnal advection-diffusion problem -t = 7.20e+03 no. steps = 979 stepsize = 3.07e+00 +t = 7.20e+03 no. steps = 91 stepsize = 6.86e+01 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 +t = 1.44e+04 no. steps = 142 stepsize = 3.58e+02 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 +t = 2.16e+04 no. steps = 165 stepsize = 4.84e+02 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 +t = 2.88e+04 no. steps = 183 stepsize = 1.94e+02 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 +t = 3.60e+04 no. steps = 224 stepsize = 7.26e+01 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 +t = 4.32e+04 no. steps = 280 stepsize = 1.07e+03 +At bottom left: c1, c2 = -3.717e-06 3.382e+11 +At top right: c1, c2 = 8.794e-06 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 +t = 5.04e+04 no. steps = 290 stepsize = 6.03e+02 +At bottom left: c1, c2 = 1.353e-06 3.358e+11 +At top right: c1, c2 = 6.480e-06 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 +t = 5.76e+04 no. steps = 299 stepsize = 8.31e+02 +At bottom left: c1, c2 = -1.924e-12 3.320e+11 +At top right: c1, c2 = 5.092e-12 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 +t = 6.48e+04 no. steps = 305 stepsize = 1.74e+03 +At bottom left: c1, c2 = -1.837e-15 3.313e+11 +At top right: c1, c2 = -3.100e-14 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 +t = 7.20e+04 no. steps = 309 stepsize = 1.73e+03 +At bottom left: c1, c2 = 1.594e-14 3.330e+11 +At top right: c1, c2 = -4.194e-13 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 +t = 7.92e+04 no. steps = 313 stepsize = 1.73e+03 +At bottom left: c1, c2 = 4.506e-14 3.334e+11 +At top right: c1, c2 = -2.208e-13 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 +t = 8.64e+04 no. steps = 317 stepsize = 1.73e+03 +At bottom left: c1, c2 = 9.056e-14 3.352e+11 +At top right: c1, c2 = -2.662e-13 4.163e+11 Final Statistics: -lenrw = 3301 leniw = 243 +lenrw = 3517 leniw = 254 lenrwls = 2455 leniwls = 126 -nst = 7237 nfe = 0 -nfi = 75881 nfels = 88695 -nni = 39568 nli = 88695 -nsetups = 431 netf = 25 -npe = 121 nps = 126028 -ncfn = 0 ncfl = 0 +nst = 317 nfe = 0 +nfi = 4172 nfels = 7549 +nni = 2189 nli = 7549 +nsetups = 58 netf = 13 +npe = 6 nps = 9654 +ncfn = 0 ncfl = 372 diff --git a/examples/arkode/C_petsc/ark_petsc_ex25.c b/examples/arkode/C_petsc/ark_petsc_ex25.c index 9c144a9782..fd232418de 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; @@ -248,9 +251,10 @@ int main(int argc, char **argv) - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ /* Free SUNDIALS data structures */ - N_VDestroy(nvecx); /* Free x nvector */ - SUNNonlinSolFree(NLS); /* Free nonlinear solver */ - ARKStepFree(&arkode_mem); /* Free integrator memory */ + 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/C_serial/ark_KrylovDemo_prec.out b/examples/arkode/C_serial/ark_KrylovDemo_prec.out index 3a63a46785..929ddad95d 100644 --- a/examples/arkode/C_serial/ark_KrylovDemo_prec.out +++ b/examples/arkode/C_serial/ark_KrylovDemo_prec.out @@ -78,11 +78,11 @@ Species 6 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 +t = 1.00e-08 nst = 5 nfe = 0 nfi = 80 nni = 47 hu = 1.84e-07 -t = 1.00e-07 nst = 5 nfe = 0 nfi = 75 nni = 47 hu = 9.89e-08 +t = 1.00e-07 nst = 5 nfe = 0 nfi = 80 nni = 47 hu = 1.84e-07 -t = 1.00e-06 nst = 8 nfe = 0 nfi = 120 nni = 77 hu = 4.79e-07 +t = 1.00e-06 nst = 7 nfe = 0 nfi = 113 nni = 68 hu = 1.10e-06 c values at t = 1e-06: @@ -111,34 +111,34 @@ Species 3 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.498 13.4981 13.4981 13.4981 13.4981 13.498 +13.4981 14.5495 15.8919 15.8919 14.5495 13.4981 +13.4981 15.8919 19.0287 19.0287 15.8919 13.4981 +13.4981 15.8919 19.0287 19.0287 15.8919 13.4981 +13.4981 14.5495 15.8919 15.8919 14.5495 13.4981 +13.498 13.4981 13.4981 13.4981 13.4981 13.498 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.498 13.4981 13.4981 13.4981 13.4981 13.498 +13.4981 14.7783 16.4131 16.4131 14.7783 13.4981 +13.4981 16.4131 20.235 20.235 16.4131 13.4981 +13.4981 16.4131 20.235 20.235 16.4131 13.4981 +13.4981 14.7783 16.4131 16.4131 14.7783 13.4981 +13.498 13.4981 13.4981 13.4981 13.4981 13.498 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.498 13.4981 13.4981 13.4981 13.4981 13.498 +13.4981 15.007 16.9343 16.9343 15.007 13.4981 +13.4981 16.9343 21.4413 21.4413 16.9343 13.4981 +13.4981 16.9343 21.4413 21.4413 16.9343 13.4981 +13.4981 15.007 16.9343 16.9343 15.007 13.4981 +13.498 13.4981 13.4981 13.4981 13.4981 13.498 -t = 1.00e-05 nst = 27 nfe = 0 nfi = 407 nni = 269 hu = 4.79e-07 +t = 1.00e-05 nst = 15 nfe = 0 nfi = 241 nni = 148 hu = 1.10e-06 -t = 1.00e-04 nst = 106 nfe = 0 nfi = 1688 nni = 1155 hu = 1.70e-05 +t = 1.00e-04 nst = 54 nfe = 0 nfi = 982 nni = 655 hu = 3.03e-05 -t = 1.00e-03 nst = 110 nfe = 0 nfi = 1750 nni = 1197 hu = 1.51e-03 +t = 1.00e-03 nst = 57 nfe = 0 nfi = 1032 nni = 687 hu = 2.90e-03 c values at t = 0.001: @@ -167,41 +167,41 @@ Species 3 9.90776 9.93088 9.96016 9.96017 9.93092 9.90781 Species 4 -297231 297749 298392 298451 297925 297520 +297231 297749 298393 298451 297925 297520 297692 307245 319327 319378 307390 297925 298276 319264 345799 345840 319378 298451 -298276 319252 345772 345799 319327 298392 +298276 319252 345772 345799 319327 298393 297691 307208 319252 319264 307245 297749 297229 297691 298276 298276 297692 297231 Species 5 -297231 297749 298392 298451 297925 297520 +297231 297749 298393 298451 297925 297520 297692 307245 319327 319378 307390 297925 298276 319264 345799 345840 319378 298451 -298276 319252 345772 345799 319327 298392 +298276 319252 345772 345799 319327 298393 297691 307208 319252 319264 307245 297749 297229 297691 298276 298276 297692 297231 Species 6 -297231 297749 298392 298451 297925 297520 +297231 297749 298393 298451 297925 297520 297692 307245 319327 319378 307390 297925 298276 319264 345799 345840 319378 298451 -298276 319252 345772 345799 319327 298392 +298276 319252 345772 345799 319327 298393 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 +t = 1.00e-02 nst = 59 nfe = 0 nfi = 1074 nni = 717 hu = 1.01e-02 -t = 1.00e-01 nst = 127 nfe = 0 nfi = 2024 nni = 1386 hu = 1.28e-02 +t = 1.00e-01 nst = 65 nfe = 0 nfi = 1195 nni = 802 hu = 1.60e-02 -t = 1.00e+00 nst = 154 nfe = 0 nfi = 2489 nni = 1716 hu = 6.84e-02 +t = 1.00e+00 nst = 85 nfe = 0 nfi = 1602 nni = 1085 hu = 8.80e-02 c values at t = 1: Species 1 -1.58851 1.59924 1.62152 1.64764 1.67036 1.68149 +1.58851 1.59924 1.62152 1.64765 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.57757 1.58547 1.60239 1.62235 1.63952 1.64765 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 @@ -210,7 +210,7 @@ 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.57034 1.57626 1.58922 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 @@ -223,34 +223,34 @@ Species 3 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 +47718.4 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 +47389.7 47627 48135 48734.2 49249.6 49493.5 +47108.5 47286.1 47674.6 48135 48527.8 48709 +46876.6 47001.1 47286.1 47627 47914 48040.3 +46781.8 46876.6 47108.5 47389.7 47622.8 47718.4 Species 5 -47718.3 48040.3 48709 49493.5 50175.5 50509.4 +47718.4 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 +47389.7 47627 48135 48734.2 49249.6 49493.5 +47108.5 47286.1 47674.6 48135 48527.8 48709 +46876.6 47001.1 47286.1 47627 47914 48040.3 +46781.8 46876.6 47108.5 47389.7 47622.8 47718.4 Species 6 -47718.3 48040.3 48709 49493.5 50175.5 50509.4 +47718.4 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 +47389.7 47627 48135 48734.2 49249.6 49493.5 +47108.5 47286.1 47674.6 48135 48527.8 48709 +46876.6 47001.1 47286.1 47627 47914 48040.3 +46781.8 46876.6 47108.5 47389.7 47622.8 47718.4 -t = 2.00e+00 nst = 165 nfe = 0 nfi = 2661 nni = 1833 hu = 4.14e-02 +t = 2.00e+00 nst = 109 nfe = 0 nfi = 2054 nni = 1378 hu = 4.17e-02 -t = 3.00e+00 nst = 177 nfe = 0 nfi = 2848 nni = 1960 hu = 1.08e-01 +t = 3.00e+00 nst = 131 nfe = 0 nfi = 2440 nni = 1621 hu = 4.59e-02 -t = 4.00e+00 nst = 187 nfe = 0 nfi = 3013 nni = 2073 hu = 1.23e-01 +t = 4.00e+00 nst = 144 nfe = 0 nfi = 2672 nni = 1768 hu = 1.74e-01 c values at t = 4: @@ -279,34 +279,34 @@ Species 3 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 +35860.6 36110.2 36632.4 37246.5 37779.4 38038.7 +35784.2 36010.4 36490.4 37056.3 37545.3 37779.4 +35597.2 35782 36180.5 36651.6 37056.3 37246.5 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 +35860.6 36110.2 36632.4 37246.5 37779.4 38038.7 +35784.2 36010.4 36490.4 37056.3 37545.3 37779.4 +35597.2 35782 36180.5 36651.6 37056.3 37246.5 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 +35860.6 36110.2 36632.4 37246.5 37779.4 38038.7 +35784.2 36010.4 36490.4 37056.3 37545.3 37779.4 +35597.2 35782 36180.5 36651.6 37056.3 37246.5 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 +t = 5.00e+00 nst = 153 nfe = 0 nfi = 2824 nni = 1862 hu = 2.64e-01 -t = 6.00e+00 nst = 207 nfe = 0 nfi = 3336 nni = 2284 hu = 9.66e-02 +t = 6.00e+00 nst = 161 nfe = 0 nfi = 2950 nni = 1937 hu = 1.34e-01 -t = 7.00e+00 nst = 216 nfe = 0 nfi = 3477 nni = 2375 hu = 1.51e-01 +t = 7.00e+00 nst = 172 nfe = 0 nfi = 3130 nni = 2045 hu = 4.37e-02 c values at t = 7: @@ -335,34 +335,34 @@ Species 3 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 +35655.3 35903.6 36423.2 37034.1 37564.4 37822.3 +35579.3 35804.2 36281.9 36844.9 37331.5 37564.4 +35393.1 35577 35973.4 36442.4 36844.9 37034.1 +35168.4 35306.6 35611.5 35973.4 36281.9 36423.2 +34983.2 35081.2 35306.6 35577 35804.2 35903.6 +34908 34983.2 35168.4 35393.1 35579.3 35655.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 +35655.3 35903.6 36423.2 37034.1 37564.4 37822.3 +35579.3 35804.2 36281.9 36844.9 37331.5 37564.4 +35393.1 35577 35973.4 36442.4 36844.9 37034.1 +35168.4 35306.6 35611.5 35973.4 36281.9 36423.2 +34983.2 35081.2 35306.6 35577 35804.2 35903.6 +34908 34983.2 35168.4 35393.1 35579.3 35655.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 +35655.3 35903.6 36423.2 37034.1 37564.4 37822.3 +35579.3 35804.2 36281.9 36844.9 37331.5 37564.4 +35393.1 35577 35973.4 36442.4 36844.9 37034.1 +35168.4 35306.6 35611.5 35973.4 36281.9 36423.2 +34983.2 35081.2 35306.6 35577 35804.2 35903.6 +34908 34983.2 35168.4 35393.1 35579.3 35655.3 -t = 8.00e+00 nst = 232 nfe = 0 nfi = 3780 nni = 2567 hu = 1.06e-01 +t = 8.00e+00 nst = 181 nfe = 0 nfi = 3271 nni = 2129 hu = 1.68e-01 -t = 9.00e+00 nst = 249 nfe = 0 nfi = 4075 nni = 2742 hu = 8.61e-02 +t = 9.00e+00 nst = 190 nfe = 0 nfi = 3409 nni = 2208 hu = 8.39e-02 -t = 1.00e+01 nst = 266 nfe = 0 nfi = 4394 nni = 2941 hu = 8.37e-02 +t = 1.00e+01 nst = 204 nfe = 0 nfi = 3616 nni = 2325 hu = 2.20e-01 c values at t = 10: @@ -391,51 +391,51 @@ Species 3 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 +35650.6 35898.8 36418.3 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 +35388.4 35572.3 35968.7 36437.5 36840 37029.2 +35163.7 35301.9 35606.7 35968.7 36277.1 36418.3 +34978.6 35076.5 35301.9 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.9 36418.3 37029.2 37559.5 37817.3 +35574.6 35799.5 36277.1 36840 37326.6 37559.5 +35388.4 35572.3 35968.7 36437.5 36840 37029.2 +35163.7 35301.9 35606.7 35968.7 36277.1 36418.3 +34978.6 35076.5 35301.9 35572.3 35799.5 35898.9 +34903.3 34978.6 35163.7 35388.4 35574.6 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.9 36418.3 37029.2 37559.5 37817.3 +35574.6 35799.5 36277.1 36840 37326.6 37559.5 +35388.4 35572.3 35968.7 36437.5 36840 37029.2 +35163.7 35301.9 35606.7 35968.7 36277.1 36418.3 +34978.6 35076.5 35301.9 35572.3 35799.5 35898.9 +34903.3 34978.6 35163.7 35388.4 35574.6 35650.6 Final statistics for this run: - ARKStep real workspace length = 3557 - ARKStep integer workspace length = 131 + ARKStep real workspace length = 3789 + ARKStep integer workspace length = 135 ARKLS real workspace length = 2647 ARKLS integer workspace length = 42 - Number of steps = 266 + Number of steps = 204 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 + Number of f-s (implicit) = 3616 + Number of f-s (SPGMR) = 7769 + Number of f-s (TOTAL) = 7769 + Number of setups = 153 + Number of nonlinear iterations = 2325 + Number of linear iterations = 7769 + Number of preconditioner evaluations = 153 + Number of preconditioner solves = 10045 + Number of error test failures = 0 + Number of nonlinear conv. failures = 61 + Number of linear convergence failures = 512 + Average Krylov subspace dimension = 3.342 ---------------------------------------------------------------------------- @@ -447,64 +447,64 @@ Preconditioner type is jpre = SUN_PREC_LEFT Gram-Schmidt method type is gstype = SUN_CLASSICAL_GS -t = 1.00e-08 nst = 5 nfe = 0 nfi = 75 nni = 47 hu = 9.89e-08 +t = 1.00e-08 nst = 5 nfe = 0 nfi = 80 nni = 47 hu = 1.84e-07 -t = 1.00e-07 nst = 5 nfe = 0 nfi = 75 nni = 47 hu = 9.89e-08 +t = 1.00e-07 nst = 5 nfe = 0 nfi = 80 nni = 47 hu = 1.84e-07 -t = 1.00e-06 nst = 8 nfe = 0 nfi = 120 nni = 77 hu = 4.79e-07 +t = 1.00e-06 nst = 7 nfe = 0 nfi = 113 nni = 68 hu = 1.10e-06 -t = 1.00e-05 nst = 27 nfe = 0 nfi = 407 nni = 269 hu = 4.79e-07 +t = 1.00e-05 nst = 15 nfe = 0 nfi = 241 nni = 148 hu = 1.10e-06 -t = 1.00e-04 nst = 106 nfe = 0 nfi = 1688 nni = 1155 hu = 1.70e-05 +t = 1.00e-04 nst = 54 nfe = 0 nfi = 982 nni = 655 hu = 3.03e-05 -t = 1.00e-03 nst = 110 nfe = 0 nfi = 1750 nni = 1197 hu = 1.51e-03 +t = 1.00e-03 nst = 57 nfe = 0 nfi = 1032 nni = 687 hu = 2.90e-03 -t = 1.00e-02 nst = 113 nfe = 0 nfi = 1797 nni = 1229 hu = 3.46e-03 +t = 1.00e-02 nst = 59 nfe = 0 nfi = 1074 nni = 717 hu = 1.01e-02 -t = 1.00e-01 nst = 127 nfe = 0 nfi = 2024 nni = 1386 hu = 1.28e-02 +t = 1.00e-01 nst = 65 nfe = 0 nfi = 1195 nni = 802 hu = 1.60e-02 -t = 1.00e+00 nst = 154 nfe = 0 nfi = 2491 nni = 1718 hu = 7.60e-02 +t = 1.00e+00 nst = 85 nfe = 0 nfi = 1602 nni = 1085 hu = 8.80e-02 -t = 2.00e+00 nst = 169 nfe = 0 nfi = 2746 nni = 1896 hu = 8.04e-02 +t = 2.00e+00 nst = 109 nfe = 0 nfi = 2054 nni = 1378 hu = 4.17e-02 -t = 3.00e+00 nst = 181 nfe = 0 nfi = 2950 nni = 2036 hu = 1.01e-01 +t = 3.00e+00 nst = 131 nfe = 0 nfi = 2440 nni = 1621 hu = 4.59e-02 -t = 4.00e+00 nst = 189 nfe = 0 nfi = 3073 nni = 2119 hu = 1.33e-01 +t = 4.00e+00 nst = 144 nfe = 0 nfi = 2672 nni = 1768 hu = 1.74e-01 -t = 5.00e+00 nst = 199 nfe = 0 nfi = 3242 nni = 2227 hu = 9.38e-02 +t = 5.00e+00 nst = 155 nfe = 0 nfi = 2858 nni = 1883 hu = 2.21e-01 -t = 6.00e+00 nst = 211 nfe = 0 nfi = 3442 nni = 2352 hu = 1.13e-01 +t = 6.00e+00 nst = 164 nfe = 0 nfi = 3005 nni = 1972 hu = 5.16e-02 -t = 7.00e+00 nst = 220 nfe = 0 nfi = 3612 nni = 2457 hu = 1.07e-01 +t = 7.00e+00 nst = 175 nfe = 0 nfi = 3179 nni = 2076 hu = 1.37e-01 -t = 8.00e+00 nst = 229 nfe = 0 nfi = 3747 nni = 2537 hu = 1.33e-01 +t = 8.00e+00 nst = 183 nfe = 0 nfi = 3307 nni = 2153 hu = 3.10e-01 -t = 9.00e+00 nst = 239 nfe = 0 nfi = 3897 nni = 2622 hu = 8.98e-02 +t = 9.00e+00 nst = 191 nfe = 0 nfi = 3432 nni = 2226 hu = 6.05e-02 -t = 1.00e+01 nst = 251 nfe = 0 nfi = 4101 nni = 2746 hu = 7.09e-02 +t = 1.00e+01 nst = 198 nfe = 0 nfi = 3537 nni = 2286 hu = 2.45e-01 Final statistics for this run: - ARKStep real workspace length = 3557 - ARKStep integer workspace length = 136 + ARKStep real workspace length = 3789 + ARKStep integer workspace length = 141 ARKLS real workspace length = 2647 ARKLS integer workspace length = 42 - Number of steps = 251 + Number of steps = 198 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 + Number of f-s (implicit) = 3537 + Number of f-s (SPGMR) = 7647 + Number of f-s (TOTAL) = 7647 + Number of setups = 146 + Number of nonlinear iterations = 2286 + Number of linear iterations = 7647 + Number of preconditioner evaluations = 146 + Number of preconditioner solves = 9884 + Number of error test failures = 0 + Number of nonlinear conv. failures = 58 + Number of linear convergence failures = 498 + Average Krylov subspace dimension = 3.345 ---------------------------------------------------------------------------- @@ -516,64 +516,64 @@ Preconditioner type is jpre = SUN_PREC_RIGHT Gram-Schmidt method type is gstype = SUN_MODIFIED_GS -t = 1.00e-08 nst = 5 nfe = 0 nfi = 75 nni = 47 hu = 9.89e-08 +t = 1.00e-08 nst = 5 nfe = 0 nfi = 80 nni = 47 hu = 1.84e-07 -t = 1.00e-07 nst = 5 nfe = 0 nfi = 75 nni = 47 hu = 9.89e-08 +t = 1.00e-07 nst = 5 nfe = 0 nfi = 80 nni = 47 hu = 1.84e-07 -t = 1.00e-06 nst = 8 nfe = 0 nfi = 120 nni = 77 hu = 4.79e-07 +t = 1.00e-06 nst = 7 nfe = 0 nfi = 113 nni = 68 hu = 1.10e-06 -t = 1.00e-05 nst = 27 nfe = 0 nfi = 407 nni = 269 hu = 4.79e-07 +t = 1.00e-05 nst = 15 nfe = 0 nfi = 241 nni = 148 hu = 1.10e-06 -t = 1.00e-04 nst = 106 nfe = 0 nfi = 1688 nni = 1155 hu = 1.70e-05 +t = 1.00e-04 nst = 54 nfe = 0 nfi = 982 nni = 655 hu = 3.03e-05 -t = 1.00e-03 nst = 110 nfe = 0 nfi = 1750 nni = 1197 hu = 1.50e-03 +t = 1.00e-03 nst = 57 nfe = 0 nfi = 1032 nni = 687 hu = 2.86e-03 -t = 1.00e-02 nst = 113 nfe = 0 nfi = 1797 nni = 1229 hu = 3.42e-03 +t = 1.00e-02 nst = 59 nfe = 0 nfi = 1087 nni = 726 hu = 2.51e-03 -t = 1.00e-01 nst = 127 nfe = 0 nfi = 2023 nni = 1385 hu = 1.23e-02 +t = 1.00e-01 nst = 72 nfe = 0 nfi = 1379 nni = 928 hu = 6.16e-03 -t = 1.00e+00 nst = 166 nfe = 0 nfi = 2714 nni = 1875 hu = 2.40e-02 +t = 1.00e+00 nst = 124 nfe = 0 nfi = 2392 nni = 1598 hu = 2.32e-02 -t = 2.00e+00 nst = 214 nfe = 0 nfi = 3550 nni = 2460 hu = 2.34e-02 +t = 2.00e+00 nst = 150 nfe = 0 nfi = 2860 nni = 1897 hu = 6.35e-02 -t = 3.00e+00 nst = 249 nfe = 0 nfi = 4111 nni = 2846 hu = 3.57e-02 +t = 3.00e+00 nst = 178 nfe = 0 nfi = 3418 nni = 2255 hu = 4.48e-02 -t = 4.00e+00 nst = 272 nfe = 0 nfi = 4472 nni = 3092 hu = 5.08e-02 +t = 4.00e+00 nst = 197 nfe = 0 nfi = 3756 nni = 2466 hu = 8.37e-02 -t = 5.00e+00 nst = 297 nfe = 0 nfi = 4851 nni = 3346 hu = 5.14e-02 +t = 5.00e+00 nst = 208 nfe = 0 nfi = 3941 nni = 2580 hu = 9.06e-02 -t = 6.00e+00 nst = 315 nfe = 0 nfi = 5117 nni = 3522 hu = 6.88e-02 +t = 6.00e+00 nst = 228 nfe = 0 nfi = 4280 nni = 2784 hu = 7.04e-02 -t = 7.00e+00 nst = 328 nfe = 0 nfi = 5302 nni = 3642 hu = 8.22e-02 +t = 7.00e+00 nst = 244 nfe = 0 nfi = 4544 nni = 2940 hu = 7.42e-02 -t = 8.00e+00 nst = 338 nfe = 0 nfi = 5441 nni = 3731 hu = 8.52e-02 +t = 8.00e+00 nst = 259 nfe = 0 nfi = 4788 nni = 3082 hu = 1.29e-01 -t = 9.00e+00 nst = 349 nfe = 0 nfi = 5592 nni = 3827 hu = 1.11e-01 +t = 9.00e+00 nst = 270 nfe = 0 nfi = 4955 nni = 3175 hu = 9.00e-02 -t = 1.00e+01 nst = 359 nfe = 0 nfi = 5722 nni = 3907 hu = 1.35e-01 +t = 1.00e+01 nst = 283 nfe = 0 nfi = 5157 nni = 3288 hu = 2.00e-01 Final statistics for this run: - ARKStep real workspace length = 3557 - ARKStep integer workspace length = 141 + ARKStep real workspace length = 3789 + ARKStep integer workspace length = 147 ARKLS real workspace length = 2647 ARKLS integer workspace length = 42 - Number of steps = 359 + Number of steps = 283 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 f-s (implicit) = 5157 + Number of f-s (SPGMR) = 11709 + Number of f-s (TOTAL) = 11709 + Number of setups = 279 + Number of nonlinear iterations = 3288 + Number of linear iterations = 11709 + Number of preconditioner evaluations = 279 + Number of preconditioner solves = 14769 Number of error test failures = 0 - Number of nonlinear conv. failures = 117 - Number of linear convergence failures = 1072 - Average Krylov subspace dimension = 3.303 + Number of nonlinear conv. failures = 147 + Number of linear convergence failures = 1039 + Average Krylov subspace dimension = 3.561 ---------------------------------------------------------------------------- @@ -585,64 +585,64 @@ Preconditioner type is jpre = SUN_PREC_RIGHT Gram-Schmidt method type is gstype = SUN_CLASSICAL_GS -t = 1.00e-08 nst = 5 nfe = 0 nfi = 75 nni = 47 hu = 9.89e-08 +t = 1.00e-08 nst = 5 nfe = 0 nfi = 80 nni = 47 hu = 1.84e-07 -t = 1.00e-07 nst = 5 nfe = 0 nfi = 75 nni = 47 hu = 9.89e-08 +t = 1.00e-07 nst = 5 nfe = 0 nfi = 80 nni = 47 hu = 1.84e-07 -t = 1.00e-06 nst = 8 nfe = 0 nfi = 120 nni = 77 hu = 4.79e-07 +t = 1.00e-06 nst = 7 nfe = 0 nfi = 113 nni = 68 hu = 1.10e-06 -t = 1.00e-05 nst = 27 nfe = 0 nfi = 407 nni = 269 hu = 4.79e-07 +t = 1.00e-05 nst = 15 nfe = 0 nfi = 241 nni = 148 hu = 1.10e-06 -t = 1.00e-04 nst = 106 nfe = 0 nfi = 1688 nni = 1155 hu = 1.70e-05 +t = 1.00e-04 nst = 54 nfe = 0 nfi = 982 nni = 655 hu = 3.03e-05 -t = 1.00e-03 nst = 110 nfe = 0 nfi = 1750 nni = 1197 hu = 1.50e-03 +t = 1.00e-03 nst = 57 nfe = 0 nfi = 1032 nni = 687 hu = 2.86e-03 -t = 1.00e-02 nst = 113 nfe = 0 nfi = 1797 nni = 1229 hu = 3.42e-03 +t = 1.00e-02 nst = 59 nfe = 0 nfi = 1087 nni = 726 hu = 2.51e-03 -t = 1.00e-01 nst = 127 nfe = 0 nfi = 2023 nni = 1385 hu = 1.23e-02 +t = 1.00e-01 nst = 72 nfe = 0 nfi = 1379 nni = 928 hu = 6.16e-03 -t = 1.00e+00 nst = 166 nfe = 0 nfi = 2714 nni = 1875 hu = 2.40e-02 +t = 1.00e+00 nst = 124 nfe = 0 nfi = 2392 nni = 1598 hu = 2.32e-02 -t = 2.00e+00 nst = 214 nfe = 0 nfi = 3556 nni = 2465 hu = 2.34e-02 +t = 2.00e+00 nst = 150 nfe = 0 nfi = 2860 nni = 1897 hu = 6.35e-02 -t = 3.00e+00 nst = 249 nfe = 0 nfi = 4117 nni = 2851 hu = 3.57e-02 +t = 3.00e+00 nst = 178 nfe = 0 nfi = 3418 nni = 2255 hu = 4.48e-02 -t = 4.00e+00 nst = 272 nfe = 0 nfi = 4478 nni = 3097 hu = 5.08e-02 +t = 4.00e+00 nst = 197 nfe = 0 nfi = 3756 nni = 2466 hu = 8.37e-02 -t = 5.00e+00 nst = 297 nfe = 0 nfi = 4857 nni = 3351 hu = 5.14e-02 +t = 5.00e+00 nst = 208 nfe = 0 nfi = 3941 nni = 2580 hu = 9.05e-02 -t = 6.00e+00 nst = 315 nfe = 0 nfi = 5123 nni = 3527 hu = 6.89e-02 +t = 6.00e+00 nst = 227 nfe = 0 nfi = 4268 nni = 2778 hu = 9.21e-02 -t = 7.00e+00 nst = 328 nfe = 0 nfi = 5308 nni = 3647 hu = 9.31e-02 +t = 7.00e+00 nst = 244 nfe = 0 nfi = 4545 nni = 2941 hu = 6.08e-02 -t = 8.00e+00 nst = 339 nfe = 0 nfi = 5464 nni = 3748 hu = 9.70e-02 +t = 8.00e+00 nst = 257 nfe = 0 nfi = 4757 nni = 3065 hu = 1.08e-01 -t = 9.00e+00 nst = 349 nfe = 0 nfi = 5598 nni = 3832 hu = 1.12e-01 +t = 9.00e+00 nst = 272 nfe = 0 nfi = 4990 nni = 3196 hu = 5.14e-02 -t = 1.00e+01 nst = 359 nfe = 0 nfi = 5728 nni = 3912 hu = 1.31e-01 +t = 1.00e+01 nst = 282 nfe = 0 nfi = 5143 nni = 3281 hu = 1.22e-01 Final statistics for this run: - ARKStep real workspace length = 3557 - ARKStep integer workspace length = 146 + ARKStep real workspace length = 3789 + ARKStep integer workspace length = 153 ARKLS real workspace length = 2647 ARKLS integer workspace length = 42 - Number of steps = 359 + Number of steps = 282 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 f-s (implicit) = 5143 + Number of f-s (SPGMR) = 11673 + Number of f-s (TOTAL) = 11673 + Number of setups = 277 + Number of nonlinear iterations = 3281 + Number of linear iterations = 11673 + Number of preconditioner evaluations = 277 + Number of preconditioner solves = 14718 Number of error test failures = 0 - Number of nonlinear conv. failures = 118 - Number of linear convergence failures = 1076 - Average Krylov subspace dimension = 3.306 + Number of nonlinear conv. failures = 146 + Number of linear convergence failures = 1030 + Average Krylov subspace dimension = 3.558 ---------------------------------------------------------------------------- diff --git a/examples/arkode/C_serial/ark_KrylovDemo_prec_1.out b/examples/arkode/C_serial/ark_KrylovDemo_prec_1.out index 58b34e703d..929ddad95d 100644 --- a/examples/arkode/C_serial/ark_KrylovDemo_prec_1.out +++ b/examples/arkode/C_serial/ark_KrylovDemo_prec_1.out @@ -78,11 +78,11 @@ Species 6 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 +t = 1.00e-08 nst = 5 nfe = 0 nfi = 80 nni = 47 hu = 1.84e-07 -t = 1.00e-07 nst = 5 nfe = 0 nfi = 75 nni = 47 hu = 9.89e-08 +t = 1.00e-07 nst = 5 nfe = 0 nfi = 80 nni = 47 hu = 1.84e-07 -t = 1.00e-06 nst = 8 nfe = 0 nfi = 120 nni = 77 hu = 4.79e-07 +t = 1.00e-06 nst = 7 nfe = 0 nfi = 113 nni = 68 hu = 1.10e-06 c values at t = 1e-06: @@ -111,34 +111,34 @@ Species 3 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.498 13.4981 13.4981 13.4981 13.4981 13.498 +13.4981 14.5495 15.8919 15.8919 14.5495 13.4981 +13.4981 15.8919 19.0287 19.0287 15.8919 13.4981 +13.4981 15.8919 19.0287 19.0287 15.8919 13.4981 +13.4981 14.5495 15.8919 15.8919 14.5495 13.4981 +13.498 13.4981 13.4981 13.4981 13.4981 13.498 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.498 13.4981 13.4981 13.4981 13.4981 13.498 +13.4981 14.7783 16.4131 16.4131 14.7783 13.4981 +13.4981 16.4131 20.235 20.235 16.4131 13.4981 +13.4981 16.4131 20.235 20.235 16.4131 13.4981 +13.4981 14.7783 16.4131 16.4131 14.7783 13.4981 +13.498 13.4981 13.4981 13.4981 13.4981 13.498 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.498 13.4981 13.4981 13.4981 13.4981 13.498 +13.4981 15.007 16.9343 16.9343 15.007 13.4981 +13.4981 16.9343 21.4413 21.4413 16.9343 13.4981 +13.4981 16.9343 21.4413 21.4413 16.9343 13.4981 +13.4981 15.007 16.9343 16.9343 15.007 13.4981 +13.498 13.4981 13.4981 13.4981 13.4981 13.498 -t = 1.00e-05 nst = 27 nfe = 0 nfi = 407 nni = 269 hu = 4.79e-07 +t = 1.00e-05 nst = 15 nfe = 0 nfi = 241 nni = 148 hu = 1.10e-06 -t = 1.00e-04 nst = 106 nfe = 0 nfi = 1688 nni = 1155 hu = 1.70e-05 +t = 1.00e-04 nst = 54 nfe = 0 nfi = 982 nni = 655 hu = 3.03e-05 -t = 1.00e-03 nst = 110 nfe = 0 nfi = 1750 nni = 1197 hu = 1.51e-03 +t = 1.00e-03 nst = 57 nfe = 0 nfi = 1032 nni = 687 hu = 2.90e-03 c values at t = 0.001: @@ -167,41 +167,41 @@ Species 3 9.90776 9.93088 9.96016 9.96017 9.93092 9.90781 Species 4 -297231 297749 298392 298451 297925 297520 +297231 297749 298393 298451 297925 297520 297692 307245 319327 319378 307390 297925 298276 319264 345799 345840 319378 298451 -298276 319252 345772 345799 319327 298392 +298276 319252 345772 345799 319327 298393 297691 307208 319252 319264 307245 297749 297229 297691 298276 298276 297692 297231 Species 5 -297231 297749 298392 298451 297925 297520 +297231 297749 298393 298451 297925 297520 297692 307245 319327 319378 307390 297925 298276 319264 345799 345840 319378 298451 -298276 319252 345772 345799 319327 298392 +298276 319252 345772 345799 319327 298393 297691 307208 319252 319264 307245 297749 297229 297691 298276 298276 297692 297231 Species 6 -297231 297749 298392 298451 297925 297520 +297231 297749 298393 298451 297925 297520 297692 307245 319327 319378 307390 297925 298276 319264 345799 345840 319378 298451 -298276 319252 345772 345799 319327 298392 +298276 319252 345772 345799 319327 298393 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 +t = 1.00e-02 nst = 59 nfe = 0 nfi = 1074 nni = 717 hu = 1.01e-02 -t = 1.00e-01 nst = 127 nfe = 0 nfi = 2024 nni = 1386 hu = 1.28e-02 +t = 1.00e-01 nst = 65 nfe = 0 nfi = 1195 nni = 802 hu = 1.60e-02 -t = 1.00e+00 nst = 154 nfe = 0 nfi = 2489 nni = 1716 hu = 6.84e-02 +t = 1.00e+00 nst = 85 nfe = 0 nfi = 1602 nni = 1085 hu = 8.80e-02 c values at t = 1: Species 1 -1.58851 1.59924 1.62152 1.64764 1.67036 1.68149 +1.58851 1.59924 1.62152 1.64765 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.57757 1.58547 1.60239 1.62235 1.63952 1.64765 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 @@ -210,7 +210,7 @@ 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.57034 1.57626 1.58922 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 @@ -223,34 +223,34 @@ Species 3 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 +47718.4 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 +47389.7 47627 48135 48734.2 49249.6 49493.5 +47108.5 47286.1 47674.6 48135 48527.8 48709 +46876.6 47001.1 47286.1 47627 47914 48040.3 +46781.8 46876.6 47108.5 47389.7 47622.8 47718.4 Species 5 -47718.3 48040.3 48709 49493.5 50175.5 50509.4 +47718.4 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 +47389.7 47627 48135 48734.2 49249.6 49493.5 +47108.5 47286.1 47674.6 48135 48527.8 48709 +46876.6 47001.1 47286.1 47627 47914 48040.3 +46781.8 46876.6 47108.5 47389.7 47622.8 47718.4 Species 6 -47718.3 48040.3 48709 49493.5 50175.5 50509.4 +47718.4 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 +47389.7 47627 48135 48734.2 49249.6 49493.5 +47108.5 47286.1 47674.6 48135 48527.8 48709 +46876.6 47001.1 47286.1 47627 47914 48040.3 +46781.8 46876.6 47108.5 47389.7 47622.8 47718.4 -t = 2.00e+00 nst = 165 nfe = 0 nfi = 2661 nni = 1833 hu = 4.14e-02 +t = 2.00e+00 nst = 109 nfe = 0 nfi = 2054 nni = 1378 hu = 4.17e-02 -t = 3.00e+00 nst = 177 nfe = 0 nfi = 2848 nni = 1960 hu = 1.08e-01 +t = 3.00e+00 nst = 131 nfe = 0 nfi = 2440 nni = 1621 hu = 4.59e-02 -t = 4.00e+00 nst = 187 nfe = 0 nfi = 3013 nni = 2073 hu = 1.23e-01 +t = 4.00e+00 nst = 144 nfe = 0 nfi = 2672 nni = 1768 hu = 1.74e-01 c values at t = 4: @@ -279,34 +279,34 @@ Species 3 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 +35860.6 36110.2 36632.4 37246.5 37779.4 38038.7 +35784.2 36010.4 36490.4 37056.3 37545.3 37779.4 +35597.2 35782 36180.5 36651.6 37056.3 37246.5 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 +35860.6 36110.2 36632.4 37246.5 37779.4 38038.7 +35784.2 36010.4 36490.4 37056.3 37545.3 37779.4 +35597.2 35782 36180.5 36651.6 37056.3 37246.5 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 +35860.6 36110.2 36632.4 37246.5 37779.4 38038.7 +35784.2 36010.4 36490.4 37056.3 37545.3 37779.4 +35597.2 35782 36180.5 36651.6 37056.3 37246.5 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 +t = 5.00e+00 nst = 153 nfe = 0 nfi = 2824 nni = 1862 hu = 2.64e-01 -t = 6.00e+00 nst = 207 nfe = 0 nfi = 3336 nni = 2284 hu = 9.66e-02 +t = 6.00e+00 nst = 161 nfe = 0 nfi = 2950 nni = 1937 hu = 1.34e-01 -t = 7.00e+00 nst = 216 nfe = 0 nfi = 3477 nni = 2375 hu = 1.51e-01 +t = 7.00e+00 nst = 172 nfe = 0 nfi = 3130 nni = 2045 hu = 4.37e-02 c values at t = 7: @@ -335,34 +335,34 @@ Species 3 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 +35655.3 35903.6 36423.2 37034.1 37564.4 37822.3 +35579.3 35804.2 36281.9 36844.9 37331.5 37564.4 +35393.1 35577 35973.4 36442.4 36844.9 37034.1 +35168.4 35306.6 35611.5 35973.4 36281.9 36423.2 +34983.2 35081.2 35306.6 35577 35804.2 35903.6 +34908 34983.2 35168.4 35393.1 35579.3 35655.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 +35655.3 35903.6 36423.2 37034.1 37564.4 37822.3 +35579.3 35804.2 36281.9 36844.9 37331.5 37564.4 +35393.1 35577 35973.4 36442.4 36844.9 37034.1 +35168.4 35306.6 35611.5 35973.4 36281.9 36423.2 +34983.2 35081.2 35306.6 35577 35804.2 35903.6 +34908 34983.2 35168.4 35393.1 35579.3 35655.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 +35655.3 35903.6 36423.2 37034.1 37564.4 37822.3 +35579.3 35804.2 36281.9 36844.9 37331.5 37564.4 +35393.1 35577 35973.4 36442.4 36844.9 37034.1 +35168.4 35306.6 35611.5 35973.4 36281.9 36423.2 +34983.2 35081.2 35306.6 35577 35804.2 35903.6 +34908 34983.2 35168.4 35393.1 35579.3 35655.3 -t = 8.00e+00 nst = 232 nfe = 0 nfi = 3780 nni = 2567 hu = 1.06e-01 +t = 8.00e+00 nst = 181 nfe = 0 nfi = 3271 nni = 2129 hu = 1.68e-01 -t = 9.00e+00 nst = 249 nfe = 0 nfi = 4075 nni = 2742 hu = 8.61e-02 +t = 9.00e+00 nst = 190 nfe = 0 nfi = 3409 nni = 2208 hu = 8.39e-02 -t = 1.00e+01 nst = 266 nfe = 0 nfi = 4394 nni = 2941 hu = 8.37e-02 +t = 1.00e+01 nst = 204 nfe = 0 nfi = 3616 nni = 2325 hu = 2.20e-01 c values at t = 10: @@ -391,51 +391,51 @@ Species 3 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 +35650.6 35898.8 36418.3 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 +35388.4 35572.3 35968.7 36437.5 36840 37029.2 +35163.7 35301.9 35606.7 35968.7 36277.1 36418.3 +34978.6 35076.5 35301.9 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.9 36418.3 37029.2 37559.5 37817.3 +35574.6 35799.5 36277.1 36840 37326.6 37559.5 +35388.4 35572.3 35968.7 36437.5 36840 37029.2 +35163.7 35301.9 35606.7 35968.7 36277.1 36418.3 +34978.6 35076.5 35301.9 35572.3 35799.5 35898.9 +34903.3 34978.6 35163.7 35388.4 35574.6 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.9 36418.3 37029.2 37559.5 37817.3 +35574.6 35799.5 36277.1 36840 37326.6 37559.5 +35388.4 35572.3 35968.7 36437.5 36840 37029.2 +35163.7 35301.9 35606.7 35968.7 36277.1 36418.3 +34978.6 35076.5 35301.9 35572.3 35799.5 35898.9 +34903.3 34978.6 35163.7 35388.4 35574.6 35650.6 Final statistics for this run: - ARKStep real workspace length = 3557 - ARKStep integer workspace length = 131 + ARKStep real workspace length = 3789 + ARKStep integer workspace length = 135 ARKLS real workspace length = 2647 ARKLS integer workspace length = 42 - Number of steps = 266 + Number of steps = 204 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 + Number of f-s (implicit) = 3616 + Number of f-s (SPGMR) = 7769 + Number of f-s (TOTAL) = 7769 + Number of setups = 153 + Number of nonlinear iterations = 2325 + Number of linear iterations = 7769 + Number of preconditioner evaluations = 153 + Number of preconditioner solves = 10045 + Number of error test failures = 0 + Number of nonlinear conv. failures = 61 + Number of linear convergence failures = 512 + Average Krylov subspace dimension = 3.342 ---------------------------------------------------------------------------- @@ -447,64 +447,64 @@ Preconditioner type is jpre = SUN_PREC_LEFT Gram-Schmidt method type is gstype = SUN_CLASSICAL_GS -t = 1.00e-08 nst = 5 nfe = 0 nfi = 75 nni = 47 hu = 9.89e-08 +t = 1.00e-08 nst = 5 nfe = 0 nfi = 80 nni = 47 hu = 1.84e-07 -t = 1.00e-07 nst = 5 nfe = 0 nfi = 75 nni = 47 hu = 9.89e-08 +t = 1.00e-07 nst = 5 nfe = 0 nfi = 80 nni = 47 hu = 1.84e-07 -t = 1.00e-06 nst = 8 nfe = 0 nfi = 120 nni = 77 hu = 4.79e-07 +t = 1.00e-06 nst = 7 nfe = 0 nfi = 113 nni = 68 hu = 1.10e-06 -t = 1.00e-05 nst = 27 nfe = 0 nfi = 407 nni = 269 hu = 4.79e-07 +t = 1.00e-05 nst = 15 nfe = 0 nfi = 241 nni = 148 hu = 1.10e-06 -t = 1.00e-04 nst = 106 nfe = 0 nfi = 1688 nni = 1155 hu = 1.70e-05 +t = 1.00e-04 nst = 54 nfe = 0 nfi = 982 nni = 655 hu = 3.03e-05 -t = 1.00e-03 nst = 110 nfe = 0 nfi = 1750 nni = 1197 hu = 1.51e-03 +t = 1.00e-03 nst = 57 nfe = 0 nfi = 1032 nni = 687 hu = 2.90e-03 -t = 1.00e-02 nst = 113 nfe = 0 nfi = 1797 nni = 1229 hu = 3.46e-03 +t = 1.00e-02 nst = 59 nfe = 0 nfi = 1074 nni = 717 hu = 1.01e-02 -t = 1.00e-01 nst = 127 nfe = 0 nfi = 2024 nni = 1386 hu = 1.28e-02 +t = 1.00e-01 nst = 65 nfe = 0 nfi = 1195 nni = 802 hu = 1.60e-02 -t = 1.00e+00 nst = 154 nfe = 0 nfi = 2491 nni = 1718 hu = 7.60e-02 +t = 1.00e+00 nst = 85 nfe = 0 nfi = 1602 nni = 1085 hu = 8.80e-02 -t = 2.00e+00 nst = 169 nfe = 0 nfi = 2746 nni = 1896 hu = 8.04e-02 +t = 2.00e+00 nst = 109 nfe = 0 nfi = 2054 nni = 1378 hu = 4.17e-02 -t = 3.00e+00 nst = 181 nfe = 0 nfi = 2950 nni = 2036 hu = 1.01e-01 +t = 3.00e+00 nst = 131 nfe = 0 nfi = 2440 nni = 1621 hu = 4.59e-02 -t = 4.00e+00 nst = 189 nfe = 0 nfi = 3073 nni = 2119 hu = 1.33e-01 +t = 4.00e+00 nst = 144 nfe = 0 nfi = 2672 nni = 1768 hu = 1.74e-01 -t = 5.00e+00 nst = 199 nfe = 0 nfi = 3242 nni = 2227 hu = 9.38e-02 +t = 5.00e+00 nst = 155 nfe = 0 nfi = 2858 nni = 1883 hu = 2.21e-01 -t = 6.00e+00 nst = 211 nfe = 0 nfi = 3442 nni = 2352 hu = 1.13e-01 +t = 6.00e+00 nst = 164 nfe = 0 nfi = 3005 nni = 1972 hu = 5.16e-02 -t = 7.00e+00 nst = 220 nfe = 0 nfi = 3612 nni = 2457 hu = 1.07e-01 +t = 7.00e+00 nst = 175 nfe = 0 nfi = 3179 nni = 2076 hu = 1.37e-01 -t = 8.00e+00 nst = 229 nfe = 0 nfi = 3747 nni = 2537 hu = 1.33e-01 +t = 8.00e+00 nst = 183 nfe = 0 nfi = 3307 nni = 2153 hu = 3.10e-01 -t = 9.00e+00 nst = 239 nfe = 0 nfi = 3897 nni = 2622 hu = 8.98e-02 +t = 9.00e+00 nst = 191 nfe = 0 nfi = 3432 nni = 2226 hu = 6.05e-02 -t = 1.00e+01 nst = 251 nfe = 0 nfi = 4101 nni = 2746 hu = 7.09e-02 +t = 1.00e+01 nst = 198 nfe = 0 nfi = 3537 nni = 2286 hu = 2.45e-01 Final statistics for this run: - ARKStep real workspace length = 3557 - ARKStep integer workspace length = 136 + ARKStep real workspace length = 3789 + ARKStep integer workspace length = 141 ARKLS real workspace length = 2647 ARKLS integer workspace length = 42 - Number of steps = 251 + Number of steps = 198 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 + Number of f-s (implicit) = 3537 + Number of f-s (SPGMR) = 7647 + Number of f-s (TOTAL) = 7647 + Number of setups = 146 + Number of nonlinear iterations = 2286 + Number of linear iterations = 7647 + Number of preconditioner evaluations = 146 + Number of preconditioner solves = 9884 + Number of error test failures = 0 + Number of nonlinear conv. failures = 58 + Number of linear convergence failures = 498 + Average Krylov subspace dimension = 3.345 ---------------------------------------------------------------------------- @@ -516,64 +516,64 @@ Preconditioner type is jpre = SUN_PREC_RIGHT Gram-Schmidt method type is gstype = SUN_MODIFIED_GS -t = 1.00e-08 nst = 5 nfe = 0 nfi = 75 nni = 47 hu = 9.89e-08 +t = 1.00e-08 nst = 5 nfe = 0 nfi = 80 nni = 47 hu = 1.84e-07 -t = 1.00e-07 nst = 5 nfe = 0 nfi = 75 nni = 47 hu = 9.89e-08 +t = 1.00e-07 nst = 5 nfe = 0 nfi = 80 nni = 47 hu = 1.84e-07 -t = 1.00e-06 nst = 8 nfe = 0 nfi = 120 nni = 77 hu = 4.79e-07 +t = 1.00e-06 nst = 7 nfe = 0 nfi = 113 nni = 68 hu = 1.10e-06 -t = 1.00e-05 nst = 27 nfe = 0 nfi = 407 nni = 269 hu = 4.79e-07 +t = 1.00e-05 nst = 15 nfe = 0 nfi = 241 nni = 148 hu = 1.10e-06 -t = 1.00e-04 nst = 106 nfe = 0 nfi = 1688 nni = 1155 hu = 1.70e-05 +t = 1.00e-04 nst = 54 nfe = 0 nfi = 982 nni = 655 hu = 3.03e-05 -t = 1.00e-03 nst = 110 nfe = 0 nfi = 1750 nni = 1197 hu = 1.50e-03 +t = 1.00e-03 nst = 57 nfe = 0 nfi = 1032 nni = 687 hu = 2.86e-03 -t = 1.00e-02 nst = 113 nfe = 0 nfi = 1797 nni = 1229 hu = 3.42e-03 +t = 1.00e-02 nst = 59 nfe = 0 nfi = 1087 nni = 726 hu = 2.51e-03 -t = 1.00e-01 nst = 127 nfe = 0 nfi = 2023 nni = 1385 hu = 1.23e-02 +t = 1.00e-01 nst = 72 nfe = 0 nfi = 1379 nni = 928 hu = 6.16e-03 -t = 1.00e+00 nst = 166 nfe = 0 nfi = 2714 nni = 1875 hu = 2.40e-02 +t = 1.00e+00 nst = 124 nfe = 0 nfi = 2392 nni = 1598 hu = 2.32e-02 -t = 2.00e+00 nst = 214 nfe = 0 nfi = 3550 nni = 2460 hu = 2.34e-02 +t = 2.00e+00 nst = 150 nfe = 0 nfi = 2860 nni = 1897 hu = 6.35e-02 -t = 3.00e+00 nst = 249 nfe = 0 nfi = 4111 nni = 2846 hu = 3.57e-02 +t = 3.00e+00 nst = 178 nfe = 0 nfi = 3418 nni = 2255 hu = 4.48e-02 -t = 4.00e+00 nst = 272 nfe = 0 nfi = 4472 nni = 3092 hu = 5.08e-02 +t = 4.00e+00 nst = 197 nfe = 0 nfi = 3756 nni = 2466 hu = 8.37e-02 -t = 5.00e+00 nst = 297 nfe = 0 nfi = 4851 nni = 3346 hu = 5.14e-02 +t = 5.00e+00 nst = 208 nfe = 0 nfi = 3941 nni = 2580 hu = 9.06e-02 -t = 6.00e+00 nst = 315 nfe = 0 nfi = 5117 nni = 3522 hu = 6.88e-02 +t = 6.00e+00 nst = 228 nfe = 0 nfi = 4280 nni = 2784 hu = 7.04e-02 -t = 7.00e+00 nst = 328 nfe = 0 nfi = 5302 nni = 3642 hu = 8.22e-02 +t = 7.00e+00 nst = 244 nfe = 0 nfi = 4544 nni = 2940 hu = 7.42e-02 -t = 8.00e+00 nst = 338 nfe = 0 nfi = 5441 nni = 3731 hu = 8.52e-02 +t = 8.00e+00 nst = 259 nfe = 0 nfi = 4788 nni = 3082 hu = 1.29e-01 -t = 9.00e+00 nst = 349 nfe = 0 nfi = 5592 nni = 3827 hu = 1.11e-01 +t = 9.00e+00 nst = 270 nfe = 0 nfi = 4955 nni = 3175 hu = 9.00e-02 -t = 1.00e+01 nst = 359 nfe = 0 nfi = 5722 nni = 3907 hu = 1.35e-01 +t = 1.00e+01 nst = 283 nfe = 0 nfi = 5157 nni = 3288 hu = 2.00e-01 Final statistics for this run: - ARKStep real workspace length = 3557 - ARKStep integer workspace length = 141 + ARKStep real workspace length = 3789 + ARKStep integer workspace length = 147 ARKLS real workspace length = 2647 ARKLS integer workspace length = 42 - Number of steps = 359 + Number of steps = 283 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 f-s (implicit) = 5157 + Number of f-s (SPGMR) = 11709 + Number of f-s (TOTAL) = 11709 + Number of setups = 279 + Number of nonlinear iterations = 3288 + Number of linear iterations = 11709 + Number of preconditioner evaluations = 279 + Number of preconditioner solves = 14769 Number of error test failures = 0 - Number of nonlinear conv. failures = 117 - Number of linear convergence failures = 1072 - Average Krylov subspace dimension = 3.303 + Number of nonlinear conv. failures = 147 + Number of linear convergence failures = 1039 + Average Krylov subspace dimension = 3.561 ---------------------------------------------------------------------------- @@ -585,64 +585,64 @@ Preconditioner type is jpre = SUN_PREC_RIGHT Gram-Schmidt method type is gstype = SUN_CLASSICAL_GS -t = 1.00e-08 nst = 5 nfe = 0 nfi = 75 nni = 47 hu = 9.89e-08 +t = 1.00e-08 nst = 5 nfe = 0 nfi = 80 nni = 47 hu = 1.84e-07 -t = 1.00e-07 nst = 5 nfe = 0 nfi = 75 nni = 47 hu = 9.89e-08 +t = 1.00e-07 nst = 5 nfe = 0 nfi = 80 nni = 47 hu = 1.84e-07 -t = 1.00e-06 nst = 8 nfe = 0 nfi = 120 nni = 77 hu = 4.79e-07 +t = 1.00e-06 nst = 7 nfe = 0 nfi = 113 nni = 68 hu = 1.10e-06 -t = 1.00e-05 nst = 27 nfe = 0 nfi = 407 nni = 269 hu = 4.79e-07 +t = 1.00e-05 nst = 15 nfe = 0 nfi = 241 nni = 148 hu = 1.10e-06 -t = 1.00e-04 nst = 106 nfe = 0 nfi = 1688 nni = 1155 hu = 1.70e-05 +t = 1.00e-04 nst = 54 nfe = 0 nfi = 982 nni = 655 hu = 3.03e-05 -t = 1.00e-03 nst = 110 nfe = 0 nfi = 1750 nni = 1197 hu = 1.50e-03 +t = 1.00e-03 nst = 57 nfe = 0 nfi = 1032 nni = 687 hu = 2.86e-03 -t = 1.00e-02 nst = 113 nfe = 0 nfi = 1797 nni = 1229 hu = 3.42e-03 +t = 1.00e-02 nst = 59 nfe = 0 nfi = 1087 nni = 726 hu = 2.51e-03 -t = 1.00e-01 nst = 127 nfe = 0 nfi = 2023 nni = 1385 hu = 1.23e-02 +t = 1.00e-01 nst = 72 nfe = 0 nfi = 1379 nni = 928 hu = 6.16e-03 -t = 1.00e+00 nst = 166 nfe = 0 nfi = 2714 nni = 1875 hu = 2.40e-02 +t = 1.00e+00 nst = 124 nfe = 0 nfi = 2392 nni = 1598 hu = 2.32e-02 -t = 2.00e+00 nst = 214 nfe = 0 nfi = 3556 nni = 2465 hu = 2.34e-02 +t = 2.00e+00 nst = 150 nfe = 0 nfi = 2860 nni = 1897 hu = 6.35e-02 -t = 3.00e+00 nst = 249 nfe = 0 nfi = 4117 nni = 2851 hu = 3.57e-02 +t = 3.00e+00 nst = 178 nfe = 0 nfi = 3418 nni = 2255 hu = 4.48e-02 -t = 4.00e+00 nst = 272 nfe = 0 nfi = 4478 nni = 3097 hu = 5.08e-02 +t = 4.00e+00 nst = 197 nfe = 0 nfi = 3756 nni = 2466 hu = 8.37e-02 -t = 5.00e+00 nst = 297 nfe = 0 nfi = 4857 nni = 3351 hu = 5.14e-02 +t = 5.00e+00 nst = 208 nfe = 0 nfi = 3941 nni = 2580 hu = 9.05e-02 -t = 6.00e+00 nst = 315 nfe = 0 nfi = 5123 nni = 3527 hu = 6.89e-02 +t = 6.00e+00 nst = 227 nfe = 0 nfi = 4268 nni = 2778 hu = 9.21e-02 -t = 7.00e+00 nst = 328 nfe = 0 nfi = 5308 nni = 3647 hu = 9.31e-02 +t = 7.00e+00 nst = 244 nfe = 0 nfi = 4545 nni = 2941 hu = 6.08e-02 -t = 8.00e+00 nst = 339 nfe = 0 nfi = 5464 nni = 3748 hu = 9.70e-02 +t = 8.00e+00 nst = 257 nfe = 0 nfi = 4757 nni = 3065 hu = 1.08e-01 -t = 9.00e+00 nst = 349 nfe = 0 nfi = 5598 nni = 3832 hu = 1.12e-01 +t = 9.00e+00 nst = 272 nfe = 0 nfi = 4990 nni = 3196 hu = 5.14e-02 -t = 1.00e+01 nst = 359 nfe = 0 nfi = 5728 nni = 3912 hu = 1.31e-01 +t = 1.00e+01 nst = 282 nfe = 0 nfi = 5143 nni = 3281 hu = 1.22e-01 Final statistics for this run: - ARKStep real workspace length = 3557 - ARKStep integer workspace length = 146 + ARKStep real workspace length = 3789 + ARKStep integer workspace length = 153 ARKLS real workspace length = 2647 ARKLS integer workspace length = 42 - Number of steps = 359 + Number of steps = 282 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 f-s (implicit) = 5143 + Number of f-s (SPGMR) = 11673 + Number of f-s (TOTAL) = 11673 + Number of setups = 277 + Number of nonlinear iterations = 3281 + Number of linear iterations = 11673 + Number of preconditioner evaluations = 277 + Number of preconditioner solves = 14718 Number of error test failures = 0 - Number of nonlinear conv. failures = 118 - Number of linear convergence failures = 1076 - Average Krylov subspace dimension = 3.306 + Number of nonlinear conv. failures = 146 + Number of linear convergence failures = 1030 + Average Krylov subspace dimension = 3.558 ---------------------------------------------------------------------------- diff --git a/examples/arkode/C_serial/ark_KrylovDemo_prec_2.out b/examples/arkode/C_serial/ark_KrylovDemo_prec_2.out index 1af6fb8046..929ddad95d 100644 --- a/examples/arkode/C_serial/ark_KrylovDemo_prec_2.out +++ b/examples/arkode/C_serial/ark_KrylovDemo_prec_2.out @@ -78,11 +78,11 @@ Species 6 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 +t = 1.00e-08 nst = 5 nfe = 0 nfi = 80 nni = 47 hu = 1.84e-07 -t = 1.00e-07 nst = 5 nfe = 0 nfi = 75 nni = 47 hu = 9.89e-08 +t = 1.00e-07 nst = 5 nfe = 0 nfi = 80 nni = 47 hu = 1.84e-07 -t = 1.00e-06 nst = 8 nfe = 0 nfi = 120 nni = 77 hu = 4.79e-07 +t = 1.00e-06 nst = 7 nfe = 0 nfi = 113 nni = 68 hu = 1.10e-06 c values at t = 1e-06: @@ -111,34 +111,34 @@ Species 3 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.498 13.4981 13.4981 13.4981 13.4981 13.498 +13.4981 14.5495 15.8919 15.8919 14.5495 13.4981 +13.4981 15.8919 19.0287 19.0287 15.8919 13.4981 +13.4981 15.8919 19.0287 19.0287 15.8919 13.4981 +13.4981 14.5495 15.8919 15.8919 14.5495 13.4981 +13.498 13.4981 13.4981 13.4981 13.4981 13.498 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.498 13.4981 13.4981 13.4981 13.4981 13.498 +13.4981 14.7783 16.4131 16.4131 14.7783 13.4981 +13.4981 16.4131 20.235 20.235 16.4131 13.4981 +13.4981 16.4131 20.235 20.235 16.4131 13.4981 +13.4981 14.7783 16.4131 16.4131 14.7783 13.4981 +13.498 13.4981 13.4981 13.4981 13.4981 13.498 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.498 13.4981 13.4981 13.4981 13.4981 13.498 +13.4981 15.007 16.9343 16.9343 15.007 13.4981 +13.4981 16.9343 21.4413 21.4413 16.9343 13.4981 +13.4981 16.9343 21.4413 21.4413 16.9343 13.4981 +13.4981 15.007 16.9343 16.9343 15.007 13.4981 +13.498 13.4981 13.4981 13.4981 13.4981 13.498 -t = 1.00e-05 nst = 27 nfe = 0 nfi = 407 nni = 269 hu = 4.79e-07 +t = 1.00e-05 nst = 15 nfe = 0 nfi = 241 nni = 148 hu = 1.10e-06 -t = 1.00e-04 nst = 106 nfe = 0 nfi = 1688 nni = 1155 hu = 1.70e-05 +t = 1.00e-04 nst = 54 nfe = 0 nfi = 982 nni = 655 hu = 3.03e-05 -t = 1.00e-03 nst = 110 nfe = 0 nfi = 1750 nni = 1197 hu = 1.51e-03 +t = 1.00e-03 nst = 57 nfe = 0 nfi = 1032 nni = 687 hu = 2.90e-03 c values at t = 0.001: @@ -167,41 +167,41 @@ Species 3 9.90776 9.93088 9.96016 9.96017 9.93092 9.90781 Species 4 -297231 297749 298392 298451 297925 297520 +297231 297749 298393 298451 297925 297520 297692 307245 319327 319378 307390 297925 298276 319264 345799 345840 319378 298451 -298276 319252 345772 345799 319327 298392 +298276 319252 345772 345799 319327 298393 297691 307208 319252 319264 307245 297749 297229 297691 298276 298276 297692 297231 Species 5 -297231 297749 298392 298451 297925 297520 +297231 297749 298393 298451 297925 297520 297692 307245 319327 319378 307390 297925 298276 319264 345799 345840 319378 298451 -298276 319252 345772 345799 319327 298392 +298276 319252 345772 345799 319327 298393 297691 307208 319252 319264 307245 297749 297229 297691 298276 298276 297692 297231 Species 6 -297231 297749 298392 298451 297925 297520 +297231 297749 298393 298451 297925 297520 297692 307245 319327 319378 307390 297925 298276 319264 345799 345840 319378 298451 -298276 319252 345772 345799 319327 298392 +298276 319252 345772 345799 319327 298393 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 +t = 1.00e-02 nst = 59 nfe = 0 nfi = 1074 nni = 717 hu = 1.01e-02 -t = 1.00e-01 nst = 127 nfe = 0 nfi = 2024 nni = 1386 hu = 1.28e-02 +t = 1.00e-01 nst = 65 nfe = 0 nfi = 1195 nni = 802 hu = 1.60e-02 -t = 1.00e+00 nst = 154 nfe = 0 nfi = 2489 nni = 1716 hu = 6.84e-02 +t = 1.00e+00 nst = 85 nfe = 0 nfi = 1602 nni = 1085 hu = 8.80e-02 c values at t = 1: Species 1 -1.58851 1.59924 1.62152 1.64764 1.67036 1.68149 +1.58851 1.59924 1.62152 1.64765 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.57757 1.58547 1.60239 1.62235 1.63952 1.64765 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 @@ -210,7 +210,7 @@ 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.57034 1.57626 1.58922 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 @@ -223,34 +223,34 @@ Species 3 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 +47718.4 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 +47389.7 47627 48135 48734.2 49249.6 49493.5 +47108.5 47286.1 47674.6 48135 48527.8 48709 +46876.6 47001.1 47286.1 47627 47914 48040.3 +46781.8 46876.6 47108.5 47389.7 47622.8 47718.4 Species 5 -47718.3 48040.3 48709 49493.5 50175.5 50509.4 +47718.4 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 +47389.7 47627 48135 48734.2 49249.6 49493.5 +47108.5 47286.1 47674.6 48135 48527.8 48709 +46876.6 47001.1 47286.1 47627 47914 48040.3 +46781.8 46876.6 47108.5 47389.7 47622.8 47718.4 Species 6 -47718.3 48040.3 48709 49493.5 50175.5 50509.4 +47718.4 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 +47389.7 47627 48135 48734.2 49249.6 49493.5 +47108.5 47286.1 47674.6 48135 48527.8 48709 +46876.6 47001.1 47286.1 47627 47914 48040.3 +46781.8 46876.6 47108.5 47389.7 47622.8 47718.4 -t = 2.00e+00 nst = 165 nfe = 0 nfi = 2661 nni = 1833 hu = 4.14e-02 +t = 2.00e+00 nst = 109 nfe = 0 nfi = 2054 nni = 1378 hu = 4.17e-02 -t = 3.00e+00 nst = 177 nfe = 0 nfi = 2848 nni = 1960 hu = 1.08e-01 +t = 3.00e+00 nst = 131 nfe = 0 nfi = 2440 nni = 1621 hu = 4.59e-02 -t = 4.00e+00 nst = 187 nfe = 0 nfi = 3013 nni = 2073 hu = 1.23e-01 +t = 4.00e+00 nst = 144 nfe = 0 nfi = 2672 nni = 1768 hu = 1.74e-01 c values at t = 4: @@ -279,34 +279,34 @@ Species 3 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 +35860.6 36110.2 36632.4 37246.5 37779.4 38038.7 +35784.2 36010.4 36490.4 37056.3 37545.3 37779.4 +35597.2 35782 36180.5 36651.6 37056.3 37246.5 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 +35860.6 36110.2 36632.4 37246.5 37779.4 38038.7 +35784.2 36010.4 36490.4 37056.3 37545.3 37779.4 +35597.2 35782 36180.5 36651.6 37056.3 37246.5 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 +35860.6 36110.2 36632.4 37246.5 37779.4 38038.7 +35784.2 36010.4 36490.4 37056.3 37545.3 37779.4 +35597.2 35782 36180.5 36651.6 37056.3 37246.5 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 +t = 5.00e+00 nst = 153 nfe = 0 nfi = 2824 nni = 1862 hu = 2.64e-01 -t = 6.00e+00 nst = 207 nfe = 0 nfi = 3336 nni = 2284 hu = 9.66e-02 +t = 6.00e+00 nst = 161 nfe = 0 nfi = 2950 nni = 1937 hu = 1.34e-01 -t = 7.00e+00 nst = 216 nfe = 0 nfi = 3477 nni = 2375 hu = 1.51e-01 +t = 7.00e+00 nst = 172 nfe = 0 nfi = 3130 nni = 2045 hu = 4.37e-02 c values at t = 7: @@ -335,34 +335,34 @@ Species 3 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 +35655.3 35903.6 36423.2 37034.1 37564.4 37822.3 +35579.3 35804.2 36281.9 36844.9 37331.5 37564.4 +35393.1 35577 35973.4 36442.4 36844.9 37034.1 +35168.4 35306.6 35611.5 35973.4 36281.9 36423.2 +34983.2 35081.2 35306.6 35577 35804.2 35903.6 +34908 34983.2 35168.4 35393.1 35579.3 35655.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 +35655.3 35903.6 36423.2 37034.1 37564.4 37822.3 +35579.3 35804.2 36281.9 36844.9 37331.5 37564.4 +35393.1 35577 35973.4 36442.4 36844.9 37034.1 +35168.4 35306.6 35611.5 35973.4 36281.9 36423.2 +34983.2 35081.2 35306.6 35577 35804.2 35903.6 +34908 34983.2 35168.4 35393.1 35579.3 35655.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 +35655.3 35903.6 36423.2 37034.1 37564.4 37822.3 +35579.3 35804.2 36281.9 36844.9 37331.5 37564.4 +35393.1 35577 35973.4 36442.4 36844.9 37034.1 +35168.4 35306.6 35611.5 35973.4 36281.9 36423.2 +34983.2 35081.2 35306.6 35577 35804.2 35903.6 +34908 34983.2 35168.4 35393.1 35579.3 35655.3 -t = 8.00e+00 nst = 232 nfe = 0 nfi = 3780 nni = 2567 hu = 1.06e-01 +t = 8.00e+00 nst = 181 nfe = 0 nfi = 3271 nni = 2129 hu = 1.68e-01 -t = 9.00e+00 nst = 249 nfe = 0 nfi = 4075 nni = 2742 hu = 8.61e-02 +t = 9.00e+00 nst = 190 nfe = 0 nfi = 3409 nni = 2208 hu = 8.39e-02 -t = 1.00e+01 nst = 266 nfe = 0 nfi = 4394 nni = 2941 hu = 8.37e-02 +t = 1.00e+01 nst = 204 nfe = 0 nfi = 3616 nni = 2325 hu = 2.20e-01 c values at t = 10: @@ -391,51 +391,51 @@ Species 3 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 +35650.6 35898.8 36418.3 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 +35388.4 35572.3 35968.7 36437.5 36840 37029.2 +35163.7 35301.9 35606.7 35968.7 36277.1 36418.3 +34978.6 35076.5 35301.9 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.9 36418.3 37029.2 37559.5 37817.3 +35574.6 35799.5 36277.1 36840 37326.6 37559.5 +35388.4 35572.3 35968.7 36437.5 36840 37029.2 +35163.7 35301.9 35606.7 35968.7 36277.1 36418.3 +34978.6 35076.5 35301.9 35572.3 35799.5 35898.9 +34903.3 34978.6 35163.7 35388.4 35574.6 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.9 36418.3 37029.2 37559.5 37817.3 +35574.6 35799.5 36277.1 36840 37326.6 37559.5 +35388.4 35572.3 35968.7 36437.5 36840 37029.2 +35163.7 35301.9 35606.7 35968.7 36277.1 36418.3 +34978.6 35076.5 35301.9 35572.3 35799.5 35898.9 +34903.3 34978.6 35163.7 35388.4 35574.6 35650.6 Final statistics for this run: - ARKStep real workspace length = 3557 - ARKStep integer workspace length = 131 + ARKStep real workspace length = 3789 + ARKStep integer workspace length = 135 ARKLS real workspace length = 2647 ARKLS integer workspace length = 42 - Number of steps = 266 + Number of steps = 204 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 + Number of f-s (implicit) = 3616 + Number of f-s (SPGMR) = 7769 + Number of f-s (TOTAL) = 7769 + Number of setups = 153 + Number of nonlinear iterations = 2325 + Number of linear iterations = 7769 + Number of preconditioner evaluations = 153 + Number of preconditioner solves = 10045 + Number of error test failures = 0 + Number of nonlinear conv. failures = 61 + Number of linear convergence failures = 512 + Average Krylov subspace dimension = 3.342 ---------------------------------------------------------------------------- @@ -447,64 +447,64 @@ Preconditioner type is jpre = SUN_PREC_LEFT Gram-Schmidt method type is gstype = SUN_CLASSICAL_GS -t = 1.00e-08 nst = 5 nfe = 0 nfi = 75 nni = 47 hu = 9.89e-08 +t = 1.00e-08 nst = 5 nfe = 0 nfi = 80 nni = 47 hu = 1.84e-07 -t = 1.00e-07 nst = 5 nfe = 0 nfi = 75 nni = 47 hu = 9.89e-08 +t = 1.00e-07 nst = 5 nfe = 0 nfi = 80 nni = 47 hu = 1.84e-07 -t = 1.00e-06 nst = 8 nfe = 0 nfi = 120 nni = 77 hu = 4.79e-07 +t = 1.00e-06 nst = 7 nfe = 0 nfi = 113 nni = 68 hu = 1.10e-06 -t = 1.00e-05 nst = 27 nfe = 0 nfi = 407 nni = 269 hu = 4.79e-07 +t = 1.00e-05 nst = 15 nfe = 0 nfi = 241 nni = 148 hu = 1.10e-06 -t = 1.00e-04 nst = 106 nfe = 0 nfi = 1688 nni = 1155 hu = 1.70e-05 +t = 1.00e-04 nst = 54 nfe = 0 nfi = 982 nni = 655 hu = 3.03e-05 -t = 1.00e-03 nst = 110 nfe = 0 nfi = 1750 nni = 1197 hu = 1.51e-03 +t = 1.00e-03 nst = 57 nfe = 0 nfi = 1032 nni = 687 hu = 2.90e-03 -t = 1.00e-02 nst = 113 nfe = 0 nfi = 1797 nni = 1229 hu = 3.46e-03 +t = 1.00e-02 nst = 59 nfe = 0 nfi = 1074 nni = 717 hu = 1.01e-02 -t = 1.00e-01 nst = 127 nfe = 0 nfi = 2024 nni = 1386 hu = 1.28e-02 +t = 1.00e-01 nst = 65 nfe = 0 nfi = 1195 nni = 802 hu = 1.60e-02 -t = 1.00e+00 nst = 154 nfe = 0 nfi = 2491 nni = 1718 hu = 7.60e-02 +t = 1.00e+00 nst = 85 nfe = 0 nfi = 1602 nni = 1085 hu = 8.80e-02 -t = 2.00e+00 nst = 169 nfe = 0 nfi = 2746 nni = 1896 hu = 8.04e-02 +t = 2.00e+00 nst = 109 nfe = 0 nfi = 2054 nni = 1378 hu = 4.17e-02 -t = 3.00e+00 nst = 181 nfe = 0 nfi = 2950 nni = 2036 hu = 1.01e-01 +t = 3.00e+00 nst = 131 nfe = 0 nfi = 2440 nni = 1621 hu = 4.59e-02 -t = 4.00e+00 nst = 189 nfe = 0 nfi = 3073 nni = 2119 hu = 1.33e-01 +t = 4.00e+00 nst = 144 nfe = 0 nfi = 2672 nni = 1768 hu = 1.74e-01 -t = 5.00e+00 nst = 199 nfe = 0 nfi = 3242 nni = 2227 hu = 9.38e-02 +t = 5.00e+00 nst = 155 nfe = 0 nfi = 2858 nni = 1883 hu = 2.21e-01 -t = 6.00e+00 nst = 211 nfe = 0 nfi = 3442 nni = 2352 hu = 1.13e-01 +t = 6.00e+00 nst = 164 nfe = 0 nfi = 3005 nni = 1972 hu = 5.16e-02 -t = 7.00e+00 nst = 220 nfe = 0 nfi = 3612 nni = 2457 hu = 1.07e-01 +t = 7.00e+00 nst = 175 nfe = 0 nfi = 3179 nni = 2076 hu = 1.37e-01 -t = 8.00e+00 nst = 229 nfe = 0 nfi = 3747 nni = 2537 hu = 1.33e-01 +t = 8.00e+00 nst = 183 nfe = 0 nfi = 3307 nni = 2153 hu = 3.10e-01 -t = 9.00e+00 nst = 239 nfe = 0 nfi = 3897 nni = 2622 hu = 8.98e-02 +t = 9.00e+00 nst = 191 nfe = 0 nfi = 3432 nni = 2226 hu = 6.05e-02 -t = 1.00e+01 nst = 251 nfe = 0 nfi = 4101 nni = 2746 hu = 7.09e-02 +t = 1.00e+01 nst = 198 nfe = 0 nfi = 3537 nni = 2286 hu = 2.45e-01 Final statistics for this run: - ARKStep real workspace length = 3557 - ARKStep integer workspace length = 136 + ARKStep real workspace length = 3789 + ARKStep integer workspace length = 141 ARKLS real workspace length = 2647 ARKLS integer workspace length = 42 - Number of steps = 251 + Number of steps = 198 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 + Number of f-s (implicit) = 3537 + Number of f-s (SPGMR) = 7647 + Number of f-s (TOTAL) = 7647 + Number of setups = 146 + Number of nonlinear iterations = 2286 + Number of linear iterations = 7647 + Number of preconditioner evaluations = 146 + Number of preconditioner solves = 9884 + Number of error test failures = 0 + Number of nonlinear conv. failures = 58 + Number of linear convergence failures = 498 + Average Krylov subspace dimension = 3.345 ---------------------------------------------------------------------------- @@ -516,64 +516,64 @@ Preconditioner type is jpre = SUN_PREC_RIGHT Gram-Schmidt method type is gstype = SUN_MODIFIED_GS -t = 1.00e-08 nst = 5 nfe = 0 nfi = 75 nni = 47 hu = 9.89e-08 +t = 1.00e-08 nst = 5 nfe = 0 nfi = 80 nni = 47 hu = 1.84e-07 -t = 1.00e-07 nst = 5 nfe = 0 nfi = 75 nni = 47 hu = 9.89e-08 +t = 1.00e-07 nst = 5 nfe = 0 nfi = 80 nni = 47 hu = 1.84e-07 -t = 1.00e-06 nst = 8 nfe = 0 nfi = 120 nni = 77 hu = 4.79e-07 +t = 1.00e-06 nst = 7 nfe = 0 nfi = 113 nni = 68 hu = 1.10e-06 -t = 1.00e-05 nst = 27 nfe = 0 nfi = 407 nni = 269 hu = 4.79e-07 +t = 1.00e-05 nst = 15 nfe = 0 nfi = 241 nni = 148 hu = 1.10e-06 -t = 1.00e-04 nst = 106 nfe = 0 nfi = 1688 nni = 1155 hu = 1.70e-05 +t = 1.00e-04 nst = 54 nfe = 0 nfi = 982 nni = 655 hu = 3.03e-05 -t = 1.00e-03 nst = 110 nfe = 0 nfi = 1750 nni = 1197 hu = 1.50e-03 +t = 1.00e-03 nst = 57 nfe = 0 nfi = 1032 nni = 687 hu = 2.86e-03 -t = 1.00e-02 nst = 113 nfe = 0 nfi = 1797 nni = 1229 hu = 3.42e-03 +t = 1.00e-02 nst = 59 nfe = 0 nfi = 1087 nni = 726 hu = 2.51e-03 -t = 1.00e-01 nst = 127 nfe = 0 nfi = 2023 nni = 1385 hu = 1.23e-02 +t = 1.00e-01 nst = 72 nfe = 0 nfi = 1379 nni = 928 hu = 6.16e-03 -t = 1.00e+00 nst = 166 nfe = 0 nfi = 2714 nni = 1875 hu = 2.40e-02 +t = 1.00e+00 nst = 124 nfe = 0 nfi = 2392 nni = 1598 hu = 2.32e-02 -t = 2.00e+00 nst = 214 nfe = 0 nfi = 3550 nni = 2460 hu = 2.34e-02 +t = 2.00e+00 nst = 150 nfe = 0 nfi = 2860 nni = 1897 hu = 6.35e-02 -t = 3.00e+00 nst = 249 nfe = 0 nfi = 4111 nni = 2846 hu = 3.57e-02 +t = 3.00e+00 nst = 178 nfe = 0 nfi = 3418 nni = 2255 hu = 4.48e-02 -t = 4.00e+00 nst = 272 nfe = 0 nfi = 4472 nni = 3092 hu = 5.08e-02 +t = 4.00e+00 nst = 197 nfe = 0 nfi = 3756 nni = 2466 hu = 8.37e-02 -t = 5.00e+00 nst = 297 nfe = 0 nfi = 4851 nni = 3346 hu = 5.14e-02 +t = 5.00e+00 nst = 208 nfe = 0 nfi = 3941 nni = 2580 hu = 9.06e-02 -t = 6.00e+00 nst = 315 nfe = 0 nfi = 5117 nni = 3522 hu = 6.88e-02 +t = 6.00e+00 nst = 228 nfe = 0 nfi = 4280 nni = 2784 hu = 7.04e-02 -t = 7.00e+00 nst = 328 nfe = 0 nfi = 5302 nni = 3642 hu = 8.22e-02 +t = 7.00e+00 nst = 244 nfe = 0 nfi = 4544 nni = 2940 hu = 7.42e-02 -t = 8.00e+00 nst = 338 nfe = 0 nfi = 5441 nni = 3731 hu = 8.52e-02 +t = 8.00e+00 nst = 259 nfe = 0 nfi = 4788 nni = 3082 hu = 1.29e-01 -t = 9.00e+00 nst = 349 nfe = 0 nfi = 5592 nni = 3827 hu = 1.11e-01 +t = 9.00e+00 nst = 270 nfe = 0 nfi = 4955 nni = 3175 hu = 9.00e-02 -t = 1.00e+01 nst = 359 nfe = 0 nfi = 5722 nni = 3907 hu = 1.35e-01 +t = 1.00e+01 nst = 283 nfe = 0 nfi = 5157 nni = 3288 hu = 2.00e-01 Final statistics for this run: - ARKStep real workspace length = 3557 - ARKStep integer workspace length = 141 + ARKStep real workspace length = 3789 + ARKStep integer workspace length = 147 ARKLS real workspace length = 2647 ARKLS integer workspace length = 42 - Number of steps = 359 + Number of steps = 283 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 f-s (implicit) = 5157 + Number of f-s (SPGMR) = 11709 + Number of f-s (TOTAL) = 11709 + Number of setups = 279 + Number of nonlinear iterations = 3288 + Number of linear iterations = 11709 + Number of preconditioner evaluations = 279 + Number of preconditioner solves = 14769 Number of error test failures = 0 - Number of nonlinear conv. failures = 117 - Number of linear convergence failures = 1072 - Average Krylov subspace dimension = 3.303 + Number of nonlinear conv. failures = 147 + Number of linear convergence failures = 1039 + Average Krylov subspace dimension = 3.561 ---------------------------------------------------------------------------- @@ -585,64 +585,64 @@ Preconditioner type is jpre = SUN_PREC_RIGHT Gram-Schmidt method type is gstype = SUN_CLASSICAL_GS -t = 1.00e-08 nst = 5 nfe = 0 nfi = 75 nni = 47 hu = 9.89e-08 +t = 1.00e-08 nst = 5 nfe = 0 nfi = 80 nni = 47 hu = 1.84e-07 -t = 1.00e-07 nst = 5 nfe = 0 nfi = 75 nni = 47 hu = 9.89e-08 +t = 1.00e-07 nst = 5 nfe = 0 nfi = 80 nni = 47 hu = 1.84e-07 -t = 1.00e-06 nst = 8 nfe = 0 nfi = 120 nni = 77 hu = 4.79e-07 +t = 1.00e-06 nst = 7 nfe = 0 nfi = 113 nni = 68 hu = 1.10e-06 -t = 1.00e-05 nst = 27 nfe = 0 nfi = 407 nni = 269 hu = 4.79e-07 +t = 1.00e-05 nst = 15 nfe = 0 nfi = 241 nni = 148 hu = 1.10e-06 -t = 1.00e-04 nst = 106 nfe = 0 nfi = 1688 nni = 1155 hu = 1.70e-05 +t = 1.00e-04 nst = 54 nfe = 0 nfi = 982 nni = 655 hu = 3.03e-05 -t = 1.00e-03 nst = 110 nfe = 0 nfi = 1750 nni = 1197 hu = 1.50e-03 +t = 1.00e-03 nst = 57 nfe = 0 nfi = 1032 nni = 687 hu = 2.86e-03 -t = 1.00e-02 nst = 113 nfe = 0 nfi = 1797 nni = 1229 hu = 3.42e-03 +t = 1.00e-02 nst = 59 nfe = 0 nfi = 1087 nni = 726 hu = 2.51e-03 -t = 1.00e-01 nst = 127 nfe = 0 nfi = 2023 nni = 1385 hu = 1.23e-02 +t = 1.00e-01 nst = 72 nfe = 0 nfi = 1379 nni = 928 hu = 6.16e-03 -t = 1.00e+00 nst = 166 nfe = 0 nfi = 2714 nni = 1875 hu = 2.40e-02 +t = 1.00e+00 nst = 124 nfe = 0 nfi = 2392 nni = 1598 hu = 2.32e-02 -t = 2.00e+00 nst = 214 nfe = 0 nfi = 3556 nni = 2465 hu = 2.34e-02 +t = 2.00e+00 nst = 150 nfe = 0 nfi = 2860 nni = 1897 hu = 6.35e-02 -t = 3.00e+00 nst = 249 nfe = 0 nfi = 4117 nni = 2851 hu = 3.57e-02 +t = 3.00e+00 nst = 178 nfe = 0 nfi = 3418 nni = 2255 hu = 4.48e-02 -t = 4.00e+00 nst = 272 nfe = 0 nfi = 4478 nni = 3097 hu = 5.08e-02 +t = 4.00e+00 nst = 197 nfe = 0 nfi = 3756 nni = 2466 hu = 8.37e-02 -t = 5.00e+00 nst = 297 nfe = 0 nfi = 4857 nni = 3351 hu = 5.14e-02 +t = 5.00e+00 nst = 208 nfe = 0 nfi = 3941 nni = 2580 hu = 9.05e-02 -t = 6.00e+00 nst = 315 nfe = 0 nfi = 5123 nni = 3527 hu = 6.89e-02 +t = 6.00e+00 nst = 227 nfe = 0 nfi = 4268 nni = 2778 hu = 9.21e-02 -t = 7.00e+00 nst = 328 nfe = 0 nfi = 5308 nni = 3647 hu = 9.31e-02 +t = 7.00e+00 nst = 244 nfe = 0 nfi = 4545 nni = 2941 hu = 6.08e-02 -t = 8.00e+00 nst = 339 nfe = 0 nfi = 5464 nni = 3748 hu = 9.70e-02 +t = 8.00e+00 nst = 257 nfe = 0 nfi = 4757 nni = 3065 hu = 1.08e-01 -t = 9.00e+00 nst = 349 nfe = 0 nfi = 5598 nni = 3832 hu = 1.12e-01 +t = 9.00e+00 nst = 272 nfe = 0 nfi = 4990 nni = 3196 hu = 5.14e-02 -t = 1.00e+01 nst = 359 nfe = 0 nfi = 5728 nni = 3912 hu = 1.31e-01 +t = 1.00e+01 nst = 282 nfe = 0 nfi = 5143 nni = 3281 hu = 1.22e-01 Final statistics for this run: - ARKStep real workspace length = 3557 - ARKStep integer workspace length = 146 + ARKStep real workspace length = 3789 + ARKStep integer workspace length = 153 ARKLS real workspace length = 2647 ARKLS integer workspace length = 42 - Number of steps = 359 + Number of steps = 282 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 f-s (implicit) = 5143 + Number of f-s (SPGMR) = 11673 + Number of f-s (TOTAL) = 11673 + Number of setups = 277 + Number of nonlinear iterations = 3281 + Number of linear iterations = 11673 + Number of preconditioner evaluations = 277 + Number of preconditioner solves = 14718 Number of error test failures = 0 - Number of nonlinear conv. failures = 118 - Number of linear convergence failures = 1076 - Average Krylov subspace dimension = 3.306 + Number of nonlinear conv. failures = 146 + Number of linear convergence failures = 1030 + Average Krylov subspace dimension = 3.558 ---------------------------------------------------------------------------- diff --git a/examples/arkode/C_serial/ark_analytic.out b/examples/arkode/C_serial/ark_analytic.out index f91f4a3492..25f4b00bb9 100644 --- a/examples/arkode/C_serial/ark_analytic.out +++ b/examples/arkode/C_serial/ark_analytic.out @@ -7,10 +7,10 @@ Analytical ODE test problem: t u --------------------- 1.000000 0.785398 - 2.000000 1.107149 + 2.000000 1.107148 3.000000 1.249046 4.000000 1.325818 - 5.000000 1.373401 + 5.000000 1.373400 6.000000 1.405648 7.000000 1.428899 8.000000 1.446441 @@ -19,12 +19,12 @@ Analytical ODE test problem: --------------------- Final Solver Statistics: - Internal solver steps = 559 (attempted = 559) - Total RHS evals: Fe = 0, Fi = 5593 - Total linear solver setups = 25 + Internal solver steps = 94 (attempted = 94) + Total RHS evals: Fe = 0, Fi = 1037 + Total linear solver setups = 21 Total RHS evals for setting up the linear system = 0 - Total number of Jacobian evaluations = 5 - Total number of Newton iterations = 2795 + Total number of Jacobian evaluations = 2 + Total number of Newton iterations = 470 Total number of linear solver convergence failures = 0 Total number of error test failures = 0 diff --git a/examples/arkode/C_serial/ark_analytic_mels.out b/examples/arkode/C_serial/ark_analytic_mels.out index 33b31c9050..128ee31fc2 100644 --- a/examples/arkode/C_serial/ark_analytic_mels.out +++ b/examples/arkode/C_serial/ark_analytic_mels.out @@ -7,10 +7,10 @@ Analytical ODE test problem: t u --------------------- 1.000000 0.785398 - 2.000000 1.107149 + 2.000000 1.107148 3.000000 1.249046 4.000000 1.325818 - 5.000000 1.373401 + 5.000000 1.373400 6.000000 1.405648 7.000000 1.428899 8.000000 1.446441 @@ -19,12 +19,12 @@ Analytical ODE test problem: --------------------- Final Solver Statistics: - Internal solver steps = 559 (attempted = 559) - Total RHS evals: Fe = 0, Fi = 5593 + Internal solver steps = 94 (attempted = 94) + Total RHS evals: Fe = 0, Fi = 1037 Total linear solver setups = 0 Total RHS evals for setting up the linear system = 0 Total number of Jacobian evaluations = 0 - Total number of Newton iterations = 2795 + Total number of Newton iterations = 470 Total number of linear solver convergence failures = 0 Total number of error test failures = 0 diff --git a/examples/arkode/C_serial/ark_analytic_nonlin.out b/examples/arkode/C_serial/ark_analytic_nonlin.out index 902ace198d..91ee81bc9a 100644 --- a/examples/arkode/C_serial/ark_analytic_nonlin.out +++ b/examples/arkode/C_serial/ark_analytic_nonlin.out @@ -6,10 +6,10 @@ Analytical ODE test problem: t u --------------------- 1.000000 0.916291 - 2.000000 1.609437 + 2.000000 1.609438 3.000000 2.140066 4.000000 2.564949 - 5.000000 2.917770 + 5.000000 2.917771 6.000000 3.218876 7.000000 3.481240 8.000000 3.713572 @@ -18,15 +18,15 @@ Analytical ODE test problem: --------------------- Final Statistics: -Current time = 10.12157090914652 -Steps = 82 -Step attempts = 83 +Current time = 10.12743729989852 +Steps = 62 +Step attempts = 62 Stability limited steps = 0 -Accuracy limited steps = 83 -Error test fails = 1 +Accuracy limited steps = 62 +Error test fails = 0 NLS step fails = 0 Inequality constraint fails = 0 Initial step size = 6.103515625000001e-12 -Last step size = 0.4463519264234082 -Current step size = 0.4463519264234082 -RHS fn evals = 417 +Last step size = 0.553529760219145 +Current step size = 0.553529760219145 +RHS fn evals = 251 diff --git a/examples/arkode/C_serial/ark_brusselator.out b/examples/arkode/C_serial/ark_brusselator.out index 260a9fb31b..40ebb2b890 100644 --- a/examples/arkode/C_serial/ark_brusselator.out +++ b/examples/arkode/C_serial/ark_brusselator.out @@ -7,25 +7,25 @@ Brusselator ODE test problem: t u v w ------------------------------------------- 0.000000 1.200000 3.100000 3.000000 - 1.000000 1.103849 3.013164 3.499981 - 2.000000 0.687998 3.521383 3.499988 - 3.000000 0.409468 4.277886 3.499993 - 4.000000 0.367888 4.942004 3.499994 - 5.000000 0.413854 5.510621 3.499993 - 6.000000 0.589240 5.855669 3.499990 - 7.000000 4.756630 0.735405 3.499917 - 8.000000 1.813466 1.575769 3.499968 - 9.000000 0.527904 2.807358 3.499991 - 10.000000 0.305600 3.657365 3.499995 + 1.000000 1.103857 3.013154 3.499981 + 2.000000 0.687999 3.521385 3.499988 + 3.000000 0.409466 4.277890 3.499993 + 4.000000 0.367899 4.942000 3.499994 + 5.000000 0.413855 5.510625 3.499993 + 6.000000 0.589277 5.855627 3.499990 + 7.000000 4.756500 0.735460 3.499917 + 8.000000 1.813441 1.575777 3.499968 + 9.000000 0.527892 2.807374 3.499991 + 10.000000 0.305601 3.657377 3.499995 ------------------------------------------- Final Solver Statistics: - Internal solver steps = 250 (attempted = 262) - Total RHS evals: Fe = 0, Fi = 3282 - Total linear solver setups = 118 + Internal solver steps = 164 (attempted = 185) + Total RHS evals: Fe = 0, Fi = 2693 + Total linear solver setups = 142 Total RHS evals for setting up the linear system = 0 - Total number of Jacobian evaluations = 72 - Total number of Newton iterations = 3279 - Total number of nonlinear solver convergence failures = 71 - Total number of error test failures = 11 - Total number of failed steps from solver failure = 1 + Total number of Jacobian evaluations = 85 + Total number of Newton iterations = 2505 + Total number of nonlinear solver convergence failures = 84 + Total number of error test failures = 5 + Total number of failed steps from solver failure = 16 diff --git a/examples/arkode/C_serial/ark_brusselator1D.out b/examples/arkode/C_serial/ark_brusselator1D.out index abe61d1f47..ca94965175 100644 --- a/examples/arkode/C_serial/ark_brusselator1D.out +++ b/examples/arkode/C_serial/ark_brusselator1D.out @@ -8,85 +8,85 @@ t ||u||_rms ||v||_rms ||w||_rms ---------------------------------------------- 0.100000 0.673914 3.377329 1.999987 - 0.200000 0.684316 3.356619 1.999987 + 0.200000 0.684316 3.356619 1.999986 0.300000 0.695306 3.334633 1.999986 0.400000 0.706918 3.311313 1.999986 0.500000 0.719185 3.286601 1.999986 - 0.600000 0.732137 3.260442 1.999986 + 0.600000 0.732138 3.260441 1.999986 0.700000 0.745798 3.232787 1.999985 - 0.800000 0.760185 3.203596 1.999985 - 0.900000 0.775303 3.172839 1.999985 - 1.000000 0.791135 3.140510 1.999984 - 1.100000 0.807648 3.106624 1.999984 - 1.200000 0.824771 3.071233 1.999984 - 1.300000 0.842402 3.034426 1.999983 - 1.400000 0.860384 2.996350 1.999983 - 1.500000 0.878514 2.957206 1.999983 - 1.600000 0.896525 2.917266 1.999982 - 1.700000 0.914089 2.876873 1.999982 - 1.800000 0.930823 2.836438 1.999982 - 1.900000 0.946292 2.796446 1.999982 - 2.000000 0.960033 2.757430 1.999981 - 2.100000 0.971576 2.719962 1.999981 - 2.200000 0.980475 2.684623 1.999981 - 2.300000 0.986338 2.651980 1.999981 - 2.400000 0.988852 2.622560 1.999981 - 2.500000 0.987815 2.596818 1.999981 - 2.600000 0.983141 2.575128 1.999981 - 2.700000 0.974858 2.557766 1.999981 - 2.800000 0.963114 2.544903 1.999981 - 2.900000 0.948154 2.536611 1.999981 - 3.000000 0.930299 2.532868 1.999982 - 3.100000 0.909930 2.533567 1.999982 - 3.200000 0.887464 2.538529 1.999983 - 3.300000 0.863335 2.547515 1.999983 + 0.800000 0.760187 3.203594 1.999985 + 0.900000 0.775304 3.172838 1.999985 + 1.000000 0.791136 3.140509 1.999984 + 1.100000 0.807652 3.106620 1.999984 + 1.200000 0.824772 3.071232 1.999984 + 1.300000 0.842405 3.034422 1.999983 + 1.400000 0.860387 2.996346 1.999983 + 1.500000 0.878515 2.957204 1.999983 + 1.600000 0.896529 2.917259 1.999982 + 1.700000 0.914090 2.876870 1.999982 + 1.800000 0.930824 2.836436 1.999982 + 1.900000 0.946293 2.796443 1.999982 + 2.000000 0.960035 2.757427 1.999981 + 2.100000 0.971577 2.719959 1.999981 + 2.200000 0.980476 2.684620 1.999981 + 2.300000 0.986337 2.651979 1.999981 + 2.400000 0.988854 2.622557 1.999981 + 2.500000 0.987814 2.596817 1.999981 + 2.600000 0.983141 2.575126 1.999981 + 2.700000 0.974857 2.557765 1.999981 + 2.800000 0.963114 2.544902 1.999981 + 2.900000 0.948154 2.536610 1.999981 + 3.000000 0.930298 2.532869 1.999982 + 3.100000 0.909930 2.533566 1.999982 + 3.200000 0.887463 2.538529 1.999983 + 3.300000 0.863334 2.547514 1.999983 3.400000 0.837978 2.560241 1.999983 3.500000 0.811818 2.576391 1.999984 - 3.600000 0.785255 2.595624 1.999984 - 3.700000 0.758659 2.617587 1.999985 - 3.800000 0.732363 2.641922 1.999986 - 3.900000 0.706662 2.668274 1.999986 - 4.000000 0.681809 2.696300 1.999986 - 4.100000 0.658012 2.725670 1.999987 + 3.600000 0.785254 2.595624 1.999984 + 3.700000 0.758658 2.617587 1.999985 + 3.800000 0.732362 2.641922 1.999986 + 3.900000 0.706662 2.668275 1.999986 + 4.000000 0.681808 2.696301 1.999986 + 4.100000 0.658010 2.725671 1.999987 4.200000 0.635435 2.756075 1.999987 - 4.300000 0.614205 2.787228 1.999988 + 4.300000 0.614204 2.787229 1.999988 4.400000 0.594404 2.818869 1.999988 - 4.500000 0.576082 2.850764 1.999989 - 4.600000 0.559255 2.882710 1.999989 - 4.700000 0.543909 2.914529 1.999989 - 4.800000 0.530011 2.946071 1.999990 - 4.900000 0.517506 2.977209 1.999990 - 5.000000 0.506326 3.007843 1.999990 - 5.100000 0.496394 3.037889 1.999990 - 5.200000 0.487626 3.067283 1.999990 - 5.300000 0.479935 3.095976 1.999991 - 5.400000 0.473237 3.123932 1.999991 - 5.500000 0.467445 3.151125 1.999991 - 5.600000 0.462480 3.177540 1.999991 - 5.700000 0.458264 3.203165 1.999991 - 5.800000 0.454726 3.227997 1.999991 - 5.900000 0.451800 3.252035 1.999991 - 6.000000 0.449425 3.275283 1.999991 - 6.100000 0.447546 3.297744 1.999991 - 6.200000 0.446115 3.319428 1.999991 - 6.300000 0.445086 3.340340 1.999991 - 6.400000 0.444419 3.360491 1.999991 - 6.500000 0.444079 3.379890 1.999991 + 4.500000 0.576081 2.850765 1.999989 + 4.600000 0.559254 2.882711 1.999989 + 4.700000 0.543909 2.914530 1.999989 + 4.800000 0.530010 2.946072 1.999990 + 4.900000 0.517505 2.977210 1.999990 + 5.000000 0.506325 3.007844 1.999990 + 5.100000 0.496393 3.037890 1.999990 + 5.200000 0.487625 3.067284 1.999990 + 5.300000 0.479935 3.095977 1.999991 + 5.400000 0.473236 3.123933 1.999991 + 5.500000 0.467445 3.151126 1.999991 + 5.600000 0.462480 3.177541 1.999991 + 5.700000 0.458264 3.203166 1.999991 + 5.800000 0.454725 3.227998 1.999991 + 5.900000 0.451799 3.252036 1.999991 + 6.000000 0.449424 3.275284 1.999991 + 6.100000 0.447546 3.297745 1.999991 + 6.200000 0.446115 3.319429 1.999991 + 6.300000 0.445085 3.340341 1.999991 + 6.400000 0.444418 3.360492 1.999991 + 6.500000 0.444079 3.379891 1.999991 6.600000 0.444034 3.398547 1.999991 - 6.700000 0.444257 3.416470 1.999991 - 6.800000 0.444722 3.433669 1.999991 - 6.900000 0.445409 3.450154 1.999991 - 7.000000 0.446297 3.465934 1.999991 - 7.100000 0.447370 3.481018 1.999991 - 7.200000 0.448614 3.495414 1.999991 - 7.300000 0.450016 3.509131 1.999991 - 7.400000 0.451564 3.522176 1.999991 + 6.700000 0.444256 3.416470 1.999991 + 6.800000 0.444722 3.433670 1.999991 + 6.900000 0.445408 3.450155 1.999991 + 7.000000 0.446297 3.465935 1.999991 + 7.100000 0.447370 3.481019 1.999991 + 7.200000 0.448614 3.495415 1.999991 + 7.300000 0.450016 3.509132 1.999991 + 7.400000 0.451564 3.522177 1.999991 7.500000 0.453249 3.534557 1.999991 - 7.600000 0.455064 3.546280 1.999991 - 7.700000 0.457000 3.557353 1.999991 - 7.800000 0.459052 3.567781 1.999991 - 7.900000 0.461216 3.577571 1.999991 - 8.000000 0.463486 3.586728 1.999991 + 7.600000 0.455064 3.546281 1.999991 + 7.700000 0.457000 3.557354 1.999991 + 7.800000 0.459052 3.567782 1.999991 + 7.900000 0.461216 3.577572 1.999991 + 8.000000 0.463486 3.586729 1.999991 8.100000 0.465860 3.595257 1.999991 8.200000 0.468335 3.603162 1.999991 8.300000 0.470909 3.610447 1.999991 @@ -94,28 +94,28 @@ 8.500000 0.476352 3.623171 1.999991 8.600000 0.479220 3.628616 1.999991 8.700000 0.482186 3.633451 1.999991 - 8.800000 0.485250 3.637679 1.999990 + 8.800000 0.485251 3.637679 1.999990 8.900000 0.488416 3.641299 1.999990 9.000000 0.491684 3.644311 1.999990 9.100000 0.495058 3.646715 1.999990 9.200000 0.498540 3.648509 1.999990 9.300000 0.502134 3.649691 1.999990 - 9.400000 0.505844 3.650257 1.999990 + 9.400000 0.505844 3.650256 1.999990 9.500000 0.509675 3.650202 1.999990 9.600000 0.513632 3.649521 1.999990 9.700000 0.517722 3.648209 1.999990 9.800000 0.521951 3.646257 1.999990 - 9.900000 0.526326 3.643656 1.999990 + 9.900000 0.526327 3.643656 1.999990 10.000000 0.530857 3.640396 1.999990 ---------------------------------------------- Final Solver Statistics: - Internal solver steps = 99 (attempted = 99) - Total RHS evals: Fe = 0, Fi = 1694 - Total linear solver setups = 35 + Internal solver steps = 66 (attempted = 67) + Total RHS evals: Fe = 0, Fi = 1302 + Total linear solver setups = 33 Total RHS evals for setting up the linear system = 0 - Total number of Jacobian evaluations = 14 - Total number of Newton iterations = 1196 - Total number of nonlinear solver convergence failures = 13 + Total number of Jacobian evaluations = 16 + Total number of Newton iterations = 899 + Total number of nonlinear solver convergence failures = 15 Total number of error test failures = 0 diff --git a/examples/arkode/C_serial/ark_brusselator1D_FEM_slu.out b/examples/arkode/C_serial/ark_brusselator1D_FEM_slu.out index 28851a7ed1..0e30875fd6 100644 --- a/examples/arkode/C_serial/ark_brusselator1D_FEM_slu.out +++ b/examples/arkode/C_serial/ark_brusselator1D_FEM_slu.out @@ -10,114 +10,114 @@ ---------------------------------------------- 0.100000 0.637854 3.356025 1.999989 0.200000 0.643035 3.345751 1.999989 - 0.300000 0.648532 3.334867 1.999989 - 0.400000 0.654362 3.323350 1.999989 - 0.500000 0.660542 3.311172 1.999988 - 0.600000 0.667093 3.298310 1.999988 - 0.700000 0.674031 3.284739 1.999988 - 0.800000 0.681370 3.270442 1.999988 - 0.900000 0.689121 3.255404 1.999988 - 1.000000 0.697285 3.239620 1.999988 - 1.100000 0.705854 3.223093 1.999987 - 1.200000 0.714805 3.205842 1.999987 - 1.300000 0.724099 3.187902 1.999987 - 1.400000 0.733671 3.169332 1.999987 - 1.500000 0.743429 3.150211 1.999987 - 1.600000 0.753249 3.130653 1.999987 - 1.700000 0.762974 3.110800 1.999986 - 1.800000 0.772412 3.090827 1.999986 - 1.900000 0.781337 3.070944 1.999986 - 2.000000 0.789501 3.051388 1.999986 - 2.100000 0.796639 3.032420 1.999986 - 2.200000 0.802490 3.014317 1.999986 - 2.300000 0.806810 2.997358 1.999986 - 2.400000 0.809386 2.981818 1.999986 - 2.500000 0.810060 2.967949 1.999986 - 2.600000 0.808729 2.955977 1.999986 - 2.700000 0.805360 2.946085 1.999986 - 2.800000 0.799989 2.938410 1.999986 - 2.900000 0.792711 2.933039 1.999986 - 3.000000 0.783680 2.930010 1.999986 - 3.100000 0.773095 2.929307 1.999986 - 3.200000 0.761187 2.930873 1.999986 - 3.300000 0.748207 2.934612 1.999987 - 3.400000 0.734416 2.940393 1.999987 - 3.500000 0.720073 2.948062 1.999987 - 3.600000 0.705429 2.957444 1.999987 + 0.300000 0.648532 3.334868 1.999989 + 0.400000 0.654362 3.323350 1.999988 + 0.500000 0.660543 3.311172 1.999988 + 0.600000 0.667094 3.298309 1.999988 + 0.700000 0.674032 3.284738 1.999988 + 0.800000 0.681371 3.270441 1.999988 + 0.900000 0.689123 3.255402 1.999988 + 1.000000 0.697286 3.239618 1.999988 + 1.100000 0.705855 3.223091 1.999987 + 1.200000 0.714810 3.205837 1.999987 + 1.300000 0.724101 3.187900 1.999987 + 1.400000 0.733673 3.169328 1.999987 + 1.500000 0.743434 3.150205 1.999987 + 1.600000 0.753251 3.130651 1.999987 + 1.700000 0.762976 3.110798 1.999986 + 1.800000 0.772414 3.090825 1.999986 + 1.900000 0.781339 3.070942 1.999986 + 2.000000 0.789502 3.051385 1.999986 + 2.100000 0.796640 3.032418 1.999986 + 2.200000 0.802492 3.014314 1.999986 + 2.300000 0.806810 2.997356 1.999986 + 2.400000 0.809388 2.981815 1.999986 + 2.500000 0.810060 2.967947 1.999986 + 2.600000 0.808729 2.955975 1.999986 + 2.700000 0.805361 2.946083 1.999986 + 2.800000 0.799988 2.938409 1.999986 + 2.900000 0.792711 2.933038 1.999986 + 3.000000 0.783680 2.930008 1.999986 + 3.100000 0.773094 2.929308 1.999986 + 3.200000 0.761185 2.930875 1.999986 + 3.300000 0.748206 2.934611 1.999987 + 3.400000 0.734415 2.940393 1.999987 + 3.500000 0.720072 2.948062 1.999987 + 3.600000 0.705427 2.957444 1.999987 3.700000 0.690714 2.968354 1.999988 - 3.800000 0.676141 2.980600 1.999988 - 3.900000 0.661891 2.993989 1.999988 + 3.800000 0.676140 2.980600 1.999988 + 3.900000 0.661890 2.993989 1.999988 4.000000 0.648122 3.008331 1.999989 - 4.100000 0.634961 3.023445 1.999989 + 4.100000 0.634960 3.023446 1.999989 4.200000 0.622506 3.039157 1.999989 - 4.300000 0.610828 3.055308 1.999989 - 4.400000 0.599972 3.071752 1.999989 - 4.500000 0.589962 3.088356 1.999990 - 4.600000 0.580801 3.105007 1.999990 - 4.700000 0.572477 3.121603 1.999990 - 4.800000 0.564964 3.138059 1.999990 - 4.900000 0.558227 3.154303 1.999990 - 5.000000 0.552224 3.170278 1.999990 - 5.100000 0.546907 3.185935 1.999991 - 5.200000 0.542228 3.201239 1.999991 - 5.300000 0.538137 3.216162 1.999991 - 5.400000 0.534585 3.230683 1.999991 - 5.500000 0.531525 3.244788 1.999991 - 5.600000 0.528910 3.258469 1.999991 - 5.700000 0.526699 3.271720 1.999991 - 5.800000 0.524852 3.284539 1.999991 - 5.900000 0.523334 3.296928 1.999991 - 6.000000 0.522111 3.308889 1.999991 - 6.100000 0.521154 3.320427 1.999991 - 6.200000 0.520436 3.331545 1.999991 - 6.300000 0.519932 3.342251 1.999991 - 6.400000 0.519621 3.352549 1.999991 - 6.500000 0.519484 3.362447 1.999991 - 6.600000 0.519503 3.371950 1.999991 - 6.700000 0.519664 3.381065 1.999991 - 6.800000 0.519953 3.389797 1.999991 - 6.900000 0.520358 3.398153 1.999991 - 7.000000 0.520869 3.406139 1.999991 - 7.100000 0.521477 3.413759 1.999991 - 7.200000 0.522174 3.421020 1.999991 - 7.300000 0.522953 3.427926 1.999991 - 7.400000 0.523807 3.434482 1.999991 - 7.500000 0.524732 3.440692 1.999991 - 7.600000 0.525723 3.446560 1.999991 - 7.700000 0.526775 3.452091 1.999991 - 7.800000 0.527887 3.457288 1.999991 - 7.900000 0.529055 3.462154 1.999991 + 4.300000 0.610826 3.055309 1.999989 + 4.400000 0.599971 3.071752 1.999989 + 4.500000 0.589960 3.088358 1.999990 + 4.600000 0.580800 3.105008 1.999990 + 4.700000 0.572476 3.121604 1.999990 + 4.800000 0.564963 3.138060 1.999990 + 4.900000 0.558226 3.154305 1.999990 + 5.000000 0.552223 3.170279 1.999990 + 5.100000 0.546906 3.185936 1.999991 + 5.200000 0.542228 3.201241 1.999991 + 5.300000 0.538137 3.216163 1.999991 + 5.400000 0.534585 3.230684 1.999991 + 5.500000 0.531524 3.244789 1.999991 + 5.600000 0.528909 3.258470 1.999991 + 5.700000 0.526698 3.271721 1.999991 + 5.800000 0.524852 3.284540 1.999991 + 5.900000 0.523333 3.296929 1.999991 + 6.000000 0.522110 3.308890 1.999991 + 6.100000 0.521154 3.320428 1.999991 + 6.200000 0.520436 3.331547 1.999991 + 6.300000 0.519931 3.342252 1.999991 + 6.400000 0.519620 3.352550 1.999991 + 6.500000 0.519484 3.362448 1.999991 + 6.600000 0.519503 3.371951 1.999991 + 6.700000 0.519663 3.381066 1.999991 + 6.800000 0.519953 3.389798 1.999991 + 6.900000 0.520358 3.398154 1.999991 + 7.000000 0.520869 3.406140 1.999991 + 7.100000 0.521477 3.413761 1.999991 + 7.200000 0.522174 3.421021 1.999991 + 7.300000 0.522953 3.427927 1.999991 + 7.400000 0.523807 3.434483 1.999991 + 7.500000 0.524732 3.440693 1.999991 + 7.600000 0.525723 3.446561 1.999991 + 7.700000 0.526775 3.452092 1.999991 + 7.800000 0.527887 3.457289 1.999991 + 7.900000 0.529055 3.462155 1.999991 8.000000 0.530276 3.466693 1.999991 8.100000 0.531549 3.470907 1.999991 - 8.200000 0.532872 3.474798 1.999991 - 8.300000 0.534244 3.478370 1.999991 - 8.400000 0.535665 3.481625 1.999991 - 8.500000 0.537133 3.484563 1.999991 - 8.600000 0.538649 3.487188 1.999991 + 8.200000 0.532872 3.474799 1.999991 + 8.300000 0.534244 3.478371 1.999991 + 8.400000 0.535665 3.481626 1.999991 + 8.500000 0.537133 3.484564 1.999991 + 8.600000 0.538650 3.487188 1.999991 8.700000 0.540213 3.489499 1.999991 - 8.800000 0.541825 3.491497 1.999991 - 8.900000 0.543486 3.493184 1.999991 - 9.000000 0.545196 3.494560 1.999991 - 9.100000 0.546957 3.495624 1.999991 + 8.800000 0.541825 3.491498 1.999991 + 8.900000 0.543486 3.493185 1.999991 + 9.000000 0.545197 3.494560 1.999991 + 9.100000 0.546958 3.495624 1.999991 9.200000 0.548771 3.496375 1.999991 - 9.300000 0.550638 3.496814 1.999990 + 9.300000 0.550639 3.496814 1.999990 9.400000 0.552562 3.496938 1.999990 9.500000 0.554543 3.496746 1.999990 - 9.600000 0.556585 3.496235 1.999990 - 9.700000 0.558691 3.495404 1.999990 - 9.800000 0.560864 3.494247 1.999990 + 9.600000 0.556586 3.496236 1.999990 + 9.700000 0.558692 3.495404 1.999990 + 9.800000 0.560865 3.494247 1.999990 9.900000 0.563108 3.492763 1.999990 - 10.000000 0.565426 3.490945 1.999990 + 10.000000 0.565426 3.490944 1.999990 ---------------------------------------------- Final Solver Statistics: - Internal solver steps = 95 (attempted = 95) - Total RHS evals: Fe = 0, Fi = 1605 + Internal solver steps = 60 (attempted = 62) + Total RHS evals: Fe = 0, Fi = 1173 Total mass matrix setups = 1 - Total mass matrix solves = 288 - Total mass times evals = 1697 - Total linear solver setups = 31 - Total number of Jacobian evaluations = 11 - Total number of Newton iterations = 1127 - Total number of nonlinear solver convergence failures = 10 + Total mass matrix solves = 245 + Total mass times evals = 1170 + Total linear solver setups = 34 + Total number of Jacobian evaluations = 34 + Total number of Newton iterations = 802 + Total number of nonlinear solver convergence failures = 14 Total number of error test failures = 0 diff --git a/examples/arkode/C_serial/ark_brusselator1D_klu.out b/examples/arkode/C_serial/ark_brusselator1D_klu.out index 7e6bc33063..872fd7c8d5 100644 --- a/examples/arkode/C_serial/ark_brusselator1D_klu.out +++ b/examples/arkode/C_serial/ark_brusselator1D_klu.out @@ -7,23 +7,23 @@ t ||u||_rms ||v||_rms ||w||_rms ---------------------------------------------- - 1.000000 0.791135 3.140510 1.999984 - 2.000000 0.960033 2.757430 1.999981 - 3.000000 0.930299 2.532868 1.999982 - 4.000000 0.681809 2.696300 1.999986 - 5.000000 0.506326 3.007843 1.999990 - 6.000000 0.449425 3.275283 1.999991 - 7.000000 0.446297 3.465934 1.999991 - 8.000000 0.463486 3.586728 1.999991 + 1.000000 0.791136 3.140509 1.999984 + 2.000000 0.960035 2.757427 1.999981 + 3.000000 0.930298 2.532869 1.999982 + 4.000000 0.681808 2.696301 1.999986 + 5.000000 0.506325 3.007844 1.999990 + 6.000000 0.449424 3.275284 1.999991 + 7.000000 0.446297 3.465935 1.999991 + 8.000000 0.463486 3.586729 1.999991 9.000000 0.491684 3.644311 1.999990 10.000000 0.530857 3.640396 1.999990 ---------------------------------------------- Final Solver Statistics: - Internal solver steps = 99 (attempted = 99) - Total RHS evals: Fe = 0, Fi = 1694 - Total linear solver setups = 35 - Total number of Jacobian evaluations = 14 - Total number of nonlinear iterations = 1196 - Total number of nonlinear solver convergence failures = 13 + Internal solver steps = 66 (attempted = 67) + Total RHS evals: Fe = 0, Fi = 1302 + Total linear solver setups = 33 + Total number of Jacobian evaluations = 16 + Total number of nonlinear iterations = 899 + Total number of nonlinear solver convergence failures = 15 Total number of error test failures = 0 diff --git a/examples/arkode/C_serial/ark_conserved_exp_entropy_ark_1_0.out b/examples/arkode/C_serial/ark_conserved_exp_entropy_ark_1_0.out index 05f6b3f4ce..e42e2ed690 100644 --- a/examples/arkode/C_serial/ark_conserved_exp_entropy_ark_1_0.out +++ b/examples/arkode/C_serial/ark_conserved_exp_entropy_ark_1_0.out @@ -8,18 +8,17 @@ Conserved Exponential Entropy problem: step t u v e delta e ------------------------------------------------------------------------------- 0 0.000000e+00 1.000000e+00 5.000000e-01 4.367003e+00 0.000000e+00 - 40 6.911091e-01 -1.121528e+00 1.396547e+00 4.367003e+00 -1.776357e-15 - 80 1.946408e+00 -6.526227e+00 1.473742e+00 4.367003e+00 4.440892e-15 + 40 1.167689e+00 -3.135232e+00 1.464068e+00 4.367003e+00 -8.881784e-15 ------------------------------------------------------------------------------- Final Solver Statistics: - Internal solver steps = 99 (attempted = 124) - Total number of error test failures = 0 - Total RHS evals: Fe = 722, Fi = 0 - Total Relaxation Fn evals = 622 - Total Relaxation Jac evals = 1019 - Total Relaxation fails = 25 - Total Relaxation bound fails = 0 - Total Relaxation NLS fails = 25 - Total Relaxation NLS iters = 399 + Internal solver steps = 54 (attempted = 65) + Total number of error test failures = 2 + Total RHS evals: Fe = 328, Fi = 0 + Total Relaxation Fn evals = 312 + Total Relaxation Jac evals = 515 + Total Relaxation fails = 9 + Total Relaxation bound fails = 1 + Total Relaxation NLS fails = 8 + Total Relaxation NLS iters = 190 diff --git a/examples/arkode/C_serial/ark_conserved_exp_entropy_erk_1.out b/examples/arkode/C_serial/ark_conserved_exp_entropy_erk_1.out index 9e1649f48e..9fc546c8cf 100644 --- a/examples/arkode/C_serial/ark_conserved_exp_entropy_erk_1.out +++ b/examples/arkode/C_serial/ark_conserved_exp_entropy_erk_1.out @@ -8,18 +8,17 @@ Conserved Exponential Entropy problem: step t u v e delta e ------------------------------------------------------------------------------- 0 0.000000e+00 1.000000e+00 5.000000e-01 4.367003e+00 0.000000e+00 - 40 6.759227e-01 -1.060311e+00 1.391445e+00 4.367003e+00 -1.776357e-15 - 80 1.694830e+00 -5.428257e+00 1.473071e+00 4.367003e+00 -8.881784e-16 + 40 1.735282e+00 -5.604749e+00 1.473234e+00 4.367003e+00 -5.748022e-08 ------------------------------------------------------------------------------- Final Solver Statistics: - Internal solver steps = 95 (attempted = 121) - Total number of error test failures = 2 - Total RHS evals = 582 - Total Relaxation Fn evals = 608 - Total Relaxation Jac evals = 995 - Total Relaxation fails = 24 - Total Relaxation bound fails = 0 - Total Relaxation NLS fails = 24 - Total Relaxation NLS iters = 390 + Internal solver steps = 47 (attempted = 51) + Total number of error test failures = 3 + Total RHS evals = 207 + Total Relaxation Fn evals = 200 + Total Relaxation Jac evals = 353 + Total Relaxation fails = 1 + Total Relaxation bound fails = 1 + Total Relaxation NLS fails = 0 + Total Relaxation NLS iters = 98 diff --git a/examples/arkode/C_serial/ark_dissipated_exp_entropy_1_0.out b/examples/arkode/C_serial/ark_dissipated_exp_entropy_1_0.out index 90df8380be..52cc4cfde0 100644 --- a/examples/arkode/C_serial/ark_dissipated_exp_entropy_1_0.out +++ b/examples/arkode/C_serial/ark_dissipated_exp_entropy_1_0.out @@ -8,19 +8,17 @@ Dissipated Exponential Entropy problem: step t u e u_err delta e ------------------------------------------------------------------------------- 0 0.000000e+00 1.000000e+00 2.718282e+00 0.000000e+00 0.000000e+00 - 40 4.675332e-01 1.798296e-01 1.197013e+00 1.083801e-01 -1.521269e+00 - 80 1.147092e+00 -4.153968e-01 6.600783e-01 -9.770808e-01 -2.058204e+00 - 120 3.654055e+00 -1.391763e+00 2.486366e-01 -2.841170e+00 -2.469645e+00 + 40 4.820760e+00 -1.646470e+00 1.927290e-01 -3.337911e+00 -2.525553e+00 ------------------------------------------------------------------------------- Final Solver Statistics: - Internal solver steps = 130 (attempted = 130) - Total number of error test failures = 0 - Total RHS evals: Fe = 783, Fi = 0 - Total Relaxation Fn evals = 392 - Total Relaxation Jac evals = 782 + Internal solver steps = 41 (attempted = 42) + Total number of error test failures = 1 + Total RHS evals: Fe = 213, Fi = 0 + Total Relaxation Fn evals = 163 + Total Relaxation Jac evals = 289 Total Relaxation fails = 0 Total Relaxation bound fails = 0 Total Relaxation NLS fails = 0 - Total Relaxation NLS iters = 132 + Total Relaxation NLS iters = 79 diff --git a/examples/arkode/C_serial/ark_heat1D.out b/examples/arkode/C_serial/ark_heat1D.out index 2f33b506c3..17f3196e66 100644 --- a/examples/arkode/C_serial/ark_heat1D.out +++ b/examples/arkode/C_serial/ark_heat1D.out @@ -18,12 +18,12 @@ ------------------------- Final Solver Statistics: - Internal solver steps = 191 (attempted = 191) - Total RHS evals: Fe = 0, Fi = 1913 + Internal solver steps = 81 (attempted = 81) + Total RHS evals: Fe = 0, Fi = 894 Total linear solver setups = 0 - Total linear iterations = 18265 - Total number of Jacobian-vector products = 18265 + Total linear iterations = 11416 + Total number of Jacobian-vector products = 11416 Total number of linear solver convergence failures = 0 - Total number of Newton iterations = 955 + Total number of Newton iterations = 405 Total number of nonlinear solver convergence failures = 0 Total number of error test failures = 0 diff --git a/examples/arkode/C_serial/ark_heat1D_adapt.c b/examples/arkode/C_serial/ark_heat1D_adapt.c index 28447942b6..604273f283 100644 --- a/examples/arkode/C_serial/ark_heat1D_adapt.c +++ b/examples/arkode/C_serial/ark_heat1D_adapt.c @@ -82,7 +82,7 @@ static int Jac(N_Vector v, N_Vector Jv, realtype t, N_Vector y, N_Vector fy, void *user_data, N_Vector tmp); /* Private function to check function return values */ -realtype * adapt_mesh(N_Vector y, sunindextype *Nnew, UserData udata); +realtype* adapt_mesh(N_Vector y, sunindextype *Nnew, UserData udata); static int project(sunindextype Nold, realtype *xold, N_Vector yold, sunindextype Nnew, realtype *xnew, N_Vector ynew); static int check_flag(void *flagvalue, const char *funcname, int opt); diff --git a/examples/arkode/C_serial/ark_heat1D_adapt.out b/examples/arkode/C_serial/ark_heat1D_adapt.out index 4eb02c8a18..a48e88153d 100644 --- a/examples/arkode/C_serial/ark_heat1D_adapt.out +++ b/examples/arkode/C_serial/ark_heat1D_adapt.out @@ -6,154 +6,69 @@ ---------------------------------------------------------------------------------------- 0 0.000000000000000e+00 0.000000000000000e+00 0.000000000000000e+00 21 0 0 1 3.629021901461023e-12 7.505751048377368e-09 2.979166031180459e-12 21 5 5 - 2 7.505751048377368e-09 1.501150209675474e-07 6.164657920191316e-09 21 5 5 - 3 1.501150209675474e-07 3.002300419350948e-06 1.293969127944767e-07 21 5 10 - 4 3.002300419350948e-06 6.004600838701896e-05 2.593514282990854e-06 21 5 10 - 5 6.004600838701896e-05 2.853823712852094e-04 5.166758334560010e-05 21 5 20 - 6 2.853823712852094e-04 2.575255578901065e-04 2.798555766932917e-04 21 5 25 - 7 2.575255578901065e-04 4.094541218029253e-04 4.794249606742115e-04 21 5 25 - 8 4.094541218029253e-04 4.094541218029253e-04 7.863858593533243e-04 21 5 29 - 9 4.094541218029253e-04 6.522910582302937e-04 1.082809153607867e-03 21 5 29 - 10 6.522910582302937e-04 5.699097250687579e-04 1.606859000290955e-03 23 5 40 - 11 5.699097250687579e-04 1.007836408495680e-03 2.005669608336064e-03 23 5 35 - 12 1.007836408495680e-03 1.007836408495680e-03 2.683041089905320e-03 23 5 40 - 13 1.007836408495680e-03 8.453991987969423e-04 3.678394954727681e-03 25 5 40 - 14 8.453991987969423e-04 1.990429430223850e-03 4.265068071685453e-03 25 5 34 - 15 1.990429430223850e-03 1.990429430223850e-03 5.574933877447707e-03 25 5 41 - 16 1.990429430223850e-03 3.606540539819520e-03 6.798364735960519e-03 25 5 35 - 17 4.980839747684550e-04 4.980839747684550e-04 6.927003506629248e-03 27 15 180 - 18 4.980839747684550e-04 4.980839747684550e-04 7.441563625964739e-03 29 5 30 - 19 4.980839747684550e-04 1.668131272315291e-03 7.722574952892512e-03 29 5 29 - 20 1.668131272315291e-03 3.659992327983156e-03 8.637136102347247e-03 29 5 44 - 21 3.659992327983156e-03 7.226886812998415e-03 1.050785838365518e-02 29 5 65 - 22 2.276503454413033e-04 2.223970105833804e-04 1.033577924663066e-02 32 20 250 - 23 2.223970105833804e-04 4.397896042992326e-04 1.092271235598801e-02 34 5 24 - 24 4.397896042992326e-04 1.023105619938674e-03 1.113382898409555e-02 34 5 33 - 25 1.023105619938674e-03 1.023105619938674e-03 1.161589583401345e-02 34 5 36 - 26 1.023105619938674e-03 3.930141141574615e-03 1.208588377404162e-02 34 5 38 - 27 3.930141141574615e-03 3.871064201787735e-03 1.378515153788083e-02 34 5 84 - 28 3.871064201787735e-03 1.255329001281564e-02 1.530995222029954e-02 34 5 59 - 29 1.601537140384145e-03 1.457835824294224e-03 1.581392684966786e-02 36 15 234 - 30 1.457835824294224e-03 3.743501735515000e-03 1.633976217518591e-02 36 5 29 - 31 2.870420514795557e-03 2.465672685089582e-03 1.732506340515539e-02 38 10 143 - 32 5.515562262925350e-04 5.470070369949626e-04 1.714361637592621e-02 40 15 253 - 33 5.470070369949626e-04 9.932912795468831e-04 1.731823052548390e-02 40 5 43 - 34 9.932912795468831e-04 2.851877222558192e-03 1.763020341932926e-02 40 5 47 - 35 2.851877222558192e-03 8.592060762682407e-03 1.849017614042958e-02 40 5 96 - 36 1.753358828184278e-03 1.753358828184278e-03 1.899364054123662e-02 40 15 259 - 37 1.753358828184278e-03 8.066441335477586e-03 1.947884133485359e-02 40 5 60 - 38 6.367831766622205e-04 6.367831766622205e-04 1.897985914604649e-02 44 15 269 - 39 6.367831766622205e-04 1.262468320666752e-03 1.914535124132059e-02 44 5 47 - 40 1.262468320666752e-03 3.587735441717919e-03 1.946692075971101e-02 44 5 62 - 41 2.843421467160759e-03 2.408215671837289e-03 1.976846530535780e-02 46 10 199 - 42 2.408215671837289e-03 4.077980222533944e-03 2.031687522001488e-02 46 5 72 - 43 4.077980222533944e-03 1.071890797618786e-02 2.118660808690947e-02 46 5 88 - 44 1.071890797618786e-02 1.071890797618786e-02 2.316134512731487e-02 46 5 105 - 45 2.694639841378283e-03 2.650454280532623e-03 2.346008222533597e-02 48 10 208 - 46 5.834157269803085e-04 5.834157269803085e-04 2.328708620673918e-02 50 15 268 - 47 5.834157269803085e-04 1.193846932419712e-03 2.337621483760628e-02 50 5 55 - 48 1.193846932419712e-03 3.258366515093616e-03 2.355525946951272e-02 50 5 66 - 49 3.258366515093616e-03 6.418173913904015e-03 2.402308335632452e-02 50 5 104 - 50 3.844477373368192e-03 3.844477373368192e-03 2.453874392666302e-02 50 10 210 - 51 3.844477373368192e-03 1.778266602162782e-02 2.501810350379247e-02 50 5 91 - 52 4.165560835571891e-03 4.165560835571891e-03 2.549975323954108e-02 50 10 209 - 53 4.165560835571891e-03 4.165560835571891e-03 2.594523957554863e-02 50 5 105 - 54 4.165560835571891e-03 1.187099370779400e-02 2.635751897001287e-02 50 5 103 - 55 7.990286205672150e-03 7.990286205672150e-03 2.706496621836213e-02 50 10 210 - 56 7.990286205672150e-03 7.366258582155646e-03 2.767656709536814e-02 50 5 105 - 57 3.192957423660317e-03 2.690992361017143e-03 2.898705700684332e-02 54 10 210 - 58 2.690992361017143e-03 4.595411828908103e-03 2.916901398660043e-02 54 5 103 - 59 4.595411828908103e-03 1.148959244582437e-02 2.946060998170889e-02 54 5 105 - 60 3.392951963605576e-03 3.392951963605576e-03 2.934282134054850e-02 56 10 210 - 61 3.392951963605576e-03 1.266181052388950e-02 2.953044118771774e-02 56 5 75 - 62 1.266181052388950e-02 2.070977380726893e-02 3.014157400043279e-02 56 5 105 - 63 4.582873894130091e-03 4.582873894130091e-03 2.988631128376999e-02 58 10 210 - 64 4.582873894130091e-03 9.607054797980071e-03 2.957561272951538e-02 60 5 105 - 65 9.607054797980071e-03 1.949020745582244e-02 2.989673188100094e-02 60 5 105 - 66 1.054807485438376e-02 1.054807485438376e-02 3.019699587646915e-02 60 10 210 - 67 2.168783293816825e-03 2.168783293816825e-03 3.025284168346583e-02 60 10 210 - 68 2.168783293816825e-03 2.168783293816825e-03 3.030686555035694e-02 60 5 104 - 69 2.168783293816825e-03 9.519769922039302e-03 3.035913346641964e-02 60 5 79 - 70 9.519769922039302e-03 3.689745921797256e-02 3.056948236696047e-02 60 5 105 - 71 5.027376845883330e-03 5.027376845883330e-03 3.066924792565106e-02 60 10 210 - 72 5.027376845883330e-03 1.680323823916145e-02 3.076207689001887e-02 60 5 84 - 73 1.190695511366464e-02 1.190695511366464e-02 3.095765596831891e-02 60 10 210 - 74 8.824020991017463e-03 8.824020991017463e-03 3.108370439289872e-02 60 10 210 - 75 8.824020991017463e-03 7.492138529693538e-03 3.119630288799381e-02 60 5 105 - 76 7.492138529693538e-03 1.126027020832041e-02 3.128267383642943e-02 60 5 105 - 77 7.641572371714925e-03 7.641572371714925e-03 3.136324481005783e-02 60 10 210 - 78 7.641572371714925e-03 1.384651466179487e-02 3.143706333937704e-02 60 5 105 - 79 1.384651466179487e-02 1.168352852310369e-02 3.155622058156962e-02 60 5 105 - 80 7.186697995423493e-03 6.679717823882544e-03 3.161160219834706e-02 60 10 210 - 81 6.679717823882544e-03 6.679717823882544e-03 3.165979180134944e-02 60 5 105 - 82 6.679717823882544e-03 1.036597822978498e-02 3.170495968309999e-02 60 5 105 - 83 1.036597822978498e-02 2.078683878676566e-02 3.176988825989206e-02 60 5 105 - 84 9.416934538800317e-03 9.416934538800317e-03 3.182402943647551e-02 60 10 210 - 85 9.416934538800317e-03 2.931003455946657e-02 3.187416014076831e-02 60 5 105 - 86 2.931003455946657e-02 2.522099385522949e-02 3.200899311332644e-02 60 5 105 - 87 9.855600599572635e-04 8.688271778628972e-04 3.201326296052575e-02 60 20 384 - 88 8.688271778628972e-04 1.468146563475753e-03 3.201682378904077e-02 60 5 52 - 89 1.468146563475753e-03 4.343969048002700e-03 3.202279095225564e-02 60 5 74 - 90 4.343969048002700e-03 1.055819789459882e-02 3.204011973102326e-02 60 5 105 - 91 1.055819789459882e-02 2.209065533222391e-02 3.208023614326307e-02 60 5 105 - 92 2.386319631553004e-03 2.386319631553004e-03 3.208893412153121e-02 60 10 201 - 93 2.386319631553004e-03 1.364130552312118e-02 3.209750202157599e-02 60 5 55 - 94 1.364130552312118e-02 3.804643259996037e-02 3.214413129385055e-02 60 5 105 - 95 1.350012470133744e-02 1.350012470133744e-02 3.218665147855618e-02 60 10 210 - 96 9.639737373424729e-03 9.639737373424729e-03 3.221511600193919e-02 60 10 210 - 97 9.639737373424729e-03 1.590630674910340e-02 3.224203283811158e-02 60 5 105 - 98 9.367414453891131e-03 9.367414453891131e-03 3.226685525508665e-02 60 10 210 - 99 9.367414453891131e-03 9.367414453891131e-03 3.229047473304966e-02 60 5 105 - 100 9.367414453891131e-03 9.367414453891131e-03 3.231292205847536e-02 60 5 105 - 101 9.367414453891131e-03 9.367414453891131e-03 3.233430846708617e-02 60 5 105 - 102 9.367414453891131e-03 1.668718345780916e-02 3.235467947113296e-02 60 5 105 - 103 5.906021531128903e-03 5.906021531128903e-03 3.236703325098769e-02 60 10 210 - 104 5.906021531128903e-03 2.471346837871190e-02 3.237901834705667e-02 60 5 96 - 105 2.471346837871190e-02 2.201998950790008e-02 3.242549498508623e-02 60 5 105 - 106 3.894024974675171e-04 3.761680700537104e-04 3.242617044596968e-02 60 20 349 - 107 3.761680700537104e-04 7.748843143493643e-04 3.242683007682674e-02 60 5 46 - 108 7.748843143493643e-04 1.939359550616336e-03 3.242818962548284e-02 60 5 48 - 109 1.939359550616336e-03 3.113184611872983e-03 3.243157178567092e-02 60 5 97 - 110 3.113184611872983e-03 1.134238283346586e-02 3.243693386177211e-02 60 5 56 - 111 1.134238283346586e-02 1.796931919942777e-02 3.245578846135799e-02 60 5 105 - 112 1.796931919942777e-02 1.796931919942777e-02 3.248360322275518e-02 60 5 105 - 113 8.830774846120172e-03 8.830774846120172e-03 3.249636376759852e-02 60 10 210 - 114 8.830774846120172e-03 1.498507899698427e-02 3.250861147195047e-02 60 5 105 - 115 1.498507899698427e-02 2.400192116112091e-02 3.252822783037751e-02 60 5 105 - 116 1.834491808739763e-02 1.623377394364994e-02 3.255035322145888e-02 60 10 210 - 117 3.788212246854621e-03 3.773941147494160e-03 3.255469746916730e-02 60 15 315 - 118 3.773941147494160e-03 7.682030983754903e-03 3.255893334479040e-02 60 5 102 - 119 7.682030983754903e-03 2.180723185927965e-02 3.256732024800101e-02 60 5 105 - 120 2.180723185927965e-02 2.180723185927965e-02 3.258952126393384e-02 60 5 105 - 121 7.835737782770146e-03 7.835737782770146e-03 3.259691115681246e-02 60 10 210 - 122 7.835737782770146e-03 7.835737782770146e-03 3.260403532591830e-02 60 5 105 - 123 7.835737782770146e-03 1.521701267403009e-02 3.261090627152081e-02 60 5 105 - 124 1.521701267403009e-02 1.453434366415250e-02 3.262350907909189e-02 60 5 105 - 125 8.703052343239644e-03 8.703052343239644e-03 3.263033111822743e-02 60 10 210 - 126 8.703052343239644e-03 1.579670548089376e-02 3.263681960135667e-02 60 5 105 - 127 1.579670548089376e-02 1.579670548089376e-02 3.264798736584679e-02 60 5 105 - 128 1.579670548089376e-02 1.579670548089376e-02 3.265832267481519e-02 60 5 105 - 129 1.579670548089376e-02 1.579670548089376e-02 3.266783834117996e-02 60 5 105 - 130 1.579670548089376e-02 1.579670548089376e-02 3.267678702878758e-02 60 5 105 - 131 1.579670548089376e-02 1.579670548089376e-02 3.268496551666714e-02 60 5 105 - 132 1.579670548089376e-02 1.579670548089376e-02 3.269259030998119e-02 60 5 105 - 133 1.579670548089376e-02 1.579670548089376e-02 3.269967993118440e-02 60 5 105 - 134 9.442981671750042e-03 9.442981671750042e-03 3.270354813120258e-02 60 10 210 - 135 9.442981671750042e-03 1.498194099824085e-02 3.270736206011246e-02 60 5 105 - 136 1.498194099824085e-02 1.498194099824085e-02 3.271299843859180e-02 60 5 105 - 137 1.498194099824085e-02 1.498194099824085e-02 3.271824887923226e-02 60 5 105 - 138 1.498194099824085e-02 1.498194099824085e-02 3.272312899128821e-02 60 5 105 - 139 1.498194099824085e-02 1.498194099824085e-02 3.272766675941034e-02 60 5 105 - 140 1.498194099824085e-02 2.323511524381186e-02 3.273188003348305e-02 60 5 105 - 141 2.323511524381186e-02 2.323511524381186e-02 3.273782698896385e-02 60 5 105 - 142 2.323511524381186e-02 2.323511524381186e-02 3.274312637533745e-02 60 5 105 - 143 2.323511524381186e-02 2.042949136658555e-02 3.274788476870443e-02 60 5 105 - 144 2.042949136658555e-02 2.042949136658555e-02 3.275161072878752e-02 60 5 105 - 145 2.042949136658555e-02 1.314912365010589e-02 3.275500884737036e-02 60 5 105 - 146 1.314912365010589e-02 1.314912365010589e-02 3.275701308437982e-02 60 5 105 + 2 7.505751048377368e-09 1.501150209675474e-07 6.164657920191307e-09 21 5 5 + 3 1.501150209675474e-07 3.002300419350948e-06 1.293969127944766e-07 21 5 10 + 4 3.002300419350948e-06 6.004600838701896e-05 2.593514282990850e-06 21 5 10 + 5 6.004600838701896e-05 9.179695538357336e-04 5.166758334560012e-05 21 5 20 + 6 6.343530005430744e-04 6.343530005430744e-04 5.490107872707672e-04 21 10 71 + 7 6.343530005430744e-04 1.640766638078654e-03 1.016222005330447e-03 21 5 30 + 8 1.640766638078654e-03 1.640766638078654e-03 2.134866382338098e-03 21 5 44 + 9 1.640766638078654e-03 3.176698444896273e-03 3.286762426687487e-03 23 5 49 + 10 3.176698444896273e-03 5.205770196716116e-03 5.734914310249919e-03 25 5 64 + 11 5.205770196716116e-03 1.339483075369273e-02 8.758410772823907e-03 25 5 68 + 12 1.339483075369273e-02 2.332818380284690e-02 1.485648013359982e-02 29 5 105 + 13 1.647710301334834e-02 1.618551920838986e-02 2.033337937546846e-02 36 10 210 + 14 5.127912200355177e-03 5.127912200355177e-03 2.050886837681435e-02 43 10 210 + 15 5.127912200355177e-03 5.127912200355177e-03 2.138372999689098e-02 45 5 105 + 16 5.127912200355177e-03 1.719643928918329e-02 2.196379880786446e-02 47 5 105 + 17 1.719643928918329e-02 1.719643928918329e-02 2.462448517775678e-02 47 5 105 + 18 2.726964651455112e-03 2.726964651455112e-03 2.459568117363327e-02 51 15 315 + 19 2.726964651455112e-03 2.009585044098471e-02 2.492062059346483e-02 51 5 105 + 20 2.009585044098471e-02 2.009585044098471e-02 2.686776400257444e-02 51 5 105 + 21 1.054130507824213e-02 1.054130507824213e-02 2.763716608616132e-02 51 10 210 + 22 1.054130507824213e-02 1.054130507824213e-02 2.909021942975254e-02 57 5 105 + 23 1.054130507824213e-02 9.413090410446200e-03 2.963349789673522e-02 57 5 105 + 24 9.413090410446200e-03 1.585980467636817e-02 2.961045366199381e-02 59 5 105 + 25 1.103692839611401e-02 1.103692839611401e-02 2.953482868887520e-02 61 10 210 + 26 1.103692839611401e-02 2.146759072689938e-02 2.986560774377844e-02 61 5 105 + 27 5.366897681724844e-03 5.366897681724844e-03 3.000696970200713e-02 61 6 126 + 28 5.366897681724844e-03 5.366897681724844e-03 3.013711556584368e-02 61 5 105 + 29 5.366897681724844e-03 2.052863455115380e-02 3.025726772389385e-02 61 5 105 + 30 7.206791531966868e-03 7.206791531966868e-03 3.040422975415536e-02 61 10 210 + 31 7.206791531966868e-03 2.943786846489305e-02 3.053709469321317e-02 61 5 105 + 32 7.359467116223263e-03 7.359467116223263e-03 3.065948310402142e-02 61 8 168 + 33 7.359467116223263e-03 2.596101309295228e-02 3.077062813129303e-02 61 5 105 + 34 1.510966488467321e-02 1.321555023957658e-02 3.096745434061076e-02 61 10 210 + 35 1.321555023957658e-02 1.321555023957658e-02 3.111132384504421e-02 61 5 105 + 36 1.321555023957658e-02 1.321555023957658e-02 3.091519933864212e-02 65 5 105 + 37 1.321555023957658e-02 2.758491476925884e-02 3.102940106828724e-02 65 5 105 + 38 1.668307996188009e-02 1.581097235471425e-02 3.114780139778827e-02 65 10 210 + 39 1.581097235471425e-02 1.581097235471425e-02 3.124464696796996e-02 65 5 105 + 40 1.581097235471425e-02 1.581097235471425e-02 3.132817278522958e-02 65 5 105 + 41 1.581097235471425e-02 2.385684000265996e-02 3.140053221676826e-02 65 5 105 + 42 2.385684000265996e-02 2.385684000265996e-02 3.149404497253858e-02 65 5 105 + 43 2.385684000265996e-02 3.759045390015354e-02 3.157205180696617e-02 65 5 105 + 44 2.927280780216978e-02 2.761139321328726e-02 3.165655349343981e-02 65 10 210 + 45 2.761139321328726e-02 2.761139321328726e-02 3.172296577833395e-02 65 5 105 + 46 2.761139321328726e-02 5.427892592063448e-02 3.177924030766782e-02 65 5 105 + 47 2.810427708722941e-02 2.614790278479289e-02 3.183040417514173e-02 65 10 210 + 48 2.614790278479289e-02 2.500544537498958e-02 3.186874278155490e-02 65 5 105 + 49 2.500544537498958e-02 2.165728265810721e-02 3.190542587451715e-02 65 5 105 + 50 2.165728265810721e-02 1.897089250050289e-02 3.193148460120560e-02 65 5 105 + 51 1.897089250050289e-02 1.897089250050289e-02 3.195303711678953e-02 65 5 105 + 52 1.897089250050289e-02 2.921928213579898e-02 3.197232746286939e-02 65 5 105 + 53 2.921928213579898e-02 2.921928213579898e-02 3.199834150818939e-02 65 5 105 + 54 1.866692246159663e-02 1.647666491993380e-02 3.201345155446300e-02 65 10 210 + 55 1.647666491993380e-02 4.365487643849412e-02 3.202553413738606e-02 65 5 105 + 56 4.365487643849412e-02 4.365487643849412e-02 3.205258724373149e-02 65 5 105 + 57 4.365487643849412e-02 6.668877263463968e-02 3.207444502993684e-02 65 5 105 + 58 5.053754284537330e-02 5.053754284537330e-02 3.209911282656243e-02 65 10 210 + 59 5.053754284537330e-02 9.231465757232735e-02 3.211074854508376e-02 65 5 105 + 60 9.231465757232735e-02 5.565747854079012e-02 3.214562655113861e-02 65 5 105 + 61 5.565747854079013e-02 5.565747854079013e-02 3.214596101962355e-02 65 5 105 ---------------------------------------------------------------------------------------- Final solver statistics: - Total number of time steps = 146 - Total nonlinear iterations = 980 - Total linear iterations = 17015 + Total number of time steps = 61 + Total nonlinear iterations = 379 + Total linear iterations = 7075 diff --git a/examples/arkode/C_serial/ark_robertson.out b/examples/arkode/C_serial/ark_robertson.out index 1aea595ee5..a8cf61e4e0 100644 --- a/examples/arkode/C_serial/ark_robertson.out +++ b/examples/arkode/C_serial/ark_robertson.out @@ -4,127 +4,127 @@ Robertson ODE test problem: t u v w -------------------------------------------------- 0.000e+00 1.00000e+00 0.00000e+00 0.00000e+00 - 1.000e+09 2.08324e-06 8.34276e-12 9.99998e-01 - 2.000e+09 1.04164e-06 4.17283e-12 9.99999e-01 - 3.000e+09 6.94437e-07 2.78375e-12 9.99999e-01 - 4.000e+09 5.20830e-07 2.05394e-12 9.99999e-01 - 5.000e+09 4.16667e-07 1.66756e-12 1.00000e+00 - 6.000e+09 3.47220e-07 1.38545e-12 1.00000e+00 - 7.000e+09 2.97617e-07 1.17655e-12 1.00000e+00 - 8.000e+09 2.60409e-07 1.02537e-12 1.00000e+00 - 9.000e+09 2.31480e-07 9.41190e-13 1.00000e+00 - 1.000e+10 2.08335e-07 8.36764e-13 1.00000e+00 - 1.100e+10 1.89395e-07 7.64332e-13 1.00000e+00 - 1.200e+10 1.73606e-07 6.70149e-13 1.00000e+00 - 1.300e+10 1.60258e-07 6.41057e-13 1.00000e+00 - 1.400e+10 1.48808e-07 6.17193e-13 1.00000e+00 - 1.500e+10 1.38890e-07 5.48220e-13 1.00000e+00 - 1.600e+10 1.30203e-07 4.86507e-13 1.00000e+00 - 1.700e+10 1.22547e-07 4.67931e-13 1.00000e+00 - 1.800e+10 1.15742e-07 4.70245e-13 1.00000e+00 - 1.900e+10 1.09647e-07 4.55585e-13 1.00000e+00 - 2.000e+10 1.04167e-07 4.24475e-13 1.00000e+00 - 2.100e+10 9.92072e-08 3.90746e-13 1.00000e+00 - 2.200e+10 9.46966e-08 3.68978e-13 1.00000e+00 - 2.300e+10 9.05806e-08 3.58503e-13 1.00000e+00 - 2.400e+10 8.68057e-08 3.53926e-13 1.00000e+00 - 2.500e+10 8.33309e-08 3.44650e-13 1.00000e+00 - 2.600e+10 8.01259e-08 3.30901e-13 1.00000e+00 - 2.700e+10 7.71607e-08 3.13931e-13 1.00000e+00 - 2.800e+10 7.44057e-08 2.95253e-13 1.00000e+00 - 2.900e+10 7.18388e-08 2.78961e-13 1.00000e+00 - 3.000e+10 6.94438e-08 2.67061e-13 1.00000e+00 - 3.100e+10 6.72046e-08 2.60762e-13 1.00000e+00 - 3.200e+10 6.51052e-08 2.61201e-13 1.00000e+00 - 3.300e+10 6.31308e-08 2.61658e-13 1.00000e+00 - 3.400e+10 6.12720e-08 2.57843e-13 1.00000e+00 - 3.500e+10 5.95204e-08 2.50778e-13 1.00000e+00 - 3.600e+10 5.78677e-08 2.41487e-13 1.00000e+00 - 3.700e+10 5.63054e-08 2.30992e-13 1.00000e+00 - 3.800e+10 5.48254e-08 2.20317e-13 1.00000e+00 - 3.900e+10 5.34196e-08 2.10724e-13 1.00000e+00 - 4.000e+10 5.20833e-08 2.03599e-13 1.00000e+00 - 4.100e+10 5.08123e-08 1.98476e-13 1.00000e+00 - 4.200e+10 4.96023e-08 1.94720e-13 1.00000e+00 - 4.300e+10 4.84493e-08 1.91698e-13 1.00000e+00 - 4.400e+10 4.73490e-08 1.88774e-13 1.00000e+00 - 4.500e+10 4.62972e-08 1.85299e-13 1.00000e+00 - 4.600e+10 4.52907e-08 1.78904e-13 1.00000e+00 - 4.700e+10 4.43271e-08 1.74761e-13 1.00000e+00 - 4.800e+10 4.34036e-08 1.75489e-13 1.00000e+00 - 4.900e+10 4.25178e-08 1.67760e-13 1.00000e+00 - 5.000e+10 4.16674e-08 1.68504e-13 1.00000e+00 - 5.100e+10 4.08503e-08 1.72673e-13 1.00000e+00 - 5.200e+10 4.00645e-08 1.71906e-13 1.00000e+00 - 5.300e+10 3.93085e-08 1.67608e-13 1.00000e+00 - 5.400e+10 3.85807e-08 1.61181e-13 1.00000e+00 - 5.500e+10 3.78794e-08 1.54027e-13 1.00000e+00 - 5.600e+10 3.72030e-08 1.47521e-13 1.00000e+00 - 5.700e+10 3.65500e-08 1.42263e-13 1.00000e+00 - 5.800e+10 3.59194e-08 1.38124e-13 1.00000e+00 - 5.900e+10 3.53102e-08 1.34960e-13 1.00000e+00 - 6.000e+10 3.47215e-08 1.32628e-13 1.00000e+00 - 6.100e+10 3.41523e-08 1.30983e-13 1.00000e+00 - 6.200e+10 3.36017e-08 1.29882e-13 1.00000e+00 - 6.300e+10 3.30688e-08 1.29180e-13 1.00000e+00 - 6.400e+10 3.25525e-08 1.28734e-13 1.00000e+00 - 6.500e+10 3.20519e-08 1.28399e-13 1.00000e+00 - 6.600e+10 3.15661e-08 1.28511e-13 1.00000e+00 - 6.700e+10 3.10945e-08 1.29667e-13 1.00000e+00 - 6.800e+10 3.06366e-08 1.31575e-13 1.00000e+00 - 6.900e+10 3.01919e-08 1.33923e-13 1.00000e+00 - 7.000e+10 2.97600e-08 1.36404e-13 1.00000e+00 - 7.100e+10 2.93405e-08 1.38706e-13 1.00000e+00 - 7.200e+10 2.89328e-08 1.40520e-13 1.00000e+00 - 7.300e+10 2.85365e-08 1.41536e-13 1.00000e+00 - 7.400e+10 2.81511e-08 1.41445e-13 1.00000e+00 - 7.500e+10 2.77762e-08 1.39937e-13 1.00000e+00 - 7.600e+10 2.74113e-08 1.36702e-13 1.00000e+00 - 7.700e+10 2.70559e-08 1.31431e-13 1.00000e+00 - 7.800e+10 2.67096e-08 1.23813e-13 1.00000e+00 - 7.900e+10 2.63719e-08 1.13538e-13 1.00000e+00 - 8.000e+10 2.60423e-08 1.00933e-13 1.00000e+00 - 8.100e+10 2.57208e-08 9.31863e-14 1.00000e+00 - 8.200e+10 2.54071e-08 9.21249e-14 1.00000e+00 - 8.300e+10 2.51010e-08 9.73996e-14 1.00000e+00 - 8.400e+10 2.48022e-08 1.03740e-13 1.00000e+00 - 8.500e+10 2.45104e-08 1.01400e-13 1.00000e+00 - 8.600e+10 2.42254e-08 9.65651e-14 1.00000e+00 - 8.700e+10 2.39469e-08 9.61320e-14 1.00000e+00 - 8.800e+10 2.36747e-08 9.68559e-14 1.00000e+00 - 8.900e+10 2.34087e-08 9.44562e-14 1.00000e+00 - 9.000e+10 2.31485e-08 9.00151e-14 1.00000e+00 - 9.100e+10 2.28941e-08 8.46151e-14 1.00000e+00 - 9.200e+10 2.26453e-08 7.93387e-14 1.00000e+00 - 9.300e+10 2.24018e-08 7.52684e-14 1.00000e+00 - 9.400e+10 2.21635e-08 7.34866e-14 1.00000e+00 - 9.500e+10 2.19303e-08 7.50757e-14 1.00000e+00 - 9.600e+10 2.17019e-08 8.11182e-14 1.00000e+00 - 9.700e+10 2.14781e-08 9.01508e-14 1.00000e+00 - 9.800e+10 2.12589e-08 9.22475e-14 1.00000e+00 - 9.900e+10 2.10442e-08 8.92813e-14 1.00000e+00 - 1.000e+11 2.08338e-08 8.47365e-14 1.00000e+00 + 1.000e+09 2.08321e-06 8.33667e-12 9.99998e-01 + 2.000e+09 1.04162e-06 4.16453e-12 9.99999e-01 + 3.000e+09 6.94406e-07 2.77720e-12 9.99999e-01 + 4.000e+09 5.20817e-07 2.08399e-12 9.99999e-01 + 5.000e+09 4.16680e-07 1.66642e-12 1.00000e+00 + 6.000e+09 3.47177e-07 1.38864e-12 1.00000e+00 + 7.000e+09 2.97605e-07 1.19072e-12 1.00000e+00 + 8.000e+09 2.60423e-07 1.04190e-12 1.00000e+00 + 9.000e+09 2.31438e-07 9.25974e-13 1.00000e+00 + 1.000e+10 2.08343e-07 8.33415e-13 1.00000e+00 + 1.100e+10 1.89385e-07 7.55199e-13 1.00000e+00 + 1.200e+10 1.73617e-07 6.92712e-13 1.00000e+00 + 1.300e+10 1.60245e-07 6.43428e-13 1.00000e+00 + 1.400e+10 1.48780e-07 5.96881e-13 1.00000e+00 + 1.500e+10 1.38881e-07 5.55622e-13 1.00000e+00 + 1.600e+10 1.30214e-07 5.22474e-13 1.00000e+00 + 1.700e+10 1.22545e-07 4.93677e-13 1.00000e+00 + 1.800e+10 1.15737e-07 4.66452e-13 1.00000e+00 + 1.900e+10 1.09654e-07 4.39837e-13 1.00000e+00 + 2.000e+10 1.04169e-07 4.15118e-13 1.00000e+00 + 2.100e+10 9.92064e-08 3.95317e-13 1.00000e+00 + 2.200e+10 9.46997e-08 3.78188e-13 1.00000e+00 + 2.300e+10 9.05833e-08 3.61484e-13 1.00000e+00 + 2.400e+10 8.68025e-08 3.45920e-13 1.00000e+00 + 2.500e+10 8.33246e-08 3.31980e-13 1.00000e+00 + 2.600e+10 8.01195e-08 3.19495e-13 1.00000e+00 + 2.700e+10 7.71571e-08 3.08298e-13 1.00000e+00 + 2.800e+10 7.44073e-08 2.98224e-13 1.00000e+00 + 2.900e+10 7.18418e-08 2.89018e-13 1.00000e+00 + 3.000e+10 6.94445e-08 2.80138e-13 1.00000e+00 + 3.100e+10 6.72027e-08 2.71406e-13 1.00000e+00 + 3.200e+10 6.51031e-08 2.62694e-13 1.00000e+00 + 3.300e+10 6.31324e-08 2.53876e-13 1.00000e+00 + 3.400e+10 6.12773e-08 2.44825e-13 1.00000e+00 + 3.500e+10 5.95260e-08 2.35976e-13 1.00000e+00 + 3.600e+10 5.78714e-08 2.28309e-13 1.00000e+00 + 3.700e+10 5.63067e-08 2.21774e-13 1.00000e+00 + 3.800e+10 5.48253e-08 2.16293e-13 1.00000e+00 + 3.900e+10 5.34205e-08 2.11789e-13 1.00000e+00 + 4.000e+10 5.20854e-08 2.08184e-13 1.00000e+00 + 4.100e+10 5.08117e-08 2.04858e-13 1.00000e+00 + 4.200e+10 4.95944e-08 2.01401e-13 1.00000e+00 + 4.300e+10 4.84312e-08 1.97832e-13 1.00000e+00 + 4.400e+10 4.73198e-08 1.94171e-13 1.00000e+00 + 4.500e+10 4.62580e-08 1.90439e-13 1.00000e+00 + 4.600e+10 4.52434e-08 1.86656e-13 1.00000e+00 + 4.700e+10 4.42739e-08 1.82842e-13 1.00000e+00 + 4.800e+10 4.33470e-08 1.79017e-13 1.00000e+00 + 4.900e+10 4.24605e-08 1.75200e-13 1.00000e+00 + 5.000e+10 4.16122e-08 1.71413e-13 1.00000e+00 + 5.100e+10 4.07997e-08 1.67675e-13 1.00000e+00 + 5.200e+10 4.00208e-08 1.64006e-13 1.00000e+00 + 5.300e+10 3.92731e-08 1.60426e-13 1.00000e+00 + 5.400e+10 3.85545e-08 1.56956e-13 1.00000e+00 + 5.500e+10 3.78625e-08 1.53615e-13 1.00000e+00 + 5.600e+10 3.71950e-08 1.50424e-13 1.00000e+00 + 5.700e+10 3.65496e-08 1.47402e-13 1.00000e+00 + 5.800e+10 3.59240e-08 1.44570e-13 1.00000e+00 + 5.900e+10 3.53162e-08 1.41943e-13 1.00000e+00 + 6.000e+10 3.47270e-08 1.39442e-13 1.00000e+00 + 6.100e+10 3.41566e-08 1.37029e-13 1.00000e+00 + 6.200e+10 3.36045e-08 1.34703e-13 1.00000e+00 + 6.300e+10 3.30700e-08 1.32462e-13 1.00000e+00 + 6.400e+10 3.25524e-08 1.30304e-13 1.00000e+00 + 6.500e+10 3.20509e-08 1.28227e-13 1.00000e+00 + 6.600e+10 3.15650e-08 1.26229e-13 1.00000e+00 + 6.700e+10 3.10940e-08 1.24308e-13 1.00000e+00 + 6.800e+10 3.06372e-08 1.22462e-13 1.00000e+00 + 6.900e+10 3.01939e-08 1.20690e-13 1.00000e+00 + 7.000e+10 2.97635e-08 1.18989e-13 1.00000e+00 + 7.100e+10 2.93453e-08 1.17357e-13 1.00000e+00 + 7.200e+10 2.89386e-08 1.15793e-13 1.00000e+00 + 7.300e+10 2.85427e-08 1.14295e-13 1.00000e+00 + 7.400e+10 2.81571e-08 1.12855e-13 1.00000e+00 + 7.500e+10 2.77811e-08 1.11402e-13 1.00000e+00 + 7.600e+10 2.74144e-08 1.09919e-13 1.00000e+00 + 7.700e+10 2.70570e-08 1.08412e-13 1.00000e+00 + 7.800e+10 2.67084e-08 1.06890e-13 1.00000e+00 + 7.900e+10 2.63686e-08 1.05358e-13 1.00000e+00 + 8.000e+10 2.60372e-08 1.03824e-13 1.00000e+00 + 8.100e+10 2.57141e-08 1.02294e-13 1.00000e+00 + 8.200e+10 2.53989e-08 1.00775e-13 1.00000e+00 + 8.300e+10 2.50916e-08 9.92752e-14 1.00000e+00 + 8.400e+10 2.47918e-08 9.78002e-14 1.00000e+00 + 8.500e+10 2.44993e-08 9.63573e-14 1.00000e+00 + 8.600e+10 2.42140e-08 9.49534e-14 1.00000e+00 + 8.700e+10 2.39355e-08 9.35955e-14 1.00000e+00 + 8.800e+10 2.36637e-08 9.22903e-14 1.00000e+00 + 8.900e+10 2.33982e-08 9.10449e-14 1.00000e+00 + 9.000e+10 2.31390e-08 8.98661e-14 1.00000e+00 + 9.100e+10 2.28857e-08 8.87609e-14 1.00000e+00 + 9.200e+10 2.26381e-08 8.77361e-14 1.00000e+00 + 9.300e+10 2.23961e-08 8.67987e-14 1.00000e+00 + 9.400e+10 2.21593e-08 8.59556e-14 1.00000e+00 + 9.500e+10 2.19276e-08 8.52136e-14 1.00000e+00 + 9.600e+10 2.17006e-08 8.45798e-14 1.00000e+00 + 9.700e+10 2.14783e-08 8.40609e-14 1.00000e+00 + 9.800e+10 2.12603e-08 8.36640e-14 1.00000e+00 + 9.900e+10 2.10465e-08 8.33959e-14 1.00000e+00 + 1.000e+11 2.08365e-08 8.32635e-14 1.00000e+00 -------------------------------------------------- Final Statistics: -Current time = 100509725868.0247 -Steps = 990 -Step attempts = 1170 +Current time = 100626656927.766 +Steps = 137 +Step attempts = 137 Stability limited steps = 0 -Accuracy limited steps = 1167 -Error test fails = 177 -NLS step fails = 3 +Accuracy limited steps = 137 +Error test fails = 0 +NLS step fails = 0 Inequality constraint fails = 0 Initial step size = 1e-08 -Last step size = 4072648616.470474 -Current step size = 4072648616.470474 +Last step size = 26945807385.61486 +Current step size = 26945807385.61486 Explicit RHS fn evals = 0 -Implicit RHS fn evals = 33161 -NLS iters = 27313 -NLS fails = 46 -NLS iters per step = 27.58888888888889 -LS setups = 517 -Jac fn evals = 56 +Implicit RHS fn evals = 5028 +NLS iters = 4205 +NLS fails = 36 +NLS iters per step = 30.69343065693431 +LS setups = 104 +Jac fn evals = 37 LS RHS fn evals = 0 Prec setup evals = 0 Prec solves = 0 @@ -133,5 +133,5 @@ LS fails = 0 Jac-times setups = 0 Jac-times evals = 0 LS iters per NLS iter = 0 -Jac evals per NLS iter = 0.002050305715227181 +Jac evals per NLS iter = 0.008799048751486327 Prec evals per NLS iter = 0 diff --git a/examples/arkode/C_serial/ark_robertson_constraints.out b/examples/arkode/C_serial/ark_robertson_constraints.out index e28ffe18c9..d3236cd0de 100644 --- a/examples/arkode/C_serial/ark_robertson_constraints.out +++ b/examples/arkode/C_serial/ark_robertson_constraints.out @@ -4,116 +4,116 @@ Robertson ODE test problem: t u v w -------------------------------------------------- 0.000e+00 1.00000e+00 0.00000e+00 0.00000e+00 - 1.000e+09 2.07857e-06 -1.09385e-10 9.99998e-01 - 2.000e+09 1.04202e-06 4.21741e-12 9.99999e-01 - 3.000e+09 6.94597e-07 2.66732e-12 9.99999e-01 - 4.000e+09 5.20918e-07 2.08504e-12 9.99999e-01 - 5.000e+09 4.16721e-07 1.50113e-12 1.00000e+00 - 6.000e+09 3.47261e-07 3.09313e-12 1.00000e+00 - 7.000e+09 2.97649e-07 1.12013e-12 1.00000e+00 - 8.000e+09 2.60438e-07 1.30410e-12 1.00000e+00 - 9.000e+09 2.31501e-07 6.01213e-15 1.00000e+00 - 1.000e+10 2.08348e-07 8.07940e-13 1.00000e+00 - 1.100e+10 1.89407e-07 5.27220e-13 1.00000e+00 - 1.200e+10 1.73622e-07 5.67013e-13 1.00000e+00 - 1.300e+10 1.60265e-07 6.62046e-13 1.00000e+00 - 1.400e+10 1.48820e-07 -1.96317e-12 1.00000e+00 - 1.500e+10 1.38895e-07 1.17103e-12 1.00000e+00 - 1.600e+10 1.30214e-07 3.98260e-13 1.00000e+00 - 1.700e+10 1.22554e-07 6.36369e-13 1.00000e+00 - 1.800e+10 1.15747e-07 -6.66047e-13 1.00000e+00 - 1.900e+10 1.09653e-07 4.39347e-13 1.00000e+00 - 2.000e+10 1.04171e-07 3.61443e-13 1.00000e+00 - 2.100e+10 9.92098e-08 5.00251e-13 1.00000e+00 - 2.200e+10 9.47001e-08 4.91884e-13 1.00000e+00 - 2.300e+10 9.05822e-08 8.71476e-13 1.00000e+00 - 2.400e+10 8.68083e-08 3.63347e-13 1.00000e+00 - 2.500e+10 8.33363e-08 -4.58969e-15 1.00000e+00 - 2.600e+10 8.01306e-08 3.78826e-13 1.00000e+00 - 2.700e+10 7.71624e-08 6.09154e-13 1.00000e+00 - 2.800e+10 7.44070e-08 2.04226e-13 1.00000e+00 - 2.900e+10 7.18410e-08 3.71843e-13 1.00000e+00 - 3.000e+10 6.94465e-08 4.86116e-14 1.00000e+00 - 3.100e+10 6.72060e-08 2.63403e-13 1.00000e+00 - 3.200e+10 6.51057e-08 3.32928e-13 1.00000e+00 - 3.300e+10 6.31329e-08 2.79447e-13 1.00000e+00 - 3.400e+10 6.12760e-08 2.69539e-13 1.00000e+00 - 3.500e+10 5.95252e-08 2.37903e-13 1.00000e+00 - 3.600e+10 5.78717e-08 2.27549e-13 1.00000e+00 - 3.700e+10 5.63075e-08 2.16412e-13 1.00000e+00 - 3.800e+10 5.48258e-08 2.20845e-13 1.00000e+00 - 3.900e+10 5.34200e-08 1.80732e-13 1.00000e+00 - 4.000e+10 5.20844e-08 2.07741e-13 1.00000e+00 - 4.100e+10 5.08141e-08 2.02952e-13 1.00000e+00 - 4.200e+10 4.96042e-08 1.74303e-13 1.00000e+00 - 4.300e+10 4.84505e-08 2.18218e-13 1.00000e+00 - 4.400e+10 4.73494e-08 1.66929e-13 1.00000e+00 - 4.500e+10 4.62972e-08 1.38049e-13 1.00000e+00 - 4.600e+10 4.52908e-08 1.08118e-13 1.00000e+00 - 4.700e+10 4.43271e-08 1.76051e-13 1.00000e+00 - 4.800e+10 4.34036e-08 1.70607e-13 1.00000e+00 - 4.900e+10 4.25178e-08 1.81842e-13 1.00000e+00 - 5.000e+10 4.16676e-08 -1.13757e-14 1.00000e+00 - 5.100e+10 4.08507e-08 -2.05065e-13 1.00000e+00 - 5.200e+10 4.00651e-08 -1.78624e-13 1.00000e+00 - 5.300e+10 3.93089e-08 1.41307e-13 1.00000e+00 - 5.400e+10 3.85809e-08 1.37592e-13 1.00000e+00 - 5.500e+10 3.78794e-08 1.22696e-13 1.00000e+00 - 5.600e+10 3.72032e-08 -1.10452e-13 1.00000e+00 - 5.700e+10 3.65501e-08 3.36533e-13 1.00000e+00 - 5.800e+10 3.59205e-08 -2.61161e-13 1.00000e+00 - 5.900e+10 3.53190e-08 -7.59722e-12 1.00000e+00 - 6.000e+10 3.47227e-08 1.85374e-13 1.00000e+00 - 6.100e+10 3.41536e-08 9.39629e-14 1.00000e+00 - 6.200e+10 3.36021e-08 7.25389e-13 1.00000e+00 - 6.300e+10 3.30696e-08 -1.63630e-13 1.00000e+00 - 6.400e+10 3.25554e-08 -2.65856e-12 1.00000e+00 - 6.500e+10 3.20517e-08 1.30711e-13 1.00000e+00 - 6.600e+10 3.15661e-08 1.26194e-13 1.00000e+00 - 6.700e+10 3.10950e-08 1.40543e-13 1.00000e+00 - 6.800e+10 3.06377e-08 1.09899e-13 1.00000e+00 - 6.900e+10 3.01937e-08 1.22297e-13 1.00000e+00 - 7.000e+10 2.97623e-08 1.43754e-13 1.00000e+00 - 7.100e+10 2.93432e-08 9.00254e-14 1.00000e+00 - 7.200e+10 2.89356e-08 1.09983e-13 1.00000e+00 - 7.300e+10 2.85392e-08 1.07976e-13 1.00000e+00 - 7.400e+10 2.81535e-08 1.10593e-13 1.00000e+00 - 7.500e+10 2.77782e-08 1.05388e-13 1.00000e+00 - 7.600e+10 2.74134e-08 -6.45069e-13 1.00000e+00 - 7.700e+10 2.70583e-08 -1.58650e-12 1.00000e+00 - 7.800e+10 2.67111e-08 -1.22796e-12 1.00000e+00 - 7.900e+10 2.63717e-08 8.74686e-14 1.00000e+00 - 8.000e+10 2.60420e-08 9.65943e-14 1.00000e+00 - 8.100e+10 2.57204e-08 1.41528e-13 1.00000e+00 - 8.200e+10 2.54068e-08 1.61138e-13 1.00000e+00 - 8.300e+10 2.51008e-08 -4.32908e-15 1.00000e+00 - 8.400e+10 2.48019e-08 6.26448e-14 1.00000e+00 - 8.500e+10 2.45101e-08 1.00567e-13 1.00000e+00 - 8.600e+10 2.42251e-08 9.76438e-14 1.00000e+00 - 8.700e+10 2.39466e-08 1.01689e-13 1.00000e+00 - 8.800e+10 2.36745e-08 1.26632e-13 1.00000e+00 - 8.900e+10 2.34085e-08 1.35620e-13 1.00000e+00 - 9.000e+10 2.31484e-08 8.73805e-14 1.00000e+00 - 9.100e+10 2.28938e-08 3.36553e-13 1.00000e+00 - 9.200e+10 2.26446e-08 7.21253e-13 1.00000e+00 - 9.300e+10 2.24013e-08 5.28310e-13 1.00000e+00 - 9.400e+10 2.21668e-08 -3.34767e-12 1.00000e+00 - 9.500e+10 2.19300e-08 1.72230e-13 1.00000e+00 - 9.600e+10 2.17016e-08 7.81589e-14 1.00000e+00 - 9.700e+10 2.14779e-08 1.07435e-13 1.00000e+00 - 9.800e+10 2.12602e-08 -1.41747e-12 1.00000e+00 - 9.900e+10 2.10435e-08 6.16285e-13 1.00000e+00 - 1.000e+11 2.08336e-08 8.08491e-14 1.00000e+00 + 1.000e+09 2.08360e-06 8.47670e-12 9.99998e-01 + 2.000e+09 1.04182e-06 3.93345e-12 9.99999e-01 + 3.000e+09 6.94558e-07 1.63873e-12 9.99999e-01 + 4.000e+09 5.20985e-07 2.04334e-12 9.99999e-01 + 5.000e+09 4.16764e-07 1.64639e-12 1.00000e+00 + 6.000e+09 3.47288e-07 1.37974e-12 1.00000e+00 + 7.000e+09 2.97664e-07 1.19319e-12 1.00000e+00 + 8.000e+09 2.60382e-07 1.17738e-12 1.00000e+00 + 9.000e+09 2.31517e-07 6.14818e-13 1.00000e+00 + 1.000e+10 2.08381e-07 8.77129e-13 1.00000e+00 + 1.100e+10 1.89437e-07 8.39256e-13 1.00000e+00 + 1.200e+10 1.73650e-07 7.11991e-13 1.00000e+00 + 1.300e+10 1.60290e-07 3.73565e-13 1.00000e+00 + 1.400e+10 1.48840e-07 6.18702e-13 1.00000e+00 + 1.500e+10 1.38915e-07 5.63229e-13 1.00000e+00 + 1.600e+10 1.30232e-07 5.19550e-13 1.00000e+00 + 1.700e+10 1.22569e-07 4.95002e-13 1.00000e+00 + 1.800e+10 1.15759e-07 4.62437e-13 1.00000e+00 + 1.900e+10 1.09665e-07 4.34797e-13 1.00000e+00 + 2.000e+10 1.04182e-07 3.68413e-13 1.00000e+00 + 2.100e+10 9.92180e-08 3.70142e-13 1.00000e+00 + 2.200e+10 9.47079e-08 4.91156e-13 1.00000e+00 + 2.300e+10 9.05929e-08 5.59251e-13 1.00000e+00 + 2.400e+10 8.68250e-08 1.91172e-13 1.00000e+00 + 2.500e+10 8.33522e-08 9.64051e-13 1.00000e+00 + 2.600e+10 8.01529e-08 4.10912e-13 1.00000e+00 + 2.700e+10 7.71835e-08 2.72452e-13 1.00000e+00 + 2.800e+10 7.44274e-08 2.45969e-13 1.00000e+00 + 2.900e+10 7.18602e-08 3.75197e-13 1.00000e+00 + 3.000e+10 6.94657e-08 5.20569e-13 1.00000e+00 + 3.100e+10 6.72575e-08 2.31670e-13 1.00000e+00 + 3.200e+10 6.51702e-08 3.07118e-13 1.00000e+00 + 3.300e+10 6.31935e-08 2.53242e-13 1.00000e+00 + 3.400e+10 6.13331e-08 2.46639e-13 1.00000e+00 + 3.500e+10 5.95791e-08 2.37203e-13 1.00000e+00 + 3.600e+10 5.79226e-08 2.28482e-13 1.00000e+00 + 3.700e+10 5.63556e-08 2.15581e-13 1.00000e+00 + 3.800e+10 5.48713e-08 2.07814e-13 1.00000e+00 + 3.900e+10 5.34633e-08 2.17054e-13 1.00000e+00 + 4.000e+10 5.21255e-08 2.20958e-13 1.00000e+00 + 4.100e+10 5.08532e-08 2.10395e-13 1.00000e+00 + 4.200e+10 4.96415e-08 1.98510e-13 1.00000e+00 + 4.300e+10 4.84862e-08 1.93377e-13 1.00000e+00 + 4.400e+10 4.73835e-08 1.88975e-13 1.00000e+00 + 4.500e+10 4.63297e-08 1.78240e-13 1.00000e+00 + 4.600e+10 4.53219e-08 1.74665e-13 1.00000e+00 + 4.700e+10 4.43569e-08 1.53678e-13 1.00000e+00 + 4.800e+10 4.34321e-08 1.02828e-14 1.00000e+00 + 4.900e+10 4.25453e-08 -1.55309e-13 1.00000e+00 + 5.000e+10 4.16940e-08 -2.26841e-13 1.00000e+00 + 5.100e+10 4.08760e-08 -8.80595e-14 1.00000e+00 + 5.200e+10 4.01060e-08 -1.06394e-14 1.00000e+00 + 5.300e+10 3.93590e-08 2.78713e-13 1.00000e+00 + 5.400e+10 3.86293e-08 1.49897e-13 1.00000e+00 + 5.500e+10 3.79261e-08 1.34213e-13 1.00000e+00 + 5.600e+10 3.72483e-08 1.50403e-13 1.00000e+00 + 5.700e+10 3.65945e-08 -2.45133e-13 1.00000e+00 + 5.800e+10 3.59627e-08 1.67296e-13 1.00000e+00 + 5.900e+10 3.53524e-08 2.41675e-13 1.00000e+00 + 6.000e+10 3.47637e-08 2.78239e-13 1.00000e+00 + 6.100e+10 3.41936e-08 -1.90130e-13 1.00000e+00 + 6.200e+10 3.36415e-08 1.44917e-13 1.00000e+00 + 6.300e+10 3.31064e-08 6.20049e-13 1.00000e+00 + 6.400e+10 3.25923e-08 1.29568e-13 1.00000e+00 + 6.500e+10 3.20903e-08 1.25254e-13 1.00000e+00 + 6.600e+10 3.16046e-08 2.64538e-13 1.00000e+00 + 6.700e+10 3.11335e-08 1.97313e-13 1.00000e+00 + 6.800e+10 3.06769e-08 1.68695e-13 1.00000e+00 + 6.900e+10 3.02603e-08 4.59038e-13 1.00000e+00 + 7.000e+10 2.98342e-08 1.98973e-13 1.00000e+00 + 7.100e+10 2.94263e-08 3.75733e-13 1.00000e+00 + 7.200e+10 2.90328e-08 -1.99865e-13 1.00000e+00 + 7.300e+10 2.87057e-08 6.33011e-14 1.00000e+00 + 7.400e+10 2.83205e-08 4.33328e-14 1.00000e+00 + 7.500e+10 2.79417e-08 3.13244e-13 1.00000e+00 + 7.600e+10 2.75761e-08 4.74471e-14 1.00000e+00 + 7.700e+10 2.72168e-08 1.21935e-13 1.00000e+00 + 7.800e+10 2.68658e-08 1.02194e-13 1.00000e+00 + 7.900e+10 2.65235e-08 3.52040e-13 1.00000e+00 + 8.000e+10 2.61900e-08 4.45797e-13 1.00000e+00 + 8.100e+10 2.58678e-08 1.53123e-13 1.00000e+00 + 8.200e+10 2.55509e-08 1.06836e-13 1.00000e+00 + 8.300e+10 2.52414e-08 1.00056e-13 1.00000e+00 + 8.400e+10 2.49393e-08 6.40829e-14 1.00000e+00 + 8.500e+10 2.46448e-08 5.91753e-14 1.00000e+00 + 8.600e+10 2.43577e-08 9.74215e-14 1.00000e+00 + 8.700e+10 2.40763e-08 4.53474e-14 1.00000e+00 + 8.800e+10 2.38031e-08 1.15407e-13 1.00000e+00 + 8.900e+10 2.35343e-08 9.62819e-14 1.00000e+00 + 9.000e+10 2.32714e-08 9.36091e-14 1.00000e+00 + 9.100e+10 2.30143e-08 9.61068e-14 1.00000e+00 + 9.200e+10 2.27629e-08 9.32373e-14 1.00000e+00 + 9.300e+10 2.25168e-08 9.38530e-14 1.00000e+00 + 9.400e+10 2.22761e-08 9.16947e-14 1.00000e+00 + 9.500e+10 2.20404e-08 9.26781e-14 1.00000e+00 + 9.600e+10 2.18097e-08 5.98257e-14 1.00000e+00 + 9.700e+10 2.15841e-08 1.91455e-13 1.00000e+00 + 9.800e+10 2.13662e-08 9.79879e-14 1.00000e+00 + 9.900e+10 2.11493e-08 8.49599e-14 1.00000e+00 + 1.000e+11 2.09368e-08 8.40558e-14 1.00000e+00 -------------------------------------------------- Final Solver Statistics: - Internal solver steps = 372 (attempted = 563) - Total RHS evals: Fe = 0, Fi = 14565 - Total linear solver setups = 581 + Internal solver steps = 278 (attempted = 448) + Total RHS evals: Fe = 0, Fi = 11591 + Total linear solver setups = 476 Total RHS evals for setting up the linear system = 0 - Total number of Jacobian evaluations = 391 - Total number of Newton iterations = 12497 - Total number of nonlinear solver convergence failures = 376 - Total number of error test failures = 1 - Total number of constraint test failures = 14 - Total number of failed steps from solver failure = 176 + Total number of Jacobian evaluations = 327 + Total number of Newton iterations = 9539 + Total number of nonlinear solver convergence failures = 306 + Total number of error test failures = 0 + Total number of constraint test failures = 20 + Total number of failed steps from solver failure = 150 diff --git a/examples/arkode/C_serial/ark_robertson_root.out b/examples/arkode/C_serial/ark_robertson_root.out index 236a53d64b..35f71bff5b 100644 --- a/examples/arkode/C_serial/ark_robertson_root.out +++ b/examples/arkode/C_serial/ark_robertson_root.out @@ -4,30 +4,30 @@ Robertson ODE test problem (with rootfinding): t u v w ----------------------------------------------------- 0.00000e+00 1.00000e+00 0.00000e+00 0.00000e+00 - 2.64019e-01 9.89965e-01 3.47058e-05 1.00000e-02 + 2.64019e-01 9.89965e-01 3.47057e-05 1.00000e-02 rootsfound[] = 0 1 - 4.00000e+00 9.05519e-01 2.24048e-05 9.44589e-02 - 4.00000e+01 7.15827e-01 9.18557e-06 2.84164e-01 - 4.00000e+02 4.50519e-01 3.22289e-06 5.49478e-01 - 4.00000e+03 1.83202e-01 8.94239e-07 8.16797e-01 - 4.00000e+04 3.89834e-02 1.62177e-07 9.61016e-01 - 4.00000e+05 4.93828e-03 1.98499e-08 9.95062e-01 - 4.00000e+06 5.16810e-04 2.06836e-09 9.99483e-01 - 2.07955e+07 1.00000e-04 4.00913e-10 9.99900e-01 + 4.00000e+00 9.05519e-01 2.24054e-05 9.44589e-02 + 4.00000e+01 7.15825e-01 9.18460e-06 2.84166e-01 + 4.00000e+02 4.50519e-01 3.22263e-06 5.49478e-01 + 4.00000e+03 1.83190e-01 8.93929e-07 8.16809e-01 + 4.00000e+04 3.89822e-02 1.62146e-07 9.61018e-01 + 4.00000e+05 4.93826e-03 1.98454e-08 9.95062e-01 + 4.00000e+06 5.16815e-04 2.06949e-09 9.99483e-01 + 2.07944e+07 1.00000e-04 3.99522e-10 9.99900e-01 rootsfound[] = -1 0 - 4.00000e+08 5.20777e-06 2.07144e-11 9.99995e-01 - 4.00000e+09 5.20870e-07 2.07803e-12 9.99999e-01 - 4.00000e+10 5.20800e-08 4.22489e-13 1.00000e+00 + 4.00000e+08 5.20253e-06 2.06717e-11 9.99995e-01 + 4.00000e+09 5.20380e-07 1.97394e-12 9.99999e-01 + 4.00000e+10 5.20909e-08 2.49377e-13 1.00000e+00 ----------------------------------------------------- Final Solver Statistics: - Internal solver steps = 1070 (attempted = 1298) - Total RHS evals: Fe = 0, Fi = 36412 - Total linear solver setups = 590 + Internal solver steps = 141 (attempted = 157) + Total RHS evals: Fe = 0, Fi = 5257 + Total linear solver setups = 142 Total RHS evals for setting up the linear system = 0 - Total number of Jacobian evaluations = 66 - Total number of Newton iterations = 29962 - Total root-function g evals = 1104 - Total number of nonlinear solver convergence failures = 55 - Total number of error test failures = 213 - Total number of failed steps from solver failure = 15 + Total number of Jacobian evaluations = 65 + Total number of Newton iterations = 4366 + Total root-function g evals = 178 + Total number of nonlinear solver convergence failures = 64 + Total number of error test failures = 0 + Total number of failed steps from solver failure = 16 diff --git a/examples/arkode/F2003_custom/ark_analytic_complex_f2003.out b/examples/arkode/F2003_custom/ark_analytic_complex_f2003.out index 32bd53e57b..f4c8f02979 100644 --- a/examples/arkode/F2003_custom/ark_analytic_complex_f2003.out +++ b/examples/arkode/F2003_custom/ark_analytic_complex_f2003.out @@ -6,21 +6,21 @@ t real(u) imag(u) error ------------------------------------------- 0.0 2.00E+00 0.00E+00 0.0E+00 - 1.0 -1.66E+00 -1.08E+00 8.7E-05 - 2.0 8.00E-01 1.79E+00 1.7E-04 - 3.0 2.99E-01 -1.92E+00 2.5E-04 - 4.0 -1.28E+00 1.43E+00 3.3E-04 - 5.0 1.84E+00 -5.00E-01 4.1E-04 - 6.0 -1.79E+00 -5.74E-01 4.9E-04 - 7.0 1.18E+00 1.44E+00 5.7E-04 - 8.0 -2.04E-01 -1.83E+00 6.4E-04 - 9.0 -8.18E-01 1.63E+00 7.2E-04 - 10.0 1.56E+00 -9.17E-01 7.9E-04 + 1.0 -1.66E+00 -1.08E+00 2.6E-04 + 2.0 8.00E-01 1.79E+00 5.1E-04 + 3.0 2.99E-01 -1.92E+00 7.5E-04 + 4.0 -1.28E+00 1.43E+00 9.9E-04 + 5.0 1.84E+00 -5.00E-01 1.2E-03 + 6.0 -1.79E+00 -5.73E-01 1.4E-03 + 7.0 1.18E+00 1.44E+00 1.7E-03 + 8.0 -2.06E-01 -1.83E+00 1.9E-03 + 9.0 -8.17E-01 1.63E+00 2.1E-03 + 10.0 1.56E+00 -9.18E-01 2.3E-03 ------------------------------------------- Final Solver Statistics: - Internal solver steps = 664, (attempted = 664) - Total RHS evals = 3987 + Internal solver steps = 508, (attempted = 508) + Total RHS evals = 2543 Total number of error test failures = 0 - Error: max = 7.87E-04, rms = 4.99E-04 + Error: max = 2.31E-03, rms = 1.47E-03 diff --git a/examples/arkode/F2003_serial/ark_analytic_f2003.f90 b/examples/arkode/F2003_serial/ark_analytic_f2003.f90 index 9de6e47616..76f0d42872 100644 --- a/examples/arkode/F2003_serial/ark_analytic_f2003.f90 +++ b/examples/arkode/F2003_serial/ark_analytic_f2003.f90 @@ -92,16 +92,18 @@ program main !======= Inclusions =========== use, intrinsic :: iso_c_binding - use farkode_mod ! Fortran interface to the ARKODE - use farkode_arkstep_mod ! Fortran interface to the ARKStep time-stepper module - use fsundials_nvector_mod ! Fortran interface to the generic N_Vector - use fsundials_matrix_mod ! Fortran interface to the generic SUNMatrix - use fsundials_linearsolver_mod ! Fortran interface to the generic SUNLinearSolver - use fnvector_serial_mod ! Fortran interface to serial N_Vector - 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 ode_mod ! ODE functions + use farkode_mod ! Fortran interface to the ARKODE + use farkode_arkstep_mod ! Fortran interface to the ARKStep time-stepper module + use fsundials_nvector_mod ! Fortran interface to the generic N_Vector + use fsundials_matrix_mod ! Fortran interface to the generic SUNMatrix + use fsundials_linearsolver_mod ! Fortran interface to the generic SUNLinearSolver + use fnvector_serial_mod ! Fortran interface to serial N_Vector + 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 ========= implicit none @@ -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/examples/arkode/F2003_serial/ark_analytic_f2003.out b/examples/arkode/F2003_serial/ark_analytic_f2003.out index fa22d69806..80882b43e6 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 - Num error test failures = 4 + Total internal steps taken = 65 + Total internal steps attempts = 68 + Total rhs function calls = 1021 + Num lin solver setup calls = 24 + Num error test failures = 3 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 - Num nonlinear solver fails = 3 + Last internal step size = 7.39137E-01 + Next internal step size = 1.17032E+00 + Current internal time = 1.03456E+01 + Num nonlinear solver iters = 610 + Num nonlinear solver fails = 1 diff --git a/include/arkode/arkode.h b/include/arkode/arkode.h index 3b12589182..608d3ebc0c 100644 --- a/include/arkode/arkode.h +++ b/include/arkode/arkode.h @@ -137,6 +137,9 @@ extern "C" { #define ARK_RELAX_FUNC_FAIL -45 #define ARK_RELAX_JAC_FAIL -46 +#define ARK_CONTROLLER_ERR -47 + +#define ARK_HEURISTICS_ERR -48 #define ARK_UNRECOGNIZED_ERROR -99 diff --git a/include/arkode/arkode_arkstep.h b/include/arkode/arkode_arkstep.h index a4951bb888..032cacda3c 100644 --- a/include/arkode/arkode_arkstep.h +++ b/include/arkode/arkode_arkstep.h @@ -20,6 +20,14 @@ #include #include #include +#include +#include +#include +#include +#include +#include +#include +#include #include #include #include @@ -38,7 +46,7 @@ extern "C" { /* explicit */ static const int ARKSTEP_DEFAULT_ERK_2 = ARKODE_HEUN_EULER_2_1_2; static const int ARKSTEP_DEFAULT_ERK_3 = ARKODE_BOGACKI_SHAMPINE_4_2_3; -static const int ARKSTEP_DEFAULT_ERK_4 = ARKODE_ZONNEVELD_5_3_4; +static const int ARKSTEP_DEFAULT_ERK_4 = ARKODE_SOFRONIOU_SPALETTA_5_3_4; static const int ARKSTEP_DEFAULT_ERK_5 = ARKODE_CASH_KARP_6_4_5; static const int ARKSTEP_DEFAULT_ERK_6 = ARKODE_VERNER_8_5_6; static const int ARKSTEP_DEFAULT_ERK_8 = ARKODE_FEHLBERG_13_7_8; @@ -46,7 +54,7 @@ static const int ARKSTEP_DEFAULT_ERK_8 = ARKODE_FEHLBERG_13_7_8; /* implicit */ static const int ARKSTEP_DEFAULT_DIRK_2 = ARKODE_SDIRK_2_1_2; static const int ARKSTEP_DEFAULT_DIRK_3 = ARKODE_ARK324L2SA_DIRK_4_2_3; -static const int ARKSTEP_DEFAULT_DIRK_4 = ARKODE_SDIRK_5_3_4; +static const int ARKSTEP_DEFAULT_DIRK_4 = ARKODE_ESDIRK436L2SA_6_3_4; static const int ARKSTEP_DEFAULT_DIRK_5 = ARKODE_ARK548L2SA_DIRK_8_4_5; /* ImEx */ @@ -159,7 +167,8 @@ SUNDIALS_EXPORT int ARKStepRootInit(void *arkode_mem, int nrtfn, /* Optional input functions -- must be called AFTER ARKStepCreate */ SUNDIALS_EXPORT int ARKStepSetDefaults(void* arkode_mem); -SUNDIALS_EXPORT int ARKStepSetOptimalParams(void *arkode_mem); +SUNDIALS_DEPRECATED_EXPORT_MSG("use individual controls instead") +int ARKStepSetOptimalParams(void *arkode_mem); SUNDIALS_EXPORT int ARKStepSetOrder(void *arkode_mem, int maxord); SUNDIALS_EXPORT int ARKStepSetInterpolantType(void *arkode_mem, int itype); SUNDIALS_EXPORT int ARKStepSetInterpolantDegree(void *arkode_mem, int degree); @@ -180,33 +189,35 @@ 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 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_EXPORT int ARKStepSetMaxGrowth(void *arkode_mem, - realtype mx_growth); -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_EXPORT int ARKStepSetMaxFirstGrowth(void *arkode_mem, - realtype etamx1); -SUNDIALS_EXPORT int ARKStepSetMaxEFailGrowth(void *arkode_mem, - realtype etamxf); -SUNDIALS_EXPORT int ARKStepSetSmallNumEFails(void *arkode_mem, - int small_nef); -SUNDIALS_EXPORT int ARKStepSetMaxCFailGrowth(void *arkode_mem, - realtype etacf); +SUNDIALS_EXPORT int ARKStepSetAdaptController(void *arkode_mem, SUNAdaptController C); +SUNDIALS_EXPORT int ARKStepSetTimestepHeuristics(void *arkode_mem, SUNTimestepHeuristics H); +SUNDIALS_DEPRECATED_EXPORT_MSG("use SUNTimestepHeuristics instead") +int ARKStepSetCFLFraction(void *arkode_mem, realtype cfl_frac); +SUNDIALS_DEPRECATED_EXPORT_MSG("use SUNTimestepHeuristics instead") +int ARKStepSetSafetyFactor(void *arkode_mem, realtype safety); +SUNDIALS_DEPRECATED_EXPORT_MSG("use SUNAdaptController instead") +int ARKStepSetErrorBias(void *arkode_mem, realtype bias); +SUNDIALS_DEPRECATED_EXPORT_MSG("use SUNTimestepHeuristics instead") +int ARKStepSetMaxGrowth(void *arkode_mem, realtype mx_growth); +SUNDIALS_DEPRECATED_EXPORT_MSG("use SUNTimestepHeuristics instead") +int ARKStepSetMinReduction(void *arkode_mem, realtype eta_min); +SUNDIALS_DEPRECATED_EXPORT_MSG("use SUNTimestepHeuristics instead") +int ARKStepSetFixedStepBounds(void *arkode_mem, realtype lb, realtype ub); +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_DEPRECATED_EXPORT_MSG("use SUNTimestepHeuristics instead") +int ARKStepSetMaxFirstGrowth(void *arkode_mem, realtype etamx1); +SUNDIALS_DEPRECATED_EXPORT_MSG("use SUNTimestepHeuristics instead") +int ARKStepSetMaxEFailGrowth(void *arkode_mem, realtype etamxf); +SUNDIALS_DEPRECATED_EXPORT_MSG("use SUNTimestepHeuristics instead") +int ARKStepSetSmallNumEFails(void *arkode_mem, int small_nef); +SUNDIALS_DEPRECATED_EXPORT_MSG("use SUNTimestepHeuristics instead") +int ARKStepSetMaxCFailGrowth(void *arkode_mem, realtype etacf); SUNDIALS_EXPORT int ARKStepSetNonlinCRDown(void *arkode_mem, realtype crdown); SUNDIALS_EXPORT int ARKStepSetNonlinRDiv(void *arkode_mem, @@ -217,9 +228,9 @@ SUNDIALS_EXPORT int ARKStepSetLSetupFrequency(void *arkode_mem, int msbp); SUNDIALS_EXPORT int ARKStepSetPredictorMethod(void *arkode_mem, int method); -SUNDIALS_EXPORT int ARKStepSetStabilityFn(void *arkode_mem, - ARKExpStabFn EStab, - void *estab_data); +SUNDIALS_DEPRECATED_EXPORT_MSG("use SUNTimestepHeuristics instead") +int ARKStepSetStabilityFn(void *arkode_mem, ARKExpStabFn EStab, + void *estab_data); SUNDIALS_EXPORT int ARKStepSetMaxErrTestFails(void *arkode_mem, int maxnef); SUNDIALS_EXPORT int ARKStepSetMaxNonlinIters(void *arkode_mem, @@ -236,10 +247,10 @@ SUNDIALS_EXPORT int ARKStepSetMaxHnilWarns(void *arkode_mem, int mxhnil); SUNDIALS_EXPORT int ARKStepSetInitStep(void *arkode_mem, realtype hin); -SUNDIALS_EXPORT int ARKStepSetMinStep(void *arkode_mem, - realtype hmin); -SUNDIALS_EXPORT int ARKStepSetMaxStep(void *arkode_mem, - realtype hmax); +SUNDIALS_DEPRECATED_EXPORT_MSG("use SUNTimestepHeuristics instead") +int ARKStepSetMinStep(void *arkode_mem, realtype hmin); +SUNDIALS_DEPRECATED_EXPORT_MSG("use SUNTimestepHeuristics instead") +int ARKStepSetMaxStep(void *arkode_mem, realtype hmax); SUNDIALS_EXPORT int ARKStepSetInterpolateStopTime(void *arkode_mem, booleantype interp); SUNDIALS_EXPORT int ARKStepSetStopTime(void *arkode_mem, diff --git a/include/arkode/arkode_butcher_dirk.h b/include/arkode/arkode_butcher_dirk.h index aecaf16a82..167c21b0d6 100644 --- a/include/arkode/arkode_butcher_dirk.h +++ b/include/arkode/arkode_butcher_dirk.h @@ -76,6 +76,7 @@ typedef enum { ARKODE_ARK324L2SA_DIRK_4_2_3, ARKODE_CASH_5_2_4, ARKODE_CASH_5_3_4, + ARKODE_ESDIRK436L2SA_6_3_4, ARKODE_SDIRK_5_3_4, ARKODE_KVAERNO_5_3_4, ARKODE_ARK436L2SA_DIRK_6_3_4, @@ -86,7 +87,6 @@ typedef enum { ARKODE_ESDIRK324L2SA_4_2_3, ARKODE_ESDIRK325L2SA_5_2_3, ARKODE_ESDIRK32I5L2SA_5_2_3, - ARKODE_ESDIRK436L2SA_6_3_4, ARKODE_ESDIRK43I6L2SA_6_3_4, ARKODE_QESDIRK436L2SA_6_3_4, ARKODE_ESDIRK437L2SA_7_3_4, diff --git a/include/arkode/arkode_butcher_erk.h b/include/arkode/arkode_butcher_erk.h index 6673acb119..b72846d1a7 100644 --- a/include/arkode/arkode_butcher_erk.h +++ b/include/arkode/arkode_butcher_erk.h @@ -72,6 +72,7 @@ typedef enum { ARKODE_HEUN_EULER_2_1_2 = ARKODE_MIN_ERK_NUM, ARKODE_BOGACKI_SHAMPINE_4_2_3, ARKODE_ARK324L2SA_ERK_4_2_3, + ARKODE_SOFRONIOU_SPALETTA_5_3_4, ARKODE_ZONNEVELD_5_3_4, ARKODE_ARK436L2SA_ERK_6_3_4, ARKODE_SAYFY_ABURUB_6_3_4, diff --git a/include/arkode/arkode_erkstep.h b/include/arkode/arkode_erkstep.h index 9f5b56f072..8999d58cba 100644 --- a/include/arkode/arkode_erkstep.h +++ b/include/arkode/arkode_erkstep.h @@ -18,6 +18,14 @@ #define _ERKSTEP_H #include +#include +#include +#include +#include +#include +#include +#include +#include #include #include @@ -33,7 +41,7 @@ extern "C" { static const int ERKSTEP_DEFAULT_2 = ARKODE_HEUN_EULER_2_1_2; static const int ERKSTEP_DEFAULT_3 = ARKODE_BOGACKI_SHAMPINE_4_2_3; -static const int ERKSTEP_DEFAULT_4 = ARKODE_ZONNEVELD_5_3_4; +static const int ERKSTEP_DEFAULT_4 = ARKODE_SOFRONIOU_SPALETTA_5_3_4; static const int ERKSTEP_DEFAULT_5 = ARKODE_CASH_KARP_6_4_5; static const int ERKSTEP_DEFAULT_6 = ARKODE_VERNER_8_5_6; static const int ERKSTEP_DEFAULT_8 = ARKODE_FEHLBERG_13_7_8; @@ -111,34 +119,36 @@ 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 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_EXPORT int ERKStepSetMaxGrowth(void *arkode_mem, - realtype mx_growth); -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_EXPORT int ERKStepSetMaxFirstGrowth(void *arkode_mem, - realtype etamx1); -SUNDIALS_EXPORT int ERKStepSetMaxEFailGrowth(void *arkode_mem, - realtype etamxf); -SUNDIALS_EXPORT int ERKStepSetSmallNumEFails(void *arkode_mem, - int small_nef); -SUNDIALS_EXPORT int ERKStepSetStabilityFn(void *arkode_mem, - ARKExpStabFn EStab, - void *estab_data); +SUNDIALS_EXPORT int ERKStepSetAdaptController(void *arkode_mem, SUNAdaptController C); +SUNDIALS_EXPORT int ERKStepSetTimestepHeuristics(void *arkode_mem, SUNTimestepHeuristics H); +SUNDIALS_DEPRECATED_EXPORT_MSG("use SUNTimestepHeuristics instead") +int ERKStepSetCFLFraction(void *arkode_mem, realtype cfl_frac); +SUNDIALS_DEPRECATED_EXPORT_MSG("use SUNTimestepHeuristics instead") +int ERKStepSetSafetyFactor(void *arkode_mem, realtype safety); +SUNDIALS_DEPRECATED_EXPORT_MSG("use SUNAdaptController instead") +int ERKStepSetErrorBias(void *arkode_mem, realtype bias); +SUNDIALS_DEPRECATED_EXPORT_MSG("use SUNTimestepHeuristics instead") +int ERKStepSetMaxGrowth(void *arkode_mem, realtype mx_growth); +SUNDIALS_DEPRECATED_EXPORT_MSG("use SUNTimestepHeuristics instead") +int ERKStepSetMinReduction(void *arkode_mem, realtype eta_min); +SUNDIALS_DEPRECATED_EXPORT_MSG("use SUNTimestepHeuristics instead") +int ERKStepSetFixedStepBounds(void *arkode_mem, realtype lb, realtype ub); +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_DEPRECATED_EXPORT_MSG("use SUNTimestepHeuristics instead") +int ERKStepSetMaxFirstGrowth(void *arkode_mem, realtype etamx1); +SUNDIALS_DEPRECATED_EXPORT_MSG("use SUNTimestepHeuristics instead") +int ERKStepSetMaxEFailGrowth(void *arkode_mem, realtype etamxf); +SUNDIALS_DEPRECATED_EXPORT_MSG("use SUNTimestepHeuristics instead") +int ERKStepSetSmallNumEFails(void *arkode_mem, int small_nef); +SUNDIALS_DEPRECATED_EXPORT_MSG("use SUNTimestepHeuristics instead") +int ERKStepSetStabilityFn(void *arkode_mem, ARKExpStabFn EStab, + void *estab_data); SUNDIALS_EXPORT int ERKStepSetMaxErrTestFails(void *arkode_mem, int maxnef); SUNDIALS_EXPORT int ERKStepSetConstraints(void *arkode_mem, @@ -149,10 +159,10 @@ SUNDIALS_EXPORT int ERKStepSetMaxHnilWarns(void *arkode_mem, int mxhnil); SUNDIALS_EXPORT int ERKStepSetInitStep(void *arkode_mem, realtype hin); -SUNDIALS_EXPORT int ERKStepSetMinStep(void *arkode_mem, - realtype hmin); -SUNDIALS_EXPORT int ERKStepSetMaxStep(void *arkode_mem, - realtype hmax); +SUNDIALS_DEPRECATED_EXPORT_MSG("use SUNTimestepHeuristics instead") +int ERKStepSetMinStep(void *arkode_mem, realtype hmin); +SUNDIALS_DEPRECATED_EXPORT_MSG("use SUNTimestepHeuristics instead") +int ERKStepSetMaxStep(void *arkode_mem, realtype hmax); SUNDIALS_EXPORT int ERKStepSetInterpolateStopTime(void *arkode_mem, booleantype interp); SUNDIALS_EXPORT int ERKStepSetStopTime(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/include/sundials/sundials_timestepheuristics.h b/include/sundials/sundials_timestepheuristics.h new file mode 100644 index 0000000000..e7ff9df5d2 --- /dev/null +++ b/include/sundials/sundials_timestepheuristics.h @@ -0,0 +1,286 @@ +/* ----------------------------------------------------------------- + * 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 time step heuristics class. These objects constrain step + * sizes based on solver heuristics. + * ----------------------------------------------------------------*/ + +#ifndef _SUNDIALS_TIMESTEPHEURISTICS_H +#define _SUNDIALS_TIMESTEPHEURISTICS_H + +#include +#include +#include +#include +#include "sundials/sundials_types.h" +#include + +#ifdef __cplusplus /* wrapper to enable C++ usage */ +extern "C" { +#endif + +/* ----------------------------------------------------------------- + * SUNTimestepHeuristics types (currently, only "H" is implemented; others + * are planned): + * STD - standard heuristic stepsize constraints + * NULL - placeholder object that applies no constraints + * ----------------------------------------------------------------- */ + +typedef enum +{ + SUN_TIMESTEPHEURISTICS_STD, + SUN_TIMESTEPHEURISTICS_NULL +} SUNTimestepHeuristics_ID; + +/* ----------------------------------------------------------------- + * User-supplied function types + * ----------------------------------------------------------------- */ + +typedef int (*SUNExpStabFn)(sunrealtype *hstab, void *user_data); + +/* ----------------------------------------------------------------- + * Generic definition of SUNTimestepHeuristics + * ----------------------------------------------------------------- */ + +/* Forward reference for pointer to SUNTimestepHeuristics_Ops object */ +typedef _SUNDIALS_STRUCT_ _generic_SUNTimestepHeuristics_Ops* SUNTimestepHeuristics_Ops; + +/* Forward reference for pointer to SUNTimestepHeuristics object */ +typedef _SUNDIALS_STRUCT_ _generic_SUNTimestepHeuristics* SUNTimestepHeuristics; + +/* Structure containing function pointers to heuristics operations */ +struct _generic_SUNTimestepHeuristics_Ops +{ + SUNTimestepHeuristics_ID (*getid)(SUNTimestepHeuristics H); + int (*destroy)(SUNTimestepHeuristics H); + int (*constrainstep)(SUNTimestepHeuristics H, sunrealtype hcur, + sunrealtype hnew, sunrealtype *hconstr); + int (*etestfail)(SUNTimestepHeuristics H, sunrealtype hcur, + sunrealtype hnew, int nef, sunrealtype *hconstr); + int (*convfail)(SUNTimestepHeuristics H, sunrealtype hcur, sunrealtype *hconstr); + int (*boundreduction)(SUNTimestepHeuristics H, sunrealtype hcur, + sunrealtype hnew, sunrealtype *hconstr); + int (*boundfirststep)(SUNTimestepHeuristics H, sunrealtype h0, sunrealtype *h0constr); + int (*reset)(SUNTimestepHeuristics H); + int (*update)(SUNTimestepHeuristics H); + int (*setdefaults)(SUNTimestepHeuristics H); + int (*write)(SUNTimestepHeuristics H, FILE* fptr); + int (*setmaxstep)(SUNTimestepHeuristics H, sunrealtype hmax); + int (*setminstep)(SUNTimestepHeuristics H, sunrealtype hmin); + int (*setexpstabfn)(SUNTimestepHeuristics H, SUNExpStabFn EStab, void* estab_data); + int (*setcflfraction)(SUNTimestepHeuristics H, sunrealtype cfl_frac); + int (*setsafetyfactor)(SUNTimestepHeuristics H, sunrealtype safety); + int (*setmaxgrowth)(SUNTimestepHeuristics H, sunrealtype mx_growth); + int (*setminreduction)(SUNTimestepHeuristics H, sunrealtype eta_min); + int (*setfixedstepbounds)(SUNTimestepHeuristics H, sunrealtype lb, sunrealtype ub); + int (*setmaxfirstgrowth)(SUNTimestepHeuristics H, sunrealtype etamx1); + int (*setmaxefailgrowth)(SUNTimestepHeuristics H, sunrealtype etamxf); + int (*setsmallnumefails)(SUNTimestepHeuristics H, int small_nef); + int (*setmaxcfailgrowth)(SUNTimestepHeuristics H, sunrealtype etacf); + int (*getnumexpsteps)(SUNTimestepHeuristics H, long int* expsteps); + int (*getnumaccsteps)(SUNTimestepHeuristics H, long int* accsteps); + int (*space)(SUNTimestepHeuristics H, long int *lenrw, long int *leniw); +}; + +/* A SUNTimestepHeuristics is a structure with an implementation-dependent + 'content' field, and a pointer to a structure of + operations corresponding to that implementation. */ +struct _generic_SUNTimestepHeuristics +{ + void* content; + SUNTimestepHeuristics_Ops ops; + SUNContext sunctx; +}; + +/* ----------------------------------------------------------------- + * Functions exported by SUNTimestepHeuristics module + * ----------------------------------------------------------------- */ + +/* Function to create an empty SUNTimestepHeuristics data structure. */ +SUNDIALS_EXPORT +SUNTimestepHeuristics SUNTimestepHeuristics_NewEmpty(SUNContext sunctx); + +/* Function to report the ID of a SUNTimestepHeuristics object. */ +SUNDIALS_EXPORT +SUNTimestepHeuristics_ID SUNTimestepHeuristics_GetID(SUNTimestepHeuristics H); + +/* Function to deallocate a SUNTimestepHeuristics object. + + Any return value other than SUNTIMESTEPHEURISTICS_SUCCESS will be treated as + an unrecoverable failure. */ +SUNDIALS_EXPORT +int SUNTimestepHeuristics_Destroy(SUNTimestepHeuristics H); + +/* Main constraint-application function. This will attempt to + change the step hcur to hnew, applying any heuristic bounds + on the step size adjustments. + + Any return value other than SUNTIMESTEPHEURISTICS_SUCCESS will be treated as + an unrecoverable failure. */ +SUNDIALS_EXPORT +int SUNTimestepHeuristics_ConstrainStep(SUNTimestepHeuristics H, sunrealtype hcur, + sunrealtype hnew, sunrealtype *hconstr); + +/* Function to apply constraints following a step with unacceptable + temporal error. Here, 'hnew' has already been predicted by a + temporal error controller, and 'nef' is the integrator-provided + counter of how many temporal error test failures have occurred + on this time step. + + Any return value other than SUNTIMESTEPHEURISTICS_SUCCESS will be treated as + an unrecoverable failure. */ +SUNDIALS_EXPORT +int SUNTimestepHeuristics_ETestFail(SUNTimestepHeuristics H, sunrealtype hcur, + sunrealtype hnew, int nef, sunrealtype *hconstr); + +/* This ensures that a step size reduction is within user-prescribed + bounds. If a reduction is requested but no reduction from hcur + is possible, this returns SUNTIMESTEPHEURISTICS_CANNOT_DECREASE, otherwise + it returns SUNTIMESTEPHEURISTICS_SUCCESS. */ +SUNDIALS_EXPORT +int SUNTimestepHeuristics_BoundReduction(SUNTimestepHeuristics H, sunrealtype hcur, + sunrealtype hnew, sunrealtype *hconstr); + +/* This bounds the initial step by user-provided min/max step values. */ +SUNDIALS_EXPORT +int SUNTimestepHeuristics_BoundFirstStep(SUNTimestepHeuristics H, sunrealtype h0, + sunrealtype *h0constr); + +/* Function to apply constraints following a step with an algebraic + solver convergence failure. */ +SUNDIALS_EXPORT +int SUNTimestepHeuristics_ConvFail(SUNTimestepHeuristics H, sunrealtype hcur, + sunrealtype *hconstr); + +/* Function to reset the heuristics to its initial state: zeros + the "accuracy" and "stability" counters (if present), and resets + any stepsize growth factor bounds. */ +SUNDIALS_EXPORT +int SUNTimestepHeuristics_Reset(SUNTimestepHeuristics H); + +/* Function to notify the heuristics that a time step has + succeeded, indicating e.g. that the stepsize growh factor should + should be set to its "default" state. */ +SUNDIALS_EXPORT +int SUNTimestepHeuristics_Update(SUNTimestepHeuristics H); + +/* Function to set the heuristics parameters to their default values. */ +SUNDIALS_EXPORT +int SUNTimestepHeuristics_SetDefaults(SUNTimestepHeuristics H); + +/* Function to write all heuristics parameters to the indicated + file pointer. */ +SUNDIALS_EXPORT +int SUNTimestepHeuristics_Write(SUNTimestepHeuristics H, FILE* fptr); + +/* Function to set the maximum absolute step size allowed + (hmax <=0 implies infinite). */ +SUNDIALS_EXPORT +int SUNTimestepHeuristics_SetMaxStep(SUNTimestepHeuristics H, sunrealtype hmax); + +/* Function to set the minimum absolute step size allowed + (hmin <= 0 implies no minimum). */ +SUNDIALS_EXPORT +int SUNTimestepHeuristics_SetMinStep(SUNTimestepHeuristics H, sunrealtype hmin); + +/* Function to provide a user-supplied function for the + maximum stable step size (EStab == NULL disables). */ +SUNDIALS_EXPORT +int SUNTimestepHeuristics_SetExpStabFn(SUNTimestepHeuristics H, SUNExpStabFn EStab, + void* estab_data); + +/* Function to set a CFL safety factor that should be applied to + the outputs of EStab, above. Allowable values must be within + the open interval (0,1). A non-positive input implies a reset + to the default value. */ +SUNDIALS_EXPORT +int SUNTimestepHeuristics_SetCFLFraction(SUNTimestepHeuristics H, sunrealtype cfl_frac); + +/* Function to set a step size safety factor that should be used + to constrain the error-controller-recommended step size. */ +SUNDIALS_EXPORT +int SUNTimestepHeuristics_SetSafetyFactor(SUNTimestepHeuristics C, sunrealtype safety); + +/* Function to set maximum stepsize growth factor for general steps. + Note: the first step uses a separate maximum growth factor. + Allowable values must be >1. Any illegal value implies a reset + to the default.*/ +SUNDIALS_EXPORT +int SUNTimestepHeuristics_SetMaxGrowth(SUNTimestepHeuristics H, sunrealtype mx_growth); + +/* Function to specify the maximum stepsize growth factor for the + first internal time step. Legal values are greater than 1.0. + Illegal values imply a reset to the default value. */ +SUNDIALS_EXPORT +int SUNTimestepHeuristics_SetMaxFirstGrowth(SUNTimestepHeuristics H, sunrealtype etamx1); + +/* Function to specify the step size growth interval within which + the step size will remain unchanged. Allowable values must + enclose the value 1.0. Any illegal interval implies a reset to + the default. */ +SUNDIALS_EXPORT +int SUNTimestepHeuristics_SetFixedStepBounds(SUNTimestepHeuristics H, sunrealtype lb, + sunrealtype ub); + +/* Function to set a lower bound for the stepsize adjustment factor + following a temporal error failure. */ +SUNDIALS_EXPORT +int SUNTimestepHeuristics_SetMinReduction(SUNTimestepHeuristics H, sunrealtype eta_min); + +/* Function to set an upper bound for the stepsize adjustment factor + following a temporal error failure (once at least small_nef + failures have occurred). Legal values are in the interval (0,1]. + Illegal values imply a reset to the default value. */ +SUNDIALS_EXPORT +int SUNTimestepHeuristics_SetMaxEFailGrowth(SUNTimestepHeuristics H, sunrealtype etamxf); + +/* Function to specify the step adaptivity constant small_nef (see + MaxEFailGrowth above). Legal values are > 0. Illegal values + imply a reset to the default value. */ +SUNDIALS_EXPORT +int SUNTimestepHeuristics_SetSmallNumEFails(SUNTimestepHeuristics H, int small_nef); + +/* Function to specify an upper bound for the stepsize adjustment + factor following an algebraic solver convergence failure. Legal + values are in the interval (0,1]. Illegal values imply a reset + to the default value. */ +SUNDIALS_EXPORT +int SUNTimestepHeuristics_SetMaxCFailGrowth(SUNTimestepHeuristics H, sunrealtype etacf); + +/* Function to return the current number of stability-limited steps. */ +SUNDIALS_EXPORT +int SUNTimestepHeuristics_GetNumExpSteps(SUNTimestepHeuristics H, long int* expsteps); + +/* Function to return the current number of accuracy-limited steps. */ +SUNDIALS_EXPORT +int SUNTimestepHeuristics_GetNumAccSteps(SUNTimestepHeuristics H, long int* accsteps); + +/* Function to return the memory requirements of the heuristics object. */ +SUNDIALS_EXPORT +int SUNTimestepHeuristics_Space(SUNTimestepHeuristics H, long int *lenrw, long int *leniw); + + +/* ----------------------------------------------------------------- + * SUNTimestepHeuristics error codes + * ----------------------------------------------------------------- */ + +#define SUNTIMESTEPHEURISTICS_SUCCESS 0 /* function successfull */ +#define SUNTIMESTEPHEURISTICS_ILL_INPUT -1101 /* illegal function input */ +#define SUNTIMESTEPHEURISTICS_CANNOT_DECREASE -1102 /* no step decrease possible */ +#define SUNTIMESTEPHEURISTICS_USER_FCN_FAIL -1103 /* user-supplied fcn failure */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SUNDIALS_TIMESTEPHEURISTICS_H */ diff --git a/include/suntimestepheuristics/suntimestepheuristics_default.h b/include/suntimestepheuristics/suntimestepheuristics_default.h new file mode 100644 index 0000000000..0683077ace --- /dev/null +++ b/include/suntimestepheuristics/suntimestepheuristics_default.h @@ -0,0 +1,136 @@ +/* ----------------------------------------------------------------- + * 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 SUNTimestepHeuristics_Default + * module. + * -----------------------------------------------------------------*/ + +#ifndef _SUNTIMESTEPHEURISTICS_DEFAULT_H +#define _SUNTIMESTEPHEURISTICS_DEFAULT_H + +#include +#include + +#ifdef __cplusplus /* wrapper to enable C++ usage */ +extern "C" { +#endif + +/* ----------------------------------------------- + * Default implementation of SUNTimestepHeuristics + * ----------------------------------------------- */ + +struct _SUNTimestepHeuristicsContent_Default { + sunrealtype hmax_inv; /* inverse of maximum allowable time step */ + sunrealtype hmin; /* minimum allowable time step */ + sunrealtype etamax; /* eta <= etamax */ + sunrealtype etamx1; /* max step size change on first step */ + sunrealtype etamxf; /* h reduction factor on multiple error fails */ + sunrealtype etamin; /* eta >= etamin on error test fail */ + int small_nef; /* bound to determine 'multiple' above */ + sunrealtype etacf; /* h reduction factor on nonlinear conv fail */ + SUNExpStabFn expstab; /* step stability function */ + void* estab_data; /* user pointer passed to expstab */ + sunrealtype cfl; /* cfl safety factor */ + sunrealtype safety; /* step safety factor */ + sunrealtype growth; /* maximum step growth safety factor */ + sunrealtype lbound; /* eta lower bound to leave h unchanged */ + sunrealtype ubound; /* eta upper bound to leave h unchanged */ + long int nst_acc; /* num accuracy-limited internal steps */ + long int nst_exp; /* num stability-limited internal steps */ +}; + +typedef struct _SUNTimestepHeuristicsContent_Default *SUNTimestepHeuristicsContent_Default; + +/* ------------------ + * Exported Functions + * ------------------ */ + +SUNDIALS_EXPORT +SUNTimestepHeuristics SUNTimestepHeuristics_Default(SUNContext sunctx); +SUNDIALS_EXPORT +SUNTimestepHeuristics_ID SUNTimestepHeuristics_GetID_Default(SUNTimestepHeuristics H); +SUNDIALS_EXPORT +int SUNTimestepHeuristics_ConstrainStep_Default(SUNTimestepHeuristics H, + sunrealtype hcur, + sunrealtype hnew, sunrealtype* hconstr); +SUNDIALS_EXPORT +int SUNTimestepHeuristics_ETestFail_Default(SUNTimestepHeuristics H, sunrealtype hcur, + sunrealtype hnew, int nef, + sunrealtype* hconstr); +SUNDIALS_EXPORT +int SUNTimestepHeuristics_ConvFail_Default(SUNTimestepHeuristics H, sunrealtype hcur, + sunrealtype* hconstr); +SUNDIALS_EXPORT +int SUNTimestepHeuristics_BoundReduction_Default(SUNTimestepHeuristics H, + sunrealtype hcur, + sunrealtype hnew, sunrealtype* hconstr); +SUNDIALS_EXPORT +int SUNTimestepHeuristics_BoundFirstStep_Default(SUNTimestepHeuristics H, sunrealtype h0, + sunrealtype* h0constr); +SUNDIALS_EXPORT +int SUNTimestepHeuristics_Reset_Default(SUNTimestepHeuristics H); +SUNDIALS_EXPORT +int SUNTimestepHeuristics_Update_Default(SUNTimestepHeuristics H); +SUNDIALS_EXPORT +int SUNTimestepHeuristics_SetDefaults_Default(SUNTimestepHeuristics H); +SUNDIALS_EXPORT +int SUNTimestepHeuristics_Write_Default(SUNTimestepHeuristics H, FILE* fptr); +SUNDIALS_EXPORT +int SUNTimestepHeuristics_SetMaxStep_Default(SUNTimestepHeuristics H, sunrealtype hmax); +SUNDIALS_EXPORT +int SUNTimestepHeuristics_SetMinStep_Default(SUNTimestepHeuristics H, sunrealtype hmin); +SUNDIALS_EXPORT +int SUNTimestepHeuristics_SetExpStabFn_Default(SUNTimestepHeuristics H, + SUNExpStabFn EStab, void* estab_data); +SUNDIALS_EXPORT +int SUNTimestepHeuristics_SetCFLFraction_Default(SUNTimestepHeuristics H, + sunrealtype cfl_frac); +SUNDIALS_EXPORT +int SUNTimestepHeuristics_SetSafetyFactor_Default(SUNTimestepHeuristics H, + sunrealtype safety); +SUNDIALS_EXPORT +int SUNTimestepHeuristics_SetMaxGrowth_Default(SUNTimestepHeuristics H, + sunrealtype mx_growth); +SUNDIALS_EXPORT +int SUNTimestepHeuristics_SetMinReduction_Default(SUNTimestepHeuristics H, + sunrealtype eta_min); +SUNDIALS_EXPORT +int SUNTimestepHeuristics_SetFixedStepBounds_Default(SUNTimestepHeuristics H, + sunrealtype lb, sunrealtype ub); +SUNDIALS_EXPORT +int SUNTimestepHeuristics_SetMaxFirstGrowth_Default(SUNTimestepHeuristics H, + sunrealtype etamx1); +SUNDIALS_EXPORT +int SUNTimestepHeuristics_SetMaxEFailGrowth_Default(SUNTimestepHeuristics H, + sunrealtype etamxf); +SUNDIALS_EXPORT +int SUNTimestepHeuristics_SetSmallNumEFails_Default(SUNTimestepHeuristics H, + int small_nef); +SUNDIALS_EXPORT +int SUNTimestepHeuristics_SetMaxCFailGrowth_Default(SUNTimestepHeuristics H, + sunrealtype etacf); +SUNDIALS_EXPORT +int SUNTimestepHeuristics_GetNumExpSteps_Default(SUNTimestepHeuristics H, + long int* expsteps); +SUNDIALS_EXPORT +int SUNTimestepHeuristics_GetNumAccSteps_Default(SUNTimestepHeuristics H, + long int* accsteps); +SUNDIALS_EXPORT +int SUNTimestepHeuristics_Space_Default(SUNTimestepHeuristics H, long int *lenrw, + long int *leniw); + +#ifdef __cplusplus +} +#endif + +#endif /* _SUNTIMESTEPHEURISTICS_DEFAULT_H */ diff --git a/include/suntimestepheuristics/suntimestepheuristics_unconstrained.h b/include/suntimestepheuristics/suntimestepheuristics_unconstrained.h new file mode 100644 index 0000000000..e4584a9ad7 --- /dev/null +++ b/include/suntimestepheuristics/suntimestepheuristics_unconstrained.h @@ -0,0 +1,68 @@ +/* ----------------------------------------------------------------- + * 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 + * SUNTimestepHeuristics_Unconstrained module. + * -----------------------------------------------------------------*/ + +#ifndef _SUNTIMESTEPHEURISTICS_UNCONSTRAINED_H +#define _SUNTIMESTEPHEURISTICS_UNCONSTRAINED_H + +#include +#include + +#ifdef __cplusplus /* wrapper to enable C++ usage */ +extern "C" { +#endif + +/* ----------------------------------------------------- + * Unconstrained implementation of SUNTimestepHeuristics + * ----------------------------------------------------- */ + +struct _SUNTimestepHeuristicsContent_Unconstrained { + long int nst_acc; /* num accuracy-limited internal steps */ +}; + +typedef struct _SUNTimestepHeuristicsContent_Unconstrained *SUNTimestepHeuristicsContent_Unconstrained; + +/* ------------------ + * Exported Functions + * ------------------ */ + +SUNDIALS_EXPORT +SUNTimestepHeuristics SUNTimestepHeuristics_Unconstrained(SUNContext sunctx); +SUNDIALS_EXPORT +SUNTimestepHeuristics_ID SUNTimestepHeuristics_GetID_Unconstrained(SUNTimestepHeuristics H); +SUNDIALS_EXPORT +int SUNTimestepHeuristics_ConstrainStep_Unconstrained(SUNTimestepHeuristics H, + sunrealtype hcur, + sunrealtype hnew, + sunrealtype* hconstr); +SUNDIALS_EXPORT +int SUNTimestepHeuristics_ConvFail_Unconstrained(SUNTimestepHeuristics H, sunrealtype hcur, + sunrealtype* hconstr); +SUNDIALS_EXPORT +int SUNTimestepHeuristics_Reset_Unconstrained(SUNTimestepHeuristics H); +SUNDIALS_EXPORT +int SUNTimestepHeuristics_Write_Unconstrained(SUNTimestepHeuristics H, FILE* fptr); +int SUNTimestepHeuristics_GetNumAccSteps_Unconstrained(SUNTimestepHeuristics H, + long int* accsteps); +SUNDIALS_EXPORT +int SUNTimestepHeuristics_Space_Unconstrained(SUNTimestepHeuristics H, long int *lenrw, + long int *leniw); + +#ifdef __cplusplus +} +#endif + +#endif /* _SUNTIMESTEPHEURISTICS_UNCONSTRAINED_H */ diff --git a/scripts/arkode b/scripts/arkode index bb216f7248..a0047ddbab 100755 --- a/scripts/arkode +++ b/scripts/arkode @@ -54,8 +54,6 @@ $tar $tarfile $distrobase/src/arkode/README.md $tar $tarfile $distrobase/src/arkode/CMakeLists.txt $tar $tarfile $distrobase/src/arkode/arkode.c -$tar $tarfile $distrobase/src/arkode/arkode_adapt.c -$tar $tarfile $distrobase/src/arkode/arkode_adapt_impl.h $tar $tarfile $distrobase/src/arkode/arkode_arkstep.c $tar $tarfile $distrobase/src/arkode/arkode_arkstep_impl.h $tar $tarfile $distrobase/src/arkode/arkode_arkstep_io.c @@ -93,6 +91,9 @@ $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_stability.c +$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 2a9cef1731..f23655be91 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 @@ -153,6 +154,7 @@ $tar $tarfile $distrobase/include/sundials/sundials_nvector_senswrapper.h $tar $tarfile $distrobase/include/sundials/sundials_nvector.h $tar $tarfile $distrobase/include/sundials/sundials_profiler.h $tar $tarfile $distrobase/include/sundials/sundials_sycl_policies.hpp +$tar $tarfile $distrobase/include/sundials/sundials_timestepheuristics.h $tar $tarfile $distrobase/include/sundials/sundials_types.h $tar $tarfile $distrobase/include/sundials/sundials_version.h $tar $tarfile $distrobase/include/sundials/sundials_xbraid.h @@ -176,6 +178,16 @@ $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/suntimestepheuristics/suntimestepheuristics_default.h +$tar $tarfile $distrobase/include/suntimestepheuristics/suntimestepheuristics_unconstrained.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 +236,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 @@ -240,8 +254,11 @@ $tar $tarfile $distrobase/src/sundials/fmod/fsundials_nvector_mod.c $tar $tarfile $distrobase/src/sundials/fmod/fsundials_nvector_mod.f90 $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_timestepheuristics_mod.c +$tar $tarfile $distrobase/src/sundials/fmod/fsundials_timestepheuristics_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 @@ -269,6 +286,7 @@ $tar $tarfile $distrobase/src/sundials/sundials_nvector_senswrapper.c $tar $tarfile $distrobase/src/sundials/sundials_profiler.c $tar $tarfile $distrobase/src/sundials/sundials_reductions.hpp $tar $tarfile $distrobase/src/sundials/sundials_sycl.h +$tar $tarfile $distrobase/src/sundials/sundials_timestepheuristics.c $tar $tarfile $distrobase/src/sundials/sundials_utils.h $tar $tarfile $distrobase/src/sundials/sundials_version.c $tar $tarfile $distrobase/src/sundials/sundials_xbraid.c @@ -371,6 +389,70 @@ $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 suntimestepheuristics modules to $tarfile" + +$tar $tarfile $distrobase/src/suntimestepheuristics/CMakeLists.txt + +echo " --- Add suntimestepheuristics/default module to $tarfile" + +$tar $tarfile $distrobase/src/suntimestepheuristics/default/CMakeLists.txt +$tar $tarfile $distrobase/src/suntimestepheuristics/default/suntimestepheuristics_default.c +$tar $tarfile $distrobase/src/suntimestepheuristics/default/fmod/fsuntimestepheuristics_default_mod.c +$tar $tarfile $distrobase/src/suntimestepheuristics/default/fmod/fsuntimestepheuristics_default_mod.f90 + +echo " --- Add suntimestepheuristics/unconstrained module to $tarfile" + +$tar $tarfile $distrobase/src/suntimestepheuristics/unconstrained/CMakeLists.txt +$tar $tarfile $distrobase/src/suntimestepheuristics/unconstrained/suntimestepheuristics_unconstrained.c +$tar $tarfile $distrobase/src/suntimestepheuristics/unconstrained/fmod/fsuntimestepheuristics_default_mod.c +$tar $tarfile $distrobase/src/suntimestepheuristics/unconstrained/fmod/fsuntimestepheuristics_default_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..4576794eb3 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -22,6 +22,8 @@ add_subdirectory(sunmatrix) add_subdirectory(sunlinsol) add_subdirectory(sunnonlinsol) add_subdirectory(sunmemory) +add_subdirectory(sunadaptcontroller) +add_subdirectory(suntimestepheuristics) # ARKODE library if(BUILD_ARKODE) diff --git a/src/arkode/CMakeLists.txt b/src/arkode/CMakeLists.txt index cf0254b3e2..b0e6771346 100644 --- a/src/arkode/CMakeLists.txt +++ b/src/arkode/CMakeLists.txt @@ -18,7 +18,6 @@ install(CODE "MESSAGE(\"\nInstall ARKODE\n\")") # Add variable arkode_SOURCES with the sources for the ARKODE library set(arkode_SOURCES - arkode_adapt.c arkode_arkstep_io.c arkode_arkstep_nls.c arkode_arkstep.c @@ -41,6 +40,8 @@ set(arkode_SOURCES arkode_sprkstep_io.c arkode_sprkstep.c arkode_sprk.c + arkode_user_controller.c + arkode_user_stability.c arkode.c ) @@ -75,6 +76,14 @@ 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_suntimestepheuristicsdefault_obj + sundials_suntimestepheuristicsunconstrained_obj sundials_sunmatrixband_obj sundials_sunmatrixdense_obj sundials_sunmatrixsparse_obj diff --git a/src/arkode/arkode.c b/src/arkode/arkode.c index 43a3920a18..9590a1f3ee 100644 --- a/src/arkode/arkode.c +++ b/src/arkode/arkode.c @@ -31,6 +31,8 @@ #include #include #include +#include +#include /*=============================================================== @@ -49,6 +51,7 @@ ARKodeMem arkCreate(SUNContext sunctx) { int iret; + long int lenrw, leniw; ARKodeMem ark_mem; if (!sunctx) { @@ -123,15 +126,29 @@ ARKodeMem arkCreate(SUNContext sunctx) /* No user_data pointer yet */ ark_mem->user_data = NULL; - /* Allocate step adaptivity structure and note storage */ - ark_mem->hadapt_mem = arkAdaptInit(); - if (ark_mem->hadapt_mem == NULL) { + /* Allocate default step controller (PID) and note storage */ + ark_mem->hcontroller = SUNAdaptController_PID(sunctx); + if (ark_mem->hcontroller == NULL) { arkProcessError(NULL, ARK_MEM_FAIL, "ARKODE", "arkCreate", - "Allocation of step adaptivity structure failed"); + "Allocation of step controller object failed"); return(NULL); } - ark_mem->lrw += ARK_ADAPT_LRW; - ark_mem->liw += ARK_ADAPT_LIW; + ark_mem->owncontroller = SUNTRUE; + (void) SUNAdaptController_Space(ark_mem->hcontroller, &lenrw, &leniw); + ark_mem->lrw += lenrw; + ark_mem->liw += leniw; + + /* Allocate default heuristic structure and note storage */ + ark_mem->hconstraints = SUNTimestepHeuristics_Default(sunctx); + if (ark_mem->hconstraints == NULL) { + arkProcessError(NULL, ARK_MEM_FAIL, "ARKODE", "arkCreate", + "Allocation of step heuristics object failed"); + return(NULL); + } + ark_mem->ownconstraints = SUNTRUE; + (void) SUNTimestepHeuristics_Space(ark_mem->hconstraints, &lenrw, &leniw); + ark_mem->lrw += lenrw; + ark_mem->liw += leniw; /* Initialize the interpolation structure to NULL */ ark_mem->interp = NULL; @@ -888,13 +905,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; @@ -905,9 +915,6 @@ int arkEvolve(ARKodeMem ark_mem, realtype tout, N_Vector yout, /* break attempt loop on successful step */ if (kflag == ARK_SUCCESS) break; - /* unsuccessful step, if |h| = hmin, return ARK_ERR_FAILURE */ - if (SUNRabs(ark_mem->h) <= ark_mem->hmin*ONEPSM) return(ARK_ERR_FAILURE); - /* update h, hprime and next_h for next iteration */ ark_mem->h *= ark_mem->eta; ark_mem->next_h = ark_mem->hprime = ark_mem->h; @@ -1099,10 +1106,14 @@ void arkFree(void **arkode_mem) /* free vector storage */ arkFreeVectors(ark_mem); - /* free the time step adaptivity module */ - if (ark_mem->hadapt_mem != NULL) { - free(ark_mem->hadapt_mem); - ark_mem->hadapt_mem = NULL; + /* free the time step controller object if owned */ + if (ark_mem->owncontroller) { + (void) SUNAdaptController_Destroy(ark_mem->hcontroller); + } + + /* free the time step heuristics object if owned */ + if (ark_mem->ownconstraints) { + (void) SUNTimestepHeuristics_Destroy(ark_mem->hconstraints); } /* free the interpolation module */ @@ -1238,6 +1249,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 */ @@ -1339,15 +1351,19 @@ int arkInit(ARKodeMem ark_mem, realtype t0, N_Vector y0, /* Tolerance scale factor */ ark_mem->tolsf = ONE; - /* 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; + /* Reset error controller and heuristics objects */ + retval = SUNAdaptController_Reset(ark_mem->hcontroller); + if (retval != SUNADAPTCONTROLLER_SUCCESS) { + arkProcessError(ark_mem, ARK_CONTROLLER_ERR, "ARKODE", "arkInit", + "Unable to reset error controller object"); + return(ARK_CONTROLLER_ERR); + } + retval = SUNTimestepHeuristics_Reset(ark_mem->hconstraints); + if (retval != SUNTIMESTEPHEURISTICS_SUCCESS) { + arkProcessError(ark_mem, ARK_HEURISTICS_ERR, "ARKODE", "arkInit", + "Unable to reset step heuristics object"); + return(ARK_HEURISTICS_ERR); + } /* Indicate that evaluation of the full RHS is not required after each step, this flag is updated to SUNTRUE by the interpolation module initialization @@ -1416,17 +1432,17 @@ void arkPrintMem(ARKodeMem ark_mem, FILE *outfile) fprintf(outfile, "eta = %" RSYM"\n", ark_mem->eta); fprintf(outfile, "tcur = %" RSYM"\n", ark_mem->tcur); fprintf(outfile, "tretlast = %" RSYM"\n", ark_mem->tretlast); - fprintf(outfile, "hmin = %" RSYM"\n", ark_mem->hmin); - fprintf(outfile, "hmax_inv = %" RSYM"\n", ark_mem->hmax_inv); fprintf(outfile, "h0u = %" RSYM"\n", ark_mem->h0u); fprintf(outfile, "tn = %" RSYM"\n", ark_mem->tn); fprintf(outfile, "hold = %" RSYM"\n", ark_mem->hold); fprintf(outfile, "maxnef = %i\n", ark_mem->maxnef); fprintf(outfile, "maxncf = %i\n", ark_mem->maxncf); - /* output time-stepping adaptivity structure */ - fprintf(outfile, "timestep adaptivity structure:\n"); - arkPrintAdaptMem(ark_mem->hadapt_mem, outfile); + /* output time-stepping controller object */ + (void) SUNAdaptController_Write(ark_mem->hcontroller, outfile); + + /* output time-stepping heuristics object */ + (void) SUNTimestepHeuristics_Write(ark_mem->hconstraints, outfile); /* output inequality constraints quantities */ fprintf(outfile, "constraintsSet = %i\n", ark_mem->constraintsSet); @@ -1828,7 +1844,7 @@ void arkFreeVectors(ARKodeMem ark_mem) int arkInitialSetup(ARKodeMem ark_mem, realtype tout) { int retval, hflag, istate; - realtype tout_hin, rh, htmp; + realtype tout_hin, htmp; booleantype conOK; /* Set up the time stepper module */ @@ -1958,21 +1974,39 @@ int arkInitialSetup(ARKodeMem ark_mem, realtype tout) istate = arkHandleFailure(ark_mem, hflag); return(istate); } - /* Use first step growth factor for estimated h */ - ark_mem->hadapt_mem->etamax = ark_mem->hadapt_mem->etamx1; + /* Reset time step heuristic controller object */ + retval = SUNTimestepHeuristics_Reset(ark_mem->hconstraints); + if (retval != 0) { + arkProcessError(ark_mem, ARK_HEURISTICS_ERR, "ARKODE", "arkInitialSetup", + "Failure resetting heuristics object"); + return(ARK_HEURISTICS_ERR); + } } else if (ark_mem->nst == 0) { - /* Use first step growth factor for user defined h */ - ark_mem->hadapt_mem->etamax = ark_mem->hadapt_mem->etamx1; + /* Reset time step heuristic controller object */ + retval = SUNTimestepHeuristics_Reset(ark_mem->hconstraints); + if (retval != 0) { + arkProcessError(ark_mem, ARK_HEURISTICS_ERR, "ARKODE", "arkInitialSetup", + "Failure resetting heuristics object"); + return(ARK_HEURISTICS_ERR); + } } else { - /* Use standard growth factor (e.g., for reset) */ - ark_mem->hadapt_mem->etamax = ark_mem->hadapt_mem->growth; + /* Notify time step heuristic controller object of previous successful steps */ + retval = SUNTimestepHeuristics_Update(ark_mem->hconstraints); + if (retval != 0) { + arkProcessError(ark_mem, ARK_HEURISTICS_ERR, "ARKODE", "arkInitialSetup", + "Failure updating heuristics object"); + return(ARK_HEURISTICS_ERR); + } } /* Enforce step size bounds */ - rh = SUNRabs(ark_mem->h)*ark_mem->hmax_inv; - if (rh > ONE) ark_mem->h /= rh; - if (SUNRabs(ark_mem->h) < ark_mem->hmin) - ark_mem->h *= ark_mem->hmin/SUNRabs(ark_mem->h); + retval = SUNTimestepHeuristics_BoundFirstStep(ark_mem->hconstraints, ark_mem->h, + &(ark_mem->h)); + if (retval != SUNTIMESTEPHEURISTICS_SUCCESS) { + arkProcessError(ark_mem, ARK_HEURISTICS_ERR, "ARKODE", "arkInitialSetup", + "Error in call to SUNTimestepHeuristics_BoundFirstStep"); + return(ARK_HEURISTICS_ERR); + } /* Check for approach to tstop */ if (ark_mem->tstopset) { @@ -2388,10 +2422,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; } @@ -2435,11 +2469,21 @@ 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->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); + } + + /* Notify time step heuristics object of successful step */ + retval = SUNTimestepHeuristics_Update(ark_mem->hconstraints); + if (retval != 0) { + arkProcessError(ark_mem, ARK_HEURISTICS_ERR, "ARKODE", "arkCompleteStep", + "Failure updating heuristics object"); + return(ARK_CONTROLLER_ERR); + } /* update scalar quantities */ ark_mem->nst++; @@ -2447,9 +2491,6 @@ int arkCompleteStep(ARKodeMem ark_mem, realtype dsm) ark_mem->tn = ark_mem->tcur; ark_mem->hprime = ark_mem->h * ark_mem->eta; - /* Reset growth factor for subsequent time step */ - ark_mem->hadapt_mem->etamax = ark_mem->hadapt_mem->growth; - /* Turn off flag indicating initial step and first stage */ ark_mem->initsetup = SUNFALSE; ark_mem->firststage = SUNFALSE; @@ -2893,25 +2934,17 @@ int arkPredict_Bootstrap(ARKodeMem ark_mem, realtype hj, --------------------------------------------------------------*/ int arkCheckConvergence(ARKodeMem ark_mem, int *nflagPtr, int *ncfPtr) { - ARKodeHAdaptMem hadapt_mem; + int retval; + realtype hnew; + /* If nonlinear solver succeeded, return with ARK_SUCCESS */ if (*nflagPtr == ARK_SUCCESS) return(ARK_SUCCESS); /* The nonlinear soln. failed; increment ncfn */ ark_mem->ncfn++; - /* If fixed time stepping, then return with convergence failure */ - if (ark_mem->fixedstep) return(ARK_CONV_FAILURE); - - /* Otherwise, access adaptivity structure */ - if (ark_mem->hadapt_mem == NULL) { - arkProcessError(ark_mem, ARK_MEM_NULL, "ARKODE", "arkCheckConvergence", - MSG_ARKADAPT_NO_MEM); - return(ARK_MEM_NULL); - } - hadapt_mem = ark_mem->hadapt_mem; - - /* Return if lsetup, lsolve, or rhs failed unrecoverably */ + /* Return with an appropriate error condition if lsetup, lsolve, or + rhs failed unrecoverably */ if (*nflagPtr < 0) { if (*nflagPtr == ARK_LSETUP_FAIL) return(ARK_LSETUP_FAIL); else if (*nflagPtr == ARK_LSOLVE_FAIL) return(ARK_LSOLVE_FAIL); @@ -2919,26 +2952,31 @@ int arkCheckConvergence(ARKodeMem ark_mem, int *nflagPtr, int *ncfPtr) else return(ARK_NLS_OP_ERR); } - /* At this point, nflag = CONV_FAIL or RHSFUNC_RECVR; increment ncf */ - (*ncfPtr)++; - hadapt_mem->etamax = ONE; - - /* If we had maxncf failures, or if |h| = hmin, - return ARK_CONV_FAILURE or ARK_REPTD_RHSFUNC_ERR. */ - if ((*ncfPtr == ark_mem->maxncf) || - (SUNRabs(ark_mem->h) <= ark_mem->hmin*ONEPSM)) { + /* If we already had maxncf failures, return ARK_CONV_FAILURE or + ARK_REPTD_RHSFUNC_ERR. */ + if (*ncfPtr == ark_mem->maxncf) { if (*nflagPtr == CONV_FAIL) return(ARK_CONV_FAILURE); if (*nflagPtr == RHSFUNC_RECVR) return(ARK_REPTD_RHSFUNC_ERR); } - /* Reduce step size due to convergence failure */ - ark_mem->eta = hadapt_mem->etacf; - - /* Signal for Jacobian/preconditioner setup */ - *nflagPtr = PREV_CONV_FAIL; + /* Attempt step reduction via heuristics control */ + retval = SUNTimestepHeuristics_ConvFail(ark_mem->hconstraints, ark_mem->h, &hnew); + + /* If step reduction successful: store step 'eta', increment ncf, signal + for Jacobian/preconditioner setup, and return to reattempt the step. + Otherwise, return ARK_CONV_FAILURE or ARK_HEURISTICS_ERR, + depending on the circumstances */ + if (retval == SUNTIMESTEPHEURISTICS_SUCCESS) { + ark_mem->eta = hnew / ark_mem->h; + (*ncfPtr)++; + *nflagPtr = PREV_CONV_FAIL; + return(PREDICT_AGAIN); + } else if (retval == SUNTIMESTEPHEURISTICS_CANNOT_DECREASE) { + return(ARK_CONV_FAILURE); + } else { + return(ARK_HEURISTICS_ERR); + } - /* Return to reattempt the step */ - return(PREDICT_AGAIN); } @@ -2953,6 +2991,8 @@ int arkCheckConvergence(ARKodeMem ark_mem, int *nflagPtr, int *ncfPtr) int arkCheckConstraints(ARKodeMem ark_mem, int *constrfails, int *nflag) { booleantype constraintsPassed; + realtype hnew; + int retval; N_Vector mm = ark_mem->tempv4; N_Vector tmp = ark_mem->tempv3; @@ -2972,14 +3012,17 @@ int arkCheckConstraints(ARKodeMem ark_mem, int *constrfails, int *nflag) /* Return with error if using fixed step sizes */ if (ark_mem->fixedstep) return(ARK_CONSTR_FAIL); - /* Return with error if |h| == hmin */ - if (SUNRabs(ark_mem->h) <= ark_mem->hmin*ONEPSM) return(ARK_CONSTR_FAIL); - - /* Reduce h by computing eta = h'/h */ + /* Recommend step size adjustment to satisfy constraints */ N_VLinearSum(ONE, ark_mem->yn, -ONE, ark_mem->ycur, tmp); N_VProd(mm, tmp, tmp); - ark_mem->eta = RCONST(0.9)*N_VMinQuotient(ark_mem->yn, tmp); - ark_mem->eta = SUNMAX(ark_mem->eta, TENTH); + hnew = ark_mem->h * SUNMAX(RCONST(0.9)*N_VMinQuotient(ark_mem->yn, tmp), TENTH); + + /* Check if step size reduction is possible; if so adjust recommended step to meet bounds */ + retval = SUNTimestepHeuristics_BoundReduction(ark_mem->hconstraints, ark_mem->h, hnew, &hnew); + if (retval != SUNTIMESTEPHEURISTICS_SUCCESS) { return(ARK_CONSTR_FAIL); } + + /* Compute step size change for subsequent use */ + ark_mem->eta = hnew / ark_mem->h; /* Signal for Jacobian/preconditioner setup */ *nflag = PREV_CONV_FAIL; @@ -3003,32 +3046,35 @@ int arkCheckConstraints(ARKodeMem ark_mem, int *constrfails, int *nflag) If the test fails: - if maxnef error test failures have occurred or if - SUNRabs(h) = hmin, we return ARK_ERR_FAILURE. + no stepsize reduction is possible, we return ARK_ERR_FAILURE. - otherwise: set *nflagPtr to PREV_ERR_FAIL, and return TRY_AGAIN. --------------------------------------------------------------*/ int arkCheckTemporalError(ARKodeMem ark_mem, int *nflagPtr, int *nefPtr, realtype dsm) { int retval; - realtype ttmp; - long int nsttmp; - ARKodeHAdaptMem hadapt_mem; - - /* Access hadapt_mem structure */ - if (ark_mem->hadapt_mem == NULL) { - arkProcessError(ark_mem, ARK_MEM_NULL, "ARKODE", "arkCheckTemporalError", - MSG_ARKADAPT_NO_MEM); - return(ARK_MEM_NULL); + realtype hnew; + + /* Request new stepsize from controller */ + retval = SUNAdaptController_EstimateStep(ark_mem->hcontroller, + ark_mem->h, dsm, &hnew); + if (retval != SUNADAPTCONTROLLER_SUCCESS) { + arkProcessError(ark_mem, ARK_CONTROLLER_ERR, "ARKODE", "arkCheckTemporalError", + "Controller unable to recommend a step size"); + return(ARK_CONTROLLER_ERR); } - hadapt_mem = ark_mem->hadapt_mem; - /* consider change of step size for next step attempt (may be - larger/smaller than current step, depending on dsm) */ - ttmp = (dsm <= ONE) ? ark_mem->tn + ark_mem->h : ark_mem->tn; - nsttmp = (dsm <= ONE) ? ark_mem->nst+1 : ark_mem->nst; - retval = arkAdapt((void*) ark_mem, hadapt_mem, ark_mem->ycur, ttmp, - ark_mem->h, dsm, nsttmp); - if (retval != ARK_SUCCESS) return(ARK_ERR_FAILURE); + /* Perform heuristic controls on recommended step size */ + retval = SUNTimestepHeuristics_ConstrainStep(ark_mem->hconstraints, + ark_mem->h, hnew, &hnew); + if (retval != SUNTIMESTEPHEURISTICS_SUCCESS) { + arkProcessError(ark_mem, ARK_HEURISTICS_ERR, "ARKODE", "arkCheckTemporalError", + "Heuristics unable to constrain recommended step"); + return(ARK_HEURISTICS_ERR); + } + + /* Store step size recommendation in ark_mem->eta */ + ark_mem->eta = hnew / ark_mem->h; /* If est. local error norm dsm passes test, return ARK_SUCCESS */ if (dsm <= ONE) return(ARK_SUCCESS); @@ -3041,41 +3087,21 @@ int arkCheckTemporalError(ARKodeMem ark_mem, int *nflagPtr, int *nefPtr, realtyp /* At maxnef failures, return ARK_ERR_FAILURE */ if (*nefPtr == ark_mem->maxnef) return(ARK_ERR_FAILURE); - /* Set etamax=1 to prevent step size increase at end of this step */ - hadapt_mem->etamax = ONE; - - /* Enforce failure bounds on eta, update h, and return for retry of step */ - if (*nefPtr >= hadapt_mem->small_nef) - ark_mem->eta = SUNMIN(ark_mem->eta, hadapt_mem->etamxf); - - return(TRY_AGAIN); -} - - -/*--------------------------------------------------------------- - arkAccessHAdaptMem: - - Shortcut routine to unpack ark_mem and hadapt_mem structures from - void* pointer. If either is missing it returns ARK_MEM_NULL. - ---------------------------------------------------------------*/ -int arkAccessHAdaptMem(void* arkode_mem, const char *fname, - ARKodeMem *ark_mem, ARKodeHAdaptMem *hadapt_mem) -{ - - /* access ARKodeMem structure */ - if (arkode_mem==NULL) { - arkProcessError(NULL, ARK_MEM_NULL, "ARKODE", - fname, MSG_ARK_NO_MEM); - return(ARK_MEM_NULL); - } - *ark_mem = (ARKodeMem) arkode_mem; - if ((*ark_mem)->hadapt_mem==NULL) { - arkProcessError(*ark_mem, ARK_MEM_NULL, "ARKODE", - fname, MSG_ARKADAPT_NO_MEM); - return(ARK_MEM_NULL); + /* Attempt step reduction via heuristics control */ + retval = SUNTimestepHeuristics_ETestFail(ark_mem->hconstraints, ark_mem->h, + hnew, *nefPtr, &hnew); + + /* If step reduction successful, store result and return to reattempt + the step. Otherwise, return ARK_ERR_FAILURE or ARK_HEURISTICS_ERR, + depending on the circumstances */ + if (retval == SUNTIMESTEPHEURISTICS_SUCCESS) { + ark_mem->eta = hnew / ark_mem->h; + return(TRY_AGAIN); + } else if (retval == SUNTIMESTEPHEURISTICS_CANNOT_DECREASE) { + return(ARK_ERR_FAILURE); + } else { + return(ARK_HEURISTICS_ERR); } - *hadapt_mem = (ARKodeHAdaptMem) (*ark_mem)->hadapt_mem; - return(ARK_SUCCESS); } diff --git a/src/arkode/arkode_adapt.c b/src/arkode/arkode_adapt.c deleted file mode 100644 index 617681e9f5..0000000000 --- a/src/arkode/arkode_adapt.c +++ /dev/null @@ -1,430 +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 ARKODE's time step - * adaptivity utilities. - *--------------------------------------------------------------*/ - -#include -#include -#include -#include - -#include "arkode_impl.h" -#include -#include - - -/*--------------------------------------------------------------- - arkAdaptInit: - - This routine creates and sets default values in an - ARKodeHAdaptMem structure. This returns a non-NULL structure - if no errors occurred, or a NULL value otherwise. - ---------------------------------------------------------------*/ -ARKodeHAdaptMem arkAdaptInit() -{ - ARKodeHAdaptMem hadapt_mem; - - /* allocate structure */ - hadapt_mem = (ARKodeHAdaptMem) malloc(sizeof(struct ARKodeHAdaptMemRec)); - if (hadapt_mem == NULL) return(NULL); - - /* 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); -} - - -/*--------------------------------------------------------------- - arkPrintAdaptMem - - This routine outputs the time step adaptivity memory structure - to a specified file pointer. - ---------------------------------------------------------------*/ -void arkPrintAdaptMem(ARKodeHAdaptMem hadapt_mem, FILE *outfile) -{ - if (hadapt_mem != NULL) { - fprintf(outfile, "ark_hadapt: etamax = %"RSYM"\n", hadapt_mem->etamax); - fprintf(outfile, "ark_hadapt: etamx1 = %"RSYM"\n", hadapt_mem->etamx1); - fprintf(outfile, "ark_hadapt: etamxf = %"RSYM"\n", hadapt_mem->etamxf); - 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) { - fprintf(outfile, " ark_hadapt: Default explicit stability function\n"); - } else { - fprintf(outfile, " ark_hadapt: User provided explicit stability function\n"); - fprintf(outfile, " ark_hadapt: stability function data pointer = %p\n", - hadapt_mem->estab_data); - } - } -} - - - - -/*--------------------------------------------------------------- - arkAdapt is the time step adaptivity wrapper function. This - computes and sets the value of ark_eta inside of the ARKodeMem - data structure. - ---------------------------------------------------------------*/ -int arkAdapt(void* arkode_mem, ARKodeHAdaptMem hadapt_mem, - N_Vector ycur, realtype tcur, realtype hcur, - realtype dsm, long int nst) -{ - int ier, k; - realtype ecur, h_acc, h_cfl, int_dir; - ARKodeMem ark_mem; - if (arkode_mem == NULL) { - arkProcessError(NULL, ARK_MEM_NULL, "ARKODE", - "arkAdapt", MSG_ARK_NO_MEM); - return(ARK_MEM_NULL); - } - 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); - } - - /* 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) { - 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); -#endif - - /* enforce safety factors */ - h_acc *= hadapt_mem->safety; - h_cfl *= hadapt_mem->cfl * int_dir; - - /* enforce maximum bound on time step growth */ - h_acc = int_dir * SUNMIN(SUNRabs(h_acc), SUNRabs(hadapt_mem->etamax*hcur)); - - /* enforce minimum bound time step reduction */ - h_acc = int_dir * SUNMAX(SUNRabs(h_acc), SUNRabs(hadapt_mem->etamin*hcur)); - - /* Solver diagnostics reporting */ - if (ark_mem->report) - fprintf(ark_mem->diagfp, "%"RSYM" %"RSYM" ", h_acc, h_cfl); - -#if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_INFO - SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_INFO, - "ARKODE::arkAdapt", "new-step-after-max-min-bounds", - "h_acc = %"RSYM", h_cfl = %"RSYM, h_acc, h_cfl); -#endif - - /* increment the relevant step counter, set desired step */ - if (SUNRabs(h_acc) < SUNRabs(h_cfl)) - hadapt_mem->nst_acc++; - else - hadapt_mem->nst_exp++; - h_acc = int_dir * SUNMIN(SUNRabs(h_acc), SUNRabs(h_cfl)); - - /* enforce adaptivity bounds to retain Jacobian/preconditioner accuracy */ - if (dsm <= ONE) { - if ( (SUNRabs(h_acc) > SUNRabs(hcur*hadapt_mem->lbound*ONEMSM)) && - (SUNRabs(h_acc) < SUNRabs(hcur*hadapt_mem->ubound*ONEPSM)) ) - h_acc = hcur; - } - - /* set basic value of ark_eta */ - ark_mem->eta = h_acc / hcur; - - /* enforce minimum time step size */ - ark_mem->eta = SUNMAX(ark_mem->eta, - ark_mem->hmin / SUNRabs(hcur)); - - /* enforce maximum time step size */ - ark_mem->eta /= SUNMAX(ONE, SUNRabs(hcur) * - ark_mem->hmax_inv*ark_mem->eta); - - /* Solver diagnostics reporting */ - if (ark_mem->report) - fprintf(ark_mem->diagfp, "%"RSYM"\n", ark_mem->eta); - -#if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_INFO - SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_INFO, "ARKODE::arkAdapt", - "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); -} - - -/*--------------------------------------------------------------- - 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 deleted file mode 100644 index 5cdd3d2e58..0000000000 --- a/src/arkode/arkode_adapt_impl.h +++ /dev/null @@ -1,149 +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 - *--------------------------------------------------------------- - * Implementation header file for ARKODE's time step adaptivity - * utilities. - *--------------------------------------------------------------*/ - -#ifndef _ARKODE_ADAPT_IMPL_H -#define _ARKODE_ADAPT_IMPL_H - -#include -#include - -#ifdef __cplusplus /* wrapper to enable C++ usage */ -extern "C" { -#endif - - -/*=============================================================== - ARKODE Time Step Adaptivity Private Constants - ===============================================================*/ - -/* size constants for the adaptivity memory structure */ -#define ARK_ADAPT_LRW 19 -#define ARK_ADAPT_LIW 8 /* 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 - test failures (multiple implies >= SMALL_NEF) */ -#define ETAMIN RCONST(0.1) /* smallest allowable step size reduction factor - on an error test failure */ -#define ETACF RCONST(0.25) /* step size reduction factor on nonlinear - convergence failure */ -#define SMALL_NEF 2 /* if an error failure occurs and SMALL_NEF <= nef, - then reset eta = MIN(eta, ETAMXF) */ - - -/*=============================================================== - ARKODE Time Step Adaptivity Data Structure - ===============================================================*/ - -/*--------------------------------------------------------------- - Types : struct ARKodeHAdaptMemRec, ARKodeHAdaptMem - ----------------------------------------------------------------- - The type ARKodeHAdaptMem is type pointer to struct - ARKodeHAdaptMemRec. This structure contains fields to - keep track of temporal adaptivity. - ---------------------------------------------------------------*/ -typedef struct ARKodeHAdaptMemRec { - - realtype etamax; /* eta <= etamax */ - realtype etamx1; /* max step size change on first step */ - realtype etamxf; /* h reduction factor on multiple error fails */ - 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) */ - - ARKExpStabFn expstab; /* step stability function */ - void *estab_data; /* user pointer passed to expstab */ - - long int nst_acc; /* num accuracy-limited internal steps */ - long int nst_exp; /* num stability-limited internal steps */ - -} *ARKodeHAdaptMem; - - -/*=============================================================== - ARKODE Time Step Adaptivity Routines - ===============================================================*/ - -ARKodeHAdaptMem arkAdaptInit(); -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 -} -#endif - -#endif diff --git a/src/arkode/arkode_arkstep.c b/src/arkode/arkode_arkstep.c index e1245168e0..4d17937abb 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->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..c0f6293ccb 100644 --- a/src/arkode/arkode_arkstep_io.c +++ b/src/arkode/arkode_arkstep_io.c @@ -52,10 +52,6 @@ int ARKStepSetMaxHnilWarns(void *arkode_mem, int mxhnil) { return(arkSetMaxHnilWarns(arkode_mem, mxhnil)); } int ARKStepSetInitStep(void *arkode_mem, realtype hin) { return(arkSetInitStep(arkode_mem, hin)); } -int ARKStepSetMinStep(void *arkode_mem, realtype hmin) { - return(arkSetMinStep(arkode_mem, hmin)); } -int ARKStepSetMaxStep(void *arkode_mem, realtype hmax) { - return(arkSetMaxStep(arkode_mem, hmax)); } int ARKStepSetStopTime(void *arkode_mem, realtype tstop) { return(arkSetStopTime(arkode_mem, tstop)); } int ARKStepSetInterpolateStopTime(void *arkode_mem, @@ -77,39 +73,16 @@ int ARKStepSetPostprocessStepFn(void *arkode_mem, int ARKStepSetPostprocessStageFn(void *arkode_mem, ARKPostProcessFn ProcessStage) { return(arkSetPostprocessStageFn(arkode_mem, ProcessStage)); } -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) { - 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) { - return(arkSetMaxEFailGrowth(arkode_mem, etamxf)); } -int ARKStepSetSmallNumEFails(void *arkode_mem, int small_nef) { - return(arkSetSmallNumEFails(arkode_mem, small_nef)); } -int ARKStepSetMaxCFailGrowth(void *arkode_mem, realtype etacf) { - return(arkSetMaxCFailGrowth(arkode_mem, etacf)); } -int ARKStepSetStabilityFn(void *arkode_mem, ARKExpStabFn EStab, void *estab_data) { - return(arkSetStabilityFn(arkode_mem, EStab, estab_data)); } 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 ARKStepSetFixedStep(void *arkode_mem, realtype hfixed) { return(arkSetFixedStep(arkode_mem, hfixed)); } +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 ARKStepSetTimestepHeuristics(void *arkode_mem, SUNTimestepHeuristics H) { + return(arkSetTimestepHeuristics(arkode_mem, H)); } /*--------------------------------------------------------------- @@ -191,10 +164,6 @@ int ARKStepGetStepStats(void *arkode_mem, long int *nsteps, return(arkGetStepStats(arkode_mem, nsteps, hinused, hlast, hcur, tcur)); } int ARKStepGetNumConstrFails(void *arkode_mem, long int *nconstrfails) { return(arkGetNumConstrFails(arkode_mem, nconstrfails)); } -int ARKStepGetNumExpSteps(void *arkode_mem, long int *nsteps) { - return(arkGetNumExpSteps(arkode_mem, nsteps)); } -int ARKStepGetNumAccSteps(void *arkode_mem, long int *nsteps) { - return(arkGetNumAccSteps(arkode_mem, nsteps)); } int ARKStepGetNumErrTestFails(void *arkode_mem, long int *netfails) { return(arkGetNumErrTestFails(arkode_mem, netfails)); } int ARKStepGetNumStepSolveFails(void *arkode_mem, long int *nncfails) { @@ -343,10 +312,269 @@ int ARKStepGetNumRelaxSolveIters(void* arkode_mem, long int* iters) return arkRelaxGetNumRelaxSolveIters(arkode_mem, iters); } + + +/*=============================================================== + DEPRECATED ARKStep optional input/output functions + ===============================================================*/ + +/*--------------------------------------------------------------- + ARKStepSetMinStep: user should create/attach a + SUNTimestepHeuristics object, and set this directly therein. + ---------------------------------------------------------------*/ +int ARKStepSetMinStep(void *arkode_mem, realtype hmin) +{ + int retval; + ARKodeMem ark_mem; + if (arkode_mem==NULL) { + arkProcessError(NULL, ARK_MEM_NULL, "ARKStep", + "ARKStepSetMinStep", MSG_ARK_NO_MEM); + return(ARK_MEM_NULL); + } + ark_mem = (ARKodeMem) arkode_mem; + retval = SUNTimestepHeuristics_SetMinStep(ark_mem->hconstraints, hmin); + if (retval != SUNTIMESTEPHEURISTICS_SUCCESS) { return(ARK_ILL_INPUT); } + return(ARK_SUCCESS); +} + +/*--------------------------------------------------------------- + ARKStepSetMaxStep: user should create/attach a + SUNTimestepHeuristics object, and set this directly therein. + ---------------------------------------------------------------*/ +int ARKStepSetMaxStep(void *arkode_mem, realtype hmax) +{ + int retval; + ARKodeMem ark_mem; + if (arkode_mem==NULL) { + arkProcessError(NULL, ARK_MEM_NULL, "ARKStep", + "ARKStepSetMaxStep", MSG_ARK_NO_MEM); + return(ARK_MEM_NULL); + } + ark_mem = (ARKodeMem) arkode_mem; + retval = SUNTimestepHeuristics_SetMaxStep(ark_mem->hconstraints, hmax); + if (retval != SUNTIMESTEPHEURISTICS_SUCCESS) { return(ARK_ILL_INPUT); } + return(ARK_SUCCESS); +} + +/*--------------------------------------------------------------- + ARKStepSetCFLFraction: user should create/attach a + SUNTimestepHeuristics object, and set this directly therein. + ---------------------------------------------------------------*/ +int ARKStepSetCFLFraction(void *arkode_mem, realtype cfl_frac) +{ + int retval; + ARKodeMem ark_mem; + if (arkode_mem==NULL) { + arkProcessError(NULL, ARK_MEM_NULL, "ARKStep", + "ARKStepSetCFLFraction", MSG_ARK_NO_MEM); + return(ARK_MEM_NULL); + } + ark_mem = (ARKodeMem) arkode_mem; + retval = SUNTimestepHeuristics_SetCFLFraction(ark_mem->hconstraints, cfl_frac); + if (retval != SUNTIMESTEPHEURISTICS_SUCCESS) { return(ARK_ILL_INPUT); } + return(ARK_SUCCESS); +} + +/*--------------------------------------------------------------- + ARKStepSetSafetyFactor: user should create/attach a + SUNTimestepHeuristics object, and set this directly therein. + ---------------------------------------------------------------*/ +int ARKStepSetSafetyFactor(void *arkode_mem, realtype safety) +{ + int retval; + ARKodeMem ark_mem; + if (arkode_mem==NULL) { + arkProcessError(NULL, ARK_MEM_NULL, "ARKStep", + "ARKStepSetSafetyFactor", MSG_ARK_NO_MEM); + return(ARK_MEM_NULL); + } + ark_mem = (ARKodeMem) arkode_mem; + retval = SUNTimestepHeuristics_SetSafetyFactor(ark_mem->hconstraints, safety); + if (retval != SUNTIMESTEPHEURISTICS_SUCCESS) { return(ARK_ILL_INPUT); } + return(ARK_SUCCESS); +} + +/*--------------------------------------------------------------- + ARKStepSetErrorBias: user should create/attach a + SUNAdaptController object, and set this directly therein. + ---------------------------------------------------------------*/ +int ARKStepSetErrorBias(void *arkode_mem, realtype bias) +{ + int retval; + ARKodeMem ark_mem; + if (arkode_mem==NULL) { + arkProcessError(NULL, ARK_MEM_NULL, "ARKStep", + "ARKStepSetErrorBias", MSG_ARK_NO_MEM); + return(ARK_MEM_NULL); + } + ark_mem = (ARKodeMem) arkode_mem; + retval = SUNAdaptController_SetErrorBias(ark_mem->hcontroller, bias); + if (retval != SUNADAPTCONTROLLER_SUCCESS) { return(ARK_ILL_INPUT); } + return(ARK_SUCCESS); +} + +/*--------------------------------------------------------------- + ARKStepSetMaxGrowth: user should create/attach a + SUNTimestepHeuristics object, and set this directly therein. + ---------------------------------------------------------------*/ +int ARKStepSetMaxGrowth(void *arkode_mem, realtype mx_growth) +{ + int retval; + ARKodeMem ark_mem; + if (arkode_mem==NULL) { + arkProcessError(NULL, ARK_MEM_NULL, "ARKStep", + "ARKStepSetMaxGrowth", MSG_ARK_NO_MEM); + return(ARK_MEM_NULL); + } + ark_mem = (ARKodeMem) arkode_mem; + retval = SUNTimestepHeuristics_SetMaxGrowth(ark_mem->hconstraints, mx_growth); + if (retval != SUNTIMESTEPHEURISTICS_SUCCESS) { return(ARK_ILL_INPUT); } + return(ARK_SUCCESS); +} + +/*--------------------------------------------------------------- + ARKStepSetMinReduction: user should create/attach a + SUNTimestepHeuristics object, and set this directly therein. + ---------------------------------------------------------------*/ +int ARKStepSetMinReduction(void *arkode_mem, realtype eta_min) +{ + int retval; + ARKodeMem ark_mem; + if (arkode_mem==NULL) { + arkProcessError(NULL, ARK_MEM_NULL, "ARKStep", + "ARKStepSetMinReduction", MSG_ARK_NO_MEM); + return(ARK_MEM_NULL); + } + ark_mem = (ARKodeMem) arkode_mem; + retval = SUNTimestepHeuristics_SetMinReduction(ark_mem->hconstraints, eta_min); + if (retval != SUNTIMESTEPHEURISTICS_SUCCESS) { return(ARK_ILL_INPUT); } + return(ARK_SUCCESS); +} + +/*--------------------------------------------------------------- + ARKStepSetFixedStepBounds: user should create/attach a + SUNTimestepHeuristics object, and set this directly therein. + ---------------------------------------------------------------*/ +int ARKStepSetFixedStepBounds(void *arkode_mem, realtype lb, realtype ub) +{ + int retval; + ARKodeMem ark_mem; + if (arkode_mem==NULL) { + arkProcessError(NULL, ARK_MEM_NULL, "ARKStep", + "ARKStepSetFixedStepBounds", MSG_ARK_NO_MEM); + return(ARK_MEM_NULL); + } + ark_mem = (ARKodeMem) arkode_mem; + retval = SUNTimestepHeuristics_SetFixedStepBounds(ark_mem->hconstraints, lb, ub); + if (retval != SUNTIMESTEPHEURISTICS_SUCCESS) { return(ARK_ILL_INPUT); } + return(ARK_SUCCESS); +} + +/*--------------------------------------------------------------- + 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)); } + +/*--------------------------------------------------------------- + ARKStepSetMaxFirstGrowth: user should create/attach a + SUNTimestepHeuristics object, and set this directly therein. + ---------------------------------------------------------------*/ +int ARKStepSetMaxFirstGrowth(void *arkode_mem, realtype etamx1) +{ + int retval; + ARKodeMem ark_mem; + if (arkode_mem==NULL) { + arkProcessError(NULL, ARK_MEM_NULL, "ARKStep", + "ARKStepSetMaxFirstGrowth", MSG_ARK_NO_MEM); + return(ARK_MEM_NULL); + } + ark_mem = (ARKodeMem) arkode_mem; + retval = SUNTimestepHeuristics_SetMaxFirstGrowth(ark_mem->hconstraints, etamx1); + if (retval != SUNTIMESTEPHEURISTICS_SUCCESS) { return(ARK_ILL_INPUT); } + return(ARK_SUCCESS); +} + +/*--------------------------------------------------------------- + ARKStepSetMaxEFailGrowth: user should create/attach a + SUNTimestepHeuristics object, and set this directly therein. + ---------------------------------------------------------------*/ +int ARKStepSetMaxEFailGrowth(void *arkode_mem, realtype etamxf) +{ + int retval; + ARKodeMem ark_mem; + if (arkode_mem==NULL) { + arkProcessError(NULL, ARK_MEM_NULL, "ARKStep", + "ARKStepSetMaxEFailGrowth", MSG_ARK_NO_MEM); + return(ARK_MEM_NULL); + } + ark_mem = (ARKodeMem) arkode_mem; + retval = SUNTimestepHeuristics_SetMaxEFailGrowth(ark_mem->hconstraints, etamxf); + if (retval != SUNTIMESTEPHEURISTICS_SUCCESS) { return(ARK_ILL_INPUT); } + return(ARK_SUCCESS); +} + +/*--------------------------------------------------------------- + ARKStepSetSmallNumEFails: user should create/attach a + SUNTimestepHeuristics object, and set this directly therein. + ---------------------------------------------------------------*/ +int ARKStepSetSmallNumEFails(void *arkode_mem, int small_nef) +{ + int retval; + ARKodeMem ark_mem; + if (arkode_mem==NULL) { + arkProcessError(NULL, ARK_MEM_NULL, "ARKStep", + "ARKStepSetSmallNumEFails", MSG_ARK_NO_MEM); + return(ARK_MEM_NULL); + } + ark_mem = (ARKodeMem) arkode_mem; + retval = SUNTimestepHeuristics_SetSmallNumEFails(ark_mem->hconstraints, small_nef); + if (retval != SUNTIMESTEPHEURISTICS_SUCCESS) { return(ARK_ILL_INPUT); } + return(ARK_SUCCESS); +} + +/*--------------------------------------------------------------- + ARKStepSetMaxCFailGrowth: user should create/attach a + SUNTimestepHeuristics object, and set this directly therein. + ---------------------------------------------------------------*/ +int ARKStepSetMaxCFailGrowth(void *arkode_mem, realtype etacf) +{ + int retval; + ARKodeMem ark_mem; + if (arkode_mem==NULL) { + arkProcessError(NULL, ARK_MEM_NULL, "ARKStep", + "ARKStepSetMaxCFailGrowth", MSG_ARK_NO_MEM); + return(ARK_MEM_NULL); + } + ark_mem = (ARKodeMem) arkode_mem; + retval = SUNTimestepHeuristics_SetMaxCFailGrowth(ark_mem->hconstraints, etacf); + if (retval != SUNTIMESTEPHEURISTICS_SUCCESS) { return(ARK_ILL_INPUT); } + return(ARK_SUCCESS); +} + +/*--------------------------------------------------------------- + ARKStepSetStabilityFn: user should create/attach a + SUNTimestepHeuristics object, and set this directly therein. + ---------------------------------------------------------------*/ +int ARKStepSetStabilityFn(void *arkode_mem, ARKExpStabFn EStab, void *estab_data) { + return(arkSetStabilityFn(arkode_mem, EStab, estab_data)); } + + + /*=============================================================== ARKStep optional input functions -- stepper-specific ===============================================================*/ + /*--------------------------------------------------------------- ARKStepSetUserData: @@ -441,7 +669,7 @@ int ARKStepSetDefaults(void* arkode_mem) /*--------------------------------------------------------------- - ARKStepSetOptimalParams: + ARKStepSetOptimalParams: ***DEPRECATED*** Sets all adaptivity and solver parameters to our 'best guess' values, for a given ARKStep integration method (ERK, DIRK, ARK), @@ -454,46 +682,90 @@ int ARKStepSetOptimalParams(void *arkode_mem) { ARKodeMem ark_mem; ARKodeARKStepMem step_mem; - ARKodeHAdaptMem hadapt_mem; int retval; + long int lenrw, leniw; /* access ARKodeARKStepMem structure */ retval = arkStep_AccessStepMem(arkode_mem, "ARKStepSetOptimalParams", &ark_mem, &step_mem); if (retval != ARK_SUCCESS) return(retval); - /* access ARKodeHAdaptMem structure */ - if (ark_mem->hadapt_mem == NULL) { - arkProcessError(ark_mem, ARK_MEM_NULL, "ARKODE::ARKStep", + /* Remove current SUNTimestepHeuristics object, and replace with "Default" */ + retval = SUNTimestepHeuristics_Space(ark_mem->hconstraints, &lenrw, &leniw); + if (retval == SUNTIMESTEPHEURISTICS_SUCCESS) { + ark_mem->liw -= leniw; + ark_mem->lrw -= lenrw; + } + if (ark_mem->ownconstraints) { + retval = SUNTimestepHeuristics_Destroy(ark_mem->hconstraints); + if (retval != SUNTIMESTEPHEURISTICS_SUCCESS) { + arkProcessError(ark_mem, ARK_MEM_FAIL, "ARKODE", "ARKStepSetOptimalParams", + "SUNTimestepHeuristics_Destroy failure"); + return(ARK_MEM_FAIL); + } + } + ark_mem->hconstraints = NULL; + ark_mem->hconstraints = SUNTimestepHeuristics_Default(ark_mem->sunctx); + if (ark_mem->hconstraints == NULL) { + arkProcessError(ark_mem, ARK_MEM_FAIL, "ARKODE::ARKStep", "ARKStepSetOptimalParams", - MSG_ARKADAPT_NO_MEM); - return(ARK_MEM_NULL); + "SUNTimestepHeuristics_Default allocation failure"); + return(ARK_MEM_FAIL); + } + ark_mem->ownconstraints = SUNTRUE; + retval = SUNTimestepHeuristics_Space(ark_mem->hconstraints, &lenrw, &leniw); + if (retval == SUNTIMESTEPHEURISTICS_SUCCESS) { + ark_mem->liw += leniw; + ark_mem->lrw += lenrw; + } + + + /* Remove current SUNAdaptController object */ + retval = SUNAdaptController_Space(ark_mem->hcontroller, &lenrw, &leniw); + if (retval == SUNADAPTCONTROLLER_SUCCESS) { + ark_mem->liw -= leniw; + ark_mem->lrw -= lenrw; + } + if (ark_mem->owncontroller) { + retval = SUNAdaptController_Destroy(ark_mem->hcontroller); + if (retval != SUNADAPTCONTROLLER_SUCCESS) { + arkProcessError(ark_mem, ARK_MEM_FAIL, "ARKODE", "ARKStepSetOptimalParams", + "SUNAdaptController_Destroy failure"); + return(ARK_MEM_FAIL); + } } - hadapt_mem = ark_mem->hadapt_mem; + ark_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->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); + ark_mem->hcontroller = SUNAdaptController_PI(ark_mem->sunctx); + if (ark_mem->hcontroller == NULL) { + arkProcessError(ark_mem, ARK_MEM_FAIL, "ARKODE::ARKStep", + "ARKStepSetOptimalParams", + "SUNAdaptController_PI allocation failure"); + return(ARK_MEM_FAIL); + } + (void) SUNAdaptController_SetErrorBias(ark_mem->hcontroller, RCONST(1.2)); + (void) SUNAdaptController_SetParams_PI(ark_mem->hcontroller, SUNFALSE, + RCONST(0.8), RCONST(0.31)); + (void) SUNTimestepHeuristics_SetSafetyFactor(ark_mem->hconstraints, RCONST(0.99)); + (void) SUNTimestepHeuristics_SetMaxGrowth(ark_mem->hconstraints, RCONST(25.0)); + (void) SUNTimestepHeuristics_SetMaxEFailGrowth(ark_mem->hconstraints, 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->safety = SAFETY; - hadapt_mem->bias = BIAS; - hadapt_mem->growth = GROWTH; - hadapt_mem->etamxf = ETAMXF; - hadapt_mem->small_nef = SMALL_NEF; - hadapt_mem->etacf = ETACF; + ark_mem->hcontroller = SUNAdaptController_PID(ark_mem->sunctx); + if (ark_mem->hcontroller == NULL) { + arkProcessError(ark_mem, ARK_MEM_FAIL, "ARKODE::ARKStep", + "ARKStepSetOptimalParams", + "SUNAdaptController_PID allocation failure"); + return(ARK_MEM_FAIL); + } step_mem->nlscoef = RCONST(0.001); step_mem->maxcor = 5; step_mem->crdown = CRDOWN; @@ -502,13 +774,17 @@ int ARKStepSetOptimalParams(void *arkode_mem) step_mem->msbp = MSBP; break; case 3: - hadapt_mem->imethod = ARK_ADAPT_I; - 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; - hadapt_mem->etacf = ETACF; + ark_mem->hcontroller = SUNAdaptController_I(ark_mem->sunctx); + if (ark_mem->hcontroller == NULL) { + arkProcessError(ark_mem, ARK_MEM_FAIL, "ARKODE::ARKStep", + "ARKStepSetOptimalParams", + "SUNAdaptController_I allocation failure"); + return(ARK_MEM_FAIL); + } + (void) SUNAdaptController_SetErrorBias(ark_mem->hcontroller, RCONST(1.9)); + (void) SUNTimestepHeuristics_SetSafetyFactor(ark_mem->hconstraints, RCONST(0.957)); + (void) SUNTimestepHeuristics_SetMaxGrowth(ark_mem->hconstraints, RCONST(17.6)); + (void) SUNTimestepHeuristics_SetMaxEFailGrowth(ark_mem->hconstraints, RCONST(0.45)); step_mem->nlscoef = RCONST(0.22); step_mem->crdown = RCONST(0.17); step_mem->rdiv = RCONST(2.3); @@ -516,16 +792,19 @@ int ARKStepSetOptimalParams(void *arkode_mem) step_mem->msbp = 60; break; case 4: - hadapt_mem->imethod = ARK_ADAPT_PID; - 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; + ark_mem->hcontroller = SUNAdaptController_PID(ark_mem->sunctx); + if (ark_mem->hcontroller == NULL) { + arkProcessError(ark_mem, ARK_MEM_FAIL, "ARKODE::ARKStep", + "ARKStepSetOptimalParams", + "SUNAdaptController_PID allocation failure"); + return(ARK_MEM_FAIL); + } + (void) SUNAdaptController_SetErrorBias(ark_mem->hcontroller, RCONST(1.2)); + (void) SUNAdaptController_SetParams_PID(ark_mem->hcontroller, SUNFALSE, + RCONST(0.535), RCONST(0.209), RCONST(0.148)); + (void) SUNTimestepHeuristics_SetSafetyFactor(ark_mem->hconstraints, RCONST(0.988)); + (void) SUNTimestepHeuristics_SetMaxGrowth(ark_mem->hconstraints, RCONST(31.5)); + (void) SUNTimestepHeuristics_SetMaxEFailGrowth(ark_mem->hconstraints, RCONST(0.33)); step_mem->nlscoef = RCONST(0.24); step_mem->crdown = RCONST(0.26); step_mem->rdiv = RCONST(2.3); @@ -533,16 +812,19 @@ int ARKStepSetOptimalParams(void *arkode_mem) step_mem->msbp = 31; break; case 5: - hadapt_mem->imethod = ARK_ADAPT_PID; - 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; + ark_mem->hcontroller = SUNAdaptController_PID(ark_mem->sunctx); + if (ark_mem->hcontroller == NULL) { + arkProcessError(ark_mem, ARK_MEM_FAIL, "ARKODE::ARKStep", + "ARKStepSetOptimalParams", + "SUNAdaptController_PID allocation failure"); + return(ARK_MEM_FAIL); + } + (void) SUNAdaptController_SetErrorBias(ark_mem->hcontroller, RCONST(3.3)); + (void) SUNAdaptController_SetParams_PID(ark_mem->hcontroller, SUNFALSE, + RCONST(0.56), RCONST(0.338), RCONST(0.14)); + (void) SUNTimestepHeuristics_SetSafetyFactor(ark_mem->hconstraints, RCONST(0.937)); + (void) SUNTimestepHeuristics_SetMaxGrowth(ark_mem->hconstraints, RCONST(22.0)); + (void) SUNTimestepHeuristics_SetMaxEFailGrowth(ark_mem->hconstraints, RCONST(0.44)); step_mem->nlscoef = RCONST(0.25); step_mem->crdown = RCONST(0.4); step_mem->rdiv = RCONST(2.3); @@ -554,17 +836,35 @@ int ARKStepSetOptimalParams(void *arkode_mem) /* imex */ } else { switch (step_mem->q) { + case 2: /* just use standard defaults since better ones unknown */ + ark_mem->hcontroller = SUNAdaptController_PID(ark_mem->sunctx); + if (ark_mem->hcontroller == NULL) { + arkProcessError(ark_mem, ARK_MEM_FAIL, "ARKODE::ARKStep", + "ARKStepSetOptimalParams", + "SUNAdaptController_PID allocation failure"); + return(ARK_MEM_FAIL); + } + 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->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; + ark_mem->hcontroller = SUNAdaptController_PID(ark_mem->sunctx); + if (ark_mem->hcontroller == NULL) { + arkProcessError(ark_mem, ARK_MEM_FAIL, "ARKODE::ARKStep", + "ARKStepSetOptimalParams", + "SUNAdaptController_PID allocation failure"); + return(ARK_MEM_FAIL); + } + (void) SUNAdaptController_SetErrorBias(ark_mem->hcontroller, RCONST(1.42)); + (void) SUNAdaptController_SetParams_PID(ark_mem->hcontroller, SUNFALSE, + RCONST(0.54), RCONST(0.36), RCONST(0.14)); + (void) SUNTimestepHeuristics_SetSafetyFactor(ark_mem->hconstraints, RCONST(0.965)); + (void) SUNTimestepHeuristics_SetMaxGrowth(ark_mem->hconstraints, RCONST(28.7)); + (void) SUNTimestepHeuristics_SetMaxEFailGrowth(ark_mem->hconstraints, RCONST(0.46)); step_mem->nlscoef = RCONST(0.22); step_mem->crdown = RCONST(0.17); step_mem->rdiv = RCONST(2.3); @@ -572,16 +872,19 @@ int ARKStepSetOptimalParams(void *arkode_mem) step_mem->msbp = 60; break; case 4: - hadapt_mem->imethod = ARK_ADAPT_PID; - 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; + ark_mem->hcontroller = SUNAdaptController_PID(ark_mem->sunctx); + if (ark_mem->hcontroller == NULL) { + arkProcessError(ark_mem, ARK_MEM_FAIL, "ARKODE::ARKStep", + "ARKStepSetOptimalParams", + "SUNAdaptController_PID allocation failure"); + return(ARK_MEM_FAIL); + } + (void) SUNAdaptController_SetErrorBias(ark_mem->hcontroller, RCONST(1.35)); + (void) SUNAdaptController_SetParams_PID(ark_mem->hcontroller, SUNFALSE, + RCONST(0.543), RCONST(0.297), RCONST(0.14)); + (void) SUNTimestepHeuristics_SetSafetyFactor(ark_mem->hconstraints, RCONST(0.97)); + (void) SUNTimestepHeuristics_SetMaxGrowth(ark_mem->hconstraints, RCONST(25.0)); + (void) SUNTimestepHeuristics_SetMaxEFailGrowth(ark_mem->hconstraints, RCONST(0.47)); step_mem->nlscoef = RCONST(0.24); step_mem->crdown = RCONST(0.26); step_mem->rdiv = RCONST(2.3); @@ -589,15 +892,19 @@ int ARKStepSetOptimalParams(void *arkode_mem) step_mem->msbp = 31; break; case 5: - hadapt_mem->imethod = ARK_ADAPT_PI; - 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; + ark_mem->hcontroller = SUNAdaptController_PI(ark_mem->sunctx); + if (ark_mem->hcontroller == NULL) { + arkProcessError(ark_mem, ARK_MEM_FAIL, "ARKODE::ARKStep", + "ARKStepSetOptimalParams", + "SUNAdaptController_PI allocation failure"); + return(ARK_MEM_FAIL); + } + (void) SUNAdaptController_SetErrorBias(ark_mem->hcontroller, RCONST(1.15)); + (void) SUNAdaptController_SetParams_PI(ark_mem->hcontroller, SUNFALSE, + RCONST(0.8), RCONST(0.35)); + (void) SUNTimestepHeuristics_SetSafetyFactor(ark_mem->hconstraints, RCONST(0.993)); + (void) SUNTimestepHeuristics_SetMaxGrowth(ark_mem->hconstraints, RCONST(28.5)); + (void) SUNTimestepHeuristics_SetMaxEFailGrowth(ark_mem->hconstraints, RCONST(0.3)); step_mem->nlscoef = RCONST(0.25); step_mem->crdown = RCONST(0.4); step_mem->rdiv = RCONST(2.3); @@ -605,6 +912,13 @@ int ARKStepSetOptimalParams(void *arkode_mem) step_mem->msbp = 31; break; } + ark_mem->owncontroller = SUNTRUE; + + retval = SUNAdaptController_Space(ark_mem->hcontroller, &lenrw, &leniw); + if (retval == SUNADAPTCONTROLLER_SUCCESS) { + ark_mem->liw += leniw; + ark_mem->lrw += lenrw; + } } return(ARK_SUCCESS); @@ -1619,17 +1933,19 @@ int ARKStepGetTimestepperStats(void *arkode_mem, long int *expsteps, &ark_mem, &step_mem); if (retval != ARK_SUCCESS) return(retval); - /* set expsteps and accsteps from adaptivity structure */ - *expsteps = ark_mem->hadapt_mem->nst_exp; - *accsteps = ark_mem->hadapt_mem->nst_acc; - - /* set remaining outputs */ + /* set integrator outputs */ *step_attempts = ark_mem->nst_attempts; *fe_evals = step_mem->nfe; *fi_evals = step_mem->nfi; *nlinsetups = step_mem->nsetups; *netfails = ark_mem->netf; + /* get expsteps and accsteps from heuristics object */ + retval = SUNTimestepHeuristics_GetNumExpSteps(ark_mem->hconstraints, expsteps); + if (retval != SUNTIMESTEPHEURISTICS_SUCCESS) { return(ARK_HEURISTICS_ERR); } + retval = SUNTimestepHeuristics_GetNumAccSteps(ark_mem->hconstraints, accsteps); + if (retval != SUNTIMESTEPHEURISTICS_SUCCESS) { return(ARK_HEURISTICS_ERR); } + return(ARK_SUCCESS); } @@ -1703,6 +2019,51 @@ int ARKStepGetNonlinSolvStats(void *arkode_mem, long int *nniters, } +/*--------------------------------------------------------------- + ARKStepGetNumExpSteps: + + Returns the current number of stability-limited steps. + + This is a convenience routine, that merely calls + SUNTimestepHeuristics_GetNumExpSteps for the result. + ---------------------------------------------------------------*/ +int ARKStepGetNumExpSteps(void *arkode_mem, long int *nsteps) +{ + ARKodeMem ark_mem; + if (arkode_mem==NULL) { + arkProcessError(NULL, ARK_MEM_NULL, "ARKStep", + "ARKStepGetNumExpSteps", MSG_ARK_NO_MEM); + return(ARK_MEM_NULL); + } + ark_mem = (ARKodeMem) arkode_mem; + if (SUNTimestepHeuristics_GetNumExpSteps(ark_mem->hconstraints, nsteps) + != SUNTIMESTEPHEURISTICS_SUCCESS) { return(ARK_HEURISTICS_ERR); } + return(ARK_SUCCESS); +} + +/*--------------------------------------------------------------- + ARKStepGetNumAccSteps: + + Returns the current number of accuracy-limited steps. + + This is a convenience routine, that merely calls + SUNTimestepHeuristics_GetNumAccSteps for the result. + ---------------------------------------------------------------*/ +int ARKStepGetNumAccSteps(void *arkode_mem, long int *nsteps) +{ + ARKodeMem ark_mem; + if (arkode_mem==NULL) { + arkProcessError(NULL, ARK_MEM_NULL, "ARKStep", + "ARKStepGetNumAccSteps", MSG_ARK_NO_MEM); + return(ARK_MEM_NULL); + } + ark_mem = (ARKodeMem) arkode_mem; + if (SUNTimestepHeuristics_GetNumAccSteps(ark_mem->hconstraints, nsteps) + != SUNTIMESTEPHEURISTICS_SUCCESS) { return(ARK_HEURISTICS_ERR); } + return(ARK_SUCCESS); +} + + /*--------------------------------------------------------------- ARKStepPrintAllStats: diff --git a/src/arkode/arkode_butcher_dirk.def b/src/arkode/arkode_butcher_dirk.def index a3cca75f66..473ab46c60 100644 --- a/src/arkode/arkode_butcher_dirk.def +++ b/src/arkode/arkode_butcher_dirk.def @@ -44,11 +44,11 @@ ARKODE_ESDIRK32I5L2SA_5_2_3 ESDIRK Y Y Y ARKODE_CASH_5_2_4 SDIRK Y Y N ARKODE_CASH_5_3_4 SDIRK Y Y N + ARKODE_ESDIRK436L2SA_6_3_4 ESDIRK Y Y N ARKODE_SDIRK_5_3_4 SDIRK Y Y Y ARKODE_KVAERNO_5_3_4 ESDIRK Y N N ARKODE_ARK436L2SA_DIRK_6_3_4* ESDIRK Y Y N ARKODE_ARK437L2SA_DIRK_7_3_4* ESDIRK Y Y N - ARKODE_ESDIRK436L2SA_6_3_4 ESDIRK Y Y N ARKODE_ESDIRK43I6L2SA_6_3_4 ESDIRK Y Y N ARKODE_QESDIRK436L2SA_6_3_4 ESDIRK Y Y N ARKODE_ESDIRK437L2SA_7_3_4 ESDIRK Y Y N @@ -304,6 +304,54 @@ ARK_BUTCHER_TABLE(ARKODE_CASH_5_3_4, { /* Cash(5,3,4)-SDIRK */ return B; }) +ARK_BUTCHER_TABLE(ARKODE_ESDIRK436L2SA_6_3_4, { /* ESDIRK4(3)6L[2]SA (A,L stable) */ + ARKodeButcherTable B = ARKodeButcherTable_Alloc(6, SUNTRUE); + B->q = 4; + B->p = 3; + + B->c[1] = RCONST(0.5); + B->c[2] = (RCONST(2.0)-SUNRsqrt(RCONST(2.0)))/RCONST(4.0); + B->c[3] = RCONST(5.0)/RCONST(8.0); + B->c[4] = RCONST(26.0)/RCONST(25.0); + B->c[5] = RCONST(1.0); + + B->b[0] = (RCONST(1181.0)-RCONST(987.0)*SUNRsqrt(RCONST(2.0)))/RCONST(13782.0); + B->b[1] = (RCONST(1181.0)-RCONST(987.0)*SUNRsqrt(RCONST(2.0)))/RCONST(13782.0); + B->b[2] = RCONST(47.0)*(-RCONST(267.0)+RCONST(1783.0)*SUNRsqrt(RCONST(2.0)))/RCONST(273343.0); + B->b[3] = -RCONST(16.0)*(-RCONST(22922.0)+RCONST(3525.0)*SUNRsqrt(RCONST(2.0)))/RCONST(571953.0); + B->b[4] = -RCONST(15625.0)*(RCONST(97.0)+RCONST(376.0)*SUNRsqrt(RCONST(2.0)))/RCONST(90749876.0); + B->b[5] = RCONST(1.0)/RCONST(4.0); + + B->d[0] = -RCONST(480923228411.0)/RCONST(4982971448372.0); + B->d[1] = -RCONST(480923228411.0)/RCONST(4982971448372.0); + B->d[2] = RCONST(6709447293961.0)/RCONST(12833189095359.0); + B->d[3] = RCONST(3513175791894.0)/RCONST(6748737351361.0); + B->d[4] = -RCONST(498863281070.0)/RCONST(6042575550617.0); + B->d[5] = RCONST(2077005547802.0)/RCONST(8945017530137.0); + + B->A[1][1] = RCONST(0.25); + B->A[2][1] = (RCONST(1.0)-SUNRsqrt(RCONST(2.0)))/RCONST(8.0); + B->A[2][2] = RCONST(0.25); + B->A[3][1] = (RCONST(5.0)-RCONST(7.0)*SUNRsqrt(RCONST(2.0)))/RCONST(64.0); + B->A[3][2] = RCONST(7.0)*(RCONST(1.0)+SUNRsqrt(RCONST(2.0)))/RCONST(32.0); + B->A[3][3] = RCONST(0.25); + B->A[4][1] = -(RCONST(13796.0)+RCONST(54539.0)*SUNRsqrt(RCONST(2.0)))/RCONST(125000.0); + B->A[4][2] = (RCONST(506605.0)+RCONST(132109.0)*SUNRsqrt(RCONST(2.0)))/RCONST(437500.0); + B->A[4][3] = RCONST(166.0)*(-RCONST(97.0)+RCONST(376.0)*SUNRsqrt(RCONST(2.0)))/RCONST(109375.0); + B->A[4][4] = RCONST(0.25); + B->A[5][0] = B->b[0]; + B->A[5][1] = B->b[1]; + B->A[5][2] = B->b[2]; + B->A[5][3] = B->b[3]; + B->A[5][4] = B->b[4]; + B->A[5][5] = B->b[5]; + B->A[1][0] = B->c[1] - B->A[1][1]; + B->A[2][0] = B->c[2] - B->A[2][1] - B->A[2][2]; + B->A[3][0] = B->c[3] - B->A[3][1] - B->A[3][2] - B->A[3][3]; + B->A[4][0] = B->c[4] - B->A[4][1] - B->A[4][2] - B->A[4][3] - B->A[4][4]; + return B; + }) + ARK_BUTCHER_TABLE(ARKODE_SDIRK_5_3_4, { /* SDIRK-5-4 */ ARKodeButcherTable B = ARKodeButcherTable_Alloc(5, SUNTRUE); B->q = 4; @@ -765,54 +813,6 @@ ARK_BUTCHER_TABLE(ARKODE_ESDIRK32I5L2SA_5_2_3, { /* ESDIRK3(2I)5L[2]SA (A,L stab return B; }) -ARK_BUTCHER_TABLE(ARKODE_ESDIRK436L2SA_6_3_4, { /* ESDIRK4(3)6L[2]SA (A,L stable) */ - ARKodeButcherTable B = ARKodeButcherTable_Alloc(6, SUNTRUE); - B->q = 4; - B->p = 3; - - B->c[1] = RCONST(0.5); - B->c[2] = (RCONST(2.0)-SUNRsqrt(RCONST(2.0)))/RCONST(4.0); - B->c[3] = RCONST(5.0)/RCONST(8.0); - B->c[4] = RCONST(26.0)/RCONST(25.0); - B->c[5] = RCONST(1.0); - - B->b[0] = (RCONST(1181.0)-RCONST(987.0)*SUNRsqrt(RCONST(2.0)))/RCONST(13782.0); - B->b[1] = (RCONST(1181.0)-RCONST(987.0)*SUNRsqrt(RCONST(2.0)))/RCONST(13782.0); - B->b[2] = RCONST(47.0)*(-RCONST(267.0)+RCONST(1783.0)*SUNRsqrt(RCONST(2.0)))/RCONST(273343.0); - B->b[3] = -RCONST(16.0)*(-RCONST(22922.0)+RCONST(3525.0)*SUNRsqrt(RCONST(2.0)))/RCONST(571953.0); - B->b[4] = -RCONST(15625.0)*(RCONST(97.0)+RCONST(376.0)*SUNRsqrt(RCONST(2.0)))/RCONST(90749876.0); - B->b[5] = RCONST(1.0)/RCONST(4.0); - - B->d[0] = -RCONST(480923228411.0)/RCONST(4982971448372.0); - B->d[1] = -RCONST(480923228411.0)/RCONST(4982971448372.0); - B->d[2] = RCONST(6709447293961.0)/RCONST(12833189095359.0); - B->d[3] = RCONST(3513175791894.0)/RCONST(6748737351361.0); - B->d[4] = -RCONST(498863281070.0)/RCONST(6042575550617.0); - B->d[5] = RCONST(2077005547802.0)/RCONST(8945017530137.0); - - B->A[1][1] = RCONST(0.25); - B->A[2][1] = (RCONST(1.0)-SUNRsqrt(RCONST(2.0)))/RCONST(8.0); - B->A[2][2] = RCONST(0.25); - B->A[3][1] = (RCONST(5.0)-RCONST(7.0)*SUNRsqrt(RCONST(2.0)))/RCONST(64.0); - B->A[3][2] = RCONST(7.0)*(RCONST(1.0)+SUNRsqrt(RCONST(2.0)))/RCONST(32.0); - B->A[3][3] = RCONST(0.25); - B->A[4][1] = -(RCONST(13796.0)+RCONST(54539.0)*SUNRsqrt(RCONST(2.0)))/RCONST(125000.0); - B->A[4][2] = (RCONST(506605.0)+RCONST(132109.0)*SUNRsqrt(RCONST(2.0)))/RCONST(437500.0); - B->A[4][3] = RCONST(166.0)*(-RCONST(97.0)+RCONST(376.0)*SUNRsqrt(RCONST(2.0)))/RCONST(109375.0); - B->A[4][4] = RCONST(0.25); - B->A[5][0] = B->b[0]; - B->A[5][1] = B->b[1]; - B->A[5][2] = B->b[2]; - B->A[5][3] = B->b[3]; - B->A[5][4] = B->b[4]; - B->A[5][5] = B->b[5]; - B->A[1][0] = B->c[1] - B->A[1][1]; - B->A[2][0] = B->c[2] - B->A[2][1] - B->A[2][2]; - B->A[3][0] = B->c[3] - B->A[3][1] - B->A[3][2] - B->A[3][3]; - B->A[4][0] = B->c[4] - B->A[4][1] - B->A[4][2] - B->A[4][3] - B->A[4][4]; - return B; - }) - ARK_BUTCHER_TABLE(ARKODE_ESDIRK43I6L2SA_6_3_4, { /* ESDIRK4(3I)6L[2]SA (A,L stable) */ ARKodeButcherTable B = ARKodeButcherTable_Alloc(6, SUNTRUE); B->q = 4; diff --git a/src/arkode/arkode_butcher_erk.def b/src/arkode/arkode_butcher_erk.def index f25fafb830..5cfb3f2af6 100644 --- a/src/arkode/arkode_butcher_erk.def +++ b/src/arkode/arkode_butcher_erk.def @@ -41,6 +41,7 @@ ARKODE_HEUN_EULER_2_1_2 Y ARKODE_BOGACKI_SHAMPINE_4_2_3 Y ARKODE_ARK324L2SA_ERK_4_2_3* N + ARKODE_SOFRONIOU_SPALETTA_5_3_4 Y ARKODE_ZONNEVELD_5_3_4 Y ARKODE_ARK436L2SA_ERK_6_3_4* N ARKODE_ARK437L2SA_ERK_7_3_4* N @@ -165,6 +166,39 @@ ARK_BUTCHER_TABLE(ARKODE_ARK324L2SA_ERK_4_2_3, { /* ARK3(2)4L[2]SA-ERK */ return B; }) +ARK_BUTCHER_TABLE(ARKODE_SOFRONIOU_SPALETTA_5_3_4, { /* Sofroniou-Spaletta-ERK */ + ARKodeButcherTable B = ARKodeButcherTable_Alloc(5, SUNTRUE); + B->q = 4; + B->p = 3; + B->A[1][0] = RCONST(2.0) / RCONST(5.0); + B->A[2][0] = RCONST(-3.0) / RCONST(20.0); + B->A[2][1] = RCONST(3.0) / RCONST(4.0); + B->A[3][0] = RCONST(19.0)/RCONST(44.0); + B->A[3][1] = RCONST(-15.0)/RCONST(44.0); + B->A[3][2] = RCONST(10.0)/RCONST(11.0); + B->A[4][0] = RCONST(11.0)/RCONST(72.0); + B->A[4][1] = RCONST(25.0)/RCONST(72.0); + B->A[4][2] = RCONST(25.0)/RCONST(72.0); + B->A[4][3] = RCONST(11.0)/RCONST(72.0); + + B->b[0] = RCONST(11.0)/RCONST(72.0); + B->b[1] = RCONST(25.0)/RCONST(72.0); + B->b[2] = RCONST(25.0)/RCONST(72.0); + B->b[3] = RCONST(11.0)/RCONST(72.0); + + B->d[0] = RCONST(1251515.0)/RCONST(8970912.0); + B->d[1] = RCONST(3710105.0)/RCONST(8970912.0); + B->d[2] = RCONST(2519695.0)/RCONST(8970912.0); + B->d[3] = RCONST(61105.0)/RCONST(8970912.0); + B->d[4] = RCONST(119041.0)/RCONST(747576.0); + + B->c[1] = RCONST(2.0) / RCONST(5.0); + B->c[2] = RCONST(3.0) / RCONST(5.0); + B->c[3] = RCONST(1.0); + B->c[4] = RCONST(1.0); + return B; + }) + ARK_BUTCHER_TABLE(ARKODE_ZONNEVELD_5_3_4, { /* Zonneveld */ ARKodeButcherTable B = ARKodeButcherTable_Alloc(5, SUNTRUE); B->q = 4; diff --git a/src/arkode/arkode_erkstep.c b/src/arkode/arkode_erkstep.c index f21aa2602b..8fcbd344dd 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->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..48fcdf61eb 100644 --- a/src/arkode/arkode_erkstep_io.c +++ b/src/arkode/arkode_erkstep_io.c @@ -53,10 +53,6 @@ int ERKStepSetMaxHnilWarns(void *arkode_mem, int mxhnil) { return(arkSetMaxHnilWarns(arkode_mem, mxhnil)); } int ERKStepSetInitStep(void *arkode_mem, realtype hin) { return(arkSetInitStep(arkode_mem, hin)); } -int ERKStepSetMinStep(void *arkode_mem, realtype hmin) { - return(arkSetMinStep(arkode_mem, hmin)); } -int ERKStepSetMaxStep(void *arkode_mem, realtype hmax) { - return(arkSetMaxStep(arkode_mem, hmax)); } int ERKStepSetStopTime(void *arkode_mem, realtype tstop) { return(arkSetStopTime(arkode_mem, tstop)); } int ERKStepSetInterpolateStopTime(void *arkode_mem, @@ -78,35 +74,14 @@ int ERKStepSetPostprocessStepFn(void *arkode_mem, int ERKStepSetPostprocessStageFn(void *arkode_mem, ARKPostProcessFn ProcessStage) { return(arkSetPostprocessStageFn(arkode_mem, ProcessStage)); } -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) { - 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) { - return(arkSetMaxEFailGrowth(arkode_mem, etamxf)); } -int ERKStepSetSmallNumEFails(void *arkode_mem, int small_nef) { - return(arkSetSmallNumEFails(arkode_mem, small_nef)); } -int ERKStepSetStabilityFn(void *arkode_mem, ARKExpStabFn EStab, void *estab_data) { - return(arkSetStabilityFn(arkode_mem, EStab, estab_data)); } 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)); } +int ERKStepSetTimestepHeuristics(void *arkode_mem, SUNTimestepHeuristics H) { + return(arkSetTimestepHeuristics(arkode_mem, H)); } /*=============================================================== @@ -142,10 +117,6 @@ int ERKStepGetStepStats(void *arkode_mem, long int *nsteps, return(arkGetStepStats(arkode_mem, nsteps, hinused, hlast, hcur, tcur)); } int ERKStepGetNumConstrFails(void *arkode_mem, long int *nconstrfails) { return(arkGetNumConstrFails(arkode_mem, nconstrfails)); } -int ERKStepGetNumExpSteps(void *arkode_mem, long int *nsteps) { - return(arkGetNumExpSteps(arkode_mem, nsteps)); } -int ERKStepGetNumAccSteps(void *arkode_mem, long int *nsteps) { - return(arkGetNumAccSteps(arkode_mem, nsteps)); } int ERKStepGetNumErrTestFails(void *arkode_mem, long int *netfails) { return(arkGetNumErrTestFails(arkode_mem, netfails)); } int ERKStepGetUserData(void *arkode_mem, void** user_data) { @@ -234,6 +205,244 @@ int ERKStepGetNumRelaxSolveIters(void* arkode_mem, long int* iters) return arkRelaxGetNumRelaxSolveIters(arkode_mem, iters); } +/*=============================================================== + DEPRECATED ERKStep optional input/output functions + ===============================================================*/ + +/*--------------------------------------------------------------- + ERKStepSetMinStep: user should create/attach a + SUNTimestepHeuristics object, and set this directly therein. + ---------------------------------------------------------------*/ +int ERKStepSetMinStep(void *arkode_mem, realtype hmin) +{ + int retval; + ARKodeMem ark_mem; + if (arkode_mem==NULL) { + arkProcessError(NULL, ARK_MEM_NULL, "ERKStep", + "ERKStepSetMinStep", MSG_ARK_NO_MEM); + return(ARK_MEM_NULL); + } + ark_mem = (ARKodeMem) arkode_mem; + retval = SUNTimestepHeuristics_SetMinStep(ark_mem->hconstraints, hmin); + if (retval != SUNTIMESTEPHEURISTICS_SUCCESS) { return(ARK_ILL_INPUT); } + return(ARK_SUCCESS); +} + +/*--------------------------------------------------------------- + ERKStepSetMaxStep: user should create/attach a + SUNTimestepHeuristics object, and set this directly therein. + ---------------------------------------------------------------*/ +int ERKStepSetMaxStep(void *arkode_mem, realtype hmax) +{ + int retval; + ARKodeMem ark_mem; + if (arkode_mem==NULL) { + arkProcessError(NULL, ARK_MEM_NULL, "ERKStep", + "ERKStepSetMaxStep", MSG_ARK_NO_MEM); + return(ARK_MEM_NULL); + } + ark_mem = (ARKodeMem) arkode_mem; + retval = SUNTimestepHeuristics_SetMaxStep(ark_mem->hconstraints, hmax); + if (retval != SUNTIMESTEPHEURISTICS_SUCCESS) { return(ARK_ILL_INPUT); } + return(ARK_SUCCESS); +} + +/*--------------------------------------------------------------- + ERKStepSetCFLFraction: user should create/attach a + SUNTimestepHeuristics object, and set this directly therein. + ---------------------------------------------------------------*/ +int ERKStepSetCFLFraction(void *arkode_mem, realtype cfl_frac) +{ + int retval; + ARKodeMem ark_mem; + if (arkode_mem==NULL) { + arkProcessError(NULL, ARK_MEM_NULL, "ERKStep", + "ERKStepSetCFLFraction", MSG_ARK_NO_MEM); + return(ARK_MEM_NULL); + } + ark_mem = (ARKodeMem) arkode_mem; + retval = SUNTimestepHeuristics_SetCFLFraction(ark_mem->hconstraints, cfl_frac); + if (retval != SUNTIMESTEPHEURISTICS_SUCCESS) { return(ARK_ILL_INPUT); } + return(ARK_SUCCESS); +} + +/*--------------------------------------------------------------- + ERKStepSetSafetyFactor: user should create/attach a + SUNTimestepHeuristics object, and set this directly therein. + ---------------------------------------------------------------*/ +int ERKStepSetSafetyFactor(void *arkode_mem, realtype safety) +{ + int retval; + ARKodeMem ark_mem; + if (arkode_mem==NULL) { + arkProcessError(NULL, ARK_MEM_NULL, "ERKStep", + "ERKStepSetSafetyFactor", MSG_ARK_NO_MEM); + return(ARK_MEM_NULL); + } + ark_mem = (ARKodeMem) arkode_mem; + retval = SUNTimestepHeuristics_SetSafetyFactor(ark_mem->hconstraints, safety); + if (retval != SUNTIMESTEPHEURISTICS_SUCCESS) { return(ARK_ILL_INPUT); } + return(ARK_SUCCESS); +} + +/*--------------------------------------------------------------- + ERKStepSetErrorBias: user should create/attach a + SUNAdaptController object, and set this directly therein. + ---------------------------------------------------------------*/ +int ERKStepSetErrorBias(void *arkode_mem, realtype bias) +{ + int retval; + ARKodeMem ark_mem; + if (arkode_mem==NULL) { + arkProcessError(NULL, ARK_MEM_NULL, "ERKStep", + "ERKStepSetErrorBias", MSG_ARK_NO_MEM); + return(ARK_MEM_NULL); + } + ark_mem = (ARKodeMem) arkode_mem; + retval = SUNAdaptController_SetErrorBias(ark_mem->hcontroller, bias); + if (retval != SUNADAPTCONTROLLER_SUCCESS) { return(ARK_ILL_INPUT); } + return(ARK_SUCCESS); +} + +/*--------------------------------------------------------------- + ERKStepSetMaxGrowth: user should create/attach a + SUNTimestepHeuristics object, and set this directly therein. + ---------------------------------------------------------------*/ +int ERKStepSetMaxGrowth(void *arkode_mem, realtype mx_growth) +{ + int retval; + ARKodeMem ark_mem; + if (arkode_mem==NULL) { + arkProcessError(NULL, ARK_MEM_NULL, "ERKStep", + "ERKStepSetMaxGrowth", MSG_ARK_NO_MEM); + return(ARK_MEM_NULL); + } + ark_mem = (ARKodeMem) arkode_mem; + retval = SUNTimestepHeuristics_SetMaxGrowth(ark_mem->hconstraints, mx_growth); + if (retval != SUNTIMESTEPHEURISTICS_SUCCESS) { return(ARK_ILL_INPUT); } + return(ARK_SUCCESS); +} + +/*--------------------------------------------------------------- + ERKStepSetMinReduction: user should create/attach a + SUNTimestepHeuristics object, and set this directly therein. + ---------------------------------------------------------------*/ +int ERKStepSetMinReduction(void *arkode_mem, realtype eta_min) +{ + int retval; + ARKodeMem ark_mem; + if (arkode_mem==NULL) { + arkProcessError(NULL, ARK_MEM_NULL, "ERKStep", + "ERKStepSetMinReduction", MSG_ARK_NO_MEM); + return(ARK_MEM_NULL); + } + ark_mem = (ARKodeMem) arkode_mem; + retval = SUNTimestepHeuristics_SetMinReduction(ark_mem->hconstraints, eta_min); + if (retval != SUNTIMESTEPHEURISTICS_SUCCESS) { return(ARK_ILL_INPUT); } + return(ARK_SUCCESS); +} + +/*--------------------------------------------------------------- + ERKStepSetFixedStepBounds: user should create/attach a + SUNTimestepHeuristics object, and set this directly therein. + ---------------------------------------------------------------*/ +int ERKStepSetFixedStepBounds(void *arkode_mem, realtype lb, realtype ub) +{ + int retval; + ARKodeMem ark_mem; + if (arkode_mem==NULL) { + arkProcessError(NULL, ARK_MEM_NULL, "ERKStep", + "ERKStepSetFixedStepBounds", MSG_ARK_NO_MEM); + return(ARK_MEM_NULL); + } + ark_mem = (ARKodeMem) arkode_mem; + retval = SUNTimestepHeuristics_SetFixedStepBounds(ark_mem->hconstraints, lb, ub); + if (retval != SUNTIMESTEPHEURISTICS_SUCCESS) { return(ARK_ILL_INPUT); } + return(ARK_SUCCESS); +} + +/*--------------------------------------------------------------- + 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)); } + +/*--------------------------------------------------------------- + ERKStepSetMaxFirstGrowth: user should create/attach a + SUNTimestepHeuristics object, and set this directly therein. + ---------------------------------------------------------------*/ +int ERKStepSetMaxFirstGrowth(void *arkode_mem, realtype etamx1) +{ + int retval; + ARKodeMem ark_mem; + if (arkode_mem==NULL) { + arkProcessError(NULL, ARK_MEM_NULL, "ERKStep", + "ERKStepSetMaxFirstGrowth", MSG_ARK_NO_MEM); + return(ARK_MEM_NULL); + } + ark_mem = (ARKodeMem) arkode_mem; + retval = SUNTimestepHeuristics_SetMaxFirstGrowth(ark_mem->hconstraints, etamx1); + if (retval != SUNTIMESTEPHEURISTICS_SUCCESS) { return(ARK_ILL_INPUT); } + return(ARK_SUCCESS); +} + +/*--------------------------------------------------------------- + ERKStepSetMaxEFailGrowth: user should create/attach a + SUNTimestepHeuristics object, and set this directly therein. + ---------------------------------------------------------------*/ +int ERKStepSetMaxEFailGrowth(void *arkode_mem, realtype etamxf) +{ + int retval; + ARKodeMem ark_mem; + if (arkode_mem==NULL) { + arkProcessError(NULL, ARK_MEM_NULL, "ERKStep", + "ERKStepSetMaxEFailGrowth", MSG_ARK_NO_MEM); + return(ARK_MEM_NULL); + } + ark_mem = (ARKodeMem) arkode_mem; + retval = SUNTimestepHeuristics_SetMaxEFailGrowth(ark_mem->hconstraints, etamxf); + if (retval != SUNTIMESTEPHEURISTICS_SUCCESS) { return(ARK_ILL_INPUT); } + return(ARK_SUCCESS); +} + +/*--------------------------------------------------------------- + ERKStepSetSmallNumEFails: user should create/attach a + SUNTimestepHeuristics object, and set this directly therein. + ---------------------------------------------------------------*/ +int ERKStepSetSmallNumEFails(void *arkode_mem, int small_nef) +{ + int retval; + ARKodeMem ark_mem; + if (arkode_mem==NULL) { + arkProcessError(NULL, ARK_MEM_NULL, "ERKStep", + "ERKStepSetSmallNumEFails", MSG_ARK_NO_MEM); + return(ARK_MEM_NULL); + } + ark_mem = (ARKodeMem) arkode_mem; + retval = SUNTimestepHeuristics_SetSmallNumEFails(ark_mem->hconstraints, small_nef); + if (retval != SUNTIMESTEPHEURISTICS_SUCCESS) { return(ARK_ILL_INPUT); } + return(ARK_SUCCESS); +} + +/*--------------------------------------------------------------- + ERKStepSetStabilityFn: user should create/attach a + SUNTimestepHeuristics object, and set this directly therein. + ---------------------------------------------------------------*/ +int ERKStepSetStabilityFn(void *arkode_mem, ARKExpStabFn EStab, void *estab_data) { + return(arkSetStabilityFn(arkode_mem, EStab, estab_data)); } + + + + /*=============================================================== ERKStep optional input functions -- stepper-specific ===============================================================*/ @@ -250,6 +459,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 +475,76 @@ int ERKStepSetDefaults(void* arkode_mem) return(retval); } + /* Remove current SUNTimestepHeuristics object, and replace with "Default" */ + retval = SUNTimestepHeuristics_Space(ark_mem->hconstraints, &lenrw, &leniw); + if (retval == SUNTIMESTEPHEURISTICS_SUCCESS) { + ark_mem->liw -= leniw; + ark_mem->lrw -= lenrw; + } + if (ark_mem->ownconstraints) { + retval = SUNTimestepHeuristics_Destroy(ark_mem->hconstraints); + if (retval != SUNTIMESTEPHEURISTICS_SUCCESS) { + arkProcessError(ark_mem, ARK_MEM_FAIL, "ARKODE", "ERKStepSetDefaults", + "SUNTimestepHeuristics_Destroy failure"); + return(ARK_MEM_FAIL); + } + } + ark_mem->hconstraints = NULL; + ark_mem->hconstraints = SUNTimestepHeuristics_Default(ark_mem->sunctx); + if (ark_mem->hconstraints == NULL) { + arkProcessError(ark_mem, ARK_MEM_FAIL, "ARKODE::ERKStep", + "ERKStepSetDefaults", + "SUNTimestepHeuristics_Default allocation failure"); + return(ARK_MEM_FAIL); + } + ark_mem->ownconstraints = SUNTRUE; + retval = SUNTimestepHeuristics_Space(ark_mem->hconstraints, &lenrw, &leniw); + if (retval == SUNTIMESTEPHEURISTICS_SUCCESS) { + ark_mem->liw += leniw; + ark_mem->lrw += lenrw; + } + + /* Remove current SUNAdaptController object, and replace with "PI" */ + retval = SUNAdaptController_Space(ark_mem->hcontroller, &lenrw, &leniw); + if (retval == SUNADAPTCONTROLLER_SUCCESS) { + ark_mem->liw -= leniw; + ark_mem->lrw -= lenrw; + } + if (ark_mem->owncontroller) { + retval = SUNAdaptController_Destroy(ark_mem->hcontroller); + if (retval != SUNADAPTCONTROLLER_SUCCESS) { + arkProcessError(ark_mem, ARK_MEM_FAIL, "ARKODE", "ERKStepSetDefaults", + "SUNAdaptController_Destroy failure"); + return(ARK_MEM_FAIL); + } + } + ark_mem->hcontroller = NULL; + ark_mem->hcontroller = SUNAdaptController_PI(ark_mem->sunctx); + if (ark_mem->hcontroller == NULL) { + arkProcessError(ark_mem, ARK_MEM_FAIL, "ARKODE::ERKStep", + "ERKStepSetDefaults", + "SUNAdaptControllerPI allocation failure"); + return(ARK_MEM_FAIL); + } + ark_mem->owncontroller = SUNTRUE; + retval = SUNAdaptController_Space(ark_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 */ - 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->hcontroller, RCONST(1.2)); + (void) SUNAdaptController_SetParams_PI(ark_mem->hcontroller, SUNFALSE, + RCONST(0.8), RCONST(0.31)); + (void) SUNTimestepHeuristics_SetSafetyFactor(ark_mem->hconstraints, RCONST(0.99)); + (void) SUNTimestepHeuristics_SetMaxEFailGrowth(ark_mem->hconstraints, RCONST(0.3)); + (void) SUNTimestepHeuristics_SetMaxGrowth(ark_mem->hconstraints, RCONST(25.0)); return(ARK_SUCCESS); } @@ -546,15 +813,62 @@ int ERKStepGetTimestepperStats(void *arkode_mem, long int *expsteps, &ark_mem, &step_mem); if (retval != ARK_SUCCESS) return(retval); - /* set expsteps and accsteps from adaptivity structure */ - *expsteps = ark_mem->hadapt_mem->nst_exp; - *accsteps = ark_mem->hadapt_mem->nst_acc; - - /* set remaining outputs */ + /* set integrator outputs */ *attempts = ark_mem->nst_attempts; *fevals = step_mem->nfe; *netfails = ark_mem->netf; + /* get expsteps and accsteps from heuristics object */ + retval = SUNTimestepHeuristics_GetNumExpSteps(ark_mem->hconstraints, expsteps); + if (retval != SUNTIMESTEPHEURISTICS_SUCCESS) { return(ARK_HEURISTICS_ERR); } + retval = SUNTimestepHeuristics_GetNumAccSteps(ark_mem->hconstraints, accsteps); + if (retval != SUNTIMESTEPHEURISTICS_SUCCESS) { return(ARK_HEURISTICS_ERR); } + + return(ARK_SUCCESS); +} + + +/*--------------------------------------------------------------- + ERKStepGetNumExpSteps: + + Returns the current number of stability-limited steps. + + This is a convenience routine, that merely calls + SUNTimestepHeuristics_GetNumExpSteps for the result. + ---------------------------------------------------------------*/ +int ERKStepGetNumExpSteps(void *arkode_mem, long int *nsteps) +{ + ARKodeMem ark_mem; + if (arkode_mem==NULL) { + arkProcessError(NULL, ARK_MEM_NULL, "ERKStep", + "ERKStepGetNumExpSteps", MSG_ARK_NO_MEM); + return(ARK_MEM_NULL); + } + ark_mem = (ARKodeMem) arkode_mem; + if (SUNTimestepHeuristics_GetNumExpSteps(ark_mem->hconstraints, nsteps) + != SUNTIMESTEPHEURISTICS_SUCCESS) { return(ARK_HEURISTICS_ERR); } + return(ARK_SUCCESS); +} + +/*--------------------------------------------------------------- + ERKStepGetNumAccSteps: + + Returns the current number of accuracy-limited steps. + + This is a convenience routine, that merely calls + SUNTimestepHeuristics_GetNumAccSteps for the result. + ---------------------------------------------------------------*/ +int ERKStepGetNumAccSteps(void *arkode_mem, long int *nsteps) +{ + ARKodeMem ark_mem; + if (arkode_mem==NULL) { + arkProcessError(NULL, ARK_MEM_NULL, "ERKStep", + "ERKStepGetNumAccSteps", MSG_ARK_NO_MEM); + return(ARK_MEM_NULL); + } + ark_mem = (ARKodeMem) arkode_mem; + if (SUNTimestepHeuristics_GetNumAccSteps(ark_mem->hconstraints, nsteps) + != SUNTIMESTEPHEURISTICS_SUCCESS) { return(ARK_HEURISTICS_ERR); } return(ARK_SUCCESS); } diff --git a/src/arkode/arkode_impl.h b/src/arkode/arkode_impl.h index 32c73219ee..1742536b93 100644 --- a/src/arkode/arkode_impl.h +++ b/src/arkode/arkode_impl.h @@ -23,13 +23,13 @@ #include #include #include -#include -#include - #include "arkode_types_impl.h" -#include "arkode_adapt_impl.h" #include "arkode_relaxation_impl.h" #include "arkode_root_impl.h" +#include +#include +#include +#include #include "sundials_context_impl.h" #include "sundials_logger_impl.h" @@ -253,6 +253,25 @@ int arkInterpEvaluate(void* arkode_mem, ARKInterp interp, realtype tau, int d, int order, N_Vector yout); +/* ======================================================================= + * User-provided stability function wrapper structure and utility routines + * ======================================================================= */ + +struct ARKUserStabilityDataMem { + ARKExpStabFn EStab; /* user-provided stability function */ + void* estab_data; /* user-provided data pointer */ + void* arkode_mem; /* ARKODE time-stepper memory */ +}; + +typedef struct ARKUserStabilityDataMem *ARKUserStabilityData; + +void* ARKUserStability(void* arkode_mem, ARKExpStabFn EStab, + void* estab_data); + +void ARKUserStability_Free(void* sdata); + +int ARKControlExpStab(realtype *hstab, void* user_data); + /*=============================================================== ARKODE data structures ===============================================================*/ @@ -355,8 +374,6 @@ struct ARKodeMemRec /* Time step data */ realtype hin; /* initial step size */ realtype h; /* current step size */ - realtype hmin; /* |h| >= hmin */ - realtype hmax_inv; /* |h| <= 1/hmax_inv */ realtype hprime; /* next actual step size to be used */ realtype next_h; /* next dynamical step size (only used in getCurrentStep); note that this could @@ -366,7 +383,10 @@ struct ARKodeMemRec (changes with each stage) */ realtype tretlast; /* value of tret last returned by ARKODE */ booleantype fixedstep; /* flag to disable temporal adaptivity */ - ARKodeHAdaptMem hadapt_mem; /* time step adaptivity structure */ + SUNAdaptController hcontroller; /* temporal error controller */ + booleantype owncontroller; /* flag indicating hcontroller ownership */ + SUNTimestepHeuristics hconstraints; /* time step constraint heuristics */ + booleantype ownconstraints; /* flag indicating hconstraints ownership */ /* Limits and various solver parameters */ @@ -977,9 +997,9 @@ int arkCheckConvergence(ARKodeMem ark_mem, int *nflagPtr, int *ncfPtr); int arkCheckConstraints(ARKodeMem ark_mem, int *nflag, int *constrfails); int arkCheckTemporalError(ARKodeMem ark_mem, int *nflagPtr, int *nefPtr, realtype dsm); -int arkAccessHAdaptMem(void* arkode_mem, const char *fname, - ARKodeMem *ark_mem, ARKodeHAdaptMem *hadapt_mem); +int arkSetAdaptController(void *arkode_mem, SUNAdaptController C); +int arkSetTimestepHeuristics(void *arkode_mem, SUNTimestepHeuristics H); 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..9ffdf21b87 100644 --- a/src/arkode/arkode_io.c +++ b/src/arkode/arkode_io.c @@ -23,8 +23,16 @@ #include "arkode_impl.h" #include "arkode_interp_impl.h" +#include "arkode_user_controller.h" #include #include +#include +#include +#include +#include +#include +#include +#include /*=============================================================== @@ -43,6 +51,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 +60,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 */ @@ -78,33 +87,20 @@ int arkSetDefaults(void *arkode_mem) ark_mem->maxncf = MAXNCF; /* max convergence fails */ ark_mem->maxconstrfails = MAXCONSTRFAILS; /* max number of constraint fails */ ark_mem->hin = ZERO; /* determine initial step on-the-fly */ - ark_mem->hmin = ZERO; /* no minimum step size */ - ark_mem->hmax_inv = ZERO; /* no maximum step size */ ark_mem->tstopset = SUNFALSE; /* no stop time set */ ark_mem->tstopinterp = SUNFALSE; /* copy at stop time */ ark_mem->tstop = ZERO; /* no fixed stop time */ ark_mem->diagfp = NULL; /* no solver diagnostics file */ ark_mem->report = SUNFALSE; /* don't report solver diagnostics */ - ark_mem->hadapt_mem->etamx1 = ETAMX1; /* max change on first step */ - ark_mem->hadapt_mem->etamxf = ETAMXF; /* max change on error-failed step */ - 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->hcontroller); + if (retval != SUNADAPTCONTROLLER_SUCCESS) { return(ARK_CONTROLLER_ERR); } + + /* Set default values for heuristics object */ + retval = SUNTimestepHeuristics_SetDefaults(ark_mem->hconstraints); + if (retval != SUNTIMESTEPHEURISTICS_SUCCESS) { return(ARK_HEURISTICS_ERR); } + return(ARK_SUCCESS); } @@ -330,158 +326,207 @@ int arkSetDiagnostics(void *arkode_mem, FILE *diagfp) /*--------------------------------------------------------------- - arkSetMaxNumSteps: + arkSetAdaptController: - Specifies the maximum number of integration steps + Specifies a non-default SUNAdaptController time step controller + object. If a NULL-valued SUNAdaptController is input, the + default will be re-enabled. ---------------------------------------------------------------*/ -int arkSetMaxNumSteps(void *arkode_mem, long int mxsteps) +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", - "arkSetMaxNumSteps", MSG_ARK_NO_MEM); + "arkSetAdaptController", MSG_ARK_NO_MEM); return(ARK_MEM_NULL); } ark_mem = (ARKodeMem) arkode_mem; - /* Passing mxsteps=0 sets the default. Passing mxsteps<0 disables the test. */ - if (mxsteps == 0) - ark_mem->mxstep = MXSTEP_DEFAULT; - else - ark_mem->mxstep = mxsteps; + /* Remove current SUNAdaptController object + (delete if owned, and then nullify pointer) */ + retval = SUNAdaptController_Space(ark_mem->hcontroller, &lenrw, &leniw); + if (retval == SUNADAPTCONTROLLER_SUCCESS) { + ark_mem->liw -= leniw; + ark_mem->lrw -= lenrw; + } + if (ark_mem->owncontroller) { + retval = SUNAdaptController_Destroy(ark_mem->hcontroller); + if (retval != SUNADAPTCONTROLLER_SUCCESS) { + arkProcessError(ark_mem, ARK_MEM_FAIL, "ARKODE", "arkSetAdaptController", + "SUNAdaptController_Destroy failure"); + return(ARK_MEM_FAIL); + } + } + ark_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->owncontroller = SUNTRUE; + } else { + ark_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->hcontroller = C; return(ARK_SUCCESS); } /*--------------------------------------------------------------- - arkSetMaxHnilWarns: + arkSetTimestepHeuristics: - Specifies the maximum number of warnings for small h + Specifies a non-default SUNTimestepHeuristics time step constraints + object. If a NULL-valued SUNTimestepHeuristics is input, the default + will be re-enabled. ---------------------------------------------------------------*/ -int arkSetMaxHnilWarns(void *arkode_mem, int mxhnil) +int arkSetTimestepHeuristics(void *arkode_mem, SUNTimestepHeuristics H) { + int retval; + long int lenrw, leniw; ARKodeMem ark_mem; if (arkode_mem==NULL) { arkProcessError(NULL, ARK_MEM_NULL, "ARKODE", - "arkSetMaxHnilWarns", MSG_ARK_NO_MEM); + "arkSetTimestepHeuristics", MSG_ARK_NO_MEM); return(ARK_MEM_NULL); } ark_mem = (ARKodeMem) arkode_mem; - /* Passing mxhnil=0 sets the default, otherwise use input. */ - if (mxhnil == 0) { - ark_mem->mxhnil = 10; + /* Remove current SUNTimestepHeuristics object + (delete if owned, and then nullify pointer) */ + retval = SUNTimestepHeuristics_Space(ark_mem->hconstraints, &lenrw, &leniw); + if (retval == SUNTIMESTEPHEURISTICS_SUCCESS) { + ark_mem->liw -= leniw; + ark_mem->lrw -= lenrw; + } + if (ark_mem->ownconstraints) { + retval = SUNTimestepHeuristics_Destroy(ark_mem->hconstraints); + if (retval != SUNTIMESTEPHEURISTICS_SUCCESS) { + arkProcessError(ark_mem, ARK_MEM_FAIL, "ARKODE", "arkSetTimestepHeuristics", + "SUNTimestepHeuristics_Destroy failure"); + return(ARK_MEM_FAIL); + } + } + ark_mem->hconstraints = NULL; + + /* On NULL-valued input, create default SUNTimestepHeuristics object */ + if (H == NULL) { + H = SUNTimestepHeuristics_Default(ark_mem->sunctx); + if (H == NULL) { + arkProcessError(ark_mem, ARK_MEM_FAIL, "ARKODE", "arkSetTimestepHeuristics", + "SUNTimestepHeuristics_Default allocation failure"); + return(ARK_MEM_FAIL); + } + ark_mem->ownconstraints = SUNTRUE; } else { - ark_mem->mxhnil = mxhnil; + ark_mem->ownconstraints = SUNFALSE; } + /* Attach new SUNTimestepHeuristics object */ + retval = SUNTimestepHeuristics_Space(H, &lenrw, &leniw); + if (retval == SUNTIMESTEPHEURISTICS_SUCCESS) { + ark_mem->liw += leniw; + ark_mem->lrw += lenrw; + } + ark_mem->hconstraints = H; + return(ARK_SUCCESS); } /*--------------------------------------------------------------- - arkSetInitStep: + arkSetMaxNumSteps: - Specifies the initial step size + Specifies the maximum number of integration steps ---------------------------------------------------------------*/ -int arkSetInitStep(void *arkode_mem, realtype hin) +int arkSetMaxNumSteps(void *arkode_mem, long int mxsteps) { ARKodeMem ark_mem; if (arkode_mem==NULL) { arkProcessError(NULL, ARK_MEM_NULL, "ARKODE", - "arkSetInitStep", MSG_ARK_NO_MEM); + "arkSetMaxNumSteps", MSG_ARK_NO_MEM); return(ARK_MEM_NULL); } ark_mem = (ARKodeMem) arkode_mem; - /* Passing hin=0 sets the default, otherwise use input. */ - if (hin == ZERO) { - ark_mem->hin = ZERO; - } else { - ark_mem->hin = hin; - } - - /* Clear previous initial step */ - ark_mem->h0u = ZERO; - - /* 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; + /* Passing mxsteps=0 sets the default. Passing mxsteps<0 disables the test. */ + if (mxsteps == 0) + ark_mem->mxstep = MXSTEP_DEFAULT; + else + ark_mem->mxstep = mxsteps; return(ARK_SUCCESS); } /*--------------------------------------------------------------- - arkSetMinStep: + arkSetMaxHnilWarns: - Specifies the minimum step size + Specifies the maximum number of warnings for small h ---------------------------------------------------------------*/ -int arkSetMinStep(void *arkode_mem, realtype hmin) +int arkSetMaxHnilWarns(void *arkode_mem, int mxhnil) { ARKodeMem ark_mem; if (arkode_mem==NULL) { arkProcessError(NULL, ARK_MEM_NULL, "ARKODE", - "arkSetMinStep", MSG_ARK_NO_MEM); + "arkSetMaxHnilWarns", MSG_ARK_NO_MEM); return(ARK_MEM_NULL); } ark_mem = (ARKodeMem) arkode_mem; - /* Passing a value <= 0 sets hmin = 0 */ - if (hmin <= ZERO) { - ark_mem->hmin = ZERO; - return(ARK_SUCCESS); - } - - /* check that hmin and hmax are agreeable */ - if (hmin * ark_mem->hmax_inv > ONE) { - arkProcessError(ark_mem, ARK_ILL_INPUT, "ARKODE", - "arkSetMinStep", MSG_ARK_BAD_HMIN_HMAX); - return(ARK_ILL_INPUT); + /* Passing mxhnil=0 sets the default, otherwise use input. */ + if (mxhnil == 0) { + ark_mem->mxhnil = 10; + } else { + ark_mem->mxhnil = mxhnil; } - /* set the value */ - ark_mem->hmin = hmin; - return(ARK_SUCCESS); } /*--------------------------------------------------------------- - arkSetMaxStep: + arkSetInitStep: - Specifies the maximum step size + Specifies the initial step size ---------------------------------------------------------------*/ -int arkSetMaxStep(void *arkode_mem, realtype hmax) +int arkSetInitStep(void *arkode_mem, realtype hin) { - realtype hmax_inv; ARKodeMem ark_mem; + int retval; if (arkode_mem==NULL) { arkProcessError(NULL, ARK_MEM_NULL, "ARKODE", - "arkSetMaxStep", MSG_ARK_NO_MEM); - return (ARK_MEM_NULL); + "arkSetInitStep", MSG_ARK_NO_MEM); + return(ARK_MEM_NULL); } ark_mem = (ARKodeMem) arkode_mem; - /* Passing a value <= 0 sets hmax = infinity */ - if (hmax <= ZERO) { - ark_mem->hmax_inv = ZERO; - return(ARK_SUCCESS); + /* Passing hin=0 sets the default, otherwise use input. */ + if (hin == ZERO) { + ark_mem->hin = ZERO; + } else { + ark_mem->hin = hin; } - /* check that hmax and hmin are agreeable */ - hmax_inv = ONE/hmax; - if (hmax_inv * ark_mem->hmin > ONE) { - arkProcessError(ark_mem, ARK_ILL_INPUT, "ARKODE", - "arkSetMaxStep", MSG_ARK_BAD_HMIN_HMAX); - return(ARK_ILL_INPUT); - } + /* Clear previous initial step */ + ark_mem->h0u = ZERO; - /* set the value */ - ark_mem->hmax_inv = hmax_inv; + /* Reset error controller (e.g., error and step size history) */ + retval = SUNAdaptController_Reset(ark_mem->hcontroller); + if (retval != SUNADAPTCONTROLLER_SUCCESS) { return(ARK_CONTROLLER_ERR); } return(ARK_SUCCESS); } @@ -567,19 +612,19 @@ int arkClearStopTime(void *arkode_mem) arkSetFixedStep: Specifies to use a fixed time step size instead of performing - any form of temporal adaptivity. ARKODE will use this step size - for all steps (unless tstop is set, in which case it may need to - modify that last step approaching tstop. If any solver failure - occurs in the timestepping module, ARKODE will typically - immediately return with an error message indicating that the - selected step size cannot be used. - - Any nonzero argument will result in the use of that fixed step - size; an argument of 0 will re-enable temporal adaptivity. + any form of temporal adaptivity. Any nonzero argument will + result in the use of that fixed step size; an argument of 0 + will re-enable temporal adaptivity. ARKODE will use this step + size for all steps (unless tstop is set, in which case it may + need to modify that last step approaching tstop. If any solver + failure occurs in the timestepping module, ARKODE will + typically immediately return with an error message indicating + that the selected step size cannot be used. ---------------------------------------------------------------*/ 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 +633,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->hcontroller, &lenrw, &leniw); + if (retval == SUNADAPTCONTROLLER_SUCCESS) { + ark_mem->liw -= leniw; + ark_mem->lrw -= lenrw; + } + if (ark_mem->owncontroller) { + retval = SUNAdaptController_Destroy(ark_mem->hcontroller); + if (retval != SUNADAPTCONTROLLER_SUCCESS) { + arkProcessError(ark_mem, ARK_MEM_FAIL, "ARKODE", "arkSetFixedStep", + "SUNAdaptController_Destroy failure"); + return(ARK_MEM_FAIL); + } + } + ark_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->hcontroller = C; + ark_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,15 +680,21 @@ int arkSetFixedStep(void *arkode_mem, realtype hfixed) if (retval != ARK_SUCCESS) return(retval); } - /* set ark_mem entry */ + /* set ark_mem "fixedstep" entry, and set + stepsize bounds into heuristics module */ if (hfixed != ZERO) { ark_mem->fixedstep = SUNTRUE; - ark_mem->hin = hfixed; + retval = SUNTimestepHeuristics_SetMaxStep(ark_mem->hconstraints, hfixed); + if (retval != ARK_SUCCESS) return(ARK_HEURISTICS_ERR); + retval = SUNTimestepHeuristics_SetMinStep(ark_mem->hconstraints, hfixed); + if (retval != ARK_SUCCESS) return(ARK_HEURISTICS_ERR); } else { ark_mem->fixedstep = SUNFALSE; } - return(ARK_SUCCESS); + /* Notify ARKODE to use hfixed as the initial step size, and return */ + retval = arkSetInitStep(arkode_mem, hfixed); + return(retval); } @@ -767,16 +856,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); } @@ -819,389 +908,246 @@ int arkSetMaxNumConstrFails(void *arkode_mem, int maxfails) /*--------------------------------------------------------------- - arkSetCFLFraction: - - Specifies the safety factor to use on the maximum explicitly- - stable step size. Allowable values must be within the open - interval (0,1). A non-positive input implies a reset to - the default value. - ---------------------------------------------------------------*/ -int arkSetCFLFraction(void *arkode_mem, realtype cfl_frac) -{ - int retval; - ARKodeHAdaptMem hadapt_mem; - ARKodeMem ark_mem; - retval = arkAccessHAdaptMem(arkode_mem, "arkSetCFLFraction", - &ark_mem, &hadapt_mem); - if (retval != ARK_SUCCESS) return(retval); - - /* check for allowable parameters */ - if (cfl_frac >= ONE) { - arkProcessError(ark_mem, ARK_ILL_INPUT, "ARKODE", - "arkSetCFLFraction", "Illegal CFL fraction"); - return(ARK_ILL_INPUT); - } + arkSetAdaptivityMethod: ***DEPRECATED*** - /* set positive-valued parameters, otherwise set default */ - if (cfl_frac <= ZERO) { - hadapt_mem->cfl = CFLFAC; - } else { - hadapt_mem->cfl = cfl_frac; - } - - return(ARK_SUCCESS); -} - - -/*--------------------------------------------------------------- - arkSetSafetyFactor: + 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. - Specifies the safety factor to use on the error-based predicted - time step size. Allowable values must be within the open - interval (0,1). A non-positive input implies a reset to the - default value. + 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 arkSetSafetyFactor(void *arkode_mem, realtype safety) +int arkSetAdaptivityMethod(void *arkode_mem, int imethod, int idefault, + int pq, realtype adapt_params[3]) { int retval; - ARKodeHAdaptMem hadapt_mem; + long int lenrw, leniw; + realtype k1, k2, k3; ARKodeMem ark_mem; - retval = arkAccessHAdaptMem(arkode_mem, "arkSetSafetyFactor", - &ark_mem, &hadapt_mem); - if (retval != ARK_SUCCESS) return(retval); + 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 allowable parameters */ - if (safety >= ONE) { + /* Check for illegal inputs */ + if ((idefault != 1) && (adapt_params == NULL)) { arkProcessError(ark_mem, ARK_ILL_INPUT, "ARKODE", - "arkSetSafetyFactor", "Illegal safety factor"); + "arkSetAdaptivityMethod", + "NULL-valued adapt_params provided"); return(ARK_ILL_INPUT); } - /* set positive-valued parameters, otherwise set default */ - if (safety <= ZERO) { - hadapt_mem->safety = SAFETY; - } else { - hadapt_mem->safety = safety; + /* Remove current SUNAdaptController object + (delete if owned, and then nullify pointer) */ + retval = SUNAdaptController_Space(ark_mem->hcontroller, &lenrw, &leniw); + if (retval == SUNADAPTCONTROLLER_SUCCESS) { + ark_mem->liw -= leniw; + ark_mem->lrw -= lenrw; } - - return(ARK_SUCCESS); -} - - -/*--------------------------------------------------------------- - arkSetErrorBias: - - Specifies the error bias to use when performing adaptive-step - error control. Allowable values must be >= 1.0. Any illegal - value implies a reset to the default value. - ---------------------------------------------------------------*/ -int arkSetErrorBias(void *arkode_mem, realtype bias) -{ - int retval; - ARKodeHAdaptMem hadapt_mem; - ARKodeMem ark_mem; - retval = arkAccessHAdaptMem(arkode_mem, "arkSetErrorBias", - &ark_mem, &hadapt_mem); - if (retval != ARK_SUCCESS) return(retval); - - /* set allowed value, otherwise set default */ - if (bias < ONE) { - hadapt_mem->bias = BIAS; - } else { - hadapt_mem->bias = bias; - } - - return(ARK_SUCCESS); -} - - -/*--------------------------------------------------------------- - arkSetMaxGrowth: - - Specifies the maximum step size growth factor to be allowed - between successive integration steps. Note: the first step uses - a separate maximum growth factor. Allowable values must be - > 1.0. Any illegal value implies a reset to the default. - ---------------------------------------------------------------*/ -int arkSetMaxGrowth(void *arkode_mem, realtype mx_growth) -{ - int retval; - ARKodeHAdaptMem hadapt_mem; - ARKodeMem ark_mem; - retval = arkAccessHAdaptMem(arkode_mem, "arkSetMaxGrowth", - &ark_mem, &hadapt_mem); - if (retval != ARK_SUCCESS) return(retval); - - /* set allowed value, otherwise set default */ - if (mx_growth <= ONE) { - hadapt_mem->growth = GROWTH; - } else { - hadapt_mem->growth = mx_growth; - } - - return(ARK_SUCCESS); -} - - -/*--------------------------------------------------------------- - arkSetMinReduction: - - Specifies the minimum possible step size reduction factor to be - allowed between successive integration steps. Allowable values - must be > 0.0 and < 1.0. Any illegal value implies a reset to - the default. - ---------------------------------------------------------------*/ -int arkSetMinReduction(void *arkode_mem, realtype eta_min) -{ - int retval; - ARKodeHAdaptMem hadapt_mem; - ARKodeMem ark_mem; - retval = arkAccessHAdaptMem(arkode_mem, "arkSetMinReduction", - &ark_mem, &hadapt_mem); - if (retval != ARK_SUCCESS) return(retval); - - /* set allowed value, otherwise set default */ - if (eta_min >= ONE || eta_min <= ZERO) { - hadapt_mem->etamin = ETAMIN; - } else { - hadapt_mem->etamin = eta_min; + if (ark_mem->owncontroller) { + retval = SUNAdaptController_Destroy(ark_mem->hcontroller); + if (retval != SUNADAPTCONTROLLER_SUCCESS) { + arkProcessError(ark_mem, ARK_MEM_FAIL, "ARKODE", "arkSetAdaptivityMethod", + "SUNAdaptController_Destroy failure"); + return(ARK_MEM_FAIL); + } } + ark_mem->hcontroller = NULL; - return(ARK_SUCCESS); -} - - -/*--------------------------------------------------------------- - arkSetFixedStepBounds: - - Specifies the step size growth interval within which the step - size will remain unchanged. Allowable values must enclose the - value 1.0. Any illegal interval implies a reset to the default. - ---------------------------------------------------------------*/ -int arkSetFixedStepBounds(void *arkode_mem, realtype lb, realtype ub) -{ - int retval; - ARKodeHAdaptMem hadapt_mem; - ARKodeMem ark_mem; - retval = arkAccessHAdaptMem(arkode_mem, "arkSetFixedStepBounds", - &ark_mem, &hadapt_mem); - if (retval != ARK_SUCCESS) return(retval); - - /* set allowable interval, otherwise set defaults */ - if ((lb <= ONE) && (ub >= ONE)) { - hadapt_mem->lbound = lb; - hadapt_mem->ubound = ub; + /* 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 { - hadapt_mem->lbound = HFIXED_LB; - hadapt_mem->ubound = HFIXED_UB; - } - - return(ARK_SUCCESS); -} - - -/*--------------------------------------------------------------- - 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)) { + 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); } - /* 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]; + /* Attach new SUNAdaptController object */ + retval = SUNAdaptController_Space(C, &lenrw, &leniw); + if (retval == SUNADAPTCONTROLLER_SUCCESS) { + ark_mem->liw += leniw; + ark_mem->lrw += lenrw; } + ark_mem->hcontroller = C; + ark_mem->owncontroller = SUNTRUE; return(ARK_SUCCESS); } /*--------------------------------------------------------------- - arkSetAdaptivityFn: + arkSetAdaptivityFn: ***DEPRECATED*** 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); -} + If 'hfun' is NULL-valued, then the default PID controller will + be used instead. - -/*--------------------------------------------------------------- - arkSetMaxFirstGrowth: - - Specifies the user-provided time step adaptivity constant - etamx1. Legal values are greater than 1.0. Illegal values - imply a reset to the default value. + Users should transition to constructing a custom SUNAdaptController + object, and providing this directly to the integrator + via the time-stepping module *SetController routines. ---------------------------------------------------------------*/ -int arkSetMaxFirstGrowth(void *arkode_mem, realtype etamx1) +int arkSetAdaptivityFn(void *arkode_mem, ARKAdaptFn hfun, void *h_data) { int retval; - ARKodeHAdaptMem hadapt_mem; + long int lenrw, leniw; ARKodeMem ark_mem; - retval = arkAccessHAdaptMem(arkode_mem, "arkSetMaxFirstGrowth", - &ark_mem, &hadapt_mem); - if (retval != ARK_SUCCESS) return(retval); - - /* if argument legal set it, otherwise set default */ - if (etamx1 <= ONE) { - hadapt_mem->etamx1 = ETAMX1; - } else { - hadapt_mem->etamx1 = etamx1; + if (arkode_mem==NULL) { + arkProcessError(NULL, ARK_MEM_NULL, "ARKODE", + "arkSetAdaptivityFn", MSG_ARK_NO_MEM); + return(ARK_MEM_NULL); } + ark_mem = (ARKodeMem) arkode_mem; - return(ARK_SUCCESS); -} - - -/*--------------------------------------------------------------- - arkSetMaxEFailGrowth: - - Specifies the user-provided time step adaptivity constant - etamxf. Legal values are in the interval (0,1]. Illegal values - imply a reset to the default value. - ---------------------------------------------------------------*/ -int arkSetMaxEFailGrowth(void *arkode_mem, realtype etamxf) -{ - int retval; - ARKodeHAdaptMem hadapt_mem; - ARKodeMem ark_mem; - retval = arkAccessHAdaptMem(arkode_mem, "arkSetMaxEFailGrowth", - &ark_mem, &hadapt_mem); - if (retval != ARK_SUCCESS) return(retval); - - /* if argument legal set it, otherwise set default */ - if ((etamxf <= ZERO) || (etamxf > ONE)) { - hadapt_mem->etamxf = ETAMXF; - } else { - hadapt_mem->etamxf = etamxf; + /* Remove current SUNAdaptController object + (delete if owned, and then nullify pointer) */ + retval = SUNAdaptController_Space(ark_mem->hcontroller, &lenrw, &leniw); + if (retval == SUNADAPTCONTROLLER_SUCCESS) { + ark_mem->liw -= leniw; + ark_mem->lrw -= lenrw; + } + if (ark_mem->owncontroller) { + retval = SUNAdaptController_Destroy(ark_mem->hcontroller); + if (retval != SUNADAPTCONTROLLER_SUCCESS) { + arkProcessError(ark_mem, ARK_MEM_FAIL, "ARKODE", "arkSetAdaptivityFn", + "SUNAdaptController_Destroy failure"); + return(ARK_MEM_FAIL); + } } + ark_mem->hcontroller = NULL; - return(ARK_SUCCESS); -} - - -/*--------------------------------------------------------------- - arkSetSmallNumEFails: - - Specifies the user-provided time step adaptivity constant - small_nef. Legal values are > 0. Illegal values - imply a reset to the default value. - ---------------------------------------------------------------*/ -int arkSetSmallNumEFails(void *arkode_mem, int small_nef) -{ - int retval; - ARKodeHAdaptMem hadapt_mem; - ARKodeMem ark_mem; - retval = arkAccessHAdaptMem(arkode_mem, "arkSetSmallNumEFails", - &ark_mem, &hadapt_mem); - if (retval != ARK_SUCCESS) return(retval); - - /* if argument legal set it, otherwise set default */ - if (small_nef <= 0) { - hadapt_mem->small_nef = SMALL_NEF; + /* 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 { - hadapt_mem->small_nef = small_nef; + 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); + } } - return(ARK_SUCCESS); -} - - -/*--------------------------------------------------------------- - arkSetMaxCFailGrowth: - - Specifies the user-provided time step adaptivity constant - etacf. Legal values are in the interval (0,1]. Illegal values - imply a reset to the default value. - ---------------------------------------------------------------*/ -int arkSetMaxCFailGrowth(void *arkode_mem, realtype etacf) -{ - int retval; - ARKodeHAdaptMem hadapt_mem; - ARKodeMem ark_mem; - retval = arkAccessHAdaptMem(arkode_mem, "arkSetMaxCFailGrowth", - &ark_mem, &hadapt_mem); - if (retval != ARK_SUCCESS) return(retval); - - /* if argument legal set it, otherwise set default */ - if ((etacf <= ZERO) || (etacf > ONE)) { - hadapt_mem->etacf = ETACF; - } else { - hadapt_mem->etacf = etacf; + /* Attach new SUNAdaptController object */ + retval = SUNAdaptController_Space(C, &lenrw, &leniw); + if (retval == SUNADAPTCONTROLLER_SUCCESS) { + ark_mem->liw += leniw; + ark_mem->lrw += lenrw; } + ark_mem->hcontroller = C; + ark_mem->owncontroller = SUNTRUE; return(ARK_SUCCESS); } /*--------------------------------------------------------------- - arkSetStabilityFn: + arkSetStabilityFn: ***DEPRECATED*** Specifies the user-provided explicit time step stability function to use. A NULL input function implies a reset to @@ -1210,19 +1156,40 @@ int arkSetMaxCFailGrowth(void *arkode_mem, realtype etacf) int arkSetStabilityFn(void *arkode_mem, ARKExpStabFn EStab, void *estab_data) { int retval; - ARKodeHAdaptMem hadapt_mem; ARKodeMem ark_mem; - retval = arkAccessHAdaptMem(arkode_mem, "arkSetStabilityFn", - &ark_mem, &hadapt_mem); - if (retval != ARK_SUCCESS) return(retval); + if (arkode_mem==NULL) { + arkProcessError(NULL, ARK_MEM_NULL, "ARKODE", + "arkSetStabilityFn", MSG_ARK_NO_MEM); + return(ARK_MEM_NULL); + } + ark_mem = (ARKodeMem) arkode_mem; - /* NULL argument sets default, otherwise set inputs */ + /* NULL argument sets default. */ if (EStab == NULL) { - hadapt_mem->expstab = arkExpStab; - hadapt_mem->estab_data = ark_mem; + retval = SUNTimestepHeuristics_SetExpStabFn(ark_mem->hconstraints, NULL, NULL); + if (retval != SUNTIMESTEPHEURISTICS_SUCCESS) { + arkProcessError(ark_mem, ARK_HEURISTICS_ERR, "ARKODE", + "arkSetStabilityFn", "SUNTimestepHeuristics_SetExpStabFn failure"); + return(ARK_HEURISTICS_ERR); + } } else { - hadapt_mem->expstab = EStab; - hadapt_mem->estab_data = estab_data; + + /* Otherwise create wrapper structure */ + void* wrapper_data = ARKUserStability(arkode_mem, EStab, estab_data); + if (wrapper_data == NULL) { + arkProcessError(ark_mem, ARK_MEM_FAIL, "ARKODE", "arkSetStabilityFn", + "ARKUserStability failure"); + return(ARK_MEM_FAIL); + } + + /* Attach ARKODE function and wrapper structure to heuristics object */ + retval = SUNTimestepHeuristics_SetExpStabFn(ark_mem->hconstraints, + ARKControlExpStab, wrapper_data); + if (retval != SUNTIMESTEPHEURISTICS_SUCCESS) { + arkProcessError(ark_mem, ARK_HEURISTICS_ERR, "ARKODE", + "arkSetStabilityFn", "SUNTimestepHeuristics_SetExpStabFn failure"); + return(ARK_HEURISTICS_ERR); + } } return(ARK_SUCCESS); @@ -1634,46 +1601,6 @@ int arkGetNumConstrFails(void *arkode_mem, long int *nconstrfails) } -/*--------------------------------------------------------------- - arkGetNumExpSteps: - - Returns the current number of stability-limited steps - ---------------------------------------------------------------*/ -int arkGetNumExpSteps(void *arkode_mem, long int *nsteps) -{ - ARKodeMem ark_mem; - if (arkode_mem==NULL) { - arkProcessError(NULL, ARK_MEM_NULL, "ARKODE", - "arkGetNumExpSteps", MSG_ARK_NO_MEM); - return(ARK_MEM_NULL); - } - ark_mem = (ARKodeMem) arkode_mem; - - *nsteps = ark_mem->hadapt_mem->nst_exp; - return(ARK_SUCCESS); -} - - -/*--------------------------------------------------------------- - arkGetNumAccSteps: - - Returns the current number of accuracy-limited steps - ---------------------------------------------------------------*/ -int arkGetNumAccSteps(void *arkode_mem, long int *nsteps) -{ - ARKodeMem ark_mem; - if (arkode_mem==NULL) { - arkProcessError(NULL, ARK_MEM_NULL, "ARKODE", - "arkGetNumAccSteps", MSG_ARK_NO_MEM); - return(ARK_MEM_NULL); - } - ark_mem = (ARKodeMem) arkode_mem; - - *nsteps = ark_mem->hadapt_mem->nst_acc; - return(ARK_SUCCESS); -} - - /*--------------------------------------------------------------- arkGetNumErrTestFails: @@ -1747,6 +1674,7 @@ int arkPrintAllStats(void *arkode_mem, FILE *outfile, SUNOutputFormat fmt) int retval; ARKodeMem ark_mem; ARKodeRootMem ark_root_mem; + long int nst_exp, nst_acc; if (arkode_mem == NULL) { arkProcessError(NULL, ARK_MEM_NULL, "ARKODE", @@ -1755,14 +1683,27 @@ int arkPrintAllStats(void *arkode_mem, FILE *outfile, SUNOutputFormat fmt) } ark_mem = (ARKodeMem) arkode_mem; + retval = SUNTimestepHeuristics_GetNumExpSteps(ark_mem->hconstraints, &nst_exp); + if (retval != SUNTIMESTEPHEURISTICS_SUCCESS) { + arkProcessError(ark_mem, ARK_HEURISTICS_ERR, "ARKODE", "arkPrintAllStats", + "Error in SUNTimestepHeuristics_GetNumExpSteps"); + return(ARK_HEURISTICS_ERR); + } + retval = SUNTimestepHeuristics_GetNumAccSteps(ark_mem->hconstraints, &nst_acc); + if (retval != SUNTIMESTEPHEURISTICS_SUCCESS) { + arkProcessError(ark_mem, ARK_HEURISTICS_ERR, "ARKODE", "arkPrintAllStats", + "Error in SUNTimestepHeuristics_GetNumAccSteps"); + return(ARK_HEURISTICS_ERR); + } + switch(fmt) { case SUN_OUTPUTFORMAT_TABLE: fprintf(outfile, "Current time = %"RSYM"\n", ark_mem->tcur); fprintf(outfile, "Steps = %ld\n", ark_mem->nst); fprintf(outfile, "Step attempts = %ld\n", ark_mem->nst_attempts); - fprintf(outfile, "Stability limited steps = %ld\n", ark_mem->hadapt_mem->nst_exp); - fprintf(outfile, "Accuracy limited steps = %ld\n", ark_mem->hadapt_mem->nst_acc); + fprintf(outfile, "Stability limited steps = %ld\n", nst_exp); + fprintf(outfile, "Accuracy limited steps = %ld\n", nst_acc); fprintf(outfile, "Error test fails = %ld\n", ark_mem->netf); fprintf(outfile, "NLS step fails = %ld\n", ark_mem->ncfn); fprintf(outfile, "Inequality constraint fails = %ld\n", ark_mem->nconstrfails); @@ -1779,8 +1720,8 @@ int arkPrintAllStats(void *arkode_mem, FILE *outfile, SUNOutputFormat fmt) fprintf(outfile, "Time,%"RSYM, ark_mem->tcur); fprintf(outfile, ",Steps,%ld", ark_mem->nst); fprintf(outfile, ",Step attempts,%ld", ark_mem->nst_attempts); - fprintf(outfile, ",Stability limited steps,%ld", ark_mem->hadapt_mem->nst_exp); - fprintf(outfile, ",Accuracy limited steps,%ld", ark_mem->hadapt_mem->nst_acc); + fprintf(outfile, ",Stability limited steps,%ld", nst_exp); + fprintf(outfile, ",Accuracy limited steps,%ld", nst_acc); fprintf(outfile, ",Error test fails,%ld", ark_mem->netf); fprintf(outfile, ",NLS step fails,%ld", ark_mem->ncfn); fprintf(outfile, ",Inequality constraint fails,%ld", ark_mem->nconstrfails); @@ -1827,6 +1768,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 +1825,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 +1852,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 +1861,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 +1873,39 @@ 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_HEURISTICS_ERR: + sprintf(name,"ARK_HEURISTICS_ERR"); + break; + case ARK_UNRECOGNIZED_ERROR: + sprintf(name,"ARK_UNRECOGNIZED_ERROR"); + break; default: sprintf(name,"NONE"); } @@ -1957,12 +1934,6 @@ int arkWriteParameters(ARKodeMem ark_mem, FILE *fp) /* print integrator parameters to file */ fprintf(fp, "ARKODE solver parameters:\n"); - if (ark_mem->hmin != ZERO) - fprintf(fp, " Minimum step size = %" RSYM"\n",ark_mem->hmin); - if (ark_mem->hmax_inv != ZERO) - fprintf(fp, " Maximum step size = %" RSYM"\n",ONE/ark_mem->hmax_inv); - if (ark_mem->fixedstep) - fprintf(fp, " Fixed time-stepping enabled\n"); if (ark_mem->itol == ARK_WF) { fprintf(fp, " User provided error weight function\n"); } else { @@ -1986,39 +1957,11 @@ int arkWriteParameters(ARKodeMem ark_mem, FILE *fp) } if (ark_mem->hin != ZERO) fprintf(fp, " Initial step size = %" RSYM"\n",ark_mem->hin); - fprintf(fp, "\n"); - fprintf(fp, " Maximum step increase (first step) = %"RSYM"\n", - ark_mem->hadapt_mem->etamx1); - fprintf(fp, " Step reduction factor on multiple error fails = %"RSYM"\n", - ark_mem->hadapt_mem->etamxf); - fprintf(fp, " Minimum error fails before above factor is used = %i\n", - ark_mem->hadapt_mem->small_nef); - fprintf(fp, " Step reduction factor on nonlinear convergence failure = %"RSYM"\n", - ark_mem->hadapt_mem->etacf); - fprintf(fp, " Explicit safety factor = %"RSYM"\n", - ark_mem->hadapt_mem->cfl); - 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, " Maximum number of error test failures = %i\n",ark_mem->maxnef); fprintf(fp, " Maximum number of convergence test failures = %i\n",ark_mem->maxncf); - + fprintf(fp, "\n"); + (void) SUNTimestepHeuristics_Write(ark_mem->hconstraints, fp); + (void) SUNAdaptController_Write(ark_mem->hcontroller, fp); return(ARK_SUCCESS); } diff --git a/src/arkode/arkode_relaxation.c b/src/arkode/arkode_relaxation.c index cc9fb5d0b8..5c536c912e 100644 --- a/src/arkode/arkode_relaxation.c +++ b/src/arkode/arkode_relaxation.c @@ -783,6 +783,7 @@ int arkRelax(ARKodeMem ark_mem, int* relax_fails, realtype* dsm_inout, { int retval; sunrealtype relax_val; + sunrealtype htest; ARKodeRelaxMem relax_mem = ark_mem->relax_mem; /* Get the relaxation memory structure */ @@ -805,17 +806,17 @@ int arkRelax(ARKodeMem ark_mem, int* relax_fails, realtype* dsm_inout, /* Check for max fails in a step */ if (*relax_fails == relax_mem->max_fails) { return ARK_RELAX_FAIL; } - /* Return with an error if |h| == hmin */ - if (SUNRabs(ark_mem->h) <= ark_mem->hmin * ONEPSM) + /* Check whether we can cut step size, if not then return with error */ + htest = ark_mem->h * relax_mem->eta_fail; + retval = SUNTimestepHeuristics_BoundReduction(ark_mem->hconstraints, + ark_mem->h, htest, &htest); + if (retval == SUNTIMESTEPHEURISTICS_CANNOT_DECREASE) { return ARK_RELAX_FAIL; } - /* Return with error if using fixed step sizes */ - if (ark_mem->fixedstep) { return(ARK_RELAX_FAIL); } - /* Cut step size and try again */ - ark_mem->eta = relax_mem->eta_fail; + ark_mem->eta = htest / ark_mem->h; #if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_INFO SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_INFO, 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/arkode_user_stability.c b/src/arkode/arkode_user_stability.c new file mode 100644 index 0000000000..f7b28636ed --- /dev/null +++ b/src/arkode/arkode_user_stability.c @@ -0,0 +1,72 @@ +/* ----------------------------------------------------------------- + * 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 + * ----------------------------------------------------------------- + * ARKUserStability structure and utility routines. + * -----------------------------------------------------------------*/ + +#include +#include +#include +#include "arkode_impl.h" + + +/* ----------------------------------------------------- + * Function to create an ARKUserStabilityData structure + */ + +void* ARKUserStability(void* arkode_mem, ARKExpStabFn EStab, void* estab_data) +{ + /* Return with failure if arkode_mem or EStab are NULL */ + if ((EStab == NULL) || (arkode_mem == NULL)) { return (NULL); } + + /* Create data structure */ + ARKUserStabilityData userstab_data = NULL; + userstab_data = (ARKUserStabilityData)malloc(sizeof *userstab_data); + if (userstab_data == NULL) { return(NULL); } + + /* Attach inputs into structure */ + userstab_data->EStab = EStab; + userstab_data->estab_data = estab_data; + userstab_data->arkode_mem = arkode_mem; + + return (void*) userstab_data; +} + + +/* ----------------------------------------------------------------- + * Function to free an ARKUserStabilityData structure + */ + +void ARKUserStability_Free(void* sdata) +{ + if (sdata == NULL) { return; } + ARKUserStabilityData userstab_data = (ARKUserStabilityData) sdata; + free(userstab_data); + userstab_data = NULL; + sdata = NULL; +} + +/* ----------------------------------------------------- + * Function to evaluate the user-provided stability fn. + */ + +int ARKControlExpStab(realtype *hstab, void* sdata) +{ + int retval; + if (sdata == NULL) { return(SUNTIMESTEPHEURISTICS_USER_FCN_FAIL); } + ARKUserStabilityData X = (ARKUserStabilityData) sdata; + ARKodeMem ark_mem = (ARKodeMem) (X->arkode_mem); + retval = (X->EStab)(ark_mem->ycur, ark_mem->tn, hstab, X->estab_data); + if (retval != ARK_SUCCESS) { return(SUNTIMESTEPHEURISTICS_USER_FCN_FAIL); } + return(SUNTIMESTEPHEURISTICS_SUCCESS); +} diff --git a/src/arkode/fmod/CMakeLists.txt b/src/arkode/fmod/CMakeLists.txt index 5ac015daf1..cca5645219 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 @@ -45,6 +51,8 @@ sundials_add_f2003_library(sundials_farkode_mod sundials_fsunlinsolpcg_mod_obj sundials_fsunnonlinsolnewton_mod_obj sundials_fsunnonlinsolfixedpoint_mod_obj + sundials_fsuntimestepheuristicsdefault_mod_obj + sundials_fsuntimestepheuristicsunconstrained_mod_obj OUTPUT_NAME sundials_farkode_mod VERSION diff --git a/src/arkode/fmod/farkode_arkstep_mod.c b/src/arkode/fmod/farkode_arkstep_mod.c index 2ae77231a3..7391d49681 100644 --- a/src/arkode/fmod/farkode_arkstep_mod.c +++ b/src/arkode/fmod/farkode_arkstep_mod.c @@ -685,6 +685,34 @@ 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_FARKStepSetTimestepHeuristics(void *farg1, SUNTimestepHeuristics farg2) { + int fresult ; + void *arg1 = (void *) 0 ; + SUNTimestepHeuristics arg2 = (SUNTimestepHeuristics) 0 ; + int result; + + arg1 = (void *)(farg1); + arg2 = (SUNTimestepHeuristics)(farg2); + result = (int)ARKStepSetTimestepHeuristics(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..04f3a97043 100644 --- a/src/arkode/fmod/farkode_arkstep_mod.f90 +++ b/src/arkode/fmod/farkode_arkstep_mod.f90 @@ -34,6 +34,8 @@ module farkode_arkstep_mod use fsundials_context_mod use fsundials_types_mod use fsundials_nonlinearsolver_mod + use fsundials_adaptcontroller_mod + use fsundials_timestepheuristics_mod use fsundials_types_mod implicit none private @@ -91,6 +93,8 @@ module farkode_arkstep_mod integer(C_SIZE_T), public :: size = 0 end type public :: FARKStepSetTableName + public :: FARKStepSetAdaptController + public :: FARKStepSetTimestepHeuristics public :: FARKStepSetCFLFraction public :: FARKStepSetSafetyFactor public :: FARKStepSetErrorBias @@ -518,6 +522,24 @@ 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_FARKStepSetTimestepHeuristics(farg1, farg2) & +bind(C, name="_wrap_FARKStepSetTimestepHeuristics") & +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 +2367,38 @@ 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 FARKStepSetTimestepHeuristics(arkode_mem, h) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(C_PTR) :: arkode_mem +type(SUNTimestepHeuristics), target, intent(inout) :: h +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 + +farg1 = arkode_mem +farg2 = c_loc(h) +fresult = swigc_FARKStepSetTimestepHeuristics(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..e0d3fbebee 100644 --- a/src/arkode/fmod/farkode_erkstep_mod.c +++ b/src/arkode/fmod/farkode_erkstep_mod.c @@ -479,6 +479,34 @@ 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_FERKStepSetTimestepHeuristics(void *farg1, SUNTimestepHeuristics farg2) { + int fresult ; + void *arg1 = (void *) 0 ; + SUNTimestepHeuristics arg2 = (SUNTimestepHeuristics) 0 ; + int result; + + arg1 = (void *)(farg1); + arg2 = (SUNTimestepHeuristics)(farg2); + result = (int)ERKStepSetTimestepHeuristics(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..723a2111de 100644 --- a/src/arkode/fmod/farkode_erkstep_mod.f90 +++ b/src/arkode/fmod/farkode_erkstep_mod.f90 @@ -34,6 +34,8 @@ module farkode_erkstep_mod use fsundials_context_mod use fsundials_types_mod use fsundials_nonlinearsolver_mod + use fsundials_adaptcontroller_mod + use fsundials_timestepheuristics_mod use fsundials_types_mod implicit none private @@ -65,6 +67,8 @@ module farkode_erkstep_mod integer(C_SIZE_T), public :: size = 0 end type public :: FERKStepSetTableName + public :: FERKStepSetAdaptController + public :: FERKStepSetTimestepHeuristics public :: FERKStepSetCFLFraction public :: FERKStepSetSafetyFactor public :: FERKStepSetErrorBias @@ -300,6 +304,24 @@ 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_FERKStepSetTimestepHeuristics(farg1, farg2) & +bind(C, name="_wrap_FERKStepSetTimestepHeuristics") & +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 +1341,38 @@ 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 FERKStepSetTimestepHeuristics(arkode_mem, h) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(C_PTR) :: arkode_mem +type(SUNTimestepHeuristics), target, intent(inout) :: h +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 + +farg1 = arkode_mem +farg2 = c_loc(h) +fresult = swigc_FERKStepSetTimestepHeuristics(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..7fabb5f4a4 100644 --- a/src/arkode/fmod/farkode_mod.f90 +++ b/src/arkode/fmod/farkode_mod.f90 @@ -33,6 +33,8 @@ module farkode_mod use fsundials_context_mod use fsundials_types_mod use fsundials_nonlinearsolver_mod + use fsundials_adaptcontroller_mod + use fsundials_timestepheuristics_mod use fsundials_types_mod implicit none private @@ -104,6 +106,8 @@ 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_HEURISTICS_ERR = -48_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..c234474dbe 100644 --- a/src/arkode/fmod/farkode_mristep_mod.f90 +++ b/src/arkode/fmod/farkode_mristep_mod.f90 @@ -34,6 +34,8 @@ module farkode_mristep_mod use fsundials_context_mod use fsundials_types_mod use fsundials_nonlinearsolver_mod + use fsundials_adaptcontroller_mod + use fsundials_timestepheuristics_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..341a891efd 100644 --- a/src/arkode/fmod/farkode_sprkstep_mod.f90 +++ b/src/arkode/fmod/farkode_sprkstep_mod.f90 @@ -34,6 +34,8 @@ module farkode_sprkstep_mod use fsundials_context_mod use fsundials_types_mod use fsundials_nonlinearsolver_mod + use fsundials_adaptcontroller_mod + use fsundials_timestepheuristics_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..b8b3676fac --- /dev/null +++ b/src/sunadaptcontroller/expgus/sunadaptcontroller_expgus.c @@ -0,0 +1,251 @@ +/* ----------------------------------------------------------------- + * 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 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..8816c332f1 --- /dev/null +++ b/src/sunadaptcontroller/i/sunadaptcontroller_i.c @@ -0,0 +1,205 @@ +/* ----------------------------------------------------------------- + * 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 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..ae2926b7a0 --- /dev/null +++ b/src/sunadaptcontroller/imexgus/sunadaptcontroller_imexgus.c @@ -0,0 +1,271 @@ +/* ----------------------------------------------------------------- + * 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 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..7fb763db3e --- /dev/null +++ b/src/sunadaptcontroller/impgus/sunadaptcontroller_impgus.c @@ -0,0 +1,256 @@ +/* ----------------------------------------------------------------- + * 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 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..65014a92d0 --- /dev/null +++ b/src/sunadaptcontroller/pi/sunadaptcontroller_pi.c @@ -0,0 +1,230 @@ +/* ----------------------------------------------------------------- + * 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 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..440ba63ad6 --- /dev/null +++ b/src/sunadaptcontroller/pid/sunadaptcontroller_pid.c @@ -0,0 +1,241 @@ +/* ----------------------------------------------------------------- + * 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 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..43d1013c61 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 @@ -43,6 +44,7 @@ set(sundials_HEADERS sundials_nvector.hpp sundials_profiler.h sundials_logger.h + sundials_timestepheuristics.h sundials_types.h sundials_version.h ) @@ -77,6 +79,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 @@ -90,6 +93,7 @@ set(sundials_SOURCES sundials_nonlinearsolver.c sundials_nvector.c sundials_nvector_senswrapper.c + sundials_timestepheuristics.c sundials_version.c ) diff --git a/src/sundials/fmod/CMakeLists.txt b/src/sundials/fmod/CMakeLists.txt index e3e05f4cd7..c1d24d227a 100644 --- a/src/sundials/fmod/CMakeLists.txt +++ b/src/sundials/fmod/CMakeLists.txt @@ -30,7 +30,11 @@ 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 + fsundials_timestepheuristics_mod.f90 + fsundials_timestepheuristics_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/fmod/fsundials_timestepheuristics_mod.c b/src/sundials/fmod/fsundials_timestepheuristics_mod.c new file mode 100644 index 0000000000..a177173e63 --- /dev/null +++ b/src/sundials/fmod/fsundials_timestepheuristics_mod.c @@ -0,0 +1,583 @@ +/* ---------------------------------------------------------------------------- + * 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_timestepheuristics.h" + +SWIGEXPORT SUNTimestepHeuristics _wrap_FSUNTimestepHeuristics_NewEmpty(void *farg1) { + SUNTimestepHeuristics fresult ; + SUNContext arg1 = (SUNContext) 0 ; + SUNTimestepHeuristics result; + + arg1 = (SUNContext)(farg1); + result = (SUNTimestepHeuristics)SUNTimestepHeuristics_NewEmpty(arg1); + fresult = result; + return fresult; +} + + +SWIGEXPORT int _wrap_FSUNTimestepHeuristics_GetID(SUNTimestepHeuristics farg1) { + int fresult ; + SUNTimestepHeuristics arg1 = (SUNTimestepHeuristics) 0 ; + SUNTimestepHeuristics_ID result; + + arg1 = (SUNTimestepHeuristics)(farg1); + result = (SUNTimestepHeuristics_ID)SUNTimestepHeuristics_GetID(arg1); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FSUNTimestepHeuristics_Destroy(SUNTimestepHeuristics farg1) { + int fresult ; + SUNTimestepHeuristics arg1 = (SUNTimestepHeuristics) 0 ; + int result; + + arg1 = (SUNTimestepHeuristics)(farg1); + result = (int)SUNTimestepHeuristics_Destroy(arg1); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FSUNTimestepHeuristics_ConstrainStep(SUNTimestepHeuristics farg1, double const *farg2, double const *farg3, double *farg4) { + int fresult ; + SUNTimestepHeuristics arg1 = (SUNTimestepHeuristics) 0 ; + sunrealtype arg2 ; + sunrealtype arg3 ; + sunrealtype *arg4 = (sunrealtype *) 0 ; + int result; + + arg1 = (SUNTimestepHeuristics)(farg1); + arg2 = (sunrealtype)(*farg2); + arg3 = (sunrealtype)(*farg3); + arg4 = (sunrealtype *)(farg4); + result = (int)SUNTimestepHeuristics_ConstrainStep(arg1,arg2,arg3,arg4); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FSUNTimestepHeuristics_ETestFail(SUNTimestepHeuristics farg1, double const *farg2, double const *farg3, int const *farg4, double *farg5) { + int fresult ; + SUNTimestepHeuristics arg1 = (SUNTimestepHeuristics) 0 ; + sunrealtype arg2 ; + sunrealtype arg3 ; + int arg4 ; + sunrealtype *arg5 = (sunrealtype *) 0 ; + int result; + + arg1 = (SUNTimestepHeuristics)(farg1); + arg2 = (sunrealtype)(*farg2); + arg3 = (sunrealtype)(*farg3); + arg4 = (int)(*farg4); + arg5 = (sunrealtype *)(farg5); + result = (int)SUNTimestepHeuristics_ETestFail(arg1,arg2,arg3,arg4,arg5); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FSUNTimestepHeuristics_BoundReduction(SUNTimestepHeuristics farg1, double const *farg2, double const *farg3, double *farg4) { + int fresult ; + SUNTimestepHeuristics arg1 = (SUNTimestepHeuristics) 0 ; + sunrealtype arg2 ; + sunrealtype arg3 ; + sunrealtype *arg4 = (sunrealtype *) 0 ; + int result; + + arg1 = (SUNTimestepHeuristics)(farg1); + arg2 = (sunrealtype)(*farg2); + arg3 = (sunrealtype)(*farg3); + arg4 = (sunrealtype *)(farg4); + result = (int)SUNTimestepHeuristics_BoundReduction(arg1,arg2,arg3,arg4); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FSUNTimestepHeuristics_BoundFirstStep(SUNTimestepHeuristics farg1, double const *farg2, double *farg3) { + int fresult ; + SUNTimestepHeuristics arg1 = (SUNTimestepHeuristics) 0 ; + sunrealtype arg2 ; + sunrealtype *arg3 = (sunrealtype *) 0 ; + int result; + + arg1 = (SUNTimestepHeuristics)(farg1); + arg2 = (sunrealtype)(*farg2); + arg3 = (sunrealtype *)(farg3); + result = (int)SUNTimestepHeuristics_BoundFirstStep(arg1,arg2,arg3); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FSUNTimestepHeuristics_ConvFail(SUNTimestepHeuristics farg1, double const *farg2, double *farg3) { + int fresult ; + SUNTimestepHeuristics arg1 = (SUNTimestepHeuristics) 0 ; + sunrealtype arg2 ; + sunrealtype *arg3 = (sunrealtype *) 0 ; + int result; + + arg1 = (SUNTimestepHeuristics)(farg1); + arg2 = (sunrealtype)(*farg2); + arg3 = (sunrealtype *)(farg3); + result = (int)SUNTimestepHeuristics_ConvFail(arg1,arg2,arg3); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FSUNTimestepHeuristics_Reset(SUNTimestepHeuristics farg1) { + int fresult ; + SUNTimestepHeuristics arg1 = (SUNTimestepHeuristics) 0 ; + int result; + + arg1 = (SUNTimestepHeuristics)(farg1); + result = (int)SUNTimestepHeuristics_Reset(arg1); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FSUNTimestepHeuristics_Update(SUNTimestepHeuristics farg1) { + int fresult ; + SUNTimestepHeuristics arg1 = (SUNTimestepHeuristics) 0 ; + int result; + + arg1 = (SUNTimestepHeuristics)(farg1); + result = (int)SUNTimestepHeuristics_Update(arg1); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FSUNTimestepHeuristics_SetDefaults(SUNTimestepHeuristics farg1) { + int fresult ; + SUNTimestepHeuristics arg1 = (SUNTimestepHeuristics) 0 ; + int result; + + arg1 = (SUNTimestepHeuristics)(farg1); + result = (int)SUNTimestepHeuristics_SetDefaults(arg1); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FSUNTimestepHeuristics_Write(SUNTimestepHeuristics farg1, void *farg2) { + int fresult ; + SUNTimestepHeuristics arg1 = (SUNTimestepHeuristics) 0 ; + FILE *arg2 = (FILE *) 0 ; + int result; + + arg1 = (SUNTimestepHeuristics)(farg1); + arg2 = (FILE *)(farg2); + result = (int)SUNTimestepHeuristics_Write(arg1,arg2); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FSUNTimestepHeuristics_SetMaxStep(SUNTimestepHeuristics farg1, double const *farg2) { + int fresult ; + SUNTimestepHeuristics arg1 = (SUNTimestepHeuristics) 0 ; + sunrealtype arg2 ; + int result; + + arg1 = (SUNTimestepHeuristics)(farg1); + arg2 = (sunrealtype)(*farg2); + result = (int)SUNTimestepHeuristics_SetMaxStep(arg1,arg2); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FSUNTimestepHeuristics_SetMinStep(SUNTimestepHeuristics farg1, double const *farg2) { + int fresult ; + SUNTimestepHeuristics arg1 = (SUNTimestepHeuristics) 0 ; + sunrealtype arg2 ; + int result; + + arg1 = (SUNTimestepHeuristics)(farg1); + arg2 = (sunrealtype)(*farg2); + result = (int)SUNTimestepHeuristics_SetMinStep(arg1,arg2); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FSUNTimestepHeuristics_SetExpStabFn(SUNTimestepHeuristics farg1, SUNExpStabFn farg2, void *farg3) { + int fresult ; + SUNTimestepHeuristics arg1 = (SUNTimestepHeuristics) 0 ; + SUNExpStabFn arg2 = (SUNExpStabFn) 0 ; + void *arg3 = (void *) 0 ; + int result; + + arg1 = (SUNTimestepHeuristics)(farg1); + arg2 = (SUNExpStabFn)(farg2); + arg3 = (void *)(farg3); + result = (int)SUNTimestepHeuristics_SetExpStabFn(arg1,arg2,arg3); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FSUNTimestepHeuristics_SetCFLFraction(SUNTimestepHeuristics farg1, double const *farg2) { + int fresult ; + SUNTimestepHeuristics arg1 = (SUNTimestepHeuristics) 0 ; + sunrealtype arg2 ; + int result; + + arg1 = (SUNTimestepHeuristics)(farg1); + arg2 = (sunrealtype)(*farg2); + result = (int)SUNTimestepHeuristics_SetCFLFraction(arg1,arg2); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FSUNTimestepHeuristics_SetSafetyFactor(SUNTimestepHeuristics farg1, double const *farg2) { + int fresult ; + SUNTimestepHeuristics arg1 = (SUNTimestepHeuristics) 0 ; + sunrealtype arg2 ; + int result; + + arg1 = (SUNTimestepHeuristics)(farg1); + arg2 = (sunrealtype)(*farg2); + result = (int)SUNTimestepHeuristics_SetSafetyFactor(arg1,arg2); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FSUNTimestepHeuristics_SetMaxGrowth(SUNTimestepHeuristics farg1, double const *farg2) { + int fresult ; + SUNTimestepHeuristics arg1 = (SUNTimestepHeuristics) 0 ; + sunrealtype arg2 ; + int result; + + arg1 = (SUNTimestepHeuristics)(farg1); + arg2 = (sunrealtype)(*farg2); + result = (int)SUNTimestepHeuristics_SetMaxGrowth(arg1,arg2); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FSUNTimestepHeuristics_SetMaxFirstGrowth(SUNTimestepHeuristics farg1, double const *farg2) { + int fresult ; + SUNTimestepHeuristics arg1 = (SUNTimestepHeuristics) 0 ; + sunrealtype arg2 ; + int result; + + arg1 = (SUNTimestepHeuristics)(farg1); + arg2 = (sunrealtype)(*farg2); + result = (int)SUNTimestepHeuristics_SetMaxFirstGrowth(arg1,arg2); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FSUNTimestepHeuristics_SetFixedStepBounds(SUNTimestepHeuristics farg1, double const *farg2, double const *farg3) { + int fresult ; + SUNTimestepHeuristics arg1 = (SUNTimestepHeuristics) 0 ; + sunrealtype arg2 ; + sunrealtype arg3 ; + int result; + + arg1 = (SUNTimestepHeuristics)(farg1); + arg2 = (sunrealtype)(*farg2); + arg3 = (sunrealtype)(*farg3); + result = (int)SUNTimestepHeuristics_SetFixedStepBounds(arg1,arg2,arg3); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FSUNTimestepHeuristics_SetMinReduction(SUNTimestepHeuristics farg1, double const *farg2) { + int fresult ; + SUNTimestepHeuristics arg1 = (SUNTimestepHeuristics) 0 ; + sunrealtype arg2 ; + int result; + + arg1 = (SUNTimestepHeuristics)(farg1); + arg2 = (sunrealtype)(*farg2); + result = (int)SUNTimestepHeuristics_SetMinReduction(arg1,arg2); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FSUNTimestepHeuristics_SetMaxEFailGrowth(SUNTimestepHeuristics farg1, double const *farg2) { + int fresult ; + SUNTimestepHeuristics arg1 = (SUNTimestepHeuristics) 0 ; + sunrealtype arg2 ; + int result; + + arg1 = (SUNTimestepHeuristics)(farg1); + arg2 = (sunrealtype)(*farg2); + result = (int)SUNTimestepHeuristics_SetMaxEFailGrowth(arg1,arg2); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FSUNTimestepHeuristics_SetSmallNumEFails(SUNTimestepHeuristics farg1, int const *farg2) { + int fresult ; + SUNTimestepHeuristics arg1 = (SUNTimestepHeuristics) 0 ; + int arg2 ; + int result; + + arg1 = (SUNTimestepHeuristics)(farg1); + arg2 = (int)(*farg2); + result = (int)SUNTimestepHeuristics_SetSmallNumEFails(arg1,arg2); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FSUNTimestepHeuristics_SetMaxCFailGrowth(SUNTimestepHeuristics farg1, double const *farg2) { + int fresult ; + SUNTimestepHeuristics arg1 = (SUNTimestepHeuristics) 0 ; + sunrealtype arg2 ; + int result; + + arg1 = (SUNTimestepHeuristics)(farg1); + arg2 = (sunrealtype)(*farg2); + result = (int)SUNTimestepHeuristics_SetMaxCFailGrowth(arg1,arg2); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FSUNTimestepHeuristics_GetNumExpSteps(SUNTimestepHeuristics farg1, long *farg2) { + int fresult ; + SUNTimestepHeuristics arg1 = (SUNTimestepHeuristics) 0 ; + long *arg2 = (long *) 0 ; + int result; + + arg1 = (SUNTimestepHeuristics)(farg1); + arg2 = (long *)(farg2); + result = (int)SUNTimestepHeuristics_GetNumExpSteps(arg1,arg2); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FSUNTimestepHeuristics_GetNumAccSteps(SUNTimestepHeuristics farg1, long *farg2) { + int fresult ; + SUNTimestepHeuristics arg1 = (SUNTimestepHeuristics) 0 ; + long *arg2 = (long *) 0 ; + int result; + + arg1 = (SUNTimestepHeuristics)(farg1); + arg2 = (long *)(farg2); + result = (int)SUNTimestepHeuristics_GetNumAccSteps(arg1,arg2); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FSUNTimestepHeuristics_Space(SUNTimestepHeuristics farg1, long *farg2, long *farg3) { + int fresult ; + SUNTimestepHeuristics arg1 = (SUNTimestepHeuristics) 0 ; + long *arg2 = (long *) 0 ; + long *arg3 = (long *) 0 ; + int result; + + arg1 = (SUNTimestepHeuristics)(farg1); + arg2 = (long *)(farg2); + arg3 = (long *)(farg3); + result = (int)SUNTimestepHeuristics_Space(arg1,arg2,arg3); + fresult = (int)(result); + return fresult; +} + + + diff --git a/src/sundials/fmod/fsundials_timestepheuristics_mod.f90 b/src/sundials/fmod/fsundials_timestepheuristics_mod.f90 new file mode 100644 index 0000000000..6493940596 --- /dev/null +++ b/src/sundials/fmod/fsundials_timestepheuristics_mod.f90 @@ -0,0 +1,798 @@ +! 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_timestepheuristics_mod + use, intrinsic :: ISO_C_BINDING + use fsundials_types_mod + use fsundials_context_mod + use fsundials_nvector_mod + use fsundials_context_mod + use fsundials_types_mod + implicit none + private + + ! DECLARATION CONSTRUCTS + ! typedef enum SUNTimestepHeuristics_ID + enum, bind(c) + enumerator :: SUN_TIMESTEPHEURISTICS_STD + enumerator :: SUN_TIMESTEPHEURISTICS_NULL + end enum + integer, parameter, public :: SUNTimestepHeuristics_ID = kind(SUN_TIMESTEPHEURISTICS_STD) + public :: SUN_TIMESTEPHEURISTICS_STD, SUN_TIMESTEPHEURISTICS_NULL + ! struct struct _generic_SUNTimestepHeuristics_Ops + type, bind(C), public :: SUNTimestepHeuristics_Ops + type(C_FUNPTR), public :: getid + type(C_FUNPTR), public :: destroy + type(C_FUNPTR), public :: constrainstep + type(C_FUNPTR), public :: etestfail + type(C_FUNPTR), public :: convfail + type(C_FUNPTR), public :: boundreduction + type(C_FUNPTR), public :: boundfirststep + type(C_FUNPTR), public :: reset + type(C_FUNPTR), public :: update + type(C_FUNPTR), public :: setdefaults + type(C_FUNPTR), public :: write + type(C_FUNPTR), public :: setmaxstep + type(C_FUNPTR), public :: setminstep + type(C_FUNPTR), public :: setexpstabfn + type(C_FUNPTR), public :: setcflfraction + type(C_FUNPTR), public :: setsafetyfactor + type(C_FUNPTR), public :: setmaxgrowth + type(C_FUNPTR), public :: setminreduction + type(C_FUNPTR), public :: setfixedstepbounds + type(C_FUNPTR), public :: setmaxfirstgrowth + type(C_FUNPTR), public :: setmaxefailgrowth + type(C_FUNPTR), public :: setsmallnumefails + type(C_FUNPTR), public :: setmaxcfailgrowth + type(C_FUNPTR), public :: getnumexpsteps + type(C_FUNPTR), public :: getnumaccsteps + type(C_FUNPTR), public :: space + end type SUNTimestepHeuristics_Ops + ! struct struct _generic_SUNTimestepHeuristics + type, bind(C), public :: SUNTimestepHeuristics + type(C_PTR), public :: content + type(C_PTR), public :: ops + type(C_PTR), public :: sunctx + end type SUNTimestepHeuristics + public :: FSUNTimestepHeuristics_NewEmpty + public :: FSUNTimestepHeuristics_GetID + public :: FSUNTimestepHeuristics_Destroy + public :: FSUNTimestepHeuristics_ConstrainStep + public :: FSUNTimestepHeuristics_ETestFail + public :: FSUNTimestepHeuristics_BoundReduction + public :: FSUNTimestepHeuristics_BoundFirstStep + public :: FSUNTimestepHeuristics_ConvFail + public :: FSUNTimestepHeuristics_Reset + public :: FSUNTimestepHeuristics_Update + public :: FSUNTimestepHeuristics_SetDefaults + public :: FSUNTimestepHeuristics_Write + public :: FSUNTimestepHeuristics_SetMaxStep + public :: FSUNTimestepHeuristics_SetMinStep + public :: FSUNTimestepHeuristics_SetExpStabFn + public :: FSUNTimestepHeuristics_SetCFLFraction + public :: FSUNTimestepHeuristics_SetSafetyFactor + public :: FSUNTimestepHeuristics_SetMaxGrowth + public :: FSUNTimestepHeuristics_SetMaxFirstGrowth + public :: FSUNTimestepHeuristics_SetFixedStepBounds + public :: FSUNTimestepHeuristics_SetMinReduction + public :: FSUNTimestepHeuristics_SetMaxEFailGrowth + public :: FSUNTimestepHeuristics_SetSmallNumEFails + public :: FSUNTimestepHeuristics_SetMaxCFailGrowth + public :: FSUNTimestepHeuristics_GetNumExpSteps + public :: FSUNTimestepHeuristics_GetNumAccSteps + public :: FSUNTimestepHeuristics_Space + integer(C_INT), parameter, public :: SUNTIMESTEPHEURISTICS_SUCCESS = 0_C_INT + integer(C_INT), parameter, public :: SUNTIMESTEPHEURISTICS_ILL_INPUT = -1101_C_INT + integer(C_INT), parameter, public :: SUNTIMESTEPHEURISTICS_CANNOT_DECREASE = -1102_C_INT + integer(C_INT), parameter, public :: SUNTIMESTEPHEURISTICS_USER_FCN_FAIL = -1103_C_INT + +! WRAPPER DECLARATIONS +interface +function swigc_FSUNTimestepHeuristics_NewEmpty(farg1) & +bind(C, name="_wrap_FSUNTimestepHeuristics_NewEmpty") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +type(C_PTR), value :: farg1 +type(C_PTR) :: fresult +end function + +function swigc_FSUNTimestepHeuristics_GetID(farg1) & +bind(C, name="_wrap_FSUNTimestepHeuristics_GetID") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +type(C_PTR), value :: farg1 +integer(C_INT) :: fresult +end function + +function swigc_FSUNTimestepHeuristics_Destroy(farg1) & +bind(C, name="_wrap_FSUNTimestepHeuristics_Destroy") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +type(C_PTR), value :: farg1 +integer(C_INT) :: fresult +end function + +function swigc_FSUNTimestepHeuristics_ConstrainStep(farg1, farg2, farg3, farg4) & +bind(C, name="_wrap_FSUNTimestepHeuristics_ConstrainStep") & +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_FSUNTimestepHeuristics_ETestFail(farg1, farg2, farg3, farg4, farg5) & +bind(C, name="_wrap_FSUNTimestepHeuristics_ETestFail") & +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 +type(C_PTR), value :: farg5 +integer(C_INT) :: fresult +end function + +function swigc_FSUNTimestepHeuristics_BoundReduction(farg1, farg2, farg3, farg4) & +bind(C, name="_wrap_FSUNTimestepHeuristics_BoundReduction") & +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_FSUNTimestepHeuristics_BoundFirstStep(farg1, farg2, farg3) & +bind(C, name="_wrap_FSUNTimestepHeuristics_BoundFirstStep") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +type(C_PTR), value :: farg1 +real(C_DOUBLE), intent(in) :: farg2 +type(C_PTR), value :: farg3 +integer(C_INT) :: fresult +end function + +function swigc_FSUNTimestepHeuristics_ConvFail(farg1, farg2, farg3) & +bind(C, name="_wrap_FSUNTimestepHeuristics_ConvFail") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +type(C_PTR), value :: farg1 +real(C_DOUBLE), intent(in) :: farg2 +type(C_PTR), value :: farg3 +integer(C_INT) :: fresult +end function + +function swigc_FSUNTimestepHeuristics_Reset(farg1) & +bind(C, name="_wrap_FSUNTimestepHeuristics_Reset") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +type(C_PTR), value :: farg1 +integer(C_INT) :: fresult +end function + +function swigc_FSUNTimestepHeuristics_Update(farg1) & +bind(C, name="_wrap_FSUNTimestepHeuristics_Update") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +type(C_PTR), value :: farg1 +integer(C_INT) :: fresult +end function + +function swigc_FSUNTimestepHeuristics_SetDefaults(farg1) & +bind(C, name="_wrap_FSUNTimestepHeuristics_SetDefaults") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +type(C_PTR), value :: farg1 +integer(C_INT) :: fresult +end function + +function swigc_FSUNTimestepHeuristics_Write(farg1, farg2) & +bind(C, name="_wrap_FSUNTimestepHeuristics_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_FSUNTimestepHeuristics_SetMaxStep(farg1, farg2) & +bind(C, name="_wrap_FSUNTimestepHeuristics_SetMaxStep") & +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_FSUNTimestepHeuristics_SetMinStep(farg1, farg2) & +bind(C, name="_wrap_FSUNTimestepHeuristics_SetMinStep") & +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_FSUNTimestepHeuristics_SetExpStabFn(farg1, farg2, farg3) & +bind(C, name="_wrap_FSUNTimestepHeuristics_SetExpStabFn") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +type(C_PTR), value :: farg1 +type(C_FUNPTR), value :: farg2 +type(C_PTR), value :: farg3 +integer(C_INT) :: fresult +end function + +function swigc_FSUNTimestepHeuristics_SetCFLFraction(farg1, farg2) & +bind(C, name="_wrap_FSUNTimestepHeuristics_SetCFLFraction") & +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_FSUNTimestepHeuristics_SetSafetyFactor(farg1, farg2) & +bind(C, name="_wrap_FSUNTimestepHeuristics_SetSafetyFactor") & +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_FSUNTimestepHeuristics_SetMaxGrowth(farg1, farg2) & +bind(C, name="_wrap_FSUNTimestepHeuristics_SetMaxGrowth") & +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_FSUNTimestepHeuristics_SetMaxFirstGrowth(farg1, farg2) & +bind(C, name="_wrap_FSUNTimestepHeuristics_SetMaxFirstGrowth") & +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_FSUNTimestepHeuristics_SetFixedStepBounds(farg1, farg2, farg3) & +bind(C, name="_wrap_FSUNTimestepHeuristics_SetFixedStepBounds") & +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_FSUNTimestepHeuristics_SetMinReduction(farg1, farg2) & +bind(C, name="_wrap_FSUNTimestepHeuristics_SetMinReduction") & +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_FSUNTimestepHeuristics_SetMaxEFailGrowth(farg1, farg2) & +bind(C, name="_wrap_FSUNTimestepHeuristics_SetMaxEFailGrowth") & +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_FSUNTimestepHeuristics_SetSmallNumEFails(farg1, farg2) & +bind(C, name="_wrap_FSUNTimestepHeuristics_SetSmallNumEFails") & +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_FSUNTimestepHeuristics_SetMaxCFailGrowth(farg1, farg2) & +bind(C, name="_wrap_FSUNTimestepHeuristics_SetMaxCFailGrowth") & +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_FSUNTimestepHeuristics_GetNumExpSteps(farg1, farg2) & +bind(C, name="_wrap_FSUNTimestepHeuristics_GetNumExpSteps") & +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_FSUNTimestepHeuristics_GetNumAccSteps(farg1, farg2) & +bind(C, name="_wrap_FSUNTimestepHeuristics_GetNumAccSteps") & +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_FSUNTimestepHeuristics_Space(farg1, farg2, farg3) & +bind(C, name="_wrap_FSUNTimestepHeuristics_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 FSUNTimestepHeuristics_NewEmpty(sunctx) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +type(SUNTimestepHeuristics), pointer :: swig_result +type(C_PTR) :: sunctx +type(C_PTR) :: fresult +type(C_PTR) :: farg1 + +farg1 = sunctx +fresult = swigc_FSUNTimestepHeuristics_NewEmpty(farg1) +call c_f_pointer(fresult, swig_result) +end function + +function FSUNTimestepHeuristics_GetID(h) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(SUNTimestepHeuristics_ID) :: swig_result +type(SUNTimestepHeuristics), target, intent(inout) :: h +integer(C_INT) :: fresult +type(C_PTR) :: farg1 + +farg1 = c_loc(h) +fresult = swigc_FSUNTimestepHeuristics_GetID(farg1) +swig_result = fresult +end function + +function FSUNTimestepHeuristics_Destroy(h) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(SUNTimestepHeuristics), target, intent(inout) :: h +integer(C_INT) :: fresult +type(C_PTR) :: farg1 + +farg1 = c_loc(h) +fresult = swigc_FSUNTimestepHeuristics_Destroy(farg1) +swig_result = fresult +end function + +function FSUNTimestepHeuristics_ConstrainStep(h, hcur, hnew, hconstr) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(SUNTimestepHeuristics), target, intent(inout) :: h +real(C_DOUBLE), intent(in) :: hcur +real(C_DOUBLE), intent(in) :: hnew +real(C_DOUBLE), target, intent(inout) :: hconstr +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +real(C_DOUBLE) :: farg2 +real(C_DOUBLE) :: farg3 +type(C_PTR) :: farg4 + +farg1 = c_loc(h) +farg2 = hcur +farg3 = hnew +farg4 = c_loc(hconstr) +fresult = swigc_FSUNTimestepHeuristics_ConstrainStep(farg1, farg2, farg3, farg4) +swig_result = fresult +end function + +function FSUNTimestepHeuristics_ETestFail(h, hcur, hnew, nef, hconstr) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(SUNTimestepHeuristics), target, intent(inout) :: h +real(C_DOUBLE), intent(in) :: hcur +real(C_DOUBLE), intent(in) :: hnew +integer(C_INT), intent(in) :: nef +real(C_DOUBLE), target, intent(inout) :: hconstr +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +real(C_DOUBLE) :: farg2 +real(C_DOUBLE) :: farg3 +integer(C_INT) :: farg4 +type(C_PTR) :: farg5 + +farg1 = c_loc(h) +farg2 = hcur +farg3 = hnew +farg4 = nef +farg5 = c_loc(hconstr) +fresult = swigc_FSUNTimestepHeuristics_ETestFail(farg1, farg2, farg3, farg4, farg5) +swig_result = fresult +end function + +function FSUNTimestepHeuristics_BoundReduction(h, hcur, hnew, hconstr) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(SUNTimestepHeuristics), target, intent(inout) :: h +real(C_DOUBLE), intent(in) :: hcur +real(C_DOUBLE), intent(in) :: hnew +real(C_DOUBLE), target, intent(inout) :: hconstr +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +real(C_DOUBLE) :: farg2 +real(C_DOUBLE) :: farg3 +type(C_PTR) :: farg4 + +farg1 = c_loc(h) +farg2 = hcur +farg3 = hnew +farg4 = c_loc(hconstr) +fresult = swigc_FSUNTimestepHeuristics_BoundReduction(farg1, farg2, farg3, farg4) +swig_result = fresult +end function + +function FSUNTimestepHeuristics_BoundFirstStep(h, h0, h0constr) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(SUNTimestepHeuristics), target, intent(inout) :: h +real(C_DOUBLE), intent(in) :: h0 +real(C_DOUBLE), target, intent(inout) :: h0constr +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +real(C_DOUBLE) :: farg2 +type(C_PTR) :: farg3 + +farg1 = c_loc(h) +farg2 = h0 +farg3 = c_loc(h0constr) +fresult = swigc_FSUNTimestepHeuristics_BoundFirstStep(farg1, farg2, farg3) +swig_result = fresult +end function + +function FSUNTimestepHeuristics_ConvFail(h, hcur, hconstr) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(SUNTimestepHeuristics), target, intent(inout) :: h +real(C_DOUBLE), intent(in) :: hcur +real(C_DOUBLE), target, intent(inout) :: hconstr +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +real(C_DOUBLE) :: farg2 +type(C_PTR) :: farg3 + +farg1 = c_loc(h) +farg2 = hcur +farg3 = c_loc(hconstr) +fresult = swigc_FSUNTimestepHeuristics_ConvFail(farg1, farg2, farg3) +swig_result = fresult +end function + +function FSUNTimestepHeuristics_Reset(h) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(SUNTimestepHeuristics), target, intent(inout) :: h +integer(C_INT) :: fresult +type(C_PTR) :: farg1 + +farg1 = c_loc(h) +fresult = swigc_FSUNTimestepHeuristics_Reset(farg1) +swig_result = fresult +end function + +function FSUNTimestepHeuristics_Update(h) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(SUNTimestepHeuristics), target, intent(inout) :: h +integer(C_INT) :: fresult +type(C_PTR) :: farg1 + +farg1 = c_loc(h) +fresult = swigc_FSUNTimestepHeuristics_Update(farg1) +swig_result = fresult +end function + +function FSUNTimestepHeuristics_SetDefaults(h) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(SUNTimestepHeuristics), target, intent(inout) :: h +integer(C_INT) :: fresult +type(C_PTR) :: farg1 + +farg1 = c_loc(h) +fresult = swigc_FSUNTimestepHeuristics_SetDefaults(farg1) +swig_result = fresult +end function + +function FSUNTimestepHeuristics_Write(h, fptr) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(SUNTimestepHeuristics), target, intent(inout) :: h +type(C_PTR) :: fptr +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 + +farg1 = c_loc(h) +farg2 = fptr +fresult = swigc_FSUNTimestepHeuristics_Write(farg1, farg2) +swig_result = fresult +end function + +function FSUNTimestepHeuristics_SetMaxStep(h, hmax) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(SUNTimestepHeuristics), target, intent(inout) :: h +real(C_DOUBLE), intent(in) :: hmax +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +real(C_DOUBLE) :: farg2 + +farg1 = c_loc(h) +farg2 = hmax +fresult = swigc_FSUNTimestepHeuristics_SetMaxStep(farg1, farg2) +swig_result = fresult +end function + +function FSUNTimestepHeuristics_SetMinStep(h, hmin) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(SUNTimestepHeuristics), target, intent(inout) :: h +real(C_DOUBLE), intent(in) :: hmin +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +real(C_DOUBLE) :: farg2 + +farg1 = c_loc(h) +farg2 = hmin +fresult = swigc_FSUNTimestepHeuristics_SetMinStep(farg1, farg2) +swig_result = fresult +end function + +function FSUNTimestepHeuristics_SetExpStabFn(h, estab, estab_data) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(SUNTimestepHeuristics), target, intent(inout) :: h +type(C_FUNPTR), intent(in), value :: estab +type(C_PTR) :: estab_data +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_FUNPTR) :: farg2 +type(C_PTR) :: farg3 + +farg1 = c_loc(h) +farg2 = estab +farg3 = estab_data +fresult = swigc_FSUNTimestepHeuristics_SetExpStabFn(farg1, farg2, farg3) +swig_result = fresult +end function + +function FSUNTimestepHeuristics_SetCFLFraction(h, cfl_frac) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(SUNTimestepHeuristics), target, intent(inout) :: h +real(C_DOUBLE), intent(in) :: cfl_frac +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +real(C_DOUBLE) :: farg2 + +farg1 = c_loc(h) +farg2 = cfl_frac +fresult = swigc_FSUNTimestepHeuristics_SetCFLFraction(farg1, farg2) +swig_result = fresult +end function + +function FSUNTimestepHeuristics_SetSafetyFactor(c, safety) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(SUNTimestepHeuristics), target, intent(inout) :: c +real(C_DOUBLE), intent(in) :: safety +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +real(C_DOUBLE) :: farg2 + +farg1 = c_loc(c) +farg2 = safety +fresult = swigc_FSUNTimestepHeuristics_SetSafetyFactor(farg1, farg2) +swig_result = fresult +end function + +function FSUNTimestepHeuristics_SetMaxGrowth(h, mx_growth) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(SUNTimestepHeuristics), target, intent(inout) :: h +real(C_DOUBLE), intent(in) :: mx_growth +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +real(C_DOUBLE) :: farg2 + +farg1 = c_loc(h) +farg2 = mx_growth +fresult = swigc_FSUNTimestepHeuristics_SetMaxGrowth(farg1, farg2) +swig_result = fresult +end function + +function FSUNTimestepHeuristics_SetMaxFirstGrowth(h, etamx1) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(SUNTimestepHeuristics), target, intent(inout) :: h +real(C_DOUBLE), intent(in) :: etamx1 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +real(C_DOUBLE) :: farg2 + +farg1 = c_loc(h) +farg2 = etamx1 +fresult = swigc_FSUNTimestepHeuristics_SetMaxFirstGrowth(farg1, farg2) +swig_result = fresult +end function + +function FSUNTimestepHeuristics_SetFixedStepBounds(h, lb, ub) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(SUNTimestepHeuristics), target, intent(inout) :: h +real(C_DOUBLE), intent(in) :: lb +real(C_DOUBLE), intent(in) :: ub +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +real(C_DOUBLE) :: farg2 +real(C_DOUBLE) :: farg3 + +farg1 = c_loc(h) +farg2 = lb +farg3 = ub +fresult = swigc_FSUNTimestepHeuristics_SetFixedStepBounds(farg1, farg2, farg3) +swig_result = fresult +end function + +function FSUNTimestepHeuristics_SetMinReduction(h, eta_min) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(SUNTimestepHeuristics), target, intent(inout) :: h +real(C_DOUBLE), intent(in) :: eta_min +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +real(C_DOUBLE) :: farg2 + +farg1 = c_loc(h) +farg2 = eta_min +fresult = swigc_FSUNTimestepHeuristics_SetMinReduction(farg1, farg2) +swig_result = fresult +end function + +function FSUNTimestepHeuristics_SetMaxEFailGrowth(h, etamxf) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(SUNTimestepHeuristics), target, intent(inout) :: h +real(C_DOUBLE), intent(in) :: etamxf +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +real(C_DOUBLE) :: farg2 + +farg1 = c_loc(h) +farg2 = etamxf +fresult = swigc_FSUNTimestepHeuristics_SetMaxEFailGrowth(farg1, farg2) +swig_result = fresult +end function + +function FSUNTimestepHeuristics_SetSmallNumEFails(h, small_nef) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(SUNTimestepHeuristics), target, intent(inout) :: h +integer(C_INT), intent(in) :: small_nef +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +integer(C_INT) :: farg2 + +farg1 = c_loc(h) +farg2 = small_nef +fresult = swigc_FSUNTimestepHeuristics_SetSmallNumEFails(farg1, farg2) +swig_result = fresult +end function + +function FSUNTimestepHeuristics_SetMaxCFailGrowth(h, etacf) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(SUNTimestepHeuristics), target, intent(inout) :: h +real(C_DOUBLE), intent(in) :: etacf +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +real(C_DOUBLE) :: farg2 + +farg1 = c_loc(h) +farg2 = etacf +fresult = swigc_FSUNTimestepHeuristics_SetMaxCFailGrowth(farg1, farg2) +swig_result = fresult +end function + +function FSUNTimestepHeuristics_GetNumExpSteps(h, expsteps) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(SUNTimestepHeuristics), target, intent(inout) :: h +integer(C_LONG), dimension(*), target, intent(inout) :: expsteps +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 + +farg1 = c_loc(h) +farg2 = c_loc(expsteps(1)) +fresult = swigc_FSUNTimestepHeuristics_GetNumExpSteps(farg1, farg2) +swig_result = fresult +end function + +function FSUNTimestepHeuristics_GetNumAccSteps(h, accsteps) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(SUNTimestepHeuristics), target, intent(inout) :: h +integer(C_LONG), dimension(*), target, intent(inout) :: accsteps +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 + +farg1 = c_loc(h) +farg2 = c_loc(accsteps(1)) +fresult = swigc_FSUNTimestepHeuristics_GetNumAccSteps(farg1, farg2) +swig_result = fresult +end function + +function FSUNTimestepHeuristics_Space(h, lenrw, leniw) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(SUNTimestepHeuristics), target, intent(inout) :: h +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(h) +farg2 = c_loc(lenrw(1)) +farg3 = c_loc(leniw(1)) +fresult = swigc_FSUNTimestepHeuristics_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/src/sundials/sundials_timestepheuristics.c b/src/sundials/sundials_timestepheuristics.c new file mode 100644 index 0000000000..5806c35e89 --- /dev/null +++ b/src/sundials/sundials_timestepheuristics.c @@ -0,0 +1,376 @@ +/* ----------------------------------------------------------------- + * 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 + * SUNTimestepHeuristics package. It contains the implementation of + * the SUNTimestepHeuristics operations listed in + * sundials_timestepheuristics.h + * -----------------------------------------------------------------*/ + +#include +#include + +/* ----------------------------------------------------------------- + * Create a new empty SUNTimestepHeuristics object + * ----------------------------------------------------------------- */ + +SUNTimestepHeuristics SUNTimestepHeuristics_NewEmpty(SUNContext sunctx) +{ + SUNTimestepHeuristics H; + SUNTimestepHeuristics_Ops ops; + + /* a context is required */ + if (sunctx == NULL) return(NULL); + + /* create heuristics object */ + H = NULL; + H = (SUNTimestepHeuristics) malloc(sizeof *H); + if (H == NULL) return(NULL); + + /* create matrix ops structure */ + ops = NULL; + ops = (SUNTimestepHeuristics_Ops) malloc(sizeof *ops); + if (ops == NULL) { free(H); return(NULL); } + + /* initialize operations to NULL */ + ops->getid = NULL; + ops->destroy = NULL; + ops->constrainstep = NULL; + ops->etestfail = NULL; + ops->convfail = NULL; + ops->boundreduction = NULL; + ops->boundfirststep = NULL; + ops->reset = NULL; + ops->update = NULL; + ops->setdefaults = NULL; + ops->write = NULL; + ops->setmaxstep = NULL; + ops->setminstep = NULL; + ops->setexpstabfn = NULL; + ops->setcflfraction = NULL; + ops->setsafetyfactor = NULL; + ops->setmaxgrowth = NULL; + ops->setminreduction = NULL; + ops->setfixedstepbounds = NULL; + ops->setmaxfirstgrowth = NULL; + ops->setmaxefailgrowth = NULL; + ops->setsmallnumefails = NULL; + ops->setmaxcfailgrowth = NULL; + ops->getnumexpsteps = NULL; + ops->getnumaccsteps = NULL; + ops->space = NULL; + + /* attach ops and initialize content to NULL */ + H->ops = ops; + H->content = NULL; + H->sunctx = sunctx; + + return(H); +} + + +/* ----------------------------------------------------------------- + * Required functions in the 'ops' structure + * ----------------------------------------------------------------- */ + +SUNTimestepHeuristics_ID SUNTimestepHeuristics_GetID(SUNTimestepHeuristics H) +{ + if (H == NULL) { return SUN_TIMESTEPHEURISTICS_NULL; } + return(H->ops->getid(H)); +} + +/* ----------------------------------------------------------------- + * Optional functions in the 'ops' structure + * ----------------------------------------------------------------- */ + +int SUNTimestepHeuristics_Destroy(SUNTimestepHeuristics H) +{ + if (H == NULL) return(SUNTIMESTEPHEURISTICS_SUCCESS); + + /* if the destroy operation exists use it */ + if (H->ops) + if (H->ops->destroy) { return(H->ops->destroy(H)); } + + /* if we reach this point, either ops == NULL or destroy == NULL, + try to cleanup by freeing the content, ops, and matrix */ + if (H->content) { free(H->content); H->content = NULL; } + if (H->ops) { free(H->ops); H->ops = NULL; } + free(H); H = NULL; + + return(SUNTIMESTEPHEURISTICS_SUCCESS); +} + +int SUNTimestepHeuristics_ConstrainStep(SUNTimestepHeuristics H, + sunrealtype hcur, + sunrealtype hnew, sunrealtype *hconstr) +{ + int ier = 0; + *hconstr = hnew; /* initialize output with identity */ + if (H->ops->constrainstep) + { + ier = H->ops->constrainstep(H, hcur, hnew, hconstr); + } + return(ier); +} + +int SUNTimestepHeuristics_ETestFail(SUNTimestepHeuristics H, + sunrealtype hcur, + sunrealtype hnew, int nef, + sunrealtype *hconstr) +{ + int ier = 0; + *hconstr = hnew; /* initialize output with identity */ + if (H->ops->etestfail) + { + ier = H->ops->etestfail(H, hcur, hnew, nef, hconstr); + } + return(ier); +} + +int SUNTimestepHeuristics_ConvFail(SUNTimestepHeuristics H, + sunrealtype hcur, + sunrealtype *hconstr) +{ + int ier = 0; + *hconstr = hcur; /* initialize output with identity */ + if (H->ops->convfail) + { + ier = H->ops->convfail(H, hcur, hconstr); + } + return(ier); +} + +int SUNTimestepHeuristics_BoundReduction(SUNTimestepHeuristics H, + sunrealtype hcur, + sunrealtype hnew, + sunrealtype *hconstr) +{ + int ier = 0; + *hconstr = hnew; /* initialize output with identity */ + if (H->ops->boundreduction) + { + ier = H->ops->boundreduction(H, hcur, hnew, hconstr); + } + return(ier); +} + + +int SUNTimestepHeuristics_BoundFirstStep(SUNTimestepHeuristics H, + sunrealtype h0, + sunrealtype *h0constr) +{ + int ier = 0; + *h0constr = h0; /* initialize output with identity */ + if (H->ops->boundfirststep) + { + ier = H->ops->boundfirststep(H, h0, h0constr); + } + return(ier); +} + + +int SUNTimestepHeuristics_Reset(SUNTimestepHeuristics H) +{ + int ier = 0; + if (H->ops->reset) { ier = H->ops->reset(H); } + return(ier); +} + +int SUNTimestepHeuristics_Update(SUNTimestepHeuristics H) +{ + int ier = 0; + if (H->ops->update) { ier = H->ops->update(H); } + return(ier); +} + +int SUNTimestepHeuristics_SetDefaults(SUNTimestepHeuristics H) +{ + int ier = 0; + if (H->ops->setdefaults) { ier = H->ops->setdefaults(H); } + return(ier); +} + +int SUNTimestepHeuristics_Write(SUNTimestepHeuristics H, FILE* fptr) +{ + int ier = 0; + if (H->ops->write) { ier = H->ops->write(H, fptr); } + return(ier); +} + +int SUNTimestepHeuristics_SetMaxStep(SUNTimestepHeuristics H, + sunrealtype hmax) +{ + int ier = 0; + if (H->ops->setmaxstep) + { + ier = H->ops->setmaxstep(H, hmax); + } + return(ier); +} + +int SUNTimestepHeuristics_SetMinStep(SUNTimestepHeuristics H, + sunrealtype hmin) +{ + int ier = 0; + if (H->ops->setminstep) + { + ier = H->ops->setminstep(H, hmin); + } + return(ier); +} + +int SUNTimestepHeuristics_SetExpStabFn(SUNTimestepHeuristics H, + SUNExpStabFn EStab, + void* estab_data) +{ + int ier = 0; + if (H->ops->setexpstabfn) + { + ier = H->ops->setexpstabfn(H, EStab, estab_data); + } + return(ier); +} + +int SUNTimestepHeuristics_SetCFLFraction(SUNTimestepHeuristics H, + sunrealtype cfl_frac) +{ + int ier = 0; + if (H->ops->setcflfraction) + { + ier = H->ops->setcflfraction(H, cfl_frac); + } + return(ier); +} + +int SUNTimestepHeuristics_SetSafetyFactor(SUNTimestepHeuristics H, + sunrealtype safety) +{ + int ier = 0; + if (H->ops->setsafetyfactor) + { + ier = H->ops->setsafetyfactor(H, safety); + } + return(ier); +} + +int SUNTimestepHeuristics_SetMaxGrowth(SUNTimestepHeuristics H, + sunrealtype mx_growth) +{ + int ier = 0; + if (H->ops->setmaxgrowth) + { + ier = H->ops->setmaxgrowth(H, mx_growth); + } + return(ier); +} + +int SUNTimestepHeuristics_SetMinReduction(SUNTimestepHeuristics H, + sunrealtype eta_min) +{ + int ier = 0; + if (H->ops->setminreduction) + { + ier = H->ops->setminreduction(H, eta_min); + } + return(ier); +} + +int SUNTimestepHeuristics_SetFixedStepBounds(SUNTimestepHeuristics H, + sunrealtype lb, sunrealtype ub) +{ + int ier = 0; + if (H->ops->setfixedstepbounds) + { + ier = H->ops->setfixedstepbounds(H, lb, ub); + } + return(ier); +} + +int SUNTimestepHeuristics_SetMaxFirstGrowth(SUNTimestepHeuristics H, + sunrealtype etamx1) +{ + int ier = 0; + if (H->ops->setmaxfirstgrowth) + { + ier = H->ops->setmaxfirstgrowth(H, etamx1); + } + return(ier); +} + +int SUNTimestepHeuristics_SetMaxEFailGrowth(SUNTimestepHeuristics H, + sunrealtype etamxf) +{ + int ier = 0; + if (H->ops->setmaxefailgrowth) + { + ier = H->ops->setmaxefailgrowth(H, etamxf); + } + return(ier); +} + +int SUNTimestepHeuristics_SetSmallNumEFails(SUNTimestepHeuristics H, + int small_nef) +{ + int ier = 0; + if (H->ops->setsmallnumefails) + { + ier = H->ops->setsmallnumefails(H, small_nef); + } + return(ier); +} + +int SUNTimestepHeuristics_SetMaxCFailGrowth(SUNTimestepHeuristics H, + sunrealtype etacf) +{ + int ier = 0; + if (H->ops->setmaxcfailgrowth) + { + ier = H->ops->setmaxcfailgrowth(H, etacf); + } + return(ier); +} + +int SUNTimestepHeuristics_GetNumExpSteps(SUNTimestepHeuristics H, + long int* expsteps) +{ + int ier = 0; + *expsteps = 0; /* initialize output with identity */ + if (H->ops->getnumexpsteps) + { + ier = H->ops->getnumexpsteps(H, expsteps); + } + return(ier); +} + +int SUNTimestepHeuristics_GetNumAccSteps(SUNTimestepHeuristics H, + long int* accsteps) +{ + int ier = 0; + *accsteps = 0; /* initialize output with identity */ + if (H->ops->getnumaccsteps) + { + ier = H->ops->getnumaccsteps(H, accsteps); + } + return(ier); +} + +int SUNTimestepHeuristics_Space(SUNTimestepHeuristics H, + long int *lenrw, + long int *leniw) +{ + int ier = 0; + *lenrw = 0; /* initialize outputs with identity */ + *leniw = 0; + if (H->ops->space) { ier = H->ops->space(H, lenrw, leniw); } + return(ier); +} diff --git a/src/sunmemory/CMakeLists.txt b/src/sunmemory/CMakeLists.txt index 95def3bd32..fdd24b73cd 100644 --- a/src/sunmemory/CMakeLists.txt +++ b/src/sunmemory/CMakeLists.txt @@ -14,10 +14,6 @@ # SUNMemory level CMakeLists.txt for SUNDIALS # ------------------------------------------------------------------------------ -if(ENABLE_CALIPER AND SUNDIALS_BUILD_WITH_PROFILING) - include_directories(${caliper_INCLUDE_DIR}) -endif() - add_subdirectory(system) if(ENABLE_CUDA) diff --git a/src/suntimestepheuristics/CMakeLists.txt b/src/suntimestepheuristics/CMakeLists.txt new file mode 100644 index 0000000000..72398d3ee8 --- /dev/null +++ b/src/suntimestepheuristics/CMakeLists.txt @@ -0,0 +1,19 @@ +# ------------------------------------------------------------------------------ +# 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 +# ------------------------------------------------------------------------------ +# suntimestepheuristics level CMakeLists.txt for SUNDIALS +# ------------------------------------------------------------------------------ + +# required native matrices +add_subdirectory(default) +add_subdirectory(unconstrained) diff --git a/src/suntimestepheuristics/default/CMakeLists.txt b/src/suntimestepheuristics/default/CMakeLists.txt new file mode 100644 index 0000000000..d50453868f --- /dev/null +++ b/src/suntimestepheuristics/default/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_suntimestepheuristicsdefault + SOURCES + suntimestepheuristics_default.c + HEADERS + ${SUNDIALS_SOURCE_DIR}/include/suntimestepheuristics/suntimestepheuristics_default.h + INCLUDE_SUBDIR + suntimestepheuristics + OBJECT_LIB_ONLY +) + +# Add F2003 module if the interface is enabled +if(BUILD_FORTRAN_MODULE_INTERFACE) + add_subdirectory(fmod) +endif() diff --git a/src/suntimestepheuristics/default/fmod/CMakeLists.txt b/src/suntimestepheuristics/default/fmod/CMakeLists.txt new file mode 100644 index 0000000000..ed0c1f6ac9 --- /dev/null +++ b/src/suntimestepheuristics/default/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_fsuntimestepheuristicsdefault_mod + SOURCES + fsuntimestepheuristics_default_mod.f90 fsuntimestepheuristics_default_mod.c + OBJECT_LIBRARIES + sundials_fgeneric_mod_obj + OUTPUT_NAME + sundials_fsuntimestepheuristics_default_mod + OBJECT_LIB_ONLY +) + +message(STATUS "Added SUNTimestepHeuristics_Default F2003 interface") diff --git a/src/suntimestepheuristics/default/fmod/fsuntimestepheuristics_default_mod.c b/src/suntimestepheuristics/default/fmod/fsuntimestepheuristics_default_mod.c new file mode 100644 index 0000000000..fb4e901238 --- /dev/null +++ b/src/suntimestepheuristics/default/fmod/fsuntimestepheuristics_default_mod.c @@ -0,0 +1,589 @@ +/* ---------------------------------------------------------------------------- + * 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_timestepheuristics.h" + + +#include "suntimestepheuristics/suntimestepheuristics_default.h" + +SWIGEXPORT SUNTimestepHeuristics _wrap_FSUNTimestepHeuristics_Default(void *farg1) { + SUNTimestepHeuristics fresult ; + SUNContext arg1 = (SUNContext) 0 ; + SUNTimestepHeuristics result; + + arg1 = (SUNContext)(farg1); + result = (SUNTimestepHeuristics)SUNTimestepHeuristics_Default(arg1); + fresult = result; + return fresult; +} + + +SWIGEXPORT int _wrap_FSUNTimestepHeuristics_GetID_Default(SUNTimestepHeuristics farg1) { + int fresult ; + SUNTimestepHeuristics arg1 = (SUNTimestepHeuristics) 0 ; + SUNTimestepHeuristics_ID result; + + arg1 = (SUNTimestepHeuristics)(farg1); + result = (SUNTimestepHeuristics_ID)SUNTimestepHeuristics_GetID_Default(arg1); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FSUNTimestepHeuristics_ConstrainStep_Default(SUNTimestepHeuristics farg1, double const *farg2, double const *farg3, double *farg4) { + int fresult ; + SUNTimestepHeuristics arg1 = (SUNTimestepHeuristics) 0 ; + sunrealtype arg2 ; + sunrealtype arg3 ; + sunrealtype *arg4 = (sunrealtype *) 0 ; + int result; + + arg1 = (SUNTimestepHeuristics)(farg1); + arg2 = (sunrealtype)(*farg2); + arg3 = (sunrealtype)(*farg3); + arg4 = (sunrealtype *)(farg4); + result = (int)SUNTimestepHeuristics_ConstrainStep_Default(arg1,arg2,arg3,arg4); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FSUNTimestepHeuristics_ETestFail_Default(SUNTimestepHeuristics farg1, double const *farg2, double const *farg3, int const *farg4, double *farg5) { + int fresult ; + SUNTimestepHeuristics arg1 = (SUNTimestepHeuristics) 0 ; + sunrealtype arg2 ; + sunrealtype arg3 ; + int arg4 ; + sunrealtype *arg5 = (sunrealtype *) 0 ; + int result; + + arg1 = (SUNTimestepHeuristics)(farg1); + arg2 = (sunrealtype)(*farg2); + arg3 = (sunrealtype)(*farg3); + arg4 = (int)(*farg4); + arg5 = (sunrealtype *)(farg5); + result = (int)SUNTimestepHeuristics_ETestFail_Default(arg1,arg2,arg3,arg4,arg5); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FSUNTimestepHeuristics_ConvFail_Default(SUNTimestepHeuristics farg1, double const *farg2, double *farg3) { + int fresult ; + SUNTimestepHeuristics arg1 = (SUNTimestepHeuristics) 0 ; + sunrealtype arg2 ; + sunrealtype *arg3 = (sunrealtype *) 0 ; + int result; + + arg1 = (SUNTimestepHeuristics)(farg1); + arg2 = (sunrealtype)(*farg2); + arg3 = (sunrealtype *)(farg3); + result = (int)SUNTimestepHeuristics_ConvFail_Default(arg1,arg2,arg3); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FSUNTimestepHeuristics_BoundReduction_Default(SUNTimestepHeuristics farg1, double const *farg2, double const *farg3, double *farg4) { + int fresult ; + SUNTimestepHeuristics arg1 = (SUNTimestepHeuristics) 0 ; + sunrealtype arg2 ; + sunrealtype arg3 ; + sunrealtype *arg4 = (sunrealtype *) 0 ; + int result; + + arg1 = (SUNTimestepHeuristics)(farg1); + arg2 = (sunrealtype)(*farg2); + arg3 = (sunrealtype)(*farg3); + arg4 = (sunrealtype *)(farg4); + result = (int)SUNTimestepHeuristics_BoundReduction_Default(arg1,arg2,arg3,arg4); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FSUNTimestepHeuristics_BoundFirstStep_Default(SUNTimestepHeuristics farg1, double const *farg2, double *farg3) { + int fresult ; + SUNTimestepHeuristics arg1 = (SUNTimestepHeuristics) 0 ; + sunrealtype arg2 ; + sunrealtype *arg3 = (sunrealtype *) 0 ; + int result; + + arg1 = (SUNTimestepHeuristics)(farg1); + arg2 = (sunrealtype)(*farg2); + arg3 = (sunrealtype *)(farg3); + result = (int)SUNTimestepHeuristics_BoundFirstStep_Default(arg1,arg2,arg3); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FSUNTimestepHeuristics_Reset_Default(SUNTimestepHeuristics farg1) { + int fresult ; + SUNTimestepHeuristics arg1 = (SUNTimestepHeuristics) 0 ; + int result; + + arg1 = (SUNTimestepHeuristics)(farg1); + result = (int)SUNTimestepHeuristics_Reset_Default(arg1); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FSUNTimestepHeuristics_Update_Default(SUNTimestepHeuristics farg1) { + int fresult ; + SUNTimestepHeuristics arg1 = (SUNTimestepHeuristics) 0 ; + int result; + + arg1 = (SUNTimestepHeuristics)(farg1); + result = (int)SUNTimestepHeuristics_Update_Default(arg1); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FSUNTimestepHeuristics_SetDefaults_Default(SUNTimestepHeuristics farg1) { + int fresult ; + SUNTimestepHeuristics arg1 = (SUNTimestepHeuristics) 0 ; + int result; + + arg1 = (SUNTimestepHeuristics)(farg1); + result = (int)SUNTimestepHeuristics_SetDefaults_Default(arg1); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FSUNTimestepHeuristics_Write_Default(SUNTimestepHeuristics farg1, void *farg2) { + int fresult ; + SUNTimestepHeuristics arg1 = (SUNTimestepHeuristics) 0 ; + FILE *arg2 = (FILE *) 0 ; + int result; + + arg1 = (SUNTimestepHeuristics)(farg1); + arg2 = (FILE *)(farg2); + result = (int)SUNTimestepHeuristics_Write_Default(arg1,arg2); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FSUNTimestepHeuristics_SetMaxStep_Default(SUNTimestepHeuristics farg1, double const *farg2) { + int fresult ; + SUNTimestepHeuristics arg1 = (SUNTimestepHeuristics) 0 ; + sunrealtype arg2 ; + int result; + + arg1 = (SUNTimestepHeuristics)(farg1); + arg2 = (sunrealtype)(*farg2); + result = (int)SUNTimestepHeuristics_SetMaxStep_Default(arg1,arg2); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FSUNTimestepHeuristics_SetMinStep_Default(SUNTimestepHeuristics farg1, double const *farg2) { + int fresult ; + SUNTimestepHeuristics arg1 = (SUNTimestepHeuristics) 0 ; + sunrealtype arg2 ; + int result; + + arg1 = (SUNTimestepHeuristics)(farg1); + arg2 = (sunrealtype)(*farg2); + result = (int)SUNTimestepHeuristics_SetMinStep_Default(arg1,arg2); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FSUNTimestepHeuristics_SetExpStabFn_Default(SUNTimestepHeuristics farg1, SUNExpStabFn farg2, void *farg3) { + int fresult ; + SUNTimestepHeuristics arg1 = (SUNTimestepHeuristics) 0 ; + SUNExpStabFn arg2 = (SUNExpStabFn) 0 ; + void *arg3 = (void *) 0 ; + int result; + + arg1 = (SUNTimestepHeuristics)(farg1); + arg2 = (SUNExpStabFn)(farg2); + arg3 = (void *)(farg3); + result = (int)SUNTimestepHeuristics_SetExpStabFn_Default(arg1,arg2,arg3); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FSUNTimestepHeuristics_SetCFLFraction_Default(SUNTimestepHeuristics farg1, double const *farg2) { + int fresult ; + SUNTimestepHeuristics arg1 = (SUNTimestepHeuristics) 0 ; + sunrealtype arg2 ; + int result; + + arg1 = (SUNTimestepHeuristics)(farg1); + arg2 = (sunrealtype)(*farg2); + result = (int)SUNTimestepHeuristics_SetCFLFraction_Default(arg1,arg2); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FSUNTimestepHeuristics_SetSafetyFactor_Default(SUNTimestepHeuristics farg1, double const *farg2) { + int fresult ; + SUNTimestepHeuristics arg1 = (SUNTimestepHeuristics) 0 ; + sunrealtype arg2 ; + int result; + + arg1 = (SUNTimestepHeuristics)(farg1); + arg2 = (sunrealtype)(*farg2); + result = (int)SUNTimestepHeuristics_SetSafetyFactor_Default(arg1,arg2); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FSUNTimestepHeuristics_SetMaxGrowth_Default(SUNTimestepHeuristics farg1, double const *farg2) { + int fresult ; + SUNTimestepHeuristics arg1 = (SUNTimestepHeuristics) 0 ; + sunrealtype arg2 ; + int result; + + arg1 = (SUNTimestepHeuristics)(farg1); + arg2 = (sunrealtype)(*farg2); + result = (int)SUNTimestepHeuristics_SetMaxGrowth_Default(arg1,arg2); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FSUNTimestepHeuristics_SetMinReduction_Default(SUNTimestepHeuristics farg1, double const *farg2) { + int fresult ; + SUNTimestepHeuristics arg1 = (SUNTimestepHeuristics) 0 ; + sunrealtype arg2 ; + int result; + + arg1 = (SUNTimestepHeuristics)(farg1); + arg2 = (sunrealtype)(*farg2); + result = (int)SUNTimestepHeuristics_SetMinReduction_Default(arg1,arg2); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FSUNTimestepHeuristics_SetFixedStepBounds_Default(SUNTimestepHeuristics farg1, double const *farg2, double const *farg3) { + int fresult ; + SUNTimestepHeuristics arg1 = (SUNTimestepHeuristics) 0 ; + sunrealtype arg2 ; + sunrealtype arg3 ; + int result; + + arg1 = (SUNTimestepHeuristics)(farg1); + arg2 = (sunrealtype)(*farg2); + arg3 = (sunrealtype)(*farg3); + result = (int)SUNTimestepHeuristics_SetFixedStepBounds_Default(arg1,arg2,arg3); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FSUNTimestepHeuristics_SetMaxFirstGrowth_Default(SUNTimestepHeuristics farg1, double const *farg2) { + int fresult ; + SUNTimestepHeuristics arg1 = (SUNTimestepHeuristics) 0 ; + sunrealtype arg2 ; + int result; + + arg1 = (SUNTimestepHeuristics)(farg1); + arg2 = (sunrealtype)(*farg2); + result = (int)SUNTimestepHeuristics_SetMaxFirstGrowth_Default(arg1,arg2); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FSUNTimestepHeuristics_SetMaxEFailGrowth_Default(SUNTimestepHeuristics farg1, double const *farg2) { + int fresult ; + SUNTimestepHeuristics arg1 = (SUNTimestepHeuristics) 0 ; + sunrealtype arg2 ; + int result; + + arg1 = (SUNTimestepHeuristics)(farg1); + arg2 = (sunrealtype)(*farg2); + result = (int)SUNTimestepHeuristics_SetMaxEFailGrowth_Default(arg1,arg2); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FSUNTimestepHeuristics_SetSmallNumEFails_Default(SUNTimestepHeuristics farg1, int const *farg2) { + int fresult ; + SUNTimestepHeuristics arg1 = (SUNTimestepHeuristics) 0 ; + int arg2 ; + int result; + + arg1 = (SUNTimestepHeuristics)(farg1); + arg2 = (int)(*farg2); + result = (int)SUNTimestepHeuristics_SetSmallNumEFails_Default(arg1,arg2); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FSUNTimestepHeuristics_SetMaxCFailGrowth_Default(SUNTimestepHeuristics farg1, double const *farg2) { + int fresult ; + SUNTimestepHeuristics arg1 = (SUNTimestepHeuristics) 0 ; + sunrealtype arg2 ; + int result; + + arg1 = (SUNTimestepHeuristics)(farg1); + arg2 = (sunrealtype)(*farg2); + result = (int)SUNTimestepHeuristics_SetMaxCFailGrowth_Default(arg1,arg2); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FSUNTimestepHeuristics_GetNumExpSteps_Default(SUNTimestepHeuristics farg1, long *farg2) { + int fresult ; + SUNTimestepHeuristics arg1 = (SUNTimestepHeuristics) 0 ; + long *arg2 = (long *) 0 ; + int result; + + arg1 = (SUNTimestepHeuristics)(farg1); + arg2 = (long *)(farg2); + result = (int)SUNTimestepHeuristics_GetNumExpSteps_Default(arg1,arg2); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FSUNTimestepHeuristics_GetNumAccSteps_Default(SUNTimestepHeuristics farg1, long *farg2) { + int fresult ; + SUNTimestepHeuristics arg1 = (SUNTimestepHeuristics) 0 ; + long *arg2 = (long *) 0 ; + int result; + + arg1 = (SUNTimestepHeuristics)(farg1); + arg2 = (long *)(farg2); + result = (int)SUNTimestepHeuristics_GetNumAccSteps_Default(arg1,arg2); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FSUNTimestepHeuristics_Space_Default(SUNTimestepHeuristics farg1, long *farg2, long *farg3) { + int fresult ; + SUNTimestepHeuristics arg1 = (SUNTimestepHeuristics) 0 ; + long *arg2 = (long *) 0 ; + long *arg3 = (long *) 0 ; + int result; + + arg1 = (SUNTimestepHeuristics)(farg1); + arg2 = (long *)(farg2); + arg3 = (long *)(farg3); + result = (int)SUNTimestepHeuristics_Space_Default(arg1,arg2,arg3); + fresult = (int)(result); + return fresult; +} + + + diff --git a/src/suntimestepheuristics/default/fmod/fsuntimestepheuristics_default_mod.f90 b/src/suntimestepheuristics/default/fmod/fsuntimestepheuristics_default_mod.f90 new file mode 100644 index 0000000000..31b0f204fa --- /dev/null +++ b/src/suntimestepheuristics/default/fmod/fsuntimestepheuristics_default_mod.f90 @@ -0,0 +1,747 @@ +! 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 fsuntimestepheuristics_default_mod + use, intrinsic :: ISO_C_BINDING + use fsundials_nvector_mod + use fsundials_context_mod + use fsundials_types_mod + use fsundials_timestepheuristics_mod + use fsundials_nvector_mod + use fsundials_context_mod + use fsundials_types_mod + implicit none + private + + ! DECLARATION CONSTRUCTS + public :: FSUNTimestepHeuristics_Default + public :: FSUNTimestepHeuristics_GetID_Default + public :: FSUNTimestepHeuristics_ConstrainStep_Default + public :: FSUNTimestepHeuristics_ETestFail_Default + public :: FSUNTimestepHeuristics_ConvFail_Default + public :: FSUNTimestepHeuristics_BoundReduction_Default + public :: FSUNTimestepHeuristics_BoundFirstStep_Default + public :: FSUNTimestepHeuristics_Reset_Default + public :: FSUNTimestepHeuristics_Update_Default + public :: FSUNTimestepHeuristics_SetDefaults_Default + public :: FSUNTimestepHeuristics_Write_Default + public :: FSUNTimestepHeuristics_SetMaxStep_Default + public :: FSUNTimestepHeuristics_SetMinStep_Default + public :: FSUNTimestepHeuristics_SetExpStabFn_Default + public :: FSUNTimestepHeuristics_SetCFLFraction_Default + public :: FSUNTimestepHeuristics_SetSafetyFactor_Default + public :: FSUNTimestepHeuristics_SetMaxGrowth_Default + public :: FSUNTimestepHeuristics_SetMinReduction_Default + public :: FSUNTimestepHeuristics_SetFixedStepBounds_Default + public :: FSUNTimestepHeuristics_SetMaxFirstGrowth_Default + public :: FSUNTimestepHeuristics_SetMaxEFailGrowth_Default + public :: FSUNTimestepHeuristics_SetSmallNumEFails_Default + public :: FSUNTimestepHeuristics_SetMaxCFailGrowth_Default + public :: FSUNTimestepHeuristics_GetNumExpSteps_Default + public :: FSUNTimestepHeuristics_GetNumAccSteps_Default + public :: FSUNTimestepHeuristics_Space_Default + +! WRAPPER DECLARATIONS +interface +function swigc_FSUNTimestepHeuristics_Default(farg1) & +bind(C, name="_wrap_FSUNTimestepHeuristics_Default") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +type(C_PTR), value :: farg1 +type(C_PTR) :: fresult +end function + +function swigc_FSUNTimestepHeuristics_GetID_Default(farg1) & +bind(C, name="_wrap_FSUNTimestepHeuristics_GetID_Default") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +type(C_PTR), value :: farg1 +integer(C_INT) :: fresult +end function + +function swigc_FSUNTimestepHeuristics_ConstrainStep_Default(farg1, farg2, farg3, farg4) & +bind(C, name="_wrap_FSUNTimestepHeuristics_ConstrainStep_Default") & +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_FSUNTimestepHeuristics_ETestFail_Default(farg1, farg2, farg3, farg4, farg5) & +bind(C, name="_wrap_FSUNTimestepHeuristics_ETestFail_Default") & +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 +type(C_PTR), value :: farg5 +integer(C_INT) :: fresult +end function + +function swigc_FSUNTimestepHeuristics_ConvFail_Default(farg1, farg2, farg3) & +bind(C, name="_wrap_FSUNTimestepHeuristics_ConvFail_Default") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +type(C_PTR), value :: farg1 +real(C_DOUBLE), intent(in) :: farg2 +type(C_PTR), value :: farg3 +integer(C_INT) :: fresult +end function + +function swigc_FSUNTimestepHeuristics_BoundReduction_Default(farg1, farg2, farg3, farg4) & +bind(C, name="_wrap_FSUNTimestepHeuristics_BoundReduction_Default") & +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_FSUNTimestepHeuristics_BoundFirstStep_Default(farg1, farg2, farg3) & +bind(C, name="_wrap_FSUNTimestepHeuristics_BoundFirstStep_Default") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +type(C_PTR), value :: farg1 +real(C_DOUBLE), intent(in) :: farg2 +type(C_PTR), value :: farg3 +integer(C_INT) :: fresult +end function + +function swigc_FSUNTimestepHeuristics_Reset_Default(farg1) & +bind(C, name="_wrap_FSUNTimestepHeuristics_Reset_Default") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +type(C_PTR), value :: farg1 +integer(C_INT) :: fresult +end function + +function swigc_FSUNTimestepHeuristics_Update_Default(farg1) & +bind(C, name="_wrap_FSUNTimestepHeuristics_Update_Default") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +type(C_PTR), value :: farg1 +integer(C_INT) :: fresult +end function + +function swigc_FSUNTimestepHeuristics_SetDefaults_Default(farg1) & +bind(C, name="_wrap_FSUNTimestepHeuristics_SetDefaults_Default") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +type(C_PTR), value :: farg1 +integer(C_INT) :: fresult +end function + +function swigc_FSUNTimestepHeuristics_Write_Default(farg1, farg2) & +bind(C, name="_wrap_FSUNTimestepHeuristics_Write_Default") & +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_FSUNTimestepHeuristics_SetMaxStep_Default(farg1, farg2) & +bind(C, name="_wrap_FSUNTimestepHeuristics_SetMaxStep_Default") & +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_FSUNTimestepHeuristics_SetMinStep_Default(farg1, farg2) & +bind(C, name="_wrap_FSUNTimestepHeuristics_SetMinStep_Default") & +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_FSUNTimestepHeuristics_SetExpStabFn_Default(farg1, farg2, farg3) & +bind(C, name="_wrap_FSUNTimestepHeuristics_SetExpStabFn_Default") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +type(C_PTR), value :: farg1 +type(C_FUNPTR), value :: farg2 +type(C_PTR), value :: farg3 +integer(C_INT) :: fresult +end function + +function swigc_FSUNTimestepHeuristics_SetCFLFraction_Default(farg1, farg2) & +bind(C, name="_wrap_FSUNTimestepHeuristics_SetCFLFraction_Default") & +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_FSUNTimestepHeuristics_SetSafetyFactor_Default(farg1, farg2) & +bind(C, name="_wrap_FSUNTimestepHeuristics_SetSafetyFactor_Default") & +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_FSUNTimestepHeuristics_SetMaxGrowth_Default(farg1, farg2) & +bind(C, name="_wrap_FSUNTimestepHeuristics_SetMaxGrowth_Default") & +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_FSUNTimestepHeuristics_SetMinReduction_Default(farg1, farg2) & +bind(C, name="_wrap_FSUNTimestepHeuristics_SetMinReduction_Default") & +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_FSUNTimestepHeuristics_SetFixedStepBounds_Default(farg1, farg2, farg3) & +bind(C, name="_wrap_FSUNTimestepHeuristics_SetFixedStepBounds_Default") & +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_FSUNTimestepHeuristics_SetMaxFirstGrowth_Default(farg1, farg2) & +bind(C, name="_wrap_FSUNTimestepHeuristics_SetMaxFirstGrowth_Default") & +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_FSUNTimestepHeuristics_SetMaxEFailGrowth_Default(farg1, farg2) & +bind(C, name="_wrap_FSUNTimestepHeuristics_SetMaxEFailGrowth_Default") & +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_FSUNTimestepHeuristics_SetSmallNumEFails_Default(farg1, farg2) & +bind(C, name="_wrap_FSUNTimestepHeuristics_SetSmallNumEFails_Default") & +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_FSUNTimestepHeuristics_SetMaxCFailGrowth_Default(farg1, farg2) & +bind(C, name="_wrap_FSUNTimestepHeuristics_SetMaxCFailGrowth_Default") & +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_FSUNTimestepHeuristics_GetNumExpSteps_Default(farg1, farg2) & +bind(C, name="_wrap_FSUNTimestepHeuristics_GetNumExpSteps_Default") & +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_FSUNTimestepHeuristics_GetNumAccSteps_Default(farg1, farg2) & +bind(C, name="_wrap_FSUNTimestepHeuristics_GetNumAccSteps_Default") & +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_FSUNTimestepHeuristics_Space_Default(farg1, farg2, farg3) & +bind(C, name="_wrap_FSUNTimestepHeuristics_Space_Default") & +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 FSUNTimestepHeuristics_Default(sunctx) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +type(SUNTimestepHeuristics), pointer :: swig_result +type(C_PTR) :: sunctx +type(C_PTR) :: fresult +type(C_PTR) :: farg1 + +farg1 = sunctx +fresult = swigc_FSUNTimestepHeuristics_Default(farg1) +call c_f_pointer(fresult, swig_result) +end function + +function FSUNTimestepHeuristics_GetID_Default(h) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(SUNTimestepHeuristics_ID) :: swig_result +type(SUNTimestepHeuristics), target, intent(inout) :: h +integer(C_INT) :: fresult +type(C_PTR) :: farg1 + +farg1 = c_loc(h) +fresult = swigc_FSUNTimestepHeuristics_GetID_Default(farg1) +swig_result = fresult +end function + +function FSUNTimestepHeuristics_ConstrainStep_Default(h, hcur, hnew, hconstr) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(SUNTimestepHeuristics), target, intent(inout) :: h +real(C_DOUBLE), intent(in) :: hcur +real(C_DOUBLE), intent(in) :: hnew +real(C_DOUBLE), target, intent(inout) :: hconstr +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +real(C_DOUBLE) :: farg2 +real(C_DOUBLE) :: farg3 +type(C_PTR) :: farg4 + +farg1 = c_loc(h) +farg2 = hcur +farg3 = hnew +farg4 = c_loc(hconstr) +fresult = swigc_FSUNTimestepHeuristics_ConstrainStep_Default(farg1, farg2, farg3, farg4) +swig_result = fresult +end function + +function FSUNTimestepHeuristics_ETestFail_Default(h, hcur, hnew, nef, hconstr) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(SUNTimestepHeuristics), target, intent(inout) :: h +real(C_DOUBLE), intent(in) :: hcur +real(C_DOUBLE), intent(in) :: hnew +integer(C_INT), intent(in) :: nef +real(C_DOUBLE), target, intent(inout) :: hconstr +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +real(C_DOUBLE) :: farg2 +real(C_DOUBLE) :: farg3 +integer(C_INT) :: farg4 +type(C_PTR) :: farg5 + +farg1 = c_loc(h) +farg2 = hcur +farg3 = hnew +farg4 = nef +farg5 = c_loc(hconstr) +fresult = swigc_FSUNTimestepHeuristics_ETestFail_Default(farg1, farg2, farg3, farg4, farg5) +swig_result = fresult +end function + +function FSUNTimestepHeuristics_ConvFail_Default(h, hcur, hconstr) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(SUNTimestepHeuristics), target, intent(inout) :: h +real(C_DOUBLE), intent(in) :: hcur +real(C_DOUBLE), target, intent(inout) :: hconstr +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +real(C_DOUBLE) :: farg2 +type(C_PTR) :: farg3 + +farg1 = c_loc(h) +farg2 = hcur +farg3 = c_loc(hconstr) +fresult = swigc_FSUNTimestepHeuristics_ConvFail_Default(farg1, farg2, farg3) +swig_result = fresult +end function + +function FSUNTimestepHeuristics_BoundReduction_Default(h, hcur, hnew, hconstr) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(SUNTimestepHeuristics), target, intent(inout) :: h +real(C_DOUBLE), intent(in) :: hcur +real(C_DOUBLE), intent(in) :: hnew +real(C_DOUBLE), target, intent(inout) :: hconstr +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +real(C_DOUBLE) :: farg2 +real(C_DOUBLE) :: farg3 +type(C_PTR) :: farg4 + +farg1 = c_loc(h) +farg2 = hcur +farg3 = hnew +farg4 = c_loc(hconstr) +fresult = swigc_FSUNTimestepHeuristics_BoundReduction_Default(farg1, farg2, farg3, farg4) +swig_result = fresult +end function + +function FSUNTimestepHeuristics_BoundFirstStep_Default(h, h0, h0constr) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(SUNTimestepHeuristics), target, intent(inout) :: h +real(C_DOUBLE), intent(in) :: h0 +real(C_DOUBLE), target, intent(inout) :: h0constr +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +real(C_DOUBLE) :: farg2 +type(C_PTR) :: farg3 + +farg1 = c_loc(h) +farg2 = h0 +farg3 = c_loc(h0constr) +fresult = swigc_FSUNTimestepHeuristics_BoundFirstStep_Default(farg1, farg2, farg3) +swig_result = fresult +end function + +function FSUNTimestepHeuristics_Reset_Default(h) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(SUNTimestepHeuristics), target, intent(inout) :: h +integer(C_INT) :: fresult +type(C_PTR) :: farg1 + +farg1 = c_loc(h) +fresult = swigc_FSUNTimestepHeuristics_Reset_Default(farg1) +swig_result = fresult +end function + +function FSUNTimestepHeuristics_Update_Default(h) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(SUNTimestepHeuristics), target, intent(inout) :: h +integer(C_INT) :: fresult +type(C_PTR) :: farg1 + +farg1 = c_loc(h) +fresult = swigc_FSUNTimestepHeuristics_Update_Default(farg1) +swig_result = fresult +end function + +function FSUNTimestepHeuristics_SetDefaults_Default(h) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(SUNTimestepHeuristics), target, intent(inout) :: h +integer(C_INT) :: fresult +type(C_PTR) :: farg1 + +farg1 = c_loc(h) +fresult = swigc_FSUNTimestepHeuristics_SetDefaults_Default(farg1) +swig_result = fresult +end function + +function FSUNTimestepHeuristics_Write_Default(h, fptr) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(SUNTimestepHeuristics), target, intent(inout) :: h +type(C_PTR) :: fptr +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 + +farg1 = c_loc(h) +farg2 = fptr +fresult = swigc_FSUNTimestepHeuristics_Write_Default(farg1, farg2) +swig_result = fresult +end function + +function FSUNTimestepHeuristics_SetMaxStep_Default(h, hmax) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(SUNTimestepHeuristics), target, intent(inout) :: h +real(C_DOUBLE), intent(in) :: hmax +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +real(C_DOUBLE) :: farg2 + +farg1 = c_loc(h) +farg2 = hmax +fresult = swigc_FSUNTimestepHeuristics_SetMaxStep_Default(farg1, farg2) +swig_result = fresult +end function + +function FSUNTimestepHeuristics_SetMinStep_Default(h, hmin) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(SUNTimestepHeuristics), target, intent(inout) :: h +real(C_DOUBLE), intent(in) :: hmin +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +real(C_DOUBLE) :: farg2 + +farg1 = c_loc(h) +farg2 = hmin +fresult = swigc_FSUNTimestepHeuristics_SetMinStep_Default(farg1, farg2) +swig_result = fresult +end function + +function FSUNTimestepHeuristics_SetExpStabFn_Default(h, estab, estab_data) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(SUNTimestepHeuristics), target, intent(inout) :: h +type(C_FUNPTR), intent(in), value :: estab +type(C_PTR) :: estab_data +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_FUNPTR) :: farg2 +type(C_PTR) :: farg3 + +farg1 = c_loc(h) +farg2 = estab +farg3 = estab_data +fresult = swigc_FSUNTimestepHeuristics_SetExpStabFn_Default(farg1, farg2, farg3) +swig_result = fresult +end function + +function FSUNTimestepHeuristics_SetCFLFraction_Default(h, cfl_frac) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(SUNTimestepHeuristics), target, intent(inout) :: h +real(C_DOUBLE), intent(in) :: cfl_frac +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +real(C_DOUBLE) :: farg2 + +farg1 = c_loc(h) +farg2 = cfl_frac +fresult = swigc_FSUNTimestepHeuristics_SetCFLFraction_Default(farg1, farg2) +swig_result = fresult +end function + +function FSUNTimestepHeuristics_SetSafetyFactor_Default(h, safety) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(SUNTimestepHeuristics), target, intent(inout) :: h +real(C_DOUBLE), intent(in) :: safety +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +real(C_DOUBLE) :: farg2 + +farg1 = c_loc(h) +farg2 = safety +fresult = swigc_FSUNTimestepHeuristics_SetSafetyFactor_Default(farg1, farg2) +swig_result = fresult +end function + +function FSUNTimestepHeuristics_SetMaxGrowth_Default(h, mx_growth) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(SUNTimestepHeuristics), target, intent(inout) :: h +real(C_DOUBLE), intent(in) :: mx_growth +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +real(C_DOUBLE) :: farg2 + +farg1 = c_loc(h) +farg2 = mx_growth +fresult = swigc_FSUNTimestepHeuristics_SetMaxGrowth_Default(farg1, farg2) +swig_result = fresult +end function + +function FSUNTimestepHeuristics_SetMinReduction_Default(h, eta_min) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(SUNTimestepHeuristics), target, intent(inout) :: h +real(C_DOUBLE), intent(in) :: eta_min +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +real(C_DOUBLE) :: farg2 + +farg1 = c_loc(h) +farg2 = eta_min +fresult = swigc_FSUNTimestepHeuristics_SetMinReduction_Default(farg1, farg2) +swig_result = fresult +end function + +function FSUNTimestepHeuristics_SetFixedStepBounds_Default(h, lb, ub) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(SUNTimestepHeuristics), target, intent(inout) :: h +real(C_DOUBLE), intent(in) :: lb +real(C_DOUBLE), intent(in) :: ub +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +real(C_DOUBLE) :: farg2 +real(C_DOUBLE) :: farg3 + +farg1 = c_loc(h) +farg2 = lb +farg3 = ub +fresult = swigc_FSUNTimestepHeuristics_SetFixedStepBounds_Default(farg1, farg2, farg3) +swig_result = fresult +end function + +function FSUNTimestepHeuristics_SetMaxFirstGrowth_Default(h, etamx1) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(SUNTimestepHeuristics), target, intent(inout) :: h +real(C_DOUBLE), intent(in) :: etamx1 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +real(C_DOUBLE) :: farg2 + +farg1 = c_loc(h) +farg2 = etamx1 +fresult = swigc_FSUNTimestepHeuristics_SetMaxFirstGrowth_Default(farg1, farg2) +swig_result = fresult +end function + +function FSUNTimestepHeuristics_SetMaxEFailGrowth_Default(h, etamxf) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(SUNTimestepHeuristics), target, intent(inout) :: h +real(C_DOUBLE), intent(in) :: etamxf +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +real(C_DOUBLE) :: farg2 + +farg1 = c_loc(h) +farg2 = etamxf +fresult = swigc_FSUNTimestepHeuristics_SetMaxEFailGrowth_Default(farg1, farg2) +swig_result = fresult +end function + +function FSUNTimestepHeuristics_SetSmallNumEFails_Default(h, small_nef) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(SUNTimestepHeuristics), target, intent(inout) :: h +integer(C_INT), intent(in) :: small_nef +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +integer(C_INT) :: farg2 + +farg1 = c_loc(h) +farg2 = small_nef +fresult = swigc_FSUNTimestepHeuristics_SetSmallNumEFails_Default(farg1, farg2) +swig_result = fresult +end function + +function FSUNTimestepHeuristics_SetMaxCFailGrowth_Default(h, etacf) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(SUNTimestepHeuristics), target, intent(inout) :: h +real(C_DOUBLE), intent(in) :: etacf +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +real(C_DOUBLE) :: farg2 + +farg1 = c_loc(h) +farg2 = etacf +fresult = swigc_FSUNTimestepHeuristics_SetMaxCFailGrowth_Default(farg1, farg2) +swig_result = fresult +end function + +function FSUNTimestepHeuristics_GetNumExpSteps_Default(h, expsteps) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(SUNTimestepHeuristics), target, intent(inout) :: h +integer(C_LONG), dimension(*), target, intent(inout) :: expsteps +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 + +farg1 = c_loc(h) +farg2 = c_loc(expsteps(1)) +fresult = swigc_FSUNTimestepHeuristics_GetNumExpSteps_Default(farg1, farg2) +swig_result = fresult +end function + +function FSUNTimestepHeuristics_GetNumAccSteps_Default(h, accsteps) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(SUNTimestepHeuristics), target, intent(inout) :: h +integer(C_LONG), dimension(*), target, intent(inout) :: accsteps +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 + +farg1 = c_loc(h) +farg2 = c_loc(accsteps(1)) +fresult = swigc_FSUNTimestepHeuristics_GetNumAccSteps_Default(farg1, farg2) +swig_result = fresult +end function + +function FSUNTimestepHeuristics_Space_Default(h, lenrw, leniw) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(SUNTimestepHeuristics), target, intent(inout) :: h +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(h) +farg2 = c_loc(lenrw(1)) +farg3 = c_loc(leniw(1)) +fresult = swigc_FSUNTimestepHeuristics_Space_Default(farg1, farg2, farg3) +swig_result = fresult +end function + + +end module diff --git a/src/suntimestepheuristics/default/suntimestepheuristics_default.c b/src/suntimestepheuristics/default/suntimestepheuristics_default.c new file mode 100644 index 0000000000..8030b4d6b9 --- /dev/null +++ b/src/suntimestepheuristics/default/suntimestepheuristics_default.c @@ -0,0 +1,511 @@ +/* ----------------------------------------------------------------- + * 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 + * SUNTimestepHeuristics_Default module. + * -----------------------------------------------------------------*/ + +#include +#include +#include +#include + + +/* --------------- + * Macro accessors + * --------------- */ + +#define SH_CONTENT(H) ( (SUNTimestepHeuristicsContent_Default)(H->content) ) +#define SH_HMAX_INV(H) ( SH_CONTENT(H)->hmax_inv ) +#define SH_HMIN(H) ( SH_CONTENT(H)->hmin ) +#define SH_ETAMAX(H) ( SH_CONTENT(H)->etamax ) +#define SH_ETAMX1(H) ( SH_CONTENT(H)->etamx1 ) +#define SH_ETAMXF(H) ( SH_CONTENT(H)->etamxf ) +#define SH_ETAMIN(H) ( SH_CONTENT(H)->etamin ) +#define SH_SMALL_NEF(H) ( SH_CONTENT(H)->small_nef ) +#define SH_ETACF(H) ( SH_CONTENT(H)->etacf ) +#define SH_EXPSTAB(H) ( SH_CONTENT(H)->expstab ) +#define SH_ESTAB_DATA(H) ( SH_CONTENT(H)->estab_data ) +#define SH_CFL(H) ( SH_CONTENT(H)->cfl ) +#define SH_SAFETY(H) ( SH_CONTENT(H)->safety ) +#define SH_GROWTH(H) ( SH_CONTENT(H)->growth ) +#define SH_LBOUND(H) ( SH_CONTENT(H)->lbound ) +#define SH_UBOUND(H) ( SH_CONTENT(H)->ubound ) +#define SH_NST_ACC(H) ( SH_CONTENT(H)->nst_acc ) +#define SH_NST_EXP(H) ( SH_CONTENT(H)->nst_exp ) + +/* ------------------ + * Default parameters + * ------------------ */ + +#define DEFAULT_CFLFAC RCONST(0.5) +#define DEFAULT_SAFETY RCONST(0.96) +#define DEFAULT_GROWTH RCONST(20.0) +#define DEFAULT_HFIXED_LB RCONST(1.0) +#define DEFAULT_HFIXED_UB RCONST(1.5) +#define DEFAULT_ETAMX1 RCONST(10000.0) +#define DEFAULT_ETAMXF RCONST(0.3) +#define DEFAULT_ETAMIN RCONST(0.1) +#define DEFAULT_ETACF RCONST(0.25) +#define DEFAULT_SMALL_NEF 2 +#define ONEPSM RCONST(1.000001) +#define ONEMSM RCONST(0.999999) + + +/* ----------------------------------------------------------------- + * exported functions + * ----------------------------------------------------------------- */ + +/* ----------------------------------------------------------------- + * Function to create a new default heuristics module + */ + +SUNTimestepHeuristics SUNTimestepHeuristics_Default(SUNContext sunctx) +{ + SUNTimestepHeuristics H; + SUNTimestepHeuristicsContent_Default content; + + /* Create an empty heuristics object */ + H = NULL; + H = SUNTimestepHeuristics_NewEmpty(sunctx); + if (H == NULL) { return (NULL); } + + /* Attach operations */ + H->ops->getid = SUNTimestepHeuristics_GetID_Default; + H->ops->constrainstep = SUNTimestepHeuristics_ConstrainStep_Default; + H->ops->etestfail = SUNTimestepHeuristics_ETestFail_Default; + H->ops->convfail = SUNTimestepHeuristics_ConvFail_Default; + H->ops->boundreduction = SUNTimestepHeuristics_BoundReduction_Default; + H->ops->boundfirststep = SUNTimestepHeuristics_BoundFirstStep_Default; + H->ops->reset = SUNTimestepHeuristics_Reset_Default; + H->ops->update = SUNTimestepHeuristics_Update_Default; + H->ops->setdefaults = SUNTimestepHeuristics_SetDefaults_Default; + H->ops->write = SUNTimestepHeuristics_Write_Default; + H->ops->setmaxstep = SUNTimestepHeuristics_SetMaxStep_Default; + H->ops->setminstep = SUNTimestepHeuristics_SetMinStep_Default; + H->ops->setexpstabfn = SUNTimestepHeuristics_SetExpStabFn_Default; + H->ops->setcflfraction = SUNTimestepHeuristics_SetCFLFraction_Default; + H->ops->setsafetyfactor = SUNTimestepHeuristics_SetSafetyFactor_Default; + H->ops->setmaxgrowth = SUNTimestepHeuristics_SetMaxGrowth_Default; + H->ops->setminreduction = SUNTimestepHeuristics_SetMinReduction_Default; + H->ops->setfixedstepbounds = SUNTimestepHeuristics_SetFixedStepBounds_Default; + H->ops->setmaxfirstgrowth = SUNTimestepHeuristics_SetMaxFirstGrowth_Default; + H->ops->setmaxefailgrowth = SUNTimestepHeuristics_SetMaxEFailGrowth_Default; + H->ops->setsmallnumefails = SUNTimestepHeuristics_SetSmallNumEFails_Default; + H->ops->setmaxcfailgrowth = SUNTimestepHeuristics_SetMaxCFailGrowth_Default; + H->ops->getnumexpsteps = SUNTimestepHeuristics_GetNumExpSteps_Default; + H->ops->getnumaccsteps = SUNTimestepHeuristics_GetNumAccSteps_Default; + H->ops->space = SUNTimestepHeuristics_Space_Default; + + /* Create content */ + content = NULL; + content = (SUNTimestepHeuristicsContent_Default)malloc(sizeof *content); + if (content == NULL) + { + (void) SUNTimestepHeuristics_Destroy(H); + return (NULL); + } + + /* Attach content */ + H->content = content; + + /* Fill content with default/reset values */ + SUNTimestepHeuristics_SetDefaults_Default(H); + SUNTimestepHeuristics_Reset_Default(H); + + /* Initialize explicit stability function and data */ + content->expstab = NULL; + content->estab_data = NULL; + + return (H); +} + + +/* ----------------------------------------------------------------- + * implementation of heuristic operations + * ----------------------------------------------------------------- */ + +SUNTimestepHeuristics_ID SUNTimestepHeuristics_GetID_Default(SUNTimestepHeuristics H) +{ return SUN_TIMESTEPHEURISTICS_STD; } + +int SUNTimestepHeuristics_ConstrainStep_Default(SUNTimestepHeuristics H, + sunrealtype hcur, + sunrealtype h_acc, + sunrealtype* hconstr) +{ + /* Determine direction of integration, int_dir */ + sunrealtype int_dir = hcur / SUNRabs(hcur); + + /* Call explicit stability function if present, multiply result by CFL factor * int_dir */ + int retval = 0; + sunrealtype h_cfl = RCONST(1.0e30) * SUNRabs(hcur); + if (SH_EXPSTAB(H) != NULL) + { + retval = SH_EXPSTAB(H)(&h_cfl, SH_ESTAB_DATA(H)); + if (retval != 0) { return SUNTIMESTEPHEURISTICS_USER_FCN_FAIL; } + h_cfl *= int_dir * SH_CFL(H); + } + + /* Enforce safety factor on h_acc prediction. */ + h_acc *= SH_SAFETY(H); + + /* Enforce maximum bound on h_acc growth (etamax) */ + h_acc = int_dir * SUNMIN(SUNRabs(h_acc), SUNRabs(SH_ETAMAX(H)*hcur)); + + /* Enforce minimum bound on time step reduction (etamin) */ + h_acc = int_dir * SUNMAX(SUNRabs(h_acc), SUNRabs(SH_ETAMIN(H)*hcur)); + + /* Increment nst_acc vs nst_exp counter, and set desired step */ + if (SUNRabs(h_acc) < SUNRabs(h_cfl)) { SH_NST_ACC(H)++; } + else { SH_NST_EXP(H)++; } + sunrealtype hnew = int_dir * SUNMIN(SUNRabs(h_acc), SUNRabs(h_cfl)); + + /* Enforce lbound*ONEMSM and ubound*ONEPSM bounds if hnew>hcur */ + if (SUNRabs(hnew) > SUNRabs(hcur)) { + if ( (SUNRabs(hnew) > SUNRabs(hcur*SH_LBOUND(H)*ONEMSM)) && + (SUNRabs(hnew) < SUNRabs(hcur*SH_UBOUND(H)*ONEPSM)) ) + hnew = hcur; + } + + /* Enforce max step size */ + hnew /= SUNMAX(RCONST(1.0), SUNRabs(hnew) * SH_HMAX_INV(H)); + + /* Bound any requested stepsize reduction, and return */ + return (SUNTimestepHeuristics_BoundReduction_Default(H, hcur, hnew, hconstr)); +} + +int SUNTimestepHeuristics_ETestFail_Default(SUNTimestepHeuristics H, + sunrealtype hcur, + sunrealtype hnew, int nef, + sunrealtype* hconstr) +{ + /* Set etamax to 1.0 for next step attempt */ + SH_ETAMAX(H) = RCONST(1.0); + + /* Enforce failure bounds on step */ + if (nef >= SH_SMALL_NEF(H)) { hnew = SUNMIN(hnew, hcur*SH_ETAMXF(H)); } + + /* Bound any requested stepsize reduction, and return */ + return (SUNTimestepHeuristics_BoundReduction_Default(H, hcur, hnew, hconstr)); +} + +int SUNTimestepHeuristics_ConvFail_Default(SUNTimestepHeuristics H, + sunrealtype hcur, + sunrealtype* hconstr) +{ + /* Set etamax to 1.0 for next step attempt */ + SH_ETAMAX(H) = RCONST(1.0); + + /* Enforce failure bounds on next step */ + sunrealtype hnew = hcur*SH_ETACF(H); + + /* Bound any requested stepsize reduction, and return */ + return (SUNTimestepHeuristics_BoundReduction_Default(H, hcur, hnew, hconstr)); +} + +int SUNTimestepHeuristics_BoundReduction_Default(SUNTimestepHeuristics H, + sunrealtype hcur, + sunrealtype hnew, + sunrealtype *hconstr) +{ + /* If reduction requested first ensure that it its possible. */ + if ((SUNRabs(hcur) <= SH_HMIN(H)*ONEPSM) && (SUNRabs(hnew) <= SUNRabs(hcur))) + { return SUNTIMESTEPHEURISTICS_CANNOT_DECREASE; } + + /* Enforce minimum step size and return. */ + *hconstr = SUNMAX(SUNRabs(hnew), SH_HMIN(H)) * hnew / SUNRabs(hnew); + return SUNTIMESTEPHEURISTICS_SUCCESS; +} + +int SUNTimestepHeuristics_BoundFirstStep_Default(SUNTimestepHeuristics H, + sunrealtype h0, + sunrealtype *h0constr) +{ + /* Enforce max step size */ + h0 /= SUNMAX(RCONST(1.0), SUNRabs(h0) * SH_HMAX_INV(H)); + + /* Enforce minimum step size and return. */ + *h0constr = SUNMAX(SUNRabs(h0), SH_HMIN(H)); + return SUNTIMESTEPHEURISTICS_SUCCESS; +} + +int SUNTimestepHeuristics_Reset_Default(SUNTimestepHeuristics H) +{ + SH_ETAMAX(H) = SH_ETAMX1(H); + SH_NST_ACC(H) = 0; + SH_NST_EXP(H) = 0; + return SUNTIMESTEPHEURISTICS_SUCCESS; +} + +int SUNTimestepHeuristics_Update_Default(SUNTimestepHeuristics H) +{ + SH_ETAMAX(H) = SH_GROWTH(H); + return SUNTIMESTEPHEURISTICS_SUCCESS; +} + +int SUNTimestepHeuristics_SetDefaults_Default(SUNTimestepHeuristics H) +{ + SH_HMAX_INV(H) = RCONST(0.0); + SH_HMIN(H) = RCONST(0.0); + SH_ETAMX1(H) = DEFAULT_ETAMX1; + SH_ETAMXF(H) = DEFAULT_ETAMXF; + SH_ETAMIN(H) = DEFAULT_ETAMIN; + SH_SMALL_NEF(H) = DEFAULT_SMALL_NEF; + SH_ETACF(H) = DEFAULT_ETACF; + SH_CFL(H) = DEFAULT_CFLFAC; + SH_SAFETY(H) = DEFAULT_SAFETY; + SH_GROWTH(H) = DEFAULT_GROWTH; + SH_LBOUND(H) = DEFAULT_HFIXED_LB; + SH_UBOUND(H) = DEFAULT_HFIXED_UB; + return SUNTIMESTEPHEURISTICS_SUCCESS; +} + +int SUNTimestepHeuristics_Write_Default(SUNTimestepHeuristics H, FILE *fptr) +{ + fprintf(fptr, "Default SUNTimestepHeuristics module:\n"); +#if defined(SUNDIALS_EXTENDED_PRECISION) + fprintf(fptr, " Minimum step size = %32Lg\n", SH_HMIN(H)); + fprintf(fptr, " Maximum step size = %32Lg\n", RCONST(1.0)/SH_HMAX_INV(H)); + fprintf(fptr, " Maximum step increase factor (first step) = %32Lg\n", SH_ETAMX1(H)); + fprintf(fptr, " Maximum step increase factor (general steps) = %32Lg\n", SH_GROWTH(H)); + fprintf(fptr, " Current maximum step increase factor = %32Lg\n", SH_ETAMAX(H)); + fprintf(fptr, " Minimum step reduction factor = %32Lg\n", SH_ETAMIN(H)); + fprintf(fptr, " Step reduction factor on algebraic solver convergence failure = %32Lg\n", SH_ETACF(H)); + fprintf(fptr, " Step reduction factor on multiple error fails = %32Lg\n", SH_ETAMXF(H)); + fprintf(fptr, " Minimum number of error fails before above factor is used = %i\n", SH_SMALL_NEF(H)); + fprintf(fptr, " Explicit stability safety factor = %32Lg\n", SH_CFL(H)); + fprintf(fptr, " Step adaptivity safety factor = %32Lg\n", SH_SAFETY(H)); + fprintf(fptr, " Unchanged step growth interval = [%32Lg, %32Lg]\n", SH_LBOUND(H), SH_UBOUND(H)); +#else + fprintf(fptr, " Minimum step size = %16g\n", SH_HMIN(H)); + fprintf(fptr, " Maximum step size = %16g\n", RCONST(1.0)/SH_HMAX_INV(H)); + fprintf(fptr, " Maximum step increase factor (first step) = %16g\n", SH_ETAMX1(H)); + fprintf(fptr, " Maximum step increase factor (general steps) = %16g\n", SH_GROWTH(H)); + fprintf(fptr, " Current maximum step increase factor = %16g\n", SH_ETAMAX(H)); + fprintf(fptr, " Minimum step reduction factor = %16g\n", SH_ETAMIN(H)); + fprintf(fptr, " Step reduction factor on algebraic solver convergence failure = %16g\n", SH_ETACF(H)); + fprintf(fptr, " Step reduction factor on multiple error fails = %16g\n", SH_ETAMXF(H)); + fprintf(fptr, " Minimum number of error fails before above factor is used = %i\n", SH_SMALL_NEF(H)); + fprintf(fptr, " Explicit stability safety factor = %16g\n", SH_CFL(H)); + fprintf(fptr, " Step adaptivity safety factor = %16g\n", SH_SAFETY(H)); + fprintf(fptr, " Unchanged step growth interval = [%16g, %16g]\n", SH_LBOUND(H), SH_UBOUND(H)); +#endif + if (SH_EXPSTAB(H) != NULL) { + fprintf(fptr, " User-provided explicit stability function\n"); + fprintf(fptr, " Stability function data pointer = %p\n", SH_ESTAB_DATA(H)); + } + fprintf(fptr, " Current number of accuracy-limited steps = %li\n", SH_NST_ACC(H)); + fprintf(fptr, " Current number of stability-limited steps = %li\n", SH_NST_EXP(H)); + return SUNTIMESTEPHEURISTICS_SUCCESS; +} + +int SUNTimestepHeuristics_SetMaxStep_Default(SUNTimestepHeuristics H, + sunrealtype hmax) +{ + /* Passing a value <= 0 sets hmax = infinity */ + if (hmax <= RCONST(0.0)) + { + SH_HMAX_INV(H) = RCONST(0.0); + return SUNTIMESTEPHEURISTICS_SUCCESS; + } + + /* set the value and return */ + SH_HMAX_INV(H) = RCONST(1.0)/hmax; + + return SUNTIMESTEPHEURISTICS_SUCCESS; +} + +int SUNTimestepHeuristics_SetMinStep_Default(SUNTimestepHeuristics H, + sunrealtype hmin) +{ + /* Passing a value <= 0 sets hmin = 0 */ + if (hmin <= RCONST(0.0)) + { + SH_HMIN(H) = RCONST(0.0); + return SUNTIMESTEPHEURISTICS_SUCCESS; + } + + /* set the value and return */ + SH_HMIN(H) = hmin; + return SUNTIMESTEPHEURISTICS_SUCCESS; +} + +int SUNTimestepHeuristics_SetExpStabFn_Default(SUNTimestepHeuristics H, + SUNExpStabFn EStab, + void* estab_data) +{ + SH_EXPSTAB(H) = EStab; + SH_ESTAB_DATA(H) = estab_data; + return SUNTIMESTEPHEURISTICS_SUCCESS; +} + +int SUNTimestepHeuristics_SetCFLFraction_Default(SUNTimestepHeuristics H, + sunrealtype cfl_frac) +{ + /* check for allowable parameters */ + if (cfl_frac >= RCONST(1.0)) + { + return SUNTIMESTEPHEURISTICS_ILL_INPUT; + } + + /* set positive-valued parameters, otherwise set default */ + if (cfl_frac <= RCONST(0.0)) + { + SH_CFL(H) = DEFAULT_CFLFAC; + } + else + { + SH_CFL(H) = cfl_frac; + } + return SUNTIMESTEPHEURISTICS_SUCCESS; +} + +int SUNTimestepHeuristics_SetSafetyFactor_Default(SUNTimestepHeuristics H, + sunrealtype safety) +{ + /* check for legal input */ + if (safety >= RCONST(1.0)) { return SUNTIMESTEPHEURISTICS_ILL_INPUT; } + + /* set positive-valued parameters, otherwise set default */ + if (safety <= RCONST(0.0)) { + SH_SAFETY(H) = DEFAULT_SAFETY; + } else { + SH_SAFETY(H) = safety; + } + + return SUNTIMESTEPHEURISTICS_SUCCESS; +} + +int SUNTimestepHeuristics_SetMaxGrowth_Default(SUNTimestepHeuristics H, + sunrealtype mx_growth) +{ + /* set allowed value, otherwise set default */ + if (mx_growth <= RCONST(1.0)) + { + SH_GROWTH(H) = DEFAULT_GROWTH; + } + else + { + SH_GROWTH(H) = mx_growth; + } + return SUNTIMESTEPHEURISTICS_SUCCESS; +} + +int SUNTimestepHeuristics_SetMinReduction_Default(SUNTimestepHeuristics H, + sunrealtype eta_min) +{ + /* set allowed value, otherwise set default */ + if (eta_min >= RCONST(1.0) || eta_min <= RCONST(0.0)) + { + SH_ETAMIN(H) = DEFAULT_ETAMIN; + } else { + SH_ETAMIN(H) = eta_min; + } + return SUNTIMESTEPHEURISTICS_SUCCESS; +} + +int SUNTimestepHeuristics_SetFixedStepBounds_Default(SUNTimestepHeuristics H, + sunrealtype lb, sunrealtype ub) +{ + /* set allowable interval, otherwise set defaults */ + if ((lb <= RCONST(1.0)) && (ub >= RCONST(1.0))) { + SH_LBOUND(H) = lb; + SH_UBOUND(H) = ub; + } else { + SH_LBOUND(H) = DEFAULT_HFIXED_LB; + SH_UBOUND(H) = DEFAULT_HFIXED_UB; + } + return SUNTIMESTEPHEURISTICS_SUCCESS; +} + +int SUNTimestepHeuristics_SetMaxFirstGrowth_Default(SUNTimestepHeuristics H, + sunrealtype etamx1) +{ + /* if argument legal set it, otherwise set default */ + if (etamx1 <= RCONST(1.0)) + { + SH_ETAMX1(H) = DEFAULT_ETAMX1; + } + else + { + SH_ETAMX1(H) = etamx1; + } + return SUNTIMESTEPHEURISTICS_SUCCESS; +} + +int SUNTimestepHeuristics_SetMaxEFailGrowth_Default(SUNTimestepHeuristics H, + sunrealtype etamxf) +{ + /* if argument legal set it, otherwise set default */ + if ((etamxf <= RCONST(0.0)) || (etamxf > RCONST(1.0))) + { + SH_ETAMXF(H) = DEFAULT_ETAMXF; + } + else + { + SH_ETAMXF(H) = etamxf; + } + return SUNTIMESTEPHEURISTICS_SUCCESS; +} + +int SUNTimestepHeuristics_SetSmallNumEFails_Default(SUNTimestepHeuristics H, + int small_nef) +{ + /* if argument legal set it, otherwise set default */ + if (small_nef <= 0) + { + SH_SMALL_NEF(H) = DEFAULT_SMALL_NEF; + } + else + { + SH_SMALL_NEF(H) = small_nef; + } + return SUNTIMESTEPHEURISTICS_SUCCESS; +} + +int SUNTimestepHeuristics_SetMaxCFailGrowth_Default(SUNTimestepHeuristics H, + sunrealtype etacf) +{ + /* if argument legal set it, otherwise set default */ + if ((etacf <= RCONST(0.0)) || (etacf > RCONST(1.0))) + { + SH_ETACF(H) = DEFAULT_ETACF; + } + else + { + SH_ETACF(H) = etacf; + } + return SUNTIMESTEPHEURISTICS_SUCCESS; +} + +int SUNTimestepHeuristics_GetNumExpSteps_Default(SUNTimestepHeuristics H, + long int* expsteps) +{ + *expsteps = SH_NST_EXP(H); + return SUNTIMESTEPHEURISTICS_SUCCESS; +} + +int SUNTimestepHeuristics_GetNumAccSteps_Default(SUNTimestepHeuristics H, + long int* accsteps) +{ + *accsteps = SH_NST_ACC(H); + return SUNTIMESTEPHEURISTICS_SUCCESS; +} + +int SUNTimestepHeuristics_Space_Default(SUNTimestepHeuristics H, + long int* lenrw, long int* leniw) +{ + *lenrw = 11; + *leniw = 5; + return SUNTIMESTEPHEURISTICS_SUCCESS; +} diff --git a/src/suntimestepheuristics/unconstrained/CMakeLists.txt b/src/suntimestepheuristics/unconstrained/CMakeLists.txt new file mode 100644 index 0000000000..94fe1a9b62 --- /dev/null +++ b/src/suntimestepheuristics/unconstrained/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_suntimestepheuristicsunconstrained + SOURCES + suntimestepheuristics_unconstrained.c + HEADERS + ${SUNDIALS_SOURCE_DIR}/include/suntimestepheuristics/suntimestepheuristics_unconstrained.h + INCLUDE_SUBDIR + suntimestepheuristics + OBJECT_LIB_ONLY +) + +# Add F2003 module if the interface is enabled +if(BUILD_FORTRAN_MODULE_INTERFACE) + add_subdirectory(fmod) +endif() diff --git a/src/suntimestepheuristics/unconstrained/fmod/CMakeLists.txt b/src/suntimestepheuristics/unconstrained/fmod/CMakeLists.txt new file mode 100644 index 0000000000..557a45198e --- /dev/null +++ b/src/suntimestepheuristics/unconstrained/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_fsuntimestepheuristicsunconstrained_mod + SOURCES + fsuntimestepheuristics_unconstrained_mod.f90 fsuntimestepheuristics_unconstrained_mod.c + OBJECT_LIBRARIES + sundials_fgeneric_mod_obj + OUTPUT_NAME + sundials_fsuntimestepheuristics_unconstrained_mod + OBJECT_LIB_ONLY +) + +message(STATUS "Added SUNTimestepHeuristics_Unconstrained F2003 interface") diff --git a/src/suntimestepheuristics/unconstrained/fmod/fsuntimestepheuristics_unconstrained_mod.c b/src/suntimestepheuristics/unconstrained/fmod/fsuntimestepheuristics_unconstrained_mod.c new file mode 100644 index 0000000000..0c9e2e8de9 --- /dev/null +++ b/src/suntimestepheuristics/unconstrained/fmod/fsuntimestepheuristics_unconstrained_mod.c @@ -0,0 +1,325 @@ +/* ---------------------------------------------------------------------------- + * 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_timestepheuristics.h" + + +#include "suntimestepheuristics/suntimestepheuristics_unconstrained.h" + +SWIGEXPORT SUNTimestepHeuristics _wrap_FSUNTimestepHeuristics_Unconstrained(void *farg1) { + SUNTimestepHeuristics fresult ; + SUNContext arg1 = (SUNContext) 0 ; + SUNTimestepHeuristics result; + + arg1 = (SUNContext)(farg1); + result = (SUNTimestepHeuristics)SUNTimestepHeuristics_Unconstrained(arg1); + fresult = result; + return fresult; +} + + +SWIGEXPORT int _wrap_FSUNTimestepHeuristics_GetID_Unconstrained(SUNTimestepHeuristics farg1) { + int fresult ; + SUNTimestepHeuristics arg1 = (SUNTimestepHeuristics) 0 ; + SUNTimestepHeuristics_ID result; + + arg1 = (SUNTimestepHeuristics)(farg1); + result = (SUNTimestepHeuristics_ID)SUNTimestepHeuristics_GetID_Unconstrained(arg1); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FSUNTimestepHeuristics_ConstrainStep_Unconstrained(SUNTimestepHeuristics farg1, double const *farg2, double const *farg3, double *farg4) { + int fresult ; + SUNTimestepHeuristics arg1 = (SUNTimestepHeuristics) 0 ; + sunrealtype arg2 ; + sunrealtype arg3 ; + sunrealtype *arg4 = (sunrealtype *) 0 ; + int result; + + arg1 = (SUNTimestepHeuristics)(farg1); + arg2 = (sunrealtype)(*farg2); + arg3 = (sunrealtype)(*farg3); + arg4 = (sunrealtype *)(farg4); + result = (int)SUNTimestepHeuristics_ConstrainStep_Unconstrained(arg1,arg2,arg3,arg4); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FSUNTimestepHeuristics_ConvFail_Unconstrained(SUNTimestepHeuristics farg1, double const *farg2, double *farg3) { + int fresult ; + SUNTimestepHeuristics arg1 = (SUNTimestepHeuristics) 0 ; + sunrealtype arg2 ; + sunrealtype *arg3 = (sunrealtype *) 0 ; + int result; + + arg1 = (SUNTimestepHeuristics)(farg1); + arg2 = (sunrealtype)(*farg2); + arg3 = (sunrealtype *)(farg3); + result = (int)SUNTimestepHeuristics_ConvFail_Unconstrained(arg1,arg2,arg3); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FSUNTimestepHeuristics_Reset_Unconstrained(SUNTimestepHeuristics farg1) { + int fresult ; + SUNTimestepHeuristics arg1 = (SUNTimestepHeuristics) 0 ; + int result; + + arg1 = (SUNTimestepHeuristics)(farg1); + result = (int)SUNTimestepHeuristics_Reset_Unconstrained(arg1); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FSUNTimestepHeuristics_Write_Unconstrained(SUNTimestepHeuristics farg1, void *farg2) { + int fresult ; + SUNTimestepHeuristics arg1 = (SUNTimestepHeuristics) 0 ; + FILE *arg2 = (FILE *) 0 ; + int result; + + arg1 = (SUNTimestepHeuristics)(farg1); + arg2 = (FILE *)(farg2); + result = (int)SUNTimestepHeuristics_Write_Unconstrained(arg1,arg2); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FSUNTimestepHeuristics_GetNumAccSteps_Unconstrained(SUNTimestepHeuristics farg1, long *farg2) { + int fresult ; + SUNTimestepHeuristics arg1 = (SUNTimestepHeuristics) 0 ; + long *arg2 = (long *) 0 ; + int result; + + arg1 = (SUNTimestepHeuristics)(farg1); + arg2 = (long *)(farg2); + result = (int)SUNTimestepHeuristics_GetNumAccSteps_Unconstrained(arg1,arg2); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FSUNTimestepHeuristics_Space_Unconstrained(SUNTimestepHeuristics farg1, long *farg2, long *farg3) { + int fresult ; + SUNTimestepHeuristics arg1 = (SUNTimestepHeuristics) 0 ; + long *arg2 = (long *) 0 ; + long *arg3 = (long *) 0 ; + int result; + + arg1 = (SUNTimestepHeuristics)(farg1); + arg2 = (long *)(farg2); + arg3 = (long *)(farg3); + result = (int)SUNTimestepHeuristics_Space_Unconstrained(arg1,arg2,arg3); + fresult = (int)(result); + return fresult; +} + + + diff --git a/src/suntimestepheuristics/unconstrained/fmod/fsuntimestepheuristics_unconstrained_mod.f90 b/src/suntimestepheuristics/unconstrained/fmod/fsuntimestepheuristics_unconstrained_mod.f90 new file mode 100644 index 0000000000..3cf4db4b42 --- /dev/null +++ b/src/suntimestepheuristics/unconstrained/fmod/fsuntimestepheuristics_unconstrained_mod.f90 @@ -0,0 +1,255 @@ +! 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 fsuntimestepheuristics_unconstrained_mod + use, intrinsic :: ISO_C_BINDING + use fsundials_nvector_mod + use fsundials_context_mod + use fsundials_types_mod + use fsundials_timestepheuristics_mod + use fsundials_nvector_mod + use fsundials_context_mod + use fsundials_types_mod + implicit none + private + + ! DECLARATION CONSTRUCTS + public :: FSUNTimestepHeuristics_Unconstrained + public :: FSUNTimestepHeuristics_GetID_Unconstrained + public :: FSUNTimestepHeuristics_ConstrainStep_Unconstrained + public :: FSUNTimestepHeuristics_ConvFail_Unconstrained + public :: FSUNTimestepHeuristics_Reset_Unconstrained + public :: FSUNTimestepHeuristics_Write_Unconstrained + public :: FSUNTimestepHeuristics_GetNumAccSteps_Unconstrained + public :: FSUNTimestepHeuristics_Space_Unconstrained + +! WRAPPER DECLARATIONS +interface +function swigc_FSUNTimestepHeuristics_Unconstrained(farg1) & +bind(C, name="_wrap_FSUNTimestepHeuristics_Unconstrained") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +type(C_PTR), value :: farg1 +type(C_PTR) :: fresult +end function + +function swigc_FSUNTimestepHeuristics_GetID_Unconstrained(farg1) & +bind(C, name="_wrap_FSUNTimestepHeuristics_GetID_Unconstrained") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +type(C_PTR), value :: farg1 +integer(C_INT) :: fresult +end function + +function swigc_FSUNTimestepHeuristics_ConstrainStep_Unconstrained(farg1, farg2, farg3, farg4) & +bind(C, name="_wrap_FSUNTimestepHeuristics_ConstrainStep_Unconstrained") & +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_FSUNTimestepHeuristics_ConvFail_Unconstrained(farg1, farg2, farg3) & +bind(C, name="_wrap_FSUNTimestepHeuristics_ConvFail_Unconstrained") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +type(C_PTR), value :: farg1 +real(C_DOUBLE), intent(in) :: farg2 +type(C_PTR), value :: farg3 +integer(C_INT) :: fresult +end function + +function swigc_FSUNTimestepHeuristics_Reset_Unconstrained(farg1) & +bind(C, name="_wrap_FSUNTimestepHeuristics_Reset_Unconstrained") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +type(C_PTR), value :: farg1 +integer(C_INT) :: fresult +end function + +function swigc_FSUNTimestepHeuristics_Write_Unconstrained(farg1, farg2) & +bind(C, name="_wrap_FSUNTimestepHeuristics_Write_Unconstrained") & +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_FSUNTimestepHeuristics_GetNumAccSteps_Unconstrained(farg1, farg2) & +bind(C, name="_wrap_FSUNTimestepHeuristics_GetNumAccSteps_Unconstrained") & +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_FSUNTimestepHeuristics_Space_Unconstrained(farg1, farg2, farg3) & +bind(C, name="_wrap_FSUNTimestepHeuristics_Space_Unconstrained") & +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 FSUNTimestepHeuristics_Unconstrained(sunctx) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +type(SUNTimestepHeuristics), pointer :: swig_result +type(C_PTR) :: sunctx +type(C_PTR) :: fresult +type(C_PTR) :: farg1 + +farg1 = sunctx +fresult = swigc_FSUNTimestepHeuristics_Unconstrained(farg1) +call c_f_pointer(fresult, swig_result) +end function + +function FSUNTimestepHeuristics_GetID_Unconstrained(h) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(SUNTimestepHeuristics_ID) :: swig_result +type(SUNTimestepHeuristics), target, intent(inout) :: h +integer(C_INT) :: fresult +type(C_PTR) :: farg1 + +farg1 = c_loc(h) +fresult = swigc_FSUNTimestepHeuristics_GetID_Unconstrained(farg1) +swig_result = fresult +end function + +function FSUNTimestepHeuristics_ConstrainStep_Unconstrained(h, hcur, hnew, hconstr) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(SUNTimestepHeuristics), target, intent(inout) :: h +real(C_DOUBLE), intent(in) :: hcur +real(C_DOUBLE), intent(in) :: hnew +real(C_DOUBLE), target, intent(inout) :: hconstr +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +real(C_DOUBLE) :: farg2 +real(C_DOUBLE) :: farg3 +type(C_PTR) :: farg4 + +farg1 = c_loc(h) +farg2 = hcur +farg3 = hnew +farg4 = c_loc(hconstr) +fresult = swigc_FSUNTimestepHeuristics_ConstrainStep_Unconstrained(farg1, farg2, farg3, farg4) +swig_result = fresult +end function + +function FSUNTimestepHeuristics_ConvFail_Unconstrained(h, hcur, hconstr) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(SUNTimestepHeuristics), target, intent(inout) :: h +real(C_DOUBLE), intent(in) :: hcur +real(C_DOUBLE), target, intent(inout) :: hconstr +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +real(C_DOUBLE) :: farg2 +type(C_PTR) :: farg3 + +farg1 = c_loc(h) +farg2 = hcur +farg3 = c_loc(hconstr) +fresult = swigc_FSUNTimestepHeuristics_ConvFail_Unconstrained(farg1, farg2, farg3) +swig_result = fresult +end function + +function FSUNTimestepHeuristics_Reset_Unconstrained(h) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(SUNTimestepHeuristics), target, intent(inout) :: h +integer(C_INT) :: fresult +type(C_PTR) :: farg1 + +farg1 = c_loc(h) +fresult = swigc_FSUNTimestepHeuristics_Reset_Unconstrained(farg1) +swig_result = fresult +end function + +function FSUNTimestepHeuristics_Write_Unconstrained(h, fptr) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(SUNTimestepHeuristics), target, intent(inout) :: h +type(C_PTR) :: fptr +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 + +farg1 = c_loc(h) +farg2 = fptr +fresult = swigc_FSUNTimestepHeuristics_Write_Unconstrained(farg1, farg2) +swig_result = fresult +end function + +function FSUNTimestepHeuristics_GetNumAccSteps_Unconstrained(h, accsteps) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(SUNTimestepHeuristics), target, intent(inout) :: h +integer(C_LONG), dimension(*), target, intent(inout) :: accsteps +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 + +farg1 = c_loc(h) +farg2 = c_loc(accsteps(1)) +fresult = swigc_FSUNTimestepHeuristics_GetNumAccSteps_Unconstrained(farg1, farg2) +swig_result = fresult +end function + +function FSUNTimestepHeuristics_Space_Unconstrained(h, lenrw, leniw) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(SUNTimestepHeuristics), target, intent(inout) :: h +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(h) +farg2 = c_loc(lenrw(1)) +farg3 = c_loc(leniw(1)) +fresult = swigc_FSUNTimestepHeuristics_Space_Unconstrained(farg1, farg2, farg3) +swig_result = fresult +end function + + +end module diff --git a/src/suntimestepheuristics/unconstrained/suntimestepheuristics_unconstrained.c b/src/suntimestepheuristics/unconstrained/suntimestepheuristics_unconstrained.c new file mode 100644 index 0000000000..410fcd88a5 --- /dev/null +++ b/src/suntimestepheuristics/unconstrained/suntimestepheuristics_unconstrained.c @@ -0,0 +1,135 @@ +/* ----------------------------------------------------------------- + * 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 + * SUNTimestepHeuristics_Unconstrained module. + * -----------------------------------------------------------------*/ + +#include +#include +#include +#include + + +/* --------------- + * Macro accessors + * --------------- */ + +#define SH_CONTENT(H) ( (SUNTimestepHeuristicsContent_Unconstrained)(H->content) ) +#define SH_NST_ACC(H) ( SH_CONTENT(H)->nst_acc ) + + +/* ----------------------------------------------------------------- + * exported functions + * ----------------------------------------------------------------- */ + +/* ----------------------------------------------------------------- + * Function to create a new unconstrained heuristics module + */ + +SUNTimestepHeuristics SUNTimestepHeuristics_Unconstrained(SUNContext sunctx) +{ + SUNTimestepHeuristics H; + SUNTimestepHeuristicsContent_Unconstrained content; + + /* Create an empty heuristics object */ + H = NULL; + H = SUNTimestepHeuristics_NewEmpty(sunctx); + if (H == NULL) { return (NULL); } + + /* Attach operations */ + H->ops->getid = SUNTimestepHeuristics_GetID_Unconstrained; + H->ops->constrainstep = SUNTimestepHeuristics_ConstrainStep_Unconstrained; + H->ops->convfail = SUNTimestepHeuristics_ConvFail_Unconstrained; + H->ops->reset = SUNTimestepHeuristics_Reset_Unconstrained; + H->ops->write = SUNTimestepHeuristics_Write_Unconstrained; + H->ops->getnumaccsteps = SUNTimestepHeuristics_GetNumAccSteps_Unconstrained; + H->ops->space = SUNTimestepHeuristics_Space_Unconstrained; + + /* Create content */ + content = NULL; + content = (SUNTimestepHeuristicsContent_Unconstrained)malloc(sizeof *content); + if (content == NULL) + { + (void) SUNTimestepHeuristics_Destroy(H); + return (NULL); + } + + /* Attach content */ + H->content = content; + + /* Fill content with default/reset values */ + SUNTimestepHeuristics_Reset_Unconstrained(H); + + return (H); +} + + +/* ----------------------------------------------------------------- + * implementation of heuristic operations + * ----------------------------------------------------------------- */ + +SUNTimestepHeuristics_ID SUNTimestepHeuristics_GetID_Unconstrained(SUNTimestepHeuristics H) +{ return SUN_TIMESTEPHEURISTICS_NULL; } + +int SUNTimestepHeuristics_ConstrainStep_Unconstrained(SUNTimestepHeuristics H, + sunrealtype hcur, + sunrealtype h_acc, + sunrealtype* hconstr) +{ + /* All steps are considered accuracy-limited */ + SH_NST_ACC(H)++; + + /* Pass recommended step size through and return */ + *hconstr = h_acc; + return SUNTIMESTEPHEURISTICS_SUCCESS; +} + +int SUNTimestepHeuristics_ConvFail_Unconstrained(SUNTimestepHeuristics H, + sunrealtype hcur, + sunrealtype* hconstr) +{ + /* No recovery is possible upon an algebraic solver convergence failure */ + *hconstr = hcur; + return SUNTIMESTEPHEURISTICS_CANNOT_DECREASE; +} + +int SUNTimestepHeuristics_Reset_Unconstrained(SUNTimestepHeuristics H) +{ + SH_NST_ACC(H) = 0; + return SUNTIMESTEPHEURISTICS_SUCCESS; +} + +int SUNTimestepHeuristics_Write_Unconstrained(SUNTimestepHeuristics H, + FILE *fptr) +{ + fprintf(fptr, "Unconstrained SUNTimestepHeuristics module:\n"); + fprintf(fptr, " Current step count = %li\n", SH_NST_ACC(H)); + return SUNTIMESTEPHEURISTICS_SUCCESS; +} + +int SUNTimestepHeuristics_GetNumAccSteps_Unconstrained(SUNTimestepHeuristics H, + long int* accsteps) +{ + *accsteps = SH_NST_ACC(H); + return SUNTIMESTEPHEURISTICS_SUCCESS; +} + +int SUNTimestepHeuristics_Space_Unconstrained(SUNTimestepHeuristics H, + long int* lenrw, + long int* leniw) +{ + *lenrw = 0; + *leniw = 1; + return SUNTIMESTEPHEURISTICS_SUCCESS; +} diff --git a/swig/Makefile b/swig/Makefile index ce4f536a66..1a4c54fb70 100644 --- a/swig/Makefile +++ b/swig/Makefile @@ -20,17 +20,19 @@ 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 fsundials_timestepheuristics_mod NVECTOR=openmp pthreads serial parallel manyvector mpiplusx SUNMATRIX=band dense sparse +SUNTIMESTEPHEURISTICS=default unconstrained +SUNADAPTCONTROLLER=expgus imexgus i impgus pid pi SUNLINSOL=band dense klu spbcgs spfgmr spgmr sptfqmr pcg SUNNONLINSOL=newton fixedpoint 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 suntimestepheuristics 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 suntimestepheuristics patch arkode: $(ARKODE:%:arkode/%.i) @for i in ${ARKODE} ; do \ @@ -102,9 +104,21 @@ 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 + +suntimestepheuristics: $(SUNTIMESTEPHEURISTICS:%:suntimestepheuristics/fsuntimestepheuristics_%_mod.i) + @for i in ${SUNTIMESTEPHEURISTICS} ; do \ + echo "swig -fortran -outdir ../src/suntimestepheuristics/$${i}/fmod -o ../src/suntimestepheuristics/$${i}/fmod ${INCLUDES} suntimestepheuristics/fsuntimestepheuristics_$${i}_mod.i" ; \ + swig -fortran -outdir ../src/suntimestepheuristics/$${i}/fmod -o ../src/suntimestepheuristics/$${i}/fmod/fsuntimestepheuristics_$${i}_mod.c ${INCLUDES} suntimestepheuristics/fsuntimestepheuristics_$${i}_mod.i ; \ + done + patch: .FORCE - cd ..; - + cd ..; + clean: rm ../src/**/fmod/*.c; rm ../src/**/fmod/*.f90 diff --git a/swig/arkode/farkode_mod.i b/swig/arkode/farkode_mod.i index caaad3f3c1..91b4e1824d 100644 --- a/swig/arkode/farkode_mod.i +++ b/swig/arkode/farkode_mod.i @@ -34,6 +34,8 @@ %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_timestepheuristics_mod.i" %import "../sundials/fsundials_types_mod.i" // Treat ARKodeButcherTable as an opaque pointer @@ -51,4 +53,3 @@ %include "arkode/arkode_butcher_erk.h" %include "arkode/arkode_sprk.h" %include "arkode/arkode_ls.h" - 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..1d1c9e16a9 100644 --- a/swig/sundials/fsundials.i +++ b/swig/sundials/fsundials.i @@ -37,6 +37,8 @@ %sundials_generic(SUNLinearSolver) %sundials_generic(SUNNonlinearSolver) %sundials_generic(SUNMatrix) +%sundials_generic(SUNAdaptController) +%sundials_generic(SUNTimestepHeuristics) // Treat FILE* as an opaque pointer %apply void* { FILE* }; @@ -101,4 +103,3 @@ ! SUNDIALS Copyright End ! --------------------------------------------------------------- %} - 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" diff --git a/swig/sundials/fsundials_timestepheuristics_mod.i b/swig/sundials/fsundials_timestepheuristics_mod.i new file mode 100644 index 0000000000..c4015065c2 --- /dev/null +++ b/swig/sundials/fsundials_timestepheuristics_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 fsundials_timestepheuristics_mod + +// Load the typedefs and generate a "use" statement in the module +%import "../sundials/fsundials_types_mod.i" +%import "../sundials/fsundials_context_mod.i" +%import "../sundials/fsundials_nvector_mod.i" + +%{ +#include "sundials/sundials_timestepheuristics.h" +%} + +// Process and wrap functions in the following files +%include "sundials/sundials_timestepheuristics.h" diff --git a/swig/suntimestepheuristics/fsuntimestepheuristics.i b/swig/suntimestepheuristics/fsuntimestepheuristics.i new file mode 100644 index 0000000000..08c6e403ea --- /dev/null +++ b/swig/suntimestepheuristics/fsuntimestepheuristics.i @@ -0,0 +1,31 @@ +// --------------------------------------------------------------- +// 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_timestepheuristics.h" +%} + +// Load the typedefs and generate "use" statements +%import "../sundials/fsundials_nvector_mod.i" +%import "../sundials/fsundials_timestepheuristics_mod.i" + +// Macro for creating an interface to an N_Vector +%define %suntimestepheuristics_impl(TYPE) + %ignore _SUNTimestepHeuristicsContent_## TYPE ##; +%enddef diff --git a/swig/suntimestepheuristics/fsuntimestepheuristics_default_mod.i b/swig/suntimestepheuristics/fsuntimestepheuristics_default_mod.i new file mode 100644 index 0000000000..fd60add3be --- /dev/null +++ b/swig/suntimestepheuristics/fsuntimestepheuristics_default_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 fsuntimestepheuristics_default_mod + +// include code common to all implementations +%include "fsuntimestepheuristics.i" + +%{ +#include "suntimestepheuristics/suntimestepheuristics_default.h" +%} + +%suntimestepheuristics_impl(Default) + +// Process and wrap functions in the following files +%include "suntimestepheuristics/suntimestepheuristics_default.h" diff --git a/swig/suntimestepheuristics/fsuntimestepheuristics_unconstrained_mod.i b/swig/suntimestepheuristics/fsuntimestepheuristics_unconstrained_mod.i new file mode 100644 index 0000000000..05c39bf7bc --- /dev/null +++ b/swig/suntimestepheuristics/fsuntimestepheuristics_unconstrained_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 fsuntimestepheuristics_unconstrained_mod + +// include code common to all implementations +%include "fsuntimestepheuristics.i" + +%{ +#include "suntimestepheuristics/suntimestepheuristics_unconstrained.h" +%} + +%suntimestepheuristics_impl(Unconstrained) + +// Process and wrap functions in the following files +%include "suntimestepheuristics/suntimestepheuristics_unconstrained.h" diff --git a/test/unit_tests/arkode/CXX_serial/ark_test_dahlquist_mri.out b/test/unit_tests/arkode/CXX_serial/ark_test_dahlquist_mri.out index ed079b7511..73bc1d248c 100644 --- a/test/unit_tests/arkode/CXX_serial/ark_test_dahlquist_mri.out +++ b/test/unit_tests/arkode/CXX_serial/ark_test_dahlquist_mri.out @@ -248,7 +248,7 @@ MRIStep Statistics: Time = 0.01 y(t) = 0.970446 y_n = 0.970446 - Error = -2.09771e-11 + Error = -2.0977e-11 Steps = 1 Fe evals = 7 Fi evals = 12 diff --git a/test/unit_tests/arkode/CXX_serial/ark_test_getjac.out b/test/unit_tests/arkode/CXX_serial/ark_test_getjac.out index 55510d3575..6cd23ccbc6 100644 --- a/test/unit_tests/arkode/CXX_serial/ark_test_getjac.out +++ b/test/unit_tests/arkode/CXX_serial/ark_test_getjac.out @@ -1,9 +1,9 @@ Jac nst = 0 -Jac t = 2.574576339619671e-05 +Jac t = 5.149152679239342e-05 Index J DQ J true absolute difference relative difference ------------------------------------------------------------------------------------------------------------ - 0 -1.999995689060819e+00 -1.999995709039434e+00 1.997861476255025e-08 -9.989328813183135e-09 - 1 4.999999950267850e-01 5.000000000000000e-01 4.973214950965144e-09 9.946429901930287e-09 - 2 4.999999864690596e-01 5.000000000000000e-01 1.353094036815605e-08 2.706188073631211e-08 - 3 -9.982835887986570e-01 -9.982836157735868e-01 2.697492984538030e-08 -2.702130879357063e-08 + 0 -1.999991397768883e+00 -1.999991418078868e+00 2.030998458302236e-08 -1.015503586636963e-08 + 1 4.999999949079691e-01 5.000000000000000e-01 5.092030852527074e-09 1.018406170505415e-08 + 2 4.999999533268726e-01 5.000000000000000e-01 4.667312741846175e-08 9.334625483692349e-08 + 3 -9.965671388854774e-01 -9.965672315471739e-01 9.266169642696553e-08 -9.298087825254695e-08