Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feautre/adapt opt #565

Draft
wants to merge 100 commits into
base: feature/min-err
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
100 commits
Select commit Hold shift + click to select a range
f6ff36d
Update default RK methods by order
Steven-Roberts Jul 26, 2024
198b442
Merge branch 'develop' into feature/rk_defaults
Steven-Roberts Jul 26, 2024
2bc4fb0
Add 5th order ERK of Tsitouras
Steven-Roberts Jul 26, 2024
6acabdc
Add FSAL 2nd order Ralston method
Steven-Roberts Jul 26, 2024
c5aeea6
Add Ralston to table in def file
Steven-Roberts Jul 26, 2024
609abba
Update Fortran interfaces
Steven-Roberts Jul 26, 2024
7dbb7f1
Merge branch 'develop' into feature/rk_defaults
Steven-Roberts Aug 29, 2024
e5df915
Merge branch 'develop' into feature/rk_defaults
Steven-Roberts Sep 6, 2024
1d790fe
Set the default ERKStep methods
Steven-Roberts Sep 6, 2024
4fee262
Update swig
Steven-Roberts Sep 6, 2024
045adb5
Butcher docs fixes
Steven-Roberts Sep 7, 2024
fb02b3e
Add Ralson method to docs
Steven-Roberts Sep 8, 2024
6a9a0ff
Update defaults in docs
Steven-Roberts Sep 8, 2024
f0b32d9
Add new methods to constants
Steven-Roberts Sep 8, 2024
b7518b2
Update changelog
Steven-Roberts Sep 8, 2024
3f015dd
Add Tsitouras method to docs
Steven-Roberts Sep 8, 2024
01b50b6
Switch to proposed adaptivity parameters
Steven-Roberts Sep 8, 2024
b733fa3
Merge branch 'feature/min-err' into feautre/adapt-opt
Steven-Roberts Sep 8, 2024
a22ad08
Update doc/arkode/guide/source/Butcher.rst
Steven-Roberts Sep 10, 2024
7e325c8
Merge branch 'feature/min-err' into feautre/adapt-opt
Steven-Roberts Sep 10, 2024
9bb63c0
Fix typos in changelog
Steven-Roberts Sep 10, 2024
875ae20
Merge branch 'develop' into feautre/adapt-opt
Steven-Roberts Sep 10, 2024
9ee43b3
Merge branch 'feature/min-err' into feautre/adapt-opt
Steven-Roberts Sep 10, 2024
d49f254
Merge branch 'develop' into feature/rk_defaults
Steven-Roberts Sep 10, 2024
65836d5
Merge branch 'feature/rk_defaults' into feautre/adapt-opt
Steven-Roberts Sep 10, 2024
1fea10b
Merge branch 'develop' into feature/rk_defaults
gardner48 Sep 11, 2024
d61fb37
Apply suggestions from code review
Steven-Roberts Sep 11, 2024
405355c
Remove trailing 0 from table
Steven-Roberts Sep 11, 2024
b625207
Merge branch 'develop' into feature/rk_defaults
Steven-Roberts Sep 16, 2024
5bfc505
Fix number of columns in table
Steven-Roberts Sep 16, 2024
fe2737f
Merge branch 'develop' into feature/rk_defaults
gardner48 Sep 16, 2024
b622b20
Add table of ERK properties
Steven-Roberts Sep 16, 2024
7ef8a2a
Remove ERK constants
Steven-Roberts Sep 16, 2024
9fb8aa9
Merge branch 'feature/rk_defaults' of github.com:LLNL/sundials into f…
Steven-Roberts Sep 16, 2024
332a7d0
Merge branch 'feature/rk_defaults' into feautre/adapt-opt
Steven-Roberts Sep 16, 2024
8a49e61
Merge branch 'feature/min-err' into feautre/adapt-opt
Steven-Roberts Sep 16, 2024
4ca3a50
Add DIRK table of properties
Steven-Roberts Sep 17, 2024
bc56b9d
update output files
gardner48 Sep 17, 2024
1660217
Remove MRI constants
Steven-Roberts Sep 17, 2024
f640b9a
Update ERK to use enumerators
Steven-Roberts Sep 17, 2024
d2a3a4a
Update DIRK to use enumerators
Steven-Roberts Sep 17, 2024
3ace173
Merge branch 'feature/rk_defaults' of github.com:LLNL/sundials into f…
Steven-Roberts Sep 17, 2024
9d865f2
Update ARK to use enumerators
Steven-Roberts Sep 17, 2024
a1ec425
Update SPRK to use enumerators
Steven-Roberts Sep 17, 2024
641746e
Fix broken refs
Steven-Roberts Sep 17, 2024
58206dd
Remove old constants
Steven-Roberts Sep 17, 2024
49cabed
Correct types of default tables
Steven-Roberts Sep 18, 2024
6666fe7
Bring back default tables to constants docs
Steven-Roberts Sep 18, 2024
a1eb43c
Added constructors for additional 'recommended' controllers from Sylv…
drreynolds Sep 18, 2024
afea9c0
Spelling fix
drreynolds Sep 18, 2024
7fe8654
Formatting
drreynolds Sep 18, 2024
cc26cf2
Fixed typo
drreynolds Sep 20, 2024
47ceedd
Added FAQ on temporal adaptivity controller selection
drreynolds Sep 20, 2024
fa46710
spelling
drreynolds Sep 20, 2024
9fefa0d
Revert default table constants to int
Steven-Roberts Sep 25, 2024
872ad0b
Merge branch 'develop' into feature/rk_defaults
Steven-Roberts Sep 25, 2024
27fca0a
Added ARKodeSetAdaptControllerByName
drreynolds Oct 16, 2024
3d66641
Merge branch 'develop' into feature/rk_defaults
Steven-Roberts Jan 9, 2025
f433f7e
Add missing whitespace
Steven-Roberts Jan 10, 2025
bab2097
Update single precision files
Steven-Roberts Jan 10, 2025
74bd101
Update additional single precision out file
Steven-Roberts Jan 10, 2025
7149aec
Enable artifacts for logging tests
Steven-Roberts Jan 10, 2025
2987445
Update double precision files
Steven-Roberts Jan 10, 2025
0ac4422
Enable artifacts for logging tests
Steven-Roberts Jan 10, 2025
ffed497
Update logging test out files
Steven-Roberts Jan 10, 2025
f689914
Level 3 logging out files
Steven-Roberts Jan 10, 2025
271ae5b
Level 4 logging out files
Steven-Roberts Jan 10, 2025
5b4a0d4
Final logging out files
Steven-Roberts Jan 10, 2025
34b2666
More out file updates for sanitizer_build_and_test
Steven-Roberts Jan 10, 2025
b5aebc8
Update answers repo
Steven-Roberts Jan 10, 2025
e6cbd0e
Update f2003 out files
Steven-Roberts Jan 11, 2025
caabcfd
update output files
gardner48 Jan 11, 2025
3b75d4b
Fix bug in floatCompare when numbers get rounded differently despite …
Steven-Roberts Jan 11, 2025
a3c9627
Update double precision out files
Steven-Roberts Jan 11, 2025
9247376
Update ark_heat1D_omp.out
Steven-Roberts Jan 12, 2025
2ebbd6e
update fortran output files
gardner48 Jan 13, 2025
ceee086
merged upstream changes
drreynolds Jan 14, 2025
e3cc34c
Cleaned up merge issues
drreynolds Jan 14, 2025
5d14239
Merge branch 'develop' into feature/rk_defaults
Steven-Roberts Jan 21, 2025
daf6a11
Merge branch 'develop' into feature/rk_defaults
Steven-Roberts Jan 28, 2025
7c765a3
Update logging out files
Steven-Roberts Jan 28, 2025
1b27b2c
Update single precision out files
Steven-Roberts Jan 28, 2025
e2ea6e8
Update level 3 logging out files
Steven-Roberts Jan 28, 2025
094c9b1
Update level 4 logging out files
Steven-Roberts Jan 28, 2025
d7f2eb5
Update level 5 logging out files
Steven-Roberts Jan 28, 2025
bc7ff83
Update double precision out files
Steven-Roberts Jan 29, 2025
6f40ec0
Merge branch 'develop' into feature/rk_defaults
Steven-Roberts Jan 29, 2025
71fa6c7
update output files
gardner48 Jan 30, 2025
42e86cb
update answers submodule
gardner48 Jan 30, 2025
479bf3b
Merge branch 'develop' into feature/rk_defaults
gardner48 Jan 30, 2025
af5f5e3
Adjust ark_heat1D_omp to be more suitable for single precision. Hopef…
Steven-Roberts Jan 30, 2025
6ed0bfd
Update ark_heat1D_omp out files
Steven-Roberts Jan 30, 2025
2600884
Merge branch 'develop' into feature/rk_defaults
gardner48 Jan 31, 2025
a097c51
Merge branch 'develop' into feature/rk_defaults
gardner48 Jan 31, 2025
7f2c641
update ark_heat1D_omp output
gardner48 Jan 31, 2025
7ce9bd8
Merge branch 'feature/rk_defaults' into feautre/adapt-opt
Steven-Roberts Jan 31, 2025
0292f28
Fix broken links when building pdf
Steven-Roberts Jan 31, 2025
6c926c9
Merge branch 'feature/min-err' into feautre/adapt-opt
Steven-Roberts Feb 14, 2025
3a33c03
Fix merge issue
Steven-Roberts Feb 18, 2025
2c1374c
Update default controllers
Steven-Roberts Feb 19, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 33 additions & 3 deletions doc/arkode/guide/source/Usage/User_callable.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1084,8 +1084,9 @@ Set max number of constraint failures :c:func:`ARKodeSetMaxNumConstr
:c:func:`ARKodeSetMinReduction`,
:c:func:`ARKodeSetSafetyFactor`,
:c:func:`ARKodeSetSmallNumEFails`,
:c:func:`ARKodeSetStabilityFn`, and
:c:func:`ARKodeSetAdaptController`
:c:func:`ARKodeSetStabilityFn`,
:c:func:`ARKodeSetAdaptController`, and
:c:func:`ARKodeSetAdaptControllerByName`
will be ignored, since temporal adaptivity is disabled.

If both :c:func:`ARKodeSetFixedStep` and
Expand Down Expand Up @@ -1114,7 +1115,7 @@ Set max number of constraint failures :c:func:`ARKodeSetMaxNumConstr
selects forward integration, a negative value selects
backward integration, and zero leaves the current direction
unchanged.


