From 94951259c28d8ce9ff06dde7d472a7cf7f817102 Mon Sep 17 00:00:00 2001 From: "David J. Gardner" Date: Wed, 18 Dec 2024 17:48:56 -0800 Subject: [PATCH 1/4] fix RHS eval logic and unit test --- src/arkode/arkode_arkstep.c | 9 +++------ .../arkode/CXX_serial/ark_test_dahlquist_ark.cpp | 7 ------- 2 files changed, 3 insertions(+), 13 deletions(-) diff --git a/src/arkode/arkode_arkstep.c b/src/arkode/arkode_arkstep.c index 0e8bc1ee3a..ab96a02ae2 100644 --- a/src/arkode/arkode_arkstep.c +++ b/src/arkode/arkode_arkstep.c @@ -1751,11 +1751,8 @@ int arkStep_TakeStep_Z(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr) } } - /* For a stiffly accurate implicit or ImEx method with an implicit first - stage, save f(tn, yn) if using Hermite interpolation as Fi[0] will be - overwritten during the implicit solve */ - save_fn_for_interp = implicit_stage && stiffly_accurate && - ark_mem->interp_type == ARK_INTERP_HERMITE; + /* Save f(tn, yn) for Hermite interpolation */ + save_fn_for_interp = ark_mem->interp_type == ARK_INTERP_HERMITE; /* For an implicit or ImEx method using the trivial predictor with an autonomous problem with an identity or fixed mass matrix, save fi(tn, yn) @@ -1778,7 +1775,7 @@ int arkStep_TakeStep_Z(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr) /* If saving the RHS evaluation for reuse in the residual, call the full RHS for all implicit methods or for ImEx methods with an explicit first stage. ImEx methods with an implicit first stage may not need to evaluate - fe depending on the interpolation type. */ + fe depending on the interpolation type (covered by save_fn_for_interp) */ sunbooleantype res_full_rhs = save_fn_for_residual && implicit_stage && !imex_method; diff --git a/test/unit_tests/arkode/CXX_serial/ark_test_dahlquist_ark.cpp b/test/unit_tests/arkode/CXX_serial/ark_test_dahlquist_ark.cpp index 0a0fe13fe5..cf9c04feb8 100644 --- a/test/unit_tests/arkode/CXX_serial/ark_test_dahlquist_ark.cpp +++ b/test/unit_tests/arkode/CXX_serial/ark_test_dahlquist_ark.cpp @@ -803,13 +803,6 @@ int expected_rhs_evals(ProblemOptions& prob_opts, int stages, int order, nfe_expected += nst; } } - - if (prob_opts.i_type != interp_type::hermite && save_fn_for_residual && - !explicit_first_stage) - { - if (stiffly_accurate) { nfe_expected++; } - else { nfe_expected += nst; } - } } // Expected number of implicit functions evaluations From ce3ca5153f7cbc48bc14ae07050730eecead4d15 Mon Sep 17 00:00:00 2001 From: "David J. Gardner" Date: Wed, 18 Dec 2024 18:10:34 -0800 Subject: [PATCH 2/4] update recent changes --- CHANGELOG.md | 5 +++++ doc/shared/RecentChanges.rst | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index c1d6714461..c50bb6917b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,11 @@ ### Bug Fixes +Fixed a bug in ARKStep where an extra right-hand side evaluation would occur +each time step when enabling the :c:func:`ARKodeSetAutonomous` option and using +an IMEX method where the DIRK table has an implicit first and is not stiffly +accurate. + ### Deprecation Notices ## Changes to SUNDIALS in release 7.2.0 diff --git a/doc/shared/RecentChanges.rst b/doc/shared/RecentChanges.rst index 4f1514700e..a9edb9a2c8 100644 --- a/doc/shared/RecentChanges.rst +++ b/doc/shared/RecentChanges.rst @@ -4,4 +4,9 @@ **Bug Fixes** +Fixed a bug in ARKStep where an extra right-hand side evaluation would occur +each time step when enabling the ``ARKodeSetAutonomous`` option and using an +IMEX method where the DIRK table has an implicit first and is not stiffly +accurate. + **Deprecation Notices** From 7ba2c58e221dea2f66cd8027ad8bf7d9dfec845b Mon Sep 17 00:00:00 2001 From: "David J. Gardner" Date: Wed, 18 Dec 2024 18:11:24 -0800 Subject: [PATCH 3/4] fix rst vs md formatting --- CHANGELOG.md | 4 ++-- doc/shared/RecentChanges.rst | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c50bb6917b..ca61ec36fe 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,8 +9,8 @@ ### Bug Fixes Fixed a bug in ARKStep where an extra right-hand side evaluation would occur -each time step when enabling the :c:func:`ARKodeSetAutonomous` option and using -an IMEX method where the DIRK table has an implicit first and is not stiffly +each time step when enabling the ``ARKodeSetAutonomous`` option and using an +IMEX method where the DIRK table has an implicit first and is not stiffly accurate. ### Deprecation Notices diff --git a/doc/shared/RecentChanges.rst b/doc/shared/RecentChanges.rst index a9edb9a2c8..20325fc582 100644 --- a/doc/shared/RecentChanges.rst +++ b/doc/shared/RecentChanges.rst @@ -5,8 +5,8 @@ **Bug Fixes** Fixed a bug in ARKStep where an extra right-hand side evaluation would occur -each time step when enabling the ``ARKodeSetAutonomous`` option and using an -IMEX method where the DIRK table has an implicit first and is not stiffly +each time step when enabling the :c:func:`ARKodeSetAutonomous` option and using +an IMEX method where the DIRK table has an implicit first and is not stiffly accurate. **Deprecation Notices** From 11ed8638eddb8b1e3cc6181ca206c1c74859ea78 Mon Sep 17 00:00:00 2001 From: David Gardner Date: Wed, 18 Dec 2024 19:55:40 -0800 Subject: [PATCH 4/4] Apply suggestions from code review Fix typos in recent changes Co-authored-by: Daniel R. Reynolds --- CHANGELOG.md | 2 +- doc/shared/RecentChanges.rst | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ca61ec36fe..3049979e70 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,7 +10,7 @@ Fixed a bug in ARKStep where an extra right-hand side evaluation would occur each time step when enabling the ``ARKodeSetAutonomous`` option and using an -IMEX method where the DIRK table has an implicit first and is not stiffly +IMEX method where the DIRK table has an implicit first stage and is not stiffly accurate. ### Deprecation Notices diff --git a/doc/shared/RecentChanges.rst b/doc/shared/RecentChanges.rst index 20325fc582..671c0051ac 100644 --- a/doc/shared/RecentChanges.rst +++ b/doc/shared/RecentChanges.rst @@ -6,7 +6,7 @@ Fixed a bug in ARKStep where an extra right-hand side evaluation would occur each time step when enabling the :c:func:`ARKodeSetAutonomous` option and using -an IMEX method where the DIRK table has an implicit first and is not stiffly +an IMEX method where the DIRK table has an implicit first stage and is not stiffly accurate. **Deprecation Notices**