Skip to content

Commit 8fc92c1

Browse files
authored
Merge branch 'develop' into docs/release-links
2 parents 0a43023 + b12e77b commit 8fc92c1

File tree

10 files changed

+305
-34
lines changed

10 files changed

+305
-34
lines changed

CHANGELOG.md

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ The latter method requires building with LAPACK support enabled.
1212
Added the function `LSRKStepSetDomEigEstimator` in LSRKStep to attach a
1313
`SUNDomEigEstimator`, when using Runge-Kutta-Chebyshev or Runge-Kutta-Legendre
1414
methods, as an alternative to supplying a user-defined function to compute the dominant
15-
eigenvalue.
15+
eigenvalue.
1616

1717
### New Features and Enhancements
1818

@@ -23,6 +23,11 @@ in any order.
2323

2424
### Bug Fixes
2525

26+
Fixed a bug in how MRIStep interacts with an MRIHTol SUNAdaptController object
27+
(the previous version essentially just reverted to a decoupled multirate
28+
controller). Removed the upper limit on `inner_max_tolfac` in
29+
`SUNAdaptController_SetParams_MRIHTol`.
30+
2631
The shared library version numbers for the oneMKL dense linear solver and
2732
matrix as well as the PETSc SNES nonlinear solver have been corrected.
2833

@@ -48,6 +53,13 @@ Fixed a bug in `ARKodeSetDefaults` with LSRKStep where the stored spectral
4853
radius data was reset to zero, flags to update the dominant eigenvalue were
4954
reset to true, and a flag indicating if an SSP is being used was reset to false.
5055

56+
Fixed a bug introduced in v7.3.0 in KINSOL when using Anderson acceleration and
57+
solving a problem multiple times with the same KINSOL instance. In this use
58+
case, the current Anderson acceleration depth from the initial solve was not
59+
reinitialized on subsequent solves.
60+
61+
Fixed a logging bug in KINSOL where logging messages would not be output.
62+
5163
Fixed a bug in the `suntools.logs` Python module where the `get_history`
5264
function, when given a `step_status` for filtering output from a multirate
5365
method, would only extract values from the fast time scale if the slow time

doc/arkode/guide/source/Mathematics.rst

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -525,8 +525,8 @@ Runge--Kutta--Chebyshev (RKC), :cite:p:`VSH:04` and Runge--Kutta--Legendre (RKL)
525525

526526
.. math::
527527
z_0 &= y_n,\\
528-
z_1 &= z_0 + h \tilde{\mu}_1 f(t_n,z_0),\\
529-
z_j &= (1-\mu_j-\nu_j)z_0 + \mu_j z_{j-1} + \nu_jz_{j-2} + h \tilde{\gamma}_j f(t_n,z_0) + h \tilde{\mu}_j f(t_n + c_{j-1}h, z_{j-1}) \\
528+
z_1 &= z_0 + h_n \tilde{\mu}_1 f(t_n,z_0),\\
529+
z_j &= (1-\mu_j-\nu_j)z_0 + \mu_j z_{j-1} + \nu_jz_{j-2} + h_n \tilde{\gamma}_j f(t_n,z_0) + h_n \tilde{\mu}_j f(t_n + c_{j-1}h, z_{j-1}) \\
530530
y_{n+1} &= z_s.
531531
:label: ARKODE_RKC_RKL
532532
@@ -546,7 +546,7 @@ The SSPRK methods in ARKODE use the following Shu--Osher representation :cite:p:
546546

547547
.. math::
548548
z_1 &= y_n,\\
549-
z_i &= \sum_{j = 1}^{i-1} \left(\alpha_{i,j}y_j + \beta_{i,j}h f(t_n + c_jh, z_j)\right),\\
549+
z_i &= \sum_{j = 1}^{i-1} \left(\alpha_{i,j}y_j + \beta_{i,j}h f(t_n + c_jh_n, z_j)\right),\\
550550
y_{n+1} &= z_s.
551551
:label: ARKODE_SSP
552552
@@ -574,15 +574,15 @@ components:
574574

575575
* :math:`f^E(t,y)` contains the "slow-nonstiff" components of the system
576576
(this will be integrated using an explicit method and a large time step
577-
:math:`h^S`),
577+
:math:`h^S_n`),
578578

579579
* :math:`f^I(t,y)` contains the "slow-stiff" components of the system
580580
(this will be integrated using an implicit method and a large time step
581-
:math:`h^S`), and
581+
:math:`h^S_n`), and
582582