:retval ARK_SUCCESS: the function exited successfully.
:retval ARK_MEM_NULL: ``arkode_mem`` was ``NULL``.
Expand Down Expand Up @@ -1454,6 +1455,7 @@ the code, is provided in :numref:`ARKODE.Mathematics.Adaptivity`.
Optional input Function name Default
========================================================= ========================================== ========
Provide a :c:type:`SUNAdaptController` for ARKODE to use :c:func:`ARKodeSetAdaptController` PID
Specify a :c:type:`SUNAdaptController` for ARKODE to use :c:func:`ARKodeSetAdaptControllerByName` PID
Adjust the method order used in the controller :c:func:`ARKodeSetAdaptivityAdjustment` -1
Explicit stability safety factor :c:func:`ARKodeSetCFLFraction` 0.5
Time step error bias factor :c:func:`ARKodeSetErrorBias` 1.5
Expand Down Expand Up @@ -1499,6 +1501,34 @@ Reset accumulated error :c:func:`ARKodeReset
.. versionadded:: 6.1.0


.. c:function:: int ARKodeSetAdaptControllerByName(void* arkode_mem, const char* cname)

Sets a user-supplied time-step controller object by name.

:param arkode_mem: pointer to the ARKODE memory block.
:param cname: name of the time adaptivity controller to use. Allowable values
currently include ``"Soderlind"``, ``"PID"``, ``"PI"``, ``"I"``,
``"ExpGus"``, ``"ImpGus"``, ``"H0211"``, ``"H211"``, ``"H312"``. For
information on these options, see :numref:`SUNAdaptController.Soderlind`.

:retval ARK_SUCCESS: the function exited successfully.
:retval ARK_ILL_INPUT: *cname* did not match an allowed value.
:retval ARK_MEM_NULL: ``arkode_mem`` was ``NULL``.
:retval ARK_STEPPER_UNSUPPORTED: adaptive step sizes are not supported
by the current time-stepping module.

.. note::

This is only compatible with time-stepping modules that support temporal adaptivity.

It is not possible to adjust the internal controller parameters when using this
function. Users who wish to adjust these parameters should create and configure
the :c:type:`SUNAdaptController` object manually, and then call
:c:func:`ARKodeSetAdaptController`.

.. versionadded:: x.y.z


.. c:function:: int ARKodeSetAdaptivityAdjustment(void* arkode_mem, int adjust)

Called by a user to adjust the method order supplied to the temporal adaptivity
Expand Down
44 changes: 44 additions & 0 deletions doc/shared/FAQ.rst
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,50 @@ CVODE(S) / IDA(S) / ARKODE
integrals (very often a large number of them) need to be computed for adjoint sensitivity.


.. collapse:: When should I select a non-default temporal adaptivity controller in ARKODE?

The default temporal adaptivity controller in ARKODE was selected due to its robust performance on test
problems that ranged in difficulty and stiffness, and when running with a wide range of solution tolerances
and method orders. While we hope that this default runs well on most applications, it is unlikely to be
optimal. A prime indicator that an alternate adaptivity controller may be useful is if the default results
in a large number of rejected steps. Alternately, for higher-cost calculations where a reduction of 10%-20%
in the number of time steps would be important, users may want to try another controller option.

The default temporal adaptivity controller in ARKODE is the industry-standard *I* controller:

.. math::
h' = h_n \varepsilon_n^{-1/(p+1)}

where :math:`\varepsilon_n = \text{bias}*\text{dsm}_n`, and :math:`\text{dsm}_n` is the WRMS norm of the
local temporal error when using the time step :math:`h_n`, weighted by the user-requested tolerances.
However, the :ref:`SUNAdaptController class <SUNAdaptController>` in SUNDIALS provides a range of more
advanced temporal error controllers that could be applied to a given application problem, including the
:math:`H_{0}321`, :math:`H_{0}211`, :math:`H211`, and :math:`H312` controllers from :cite:p:`Sod:03`,
as well as a variety of controllers (*PI*, *PID*, *ExpGus*, *ImpGus*, and *ImExGus*) that were included
in the initial ARKODE release.

The adaptive time-stepping controllers introduced by Soderlind in :cite:p:`Sod:03` can be classified into
two groups; *deadbeat* controllers and *non-deadbeat* controllers. A controller is known as deadbeat if
the roots of its characteristic equation are located at the origin. These controllers are generalized
forms of the *I* controller, are denoted with a zero subscript as part of the controller name (e.g.,
:math:`H_{0}321`), and are generally recommended for applications with smooth solutions as a function of time.

While it is impossible to exhaustively explore the question of controller optimality for all application
problems, we have performed tests on the range of provided controllers on a variety of stiff and non-stiff
problems, at varying tolerances (:math:`10^{-9} \to 10^{-3}`), and for Runge--Kutta methods at a wide range
of orders of accuracy (ERK orders 2-9, and DIRK orders 2-5). From our experiments, stiff problems benefitted
from the *I*, *PI*, :math:`H_{0}211`, :math:`H_{0}321`, and *ImpGus* controllers. On the other hand,
non-stiff test problems ran most efficiently when using the *PID*, *I*, *ExpGus*, :math:`H211`, and
:math:`H312` controllers.

Lastly, we note that the internal controller parameters for the legacy ARKODE controllers (*PI*, *PID*,
*ExpGus*, *ImpGus*, and *ImExGus*) were determined via numerical optimization over a given set of test
problems. As a result, although those controllers work very well for some applications, they may not
work well with others. For users who are interested in exploring novel controller methods, we point out
that the :ref:`"Soderlind" <SUNAdaptController.Soderlind>` SUNAdaptController allows complete control
over all internal parameters via the :c:func:`SUNAdaptController_SetParams_Soderlind` function.


KINSOL
------

Expand Down
69 changes: 61 additions & 8 deletions doc/shared/sunadaptcontroller/SUNAdaptController_Soderlind.rst
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,12 @@ and :cite:p:`Sod:06`. This controller has the form

with default parameter values :math:`k_1 = 1.25`, :math:`k_2 = 0.5`,
:math:`k_3 = -0.75`, :math:`k_4 = 0.25`, and :math:`k_5 = 0.75`, where
:math:`p` is the global order of the time integration method. During the first
:math:`p` is the global order of the time integration method. We note that
this combination of parameters corresponds with the :math:`H_{0}321`
controller described in :cite:p:`Sod:03`. During the first
two steps (when :math:`\varepsilon_{n-2}`, :math:`\varepsilon_{n-1}`,
:math:`h_{n-2}`, and :math:`h_{n-2}` may be unavailable), the I controller
:math:`h' = h_n \varepsilon_1^{-1/(p+1)}` is used.
:math:`h' = h_n \varepsilon_n^{-1/(p+1)}` is used.

The SUNAdaptController_Soderlind controller is implemented as a derived
SUNAdaptController class, and defines its *content* field as:
Expand Down Expand Up @@ -71,11 +73,11 @@ The header file to be included when using this module is
``sunadaptcontroller/sunadaptcontroller_soderlind.h``.

We note that through appropriate selection of the parameters :math:`k_*`,
this controller may create a wide range of proposed temporal adaptivity controllers,
including the PID, PI, I, as well as Gustafsson's explicit and implicit controllers,
:cite:p:`Gust:91` and :cite:p:`Gust:94`. As a convenience, utility routines to
create these controllers and set their parameters (as special cases of the
SUNAdaptController_Soderlind) are provided.
this controller may create a wide range of proposed temporal adaptivity
controllers, including the :math:`H_{0}321`, I, PI, PID, as well as Gustafsson's
explicit and implicit controllers, :cite:p:`Gust:91` and :cite:p:`Gust:94`,
among others. As a convenience, utility routines to create a variety of these
controllers and set their parameters (as special cases of SUNAdaptController_Soderlind) are provided.

The SUNAdaptController_Soderlind class provides implementations of all operations
relevant to a ``SUN_ADAPTCONTROLLER_H`` controller listed in
Expand Down Expand Up @@ -242,7 +244,7 @@ also provides the following additional user-callable routines:
.. c:function:: SUNErrCode SUNAdaptController_SetParams_ExpGus(SUNAdaptController C, sunrealtype k1_hat, sunrealtype k2_hat)