583583
* :math:`f^F(t,y)` contains the "fast" components of the system (this will be
584584
integrated using a possibly different method than the slow time scale and a
585-
small time step :math:`h^F \ll h^S`).
585+
small time step :math:`h^F_n \ll h^S_n`).
586586

587587
As with ERKStep, MRIStep currently requires that problems be posed with
588588
an identity mass matrix, :math:`M(t)=I`. The slow time scale may consist of only
@@ -626,10 +626,10 @@ algorithm for a single step:
626626
diagonally-implicit, or additive Runge--Kutta stage update,
627627

628628
.. math::
629-
z_i - \theta_{i,i} h^S f^I(t_{n,i}^S, z_i) = a_i.
629+
z_i - \theta_{i,i} h^S_n f^I(t_{n,i}^S, z_i) = a_i.
630630
:label: MRI_implicit_solve
631631
632-
where :math:`t_{n,j}^S = t_{n-1} + h^S c^S_j`.
632+
where :math:`t_{n,j}^S = t_{n-1} + h^S_n c^S_j`.
633633

634634
#. Set :math:`y_{n} = z_{s}`.
635635

@@ -645,7 +645,7 @@ algorithm for a single step:
645645
stage update,
646646

647647
.. math::
648-
\tilde{y}_n - \tilde{\theta} h^S f^I(t_n, \tilde{y}_n) = \tilde{a}.
648+
\tilde{y}_n - \tilde{\theta} h^S_n f^I(t_n, \tilde{y}_n) = \tilde{a}.
649649
:label: MRI_embedding_implicit_solve
650650
651651
Whether a fast IVP evolution or a stage update (or both) is needed depends on
@@ -684,7 +684,7 @@ given by
684684
+ \frac{1}{\Delta c_i^S} \sum\limits_{j=1}^i \gamma_{i,j}(\tau) f^I(t_{n,j}^S, z_j)
685685
686686
where :math:`\Delta c_i^S=\left(c^S_i - c^S_{i-1}\right)`, :math:`\tau = (t -
687-
t_{n,i-1}^S)/(h^S \Delta c_i^S)` is the normalized time, the coefficients
687+
t_{n,i-1}^S)/(h^S_n \Delta c_i^S)` is the normalized time, the coefficients
688688
:math:`\omega_{i,j}` and :math:`\gamma_{i,j}` are polynomials in time of degree
689689
:math:`k-1` given by
690690

@@ -701,9 +701,9 @@ stage is computed as
701701

702702
.. math::
703703
z_i = z_{i-1}
704-
+ h^S \sum_{j=1}^{i-1} \left(\sum_{\ell = 1}^{k}
704+
+ h^S_n \sum_{j=1}^{i-1} \left(\sum_{\ell = 1}^{k}
705705
\frac{\Omega_{i,j,\ell}}{\ell}\right) f^E(t_{n,j}^S, z_j)
706-
+ h^S \sum_{j=1}^i \left(\sum_{\ell = 1}^{k}
706+
+ h^S_n \sum_{j=1}^i \left(\sum_{\ell = 1}^{k}
707707
\frac{\Gamma_{i,j,\ell}}{\ell}\right) f^I(t_{n,j}^S, z_j).
708708
:label: ARKODE_MRI_delta_c_zero
709709
@@ -747,15 +747,15 @@ given by
747747
r_i(t) = \frac{1}{c_i^S} \sum\limits_{j=1}^{i-1} \omega_{i,j}(\tau) \left( f^E(t_{n,j}^S, z_j) + f^I(t_{n,j}^S, z_j)\right),
748748
:label: IMEXMRISR_forcing
749749
750-
where :math:`\tau = (t - t_n)/(h^S c_i^S)` is the normalized time, and the coefficients
750+
where :math:`\tau = (t - t_n)/(h^S_n c_i^S)` is the normalized time, and the coefficients
751751
:math:`\omega_{i,j}` are polynomials in time of degree :math:`k-1` that are also given by
752752
:eq:`ARKODE_MRI_coupling`. The solution of these fast IVPs defines an intermediate stage
753753
solution, :math:`\tilde{z}_i`.
754754

755755
The implicit solve that follows each fast IVP must solve the algebraic equation for :math:`z_i`
756756

757757
.. math::
758-
z_i = \tilde{z}_i + h^S \sum_{j=1}^{i} \gamma_{i,j} f^I(t_{n,j}^S, z_j).
758+
z_i = \tilde{z}_i + h^S_n \sum_{j=1}^{i} \gamma_{i,j} f^I(t_{n,j}^S, z_j).
759759
:label: ARKODE_MRISR_implicit
760760
761761
We note that IMEX-MRI-SR methods are solve-decoupled by construction, and thus the structure
@@ -798,10 +798,10 @@ solutions at these times as the stages :math:`z_i`. For example, the
798798
groups. The fourth group contains stages 7, 8, 9, and the embedding, corresponding to
799799
the :math:`c_i^S` values :math:`7/10`, :math:`1/2`, :math:`2/3`, and :math:`1`.
800800
Sorting these, a single fast IVP for this group must be evolved over the interval
801-
:math:`[t_{0,i},t_{F,i}] = [t_{n-1}, t_{n}]`, first pausing at :math:`t_{n-1}+\frac12 h^S`
802-
to store :math:`z_8`, then pausing at :math:`t_{n-1}+\frac{2}{3} h^S` to store
803-
:math:`z_9`, then pausing at :math:`t_{n-1}+\frac{7}{10} h^S` to store :math:`z_7`,
804-
and finally finishing the IVP solve to :math:`t_{n-1}+h^S` to obtain :math:`\tilde{y}_n`.
801+
:math:`[t_{0,i},t_{F,i}] = [t_{n-1}, t_{n}]`, first pausing at :math:`t_{n-1}+\frac12 h^S_n`
802+
to store :math:`z_8`, then pausing at :math:`t_{n-1}+\frac{2}{3} h^S_n` to store
803+
:math:`z_9`, then pausing at :math:`t_{n-1}+\frac{7}{10} h^S_n` to store :math:`z_7`,
804+
and finally finishing the IVP solve to :math:`t_{n-1}+h^S_n` to obtain :math:`\tilde{y}_n`.
805805

806806
.. note::
807807

@@ -1257,8 +1257,8 @@ Multirate time step adaptivity (MRIStep)
12571257

12581258
Since multirate applications evolve on multiple time scales,
12591259
MRIStep supports additional forms of temporal adaptivity. Specifically,
1260-
we consider time steps at two adjacent levels, :math:`h^S > h^F`, where
1261-
:math:`h^S` is the step size used by MRIStep, and :math:`h^F` is the
1260+
we consider time steps at two adjacent levels, :math:`h^S_n > h^F_n`, where
1261+
:math:`h^S_n` is the step size used by MRIStep, and :math:`h^F_n` is the
12621262
step size used to solve the corresponding fast-time-scale IVPs in
12631263
MRIStep, :eq:`MRI_fast_IVP` and :eq:`MRI_embedding_fast_IVP`.
12641264

@@ -1271,8 +1271,8 @@ Multirate temporal controls
12711271
We consider two categories of temporal controllers that may be used within MRI
12721272
methods. The first (and simplest), are "decoupled" controllers, that consist of
12731273
two separate single-rate temporal controllers: one that adapts the slow time scale
1274-
step size, :math:`h^S`, and the other that adapts the fast time scale step size,
1275-
:math:`h^F`. As these ignore any coupling between the two time scales, these
1274+
step size, :math:`h^S_n`, and the other that adapts the fast time scale step size,
1275+
:math:`h^F_n`. As these ignore any coupling between the two time scales, these
12761276
methods should work well for multirate problems where the time scales are somewhat
12771277
decoupled, and that errors introduced at one scale do not "pollute" the other.
12781278

@@ -1319,7 +1319,7 @@ adaptivity controllers:
13191319
* scontrol-Tol -- this is a single-rate controller that adapts :math:`\text{RTOL}^F_n`
13201320
using the strategy described above.
13211321

1322-
* fcontrol -- this adapts time steps :math:`h^F` within the fast integrator to achieve
1322+
* fcontrol -- this adapts time steps :math:`h^F_n` within the fast integrator to achieve
13231323
the current tolerance, :math:`\text{RTOL}^F_n`.
13241324

13251325
We note that both the decoupled and :math:`h^S`-:math:`Tol` controller families may be used in
@@ -1670,26 +1670,26 @@ differently based on the type of mass-matrix supplied by the user.
16701670
have the residual
16711671

16721672
.. math::
1673-
G(z_i) \equiv z_i - h^S \left(\sum_{k\geq 1} \frac{\Gamma_{i,i,k}}{k}\right)
1673+
G(z_i) \equiv z_i - h^S_n \left(\sum_{k\geq 1} \frac{\Gamma_{i,i,k}}{k}\right)
16741674
f^I(t_{n,i}^S, z_i) - a_i = 0
16751675
:label: ARKODE_IMEX-MRI-GARK_Residual
16761676
16771677
where
16781678

16791679
.. math::
1680-
a_i \equiv z_{i-1} + h^S \sum_{j=1}^{i-1} \left(\sum_{k\geq 1}
1680+
a_i \equiv z_{i-1} + h^S_n \sum_{j=1}^{i-1} \left(\sum_{k\geq 1}
16811681
\frac{\Gamma_{i,j,k}}{k}\right)f^I(t_{n,j}^S, z_j).
16821682
16831683
IMEX-MRI-SR methods have the residual
16841684

16851685
.. math::
1686-
G(z_i) \equiv z_i - h^S \Gamma_{i,i} f^I(t_{n,i}^S, z_i) - a_i = 0
1686+
G(z_i) \equiv z_i - h^S_n \Gamma_{i,i} f^I(t_{n,i}^S, z_i) - a_i = 0
16871687
:label: ARKODE_IMEX-MRI-SR_Residual
16881688
16891689
where
16901690

16911691
.. math::
1692-
a_i \equiv z_{i-1} + h^S \sum_{j=1}^{i-1} \Gamma_{i,j} f^I(t_{n,j}^S, z_j).
1692+
a_i \equiv z_{i-1} + h^S_n \sum_{j=1}^{i-1} \Gamma_{i,j} f^I(t_{n,j}^S, z_j).
16931693
16941694
16951695
Upon solving for :math:`z_i`, method stages must store
@@ -1748,7 +1748,7 @@ within ARKStep, or
17481748
.. math::
17491749
{\mathcal A}(t,z) \approx I - \gamma J(t,z), \quad
17501750
J(t,z) = \frac{\partial f^I(t,z)}{\partial z}, \quad\text{and}\quad
1751-
\gamma = h^S \sum_{k\geq 1} \frac{\Gamma_{i,i,k}}{k}
1751+
\gamma = h^S_n \sum_{k\geq 1} \frac{\Gamma_{i,i,k}}{k}
17521752
:label: ARKODE_NewtonMatrix_MRIStep
17531753
17541754
within MRIStep.

doc/shared/RecentChanges.rst

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,11 @@ method after :c:func:`KINInit`. Additionally, :c:func:`KINSetMAA` and
2121

2222
**Bug Fixes**
2323

24+
Fixed a bug in how MRIStep interacts with an MRIHTol SUNAdaptController object
25+
(the previous version essentially just reverted to a decoupled multirate
26+
controller). Removed the upper limit on `inner_max_tolfac` in
27+
:c:func:`SUNAdaptController_SetParams_MRIHTol`.
28+
2429
The shared library version numbers for the oneMKL dense linear solver and
2530
matrix as well as the PETSc SNES nonlinear solver have been corrected.
2631

@@ -48,6 +53,13 @@ spectral radius data was reset to zero, flags to update the dominant eigenvalue
4853
were reset to true, and a flag indicating if an SSP is being used was reset to
4954
false.
5055

56+
Fixed a bug introduced in v7.3.0 in KINSOL when using Anderson acceleration and
57+
solving a problem multiple times with the same KINSOL instance. In this use
58+
case, the current Anderson acceleration depth from the initial solve was not
59+
reinitialized on subsequent solves.
60+
61+
Fixed a logging bug in KINSOL where logging messages would not be output.
62+
5163
Fixed a bug in the ``suntools.logs`` Python module where the ``get_history``
5264
function, when given a ``step_status`` for filtering output from a multirate
5365
method, would only extract values from the fast time scale if the slow time

doc/shared/sunadaptcontroller/SUNAdaptController_MRIHTol.rst

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,9 +153,14 @@ also provides the following additional user-callable routines:
153153
:param C: the SUNAdaptController_MRIHTol object.
154154
:param inner_max_relch: the parameter :math:`relch_{\text{max}}` (must be :math:`\ge 1`).
155155
:param inner_min_tolfac: the parameter :math:`\text{tolfac}_{min}` (must be :math:`> 0`).
156-
:param inner_max_tolfac: the parameter :math:`\text{tolfac}_{max}` (must be :math:`> 0` and :math:`\le 1`).
156+
:param inner_max_tolfac: the parameter :math:`\text{tolfac}_{max}` (must be :math:`> 0`).
157157

158158
:returns: :c:type:`SUNErrCode` indicating success or failure.
159+
160+
.. versionchanged:: x.y.z
161+
162+
Removed the requirement that ``inner_max_tolfac`` must be :math:`\le 1`
163+
159164

160165
.. note::
161166

src/arkode/arkode_mristep.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3571,6 +3571,11 @@ int mriStep_StageERKFast(ARKodeMem ark_mem, ARKodeMRIStepMem step_mem,
35713571
__FILE__, "Unable to get accumulated error from the inner stepper");
35723572
return (ARK_INNERSTEP_FAIL);
35733573
}
3574+
3575+
/* scale the error estimate by 1/rtol to account for different inner/outer tolerances */
3576+
step_mem->inner_dsm /= ark_mem->reltol;
3577+
SUNLogInfo(ARK_LOGGER, "accumulated-fast-error", "inner_dsm = %e",
3578+
step_mem->inner_dsm);
35743579
}
35753580
}
35763581

src/kinsol/kinsol.c

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,7 @@
149149
#define PRNT_BETA 10
150150
#define PRNT_ALPHABETA 11
151151
#define PRNT_ADJ 12
152+
#define PRNT_OTHER 13
152153

153154
/*=================================================================*/
154155
/* Shortcuts */
@@ -2127,7 +2128,9 @@ void KINPrintInfo(SUNDIALS_MAYBE_UNUSED KINMem kin_mem, int info_code,
21272128
vsnprintf(msg, sizeof msg, msgfmt, ap);
21282129
}
21292130

2130-
SUNLogInfo(KIN_LOGGER, "KINSOL", fname, "%s", msg);
2131+
/* Call QueueMsg directly rather than using the SUNLogInfo macro in order to
2132+
use the passed in function name */
2133+
SUNLogger_QueueMsg(KIN_LOGGER, SUN_LOGLEVEL_INFO, fname, "KINSOL", "%s", msg);
21312134

21322135
/* finalize argument processing */
21332136

@@ -2719,6 +2722,11 @@ static int AndersonAcc(KINMem kin_mem, N_Vector gval, N_Vector fv, N_Vector x,
27192722
kin_mem->kin_current_depth++;
27202723
}
27212724

2725+
#if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGLEVEL_INFO
2726+
KINPrintInfo(kin_mem, PRNT_OTHER, "KINSOL", __func__, "current_depth = %i",
2727+
kin_mem->kin_current_depth);
2728+
#endif
2729+
27222730
N_VScale(ONE, gval, kin_mem->kin_gold_aa);
27232731
N_VScale(ONE, fv, kin_mem->kin_fold_aa);
27242732

@@ -2794,6 +2802,11 @@ static int AndersonAcc(KINMem kin_mem, N_Vector gval, N_Vector fv, N_Vector x,
27942802
new_depth = SUNMIN(new_depth, kin_mem->kin_current_depth);
27952803
new_depth = SUNMAX(new_depth, 0);
27962804

2805+
#if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGLEVEL_INFO
2806+
KINPrintInfo(kin_mem, PRNT_OTHER, "KINSOL", __func__, "new_depth = %i",
2807+
new_depth);
2808+
#endif
2809+
27972810
if (new_depth == 0)
27982811
{
27992812
kin_mem->kin_current_depth = new_depth;

src/kinsol/kinsol_aa.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@ int KINInitAA(KINMem kin_mem)
2727
kin_mem->kin_m_aa = kin_mem->kin_mxiter - 1;
2828
}
2929

30+
// Initialize the current depth
31+
kin_mem->kin_current_depth = 0;
32+
3033
// Do we need to (re)allocate the AA workspace?
3134
sunbooleantype allocate = kin_mem->kin_m_aa > kin_mem->kin_m_aa_alloc;
3235

src/sunadaptcontroller/mrihtol/sunadaptcontroller_mrihtol.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -236,8 +236,7 @@ SUNErrCode SUNAdaptController_SetParams_MRIHTol(SUNAdaptController C,
236236
MRIHTOL_INNER_MIN_TOLFAC(C) = INNER_MIN_TOLFAC;
237237
}
238238
else { MRIHTOL_INNER_MIN_TOLFAC(C) = inner_min_tolfac; }
239-
if ((inner_max_tolfac <= SUN_RCONST(0.0)) ||
240-
(inner_max_tolfac > SUN_RCONST(1.0)))
239+
if (inner_max_tolfac <= SUN_RCONST(0.0))
241240
{
242241
MRIHTOL_INNER_MAX_TOLFAC(C) = INNER_MAX_TOLFAC;
243242
}

test/unit_tests/kinsol/C_serial/CMakeLists.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@
1515
# ---------------------------------------------------------------
1616

1717
# List of test tuples of the form "name\;args"
18-
set(unit_tests "kin_test_getuserdata\;")
18+
set(unit_tests "kin_test_getuserdata\;" "kin_test_reuse_fp\;0"
19+
"kin_test_reuse_fp\;1")
1920

2021
# Add the build and install targets for each test
2122
foreach(test_tuple ${unit_tests})

0 commit comments

Comments
 (0)