This user-callable function provides control over the relevant parameters
above for the explicit Gustafsson controller, setting :math:`k_3 = k_4 = k_5 = 0`.
above for the explicit Gustafsson controller, setting :math:`k_3 = k_4 = k_5 = 0`.
This should be called *before* the time integrator is called to evolve the problem.

.. note::
Expand Down Expand Up @@ -312,3 +314,54 @@ also provides the following additional user-callable routines:
.. code-block:: c

retval = SUNAdaptController_SetParams_ImpGus(C, 0.98, 0.95);

.. c:function:: SUNAdaptController SUNAdaptController_H0211(SUNContext sunctx)

This constructor creates and allocates memory for a
SUNAdaptController_Soderlind object, set up to replicate the :math:`H_{0}211`
controller from :cite:p:`Sod:03`, corresponding with the parameters :math:`k_1=0.5`,
:math:`k_2=0.5`, :math:`k_4=-0.5`, and :math:`k_3=k_5=0`.

:param sunctx: the current :c:type:`SUNContext` object.
:return: if successful, a usable :c:type:`SUNAdaptController` object;
otherwise it will return ``NULL``.

Usage:

.. code-block:: c

SUNAdaptController C = SUNAdaptController_H0211(sunctx);

.. c:function:: SUNAdaptController SUNAdaptController_H211(SUNContext sunctx)

This constructor creates and allocates memory for a
SUNAdaptController_Soderlind object, set up to replicate the :math:`H211`
controller from :cite:p:`Sod:03`, corresponding with the parameters :math:`k_1=0.25`,
:math:`k_2=0.25`, :math:`k_4=-0.25`, and :math:`k_3=k_5=0`.

:param sunctx: the current :c:type:`SUNContext` object.
:return: if successful, a usable :c:type:`SUNAdaptController` object;
otherwise it will return ``NULL``.

Usage:

.. code-block:: c

SUNAdaptController C = SUNAdaptController_H211(sunctx);

.. c:function:: SUNAdaptController SUNAdaptController_H312(SUNContext sunctx)

This constructor creates and allocates memory for a
SUNAdaptController_Soderlind object, set up to replicate the :math:`H312`
controller from :cite:p:`Sod:03`, corresponding with the parameters :math:`k_1=0.125`,
:math:`k_2=0.25`, :math:`k_3=0.125`, :math:`k_4=-0.375`, and :math:`k_5=-0.125`.

: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_H312(sunctx);
63 changes: 19 additions & 44 deletions examples/arkode/CXX_parallel/ark_diffusion_reaction_p.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@
#include <limits>
#include <random>
#include <sstream>
#include <string>

// Include MPI
#include "mpi.h"
Expand Down Expand Up @@ -282,10 +283,10 @@ struct UserData
// Shared IMEX and MRI settings
// ----------------------------

int controller = 0; // step size adaptivity method (0 = use default)
int maxsteps = 0; // max steps between outputs (0 = use default)
bool linear = true; // enable/disable linearly implicit option
bool diagnostics = false; // output diagnostics
string controller = "PID"; // step size adaptivity method
int maxsteps = 0; // max steps between outputs (0 = use default)
bool linear = true; // enable/disable linearly implicit option
bool diagnostics = false; // output diagnostics

// -----------------------------------------
// Nonlinear solver settings
Expand Down Expand Up @@ -379,11 +380,10 @@ static int SetupDecomp(UserData* udata);

// Integrator setup functions
static int SetupARK(SUNContext ctx, UserData* udata, N_Vector u,
SUNLinearSolver LS, SUNAdaptController* Ctrl,
void** arkode_mem);
SUNLinearSolver LS, void** arkode_mem);
static int SetupMRI(SUNContext ctx, UserData* udata, N_Vector u,
SUNLinearSolver LS, SUNAdaptController* Ctrl,
void** arkode_mem, MRIStepInnerStepper* stepper);
SUNLinearSolver LS, void** arkode_mem,
MRIStepInnerStepper* stepper);
static int SetupMRICVODE(SUNContext ctx, UserData* udata, N_Vector u,
SUNLinearSolver LS, SUNNonlinearSolver* NLS,
void** arkode_mem, MRIStepInnerStepper* stepper);
Expand Down Expand Up @@ -557,18 +557,15 @@ 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, &Ctrl, &arkode_mem);
flag = SetupARK(ctx, &udata, u, LS, &arkode_mem);
if (check_flag((void*)arkode_mem, "SetupARK", 0)) { return 1; }
break;
case (1):
flag = SetupMRI(ctx, &udata, u, LS, &Ctrl, &arkode_mem, &stepper);
flag = SetupMRI(ctx, &udata, u, LS, &arkode_mem, &stepper);
if (check_flag((void*)arkode_mem, "SetupMRI", 0)) { return 1; }
break;
case (2):
Expand Down Expand Up @@ -700,7 +697,6 @@ 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;
Expand Down Expand Up @@ -906,8 +902,7 @@ static int SetupDecomp(UserData* udata)
// -----------------------------------------------------------------------------

static int SetupARK(SUNContext ctx, UserData* udata, N_Vector u,
SUNLinearSolver LS, SUNAdaptController* Ctrl,
void** arkode_mem)
SUNLinearSolver LS, void** arkode_mem)
{
int flag;

Expand Down Expand Up @@ -968,17 +963,8 @@ static int SetupARK(SUNContext ctx, UserData* udata, N_Vector u,
}
else
{
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 = ARKodeSetAdaptController(*arkode_mem, *Ctrl);
if (check_flag(&flag, "ARKodeSetAdaptController", 1)) { return 1; }
flag = ARKodeSetAdaptControllerByName(*arkode_mem, udata->controller.c_str());
if (check_flag(&flag, "ARKodeSetAdaptControllerByName", 1)) { return 1; }
}

// Set max steps between outputs
Expand All @@ -993,8 +979,8 @@ static int SetupARK(SUNContext ctx, UserData* udata, N_Vector u,
}

static int SetupMRI(SUNContext ctx, UserData* udata, N_Vector y,
SUNLinearSolver LS, SUNAdaptController* Ctrl,
void** arkode_mem, MRIStepInnerStepper* stepper)
SUNLinearSolver LS, void** arkode_mem,
MRIStepInnerStepper* stepper)
{
int flag;

Expand Down Expand Up @@ -1026,17 +1012,9 @@ static int SetupMRI(SUNContext ctx, UserData* udata, N_Vector y,
}
else
{
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 = ARKodeSetAdaptController(inner_arkode_mem, *Ctrl);
if (check_flag(&flag, "ARKodeSetAdaptController", 1)) { return 1; }
flag = ARKodeSetAdaptControllerByName(inner_arkode_mem,
udata->controller.c_str());
if (check_flag(&flag, "ARKodeSetAdaptControllerByName", 1)) { return 1; }
}

// Set max steps between outputs
Expand Down Expand Up @@ -2221,10 +2199,7 @@ static int ReadInputs(int* argc, char*** argv, UserData* udata)
else if (arg == "--h_slow") { udata->h_slow = stod((*argv)[arg_idx++]); }
else if (arg == "--h_fast") { udata->h_fast = stod((*argv)[arg_idx++]); }
// Shared IMEX and MRI settings
else if (arg == "--controller")
{
udata->controller = stoi((*argv)[arg_idx++]);
}
else if (arg == "--controller") { udata->controller = (*argv)[arg_idx++]; }
else if (arg == "--nonlinear") { udata->linear = false; }
else if (arg == "--diagnostics") { udata->diagnostics = true; }
// Linear solver settings
Expand Down
Loading
Loading