From 9951d88d44f01408c8234bf873c650bd125fad8c Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Wed, 24 Jul 2024 16:34:45 -0500 Subject: [PATCH 001/286] Initial merge with rebased 'develop' branch -- I'm still ironing out some issues --- CHANGELOG.md | 9 + doc/arkode/guide/source/Constants.rst | 21 +- doc/arkode/guide/source/Mathematics.rst | 4 +- .../Custom_Inner_Stepper/Description.rst | 283 +- .../MRIStep/Custom_Inner_Stepper/index.rst | 16 +- .../source/Usage/MRIStep/MRIStepCoupling.rst | 177 +- .../source/Usage/MRIStep/User_callable.rst | 2328 ++++++++--------- .../guide/source/Usage/User_callable.rst | 86 +- doc/shared/RecentChanges.rst | 9 + examples/arkode/C_serial/CMakeLists.txt | 29 +- examples/arkode/C_serial/ark_kpr_mri.c | 602 +++-- examples/arkode/C_serial/ark_kpr_mri.out | 69 - .../arkode/C_serial/ark_kpr_mri_0_0.002.out | 69 - ..._2_0.005.out => ark_kpr_mri_0_1_0.005.out} | 6 +- ...ark_kpr_mri_10_4_0.001_-100_100_0.5_1.out} | 5 +- .../C_serial/ark_kpr_mri_11_2_0.001.out | 73 + .../C_serial/ark_kpr_mri_12_3_0.005.out | 73 + .../arkode/C_serial/ark_kpr_mri_13_4_0.01.out | 73 + .../arkode/C_serial/ark_kpr_mri_1_0.002.out | 69 - ...ri_3_0.01.out => ark_kpr_mri_1_0_0.01.out} | 3 +- .../arkode/C_serial/ark_kpr_mri_1_1_0.002.out | 73 + ..._5_0.002.out => ark_kpr_mri_2_4_0.002.out} | 4 +- .../arkode/C_serial/ark_kpr_mri_3_2_0.001.out | 69 + .../arkode/C_serial/ark_kpr_mri_4_0.002.out | 72 - .../arkode/C_serial/ark_kpr_mri_4_3_0.001.out | 69 + .../arkode/C_serial/ark_kpr_mri_5_4_0.001.out | 69 + .../arkode/C_serial/ark_kpr_mri_6_0.005.out | 69 - .../arkode/C_serial/ark_kpr_mri_6_5_0.001.out | 69 + .../arkode/C_serial/ark_kpr_mri_7_0.001.out | 72 - .../arkode/C_serial/ark_kpr_mri_7_2_0.002.out | 73 + .../arkode/C_serial/ark_kpr_mri_8_0.001.out | 72 - ... ark_kpr_mri_8_3_0.001_-100_100_0.5_1.out} | 5 +- .../arkode/C_serial/ark_kpr_mri_9_0.001.out | 72 - ... ark_kpr_mri_9_3_0.001_-100_100_0.5_1.out} | 5 +- include/arkode/arkode.h | 5 + include/arkode/arkode_arkstep.h | 2 +- include/arkode/arkode_erkstep.h | 4 + include/arkode/arkode_mristep.h | 64 +- .../sunadaptcontroller_mricc.h | 72 + .../sunadaptcontroller_mrihtol.h | 88 + .../sunadaptcontroller_mrill.h | 86 + .../sunadaptcontroller_mripi.h | 83 + .../sunadaptcontroller_mripid.h | 89 + include/sundials/sundials_adaptcontroller.h | 72 +- src/arkode/CMakeLists.txt | 6 + src/arkode/arkode.c | 196 +- src/arkode/arkode_arkstep.c | 156 +- src/arkode/arkode_arkstep_impl.h | 5 + src/arkode/arkode_arkstep_io.c | 5 +- src/arkode/arkode_arkstep_nls.c | 2 +- src/arkode/arkode_erkstep.c | 463 +++- src/arkode/arkode_erkstep_impl.h | 27 + src/arkode/arkode_erkstep_io.c | 5 +- src/arkode/arkode_impl.h | 28 +- src/arkode/arkode_io.c | 107 + src/arkode/arkode_mri_tables.c | 354 ++- src/arkode/arkode_mri_tables.def | 569 +++- src/arkode/arkode_mristep.c | 2153 +++++++++++++-- src/arkode/arkode_mristep_controller.c | 197 ++ src/arkode/arkode_mristep_impl.h | 115 +- src/arkode/arkode_mristep_io.c | 91 + src/arkode/arkode_mristep_nls.c | 2 +- src/arkode/arkode_relaxation.c | 2 +- src/arkode/fmod_int32/farkode_erkstep_mod.c | 14 + src/arkode/fmod_int32/farkode_erkstep_mod.f90 | 26 + src/arkode/fmod_int32/farkode_mod.c | 40 + src/arkode/fmod_int32/farkode_mod.f90 | 74 + src/arkode/fmod_int32/farkode_mristep_mod.c | 156 ++ src/arkode/fmod_int32/farkode_mristep_mod.f90 | 311 ++- src/arkode/fmod_int64/farkode_erkstep_mod.c | 14 + src/arkode/fmod_int64/farkode_erkstep_mod.f90 | 26 + src/arkode/fmod_int64/farkode_mod.c | 40 + src/arkode/fmod_int64/farkode_mod.f90 | 74 + src/arkode/fmod_int64/farkode_mristep_mod.c | 156 ++ src/arkode/fmod_int64/farkode_mristep_mod.f90 | 311 ++- src/sunadaptcontroller/CMakeLists.txt | 9 +- src/sunadaptcontroller/mricc/CMakeLists.txt | 28 + .../mricc/fmod_int32/CMakeLists.txt | 26 + .../fsunadaptcontroller_mricc_mod.c | 335 +++ .../fsunadaptcontroller_mricc_mod.f90 | 269 ++ .../mricc/fmod_int64/CMakeLists.txt | 26 + .../fsunadaptcontroller_mricc_mod.c | 335 +++ .../fsunadaptcontroller_mricc_mod.f90 | 269 ++ .../mricc/sunadaptcontroller_mricc.c | 189 ++ src/sunadaptcontroller/mrihtol/CMakeLists.txt | 28 + .../mrihtol/fmod_int32/CMakeLists.txt | 26 + .../fsunadaptcontroller_mrihtol_mod.c | 395 +++ .../fsunadaptcontroller_mrihtol_mod.f90 | 381 +++ .../mrihtol/fmod_int64/CMakeLists.txt | 26 + .../fsunadaptcontroller_mrihtol_mod.c | 395 +++ .../fsunadaptcontroller_mrihtol_mod.f90 | 381 +++ .../mrihtol/sunadaptcontroller_mrihtol.c | 251 ++ src/sunadaptcontroller/mrill/CMakeLists.txt | 28 + .../mrill/fmod_int32/CMakeLists.txt | 26 + .../fsunadaptcontroller_mrill_mod.c | 371 +++ .../fsunadaptcontroller_mrill_mod.f90 | 337 +++ .../mrill/fmod_int64/CMakeLists.txt | 26 + .../fsunadaptcontroller_mrill_mod.c | 371 +++ .../fsunadaptcontroller_mrill_mod.f90 | 337 +++ .../mrill/sunadaptcontroller_mrill.c | 265 ++ src/sunadaptcontroller/mripi/CMakeLists.txt | 28 + .../mripi/fmod_int32/CMakeLists.txt | 26 + .../fsunadaptcontroller_mripi_mod.c | 371 +++ .../fsunadaptcontroller_mripi_mod.f90 | 337 +++ .../mripi/fmod_int64/CMakeLists.txt | 26 + .../fsunadaptcontroller_mripi_mod.c | 371 +++ .../fsunadaptcontroller_mripi_mod.f90 | 337 +++ .../mripi/sunadaptcontroller_mripi.c | 237 ++ src/sunadaptcontroller/mripid/CMakeLists.txt | 28 + .../mripid/fmod_int32/CMakeLists.txt | 26 + .../fsunadaptcontroller_mripid_mod.c | 375 +++ .../fsunadaptcontroller_mripid_mod.f90 | 345 +++ .../mripid/fmod_int64/CMakeLists.txt | 26 + .../fsunadaptcontroller_mripid_mod.c | 375 +++ .../fsunadaptcontroller_mripid_mod.f90 | 345 +++ .../mripid/sunadaptcontroller_mripid.c | 268 ++ src/sundials/fmod_int32/fsundials_core_mod.c | 92 + .../fmod_int32/fsundials_core_mod.f90 | 184 +- src/sundials/fmod_int64/fsundials_core_mod.c | 92 + .../fmod_int64/fsundials_core_mod.f90 | 184 +- src/sundials/sundials_adaptcontroller.c | 87 +- .../fsunadaptcontroller_mricc_mod.i | 29 + .../fsunadaptcontroller_mrihtol_mod.i | 29 + .../fsunadaptcontroller_mrill_mod.i | 29 + .../fsunadaptcontroller_mripi_mod.i | 29 + .../fsunadaptcontroller_mripid_mod.i | 29 + .../arkode/CXX_serial/CMakeLists.txt | 21 +- .../ark_test_accumerror_brusselator.cpp | 706 +++++ ...rk_test_accumerror_brusselator_20_-4_0.out | 249 ++ ...ark_test_accumerror_brusselator_20_3_1.out | 129 + ...ark_test_accumerror_brusselator_20_5_0.out | 129 + .../CXX_serial/ark_test_accumerror_kpr.cpp | 721 +++++ .../ark_test_accumerror_kpr_20_-4_1.out | 250 ++ .../ark_test_accumerror_kpr_20_2_0.out | 130 + .../ark_test_accumerror_kpr_20_3_1.out | 130 + .../ark_test_brusselator_mriadapt.cpp | 1463 +++++++++++ ..._mriadapt_--rtol_0.000004_--scontrol_0.out | 43 + .../CXX_serial/ark_test_dahlquist_mri.cpp | 29 +- .../CXX_serial/ark_test_dahlquist_mri_-1.out | 364 ++- .../CXX_serial/ark_test_dahlquist_mri_0.out | 364 ++- .../CXX_serial/ark_test_dahlquist_mri_1.out | 364 ++- .../CXX_serial/ark_test_kpr_mriadapt.cpp | 1478 +++++++++++ ...-hs_0.002_--rtol_0.000004_--scontrol_0.out | 45 + .../ark_test_slowerror_brusselator.cpp | 611 +++++ .../ark_test_slowerror_brusselator.out | 114 + .../CXX_serial/ark_test_slowerror_kpr.cpp | 564 ++++ .../CXX_serial/ark_test_slowerror_kpr.out | 113 + .../ark_test_slowerror_polynomial.cpp | 410 +++ .../ark_test_slowerror_polynomial.out | 9 + .../C_serial/ark_test_erkstepsetforcing.c | 386 +++ .../arkode/C_serial/ark_test_reset.c | 26 +- test/unit_tests/utilities/test_utilities.hpp | 108 + 152 files changed, 26510 insertions(+), 2968 deletions(-) delete mode 100644 examples/arkode/C_serial/ark_kpr_mri.out delete mode 100644 examples/arkode/C_serial/ark_kpr_mri_0_0.002.out rename examples/arkode/C_serial/{ark_kpr_mri_2_0.005.out => ark_kpr_mri_0_1_0.005.out} (97%) rename examples/arkode/C_serial/{ark_kpr_mri_9_0.001_-100_100_0.5_1.out => ark_kpr_mri_10_4_0.001_-100_100_0.5_1.out} (96%) create mode 100644 examples/arkode/C_serial/ark_kpr_mri_11_2_0.001.out create mode 100644 examples/arkode/C_serial/ark_kpr_mri_12_3_0.005.out create mode 100644 examples/arkode/C_serial/ark_kpr_mri_13_4_0.01.out delete mode 100644 examples/arkode/C_serial/ark_kpr_mri_1_0.002.out rename examples/arkode/C_serial/{ark_kpr_mri_3_0.01.out => ark_kpr_mri_1_0_0.01.out} (98%) create mode 100644 examples/arkode/C_serial/ark_kpr_mri_1_1_0.002.out rename examples/arkode/C_serial/{ark_kpr_mri_5_0.002.out => ark_kpr_mri_2_4_0.002.out} (98%) create mode 100644 examples/arkode/C_serial/ark_kpr_mri_3_2_0.001.out delete mode 100644 examples/arkode/C_serial/ark_kpr_mri_4_0.002.out create mode 100644 examples/arkode/C_serial/ark_kpr_mri_4_3_0.001.out create mode 100644 examples/arkode/C_serial/ark_kpr_mri_5_4_0.001.out delete mode 100644 examples/arkode/C_serial/ark_kpr_mri_6_0.005.out create mode 100644 examples/arkode/C_serial/ark_kpr_mri_6_5_0.001.out delete mode 100644 examples/arkode/C_serial/ark_kpr_mri_7_0.001.out create mode 100644 examples/arkode/C_serial/ark_kpr_mri_7_2_0.002.out delete mode 100644 examples/arkode/C_serial/ark_kpr_mri_8_0.001.out rename examples/arkode/C_serial/{ark_kpr_mri_7_0.001_-100_100_0.5_1.out => ark_kpr_mri_8_3_0.001_-100_100_0.5_1.out} (96%) delete mode 100644 examples/arkode/C_serial/ark_kpr_mri_9_0.001.out rename examples/arkode/C_serial/{ark_kpr_mri_8_0.001_-100_100_0.5_1.out => ark_kpr_mri_9_3_0.001_-100_100_0.5_1.out} (96%) create mode 100644 include/sunadaptcontroller/sunadaptcontroller_mricc.h create mode 100644 include/sunadaptcontroller/sunadaptcontroller_mrihtol.h create mode 100644 include/sunadaptcontroller/sunadaptcontroller_mrill.h create mode 100644 include/sunadaptcontroller/sunadaptcontroller_mripi.h create mode 100644 include/sunadaptcontroller/sunadaptcontroller_mripid.h create mode 100644 src/arkode/arkode_mristep_controller.c create mode 100644 src/sunadaptcontroller/mricc/CMakeLists.txt create mode 100644 src/sunadaptcontroller/mricc/fmod_int32/CMakeLists.txt create mode 100644 src/sunadaptcontroller/mricc/fmod_int32/fsunadaptcontroller_mricc_mod.c create mode 100644 src/sunadaptcontroller/mricc/fmod_int32/fsunadaptcontroller_mricc_mod.f90 create mode 100644 src/sunadaptcontroller/mricc/fmod_int64/CMakeLists.txt create mode 100644 src/sunadaptcontroller/mricc/fmod_int64/fsunadaptcontroller_mricc_mod.c create mode 100644 src/sunadaptcontroller/mricc/fmod_int64/fsunadaptcontroller_mricc_mod.f90 create mode 100644 src/sunadaptcontroller/mricc/sunadaptcontroller_mricc.c create mode 100644 src/sunadaptcontroller/mrihtol/CMakeLists.txt create mode 100644 src/sunadaptcontroller/mrihtol/fmod_int32/CMakeLists.txt create mode 100644 src/sunadaptcontroller/mrihtol/fmod_int32/fsunadaptcontroller_mrihtol_mod.c create mode 100644 src/sunadaptcontroller/mrihtol/fmod_int32/fsunadaptcontroller_mrihtol_mod.f90 create mode 100644 src/sunadaptcontroller/mrihtol/fmod_int64/CMakeLists.txt create mode 100644 src/sunadaptcontroller/mrihtol/fmod_int64/fsunadaptcontroller_mrihtol_mod.c create mode 100644 src/sunadaptcontroller/mrihtol/fmod_int64/fsunadaptcontroller_mrihtol_mod.f90 create mode 100644 src/sunadaptcontroller/mrihtol/sunadaptcontroller_mrihtol.c create mode 100644 src/sunadaptcontroller/mrill/CMakeLists.txt create mode 100644 src/sunadaptcontroller/mrill/fmod_int32/CMakeLists.txt create mode 100644 src/sunadaptcontroller/mrill/fmod_int32/fsunadaptcontroller_mrill_mod.c create mode 100644 src/sunadaptcontroller/mrill/fmod_int32/fsunadaptcontroller_mrill_mod.f90 create mode 100644 src/sunadaptcontroller/mrill/fmod_int64/CMakeLists.txt create mode 100644 src/sunadaptcontroller/mrill/fmod_int64/fsunadaptcontroller_mrill_mod.c create mode 100644 src/sunadaptcontroller/mrill/fmod_int64/fsunadaptcontroller_mrill_mod.f90 create mode 100644 src/sunadaptcontroller/mrill/sunadaptcontroller_mrill.c create mode 100644 src/sunadaptcontroller/mripi/CMakeLists.txt create mode 100644 src/sunadaptcontroller/mripi/fmod_int32/CMakeLists.txt create mode 100644 src/sunadaptcontroller/mripi/fmod_int32/fsunadaptcontroller_mripi_mod.c create mode 100644 src/sunadaptcontroller/mripi/fmod_int32/fsunadaptcontroller_mripi_mod.f90 create mode 100644 src/sunadaptcontroller/mripi/fmod_int64/CMakeLists.txt create mode 100644 src/sunadaptcontroller/mripi/fmod_int64/fsunadaptcontroller_mripi_mod.c create mode 100644 src/sunadaptcontroller/mripi/fmod_int64/fsunadaptcontroller_mripi_mod.f90 create mode 100644 src/sunadaptcontroller/mripi/sunadaptcontroller_mripi.c create mode 100644 src/sunadaptcontroller/mripid/CMakeLists.txt create mode 100644 src/sunadaptcontroller/mripid/fmod_int32/CMakeLists.txt create mode 100644 src/sunadaptcontroller/mripid/fmod_int32/fsunadaptcontroller_mripid_mod.c create mode 100644 src/sunadaptcontroller/mripid/fmod_int32/fsunadaptcontroller_mripid_mod.f90 create mode 100644 src/sunadaptcontroller/mripid/fmod_int64/CMakeLists.txt create mode 100644 src/sunadaptcontroller/mripid/fmod_int64/fsunadaptcontroller_mripid_mod.c create mode 100644 src/sunadaptcontroller/mripid/fmod_int64/fsunadaptcontroller_mripid_mod.f90 create mode 100644 src/sunadaptcontroller/mripid/sunadaptcontroller_mripid.c create mode 100644 swig/sunadaptcontroller/fsunadaptcontroller_mricc_mod.i create mode 100644 swig/sunadaptcontroller/fsunadaptcontroller_mrihtol_mod.i create mode 100644 swig/sunadaptcontroller/fsunadaptcontroller_mrill_mod.i create mode 100644 swig/sunadaptcontroller/fsunadaptcontroller_mripi_mod.i create mode 100644 swig/sunadaptcontroller/fsunadaptcontroller_mripid_mod.i create mode 100644 test/unit_tests/arkode/CXX_serial/ark_test_accumerror_brusselator.cpp create mode 100644 test/unit_tests/arkode/CXX_serial/ark_test_accumerror_brusselator_20_-4_0.out create mode 100644 test/unit_tests/arkode/CXX_serial/ark_test_accumerror_brusselator_20_3_1.out create mode 100644 test/unit_tests/arkode/CXX_serial/ark_test_accumerror_brusselator_20_5_0.out create mode 100644 test/unit_tests/arkode/CXX_serial/ark_test_accumerror_kpr.cpp create mode 100644 test/unit_tests/arkode/CXX_serial/ark_test_accumerror_kpr_20_-4_1.out create mode 100644 test/unit_tests/arkode/CXX_serial/ark_test_accumerror_kpr_20_2_0.out create mode 100644 test/unit_tests/arkode/CXX_serial/ark_test_accumerror_kpr_20_3_1.out create mode 100644 test/unit_tests/arkode/CXX_serial/ark_test_brusselator_mriadapt.cpp create mode 100644 test/unit_tests/arkode/CXX_serial/ark_test_brusselator_mriadapt_--rtol_0.000004_--scontrol_0.out create mode 100644 test/unit_tests/arkode/CXX_serial/ark_test_kpr_mriadapt.cpp create mode 100644 test/unit_tests/arkode/CXX_serial/ark_test_kpr_mriadapt_--hs_0.002_--rtol_0.000004_--scontrol_0.out create mode 100644 test/unit_tests/arkode/CXX_serial/ark_test_slowerror_brusselator.cpp create mode 100644 test/unit_tests/arkode/CXX_serial/ark_test_slowerror_brusselator.out create mode 100644 test/unit_tests/arkode/CXX_serial/ark_test_slowerror_kpr.cpp create mode 100644 test/unit_tests/arkode/CXX_serial/ark_test_slowerror_kpr.out create mode 100644 test/unit_tests/arkode/CXX_serial/ark_test_slowerror_polynomial.cpp create mode 100644 test/unit_tests/arkode/CXX_serial/ark_test_slowerror_polynomial.out create mode 100644 test/unit_tests/arkode/C_serial/ark_test_erkstepsetforcing.c create mode 100644 test/unit_tests/utilities/test_utilities.hpp diff --git a/CHANGELOG.md b/CHANGELOG.md index c77cdcbdfb..47e9f31db6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,15 @@ ### New Features and Enhancements +Added Multirate time step adaptivity controllers, based on the recently introduced +`SUNAdaptController` base class, to ARKODE's MRIStep module. + +Added functionality to ARKStep and ERKStep to accumulate a temporal error +estimate over multiple time steps. See the routines `ARKStepSetAccumulatedErrorType`, +`ARKStepResetAccumulatedError`, `ARKStepGetAccumulatedError`, +`ERKStepSetAccumulatedErrorType`, `ERKStepResetAccumulatedError`, +and `ERKStepGetAccumulatedError` for details. + ### Bug Fixes Fixed the loading of ARKStep's default first order explicit method. diff --git a/doc/arkode/guide/source/Constants.rst b/doc/arkode/guide/source/Constants.rst index 22363ef243..99f76ddcec 100644 --- a/doc/arkode/guide/source/Constants.rst +++ b/doc/arkode/guide/source/Constants.rst @@ -337,7 +337,7 @@ contains the ARKODE output constants. +-----------------------------------------------+------------------------------------------------------------+ | :index:`ARKODE_MRI_GARK_RALSTON2` | Use the second order Ralston MRI-GARK method. | +-----------------------------------------------+------------------------------------------------------------+ - | :index:`ARKODE_MIS_MW3` | Use the Knoth-Wolke-3 MIS method. | + | :index:`ARKODE_MIS_KW3` | Use the Knoth-Wolke-3 MIS method (non-embedded). | +-----------------------------------------------+------------------------------------------------------------+ | :index:`ARKODE_MRI_GARK_ERK33a` | Use the ERK33a MRI-GARK method. | +-----------------------------------------------+------------------------------------------------------------+ @@ -361,11 +361,11 @@ contains the ARKODE output constants. +-----------------------------------------------+------------------------------------------------------------+ | :index:`ARKODE_IMEX_MRI_GARK_MIDPOINT` | Use the midpoint rule IMEX-MRI-GARK method. | +-----------------------------------------------+------------------------------------------------------------+ - | :index:`ARKODE_IMEX_MRI_GARK3a` | Use the IMEX-MRI-GARK3a method. | + | :index:`ARKODE_IMEX_MRI_GARK3a` | Use the IMEX-MRI-GARK3a method (non-embedded). | +-----------------------------------------------+------------------------------------------------------------+ - | :index:`ARKODE_IMEX_MRI_GARK3b` | Use the IMEX-MRI-GARK3b method. | + | :index:`ARKODE_IMEX_MRI_GARK3b` | Use the IMEX-MRI-GARK3b method (non-embedded). | +-----------------------------------------------+------------------------------------------------------------+ - | :index:`ARKODE_IMEX_MRI_GARK4` | Use the IMEX-MRI-GARK4 method. | + | :index:`ARKODE_IMEX_MRI_GARK4` | Use the IMEX-MRI-GARK4 method (non-embedded). | +-----------------------------------------------+------------------------------------------------------------+ | :index:`MRISTEP_DEFAULT_EXPL_TABLE_1` | Use MRIStep's default 1st-order explicit method | | | (MRI_GARK_FORWARD_EULER). | @@ -374,7 +374,10 @@ contains the ARKODE output constants. | | (MRI_GARK_ERK22b). | +-----------------------------------------------+------------------------------------------------------------+ | :index:`MRISTEP_DEFAULT_EXPL_TABLE_3` | Use MRIStep's default 3rd-order explicit method | - | | (MIS_MW3). | + | | (ARKODE_MIS_KW3). | + +-----------------------------------------------+------------------------------------------------------------+ + | :index:`MRISTEP_DEFAULT_EXPL_TABLE_3_AD` | Use MRIStep's default 3rd-order adaptive explicit method | + | | (ARKODE_MRI_GARK_ERK33a). | +-----------------------------------------------+------------------------------------------------------------+ | :index:`MRISTEP_DEFAULT_EXPL_TABLE_4` | Use MRIStep's default 4th-order explicit method | | | (MRI_GARK_ERK45a). | @@ -383,10 +386,10 @@ contains the ARKODE output constants. | | method (MRI_GARK_BACKWARD_EULER). | +-----------------------------------------------+------------------------------------------------------------+ | :index:`MRISTEP_DEFAULT_IMPL_SD_TABLE_2` | Use MRIStep's default 2nd-order solve-decoupled implicit | - | | method (MRI_GARK_IRK21a). | + | | method (ARKODE_MRI_GARK_IRK21a). | +-----------------------------------------------+------------------------------------------------------------+ | :index:`MRISTEP_DEFAULT_IMPL_SD_TABLE_3` | Use MRIStep's default 3rd-order solve-decoupled implicit | - | | method (MRI_GARK_ESDIRK34a). | + | | method (ARKODE_MRI_GARK_ESDIRK34a). | +-----------------------------------------------+------------------------------------------------------------+ | :index:`MRISTEP_DEFAULT_IMPL_SD_TABLE_4` | Use MRIStep's default 4th-order solve-decoupled implicit | | | method (MRI_GARK_ESDIRK46a). | @@ -398,10 +401,10 @@ contains the ARKODE output constants. | | method (ARKODE_IMEX_MRI_GARK_TRAPEZOIDAL). | +-----------------------------------------------+------------------------------------------------------------+ | :index:`MRISTEP_DEFAULT_IMEX_SD_TABLE_3` | Use MRIStep's default 3rd-order solve-decoupled ImEx | - | | method (IMEX_MRI_GARK3b). | + | | method (ARKODE_IMEX_MRI_GARK3b). | +-----------------------------------------------+------------------------------------------------------------+ | :index:`MRISTEP_DEFAULT_IMEX_SD_TABLE_4` | Use MRIStep's default 4th-order solve-decoupled ImEx | - | | method (IMEX_MRI_GARK4). | + | | method (ARKODE_IMEX_MRI_GARK4). | +-----------------------------------------------+------------------------------------------------------------+ diff --git a/doc/arkode/guide/source/Mathematics.rst b/doc/arkode/guide/source/Mathematics.rst index 9d9835c53d..076c311bb4 100644 --- a/doc/arkode/guide/source/Mathematics.rst +++ b/doc/arkode/guide/source/Mathematics.rst @@ -991,10 +991,10 @@ Here the explicit stability step factor :math:`c>0` (often called the Fixed time stepping =================== -While both the ARKStep and ERKStep time-stepping modules are +While the ARKStep, ERKStep and MRIStep time-stepping modules are designed for tolerance-based time step adaptivity, they additionally support a "fixed-step" mode. This mode is typically used for debugging -purposes, for verification against hand-coded Runge--Kutta methods, or for +purposes, for verification against hand-coded methods, or for problems where the time steps should be chosen based on other problem-specific information. In this mode, all internal time step adaptivity is disabled: diff --git a/doc/arkode/guide/source/Usage/MRIStep/Custom_Inner_Stepper/Description.rst b/doc/arkode/guide/source/Usage/MRIStep/Custom_Inner_Stepper/Description.rst index 523bd8a7be..ec100d56c2 100644 --- a/doc/arkode/guide/source/Usage/MRIStep/Custom_Inner_Stepper/Description.rst +++ b/doc/arkode/guide/source/Usage/MRIStep/Custom_Inner_Stepper/Description.rst @@ -19,17 +19,20 @@ The MRIStepInnerStepper Class As with other SUNDIALS classes, the :c:type:`MRIStepInnerStepper` abstract base class is implemented using a C structure containing a ``content`` pointer to the -derived class member data and a structure of function pointers the derived class -implementations of the virtual methods. +derived class member data and a structure of function pointers wherein the +derived class implements the base class virtual methods. +The :c:type:`MRIStepInnerStepper` type is defined in ``include/arkode/arkode.h`` as .. c:type:: MRIStepInnerStepper An object for solving the fast (inner) ODE in an MRI method. - The actual definition of the ``MRIStepInnerStepper`` structure is kept - private to allow for the object internals to change without impacting user - code. The following sections describe the base class methods and the virtual - methods that a must be provided by a derived class. +The actual definitions of the ``_MRIStepInnerStepper`` structure and the +corresponding operations structure are kept private to allow for the object +internals to change without impacting user code. The following sections describe +the base (:numref:`ARKODE.Usage.MRIStep.CustomInnerStepper.Description.BaseMethods`) +and virtual methods (:numref:`ARKODE.Usage.MRIStep.CustomInnerStepper.Description.ImplMethods`) +that a must be provided by a derived class. .. _ARKODE.Usage.MRIStep.CustomInnerStepper.Description.BaseMethods: @@ -53,13 +56,11 @@ Creating and Destroying an Object This function creates an :c:type:`MRIStepInnerStepper` object to which a user should attach the member data (content) pointer and method function pointers. - **Arguments:** - * ``sunctx`` -- the SUNDIALS simulation context. - * ``stepper`` -- a pointer to an inner stepper object. + :param sunctx: the SUNDIALS simulation context. + :param stepper: a pointer to an inner stepper object. - **Return value:** - * ARK_SUCCESS if successful - * ARK_MEM_FAIL if a memory allocation error occurs + :retval ARK_SUCCESS: if successful + :retval ARK_MEM_FAIL: if a memory allocation error occurs **Example usage:** @@ -83,11 +84,9 @@ Creating and Destroying an Object This function destroys an :c:type:`MRIStepInnerStepper` object. - **Arguments:** - * *stepper* -- a pointer to an inner stepper object. + :param stepper: a pointer to an inner stepper object. - **Return value:** - * ARK_SUCCESS if successful + :retval ARK_SUCCESS: if successful **Example usage:** @@ -115,13 +114,11 @@ Attaching and Accessing the Content Pointer This function attaches a member data (content) pointer to an :c:type:`MRIStepInnerStepper` object. - **Arguments:** - * *stepper* -- an inner stepper object. - * *content* -- a pointer to the stepper member data. + :param stepper: an inner stepper object. + :param content: a pointer to the stepper member data. - **Return value:** - * ARK_SUCCESS if successful - * ARK_ILL_INPUT if the stepper is ``NULL`` + :retval ARK_SUCCESS: if successful + :retval ARK_ILL_INPUT: if the stepper is ``NULL`` **Example usage:** @@ -140,13 +137,11 @@ Attaching and Accessing the Content Pointer This function retrieves the member data (content) pointer from an :c:type:`MRIStepInnerStepper` object. - **Arguments:** - * *stepper* -- an inner stepper object. - * *content* -- a pointer to set to the stepper member data pointer. + :param stepper: an inner stepper object. + :param content: a pointer to set to the stepper member data pointer. - **Return value:** - * ARK_SUCCESS if successful - * ARK_ILL_INPUT if the stepper is ``NULL`` + :retval ARK_SUCCESS: if successful + :retval ARK_ILL_INPUT: if the stepper is ``NULL`` **Example usage:** @@ -173,13 +168,11 @@ Setting Member Functions This function attaches an :c:type:`MRIStepInnerEvolveFn` function to an :c:type:`MRIStepInnerStepper` object. - **Arguments:** - * *stepper* -- an inner stepper object. - * *fn* -- the :c:type:`MRIStepInnerStepper` function to attach. + :param stepper: an inner stepper object. + :param fn: the :c:type:`MRIStepInnerStepper` function to attach. - **Return value:** - * ARK_SUCCESS if successful - * ARK_ILL_INPUT if the stepper is ``NULL`` + :retval ARK_SUCCESS: if successful + :retval ARK_ILL_INPUT: if the stepper is ``NULL`` **Example usage:** @@ -197,13 +190,11 @@ Setting Member Functions This function attaches an :c:type:`MRIStepInnerFullRhsFn` function to an :c:type:`MRIStepInnerStepper` object. - **Arguments:** - * *stepper* -- an inner stepper object. - * *fn* -- the :c:type:`MRIStepInnerFullRhsFn` function to attach. + :param stepper: an inner stepper object. + :param fn: the :c:type:`MRIStepInnerFullRhsFn` function to attach. - **Return value:** - * ARK_SUCCESS if successful - * ARK_ILL_INPUT if the stepper is ``NULL`` + :retval ARK_SUCCESS: if successful + :retval ARK_ILL_INPUT: if the stepper is ``NULL`` **Example usage:** @@ -221,13 +212,11 @@ Setting Member Functions This function attaches an :c:type:`MRIStepInnerResetFn` function to an :c:type:`MRIStepInnerStepper` object. - **Arguments:** - * *stepper* -- an inner stepper object. - * *fn* -- the :c:type:`MRIStepInnerResetFn` function to attach. + :param stepper: an inner stepper object. + :param fn: the :c:type:`MRIStepInnerResetFn` function to attach. - **Return value:** - * ARK_SUCCESS if successful - * ARK_ILL_INPUT if the stepper is ``NULL`` + :retval ARK_SUCCESS: if successful + :retval ARK_ILL_INPUT: if the stepper is ``NULL`` **Example usage:** @@ -239,6 +228,79 @@ Setting Member Functions **Example codes:** * ``examples/arkode/CXX_parallel/ark_diffusion_reaction_p.cpp`` +.. c:function:: int MRIStepInnerStepper_SetAccumulatedErrorGetFn(MRIStepInnerStepper stepper, MRIStepInnerGetAccumulatedError fn) + + This function attaches an :c:type:`MRIStepInnerGetAccumulatedError` function to an + :c:type:`MRIStepInnerStepper` object. + + :param stepper: an inner stepper object. + :param fn: the :c:type:`MRIStepInnerGetAccumulatedError` function to attach. + + :retval ARK_SUCCESS: if successful + :retval ARK_ILL_INPUT: if the stepper is ``NULL`` + + **Example usage:** + + .. code-block:: C + + /* set the inner stepper accumulated error 'get' function */ + flag = MRIStepInnerStepper_SetAccumulatedErrorGetFn(inner_stepper, MyAccumErr); + +.. c:function:: int MRIStepInnerStepper_SetAccumulatedErrorResetFn(MRIStepInnerStepper stepper, MRIStepInnerResetAccumulatedError fn) + + This function attaches an :c:type:`MRIStepInnerResetAccumulatedError` function to an + :c:type:`MRIStepInnerStepper` object. + + :param stepper: an inner stepper object. + :param fn: the :c:type:`MRIStepInnerResetAccumulatedError` function to attach. + + :retval ARK_SUCCESS: if successful + :retval ARK_ILL_INPUT: if the stepper is ``NULL`` + + **Example usage:** + + .. code-block:: C + + /* set the inner stepper accumulated error 'reset' function */ + flag = MRIStepInnerStepper_SetAccumulatedErrorResetFn(inner_stepper, MyResetAccumErr); + +.. c:function:: int MRIStepInnerStepper_SetFixedStepFn(MRIStepInnerStepper stepper, MRIStepInnerSetFixedStep fn) + + This function attaches an :c:type:`MRIStepInnerSetFixedStep` function to an + :c:type:`MRIStepInnerStepper` object. + + :param stepper: an inner stepper object. + :param fn: the :c:type:`MRIStepInnerSetFixedStep` function to attach. + + :retval ARK_SUCCESS: if successful + :retval ARK_ILL_INPUT: if the stepper is ``NULL`` + + **Example usage:** + + .. code-block:: C + + /* set the inner stepper fixed step size function */ + flag = MRIStepInnerStepper_SetFixedStep(inner_stepper, MySetFixedStep); + +.. c:function:: int MRIStepInnerStepper_SetRTolFn(MRIStepInnerStepper stepper, MRIStepInnerSetRTol fn) + + This function attaches an :c:type:`MRIStepInnerSetRTol` function to an + :c:type:`MRIStepInnerStepper` object. + + :param stepper: an inner stepper object. + :param fn: the :c:type:`MRIStepInnerSetRTol` function to attach. + + :retval ARK_SUCCESS: if successful + :retval ARK_ILL_INPUT: if the stepper is ``NULL`` + + **Example usage:** + + .. code-block:: C + + /* set the inner stepper relative tolerance function */ + flag = MRIStepInnerStepper_SetRTolFn(inner_stepper, MySetRTol); + + .. _ARKODE.Usage.MRIStep.CustomInnerStepper.Description.BaseMethods.Forcing: Applying and Accessing Forcing Data @@ -258,14 +320,12 @@ data necessary to construct the inner (fast) forcing polynomial. time *t* and adds it to input vector *ff*, i.e., the inner (fast) right-hand side vector. - **Arguments:** - * *stepper* -- an inner stepper object. - * *t* -- the time at which the forcing should be evaluated. - * *f* -- the vector to which the forcing should be applied. + :param stepper: an inner stepper object. + :param t: the time at which the forcing should be evaluated. + :param f: the vector to which the forcing should be applied. - **Return value:** - * ARK_SUCCESS if successful - * ARK_ILL_INPUT if the stepper is ``NULL`` + :retval ARK_SUCCESS: if successful + :retval ARK_ILL_INPUT: if the stepper is ``NULL`` **Example usage:** @@ -285,19 +345,17 @@ data necessary to construct the inner (fast) forcing polynomial. normalized time :math:`\tau = (t - t_{n,i-1}^S)/(h^S \Delta c_i^S)` and the array of polynomial coefficient vectors :math:`\hat{\gamma}^{\{k\}}_i`. - **Arguments:** - * *stepper* -- an inner stepper object. - * *tshift* -- the time shift to apply to the current time when computing the + :param stepper: an inner stepper object. + :param tshift: the time shift to apply to the current time when computing the forcing, :math:`t_{n,i-1}^S`. - * *tscale* -- the time scaling to apply to the current time when computing + :param tscale: the time scaling to apply to the current time when computing the forcing, :math:`h^S \Delta c_i^S`. - * *forcing* -- a pointer to an array of forcing vectors, + :param forcing: a pointer to an array of forcing vectors, :math:`\hat{\gamma}^{\{k\}}_i`. - * *nforcing* -- the number of forcing vectors. + :param nforcing: the number of forcing vectors. - **Return value:** - * ARK_SUCCESS if successful - * ARK_ILL_INPUT if the stepper is ``NULL`` + :retval ARK_SUCCESS: if successful + :retval ARK_ILL_INPUT: if the stepper is ``NULL`` **Example usage:** @@ -416,5 +474,106 @@ following member functions: value if a recoverable error occurred, or a negative value if it failed unrecoverably. + **Notes:** + If provided, the :c:type:`MRIStepInnerResetFn` function will always be called + *before* the function :c:type:`MRIStepInnerEvolveFn` is first called. + + **Example codes:** * ``examples/arkode/CXX_parallel/ark_diffusion_reaction_p.cpp`` + + +.. c:type:: int (*MRIStepInnerGetAccumulatedError)(MRIStepInnerStepper stepper, sunrealtype* accum_error) + + This function returns an estimate of the accumulated solution error arising from the inner stepper. + + **Arguments:** + * *stepper* -- the inner stepper object. + * *accum_error* -- estimation of the accumulated solution error. + + **Return value:** + An :c:type:`MRIStepInnerGetAccumulatedError` should return 0 if successful, a positive + value if a recoverable error occurred, or a negative value if it failed + unrecoverably. + + **Notes:** + This function is only called when multirate temporal adaptivity has been enabled, + using a :c:type:`SUNControl` module having type ``SUNDIALS_CONTROL_MRI_H`` or + ``SUNDIALS_CONTROL_MRI_TOL``. + + If provided, the :c:type:`MRIStepInnerGetAccumulatedError` function will always + be called *after* a preceding call to the :c:type:`MRIStepInnerResetAccumulatedError` + function. + + Both the :c:type:`MRIStepInnerGetAccumulatedError` and + :c:type:`MRIStepInnerResetAccumulatedError` functions should be provided, or not; if only + one is provided then MRIStep will disable multirate temporal adaptivity and call neither. + + +.. c:type:: int (*MRIStepInnerResetAccumulatedError)(MRIStepInnerStepper stepper) + + This function resets the inner stepper's accumulated solution error to zero. + + **Arguments:** + * *stepper* -- the inner stepper object. + + **Return value:** + An :c:type:`MRIStepInnerResetAccumulatedError` should return 0 if successful, a positive + value if a recoverable error occurred, or a negative value if it failed + unrecoverably. + + **Notes:** + This function is only called when multirate temporal adaptivity has been enabled, + using a :c:type:`SUNControl` module having type ``SUNDIALS_CONTROL_MRI_H`` or + ``SUNDIALS_CONTROL_MRI_TOL``. + + The :c:type:`MRIStepInnerResetAccumulatedError` function will always be called + *before* any calls to the :c:type:`MRIStepInnerGetAccumulatedError` function. + + Both the :c:type:`MRIStepInnerGetAccumulatedError` and + :c:type:`MRIStepInnerResetAccumulatedError` functions should be provided, or not; if only + one is provided then MRIStep will disable multirate temporal adaptivity and call neither. + + This function peforms a different role within MRIStep than the + :c:type:`MRIStepInnerResetFn`, and thus an implementation should make no + assumptions about the frequency/ordering of calls to either. + + +.. c:type:: int (*MRIStepInnerSetFixedStep)(MRIStepInnerStepper stepper, sunrealtype h) + + This function accepts a fixed step size for the inner stepper to use. + + **Arguments:** + * *stepper* -- the inner stepper object. + * *h* -- fixed step size to use on the upcoming solve. + + **Return value:** + An :c:type:`MRIStepInnerSetFixedStep` should return 0 if successful, a positive + value if a recoverable error occurred, or a negative value if it failed + unrecoverably. + + **Notes:** + This function is only called when multirate temporal adaptivity has been enabled + using a :c:type:`SUNControl` module having type ``SUNDIALS_CONTROL_MRI_H``. + + +.. c:type:: int (*MRIStepInnerSetRTol)(MRIStepInnerStepper stepper, sunrealtype rtol) + + This function accepts a relative tolerance for the inner stepper to use in its upcoming adaptive solve. + + **Arguments:** + * *stepper* -- the inner stepper object. + * *rtol* -- relative tolerance to use on the upcoming solve. + + **Return value:** + An :c:type:`MRIStepInnerSetRTol` should return 0 if successful, a positive + value if a recoverable error occurred, or a negative value if it failed + unrecoverably. + + **Notes:** + This function is only called when multirate temporal adaptivity has been enabled + using a :c:type:`SUNControl` module having type ``SUNDIALS_CONTROL_MRI_TOL``. + + It is assumed that if the inner stepper supports absolute tolerances as well, then + these have been set up directly by the user to indicate the "noise" level for + solution components. diff --git a/doc/arkode/guide/source/Usage/MRIStep/Custom_Inner_Stepper/index.rst b/doc/arkode/guide/source/Usage/MRIStep/Custom_Inner_Stepper/index.rst index 9ce5b94aa9..22a3fcda7c 100644 --- a/doc/arkode/guide/source/Usage/MRIStep/Custom_Inner_Stepper/index.rst +++ b/doc/arkode/guide/source/Usage/MRIStep/Custom_Inner_Stepper/index.rst @@ -17,16 +17,15 @@ MRIStep Custom Inner Steppers ============================= -Recall, MIS and MRI-GARK methods require solving the auxiliary IVP +Recall that MIS, MRI-GARK, and IMEX-MRI-GARK methods require solving a set of auxiliary IVPs .. math:: - \dot{v}(t) = f^F(t, v) + r_i(t), \qquad v(t_{n,i-1}^S) = z_{i-1} + \dot{v}(t) = f^F(t, v) + r_i(t), \qquad v(t_{i,0}) = v_{i,0}, :label: ARKODE_MRI_IVP -for :math:`i \geq 2` on the interval :math:`t \in [t_{n,i-1}^S, t_{n,i}^S]` -where :math:`t_{n,i-1}^S = t_{n-1} + c_{i-1}^S h^S`. The forcing term -:math:`r_i(t)` presented in :numref:`ARKODE.Mathematics.MRIStep` can be equivalently -written as +on intervals :math:`t \in [t_{i,0}, t_{i,f}]`. For MIS, MRI-GARK and IMEX-MRI-GARK methods, +the forcing term :math:`r_i(t)` presented in :numref:`ARKODE.Mathematics.MRIStep` can be +equivalently written as .. math:: r_i(t) = @@ -36,8 +35,9 @@ written as :label: ARKODE_MRI_forcing_poly where :math:`\tau = (t - t_{n,i-1}^S)/(h^S \Delta c_i^S)` is the normalized time -with :math:`\Delta c_i^S=\left(c^S_i - c^S_{i-1}\right)` and the polynomial -coefficient vectors are +with :math:`\Delta c_i^S=\left(c^S_i - c^S_{i-1}\right)`, the slow stage times are +:math:`t_{n,i-1}^S = t_{n-1} + c_{i-1}^S h^S`, and the polynomial coefficient +vectors are .. math:: \hat{\omega}^{\{k\}}_i = \frac{1}{\Delta c_i^S} \sum\limits_{j=1}^{i-1} diff --git a/doc/arkode/guide/source/Usage/MRIStep/MRIStepCoupling.rst b/doc/arkode/guide/source/Usage/MRIStep/MRIStepCoupling.rst index 53d5a8c7d5..2f4622374f 100644 --- a/doc/arkode/guide/source/Usage/MRIStep/MRIStepCoupling.rst +++ b/doc/arkode/guide/source/Usage/MRIStep/MRIStepCoupling.rst @@ -59,13 +59,13 @@ constructing a coupling table and attaching it with .. c:member:: sunrealtype*** W - A three-dimensional array with dimensions ``[nmat][stages][stages]`` + A three-dimensional array with dimensions ``[nmat][stages+1][stages]`` containing the method's :math:`\Omega^{\{k\}}` coupling matrices for the slow-nonstiff (explicit) terms in :eq:`ARKODE_IVP_two_rate` .. c:member:: sunrealtype*** G - A three-dimensional array with dimensions ``[nmat][stages][stages]`` + A three-dimensional array with dimensions ``[nmat][stages+1][stages]`` containing the method's :math:`\Gamma^{\{k\}}` coupling matrices for the slow-stiff (implicit) terms in :eq:`ARKODE_IVP_two_rate` @@ -89,7 +89,7 @@ are defined ``arkode/arkode_mristep.h``. +---------------------------------------------+--------------------------------------------------------------------+ | Function name | Description | - +---------------------------------------------+--------------------------------------------------------------------+ + +=============================================+====================================================================+ | :c:func:`MRIStepCoupling_LoadTable()` | Loads a pre-defined MRIStepCoupling table by ID | +---------------------------------------------+--------------------------------------------------------------------+ | :c:func:`MRIStepCoupling_LoadTableByName()` | Loads a pre-defined MRIStepCoupling table by name | @@ -116,13 +116,10 @@ are defined ``arkode/arkode_mristep.h``. set of coupling tables and their corresponding identifiers, see :numref:`ARKODE.Usage.MRIStep.MRIStepCoupling.Tables`. + :param method: the coupling table identifier. - **Arguments:** - * ``method`` -- the coupling table identifier. - - **Return value:** - * An :c:type:`MRIStepCoupling` structure if successful. - * A ``NULL`` pointer if *method* was invalid or an allocation error occurred. + :return value: An :c:type:`MRIStepCoupling` structure if successful. A ``NULL`` + pointer if *method* was invalid or an allocation error occurred. .. c:function:: MRIStepCoupling MRIStepCoupling_LoadTableByName(const char *method) @@ -131,14 +128,11 @@ are defined ``arkode/arkode_mristep.h``. set of coupling tables and their corresponding name, see :numref:`ARKODE.Usage.MRIStep.MRIStepCoupling.Tables`. + :param method: the coupling table name. - **Arguments:** - * ``method`` -- the coupling table name. - - **Return value:** - * An :c:type:`MRIStepCoupling` structure if successful. - * A ``NULL`` pointer if *method* was invalid, *method* was - ``"ARKODE_MRI_NONE"``, or an allocation error occurred. + :return value: An :c:type:`MRIStepCoupling` structure if successful. + A ``NULL`` pointer if *method* was invalid, *method* was + ``"ARKODE_MRI_NONE"``, or an allocation error occurred. .. note:: @@ -149,16 +143,14 @@ are defined ``arkode/arkode_mristep.h``. Allocates an empty MRIStepCoupling table. - **Arguments:** - * ``nmat`` -- number of :math:`\Omega^{\{k\}}` and/or :math:`\Gamma^{\{k\}}` + :param nmat: number of :math:`\Omega^{\{k\}}` and/or :math:`\Gamma^{\{k\}}` matrices in the coupling table. - * ``stages`` -- number of stages in the coupling table. - * ``type`` -- the method type: explicit (0), implicit (1), or ImEx (2). + :param stages: number of stages in the coupling table. + :param type: the method type: explicit (0), implicit (1), or ImEx (2). - **Return value:** - * An :c:type:`MRIStepCoupling` structure if successful. - * A ``NULL`` pointer if *stages* or *type* was invalid or an allocation error - occurred. + :return value: An :c:type:`MRIStepCoupling` structure if successful. + A ``NULL`` pointer if *stages* or *type* was invalid or an allocation error + occurred. .. note:: @@ -171,46 +163,47 @@ are defined ``arkode/arkode_mristep.h``. Allocates a coupling table and fills it with the given values. - **Arguments:** - * ``nmat`` -- number of :math:`\Omega^{\{k\}}` and/or :math:`\Gamma^{\{k\}}` - matrices in the coupling table. - * ``stages`` -- number of stages in the method. - * ``q`` -- global order of accuracy for the method. - * ``p`` -- global order of accuracy for the embedded method. - * ``W`` -- array of coefficients defining the explicit coupling matrices - :math:`\Omega^{\{k\}}`. The entries should be stored as a 1D array of size - ``nmat * stages * stages``, in row-major order. If the slow method is - implicit pass ``NULL``. - * ``G`` -- array of coefficients defining the implicit coupling matrices - :math:`\Gamma^{\{k\}}`. The entries should be stored as a 1D array of size - ``nmat * stages * stages``, in row-major order. If the slow method is - explicit pass ``NULL``. - * ``c`` -- array of slow abscissae for the MRI method. The entries should be - stored as a 1D array of length ``stages``. - - **Return value:** - * An :c:type:`MRIStepCoupling` structure if successful. - * A ``NULL`` pointer if ``stages`` was invalid, an allocation error occurred, - or the input data arrays are inconsistent with the method type. + :param nmat: number of :math:`\Omega^{\{k\}}` and/or :math:`\Gamma^{\{k\}}` + matrices in the coupling table. + :param stages: number of stages in the method. + :param q: global order of accuracy for the method. + :param p: global order of accuracy for the embedded method. + :param W: array of coefficients defining the explicit coupling matrices + :math:`\Omega^{\{k\}}`. If the slow method is implicit pass ``NULL``. + :param G: array of coefficients defining the implicit coupling matrices + :math:`\Gamma^{\{k\}}`. If the slow method is explicit pass ``NULL``. + :param c: array of slow abscissae for the MRI method. The entries should be + stored as a 1D array of length ``stages``. + + :return value: An :c:type:`MRIStepCoupling` structure if successful. + A ``NULL`` pointer if ``stages`` was invalid, an allocation error occurred, + or the input data arrays are inconsistent with the method type. .. note:: - As embeddings are not currently supported in MRIStep, ``p`` should be - equal to zero. + The arrays *W* and *G* are assumed to have different sizes depending + on the embedding input, *p*. + + Non-embedded methods should be indicated by an input *p=0*, in which + case *W* and/or *G* should have entries stored as a 1D array of size + ``nmat * stages * stages``, in row-major order. + + Embedded methods should be indicated by an input *p>0*, in which + case *W* and/or *G* should have entries stored as a 1D array of size + ``nmat * (stages+1) * stages``, in row-major order. The additional + "row" is assumed to hold the embedding coefficients. .. c:function:: MRIStepCoupling MRIStepCoupling_MIStoMRI(ARKodeButcherTable B, int q, int p) Creates an MRI coupling table for a traditional MIS method based on the slow Butcher table *B*, following the formula shown in :eq:`ARKODE_MIS_to_MRI` - **Arguments:** - * ``B`` -- the :c:type:`ARKodeButcherTable` for the 'slow' MIS method. - * ``q`` -- the overall order of the MIS/MRI method. - * ``p`` -- the overall order of the MIS/MRI embedding. + :param B: the :c:type:`ARKodeButcherTable` for the "slow" MIS method. + :param q: the overall order of the MIS/MRI method. + :param p: the overall order of the MIS/MRI embedding. - **Return value:** - * An :c:type:`MRIStepCoupling` structure if successful. - * A ``NULL`` pointer if an allocation error occurred. + :return value: An :c:type:`MRIStepCoupling` structure if successful. + A ``NULL`` pointer if an allocation error occurred. .. note:: @@ -224,52 +217,44 @@ are defined ``arkode/arkode_mristep.h``. for the Runge--Kutta method encoded in *B*, which is why these arguments should be supplied separately. - As embeddings are not currently supported in MRIStep, then *p* should be - equal to zero. + If *p>0* is input, then the table *B* must include embedding coefficients. .. c:function:: MRIStepCoupling MRIStepCoupling_Copy(MRIStepCoupling C) Creates copy of the given coupling table. - **Arguments:** - * ``C`` -- the coupling table to copy. + :param C: the coupling table to copy. - **Return value:** - * An :c:type:`MRIStepCoupling` structure if successful. - * A ``NULL`` pointer if an allocation error occurred. + :return value: An :c:type:`MRIStepCoupling` structure if successful. + A ``NULL`` pointer if an allocation error occurred. .. c:function:: void MRIStepCoupling_Space(MRIStepCoupling C, sunindextype *liw, sunindextype *lrw) Get the real and integer workspace size for a coupling table. - **Arguments:** - * ``C`` -- the coupling table. - * ``lenrw`` -- the number of ``sunrealtype`` values in the coupling table - workspace. - * ``leniw`` -- the number of integer values in the coupling table workspace. + :param C: the coupling table. + :param lenrw: the number of ``sunrealtype`` values in the coupling table + workspace. + :param leniw: the number of integer values in the coupling table workspace. - **Return value:** - * *ARK_SUCCESS* if successful. - * *ARK_MEM_NULL* if the Butcher table memory was ``NULL``. + :retval ARK_SUCCESS: if successful. + :retval ARK_MEM_NULL: if the Butcher table memory was ``NULL``. .. c:function:: void MRIStepCoupling_Free(MRIStepCoupling C) Deallocate the coupling table memory. - **Arguments:** - * ``C`` -- the coupling table. - + :param C: the coupling table. .. c:function:: void MRIStepCoupling_Write(MRIStepCoupling C, FILE *outfile) Write the coupling table to the provided file pointer. - **Arguments:** - * ``C`` -- the coupling table. - * ``outfile`` -- pointer to use for printing the table. + :param C: the coupling table. + :param outfile: pointer to use for printing the table. .. note:: @@ -306,33 +291,33 @@ with values specified for each method below (e.g., ``ARKODE_MIS_KW3``). .. table:: Explicit MRI-GARK coupling tables. The default method for each order is marked with an asterisk (:math:`^*`). - ================================= =========== ===================== - Table name Order Reference - ================================= =========== ===================== - ``ARKODE_MRI_GARK_FORWARD_EULER`` :math:`1^*` - ``ARKODE_MRI_GARK_ERK22b`` :math:`2^*` :cite:p:`Sandu:19` - ``ARKODE_MRI_GARK_ERK22a`` 2 :cite:p:`Sandu:19` - ``ARKODE_MRI_GARK_RALSTON2`` 2 :cite:p:`Roberts:22` - ``ARKODE_MIS_KW3`` :math:`3^*` :cite:p:`Schlegel:09` - ``ARKODE_MRI_GARK_ERK33a`` 3 :cite:p:`Sandu:19` - ``ARKODE_MRI_GARK_RALSTON3`` 3 :cite:p:`Roberts:22` - ``ARKODE_MRI_GARK_ERK45a`` :math:`4^*` :cite:p:`Sandu:19` - ================================= =========== ===================== + ================================= ============ =============== ===================== + Table name Method Order Embedding Order Reference + ================================= ============ =============== ===================== + ``ARKODE_MRI_GARK_FORWARD_EULER`` :math:`1^*` 0 + ``ARKODE_MRI_GARK_ERK22b`` :math:`2^*` 0 :cite:p:`Sandu:19` + ``ARKODE_MRI_GARK_ERK22a`` 2 1 :cite:p:`Sandu:19` + ``ARKODE_MRI_GARK_RALSTON2`` 2 0 :cite:p:`Roberts:22` + ``ARKODE_MIS_KW3`` :math:`3^*` 0 :cite:p:`Schlegel:09` + ``ARKODE_MRI_GARK_ERK33a`` 3 2 :cite:p:`Sandu:19` + ``ARKODE_MRI_GARK_RALSTON3`` 3 0 :cite:p:`Roberts:22` + ``ARKODE_MRI_GARK_ERK45a`` :math:`4^*` 3 :cite:p:`Sandu:19` + ================================= ============ =============== ===================== .. table:: Diagonally-implicit, solve-decoupled MRI-GARK coupling tables. The default method for each order is marked with an asterisk (:math:`^*`). - ===================================== =========== =============== ================== - Table name Order Implicit Solves Reference - ===================================== =========== =============== ================== - ``ARKODE_MRI_GARK_BACKWARD_EULER`` :math:`1^*` 1 - ``ARKODE_MRI_GARK_IRK21a`` :math:`2^*` 1 :cite:p:`Sandu:19` - ``ARKODE_MRI_GARK_IMPLICIT_MIDPOINT`` 2 2 - ``ARKODE_MRI_GARK_ESDIRK34a`` :math:`3^*` 3 :cite:p:`Sandu:19` - ``ARKODE_MRI_GARK_ESDIRK46a`` :math:`4^*` 5 :cite:p:`Sandu:19` - ===================================== =========== =============== ================== + ===================================== ============ =============== =============== ================== + Table name Method Order Embedding Order Implicit Solves Reference + ===================================== ============ =============== =============== ================== + ``ARKODE_MRI_GARK_BACKWARD_EULER`` :math:`1^*` 0 1 + ``ARKODE_MRI_GARK_IRK21a`` :math:`2^*` 1 1 :cite:p:`Sandu:19` + ``ARKODE_MRI_GARK_IMPLICIT_MIDPOINT`` 2 0 2 + ``ARKODE_MRI_GARK_ESDIRK34a`` :math:`3^*` 2 3 :cite:p:`Sandu:19` + ``ARKODE_MRI_GARK_ESDIRK46a`` :math:`4^*` 3 5 :cite:p:`Sandu:19` + ===================================== ============ =============== =============== ================== .. table:: Diagonally-implicit, solve-decoupled IMEX-MRI-GARK coupling tables. diff --git a/doc/arkode/guide/source/Usage/MRIStep/User_callable.rst b/doc/arkode/guide/source/Usage/MRIStep/User_callable.rst index 24e8497c04..6424e09793 100644 --- a/doc/arkode/guide/source/Usage/MRIStep/User_callable.rst +++ b/doc/arkode/guide/source/Usage/MRIStep/User_callable.rst @@ -46,24 +46,22 @@ MRIStep initialization and deallocation functions This function allocates and initializes memory for a problem to be solved using the MRIStep time-stepping module in ARKODE. - **Arguments:** - * *fse* -- the name of the function (of type :c:func:`ARKRhsFn()`) - defining the explicit slow portion of the right-hand side function in - :math:`\dot{y} = f^E(t,y) + f^I(t,y) + f^F(t,y)`. - * *fsi* -- the name of the function (of type :c:func:`ARKRhsFn()`) - defining the implicit slow portion of the right-hand side function in - :math:`\dot{y} = f^E(t,y) + f^I(t,y) + f^F(t,y)`. - * *t0* -- the initial value of :math:`t`. - * *y0* -- the initial condition vector :math:`y(t_0)`. - * *stepper* -- an :c:type:`MRIStepInnerStepper` for integrating the fast - time scale. - * *sunctx* -- the :c:type:`SUNContext` object (see :numref:`SUNDIALS.SUNContext`) - - **Return value:** - If successful, a pointer to initialized problem memory of type ``void*``, to - be passed to all user-facing MRIStep routines listed below. If unsuccessful, - a ``NULL`` pointer will be returned, and an error message will be printed to - ``stderr``. + :param fse: the name of the function (of type :c:func:`ARKRhsFn()`) + defining the explicit slow portion of the right-hand side function in + :math:`\dot{y} = f^E(t,y) + f^I(t,y) + f^F(t,y)`. + :param fsi: the name of the function (of type :c:func:`ARKRhsFn()`) + defining the implicit slow portion of the right-hand side function in + :math:`\dot{y} = f^E(t,y) + f^I(t,y) + f^F(t,y)`. + :param t0: the initial value of :math:`t`. + :param y0: the initial condition vector :math:`y(t_0)`. + :param stepper: an :c:type:`MRIStepInnerStepper` for integrating the fast + time scale. + :param sunctx: the :c:type:`SUNContext` object (see :numref:`SUNDIALS.SUNContext`) + + :return value: If successful, a pointer to initialized problem memory of type ``void*``, to + be passed to all user-facing MRIStep routines listed below. If unsuccessful, + a ``NULL`` pointer will be returned, and an error message will be printed to + ``stderr``. **Example usage:** @@ -105,10 +103,9 @@ MRIStep initialization and deallocation functions This function frees the problem memory *arkode_mem* created by :c:func:`MRIStepCreate`. - **Arguments:** - * *arkode_mem* -- pointer to the MRIStep memory block. + :param arkode_mem: pointer to the MRIStep memory block. - **Return value:** None + :return value: None .. deprecated:: 6.1.0 @@ -125,16 +122,14 @@ MRIStep tolerance specification functions This function specifies scalar relative and absolute tolerances. - **Arguments:** - * *arkode_mem* -- pointer to the MRIStep memory block. - * *reltol* -- scalar relative tolerance. - * *abstol* -- scalar absolute tolerance. + :param arkode_mem: pointer to the MRIStep memory block. + :param reltol: scalar relative tolerance. + :param abstol: scalar absolute tolerance. - **Return value:** - * *ARK_SUCCESS* if successful - * *ARK_MEM_NULL* if the MRIStep memory was ``NULL`` - * *ARK_NO_MALLOC* if the MRIStep memory was not allocated by the time-stepping module - * *ARK_ILL_INPUT* if an argument has an illegal value (e.g. a negative tolerance). + :retval ARK_SUCCESS: if successful + :retval ARK_MEM_NULL: if the MRIStep memory was ``NULL`` + :retval ARK_NO_MALLOC: if the MRIStep memory was not allocated by the time-stepping module + :retval ARK_ILL_INPUT: if an argument has an illegal value (e.g. a negative tolerance). .. deprecated:: 6.1.0 @@ -148,17 +143,15 @@ MRIStep tolerance specification functions absolute tolerance (a potentially different absolute tolerance for each vector component). - **Arguments:** - * *arkode_mem* -- pointer to the MRIStep memory block. - * *reltol* -- scalar relative tolerance. - * *abstol* -- vector containing the absolute tolerances for each - solution component. + :param arkode_mem: pointer to the MRIStep memory block. + :param reltol: scalar relative tolerance. + :param abstol: vector containing the absolute tolerances for each + solution component. - **Return value:** - * *ARK_SUCCESS* if successful - * *ARK_MEM_NULL* if the MRIStep memory was ``NULL`` - * *ARK_NO_MALLOC* if the MRIStep memory was not allocated by the time-stepping module - * *ARK_ILL_INPUT* if an argument has an illegal value (e.g. a negative tolerance). + :retval ARK_SUCCESS: if successful + :retval ARK_MEM_NULL: if the MRIStep memory was ``NULL`` + :retval ARK_NO_MALLOC: if the MRIStep memory was not allocated by the time-stepping module + :retval ARK_ILL_INPUT: if an argument has an illegal value (e.g. a negative tolerance). .. deprecated:: 6.1.0 @@ -171,15 +164,13 @@ MRIStep tolerance specification functions This function specifies a user-supplied function *efun* to compute the error weight vector ``ewt``. - **Arguments:** - * *arkode_mem* -- pointer to the MRIStep memory block. - * *efun* -- the name of the function (of type :c:func:`ARKEwtFn()`) - that implements the error weight vector computation. + :param arkode_mem: pointer to the MRIStep memory block. + :param efun: the name of the function (of type :c:func:`ARKEwtFn()`) + that implements the error weight vector computation. - **Return value:** - * *ARK_SUCCESS* if successful - * *ARK_MEM_NULL* if the MRIStep memory was ``NULL`` - * *ARK_NO_MALLOC* if the MRIStep memory was not allocated by the time-stepping module + :retval ARK_SUCCESS: if successful + :retval ARK_MEM_NULL: if the MRIStep memory was ``NULL`` + :retval ARK_NO_MALLOC: if the MRIStep memory was not allocated by the time-stepping module .. deprecated:: 6.1.0 @@ -198,40 +189,40 @@ Linear solver interface functions should use, as well as a template Jacobian ``SUNMatrix`` object (if applicable). - **Arguments:** - * *arkode_mem* -- pointer to the MRIStep memory block. - * *LS* -- the ``SUNLinearSolver`` object to use. - * *J* -- the template Jacobian ``SUNMatrix`` object to use (or - ``NULL`` if not applicable). + :param arkode_mem: pointer to the MRIStep memory block. + :param LS: the ``SUNLinearSolver`` object to use. + :param J: the template Jacobian ``SUNMatrix`` object to use (or + ``NULL`` if not applicable). - **Return value:** - * *ARKLS_SUCCESS* if successful - * *ARKLS_MEM_NULL* if the MRIStep memory was ``NULL`` - * *ARKLS_MEM_FAIL* if there was a memory allocation failure - * *ARKLS_ILL_INPUT* if ARKLS is incompatible with the - provided *LS* or *J* input objects, or the current - ``N_Vector`` module. - - **Notes:** If *LS* is a matrix-free linear solver, then the *J* - argument should be ``NULL``. - - If *LS* is a matrix-based linear solver, then the template Jacobian - matrix *J* will be used in the solve process, so if additional - storage is required within the ``SUNMatrix`` object (e.g. for - factorization of a banded matrix), ensure that the input object is - allocated with sufficient size (see the documentation of - the particular SUNMATRIX type in :numref:`SUNMatrix` for - further information). - - When using sparse linear solvers, it is typically much more - efficient to supply *J* so that it includes the full sparsity - pattern of the Newton system matrices :math:`\mathcal{A} = - I-\gamma J`, even if *J* itself has zeros in nonzero - locations of :math:`I`. The reasoning for this is - that :math:`\mathcal{A}` is constructed in-place, on top of the - user-specified values of *J*, so if the sparsity pattern in *J* is - insufficient to store :math:`\mathcal{A}` then it will need to be - resized internally by MRIStep. + :retval ARKLS_SUCCESS: if successful + :retval ARKLS_MEM_NULL: if the MRIStep memory was ``NULL`` + :retval ARKLS_MEM_FAIL: if there was a memory allocation failure + :retval ARKLS_ILL_INPUT: if ARKLS is incompatible with the + provided *LS* or *J* input objects, or the current + ``N_Vector`` module. + + .. note:: + + If *LS* is a matrix-free linear solver, then the *J* + argument should be ``NULL``. + + If *LS* is a matrix-based linear solver, then the template Jacobian + matrix *J* will be used in the solve process, so if additional + storage is required within the ``SUNMatrix`` object (e.g. for + factorization of a banded matrix), ensure that the input object is + allocated with sufficient size (see the documentation of + the particular SUNMATRIX type in :numref:`SUNMatrix` for + further information). + + When using sparse linear solvers, it is typically much more + efficient to supply *J* so that it includes the full sparsity + pattern of the Newton system matrices :math:`\mathcal{A} = + I-\gamma J`, even if *J* itself has zeros in nonzero + locations of :math:`I`. The reasoning for this is + that :math:`\mathcal{A}` is constructed in-place, on top of the + user-specified values of *J*, so if the sparsity pattern in *J* is + insufficient to store :math:`\mathcal{A}` then it will need to be + resized internally by MRIStep. .. deprecated:: 6.1.0 @@ -249,20 +240,20 @@ Nonlinear solver interface functions This function specifies the ``SUNNonlinearSolver`` object that MRIStep should use for implicit stage solves. - **Arguments:** - * *arkode_mem* -- pointer to the MRIStep memory block. - * *NLS* -- the ``SUNNonlinearSolver`` object to use. + :param arkode_mem: pointer to the MRIStep memory block. + :param NLS: the ``SUNNonlinearSolver`` object to use. - **Return value:** - * *ARK_SUCCESS* if successful - * *ARK_MEM_NULL* if the MRIStep memory was ``NULL`` - * *ARK_MEM_FAIL* if there was a memory allocation failure - * *ARK_ILL_INPUT* if MRIStep is incompatible with the - provided *NLS* input object. + :retval ARK_SUCCESS: if successful + :retval ARK_MEM_NULL: if the MRIStep memory was ``NULL`` + :retval ARK_MEM_FAIL: if there was a memory allocation failure + :retval ARK_ILL_INPUT: if MRIStep is incompatible with the + provided *NLS* input object. - **Notes:** MRIStep will use the Newton ``SUNNonlinearSolver`` module by - default; a call to this routine replaces that module with the - supplied *NLS* object. + .. note:: + + MRIStep will use the Newton ``SUNNonlinearSolver`` module by + default; a call to this routine replaces that module with the + supplied *NLS* object. .. deprecated:: 6.1.0 @@ -281,29 +272,29 @@ Rootfinding initialization function integration of the ODE system. It must be called after :c:func:`MRIStepCreate()`, and before :c:func:`MRIStepEvolve()`. - **Arguments:** - * *arkode_mem* -- pointer to the MRIStep memory block. - * *nrtfn* -- number of functions :math:`g_i`, an integer :math:`\ge` 0. - * *g* -- name of user-supplied function, of type :c:func:`ARKRootFn()`, - defining the functions :math:`g_i` whose roots are sought. + :param arkode_mem: pointer to the MRIStep memory block. + :param nrtfn: number of functions :math:`g_i`, an integer :math:`\ge` 0. + :param g: name of user-supplied function, of type :c:func:`ARKRootFn()`, + defining the functions :math:`g_i` whose roots are sought. - **Return value:** - * *ARK_SUCCESS* if successful - * *ARK_MEM_NULL* if the MRIStep memory was ``NULL`` - * *ARK_MEM_FAIL* if there was a memory allocation failure - * *ARK_ILL_INPUT* if *nrtfn* is greater than zero but *g* = ``NULL``. + :retval ARK_SUCCESS: if successful + :retval ARK_MEM_NULL: if the MRIStep memory was ``NULL`` + :retval ARK_MEM_FAIL: if there was a memory allocation failure + :retval ARK_ILL_INPUT: if *nrtfn* is greater than zero but *g* = ``NULL``. + + .. note:: - **Notes:** To disable the rootfinding feature after it has already - been initialized, or to free memory associated with MRIStep's - rootfinding module, call *MRIStepRootInit* with *nrtfn = 0*. + To disable the rootfinding feature after it has already + been initialized, or to free memory associated with MRIStep's + rootfinding module, call *MRIStepRootInit* with *nrtfn = 0*. - Similarly, if a new IVP is to be solved with a call to - :c:func:`MRIStepReInit()`, where the new IVP has no rootfinding - problem but the prior one did, then call *MRIStepRootInit* with - *nrtfn = 0*. + Similarly, if a new IVP is to be solved with a call to + :c:func:`MRIStepReInit()`, where the new IVP has no rootfinding + problem but the prior one did, then call *MRIStepRootInit* with + *nrtfn = 0*. - Rootfinding is only supported for the slow (outer) integrator and should not - be activated for the fast (inner) integrator. + Rootfinding is only supported for the slow (outer) integrator and should not + be actived for the fast (inner) integrator. .. deprecated:: 6.1.0 @@ -320,72 +311,73 @@ MRIStep solver function Integrates the ODE over an interval in :math:`t`. - **Arguments:** - * *arkode_mem* -- pointer to the MRIStep memory block. - * *tout* -- the next time at which a computed solution is desired. - * *yout* -- the computed solution vector. - * *tret* -- the time corresponding to *yout* (output). - * *itask* -- a flag indicating the job of the solver for the next - user step. - - The *ARK_NORMAL* option causes the solver to take internal - steps until it has just overtaken a user-specified output - time, *tout*, in the direction of integration, - i.e. :math:`t_{n-1} <` *tout* :math:`\le t_{n}` for forward - integration, or :math:`t_{n} \le` *tout* :math:`< t_{n-1}` for - backward integration. It will then compute an approximation - to the solution :math:`y(tout)` by interpolation (as described - in :numref:`ARKODE.Mathematics.Interpolation`). - - The *ARK_ONE_STEP* option tells the solver to only take a - single internal step, :math:`y_{n-1} \to y_{n}`, and return the solution - at that point, :math:`y_{n}`, in the vector *yout*. + :param arkode_mem: pointer to the MRIStep memory block. + :param tout: the next time at which a computed solution is desired. + :param yout: the computed solution vector. + :param tret: the time corresponding to *yout* (output). + :param itask: a flag indicating the job of the solver for the next + user step. + + The *ARK_NORMAL* option causes the solver to take internal + steps until it has just overtaken a user-specified output + time, *tout*, in the direction of integration, + i.e. :math:`t_{n-1} <` *tout* :math:`\le t_{n}` for forward + integration, or :math:`t_{n} \le` *tout* :math:`< t_{n-1}` for + backward integration. It will then compute an approximation + to the solution :math:`y(tout)` by interpolation (as described + in :numref:`ARKODE.Mathematics.Interpolation`). + + The *ARK_ONE_STEP* option tells the solver to only take a + single internal step, :math:`y_{n-1} \to y_{n}`, and return the + solution at that point, :math:`y_{n}`, in the vector *yout*. + + :retval ARK_SUCCESS: if successful. + :retval ARK_ROOT_RETURN: if :c:func:`MRIStepEvolve()` succeeded, and + found one or more roots. If the number of root + functions, *nrtfn*, is greater than 1, call + :c:func:`MRIStepGetRootInfo()` to see which + :math:`g_i` were found to have a root at (*\*tret*). + :retval ARK_TSTOP_RETURN: if :c:func:`MRIStepEvolve()` succeeded and + returned at *tstop*. + :retval ARK_MEM_NULL: if the *arkode_mem* argument was ``NULL``. + :retval ARK_NO_MALLOC: if *arkode_mem* was not allocated. + :retval ARK_ILL_INPUT: if one of the inputs to + :c:func:`MRIStepEvolve()` is illegal, or some other + input to the solver was either illegal or missing. + Details will be provided in the error message. + Typical causes of this failure: + + (a) A component of the error weight vector became + zero during internal time-stepping. + + (b) The linear solver initialization function + (called by the user after calling + :c:func:`ARKStepCreate`) failed to set + the linear solver-specific *lsolve* field in + *arkode_mem*. + + (c) A root of one of the root functions was found both + at a point :math:`t` and also very near :math:`t`. + + :retval ARK_TOO_MUCH_WORK: if the solver took *mxstep* internal steps + but could not reach *tout*. The default value for + *mxstep* is *MXSTEP_DEFAULT = 500*. + :retval ARK_CONV_FAILURE: if convergence test failures occurred too many + times (*ark_maxncf*) during one internal time step. + :retval ARK_LINIT_FAIL: if the linear solver's initialization function failed. + :retval ARK_LSETUP_FAIL: if the linear solver's setup routine failed in + an unrecoverable manner. + :retval ARK_LSOLVE_FAIL: if the linear solver's solve routine failed in + an unrecoverable manner. + :retval ARK_VECTOROP_ERR: a vector operation error occurred. + :retval ARK_INNERSTEP_FAILED: if the inner stepper returned with an + unrecoverable error. The value returned from the + inner stepper can be obtained with + :c:func:`MRIStepGetLastInnerStepFlag()`. + :retval ARK_INVALID_TABLE: if an invalid coupling table was provided. + + .. note:: - **Return value:** - * *ARK_SUCCESS* if successful. - * *ARK_ROOT_RETURN* if :c:func:`MRIStepEvolve()` succeeded, and - found one or more roots. If the number of root functions, - *nrtfn*, is greater than 1, call - :c:func:`MRIStepGetRootInfo()` to see which :math:`g_i` were - found to have a root at (*\*tret*). - * *ARK_TSTOP_RETURN* if :c:func:`MRIStepEvolve()` succeeded and - returned at *tstop*. - * *ARK_MEM_NULL* if the *arkode_mem* argument was ``NULL``. - * *ARK_NO_MALLOC* if *arkode_mem* was not allocated. - * *ARK_ILL_INPUT* if one of the inputs to - :c:func:`MRIStepEvolve()` is illegal, or some other input to - the solver was either illegal or missing. Details will be - provided in the error message. Typical causes of this failure: - - (a) A component of the error weight vector became zero during - internal time-stepping. - - (b) The linear solver initialization function (called by the - user after calling :c:func:`ARKStepCreate`) failed to set - the linear solver-specific *lsolve* field in - *arkode_mem*. - - (c) A root of one of the root functions was found both at a - point :math:`t` and also very near :math:`t`. - - * *ARK_TOO_MUCH_WORK* if the solver took *mxstep* internal steps - but could not reach *tout*. The default value for *mxstep* is - *MXSTEP_DEFAULT = 500*. - * *ARK_CONV_FAILURE* if convergence test failures occurred - too many times (*ark_maxncf*) during one internal time step. - * *ARK_LINIT_FAIL* if the linear solver's initialization - function failed. - * *ARK_LSETUP_FAIL* if the linear solver's setup routine failed in - an unrecoverable manner. - * *ARK_LSOLVE_FAIL* if the linear solver's solve routine failed in - an unrecoverable manner. - * *ARK_VECTOROP_ERR* a vector operation error occurred. - * *ARK_INNERSTEP_FAILED* if the inner stepper returned with an - unrecoverable error. The value returned from the inner stepper can be - obtained with :c:func:`MRIStepGetLastInnerStepFlag()`. - * *ARK_INVALID_TABLE* if an invalid coupling table was provided. - - **Notes:** The input vector *yout* can use the same memory as the vector *y0* of initial conditions that was passed to :c:func:`MRIStepCreate`. @@ -432,27 +424,81 @@ Optional inputs for MRIStep ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +.. c:function:: int MRIStepSetAdaptController(void* arkode_mem, SUNAdaptController C) + + Sets a user-supplied multirate time-step controller object. + + :param arkode_mem: pointer to the ARKODE memory block. + :param C: user-supplied time adaptivity controller. If ``NULL`` then this routine + will just call :c:func:`ARKodeSetAdaptController` to specify that the + default ARKODE controller should be created. + + :retval ARK_SUCCESS: the function exited successfully. + :retval ARK_MEM_NULL: ``arkode_mem`` was ``NULL``. + :retval ARK_MEM_FAIL: *C* was ``NULL`` and the PID controller could not be allocated. + :retval ARK_STEPPER_UNSUPPORTED: adaptive step sizes are not supported + by the current time-stepping module. + + .. note:: + + This routine should only be called directly when using a "multirate" + :c:type:`SUNAdaptController`, i.e., one with type ``SUN_ADAPTCONTROLLER_MRI_H`` + or ``SUN_ADAPTCONTROLLER_MRI_TOL``. Otherwise, it is more efficient to call + :c:func:`ARKodeSetAdaptController` directly. + + .. versionadded:: x.y.z + + +.. c:function:: int MRIStepSetFastErrorStepFactor(void* arkode_mem, sunrealtype hfactor) + + Specifies a fast stepsize factor for MRIStep to use within a "brute force" fast + time scale error estimation strategy. If this value is nonzero and MRI temporal + adaptivity is enabled, then the fast integrator is run twice over each fast time + interval, once using the inner step size ``h``, and again using ``hfactor*h`` + (typically ``hfactor`` will be either :math:`k` or :math:`1/k` for an integer + :math:`k>1`). This is only needed when the results from the fast-integrator-provided + :c:type:`MRIStepInnerGetAccumulatedError` cannot be trusted. In testing, we found + this to be the case when the inner integrator uses fixed step sizes. + + An argument of 0 disables this fast error estimation strategy. + Arguments less than zero or exactly equal to one are illegal. + All other positive ``hfactor`` values will *attempt* to be used. + + :param arkode_mem: pointer to the ARKODE memory block. + :param hfactor: user-supplied fast stepsize factor. + + :retval ARK_SUCCESS: the function exited successfully. + :retval ARK_MEM_NULL: ``arkode_mem`` was ``NULL``. + :retval ARK_ILL_INPUT: the value of ``hfactor`` was illegal. + + .. note:: + + This routine should only be called directly when using a "multirate" + :c:type:`SUNAdaptController` of type ``SUN_ADAPTCONTROLLER_MRI_H``. + + .. versionadded:: x.y.z + + + + .. c:function:: int MRIStepSetDefaults(void* arkode_mem) Resets all optional input parameters to MRIStep's original default values. - **Arguments:** - - * *arkode_mem* -- pointer to the MRIStep memory block. + :param arkode_mem: pointer to the MRIStep memory block. - **Return value:** - - * *ARK_SUCCESS* if successful + :retval ARK_SUCCESS: if successful + :retval ARK_MEM_NULL: if the MRIStep memory is ``NULL`` + :retval ARK_ILL_INPUT: if an argument has an illegal value - * *ARK_MEM_NULL* if the MRIStep memory is ``NULL`` + .. note:: - * *ARK_ILL_INPUT* if an argument has an illegal value - **Notes:** This function does not change problem-defining function pointers - *fs* and *ff* or the *user_data* pointer. It also does not affect any data - structures or options related to root-finding (those can be reset using - :c:func:`MRIStepRootInit()`). + This function does not change problem-defining function pointers + *fs* and *ff* or the *user_data* pointer. It also does not affect any data + structures or options related to root-finding (those can be reset using + :c:func:`MRIStepRootInit()`). .. deprecated:: 6.1.0 @@ -475,39 +521,32 @@ Optional inputs for MRIStep used for dense output (i.e. interpolation of solution output values and implicit method predictors). - **Arguments:** - - * *arkode_mem* -- pointer to the MRIStep memory block. - - * *degree* -- requested polynomial degree. - - **Return value:** - - * *ARK_SUCCESS* if successful - - * *ARK_MEM_NULL* if the MRIStep memory or interpolation module are ``NULL`` + :param arkode_mem: pointer to the MRIStep memory block. + :param degree: requested polynomial degree. - * *ARK_INTERP_FAIL* if this is called after :c:func:`MRIStepEvolve()` + :retval ARK_SUCCESS: if successful + :retval ARK_MEM_NULL: if the MRIStep memory or interpolation module are ``NULL`` + :retval ARK_INTERP_FAIL: if this is called after :c:func:`MRIStepEvolve()` + :retval ARK_ILL_INPUT: if an argument has an illegal value or the + interpolation module has already been initialized - * *ARK_ILL_INPUT* if an argument has an illegal value or the - interpolation module has already been initialized - - **Notes:** Allowed values are between 0 and 5. + .. note:: - This routine should be called *after* :c:func:`MRIStepCreate()` and *before* - :c:func:`MRIStepEvolve()`. After the first call to :c:func:`MRIStepEvolve()` - the interpolation degree may not be changed without first calling - :c:func:`MRIStepReInit()`. + Allowed values are between 0 and 5. + This routine should be called *after* :c:func:`MRIStepCreate()` and *before* + :c:func:`MRIStepEvolve()`. After the first call to :c:func:`MRIStepEvolve()` + the interpolation degree may not be changed without first calling + :c:func:`MRIStepReInit()`. - If a user calls both this routine and :c:func:`MRIStepSetInterpolantType()`, then - :c:func:`MRIStepSetInterpolantType()` must be called first. + If a user calls both this routine and :c:func:`MRIStepSetInterpolantType()`, then + :c:func:`MRIStepSetInterpolantType()` must be called first. - Since the accuracy of any polynomial interpolant is limited by the accuracy - of the time-step solutions on which it is based, the *actual* polynomial - degree that is used by MRIStep will be the minimum of :math:`q-1` and the - input *degree*, for :math:`q > 1` where :math:`q` is the order of accuracy - for the time integration method. + Since the accuracy of any polynomial interpolant is limited by the accuracy + of the time-step solutions on which it is based, the *actual* polynomial + degree that is used by MRIStep will be the minimum of :math:`q-1` and the + input *degree*, for :math:`q > 1` where :math:`q` is the order of accuracy + for the time integration method. .. versionchanged:: 5.5.1 @@ -532,28 +571,23 @@ Optional inputs for MRIStep Specifies the file pointer for a diagnostics file where all MRIStep step adaptivity and solver information is written. - **Arguments:** - - * *arkode_mem* -- pointer to the MRIStep memory block. - - * *diagfp* -- pointer to the diagnostics output file. - - **Return value:** - - * *ARK_SUCCESS* if successful + :param arkode_mem: pointer to the MRIStep memory block. + :param diagfp: pointer to the diagnostics output file. - * *ARK_MEM_NULL* if the MRIStep memory is ``NULL`` + :retval ARK_SUCCESS: if successful + :retval ARK_MEM_NULL: if the MRIStep memory is ``NULL`` + :retval ARK_ILL_INPUT: if an argument has an illegal value - * *ARK_ILL_INPUT* if an argument has an illegal value + .. note:: - **Notes:** This parameter can be ``stdout`` or ``stderr``, although the - suggested approach is to specify a pointer to a unique file opened - by the user and returned by ``fopen``. If not called, or if called - with a ``NULL`` file pointer, all diagnostics output is disabled. + This parameter can be ``stdout`` or ``stderr``, although the + suggested approach is to specify a pointer to a unique file opened + by the user and returned by ``fopen``. If not called, or if called + with a ``NULL`` file pointer, all diagnostics output is disabled. - When run in parallel, only one process should set a non-NULL value - for this pointer, since statistics from all processes would be - identical. + When run in parallel, only one process should set a non-NULL value + for this pointer, since statistics from all processes would be + identical. .. deprecated:: 5.2.0 @@ -565,24 +599,17 @@ Optional inputs for MRIStep Set the slow step size used within MRIStep for the following internal step(s). - **Arguments:** - - * *arkode_mem* -- pointer to the MRIStep memory block. - - * *hs* -- value of the outer (slow) step size. - - **Return value:** - - * *ARK_SUCCESS* if successful - - * *ARK_MEM_NULL* if the MRIStep memory is ``NULL`` + :param arkode_mem: pointer to the MRIStep memory block. + :param hs: value of the outer (slow) step size. - * *ARK_ILL_INPUT* if an argument has an illegal value + :retval ARK_SUCCESS: if successful + :retval ARK_MEM_NULL: if the MRIStep memory is ``NULL`` + :retval ARK_ILL_INPUT: if an argument has an illegal value - **Notes:** + .. note:: - The step sizes used by the inner (fast) stepper may be controlled through calling the - appropriate "Set" routines on the inner integrator. + The step sizes used by the inner (fast) stepper may be controlled through calling the + appropriate "Set" routines on the inner integrator. .. deprecated:: 6.1.0 @@ -596,24 +623,18 @@ Optional inputs for MRIStep solver to warn that :math:`t+h=t` on the next internal step, before MRIStep will instead return with an error. - **Arguments:** - - * *arkode_mem* -- pointer to the MRIStep memory block. - - * *mxhnil* -- maximum allowed number of warning messages :math:`(>0)`. - - **Return value:** - - * *ARK_SUCCESS* if successful + :param arkode_mem: pointer to the MRIStep memory block. + :param mxhnil: maximum allowed number of warning messages :math:`(>0)`. - * *ARK_MEM_NULL* if the MRIStep memory is ``NULL`` + :retval ARK_SUCCESS: if successful + :retval ARK_MEM_NULL: if the MRIStep memory is ``NULL`` + :retval ARK_ILL_INPUT: if an argument has an illegal value - * *ARK_ILL_INPUT* if an argument has an illegal value + .. note:: - **Notes:** The default value is 10; set *mxhnil* to zero to specify - this default. + The default value is 10; set *mxhnil* to zero to specify this default. - A negative value indicates that no warning messages should be issued. + A negative value indicates that no warning messages should be issued. .. deprecated:: 6.1.0 @@ -627,24 +648,19 @@ Optional inputs for MRIStep solver in its attempt to reach the next output time, before MRIStep will return with an error. - **Arguments:** - - * *arkode_mem* -- pointer to the MRIStep memory block. - - * *mxsteps* -- maximum allowed number of internal steps. - - **Return value:** - - * *ARK_SUCCESS* if successful + :param arkode_mem: pointer to the MRIStep memory block. + :param mxsteps: maximum allowed number of internal steps. - * *ARK_MEM_NULL* if the MRIStep memory is ``NULL`` + :retval ARK_SUCCESS: if successful + :retval ARK_MEM_NULL: if the MRIStep memory is ``NULL`` + :retval ARK_ILL_INPUT: if an argument has an illegal value - * *ARK_ILL_INPUT* if an argument has an illegal value + .. note:: - **Notes:** Passing *mxsteps* = 0 results in MRIStep using the - default value (500). + Passing *mxsteps* = 0 results in MRIStep using the + default value (500). - Passing *mxsteps* < 0 disables the test (not recommended). + Passing *mxsteps* < 0 disables the test (not recommended). .. deprecated:: 6.1.0 @@ -657,21 +673,14 @@ Optional inputs for MRIStep Specifies the value of the independent variable :math:`t` past which the solution is not to proceed. - **Arguments:** - - * *arkode_mem* -- pointer to the MRIStep memory block. - - * *tstop* -- stopping time for the integrator. - - **Return value:** - - * *ARK_SUCCESS* if successful - - * *ARK_MEM_NULL* if the MRIStep memory is ``NULL`` + :param arkode_mem: pointer to the MRIStep memory block. + :param tstop: stopping time for the integrator. - * *ARK_ILL_INPUT* if an argument has an illegal value + :retval ARK_SUCCESS: if successful + :retval ARK_MEM_NULL: if the MRIStep memory is ``NULL`` + :retval ARK_ILL_INPUT: if an argument has an illegal value - **Notes:** + .. note:: The default is that no stop time is imposed. @@ -715,15 +724,14 @@ Optional inputs for MRIStep Disables the stop time set with :c:func:`MRIStepSetStopTime`. - **Arguments:** - * *arkode_mem* -- pointer to the MRIStep memory block. + :param arkode_mem: pointer to the MRIStep memory block. - **Return value:** - * *ARK_SUCCESS* if successful - * *ARK_MEM_NULL* if the MRIStep memory is ``NULL`` + :retval ARK_SUCCESS: if successful + :retval ARK_MEM_NULL: if the MRIStep memory is ``NULL`` + + .. note:: - **Notes:** - The stop time can be re-enabled though a new call to + The stop time can be reenabled though a new call to :c:func:`MRIStepSetStopTime`. .. versionadded:: 5.5.1 @@ -739,29 +747,24 @@ Optional inputs for MRIStep Specifies the user data block *user_data* for the outer integrator and attaches it to the main MRIStep memory block. - **Arguments:** - - * *arkode_mem* -- pointer to the MRIStep memory block. - - * *user_data* -- pointer to the user data. - - **Return value:** - - * *ARK_SUCCESS* if successful + :param arkode_mem: pointer to the MRIStep memory block. + :param user_data: pointer to the user data. - * *ARK_MEM_NULL* if the MRIStep memory is ``NULL`` + :retval ARK_SUCCESS: if successful + :retval ARK_MEM_NULL: if the MRIStep memory is ``NULL`` + :retval ARK_ILL_INPUT: if an argument has an illegal value - * *ARK_ILL_INPUT* if an argument has an illegal value + .. note:: - **Notes:** If specified, the pointer to *user_data* is passed to all - user-supplied functions called by the outer integrator for which it is an - argument; otherwise ``NULL`` is passed. + If specified, the pointer to *user_data* is passed to all + user-supplied functions called by the outer integrator for which it is an + argument; otherwise ``NULL`` is passed. - To attach a user data block to the inner integrator call the appropriate - *SetUserData* function for the inner integrator memory structure (e.g., - :c:func:`ARKStepSetUserData()` if the inner stepper is ARKStep). This pointer - may be the same as or different from the pointer attached to the outer - integrator depending on what is required by the user code. + To attach a user data block to the inner integrator call the appropriate + *SetUserData* function for the inner integrator memory structure (e.g., + :c:func:`ARKStepSetUserData()` if the inner stepper is ARKStep). This pointer + may be the same as or different from the pointer attached to the outer + integrator depending on what is required by the user code. .. deprecated:: 6.1.0 @@ -773,18 +776,12 @@ Optional inputs for MRIStep Specifies the function called *before* each inner integration. - **Arguments:** - - * *arkode_mem* -- pointer to the MRIStep memory block. + :param arkode_mem: pointer to the MRIStep memory block. + :param prefn: the name of the C function (of type :c:func:`MRIStepPreInnerFn()`) + defining pre inner integration function. - * *prefn* -- the name of the C function (of type :c:func:`MRIStepPreInnerFn()`) - defining pre inner integration function. - - **Return value:** - - * *ARK_SUCCESS* if successful - - * *ARK_MEM_NULL* if the MRIStep memory is ``NULL`` + :retval ARK_SUCCESS: if successful + :retval ARK_MEM_NULL: if the MRIStep memory is ``NULL`` @@ -792,18 +789,13 @@ Optional inputs for MRIStep Specifies the function called *after* each inner integration. - **Arguments:** - - * *arkode_mem* -- pointer to the MRIStep memory block. - - * *postfn* -- the name of the C function (of type :c:func:`MRIStepPostInnerFn()`) - defining post inner integration function. - - **Return value:** + :param arkode_mem: pointer to the MRIStep memory block. + :param postfn: the name of the C function (of type :c:func:`MRIStepPostInnerFn()`) + defining post inner integration function. - * *ARK_SUCCESS* if successful + :retval ARK_SUCCESS: if successful + :retval ARK_MEM_NULL: if the MRIStep memory is ``NULL`` - * *ARK_MEM_NULL* if the MRIStep memory is ``NULL`` @@ -818,7 +810,7 @@ Optional inputs for IVP method selection +--------------------------------+-------------------------------------+----------+ | Optional input | Function name | Default | - +--------------------------------+-------------------------------------+----------+ + +================================+=====================================+==========+ | Select the default MRI method | :c:func:`MRIStepSetOrder()` | 3 | | of a given order | | | +--------------------------------+-------------------------------------+----------+ @@ -833,17 +825,11 @@ Optional inputs for IVP method selection The default order is 3. An order less than 3 or greater than 4 will result in using the default. - **Arguments:** - - * *arkode_mem* -- pointer to the MRIStep memory block. - - * *ord* -- the method order. - - **Return value:** - - * *ARK_SUCCESS* if successful + :param arkode_mem: pointer to the MRIStep memory block. + :param ord: the method order. - * *ARK_MEM_NULL* if the MRIStep memory is ``NULL`` + :retval ARK_SUCCESS: if successful + :retval ARK_MEM_NULL: if the MRIStep memory is ``NULL`` .. deprecated:: 6.1.0 @@ -855,28 +841,21 @@ Optional inputs for IVP method selection Specifies a customized set of slow-to-fast coupling coefficients for the MRI method. - **Arguments:** - - * *arkode_mem* -- pointer to the MRIStep memory block. - - * *C* -- the table of coupling coefficients for the MRI method. - - **Return value:** - - * *ARK_SUCCESS* if successful + :param arkode_mem: pointer to the MRIStep memory block. + :param C: the table of coupling coefficients for the MRI method. - * *ARK_MEM_NULL* if the MRIStep memory is ``NULL`` + :retval ARK_SUCCESS: if successful + :retval ARK_MEM_NULL: if the MRIStep memory is ``NULL`` + :retval ARK_ILL_INPUT: if an argument has an illegal value - * *ARK_ILL_INPUT* if an argument has an illegal value - - **Notes:** + .. note:: - For a description of the :c:type:`MRIStepCoupling` type and related - functions for creating Butcher tables see :numref:`ARKODE.Usage.MRIStep.MRIStepCoupling`. + For a description of the :c:type:`MRIStepCoupling` type and related + functions for creating Butcher tables see :numref:`ARKODE.Usage.MRIStep.MRIStepCoupling`. - **Warning:** + .. warning:: - This should not be used with :c:func:`ARKodeSetOrder`. + This should not be used with :c:func:`ARKodeSetOrder`. @@ -890,28 +869,28 @@ Optional inputs for implicit stage solves Specifies that the implicit slow right-hand side function, :math:`f^I(t,y)` is linear in :math:`y`. - **Arguments:** - * *arkode_mem* -- pointer to the MRIStep memory block. - * *timedepend* -- flag denoting whether the Jacobian of - :math:`f^I(t,y)` is time-dependent (1) or not (0). - Alternately, when using a matrix-free iterative linear solver - this flag denotes time dependence of the preconditioner. + :param arkode_mem: pointer to the MRIStep memory block. + :param timedepend: flag denoting whether the Jacobian of + :math:`f^I(t,y)` is time-dependent (1) or not (0). + Alternately, when using a matrix-free iterative linear solver + this flag denotes time dependence of the preconditioner. - **Return value:** - * *ARK_SUCCESS* if successful - * *ARK_MEM_NULL* if the MRIStep memory is ``NULL`` - * *ARK_ILL_INPUT* if an argument has an illegal value + :retval ARK_SUCCESS: if successful + :retval ARK_MEM_NULL: if the MRIStep memory is ``NULL`` + :retval ARK_ILL_INPUT: if an argument has an illegal value + + .. note:: - **Notes:** Tightens the linear solver tolerances and takes only a - single Newton iteration. Calls :c:func:`MRIStepSetDeltaGammaMax()` - to enforce Jacobian recomputation when the step size ratio changes - by more than 100 times the unit roundoff (since nonlinear - convergence is not tested). Only applicable when used in - combination with the modified or inexact Newton iteration (not the - fixed-point solver). + Tightens the linear solver tolerances and takes only a + single Newton iteration. Calls :c:func:`MRIStepSetDeltaGammaMax()` + to enforce Jacobian recomputation when the step size ratio changes + by more than 100 times the unit roundoff (since nonlinear + convergence is not tested). Only applicable when used in + combination with the modified or inexact Newton iteration (not the + fixed-point solver). - The only SUNDIALS-provided SUNNonlinearSolver module that is compatible - with the :c:func:`MRIStepSetLinear()` option is the Newton solver. + The only SUNDIALS-provided SUNNonlinearSolver module that is compatible + with the :c:func:`MRIStepSetLinear()` option is the Newton solver. .. deprecated:: 6.1.0 @@ -924,19 +903,19 @@ Optional inputs for implicit stage solves Specifies that the implicit slow right-hand side function, :math:`f^I(t,y)` is nonlinear in :math:`y`. - **Arguments:** - * *arkode_mem* -- pointer to the MRIStep memory block. + :param arkode_mem: pointer to the MRIStep memory block. - **Return value:** - * *ARK_SUCCESS* if successful - * *ARK_MEM_NULL* if the MRIStep memory is ``NULL`` - * *ARK_ILL_INPUT* if an argument has an illegal value + :retval ARK_SUCCESS: if successful + :retval ARK_MEM_NULL: if the MRIStep memory is ``NULL`` + :retval ARK_ILL_INPUT: if an argument has an illegal value + + .. note:: - **Notes:** This is the default behavior of MRIStep, so the function - is primarily useful to undo a previous call to - :c:func:`MRIStepSetLinear()`. Calls - :c:func:`MRIStepSetDeltaGammaMax()` to reset the step size ratio - threshold to the default value. + This is the default behavior of MRIStep, so the function + is primarily useful to undo a previous call to + :c:func:`MRIStepSetLinear()`. Calls + :c:func:`MRIStepSetDeltaGammaMax()` to reset the step size ratio + threshold to the default value. .. deprecated:: 6.1.0 @@ -948,35 +927,37 @@ Optional inputs for implicit stage solves Specifies the method to use for predicting implicit solutions. - **Arguments:** - * *arkode_mem* -- pointer to the MRIStep memory block. - * *method* -- method choice (0 :math:`\le` *method* :math:`\le` 4): + :param arkode_mem: pointer to the MRIStep memory block. + :param method: - * 0 is the trivial predictor, + * 0 is the trivial predictor, - * 1 is the maximum order (dense output) predictor, + * 1 is the maximum order (dense output) predictor, - * 2 is the variable order predictor, that decreases the - polynomial degree for more distant RK stages, + * 2 is the variable order predictor, that decreases the + polynomial degree for more distant RK stages, - * 3 is the cutoff order predictor, that uses the maximum order - for early RK stages, and a first-order predictor for distant - RK stages, + * 3 is the cutoff order predictor, that uses the maximum order + for early RK stages, and a first-order predictor for distant + RK stages, - * 4 is the bootstrap predictor, that uses a second-order - predictor based on only information within the current step. - **deprecated** + * 4 is the bootstrap predictor, that uses a second-order + predictor based on only information within the current step. + **deprecated** - **Return value:** - * *ARK_SUCCESS* if successful - * *ARK_MEM_NULL* if the MRIStep memory is ``NULL`` - * *ARK_ILL_INPUT* if an argument has an illegal value + :retval ARK_SUCCESS: if successful + :retval ARK_MEM_NULL: if the MRIStep memory is ``NULL`` + :retval ARK_ILL_INPUT: if an argument has an illegal value + + .. note:: + + The default value is 0. If *method* is set to an + undefined value, this default predictor will be used. - **Notes:** The default value is 0. If *method* is set to an - undefined value, this default predictor will be used. + .. warning:: - **The "bootstrap" predictor (option 4 above) has been deprecated, and - will be removed from a future release.** + The "bootstrap" predictor (option 4 above) has been deprecated, and + will be removed from a future release. .. deprecated:: 6.1.0 @@ -989,18 +970,17 @@ Optional inputs for implicit stage solves Specifies the maximum number of nonlinear solver iterations permitted per slow MRI stage within each time step. - **Arguments:** - * *arkode_mem* -- pointer to the MRIStep memory block. - * *maxcor* -- maximum allowed solver iterations per stage :math:`(>0)`. + :param arkode_mem: pointer to the MRIStep memory block. + :param maxcor: maximum allowed solver iterations per stage :math:`(>0)`. - **Return value:** - * *ARK_SUCCESS* if successful - * *ARK_MEM_NULL* if the MRIStep memory is ``NULL`` - * *ARK_ILL_INPUT* if an argument has an illegal value or if the SUNNONLINSOL module is ``NULL`` - * *ARK_NLS_OP_ERR* if the SUNNONLINSOL object returned a failure flag + :retval ARK_SUCCESS: if successful + :retval ARK_MEM_NULL: if the MRIStep memory is ``NULL`` + :retval ARK_ILL_INPUT: if an argument has an illegal value or if the SUNNONLINSOL module is ``NULL`` + :retval ARK_NLS_OP_ERR: if the SUNNONLINSOL object returned a failure flag + + .. note:: - **Notes:** The default value is 3; set *maxcor* :math:`\le 0` - to specify this default. + The default value is 3; set *maxcor* :math:`\le 0` to specify this default. .. deprecated:: 6.1.0 @@ -1012,17 +992,16 @@ Optional inputs for implicit stage solves Specifies the safety factor used within the nonlinear solver convergence test. - **Arguments:** - * *arkode_mem* -- pointer to the MRIStep memory block. - * *nlscoef* -- coefficient in nonlinear solver convergence test :math:`(>0.0)`. + :param arkode_mem: pointer to the MRIStep memory block. + :param nlscoef: coefficient in nonlinear solver convergence test :math:`(>0.0)`. - **Return value:** - * *ARK_SUCCESS* if successful - * *ARK_MEM_NULL* if the MRIStep memory is ``NULL`` - * *ARK_ILL_INPUT* if an argument has an illegal value + :retval ARK_SUCCESS: if successful + :retval ARK_MEM_NULL: if the MRIStep memory is ``NULL`` + :retval ARK_ILL_INPUT: if an argument has an illegal value + + .. note:: - **Notes:** The default value is 0.1; set *nlscoef* :math:`\le 0` - to specify this default. + The default value is 0.1; set *nlscoef* :math:`\le 0` to specify this default. .. deprecated:: 6.1.0 @@ -1034,16 +1013,16 @@ Optional inputs for implicit stage solves Specifies the constant used in estimating the nonlinear solver convergence rate. - **Arguments:** - * *arkode_mem* -- pointer to the MRIStep memory block. - * *crdown* -- nonlinear convergence rate estimation constant (default is 0.3). + :param arkode_mem: pointer to the MRIStep memory block. + :param crdown: nonlinear convergence rate estimation constant (default is 0.3). - **Return value:** - * *ARK_SUCCESS* if successful - * *ARK_MEM_NULL* if the MRIStep memory is ``NULL`` - * *ARK_ILL_INPUT* if an argument has an illegal value + :retval ARK_SUCCESS: if successful + :retval ARK_MEM_NULL: if the MRIStep memory is ``NULL`` + :retval ARK_ILL_INPUT: if an argument has an illegal value + + .. note:: - **Notes:** Any non-positive parameter will imply a reset to the default value. + Any non-positive parameter will imply a reset to the default value. .. deprecated:: 6.1.0 @@ -1056,17 +1035,17 @@ Optional inputs for implicit stage solves Specifies the nonlinear correction threshold beyond which the iteration will be declared divergent. - **Arguments:** - * *arkode_mem* -- pointer to the MRIStep memory block. - * *rdiv* -- tolerance on nonlinear correction size ratio to - declare divergence (default is 2.3). + :param arkode_mem: pointer to the MRIStep memory block. + :param rdiv: tolerance on nonlinear correction size ratio to + declare divergence (default is 2.3). - **Return value:** - * *ARK_SUCCESS* if successful - * *ARK_MEM_NULL* if the MRIStep memory is ``NULL`` - * *ARK_ILL_INPUT* if an argument has an illegal value + :retval ARK_SUCCESS: if successful + :retval ARK_MEM_NULL: if the MRIStep memory is ``NULL`` + :retval ARK_ILL_INPUT: if an argument has an illegal value + + .. note:: - **Notes:** Any non-positive parameter will imply a reset to the default value. + Any non-positive parameter will imply a reset to the default value. .. deprecated:: 6.1.0 @@ -1079,17 +1058,17 @@ Optional inputs for implicit stage solves Sets the user-supplied function to update the implicit stage predictor prior to execution of the nonlinear or linear solver algorithms that compute the implicit stage solution. - **Arguments:** - * *arkode_mem* -- pointer to the MRIStep memory block. - * *PredictStage* -- name of user-supplied predictor function. If ``NULL``, then any - previously-provided stage prediction function will be disabled. + :param arkode_mem: pointer to the MRIStep memory block. + :param PredictStage: name of user-supplied predictor function. If ``NULL``, then any + previously-provided stage prediction function will be disabled. - **Return value:** - * *ARK_SUCCESS* if successful - * *ARK_MEM_NULL* if the MRIStep memory is ``NULL`` + :retval ARK_SUCCESS: if successful + :retval ARK_MEM_NULL: if the MRIStep memory is ``NULL`` + + .. note:: - **Notes:** See :numref:`ARKODE.Usage.StagePredictFn` for more information on - this user-supplied routine. + See :numref:`ARKODE.Usage.StagePredictFn` for more information on + this user-supplied routine. .. deprecated:: 6.1.0 @@ -1102,22 +1081,22 @@ Optional inputs for implicit stage solves Specifies an alternative implicit slow right-hand side function for evaluating :math:`f^I(t,y)` within nonlinear system function evaluations. - **Arguments:** - * *arkode_mem* -- pointer to the MRIStep memory block. - * *nls_fs* -- the alternative C function for computing the right-hand side - function :math:`f^I(t,y)` in the ODE. + :param arkode_mem: pointer to the MRIStep memory block. + :param nls_fs: the alternative C function for computing the right-hand side + function :math:`f^I(t,y)` in the ODE. - **Return value:** - * *ARK_SUCCESS* if successful. - * *ARK_MEM_NULL* if the MRIStep memory was ``NULL``. + :retval ARK_SUCCESS: if successful. + :retval ARK_MEM_NULL: if the MRIStep memory was ``NULL``. + + .. note:: - **Notes:** The default is to use the implicit slow right-hand side function - provided to :c:func:`MRIStepCreate()` in nonlinear system functions. If the - input implicit slow right-hand side function is ``NULL``, the default is - used. + The default is to use the implicit slow right-hand side function + provided to :c:func:`MRIStepCreate()` in nonlinear system functions. If the + input implicit slow right-hand side function is ``NULL``, the default is + used. - When using a non-default nonlinear solver, this function must be called - *after* :c:func:`MRIStepSetNonlinearSolver()`. + When using a non-default nonlinear solver, this function must be called + *after* :c:func:`MRIStepSetNonlinearSolver()`. .. deprecated:: 6.1.0 @@ -1130,16 +1109,14 @@ Optional inputs for implicit stage solves Specifies if implicit stage derivatives are deduced without evaluating :math:`f^I`. See :numref:`ARKODE.Mathematics.Nonlinear` for more details. - **Arguments:** - * *arkode_mem* -- pointer to the MRIStep memory block. - * *deduce* -- If ``SUNFALSE`` (default), the stage derivative is obtained - by evaluating :math:`f^I` with the stage solution returned from the - nonlinear solver. If ``SUNTRUE``, the stage derivative is deduced - without an additional evaluation of :math:`f^I`. + :param arkode_mem: pointer to the MRIStep memory block. + :param deduce: If ``SUNFALSE`` (default), the stage derivative is obtained + by evaluating :math:`f^I` with the stage solution returned from the + nonlinear solver. If ``SUNTRUE``, the stage derivative is deduced + without an additional evaluation of :math:`f^I`. - **Return value:** - * *ARK_SUCCESS* if successful - * *ARK_MEM_NULL* if the MRIStep memory is ``NULL`` + :retval ARK_SUCCESS: if successful + :retval ARK_MEM_NULL: if the MRIStep memory is ``NULL`` .. versionadded:: 5.2.0 @@ -1165,17 +1142,17 @@ Optional inputs for the ARKLS linear solver interface Specifies a scaled step size ratio tolerance, beyond which the linear solver setup routine will be signaled. - **Arguments:** - * *arkode_mem* -- pointer to the MRIStep memory block. - * *dgmax* -- tolerance on step size ratio change before calling - linear solver setup routine (default is 0.2). + :param arkode_mem: pointer to the MRIStep memory block. + :param dgmax: tolerance on step size ratio change before calling + linear solver setup routine (default is 0.2). - **Return value:** - * *ARK_SUCCESS* if successful - * *ARK_MEM_NULL* if the MRIStep memory is ``NULL`` - * *ARK_ILL_INPUT* if an argument has an illegal value + :retval ARK_SUCCESS: if successful + :retval ARK_MEM_NULL: if the MRIStep memory is ``NULL`` + :retval ARK_ILL_INPUT: if an argument has an illegal value - **Notes:** Any non-positive parameter will imply a reset to the default value. + .. note:: + + Any non-positive parameter will imply a reset to the default value. .. deprecated:: 6.1.0 @@ -1188,20 +1165,19 @@ Optional inputs for the ARKLS linear solver interface Specifies the frequency of calls to the linear solver setup routine. - **Arguments:** - * *arkode_mem* -- pointer to the MRIStep memory block. - * *msbp* -- the linear solver setup frequency. + :param arkode_mem: pointer to the MRIStep memory block. + :param msbp: the linear solver setup frequency. - **Return value:** - * *ARK_SUCCESS* if successful - * *ARK_MEM_NULL* if the MRIStep memory is ``NULL`` + :retval ARK_SUCCESS: if successful + :retval ARK_MEM_NULL: if the MRIStep memory is ``NULL`` + + .. note:: - **Notes:** - Positive values of **msbp** specify the linear solver setup frequency. For - example, an input of 1 means the setup function will be called every time - step while an input of 2 means it will be called called every other time - step. If **msbp** is 0, the default value of 20 will be used. A negative - value forces a linear solver step at each implicit stage. + Positive values of **msbp** specify the linear solver setup frequency. For + example, an input of 1 means the setup function will be called every time + step while an input of 2 means it will be called called every other time + step. If **msbp** is 0, the default value of 20 will be used. A negative + value forces a linear solver step at each implicit stage. .. deprecated:: 6.1.0 @@ -1214,27 +1190,26 @@ Optional inputs for the ARKLS linear solver interface Specifies the frequency for recomputing the Jacobian or recommending a preconditioner update. - **Arguments:** - * *arkode_mem* -- pointer to the MRIStep memory block. - * *msbj* -- the Jacobian re-computation or preconditioner update frequency. + :param arkode_mem: pointer to the MRIStep memory block. + :param msbj: the Jacobian re-computation or preconditioner update frequency. - **Return value:** - * *ARKLS_SUCCESS* if successful. - * *ARKLS_MEM_NULL* if the MRIStep memory was ``NULL``. - * *ARKLS_LMEM_NULL* if the linear solver memory was ``NULL``. + :retval ARKLS_SUCCESS: if successful. + :retval ARKLS_MEM_NULL: if the MRIStep memory was ``NULL``. + :retval ARKLS_LMEM_NULL: if the linear solver memory was ``NULL``. + + .. note:: - **Notes:** - The Jacobian update frequency is only checked *within* calls to the linear - solver setup routine, as such values of *msbj* :math:`<` *msbp* will result - in recomputing the Jacobian every *msbp* steps. See - :c:func:`MRIStepSetLSetupFrequency()` for setting the linear solver setup - frequency *msbp*. + The Jacobian update frequency is only checked *within* calls to the linear + solver setup routine, as such values of *msbj* :math:`<` *msbp* will result + in recomputing the Jacobian every *msbp* steps. See + :c:func:`MRIStepSetLSetupFrequency()` for setting the linear solver setup + frequency *msbp*. - Passing a value *msbj* :math:`\le 0` indicates to use the - default value of 50. + Passing a value *msbj* :math:`\le 0` indicates to use the + default value of 50. - This function must be called *after* the ARKLS system solver interface has - been initialized through a call to :c:func:`MRIStepSetLinearSolver()`. + This function must be called *after* the ARKLS system solver interface has + been initialized through a call to :c:func:`MRIStepSetLinearSolver()`. .. deprecated:: 6.1.0 @@ -1253,26 +1228,26 @@ Optional inputs for matrix-based ``SUNLinearSolver`` modules Specifies the Jacobian approximation routine to be used for the matrix-based solver with the ARKLS interface. - **Arguments:** - * *arkode_mem* -- pointer to the MRIStep memory block. - * *jac* -- name of user-supplied Jacobian approximation function. + :param arkode_mem: pointer to the MRIStep memory block. + :param jac: name of user-supplied Jacobian approximation function. - **Return value:** - * *ARKLS_SUCCESS* if successful - * *ARKLS_MEM_NULL* if the MRIStep memory was ``NULL`` - * *ARKLS_LMEM_NULL* if the linear solver memory was ``NULL`` + :retval ARKLS_SUCCESS: if successful + :retval ARKLS_MEM_NULL: if the MRIStep memory was ``NULL`` + :retval ARKLS_LMEM_NULL: if the linear solver memory was ``NULL`` - **Notes:** This routine must be called after the ARKLS linear - solver interface has been initialized through a call to - :c:func:`MRIStepSetLinearSolver()`. + .. note:: + + This routine must be called after the ARKLS linear + solver interface has been initialized through a call to + :c:func:`MRIStepSetLinearSolver()`. - By default, ARKLS uses an internal difference quotient function for - dense and band matrices. If ``NULL`` is passed in for *jac*, this - default is used. An error will occur if no *jac* is supplied when - using other matrix types. + By default, ARKLS uses an internal difference quotient function for + dense and band matrices. If ``NULL`` is passed in for *jac*, this + default is used. An error will occur if no *jac* is supplied when + using other matrix types. - The function type :c:func:`ARKLsJacFn()` is described in - :numref:`ARKODE.Usage.UserSupplied`. + The function type :c:func:`ARKLsJacFn()` is described in + :numref:`ARKODE.Usage.UserSupplied`. .. deprecated:: 6.1.0 @@ -1285,25 +1260,25 @@ Optional inputs for matrix-based ``SUNLinearSolver`` modules Specifies the linear system approximation routine to be used for the matrix-based solver with the ARKLS interface. - **Arguments:** - * *arkode_mem* -- pointer to the MRIStep memory block. - * *linsys* -- name of user-supplied linear system approximation function. + :param arkode_mem: pointer to the MRIStep memory block. + :param linsys: name of user-supplied linear system approximation function. - **Return value:** - * *ARKLS_SUCCESS* if successful - * *ARKLS_MEM_NULL* if the MRIStep memory was ``NULL`` - * *ARKLS_LMEM_NULL* if the linear solver memory was ``NULL`` + :retval ARKLS_SUCCESS: if successful + :retval ARKLS_MEM_NULL: if the MRIStep memory was ``NULL`` + :retval ARKLS_LMEM_NULL: if the linear solver memory was ``NULL`` + + .. note:: - **Notes:** This routine must be called after the ARKLS linear - solver interface has been initialized through a call to - :c:func:`MRIStepSetLinearSolver()`. + This routine must be called after the ARKLS linear + solver interface has been initialized through a call to + :c:func:`MRIStepSetLinearSolver()`. - By default, ARKLS uses an internal linear system function that leverages the - SUNMATRIX API to form the system :math:`I - \gamma J`. If ``NULL`` is passed - in for *linsys*, this default is used. + By default, ARKLS uses an internal linear system function that leverages the + SUNMATRIX API to form the system :math:`I - \gamma J`. If ``NULL`` is passed + in for *linsys*, this default is used. - The function type :c:func:`ARKLsLinSysFn()` is described in - :numref:`ARKODE.Usage.UserSupplied`. + The function type :c:func:`ARKLsLinSysFn()` is described in + :numref:`ARKODE.Usage.UserSupplied`. .. deprecated:: 6.1.0 @@ -1317,18 +1292,18 @@ Optional inputs for matrix-based ``SUNLinearSolver`` modules change in :math:`\gamma` in the linear system. For more details see :numref:`SUNLinSol.Lagged_matrix`. - **Arguments:** - * *arkode_mem* -- pointer to the MRIStep memory block. - * *onoff* -- flag to enable (``SUNTRUE``) or disable (``SUNFALSE``) - scaling + :param arkode_mem: pointer to the MRIStep memory block. + :param onoff: flag to enable (``SUNTRUE``) or disable (``SUNFALSE``) + scaling - **Return value:** - * *ARKLS_SUCCESS* if successful - * *ARKLS_MEM_NULL* if the MRIStep memory was ``NULL`` - * *ARKLS_ILL_INPUT* if the attached linear solver is not matrix-based + :retval ARKLS_SUCCESS: if successful + :retval ARKLS_MEM_NULL: if the MRIStep memory was ``NULL`` + :retval ARKLS_ILL_INPUT: if the attached linear solver is not matrix-based + + .. note:: - **Notes:** Linear solution scaling is enabled by default when a matrix-based - linear solver is attached. + Linear solution scaling is enabled by default when a matrix-based + linear solver is attached. .. deprecated:: 6.1.0 @@ -1345,33 +1320,33 @@ Optional inputs for matrix-free ``SUNLinearSolver`` modules Specifies the Jacobian-times-vector setup and product functions. - **Arguments:** - * *arkode_mem* -- pointer to the MRIStep memory block. - * *jtsetup* -- user-defined Jacobian-vector setup function. - Pass ``NULL`` if no setup is necessary. - * *jtimes* -- user-defined Jacobian-vector product function. + :param arkode_mem: pointer to the MRIStep memory block. + :param jtsetup: user-defined Jacobian-vector setup function. + Pass ``NULL`` if no setup is necessary. + :param jtimes: user-defined Jacobian-vector product function. - **Return value:** - * *ARKLS_SUCCESS* if successful. - * *ARKLS_MEM_NULL* if the MRIStep memory was ``NULL``. - * *ARKLS_LMEM_NULL* if the linear solver memory was ``NULL``. - * *ARKLS_ILL_INPUT* if an input has an illegal value. - * *ARKLS_SUNLS_FAIL* if an error occurred when setting up - the Jacobian-vector product in the ``SUNLinearSolver`` - object used by the ARKLS interface. + :retval ARKLS_SUCCESS: if successful. + :retval ARKLS_MEM_NULL: if the MRIStep memory was ``NULL``. + :retval ARKLS_LMEM_NULL: if the linear solver memory was ``NULL``. + :retval ARKLS_ILL_INPUT: if an input has an illegal value. + :retval ARKLS_SUNLS_FAIL: if an error occurred when setting up + the Jacobian-vector product in the ``SUNLinearSolver`` + object used by the ARKLS interface. + + .. note:: - **Notes:** The default is to use an internal finite difference - quotient for *jtimes* and to leave out *jtsetup*. If ``NULL`` is - passed to *jtimes*, these defaults are used. A user may - specify non-``NULL`` *jtimes* and ``NULL`` *jtsetup* inputs. + The default is to use an internal finite difference + quotient for *jtimes* and to leave out *jtsetup*. If ``NULL`` is + passed to *jtimes*, these defaults are used. A user may + specify non-``NULL`` *jtimes* and ``NULL`` *jtsetup* inputs. - This function must be called *after* the ARKLS system solver - interface has been initialized through a call to - :c:func:`MRIStepSetLinearSolver()`. + This function must be called *after* the ARKLS system solver + interface has been initialized through a call to + :c:func:`MRIStepSetLinearSolver()`. - The function types :c:type:`ARKLsJacTimesSetupFn` and - :c:type:`ARKLsJacTimesVecFn` are described in - :numref:`ARKODE.Usage.UserSupplied`. + The function types :c:type:`ARKLsJacTimesSetupFn` and + :c:type:`ARKLsJacTimesVecFn` are described in + :numref:`ARKODE.Usage.UserSupplied`. .. deprecated:: 6.1.0 @@ -1383,23 +1358,23 @@ Optional inputs for matrix-free ``SUNLinearSolver`` modules Specifies an alternative implicit right-hand side function for use in the internal Jacobian-vector product difference quotient approximation. - **Arguments:** - * *arkode_mem* -- pointer to the MRIStep memory block. - * *jtimesRhsFn* -- the name of the C function (of type - :c:func:`ARKRhsFn()`) defining the alternative right-hand side function. + :param arkode_mem: pointer to the MRIStep memory block. + :param jtimesRhsFn: the name of the C function defining the alternative + right-hand side function. - **Return value:** - * *ARKLS_SUCCESS* if successful. - * *ARKLS_MEM_NULL* if the MRIStep memory was ``NULL``. - * *ARKLS_LMEM_NULL* if the linear solver memory was ``NULL``. - * *ARKLS_ILL_INPUT* if an input has an illegal value. + :retval ARKLS_SUCCESS: if successful. + :retval ARKLS_MEM_NULL: if the MRIStep memory was ``NULL``. + :retval ARKLS_LMEM_NULL: if the linear solver memory was ``NULL``. + :retval ARKLS_ILL_INPUT: if an input has an illegal value. - **Notes:** The default is to use the implicit right-hand side function - provided to :c:func:`MRIStepCreate()` in the internal difference quotient. If - the input implicit right-hand side function is ``NULL``, the default is used. + .. note:: + + The default is to use the implicit right-hand side function provided + to :c:func:`MRIStepCreate()` in the internal difference quotient. If + the input implicit right-hand side function is ``NULL``, the default is used. - This function must be called *after* the ARKLS system solver interface has - been initialized through a call to :c:func:`MRIStepSetLinearSolver()`. + This function must be called *after* the ARKLS system solver interface has + been initialized through a call to :c:func:`MRIStepSetLinearSolver()`. .. deprecated:: 6.1.0 @@ -1418,31 +1393,31 @@ Optional inputs for iterative ``SUNLinearSolver`` modules Specifies the user-supplied preconditioner setup and solve functions. - **Arguments:** - * *arkode_mem* -- pointer to the MRIStep memory block. - * *psetup* -- user defined preconditioner setup function. Pass - ``NULL`` if no setup is needed. - * *psolve* -- user-defined preconditioner solve function. + :param arkode_mem: pointer to the MRIStep memory block. + :param psetup: user defined preconditioner setup function. Pass + ``NULL`` if no setup is needed. + :param psolve: user-defined preconditioner solve function. - **Return value:** - * *ARKLS_SUCCESS* if successful. - * *ARKLS_MEM_NULL* if the MRIStep memory was ``NULL``. - * *ARKLS_LMEM_NULL* if the linear solver memory was ``NULL``. - * *ARKLS_ILL_INPUT* if an input has an illegal value. - * *ARKLS_SUNLS_FAIL* if an error occurred when setting up - preconditioning in the ``SUNLinearSolver`` object used - by the ARKLS interface. + :retval ARKLS_SUCCESS: if successful. + :retval ARKLS_MEM_NULL: if the MRIStep memory was ``NULL``. + :retval ARKLS_LMEM_NULL: if the linear solver memory was ``NULL``. + :retval ARKLS_ILL_INPUT: if an input has an illegal value. + :retval ARKLS_SUNLS_FAIL: if an error occurred when setting up + preconditioning in the ``SUNLinearSolver`` object used + by the ARKLS interface. + + .. note:: - **Notes:** The default is ``NULL`` for both arguments (i.e., no - preconditioning). + The default is ``NULL`` for both arguments (i.e., no + preconditioning). - This function must be called *after* the ARKLS system solver - interface has been initialized through a call to - :c:func:`MRIStepSetLinearSolver()`. + This function must be called *after* the ARKLS system solver + interface has been initialized through a call to + :c:func:`MRIStepSetLinearSolver()`. - Both of the function types :c:func:`ARKLsPrecSetupFn()` and - :c:func:`ARKLsPrecSolveFn()` are described in - :numref:`ARKODE.Usage.UserSupplied`. + Both of the function types :c:func:`ARKLsPrecSetupFn()` and + :c:func:`ARKLsPrecSolveFn()` are described in + :numref:`ARKODE.Usage.UserSupplied`. .. deprecated:: 6.1.0 @@ -1456,22 +1431,22 @@ Optional inputs for iterative ``SUNLinearSolver`` modules iteration is multiplied to get a tolerance on the linear iteration. - **Arguments:** - * *arkode_mem* -- pointer to the MRIStep memory block. - * *eplifac* -- linear convergence safety factor. + :param arkode_mem: pointer to the MRIStep memory block. + :param eplifac: linear convergence safety factor. - **Return value:** - * *ARKLS_SUCCESS* if successful. - * *ARKLS_MEM_NULL* if the MRIStep memory was ``NULL``. - * *ARKLS_LMEM_NULL* if the linear solver memory was ``NULL``. - * *ARKLS_ILL_INPUT* if an input has an illegal value. + :retval ARKLS_SUCCESS: if successful. + :retval ARKLS_MEM_NULL: if the MRIStep memory was ``NULL``. + :retval ARKLS_LMEM_NULL: if the linear solver memory was ``NULL``. + :retval ARKLS_ILL_INPUT: if an input has an illegal value. + + .. note:: - **Notes:** Passing a value *eplifac* :math:`\le 0` indicates to use the - default value of 0.05. + Passing a value *eplifac* :math:`\le 0` indicates to use the + default value of 0.05. - This function must be called *after* the ARKLS system solver - interface has been initialized through a call to - :c:func:`MRIStepSetLinearSolver()`. + This function must be called *after* the ARKLS system solver + interface has been initialized through a call to + :c:func:`MRIStepSetLinearSolver()`. .. deprecated:: 6.1.0 @@ -1485,26 +1460,25 @@ Optional inputs for iterative ``SUNLinearSolver`` modules (WRMS norm) to the linear solver tolerance (L2 norm) for Newton linear system solves e.g., ``tol_L2 = fac * tol_WRMS``. - **Arguments:** - * *arkode_mem* -- pointer to the MRIStep memory block. - * *nrmfac* -- the norm conversion factor. If *nrmfac* is: + :param arkode_mem: pointer to the MRIStep memory block. + :param nrmfac: the norm conversion factor. If *nrmfac* is: - :math:`> 0` then the provided value is used. + :math:`> 0` then the provided value is used. - :math:`= 0` then the conversion factor is computed using the vector - length i.e., ``nrmfac = sqrt(N_VGetLength(y))`` (*default*). + :math:`= 0` then the conversion factor is computed using the vector + length i.e., ``nrmfac = sqrt(N_VGetLength(y))`` (*default*). - :math:`< 0` then the conversion factor is computed using the vector dot - product i.e., ``nrmfac = sqrt(N_VDotProd(v,v))`` where all the entries - of ``v`` are one. + :math:`< 0` then the conversion factor is computed using the vector dot + product i.e., ``nrmfac = sqrt(N_VDotProd(v,v))`` where all the entries + of ``v`` are one. - **Return value:** - * *ARK_SUCCESS* if successful. - * *ARK_MEM_NULL* if the MRIStep memory was ``NULL``. + :retval ARK_SUCCESS: if successful. + :retval ARK_MEM_NULL: if the MRIStep memory was ``NULL``. + + .. note:: - **Notes:** - This function must be called *after* the ARKLS system solver interface has - been initialized through a call to :c:func:`MRIStepSetLinearSolver()`. + This function must be called *after* the ARKLS system solver interface has + been initialized through a call to :c:func:`MRIStepSetLinearSolver()`. .. deprecated:: 6.1.0 @@ -1521,22 +1495,22 @@ Rootfinding optional input functions Specifies the direction of zero-crossings to be located and returned. - **Arguments:** - * *arkode_mem* -- pointer to the MRIStep memory block. - * *rootdir* -- state array of length *nrtfn*, the number of root - functions :math:`g_i` (the value of *nrtfn* was supplied in - the call to :c:func:`MRIStepRootInit()`). If ``rootdir[i] == - 0`` then crossing in either direction for :math:`g_i` should be - reported. A value of +1 or -1 indicates that the solver - should report only zero-crossings where :math:`g_i` is - increasing or decreasing, respectively. + :param arkode_mem: pointer to the MRIStep memory block. + :param rootdir: state array of length *nrtfn*, the number of root + functions :math:`g_i` (the value of *nrtfn* was supplied in + the call to :c:func:`MRIStepRootInit()`). If + ``rootdir[i] == 0`` then crossing in either direction for + :math:`g_i` should be reported. A value of +1 or -1 indicates + that the solver should report only zero-crossings where + :math:`g_i` is increasing or decreasing, respectively. - **Return value:** - * *ARK_SUCCESS* if successful - * *ARK_MEM_NULL* if the MRIStep memory is ``NULL`` - * *ARK_ILL_INPUT* if an argument has an illegal value + :retval ARK_SUCCESS: if successful + :retval ARK_MEM_NULL: if the MRIStep memory is ``NULL`` + :retval ARK_ILL_INPUT: if an argument has an illegal value + + .. note:: - **Notes:** The default behavior is to monitor for both zero-crossing directions. + The default behavior is to monitor for both zero-crossing directions. .. deprecated:: 6.1.0 @@ -1549,20 +1523,20 @@ Rootfinding optional input functions Disables issuing a warning if some root function appears to be identically zero at the beginning of the integration. - **Arguments:** - * *arkode_mem* -- pointer to the MRIStep memory block. + :param arkode_mem: pointer to the MRIStep memory block. - **Return value:** - * *ARK_SUCCESS* if successful - * *ARK_MEM_NULL* if the MRIStep memory is ``NULL`` + :retval ARK_SUCCESS: if successful + :retval ARK_MEM_NULL: if the MRIStep memory is ``NULL`` - **Notes:** MRIStep will not report the initial conditions as a - possible zero-crossing (assuming that one or more components - :math:`g_i` are zero at the initial time). However, if it appears - that some :math:`g_i` is identically zero at the initial time - (i.e., :math:`g_i` is zero at the initial time *and* after the - first step), MRIStep will issue a warning which can be disabled with - this optional input function. + .. note:: + + MRIStep will not report the initial conditions as a + possible zero-crossing (assuming that one or more components + :math:`g_i` are zero at the initial time). However, if it appears + that some :math:`g_i` is identically zero at the initial time + (i.e., :math:`g_i` is zero at the initial time *and* after the + first step), MRIStep will issue a warning which can be disabled with + this optional input function. .. deprecated:: 6.1.0 @@ -1590,35 +1564,26 @@ Interpolated output function interpolation module. For Hermite interpolants *kmax = 5* and for Lagrange interpolants *kmax = 3*. - **Arguments:** - - * *arkode_mem* -- pointer to the MRIStep memory block. - - * *t* -- the value of the independent variable at which the - derivative is to be evaluated. + :param arkode_mem: pointer to the MRIStep memory block. + :param t: the value of the independent variable at which the + derivative is to be evaluated. + :param k: the derivative order requested. + :param dky: output vector (must be allocated by the user). - * *k* -- the derivative order requested. + :retval ARK_SUCCESS: if successful + :retval ARK_BAD_K: if *k* is not in the range {0,..., *min(degree, kmax)*}. + :retval ARK_BAD_T: if *t* is not in the interval :math:`[t_n-h_n, t_n]` + :retval ARK_BAD_DKY: if the *dky* vector was ``NULL`` + :retval ARK_MEM_NULL: if the MRIStep memory is ``NULL`` - * *dky* -- output vector (must be allocated by the user). - - **Return value:** - - * *ARK_SUCCESS* if successful - - * *ARK_BAD_K* if *k* is not in the range {0,..., *min(degree, kmax)*}. - - * *ARK_BAD_T* if *t* is not in the interval :math:`[t_n-h_n, t_n]` - - * *ARK_BAD_DKY* if the *dky* vector was ``NULL`` - - * *ARK_MEM_NULL* if the MRIStep memory is ``NULL`` + .. note:: - **Notes:** It is only legal to call this function after a successful - return from :c:func:`MRIStepEvolve()`. + It is only legal to call this function after a successful + return from :c:func:`MRIStepEvolve()`. - A user may access the values :math:`t_n` and :math:`h_n` via the - functions :c:func:`MRIStepGetCurrentTime()` and - :c:func:`MRIStepGetLastStep()`, respectively. + A user may access the values :math:`t_n` and :math:`h_n` via the + functions :c:func:`MRIStepGetCurrentTime()` and + :c:func:`MRIStepGetLastStep()`, respectively. .. deprecated:: 6.1.0 @@ -1642,19 +1607,12 @@ Main solver optional output functions Returns the MRIStep real and integer workspace sizes. - **Arguments:** - - * *arkode_mem* -- pointer to the MRIStep memory block. - - * *lenrw* -- the number of ``sunrealtype`` values in the MRIStep workspace. - - * *leniw* -- the number of integer values in the MRIStep workspace. - - **Return value:** - - * *ARK_SUCCESS* if successful + :param arkode_mem: pointer to the MRIStep memory block. + :param lenrw: the number of ``realtype`` values in the MRIStep workspace. + :param leniw: the number of integer values in the MRIStep workspace. - * *ARK_MEM_NULL* if the MRIStep memory was ``NULL`` + :retval ARK_SUCCESS: if successful + :retval ARK_MEM_NULL: if the MRIStep memory was ``NULL`` .. deprecated:: 6.1.0 @@ -1667,19 +1625,12 @@ Main solver optional output functions Returns the cumulative number of slow and fast internal steps taken by the solver (so far). - **Arguments:** - - * *arkode_mem* -- pointer to the MRIStep memory block. + :param arkode_mem: pointer to the MRIStep memory block. + :param nssteps: number of slow steps taken in the solver. + :param nfsteps: number of fast steps taken in the solver. - * *nssteps* -- number of slow steps taken in the solver. - - * *nfsteps* -- number of fast steps taken in the solver. - - **Return value:** - - * *ARK_SUCCESS* if successful - - * *ARK_MEM_NULL* if the MRIStep memory was ``NULL`` + :retval ARK_SUCCESS: if successful + :retval ARK_MEM_NULL: if the MRIStep memory was ``NULL`` .. deprecated:: 6.1.0 @@ -1692,17 +1643,11 @@ Main solver optional output functions Returns the integration step size taken on the last successful internal step. - **Arguments:** - - * *arkode_mem* -- pointer to the MRIStep memory block. - - * *hlast* -- step size taken on the last internal step. - - **Return value:** - - * *ARK_SUCCESS* if successful + :param arkode_mem: pointer to the MRIStep memory block. + :param hlast: step size taken on the last internal step. - * *ARK_MEM_NULL* if the MRIStep memory was ``NULL`` + :retval ARK_SUCCESS: if successful + :retval ARK_MEM_NULL: if the MRIStep memory was ``NULL`` .. deprecated:: 6.1.0 @@ -1714,17 +1659,11 @@ Main solver optional output functions Returns the current internal time reached by the solver. - **Arguments:** - - * *arkode_mem* -- pointer to the MRIStep memory block. - - * *tcur* -- current internal time reached. - - **Return value:** + :param arkode_mem: pointer to the MRIStep memory block. + :param tcur: current internal time reached. - * *ARK_SUCCESS* if successful - - * *ARK_MEM_NULL* if the MRIStep memory was ``NULL`` + :retval ARK_SUCCESS: if successful + :retval ARK_MEM_NULL: if the MRIStep memory was ``NULL`` .. deprecated:: 6.1.0 @@ -1735,21 +1674,17 @@ Main solver optional output functions Returns the current internal solution reached by the solver. - **Arguments:** - - * *arkode_mem* -- pointer to the MRIStep memory block. - - * *ycur* -- current internal solution. + :param arkode_mem: pointer to the MRIStep memory block. + :param ycur: current internal solution. - **Return value:** - - * *ARK_SUCCESS* if successful + :retval ARK_SUCCESS: if successful + :retval ARK_MEM_NULL: if the MRIStep memory was ``NULL`` - * *ARK_MEM_NULL* if the MRIStep memory was ``NULL`` + .. note:: - **Notes:** Users should exercise extreme caution when using this function, - as altering values of *ycur* may lead to undesirable behavior, depending - on the particular use case and on when this routine is called. + Users should exercise extreme caution when using this function, + as altering values of *ycur* may lead to undesirable behavior, depending + on the particular use case and on when this routine is called. .. deprecated:: 6.1.0 @@ -1761,17 +1696,11 @@ Main solver optional output functions Returns the current internal value of :math:`\gamma` used in the implicit solver Newton matrix (see equation :eq:`ARKODE_NewtonMatrix`). - **Arguments:** - - * *arkode_mem* -- pointer to the MRIStep memory block. - - * *gamma* -- current step size scaling factor in the Newton system. - - **Return value:** - - * *ARK_SUCCESS* if successful + :param arkode_mem: pointer to the MRIStep memory block. + :param gamma: current step size scaling factor in the Newton system. - * *ARK_MEM_NULL* if the MRIStep memory was ``NULL`` + :retval ARK_SUCCESS: if successful + :retval ARK_MEM_NULL: if the MRIStep memory was ``NULL`` .. deprecated:: 6.1.0 @@ -1784,17 +1713,11 @@ Main solver optional output functions tolerances should be scaled when too much accuracy has been requested for some internal step. - **Arguments:** - - * *arkode_mem* -- pointer to the MRIStep memory block. - - * *tolsfac* -- suggested scaling factor for user-supplied tolerances. - - **Return value:** + :param arkode_mem: pointer to the MRIStep memory block. + :param tolsfac: suggested scaling factor for user-supplied tolerances. - * *ARK_SUCCESS* if successful - - * *ARK_MEM_NULL* if the MRIStep memory was ``NULL`` + :retval ARK_SUCCESS: if successful + :retval ARK_MEM_NULL: if the MRIStep memory was ``NULL`` .. deprecated:: 6.1.0 @@ -1805,20 +1728,16 @@ Main solver optional output functions Returns the current error weight vector. - **Arguments:** - - * *arkode_mem* -- pointer to the MRIStep memory block. + :param arkode_mem: pointer to the MRIStep memory block. + :param eweight: solution error weights at the current time. - * *eweight* -- solution error weights at the current time. - - **Return value:** + :retval ARK_SUCCESS: if successful + :retval ARK_MEM_NULL: if the MRIStep memory was ``NULL`` - * *ARK_SUCCESS* if successful - - * *ARK_MEM_NULL* if the MRIStep memory was ``NULL`` + .. note:: - **Notes:** The user must allocate space for *eweight*, that will be - filled in by this function. + The user must allocate space for *eweight*, that will be + filled in by this function. .. deprecated:: 6.1.0 @@ -1830,19 +1749,18 @@ Main solver optional output functions Outputs all of the integrator, nonlinear solver, linear solver, and other statistics. - **Arguments:** - * *arkode_mem* -- pointer to the MRIStep memory block. - * *outfile* -- pointer to output file. - * *fmt* -- the output format: + :param arkode_mem: pointer to the MRIStep memory block. + :param outfile: pointer to output file. + :param fmt: the output format: - * :c:enumerator:`SUN_OUTPUTFORMAT_TABLE` -- prints a table of values - * :c:enumerator:`SUN_OUTPUTFORMAT_CSV` -- prints a comma-separated list - of key and value pairs e.g., ``key1,value1,key2,value2,...`` + * :c:enumerator:`SUN_OUTPUTFORMAT_TABLE` -- prints a table of values - **Return value:** - * *ARK_SUCCESS* -- if the output was successfully. - * *CV_MEM_NULL* -- if the MRIStep memory was ``NULL``. - * *CV_ILL_INPUT* -- if an invalid formatting option was provided. + * :c:enumerator:`SUN_OUTPUTFORMAT_CSV` -- prints a comma-separated list + of key and value pairs e.g., ``key1,value1,key2,value2,...`` + + :retval ARK_SUCCESS: -- if the output was successfully. + :retval CV_MEM_NULL: -- if the MRIStep memory was ``NULL``. + :retval CV_ILL_INPUT: -- if an invalid formatting option was provided. .. note:: @@ -1862,13 +1780,10 @@ Main solver optional output functions Returns the name of the MRIStep constant corresponding to *flag*. See :ref:`ARKODE.Constants`. - **Arguments:** - - * *flag* -- a return flag from an MRIStep function. + :param flag: a return flag from an MRIStep function. - **Return value:** - The return value is a string containing the name of - the corresponding constant. + :return value: The return value is a string containing the name of + the corresponding constant. .. deprecated:: 6.1.0 @@ -1881,19 +1796,12 @@ Main solver optional output functions Returns the number of calls to the user's outer (slow) right-hand side functions, :math:`f^E` and :math:`f^I`, so far. - **Arguments:** + :param arkode_mem: pointer to the MRIStep memory block. + :param nfse_evals: number of calls to the user's :math:`f^E(t,y)` function. + :param nfsi_evals: number of calls to the user's :math:`f^I(t,y)` function. - * *arkode_mem* -- pointer to the MRIStep memory block. - - * *nfse_evals* -- number of calls to the user's :math:`f^E(t,y)` function. - - * *nfsi_evals* -- number of calls to the user's :math:`f^I(t,y)` function. - - **Return value:** - - * *ARK_SUCCESS* if successful - - * *ARK_MEM_NULL* if the MRIStep memory was ``NULL`` + :retval ARK_SUCCESS: if successful + :retval ARK_MEM_NULL: if the MRIStep memory was ``NULL`` @@ -1901,17 +1809,11 @@ Main solver optional output functions Returns the number of failed steps due to a nonlinear solver failure (so far). - **Arguments:** - - * *arkode_mem* -- pointer to the MRIStep memory block. - - * *ncnf* -- number of step failures. + :param arkode_mem: pointer to the MRIStep memory block. + :param ncnf: number of step failures. - **Return value:** - - * *ARK_SUCCESS* if successful - - * *ARK_MEM_NULL* if the MRIStep memory was ``NULL`` + :retval ARK_SUCCESS: if successful + :retval ARK_MEM_NULL: if the MRIStep memory was ``NULL`` .. deprecated:: 6.1.0 @@ -1922,54 +1824,29 @@ Main solver optional output functions Returns the MRI coupling table currently in use by the solver. - **Arguments:** - - * *arkode_mem* -- pointer to the MRIStep memory block. - - * *C* -- pointer to slow-to-fast MRI coupling structure. - - **Return value:** - - * *ARK_SUCCESS* if successful + :param arkode_mem: pointer to the MRIStep memory block. + :param C: pointer to slow-to-fast MRI coupling structure. - * *ARK_MEM_NULL* if the MRIStep memory was ``NULL`` + :retval ARK_SUCCESS: if successful + :retval ARK_MEM_NULL: if the MRIStep memory was ``NULL`` - **Notes:** The *MRIStepCoupling* data structure is defined in - the header file ``arkode/arkode_mristep.h``. It is defined as a - pointer to the following C structure: - - .. code-block:: c - - struct MRIStepCouplingMem { - - int nmat; /* number of MRI coupling matrices */ - int stages; /* size of coupling matrices (stages * stages) */ - int q; /* method order of accuracy */ - int p; /* embedding order of accuracy */ - sunrealtype ***G; /* coupling matrices [nmat][stages][stages] */ - sunrealtype *c; /* abscissae */ - - }; - typedef MRIStepCouplingMem *MRIStepCoupling; + .. note:: - For more details see :numref:`ARKODE.Usage.MRIStep.MRIStepCoupling`. + The *MRIStepCoupling* data structure is defined in + the header file ``arkode/arkode_mristep.h``. For more details + see :numref:`ARKODE.Usage.MRIStep.MRIStepCoupling`. .. c:function:: int MRIStepGetLastInnerStepFlag(void* arkode_mem, int* flag) Returns the last return value from the inner stepper. - **Arguments:** - - * *arkode_mem* -- pointer to the MRIStep memory block. - - * *flag* -- inner stepper return value. - - **Return value:** + :param arkode_mem: pointer to the MRIStep memory block. + :param flag: inner stepper return value. - * *ARK_SUCCESS* if successful + :retval ARK_SUCCESS: if successful + :retval ARK_MEM_NULL: if the MRIStep memory was ``NULL`` - * *ARK_MEM_NULL* if the MRIStep memory was ``NULL`` .. c:function:: int MRIStepGetUserData(void* arkode_mem, void** user_data) @@ -1977,17 +1854,11 @@ Main solver optional output functions Returns the user data pointer previously set with :c:func:`MRIStepSetUserData`. - **Arguments:** - - * *arkode_mem* -- pointer to the MRIStep memory block. + :param arkode_mem: pointer to the MRIStep memory block. + :param user_data: memory reference to a user data pointer - * *user_data* -- memory reference to a user data pointer - - **Return value:** - - * *ARK_SUCCESS* if successful - - * *ARK_MEM_NULL* if the ARKStep memory was ``NULL`` + :retval ARK_SUCCESS: if successful + :retval ARK_MEM_NULL: if the ARKStep memory was ``NULL`` .. versionadded:: 5.3.0 @@ -2007,21 +1878,17 @@ Implicit solver optional output functions Returns the number of calls made to the linear solver's setup routine (so far). - **Arguments:** - - * *arkode_mem* -- pointer to the MRIStep memory block. + :param arkode_mem: pointer to the MRIStep memory block. + :param nlinsetups: number of linear solver setup calls made. - * *nlinsetups* -- number of linear solver setup calls made. + :retval ARK_SUCCESS: if successful + :retval ARK_MEM_NULL: if the MRIStep memory was ``NULL`` - **Return value:** - - * *ARK_SUCCESS* if successful - - * *ARK_MEM_NULL* if the MRIStep memory was ``NULL`` + .. note:: - **Notes:** This is only accumulated for the "life" of the nonlinear - solver object; the counter is reset whenever a new nonlinear solver - module is "attached" to MRIStep, or when MRIStep is resized. + This is only accumulated for the "life" of the nonlinear + solver object; the counter is reset whenever a new nonlinear solver + module is "attached" to MRIStep, or when MRIStep is resized. .. deprecated:: 6.1.0 @@ -2032,23 +1899,18 @@ Implicit solver optional output functions Returns the number of nonlinear solver iterations performed (so far). - **Arguments:** - - * *arkode_mem* -- pointer to the MRIStep memory block. - - * *nniters* -- number of nonlinear iterations performed. - - **Return value:** - - * *ARK_SUCCESS* if successful + :param arkode_mem: pointer to the MRIStep memory block. + :param nniters: number of nonlinear iterations performed. - * *ARK_MEM_NULL* if the MRIStep memory was ``NULL`` + :retval ARK_SUCCESS: if successful + :retval ARK_MEM_NULL: if the MRIStep memory was ``NULL`` + :retval ARK_NLS_OP_ERR: if the SUNNONLINSOL object returned a failure flag - * *ARK_NLS_OP_ERR* if the SUNNONLINSOL object returned a failure flag + .. note:: - **Notes:** This is only accumulated for the "life" of the nonlinear - solver object; the counter is reset whenever a new nonlinear solver - module is "attached" to MRIStep, or when MRIStep is resized. + This is only accumulated for the "life" of the nonlinear + solver object; the counter is reset whenever a new nonlinear solver + module is "attached" to MRIStep, or when MRIStep is resized. .. deprecated:: 6.1.0 @@ -2061,21 +1923,17 @@ Implicit solver optional output functions Returns the number of nonlinear solver convergence failures that have occurred (so far). - **Arguments:** + :param arkode_mem: pointer to the MRIStep memory block. + :param nncfails: number of nonlinear convergence failures. - * *arkode_mem* -- pointer to the MRIStep memory block. + :retval ARK_SUCCESS: if successful + :retval ARK_MEM_NULL: if the MRIStep memory was ``NULL`` - * *nncfails* -- number of nonlinear convergence failures. - - **Return value:** - - * *ARK_SUCCESS* if successful - - * *ARK_MEM_NULL* if the MRIStep memory was ``NULL`` + .. note:: - **Notes:** This is only accumulated for the "life" of the nonlinear - solver object; the counter is reset whenever a new nonlinear solver - module is "attached" to MRIStep, or when MRIStep is resized. + This is only accumulated for the "life" of the nonlinear + solver object; the counter is reset whenever a new nonlinear solver + module is "attached" to MRIStep, or when MRIStep is resized. .. deprecated:: 6.1.0 @@ -2087,25 +1945,19 @@ Implicit solver optional output functions Returns all of the nonlinear solver statistics in a single call. - **Arguments:** - - * *arkode_mem* -- pointer to the MRIStep memory block. - - * *nniters* -- number of nonlinear iterations performed. - - * *nncfails* -- number of nonlinear convergence failures. - - **Return value:** - - * *ARK_SUCCESS* if successful + :param arkode_mem: pointer to the MRIStep memory block. + :param nniters: number of nonlinear iterations performed. + :param nncfails: number of nonlinear convergence failures. - * *ARK_MEM_NULL* if the MRIStep memory was ``NULL`` + :retval ARK_SUCCESS: if successful + :retval ARK_MEM_NULL: if the MRIStep memory was ``NULL`` + :retval ARK_NLS_OP_ERR: if the SUNNONLINSOL object returned a failure flag - * *ARK_NLS_OP_ERR* if the SUNNONLINSOL object returned a failure flag + .. note:: - **Notes:** These are only accumulated for the "life" of the - nonlinear solver object; the counters are reset whenever a new - nonlinear solver module is "attached" to MRIStep, or when MRIStep is resized. + These are only accumulated for the "life" of the + nonlinear solver object; the counters are reset whenever a new + nonlinear solver module is "attached" to MRIStep, or when MRIStep is resized. .. deprecated:: 6.1.0 @@ -2123,26 +1975,26 @@ Rootfinding optional output functions Returns an array showing which functions were found to have a root. - **Arguments:** - * *arkode_mem* -- pointer to the MRIStep memory block. - * *rootsfound* -- array of length *nrtfn* with the indices of the - user functions :math:`g_i` found to have a root (the value of - *nrtfn* was supplied in the call to - :c:func:`MRIStepRootInit()`). For :math:`i = 0 \ldots` - *nrtfn*-1, ``rootsfound[i]`` is nonzero if :math:`g_i` has a - root, and 0 if not. + :param arkode_mem: pointer to the MRIStep memory block. + :param rootsfound: array of length *nrtfn* with the indices of the + user functions :math:`g_i` found to have a root (the value of + *nrtfn* was supplied in the call to + :c:func:`MRIStepRootInit()`). For :math:`i = 0 \ldots` + *nrtfn*-1, ``rootsfound[i]`` is nonzero if :math:`g_i` has a + root, and 0 if not. - **Return value:** - * *ARK_SUCCESS* if successful - * *ARK_MEM_NULL* if the MRIStep memory was ``NULL`` + :retval ARK_SUCCESS: if successful + :retval ARK_MEM_NULL: if the MRIStep memory was ``NULL`` + + .. note:: - **Notes:** The user must allocate space for *rootsfound* prior to - calling this function. + The user must allocate space for *rootsfound* prior to + calling this function. - For the components of :math:`g_i` for which a root was found, the - sign of ``rootsfound[i]`` indicates the direction of - zero-crossing. A value of +1 indicates that :math:`g_i` is - increasing, while a value of -1 indicates a decreasing :math:`g_i`. + For the components of :math:`g_i` for which a root was found, the + sign of ``rootsfound[i]`` indicates the direction of + zero-crossing. A value of +1 indicates that :math:`g_i` is + increasing, while a value of -1 indicates a decreasing :math:`g_i`. .. deprecated:: 6.1.0 @@ -2155,13 +2007,11 @@ Rootfinding optional output functions Returns the cumulative number of calls made to the user's root function :math:`g`. - **Arguments:** - * *arkode_mem* -- pointer to the MRIStep memory block. - * *ngevals* -- number of calls made to :math:`g` so far. + :param arkode_mem: pointer to the MRIStep memory block. + :param ngevals: number of calls made to :math:`g` so far. - **Return value:** - * *ARK_SUCCESS* if successful - * *ARK_MEM_NULL* if the MRIStep memory was ``NULL`` + :retval ARK_SUCCESS: if successful + :retval ARK_MEM_NULL: if the MRIStep memory was ``NULL`` .. deprecated:: 6.1.0 @@ -2235,30 +2085,24 @@ Linear solver interface optional output functions Returns the real and integer workspace used by the ARKLS linear solver interface. - **Arguments:** - - * *arkode_mem* -- pointer to the MRIStep memory block. + :param arkode_mem: pointer to the MRIStep memory block. + :param lenrwLS: the number of ``realtype`` values in the ARKLS workspace. + :param leniwLS: the number of integer values in the ARKLS workspace. - * *lenrwLS* -- the number of ``sunrealtype`` values in the ARKLS workspace. + :retval ARKLS_SUCCESS: if successful + :retval ARKLS_MEM_NULL: if the MRIStep memory was ``NULL`` + :retval ARKLS_LMEM_NULL: if the linear solver memory was ``NULL`` - * *leniwLS* -- the number of integer values in the ARKLS workspace. - - **Return value:** - - * *ARKLS_SUCCESS* if successful - - * *ARKLS_MEM_NULL* if the MRIStep memory was ``NULL`` - - * *ARKLS_LMEM_NULL* if the linear solver memory was ``NULL`` + .. note:: - **Notes:** The workspace requirements reported by this routine - correspond only to memory allocated within this interface and to - memory allocated by the ``SUNLinearSolver`` object attached - to it. The template Jacobian matrix allocated by the user outside - of ARKLS is not included in this report. + The workspace requirements reported by this routine + correspond only to memory allocated within this interface and to + memory allocated by the ``SUNLinearSolver`` object attached + to it. The template Jacobian matrix allocated by the user outside + of ARKLS is not included in this report. - In a parallel setting, the above values are global (i.e., summed over all - processors). + In a parallel setting, the above values are global (i.e., summed over all + processors). .. deprecated:: 6.1.0 @@ -2269,23 +2113,18 @@ Linear solver interface optional output functions Returns the number of Jacobian evaluations. - **Arguments:** - - * *arkode_mem* -- pointer to the MRIStep memory block. - - * *njevals* -- number of Jacobian evaluations. + :param arkode_mem: pointer to the MRIStep memory block. + :param njevals: number of Jacobian evaluations. - **Return value:** - - * *ARKLS_SUCCESS* if successful - - * *ARKLS_MEM_NULL* if the MRIStep memory was ``NULL`` + :retval ARKLS_SUCCESS: if successful + :retval ARKLS_MEM_NULL: if the MRIStep memory was ``NULL`` + :retval ARKLS_LMEM_NULL: if the linear solver memory was ``NULL`` - * *ARKLS_LMEM_NULL* if the linear solver memory was ``NULL`` + .. note:: - **Notes:** This is only accumulated for the "life" of the linear - solver object; the counter is reset whenever a new linear solver - module is "attached" to MRIStep, or when MRIStep is resized. + This is only accumulated for the "life" of the linear + solver object; the counter is reset whenever a new linear solver + module is "attached" to MRIStep, or when MRIStep is resized. .. deprecated:: 6.1.0 @@ -2298,23 +2137,18 @@ Linear solver interface optional output functions i.e., the number of calls made to *psetup* with ``jok`` = ``SUNFALSE`` and that returned ``*jcurPtr`` = ``SUNTRUE``. - **Arguments:** - - * *arkode_mem* -- pointer to the MRIStep memory block. - - * *npevals* -- the current number of calls to *psetup*. - - **Return value:** - - * *ARKLS_SUCCESS* if successful + :param arkode_mem: pointer to the MRIStep memory block. + :param npevals: the current number of calls to *psetup*. - * *ARKLS_MEM_NULL* if the MRIStep memory was ``NULL`` + :retval ARKLS_SUCCESS: if successful + :retval ARKLS_MEM_NULL: if the MRIStep memory was ``NULL`` + :retval ARKLS_LMEM_NULL: if the linear solver memory was ``NULL`` - * *ARKLS_LMEM_NULL* if the linear solver memory was ``NULL`` + .. note:: - **Notes:** This is only accumulated for the "life" of the linear - solver object; the counter is reset whenever a new linear solver - module is "attached" to MRIStep, or when MRIStep is resized. + This is only accumulated for the "life" of the linear + solver object; the counter is reset whenever a new linear solver + module is "attached" to MRIStep, or when MRIStep is resized. .. deprecated:: 6.1.0 @@ -2326,23 +2160,18 @@ Linear solver interface optional output functions Returns the number of calls made to the preconditioner solve function, *psolve*. - **Arguments:** - - * *arkode_mem* -- pointer to the MRIStep memory block. - - * *npsolves* -- the number of calls to *psolve*. + :param arkode_mem: pointer to the MRIStep memory block. + :param npsolves: the number of calls to *psolve*. - **Return value:** - - * *ARKLS_SUCCESS* if successful - - * *ARKLS_MEM_NULL* if the MRIStep memory was ``NULL`` + :retval ARKLS_SUCCESS: if successful + :retval ARKLS_MEM_NULL: if the MRIStep memory was ``NULL`` + :retval ARKLS_LMEM_NULL: if the linear solver memory was ``NULL`` - * *ARKLS_LMEM_NULL* if the linear solver memory was ``NULL`` + .. note:: - **Notes:** This is only accumulated for the "life" of the linear - solver object; the counter is reset whenever a new linear solver - module is "attached" to MRIStep, or when MRIStep is resized. + This is only accumulated for the "life" of the linear + solver object; the counter is reset whenever a new linear solver + module is "attached" to MRIStep, or when MRIStep is resized. .. deprecated:: 6.1.0 @@ -2353,23 +2182,18 @@ Linear solver interface optional output functions Returns the cumulative number of linear iterations. - **Arguments:** + :param arkode_mem: pointer to the MRIStep memory block. + :param nliters: the current number of linear iterations. - * *arkode_mem* -- pointer to the MRIStep memory block. + :retval ARKLS_SUCCESS: if successful + :retval ARKLS_MEM_NULL: if the MRIStep memory was ``NULL`` + :retval ARKLS_LMEM_NULL: if the linear solver memory was ``NULL`` - * *nliters* -- the current number of linear iterations. - - **Return value:** - - * *ARKLS_SUCCESS* if successful - - * *ARKLS_MEM_NULL* if the MRIStep memory was ``NULL`` - - * *ARKLS_LMEM_NULL* if the linear solver memory was ``NULL`` + .. note:: - **Notes:** This is only accumulated for the "life" of the linear - solver object; the counter is reset whenever a new linear solver - module is "attached" to MRIStep, or when MRIStep is resized. + This is only accumulated for the "life" of the linear + solver object; the counter is reset whenever a new linear solver + module is "attached" to MRIStep, or when MRIStep is resized. .. deprecated:: 6.1.0 @@ -2380,23 +2204,18 @@ Linear solver interface optional output functions Returns the cumulative number of linear convergence failures. - **Arguments:** - - * *arkode_mem* -- pointer to the MRIStep memory block. + :param arkode_mem: pointer to the MRIStep memory block. + :param nlcfails: the current number of linear convergence failures. - * *nlcfails* -- the current number of linear convergence failures. + :retval ARKLS_SUCCESS: if successful + :retval ARKLS_MEM_NULL: if the MRIStep memory was ``NULL`` + :retval ARKLS_LMEM_NULL: if the linear solver memory was ``NULL`` - **Return value:** - - * *ARKLS_SUCCESS* if successful - - * *ARKLS_MEM_NULL* if the MRIStep memory was ``NULL`` - - * *ARKLS_LMEM_NULL* if the linear solver memory was ``NULL`` + .. note:: - **Notes:** This is only accumulated for the "life" of the linear - solver object; the counter is reset whenever a new linear solver - module is "attached" to MRIStep, or when MRIStep is resized. + This is only accumulated for the "life" of the linear + solver object; the counter is reset whenever a new linear solver + module is "attached" to MRIStep, or when MRIStep is resized. .. deprecated:: 6.1.0 @@ -2408,23 +2227,18 @@ Linear solver interface optional output functions Returns the cumulative number of calls made to the user-supplied Jacobian-vector setup function, *jtsetup*. - **Arguments:** - - * *arkode_mem* -- pointer to the MRIStep memory block. - - * *njtsetup* -- the current number of calls to *jtsetup*. - - **Return value:** - - * *ARKLS_SUCCESS* if successful + :param arkode_mem: pointer to the MRIStep memory block. + :param njtsetup: the current number of calls to *jtsetup*. - * *ARKLS_MEM_NULL* if the MRIStep memory was ``NULL`` + :retval ARKLS_SUCCESS: if successful + :retval ARKLS_MEM_NULL: if the MRIStep memory was ``NULL`` + :retval ARKLS_LMEM_NULL: if the linear solver memory was ``NULL`` - * *ARKLS_LMEM_NULL* if the linear solver memory was ``NULL`` + .. note:: - **Notes:** This is only accumulated for the "life" of the linear - solver object; the counter is reset whenever a new linear solver - module is "attached" to MRIStep, or when MRIStep is resized. + This is only accumulated for the "life" of the linear + solver object; the counter is reset whenever a new linear solver + module is "attached" to MRIStep, or when MRIStep is resized. .. deprecated:: 6.1.0 @@ -2436,23 +2250,18 @@ Linear solver interface optional output functions Returns the cumulative number of calls made to the Jacobian-vector product function, *jtimes*. - **Arguments:** + :param arkode_mem: pointer to the MRIStep memory block. + :param njvevals: the current number of calls to *jtimes*. - * *arkode_mem* -- pointer to the MRIStep memory block. + :retval ARKLS_SUCCESS: if successful + :retval ARKLS_MEM_NULL: if the MRIStep memory was ``NULL`` + :retval ARKLS_LMEM_NULL: if the linear solver memory was ``NULL`` - * *njvevals* -- the current number of calls to *jtimes*. - - **Return value:** - - * *ARKLS_SUCCESS* if successful - - * *ARKLS_MEM_NULL* if the MRIStep memory was ``NULL`` - - * *ARKLS_LMEM_NULL* if the linear solver memory was ``NULL`` + .. note:: - **Notes:** This is only accumulated for the "life" of the linear - solver object; the counter is reset whenever a new linear solver - module is "attached" to MRIStep, or when MRIStep is resized. + This is only accumulated for the "life" of the linear + solver object; the counter is reset whenever a new linear solver + module is "attached" to MRIStep, or when MRIStep is resized. .. deprecated:: 6.1.0 @@ -2465,27 +2274,22 @@ Linear solver interface optional output functions right-hand side function :math:`f^I` for finite difference Jacobian or Jacobian-vector product approximation. - **Arguments:** - - * *arkode_mem* -- pointer to the MRIStep memory block. - - * *nfevalsLS* -- the number of calls to the user implicit - right-hand side function. - - **Return value:** + :param arkode_mem: pointer to the MRIStep memory block. + :param nfevalsLS: the number of calls to the user implicit + right-hand side function. - * *ARKLS_SUCCESS* if successful + :retval ARKLS_SUCCESS: if successful + :retval ARKLS_MEM_NULL: if the MRIStep memory was ``NULL`` + :retval ARKLS_LMEM_NULL: if the linear solver memory was ``NULL`` - * *ARKLS_MEM_NULL* if the MRIStep memory was ``NULL`` - - * *ARKLS_LMEM_NULL* if the linear solver memory was ``NULL`` + .. note:: - **Notes:** The value *nfevalsLS* is incremented only if the default - internal difference quotient function is used. + The value *nfevalsLS* is incremented only if the default + internal difference quotient function is used. - This is only accumulated for the "life" of the linear - solver object; the counter is reset whenever a new linear solver - module is "attached" to MRIStep, or when MRIStep is resized. + This is only accumulated for the "life" of the linear + solver object; the counter is reset whenever a new linear solver + module is "attached" to MRIStep, or when MRIStep is resized. .. deprecated:: 6.1.0 @@ -2496,55 +2300,58 @@ Linear solver interface optional output functions Returns the last return value from an ARKLS routine. - **Arguments:** + :param arkode_mem: pointer to the MRIStep memory block. + :param lsflag: the value of the last return flag from an + ARKLS function. - * *arkode_mem* -- pointer to the MRIStep memory block. + :retval ARKLS_SUCCESS: if successful + :retval ARKLS_MEM_NULL: if the MRIStep memory was ``NULL`` + :retval ARKLS_LMEM_NULL: if the linear solver memory was ``NULL`` - * *lsflag* -- the value of the last return flag from an - ARKLS function. + .. note:: - **Return value:** + If the ARKLS setup function failed when using the + ``SUNLINSOL_DENSE`` or ``SUNLINSOL_BAND`` modules, then the value + of *lsflag* is equal to the column index (numbered from one) at + which a zero diagonal element was encountered during the LU + factorization of the (dense or banded) Jacobian matrix. For all + other failures, *lsflag* is negative. + + Otherwise, if the ARKLS setup function failed + (:c:func:`MRIStepEvolve()` returned *ARK_LSETUP_FAIL*), then + *lsflag* will be *SUNLS_PSET_FAIL_UNREC*, *SUNLS_ASET_FAIL_UNREC* + or *SUNLS_PACKAGE_FAIL_UNREC*. + + If the ARKLS solve function failed (:c:func:`MRIStepEvolve()` + returned *ARK_LSOLVE_FAIL*), then *lsflag* contains the error + return flag from the ``SUNLinearSolver`` object, which will + be one of: + + * *SUNLS_MEM_NULL*, indicating that the ``SUNLinearSolver`` + memory is ``NULL``; + + * *SUNLS_ATIMES_NULL*, indicating that a matrix-free iterative solver + was provided, but is missing a routine for the matrix-vector product + approximation, + + * *SUNLS_ATIMES_FAIL_UNREC*, indicating an unrecoverable failure in + the :math:`Jv` function; + + * *SUNLS_PSOLVE_NULL*, indicating that an iterative linear solver was + configured to use preconditioning, but no preconditioner solve + routine was provided, + + * *SUNLS_PSOLVE_FAIL_UNREC*, indicating that the preconditioner solve + function failed unrecoverably; + + * *SUNLS_GS_FAIL*, indicating a failure in the Gram-Schmidt procedure + (SPGMR and SPFGMR only); + + * *SUNLS_QRSOL_FAIL*, indicating that the matrix :math:`R` was found + to be singular during the QR solve phase (SPGMR and SPFGMR only); or - * *ARKLS_SUCCESS* if successful - - * *ARKLS_MEM_NULL* if the MRIStep memory was ``NULL`` - - * *ARKLS_LMEM_NULL* if the linear solver memory was ``NULL`` - - **Notes:** If the ARKLS setup function failed when using the - ``SUNLINSOL_DENSE`` or ``SUNLINSOL_BAND`` modules, then the value - of *lsflag* is equal to the column index (numbered from one) at - which a zero diagonal element was encountered during the LU - factorization of the (dense or banded) Jacobian matrix. For all - other failures, *lsflag* is negative. - - Otherwise, if the ARKLS setup function failed - (:c:func:`MRIStepEvolve()` returned *ARK_LSETUP_FAIL*), then - *lsflag* will be *SUNLS_PSET_FAIL_UNREC*, *SUNLS_ASET_FAIL_UNREC* - or *SUN_ERR_EXT_FAIL*. - - If the ARKLS solve function failed (:c:func:`MRIStepEvolve()` - returned *ARK_LSOLVE_FAIL*), then *lsflag* contains the error - return flag from the ``SUNLinearSolver`` object, which will - be one of: - *SUN_ERR_ARG_CORRUPTRRUPT*, indicating that the ``SUNLinearSolver`` - memory is ``NULL``; - *SUNLS_ATIMES_NULL*, indicating that a matrix-free iterative solver - was provided, but is missing a routine for the matrix-vector product - approximation, - *SUNLS_ATIMES_FAIL_UNREC*, indicating an unrecoverable failure in - the :math:`Jv` function; - *SUNLS_PSOLVE_NULL*, indicating that an iterative linear solver was - configured to use preconditioning, but no preconditioner solve - routine was provided, - *SUNLS_PSOLVE_FAIL_UNREC*, indicating that the preconditioner solve - function failed unrecoverably; - *SUNLS_GS_FAIL*, indicating a failure in the Gram-Schmidt procedure - (SPGMR and SPFGMR only); - *SUNLS_QRSOL_FAIL*, indicating that the matrix :math:`R` was found - to be singular during the QR solve phase (SPGMR and SPFGMR only); or - *SUN_ERR_EXT_FAIL*, indicating an unrecoverable failure in - an external iterative linear solver package. + * *SUNLS_PACKAGE_FAIL_UNREC*, indicating an unrecoverable failure in + an external iterative linear solver package. .. deprecated:: 6.1.0 @@ -2555,14 +2362,13 @@ Linear solver interface optional output functions Returns the name of the ARKLS constant corresponding to *lsflag*. - **Arguments:** - - * *lsflag* -- a return flag from an ARKLS function. + :param lsflag: a return flag from an ARKLS function. - **Return value:** The return value is a string containing the name of - the corresponding constant. If using the ``SUNLINSOL_DENSE`` or - ``SUNLINSOL_BAND`` modules, then if 1 :math:`\le` `lsflag` - :math:`\le n` (LU factorization failed), this routine returns "NONE". + :return value: The return value is a string containing the name of + the corresponding constant. If using the ``SUNLINSOL_DENSE`` + or ``SUNLINSOL_BAND`` modules, then if 1 :math:`\le` `lsflag` + :math:`\le n` (LU factorization failed), this routine returns + "NONE". .. deprecated:: 6.1.0 @@ -2580,24 +2386,20 @@ General usability functions Outputs all MRIStep solver parameters to the provided file pointer. - **Arguments:** + :param arkode_mem: pointer to the MRIStep memory block. + :param fp: pointer to use for printing the solver parameters. - * *arkode_mem* -- pointer to the MRIStep memory block. + :retval ARKS_SUCCESS: if successful + :retval ARKS_MEM_NULL: if the MRIStep memory was ``NULL`` - * *fp* -- pointer to use for printing the solver parameters. - - **Return value:** - - * *ARKS_SUCCESS* if successful - - * *ARKS_MEM_NULL* if the MRIStep memory was ``NULL`` + .. note:: - **Notes:** The *fp* argument can be ``stdout`` or ``stderr``, or it - may point to a specific file created using ``fopen``. + The *fp* argument can be ``stdout`` or ``stderr``, or it + may point to a specific file created using ``fopen``. - When run in parallel, only one process should set a non-NULL value - for this pointer, since parameters for all processes would be - identical. + When run in parallel, only one process should set a non-NULL value + for this pointer, since parameters for all processes would be + identical. .. deprecated:: 6.1.0 @@ -2608,24 +2410,20 @@ General usability functions Outputs the current MRI coupling table to the provided file pointer. - **Arguments:** - - * *arkode_mem* -- pointer to the MRIStep memory block. - - * *fp* -- pointer to use for printing the Butcher tables. + :param arkode_mem: pointer to the MRIStep memory block. + :param fp: pointer to use for printing the Butcher tables. - **Return value:** + :retval ARK_SUCCESS: if successful + :retval ARK_MEM_NULL: if the MRIStep memory was ``NULL`` - * *ARK_SUCCESS* if successful - - * *ARK_MEM_NULL* if the MRIStep memory was ``NULL`` + .. note:: - **Notes:** The *fp* argument can be ``stdout`` or ``stderr``, or it - may point to a specific file created using ``fopen``. + The *fp* argument can be ``stdout`` or ``stderr``, or it + may point to a specific file created using ``fopen``. - When run in parallel, only one process should set a non-NULL value - for this pointer, since tables for all processes would be - identical. + When run in parallel, only one process should set a non-NULL value + for this pointer, since tables for all processes would be + identical. .. deprecated:: 6.1.0 @@ -2681,42 +2479,32 @@ vector. Provides required problem specifications and re-initializes the MRIStep outer (slow) stepper. - **Arguments:** - - * *arkode_mem* -- pointer to the MRIStep memory block. - - * *fse* -- the name of the function (of type :c:func:`ARKRhsFn()`) - defining the explicit slow portion of the right-hand side function in - :math:`\dot{y} = f^E(t,y) + f^I(t,y) + f^F(t,y)`. - - * *fsi* -- the name of the function (of type :c:func:`ARKRhsFn()`) - defining the implicit slow portion of the right-hand side function in - :math:`\dot{y} = f^E(t,y) + f^I(t,y) + f^F(t,y)`. + :param arkode_mem: pointer to the MRIStep memory block. + :param fse: the name of the function (of type :c:func:`ARKRhsFn()`) + defining the explicit slow portion of the right-hand side function in + :math:`\dot{y} = f^E(t,y) + f^I(t,y) + f^F(t,y)`. + :param fsi: the name of the function (of type :c:func:`ARKRhsFn()`) + defining the implicit slow portion of the right-hand side function in + :math:`\dot{y} = f^E(t,y) + f^I(t,y) + f^F(t,y)`. + :param t0: the initial value of :math:`t`. + :param y0: the initial condition vector :math:`y(t_0)`. + + :retval ARK_SUCCESS: if successful + :retval ARK_MEM_NULL: if the MRIStep memory was ``NULL`` + :retval ARK_MEM_FAIL: if a memory allocation failed + :retval ARK_ILL_INPUT: if an argument has an illegal value. - * *t0* -- the initial value of :math:`t`. - - * *y0* -- the initial condition vector :math:`y(t_0)`. - - **Return value:** - - * *ARK_SUCCESS* if successful - - * *ARK_MEM_NULL* if the MRIStep memory was ``NULL`` - - * *ARK_MEM_FAIL* if a memory allocation failed - - * *ARK_ILL_INPUT* if an argument has an illegal value. + .. note:: - **Notes:** - If the inner (fast) stepper also needs to be reinitialized, its - reinitialization function should be called before calling - :c:func:`MRIStepReInit()` to reinitialize the outer stepper. + If the inner (fast) stepper also needs to be reinitialized, its + reinitialization function should be called before calling + :c:func:`MRIStepReInit()` to reinitialize the outer stepper. - All previously set options are retained but may be updated by calling - the appropriate "Set" functions. + All previously set options are retained but may be updated by calling + the appropriate "Set" functions. - If an error occurred, :c:func:`MRIStepReInit()` also - sends an error message to the error handler function. + If an error occurred, :c:func:`MRIStepReInit()` also + sends an error message to the error handler function. @@ -2730,33 +2518,25 @@ MRIStep reset function Resets the current MRIStep outer (slow) time-stepper module state to the provided independent variable value and dependent variable vector. - **Arguments:** - - * *arkode_mem* -- pointer to the MRIStep memory block. - - * *tR* -- the value of the independent variable :math:`t`. - - * *yR* -- the value of the dependent variable vector :math:`y(t_R)`. - - **Return value:** + :param arkode_mem: pointer to the MRIStep memory block. + :param tR: the value of the independent variable :math:`t`. + :param yR: the value of the dependent variable vector :math:`y(t_R)`. - * *ARK_SUCCESS* if successful + :retval ARK_SUCCESS: if successful + :retval ARK_MEM_NULL: if the MRIStep memory was ``NULL`` + :retval ARK_MEM_FAIL: if a memory allocation failed + :retval ARK_ILL_INPUT: if an argument has an illegal value. - * *ARK_MEM_NULL* if the MRIStep memory was ``NULL`` - - * *ARK_MEM_FAIL* if a memory allocation failed - - * *ARK_ILL_INPUT* if an argument has an illegal value. + .. note:: - **Notes:** - If the inner (fast) stepper also needs to be reset, its reset function should - be called before calling :c:func:`MRIStepReset()` to reset the outer stepper. + If the inner (fast) stepper also needs to be reset, its reset function should + be called before calling :c:func:`MRIStepReset()` to reset the outer stepper. - All previously set options are retained but may be updated by calling - the appropriate "Set" functions. + All previously set options are retained but may be updated by calling + the appropriate "Set" functions. - If an error occurred, :c:func:`MRIStepReset()` also sends an error message to - the error handler function. + If an error occurred, :c:func:`MRIStepReset()` also sends an error message to + the error handler function. .. versionchanged:: 5.3.0 @@ -2770,6 +2550,7 @@ MRIStep reset function + .. _ARKODE.Usage.MRIStep.Resizing: MRIStep system resize function @@ -2779,68 +2560,59 @@ MRIStep system resize function Re-initializes MRIStep with a different state vector. - **Arguments:** - - * *arkode_mem* -- pointer to the MRIStep memory block. - - * *yR* -- the newly-sized solution vector, holding the current - dependent variable values :math:`y(t_R)`. - - * *tR* -- the current value of the independent variable - :math:`t_R` (this must be consistent with *yR*). - - * *resize* -- the user-supplied vector resize function (of type - :c:func:`ARKVecResizeFn()`. - - * *resize_data* -- the user-supplied data structure to be passed - to *resize* when modifying internal MRIStep vectors. - - **Return value:** - - * *ARK_SUCCESS* if successful + :param arkode_mem: pointer to the MRIStep memory block. + :param yR: the newly-sized solution vector, holding the current + dependent variable values :math:`y(t_R)`. + :param tR: the current value of the independent variable + :math:`t_R` (this must be consistent with *yR*). + :param resize: the user-supplied vector resize function (of type + :c:func:`ARKVecResizeFn()`. + :param resize_data: the user-supplied data structure to be passed + to *resize* when modifying internal MRIStep vectors. + + :retval ARK_SUCCESS: if successful + :retval ARK_MEM_NULL: if the MRIStep memory was ``NULL`` + :retval ARK_NO_MALLOC: if *arkode_mem* was not allocated. + :retval ARK_ILL_INPUT: if an argument has an illegal value. - * *ARK_MEM_NULL* if the MRIStep memory was ``NULL`` - - * *ARK_NO_MALLOC* if *arkode_mem* was not allocated. - - * *ARK_ILL_INPUT* if an argument has an illegal value. - - **Notes:** If an error occurred, :c:func:`MRIStepResize()` also sends an error - message to the error handler function. - - **Resizing the linear solver:** - When using any of the SUNDIALS-provided linear solver modules, the - linear solver memory structures must also be resized. At present, - none of these include a solver-specific "resize" function, so the linear - solver memory must be destroyed and re-allocated **following** each - call to :c:func:`MRIStepResize()`. Moreover, the existing ARKLS - interface should then be deleted and recreated by attaching the - updated ``SUNLinearSolver`` (and possibly ``SUNMatrix``) object(s) - through calls to :c:func:`MRIStepSetLinearSolver()`. - - If any user-supplied routines are provided to aid the linear solver - (e.g. Jacobian construction, Jacobian-vector product, - mass-matrix-vector product, preconditioning), then the corresponding - "set" routines must be called again **following** the solver - re-specification. - - **Resizing the absolute tolerance array:** - If using array-valued absolute tolerances, the absolute tolerance - vector will be invalid after the call to :c:func:`MRIStepResize()`, so - the new absolute tolerance vector should be re-set **following** each - call to :c:func:`MRIStepResize()` through a new call to - :c:func:`MRIStepSVtolerances()`. - - If scalar-valued tolerances or a tolerance function was specified - through either :c:func:`MRIStepSStolerances()` or - :c:func:`MRIStepWFtolerances()`, then these will remain valid and no - further action is necessary. - - .. note:: + .. note:: - For an example showing usage of the similar :c:func:`ARKStepResize()` - routine, see the supplied serial C example problem, - ``ark_heat1D_adapt.c``. + If an error occurred, :c:func:`MRIStepResize()` also sends an error + message to the error handler function. + + **Resizing the linear solver:** + When using any of the SUNDIALS-provided linear solver modules, the + linear solver memory structures must also be resized. At present, + none of these include a solver-specific "resize" function, so the linear + solver memory must be destroyed and re-allocated **following** each + call to :c:func:`MRIStepResize()`. Moreover, the existing ARKLS + interface should then be deleted and recreated by attaching the + updated ``SUNLinearSolver`` (and possibly ``SUNMatrix``) object(s) + through calls to :c:func:`MRIStepSetLinearSolver()`. + + If any user-supplied routines are provided to aid the linear solver + (e.g. Jacobian construction, Jacobian-vector product, + mass-matrix-vector product, preconditioning), then the corresponding + "set" routines must be called again **following** the solver + re-specification. + + **Resizing the absolute tolerance array:** + If using array-valued absolute tolerances, the absolute tolerance + vector will be invalid after the call to :c:func:`MRIStepResize()`, so + the new absolute tolerance vector should be re-set **following** each + call to :c:func:`MRIStepResize()` through a new call to + :c:func:`MRIStepSVtolerances()` and possibly + :c:func:`MRIStepResVtolerance()` if applicable. + + If scalar-valued tolerances or a tolerance function was specified + through either :c:func:`MRIStepSStolerances()` or + :c:func:`MRIStepWFtolerances()`, then these will remain valid and no + further action is necessary. + + **Example codes:** + For an example showing usage of the similar :c:func:`ARKStepResize()` + routine, see the supplied serial C example problem, + ``ark_heat1D_adapt.c``. .. deprecated:: 6.1.0 diff --git a/doc/arkode/guide/source/Usage/User_callable.rst b/doc/arkode/guide/source/Usage/User_callable.rst index fd9b572382..b235c4e7d2 100644 --- a/doc/arkode/guide/source/Usage/User_callable.rst +++ b/doc/arkode/guide/source/Usage/User_callable.rst @@ -988,16 +988,14 @@ Set max number of constraint failures :c:func:`ARKodeSetMaxNumConstr .. versionchanged:: 6.1.0 + This function replaces stepper specific versions in ARKStep, ERKStep, + MRIStep, and SPRKStep. + Added the ``ARK_INTERP_NONE`` option to disable interpolation. Values set by a previous call to :c:func:`ARKStepSetInterpolantDegree` are no longer nullified by a call to :c:func:`ARKStepSetInterpolantType`. - .. versionadded:: 6.1.0 - - This function replaces stepper specific versions in ARKStep, ERKStep, - MRIStep, and SPRKStep. - .. c:function:: int ARKodeSetInterpolantDegree(void* arkode_mem, int degree) @@ -1426,6 +1424,8 @@ Minimum allowed step reduction factor on error test fail :c:func:`ARKodeSetMi Time step safety factor :c:func:`ARKodeSetSafetyFactor` 0.96 Error fails before MaxEFailGrowth takes effect :c:func:`ARKodeSetSmallNumEFails` 2 Explicit stability function :c:func:`ARKodeSetStabilityFn` none +Set accumulated error estimation type :c:func:`ARKodeSetAccumulatedErrorType` none +Reset accumulated error :c:func:`ARKodeResetAccumulatedError` ========================================================= ========================================== ======== @@ -1751,6 +1751,62 @@ Explicit stability function :c:func:`ARKodeSetSt .. versionadded:: 6.1.0 +.. c:function:: int ARKodeSetAccumulatedErrorType(void* arkode_mem, int accum_type) + + Sets the strategy to use for accumulating a temporal error estimate + over multiple time steps. + + :param arkode_mem: pointer to the ARKODE memory block. + :param accum_type: accumulation strategy: + + * ``-1`` -- no accumulation (default). + * ``0`` -- maximum accumulation. + * ``1`` -- additive accumulation. + + :retval ARK_SUCCESS: the function exited successfully. + :retval ARK_MEM_NULL: ``arkode_mem`` was ``NULL`` + :retval ARK_STEPPER_UNSUPPORTED: temporal error estimation is not supported + by the current time-stepping module. + + .. note:: + + Multiple of ARKODE's time-stepping modules compute both a solution and embedding, + :math:`y_n` and :math:`\tilde{y}_n`, that may be combined to create a vector-valued + local temporal error estimate, :math:`y_n - \tilde{y}_n`. By default, ARKODE will + not accumulate these local error estimates, but accumulation can be triggered by + calling this function with one of two options: + + * ``0`` computes :math:`\text{reltol} \max_{n\in N} \|y_n - \tilde{y}_n\|_{WRMS}` + + * ``1`` computes :math:`\frac{\text{reltol}}{N} \sum_{n\in N} \|y_n - \tilde{y}_n\|_{WRMS}`, + + In both cases, the sum or maximum is taken over all steps :math:`n\in N` since the most + recent call to either :c:func:`ARKodeSetAccumulatedErrorType` or + :c:func:`ARKodeResetAccumulatedError`. The norm is taken using the tolerance-informed + error-weight vector (see :c:func:`ARKodeGetErrWeights`), and ``reltol`` is the + user-specified relative solution tolerance. + + Error accumulation can be disabled by calling :c:func:`ARKodeSetAccumulatedErrorType` + with the argument ``-1``. + + .. versionadded:: x.y.z + + +.. c:function:: int ARKodeResetAccumulatedError(void* arkode_mem) + + Resets the accumulated temporal error estimate, that was triggered by a previous call to + :c:func:`ARKodeSetAccumulatedErrorType`. + + :param arkode_mem: pointer to the ARKODE memory block. + + :retval ARK_SUCCESS: the function exited successfully. + :retval ARK_MEM_NULL: ``arkode_mem`` was ``NULL`` + :retval ARK_STEPPER_UNSUPPORTED: temporal error estimation is not supported + by the current time-stepping module. + + .. versionadded:: x.y.z + + .. _ARKODE.Usage.ARKodeSolverInputTable: @@ -3170,6 +3226,7 @@ No. of failed steps due to a nonlinear solver failure :c:func:`ARKodeGetNumStep Estimated local truncation error vector :c:func:`ARKodeGetEstLocalErrors` Number of constraint test failures :c:func:`ARKodeGetNumConstrFails` Retrieve a pointer for user data :c:func:`ARKodeGetUserData` +Retrieve the accumulated temporal error estimate :c:func:`ARKodeGetAccumulatedError` ===================================================== ============================================ @@ -3571,6 +3628,25 @@ Retrieve a pointer for user data :c:func:`ARKodeGetUserDat .. versionadded:: 6.1.0 +.. c:function:: int ARKStepGetAccumulatedError(void* arkode_mem, sunrealtype* accum_error) + + Returns the accumulated temporal error estimate. + + :param arkode_mem: pointer to the ARKODE memory block. + :param accum_error: pointer to accumulated error estimate. + + :retval ARK_SUCCESS: the function exited successfully. + :retval ARK_MEM_NULL: ``arkode_mem`` was ``NULL``. + :retval ARK_STEPPER_UNSUPPORTED: temporal error estimation is not supported + by the current time-stepping module, or accumulated + error estimation is currently disabled in the stepper. + + .. versionadded:: x.y.z + + + + + .. _ARKODE.Usage.ARKodeImplicitSolverOutputs: Implicit solver optional output functions diff --git a/doc/shared/RecentChanges.rst b/doc/shared/RecentChanges.rst index cc4a9f919c..183b793459 100644 --- a/doc/shared/RecentChanges.rst +++ b/doc/shared/RecentChanges.rst @@ -2,6 +2,15 @@ **New Features and Enhancements** +Added Multirate time step adaptivity controllers, based on the recently introduced +`SUNAdaptController` base class, to ARKODE's MRIStep module. + +Added functionality to ARKStep and ERKStep to accumulate a temporal error +estimate over multiple time steps. See the routines :c:func:`ARKStepSetAccumulatedErrorType`, +:c:func:`ARKStepResetAccumulatedError`, :c:func:`ARKStepGetAccumulatedError`, +:c:func:`ERKStepSetAccumulatedErrorType`, :c:func:`ERKStepResetAccumulatedError`, +and :c:func:`ERKStepGetAccumulatedError` for details. + **Bug Fixes** Fixed the loading of ARKStep's default first order explicit method. diff --git a/examples/arkode/C_serial/CMakeLists.txt b/examples/arkode/C_serial/CMakeLists.txt index fbba99ffb9..74e5665ea9 100644 --- a/examples/arkode/C_serial/CMakeLists.txt +++ b/examples/arkode/C_serial/CMakeLists.txt @@ -59,20 +59,21 @@ set(ARKODE_examples "ark_kepler\;--stepper SPRK --step-mode fixed --method ARKODE_SPRK_RUTH_3_3 --tf 50 --check-order --nout 1\;exclude-single" "ark_kepler\;--stepper SPRK --step-mode fixed --method ARKODE_SPRK_YOSHIDA_6_8 --tf 50 --check-order --nout 1\;exclude-single" "ark_kepler\;\;develop" - "ark_kpr_mri\;\;develop" - "ark_kpr_mri\;0 0.002\;develop" - "ark_kpr_mri\;1 0.002\;develop" - "ark_kpr_mri\;2 0.005\;develop" - "ark_kpr_mri\;3 0.01\;develop" - "ark_kpr_mri\;4 0.002\;develop" - "ark_kpr_mri\;5 0.002\;develop" - "ark_kpr_mri\;6 0.005\;develop" - "ark_kpr_mri\;7 0.001 -100 100 0.5 1\;exclude-single" - "ark_kpr_mri\;7 0.001\;exclude-single" - "ark_kpr_mri\;8 0.001 -100 100 0.5 1\;exclude-single" - "ark_kpr_mri\;8 0.001\;exclude-single" - "ark_kpr_mri\;9 0.001 -100 100 0.5 1\;exclude-single" - "ark_kpr_mri\;9 0.001\;exclude-single" + "ark_kpr_mri\;0 1 0.005\;develop" + "ark_kpr_mri\;1 0 0.01\;develop" + "ark_kpr_mri\;1 1 0.002\;develop" + "ark_kpr_mri\;2 4 0.002\;develop" + "ark_kpr_mri\;3 2 0.001\;develop" + "ark_kpr_mri\;4 3 0.001\;develop" + "ark_kpr_mri\;5 4 0.001\;develop" + "ark_kpr_mri\;6 5 0.001\;develop" + "ark_kpr_mri\;7 2 0.002\;develop" + "ark_kpr_mri\;8 3 0.001 -100 100 0.5 1\;exclude-single" + "ark_kpr_mri\;9 3 0.001 -100 100 0.5 1\;exclude-single" + "ark_kpr_mri\;10 4 0.001 -100 100 0.5 1\;exclude-single" + "ark_kpr_mri\;11 2 0.001\;develop" + "ark_kpr_mri\;12 3 0.005\;develop" + "ark_kpr_mri\;13 4 0.01\;develop" "ark_KrylovDemo_prec\;\;exclude-single" "ark_KrylovDemo_prec\;1\;exclude-single" "ark_KrylovDemo_prec\;2\;exclude-single" diff --git a/examples/arkode/C_serial/ark_kpr_mri.c b/examples/arkode/C_serial/ark_kpr_mri.c index 2ae783435e..3422f63a5b 100644 --- a/examples/arkode/C_serial/ark_kpr_mri.c +++ b/examples/arkode/C_serial/ark_kpr_mri.c @@ -34,33 +34,41 @@ * by G, for |G| > 50 it is 'stiff' and ideally suited to a * multirate method that is implicit at the slow time scale. * - * We select the MRI method to use based on an additional input, - * solve_type; with options (slow type-order/fast type-order): - * 0. exp-3/exp-3 (standard MIS) [default] - * 1. none/exp-3 (no slow, explicit fast) - * 2. none/dirk-3 (no slow, dirk fast) - * 3. exp-3/none (explicit slow, no fast) - * 4. dirk-2/none (dirk slow, no fast) -- solve-decoupled - * 5. exp-4/exp-4 (MRI-GARK-ERK45a / ERK-4-4) - * 6. exp-4/exp-3 (MRI-GARK-ERK45a / ERK-3-3) - * 7. dirk-3/exp-3 (MRI-GARK-ESDIRK34a / ERK-3-3) -- solve decoupled - * 8. ars343/exp-3 (IMEX-MRI3b / ERK-3-3) -- solve decoupled - * 9. imexark4/exp-4 (IMEX-MRI4/ ERK-4-4) -- solve decoupled + * We select the MRI method to use based on additional inputs: * - * We note that once we have methods that are IMEX at the slow time - * scale, the nonstiff slow term, [ r'(t)/(2u) ], can be treated - * explicitly. + * slow_type: + * 0 - none (full problem at fast scale) + * 1 - ARKODE_MIS_KW3 + * 2 - ARKODE_MRI_GARK_ERK45a + * 3 - ARKODE_MERK21 + * 4 - ARKODE_MERK32 + * 5 - ARKODE_MERK43 + * 6 - ARKODE_MERK54 + * 7 - ARKODE_MRI_GARK_IRK21a + * 8 - ARKODE_MRI_GARK_ESDIRK34a + * 9 - ARKODE_IMEX_MRI_GARK3b + * 10 - ARKODE_IMEX_MRI_GARK4 + * 11 - ARKODE_IMEX_MRI_SR21 + * 12 - ARKODE_IMEX_MRI_SR32 + * 13 - ARKODE_IMEX_MRI_SR43 * + * fast_type: + * 0 - none (full problem at slow scale) + * 1 - esdirk-3-3 (manually entered non-embedded table) + * 2 - ARKODE_HEUN_EULER_2_1_2 + * 3 - erk-3-3 (manually entered non-embedded table) + * 4 - erk-4-4 (manually entered non-embeded table) + * 5 - ARKODE_DORMAND_PRINCE_7_4_5 + * * The program should be run with arguments in the following order: - * $ a.out solve_type h G w e deduce + * $ a.out slow_type fast_type h G w e deduce * Not all arguments are required, but these must be omitted from * end-to-beginning, i.e. any one of - * $ a.out solve_type h G w e - * $ a.out solve_type h G w - * $ a.out solve_type h G - * $ a.out solve_type h - * $ a.out solve_type - * $ a.out + * $ a.out slow_type fast_type h G w e + * $ a.out slow_type fast_type h G w + * $ a.out slow_type fast_type h G + * $ a.out slow_type fast_type h + * $ a.out slow_type fast_type * are acceptable. We require: * * 0 <= solve_type <= 9 * * 0 < h < 1/|G| @@ -109,6 +117,8 @@ static int Jsi(sunrealtype t, N_Vector y, N_Vector fy, SUNMatrix J, void* user_data, N_Vector tmp1, N_Vector tmp2, N_Vector tmp3); static int Jn(sunrealtype t, N_Vector y, N_Vector fy, SUNMatrix J, void* user_data, N_Vector tmp1, N_Vector tmp2, N_Vector tmp3); +static int Jf(sunrealtype t, N_Vector y, N_Vector fy, SUNMatrix J, + void* user_data, N_Vector tmp1, N_Vector tmp2, N_Vector tmp3); /* Private function to check function return values */ static sunrealtype r(sunrealtype t, void* user_data); @@ -131,7 +141,8 @@ int main(int argc, char* argv[]) sunrealtype dTout = SUN_RCONST(0.1); /* time between outputs */ sunindextype NEQ = 2; /* number of dependent vars. */ int Nt = (int)ceil(Tf / dTout); /* number of output times */ - int solve_type = 0; /* problem configuration type */ + int slow_type = 0; /* problem configuration type */ + int fast_type = 0; /* problem configuration type */ sunrealtype hs = SUN_RCONST(0.01); /* slow step size */ sunrealtype e = SUN_RCONST(0.5); /* fast/slow coupling strength */ sunrealtype G = SUN_RCONST(-100.0); /* stiffness at slow time scale */ @@ -151,9 +162,14 @@ int main(int argc, char* argv[]) SUNLinearSolver LSf = NULL; /* fast linear solver object */ SUNMatrix As = NULL; /* matrix for slow solver */ SUNLinearSolver LSs = NULL; /* slow linear solver object */ - sunbooleantype implicit_slow; - sunbooleantype imex_slow = SUNFALSE; - sunbooleantype deduce = SUNFALSE; + sunbooleantype implicit_slow = SUNFALSE; + sunbooleantype imex_slow = SUNFALSE; + sunbooleantype explicit_slow = SUNFALSE; + sunbooleantype no_slow = SUNFALSE; + sunbooleantype implicit_fast = SUNFALSE; + sunbooleantype explicit_fast = SUNFALSE; + sunbooleantype no_fast = SUNFALSE; + sunbooleantype deduce = SUNFALSE; FILE* UFID; sunrealtype hf, gamma, beta, t, tout, rpar[3]; sunrealtype uerr, verr, uerrtot, verrtot, errtot; @@ -164,36 +180,55 @@ int main(int argc, char* argv[]) * Initialization */ - /* Retrieve the command-line options: solve_type h G w e */ - if (argc > 1) { solve_type = (sunindextype)atol(argv[1]); } - if (argc > 2) { hs = SUNStrToReal(argv[2]); } - if (argc > 3) { G = SUNStrToReal(argv[3]); } - if (argc > 4) { w = SUNStrToReal(argv[4]); } - if (argc > 5) { e = SUNStrToReal(argv[5]); } - if (argc > 6) { deduce = (sunbooleantype)atoi(argv[6]); } + /* Retrieve the command-line options: slow_type fast_type h G w e deduce */ + if (argc < 3) + { + printf("ERROR: executable requires at least two arguments [slow_type " + "fast_type]\n"); + printf("Usage:\n"); + printf(" a.out slow_type fast_type h G w e deduce"); + return (-1); + } + slow_type = (sunindextype)atol(argv[1]); + fast_type = (sunindextype)atol(argv[2]); + if (argc > 3) { hs = SUNStrToReal(argv[3]); } + if (argc > 4) { G = SUNStrToReal(argv[4]); } + if (argc > 5) { w = SUNStrToReal(argv[5]); } + if (argc > 6) { e = SUNStrToReal(argv[6]); } + if (argc > 7) { deduce = (sunbooleantype)atoi(argv[7]); } /* Check arguments for validity */ - /* 0 <= solve_type <= 9 */ + /* 0 <= slow_type <= 13 */ + /* 0 <= fast_type <= 5 */ /* G < 0.0 */ /* h > 0 */ /* h < 1/|G| (explicit slow) */ /* w >= 1.0 */ - if ((solve_type < 0) || (solve_type > 9)) + if ((slow_type < 0) || (slow_type > 13)) { - printf("ERROR: solve_type be an integer in [0,9] \n"); + printf("ERROR: slow_type be an integer in [0,13] \n"); return (-1); } - if (G >= ZERO) + if ((fast_type < 0) || (fast_type > 5)) { - printf("ERROR: G must be a negative real number\n"); + printf("ERROR: fast_type be an integer in [0,3] \n"); return (-1); } - implicit_slow = SUNFALSE; - if ((solve_type == 4) || (solve_type == 7)) { implicit_slow = SUNTRUE; } - if ((solve_type == 8) || (solve_type == 9)) + if ((slow_type == 0) && (fast_type == 0)) { - implicit_slow = SUNTRUE; - imex_slow = SUNTRUE; + printf("ERROR: at least one of slow_type and fast_type must be nonzero\n"); + return (-1); + } + if (((slow_type == 9) || (slow_type == 10)) && (fast_type == 0)) + { + printf("ERROR: example not configured for ImEx slow solver with no fast " + "solver\n"); + return (-1); + } + if (G >= ZERO) + { + printf("ERROR: G must be a negative real number\n"); + return (-1); } if (hs <= ZERO) { @@ -223,51 +258,114 @@ int main(int argc, char* argv[]) printf(" G = %" GSYM "\n", G); printf(" w = %" GSYM "\n", w); printf(" e = %" GSYM "\n", e); - switch (solve_type) + switch (slow_type) { - case (0): printf(" solver: exp-3/exp-3 (standard MIS)\n\n"); break; + case (0): + printf(" slow solver: none\n"); + no_slow = SUNTRUE; + break; case (1): - printf(" solver: none/exp-3 (no slow, explicit fast)\n\n"); + printf(" slow solver: ARKODE_MIS_KW3\n"); + explicit_slow = SUNTRUE; break; case (2): - reltol = SUNMAX(hs * hs * hs, 1e-10); - abstol = 1e-11; - printf(" solver: none/dirk-3 (no slow, dirk fast)\n\n"); - printf(" reltol = %.2" ESYM ", abstol = %.2" ESYM "\n", reltol, abstol); + printf(" slow solver: ARKODE_MRI_GARK_ERK45a\n"); + explicit_slow = SUNTRUE; + break; + case (3): + printf(" slow solver: ARKODE_MERK21\n"); + explicit_slow = SUNTRUE; break; - case (3): printf(" solver: exp-3/none (explicit slow, no fast)\n"); break; case (4): - reltol = SUNMAX(hs * hs, 1e-10); - abstol = 1e-11; - printf(" solver: dirk-2/none (dirk slow, no fast)\n"); - printf(" reltol = %.2" ESYM ", abstol = %.2" ESYM "\n", reltol, abstol); + printf(" slow solver: ARKODE_MERK32\n"); + explicit_slow = SUNTRUE; break; case (5): - printf(" solver: exp-4/exp-4 (MRI-GARK-ERK45a / ERK-4-4)\n\n"); + printf(" slow solver: ARKODE_MERK43\n"); + explicit_slow = SUNTRUE; break; case (6): - printf(" solver: exp-4/exp-3 (MRI-GARK-ERK45a / ERK-3-3)\n\n"); + printf(" slow solver: ARKODE_MERK54\n"); + explicit_slow = SUNTRUE; break; case (7): - reltol = SUNMAX(hs * hs * hs, 1e-10); - abstol = 1e-11; - printf(" solver: dirk-3/exp-3 (MRI-GARK-ESDIRK34a / ERK-3-3) -- solve " - "decoupled\n"); - printf(" reltol = %.2" ESYM ", abstol = %.2" ESYM "\n", reltol, abstol); + printf(" slow solver: ARKODE_MRI_GARK_IRK21a\n"); + implicit_slow = SUNTRUE; + reltol = SUNMAX(hs * hs, 1e-10); + abstol = 1e-11; + printf(" reltol = %.2" ESYM ", abstol = %.2" ESYM "\n", reltol, abstol); break; case (8): - reltol = SUNMAX(hs * hs * hs, 1e-10); - abstol = 1e-11; - printf( - " solver: ars343/exp-3 (IMEX-MRI3b / ERK-3-3) -- solve decoupled\n"); - printf(" reltol = %.2" ESYM ", abstol = %.2" ESYM "\n", reltol, abstol); + printf(" slow solver: ARKODE_MRI_GARK_ESDIRK34a\n"); + implicit_slow = SUNTRUE; + reltol = SUNMAX(hs * hs * hs, 1e-10); + abstol = 1e-11; + printf(" reltol = %.2" ESYM ", abstol = %.2" ESYM "\n", reltol, abstol); break; case (9): - reltol = SUNMAX(hs * hs * hs * hs, 1e-14); - abstol = 1e-14; - printf( - " solver: imexark4/exp-4 (IMEX-MRI4 / ERK-4-4) -- solve decoupled\n"); - printf(" reltol = %.2" ESYM ", abstol = %.2" ESYM "\n", reltol, abstol); + printf(" slow solver: ARKODE_IMEX_MRI_GARK3b\n"); + imex_slow = SUNTRUE; + reltol = SUNMAX(hs * hs * hs, 1e-10); + abstol = 1e-11; + printf(" reltol = %.2" ESYM ", abstol = %.2" ESYM "\n", reltol, abstol); + break; + case (10): + printf(" slow solver: ARKODE_IMEX_MRI_GARK4\n"); + imex_slow = SUNTRUE; + reltol = SUNMAX(hs * hs * hs * hs, 1e-14); + abstol = 1e-14; + printf(" reltol = %.2" ESYM ", abstol = %.2" ESYM "\n", reltol, abstol); + break; + case (11): + printf(" slow solver: ARKODE_IMEX_MRI_SR21\n"); + imex_slow = SUNTRUE; + reltol = SUNMAX(hs * hs, 1e-10); + abstol = 1e-11; + printf(" reltol = %.2" ESYM ", abstol = %.2" ESYM "\n", reltol, abstol); + break; + case (12): + printf(" slow solver: ARKODE_IMEX_MRI_SR32\n"); + imex_slow = SUNTRUE; + reltol = SUNMAX(hs * hs * hs, 1e-10); + abstol = 1e-11; + printf(" reltol = %.2" ESYM ", abstol = %.2" ESYM "\n", reltol, abstol); + break; + case (13): + printf(" slow solver: ARKODE_IMEX_MRI_SR43\n"); + imex_slow = SUNTRUE; + reltol = SUNMAX(hs * hs * hs * hs, 1e-14); + abstol = 1e-14; + printf(" reltol = %.2" ESYM ", abstol = %.2" ESYM "\n", reltol, abstol); + break; + } + switch (fast_type) + { + case (0): + printf(" fast solver: none\n"); + no_fast = SUNTRUE; + break; + case (3): + printf(" fast solver: erk-3-3\n"); + explicit_fast = SUNTRUE; + break; + case (1): + printf(" fast solver: esdirk-3-3\n"); + implicit_fast = SUNTRUE; + reltol = SUNMAX(hs * hs * hs, 1e-10); + abstol = 1e-11; + printf(" reltol = %.2" ESYM ", abstol = %.2" ESYM "\n", reltol, abstol); + break; + case (4): + printf(" fast solver: erk-4-4\n"); + explicit_fast = SUNTRUE; + break; + case (2): + printf(" fast solver: ARKODE_HEUN_EULER_2_1_2\n"); + explicit_fast = SUNTRUE; + break; + case (5): + printf(" fast solver: ARKODE_DORMAND_PRINCE_7_4_5\n"); + explicit_fast = SUNTRUE; break; } @@ -286,36 +384,55 @@ int main(int argc, char* argv[]) */ /* Initialize the fast integrator. Specify the fast right-hand side - function in y'=fs(t,y)+ff(t,y) = fse(t,y)+fsi(t,y)+ff(t,y), the initial time T0, - and the initial dependent variable vector y. */ - switch (solve_type) + function in y'=fs(t,y)+ff(t,y) = fse(t,y)+fsi(t,y)+ff(t,y), the inital time T0, + and the initial dependent variable vector y. If the fast scale is implicit, + set up matrix, linear solver, and Jacobian function */ + if (implicit_fast) + { + Af = SUNDenseMatrix(NEQ, NEQ, ctx); + if (check_retval((void*)Af, "SUNDenseMatrix", 0)) { return 1; } + LSf = SUNLinSol_Dense(y, Af, ctx); + if (check_retval((void*)LSf, "SUNLinSol_Dense", 0)) { return 1; } + } + if (no_fast) + { + inner_arkode_mem = ARKStepCreate(f0, NULL, T0, y, ctx); + if (check_retval((void*)inner_arkode_mem, "ARKStepCreate", 0)) { return 1; } + } + else if (explicit_fast && !no_slow) { - case (0): - case (6): - case (7): - case (8): /* erk-3-3 fast solver */ inner_arkode_mem = ARKStepCreate(ff, NULL, T0, y, ctx); if (check_retval((void*)inner_arkode_mem, "ARKStepCreate", 0)) { return 1; } - B = ARKodeButcherTable_Alloc(3, SUNTRUE); - if (check_retval((void*)B, "ARKodeButcherTable_Alloc", 0)) { return 1; } - B->A[1][0] = SUN_RCONST(0.5); - B->A[2][0] = -ONE; - B->A[2][1] = TWO; - B->b[0] = ONE / SUN_RCONST(6.0); - B->b[1] = TWO / SUN_RCONST(3.0); - B->b[2] = ONE / SUN_RCONST(6.0); - B->d[1] = ONE; - B->c[1] = SUN_RCONST(0.5); - B->c[2] = ONE; - B->q = 3; - B->p = 2; - retval = ARKStepSetTables(inner_arkode_mem, 3, 2, NULL, B); - if (check_retval(&retval, "ARKStepSetTables", 1)) { return 1; } - ARKodeButcherTable_Free(B); - break; - case (1): /* erk-3-3 fast solver (full problem) */ + } + else if (explicit_fast && no_slow) + { inner_arkode_mem = ARKStepCreate(fn, NULL, T0, y, ctx); if (check_retval((void*)inner_arkode_mem, "ARKStepCreate", 0)) { return 1; } + } + else if (implicit_fast && no_slow) + { + inner_arkode_mem = ARKStepCreate(NULL, fn, T0, y, ctx); + if (check_retval((void*)inner_arkode_mem, "ARKStepCreate", 0)) { return 1; } + retval = ARKodeSetLinearSolver(inner_arkode_mem, LSf, Af); + if (check_retval(&retval, "ARKodeSetLinearSolver", 1)) { return 1; } + retval = ARKodeSetJacFn(inner_arkode_mem, Jn); + if (check_retval(&retval, "ARKodeSetJacFn", 1)) { return 1; } + } + else if (implicit_fast && !no_slow) + { + inner_arkode_mem = ARKStepCreate(NULL, ff, T0, y, ctx); + if (check_retval((void*)inner_arkode_mem, "ARKStepCreate", 0)) { return 1; } + retval = ARKodeSetLinearSolver(inner_arkode_mem, LSf, Af); + if (check_retval(&retval, "ARKodeSetLinearSolver", 1)) { return 1; } + retval = ARKodeSetJacFn(inner_arkode_mem, Jf); + if (check_retval(&retval, "ARKodeSetJacFn", 1)) { return 1; } + } + + /* Set Butcher table for fast integrator */ + switch (fast_type) + { + case (0): + case (3): B = ARKodeButcherTable_Alloc(3, SUNTRUE); if (check_retval((void*)B, "ARKodeButcherTable_Alloc", 0)) { return 1; } B->A[1][0] = SUN_RCONST(0.5); @@ -331,32 +448,8 @@ int main(int argc, char* argv[]) B->p = 2; retval = ARKStepSetTables(inner_arkode_mem, 3, 2, NULL, B); if (check_retval(&retval, "ARKStepSetTables", 1)) { return 1; } - ARKodeButcherTable_Free(B); break; - case (9): - case (5): /* erk-4-4 fast solver */ - inner_arkode_mem = ARKStepCreate(ff, NULL, T0, y, ctx); - if (check_retval((void*)inner_arkode_mem, "ARKStepCreate", 0)) { return 1; } - B = ARKodeButcherTable_Alloc(4, SUNFALSE); - if (check_retval((void*)B, "ARKodeButcherTable_Alloc", 0)) { return 1; } - B->A[1][0] = SUN_RCONST(0.5); - B->A[2][1] = SUN_RCONST(0.5); - B->A[3][2] = ONE; - B->b[0] = ONE / SUN_RCONST(6.0); - B->b[1] = ONE / SUN_RCONST(3.0); - B->b[2] = ONE / SUN_RCONST(3.0); - B->b[3] = ONE / SUN_RCONST(6.0); - B->c[1] = SUN_RCONST(0.5); - B->c[2] = SUN_RCONST(0.5); - B->c[3] = ONE; - B->q = 4; - retval = ARKStepSetTables(inner_arkode_mem, 4, 0, NULL, B); - if (check_retval(&retval, "ARKStepSetTables", 1)) { return 1; } - ARKodeButcherTable_Free(B); - break; - case (2): /* esdirk-3-3 fast solver (full problem) */ - inner_arkode_mem = ARKStepCreate(NULL, fn, T0, y, ctx); - if (check_retval((void*)inner_arkode_mem, "ARKStepCreate", 0)) { return 1; } + case (1): B = ARKodeButcherTable_Alloc(3, SUNFALSE); if (check_retval((void*)B, "ARKodeButcherTable_Alloc", 0)) { return 1; } beta = SUNRsqrt(SUN_RCONST(3.0)) / SUN_RCONST(6.0) + SUN_RCONST(0.5); @@ -374,39 +467,42 @@ int main(int argc, char* argv[]) B->q = 3; retval = ARKStepSetTables(inner_arkode_mem, 3, 0, B, NULL); if (check_retval(&retval, "ARKStepSetTables", 1)) { return 1; } - Af = SUNDenseMatrix(NEQ, NEQ, ctx); - if (check_retval((void*)Af, "SUNDenseMatrix", 0)) { return 1; } - LSf = SUNLinSol_Dense(y, Af, ctx); - if (check_retval((void*)LSf, "SUNLinSol_Dense", 0)) { return 1; } - retval = ARKodeSetLinearSolver(inner_arkode_mem, LSf, Af); - if (check_retval(&retval, "ARKodeSetLinearSolver", 1)) { return 1; } - retval = ARKodeSetJacFn(inner_arkode_mem, Jn); - if (check_retval(&retval, "ARKodeSetJacFn", 1)) { return 1; } - retval = ARKodeSStolerances(inner_arkode_mem, reltol, abstol); - if (check_retval(&retval, "ARKodeSStolerances", 1)) { return 1; } - ARKodeButcherTable_Free(B); break; - case (3): /* no fast dynamics ('evolve' explicitly w/ erk-3-3) */ case (4): - inner_arkode_mem = ARKStepCreate(f0, NULL, T0, y, ctx); - if (check_retval((void*)inner_arkode_mem, "ARKStepCreate", 0)) { return 1; } - B = ARKodeButcherTable_Alloc(3, SUNTRUE); + B = ARKodeButcherTable_Alloc(4, SUNFALSE); if (check_retval((void*)B, "ARKodeButcherTable_Alloc", 0)) { return 1; } B->A[1][0] = SUN_RCONST(0.5); - B->A[2][0] = -ONE; - B->A[2][1] = TWO; + B->A[2][1] = SUN_RCONST(0.5); + B->A[3][2] = ONE; B->b[0] = ONE / SUN_RCONST(6.0); - B->b[1] = TWO / SUN_RCONST(3.0); - B->b[2] = ONE / SUN_RCONST(6.0); - B->d[1] = ONE; + B->b[1] = ONE / SUN_RCONST(3.0); + B->b[2] = ONE / SUN_RCONST(3.0); + B->b[3] = ONE / SUN_RCONST(6.0); B->c[1] = SUN_RCONST(0.5); - B->c[2] = ONE; - B->q = 3; - B->p = 2; - retval = ARKStepSetTables(inner_arkode_mem, 3, 2, NULL, B); + B->c[2] = SUN_RCONST(0.5); + B->c[3] = ONE; + B->q = 4; + retval = ARKStepSetTables(inner_arkode_mem, 4, 0, NULL, B); if (check_retval(&retval, "ARKStepSetTables", 1)) { return 1; } - ARKodeButcherTable_Free(B); + break; + case (2): + B = ARKodeButcherTable_LoadERK(ARKODE_HEUN_EULER_2_1_2); + if (check_retval((void*)B, "ARKodeButcherTable_LoadERK", 0)) { return 1; } + retval = ARKStepSetTables(inner_arkode_mem, 2, 1, NULL, B); + if (check_retval(&retval, "ARKStepSetTables", 1)) { return 1; } + break; + case (5): + B = ARKodeButcherTable_LoadERK(ARKODE_DORMAND_PRINCE_7_4_5); + if (check_retval((void*)B, "ARKodeButcherTable_LoadERK", 0)) { return 1; } + retval = ARKStepSetTables(inner_arkode_mem, 5, 4, NULL, B); + if (check_retval(&retval, "ARKStepSetTables", 1)) { return 1; } + break; } + ARKodeButcherTable_Free(B); + + /* Set the tolerances */ + retval = ARKodeSStolerances(inner_arkode_mem, reltol, abstol); + if (check_retval(&retval, "ARKodeSStolerances", 1)) { return 1; } /* Set the user data pointer */ retval = ARKodeSetUserData(inner_arkode_mem, (void*)rpar); @@ -428,39 +524,64 @@ int main(int argc, char* argv[]) */ /* Initialize the slow integrator. Specify the slow right-hand side - function in y'=fs(t,y)+ff(t,y) = fse(t,y)+fsi(t,y)+ff(t,y), the initial time - T0, the initial dependent variable vector y, and the fast integrator. */ - switch (solve_type) + function in y'=fs(t,y)+ff(t,y) = fse(t,y)+fsi(t,y)+ff(t,y), the inital time + T0, the initial dependent variable vector y, and the fast integrator. If + the slow scale contains an implicit component, set up matrix, linear solver, + and Jacobian function. */ + if (implicit_slow || imex_slow) + { + As = SUNDenseMatrix(NEQ, NEQ, ctx); + if (check_retval((void*)As, "SUNDenseMatrix", 0)) { return 1; } + LSs = SUNLinSol_Dense(y, As, ctx); + if (check_retval((void*)LSs, "SUNLinSol_Dense", 0)) { return 1; } + } + if (no_slow) + { + arkode_mem = MRIStepCreate(f0, NULL, T0, y, inner_stepper, ctx); + if (check_retval((void*)arkode_mem, "MRIStepCreate", 0)) { return 1; } + } + else if (explicit_slow && !no_fast) { - case (0): /* KW3 slow solver */ arkode_mem = MRIStepCreate(fs, NULL, T0, y, inner_stepper, ctx); if (check_retval((void*)arkode_mem, "MRIStepCreate", 0)) { return 1; } - C = MRIStepCoupling_LoadTable(ARKODE_MIS_KW3); - if (check_retval((void*)C, "MRIStepCoupling_LoadTable", 0)) { return 1; } - retval = MRIStepSetCoupling(arkode_mem, C); - if (check_retval(&retval, "MRIStepSetCoupling", 1)) { return 1; } - break; - case (3): /* KW3 slow solver (full problem) */ + } + else if (explicit_slow && no_fast) + { arkode_mem = MRIStepCreate(fn, NULL, T0, y, inner_stepper, ctx); if (check_retval((void*)arkode_mem, "MRIStepCreate", 0)) { return 1; } - C = MRIStepCoupling_LoadTable(ARKODE_MIS_KW3); - if (check_retval((void*)C, "MRIStepCoupling_LoadTable", 0)) { return 1; } - retval = MRIStepSetCoupling(arkode_mem, C); - if (check_retval(&retval, "MRIStepSetCoupling", 1)) { return 1; } - break; - case (5): /* MRI-GARK-ERK45a slow solver */ - case (6): - arkode_mem = MRIStepCreate(fs, NULL, T0, y, inner_stepper, ctx); + } + else if (implicit_slow && !no_fast) + { + arkode_mem = MRIStepCreate(NULL, fs, T0, y, inner_stepper, ctx); if (check_retval((void*)arkode_mem, "MRIStepCreate", 0)) { return 1; } - C = MRIStepCoupling_LoadTable(ARKODE_MRI_GARK_ERK45a); - if (check_retval((void*)C, "MRIStepCoupling_LoadTable", 1)) { return 1; } - retval = MRIStepSetCoupling(arkode_mem, C); - if (check_retval(&retval, "MRIStepSetCoupling", 1)) { return 1; } - break; - case (1): - case (2): /* no slow dynamics (use ERK-2-2) */ - arkode_mem = MRIStepCreate(f0, NULL, T0, y, inner_stepper, ctx); + retval = ARKodeSetLinearSolver(arkode_mem, LSs, As); + if (check_retval(&retval, "ARKodeSetLinearSolver", 1)) { return 1; } + retval = ARKodeSetJacFn(arkode_mem, Js); + if (check_retval(&retval, "ARKodeSetJacFn", 1)) { return 1; } + } + else if (implicit_slow && no_fast) + { + arkode_mem = MRIStepCreate(NULL, fn, T0, y, inner_stepper, ctx); + if (check_retval((void*)arkode_mem, "MRIStepCreate", 0)) { return 1; } + retval = ARKodeSetLinearSolver(arkode_mem, LSs, As); + if (check_retval(&retval, "ARKodeSetLinearSolver", 1)) { return 1; } + retval = ARKodeSetJacFn(arkode_mem, Jn); + if (check_retval(&retval, "ARKodeSetJacFn", 1)) { return 1; } + } + else if (imex_slow) + { + arkode_mem = MRIStepCreate(fse, fsi, T0, y, inner_stepper, ctx); if (check_retval((void*)arkode_mem, "MRIStepCreate", 0)) { return 1; } + retval = ARKodeSetLinearSolver(arkode_mem, LSs, As); + if (check_retval(&retval, "ARKodeSetLinearSolver", 1)) { return 1; } + retval = ARKodeSetJacFn(arkode_mem, Jsi); + if (check_retval(&retval, "ARKodeSetJacFn", 1)) { return 1; } + } + + /* Set coupling table for slow integrator */ + switch (slow_type) + { + case (0): /* no slow dynamics (use ERK-2-2) */ B = ARKodeButcherTable_Alloc(2, SUNFALSE); if (check_retval((void*)B, "ARKodeButcherTable_Alloc", 0)) { return 1; } B->A[1][0] = TWO / SUN_RCONST(3.0); @@ -470,83 +591,68 @@ int main(int argc, char* argv[]) B->q = 2; C = MRIStepCoupling_MIStoMRI(B, 2, 0); if (check_retval((void*)C, "MRIStepCoupling_MIStoMRI", 0)) { return 1; } - retval = MRIStepSetCoupling(arkode_mem, C); - if (check_retval(&retval, "MRIStepSetCoupling", 1)) { return 1; } ARKodeButcherTable_Free(B); break; - case (4): /* dirk-2 (trapezoidal), solve-decoupled slow solver */ - arkode_mem = MRIStepCreate(NULL, fn, T0, y, inner_stepper, ctx); - if (check_retval((void*)arkode_mem, "MRIStepCreate", 0)) { return 1; } + case (1): + C = MRIStepCoupling_LoadTable(ARKODE_MIS_KW3); + if (check_retval((void*)C, "MRIStepCoupling_LoadTable", 0)) { return 1; } + break; + case (2): + C = MRIStepCoupling_LoadTable(ARKODE_MRI_GARK_ERK45a); + if (check_retval((void*)C, "MRIStepCoupling_LoadTable", 1)) { return 1; } + break; + case (3): + C = MRIStepCoupling_LoadTable(ARKODE_MERK21); + if (check_retval((void*)C, "MRIStepCoupling_LoadTable", 1)) { return 1; } + break; + case (4): + C = MRIStepCoupling_LoadTable(ARKODE_MERK32); + if (check_retval((void*)C, "MRIStepCoupling_LoadTable", 1)) { return 1; } + break; + case (5): + C = MRIStepCoupling_LoadTable(ARKODE_MERK43); + if (check_retval((void*)C, "MRIStepCoupling_LoadTable", 1)) { return 1; } + break; + case (6): + C = MRIStepCoupling_LoadTable(ARKODE_MERK54); + if (check_retval((void*)C, "MRIStepCoupling_LoadTable", 1)) { return 1; } + break; + case (7): C = MRIStepCoupling_LoadTable(ARKODE_MRI_GARK_IRK21a); if (check_retval((void*)C, "MRIStepCoupling_LoadTable", 1)) { return 1; } - retval = MRIStepSetCoupling(arkode_mem, C); - if (check_retval(&retval, "MRIStepSetCoupling", 1)) { return 1; } - As = SUNDenseMatrix(NEQ, NEQ, ctx); - if (check_retval((void*)As, "SUNDenseMatrix", 0)) { return 1; } - LSs = SUNLinSol_Dense(y, As, ctx); - if (check_retval((void*)LSs, "SUNLinSol_Dense", 0)) { return 1; } - retval = ARKodeSetLinearSolver(arkode_mem, LSs, As); - if (check_retval(&retval, "ARKodeSetLinearSolver", 1)) { return 1; } - retval = ARKodeSetJacFn(arkode_mem, Jn); - if (check_retval(&retval, "ARKodeSetJacFn", 1)) { return 1; } - retval = ARKodeSStolerances(arkode_mem, reltol, abstol); - if (check_retval(&retval, "ARKodeSStolerances", 1)) { return 1; } break; - case (7): /* MRI-GARK-ESDIRK34a, solve-decoupled slow solver */ - arkode_mem = MRIStepCreate(NULL, fs, T0, y, inner_stepper, ctx); - if (check_retval((void*)arkode_mem, "MRIStepCreate", 0)) { return 1; } + case (8): C = MRIStepCoupling_LoadTable(ARKODE_MRI_GARK_ESDIRK34a); if (check_retval((void*)C, "MRIStepCoupling_LoadTable", 1)) { return 1; } - retval = MRIStepSetCoupling(arkode_mem, C); - if (check_retval(&retval, "MRIStepSetCoupling", 1)) { return 1; } - As = SUNDenseMatrix(NEQ, NEQ, ctx); - if (check_retval((void*)As, "SUNDenseMatrix", 0)) { return 1; } - LSs = SUNLinSol_Dense(y, As, ctx); - if (check_retval((void*)LSs, "SUNLinSol_Dense", 0)) { return 1; } - retval = ARKodeSetLinearSolver(arkode_mem, LSs, As); - if (check_retval(&retval, "ARKodeSetLinearSolver", 1)) { return 1; } - retval = ARKodeSetJacFn(arkode_mem, Js); - if (check_retval(&retval, "ARKodeSetJacFn", 1)) { return 1; } - retval = ARKodeSStolerances(arkode_mem, reltol, abstol); - if (check_retval(&retval, "ARKodeSStolerances", 1)) { return 1; } break; - case (8): /* IMEX-MRI-GARK3b, solve-decoupled slow solver */ - arkode_mem = MRIStepCreate(fse, fsi, T0, y, inner_stepper, ctx); - if (check_retval((void*)arkode_mem, "MRIStepCreate", 0)) { return 1; } + case (9): C = MRIStepCoupling_LoadTable(ARKODE_IMEX_MRI_GARK3b); if (check_retval((void*)C, "MRIStepCoupling_LoadTable", 0)) { return 1; } - retval = MRIStepSetCoupling(arkode_mem, C); - if (check_retval(&retval, "MRIStepSetCoupling", 1)) { return 1; } - As = SUNDenseMatrix(NEQ, NEQ, ctx); - if (check_retval((void*)As, "SUNDenseMatrix", 0)) { return 1; } - LSs = SUNLinSol_Dense(y, As, ctx); - if (check_retval((void*)LSs, "SUNLinSol_Dense", 0)) { return 1; } - retval = ARKodeSetLinearSolver(arkode_mem, LSs, As); - if (check_retval(&retval, "ARKodeSetLinearSolver", 1)) { return 1; } - retval = ARKodeSetJacFn(arkode_mem, Jsi); - if (check_retval(&retval, "ARKodeSetJacFn", 1)) { return 1; } - retval = ARKodeSStolerances(arkode_mem, reltol, abstol); - if (check_retval(&retval, "ARKodeSStolerances", 1)) { return 1; } break; - case (9): /* IMEX-MRI-GARK4, solve-decoupled slow solver */ - arkode_mem = MRIStepCreate(fse, fsi, T0, y, inner_stepper, ctx); - if (check_retval((void*)arkode_mem, "MRIStepCreate", 0)) { return 1; } + case (10): C = MRIStepCoupling_LoadTable(ARKODE_IMEX_MRI_GARK4); if (check_retval((void*)C, "MRIStepCoupling_LoadTable", 0)) { return 1; } - retval = MRIStepSetCoupling(arkode_mem, C); - if (check_retval(&retval, "MRIStepSetCoupling", 1)) { return 1; } - As = SUNDenseMatrix(NEQ, NEQ, ctx); - if (check_retval((void*)As, "SUNDenseMatrix", 0)) { return 1; } - LSs = SUNLinSol_Dense(y, As, ctx); - if (check_retval((void*)LSs, "SUNLinSol_Dense", 0)) { return 1; } - retval = ARKodeSetLinearSolver(arkode_mem, LSs, As); - if (check_retval(&retval, "ARKodeSetLinearSolver", 1)) { return 1; } - retval = ARKodeSetJacFn(arkode_mem, Jsi); - if (check_retval(&retval, "ARKodeSetJacFn", 1)) { return 1; } - retval = ARKodeSStolerances(arkode_mem, reltol, abstol); - if (check_retval(&retval, "ARKodeSStolerances", 1)) { return 1; } + break; + case (11): + C = MRIStepCoupling_LoadTable(ARKODE_IMEX_MRI_SR21); + if (check_retval((void*)C, "MRIStepCoupling_LoadTable", 0)) { return 1; } + break; + case (12): + C = MRIStepCoupling_LoadTable(ARKODE_IMEX_MRI_SR32); + if (check_retval((void*)C, "MRIStepCoupling_LoadTable", 0)) { return 1; } + break; + case (13): + C = MRIStepCoupling_LoadTable(ARKODE_IMEX_MRI_SR43); + if (check_retval((void*)C, "MRIStepCoupling_LoadTable", 0)) { return 1; } break; } + retval = MRIStepSetCoupling(arkode_mem, C); + if (check_retval(&retval, "MRIStepSetCoupling", 1)) { return 1; } + MRIStepCoupling_Free(C); /* free coupling coefficients */ + + /* Set the tolerances */ + retval = ARKodeSStolerances(arkode_mem, reltol, abstol); + if (check_retval(&retval, "ARKodeSStolerances", 1)) { return 1; } /* Set the user data pointer */ retval = ARKodeSetUserData(arkode_mem, (void*)rpar); @@ -653,8 +759,7 @@ int main(int argc, char* argv[]) else { printf(" Total RHS evals: Fs = %li, Ff = %li\n", nfse, nff); } /* Get/print slow integrator decoupled implicit solver statistics */ - if ((solve_type == 4) || (solve_type == 7) || (solve_type == 8) || - (solve_type == 9)) + if (implicit_slow || imex_slow) { retval = ARKodeGetNonlinSolvStats(arkode_mem, &nnis, &nncs); check_retval(&retval, "ARKodeGetNonlinSolvStats", 1); @@ -666,7 +771,7 @@ int main(int argc, char* argv[]) } /* Get/print fast integrator implicit solver statistics */ - if (solve_type == 2) + if (implicit_fast) { retval = ARKodeGetNonlinSolvStats(inner_arkode_mem, &nnif, &nncf); check_retval(&retval, "ARKodeGetNonlinSolvStats", 1); @@ -679,7 +784,6 @@ int main(int argc, char* argv[]) /* Clean up and return */ N_VDestroy(y); /* Free y vector */ - MRIStepCoupling_Free(C); /* free coupling coefficients */ SUNMatDestroy(Af); /* free fast matrix */ SUNLinSolFree(LSf); /* free fast linear solver */ SUNMatDestroy(As); /* free fast matrix */ @@ -869,6 +973,26 @@ static int Jn(sunrealtype t, N_Vector y, N_Vector fy, SUNMatrix J, return 0; } +static int Jf(sunrealtype t, N_Vector y, N_Vector fy, SUNMatrix J, + void* user_data, N_Vector tmp1, N_Vector tmp2, N_Vector tmp3) +{ + sunrealtype* rpar = (sunrealtype*)user_data; + const sunrealtype e = rpar[2]; + const sunrealtype u = NV_Ith_S(y, 0); + const sunrealtype v = NV_Ith_S(y, 1); + + /* fill in the Jacobian: + [ 0 0 ] + [e/2+e*(1+r(t))/(2*u^2) -1/2-(2+s(t))/(2*v^2)] */ + SM_ELEMENT_D(J, 0, 0) = ZERO; + SM_ELEMENT_D(J, 0, 1) = ZERO; + SM_ELEMENT_D(J, 1, 0) = e / TWO + e * (ONE + r(t, rpar)) / (TWO * u * u); + SM_ELEMENT_D(J, 1, 1) = -ONE / TWO - (TWO + s(t, rpar)) / (TWO * v * v); + + /* Return with success */ + return 0; +} + /* ------------------------------ * Private helper functions * ------------------------------*/ diff --git a/examples/arkode/C_serial/ark_kpr_mri.out b/examples/arkode/C_serial/ark_kpr_mri.out deleted file mode 100644 index e551c2cee3..0000000000 --- a/examples/arkode/C_serial/ark_kpr_mri.out +++ /dev/null @@ -1,69 +0,0 @@ - -Multirate nonlinear Kvaerno-Prothero-Robinson test problem: - time domain: (0,5] - hs = 0.01 - hf = 0.0001 - G = -100 - w = 100 - e = 0.5 - solver: exp-3/exp-3 (standard MIS) - - t u v uerr verr - ------------------------------------------------------ - 0.000000 1.224745 1.732051 0.00e+00 0.00e+00 - 0.100000 1.223726 1.077464 8.49e-07 8.80e-09 - 0.200000 1.220670 1.551800 8.43e-07 2.05e-08 - 0.300000 1.215595 1.467737 8.33e-07 3.10e-08 - 0.400000 1.208525 1.154583 8.19e-07 4.03e-08 - 0.500000 1.199497 1.721908 8.00e-07 4.85e-08 - 0.600000 1.188558 1.023517 7.77e-07 5.56e-08 - 0.700000 1.175765 1.622751 7.49e-07 6.17e-08 - 0.800000 1.161187 1.374632 7.16e-07 6.68e-08 - 0.900000 1.144905 1.245763 6.78e-07 7.09e-08 - 1.000000 1.127010 1.691839 6.36e-07 7.40e-08 - 1.100000 1.107610 1.000490 5.87e-07 7.62e-08 - 1.200000 1.086821 1.677552 5.33e-07 7.74e-08 - 1.300000 1.064777 1.277775 4.73e-07 7.77e-08 - 1.400000 1.041626 1.342455 4.06e-07 7.71e-08 - 1.500000 1.017531 1.642940 3.32e-07 7.55e-08 - 1.600000 0.992674 1.012112 2.51e-07 7.29e-08 - 1.700000 0.967253 1.714058 1.61e-07 6.93e-08 - 1.800000 0.941488 1.183867 6.33e-08 6.48e-08 - 1.900000 0.915617 1.437465 4.33e-08 5.91e-08 - 2.000000 0.889902 1.577082 1.59e-07 5.24e-08 - 2.100000 0.864625 1.056467 2.83e-07 4.46e-08 - 2.200000 0.840089 1.730920 4.16e-07 3.57e-08 - 2.300000 0.816616 1.101047 5.56e-07 2.56e-08 - 2.400000 0.794545 1.525051 7.01e-07 1.44e-08 - 2.500000 0.774227 1.496993 8.48e-07 2.09e-09 - 2.600000 0.756012 1.126857 9.92e-07 1.12e-08 - 2.700000 0.740245 1.727536 1.13e-06 2.54e-08 - 2.800000 0.727246 1.038393 1.25e-06 4.01e-08 - 2.900000 0.717300 1.600759 1.35e-06 5.53e-08 - 3.000000 0.710635 1.406379 1.43e-06 7.03e-08 - 3.100000 0.707411 1.214353 1.47e-06 8.49e-08 - 3.200000 0.707708 1.704026 1.47e-06 9.86e-08 - 3.300000 0.711518 1.004391 1.44e-06 1.11e-07 - 3.400000 0.718748 1.661225 1.37e-06 1.21e-07 - 3.500000 0.729225 1.310102 1.28e-06 1.30e-07 - 3.600000 0.742711 1.310080 1.16e-06 1.36e-07 - 3.700000 0.758913 1.661237 1.03e-06 1.40e-07 - 3.800000 0.777505 1.004387 8.82e-07 1.41e-07 - 3.900000 0.798143 1.704018 7.35e-07 1.40e-07 - 4.000000 0.820474 1.214374 5.88e-07 1.37e-07 - 4.100000 0.844149 1.406358 4.47e-07 1.32e-07 - 4.200000 0.868832 1.600774 3.11e-07 1.26e-07 - 4.300000 0.894204 1.038382 1.84e-07 1.18e-07 - 4.400000 0.919964 1.727533 6.62e-08 1.09e-07 - 4.500000 0.945834 1.126875 4.29e-08 9.90e-08 - 4.600000 0.971558 1.496973 1.43e-07 8.85e-08 - 4.700000 0.996898 1.525070 2.35e-07 7.76e-08 - 4.800000 1.021641 1.101030 3.18e-07 6.64e-08 - 4.900000 1.045589 1.730922 3.94e-07 5.51e-08 - 5.000000 1.068565 1.056480 4.62e-07 4.38e-08 - ------------------------------------------------------ - -Final Solver Statistics: - Steps: nsts = 501, nstf = 50601 - u error = 7.941e-07, v error = 8.255e-08, total error = 5.646e-07 - Total RHS evals: Fs = 1504, Ff = 151853 diff --git a/examples/arkode/C_serial/ark_kpr_mri_0_0.002.out b/examples/arkode/C_serial/ark_kpr_mri_0_0.002.out deleted file mode 100644 index ef1ab12278..0000000000 --- a/examples/arkode/C_serial/ark_kpr_mri_0_0.002.out +++ /dev/null @@ -1,69 +0,0 @@ - -Multirate nonlinear Kvaerno-Prothero-Robinson test problem: - time domain: (0,5] - hs = 0.002 - hf = 2e-05 - G = -100 - w = 100 - e = 0.5 - solver: exp-3/exp-3 (standard MIS) - - t u v uerr verr - ------------------------------------------------------ - 0.000000 1.224745 1.732051 0.00e+00 0.00e+00 - 0.100000 1.223725 1.077464 4.99e-09 6.32e-11 - 0.200000 1.220669 1.551800 4.96e-09 1.43e-10 - 0.300000 1.215594 1.467737 4.90e-09 2.14e-10 - 0.400000 1.208524 1.154583 4.81e-09 2.78e-10 - 0.500000 1.199496 1.721908 4.70e-09 3.33e-10 - 0.600000 1.188557 1.023517 4.57e-09 3.82e-10 - 0.700000 1.175764 1.622751 4.40e-09 4.23e-10 - 0.800000 1.161186 1.374632 4.21e-09 4.57e-10 - 0.900000 1.144904 1.245763 3.98e-09 4.85e-10 - 1.000000 1.127010 1.691839 3.73e-09 5.06e-10 - 1.100000 1.107609 1.000489 3.45e-09 5.18e-10 - 1.200000 1.086821 1.677552 3.13e-09 5.29e-10 - 1.300000 1.064777 1.277775 2.77e-09 5.29e-10 - 1.400000 1.041625 1.342455 2.38e-09 5.25e-10 - 1.500000 1.017531 1.642940 1.94e-09 5.14e-10 - 1.600000 0.992673 1.012112 1.46e-09 4.94e-10 - 1.700000 0.967253 1.714058 9.32e-10 4.72e-10 - 1.800000 0.941488 1.183867 3.54e-10 4.39e-10 - 1.900000 0.915617 1.437465 2.75e-10 4.01e-10 - 2.000000 0.889903 1.577082 9.56e-10 3.55e-10 - 2.100000 0.864625 1.056467 1.69e-09 3.05e-10 - 2.200000 0.840089 1.730920 2.47e-09 2.38e-10 - 2.300000 0.816616 1.101047 3.30e-09 1.73e-10 - 2.400000 0.794546 1.525051 4.15e-09 9.32e-11 - 2.500000 0.774227 1.496993 5.01e-09 8.75e-12 - 2.600000 0.756013 1.126857 5.86e-09 8.02e-11 - 2.700000 0.740246 1.727536 6.67e-09 1.81e-10 - 2.800000 0.727247 1.038393 7.38e-09 2.78e-10 - 2.900000 0.717301 1.600759 7.97e-09 3.85e-10 - 3.000000 0.710636 1.406380 8.40e-09 4.87e-10 - 3.100000 0.707412 1.214353 8.63e-09 5.85e-10 - 3.200000 0.707709 1.704026 8.65e-09 6.81e-10 - 3.300000 0.711520 1.004391 8.46e-09 7.60e-10 - 3.400000 0.718750 1.661225 8.06e-09 8.35e-10 - 3.500000 0.729227 1.310102 7.50e-09 8.89e-10 - 3.600000 0.742712 1.310080 6.80e-09 9.30e-10 - 3.700000 0.758914 1.661237 6.01e-09 9.57e-10 - 3.800000 0.777506 1.004387 5.16e-09 9.60e-10 - 3.900000 0.798144 1.704019 4.29e-09 9.58e-10 - 4.000000 0.820474 1.214374 3.43e-09 9.33e-10 - 4.100000 0.844149 1.406358 2.60e-09 9.00e-10 - 4.200000 0.868832 1.600774 1.81e-09 8.56e-10 - 4.300000 0.894204 1.038382 1.06e-09 7.99e-10 - 4.400000 0.919964 1.727533 3.69e-10 7.42e-10 - 4.500000 0.945834 1.126875 2.71e-10 6.70e-10 - 4.600000 0.971557 1.496974 8.58e-10 6.01e-10 - 4.700000 0.996898 1.525070 1.40e-09 5.27e-10 - 4.800000 1.021641 1.101030 1.88e-09 4.48e-10 - 4.900000 1.045589 1.730922 2.33e-09 3.74e-10 - 5.000000 1.068565 1.056480 2.73e-09 2.92e-10 - ------------------------------------------------------ - -Final Solver Statistics: - Steps: nsts = 2501, nstf = 252601 - u error = 4.671e-09, v error = 5.638e-10, total error = 3.327e-09 - Total RHS evals: Fs = 7504, Ff = 757853 diff --git a/examples/arkode/C_serial/ark_kpr_mri_2_0.005.out b/examples/arkode/C_serial/ark_kpr_mri_0_1_0.005.out similarity index 97% rename from examples/arkode/C_serial/ark_kpr_mri_2_0.005.out rename to examples/arkode/C_serial/ark_kpr_mri_0_1_0.005.out index abedbafb39..59f23631ed 100644 --- a/examples/arkode/C_serial/ark_kpr_mri_2_0.005.out +++ b/examples/arkode/C_serial/ark_kpr_mri_0_1_0.005.out @@ -6,9 +6,9 @@ Multirate nonlinear Kvaerno-Prothero-Robinson test problem: G = -100 w = 100 e = 0.5 - solver: none/dirk-3 (no slow, dirk fast) - - reltol = 1.25e-07, abstol = 1.00e-11 + slow solver: none + fast solver: esdirk-3-3 + reltol = 1.25e-07, abstol = 1.00e-11 t u v uerr verr ------------------------------------------------------ 0.000000 1.224745 1.732051 0.00e+00 0.00e+00 diff --git a/examples/arkode/C_serial/ark_kpr_mri_9_0.001_-100_100_0.5_1.out b/examples/arkode/C_serial/ark_kpr_mri_10_4_0.001_-100_100_0.5_1.out similarity index 96% rename from examples/arkode/C_serial/ark_kpr_mri_9_0.001_-100_100_0.5_1.out rename to examples/arkode/C_serial/ark_kpr_mri_10_4_0.001_-100_100_0.5_1.out index a227a0db6a..0cec3055ec 100644 --- a/examples/arkode/C_serial/ark_kpr_mri_9_0.001_-100_100_0.5_1.out +++ b/examples/arkode/C_serial/ark_kpr_mri_10_4_0.001_-100_100_0.5_1.out @@ -6,8 +6,9 @@ Multirate nonlinear Kvaerno-Prothero-Robinson test problem: G = -100 w = 100 e = 0.5 - solver: imexark4/exp-4 (IMEX-MRI4 / ERK-4-4) -- solve decoupled - reltol = 1.00e-12, abstol = 1.00e-14 + slow solver: ARKODE_IMEX_MRI_GARK4 + reltol = 1.00e-12, abstol = 1.00e-14 + fast solver: erk-4-4 t u v uerr verr ------------------------------------------------------ 0.000000 1.224745 1.732051 0.00e+00 0.00e+00 diff --git a/examples/arkode/C_serial/ark_kpr_mri_11_2_0.001.out b/examples/arkode/C_serial/ark_kpr_mri_11_2_0.001.out new file mode 100644 index 0000000000..6ace2a0eae --- /dev/null +++ b/examples/arkode/C_serial/ark_kpr_mri_11_2_0.001.out @@ -0,0 +1,73 @@ + +Multirate nonlinear Kvaerno-Prothero-Robinson test problem: + time domain: (0,5] + hs = 0.001 + hf = 1e-05 + G = -100 + w = 100 + e = 0.5 + slow solver: ARKODE_IMEX_MRI_SR21 + reltol = 1.00e-06, abstol = 1.00e-11 + fast solver: ARKODE_HEUN_EULER_2_1_2 + t u v uerr verr + ------------------------------------------------------ + 0.000000 1.224745 1.732051 0.00e+00 0.00e+00 + 0.100000 1.223724 1.077464 3.41e-07 4.18e-08 + 0.200000 1.220669 1.551800 4.37e-07 9.15e-09 + 0.300000 1.215593 1.467737 1.19e-06 1.93e-08 + 0.400000 1.208524 1.154583 5.25e-07 3.04e-09 + 0.500000 1.199497 1.721908 2.75e-07 4.77e-08 + 0.600000 1.188557 1.023517 8.00e-08 1.04e-08 + 0.700000 1.175764 1.622750 3.49e-07 5.45e-08 + 0.800000 1.161186 1.374632 2.49e-07 5.22e-08 + 0.900000 1.144903 1.245763 5.52e-07 4.13e-08 + 1.000000 1.127010 1.691839 2.30e-07 7.24e-08 + 1.100000 1.107609 1.000489 4.75e-08 1.07e-08 + 1.200000 1.086820 1.677552 2.41e-07 8.61e-08 + 1.300000 1.064776 1.277775 2.56e-07 6.28e-08 + 1.400000 1.041625 1.342455 5.27e-07 6.87e-08 + 1.500000 1.017531 1.642940 6.76e-08 8.58e-08 + 1.600000 0.992673 1.012112 1.98e-07 3.21e-08 + 1.700000 0.967253 1.714058 6.85e-08 1.01e-07 + 1.800000 0.941487 1.183866 9.72e-07 6.42e-08 + 1.900000 0.915617 1.437465 5.69e-07 8.59e-08 + 2.000000 0.889902 1.577082 5.85e-07 9.51e-08 + 2.100000 0.864625 1.056467 3.94e-07 4.96e-08 + 2.200000 0.840089 1.730920 1.99e-07 1.03e-07 + 2.300000 0.816616 1.101047 5.02e-07 5.52e-08 + 2.400000 0.794545 1.525051 5.04e-07 9.24e-08 + 2.500000 0.774227 1.496993 1.29e-07 9.43e-08 + 2.600000 0.756012 1.126857 5.61e-07 6.08e-08 + 2.700000 0.740246 1.727536 1.76e-07 1.06e-07 + 2.800000 0.727247 1.038393 2.22e-07 4.56e-08 + 2.900000 0.717301 1.600759 4.60e-07 1.01e-07 + 3.000000 0.710636 1.406379 1.73e-07 8.99e-08 + 3.100000 0.707412 1.214353 5.27e-07 7.13e-08 + 3.200000 0.707710 1.704026 1.97e-07 1.04e-07 + 3.300000 0.711519 1.004391 1.04e-07 4.02e-08 + 3.400000 0.718749 1.661225 2.20e-07 1.04e-07 + 3.500000 0.729226 1.310102 2.64e-07 8.23e-08 + 3.600000 0.742711 1.310080 3.67e-07 8.33e-08 + 3.700000 0.758914 1.661237 1.20e-08 1.02e-07 + 3.800000 0.777506 1.004387 1.78e-07 4.32e-08 + 3.900000 0.798144 1.704018 1.64e-08 1.06e-07 + 4.000000 0.820473 1.214374 1.14e-06 7.40e-08 + 4.100000 0.844149 1.406358 4.80e-07 9.06e-08 + 4.200000 0.868832 1.600774 4.07e-07 1.01e-07 + 4.300000 0.894203 1.038382 3.42e-07 5.61e-08 + 4.400000 0.919964 1.727533 1.65e-07 1.12e-07 + 4.500000 0.945833 1.126875 6.61e-07 6.93e-08 + 4.600000 0.971557 1.496973 5.02e-07 9.91e-08 + 4.700000 0.996897 1.525070 9.23e-07 1.04e-07 + 4.800000 1.021640 1.101030 4.76e-07 6.78e-08 + 4.900000 1.045589 1.730922 3.12e-07 1.11e-07 + 5.000000 1.068565 1.056480 2.37e-07 5.32e-08 + ------------------------------------------------------ + +Final Solver Statistics: + Steps: nsts = 5000, nstf = 935000 + u error = 4.564e-07, v error = 7.637e-08, total error = 3.272e-07 + Total RHS evals: Fse = 15001, Fsi = 32981, Ff = 1870050 + Slow Newton iters = 17980 + Slow Newton conv fails = 0 + Slow Jacobian evals = 250 diff --git a/examples/arkode/C_serial/ark_kpr_mri_12_3_0.005.out b/examples/arkode/C_serial/ark_kpr_mri_12_3_0.005.out new file mode 100644 index 0000000000..9004de672b --- /dev/null +++ b/examples/arkode/C_serial/ark_kpr_mri_12_3_0.005.out @@ -0,0 +1,73 @@ + +Multirate nonlinear Kvaerno-Prothero-Robinson test problem: + time domain: (0,5] + hs = 0.005 + hf = 5e-05 + G = -100 + w = 100 + e = 0.5 + slow solver: ARKODE_IMEX_MRI_SR32 + reltol = 1.25e-07, abstol = 1.00e-11 + fast solver: erk-3-3 + t u v uerr verr + ------------------------------------------------------ + 0.000000 1.224745 1.732051 0.00e+00 0.00e+00 + 0.100000 1.223725 1.077464 2.84e-08 3.07e-09 + 0.200000 1.220669 1.551800 2.84e-08 5.68e-09 + 0.300000 1.215594 1.467737 2.92e-08 8.00e-09 + 0.400000 1.208524 1.154583 2.94e-08 1.01e-08 + 0.500000 1.199496 1.721908 2.86e-08 1.18e-08 + 0.600000 1.188557 1.023517 2.66e-08 1.34e-08 + 0.700000 1.175764 1.622750 2.55e-08 1.47e-08 + 0.800000 1.161186 1.374632 2.74e-08 1.57e-08 + 0.900000 1.144904 1.245763 2.77e-08 1.65e-08 + 1.000000 1.127010 1.691839 2.65e-08 1.71e-08 + 1.100000 1.107609 1.000489 2.19e-08 1.75e-08 + 1.200000 1.086821 1.677552 1.79e-08 1.76e-08 + 1.300000 1.064777 1.277775 1.99e-08 1.76e-08 + 1.400000 1.041625 1.342455 2.04e-08 1.73e-08 + 1.500000 1.017531 1.642940 1.99e-08 1.67e-08 + 1.600000 0.992673 1.012112 1.36e-08 1.60e-08 + 1.700000 0.967253 1.714058 6.17e-09 1.50e-08 + 1.800000 0.941488 1.183867 5.03e-09 1.38e-08 + 1.900000 0.915617 1.437465 4.85e-09 1.24e-08 + 2.000000 0.889903 1.577082 5.33e-09 1.06e-08 + 2.100000 0.864625 1.056467 1.38e-09 8.64e-09 + 2.200000 0.840089 1.730920 1.11e-08 6.36e-09 + 2.300000 0.816616 1.101047 1.77e-08 3.89e-09 + 2.400000 0.794546 1.525051 2.04e-08 1.22e-09 + 2.500000 0.774227 1.496993 1.96e-08 1.74e-09 + 2.600000 0.756013 1.126857 2.53e-08 4.94e-09 + 2.700000 0.740246 1.727536 3.36e-08 8.35e-09 + 2.800000 0.727247 1.038393 4.17e-08 1.18e-08 + 2.900000 0.717301 1.600759 4.50e-08 1.53e-08 + 3.000000 0.710636 1.406380 4.43e-08 1.88e-08 + 3.100000 0.707412 1.214353 4.62e-08 2.20e-08 + 3.200000 0.707709 1.704026 4.79e-08 2.50e-08 + 3.300000 0.711520 1.004391 4.75e-08 2.76e-08 + 3.400000 0.718749 1.661225 4.48e-08 2.98e-08 + 3.500000 0.729227 1.310102 1.02e-07 3.08e-08 + 3.600000 0.742712 1.310080 4.22e-08 3.17e-08 + 3.700000 0.758914 1.661237 4.00e-08 3.23e-08 + 3.800000 0.777506 1.004387 3.22e-08 3.23e-08 + 3.900000 0.798144 1.704019 2.37e-08 3.17e-08 + 4.000000 0.820474 1.214374 2.24e-08 3.08e-08 + 4.100000 0.844149 1.406358 2.13e-08 2.95e-08 + 4.200000 0.868832 1.600774 2.06e-08 2.78e-08 + 4.300000 0.894204 1.038382 1.34e-08 2.58e-08 + 4.400000 0.919964 1.727533 4.37e-09 2.35e-08 + 4.500000 0.945834 1.126875 4.59e-10 2.11e-08 + 4.600000 0.971557 1.496974 1.59e-10 1.87e-08 + 4.700000 0.996898 1.525070 1.78e-09 1.61e-08 + 4.800000 1.021641 1.101030 2.16e-09 1.34e-08 + 4.900000 1.045589 1.730922 8.50e-09 1.07e-08 + 5.000000 1.068565 1.056480 1.41e-08 8.06e-09 + ------------------------------------------------------ + +Final Solver Statistics: + Steps: nsts = 1001, nstf = 362362 + u error = 2.987e-08, v error = 1.896e-08, total error = 2.502e-08 + Total RHS evals: Fse = 4005, Fsi = 12096, Ff = 1087136 + Slow Newton iters = 8091 + Slow Newton conv fails = 0 + Slow Jacobian evals = 51 diff --git a/examples/arkode/C_serial/ark_kpr_mri_13_4_0.01.out b/examples/arkode/C_serial/ark_kpr_mri_13_4_0.01.out new file mode 100644 index 0000000000..73178461e3 --- /dev/null +++ b/examples/arkode/C_serial/ark_kpr_mri_13_4_0.01.out @@ -0,0 +1,73 @@ + +Multirate nonlinear Kvaerno-Prothero-Robinson test problem: + time domain: (0,5] + hs = 0.01 + hf = 0.0001 + G = -100 + w = 100 + e = 0.5 + slow solver: ARKODE_IMEX_MRI_SR43 + reltol = 1.00e-08, abstol = 1.00e-14 + fast solver: erk-4-4 + t u v uerr verr + ------------------------------------------------------ + 0.000000 1.224745 1.732051 0.00e+00 0.00e+00 + 0.100000 1.223725 1.077464 7.51e-08 2.97e-08 + 0.200000 1.220669 1.551800 7.47e-08 5.67e-08 + 0.300000 1.215594 1.467737 7.40e-08 8.08e-08 + 0.400000 1.208524 1.154583 7.27e-08 1.02e-07 + 0.500000 1.199496 1.721908 7.14e-08 1.21e-07 + 0.600000 1.188557 1.023517 6.91e-08 1.37e-07 + 0.700000 1.175764 1.622750 6.68e-08 1.51e-07 + 0.800000 1.161186 1.374632 6.39e-08 1.62e-07 + 0.900000 1.144904 1.245763 6.08e-08 1.72e-07 + 1.000000 1.127010 1.691839 5.67e-08 1.78e-07 + 1.100000 1.107609 1.000489 5.49e-08 1.83e-07 + 1.200000 1.086820 1.677552 4.79e-08 1.85e-07 + 1.300000 1.064777 1.277775 4.43e-08 1.85e-07 + 1.400000 1.041625 1.342455 3.64e-08 1.83e-07 + 1.500000 1.017531 1.642940 3.04e-08 1.78e-07 + 1.600000 0.992673 1.012112 2.26e-08 1.71e-07 + 1.700000 0.967253 1.714058 1.02e-08 1.62e-07 + 1.800000 0.941488 1.183866 6.48e-09 1.50e-07 + 1.900000 0.915617 1.437465 3.83e-09 1.36e-07 + 2.000000 0.889903 1.577082 1.47e-08 1.19e-07 + 2.100000 0.864625 1.056467 2.49e-08 9.99e-08 + 2.200000 0.840089 1.730920 3.69e-08 7.77e-08 + 2.300000 0.816616 1.101047 5.28e-08 5.28e-08 + 2.400000 0.794546 1.525051 6.32e-08 2.50e-08 + 2.500000 0.774228 1.496993 7.57e-08 5.17e-09 + 2.600000 0.756013 1.126857 8.93e-08 3.76e-08 + 2.700000 0.740246 1.727536 1.01e-07 7.19e-08 + 2.800000 0.727248 1.038393 1.12e-07 1.07e-07 + 2.900000 0.717301 1.600759 1.21e-07 1.44e-07 + 3.000000 0.710636 1.406380 1.27e-07 1.79e-07 + 3.100000 0.707413 1.214353 1.31e-07 2.13e-07 + 3.200000 0.707710 1.704026 1.31e-07 2.45e-07 + 3.300000 0.711520 1.004391 1.28e-07 2.73e-07 + 3.400000 0.718750 1.661225 1.22e-07 2.97e-07 + 3.500000 0.729227 1.310102 1.14e-07 3.15e-07 + 3.600000 0.742712 1.310080 1.03e-07 3.28e-07 + 3.700000 0.758914 1.661237 9.11e-08 3.35e-07 + 3.800000 0.777506 1.004387 7.85e-08 3.36e-07 + 3.900000 0.798144 1.704019 6.30e-08 3.32e-07 + 4.000000 0.820474 1.214374 5.22e-08 3.23e-07 + 4.100000 0.844149 1.406358 4.01e-08 3.10e-07 + 4.200000 0.868832 1.600775 2.78e-08 2.94e-07 + 4.300000 0.894204 1.038382 1.74e-08 2.74e-07 + 4.400000 0.919964 1.727534 6.17e-09 2.52e-07 + 4.500000 0.945834 1.126875 2.12e-09 2.28e-07 + 4.600000 0.971557 1.496974 1.37e-08 2.03e-07 + 4.700000 0.996898 1.525070 1.98e-08 1.77e-07 + 4.800000 1.021641 1.101030 2.80e-08 1.50e-07 + 4.900000 1.045589 1.730922 4.06e-08 1.23e-07 + 5.000000 1.068565 1.056480 4.09e-08 9.60e-08 + ------------------------------------------------------ + +Final Solver Statistics: + Steps: nsts = 501, nstf = 202905 + u error = 7.089e-08, v error = 1.970e-07, total error = 1.480e-07 + Total RHS evals: Fse = 3007, Fsi = 8869, Ff = 811670 + Slow Newton iters = 5862 + Slow Newton conv fails = 0 + Slow Jacobian evals = 26 diff --git a/examples/arkode/C_serial/ark_kpr_mri_1_0.002.out b/examples/arkode/C_serial/ark_kpr_mri_1_0.002.out deleted file mode 100644 index 2cb8b8d4ff..0000000000 --- a/examples/arkode/C_serial/ark_kpr_mri_1_0.002.out +++ /dev/null @@ -1,69 +0,0 @@ - -Multirate nonlinear Kvaerno-Prothero-Robinson test problem: - time domain: (0,5] - hs = 0.002 - hf = 2e-05 - G = -100 - w = 100 - e = 0.5 - solver: none/exp-3 (no slow, explicit fast) - - t u v uerr verr - ------------------------------------------------------ - 0.000000 1.224745 1.732051 0.00e+00 0.00e+00 - 0.100000 1.223725 1.077464 5.15e-13 1.86e-13 - 0.200000 1.220669 1.551800 3.61e-13 4.93e-14 - 0.300000 1.215594 1.467737 2.05e-13 2.51e-13 - 0.400000 1.208524 1.154583 9.50e-14 5.58e-13 - 0.500000 1.199496 1.721908 2.07e-13 4.33e-14 - 0.600000 1.188557 1.023517 4.75e-13 6.09e-13 - 0.700000 1.175764 1.622751 3.64e-13 3.18e-14 - 0.800000 1.161186 1.374632 3.10e-13 2.24e-13 - 0.900000 1.144904 1.245763 1.97e-13 3.70e-13 - 1.000000 1.127010 1.691839 1.30e-13 1.26e-13 - 1.100000 1.107609 1.000489 3.46e-13 3.11e-12 - 1.200000 1.086821 1.677552 3.71e-13 7.33e-14 - 1.300000 1.064777 1.277775 3.83e-13 1.61e-12 - 1.400000 1.041625 1.342455 2.93e-13 1.22e-12 - 1.500000 1.017531 1.642940 5.93e-14 2.38e-13 - 1.600000 0.992673 1.012112 2.03e-13 2.53e-12 - 1.700000 0.967253 1.714058 3.44e-13 7.20e-13 - 1.800000 0.941488 1.183867 4.52e-13 1.59e-12 - 1.900000 0.915617 1.437465 3.44e-13 3.82e-13 - 2.000000 0.889903 1.577082 3.50e-14 3.23e-13 - 2.100000 0.864625 1.056467 9.49e-14 3.63e-12 - 2.200000 0.840089 1.730920 2.82e-13 9.77e-13 - 2.300000 0.816616 1.101047 5.31e-13 3.10e-12 - 2.400000 0.794546 1.525051 3.55e-13 1.45e-13 - 2.500000 0.774227 1.496993 1.73e-13 1.47e-13 - 2.600000 0.756013 1.126857 5.61e-14 2.76e-12 - 2.700000 0.740246 1.727536 2.34e-13 1.63e-12 - 2.800000 0.727247 1.038393 4.93e-13 3.33e-12 - 2.900000 0.717301 1.600759 3.84e-13 8.97e-13 - 3.000000 0.710636 1.406380 2.69e-13 3.69e-13 - 3.100000 0.707412 1.214353 1.84e-13 1.89e-12 - 3.200000 0.707709 1.704026 1.75e-13 1.92e-12 - 3.300000 0.711520 1.004391 3.96e-13 3.62e-12 - 3.400000 0.718750 1.661225 3.90e-13 1.72e-12 - 3.500000 0.729227 1.310102 3.60e-13 8.16e-13 - 3.600000 0.742712 1.310080 2.78e-13 9.20e-13 - 3.700000 0.758914 1.661237 9.77e-14 1.96e-12 - 3.800000 0.777506 1.004387 2.59e-13 3.77e-12 - 3.900000 0.798144 1.704019 3.72e-13 2.32e-12 - 4.000000 0.820474 1.214374 4.43e-13 1.53e-12 - 4.100000 0.844149 1.406358 3.40e-13 1.78e-14 - 4.200000 0.868832 1.600774 6.66e-16 1.74e-12 - 4.300000 0.894204 1.038382 1.07e-13 3.58e-12 - 4.400000 0.919964 1.727533 3.31e-13 2.75e-12 - 4.500000 0.945834 1.126875 4.96e-13 2.41e-12 - 4.600000 0.971557 1.496974 3.76e-13 9.10e-13 - 4.700000 0.996898 1.525070 1.11e-13 1.32e-12 - 4.800000 1.021641 1.101030 3.06e-14 2.99e-12 - 4.900000 1.045589 1.730922 2.75e-13 3.00e-12 - 5.000000 1.068565 1.056480 5.02e-13 3.36e-12 - ------------------------------------------------------ - -Final Solver Statistics: - Steps: nsts = 2501, nstf = 252601 - u error = 3.156e-13, v error = 1.909e-12, total error = 1.368e-12 - Total RHS evals: Fs = 5003, Ff = 757853 diff --git a/examples/arkode/C_serial/ark_kpr_mri_3_0.01.out b/examples/arkode/C_serial/ark_kpr_mri_1_0_0.01.out similarity index 98% rename from examples/arkode/C_serial/ark_kpr_mri_3_0.01.out rename to examples/arkode/C_serial/ark_kpr_mri_1_0_0.01.out index 9504b4c524..2c625caeca 100644 --- a/examples/arkode/C_serial/ark_kpr_mri_3_0.01.out +++ b/examples/arkode/C_serial/ark_kpr_mri_1_0_0.01.out @@ -6,7 +6,8 @@ Multirate nonlinear Kvaerno-Prothero-Robinson test problem: G = -100 w = 100 e = 0.5 - solver: exp-3/none (explicit slow, no fast) + slow solver: ARKODE_MIS_KW3 + fast solver: none t u v uerr verr ------------------------------------------------------ 0.000000 1.224745 1.732051 0.00e+00 0.00e+00 diff --git a/examples/arkode/C_serial/ark_kpr_mri_1_1_0.002.out b/examples/arkode/C_serial/ark_kpr_mri_1_1_0.002.out new file mode 100644 index 0000000000..ce045454c5 --- /dev/null +++ b/examples/arkode/C_serial/ark_kpr_mri_1_1_0.002.out @@ -0,0 +1,73 @@ + +Multirate nonlinear Kvaerno-Prothero-Robinson test problem: + time domain: (0,5] + hs = 0.002 + hf = 2e-05 + G = -100 + w = 100 + e = 0.5 + slow solver: ARKODE_MIS_KW3 + fast solver: esdirk-3-3 + reltol = 8.00e-09, abstol = 1.00e-11 + t u v uerr verr + ------------------------------------------------------ + 0.000000 1.224745 1.732051 0.00e+00 0.00e+00 + 0.100000 1.223725 1.077464 4.99e-09 6.44e-11 + 0.200000 1.220669 1.551800 4.96e-09 1.43e-10 + 0.300000 1.215594 1.467737 4.90e-09 2.14e-10 + 0.400000 1.208524 1.154583 4.81e-09 2.79e-10 + 0.500000 1.199496 1.721908 4.70e-09 3.33e-10 + 0.600000 1.188557 1.023517 4.57e-09 3.84e-10 + 0.700000 1.175764 1.622751 4.40e-09 4.23e-10 + 0.800000 1.161186 1.374632 4.21e-09 4.58e-10 + 0.900000 1.144904 1.245763 3.98e-09 4.86e-10 + 1.000000 1.127010 1.691839 3.73e-09 5.06e-10 + 1.100000 1.107609 1.000489 3.45e-09 5.20e-10 + 1.200000 1.086821 1.677552 3.13e-09 5.29e-10 + 1.300000 1.064777 1.277775 2.77e-09 5.30e-10 + 1.400000 1.041625 1.342455 2.38e-09 5.25e-10 + 1.500000 1.017531 1.642940 1.94e-09 5.15e-10 + 1.600000 0.992673 1.012112 1.46e-09 4.96e-10 + 1.700000 0.967253 1.714058 9.32e-10 4.72e-10 + 1.800000 0.941488 1.183867 3.54e-10 4.40e-10 + 1.900000 0.915617 1.437465 2.75e-10 4.01e-10 + 2.000000 0.889903 1.577082 9.56e-10 3.55e-10 + 2.100000 0.864625 1.056467 1.69e-09 3.06e-10 + 2.200000 0.840089 1.730920 2.47e-09 2.39e-10 + 2.300000 0.816616 1.101047 3.30e-09 1.74e-10 + 2.400000 0.794546 1.525051 4.15e-09 9.35e-11 + 2.500000 0.774227 1.496993 5.01e-09 9.06e-12 + 2.600000 0.756013 1.126857 5.86e-09 7.92e-11 + 2.700000 0.740246 1.727536 6.67e-09 1.81e-10 + 2.800000 0.727247 1.038393 7.38e-09 2.77e-10 + 2.900000 0.717301 1.600759 7.97e-09 3.85e-10 + 3.000000 0.710636 1.406380 8.40e-09 4.86e-10 + 3.100000 0.707412 1.214353 8.63e-09 5.84e-10 + 3.200000 0.707709 1.704026 8.65e-09 6.81e-10 + 3.300000 0.711520 1.004391 8.46e-09 7.58e-10 + 3.400000 0.718750 1.661225 8.06e-09 8.35e-10 + 3.500000 0.729227 1.310102 7.50e-09 8.89e-10 + 3.600000 0.742712 1.310080 6.80e-09 9.29e-10 + 3.700000 0.758914 1.661237 6.01e-09 9.56e-10 + 3.800000 0.777506 1.004387 5.16e-09 9.59e-10 + 3.900000 0.798144 1.704019 4.29e-09 9.58e-10 + 4.000000 0.820474 1.214374 3.43e-09 9.32e-10 + 4.100000 0.844149 1.406358 2.60e-09 9.00e-10 + 4.200000 0.868832 1.600774 1.81e-09 8.56e-10 + 4.300000 0.894204 1.038382 1.06e-09 7.97e-10 + 4.400000 0.919964 1.727533 3.69e-10 7.42e-10 + 4.500000 0.945834 1.126875 2.71e-10 6.69e-10 + 4.600000 0.971557 1.496974 8.58e-10 6.01e-10 + 4.700000 0.996898 1.525070 1.40e-09 5.27e-10 + 4.800000 1.021641 1.101030 1.88e-09 4.46e-10 + 4.900000 1.045589 1.730922 2.33e-09 3.74e-10 + 5.000000 1.068565 1.056480 2.73e-09 2.91e-10 + ------------------------------------------------------ + +Final Solver Statistics: + Steps: nsts = 2501, nstf = 252601 + u error = 4.671e-09, v error = 5.637e-10, total error = 3.327e-09 + Total RHS evals: Fs = 7504, Ff = 0 + Fast Newton iters = 653849 + Fast Newton conv fails = 0 + Fast Jacobian evals = 4169 diff --git a/examples/arkode/C_serial/ark_kpr_mri_5_0.002.out b/examples/arkode/C_serial/ark_kpr_mri_2_4_0.002.out similarity index 98% rename from examples/arkode/C_serial/ark_kpr_mri_5_0.002.out rename to examples/arkode/C_serial/ark_kpr_mri_2_4_0.002.out index 1a38aa16e6..b8abfa84b0 100644 --- a/examples/arkode/C_serial/ark_kpr_mri_5_0.002.out +++ b/examples/arkode/C_serial/ark_kpr_mri_2_4_0.002.out @@ -6,8 +6,8 @@ Multirate nonlinear Kvaerno-Prothero-Robinson test problem: G = -100 w = 100 e = 0.5 - solver: exp-4/exp-4 (MRI-GARK-ERK45a / ERK-4-4) - + slow solver: ARKODE_MRI_GARK_ERK45a + fast solver: erk-4-4 t u v uerr verr ------------------------------------------------------ 0.000000 1.224745 1.732051 0.00e+00 0.00e+00 diff --git a/examples/arkode/C_serial/ark_kpr_mri_3_2_0.001.out b/examples/arkode/C_serial/ark_kpr_mri_3_2_0.001.out new file mode 100644 index 0000000000..f5196d7797 --- /dev/null +++ b/examples/arkode/C_serial/ark_kpr_mri_3_2_0.001.out @@ -0,0 +1,69 @@ + +Multirate nonlinear Kvaerno-Prothero-Robinson test problem: + time domain: (0,5] + hs = 0.001 + hf = 1e-05 + G = -100 + w = 100 + e = 0.5 + slow solver: ARKODE_MERK21 + fast solver: ARKODE_HEUN_EULER_2_1_2 + t u v uerr verr + ------------------------------------------------------ + 0.000000 1.224745 1.732051 0.00e+00 0.00e+00 + 0.100000 1.223725 1.077464 2.66e-08 4.86e-08 + 0.200000 1.220669 1.551800 2.66e-08 1.34e-09 + 0.300000 1.215594 1.467737 2.62e-08 4.29e-09 + 0.400000 1.208524 1.154583 2.58e-08 2.80e-08 + 0.500000 1.199496 1.721908 2.53e-08 1.39e-08 + 0.600000 1.188557 1.023517 2.44e-08 4.48e-08 + 0.700000 1.175764 1.622750 2.37e-08 1.39e-08 + 0.800000 1.161186 1.374632 2.25e-08 9.64e-11 + 0.900000 1.144904 1.245763 2.14e-08 8.43e-09 + 1.000000 1.127010 1.691839 2.01e-08 2.07e-08 + 1.100000 1.107609 1.000490 1.84e-08 4.20e-08 + 1.200000 1.086821 1.677552 1.69e-08 2.25e-08 + 1.300000 1.064777 1.277775 1.48e-08 2.79e-09 + 1.400000 1.041625 1.342455 1.28e-08 4.44e-09 + 1.500000 1.017531 1.642940 1.04e-08 2.19e-08 + 1.600000 0.992673 1.012112 7.76e-09 3.67e-08 + 1.700000 0.967253 1.714058 5.06e-09 2.59e-08 + 1.800000 0.941488 1.183867 1.75e-09 1.13e-08 + 1.900000 0.915617 1.437465 1.44e-09 1.16e-08 + 2.000000 0.889903 1.577082 5.21e-09 1.82e-08 + 2.100000 0.864625 1.056467 9.17e-09 2.94e-08 + 2.200000 0.840089 1.730920 1.33e-08 2.47e-08 + 2.300000 0.816616 1.101047 1.79e-08 2.45e-08 + 2.400000 0.794546 1.525051 2.23e-08 1.36e-08 + 2.500000 0.774228 1.496993 2.71e-08 9.85e-09 + 2.600000 0.756013 1.126857 3.16e-08 2.30e-08 + 2.700000 0.740246 1.727536 3.59e-08 1.92e-08 + 2.800000 0.727247 1.038393 3.99e-08 4.04e-08 + 2.900000 0.717301 1.600759 4.28e-08 1.12e-08 + 3.000000 0.710636 1.406380 4.52e-08 2.44e-09 + 3.100000 0.707413 1.214353 4.63e-08 1.90e-08 + 3.200000 0.707709 1.704026 4.64e-08 1.14e-08 + 3.300000 0.711520 1.004391 4.55e-08 5.32e-08 + 3.400000 0.718750 1.661225 4.31e-08 8.10e-09 + 3.500000 0.729227 1.310102 4.03e-08 1.50e-08 + 3.600000 0.742712 1.310080 3.64e-08 1.43e-08 + 3.700000 0.758914 1.661237 3.21e-08 6.04e-09 + 3.800000 0.777506 1.004387 2.77e-08 5.53e-08 + 3.900000 0.798144 1.704019 2.29e-08 8.68e-09 + 4.000000 0.820474 1.214374 1.85e-08 2.42e-08 + 4.100000 0.844149 1.406358 1.38e-08 6.00e-09 + 4.200000 0.868832 1.600774 9.67e-09 4.99e-09 + 4.300000 0.894204 1.038382 5.70e-09 4.57e-08 + 4.400000 0.919964 1.727533 1.89e-09 1.31e-08 + 4.500000 0.945834 1.126875 1.34e-09 3.06e-08 + 4.600000 0.971557 1.496974 4.69e-09 4.31e-09 + 4.700000 0.996898 1.525070 7.45e-09 5.97e-09 + 4.800000 1.021641 1.101030 1.01e-08 2.99e-08 + 4.900000 1.045589 1.730922 1.25e-08 1.86e-08 + 5.000000 1.068565 1.056480 1.45e-08 3.56e-08 + ------------------------------------------------------ + +Final Solver Statistics: + Steps: nsts = 5000, nstf = 750000 + u error = 2.508e-08, v error = 2.443e-08, total error = 2.476e-08 + Total RHS evals: Fs = 10001, Ff = 1500050 diff --git a/examples/arkode/C_serial/ark_kpr_mri_4_0.002.out b/examples/arkode/C_serial/ark_kpr_mri_4_0.002.out deleted file mode 100644 index 9f53b0e3b4..0000000000 --- a/examples/arkode/C_serial/ark_kpr_mri_4_0.002.out +++ /dev/null @@ -1,72 +0,0 @@ - -Multirate nonlinear Kvaerno-Prothero-Robinson test problem: - time domain: (0,5] - hs = 0.002 - hf = 2e-05 - G = -100 - w = 100 - e = 0.5 - solver: dirk-2/none (dirk slow, no fast) - reltol = 4.00e-06, abstol = 1.00e-11 - t u v uerr verr - ------------------------------------------------------ - 0.000000 1.224745 1.732051 0.00e+00 0.00e+00 - 0.100000 1.223734 1.079428 9.43e-06 1.96e-03 - 0.200000 1.220669 1.551975 3.21e-07 1.75e-04 - 0.300000 1.215599 1.468008 5.52e-06 2.71e-04 - 0.400000 1.208526 1.155919 2.23e-06 1.34e-03 - 0.500000 1.199497 1.721561 8.79e-07 3.47e-04 - 0.600000 1.188564 1.025537 7.38e-06 2.02e-03 - 0.700000 1.175763 1.622485 1.23e-06 2.66e-04 - 0.800000 1.161186 1.374900 2.52e-07 2.68e-04 - 0.900000 1.144904 1.246450 1.12e-07 6.87e-04 - 1.000000 1.127010 1.691322 5.38e-07 5.17e-04 - 1.100000 1.107615 1.002500 5.42e-06 2.01e-03 - 1.200000 1.086818 1.677003 2.06e-06 5.49e-04 - 1.300000 1.064782 1.278198 5.48e-06 4.23e-04 - 1.400000 1.041624 1.342655 1.37e-06 2.00e-04 - 1.500000 1.017531 1.642375 7.35e-07 5.65e-04 - 1.600000 0.992677 1.013911 3.39e-06 1.80e-03 - 1.700000 0.967249 1.713353 3.48e-06 7.05e-04 - 1.800000 0.941493 1.184579 5.35e-06 7.12e-04 - 1.900000 0.915615 1.437305 2.35e-06 1.61e-04 - 2.000000 0.889904 1.576564 1.28e-06 5.18e-04 - 2.100000 0.864627 1.057868 1.53e-06 1.40e-03 - 2.200000 0.840087 1.730117 2.43e-06 8.03e-04 - 2.300000 0.816622 1.102136 5.78e-06 1.09e-03 - 2.400000 0.794543 1.524625 3.12e-06 4.26e-04 - 2.500000 0.774230 1.496597 2.15e-06 3.96e-04 - 2.600000 0.756013 1.127800 7.68e-08 9.44e-04 - 2.700000 0.740244 1.726696 1.85e-06 8.41e-04 - 2.800000 0.727253 1.039861 5.33e-06 1.47e-03 - 2.900000 0.717298 1.600138 3.24e-06 6.21e-04 - 3.000000 0.710633 1.406200 3.03e-06 1.79e-04 - 3.100000 0.707411 1.214845 1.22e-06 4.92e-04 - 3.200000 0.707708 1.703196 1.21e-06 8.30e-04 - 3.300000 0.711524 1.006102 4.35e-06 1.71e-03 - 3.400000 0.718746 1.660466 3.40e-06 7.59e-04 - 3.500000 0.729231 1.310194 4.07e-06 9.26e-05 - 3.600000 0.742710 1.310190 2.18e-06 1.11e-04 - 3.700000 0.758913 1.660462 4.65e-07 7.74e-04 - 3.800000 0.777509 1.006087 3.06e-06 1.70e-03 - 3.900000 0.798140 1.703188 3.88e-06 8.31e-04 - 4.000000 0.820479 1.214819 4.63e-06 4.45e-04 - 4.100000 0.844147 1.406163 2.79e-06 1.95e-04 - 4.200000 0.868833 1.600102 4.16e-07 6.73e-04 - 4.300000 0.894205 1.039813 1.50e-06 1.43e-03 - 4.400000 0.919961 1.726651 2.81e-06 8.83e-04 - 4.500000 0.945839 1.127737 5.31e-06 8.63e-04 - 4.600000 0.971554 1.496541 3.29e-06 4.33e-04 - 4.700000 0.996899 1.524547 1.45e-06 5.23e-04 - 4.800000 1.021641 1.102066 8.60e-08 1.04e-03 - 4.900000 1.045587 1.730025 2.02e-06 8.96e-04 - 5.000000 1.068570 1.057773 5.26e-06 1.29e-03 - ------------------------------------------------------ - -Final Solver Statistics: - Steps: nsts = 2501, nstf = 250100 - u error = 3.482e-06, v error = 9.535e-04, total error = 6.742e-04 - Total RHS evals: Fs = 7143, Ff = 750350 - Slow Newton iters = 4641 - Slow Newton conv fails = 0 - Slow Jacobian evals = 126 diff --git a/examples/arkode/C_serial/ark_kpr_mri_4_3_0.001.out b/examples/arkode/C_serial/ark_kpr_mri_4_3_0.001.out new file mode 100644 index 0000000000..5002013f25 --- /dev/null +++ b/examples/arkode/C_serial/ark_kpr_mri_4_3_0.001.out @@ -0,0 +1,69 @@ + +Multirate nonlinear Kvaerno-Prothero-Robinson test problem: + time domain: (0,5] + hs = 0.001 + hf = 1e-05 + G = -100 + w = 100 + e = 0.5 + slow solver: ARKODE_MERK32 + fast solver: erk-3-3 + t u v uerr verr + ------------------------------------------------------ + 0.000000 1.224745 1.732051 0.00e+00 0.00e+00 + 0.100000 1.223725 1.077464 8.92e-10 3.75e-11 + 0.200000 1.220669 1.551800 8.86e-10 7.57e-11 + 0.300000 1.215594 1.467737 8.75e-10 1.10e-10 + 0.400000 1.208524 1.154583 8.59e-10 1.40e-10 + 0.500000 1.199496 1.721908 8.39e-10 1.66e-10 + 0.600000 1.188557 1.023517 8.15e-10 1.89e-10 + 0.700000 1.175764 1.622751 7.85e-10 2.09e-10 + 0.800000 1.161186 1.374632 7.50e-10 2.25e-10 + 0.900000 1.144904 1.245763 7.10e-10 2.38e-10 + 1.000000 1.127010 1.691839 6.65e-10 2.47e-10 + 1.100000 1.107609 1.000489 6.13e-10 2.58e-10 + 1.200000 1.086821 1.677552 5.56e-10 2.57e-10 + 1.300000 1.064777 1.277775 4.92e-10 2.59e-10 + 1.400000 1.041625 1.342455 4.21e-10 2.56e-10 + 1.500000 1.017531 1.642940 3.43e-10 2.47e-10 + 1.600000 0.992673 1.012112 2.56e-10 2.42e-10 + 1.700000 0.967253 1.714058 1.61e-10 2.25e-10 + 1.800000 0.941488 1.183867 5.78e-11 2.12e-10 + 1.900000 0.915617 1.437465 5.52e-11 1.90e-10 + 2.000000 0.889903 1.577082 1.78e-10 1.66e-10 + 2.100000 0.864625 1.056467 3.09e-10 1.42e-10 + 2.200000 0.840089 1.730920 4.50e-10 1.07e-10 + 2.300000 0.816616 1.101047 5.97e-10 7.65e-11 + 2.400000 0.794546 1.525051 7.50e-10 3.53e-11 + 2.500000 0.774227 1.496993 9.05e-10 6.53e-12 + 2.600000 0.756013 1.126857 1.06e-09 4.93e-11 + 2.700000 0.740246 1.727536 1.20e-09 1.01e-10 + 2.800000 0.727247 1.038393 1.33e-09 1.46e-10 + 2.900000 0.717301 1.600759 1.43e-09 2.00e-10 + 3.000000 0.710636 1.406380 1.50e-09 2.49e-10 + 3.100000 0.707412 1.214353 1.54e-09 2.95e-10 + 3.200000 0.707709 1.704026 1.55e-09 3.43e-10 + 3.300000 0.711520 1.004391 1.51e-09 3.77e-10 + 3.400000 0.718750 1.661225 1.44e-09 4.14e-10 + 3.500000 0.729227 1.310102 1.33e-09 4.38e-10 + 3.600000 0.742712 1.310080 1.21e-09 4.56e-10 + 3.700000 0.758914 1.661237 1.07e-09 4.68e-10 + 3.800000 0.777506 1.004387 9.14e-10 4.66e-10 + 3.900000 0.798144 1.704019 7.60e-10 4.65e-10 + 4.000000 0.820474 1.214374 6.06e-10 4.50e-10 + 4.100000 0.844149 1.406358 4.58e-10 4.31e-10 + 4.200000 0.868832 1.600774 3.16e-10 4.10e-10 + 4.300000 0.894204 1.038382 1.84e-10 3.81e-10 + 4.400000 0.919964 1.727533 6.02e-11 3.51e-10 + 4.500000 0.945834 1.126875 5.36e-11 3.19e-10 + 4.600000 0.971557 1.496974 1.58e-10 2.82e-10 + 4.700000 0.996898 1.525070 2.54e-10 2.47e-10 + 4.800000 1.021641 1.101030 3.41e-10 2.09e-10 + 4.900000 1.045589 1.730922 4.20e-10 1.72e-10 + 5.000000 1.068565 1.056480 4.91e-10 1.34e-10 + ------------------------------------------------------ + +Final Solver Statistics: + Steps: nsts = 5000, nstf = 1085000 + u error = 8.345e-10, v error = 2.743e-10, total error = 6.212e-10 + Total RHS evals: Fs = 15001, Ff = 3255050 diff --git a/examples/arkode/C_serial/ark_kpr_mri_5_4_0.001.out b/examples/arkode/C_serial/ark_kpr_mri_5_4_0.001.out new file mode 100644 index 0000000000..292e3d4c0a --- /dev/null +++ b/examples/arkode/C_serial/ark_kpr_mri_5_4_0.001.out @@ -0,0 +1,69 @@ + +Multirate nonlinear Kvaerno-Prothero-Robinson test problem: + time domain: (0,5] + hs = 0.001 + hf = 1e-05 + G = -100 + w = 100 + e = 0.5 + slow solver: ARKODE_MERK43 + fast solver: erk-4-4 + t u v uerr verr + ------------------------------------------------------ + 0.000000 1.224745 1.732051 0.00e+00 0.00e+00 + 0.100000 1.223725 1.077464 2.23e-11 1.15e-12 + 0.200000 1.220669 1.551800 2.21e-11 1.92e-12 + 0.300000 1.215594 1.467737 2.19e-11 2.71e-12 + 0.400000 1.208524 1.154583 2.15e-11 3.14e-12 + 0.500000 1.199496 1.721908 2.10e-11 4.37e-12 + 0.600000 1.188557 1.023517 2.03e-11 4.94e-12 + 0.700000 1.175764 1.622751 1.96e-11 5.31e-12 + 0.800000 1.161186 1.374632 1.87e-11 5.82e-12 + 0.900000 1.144904 1.245763 1.77e-11 5.97e-12 + 1.000000 1.127010 1.691839 1.66e-11 6.30e-12 + 1.100000 1.107609 1.000489 1.54e-11 2.00e-12 + 1.200000 1.086821 1.677552 1.43e-11 6.20e-12 + 1.300000 1.064777 1.277775 1.29e-11 6.14e-12 + 1.400000 1.041625 1.342455 1.14e-11 1.56e-12 + 1.500000 1.017531 1.642940 9.78e-12 9.89e-12 + 1.600000 0.992673 1.012112 7.92e-12 4.47e-13 + 1.700000 0.967253 1.714058 5.88e-12 6.46e-12 + 1.800000 0.941488 1.183867 3.60e-12 7.16e-12 + 1.900000 0.915617 1.437465 1.07e-12 2.70e-12 + 2.000000 0.889903 1.577082 1.73e-12 1.16e-11 + 2.100000 0.864625 1.056467 4.78e-12 5.16e-12 + 2.200000 0.840089 1.730920 8.10e-12 6.35e-12 + 2.300000 0.816616 1.101047 1.17e-11 4.17e-12 + 2.400000 0.794546 1.525051 1.54e-11 8.29e-12 + 2.500000 0.774227 1.496993 1.93e-11 1.08e-11 + 2.600000 0.756013 1.126857 2.33e-11 1.42e-11 + 2.700000 0.740246 1.727536 2.71e-11 5.47e-12 + 2.800000 0.727247 1.038393 3.06e-11 3.03e-12 + 2.900000 0.717301 1.600759 3.37e-11 1.40e-11 + 3.000000 0.710636 1.406380 3.62e-11 7.68e-12 + 3.100000 0.707412 1.214353 3.78e-11 2.49e-11 + 3.200000 0.707709 1.704026 3.87e-11 4.61e-12 + 3.300000 0.711520 1.004391 3.87e-11 1.29e-11 + 3.400000 0.718750 1.661225 3.78e-11 1.68e-11 + 3.500000 0.729227 1.310102 3.62e-11 4.71e-12 + 3.600000 0.742712 1.310080 3.40e-11 3.30e-11 + 3.700000 0.758914 1.661237 3.14e-11 6.81e-12 + 3.800000 0.777506 1.004387 2.85e-11 2.15e-11 + 3.900000 0.798144 1.704019 2.55e-11 1.30e-11 + 4.000000 0.820474 1.214374 2.24e-11 4.33e-12 + 4.100000 0.844149 1.406358 1.83e-11 3.43e-11 + 4.200000 0.868832 1.600774 1.43e-11 5.29e-12 + 4.300000 0.894204 1.038382 1.03e-11 2.10e-11 + 4.400000 0.919964 1.727533 6.45e-12 8.06e-12 + 4.500000 0.945834 1.126875 2.75e-12 2.24e-12 + 4.600000 0.971557 1.496974 7.37e-13 1.69e-11 + 4.700000 0.996898 1.525070 4.02e-12 2.17e-13 + 4.800000 1.021641 1.101030 7.08e-12 1.01e-11 + 4.900000 1.045589 1.730922 9.91e-12 4.05e-12 + 5.000000 1.068565 1.056480 1.23e-11 3.61e-12 + ------------------------------------------------------ + +Final Solver Statistics: + Steps: nsts = 5000, nstf = 1425000 + u error = 2.136e-11, v error = 1.132e-11, total error = 1.710e-11 + Total RHS evals: Fs = 30001, Ff = 5700050 diff --git a/examples/arkode/C_serial/ark_kpr_mri_6_0.005.out b/examples/arkode/C_serial/ark_kpr_mri_6_0.005.out deleted file mode 100644 index 7929d73e39..0000000000 --- a/examples/arkode/C_serial/ark_kpr_mri_6_0.005.out +++ /dev/null @@ -1,69 +0,0 @@ - -Multirate nonlinear Kvaerno-Prothero-Robinson test problem: - time domain: (0,5] - hs = 0.005 - hf = 5e-05 - G = -100 - w = 100 - e = 0.5 - solver: exp-4/exp-3 (MRI-GARK-ERK45a / ERK-3-3) - - t u v uerr verr - ------------------------------------------------------ - 0.000000 1.224745 1.732051 0.00e+00 0.00e+00 - 0.100000 1.223725 1.077464 8.08e-09 4.56e-10 - 0.200000 1.220669 1.551800 8.03e-09 9.03e-10 - 0.300000 1.215594 1.467737 7.94e-09 1.30e-09 - 0.400000 1.208524 1.154583 7.80e-09 1.66e-09 - 0.500000 1.199496 1.721908 7.62e-09 1.97e-09 - 0.600000 1.188557 1.023517 7.40e-09 2.24e-09 - 0.700000 1.175764 1.622751 7.13e-09 2.47e-09 - 0.800000 1.161186 1.374632 6.82e-09 2.66e-09 - 0.900000 1.144904 1.245763 6.46e-09 2.81e-09 - 1.000000 1.127010 1.691839 6.05e-09 2.92e-09 - 1.100000 1.107609 1.000489 5.59e-09 3.00e-09 - 1.200000 1.086821 1.677552 5.08e-09 3.04e-09 - 1.300000 1.064777 1.277775 4.50e-09 3.04e-09 - 1.400000 1.041625 1.342455 3.87e-09 3.00e-09 - 1.500000 1.017531 1.642940 3.17e-09 2.93e-09 - 1.600000 0.992673 1.012112 2.39e-09 2.82e-09 - 1.700000 0.967253 1.714058 1.54e-09 2.67e-09 - 1.800000 0.941488 1.183867 6.13e-10 2.48e-09 - 1.900000 0.915617 1.437465 4.00e-10 2.25e-09 - 2.000000 0.889903 1.577082 1.50e-09 1.98e-09 - 2.100000 0.864625 1.056467 2.68e-09 1.66e-09 - 2.200000 0.840089 1.730920 3.94e-09 1.30e-09 - 2.300000 0.816616 1.101047 5.27e-09 9.00e-10 - 2.400000 0.794546 1.525051 6.65e-09 4.47e-10 - 2.500000 0.774227 1.496993 8.05e-09 3.94e-11 - 2.600000 0.756013 1.126857 9.42e-09 5.73e-10 - 2.700000 0.740246 1.727536 1.07e-08 1.13e-09 - 2.800000 0.727247 1.038393 1.19e-08 1.71e-09 - 2.900000 0.717301 1.600759 1.29e-08 2.31e-09 - 3.000000 0.710636 1.406380 1.36e-08 2.89e-09 - 3.100000 0.707412 1.214353 1.40e-08 3.46e-09 - 3.200000 0.707709 1.704026 1.40e-08 3.98e-09 - 3.300000 0.711520 1.004391 1.37e-08 4.45e-09 - 3.400000 0.718750 1.661225 1.31e-08 4.85e-09 - 3.500000 0.729227 1.310102 1.22e-08 5.15e-09 - 3.600000 0.742712 1.310080 1.11e-08 5.38e-09 - 3.700000 0.758914 1.661237 9.81e-09 5.49e-09 - 3.800000 0.777506 1.004387 8.45e-09 5.53e-09 - 3.900000 0.798144 1.704019 7.04e-09 5.47e-09 - 4.000000 0.820474 1.214374 5.64e-09 5.33e-09 - 4.100000 0.844149 1.406358 4.29e-09 5.13e-09 - 4.200000 0.868832 1.600774 3.00e-09 4.86e-09 - 4.300000 0.894204 1.038382 1.78e-09 4.54e-09 - 4.400000 0.919964 1.727533 6.51e-10 4.18e-09 - 4.500000 0.945834 1.126875 3.93e-10 3.79e-09 - 4.600000 0.971557 1.496974 1.35e-09 3.38e-09 - 4.700000 0.996898 1.525070 2.23e-09 2.94e-09 - 4.800000 1.021641 1.101030 3.02e-09 2.51e-09 - 4.900000 1.045589 1.730922 3.75e-09 2.06e-09 - 5.000000 1.068565 1.056480 4.40e-09 1.61e-09 - ------------------------------------------------------ - -Final Solver Statistics: - Steps: nsts = 1001, nstf = 100100 - u error = 7.569e-09, v error = 3.238e-09, total error = 5.821e-09 - Total RHS evals: Fs = 5006, Ff = 300350 diff --git a/examples/arkode/C_serial/ark_kpr_mri_6_5_0.001.out b/examples/arkode/C_serial/ark_kpr_mri_6_5_0.001.out new file mode 100644 index 0000000000..3ea2bad8da --- /dev/null +++ b/examples/arkode/C_serial/ark_kpr_mri_6_5_0.001.out @@ -0,0 +1,69 @@ + +Multirate nonlinear Kvaerno-Prothero-Robinson test problem: + time domain: (0,5] + hs = 0.001 + hf = 1e-05 + G = -100 + w = 100 + e = 0.5 + slow solver: ARKODE_MERK54 + fast solver: ARKODE_DORMAND_PRINCE_7_4_5 + t u v uerr verr + ------------------------------------------------------ + 0.000000 1.224745 1.732051 0.00e+00 0.00e+00 + 0.100000 1.223725 1.077464 4.46e-13 2.08e-13 + 0.200000 1.220669 1.551800 4.42e-13 6.88e-15 + 0.300000 1.215594 1.467737 4.37e-13 7.22e-14 + 0.400000 1.208524 1.154583 4.28e-13 3.99e-13 + 0.500000 1.199496 1.721908 4.18e-13 1.65e-13 + 0.600000 1.188557 1.023517 4.07e-13 1.50e-13 + 0.700000 1.175764 1.622751 3.88e-13 2.86e-14 + 0.800000 1.161186 1.374632 3.73e-13 1.48e-13 + 0.900000 1.144904 1.245763 3.52e-13 3.93e-14 + 1.000000 1.127010 1.691839 3.32e-13 4.77e-14 + 1.100000 1.107609 1.000489 1.33e-13 4.42e-12 + 1.200000 1.086821 1.677552 1.51e-13 2.80e-13 + 1.300000 1.064777 1.277775 4.36e-13 3.47e-13 + 1.400000 1.041625 1.342455 7.76e-13 4.84e-12 + 1.500000 1.017531 1.642940 1.11e-12 3.64e-12 + 1.600000 0.992673 1.012112 1.47e-12 5.55e-12 + 1.700000 0.967253 1.714058 1.84e-12 7.75e-13 + 1.800000 0.941488 1.183867 2.19e-12 1.87e-12 + 1.900000 0.915617 1.437465 2.55e-12 7.48e-12 + 2.000000 0.889903 1.577082 2.86e-12 7.44e-12 + 2.100000 0.864625 1.056467 3.16e-12 8.63e-12 + 2.200000 0.840089 1.730920 3.42e-12 3.66e-12 + 2.300000 0.816616 1.101047 3.60e-12 2.38e-12 + 2.400000 0.794546 1.525051 3.74e-12 9.12e-12 + 2.500000 0.774227 1.496993 3.76e-12 1.11e-11 + 2.600000 0.756013 1.126857 3.70e-12 1.28e-11 + 2.700000 0.740246 1.727536 3.52e-12 8.05e-12 + 2.800000 0.727247 1.038393 3.21e-12 7.73e-13 + 2.900000 0.717301 1.600759 2.79e-12 8.96e-12 + 3.000000 0.710636 1.406380 2.21e-12 1.40e-11 + 3.100000 0.707412 1.214353 1.52e-12 1.74e-11 + 3.200000 0.707709 1.704026 7.13e-13 1.33e-11 + 3.300000 0.711520 1.004391 2.00e-13 3.30e-12 + 3.400000 0.718750 1.661225 1.16e-12 6.43e-12 + 3.500000 0.729227 1.310102 2.19e-12 1.58e-11 + 3.600000 0.742712 1.310080 3.21e-12 2.14e-11 + 3.700000 0.758914 1.661237 4.24e-12 1.86e-11 + 3.800000 0.777506 1.004387 5.23e-12 9.68e-12 + 3.900000 0.798144 1.704019 6.15e-12 1.34e-12 + 4.000000 0.820474 1.214374 7.00e-12 1.57e-11 + 4.100000 0.844149 1.406358 6.74e-12 2.33e-11 + 4.200000 0.868832 1.600774 6.28e-12 1.56e-11 + 4.300000 0.894204 1.038382 5.68e-12 1.13e-11 + 4.400000 0.919964 1.727533 4.97e-12 7.79e-13 + 4.500000 0.945834 1.126875 4.19e-12 5.77e-12 + 4.600000 0.971557 1.496974 3.36e-12 9.76e-12 + 4.700000 0.996898 1.525070 2.51e-12 6.00e-12 + 4.800000 1.021641 1.101030 1.67e-12 4.81e-12 + 4.900000 1.045589 1.730922 8.58e-13 2.44e-13 + 5.000000 1.068565 1.056480 2.51e-13 2.92e-13 + ------------------------------------------------------ + +Final Solver Statistics: + Steps: nsts = 5000, nstf = 1615000 + u error = 3.075e-12, v error = 8.987e-12, total error = 6.716e-12 + Total RHS evals: Fs = 50051, Ff = 9715100 diff --git a/examples/arkode/C_serial/ark_kpr_mri_7_0.001.out b/examples/arkode/C_serial/ark_kpr_mri_7_0.001.out deleted file mode 100644 index 460bf53318..0000000000 --- a/examples/arkode/C_serial/ark_kpr_mri_7_0.001.out +++ /dev/null @@ -1,72 +0,0 @@ - -Multirate nonlinear Kvaerno-Prothero-Robinson test problem: - time domain: (0,5] - hs = 0.001 - hf = 1e-05 - G = -100 - w = 100 - e = 0.5 - solver: dirk-3/exp-3 (MRI-GARK-ESDIRK34a / ERK-3-3) -- solve decoupled - reltol = 1.00e-09, abstol = 1.00e-11 - t u v uerr verr - ------------------------------------------------------ - 0.000000 1.224745 1.732051 0.00e+00 0.00e+00 - 0.100000 1.223725 1.077464 4.01e-10 5.72e-11 - 0.200000 1.220669 1.551800 4.06e-10 1.12e-10 - 0.300000 1.215594 1.467737 3.95e-10 1.60e-10 - 0.400000 1.208524 1.154583 3.88e-10 2.03e-10 - 0.500000 1.199496 1.721908 3.80e-10 2.39e-10 - 0.600000 1.188557 1.023517 3.85e-10 2.71e-10 - 0.700000 1.175764 1.622751 3.48e-10 3.02e-10 - 0.800000 1.161186 1.374632 3.42e-10 3.23e-10 - 0.900000 1.144904 1.245763 3.24e-10 3.40e-10 - 1.000000 1.127010 1.691839 3.03e-10 3.56e-10 - 1.100000 1.107609 1.000489 2.77e-10 3.66e-10 - 1.200000 1.086821 1.677552 2.55e-10 3.66e-10 - 1.300000 1.064777 1.277775 2.29e-10 3.68e-10 - 1.400000 1.041625 1.342455 1.96e-10 3.63e-10 - 1.500000 1.017531 1.642940 1.59e-10 3.51e-10 - 1.600000 0.992673 1.012112 1.22e-10 3.42e-10 - 1.700000 0.967253 1.714058 7.84e-11 3.18e-10 - 1.800000 0.941488 1.183867 3.53e-11 2.98e-10 - 1.900000 0.915617 1.437465 1.65e-11 2.68e-10 - 2.000000 0.889903 1.577082 7.04e-11 2.33e-10 - 2.100000 0.864625 1.056467 1.30e-10 1.98e-10 - 2.200000 0.840089 1.730920 1.96e-10 1.49e-10 - 2.300000 0.816616 1.101047 2.60e-10 1.03e-10 - 2.400000 0.794546 1.525051 3.29e-10 4.53e-11 - 2.500000 0.774227 1.496993 4.02e-10 1.97e-11 - 2.600000 0.756013 1.126857 4.66e-10 8.15e-11 - 2.700000 0.740246 1.727536 5.35e-10 1.53e-10 - 2.800000 0.727247 1.038393 5.92e-10 2.19e-10 - 2.900000 0.717301 1.600759 7.54e-10 2.96e-10 - 3.000000 0.710636 1.406380 6.69e-10 3.66e-10 - 3.100000 0.707412 1.214353 6.92e-10 4.31e-10 - 3.200000 0.707709 1.704026 6.98e-10 4.97e-10 - 3.300000 0.711520 1.004391 6.80e-10 5.46e-10 - 3.400000 0.718750 1.661225 6.52e-10 5.96e-10 - 3.500000 0.729227 1.310102 6.05e-10 6.29e-10 - 3.600000 0.742712 1.310080 5.52e-10 6.53e-10 - 3.700000 0.758914 1.661237 4.96e-10 6.77e-10 - 3.800000 0.777506 1.004387 4.21e-10 6.74e-10 - 3.900000 0.798144 1.704019 3.55e-10 6.70e-10 - 4.000000 0.820474 1.214374 2.86e-10 6.48e-10 - 4.100000 0.844149 1.406358 2.57e-10 6.16e-10 - 4.200000 0.868832 1.600774 1.53e-10 5.75e-10 - 4.300000 0.894204 1.038382 9.25e-11 5.57e-10 - 4.400000 0.919964 1.727533 3.64e-11 4.94e-10 - 4.500000 0.945834 1.126875 1.44e-11 4.68e-10 - 4.600000 0.971557 1.496974 6.29e-11 4.03e-10 - 4.700000 0.996898 1.525070 1.03e-10 3.50e-10 - 4.800000 1.021641 1.101030 1.45e-10 3.12e-10 - 4.900000 1.045589 1.730922 1.85e-10 2.34e-10 - 5.000000 1.068565 1.056480 3.89e-11 2.06e-10 - ------------------------------------------------------ - -Final Solver Statistics: - Steps: nsts = 5000, nstf = 510000 - u error = 3.803e-10, v error = 3.943e-10, total error = 3.874e-10 - Total RHS evals: Fs = 45313, Ff = 1530050 - Slow Newton iters = 30312 - Slow Newton conv fails = 0 - Slow Jacobian evals = 250 diff --git a/examples/arkode/C_serial/ark_kpr_mri_7_2_0.002.out b/examples/arkode/C_serial/ark_kpr_mri_7_2_0.002.out new file mode 100644 index 0000000000..b45b167aaa --- /dev/null +++ b/examples/arkode/C_serial/ark_kpr_mri_7_2_0.002.out @@ -0,0 +1,73 @@ + +Multirate nonlinear Kvaerno-Prothero-Robinson test problem: + time domain: (0,5] + hs = 0.002 + hf = 2e-05 + G = -100 + w = 100 + e = 0.5 + slow solver: ARKODE_MRI_GARK_IRK21a + reltol = 4.00e-06, abstol = 1.00e-11 + fast solver: ARKODE_HEUN_EULER_2_1_2 + t u v uerr verr + ------------------------------------------------------ + 0.000000 1.224745 1.732051 0.00e+00 0.00e+00 + 0.100000 1.223725 1.077464 2.77e-08 1.95e-07 + 0.200000 1.220666 1.551800 2.88e-06 1.79e-08 + 0.300000 1.215594 1.467737 1.91e-09 1.21e-07 + 0.400000 1.208524 1.154583 1.40e-07 1.75e-07 + 0.500000 1.199497 1.721908 3.79e-07 2.40e-09 + 0.600000 1.188557 1.023517 3.85e-07 8.51e-08 + 0.700000 1.175764 1.622750 1.42e-08 3.18e-07 + 0.800000 1.161181 1.374632 5.67e-06 2.43e-07 + 0.900000 1.144904 1.245763 6.01e-08 5.50e-07 + 1.000000 1.127010 1.691838 7.31e-09 6.14e-07 + 1.100000 1.107609 1.000489 3.52e-07 3.21e-07 + 1.200000 1.086820 1.677551 1.85e-07 7.19e-07 + 1.300000 1.064777 1.277774 2.56e-08 7.35e-07 + 1.400000 1.041625 1.342455 6.88e-08 6.97e-07 + 1.500000 1.017531 1.642939 1.30e-08 6.97e-07 + 1.600000 0.992673 1.012112 3.27e-09 4.12e-07 + 1.700000 0.967251 1.714057 1.26e-06 6.48e-07 + 1.800000 0.941487 1.183866 5.95e-07 6.78e-07 + 1.900000 0.915617 1.437465 2.80e-09 7.03e-07 + 2.000000 0.889902 1.577081 8.56e-08 6.75e-07 + 2.100000 0.864625 1.056467 3.05e-08 4.34e-07 + 2.200000 0.840089 1.730920 2.80e-07 8.05e-07 + 2.300000 0.816616 1.101046 1.68e-08 5.59e-07 + 2.400000 0.794545 1.525051 5.06e-07 6.57e-07 + 2.500000 0.774227 1.496992 1.40e-09 6.01e-07 + 2.600000 0.756013 1.126856 1.29e-07 4.75e-07 + 2.700000 0.740246 1.727536 2.31e-07 6.14e-07 + 2.800000 0.727247 1.038393 7.35e-08 4.97e-07 + 2.900000 0.717301 1.600758 1.47e-08 6.62e-07 + 3.000000 0.710630 1.406379 6.27e-06 5.84e-07 + 3.100000 0.707412 1.214352 2.47e-08 5.12e-07 + 3.200000 0.707709 1.704026 3.06e-09 6.10e-07 + 3.300000 0.711519 1.004391 8.82e-08 3.18e-07 + 3.400000 0.718749 1.661224 2.15e-07 5.37e-07 + 3.500000 0.729227 1.310101 1.72e-08 4.60e-07 + 3.600000 0.742712 1.310079 1.13e-08 4.35e-07 + 3.700000 0.758914 1.661236 2.50e-08 4.85e-07 + 3.800000 0.777506 1.004387 5.18e-09 2.14e-07 + 3.900000 0.798143 1.704018 8.33e-07 4.86e-07 + 4.000000 0.820474 1.214373 7.45e-07 3.28e-07 + 4.100000 0.844149 1.406358 3.41e-09 3.70e-07 + 4.200000 0.868832 1.600774 1.40e-07 3.87e-07 + 4.300000 0.894204 1.038382 7.05e-08 1.61e-07 + 4.400000 0.919964 1.727533 3.53e-07 8.36e-08 + 4.500000 0.945834 1.126875 6.51e-09 8.35e-08 + 4.600000 0.971557 1.496973 7.24e-07 5.21e-08 + 4.700000 0.996898 1.525070 4.86e-08 6.22e-08 + 4.800000 1.021640 1.101030 1.21e-07 3.47e-08 + 4.900000 1.045589 1.730922 1.37e-07 1.60e-07 + 5.000000 1.068565 1.056481 2.77e-07 3.04e-07 + ------------------------------------------------------ + +Final Solver Statistics: + Steps: nsts = 2501, nstf = 250100 + u error = 1.302e-06, v error = 4.719e-07, total error = 9.791e-07 + Total RHS evals: Fs = 6952, Ff = 500250 + Slow Newton iters = 4500 + Slow Newton conv fails = 0 + Slow Jacobian evals = 126 diff --git a/examples/arkode/C_serial/ark_kpr_mri_8_0.001.out b/examples/arkode/C_serial/ark_kpr_mri_8_0.001.out deleted file mode 100644 index f96e203514..0000000000 --- a/examples/arkode/C_serial/ark_kpr_mri_8_0.001.out +++ /dev/null @@ -1,72 +0,0 @@ - -Multirate nonlinear Kvaerno-Prothero-Robinson test problem: - time domain: (0,5] - hs = 0.001 - hf = 1e-05 - G = -100 - w = 100 - e = 0.5 - solver: ars343/exp-3 (IMEX-MRI3b / ERK-3-3) -- solve decoupled - reltol = 1.00e-09, abstol = 1.00e-11 - t u v uerr verr - ------------------------------------------------------ - 0.000000 1.224745 1.732051 0.00e+00 0.00e+00 - 0.100000 1.223725 1.077464 2.79e-10 2.64e-11 - 0.200000 1.220669 1.551800 1.84e-10 4.85e-11 - 0.300000 1.215594 1.467737 1.86e-10 6.94e-11 - 0.400000 1.208524 1.154583 1.83e-10 8.79e-11 - 0.500000 1.199496 1.721908 1.82e-10 1.04e-10 - 0.600000 1.188557 1.023517 1.72e-10 1.20e-10 - 0.700000 1.175764 1.622751 1.67e-10 1.28e-10 - 0.800000 1.161186 1.374632 1.63e-10 1.39e-10 - 0.900000 1.144904 1.245763 1.52e-10 1.47e-10 - 1.000000 1.127010 1.691839 1.39e-10 1.50e-10 - 1.100000 1.107609 1.000489 1.29e-10 1.51e-10 - 1.200000 1.086821 1.677552 1.17e-10 1.57e-10 - 1.300000 1.064777 1.277775 1.10e-10 1.55e-10 - 1.400000 1.041625 1.342455 9.08e-11 1.53e-10 - 1.500000 1.017531 1.642940 6.96e-11 1.52e-10 - 1.600000 0.992673 1.012112 5.33e-11 1.42e-10 - 1.700000 0.967253 1.714058 3.20e-11 1.38e-10 - 1.800000 0.941488 1.183867 1.63e-11 1.24e-10 - 1.900000 0.915617 1.437465 1.06e-11 1.13e-10 - 2.000000 0.889903 1.577082 3.61e-11 9.93e-11 - 2.100000 0.864625 1.056467 6.56e-11 7.88e-11 - 2.200000 0.840089 1.730920 9.97e-11 6.38e-11 - 2.300000 0.816616 1.101047 1.27e-10 3.80e-11 - 2.400000 0.794546 1.525051 1.59e-10 1.69e-11 - 2.500000 0.774227 1.496993 1.88e-10 9.36e-12 - 2.600000 0.756013 1.126857 2.24e-10 3.98e-11 - 2.700000 0.740246 1.727536 2.59e-10 6.53e-11 - 2.800000 0.727247 1.038393 2.83e-10 1.00e-10 - 2.900000 0.717301 1.600759 3.04e-10 1.27e-10 - 3.000000 0.710636 1.406380 3.17e-10 1.58e-10 - 3.100000 0.707412 1.214353 3.28e-10 1.88e-10 - 3.200000 0.707709 1.704026 3.27e-10 2.11e-10 - 3.300000 0.711520 1.004391 3.17e-10 2.40e-10 - 3.400000 0.718750 1.661225 3.04e-10 2.54e-10 - 3.500000 0.729227 1.310102 2.87e-10 2.71e-10 - 3.600000 0.742712 1.310080 2.57e-10 2.81e-10 - 3.700000 0.758914 1.661237 2.23e-10 2.83e-10 - 3.800000 0.777506 1.004387 1.91e-10 2.87e-10 - 3.900000 0.798144 1.704019 1.58e-10 2.78e-10 - 4.000000 0.820474 1.214374 1.33e-10 2.73e-10 - 4.100000 0.844149 1.406358 9.74e-11 2.68e-10 - 4.200000 0.868832 1.600774 6.64e-11 2.60e-10 - 4.300000 0.894204 1.038382 3.79e-11 2.21e-10 - 4.400000 0.919964 1.727533 9.36e-12 2.25e-10 - 4.500000 0.945834 1.126875 1.03e-11 1.82e-10 - 4.600000 0.971557 1.496974 3.35e-11 1.74e-10 - 4.700000 0.996898 1.525070 5.03e-11 1.52e-10 - 4.800000 1.021641 1.101030 7.16e-11 1.11e-10 - 4.900000 1.045589 1.730922 9.30e-11 1.12e-10 - 5.000000 1.068565 1.056480 1.05e-10 6.39e-11 - ------------------------------------------------------ - -Final Solver Statistics: - Steps: nsts = 5000, nstf = 510000 - u error = 1.795e-10, v error = 1.678e-10, total error = 1.737e-10 - Total RHS evals: Fse = 20001, Fsi = 50342, Ff = 1530050 - Slow Newton iters = 30341 - Slow Newton conv fails = 0 - Slow Jacobian evals = 250 diff --git a/examples/arkode/C_serial/ark_kpr_mri_7_0.001_-100_100_0.5_1.out b/examples/arkode/C_serial/ark_kpr_mri_8_3_0.001_-100_100_0.5_1.out similarity index 96% rename from examples/arkode/C_serial/ark_kpr_mri_7_0.001_-100_100_0.5_1.out rename to examples/arkode/C_serial/ark_kpr_mri_8_3_0.001_-100_100_0.5_1.out index 38dc23acf1..18e6e54eaa 100644 --- a/examples/arkode/C_serial/ark_kpr_mri_7_0.001_-100_100_0.5_1.out +++ b/examples/arkode/C_serial/ark_kpr_mri_8_3_0.001_-100_100_0.5_1.out @@ -6,8 +6,9 @@ Multirate nonlinear Kvaerno-Prothero-Robinson test problem: G = -100 w = 100 e = 0.5 - solver: dirk-3/exp-3 (MRI-GARK-ESDIRK34a / ERK-3-3) -- solve decoupled - reltol = 1.00e-09, abstol = 1.00e-11 + slow solver: ARKODE_MRI_GARK_ESDIRK34a + reltol = 1.00e-09, abstol = 1.00e-11 + fast solver: erk-3-3 t u v uerr verr ------------------------------------------------------ 0.000000 1.224745 1.732051 0.00e+00 0.00e+00 diff --git a/examples/arkode/C_serial/ark_kpr_mri_9_0.001.out b/examples/arkode/C_serial/ark_kpr_mri_9_0.001.out deleted file mode 100644 index 8da07cba27..0000000000 --- a/examples/arkode/C_serial/ark_kpr_mri_9_0.001.out +++ /dev/null @@ -1,72 +0,0 @@ - -Multirate nonlinear Kvaerno-Prothero-Robinson test problem: - time domain: (0,5] - hs = 0.001 - hf = 1e-05 - G = -100 - w = 100 - e = 0.5 - solver: imexark4/exp-4 (IMEX-MRI4 / ERK-4-4) -- solve decoupled - reltol = 1.00e-12, abstol = 1.00e-14 - t u v uerr verr - ------------------------------------------------------ - 0.000000 1.224745 1.732051 0.00e+00 0.00e+00 - 0.100000 1.223725 1.077464 1.63e-11 6.38e-13 - 0.200000 1.220669 1.551800 1.60e-11 6.83e-13 - 0.300000 1.215594 1.467737 1.52e-11 9.61e-13 - 0.400000 1.208524 1.154583 1.51e-11 9.22e-13 - 0.500000 1.199496 1.721908 1.60e-11 1.73e-12 - 0.600000 1.188557 1.023517 1.48e-11 3.43e-12 - 0.700000 1.175764 1.622751 1.36e-11 2.17e-12 - 0.800000 1.161186 1.374632 1.23e-11 2.77e-12 - 0.900000 1.144904 1.245763 1.12e-11 3.13e-12 - 1.000000 1.127010 1.691839 1.31e-11 2.17e-12 - 1.100000 1.107609 1.000489 1.11e-11 2.12e-12 - 1.200000 1.086821 1.677552 9.50e-12 1.93e-12 - 1.300000 1.064777 1.277775 7.58e-12 1.91e-12 - 1.400000 1.041625 1.342455 5.18e-12 2.57e-12 - 1.500000 1.017531 1.642940 6.04e-12 5.82e-12 - 1.600000 0.992673 1.012112 3.77e-12 3.35e-12 - 1.700000 0.967253 1.714058 3.32e-12 2.74e-12 - 1.800000 0.941488 1.183867 2.38e-13 3.75e-12 - 1.900000 0.915617 1.437465 3.30e-12 5.77e-12 - 2.000000 0.889903 1.577082 6.57e-12 8.88e-12 - 2.100000 0.864625 1.056467 7.88e-12 7.37e-12 - 2.200000 0.840089 1.730920 6.75e-12 4.53e-12 - 2.300000 0.816616 1.101047 1.18e-11 3.00e-12 - 2.400000 0.794546 1.525051 1.53e-11 8.93e-12 - 2.500000 0.774227 1.496993 1.85e-11 1.08e-11 - 2.600000 0.756013 1.126857 2.18e-11 1.35e-11 - 2.700000 0.740246 1.727536 2.05e-11 6.87e-12 - 2.800000 0.727247 1.038393 2.46e-11 7.76e-13 - 2.900000 0.717301 1.600759 2.68e-11 1.11e-11 - 3.000000 0.710636 1.406380 2.78e-11 1.14e-11 - 3.100000 0.707412 1.214353 2.85e-11 2.04e-11 - 3.200000 0.707709 1.704026 2.85e-11 9.74e-12 - 3.300000 0.711520 1.004391 2.77e-11 7.12e-12 - 3.400000 0.718750 1.661225 2.60e-11 1.06e-11 - 3.500000 0.729227 1.310102 2.41e-11 1.14e-11 - 3.600000 0.742712 1.310080 2.08e-11 2.60e-11 - 3.700000 0.758914 1.661237 1.99e-11 1.39e-11 - 3.800000 0.777506 1.004387 1.62e-11 1.43e-11 - 3.900000 0.798144 1.704019 1.39e-11 5.96e-12 - 4.000000 0.820474 1.214374 1.04e-11 1.12e-11 - 4.100000 0.844149 1.406358 6.45e-12 2.95e-11 - 4.200000 0.868832 1.600774 3.65e-12 5.01e-12 - 4.300000 0.894204 1.038382 1.63e-12 9.96e-12 - 4.400000 0.919964 1.727533 2.33e-12 1.06e-11 - 4.500000 0.945834 1.126875 2.28e-12 5.45e-12 - 4.600000 0.971557 1.496974 5.15e-12 1.52e-11 - 4.700000 0.996898 1.525070 8.52e-12 7.66e-13 - 4.800000 1.021641 1.101030 8.55e-12 1.92e-12 - 4.900000 1.045589 1.730922 6.11e-12 8.80e-12 - 5.000000 1.068565 1.056480 9.97e-12 3.37e-12 - ------------------------------------------------------ - -Final Solver Statistics: - Steps: nsts = 5000, nstf = 510000 - u error = 1.532e-11, v error = 9.496e-12, total error = 1.274e-11 - Total RHS evals: Fse = 30001, Fsi = 82555, Ff = 2040050 - Slow Newton iters = 52554 - Slow Newton conv fails = 0 - Slow Jacobian evals = 250 diff --git a/examples/arkode/C_serial/ark_kpr_mri_8_0.001_-100_100_0.5_1.out b/examples/arkode/C_serial/ark_kpr_mri_9_3_0.001_-100_100_0.5_1.out similarity index 96% rename from examples/arkode/C_serial/ark_kpr_mri_8_0.001_-100_100_0.5_1.out rename to examples/arkode/C_serial/ark_kpr_mri_9_3_0.001_-100_100_0.5_1.out index f9d68539de..969eb31845 100644 --- a/examples/arkode/C_serial/ark_kpr_mri_8_0.001_-100_100_0.5_1.out +++ b/examples/arkode/C_serial/ark_kpr_mri_9_3_0.001_-100_100_0.5_1.out @@ -6,8 +6,9 @@ Multirate nonlinear Kvaerno-Prothero-Robinson test problem: G = -100 w = 100 e = 0.5 - solver: ars343/exp-3 (IMEX-MRI3b / ERK-3-3) -- solve decoupled - reltol = 1.00e-09, abstol = 1.00e-11 + slow solver: ARKODE_IMEX_MRI_GARK3b + reltol = 1.00e-09, abstol = 1.00e-11 + fast solver: erk-3-3 t u v uerr verr ------------------------------------------------------ 0.000000 1.224745 1.732051 0.00e+00 0.00e+00 diff --git a/include/arkode/arkode.h b/include/arkode/arkode.h index f4e0667d72..5a7fb8485b 100644 --- a/include/arkode/arkode.h +++ b/include/arkode/arkode.h @@ -280,6 +280,9 @@ SUNDIALS_EXPORT int ARKodeSetInitStep(void* arkode_mem, sunrealtype hin); SUNDIALS_EXPORT int ARKodeSetMinStep(void* arkode_mem, sunrealtype hmin); SUNDIALS_EXPORT int ARKodeSetMaxStep(void* arkode_mem, sunrealtype hmax); SUNDIALS_EXPORT int ARKodeSetMaxNumConstrFails(void* arkode_mem, int maxfails); +SUNDIALS_EXPORT int ARKodeSetAccumulatedErrorType(void* arkode_mem, + int accum_type); +SUNDIALS_EXPORT int ARKodeResetAccumulatedError(void* arkode_mem); /* Integrate the ODE over an interval in t */ SUNDIALS_EXPORT int ARKodeEvolve(void* arkode_mem, sunrealtype tout, @@ -325,6 +328,8 @@ SUNDIALS_EXPORT int ARKodeGetNumConstrFails(void* arkode_mem, SUNDIALS_EXPORT int ARKodeGetStepStats(void* arkode_mem, long int* nsteps, sunrealtype* hinused, sunrealtype* hlast, sunrealtype* hcur, sunrealtype* tcur); +SUNDIALS_EXPORT int ARKodeGetAccumulatedError(void* arkode_mem, + sunrealtype* accum_error); /* Optional output functions (implicit solver) */ SUNDIALS_EXPORT int ARKodeGetNumLinSolvSetups(void* arkode_mem, diff --git a/include/arkode/arkode_arkstep.h b/include/arkode/arkode_arkstep.h index f7a6f112f5..01c1e9bf17 100644 --- a/include/arkode/arkode_arkstep.h +++ b/include/arkode/arkode_arkstep.h @@ -96,7 +96,7 @@ SUNDIALS_EXPORT int ARKStepGetTimestepperStats( long int* step_attempts, long int* nfe_evals, long int* nfi_evals, long int* nlinsetups, long int* netfails); -/* MRIStep interface functions */ +/* Utility to wrap ARKStep as an MRIStepInnerStepper */ SUNDIALS_EXPORT int ARKStepCreateMRIStepInnerStepper(void* arkode_mem, MRIStepInnerStepper* stepper); diff --git a/include/arkode/arkode_erkstep.h b/include/arkode/arkode_erkstep.h index ed93a240b9..8257b2f6f2 100644 --- a/include/arkode/arkode_erkstep.h +++ b/include/arkode/arkode_erkstep.h @@ -68,6 +68,10 @@ SUNDIALS_EXPORT int ERKStepGetTimestepperStats( void* arkode_mem, long int* expsteps, long int* accsteps, long int* step_attempts, long int* nfevals, long int* netfails); +/* Utility to wrap ERKStep as an MRIStepInnerStepper */ +SUNDIALS_EXPORT int ERKStepCreateMRIStepInnerStepper(void* arkode_mem, + MRIStepInnerStepper* stepper); + /* -------------------------------------------------------------------------- * Deprecated Functions -- all are superseded by shared ARKODE-level routines * -------------------------------------------------------------------------- */ diff --git a/include/arkode/arkode_mristep.h b/include/arkode/arkode_mristep.h index 000bae135a..551493c561 100644 --- a/include/arkode/arkode_mristep.h +++ b/include/arkode/arkode_mristep.h @@ -36,7 +36,9 @@ typedef enum { MRISTEP_EXPLICIT, MRISTEP_IMPLICIT, - MRISTEP_IMEX + MRISTEP_IMEX, + MRISTEP_MERK, + MRISTEP_MRISR } MRISTEP_METHOD_TYPE; typedef enum @@ -62,10 +64,17 @@ typedef enum ARKODE_IMEX_MRI_GARK_EULER, ARKODE_IMEX_MRI_GARK_TRAPEZOIDAL, ARKODE_IMEX_MRI_GARK_MIDPOINT, - ARKODE_MAX_MRI_NUM = ARKODE_IMEX_MRI_GARK_MIDPOINT, + ARKODE_MERK21, + ARKODE_MERK32, + ARKODE_MERK43, + ARKODE_MERK54, + ARKODE_IMEX_MRI_SR21, + ARKODE_IMEX_MRI_SR32, + ARKODE_IMEX_MRI_SR43, + ARKODE_MAX_MRI_NUM = ARKODE_IMEX_MRI_SR43 } ARKODE_MRITableID; -/* Default MRI coupling tables for each order */ +/* Default MRI coupling tables for each order and type */ static const int MRISTEP_DEFAULT_EXPL_1 = ARKODE_MRI_GARK_FORWARD_EULER; static const int MRISTEP_DEFAULT_EXPL_2 = ARKODE_MRI_GARK_ERK22b; static const int MRISTEP_DEFAULT_EXPL_3 = ARKODE_MIS_KW3; @@ -81,6 +90,15 @@ static const int MRISTEP_DEFAULT_IMEX_SD_2 = ARKODE_IMEX_MRI_GARK_TRAPEZOIDAL; static const int MRISTEP_DEFAULT_IMEX_SD_3 = ARKODE_IMEX_MRI_GARK3b; static const int MRISTEP_DEFAULT_IMEX_SD_4 = ARKODE_IMEX_MRI_GARK4; +static const int MRISTEP_DEFAULT_EXPL_2_AD = ARKODE_MRI_GARK_ERK22a; +static const int MRISTEP_DEFAULT_EXPL_3_AD = ARKODE_MRI_GARK_ERK33a; +static const int MRISTEP_DEFAULT_EXPL_4_AD = ARKODE_MRI_GARK_ERK45a; +static const int MRISTEP_DEFAULT_EXPL_5_AD = ARKODE_MERK54; + +static const int MRISTEP_DEFAULT_IMEX_SD_2_AD = ARKODE_IMEX_MRI_SR21; +static const int MRISTEP_DEFAULT_IMEX_SD_3_AD = ARKODE_IMEX_MRI_SR32; +static const int MRISTEP_DEFAULT_IMEX_SD_4_AD = ARKODE_IMEX_MRI_SR43; + /* ------------------------------------ * MRIStep Inner Stepper Function Types * ------------------------------------ */ @@ -94,18 +112,32 @@ typedef int (*MRIStepInnerFullRhsFn)(MRIStepInnerStepper stepper, sunrealtype t, typedef int (*MRIStepInnerResetFn)(MRIStepInnerStepper stepper, sunrealtype tR, N_Vector yR); +typedef int (*MRIStepInnerGetAccumulatedError)(MRIStepInnerStepper stepper, + sunrealtype* accum_error); + +typedef int (*MRIStepInnerResetAccumulatedError)(MRIStepInnerStepper stepper); + +typedef int (*MRIStepInnerSetFixedStep)(MRIStepInnerStepper stepper, + sunrealtype h); + +typedef int (*MRIStepInnerSetRTol)(MRIStepInnerStepper stepper, sunrealtype rtol); + /*--------------------------------------------------------------- MRI coupling data structure and associated utility routines ---------------------------------------------------------------*/ struct MRIStepCouplingMem { - int nmat; /* number of MRI coupling matrices */ - int stages; /* size of coupling matrices (stages * stages) */ - int q; /* method order of accuracy */ - int p; /* embedding order of accuracy */ - sunrealtype* c; /* stage abscissae */ - sunrealtype*** W; /* explicit coupling matrices [nmat][stages][stages] */ - sunrealtype*** G; /* implicit coupling matrices [nmat][stages][stages] */ + MRISTEP_METHOD_TYPE type; /* flag to encode the MRI method type */ + int nmat; /* number of MRI coupling matrices */ + int stages; /* size of coupling matrices ((stages+1) * stages) */ + int q; /* method order of accuracy */ + int p; /* embedding order of accuracy */ + sunrealtype* c; /* stage abscissae */ + sunrealtype*** W; /* explicit coupling matrices [nmat][stages+1][stages] */ + sunrealtype*** G; /* implicit coupling matrices [nmat][stages+1][stages] */ + + int ngroup; /* number of stage groups (MERK-specific) */ + int** group; /* stages to integrate together (MERK-specific) */ }; typedef _SUNDIALS_STRUCT_ MRIStepCouplingMem* MRIStepCoupling; @@ -158,6 +190,10 @@ SUNDIALS_EXPORT int MRIStepSetPreInnerFn(void* arkode_mem, MRIStepPreInnerFn prefn); SUNDIALS_EXPORT int MRIStepSetPostInnerFn(void* arkode_mem, MRIStepPostInnerFn postfn); +SUNDIALS_EXPORT int MRIStepSetFastErrorStepFactor(void* arkode_mem, + sunrealtype hfactor); +SUNDIALS_EXPORT int MRIStepSetAdaptController(void* arkode_mem, + SUNAdaptController C); /* Optional output functions */ SUNDIALS_EXPORT int MRIStepGetNumRhsEvals(void* arkode_mem, long int* nfse_evals, @@ -180,6 +216,14 @@ SUNDIALS_EXPORT int MRIStepInnerStepper_SetFullRhsFn(MRIStepInnerStepper stepper MRIStepInnerFullRhsFn fn); SUNDIALS_EXPORT int MRIStepInnerStepper_SetResetFn(MRIStepInnerStepper stepper, MRIStepInnerResetFn fn); +SUNDIALS_EXPORT int MRIStepInnerStepper_SetAccumulatedErrorGetFn( + MRIStepInnerStepper stepper, MRIStepInnerGetAccumulatedError fn); +SUNDIALS_EXPORT int MRIStepInnerStepper_SetAccumulatedErrorResetFn( + MRIStepInnerStepper stepper, MRIStepInnerResetAccumulatedError fn); +SUNDIALS_EXPORT int MRIStepInnerStepper_SetFixedStepFn( + MRIStepInnerStepper stepper, MRIStepInnerSetFixedStep fn); +SUNDIALS_EXPORT int MRIStepInnerStepper_SetRTolFn(MRIStepInnerStepper stepper, + MRIStepInnerSetRTol fn); SUNDIALS_EXPORT int MRIStepInnerStepper_AddForcing(MRIStepInnerStepper stepper, sunrealtype t, N_Vector f); SUNDIALS_EXPORT int MRIStepInnerStepper_GetForcingData( diff --git a/include/sunadaptcontroller/sunadaptcontroller_mricc.h b/include/sunadaptcontroller/sunadaptcontroller_mricc.h new file mode 100644 index 0000000000..685ca5e7bf --- /dev/null +++ b/include/sunadaptcontroller/sunadaptcontroller_mricc.h @@ -0,0 +1,72 @@ +/* ----------------------------------------------------------------- + * Programmer(s): Daniel R. Reynolds @ SMU + * ----------------------------------------------------------------- + * SUNDIALS Copyright Start + * Copyright (c) 2002-2024, 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_MRICC module. + * -----------------------------------------------------------------*/ + +#ifndef _SUNADAPTCONTROLLER_MRICC_H +#define _SUNADAPTCONTROLLER_MRICC_H + +#include +#include + +#ifdef __cplusplus /* wrapper to enable C++ usage */ +extern "C" { +#endif + +/* -------------------------------------------------- + * MRI constant-constant implementation of SUNAdaptController + * -------------------------------------------------- */ + +struct _SUNAdaptControllerContent_MRICC +{ + sunrealtype k1; /* internal controller parameters */ + sunrealtype k2; + sunrealtype bias; /* error bias factor */ + int p; /* fast order of accuracy to use */ +}; + +typedef struct _SUNAdaptControllerContent_MRICC* SUNAdaptControllerContent_MRICC; + +/* ------------------ + * Exported Functions + * ------------------ */ + +SUNDIALS_EXPORT +SUNAdaptController SUNAdaptController_MRICC(SUNContext sunctx, int p); +SUNDIALS_EXPORT +int SUNAdaptController_SetParams_MRICC(SUNAdaptController C, sunrealtype k1, + sunrealtype k2); +SUNDIALS_EXPORT +SUNAdaptController_Type SUNAdaptController_GetType_MRICC(SUNAdaptController C); +SUNDIALS_EXPORT +int SUNAdaptController_EstimateMRISteps_MRICC(SUNAdaptController C, + sunrealtype H, sunrealtype h, + int P, sunrealtype DSM, + sunrealtype dsm, sunrealtype* Hnew, + sunrealtype* hnew); +SUNDIALS_EXPORT +int SUNAdaptController_SetDefaults_MRICC(SUNAdaptController C); +SUNDIALS_EXPORT +int SUNAdaptController_Write_MRICC(SUNAdaptController C, FILE* fptr); +SUNDIALS_EXPORT +int SUNAdaptController_SetErrorBias_MRICC(SUNAdaptController C, sunrealtype bias); +SUNDIALS_EXPORT +int SUNAdaptController_Space_MRICC(SUNAdaptController C, long int* lenrw, + long int* leniw); + +#ifdef __cplusplus +} +#endif + +#endif /* _SUNADAPTCONTROLLER_MRICC_H */ diff --git a/include/sunadaptcontroller/sunadaptcontroller_mrihtol.h b/include/sunadaptcontroller/sunadaptcontroller_mrihtol.h new file mode 100644 index 0000000000..e15692e53b --- /dev/null +++ b/include/sunadaptcontroller/sunadaptcontroller_mrihtol.h @@ -0,0 +1,88 @@ +/* ----------------------------------------------------------------- + * Programmer(s): Daniel R. Reynolds @ SMU + * ----------------------------------------------------------------- + * SUNDIALS Copyright Start + * Copyright (c) 2002-2024, 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_MRIHTol module. + * -----------------------------------------------------------------*/ + +#ifndef _SUNADAPTCONTROLLER_MRIHTOL_H +#define _SUNADAPTCONTROLLER_MRIHTOL_H + +#include +#include + +#ifdef __cplusplus /* wrapper to enable C++ usage */ +extern "C" { +#endif + +/* -------------------------------------------- + * MRI H+tolerance implementation of SUNAdaptController + * -------------------------------------------- */ + +struct _SUNAdaptControllerContent_MRIHTol +{ + SUNAdaptController HControl; + SUNAdaptController TolControl; + sunrealtype inner_max_relch; + sunrealtype inner_min_tolfac; + sunrealtype inner_max_tolfac; +}; + +typedef struct _SUNAdaptControllerContent_MRIHTol* SUNAdaptControllerContent_MRIHTol; + +/* ------------------ + * Exported Functions + * ------------------ */ + +SUNDIALS_EXPORT +SUNAdaptController SUNAdaptController_MRIHTol(SUNContext sunctx, + SUNAdaptController HControl, + SUNAdaptController TolControl); +SUNDIALS_EXPORT +SUNErrCode SUNAdaptController_SetParams_MRIHTol(SUNAdaptController C, + sunrealtype inner_max_relch, + sunrealtype inner_min_tolfac, + sunrealtype inner_max_tolfac); +SUNDIALS_EXPORT +SUNAdaptController SUNAdaptController_GetSlowController_MRIHTol( + SUNAdaptController C); +SUNDIALS_EXPORT +SUNAdaptController SUNAdaptController_GetFastController_MRIHTol( + SUNAdaptController C); +SUNDIALS_EXPORT +SUNAdaptController_Type SUNAdaptController_GetType_MRIHTol(SUNAdaptController C); +SUNDIALS_EXPORT +int SUNAdaptController_EstimateStepTol_MRIHTol( + SUNAdaptController C, sunrealtype H, sunrealtype tolfac, int P, + sunrealtype DSM, sunrealtype dsm, sunrealtype* Hnew, sunrealtype* tolfacnew); +SUNDIALS_EXPORT +int SUNAdaptController_Reset_MRIHTol(SUNAdaptController C); +SUNDIALS_EXPORT +int SUNAdaptController_SetDefaults_MRIHTol(SUNAdaptController C); +SUNDIALS_EXPORT +int SUNAdaptController_Write_MRIHTol(SUNAdaptController C, FILE* fptr); +SUNDIALS_EXPORT +int SUNAdaptController_SetErrorBias_MRIHTol(SUNAdaptController C, + sunrealtype bias); +SUNDIALS_EXPORT +int SUNAdaptController_UpdateMRITol_MRIHTol(SUNAdaptController C, sunrealtype H, + sunrealtype tolfac, sunrealtype DSM, + sunrealtype dsm); +SUNDIALS_EXPORT +int SUNAdaptController_Space_MRIHTol(SUNAdaptController C, long int* lenrw, + long int* leniw); + +#ifdef __cplusplus +} +#endif + +#endif /* _SUNADAPTCONTROLLER_MRIHTOL_H */ diff --git a/include/sunadaptcontroller/sunadaptcontroller_mrill.h b/include/sunadaptcontroller/sunadaptcontroller_mrill.h new file mode 100644 index 0000000000..49457cfbb0 --- /dev/null +++ b/include/sunadaptcontroller/sunadaptcontroller_mrill.h @@ -0,0 +1,86 @@ +/* ----------------------------------------------------------------- + * Programmer(s): Daniel R. Reynolds @ SMU + * ----------------------------------------------------------------- + * SUNDIALS Copyright Start + * Copyright (c) 2002-2024, 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_MRILL module. + * -----------------------------------------------------------------*/ + +#ifndef _SUNADAPTCONTROLLER_MRILL_H +#define _SUNADAPTCONTROLLER_MRILL_H + +#include +#include + +#ifdef __cplusplus /* wrapper to enable C++ usage */ +extern "C" { +#endif + +/* ---------------------------------------------- + * MRI linear-linear implementation of SUNAdaptController + * ---------------------------------------------- */ + +struct _SUNAdaptControllerContent_MRILL +{ + sunrealtype k11; /* internal controller parameters */ + sunrealtype k12; + sunrealtype k21; + sunrealtype k22; + sunrealtype bias; /* error bias factor */ + sunrealtype esp; /* slow error from previous step */ + sunrealtype efp; /* fast error from previous step */ + sunrealtype hsp; /* slow previous step size */ + sunrealtype hfp; /* fast previous step size */ + int p; /* fast order of accuracy to use */ + sunbooleantype firststep; /* flag indicating first step */ +}; + +typedef struct _SUNAdaptControllerContent_MRILL* SUNAdaptControllerContent_MRILL; + +/* ------------------ + * Exported Functions + * ------------------ */ + +SUNDIALS_EXPORT +SUNAdaptController SUNAdaptController_MRILL(SUNContext sunctx, int p); +SUNDIALS_EXPORT +int SUNAdaptController_SetParams_MRILL(SUNAdaptController C, sunrealtype k11, + sunrealtype k12, sunrealtype k21, + sunrealtype k22); +SUNDIALS_EXPORT +SUNAdaptController_Type SUNAdaptController_GetType_MRILL(SUNAdaptController C); +SUNDIALS_EXPORT +int SUNAdaptController_EstimateMRISteps_MRILL(SUNAdaptController C, + sunrealtype H, sunrealtype h, + int P, sunrealtype DSM, + sunrealtype dsm, sunrealtype* Hnew, + sunrealtype* hnew); +SUNDIALS_EXPORT +int SUNAdaptController_Reset_MRILL(SUNAdaptController C); +SUNDIALS_EXPORT +int SUNAdaptController_SetDefaults_MRILL(SUNAdaptController C); +SUNDIALS_EXPORT +int SUNAdaptController_Write_MRILL(SUNAdaptController C, FILE* fptr); +SUNDIALS_EXPORT +int SUNAdaptController_SetErrorBias_MRILL(SUNAdaptController C, sunrealtype bias); +SUNDIALS_EXPORT +int SUNAdaptController_UpdateMRIH_MRILL(SUNAdaptController C, sunrealtype H, + sunrealtype h, sunrealtype DSM, + sunrealtype dsm); +SUNDIALS_EXPORT +int SUNAdaptController_Space_MRILL(SUNAdaptController C, long int* lenrw, + long int* leniw); + +#ifdef __cplusplus +} +#endif + +#endif /* _SUNADAPTCONTROLLER_MRILL_H */ diff --git a/include/sunadaptcontroller/sunadaptcontroller_mripi.h b/include/sunadaptcontroller/sunadaptcontroller_mripi.h new file mode 100644 index 0000000000..80cdd0e88b --- /dev/null +++ b/include/sunadaptcontroller/sunadaptcontroller_mripi.h @@ -0,0 +1,83 @@ +/* ----------------------------------------------------------------- + * Programmer(s): Daniel R. Reynolds @ SMU + * ----------------------------------------------------------------- + * SUNDIALS Copyright Start + * Copyright (c) 2002-2024, 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_MRIPI module. + * -----------------------------------------------------------------*/ + +#ifndef _SUNADAPTCONTROLLER_MRIPI_H +#define _SUNADAPTCONTROLLER_MRIPI_H + +#include +#include + +#ifdef __cplusplus /* wrapper to enable C++ usage */ +extern "C" { +#endif + +/* ----------------------------------- + * MRI PI implementation of SUNAdaptController + * ----------------------------------- */ + +struct _SUNAdaptControllerContent_MRIPI +{ + sunrealtype k11; /* internal controller parameters */ + sunrealtype k12; + sunrealtype k21; + sunrealtype k22; + sunrealtype bias; /* error bias factor */ + sunrealtype esp; /* slow error from previous step */ + sunrealtype efp; /* fast error from previous step */ + int p; /* fast order of accuracy to use */ +}; + +typedef struct _SUNAdaptControllerContent_MRIPI* SUNAdaptControllerContent_MRIPI; + +/* ------------------ + * Exported Functions + * ------------------ */ + +SUNDIALS_EXPORT +SUNAdaptController SUNAdaptController_MRIPI(SUNContext sunctx, int p); +SUNDIALS_EXPORT +int SUNAdaptController_SetParams_MRIPI(SUNAdaptController C, sunrealtype k11, + sunrealtype k12, sunrealtype k21, + sunrealtype k22); +SUNDIALS_EXPORT +SUNAdaptController_Type SUNAdaptController_GetType_MRIPI(SUNAdaptController C); +SUNDIALS_EXPORT +int SUNAdaptController_EstimateMRISteps_MRIPI(SUNAdaptController C, + sunrealtype H, sunrealtype h, + int P, sunrealtype DSM, + sunrealtype dsm, sunrealtype* Hnew, + sunrealtype* hnew); +SUNDIALS_EXPORT +int SUNAdaptController_Reset_MRIPI(SUNAdaptController C); +SUNDIALS_EXPORT +int SUNAdaptController_SetDefaults_MRIPI(SUNAdaptController C); +SUNDIALS_EXPORT +int SUNAdaptController_Write_MRIPI(SUNAdaptController C, FILE* fptr); +SUNDIALS_EXPORT +int SUNAdaptController_SetErrorBias_MRIPI(SUNAdaptController C, sunrealtype bias); +SUNDIALS_EXPORT +int SUNAdaptController_UpdateMRIH_MRIPI(SUNAdaptController C, sunrealtype H, + sunrealtype h, sunrealtype DSM, + sunrealtype dsm); +SUNDIALS_EXPORT +int SUNAdaptController_Space_MRIPI(SUNAdaptController C, long int* lenrw, + long int* leniw); + +#ifdef __cplusplus +} +#endif + +#endif /* _SUNADAPTCONTROLLER_MRIPI_H */ diff --git a/include/sunadaptcontroller/sunadaptcontroller_mripid.h b/include/sunadaptcontroller/sunadaptcontroller_mripid.h new file mode 100644 index 0000000000..1adb128f45 --- /dev/null +++ b/include/sunadaptcontroller/sunadaptcontroller_mripid.h @@ -0,0 +1,89 @@ +/* ----------------------------------------------------------------- + * Programmer(s): Daniel R. Reynolds @ SMU + * ----------------------------------------------------------------- + * SUNDIALS Copyright Start + * Copyright (c) 2002-2024, 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_MRIPID module. + * -----------------------------------------------------------------*/ + +#ifndef _SUNADAPTCONTROLLER_MRIPID_H +#define _SUNADAPTCONTROLLER_MRIPID_H + +#include +#include + +#ifdef __cplusplus /* wrapper to enable C++ usage */ +extern "C" { +#endif + +/* ----------------------------------- + * MRI PI implementation of SUNAdaptController + * ----------------------------------- */ + +struct _SUNAdaptControllerContent_MRIPID +{ + sunrealtype k11; /* internal controller parameters */ + sunrealtype k12; + sunrealtype k13; + sunrealtype k21; + sunrealtype k22; + sunrealtype k23; + sunrealtype bias; /* error bias factor */ + sunrealtype esp; /* slow error from previous step */ + sunrealtype efp; /* fast error from previous step */ + sunrealtype espp; /* slow error from two previous steps ago */ + sunrealtype efpp; /* fast error from two previous steps ago */ + int p; /* fast order of accuracy to use */ +}; + +typedef struct _SUNAdaptControllerContent_MRIPID* SUNAdaptControllerContent_MRIPID; + +/* ------------------ + * Exported Functions + * ------------------ */ + +SUNDIALS_EXPORT +SUNAdaptController SUNAdaptController_MRIPID(SUNContext sunctx, int p); +SUNDIALS_EXPORT +int SUNAdaptController_SetParams_MRIPID(SUNAdaptController C, sunrealtype k11, + sunrealtype k12, sunrealtype k13, + sunrealtype k21, sunrealtype k22, + sunrealtype k23); +SUNDIALS_EXPORT +SUNAdaptController_Type SUNAdaptController_GetType_MRIPID(SUNAdaptController C); +SUNDIALS_EXPORT +int SUNAdaptController_EstimateMRISteps_MRIPID(SUNAdaptController C, + sunrealtype H, sunrealtype h, + int P, sunrealtype DSM, + sunrealtype dsm, sunrealtype* Hnew, + sunrealtype* hnew); +SUNDIALS_EXPORT +int SUNAdaptController_Reset_MRIPID(SUNAdaptController C); +SUNDIALS_EXPORT +int SUNAdaptController_SetDefaults_MRIPID(SUNAdaptController C); +SUNDIALS_EXPORT +int SUNAdaptController_Write_MRIPID(SUNAdaptController C, FILE* fptr); +SUNDIALS_EXPORT +int SUNAdaptController_SetErrorBias_MRIPID(SUNAdaptController C, + sunrealtype bias); +SUNDIALS_EXPORT +int SUNAdaptController_UpdateMRIH_MRIPID(SUNAdaptController C, sunrealtype H, + sunrealtype h, sunrealtype DSM, + sunrealtype dsm); +SUNDIALS_EXPORT +int SUNAdaptController_Space_MRIPID(SUNAdaptController C, long int* lenrw, + long int* leniw); + +#ifdef __cplusplus +} +#endif + +#endif /* _SUNADAPTCONTROLLER_MRIPID_H */ diff --git a/include/sundials/sundials_adaptcontroller.h b/include/sundials/sundials_adaptcontroller.h index b27d7c73c8..77a06a4748 100644 --- a/include/sundials/sundials_adaptcontroller.h +++ b/include/sundials/sundials_adaptcontroller.h @@ -31,16 +31,19 @@ extern "C" { #endif /* ----------------------------------------------------------------- - * SUNAdaptController types (currently, only "H" is implemented; - * others are planned): + * SUNAdaptController types: * NONE - empty controller (does nothing) * H - controls a single-rate step size + * 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_H, + SUN_ADAPTCONTROLLER_MRI_H, + SUN_ADAPTCONTROLLER_MRI_TOL } SUNAdaptController_Type; /* ----------------------------------------------------------------- @@ -63,6 +66,18 @@ struct _generic_SUNAdaptController_Ops SUNErrCode (*estimatestep)(SUNAdaptController C, sunrealtype h, int p, sunrealtype dsm, sunrealtype* hnew); + /* REQUIRED for controllers of SUN_ADAPTCONTROLLER_MRI_H type. */ + SUNErrCode (*estimatemristeps)(SUNAdaptController C, sunrealtype H, + sunrealtype h, int P, sunrealtype DSM, + sunrealtype dsm, sunrealtype* Hnew, + sunrealtype* hnew); + + /* REQUIRED for controllers of SUN_ADAPTCONTROLLER_MRI_TOL type. */ + SUNErrCode (*estimatesteptol)(SUNAdaptController C, sunrealtype H, + sunrealtype tolfac, int P, sunrealtype DSM, + sunrealtype dsm, sunrealtype* Hnew, + sunrealtype* tolfacnew); + /* OPTIONAL for all SUNAdaptController implementations. */ SUNErrCode (*destroy)(SUNAdaptController C); SUNErrCode (*reset)(SUNAdaptController C); @@ -70,6 +85,11 @@ struct _generic_SUNAdaptController_Ops SUNErrCode (*write)(SUNAdaptController C, FILE* fptr); SUNErrCode (*seterrorbias)(SUNAdaptController C, sunrealtype bias); SUNErrCode (*updateh)(SUNAdaptController C, sunrealtype h, sunrealtype dsm); + SUNErrCode (*updatemrih)(SUNAdaptController C, sunrealtype H, sunrealtype h, + sunrealtype DSM, sunrealtype dsm); + SUNErrCode (*updatemritol)(SUNAdaptController C, sunrealtype H, + sunrealtype tolfac, sunrealtype DSM, + sunrealtype dsm); SUNErrCode (*space)(SUNAdaptController C, long int* lenrw, long int* leniw); }; @@ -118,6 +138,34 @@ SUNErrCode SUNAdaptController_EstimateStep(SUNAdaptController C, sunrealtype h, int p, sunrealtype dsm, sunrealtype* hnew); +/* 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 +SUNErrCode SUNAdaptController_EstimateMRISteps(SUNAdaptController C, + sunrealtype H, sunrealtype h, + int P, sunrealtype DSM, + sunrealtype dsm, sunrealtype* Hnew, + sunrealtype* hnew); + +/* Combined slow step/fast tolerance multirate controller function. + This is called following a slow multirate time step with size 'H' + and fast/slow relative tolerance ratio 'tolfac', and error factors + 'DSM' and 'dsm' (slow and fast, resp.). The controller should + estimate slow stepsize 'Hnew' and updated relative tolerance ratio + 'tolfacnew', so that the ensuing step will have 'DSM' and 'dsm' + values JUST BELOW 1 with minimal computational effort. */ +SUNDIALS_EXPORT +SUNErrCode SUNAdaptController_EstimateStepTol(SUNAdaptController C, + sunrealtype H, sunrealtype tolfac, + int P, 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 @@ -145,6 +193,24 @@ SUNDIALS_EXPORT SUNErrCode SUNAdaptController_UpdateH(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 +SUNErrCode 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 +SUNErrCode SUNAdaptController_UpdateMRITol(SUNAdaptController C, sunrealtype H, + sunrealtype tolfac, sunrealtype DSM, + sunrealtype dsm); + /* Function to return the memory requirements of the controller object. */ SUNDIALS_EXPORT SUNErrCode SUNAdaptController_Space(SUNAdaptController C, long int* lenrw, diff --git a/src/arkode/CMakeLists.txt b/src/arkode/CMakeLists.txt index f8a0f4be63..8f2d296d58 100644 --- a/src/arkode/CMakeLists.txt +++ b/src/arkode/CMakeLists.txt @@ -33,6 +33,7 @@ set(arkode_SOURCES arkode_io.c arkode_ls.c arkode_mri_tables.c + arkode_mristep_controller.c arkode_mristep_io.c arkode_mristep_nls.c arkode_mristep.c @@ -74,6 +75,11 @@ sundials_add_library( sundials_nvecserial_obj sundials_sunadaptcontrollerimexgus_obj sundials_sunadaptcontrollersoderlind_obj + sundials_sunadaptcontrollermrill_obj + sundials_sunadaptcontrollermricc_obj + sundials_sunadaptcontrollermripi_obj + sundials_sunadaptcontrollermripid_obj + sundials_sunadaptcontrollermrihtol_obj sundials_sunmatrixband_obj sundials_sunmatrixdense_obj sundials_sunmatrixsparse_obj diff --git a/src/arkode/arkode.c b/src/arkode/arkode.c index 1473b8f204..d8f617997d 100644 --- a/src/arkode/arkode.c +++ b/src/arkode/arkode.c @@ -135,7 +135,7 @@ int ARKodeResize(void* arkode_mem, N_Vector y0, sunrealtype hscale, } } - /* Determining change in vector sizes */ + /* Determine change in vector sizes */ lrw1 = liw1 = 0; if (y0->ops->nvspace != NULL) { N_VSpace(y0, &lrw1, &liw1); } lrw_diff = lrw1 - ark_mem->lrw1; @@ -702,6 +702,9 @@ int ARKodeEvolve(void* arkode_mem, sunrealtype tout, N_Vector yout, ark_mem->root_mem->taskc = itask; } + /* store copy of tout, in case it is required for stepper initialization */ + ark_mem->tout = tout; + /* perform first-step-specific initializations: - initialize tret values to initialization time - perform initial integrator setup */ @@ -1523,6 +1526,10 @@ ARKodeMem arkCreate(SUNContext sunctx) ark_mem->h = ZERO; ark_mem->h0u = ZERO; + /* Accumulated error estimation strategy */ + ark_mem->AccumErrorType = -1; + ark_mem->AccumError = ZERO; + /* Set default values for integrator optional inputs */ iret = ARKodeSetDefaults(ark_mem); if (iret != ARK_SUCCESS) @@ -1792,29 +1799,6 @@ int arkInitialSetup(ARKodeMem ark_mem, sunrealtype tout) sunrealtype tout_hin, rh, htmp; sunbooleantype conOK; - /* Set up the time stepper module */ - if (ark_mem->step_init == NULL) - { - arkProcessError(ark_mem, ARK_ILL_INPUT, __LINE__, __func__, __FILE__, - "Time stepper module is missing"); - return (ARK_ILL_INPUT); - } - retval = ark_mem->step_init(ark_mem, ark_mem->init_type); - if (retval != ARK_SUCCESS) - { - arkProcessError(ark_mem, retval, __LINE__, __func__, __FILE__, - "Error in initialization of time stepper module"); - return (retval); - } - - /* Check that user has supplied an initial step size if fixedstep mode is on */ - if ((ark_mem->fixedstep) && (ark_mem->hin == ZERO)) - { - arkProcessError(ark_mem, ARK_ILL_INPUT, __LINE__, __func__, __FILE__, - "Fixed step mode enabled, but no step size set"); - return (ARK_ILL_INPUT); - } - /* If using a built-in routine for error/residual weights with abstol==0, ensure that N_VMin is available */ if ((!ark_mem->user_efun) && (ark_mem->atolmin0) && (!ark_mem->yn->ops->nvmin)) @@ -1831,30 +1815,6 @@ int arkInitialSetup(ARKodeMem ark_mem, sunrealtype tout) return (ARK_ILL_INPUT); } - /* Test input tstop for legality (correct direction of integration) */ - if (ark_mem->tstopset) - { - htmp = (ark_mem->h == ZERO) ? tout - ark_mem->tcur : ark_mem->h; - if ((ark_mem->tstop - ark_mem->tcur) * htmp <= ZERO) - { - arkProcessError(ark_mem, ARK_ILL_INPUT, __LINE__, __func__, __FILE__, - MSG_ARK_BAD_TSTOP, ark_mem->tstop, ark_mem->tcur); - return (ARK_ILL_INPUT); - } - } - - /* Check to see if y0 satisfies constraints */ - if (ark_mem->constraintsSet) - { - conOK = N_VConstrMask(ark_mem->constraints, ark_mem->yn, ark_mem->tempv1); - if (!conOK) - { - arkProcessError(ark_mem, ARK_ILL_INPUT, __LINE__, __func__, __FILE__, - MSG_ARK_Y0_FAIL_CONSTR); - return (ARK_ILL_INPUT); - } - } - /* Load initial error weights */ retval = ark_mem->efun(ark_mem->yn, ark_mem->ewt, ark_mem->e_data); if (retval != 0) @@ -1896,6 +1856,53 @@ int arkInitialSetup(ARKodeMem ark_mem, sunrealtype tout) } } + /* Set up the time stepper module */ + if (ark_mem->step_init == NULL) + { + arkProcessError(ark_mem, ARK_ILL_INPUT, __LINE__, __func__, __FILE__, + "Time stepper module is missing"); + return (ARK_ILL_INPUT); + } + retval = ark_mem->step_init(ark_mem, ark_mem->init_type); + if (retval != ARK_SUCCESS) + { + arkProcessError(ark_mem, retval, __LINE__, __func__, __FILE__, + "Error in initialization of time stepper module"); + return (retval); + } + + /* Check that user has supplied an initial step size if fixedstep mode is on */ + if ((ark_mem->fixedstep) && (ark_mem->hin == ZERO)) + { + arkProcessError(ark_mem, ARK_ILL_INPUT, __LINE__, __func__, __FILE__, + "Fixed step mode enabled, but no step size set"); + return (ARK_ILL_INPUT); + } + + /* Test input tstop for legality (correct direction of integration) */ + if (ark_mem->tstopset) + { + htmp = (ark_mem->h == ZERO) ? tout - ark_mem->tcur : ark_mem->h; + if ((ark_mem->tstop - ark_mem->tcur) * htmp <= ZERO) + { + arkProcessError(ark_mem, ARK_ILL_INPUT, __LINE__, __func__, __FILE__, + MSG_ARK_BAD_TSTOP, ark_mem->tstop, ark_mem->tcur); + return (ARK_ILL_INPUT); + } + } + + /* Check to see if y0 satisfies constraints */ + if (ark_mem->constraintsSet) + { + conOK = N_VConstrMask(ark_mem->constraints, ark_mem->yn, ark_mem->tempv1); + if (!conOK) + { + arkProcessError(ark_mem, ARK_ILL_INPUT, __LINE__, __func__, __FILE__, + MSG_ARK_Y0_FAIL_CONSTR); + return (ARK_ILL_INPUT); + } + } + /* Create default Hermite interpolation module (if needed) */ if (ark_mem->interp_type != ARK_INTERP_NONE && !(ark_mem->interp)) { @@ -1982,9 +1989,16 @@ int arkInitialSetup(ARKodeMem ark_mem, sunrealtype tout) /* Estimate initial h if not set */ if (ark_mem->h == ZERO) { - /* Again, temporarily set h for estimating an optimal value */ + /* If necessary, temporarily set h as it is used to compute the tolerance + in a potential mass matrix solve when computing the full rhs */ ark_mem->h = SUNRabs(tout - ark_mem->tcur); - if (ark_mem->h == ZERO) { ark_mem->h = ONE; } + if (ark_mem->h == ZERO) ark_mem->h = ONE; + + /* Call fullrhs */ + retval = ark_mem->step_fullrhs(ark_mem, ark_mem->tcur, ark_mem->yn, + ark_mem->fn, ARK_FULLRHS_START); + if (retval != 0) return (ARK_RHSFUNC_FAIL); + /* Estimate the first step size */ tout_hin = tout; if (ark_mem->tstopset && @@ -1992,7 +2006,9 @@ int arkInitialSetup(ARKodeMem ark_mem, sunrealtype tout) { tout_hin = ark_mem->tstop; } - hflag = arkHin(ark_mem, tout_hin); + hflag = arkHin(ark_mem, ark_mem->tcur, tout_hin, ark_mem->yn, ark_mem->fn, + ark_mem->ycur, ark_mem->tempv1, ark_mem->tempv2, + ark_mem->step_fullrhs, &ark_mem->h); if (hflag != ARK_SUCCESS) { istate = arkHandleFailure(ark_mem, hflag); @@ -2292,7 +2308,9 @@ int arkStopTests(ARKodeMem ark_mem, sunrealtype tout, N_Vector yout, Finally, we apply a bias (0.5) and verify that h0 is within bounds. ---------------------------------------------------------------*/ -int arkHin(ARKodeMem ark_mem, sunrealtype tout) +int arkHin(ARKodeMem ark_mem, sunrealtype tcur, sunrealtype tout, N_Vector ycur, + N_Vector fcur, N_Vector ytmp, N_Vector temp1, N_Vector temp2, + ARKTimestepFullRHSFn rhs, sunrealtype* h) { int retval, sign, count1, count2; sunrealtype tdiff, tdist, tround, hlb, hub; @@ -2300,39 +2318,26 @@ int arkHin(ARKodeMem ark_mem, sunrealtype tout) sunbooleantype hgOK; /* If tout is too close to tn, give up */ - if ((tdiff = tout - ark_mem->tcur) == ZERO) { return (ARK_TOO_CLOSE); } + if ((tdiff = tout - tcur) == ZERO) { return (ARK_TOO_CLOSE); } sign = (tdiff > ZERO) ? 1 : -1; tdist = SUNRabs(tdiff); - tround = ark_mem->uround * SUNMAX(SUNRabs(ark_mem->tcur), SUNRabs(tout)); + tround = ark_mem->uround * SUNMAX(SUNRabs(tcur), SUNRabs(tout)); if (tdist < TWO * tround) { return (ARK_TOO_CLOSE); } - /* call full RHS if needed */ - if (!(ark_mem->fn_is_current)) - { - /* NOTE: The step size (h) is used in setting the tolerance in a potential - mass matrix solve when computing the full RHS. Before calling arkHin, h - is set to |tout - tcur| or 1 and so we do not need to guard against - h == 0 here before calling the full RHS. */ - retval = ark_mem->step_fullrhs(ark_mem, ark_mem->tn, ark_mem->yn, - ark_mem->fn, ARK_FULLRHS_START); - if (retval) { return ARK_RHSFUNC_FAIL; } - ark_mem->fn_is_current = SUNTRUE; - } - /* Set lower and upper bounds on h0, and take geometric mean as first trial value. Exit with this value if the bounds cross each other. */ hlb = H0_LBFACTOR * tround; - hub = arkUpperBoundH0(ark_mem, tdist); + hub = arkUpperBoundH0(ark_mem, tdist, ycur, fcur, temp1, temp2); hg = SUNRsqrt(hlb * hub); if (hub < hlb) { - if (sign == -1) { ark_mem->h = -hg; } - else { ark_mem->h = hg; } + if (sign == -1) { *h = -hg; } + else { *h = hg; } return (ARK_SUCCESS); } @@ -2346,7 +2351,8 @@ int arkHin(ARKodeMem ark_mem, sunrealtype tout) for (count2 = 1; count2 <= H0_ITERS; count2++) { hgs = hg * sign; - retval = arkYddNorm(ark_mem, hgs, &yddnrm); + retval = arkYddNorm(ark_mem, hgs, tcur, ycur, fcur, ytmp, temp1, rhs, + &yddnrm); /* If f() failed unrecoverably, give up */ if (retval < 0) { return (ARK_RHSFUNC_FAIL); } /* If successful, we can use ydd */ @@ -2401,7 +2407,7 @@ int arkHin(ARKodeMem ark_mem, sunrealtype tout) if (h0 < hlb) { h0 = hlb; } if (h0 > hub) { h0 = hub; } if (sign == -1) { h0 = -h0; } - ark_mem->h = h0; + *h = h0; return (ARK_SUCCESS); } @@ -2411,24 +2417,24 @@ int arkHin(ARKodeMem ark_mem, sunrealtype tout) This routine sets an upper bound on abs(h0) based on tdist = tn - t0 and the values of y[i]/y'[i]. + + It is assumed that the input f equals y', and that + temp1 and temp2 may be modified as desired. ---------------------------------------------------------------*/ -sunrealtype arkUpperBoundH0(ARKodeMem ark_mem, sunrealtype tdist) +sunrealtype arkUpperBoundH0(ARKodeMem ark_mem, sunrealtype tdist, N_Vector y, + N_Vector f, N_Vector temp1, N_Vector temp2) { sunrealtype hub_inv, hub; - N_Vector temp1, temp2; /* Bound based on |y0|/|y0'| -- allow at most an increase of * H0_UBFACTOR in y0 (based on a forward Euler step). The weight * factor is used as a safeguard against zero components in y0. */ - temp1 = ark_mem->tempv1; - temp2 = ark_mem->tempv2; - - N_VAbs(ark_mem->yn, temp2); - ark_mem->efun(ark_mem->yn, temp1, ark_mem->e_data); + N_VAbs(y, temp2); + ark_mem->efun(y, temp1, ark_mem->e_data); N_VInv(temp1, temp1); N_VLinearSum(H0_UBFACTOR, temp2, ONE, temp1, temp1); - N_VAbs(ark_mem->fn, temp2); + N_VAbs(f, temp2); N_VDiv(temp2, temp1, temp1); hub_inv = N_VMaxNorm(temp1); @@ -2448,28 +2454,32 @@ sunrealtype arkUpperBoundH0(ARKodeMem ark_mem, sunrealtype tdist) This routine computes an estimate of the second derivative of y using a difference quotient, and returns its WRMS norm. + + It is assumed that the input f equals y'(t), that ycur can + be modified as desired, but upon return to equal y, and that + temp1 may be modified as desired. ---------------------------------------------------------------*/ -int arkYddNorm(ARKodeMem ark_mem, sunrealtype hg, sunrealtype* yddnrm) +int arkYddNorm(ARKodeMem ark_mem, sunrealtype hg, sunrealtype t, N_Vector y, + N_Vector f, N_Vector ycur, N_Vector temp1, + ARKTimestepFullRHSFn rhs, sunrealtype* yddnrm) { int retval; /* increment y with a multiple of f */ - N_VLinearSum(hg, ark_mem->fn, ONE, ark_mem->yn, ark_mem->ycur); + N_VLinearSum(hg, f, ONE, y, ycur); /* compute y', via the ODE RHS routine */ - retval = ark_mem->step_fullrhs(ark_mem, ark_mem->tcur + hg, ark_mem->ycur, - ark_mem->tempv1, ARK_FULLRHS_OTHER); - if (retval != 0) { return (ARK_RHSFUNC_FAIL); } + retval = rhs(ark_mem, t + hg, ycur, temp1, ARK_FULLRHS_OTHER); + if (retval != 0) return (ARK_RHSFUNC_FAIL); /* difference new f and original f to estimate y'' */ - N_VLinearSum(ONE / hg, ark_mem->tempv1, -ONE / hg, ark_mem->fn, - ark_mem->tempv1); + N_VLinearSum(ONE / hg, temp1, -ONE / hg, f, temp1); /* reset ycur to equal yn (unnecessary?) */ - N_VScale(ONE, ark_mem->yn, ark_mem->ycur); + N_VScale(ONE, y, ycur); /* compute norm of y'' */ - *yddnrm = N_VWrmsNorm(ark_mem->tempv1, ark_mem->ewt); + *yddnrm = N_VWrmsNorm(temp1, ark_mem->ewt); return (ARK_SUCCESS); } @@ -2521,6 +2531,13 @@ int arkCompleteStep(ARKodeMem ark_mem, sunrealtype dsm) ark_mem->nst, ark_mem->h, ark_mem->tcur); #endif + /* store this step's contribution to accumulated temporal error */ + if (ark_mem->AccumErrorType == 0) + { + ark_mem->AccumError = SUNMAX(dsm, ark_mem->AccumError); + } + else if (ark_mem->AccumErrorType == 1) { ark_mem->AccumError += dsm; } + /* apply user-supplied step postprocessing function (if supplied) */ if (ark_mem->ProcessStep != NULL) { @@ -2994,6 +3011,7 @@ int arkCheckConvergence(ARKodeMem ark_mem, int* nflagPtr, int* ncfPtr) { ARKodeHAdaptMem hadapt_mem; + /* If nonlinear solver succeeded, return with ARK_SUCCESS */ if (*nflagPtr == ARK_SUCCESS) { return (ARK_SUCCESS); } /* The nonlinear soln. failed; increment ncfn */ diff --git a/src/arkode/arkode_arkstep.c b/src/arkode/arkode_arkstep.c index 4f6e403ccf..26646000fb 100644 --- a/src/arkode/arkode_arkstep.c +++ b/src/arkode/arkode_arkstep.c @@ -379,6 +379,23 @@ int ARKStepCreateMRIStepInnerStepper(void* inner_arkode_mem, retval = MRIStepInnerStepper_SetResetFn(*stepper, arkStep_MRIStepInnerReset); if (retval != ARK_SUCCESS) { return (retval); } + retval = + MRIStepInnerStepper_SetAccumulatedErrorGetFn(*stepper, + arkStep_MRIStepInnerGetAccumulatedError); + if (retval != ARK_SUCCESS) { return (retval); } + + retval = + MRIStepInnerStepper_SetAccumulatedErrorResetFn(*stepper, + arkStep_MRIStepInnerResetAccumulatedError); + if (retval != ARK_SUCCESS) { return (retval); } + + retval = MRIStepInnerStepper_SetFixedStepFn(*stepper, + arkStep_MRIStepInnerSetFixedStep); + if (retval != ARK_SUCCESS) { return (retval); } + + retval = MRIStepInnerStepper_SetRTolFn(*stepper, arkStep_MRIStepInnerSetRTol); + if (retval != ARK_SUCCESS) { return (retval); } + return (ARK_SUCCESS); } @@ -995,12 +1012,14 @@ int arkStep_Init(ARKodeMem ark_mem, int init_type) if (init_type == FIRST_INIT) { /* enforce use of arkEwtSmallReal if using a fixed step size for - an explicit method, an internal error weight function, and not - using an iterative mass matrix solver with rwt=ewt */ + an explicit method, an internal error weight function, not + using an iterative mass matrix solver with rwt=ewt, and not + performing accumulated temporal error estimation */ reset_efun = SUNTRUE; if (step_mem->implicit) { reset_efun = SUNFALSE; } if (!ark_mem->fixedstep) { reset_efun = SUNFALSE; } if (ark_mem->user_efun) { reset_efun = SUNFALSE; } + if (ark_mem->AccumErrorType >= 0) { reset_efun = SUNFALSE; } if (ark_mem->rwt_is_ewt && (step_mem->msolve_type == SUNLINEARSOLVER_ITERATIVE)) { @@ -1048,11 +1067,13 @@ int arkStep_Init(ARKodeMem ark_mem, int init_type) step_mem->p = ark_mem->hadapt_mem->p = step_mem->Be->p; } - /* Ensure that if adaptivity is enabled, then method includes embedding coefficients */ - if (!ark_mem->fixedstep && (step_mem->p == 0)) + /* Ensure that if adaptivity or error accumulation is enabled, then + method includes embedding coefficients */ + if ((!ark_mem->fixedstep || (ark_mem->AccumErrorType >= 0)) && + (step_mem->p == 0)) { arkProcessError(ark_mem, ARK_ILL_INPUT, __LINE__, __func__, - __FILE__, "Adaptive timestepping cannot be performed without embedding coefficients"); + __FILE__, "Temporal error estimation cannot be performed without embedding coefficients"); return (ARK_ILL_INPUT); } @@ -1838,20 +1859,20 @@ int arkStep_TakeStep_Z(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr) #ifdef SUNDIALS_LOGGING_EXTRA_DEBUG SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, "ARKODE::arkStep_TakeStep_Z", "explicit stage", - "z_%i(:) =", 0); + "z[%i] =", 0); N_VPrintFile(ark_mem->ycur, ARK_LOGGER->debug_fp); if (step_mem->implicit) { SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, "ARKODE::arkStep_TakeStep_Z", "implicit RHS", - "Fi_%i(:) =", 0); + "Fi[%i] =", 0); N_VPrintFile(step_mem->Fi[0], ARK_LOGGER->debug_fp); } if (step_mem->explicit) { SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, "ARKODE::arkStep_TakeStep_Z", "explicit RHS", - "Fe_%i(:) =", 0); + "Fe[%i] =", 0); N_VPrintFile(step_mem->Fe[0], ARK_LOGGER->debug_fp); } #endif @@ -1919,8 +1940,7 @@ int arkStep_TakeStep_Z(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr) #ifdef SUNDIALS_LOGGING_EXTRA_DEBUG SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, - "ARKODE::arkStep_TakeStep_Z", "predictor", - "zpred(:) =", ""); + "ARKODE::arkStep_TakeStep_Z", "predictor", "zpred =", ""); N_VPrintFile(step_mem->zpred, ARK_LOGGER->debug_fp); #endif @@ -1930,8 +1950,7 @@ int arkStep_TakeStep_Z(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr) #ifdef SUNDIALS_LOGGING_EXTRA_DEBUG SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, - "ARKODE::arkStep_TakeStep_Z", "rhs data", - "sdata(:) =", ""); + "ARKODE::arkStep_TakeStep_Z", "rhs data", "sdata =", ""); N_VPrintFile(step_mem->sdata, ARK_LOGGER->debug_fp); #endif @@ -1946,7 +1965,7 @@ int arkStep_TakeStep_Z(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr) #ifdef SUNDIALS_LOGGING_EXTRA_DEBUG SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, "ARKODE::arkStep_TakeStep_Z", "implicit stage", - "z_%i(:) =", is); + "z[%i] =", is); N_VPrintFile(ark_mem->ycur, ARK_LOGGER->debug_fp); #endif @@ -1970,7 +1989,7 @@ int arkStep_TakeStep_Z(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr) #ifdef SUNDIALS_LOGGING_EXTRA_DEBUG SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, "ARKODE::arkStep_TakeStep_Z", "explicit stage", - "z_%i(:) =", is); + "z[%i] =", is); N_VPrintFile(ark_mem->ycur, ARK_LOGGER->debug_fp); #endif } @@ -2015,7 +2034,7 @@ int arkStep_TakeStep_Z(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr) #ifdef SUNDIALS_LOGGING_EXTRA_DEBUG SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, "ARKODE::arkStep_TakeStep_Z", "implicit RHS", - "Fi_%i(:) =", is); + "Fi[%i] =", is); N_VPrintFile(step_mem->Fi[is], ARK_LOGGER->debug_fp); #endif @@ -2033,7 +2052,7 @@ int arkStep_TakeStep_Z(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr) #ifdef SUNDIALS_LOGGING_EXTRA_DEBUG SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, "ARKODE::arkStep_TakeStep_Z", "explicit RHS", - "Fe_%i(:) =", is); + "Fe[%i] =", is); N_VPrintFile(step_mem->Fe[is], ARK_LOGGER->debug_fp); #endif @@ -2052,7 +2071,7 @@ int arkStep_TakeStep_Z(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr) #ifdef SUNDIALS_LOGGING_EXTRA_DEBUG SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, "ARKODE::arkStep_TakeStep_Z", "M^{-1} implicit RHS", - "Fi_%i(:) =", is); + "Fi[%i] =", is); N_VPrintFile(step_mem->Fi[is], ARK_LOGGER->debug_fp); #endif if (*nflagPtr != ARK_SUCCESS) { return (TRY_AGAIN); } @@ -2064,7 +2083,7 @@ int arkStep_TakeStep_Z(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr) #ifdef SUNDIALS_LOGGING_EXTRA_DEBUG SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, "ARKODE::arkStep_TakeStep_Z", "M^{-1} explicit RHS", - "Fe_%i(:) =", is); + "Fe[%i] =", is); N_VPrintFile(step_mem->Fe[is], ARK_LOGGER->debug_fp); #endif if (*nflagPtr != ARK_SUCCESS) { return (TRY_AGAIN); } @@ -2086,15 +2105,16 @@ int arkStep_TakeStep_Z(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr) #ifdef SUNDIALS_LOGGING_EXTRA_DEBUG SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, "ARKODE::arkStep_TakeStep_Z", - "updated solution", "ycur(:) =", ""); + "updated solution", "ycur =", ""); N_VPrintFile(ark_mem->ycur, ARK_LOGGER->debug_fp); #endif #if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_INFO SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_INFO, "ARKODE::arkStep_TakeStep_Z", "end-step", - "step = %li, h = %" RSYM ", dsm = %" RSYM ", nflag = %d", - ark_mem->nst, ark_mem->h, *dsmPtr, *nflagPtr); + "step = %li, t = %" RSYM ", h = %" RSYM ", dsm = %" RSYM + ", nflag = %d", + ark_mem->nst, ark_mem->tn, ark_mem->h, *dsmPtr, *nflagPtr); #endif return (ARK_SUCCESS); @@ -2957,8 +2977,8 @@ int arkStep_ComputeSolutions(ARKodeMem ark_mem, sunrealtype* dsmPtr) if (retval != 0) { return (ARK_VECTOROP_ERR); } } - /* Compute yerr (if step adaptivity enabled) */ - if (!ark_mem->fixedstep) + /* Compute yerr (if temporal error estimation is enabled). */ + if (!ark_mem->fixedstep || (ark_mem->AccumErrorType >= 0)) { /* set arrays for fused vector operation */ nvec = 0; @@ -3248,6 +3268,96 @@ int arkStep_MRIStepInnerReset(MRIStepInnerStepper stepper, sunrealtype tR, return (ARKodeReset(arkode_mem, tR, yR)); } +/*------------------------------------------------------------------------------ + arkStep_MRIStepInnerGetAccumulatedError + + Implementation of MRIStepInnerGetAccumulatedError to retrieve the accumulated + temporal error estimate from the inner (fast) stepper. + ----------------------------------------------------------------------------*/ + +int arkStep_MRIStepInnerGetAccumulatedError(MRIStepInnerStepper stepper, + sunrealtype* accum_error) +{ + void* arkode_mem; + int retval; + + /* extract the ARKODE memory struct */ + retval = MRIStepInnerStepper_GetContent(stepper, &arkode_mem); + if (retval != ARK_SUCCESS) { return (retval); } + + return (ARKodeGetAccumulatedError(arkode_mem, accum_error)); +} + +/*------------------------------------------------------------------------------ + arkStep_MRIStepInnerResetAccumulatedError + + Implementation of MRIStepInnerResetAccumulatedError to reset the accumulated + temporal error estimator in the inner (fast) stepper. + ----------------------------------------------------------------------------*/ + +int arkStep_MRIStepInnerResetAccumulatedError(MRIStepInnerStepper stepper) +{ + void* arkode_mem; + int retval; + + /* extract the ARKODE memory struct */ + retval = MRIStepInnerStepper_GetContent(stepper, &arkode_mem); + if (retval != ARK_SUCCESS) { return (retval); } + + return (ARKodeResetAccumulatedError(arkode_mem)); +} + +/*------------------------------------------------------------------------------ + arkStep_MRIStepInnerSetFixedStep + + Implementation of MRIStepInnerSetFixedStep to set a fixed step size for + the upcoming evolution using the inner (fast) stepper. + ----------------------------------------------------------------------------*/ + +int arkStep_MRIStepInnerSetFixedStep(MRIStepInnerStepper stepper, sunrealtype h) +{ + void* arkode_mem; + int retval; + + /* extract the ARKODE memory struct */ + retval = MRIStepInnerStepper_GetContent(stepper, &arkode_mem); + if (retval != ARK_SUCCESS) { return (retval); } + + return (ARKodeSetFixedStep(arkode_mem, h)); +} + +/*------------------------------------------------------------------------------ + arkStep_MRIStepInnerSetRTol + + Implementation of MRIStepInnerSetRTol to set a relative tolerance for the + upcoming evolution using the inner (fast) stepper. + ----------------------------------------------------------------------------*/ + +int arkStep_MRIStepInnerSetRTol(MRIStepInnerStepper stepper, sunrealtype rtol) +{ + void* arkode_mem; + ARKodeMem ark_mem; + int retval; + + /* extract the ARKODE memory struct */ + retval = MRIStepInnerStepper_GetContent(stepper, &arkode_mem); + if (retval != ARK_SUCCESS) return (retval); + if (arkode_mem == NULL) + { + arkProcessError(NULL, ARK_ILL_INPUT, __LINE__, __func__, __FILE__, + MSG_ARK_NO_MEM); + return (ARK_MEM_NULL); + } + ark_mem = (ARKodeMem)arkode_mem; + + if (rtol > ZERO) + { + ark_mem->reltol = rtol; + return (ARK_SUCCESS); + } + else { return (ARK_ILL_INPUT); } +} + /*------------------------------------------------------------------------------ arkStep_ApplyForcing diff --git a/src/arkode/arkode_arkstep_impl.h b/src/arkode/arkode_arkstep_impl.h index 8af982cd1b..190fe8ce5f 100644 --- a/src/arkode/arkode_arkstep_impl.h +++ b/src/arkode/arkode_arkstep_impl.h @@ -277,6 +277,11 @@ int arkStep_MRIStepInnerFullRhs(MRIStepInnerStepper stepper, sunrealtype t, N_Vector y, N_Vector f, int mode); int arkStep_MRIStepInnerReset(MRIStepInnerStepper stepper, sunrealtype tR, N_Vector yR); +int arkStep_MRIStepInnerGetAccumulatedError(MRIStepInnerStepper stepper, + sunrealtype* accum_error); +int arkStep_MRIStepInnerResetAccumulatedError(MRIStepInnerStepper stepper); +int arkStep_MRIStepInnerSetFixedStep(MRIStepInnerStepper stepper, sunrealtype h); +int arkStep_MRIStepInnerSetRTol(MRIStepInnerStepper stepper, sunrealtype rtol); /* private functions for relaxation */ int arkStep_SetRelaxFn(ARKodeMem ark_mem, ARKRelaxFn rfn, ARKRelaxJacFn rjac); diff --git a/src/arkode/arkode_arkstep_io.c b/src/arkode/arkode_arkstep_io.c index 7df74cb590..7f6e4a43b3 100644 --- a/src/arkode/arkode_arkstep_io.c +++ b/src/arkode/arkode_arkstep_io.c @@ -1098,7 +1098,10 @@ int arkStep_GetEstLocalErrors(ARKodeMem ark_mem, N_Vector ele) if (retval != ARK_SUCCESS) { return (retval); } /* return an error if local truncation error is not computed */ - if (ark_mem->fixedstep) { return (ARK_STEPPER_UNSUPPORTED); } + if (ark_mem->fixedstep && (ark_mem->AccumErrorType < 0)) + { + return (ARK_STEPPER_UNSUPPORTED); + } /* otherwise, copy local truncation error vector to output */ N_VScale(ONE, ark_mem->tempv1, ele); diff --git a/src/arkode/arkode_arkstep_nls.c b/src/arkode/arkode_arkstep_nls.c index 939a82ad02..5f1811b156 100644 --- a/src/arkode/arkode_arkstep_nls.c +++ b/src/arkode/arkode_arkstep_nls.c @@ -425,7 +425,7 @@ int arkStep_Nls(ARKodeMem ark_mem, int nflag) #ifdef SUNDIALS_LOGGING_EXTRA_DEBUG SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, "ARKODE::arkStep_Nls", - "correction", "zcor(:) =", ""); + "correction", "zcor =", ""); N_VPrintFile(step_mem->zcor, ARK_LOGGER->debug_fp); #endif diff --git a/src/arkode/arkode_erkstep.c b/src/arkode/arkode_erkstep.c index 5cc09d2390..42f3dd09b5 100644 --- a/src/arkode/arkode_erkstep.c +++ b/src/arkode/arkode_erkstep.c @@ -131,6 +131,15 @@ void* ERKStepCreate(ARKRhsFn f, sunrealtype t0, N_Vector y0, SUNContext sunctx) /* Initialize all the counters */ step_mem->nfe = 0; + /* Initialize fused op work space */ + step_mem->cvals = NULL; + step_mem->Xvecs = NULL; + step_mem->nfusedopvecs = 0; + + /* Initialize external polynomial forcing data */ + step_mem->forcing = NULL; + step_mem->nforcing = 0; + /* Initialize main ARKODE infrastructure */ retval = arkInit(ark_mem, t0, y0, FIRST_INIT); if (retval != ARK_SUCCESS) @@ -296,14 +305,15 @@ void erkStep_Free(ARKodeMem ark_mem) { free(step_mem->cvals); step_mem->cvals = NULL; - ark_mem->lrw -= (step_mem->stages + 1); + ark_mem->lrw -= step_mem->nfusedopvecs; } if (step_mem->Xvecs != NULL) { free(step_mem->Xvecs); step_mem->Xvecs = NULL; - ark_mem->liw -= (step_mem->stages + 1); + ark_mem->liw -= step_mem->nfusedopvecs; } + step_mem->nfusedopvecs = 0; /* free the time stepper module itself */ free(ark_mem->step_mem); @@ -370,6 +380,7 @@ void erkStep_PrintMem(ARKodeMem ark_mem, FILE* outfile) int erkStep_Init(ARKodeMem ark_mem, int init_type) { ARKodeERKStepMem step_mem; + sunbooleantype reset_efun; int retval, j; /* access ARKodeERKStepMem structure */ @@ -382,9 +393,14 @@ int erkStep_Init(ARKodeMem ark_mem, int init_type) return (ARK_SUCCESS); } - /* enforce use of arkEwtSmallReal if using a fixed step size - and an internal error weight function */ - if (ark_mem->fixedstep && !ark_mem->user_efun) + /* enforce use of arkEwtSmallReal if using a fixed step size, + an internal error weight function, and not performing accumulated + temporal error estimation */ + reset_efun = SUNTRUE; + if (!ark_mem->fixedstep) { reset_efun = SUNFALSE; } + if (ark_mem->user_efun) { reset_efun = SUNFALSE; } + if (ark_mem->AccumErrorType >= 0) { reset_efun = SUNFALSE; } + if (reset_efun) { ark_mem->user_efun = SUNFALSE; ark_mem->efun = arkEwtSetSmallReal; @@ -413,11 +429,13 @@ int erkStep_Init(ARKodeMem ark_mem, int init_type) step_mem->q = ark_mem->hadapt_mem->q = step_mem->B->q; step_mem->p = ark_mem->hadapt_mem->p = step_mem->B->p; - /* Ensure that if adaptivity is enabled, then method includes embedding coefficients */ - if (!ark_mem->fixedstep && (step_mem->p == 0)) + /* Ensure that if adaptivity or error accumulation is enabled, then + method includes embedding coefficients */ + if ((!ark_mem->fixedstep || (ark_mem->AccumErrorType >= 0)) && + (step_mem->p == 0)) { arkProcessError(ark_mem, ARK_ILL_INPUT, __LINE__, __func__, - __FILE__, "Adaptive timestepping cannot be performed without embedding coefficients"); + __FILE__, "Temporal error estimation cannot be performed without embedding coefficients"); return (ARK_ILL_INPUT); } @@ -437,18 +455,19 @@ int erkStep_Init(ARKodeMem ark_mem, int init_type) ark_mem->liw += step_mem->stages; /* pointers */ /* Allocate reusable arrays for fused vector interface */ + step_mem->nfusedopvecs = step_mem->stages + 1 + step_mem->nforcing; if (step_mem->cvals == NULL) { - step_mem->cvals = (sunrealtype*)calloc(step_mem->stages + 1, + step_mem->cvals = (sunrealtype*)calloc(step_mem->nfusedopvecs, sizeof(sunrealtype)); if (step_mem->cvals == NULL) { return (ARK_MEM_FAIL); } - ark_mem->lrw += (step_mem->stages + 1); + ark_mem->lrw += step_mem->nfusedopvecs; } if (step_mem->Xvecs == NULL) { - step_mem->Xvecs = (N_Vector*)calloc(step_mem->stages + 1, sizeof(N_Vector)); + step_mem->Xvecs = (N_Vector*)calloc(step_mem->nfusedopvecs, sizeof(N_Vector)); if (step_mem->Xvecs == NULL) { return (ARK_MEM_FAIL); } - ark_mem->liw += (step_mem->stages + 1); /* pointers */ + ark_mem->liw += step_mem->nfusedopvecs; /* pointers */ } /* Override the interpolant degree (if needed), used in arkInitialSetup */ @@ -502,14 +521,20 @@ int erkStep_Init(ARKodeMem ark_mem, int init_type) int erkStep_FullRHS(ARKodeMem ark_mem, sunrealtype t, N_Vector y, N_Vector f, int mode) { - int retval; + int nvec, retval; ARKodeERKStepMem step_mem; sunbooleantype recomputeRHS; + sunrealtype* cvals; + N_Vector* Xvecs; /* access ARKodeERKStepMem structure */ retval = erkStep_AccessStepMem(ark_mem, __func__, &step_mem); if (retval != ARK_SUCCESS) { return (retval); } + /* local shortcuts for use with fused vector operations */ + cvals = step_mem->cvals; + Xvecs = step_mem->Xvecs; + /* perform RHS functions contingent on 'mode' argument */ switch (mode) { @@ -526,6 +551,16 @@ int erkStep_FullRHS(ARKodeMem ark_mem, sunrealtype t, N_Vector y, N_Vector f, MSG_ARK_RHSFUNC_FAILED, t); return (ARK_RHSFUNC_FAIL); } + + /* apply external polynomial forcing */ + if (step_mem->nforcing > 0) + { + cvals[0] = ONE; + Xvecs[0] = step_mem->F[0]; + nvec = 1; + erkStep_ApplyForcing(step_mem, t, ONE, &nvec); + N_VLinearCombination(nvec, cvals, Xvecs, step_mem->F[0]); + } } /* copy RHS vector into output */ @@ -555,6 +590,15 @@ int erkStep_FullRHS(ARKodeMem ark_mem, sunrealtype t, N_Vector y, N_Vector f, __FILE__, MSG_ARK_RHSFUNC_FAILED, t); return (ARK_RHSFUNC_FAIL); } + /* apply external polynomial forcing */ + if (step_mem->nforcing > 0) + { + cvals[0] = ONE; + Xvecs[0] = step_mem->F[0]; + nvec = 1; + erkStep_ApplyForcing(step_mem, t, ONE, &nvec); + N_VLinearCombination(nvec, cvals, Xvecs, step_mem->F[0]); + } } else { N_VScale(ONE, step_mem->F[step_mem->stages - 1], step_mem->F[0]); } } @@ -575,6 +619,15 @@ int erkStep_FullRHS(ARKodeMem ark_mem, sunrealtype t, N_Vector y, N_Vector f, MSG_ARK_RHSFUNC_FAILED, t); return (ARK_RHSFUNC_FAIL); } + /* apply external polynomial forcing */ + if (step_mem->nforcing > 0) + { + cvals[0] = ONE; + Xvecs[0] = f; + nvec = 1; + erkStep_ApplyForcing(step_mem, t, ONE, &nvec); + N_VLinearCombination(nvec, cvals, Xvecs, f); + } break; @@ -635,10 +688,10 @@ int erkStep_TakeStep(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr) #ifdef SUNDIALS_LOGGING_EXTRA_DEBUG SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, "ARKODE::erkStep_TakeStep", - "stage", "z_0(:) =", ""); + "stage", "z[0] =", ""); N_VPrintFile(ark_mem->ycur, ARK_LOGGER->debug_fp); SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, "ARKODE::erkStep_TakeStep", - "stage RHS", "F_0(:) =", ""); + "stage RHS", "F[0] =", ""); N_VPrintFile(step_mem->F[0], ARK_LOGGER->debug_fp); #endif @@ -702,9 +755,19 @@ int erkStep_TakeStep(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr) if (retval < 0) { return (ARK_RHSFUNC_FAIL); } if (retval > 0) { return (ARK_UNREC_RHSFUNC_ERR); } + /* apply external polynomial forcing */ + if (step_mem->nforcing > 0) + { + cvals[0] = ONE; + Xvecs[0] = step_mem->F[is]; + nvec = 1; + erkStep_ApplyForcing(step_mem, ark_mem->tcur, ONE, &nvec); + N_VLinearCombination(nvec, cvals, Xvecs, step_mem->F[is]); + } + #ifdef SUNDIALS_LOGGING_EXTRA_DEBUG SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, - "ARKODE::erkStep_TakeStep", "stage RHS", "F_%i(:) =", is); + "ARKODE::erkStep_TakeStep", "stage RHS", "F[%i] =", is); N_VPrintFile(step_mem->F[is], ARK_LOGGER->debug_fp); #endif @@ -716,14 +779,15 @@ int erkStep_TakeStep(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr) #ifdef SUNDIALS_LOGGING_EXTRA_DEBUG SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, "ARKODE::erkStep_TakeStep", - "updated solution", "ycur(:) =", ""); + "updated solution", "ycur =", ""); N_VPrintFile(ark_mem->ycur, ARK_LOGGER->debug_fp); #endif #if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_DEBUG SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, "ARKODE::erkStep_TakeStep", - "error-test", "step = %li, h = %" RSYM ", dsm = %" RSYM, - ark_mem->nst, ark_mem->h, *dsmPtr); + "end-step", + "step = %li, t = %" RSYM ", h = %" RSYM ", dsm = %" RSYM, + ark_mem->nst, ark_mem->tn, ark_mem->h, *dsmPtr); #endif return (ARK_SUCCESS); @@ -1026,8 +1090,8 @@ int erkStep_ComputeSolutions(ARKodeMem ark_mem, sunrealtype* dsmPtr) retval = N_VLinearCombination(nvec, cvals, Xvecs, y); if (retval != 0) { return (ARK_VECTOROP_ERR); } - /* Compute yerr (if step adaptivity enabled) */ - if (!ark_mem->fixedstep) + /* Compute yerr (if step adaptivity or error accumulation enabled) */ + if (!ark_mem->fixedstep || (ark_mem->AccumErrorType >= 0)) { /* set arrays for fused vector operation */ nvec = 0; @@ -1144,6 +1208,363 @@ int erkStep_GetOrder(ARKodeMem ark_mem) return step_mem->q; } +/*--------------------------------------------------------------- + Utility routines for ERKStep to serve as an MRIStepInnerStepper + ---------------------------------------------------------------*/ + +/*------------------------------------------------------------------------------ + ERKStepCreateMRIStepInnerStepper + + Wraps an ERKStep memory structure as an MRIStep inner stepper. + ----------------------------------------------------------------------------*/ + +int ERKStepCreateMRIStepInnerStepper(void* inner_arkode_mem, + MRIStepInnerStepper* stepper) +{ + int retval; + ARKodeMem ark_mem; + ARKodeERKStepMem step_mem; + + retval = erkStep_AccessARKODEStepMem(inner_arkode_mem, __func__, &ark_mem, + &step_mem); + if (retval) + { + arkProcessError(NULL, ARK_ILL_INPUT, __LINE__, __func__, __FILE__, + "The ERKStep memory pointer is NULL"); + return ARK_ILL_INPUT; + } + + retval = MRIStepInnerStepper_Create(ark_mem->sunctx, stepper); + if (retval != ARK_SUCCESS) { return (retval); } + + retval = MRIStepInnerStepper_SetContent(*stepper, inner_arkode_mem); + if (retval != ARK_SUCCESS) { return (retval); } + + retval = MRIStepInnerStepper_SetEvolveFn(*stepper, erkStep_MRIStepInnerEvolve); + if (retval != ARK_SUCCESS) { return (retval); } + + retval = MRIStepInnerStepper_SetFullRhsFn(*stepper, + erkStep_MRIStepInnerFullRhs); + if (retval != ARK_SUCCESS) { return (retval); } + + retval = MRIStepInnerStepper_SetResetFn(*stepper, erkStep_MRIStepInnerReset); + if (retval != ARK_SUCCESS) { return (retval); } + + retval = + MRIStepInnerStepper_SetAccumulatedErrorGetFn(*stepper, + erkStep_MRIStepInnerGetAccumulatedError); + if (retval != ARK_SUCCESS) { return (retval); } + + retval = + MRIStepInnerStepper_SetAccumulatedErrorResetFn(*stepper, + erkStep_MRIStepInnerResetAccumulatedError); + if (retval != ARK_SUCCESS) { return (retval); } + + retval = MRIStepInnerStepper_SetFixedStepFn(*stepper, + erkStep_MRIStepInnerSetFixedStep); + if (retval != ARK_SUCCESS) { return (retval); } + + retval = MRIStepInnerStepper_SetRTolFn(*stepper, erkStep_MRIStepInnerSetRTol); + if (retval != ARK_SUCCESS) { return (retval); } + + return (ARK_SUCCESS); +} + +/*------------------------------------------------------------------------------ + erkStep_MRIStepInnerEvolve + + Implementation of MRIStepInnerStepperEvolveFn to advance the inner (fast) + ODE IVP. + ----------------------------------------------------------------------------*/ + +int erkStep_MRIStepInnerEvolve(MRIStepInnerStepper stepper, sunrealtype t0, + sunrealtype tout, N_Vector y) +{ + void* arkode_mem; /* arkode memory */ + sunrealtype tret; /* return time */ + sunrealtype tshift, tscale; /* time normalization values */ + N_Vector* forcing; /* forcing vectors */ + int nforcing; /* number of forcing vectors */ + int retval; /* return value */ + + /* extract the ARKODE memory struct */ + retval = MRIStepInnerStepper_GetContent(stepper, &arkode_mem); + if (retval != ARK_SUCCESS) { return (retval); } + + /* get the forcing data */ + retval = MRIStepInnerStepper_GetForcingData(stepper, &tshift, &tscale, + &forcing, &nforcing); + if (retval != ARK_SUCCESS) { return (retval); } + + /* set the inner forcing data */ + retval = erkStep_SetInnerForcing(arkode_mem, tshift, tscale, forcing, nforcing); + if (retval != ARK_SUCCESS) { return (retval); } + + /* set the stop time */ + retval = ARKodeSetStopTime(arkode_mem, tout); + if (retval != ARK_SUCCESS) { return (retval); } + + /* evolve inner ODE */ + retval = ARKodeEvolve(arkode_mem, tout, y, &tret, ARK_NORMAL); + if (retval < 0) { return (retval); } + + /* disable inner forcing */ + retval = erkStep_SetInnerForcing(arkode_mem, ZERO, ONE, NULL, 0); + if (retval != ARK_SUCCESS) { return (retval); } + + return (ARK_SUCCESS); +} + +/*------------------------------------------------------------------------------ + erkStep_MRIStepInnerFullRhs + + Implementation of MRIStepInnerStepperFullRhsFn to compute the full inner + (fast) ODE IVP RHS. + ----------------------------------------------------------------------------*/ + +int erkStep_MRIStepInnerFullRhs(MRIStepInnerStepper stepper, sunrealtype t, + N_Vector y, N_Vector f, int mode) +{ + void* arkode_mem; + int retval; + + /* extract the ARKODE memory struct */ + retval = MRIStepInnerStepper_GetContent(stepper, &arkode_mem); + if (retval != ARK_SUCCESS) { return (retval); } + + return (erkStep_FullRHS(arkode_mem, t, y, f, mode)); +} + +/*------------------------------------------------------------------------------ + erkStep_MRIStepInnerReset + + Implementation of MRIStepInnerStepperResetFn to reset the inner (fast) stepper + state. + ----------------------------------------------------------------------------*/ + +int erkStep_MRIStepInnerReset(MRIStepInnerStepper stepper, sunrealtype tR, + N_Vector yR) +{ + void* arkode_mem; + int retval; + + /* extract the ARKODE memory struct */ + retval = MRIStepInnerStepper_GetContent(stepper, &arkode_mem); + if (retval != ARK_SUCCESS) { return (retval); } + + return (ARKodeReset(arkode_mem, tR, yR)); +} + +/*------------------------------------------------------------------------------ + erkStep_MRIStepInnerGetAccumulatedError + + Implementation of MRIStepInnerGetAccumulatedError to retrieve the accumulated + temporal error estimate from the inner (fast) stepper. + ----------------------------------------------------------------------------*/ + +int erkStep_MRIStepInnerGetAccumulatedError(MRIStepInnerStepper stepper, + sunrealtype* accum_error) +{ + void* arkode_mem; + int retval; + + /* extract the ARKODE memory struct */ + retval = MRIStepInnerStepper_GetContent(stepper, &arkode_mem); + if (retval != ARK_SUCCESS) { return (retval); } + + return (ARKodeGetAccumulatedError(arkode_mem, accum_error)); +} + +/*------------------------------------------------------------------------------ + erkStep_MRIStepInnerResetAccumulatedError + + Implementation of MRIStepInnerResetAccumulatedError to reset the accumulated + temporal error estimator in the inner (fast) stepper. + ----------------------------------------------------------------------------*/ + +int erkStep_MRIStepInnerResetAccumulatedError(MRIStepInnerStepper stepper) +{ + void* arkode_mem; + int retval; + + /* extract the ARKODE memory struct */ + retval = MRIStepInnerStepper_GetContent(stepper, &arkode_mem); + if (retval != ARK_SUCCESS) { return (retval); } + + return (ARKodeResetAccumulatedError(arkode_mem)); +} + +/*------------------------------------------------------------------------------ + erkStep_MRIStepInnerSetFixedStep + + Implementation of MRIStepInnerSetFixedStep to set a fixed step size for + the upcoming evolution using the inner (fast) stepper. + ----------------------------------------------------------------------------*/ + +int erkStep_MRIStepInnerSetFixedStep(MRIStepInnerStepper stepper, sunrealtype h) +{ + void* arkode_mem; + int retval; + + /* extract the ARKODE memory struct */ + retval = MRIStepInnerStepper_GetContent(stepper, &arkode_mem); + if (retval != ARK_SUCCESS) { return (retval); } + + return (ARKodeSetFixedStep(arkode_mem, h)); +} + +/*------------------------------------------------------------------------------ + erkStep_MRIStepInnerSetRTol + + Implementation of MRIStepInnerSetRTol to set a relative tolerance for the + upcoming evolution using the inner (fast) stepper. + ----------------------------------------------------------------------------*/ + +int erkStep_MRIStepInnerSetRTol(MRIStepInnerStepper stepper, sunrealtype rtol) +{ + void* arkode_mem; + ARKodeMem ark_mem; + int retval; + + /* extract the ARKODE memory struct */ + retval = MRIStepInnerStepper_GetContent(stepper, &arkode_mem); + if (retval != ARK_SUCCESS) { return (retval); } + if (arkode_mem == NULL) + { + arkProcessError(NULL, ARK_MEM_NULL, __LINE__, __func__, __FILE__, + MSG_ERKSTEP_NO_MEM); + return ARK_MEM_NULL; + } + ark_mem = (ARKodeMem)arkode_mem; + + if (rtol > ZERO) + { + ark_mem->reltol = rtol; + return (ARK_SUCCESS); + } + else { return (ARK_ILL_INPUT); } +} + +/*------------------------------------------------------------------------------ + erkStep_ApplyForcing + + Determines the linear combination coefficients and vectors to apply forcing + at a given value of the independent variable (t). This occurs through + appending coefficients and N_Vector pointers to the underlying cvals and Xvecs + arrays in the step_mem structure. The dereferenced input *nvec should indicate + the next available entry in the cvals/Xvecs arrays. The input 's' is a + scaling factor that should be applied to each of these coefficients. + ----------------------------------------------------------------------------*/ + +void erkStep_ApplyForcing(ARKodeERKStepMem step_mem, sunrealtype t, + sunrealtype s, int* nvec) +{ + sunrealtype tau, taui; + int i; + + /* always append the constant forcing term */ + step_mem->cvals[*nvec] = s; + step_mem->Xvecs[*nvec] = step_mem->forcing[0]; + (*nvec) += 1; + + /* compute normalized time tau and initialize tau^i */ + tau = (t - step_mem->tshift) / (step_mem->tscale); + taui = tau; + for (i = 1; i < step_mem->nforcing; i++) + { + step_mem->cvals[*nvec] = s * taui; + step_mem->Xvecs[*nvec] = step_mem->forcing[i]; + taui *= tau; + (*nvec) += 1; + } +} + +/*------------------------------------------------------------------------------ + erkStep_SetInnerForcing + + Sets an array of coefficient vectors for a time-dependent external polynomial + forcing term in the ODE RHS i.e., y' = f(t,y) + p(t). This function is + primarily intended for use with multirate integration methods (e.g., MRIStep) + where ERKStep is used to solve a modified ODE at a fast time scale. The + polynomial is of the form + + p(t) = sum_{i = 0}^{nvecs - 1} forcing[i] * ((t - tshift) / (tscale))^i + + where tshift and tscale are used to normalize the time t (e.g., with MRIGARK + methods). + ----------------------------------------------------------------------------*/ + +int erkStep_SetInnerForcing(void* arkode_mem, sunrealtype tshift, + sunrealtype tscale, N_Vector* forcing, int nvecs) +{ + ARKodeMem ark_mem; + ARKodeERKStepMem step_mem; + int retval; + + /* access ARKodeERKStepMem structure */ + retval = erkStep_AccessARKODEStepMem(arkode_mem, "erkStep_SetInnerForcing", + &ark_mem, &step_mem); + if (retval != ARK_SUCCESS) { return (retval); } + + if (nvecs > 0) + { + /* store forcing inputs */ + step_mem->tshift = tshift; + step_mem->tscale = tscale; + step_mem->forcing = forcing; + step_mem->nforcing = nvecs; + + /* If cvals and Xvecs are not allocated then erkStep_Init has not been + called and the number of stages has not been set yet. These arrays will + be allocated in erkStep_Init and take into account the value of nforcing. + On subsequent calls will check if enough space has allocated in case + nforcing has increased since the original allocation. */ + if (step_mem->cvals != NULL && step_mem->Xvecs != NULL) + { + /* check if there are enough reusable arrays for fused operations */ + if ((step_mem->nfusedopvecs - nvecs) < (step_mem->stages + 1)) + { + /* free current work space */ + if (step_mem->cvals != NULL) + { + free(step_mem->cvals); + ark_mem->lrw -= step_mem->nfusedopvecs; + } + if (step_mem->Xvecs != NULL) + { + free(step_mem->Xvecs); + ark_mem->liw -= step_mem->nfusedopvecs; + } + + /* allocate reusable arrays for fused vector operations */ + step_mem->nfusedopvecs = step_mem->stages + 1 + nvecs; + + step_mem->cvals = NULL; + step_mem->cvals = (sunrealtype*)calloc(step_mem->nfusedopvecs, + sizeof(sunrealtype)); + if (step_mem->cvals == NULL) { return (ARK_MEM_FAIL); } + ark_mem->lrw += step_mem->nfusedopvecs; + + step_mem->Xvecs = NULL; + step_mem->Xvecs = (N_Vector*)calloc(step_mem->nfusedopvecs, + sizeof(N_Vector)); + if (step_mem->Xvecs == NULL) { return (ARK_MEM_FAIL); } + ark_mem->liw += step_mem->nfusedopvecs; + } + } + } + else + { + /* disable forcing */ + step_mem->tshift = ZERO; + step_mem->tscale = ONE; + step_mem->forcing = NULL; + step_mem->nforcing = 0; + } + + return (ARK_SUCCESS); +} + /*=============================================================== EOF ===============================================================*/ diff --git a/src/arkode/arkode_erkstep_impl.h b/src/arkode/arkode_erkstep_impl.h index 794f112550..b0ad2e1448 100644 --- a/src/arkode/arkode_erkstep_impl.h +++ b/src/arkode/arkode_erkstep_impl.h @@ -22,6 +22,9 @@ #include "arkode_impl.h" +/* access to MRIStepInnerStepper_Create */ +#include "arkode/arkode_mristep.h" + #ifdef __cplusplus /* wrapper to enable C++ usage */ extern "C" { #endif @@ -60,6 +63,13 @@ typedef struct ARKodeERKStepMemRec /* Reusable arrays for fused vector operations */ sunrealtype* cvals; N_Vector* Xvecs; + int nfusedopvecs; /* length of cvals and Xvecs arrays */ + + /* Data for using ERKStep with external polynomial forcing */ + sunrealtype tshift; /* time normalization shift */ + sunrealtype tscale; /* time normalization scaling */ + N_Vector* forcing; /* array of forcing vectors */ + int nforcing; /* number of forcing vectors */ }* ARKodeERKStepMem; @@ -93,6 +103,23 @@ sunbooleantype erkStep_CheckNVector(N_Vector tmpl); int erkStep_SetButcherTable(ARKodeMem ark_mem); int erkStep_CheckButcherTable(ARKodeMem ark_mem); int erkStep_ComputeSolutions(ARKodeMem ark_mem, sunrealtype* dsm); +void erkStep_ApplyForcing(ARKodeERKStepMem step_mem, sunrealtype t, + sunrealtype s, int* nvec); + +/* private functions for interfacing with MRIStep */ +int erkStep_SetInnerForcing(void* arkode_mem, sunrealtype tshift, + sunrealtype tscale, N_Vector* f, int nvecs); +int erkStep_MRIStepInnerEvolve(MRIStepInnerStepper stepper, sunrealtype t0, + sunrealtype tout, N_Vector y); +int erkStep_MRIStepInnerFullRhs(MRIStepInnerStepper stepper, sunrealtype t, + N_Vector y, N_Vector f, int mode); +int erkStep_MRIStepInnerReset(MRIStepInnerStepper stepper, sunrealtype tR, + N_Vector yR); +int erkStep_MRIStepInnerGetAccumulatedError(MRIStepInnerStepper stepper, + sunrealtype* accum_error); +int erkStep_MRIStepInnerResetAccumulatedError(MRIStepInnerStepper stepper); +int erkStep_MRIStepInnerSetFixedStep(MRIStepInnerStepper stepper, sunrealtype h); +int erkStep_MRIStepInnerSetRTol(MRIStepInnerStepper stepper, sunrealtype rtol); /* private functions for relaxation */ int erkStep_SetRelaxFn(ARKodeMem ark_mem, ARKRelaxFn rfn, ARKRelaxJacFn rjac); diff --git a/src/arkode/arkode_erkstep_io.c b/src/arkode/arkode_erkstep_io.c index ffbf9a18fb..48bb1a018c 100644 --- a/src/arkode/arkode_erkstep_io.c +++ b/src/arkode/arkode_erkstep_io.c @@ -363,7 +363,10 @@ int erkStep_GetEstLocalErrors(ARKodeMem ark_mem, N_Vector ele) if (retval != ARK_SUCCESS) { return (retval); } /* return an error if local truncation error is not computed */ - if (ark_mem->fixedstep) { return (ARK_STEPPER_UNSUPPORTED); } + if (ark_mem->fixedstep && (ark_mem->AccumErrorType < 0)) + { + return (ARK_STEPPER_UNSUPPORTED); + } /* otherwise, copy local truncation error vector to output */ N_VScale(ONE, ark_mem->tempv1, ele); diff --git a/src/arkode/arkode_impl.h b/src/arkode/arkode_impl.h index fff9d2e693..8a440dc2b0 100644 --- a/src/arkode/arkode_impl.h +++ b/src/arkode/arkode_impl.h @@ -490,7 +490,8 @@ struct ARKodeMemRec overtake tstop */ sunrealtype eta; /* eta = hprime / h */ sunrealtype tcur; /* current internal value of t - (changes with each stage) */ + (changes with each stage) */ + sunrealtype tout; /* user's requested output time */ sunrealtype tretlast; /* value of tret last returned by ARKODE */ sunbooleantype fixedstep; /* flag to disable temporal adaptivity */ ARKodeHAdaptMem hadapt_mem; /* time step adaptivity structure */ @@ -519,11 +520,15 @@ struct ARKodeMemRec long int liw; /* no. of integer words in ARKODE work vectors */ /* Saved Values */ - sunrealtype h0u; /* actual initial stepsize */ - sunrealtype tn; /* time of last successful step */ - sunrealtype terr; /* error in tn for compensated sums */ - sunrealtype hold; /* last successful h value used */ - sunrealtype tolsf; /* tolerance scale factor (suggestion to user) */ + sunrealtype h0u; /* actual initial stepsize */ + sunrealtype tn; /* time of last successful step */ + sunrealtype terr; /* error in tn for compensated sums */ + sunrealtype hold; /* last successful h value used */ + sunrealtype tolsf; /* tolerance scale factor (suggestion to user) */ + int AccumErrorType; /* accumulated error estimation type: + none (-1), scalar-max (0), scalar-sum (1) */ + long int AccumErrorStep; /* time step of last accumulated error reset */ + sunrealtype AccumError; /* accumulated error estimate */ sunbooleantype VabstolMallocDone; sunbooleantype VRabstolMallocDone; sunbooleantype MallocDone; @@ -610,9 +615,14 @@ sunbooleantype arkCheckNvector(N_Vector tmpl); int arkInitialSetup(ARKodeMem ark_mem, sunrealtype tout); int arkStopTests(ARKodeMem ark_mem, sunrealtype tout, N_Vector yout, sunrealtype* tret, int itask, int* ier); -int arkHin(ARKodeMem ark_mem, sunrealtype tout); -sunrealtype arkUpperBoundH0(ARKodeMem ark_mem, sunrealtype tdist); -int arkYddNorm(ARKodeMem ark_mem, sunrealtype hg, sunrealtype* yddnrm); +int arkHin(ARKodeMem ark_mem, sunrealtype tcur, sunrealtype tout, N_Vector ycur, + N_Vector fcur, N_Vector ytmp, N_Vector temp1, N_Vector temp2, + ARKTimestepFullRHSFn rhs, sunrealtype* h); +sunrealtype arkUpperBoundH0(ARKodeMem ark_mem, sunrealtype tdist, N_Vector y, + N_Vector f, N_Vector temp1, N_Vector temp2); +int arkYddNorm(ARKodeMem ark_mem, sunrealtype hg, sunrealtype t, N_Vector y, + N_Vector f, N_Vector ycur, N_Vector temp1, + ARKTimestepFullRHSFn rhs, sunrealtype* yddnrm); int arkCompleteStep(ARKodeMem ark_mem, sunrealtype dsm); int arkHandleFailure(ARKodeMem ark_mem, int flag); diff --git a/src/arkode/arkode_io.c b/src/arkode/arkode_io.c index 357912409d..0daa2992fc 100644 --- a/src/arkode/arkode_io.c +++ b/src/arkode/arkode_io.c @@ -1981,6 +1981,74 @@ int ARKodeSetMaxConvFails(void* arkode_mem, int maxncf) return (ARK_SUCCESS); } +/*--------------------------------------------------------------- + ARKodeSetAccumulatedErrorType: + + This routine sets the accumulated temporal error estimation + strategy: + 0 => scalar 'max' accumulation + 1 => scalar 'mean' accumulation + -1 => no accumulation + ---------------------------------------------------------------*/ +int ARKodeSetAccumulatedErrorType(void* arkode_mem, int accum_type) +{ + ARKodeMem ark_mem; + if (arkode_mem == NULL) + { + arkProcessError(NULL, ARK_MEM_NULL, __LINE__, __func__, __FILE__, + MSG_ARK_NO_MEM); + return (ARK_MEM_NULL); + } + ark_mem = (ARKodeMem)arkode_mem; + + /* Guard against use for non-adaptive time stepper modules */ + if (!ark_mem->step_supports_adaptive) + { + arkProcessError(ark_mem, ARK_STEPPER_UNSUPPORTED, __LINE__, __func__, + __FILE__, "time-stepping module does not support temporal adaptivity"); + return (ARK_STEPPER_UNSUPPORTED); + } + + /* Check for valid accumulation type (set to none on illegal input) */ + if ((accum_type < 0) || (accum_type > 1)) { accum_type = -1; } + + /* Store type, reset accumulated error value and counter, and return */ + ark_mem->AccumErrorType = accum_type; + ark_mem->AccumErrorStep = ark_mem->nst; + ark_mem->AccumError = ZERO; + return (ARK_SUCCESS); +} + +/*--------------------------------------------------------------- + ARKodeResetAccumulatedError: + + This routine resets the accumulated temporal error estimate. + ---------------------------------------------------------------*/ +int ARKodeResetAccumulatedError(void* arkode_mem) +{ + ARKodeMem ark_mem; + if (arkode_mem == NULL) + { + arkProcessError(NULL, ARK_MEM_NULL, __LINE__, __func__, __FILE__, + MSG_ARK_NO_MEM); + return (ARK_MEM_NULL); + } + ark_mem = (ARKodeMem)arkode_mem; + + /* Guard against use for non-adaptive time stepper modules */ + if (!ark_mem->step_supports_adaptive) + { + arkProcessError(ark_mem, ARK_STEPPER_UNSUPPORTED, __LINE__, __func__, + __FILE__, "time-stepping module does not support temporal adaptivity"); + return (ARK_STEPPER_UNSUPPORTED); + } + + /* Reset value and counter, and return */ + ark_mem->AccumErrorStep = ark_mem->nst; + ark_mem->AccumError = ZERO; + return (ARK_SUCCESS); +} + /*=============================================================== ARKODE optional output utility functions ===============================================================*/ @@ -2381,6 +2449,45 @@ int ARKodeGetStepStats(void* arkode_mem, long int* nsteps, sunrealtype* hinused, return (ARK_SUCCESS); } +/*--------------------------------------------------------------- + ARKodeGetAccumulatedError: + + This routine returns the accumulated temporal error estimate. + ---------------------------------------------------------------*/ +int ARKodeGetAccumulatedError(void* arkode_mem, sunrealtype* accum_error) +{ + ARKodeMem ark_mem; + if (arkode_mem == NULL) + { + arkProcessError(NULL, ARK_MEM_NULL, __LINE__, __func__, __FILE__, + MSG_ARK_NO_MEM); + return (ARK_MEM_NULL); + } + ark_mem = (ARKodeMem)arkode_mem; + + /* Get number of steps since last accumulated error reset + (set floor of 1 to safeguard against division-by-zero) */ + long int steps = SUNMAX(1, ark_mem->nst - ark_mem->AccumErrorStep); + + /* Fill output based on error accumulation type */ + if (ark_mem->AccumErrorType == 0) + { + *accum_error = ark_mem->AccumError * ark_mem->reltol; + } + else if (ark_mem->AccumErrorType == 1) + { + *accum_error = ark_mem->AccumError * ark_mem->reltol / steps; + } + else + { + arkProcessError(ark_mem, ARK_STEPPER_UNSUPPORTED, __LINE__, __func__, + __FILE__, "time-stepping module does not support accumulated error estimation"); + return (ARK_STEPPER_UNSUPPORTED); + } + + return (ARK_SUCCESS); +} + /*--------------------------------------------------------------- ARKodeGetNumConstrFails: diff --git a/src/arkode/arkode_mri_tables.c b/src/arkode/arkode_mri_tables.c index 7d68143884..010f05a873 100644 --- a/src/arkode/arkode_mri_tables.c +++ b/src/arkode/arkode_mri_tables.c @@ -73,6 +73,7 @@ MRIStepCoupling MRIStepCoupling_Alloc(int nmat, int stages, MRISTEP_METHOD_TYPE type) { int i, j; + sunbooleantype hasOmegas, hasGammas; MRIStepCoupling MRIC = NULL; /* Check for legal input values */ @@ -85,6 +86,7 @@ MRIStepCoupling MRIStepCoupling_Alloc(int nmat, int stages, MRIC = (MRIStepCoupling)malloc(sizeof(struct MRIStepCouplingMem)); if (!MRIC) { return (NULL); } + MRIC->type = type; MRIC->nmat = nmat; MRIC->stages = stages; MRIC->q = 0; @@ -92,6 +94,24 @@ MRIStepCoupling MRIStepCoupling_Alloc(int nmat, int stages, MRIC->c = NULL; MRIC->W = NULL; MRIC->G = NULL; + MRIC->ngroup = 0; + MRIC->group = NULL; + + /* -------------------------------------------- + * Determine general storage format + * -------------------------------------------- */ + + hasOmegas = hasGammas = SUNFALSE; + if ((type == MRISTEP_EXPLICIT) || (type == MRISTEP_IMEX) || + (type == MRISTEP_MERK) || (type == MRISTEP_MRISR)) + { + hasOmegas = SUNTRUE; + } + if ((type == MRISTEP_IMPLICIT) || (type == MRISTEP_IMEX) || + (type == MRISTEP_MRISR)) + { + hasGammas = SUNTRUE; + } /* -------------------------------------------- * Allocate abscissae and coupling coefficients @@ -104,7 +124,7 @@ MRIStepCoupling MRIStepCoupling_Alloc(int nmat, int stages, return (NULL); } - if (type == MRISTEP_EXPLICIT || type == MRISTEP_IMEX) + if (hasOmegas) { /* allocate W matrices */ MRIC->W = (sunrealtype***)calloc(nmat, sizeof(sunrealtype**)); @@ -118,7 +138,7 @@ MRIStepCoupling MRIStepCoupling_Alloc(int nmat, int stages, for (i = 0; i < nmat; i++) { MRIC->W[i] = NULL; - MRIC->W[i] = (sunrealtype**)calloc(stages, sizeof(sunrealtype*)); + MRIC->W[i] = (sunrealtype**)calloc(stages + 1, sizeof(sunrealtype*)); if (!(MRIC->W[i])) { MRIStepCoupling_Free(MRIC); @@ -129,7 +149,7 @@ MRIStepCoupling MRIStepCoupling_Alloc(int nmat, int stages, /* allocate columns of each matrix in W */ for (i = 0; i < nmat; i++) { - for (j = 0; j < stages; j++) + for (j = 0; j <= stages; j++) { MRIC->W[i][j] = NULL; MRIC->W[i][j] = (sunrealtype*)calloc(stages, sizeof(sunrealtype)); @@ -142,7 +162,7 @@ MRIStepCoupling MRIStepCoupling_Alloc(int nmat, int stages, } } - if (type == MRISTEP_IMPLICIT || type == MRISTEP_IMEX) + if (hasGammas) { /* allocate G matrices */ MRIC->G = (sunrealtype***)calloc(nmat, sizeof(sunrealtype**)); @@ -156,7 +176,7 @@ MRIStepCoupling MRIStepCoupling_Alloc(int nmat, int stages, for (i = 0; i < nmat; i++) { MRIC->G[i] = NULL; - MRIC->G[i] = (sunrealtype**)calloc(stages, sizeof(sunrealtype*)); + MRIC->G[i] = (sunrealtype**)calloc(stages + 1, sizeof(sunrealtype*)); if (!(MRIC->G[i])) { MRIStepCoupling_Free(MRIC); @@ -167,7 +187,7 @@ MRIStepCoupling MRIStepCoupling_Alloc(int nmat, int stages, /* allocate columns of each matrix in G */ for (i = 0; i < nmat; i++) { - for (j = 0; j < stages; j++) + for (j = 0; j <= stages; j++) { MRIC->G[i][j] = NULL; MRIC->G[i][j] = (sunrealtype*)calloc(stages, sizeof(sunrealtype)); @@ -180,11 +200,35 @@ MRIStepCoupling MRIStepCoupling_Alloc(int nmat, int stages, } } + /* for MERK methods, allocate maximum possible number/sizes of stage groups */ + if (type == MRISTEP_MERK) + { + MRIC->ngroup = stages; + MRIC->group = (int**)malloc(stages * sizeof(int*)); + if (!(MRIC->group)) + { + MRIStepCoupling_Free(MRIC); + return (NULL); + } + for (i = 0; i < stages; i++) + { + MRIC->group[i] = NULL; + MRIC->group[i] = (int*)malloc(stages * sizeof(int)); + if (!(MRIC->group[i])) + { + MRIStepCoupling_Free(MRIC); + return (NULL); + } + for (j = 0; j < stages; j++) { MRIC->group[i][j] = -1; } + } + } + return (MRIC); } /*--------------------------------------------------------------- - Routine to allocate and fill a MRIStepCoupling structure + Routine to allocate and fill an explicit, implicit, or ImEx + MRIGARK MRIStepCoupling structure. ---------------------------------------------------------------*/ MRIStepCoupling MRIStepCoupling_Create(int nmat, int stages, int q, int p, sunrealtype* W, sunrealtype* G, @@ -218,41 +262,78 @@ MRIStepCoupling MRIStepCoupling_Create(int nmat, int stages, int q, int p, /* Abscissae */ for (i = 0; i < stages; i++) { MRIC->c[i] = c[i]; } - /* Coupling coefficients stored as 1D arrays of length nmat * stages * stages, - with each stages * stages matrix stored in C (row-major) order */ - if (type == MRISTEP_EXPLICIT || type == MRISTEP_IMEX) + /* Coupling coefficients stored as 1D arrays, based on whether they + include embedding coefficients */ + if (p == 0) { - for (k = 0; k < nmat; k++) + /* non-embedded method: coupling coefficient 1D arrays have + length nmat * stages * stages, with each stages * stages + matrix stored in C (row-major) order */ + if (type == MRISTEP_EXPLICIT || type == MRISTEP_IMEX) { - for (i = 0; i < stages; i++) + for (k = 0; k < nmat; k++) { - for (j = 0; j < stages; j++) + for (i = 0; i < stages; i++) + { + for (j = 0; j < stages; j++) + { + MRIC->W[k][i][j] = W[stages * (stages * k + i) + j]; + } + } + } + } + if (type == MRISTEP_IMPLICIT || type == MRISTEP_IMEX) + { + for (k = 0; k < nmat; k++) + { + for (i = 0; i < stages; i++) { - MRIC->W[k][i][j] = W[stages * (stages * k + i) + j]; + for (j = 0; j < stages; j++) + { + MRIC->G[k][i][j] = G[stages * (stages * k + i) + j]; + } } } } } - if (type == MRISTEP_IMPLICIT || type == MRISTEP_IMEX) + else { - for (k = 0; k < nmat; k++) + /* embedded method: coupling coefficient 1D arrays have + length nmat * (stages+1) * stages, with each (stages+1) * stages + matrix stored in C (row-major) order */ + if (type == MRISTEP_EXPLICIT || type == MRISTEP_IMEX) { - for (i = 0; i < stages; i++) + for (k = 0; k < nmat; k++) { - for (j = 0; j < stages; j++) + for (i = 0; i <= stages; i++) + { + for (j = 0; j < stages; j++) + { + MRIC->W[k][i][j] = W[(stages + 1) * (stages * k + i) + j]; + } + } + } + } + if (type == MRISTEP_IMPLICIT || type == MRISTEP_IMEX) + { + for (k = 0; k < nmat; k++) + { + for (i = 0; i <= stages; i++) { - MRIC->G[k][i][j] = G[stages * (stages * k + i) + j]; + for (j = 0; j < stages; j++) + { + MRIC->G[k][i][j] = G[(stages + 1) * (stages * k + i) + j]; + } } } } } - return (MRIC); } /*--------------------------------------------------------------- - Construct the MRI coupling matrix for an MIS method based on - a given 'slow' Butcher table. + Construct the MRIGARK coupling matrix for an MIS method based + on a given "slow" Butcher table. ---------------------------------------------------------------*/ MRIStepCoupling MRIStepCoupling_MIStoMRI(ARKodeButcherTable B, int q, int p) { @@ -268,6 +349,9 @@ MRIStepCoupling MRIStepCoupling_MIStoMRI(ARKodeButcherTable B, int q, int p) /* Check that input table is non-NULL */ if (!B) { return (NULL); } + /* If p>0, check that input table includes embedding coefficients */ + if ((p > 0) && (B->d == NULL)) { return (NULL); } + /* ----------------------------------- * Check that the input table is valid * ----------------------------------- */ @@ -300,14 +384,21 @@ MRIStepCoupling MRIStepCoupling_MIStoMRI(ARKodeButcherTable B, int q, int p) padding = SUNFALSE; - /* Last stage time should equal 1 */ + /* Pad if last stage does not equal 1 */ if (SUNRabs(B->c[B->stages - 1] - ONE) > tol) { padding = SUNTRUE; } - /* Last row of A should equal b */ + /* Pad if last row of A does not equal b */ for (j = 0; j < B->stages; j++) { if (SUNRabs(B->A[B->stages - 1][j] - B->b[j]) > tol) { padding = SUNTRUE; } } + + /* If final stage is implicit and the method contains an embedding, + we require padding since d != b */ + if ((p > 0) && (SUNRabs(B->A[B->stages - 1][B->stages - 1]) > tol)) + { + padding = SUNTRUE; + } stages = (padding) ? B->stages + 1 : B->stages; /* ------------------------- @@ -369,6 +460,15 @@ MRIStepCoupling MRIStepCoupling_MIStoMRI(ARKodeButcherTable B, int q, int p) } } + /* Embedded row = d(:) - A(end,:) */ + if (p > 0) + { + for (j = 0; j < B->stages; j++) + { + C[0][stages][j] = B->d[j] - B->A[B->stages - 1][j]; + } + } + return (MRIC); } @@ -384,11 +484,8 @@ MRIStepCoupling MRIStepCoupling_Copy(MRIStepCoupling MRIC) /* Check for legal input */ if (!MRIC) { return (NULL); } - /* Check for method coefficients and set method type */ - if (MRIC->W && MRIC->G) { type = MRISTEP_IMEX; } - else if (MRIC->W && !(MRIC->G)) { type = MRISTEP_EXPLICIT; } - else if (!(MRIC->W) && MRIC->G) { type = MRISTEP_IMPLICIT; } - else { return (NULL); } + /* Copy method type */ + type = MRIC->type; /* Check for stage times */ if (!(MRIC->c)) { return (NULL); } @@ -413,7 +510,7 @@ MRIStepCoupling MRIStepCoupling_Copy(MRIStepCoupling MRIC) { for (k = 0; k < nmat; k++) { - for (i = 0; i < stages; i++) + for (i = 0; i <= stages; i++) { for (j = 0; j < stages; j++) { @@ -428,7 +525,7 @@ MRIStepCoupling MRIStepCoupling_Copy(MRIStepCoupling MRIC) { for (k = 0; k < nmat; k++) { - for (i = 0; i < stages; i++) + for (i = 0; i <= stages; i++) { for (j = 0; j < stages; j++) { @@ -438,6 +535,19 @@ MRIStepCoupling MRIStepCoupling_Copy(MRIStepCoupling MRIC) } } + /* Copy MERK stage groups */ + if (MRIC->group) + { + MRICcopy->ngroup = MRIC->ngroup; + for (i = 0; i < stages; i++) + { + for (j = 0; j < stages; j++) + { + MRICcopy->group[i][j] = MRIC->group[i][j]; + } + } + } + return (MRICcopy); } @@ -453,10 +563,11 @@ void MRIStepCoupling_Space(MRIStepCoupling MRIC, sunindextype* liw, if (!MRIC) { return; } /* fill outputs based on MRIC */ - *liw = 4; + *liw = 5; if (MRIC->c) { *lrw += MRIC->stages; } - if (MRIC->W) { *lrw += MRIC->nmat * MRIC->stages * MRIC->stages; } - if (MRIC->G) { *lrw += MRIC->nmat * MRIC->stages * MRIC->stages; } + if (MRIC->W) { *lrw += MRIC->nmat * (MRIC->stages + 1) * MRIC->stages; } + if (MRIC->G) { *lrw += MRIC->nmat * (MRIC->stages + 1) * MRIC->stages; } + if (MRIC->group) { *liw += MRIC->stages * MRIC->stages; } } /*--------------------------------------------------------------- @@ -478,7 +589,7 @@ void MRIStepCoupling_Free(MRIStepCoupling MRIC) { if (MRIC->W[k]) { - for (i = 0; i < MRIC->stages; i++) + for (i = 0; i <= MRIC->stages; i++) { if (MRIC->W[k][i]) { @@ -499,7 +610,7 @@ void MRIStepCoupling_Free(MRIStepCoupling MRIC) { if (MRIC->G[k]) { - for (i = 0; i < MRIC->stages; i++) + for (i = 0; i <= MRIC->stages; i++) { if (MRIC->G[k][i]) { @@ -514,6 +625,19 @@ void MRIStepCoupling_Free(MRIStepCoupling MRIC) free(MRIC->G); } + if (MRIC->group) + { + for (i = 0; i < MRIC->stages; i++) + { + if (MRIC->group[i]) + { + free(MRIC->group[i]); + MRIC->group[i] = NULL; + } + } + free(MRIC->group); + } + free(MRIC); } } @@ -535,7 +659,7 @@ void MRIStepCoupling_Write(MRIStepCoupling MRIC, FILE* outfile) for (i = 0; i < MRIC->nmat; i++) { if (!(MRIC->W[i])) { return; } - for (j = 0; j < MRIC->stages; j++) + for (j = 0; j <= MRIC->stages; j++) { if (!(MRIC->W[i][j])) { return; } } @@ -547,13 +671,30 @@ void MRIStepCoupling_Write(MRIStepCoupling MRIC, FILE* outfile) for (i = 0; i < MRIC->nmat; i++) { if (!(MRIC->G[i])) { return; } - for (j = 0; j < MRIC->stages; j++) + for (j = 0; j <= MRIC->stages; j++) { if (!(MRIC->G[i][j])) { return; } } } } + if (MRIC->group) + { + for (i = 0; i < MRIC->stages; i++) + { + if (!(MRIC->group[i])) { return; } + } + } + + switch (MRIC->type) + { + case MRISTEP_EXPLICIT: fprintf(outfile, " type = explicit MRI\n"); break; + case MRISTEP_IMPLICIT: fprintf(outfile, " type = implicit MRI\n"); break; + case MRISTEP_IMEX: fprintf(outfile, " type = ImEx MRI\n"); break; + case MRISTEP_MERK: fprintf(outfile, " type = MERK\n"); break; + case MRISTEP_MRISR: fprintf(outfile, " type = MRISR\n"); break; + default: fprintf(outfile, " type = unknown\n"); + } fprintf(outfile, " nmat = %i\n", MRIC->nmat); fprintf(outfile, " stages = %i\n", MRIC->stages); fprintf(outfile, " method order (q) = %i\n", MRIC->q); @@ -570,7 +711,7 @@ void MRIStepCoupling_Write(MRIStepCoupling MRIC, FILE* outfile) for (k = 0; k < MRIC->nmat; k++) { fprintf(outfile, " W[%i] = \n", k); - for (i = 0; i < MRIC->stages; i++) + for (i = 0; i <= MRIC->stages; i++) { fprintf(outfile, " "); for (j = 0; j < MRIC->stages; j++) @@ -588,7 +729,7 @@ void MRIStepCoupling_Write(MRIStepCoupling MRIC, FILE* outfile) for (k = 0; k < MRIC->nmat; k++) { fprintf(outfile, " G[%i] = \n", k); - for (i = 0; i < MRIC->stages; i++) + for (i = 0; i <= MRIC->stages; i++) { fprintf(outfile, " "); for (j = 0; j < MRIC->stages; j++) @@ -600,6 +741,23 @@ void MRIStepCoupling_Write(MRIStepCoupling MRIC, FILE* outfile) fprintf(outfile, "\n"); } } + + if (MRIC->group) + { + fprintf(outfile, " ngroup = %i\n", MRIC->ngroup); + for (i = 0; i < MRIC->ngroup; i++) + { + fprintf(outfile, " group[%i] = ", i); + for (j = 0; j < MRIC->stages; j++) + { + if (MRIC->group[i][j] >= 0) + { + fprintf(outfile, "%i ", MRIC->group[i][j]); + } + } + fprintf(outfile, "\n"); + } + } } /* =========================================================================== @@ -613,33 +771,97 @@ void MRIStepCoupling_Write(MRIStepCoupling MRIC, FILE* outfile) * MRISTAGE_ERK_NOFAST -- standard ERK stage * MRISTAGE_DIRK_NOFAST -- standard DIRK stage * MRISTAGE_DIRK_FAST -- coupled DIRK + MIS-like stage + * MRISTAGE_STIFF_ACC -- "extra" stiffly-accurate stage * - * for each nontrivial stage in an MRI-like method. Otherwise (i.e., stage is - * not in [1,MRIC->stages-1]), returns ARK_INVALID_TABLE (<0). + * for each nontrivial stage, or embedding stage, in an MRI-like method. + * Otherwise (i.e., stage is not in [1,MRIC->stages]), returns + * ARK_INVALID_TABLE (<0). * - * The stage type is determined by 2 factors: + * The stage type is determined by 2 factors (for normal stages): * (a) Sum |MRIC->G[:][is][is]| (nonzero => DIRK) * (b) MRIC->c[is] - MRIC->c[is-1] (nonzero => fast) + * Similar tests are used for embedding stages. + * + * Note that MERK and MRI-SR methods do not use the stage-type identifiers, + * so if those tables are input we just return MRISTAGE_ERK_FAST. * ---------------------------------------------------------------------------*/ int mriStepCoupling_GetStageType(MRIStepCoupling MRIC, int is) { - int i; - sunrealtype Gabs, cdiff; + int i, j; + sunrealtype Gabs, cdiff, Gabsrow, Wabsrow; const sunrealtype tol = SUN_RCONST(100.0) * SUN_UNIT_ROUNDOFF; - if ((is < 1) || (is >= MRIC->stages)) { return ARK_INVALID_TABLE; } + if ((is < 1) || (is > MRIC->stages)) { return ARK_INVALID_TABLE; } - /* sum of stage diagonal entries across implicit tables */ - Gabs = ZERO; - if (MRIC->G) + /* report MRISTAGE_ERK_FAST for MERK and MRI-SR methods */ + if ((MRIC->type == MRISTEP_MRISR) || (MRIC->type == MRISTEP_MERK)) { - for (i = 0; i < MRIC->nmat; i++) { Gabs += SUNRabs(MRIC->G[i][is][is]); } + return (MRISTAGE_ERK_FAST); } - /* abscissae difference */ - cdiff = MRIC->c[is] - MRIC->c[is - 1]; + /* separately handle an embedding "stage" from normal stages */ + if (is < MRIC->stages) + { /* normal */ + /* sum of stage diagonal entries across implicit tables */ + Gabs = Gabsrow = Wabsrow = ZERO; + if (MRIC->G) + { + for (i = 0; i < MRIC->nmat; i++) + { + Gabs += SUNRabs(MRIC->G[i][is][is]); + for (j = 0; j < MRIC->stages; j++) + { + Gabsrow += SUNRabs(MRIC->G[i][is][j]); + } + } + } + if (MRIC->W) + { + for (i = 0; i < MRIC->nmat; i++) + { + for (j = 0; j < MRIC->stages; j++) + { + Wabsrow += SUNRabs(MRIC->W[i][is][j]); + } + } + } + + /* abscissae difference */ + cdiff = MRIC->c[is] - MRIC->c[is - 1]; + } + else + { /* embedding */ + Gabs = Gabsrow = Wabsrow = ZERO; + if (MRIC->G) + { + for (i = 0; i < MRIC->nmat; i++) + { + Gabs += SUNRabs(MRIC->G[i][is][is - 1]); + for (j = 0; j < MRIC->stages; j++) + { + Gabsrow += SUNRabs(MRIC->G[i][is][j]); + } + } + } + if (MRIC->W) + { + for (i = 0; i < MRIC->nmat; i++) + { + for (j = 0; j < MRIC->stages; j++) + { + Wabsrow += SUNRabs(MRIC->W[i][is][j]); + } + } + } + cdiff = MRIC->c[is - 1] - MRIC->c[is - 2]; + } + /* make determination */ + if ((Gabs <= tol) && (Gabsrow <= tol) && (Wabsrow <= tol) && (cdiff <= tol)) + { /* stiffly-accurate stage */ + return (MRISTAGE_STIFF_ACC); + } if (Gabs > tol) { /* DIRK */ if (cdiff > tol) @@ -663,6 +885,9 @@ int mriStepCoupling_GetStageType(MRIStepCoupling MRIC, int is) * first stage of the pair generally corresponds to a column of zeros and so * does not need to be computed and stored. The stage_map indicates if the RHS * needs to be computed and where to store it i.e., stage_map[i] > -1. + * + * Note: for MERK and MRI-SR methods, this should be an "identity" map, and all + * stage vectors should be allocated. * ---------------------------------------------------------------------------*/ int mriStepCoupling_GetStageMap(MRIStepCoupling MRIC, int* stage_map, @@ -680,9 +905,24 @@ int mriStepCoupling_GetStageMap(MRIStepCoupling MRIC, int* stage_map, if (!(MRIC->W) && !(MRIC->G)) { return (ARK_ILL_INPUT); } if (!stage_map || !nstages_active) { return (ARK_ILL_INPUT); } - /* ------------------- - * Compute storage map - * ------------------- */ + /* ------------------------------------------- + * MERK and MRI-SR have "identity" storage map + * ------------------------------------------- */ + + if ((MRIC->type == MRISTEP_MERK) || (MRIC->type == MRISTEP_MRISR)) + { + /* Number of stage RHS vectors active */ + *nstages_active = MRIC->stages; + + /* Check if a stage corresponds to a column of zeros for all coupling + * matrices by computing the column sums */ + for (j = 0; j < MRIC->stages; j++) { stage_map[j] = j; } + return (ARK_SUCCESS); + } + + /* ---------------------------------------- + * Compute storage map for MRI-GARK methods + * ---------------------------------------- */ /* Number of stage RHS vectors active */ *nstages_active = 0; @@ -701,7 +941,7 @@ int mriStepCoupling_GetStageMap(MRIStepCoupling MRIC, int* stage_map, { for (k = 0; k < MRIC->nmat; k++) { - for (i = 0; i < MRIC->stages; i++) + for (i = 0; i <= MRIC->stages; i++) { Wsum += SUNRabs(MRIC->W[k][i][j]); } @@ -712,7 +952,7 @@ int mriStepCoupling_GetStageMap(MRIStepCoupling MRIC, int* stage_map, { for (k = 0; k < MRIC->nmat; k++) { - for (i = 0; i < MRIC->stages; i++) + for (i = 0; i <= MRIC->stages; i++) { Gsum += SUNRabs(MRIC->G[k][i][j]); } diff --git a/src/arkode/arkode_mri_tables.def b/src/arkode/arkode_mri_tables.def index 999ef71f95..68220c7a4b 100644 --- a/src/arkode/arkode_mri_tables.def +++ b/src/arkode/arkode_mri_tables.def @@ -25,34 +25,43 @@ below. The 'type' column denotes whether the method is explicit (E), - or solve-decoupled implicit (ID). + solve-decoupled implicit (ID), solve-decoupled ImEx (IED), + and/or has stage-restart structure (S). The 'QP' column denotes whether the coefficients of the method are known precisely enough for use in quad precision (128-bit) calculations. - imeth order type QP - ----------------------------------------------------- - ARKODE_MRI_GARK_FORWARD_EULER 1 E Y - ARKODE_MRI_GARK_RALSTON2 2 E Y - ARKODE_MIS_KW3 3 E Y - ARKODE_MRI_GARK_ERK22a 2 E Y - ARKODE_MRI_GARK_ERK22b 2 E Y - ARKODE_MRI_GARK_ERK33a 3 E Y - ARKODE_MRI_GARK_RALSTON3 3 E Y - ARKODE_MRI_GARK_ERK45a 4 E Y - ARKODE_MRI_GARK_BACKWARD_EULER 1 ID Y - ARKODE_MRI_GARK_IRK21a 2 ID Y - ARKODE_MRI_GARK_IMPLICIT_MIDPOINT 2 ID Y - ARKODE_MRI_GARK_ESDIRK34a 3 ID Y - ARKODE_MRI_GARK_ESDIRK46a 4 ID Y - ARKODE_IMEX_MRI_GARK_EULER 1 ID Y - ARKODE_IMEX_MRI_GARK_TRAPEZOIDAL 2 ID Y - ARKODE_IMEX_MRI_GARK_MIDPOINT 2 ID Y - ARKODE_IMEX_MRI_GARK3a 3 ID Y - ARKODE_IMEX_MRI_GARK3b 3 ID Y - ARKODE_IMEX_MRI_GARK4 4 ID Y - ----------------------------------------------------- + method embedding + imeth order order type QP + ---------------------------------------------------------------- + ARKODE_MRI_GARK_FORWARD_EULER 1 0 E Y + ARKODE_MRI_GARK_RALSTON2 2 1 E Y + ARKODE_MIS_KW3 3 0 E Y + ARKODE_MRI_GARK_ERK22a 2 1 E Y + ARKODE_MRI_GARK_ERK22b 2 1 E Y + ARKODE_MRI_GARK_ERK33a 3 2 E Y + ARKODE_MRI_GARK_RALSTON3 3 0 E Y + ARKODE_MRI_GARK_ERK45a 4 3 E Y + ARKODE_MERK21 2 1 ES Y + ARKODE_MERK32 3 2 ES Y + ARKODE_MERK43 4 3 ES Y + ARKODE_MERK54 5 4 ES Y + ARKODE_MRI_GARK_BACKWARD_EULER 1 0 ID Y + ARKODE_MRI_GARK_IRK21a 2 1 ID Y + ARKODE_MRI_GARK_IMPLICIT_MIDPOINT 2 0 ID Y + ARKODE_MRI_GARK_ESDIRK34a 3 2 ID Y + ARKODE_MRI_GARK_ESDIRK46a 4 3 ID Y + ARKODE_IMEX_MRI_GARK_EULER 1 0 ID Y + ARKODE_IMEX_MRI_GARK_TRAPEZOIDAL 2 0 ID Y + ARKODE_IMEX_MRI_GARK_MIDPOINT 2 0 ID Y + ARKODE_IMEX_MRI_GARK3a 3 0 IED Y + ARKODE_IMEX_MRI_GARK3b 3 0 IED Y + ARKODE_IMEX_MRI_GARK4 4 0 IED Y + ARKODE_IMEX_MRI_SR21 2 1 IEDS Y + ARKODE_IMEX_MRI_SR32 3 2 IEDS Y + ARKODE_IMEX_MRI_SR43 4 3 IEDS Y + ---------------------------------------------------------------- */ @@ -62,35 +71,35 @@ ARK_MRI_TABLE(ARKODE_MRI_NONE, { ARK_MRI_TABLE(ARKODE_MRI_GARK_FORWARD_EULER, { ARKodeButcherTable B = ARKodeButcherTable_LoadERK(ARKODE_FORWARD_EULER_1_1); - MRIStepCoupling C = MRIStepCoupling_MIStoMRI(B, 1, 0); + MRIStepCoupling C = MRIStepCoupling_MIStoMRI(B, B->q, B->p); ARKodeButcherTable_Free(B); return C; }) ARK_MRI_TABLE(ARKODE_MRI_GARK_RALSTON2, { /* Roberts et al., SISC 44:A1405 - A1427, 2022 */ ARKodeButcherTable B = ARKodeButcherTable_LoadERK(ARKODE_RALSTON_EULER_2_1_2); - MRIStepCoupling C = MRIStepCoupling_MIStoMRI(B, 2, 0); + MRIStepCoupling C = MRIStepCoupling_MIStoMRI(B, B->q, B->p); ARKodeButcherTable_Free(B); return C; }) ARK_MRI_TABLE(ARKODE_MIS_KW3, { /* Schlegel et al., JCAM 226:345-357, 2009 */ ARKodeButcherTable B = ARKodeButcherTable_LoadERK(ARKODE_KNOTH_WOLKE_3_3); - MRIStepCoupling C = MRIStepCoupling_MIStoMRI(B, 3, 0); + MRIStepCoupling C = MRIStepCoupling_MIStoMRI(B, B->q, B->p); ARKodeButcherTable_Free(B); return C; }) ARK_MRI_TABLE(ARKODE_MRI_GARK_ERK22a, { /* A. Sandu, SINUM 57:2300-2327, 2019 */ ARKodeButcherTable B = ARKodeButcherTable_LoadERK(ARKODE_EXPLICIT_MIDPOINT_EULER_2_1_2); - MRIStepCoupling C = MRIStepCoupling_MIStoMRI(B, 2, 0); + MRIStepCoupling C = MRIStepCoupling_MIStoMRI(B, B->q, B->p); ARKodeButcherTable_Free(B); return C; }) ARK_MRI_TABLE(ARKODE_MRI_GARK_ERK22b, { /* A. Sandu, SINUM 57:2300-2327, 2019 */ ARKodeButcherTable B = ARKodeButcherTable_LoadERK(ARKODE_HEUN_EULER_2_1_2); - MRIStepCoupling C = MRIStepCoupling_MIStoMRI(B, 2, 0); + MRIStepCoupling C = MRIStepCoupling_MIStoMRI(B, B->q, B->p); ARKodeButcherTable_Free(B); return C; }) @@ -99,7 +108,7 @@ ARK_MRI_TABLE(ARKODE_MRI_GARK_ERK33a, { /* A. Sandu, SINUM 57:2300-2327, 2019 */ MRIStepCoupling C = MRIStepCoupling_Alloc(2, 4, MRISTEP_EXPLICIT); C->q = 3; - C->p = 0; + C->p = 2; C->c[1] = ONE/SUN_RCONST(3.0); C->c[2] = TWO/SUN_RCONST(3.0); @@ -110,6 +119,9 @@ ARK_MRI_TABLE(ARKODE_MRI_GARK_ERK33a, { /* A. Sandu, SINUM 57:2300-2327, 2019 */ C->W[0][2][1] = TWO/SUN_RCONST(3.0); C->W[0][3][1] = -TWO/SUN_RCONST(3.0); C->W[0][3][2] = ONE; + C->W[0][4][0] = ONE/SUN_RCONST(12.0); + C->W[0][4][1] = -ONE/SUN_RCONST(3.0); + C->W[0][4][2] = SUN_RCONST(7.0)/SUN_RCONST(12.0); C->W[1][3][0] = ONE/TWO; C->W[1][3][2] = -ONE/TWO; @@ -142,10 +154,11 @@ ARK_MRI_TABLE(ARKODE_MRI_GARK_RALSTON3, { /* Roberts et al., SISC 44:A1405 - A14 }) ARK_MRI_TABLE(ARKODE_MRI_GARK_ERK45a, { /* A. Sandu, SINUM 57:2300-2327, 2019 */ + /* Embedding coefficients CORRECTED in A. Sandu, arxiv:1808.02759, 2018 */ MRIStepCoupling C = MRIStepCoupling_Alloc(2, 6, MRISTEP_EXPLICIT); C->q = 4; - C->p = 0; + C->p = 3; C->c[1] = SUN_RCONST(0.2); C->c[2] = SUN_RCONST(0.4); @@ -168,6 +181,11 @@ ARK_MRI_TABLE(ARKODE_MRI_GARK_ERK45a, { /* A. Sandu, SINUM 57:2300-2327, 2019 */ C->W[0][5][2] = -SUN_RCONST(1360217.0)/SUN_RCONST(1139280.0); C->W[0][5][3] = -SUN_RCONST(148789.0)/SUN_RCONST(56964.0); C->W[0][5][4] = SUN_RCONST(147889.0)/SUN_RCONST(45120.0); + C->W[0][6][0] = -SUN_RCONST(1482837.0)/SUN_RCONST(759520.0); + C->W[0][6][1] = SUN_RCONST(175781.0)/SUN_RCONST(71205.0); + C->W[0][6][2] = -SUN_RCONST(790577.0)/SUN_RCONST(1139280.0); + C->W[0][6][3] = -SUN_RCONST(6379.0)/SUN_RCONST(56964.0); + C->W[0][6][4] = SUN_RCONST(47.0)/SUN_RCONST(96.0); C->W[1][2][0] = SUN_RCONST(503.0)/SUN_RCONST(80.0); C->W[1][2][1] = -SUN_RCONST(503.0)/SUN_RCONST(80.0); @@ -183,6 +201,8 @@ ARK_MRI_TABLE(ARKODE_MRI_GARK_ERK45a, { /* A. Sandu, SINUM 57:2300-2327, 2019 */ C->W[1][5][2] = ONE; C->W[1][5][3] = SUN_RCONST(5.0); C->W[1][5][4] = -SUN_RCONST(41933.0)/SUN_RCONST(7520.0); + C->W[1][6][0] = SUN_RCONST(6213.0)/SUN_RCONST(1880.0); + C->W[1][6][1] = -SUN_RCONST(6213.0)/SUN_RCONST(1880.0); return C; }) @@ -203,9 +223,10 @@ ARK_MRI_TABLE(ARKODE_MRI_GARK_BACKWARD_EULER, { ARK_MRI_TABLE(ARKODE_MRI_GARK_IRK21a, { /* A. Sandu, SINUM 57:2300-2327, 2019 */ MRIStepCoupling C; - ARKodeButcherTable B = ARKodeButcherTable_Alloc(3, SUNFALSE); + ARKodeButcherTable B = ARKodeButcherTable_Alloc(3, SUNTRUE); B->q=2; + B->p=1; B->c[1] = ONE; B->c[2] = ONE; @@ -217,7 +238,9 @@ ARK_MRI_TABLE(ARKODE_MRI_GARK_IRK21a, { /* A. Sandu, SINUM 57:2300-2327, 2019 */ B->b[0] = SUN_RCONST(0.5); B->b[2] = SUN_RCONST(0.5); - C = MRIStepCoupling_MIStoMRI(B, 2, 0); + B->d[2] = SUN_RCONST(1.0); + + C = MRIStepCoupling_MIStoMRI(B, B->q, B->p); ARKodeButcherTable_Free(B); return C; }) @@ -240,11 +263,11 @@ ARK_MRI_TABLE(ARKODE_MRI_GARK_IMPLICIT_MIDPOINT, { }) ARK_MRI_TABLE(ARKODE_MRI_GARK_ESDIRK34a, { /* A. Sandu, SINUM 57:2300-2327, 2019 */ - MRIStepCoupling C = MRIStepCoupling_Alloc(1, 7, MRISTEP_IMPLICIT); + MRIStepCoupling C = MRIStepCoupling_Alloc(1, 8, MRISTEP_IMPLICIT); sunrealtype beta = SUN_RCONST(0.4358665215084589994160194511935568425); C->q = 3; - C->p = 0; + C->p = 2; C->c[1] = ONE/SUN_RCONST(3.0); C->c[2] = ONE/SUN_RCONST(3.0); @@ -252,6 +275,7 @@ ARK_MRI_TABLE(ARKODE_MRI_GARK_ESDIRK34a, { /* A. Sandu, SINUM 57:2300-2327, 2019 C->c[4] = TWO/SUN_RCONST(3.0); C->c[5] = ONE; C->c[6] = ONE; + C->c[7] = ONE; C->G[0][1][0] = ONE/SUN_RCONST(3.0); C->G[0][2][0] = -beta; @@ -266,14 +290,18 @@ ARK_MRI_TABLE(ARKODE_MRI_GARK_ESDIRK34a, { /* A. Sandu, SINUM 57:2300-2327, 2019 C->G[0][5][4] = SUN_RCONST(-0.9934660860338359976640778047742273701); C->G[0][6][0] = -beta; C->G[0][6][6] = beta; + C->G[0][8][0] = SUN_RCONST(0.2453831999117524372455680781104585876241); + C->G[0][8][2] = SUN_RCONST(0.4204215033044044563073464989473988121422); + C->G[0][8][4] = -SUN_RCONST(1.576992606344066224351397232226173387157); + C->G[0][8][6] = SUN_RCONST(0.9111879031279093307984826551683159873903); return C; }) ARK_MRI_TABLE(ARKODE_MRI_GARK_ESDIRK46a, { /* A. Sandu, SINUM 57:2300-2327, 2019 */ - MRIStepCoupling C = MRIStepCoupling_Alloc(2, 11, MRISTEP_IMPLICIT); + MRIStepCoupling C = MRIStepCoupling_Alloc(2, 12, MRISTEP_IMPLICIT); C->q = 4; - C->p = 0; + C->p = 3; C->c[1] = ONE/SUN_RCONST(5.0); C->c[2] = ONE/SUN_RCONST(5.0); @@ -285,6 +313,7 @@ ARK_MRI_TABLE(ARKODE_MRI_GARK_ESDIRK46a, { /* A. Sandu, SINUM 57:2300-2327, 2019 C->c[8] = SUN_RCONST(4.0)/SUN_RCONST(5.0); C->c[9] = ONE; C->c[10] = ONE; + C->c[11] = ONE; C->G[0][1][0] = ONE/SUN_RCONST(5.0); C->G[0][2][0] = -ONE/SUN_RCONST(4.0); @@ -321,6 +350,12 @@ ARK_MRI_TABLE(ARKODE_MRI_GARK_ESDIRK46a, { /* A. Sandu, SINUM 57:2300-2327, 2019 C->G[0][10][6] = SUN_RCONST(127.0)/SUN_RCONST(300.0); C->G[0][10][8] = -SUN_RCONST(313.0)/SUN_RCONST(300.0); C->G[0][10][10] = ONE/SUN_RCONST(4.0); + C->G[0][12][0] = -ONE/SUN_RCONST(4.0); + C->G[0][12][2] = SUN_RCONST(5595.0)/SUN_RCONST(8804.0); + C->G[0][12][4] = -SUN_RCONST(2445.0)/SUN_RCONST(8804.0); + C->G[0][12][6] = -SUN_RCONST(4225.0)/SUN_RCONST(8804.0); + C->G[0][12][8] = SUN_RCONST(2205.0)/SUN_RCONST(4402.0); + C->G[0][12][10] = -SUN_RCONST(567.0)/SUN_RCONST(4402.0); C->G[1][3][0] = -SUN_RCONST(1674554930619.0)/SUN_RCONST(964681845400.0); C->G[1][3][2] = SUN_RCONST(1674554930619.0)/SUN_RCONST(964681845400.0); @@ -618,3 +653,465 @@ ARK_MRI_TABLE(ARKODE_IMEX_MRI_GARK4, { /* R. Chinomona & D. Reynolds SINUM 43(5) return C; }) +ARK_MRI_TABLE(ARKODE_IMEX_MRI_SR21, { /* A.C. Fish, D.R. Reynolds, S.B. Roberts, JCAM 438:115534, 2024 */ + MRIStepCoupling C = MRIStepCoupling_Alloc(1, 4, MRISTEP_MRISR); + + C->q = 2; + C->p = 1; + + C->c[1] = SUN_RCONST(3.0)/SUN_RCONST(5.0); + C->c[2] = SUN_RCONST(4.0)/SUN_RCONST(15.0); + C->c[3] = ONE; + + C->W[0][1][0] = SUN_RCONST(3.0)/SUN_RCONST(5.0); + C->W[0][2][0] = SUN_RCONST(14.0)/SUN_RCONST(165.0); + C->W[0][2][1] = SUN_RCONST(2.0)/SUN_RCONST(11.0); + C->W[0][3][0] = -SUN_RCONST(13.0)/SUN_RCONST(54.0); + C->W[0][3][1] = SUN_RCONST(137.0)/SUN_RCONST(270.0); + C->W[0][3][2] = SUN_RCONST(11.0)/SUN_RCONST(15.0); + C->W[0][4][0] = -SUN_RCONST(0.25); + C->W[0][4][1] = SUN_RCONST(0.5); + C->W[0][4][2] = SUN_RCONST(0.75); + + C->G[0][1][0] = -SUN_RCONST(11.0)/SUN_RCONST(23.0); + C->G[0][1][1] = SUN_RCONST(11.0)/SUN_RCONST(23.0); + C->G[0][2][0] = -SUN_RCONST(6692.0)/SUN_RCONST(52371.0); + C->G[0][2][1] = -SUN_RCONST(18355.0)/SUN_RCONST(52371.0); + C->G[0][2][2] = SUN_RCONST(11.0)/SUN_RCONST(23.0); + C->G[0][3][0] = SUN_RCONST(11621.0)/SUN_RCONST(90666.0); + C->G[0][3][1] = -SUN_RCONST(215249.0)/SUN_RCONST(226665.0); + C->G[0][3][2] = SUN_RCONST(17287.0)/SUN_RCONST(50370.0); + C->G[0][3][3] = SUN_RCONST(11.0)/SUN_RCONST(23.0); + C->G[0][4][0] = -SUN_RCONST(31.0)/SUN_RCONST(12.0); + C->G[0][4][1] = -ONE/SUN_RCONST(6.0); + C->G[0][4][2] = SUN_RCONST(11.0)/SUN_RCONST(4.0); + return C; + }) + +ARK_MRI_TABLE(ARKODE_IMEX_MRI_SR32, { /* A.C. Fish, D.R. Reynolds, S.B. Roberts, JCAM 438:115534, 2024 */ + MRIStepCoupling C = MRIStepCoupling_Alloc(2, 5, MRISTEP_MRISR); + + C->q = 3; + C->p = 2; + + C->c[1] = SUN_RCONST(23.0)/SUN_RCONST(34.0); + C->c[2] = SUN_RCONST(4.0)/SUN_RCONST(5.0); + C->c[3] = SUN_RCONST(17.0)/SUN_RCONST(15.0); + C->c[4] = ONE; + + C->W[0][1][0] = SUN_RCONST(23.0)/SUN_RCONST(34.0); + C->W[0][2][0] = SUN_RCONST(71.0)/SUN_RCONST(70.0); + C->W[0][2][1] = -SUN_RCONST(3.0)/SUN_RCONST(14.0); + C->W[0][3][0] = SUN_RCONST(124.0)/SUN_RCONST(1155.0); + C->W[0][3][1] = SUN_RCONST(4.0)/SUN_RCONST(7.0); + C->W[0][3][2] = SUN_RCONST(5.0)/SUN_RCONST(11.0); + C->W[0][4][0] = SUN_RCONST(162181.0)/SUN_RCONST(187680.0); + C->W[0][4][1] = SUN_RCONST(119.0)/SUN_RCONST(1380.0); + C->W[0][4][2] = SUN_RCONST(11.0)/SUN_RCONST(32.0); + C->W[0][4][3] = -SUN_RCONST(5.0)/SUN_RCONST(17.0); + C->W[0][5][0] = SUN_RCONST(76355.0)/SUN_RCONST(74834.0); + C->W[0][5][1] = -SUN_RCONST(46.0)/SUN_RCONST(31.0); + C->W[0][5][2] = SUN_RCONST(67.0)/SUN_RCONST(34.0); + C->W[0][5][3] = -SUN_RCONST(36.0)/SUN_RCONST(71.0); + + C->W[1][2][0] = -SUN_RCONST(14453.0)/SUN_RCONST(63825.0); + C->W[1][2][1] = SUN_RCONST(14453.0)/SUN_RCONST(63825.0); + C->W[1][3][0] = -SUN_RCONST(2101267877.0)/SUN_RCONST(1206582300.0); + C->W[1][3][1] = SUN_RCONST(2476735438.0)/SUN_RCONST(301645575.0); + C->W[1][3][2] = -SUN_RCONST(13575085.0)/SUN_RCONST(2098404.0); + C->W[1][4][0] = -SUN_RCONST(762580446799.0)/SUN_RCONST(588660102960.0); + C->W[1][4][1] = SUN_RCONST(11083240219.0)/SUN_RCONST(4328383110.0); + C->W[1][4][2] = -SUN_RCONST(211274129.0)/SUN_RCONST(100368304.0); + C->W[1][4][3] = SUN_RCONST(89562055.0)/SUN_RCONST(106641323.0); + C->W[1][5][0] = -SUN_RCONST(3732974.0)/SUN_RCONST(2278035.0); + C->W[1][5][1] = SUN_RCONST(13857574.0)/SUN_RCONST(2278035.0); + C->W[1][5][2] = -SUN_RCONST(52.0)/SUN_RCONST(9.0); + C->W[1][5][3] = SUN_RCONST(4.0)/SUN_RCONST(3.0); + + C->G[0][1][0] = -SUN_RCONST(4.0)/SUN_RCONST(7.0); + C->G[0][1][1] = SUN_RCONST(4.0)/SUN_RCONST(7.0); + C->G[0][2][0] = -SUN_RCONST(2707004.0)/SUN_RCONST(3127425.0); + C->G[0][2][1] = SUN_RCONST(919904.0)/SUN_RCONST(3127425.0); + C->G[0][2][2] = SUN_RCONST(4.0)/SUN_RCONST(7.0); + C->G[0][3][0] = SUN_RCONST(852879271.0)/SUN_RCONST(703839675.0); + C->G[0][3][1] = -SUN_RCONST(1575000496.0)/SUN_RCONST(703839675.0); + C->G[0][3][2] = SUN_RCONST(5.0)/SUN_RCONST(11.0); + C->G[0][3][3] = SUN_RCONST(4.0)/SUN_RCONST(7.0); + C->G[0][4][0] = SUN_RCONST(43136869.0)/SUN_RCONST(2019912118.0); + C->G[0][4][1] = -SUN_RCONST(73810600.0)/SUN_RCONST(1009956059.0); + C->G[0][4][2] = -SUN_RCONST(17653551.0)/SUN_RCONST(87822266.0); + C->G[0][4][3] = -SUN_RCONST(13993902.0)/SUN_RCONST(43911133.0); + C->G[0][4][4] = SUN_RCONST(4.0)/SUN_RCONST(7.0); + C->G[0][5][0] = -SUN_RCONST(179.0)/SUN_RCONST(4140.0); + C->G[0][5][1] = SUN_RCONST(799.0)/SUN_RCONST(14490.0); + C->G[0][5][2] = ONE/SUN_RCONST(14.0); + C->G[0][5][3] = -ONE/SUN_RCONST(12.0); + return C; + }) + +ARK_MRI_TABLE(ARKODE_IMEX_MRI_SR43, { /* A.C. Fish, D.R. Reynolds, S.B. Roberts, arXiv:2301.00865, 2023 */ + MRIStepCoupling C = MRIStepCoupling_Alloc(2, 7, MRISTEP_MRISR); + + C->q = 4; + C->p = 3; + + C->c[1] = ONE/SUN_RCONST(4.0); + C->c[2] = SUN_RCONST(3.0)/SUN_RCONST(4.0); + C->c[3] = SUN_RCONST(11.0)/SUN_RCONST(20.0); + C->c[4] = ONE/SUN_RCONST(2.0); + C->c[5] = ONE; + C->c[6] = ONE; + + C->W[0][1][0] = ONE/SUN_RCONST(4.0); + C->W[0][2][0] = SUN_RCONST(9.0)/SUN_RCONST(8.0); + C->W[0][2][1] = -SUN_RCONST(3.0)/SUN_RCONST(8.0); + C->W[0][3][0] = SUN_RCONST(187.0)/SUN_RCONST(2340.0); + C->W[0][3][1] = SUN_RCONST(7.0)/SUN_RCONST(9.0); + C->W[0][3][2] = -SUN_RCONST(4.0)/SUN_RCONST(13.0); + C->W[0][4][0] = SUN_RCONST(64.0)/SUN_RCONST(165.0); + C->W[0][4][1] = ONE/SUN_RCONST(6.0); + C->W[0][4][2] = -SUN_RCONST(3.0)/SUN_RCONST(5.0); + C->W[0][4][3] = SUN_RCONST(6.0)/SUN_RCONST(11.0); + C->W[0][5][0] = SUN_RCONST(1816283.0)/SUN_RCONST(549120.0); + C->W[0][5][1] = -SUN_RCONST(2.0)/SUN_RCONST(9.0); + C->W[0][5][2] = -SUN_RCONST(4.0)/SUN_RCONST(11.0); + C->W[0][5][3] = -ONE/SUN_RCONST(6.0); + C->W[0][5][4] = -SUN_RCONST(2561809.0)/SUN_RCONST(1647360.0); + C->W[0][6][1] = SUN_RCONST(7.0)/SUN_RCONST(11.0); + C->W[0][6][2] = -SUN_RCONST(2203.0)/SUN_RCONST(264.0); + C->W[0][6][3] = SUN_RCONST(10825.0)/SUN_RCONST(792.0); + C->W[0][6][4] = -SUN_RCONST(85.0)/SUN_RCONST(12.0); + C->W[0][6][5] = SUN_RCONST(841.0)/SUN_RCONST(396.0); + C->W[0][7][0] = ONE/SUN_RCONST(400.0); + C->W[0][7][1] = SUN_RCONST(49.0)/SUN_RCONST(12.0); + C->W[0][7][2] = SUN_RCONST(43.0)/SUN_RCONST(6.0); + C->W[0][7][3] = -SUN_RCONST(7.0)/SUN_RCONST(10.0); + C->W[0][7][4] = -SUN_RCONST(85.0)/SUN_RCONST(12.0); + C->W[0][7][5] = -SUN_RCONST(2963.0)/SUN_RCONST(1200.0); + + C->W[1][2][0] = -SUN_RCONST(11.0)/SUN_RCONST(4.0); + C->W[1][2][1] = SUN_RCONST(11.0)/SUN_RCONST(4.0); + C->W[1][3][0] = -SUN_RCONST(1228.0)/SUN_RCONST(2925.0); + C->W[1][3][1] = -SUN_RCONST(92.0)/SUN_RCONST(225.0); + C->W[1][3][2] = SUN_RCONST(808.0)/SUN_RCONST(975.0); + C->W[1][4][0] = -SUN_RCONST(2572.0)/SUN_RCONST(2805.0); + C->W[1][4][1] = SUN_RCONST(167.0)/SUN_RCONST(255.0); + C->W[1][4][2] = SUN_RCONST(199.0)/SUN_RCONST(136.0); + C->W[1][4][3] = -SUN_RCONST(1797.0)/SUN_RCONST(1496.0); + C->W[1][5][0] = -SUN_RCONST(1816283.0)/SUN_RCONST(274560.0); + C->W[1][5][1] = SUN_RCONST(253.0)/SUN_RCONST(36.0); + C->W[1][5][2] = -SUN_RCONST(23.0)/SUN_RCONST(44.0); + C->W[1][5][3] = SUN_RCONST(76.0)/SUN_RCONST(3.0); + C->W[1][5][4] = -SUN_RCONST(20775791.0)/SUN_RCONST(823680.0); + C->W[1][6][1] = SUN_RCONST(107.0)/SUN_RCONST(132.0); + C->W[1][6][2] = SUN_RCONST(1289.0)/SUN_RCONST(88.0); + C->W[1][6][3] = -SUN_RCONST(9275.0)/SUN_RCONST(792.0); + C->W[1][6][5] = -SUN_RCONST(371.0)/SUN_RCONST(99.0); + C->W[1][7][0] = -ONE/SUN_RCONST(200.0); + C->W[1][7][1] = -SUN_RCONST(137.0)/SUN_RCONST(24.0); + C->W[1][7][2] = -SUN_RCONST(235.0)/SUN_RCONST(16.0); + C->W[1][7][3] = SUN_RCONST(1237.0)/SUN_RCONST(80.0); + C->W[1][7][5] = SUN_RCONST(2963.0)/SUN_RCONST(600.0); + + C->G[0][1][0] = -ONE/SUN_RCONST(4.0); + C->G[0][1][1] = ONE/SUN_RCONST(4.0); + C->G[0][2][0] = ONE/SUN_RCONST(4.0); + C->G[0][2][1] = -ONE/SUN_RCONST(2.0); + C->G[0][2][2] = ONE/SUN_RCONST(4.0); + C->G[0][3][0] = SUN_RCONST(13.0)/SUN_RCONST(100.0); + C->G[0][3][1] = -SUN_RCONST(7.0)/SUN_RCONST(30.0); + C->G[0][3][2] = -SUN_RCONST(11.0)/SUN_RCONST(75.0); + C->G[0][3][3] = ONE/SUN_RCONST(4.0); + C->G[0][4][0] = SUN_RCONST(6.0)/SUN_RCONST(85.0); + C->G[0][4][1] = -SUN_RCONST(301.0)/SUN_RCONST(1360.0); + C->G[0][4][2] = -SUN_RCONST(99.0)/SUN_RCONST(544.0); + C->G[0][4][3] = SUN_RCONST(45.0)/SUN_RCONST(544.0); + C->G[0][4][4] = ONE/SUN_RCONST(4.0); + C->G[0][5][1] = -SUN_RCONST(9.0)/SUN_RCONST(4.0); + C->G[0][5][2] = -SUN_RCONST(19.0)/SUN_RCONST(48.0); + C->G[0][5][3] = -SUN_RCONST(75.0)/SUN_RCONST(16.0); + C->G[0][5][4] = SUN_RCONST(85.0)/SUN_RCONST(12.0); + C->G[0][5][5] = ONE/SUN_RCONST(4.0); + return C; + }) + +ARK_MRI_TABLE(ARKODE_MERK21, { /* A.C. Fish, D.R. Reynolds, S.B. Roberts, JCAM 438:115534, 2024 (embedding unpublished) */ + MRIStepCoupling C = MRIStepCoupling_Alloc(2, 3, MRISTEP_MERK); + sunrealtype c2 = SUN_RCONST(0.5); + + C->q = 2; + C->p = 1; + C->ngroup = 2; + C->group[0][0] = 1; + C->group[0][1] = 3; + C->group[1][0] = 2; + + C->c[1] = c2; + C->c[2] = ONE; + + C->W[0][1][0] = ONE; + C->W[0][2][0] = ONE; + C->W[0][3][0] = ONE; + + C->W[1][2][0] = -ONE/c2; + C->W[1][2][1] = ONE/c2; + return C; + }) + +ARK_MRI_TABLE(ARKODE_MERK32, { /* A.C. Fish, D.R. Reynolds, S.B. Roberts, JCAM 438:115534, 2024 (embedding unpublished) */ + MRIStepCoupling C = MRIStepCoupling_Alloc(2, 4, MRISTEP_MERK); + sunrealtype c2 = SUN_RCONST(0.5); + + C->q = 3; + C->p = 2; + C->ngroup = 3; + C->group[0][0] = 1; + C->group[1][0] = 2; + C->group[1][1] = 4; + C->group[2][0] = 3; + + C->c[1] = c2; + C->c[2] = SUN_RCONST(2.0)/SUN_RCONST(3.0); + C->c[3] = ONE; + + C->W[0][1][0] = ONE; + C->W[0][2][0] = ONE; + C->W[0][3][0] = ONE; + C->W[0][4][0] = ONE; + + C->W[1][2][0] = -ONE/c2; + C->W[1][2][1] = ONE/c2; + C->W[1][3][0] = -SUN_RCONST(1.5); + C->W[1][3][2] = SUN_RCONST(1.5); + C->W[1][4][0] = -ONE/c2; + C->W[1][4][1] = ONE/c2; + return C; + }) + +ARK_MRI_TABLE(ARKODE_MERK43, { /* A.C. Fish, D.R. Reynolds, S.B. Roberts, JCAM 438:115534, 2024 (embedding unpublished) */ + MRIStepCoupling C = MRIStepCoupling_Alloc(3, 7, MRISTEP_MERK); + sunrealtype c2 = SUN_RCONST(0.5); + sunrealtype c3 = SUN_RCONST(0.5); + sunrealtype c4 = ONE/SUN_RCONST(3.0); + sunrealtype c5 = SUN_RCONST(5.0)/SUN_RCONST(6.0); + sunrealtype c6 = ONE/SUN_RCONST(3.0); + + C->q = 4; + C->p = 3; + C->ngroup = 4; + C->group[0][0] = 1; + C->group[1][0] = 3; + C->group[1][1] = 2; + C->group[2][0] = 5; + C->group[2][1] = 4; + C->group[2][2] = 7; + C->group[3][0] = 6; + + C->c[1] = c2; + C->c[2] = c3; + C->c[3] = c4; + C->c[4] = c5; + C->c[5] = c6; + C->c[6] = ONE; + + C->W[0][1][0] = ONE; + C->W[0][2][0] = ONE; + C->W[0][3][0] = ONE; + C->W[0][4][0] = ONE; + C->W[0][5][0] = ONE; + C->W[0][6][0] = ONE; + C->W[0][7][0] = ONE; + + C->W[1][2][0] = -ONE/c2; + C->W[1][2][1] = ONE/c2; + C->W[1][3][0] = -ONE/c2; + C->W[1][3][1] = ONE/c2; + C->W[1][4][0] = c4/c3/(c3-c4) - c3/c4/(c3-c4); + C->W[1][4][2] = -c4/c3/(c3-c4); + C->W[1][4][3] = c3/c4/(c3-c4); + C->W[1][5][0] = c4/c3/(c3-c4) - c3/c4/(c3-c4); + C->W[1][5][2] = -c4/c3/(c3-c4); + C->W[1][5][3] = c3/c4/(c3-c4); + C->W[1][6][0] = c6/c5/(c5-c6) - c5/c6/(c5-c6); + C->W[1][6][4] = -c6/c5/(c5-c6); + C->W[1][6][5] = c5/c6/(c5-c6); + C->W[1][7][0] = c4/c3/(c3-c4) - c3/c4/(c3-c4); + C->W[1][7][2] = -c4/c3/(c3-c4); + C->W[1][7][3] = c3/c4/(c3-c4); + + C->W[2][4][0] = ONE/c4/(c3-c4) - ONE/c3/(c3-c4); + C->W[2][4][2] = ONE/c3/(c3-c4); + C->W[2][4][3] = -ONE/c4/(c3-c4); + C->W[2][5][0] = ONE/c4/(c3-c4) - ONE/c3/(c3-c4); + C->W[2][5][2] = ONE/c3/(c3-c4); + C->W[2][5][3] = -ONE/c4/(c3-c4); + C->W[2][6][0] = ONE/c6/(c5-c6) - ONE/c5/(c5-c6); + C->W[2][6][4] = ONE/c5/(c5-c6); + C->W[2][6][5] = -ONE/c6/(c5-c6); + C->W[2][7][0] = ONE/c4/(c3-c4) - ONE/c3/(c3-c4); + C->W[2][7][2] = ONE/c3/(c3-c4); + C->W[2][7][3] = -ONE/c4/(c3-c4); + + return C; + }) + +ARK_MRI_TABLE(ARKODE_MERK54, { /* A.C. Fish, D.R. Reynolds, S.B. Roberts, JCAM 438:115534, 2024 (embedding unpublished) */ + MRIStepCoupling C = MRIStepCoupling_Alloc(4, 11, MRISTEP_MERK); + sunrealtype c2 = SUN_RCONST(0.5); + sunrealtype c3 = SUN_RCONST(0.5); + sunrealtype c4 = ONE/SUN_RCONST(3.0); + sunrealtype c5 = SUN_RCONST(0.5); + sunrealtype c6 = ONE/SUN_RCONST(3.0); + sunrealtype c7 = SUN_RCONST(0.25); + sunrealtype c8 = SUN_RCONST(0.7); + sunrealtype c9 = SUN_RCONST(0.5); + sunrealtype c10 = SUN_RCONST(2.0)/SUN_RCONST(3.0); + sunrealtype a2 = ONE/c2; + sunrealtype a3 = c4/c3/(c4-c3); + sunrealtype a4 = c3/c4/(c3-c4); + sunrealtype a5 = c6*c7/c5/(c5-c6)/(c5-c7); + sunrealtype a6 = c5*c7/c6/(c6-c5)/(c6-c7); + sunrealtype a7 = c5*c6/c7/(c7-c5)/(c7-c6); + sunrealtype a8 = c9*c10/c8/(c8-c9)/(c8-c10); + sunrealtype a9 = c8*c10/c9/(c9-c8)/(c9-c10); + sunrealtype a10 = c8*c9/c10/(c10-c8)/(c10-c9); + sunrealtype b3 = ONE/c3/(c3-c4); + sunrealtype b4 = ONE/c4/(c3-c4); + sunrealtype b5 = (c6+c7)/c5/(c5-c6)/(c5-c7); + sunrealtype b6 = (c5+c7)/c6/(c6-c5)/(c6-c7); + sunrealtype b7 = (c5+c6)/c7/(c7-c5)/(c7-c6); + sunrealtype b8 = (c9+c10)/c8/(c8-c9)/(c8-c10); + sunrealtype b9 = (c8+c10)/c9/(c9-c8)/(c9-c10); + sunrealtype b10 = (c8+c9)/c10/(c10-c8)/(c10-c9); + sunrealtype g5 = ONE/c5/(c5-c6)/(c5-c7); + sunrealtype g6 = ONE/c6/(c6-c5)/(c6-c7); + sunrealtype g7 = ONE/c7/(c7-c5)/(c7-c6); + sunrealtype g8 = ONE/c8/(c8-c9)/(c8-c10); + sunrealtype g9 = ONE/c9/(c9-c8)/(c9-c10); + sunrealtype g10 = ONE/c10/(c10-c8)/(c10-c9); + + C->q = 5; + C->p = 4; + C->ngroup = 5; + C->group[0][0] = 1; + C->group[1][0] = 3; + C->group[1][1] = 2; + C->group[2][0] = 6; + C->group[2][1] = 5; + C->group[2][2] = 4; + C->group[3][0] = 8; + C->group[3][1] = 9; + C->group[3][2] = 7; + C->group[3][3] = 11; + C->group[4][0] = 10; + + C->c[1] = c2; + C->c[2] = c3; + C->c[3] = c4; + C->c[4] = c5; + C->c[5] = c6; + C->c[6] = c7; + C->c[7] = c8; + C->c[8] = c9; + C->c[9] = c10; + C->c[10] = ONE; + + C->W[0][1][0] = ONE; + C->W[0][2][0] = ONE; + C->W[0][3][0] = ONE; + C->W[0][4][0] = ONE; + C->W[0][5][0] = ONE; + C->W[0][6][0] = ONE; + C->W[0][7][0] = ONE; + C->W[0][8][0] = ONE; + C->W[0][9][0] = ONE; + C->W[0][10][0] = ONE; + C->W[0][11][0] = ONE; + + C->W[1][2][0] = -a2; + C->W[1][2][1] = a2; + C->W[1][3][0] = -a2; + C->W[1][3][1] = a2; + C->W[1][4][0] = -(a3 + a4); + C->W[1][4][2] = a3; + C->W[1][4][3] = a4; + C->W[1][5][0] = -(a3 + a4); + C->W[1][5][2] = a3; + C->W[1][5][3] = a4; + C->W[1][6][0] = -(a3 + a4); + C->W[1][6][2] = a3; + C->W[1][6][3] = a4; + C->W[1][7][0] = -(a5 + a6 + a7); + C->W[1][7][4] = a5; + C->W[1][7][5] = a6; + C->W[1][7][6] = a7; + C->W[1][8][0] = -(a5 + a6 + a7); + C->W[1][8][4] = a5; + C->W[1][8][5] = a6; + C->W[1][8][6] = a7; + C->W[1][9][0] = -(a5 + a6 + a7); + C->W[1][9][4] = a5; + C->W[1][9][5] = a6; + C->W[1][9][6] = a7; + C->W[1][10][0] = -(a8 + a9 + a10); + C->W[1][10][7] = a8; + C->W[1][10][8] = a9; + C->W[1][10][9] = a10; + C->W[1][11][0] = -(a5 + a6 + a7); + C->W[1][11][4] = a5; + C->W[1][11][5] = a6; + C->W[1][11][6] = a7; + + C->W[2][4][0] = b4 - b3; + C->W[2][4][2] = b3; + C->W[2][4][3] = -b4; + C->W[2][5][0] = b4 - b3; + C->W[2][5][2] = b3; + C->W[2][5][3] = -b4; + C->W[2][6][0] = b4 - b3; + C->W[2][6][2] = b3; + C->W[2][6][3] = -b4; + C->W[2][7][0] = b5 + b6 + b7; + C->W[2][7][4] = -b5; + C->W[2][7][5] = -b6; + C->W[2][7][6] = -b7; + C->W[2][8][0] = b5 + b6 + b7; + C->W[2][8][4] = -b5; + C->W[2][8][5] = -b6; + C->W[2][8][6] = -b7; + C->W[2][9][0] = b5 + b6 + b7; + C->W[2][9][4] = -b5; + C->W[2][9][5] = -b6; + C->W[2][9][6] = -b7; + C->W[2][10][0] = b8 + b9 + b10; + C->W[2][10][7] = -b8; + C->W[2][10][8] = -b9; + C->W[2][10][9] = -b10; + C->W[2][11][0] = b5 + b6 + b7; + C->W[2][11][4] = -b5; + C->W[2][11][5] = -b6; + C->W[2][11][6] = -b7; + + C->W[3][7][0] = -(g5 + g6 + g7); + C->W[3][7][4] = g5; + C->W[3][7][5] = g6; + C->W[3][7][6] = g7; + C->W[3][8][0] = -(g5 + g6 + g7); + C->W[3][8][4] = g5; + C->W[3][8][5] = g6; + C->W[3][8][6] = g7; + C->W[3][9][0] = -(g5 + g6 + g7); + C->W[3][9][4] = g5; + C->W[3][9][5] = g6; + C->W[3][9][6] = g7; + C->W[3][10][0] = -(g8 + g9 + g10); + C->W[3][10][7] = g8; + C->W[3][10][8] = g9; + C->W[3][10][9] = g10; + C->W[3][11][0] = -(g5 + g6 + g7); + C->W[3][11][4] = g5; + C->W[3][11][5] = g6; + C->W[3][11][6] = g7; + + return C; + }) diff --git a/src/arkode/arkode_mristep.c b/src/arkode/arkode_mristep.c index 0989e43a7c..dfbd3fd456 100644 --- a/src/arkode/arkode_mristep.c +++ b/src/arkode/arkode_mristep.c @@ -107,7 +107,7 @@ void* MRIStepCreate(ARKRhsFn fse, ARKRhsFn fsi, sunrealtype t0, N_Vector y0, ark_mem->step_getgammas = mriStep_GetGammas; ark_mem->step_init = mriStep_Init; ark_mem->step_fullrhs = mriStep_FullRHS; - ark_mem->step = mriStep_TakeStep; + ark_mem->step = mriStep_TakeStepMRIGARK; ark_mem->step_setuserdata = mriStep_SetUserData; ark_mem->step_printallstats = mriStep_PrintAllStats; ark_mem->step_writeparameters = mriStep_WriteParameters; @@ -133,11 +133,14 @@ void* MRIStepCreate(ARKRhsFn fse, ARKRhsFn fsi, sunrealtype t0, N_Vector y0, ark_mem->step_setstagepredictfn = mriStep_SetStagePredictFn; ark_mem->step_getnumlinsolvsetups = mriStep_GetNumLinSolvSetups; ark_mem->step_getcurrentgamma = mriStep_GetCurrentGamma; + ark_mem->step_getestlocalerrors = mriStep_GetEstLocalErrors; ark_mem->step_getnonlinearsystemdata = mriStep_GetNonlinearSystemData; ark_mem->step_getnumnonlinsolviters = mriStep_GetNumNonlinSolvIters; ark_mem->step_getnumnonlinsolvconvfails = mriStep_GetNumNonlinSolvConvFails; ark_mem->step_getnonlinsolvstats = mriStep_GetNonlinSolvStats; + ark_mem->step_supports_adaptive = SUNTRUE; ark_mem->step_supports_implicit = SUNTRUE; + ark_mem->step_supports_relaxation = SUNTRUE; ark_mem->step_mem = (void*)step_mem; /* Set default values for optional inputs */ @@ -163,8 +166,8 @@ void* MRIStepCreate(ARKRhsFn fse, ARKRhsFn fsi, sunrealtype t0, N_Vector y0, step_mem->implicit_rhs = (fsi == NULL) ? SUNFALSE : SUNTRUE; /* Update the ARKODE workspace requirements */ - ark_mem->liw += 42; /* fcn/data ptr, int, long int, sunindextype, sunbooleantype */ - ark_mem->lrw += 10; + ark_mem->liw += 49; /* fcn/data ptr, int, long int, sunindextype, sunbooleantype */ + ark_mem->lrw += 14; /* Create a default Newton NLS object (just in case; will be deleted if the user attaches a nonlinear solver) */ @@ -199,6 +202,9 @@ void* MRIStepCreate(ARKRhsFn fse, ARKRhsFn fsi, sunrealtype t0, N_Vector y0, step_mem->lfree = NULL; step_mem->lmem = NULL; + /* Initialize error norm */ + step_mem->eRNrm = ONE; + /* Initialize all the counters */ step_mem->nfse = 0; step_mem->nfsi = 0; @@ -211,6 +217,11 @@ void* MRIStepCreate(ARKRhsFn fse, ARKRhsFn fsi, sunrealtype t0, N_Vector y0, step_mem->cvals = NULL; step_mem->Xvecs = NULL; + /* Initialize adaptivity parameters */ + step_mem->inner_control = ONE; + step_mem->inner_dsm = ONE; + step_mem->inner_control_new = ONE; + /* Initialize pre and post inner evolve functions */ step_mem->pre_inner_evolve = NULL; step_mem->post_inner_evolve = NULL; @@ -380,10 +391,11 @@ int mriStep_Resize(ARKodeMem ark_mem, N_Vector y0, "Unable to resize vector"); return (ARK_MEM_FAIL); } + if (step_mem->unify_Fs) { step_mem->Fsi = step_mem->Fse; } } /* Resize Fsi */ - if (step_mem->Fsi) + if (step_mem->Fsi && !step_mem->unify_Fs) { if (!arkResizeVecArray(resize, resize_data, step_mem->nstages_allocated, y0, &(step_mem->Fsi), lrw_diff, &(ark_mem->lrw), @@ -492,7 +504,12 @@ int mriStep_Reset(ARKodeMem ark_mem, sunrealtype tR, N_Vector yR) /* Reset the inner integrator with this same state */ retval = mriStepInnerStepper_Reset(step_mem->stepper, tR, yR); - if (retval != ARK_SUCCESS) { return (ARK_INNERSTEP_FAIL); } + if (retval != ARK_SUCCESS) + { + arkProcessError(ark_mem, ARK_INNERSTEP_FAIL, __LINE__, __func__, __FILE__, + "Unable to reset the inner stepper"); + return (ARK_INNERSTEP_FAIL); + } return (ARK_SUCCESS); } @@ -544,7 +561,7 @@ void mriStep_Free(ARKodeMem ark_mem) { free(step_mem->stagetypes); step_mem->stagetypes = NULL; - ark_mem->liw -= step_mem->stages; + ark_mem->liw -= (step_mem->stages + 1); } if (step_mem->stage_map) { @@ -604,6 +621,7 @@ void mriStep_Free(ARKodeMem ark_mem) arkFreeVecArray(step_mem->nstages_allocated, &(step_mem->Fse), ark_mem->lrw1, &(ark_mem->lrw), ark_mem->liw1, &(ark_mem->liw)); + if (step_mem->unify_Fs) { step_mem->Fsi = NULL; } } if (step_mem->Fsi) @@ -659,7 +677,7 @@ void mriStep_PrintMem(ARKodeMem ark_mem, FILE* outfile) fprintf(outfile, "MRIStep: predictor = %i\n", step_mem->predictor); fprintf(outfile, "MRIStep: convfail = %i\n", step_mem->convfail); fprintf(outfile, "MRIStep: stagetypes ="); - for (i = 0; i < step_mem->stages; i++) + for (i = 0; i <= step_mem->stages; i++) { fprintf(outfile, " %i", step_mem->stagetypes[i]); } @@ -722,7 +740,7 @@ void mriStep_PrintMem(ARKodeMem ark_mem, FILE* outfile) fprintf(outfile, "MRIStep: Fse[%i]:\n", i); N_VPrintFile(step_mem->Fse[i], outfile); } - if (step_mem->Fsi) + if (step_mem->Fsi && !step_mem->unify_Fs) for (i = 0; i < step_mem->nstages_active; i++) { fprintf(outfile, "MRIStep: Fsi[%i]:\n", i); @@ -858,9 +876,9 @@ int mriStep_GetGammas(ARKodeMem ark_mem, sunrealtype* gamma, sunrealtype* gamrat within arkInitialSetup. With initialization types FIRST_INIT this routine: - - sets/checks the ARK Butcher tables to be used - - allocates any memory that depends on the number of ARK - stages, method order, or solver options + - sets/checks the coefficient tables to be used + - allocates any internal memory that depend on the MRI method + structure or solver options With other initialization types, this routine does nothing. ---------------------------------------------------------------*/ @@ -869,6 +887,7 @@ int mriStep_Init(ARKodeMem ark_mem, int init_type) ARKodeMRIStepMem step_mem; int retval, j; sunbooleantype reset_efun; + SUNAdaptController_Type adapt_type; /* access ARKodeMRIStepMem structure */ retval = mriStep_AccessStepMem(ark_mem, __func__, &step_mem); @@ -881,10 +900,13 @@ int mriStep_Init(ARKodeMem ark_mem, int init_type) if (init_type == FIRST_INIT) { /* enforce use of arkEwtSmallReal if using a fixed step size for - an explicit method and an internal error weight function */ + an explicit method, an internal error weight function, and not performing + accumulated temporal error estimation */ reset_efun = SUNTRUE; if (step_mem->implicit_rhs) { reset_efun = SUNFALSE; } + if (!ark_mem->fixedstep) { reset_efun = SUNFALSE; } if (ark_mem->user_efun) { reset_efun = SUNFALSE; } + if (ark_mem->AccumErrorType >= 0) { reset_efun = SUNFALSE; } if (reset_efun) { ark_mem->user_efun = SUNFALSE; @@ -892,14 +914,6 @@ int mriStep_Init(ARKodeMem ark_mem, int init_type) ark_mem->e_data = ark_mem; } - /* assume fixed outer step size */ - if (!ark_mem->fixedstep) - { - arkProcessError(ark_mem, ARK_ILL_INPUT, __LINE__, __func__, - __FILE__, "Adaptive outer time stepping is not currently supported"); - return (ARK_ILL_INPUT); - } - /* Create coupling structure (if not already set) */ retval = mriStep_SetCoupling(ark_mem); if (retval != ARK_SUCCESS) @@ -918,6 +932,31 @@ int mriStep_Init(ARKodeMem ark_mem, int init_type) return (ARK_ILL_INPUT); } + /* Attach correct TakeStep routine for this coupling table */ + switch (step_mem->MRIC->type) + { + case MRISTEP_EXPLICIT: + case MRISTEP_IMPLICIT: + case MRISTEP_IMEX: ark_mem->step = mriStep_TakeStepMRIGARK; break; + case MRISTEP_MERK: ark_mem->step = mriStep_TakeStepMERK; break; + case MRISTEP_MRISR: ark_mem->step = mriStep_TakeStepMRISR; break; + } + + /* Retrieve/store method and embedding orders now that tables are finalized */ + step_mem->stages = step_mem->MRIC->stages; + step_mem->q = ark_mem->hadapt_mem->q = step_mem->MRIC->q; + step_mem->p = ark_mem->hadapt_mem->p = step_mem->MRIC->p; + + /* Ensure that if adaptivity or error accumulation is enabled, then + method includes embedding coefficients */ + if ((!ark_mem->fixedstep || (ark_mem->AccumErrorType >= 0)) && + (step_mem->p == 0)) + { + arkProcessError(ark_mem, ARK_ILL_INPUT, __LINE__, __func__, + __FILE__, "Temporal error estimation cannot be performed without embedding coefficients"); + return (ARK_ILL_INPUT); + } + /* allocate/fill derived quantities from MRIC structure */ /* stage map */ @@ -950,7 +989,7 @@ int mriStep_Init(ARKodeMem ark_mem, int init_type) free(step_mem->stagetypes); ark_mem->liw -= step_mem->stages; } - step_mem->stagetypes = (int*)calloc(step_mem->MRIC->stages, + step_mem->stagetypes = (int*)calloc(step_mem->MRIC->stages + 1, sizeof(*step_mem->stagetypes)); if (step_mem->stagetypes == NULL) { @@ -958,8 +997,10 @@ int mriStep_Init(ARKodeMem ark_mem, int init_type) MSG_ARK_MEM_FAIL); return (ARK_MEM_FAIL); } - ark_mem->liw += step_mem->MRIC->stages; - for (j = 0; j < step_mem->MRIC->stages; j++) + ark_mem->liw += (step_mem->MRIC->stages + 1); + step_mem->stagetypes[0] = + MRISTAGE_ERK_NOFAST; /* 1st stage is always ERK_NOFAST */ + for (j = 1; j <= step_mem->MRIC->stages; j++) { step_mem->stagetypes[j] = mriStepCoupling_GetStageType(step_mem->MRIC, j); } @@ -1033,6 +1074,16 @@ int mriStep_Init(ARKodeMem ark_mem, int init_type) step_mem->q = step_mem->MRIC->q; step_mem->p = step_mem->MRIC->p; + /* If an MRISR method is applied to a non-ImEx problem, we "unify" + the Fse and Fsi vectors to point at the same memory */ + step_mem->unify_Fs = SUNFALSE; + if ((step_mem->MRIC->type == MRISTEP_MRISR) && + ((step_mem->explicit_rhs && !step_mem->implicit_rhs) || + (!step_mem->explicit_rhs && step_mem->implicit_rhs))) + { + step_mem->unify_Fs = SUNTRUE; + } + /* Allocate MRI RHS vector memory, update storage requirements */ /* Allocate Fse[0] ... Fse[nstages_active - 1] and */ /* Fsi[0] ... Fsi[nstages_active - 1] if needed */ @@ -1045,15 +1096,17 @@ int mriStep_Init(ARKodeMem ark_mem, int init_type) arkFreeVecArray(step_mem->nstages_allocated, &(step_mem->Fse), ark_mem->lrw1, &(ark_mem->lrw), ark_mem->liw1, &(ark_mem->liw)); + if (step_mem->unify_Fs) { step_mem->Fsi = NULL; } } if (step_mem->implicit_rhs) { arkFreeVecArray(step_mem->nstages_allocated, &(step_mem->Fsi), ark_mem->lrw1, &(ark_mem->lrw), ark_mem->liw1, &(ark_mem->liw)); + if (step_mem->unify_Fs) { step_mem->Fse = NULL; } } } - if (step_mem->explicit_rhs) + if (step_mem->explicit_rhs && !step_mem->unify_Fs) { if (!arkAllocVecArray(step_mem->nstages_active, ark_mem->ewt, &(step_mem->Fse), ark_mem->lrw1, &(ark_mem->lrw), @@ -1062,7 +1115,7 @@ int mriStep_Init(ARKodeMem ark_mem, int init_type) return (ARK_MEM_FAIL); } } - if (step_mem->implicit_rhs) + if (step_mem->implicit_rhs && !step_mem->unify_Fs) { if (!arkAllocVecArray(step_mem->nstages_active, ark_mem->ewt, &(step_mem->Fsi), ark_mem->lrw1, &(ark_mem->lrw), @@ -1071,6 +1124,17 @@ int mriStep_Init(ARKodeMem ark_mem, int init_type) return (ARK_MEM_FAIL); } } + if (step_mem->unify_Fs) + { + if (!arkAllocVecArray(step_mem->nstages_active, ark_mem->ewt, + &(step_mem->Fse), ark_mem->lrw1, &(ark_mem->lrw), + ark_mem->liw1, &(ark_mem->liw))) + { + return (ARK_MEM_FAIL); + } + step_mem->Fsi = step_mem->Fse; + } + step_mem->nstages_allocated = step_mem->nstages_active; } @@ -1164,6 +1228,145 @@ int mriStep_Init(ARKodeMem ark_mem, int init_type) } } + /* get timestep adaptivity type, and return an error if an + incompatible type is detected */ + adapt_type = SUNAdaptController_GetType(ark_mem->hadapt_mem->hcontroller); + if ((adapt_type != SUN_ADAPTCONTROLLER_MRI_H) && + (adapt_type != SUN_ADAPTCONTROLLER_MRI_TOL) && + (adapt_type != SUN_ADAPTCONTROLLER_H)) + { + arkProcessError(ark_mem, ARK_ILL_INPUT, __LINE__, __func__, __FILE__, + "SUNAdaptController type is unsupported by MRIStep"); + return (ARK_ILL_INPUT); + } + + /*** Perform timestep adaptivity checks and initial setup ***/ + + if (ark_mem->fixedstep) + { + /* Non-adaptive controller: user must have supplied initial step + size, and indicated fixed time stepping */ + if ((ark_mem->hin == ZERO) || (ark_mem->fixedstep == SUNFALSE)) + { + arkProcessError(ark_mem, ARK_ILL_INPUT, __LINE__, __func__, + __FILE__, "Timestep adaptivity disabled, but missing user-defined fixed stepsize"); + return (ARK_ILL_INPUT); + } + } + else + { + /* Controller provides adaptivity (at least at the slow time scale): + - verify that the MRI method includes an embedding, and + - estimate initial slow step size (store in ark_mem->hin) */ + if (step_mem->MRIC->p == 0) + { + arkProcessError(ark_mem, ARK_ILL_INPUT, __LINE__, __func__, + __FILE__, "Timestep adaptivity enabled, but non-embedded MRI table specified"); + return (ARK_ILL_INPUT); + } + if (ark_mem->hin == ZERO) + { + /* tempv1 = fslow(t0, y0) */ + if (mriStep_SlowRHS(ark_mem, ark_mem->tcur, ark_mem->yn, ark_mem->tempv1, + ARK_FULLRHS_START) != ARK_SUCCESS) + { + arkProcessError(ark_mem, ARK_RHSFUNC_FAIL, __LINE__, __func__, __FILE__, + "error calling slow RHS function(s)"); + return (ARK_RHSFUNC_FAIL); + } + retval = mriStep_Hin(ark_mem, ark_mem->tcur, ark_mem->tout, ark_mem->yn, + ark_mem->tempv1, ark_mem->ycur, ark_mem->tempv2, + ark_mem->tempv3, mriStep_SlowRHS, &(ark_mem->hin)); + if (retval != ARK_SUCCESS) + { + retval = arkHandleFailure(ark_mem, retval); + return (retval); + } + } + } + + /* Perform additional setup for (H,tol) controller */ + if (adapt_type == SUN_ADAPTCONTROLLER_MRI_TOL) + { + /* Verify that adaptivity type is supported by inner stepper */ + if (!mriStepInnerStepper_SupportsRTolAdaptivity(step_mem->stepper)) + { + arkProcessError(ark_mem, ARK_ILL_INPUT, __LINE__, __func__, + __FILE__, "MRI-TOL SUNAdaptController provided, but unsupported by inner stepper"); + return (ARK_ILL_INPUT); + } + + /* initialize fast stepper to use the same relative tolerance as MRIStep */ + step_mem->inner_control = ONE; + } + + /* Perform additional setup for (H,h) controller */ + if (adapt_type == SUN_ADAPTCONTROLLER_MRI_H) + { + /* verify that adaptivity type is supported by inner stepper */ + if (!mriStepInnerStepper_SupportsStepAdaptivity(step_mem->stepper)) + { + arkProcessError(ark_mem, ARK_ILL_INPUT, __LINE__, __func__, + __FILE__, "MRI-H SUNAdaptController provided, but unsupported by inner stepper"); + return (ARK_ILL_INPUT); + } + + /* If user has left inner_hfactor unset, reset to our default to indicate + that we **do not trust** fixed-stepsize fast error estimates. */ + if (step_mem->inner_hfactor < ZERO) + { + step_mem->inner_hfactor = INNER_HFACTOR; + } + + /* initialize fast stepper fixed step size (store in step_mem->inner_control) */ + if (step_mem->stepper->ops->fullrhs) + { + /* tempv1 = ffast(t0, y0) */ + if (mriStep_FastRHS(ark_mem, ark_mem->tcur, ark_mem->yn, ark_mem->tempv1, + ARK_FULLRHS_START) != ARK_SUCCESS) + { + arkProcessError(ark_mem, ARK_RHSFUNC_FAIL, __LINE__, __func__, __FILE__, + "error calling fast RHS function(s)"); + return (ARK_RHSFUNC_FAIL); + } + + /* compute initial fast step size */ + retval = arkHin(ark_mem, ark_mem->tcur, ark_mem->tout, ark_mem->yn, + ark_mem->tempv1, ark_mem->ycur, ark_mem->tempv2, + ark_mem->tempv3, mriStep_FastRHS, + &(step_mem->inner_control)); + if (retval != ARK_SUCCESS) + { + retval = arkHandleFailure(ark_mem, retval); + return (retval); + } + } + else + { + /* set step_mem->inner_control to equal H/100 */ + step_mem->inner_control = SUN_RCONST(0.01) * ark_mem->hin; + } + /* Pass fixed stepsize to inner stepper */ + retval = mriStepInnerStepper_SetFixedStep(step_mem->stepper, + step_mem->inner_control); + if (retval != ARK_SUCCESS) + { + arkProcessError(ark_mem, ARK_INNERSTEP_FAIL, __LINE__, __func__, __FILE__, + "error setting fast fixed step"); + return (ARK_INNERSTEP_FAIL); + } + } + else + { + /* If user has left inner_hfactor unset, reset to zero to indicate + either that we **trust** tolerance-based adaptive fast error + estimates, or that the method does not use fast error estimates. */ + if (step_mem->inner_hfactor < ZERO) { step_mem->inner_hfactor = ZERO; } + } + + /* /\* Signal to shared arkode module that fullrhs is required after each step *\/ */ + /* /\* TO-DO: verify whether this is actually required *\/ */ + /* ark_mem->call_fullrhs = SUNTRUE; */ return (ARK_SUCCESS); } @@ -1200,7 +1403,7 @@ int mriStep_FullRHS(ARKodeMem ark_mem, sunrealtype t, N_Vector y, N_Vector f, int mode) { ARKodeMRIStepMem step_mem; - int retval; + int i, sa_stage, retval; /* access ARKodeMRIStepMem structure */ retval = mriStep_AccessStepMem(ark_mem, __func__, &step_mem); @@ -1284,29 +1487,56 @@ int mriStep_FullRHS(ARKodeMem ark_mem, sunrealtype t, N_Vector y, N_Vector f, /* compute the full RHS */ if (!(ark_mem->fn_is_current)) { - /* compute the explicit component */ - if (step_mem->explicit_rhs) + /* if the method had a stiffly-accurate internal stage, use the + already-computed RHS vectors */ + sa_stage = -1; + for (i = 1; i < step_mem->stages; i++) { - retval = step_mem->fse(t, y, step_mem->Fse[0], ark_mem->user_data); - step_mem->nfse++; - if (retval != 0) + if (step_mem->stagetypes[i] == MRISTAGE_STIFF_ACC) { - arkProcessError(ark_mem, ARK_RHSFUNC_FAIL, __LINE__, __func__, - __FILE__, MSG_ARK_RHSFUNC_FAILED, t); - return (ARK_RHSFUNC_FAIL); + sa_stage = step_mem->stage_map[i - 1]; } } + if (sa_stage > -1) + { + /* copy the explicit component */ + if (step_mem->explicit_rhs) + { + N_VScale(ONE, step_mem->Fse[sa_stage], step_mem->Fse[0]); + } - /* compute the implicit component */ - if (step_mem->implicit_rhs) + /* copy the implicit component */ + if (step_mem->implicit_rhs) + { + N_VScale(ONE, step_mem->Fsi[sa_stage], step_mem->Fsi[0]); + } + } + else { - retval = step_mem->fsi(t, y, step_mem->Fsi[0], ark_mem->user_data); - step_mem->nfsi++; - if (retval != 0) + /* compute the explicit component */ + if (step_mem->explicit_rhs) { - arkProcessError(ark_mem, ARK_RHSFUNC_FAIL, __LINE__, __func__, - __FILE__, MSG_ARK_RHSFUNC_FAILED, t); - return (ARK_RHSFUNC_FAIL); + retval = step_mem->fse(t, y, step_mem->Fse[0], ark_mem->user_data); + step_mem->nfse++; + if (retval != 0) + { + arkProcessError(ark_mem, ARK_RHSFUNC_FAIL, __LINE__, __func__, + __FILE__, MSG_ARK_RHSFUNC_FAILED, t); + return (ARK_RHSFUNC_FAIL); + } + } + + /* compute the implicit component */ + if (step_mem->implicit_rhs) + { + retval = step_mem->fsi(t, y, step_mem->Fsi[0], ark_mem->user_data); + step_mem->nfsi++; + if (retval != 0) + { + arkProcessError(ark_mem, ARK_RHSFUNC_FAIL, __LINE__, __func__, + __FILE__, MSG_ARK_RHSFUNC_FAILED, t); + return (ARK_RHSFUNC_FAIL); + } } } @@ -1410,14 +1640,24 @@ int mriStep_FullRHS(ARKodeMem ark_mem, sunrealtype t, N_Vector y, N_Vector f, } /*--------------------------------------------------------------- - mriStep_TakeStep: + mriStep_TakeStepMRIGARK: This routine serves the primary purpose of the MRIStep module: it performs a single MRI step (with embedding, if possible). - The output variable dsmPtr should contain estimate of the - weighted local error if an embedding is present; otherwise it - should be 0. + The vector ark_mem->yn holds the previous time-step solution + on input, and the vector ark_mem->ycur should hold the result + of this step on output. + + If timestep adaptivity is enabled, this routine also computes + the error estimate y-ytilde, where ytilde is the + embedded solution, and the norm weights come from ark_ewt. + This esimate is stored in ark_mem->tempv1, in case the calling + routine wishes to examine the error locations. + + The output variable dsmPtr should contain a scalar-valued + estimate of the temporal error from this step, ||y-ytilde||_WRMS + if timestep adaptivity is enabled; otherwise it should be 0. The input/output variable nflagPtr is used to gauge convergence of any algebraic solvers within the step. At the start of a new @@ -1427,6 +1667,9 @@ int mriStep_FullRHS(ARKodeMem ark_mem, sunrealtype t, N_Vector y, N_Vector f, >0 => solve did not converge at this step size (but may with a smaller stepsize) <0 => solve encountered an unrecoverable failure + Since the fast-scale evolution could be considered a different + type of "algebraic solver", we similarly report any fast-scale + evolution error as a recoverable nflagPtr value. The return value from this routine is: 0 => step completed successfully @@ -1434,28 +1677,94 @@ int mriStep_FullRHS(ARKodeMem ark_mem, sunrealtype t, N_Vector y, N_Vector f, reduce step and retry (if possible) <0 => step encountered unrecoverable failure ---------------------------------------------------------------*/ -int mriStep_TakeStep(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr) +int mriStep_TakeStepMRIGARK(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr) { - ARKodeMRIStepMem step_mem; /* outer stepper memory */ - int is; /* current stage index */ - int retval; /* reusable return flag */ + ARKodeMRIStepMem step_mem; /* outer stepper memory */ + int is; /* current stage index */ + int retval; /* reusable return flag */ + N_Vector tmp; /* N_Vector pointer */ + SUNAdaptController_Type adapt_type; /* timestep adaptivity type */ + sunrealtype t0, tf; /* start/end of each stage */ + sunbooleantype calc_fslow; + sunbooleantype need_inner_dsm; + sunbooleantype do_embedding; + + /* access the MRIStep mem structure */ + retval = mriStep_AccessStepMem(ark_mem, __func__, &step_mem); + if (retval != ARK_SUCCESS) { return (retval); } /* initialize algebraic solver convergence flag to success; error estimate to zero */ *nflagPtr = ARK_SUCCESS; *dsmPtr = ZERO; - /* access the MRIStep mem structure */ - retval = mriStep_AccessStepMem(ark_mem, __func__, &step_mem); - if (retval != ARK_SUCCESS) { return (retval); } + /* initial time and state for step */ + N_VScale(ONE, ark_mem->yn, ark_mem->ycur); + t0 = ark_mem->tn; + + /* determine whether embedding stage is needed */ + do_embedding = !ark_mem->fixedstep || (ark_mem->AccumErrorType >= 0); + + /* if MRI adaptivity is enabled: reset fast accumulated error, + and send appropriate control parameter to the fast integrator */ + adapt_type = SUNAdaptController_GetType(ark_mem->hadapt_mem->hcontroller); + need_inner_dsm = SUNFALSE; + if ((adapt_type == SUN_ADAPTCONTROLLER_MRI_H) || + (adapt_type == SUN_ADAPTCONTROLLER_MRI_TOL)) + { + need_inner_dsm = SUNTRUE; + step_mem->inner_dsm = ZERO; + retval = mriStepInnerStepper_ResetError(step_mem->stepper); + if (retval != ARK_SUCCESS) + { + arkProcessError(ark_mem, ARK_INNERSTEP_FAIL, __LINE__, __func__, __FILE__, + "Unable to reset the inner stepper error estimate"); + return (ARK_INNERSTEP_FAIL); + } + } + if (adapt_type == SUN_ADAPTCONTROLLER_MRI_H) + { + retval = mriStepInnerStepper_SetFixedStep(step_mem->stepper, + step_mem->inner_control); + if (retval != ARK_SUCCESS) + { + arkProcessError(ark_mem, ARK_INNERSTEP_FAIL, __LINE__, __func__, __FILE__, + "Unable to set a fixed stepsize in the inner stepper"); + return (ARK_INNERSTEP_FAIL); + } + } + if (adapt_type == SUN_ADAPTCONTROLLER_MRI_TOL) + { + retval = + mriStepInnerStepper_SetRTol(step_mem->stepper, + step_mem->inner_control * ark_mem->reltol); + if (retval != ARK_SUCCESS) + { + arkProcessError(ark_mem, ARK_INNERSTEP_FAIL, __LINE__, __func__, __FILE__, + "Unable to set the inner stepper tolerance"); + return (ARK_INNERSTEP_FAIL); + } + } + + /* if any temporal adaptivity is enabled: reset the inner integrator + to the beginning of this step (in case of recomputation) */ + if (!ark_mem->fixedstep) + { + retval = mriStepInnerStepper_Reset(step_mem->stepper, t0, ark_mem->yn); + if (retval != ARK_SUCCESS) + { + arkProcessError(ark_mem, ARK_INNERSTEP_FAIL, __LINE__, __func__, __FILE__, + "Unable to reset the inner stepper"); + return (ARK_INNERSTEP_FAIL); + } + } /* call nonlinear solver setup if it exists */ if (step_mem->NLS) { if ((step_mem->NLS)->ops->setup) { - N_VConst(ZERO, - ark_mem->tempv3); /* set guess to 0 for predictor-corrector form */ + N_VConst(ZERO, ark_mem->tempv3); /* set guess to 0 */ retval = SUNNonlinSolSetup(step_mem->NLS, ark_mem->tempv3, ark_mem); if (retval < 0) { return (ARK_NLS_SETUP_FAIL); } if (retval > 0) { return (ARK_NLS_SETUP_RECVR); } @@ -1472,7 +1781,7 @@ int mriStep_TakeStep(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr) /* compute the explicit component */ if (step_mem->explicit_rhs) { - retval = step_mem->fse(ark_mem->tn, ark_mem->yn, step_mem->Fse[0], + retval = step_mem->fse(t0, ark_mem->yn, step_mem->Fse[0], ark_mem->user_data); step_mem->nfse++; if (retval) { return ARK_RHSFUNC_FAIL; } @@ -1481,7 +1790,7 @@ int mriStep_TakeStep(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr) /* compute the implicit component */ if (step_mem->implicit_rhs) { - retval = step_mem->fsi(ark_mem->tn, ark_mem->yn, step_mem->Fsi[0], + retval = step_mem->fsi(t0, ark_mem->yn, step_mem->Fsi[0], ark_mem->user_data); step_mem->nfsi++; if (retval) { return ARK_RHSFUNC_FAIL; } @@ -1492,24 +1801,27 @@ int mriStep_TakeStep(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr) #ifdef SUNDIALS_DEBUG printf(" MRIStep step %li, stage 0, h = %" RSYM ", t_n = %" RSYM "\n", - ark_mem->nst, ark_mem->h, ark_mem->tcur); + ark_mem->nst, ark_mem->h, t0); #endif #ifdef SUNDIALS_LOGGING_EXTRA_DEBUG - SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, "ARKODE::mriStep_TakeStep", - "slow stage", "z_0(:) =", ""); - N_VPrintFile(ark_mem->ycur, ARK_LOGGER->debug_fp); + SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, + "ARKODE::mriStep_TakeStepMRIGARK", "slow stage", + "z[0] =", ""); + N_VPrintFile(ark_mem->yn, ARK_LOGGER->debug_fp); if (step_mem->explicit_rhs) { - SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, "ARKODE::mriStep_TakeStep", - "slow explicit RHS", "Fse_0(:) =", ""); + SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, + "ARKODE::mriStep_TakeStepMRIGARK", "slow explicit RHS", + "Fse[0] =", ""); N_VPrintFile(step_mem->Fse[0], ARK_LOGGER->debug_fp); } if (step_mem->implicit_rhs) { - SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, "ARKODE::mriStep_TakeStep", - "slow implicit RHS", "Fsi_0(:) =", ""); + SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, + "ARKODE::mriStep_TakeStepMRIGARK", "slow implicit RHS", + "Fsi[0] =", ""); N_VPrintFile(step_mem->Fsi[0], ARK_LOGGER->debug_fp); } #endif @@ -1520,13 +1832,14 @@ int mriStep_TakeStep(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr) /* Loop over remaining stages */ for (is = 1; is < step_mem->stages; is++) { - /* Set current stage time */ - ark_mem->tcur = ark_mem->tn + step_mem->MRIC->c[is] * ark_mem->h; + /* Set relevant stage times (including desired stage time for implicit solves) */ + t0 = ark_mem->tn + step_mem->MRIC->c[is - 1] * ark_mem->h; + tf = ark_mem->tcur = ark_mem->tn + step_mem->MRIC->c[is] * ark_mem->h; /* Solver diagnostics reporting */ #if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_DEBUG SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, - "ARKODE::mriStep_TakeStep", "start-stage", + "ARKODE::mriStep_TakeStepMRIGARK", "start-stage", "step = %li, stage = %i, stage type = %d, h = %" RSYM ", tcur = %" RSYM, ark_mem->nst, is, step_mem->stagetypes[is], ark_mem->h, @@ -1539,7 +1852,15 @@ int mriStep_TakeStep(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr) switch (step_mem->stagetypes[is]) { case (MRISTAGE_ERK_FAST): - retval = mriStep_StageERKFast(ark_mem, step_mem, is); + retval = mriStep_ComputeInnerForcing(ark_mem, step_mem, is, t0, tf); + if (retval != ARK_SUCCESS) + { + *nflagPtr = CONV_FAIL; + break; + } + retval = mriStep_StageERKFast(ark_mem, step_mem, is, t0, tf, ark_mem->ycur, + ark_mem->tempv2, SUNTRUE, need_inner_dsm); + if (retval != ARK_SUCCESS) { *nflagPtr = CONV_FAIL; } break; case (MRISTAGE_ERK_NOFAST): retval = mriStep_StageERKNoFast(ark_mem, step_mem, is); @@ -1550,40 +1871,61 @@ int mriStep_TakeStep(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr) case (MRISTAGE_DIRK_FAST): retval = mriStep_StageDIRKFast(ark_mem, step_mem, is, nflagPtr); break; + case (MRISTAGE_STIFF_ACC): retval = ARK_SUCCESS; break; } if (retval != ARK_SUCCESS) { return (retval); } #ifdef SUNDIALS_LOGGING_EXTRA_DEBUG SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, - "ARKODE::mriStep_TakeStep", "slow stage", "z_%i(:) =", is); + "ARKODE::mriStep_TakeStepMRIGARK", "slow stage", + "z[%i] =", is); N_VPrintFile(ark_mem->ycur, ARK_LOGGER->debug_fp); #endif /* apply user-supplied stage postprocessing function (if supplied) */ - if (ark_mem->ProcessStage != NULL) + if ((ark_mem->ProcessStage != NULL) && + (step_mem->stagetypes[is] != MRISTAGE_STIFF_ACC)) { - retval = ark_mem->ProcessStage(ark_mem->tcur, ark_mem->ycur, - ark_mem->user_data); + retval = ark_mem->ProcessStage(tf, ark_mem->ycur, ark_mem->user_data); if (retval != 0) { return (ARK_POSTPROCESS_STAGE_FAIL); } } /* conditionally reset the inner integrator with the modified stage solution */ - if ((step_mem->stagetypes[is] != MRISTAGE_ERK_FAST) || - (ark_mem->ProcessStage != NULL)) + if (step_mem->stagetypes[is] != MRISTAGE_STIFF_ACC) { - retval = mriStepInnerStepper_Reset(step_mem->stepper, ark_mem->tcur, - ark_mem->ycur); - if (retval != ARK_SUCCESS) { return (ARK_INNERSTEP_FAIL); } + if ((step_mem->stagetypes[is] != MRISTAGE_ERK_FAST) || + (ark_mem->ProcessStage != NULL)) + { + retval = mriStepInnerStepper_Reset(step_mem->stepper, tf, ark_mem->ycur); + if (retval != ARK_SUCCESS) + { + arkProcessError(ark_mem, ARK_INNERSTEP_FAIL, __LINE__, __func__, + __FILE__, "Unable to reset the inner stepper"); + return (ARK_INNERSTEP_FAIL); + } + } } - /* Compute updated slow RHS except at last stage which is the new solution. - * The new solution RHS evaluation happens in arkCompleteStep */ - if (is < step_mem->stages - 1 && step_mem->stage_map[is] > -1) + /* Compute updated slow RHS, except: + 1. at last stage which is the new solution, since that RHS occurs in arkCompleteStep. + 2. if the stage is excluded from stage_map + 3. if the next stage has "STIFF_ACC" type, and temporal estimation is disabled */ + calc_fslow = SUNTRUE; + if (is == step_mem->stages - 1) { calc_fslow = SUNFALSE; } + if (step_mem->stage_map[is] == -1) { calc_fslow = SUNFALSE; } + if (is < step_mem->stages - 1) + { + if (!do_embedding && (step_mem->stagetypes[is + 1] == MRISTAGE_STIFF_ACC)) + { + calc_fslow = SUNFALSE; + } + } + if (calc_fslow) { /* store explicit slow rhs */ if (step_mem->explicit_rhs) { - retval = step_mem->fse(ark_mem->tcur, ark_mem->ycur, + retval = step_mem->fse(tf, ark_mem->ycur, step_mem->Fse[step_mem->stage_map[is]], ark_mem->user_data); step_mem->nfse++; @@ -1592,8 +1934,8 @@ int mriStep_TakeStep(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr) #ifdef SUNDIALS_LOGGING_EXTRA_DEBUG SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, - "ARKODE::mriStep_TakeStep", "slow explicit RHS", - "Fse_%i(:) =", is); + "ARKODE::mriStep_TakeStepMRIGARK", + "slow explicit RHS", "Fse[%i] =", is); N_VPrintFile(step_mem->Fse[step_mem->stage_map[is]], ARK_LOGGER->debug_fp); #endif @@ -1605,7 +1947,7 @@ int mriStep_TakeStep(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr) if (!step_mem->deduce_rhs || (step_mem->stagetypes[is] != MRISTAGE_DIRK_NOFAST)) { - retval = step_mem->fsi(ark_mem->tcur, ark_mem->ycur, + retval = step_mem->fsi(tf, ark_mem->ycur, step_mem->Fsi[step_mem->stage_map[is]], ark_mem->user_data); step_mem->nfsi++; @@ -1622,57 +1964,889 @@ int mriStep_TakeStep(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr) #ifdef SUNDIALS_LOGGING_EXTRA_DEBUG SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, - "ARKODE::mriStep_TakeStep", "slow implicit RHS", - "Fsi_%i(:) =", is); + "ARKODE::mriStep_TakeStepMRIGARK", + "slow implicit RHS", "Fsi[%i] =", is); N_VPrintFile(step_mem->Fsi[step_mem->stage_map[is]], ARK_LOGGER->debug_fp); #endif } + + /* if this is the next-to-last internal stage, and if temporal error estimation + is enabled, save ycur into ark_mem->tempv4 (needed for embedding) */ + if ((is == step_mem->stages - 2) && do_embedding) + { + N_VScale(ONE, ark_mem->ycur, ark_mem->tempv4); + } + } /* compute slow RHS */ } /* loop over stages */ #ifdef SUNDIALS_LOGGING_EXTRA_DEBUG - SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, "ARKODE::mriStep_TakeStep", - "updated solution", "ycur(:) =", ""); + SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, + "ARKODE::mriStep_TakeStepMRIGARK", "updated solution", + "ycur =", ""); N_VPrintFile(ark_mem->ycur, ARK_LOGGER->debug_fp); #endif + /* perform embedded stage (if needed) to compute error and store in dsmPtr */ + if (do_embedding) + { + /* Temporarily swap ark_mem->ycur and ark_mem->tempv4 pointers, so that + during this embedding "stage": + - ark_mem->ycur starts out as what it was for the last internal stage, + and ends up as the embedded solution. + - ark_mem->tempv4 archives the current time step solution vector. */ + tmp = ark_mem->ycur; + ark_mem->ycur = ark_mem->tempv4; + ark_mem->tempv4 = tmp; + + /* Reset ark_mem->tcur as the time value corresponding with the end of the step */ + /* Set relevant stage times (including desired stage time for implicit solves) */ + t0 = ark_mem->tn + step_mem->MRIC->c[step_mem->stages - 2] * ark_mem->h; + tf = ark_mem->tcur = ark_mem->tn + + step_mem->MRIC->c[step_mem->stages - 1] * ark_mem->h; + + /* Solver diagnostics reporting */ +#if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_DEBUG + SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, + "ARKODE::mriStep_TakeStepMRIGARK", "embedding-stage", + "step = %li, stage = %i, stage type = %d, h = %" RSYM + ", tcur = %" RSYM, + ark_mem->nst, step_mem->stages, + step_mem->stagetypes[step_mem->stages], ark_mem->h, + ark_mem->tcur); +#endif + + /* Determine embedding stage type, and call corresponding routine; the + vector ark_mem->ycur stores the previous stage solution on input, and + should store the result of this stage solution on output. */ + switch (step_mem->stagetypes[step_mem->stages]) + { + case (MRISTAGE_ERK_FAST): + retval = mriStep_ComputeInnerForcing(ark_mem, step_mem, step_mem->stages, + t0, tf); + if (retval != ARK_SUCCESS) + { + *nflagPtr = CONV_FAIL; + break; + } + retval = mriStep_StageERKFast(ark_mem, step_mem, step_mem->stages, t0, tf, + ark_mem->ycur, ark_mem->tempv2, SUNTRUE, + SUNFALSE); + if (retval != ARK_SUCCESS) { *nflagPtr = CONV_FAIL; } + break; + case (MRISTAGE_ERK_NOFAST): + retval = mriStep_StageERKNoFast(ark_mem, step_mem, step_mem->stages); + break; + case (MRISTAGE_DIRK_NOFAST): + retval = mriStep_StageDIRKNoFast(ark_mem, step_mem, step_mem->stages, + nflagPtr); + break; + case (MRISTAGE_DIRK_FAST): + retval = mriStep_StageDIRKFast(ark_mem, step_mem, step_mem->stages, + nflagPtr); + break; + } + if (retval != ARK_SUCCESS) { return (retval); } + +#ifdef SUNDIALS_LOGGING_EXTRA_DEBUG + SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, + "ARKODE::mriStep_TakeStepMRIGARK", "embedded solution", + "ytilde =", ""); + N_VPrintFile(ark_mem->ycur, ARK_LOGGER->debug_fp); +#endif + + /* Compute temporal error estimate via difference between step + solution and embedding, store in ark_mem->tempv1, and take norm. */ + N_VLinearSum(ONE, ark_mem->tempv4, -ONE, ark_mem->ycur, ark_mem->tempv1); + *dsmPtr = N_VWrmsNorm(ark_mem->tempv1, ark_mem->ewt); + + /* Swap back ark_mem->ycur with ark_mem->tempv4. */ + tmp = ark_mem->ycur; + ark_mem->ycur = ark_mem->tempv4; + ark_mem->tempv4 = tmp; + } + /* Solver diagnostics reporting */ #if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_DEBUG - SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, "ARKODE::mriStep_TakeStep", - "error-test", "step = %li, h = %" RSYM ", dsm = %" RSYM, - ark_mem->nst, ark_mem->h, *dsmPtr); + SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, + "ARKODE::mriStep_TakeStepMRIGARK", "end-step", + "step = %li, t = %" RSYM ", h = %" RSYM ", dsm = %" RSYM, + ark_mem->nst, ark_mem->tn, ark_mem->h, *dsmPtr); #endif return (ARK_SUCCESS); } -/*=============================================================== - Internal utility routines - ===============================================================*/ - /*--------------------------------------------------------------- - mriStep_AccessARKODEStepMem: + mriStep_TakeStepMRISR: - Shortcut routine to unpack ark_mem and step_mem structures from - void* pointer. If either is missing it returns ARK_MEM_NULL. - ---------------------------------------------------------------*/ -int mriStep_AccessARKODEStepMem(void* arkode_mem, const char* fname, - ARKodeMem* ark_mem, ARKodeMRIStepMem* step_mem) -{ - /* access ARKodeMem structure */ - if (arkode_mem == NULL) - { - arkProcessError(NULL, ARK_MEM_NULL, __LINE__, fname, __FILE__, - MSG_ARK_NO_MEM); - return (ARK_MEM_NULL); - } - *ark_mem = (ARKodeMem)arkode_mem; + This routine performs a single MRISR step. - /* access ARKodeMRIStepMem structure */ - if ((*ark_mem)->step_mem == NULL) - { - arkProcessError(*ark_mem, ARK_MEM_NULL, __LINE__, fname, __FILE__, + The vector ark_mem->yn holds the previous time-step solution + on input, and the vector ark_mem->ycur should hold the result + of this step on output. + + If timestep adaptivity is enabled, this routine also computes + the error estimate y-ytilde, where ytilde is the + embedded solution, and the norm weights come from ark_ewt. + This esimate is stored in ark_mem->tempv1, in case the calling + routine wishes to examine the error locations. + + The output variable dsmPtr should contain a scalar-valued + estimate of the temporal error from this step, ||y-ytilde||_WRMS + if timestep adaptivity is enabled; otherwise it should be 0. + + The input/output variable nflagPtr is used to gauge convergence + of any algebraic solvers within the step. At the start of a new + time step, this will initially have the value FIRST_CALL. On + return from this function, nflagPtr should have a value: + 0 => algebraic solve completed successfully + >0 => solve did not converge at this step size + (but may with a smaller stepsize) + <0 => solve encountered an unrecoverable failure + Since the fast-scale evolution could be considered a different + type of "algebraic solver", we similarly report any fast-scale + evolution error as a recoverable nflagPtr value. + + The return value from this routine is: + 0 => step completed successfully + >0 => step encountered recoverable failure; + reduce step and retry (if possible) + <0 => step encountered unrecoverable failure + ---------------------------------------------------------------*/ +int mriStep_TakeStepMRISR(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr) +{ + ARKodeMRIStepMem step_mem; /* outer stepper memory */ + int stage, j; /* stage indices */ + int retval; /* reusable return flag */ + N_Vector ytilde; /* embedded solution */ + N_Vector ytemp; /* temporary vector */ + SUNAdaptController_Type adapt_type; /* timestep adaptivity type */ + sunbooleantype embedding; /* flag indicating embedding */ + sunbooleantype solution; /* or solution stages */ + sunbooleantype impl_corr; /* is slow correct. implicit? */ + sunbooleantype store_imprhs; /* temporary storage */ + sunbooleantype store_exprhs; + sunrealtype cstage; /* current stage abscissa */ + sunbooleantype need_inner_dsm; + const sunrealtype tol = SUN_RCONST(100.0) * SUN_UNIT_ROUNDOFF; + + /* access the MRIStep mem structure */ + retval = mriStep_AccessStepMem(ark_mem, __func__, &step_mem); + if (retval != ARK_SUCCESS) { return (retval); } + + /* initialize algebraic solver convergence flag to success; + error estimate to zero */ + *nflagPtr = ARK_SUCCESS; + *dsmPtr = ZERO; + + /* set N_Vector shortcuts */ + ytilde = ark_mem->tempv4; + ytemp = ark_mem->tempv2; + + /* if MRI adaptivity is enabled: reset fast accumulated error, + and send appropriate control parameter to the fast integrator */ + adapt_type = SUNAdaptController_GetType(ark_mem->hadapt_mem->hcontroller); + need_inner_dsm = SUNFALSE; + if ((adapt_type == SUN_ADAPTCONTROLLER_MRI_H) || + (adapt_type == SUN_ADAPTCONTROLLER_MRI_TOL)) + { + need_inner_dsm = SUNTRUE; + step_mem->inner_dsm = ZERO; + retval = mriStepInnerStepper_ResetError(step_mem->stepper); + if (retval != ARK_SUCCESS) + { + arkProcessError(ark_mem, ARK_INNERSTEP_FAIL, __LINE__, __func__, __FILE__, + "Unable to reset the inner stepper error estimate"); + return (ARK_INNERSTEP_FAIL); + } + } + if (adapt_type == SUN_ADAPTCONTROLLER_MRI_H) + { + retval = mriStepInnerStepper_SetFixedStep(step_mem->stepper, + step_mem->inner_control); + if (retval != ARK_SUCCESS) + { + arkProcessError(ark_mem, ARK_INNERSTEP_FAIL, __LINE__, __func__, __FILE__, + "Unable to set a fixed stepsize in the inner stepper"); + return (ARK_INNERSTEP_FAIL); + } + } + if (adapt_type == SUN_ADAPTCONTROLLER_MRI_TOL) + { + retval = + mriStepInnerStepper_SetRTol(step_mem->stepper, + step_mem->inner_control * ark_mem->reltol); + if (retval != ARK_SUCCESS) + { + arkProcessError(ark_mem, ARK_INNERSTEP_FAIL, __LINE__, __func__, __FILE__, + "Unable to set the inner stepper tolerance"); + return (ARK_INNERSTEP_FAIL); + } + } + + /* if any temporal adaptivity is enabled: reset the inner integrator + to the beginning of this step (in case of recomputation) */ + if (!ark_mem->fixedstep) + { + retval = mriStepInnerStepper_Reset(step_mem->stepper, ark_mem->tn, + ark_mem->yn); + if (retval != ARK_SUCCESS) + { + arkProcessError(ark_mem, ARK_INNERSTEP_FAIL, __LINE__, __func__, __FILE__, + "Unable to reset the inner stepper"); + return (ARK_INNERSTEP_FAIL); + } + } + + /* Evaluate the slow RHS functions if needed. NOTE: We do not use the full RHS + function here (unlike ERKStep and ARKStep) since it does not need to check + for FSAL or SA methods and thus avoids potentially unnecessary evaluations + of the inner (fast) RHS function */ + if (!(ark_mem->fn_is_current)) + { + /* compute the explicit component */ + if (step_mem->explicit_rhs) + { + retval = step_mem->fse(ark_mem->tn, ark_mem->yn, step_mem->Fse[0], + ark_mem->user_data); + step_mem->nfse++; + if (retval) { return ARK_RHSFUNC_FAIL; } + } + + /* compute the implicit component */ + if (step_mem->implicit_rhs) + { + retval = step_mem->fsi(ark_mem->tn, ark_mem->yn, step_mem->Fsi[0], + ark_mem->user_data); + step_mem->nfsi++; + if (retval) { return ARK_RHSFUNC_FAIL; } + } + + /* combine both RHS into Fse for ImEx problems */ + if (step_mem->implicit_rhs && step_mem->explicit_rhs) + { + N_VLinearSum(ONE, step_mem->Fse[0], ONE, step_mem->Fsi[0], + step_mem->Fse[0]); + } + + ark_mem->fn_is_current = SUNTRUE; + } + +#ifdef SUNDIALS_DEBUG + printf(" MRIStep step %li, stage 0, h = %" RSYM ", t_n = %" RSYM "\n", + ark_mem->nst, ark_mem->h, ark_mem->tn); +#endif + +#ifdef SUNDIALS_LOGGING_EXTRA_DEBUG + SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, + "ARKODE::mriStep_TakeStepMRISR", "slow stage", "z[0] =", ""); + N_VPrintFile(ark_mem->yn, ARK_LOGGER->debug_fp); + + if (step_mem->explicit_rhs) + { + SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, + "ARKODE::mriStep_TakeStepMRISR", "slow explicit RHS", + "Fse[0] =", ""); + N_VPrintFile(step_mem->Fse[0], ARK_LOGGER->debug_fp); + } + + if (step_mem->implicit_rhs) + { + SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, + "ARKODE::mriStep_TakeStepMRISR", "slow implicit RHS", + "Fsi[0] =", ""); + N_VPrintFile(step_mem->Fsi[0], ARK_LOGGER->debug_fp); + } +#endif + + /* The first stage is the previous time-step solution, so its RHS + is the [already-computed] slow RHS from the start of the step */ + + /* Loop over stages */ + for (stage = 1; stage <= step_mem->stages; stage++) + { + /* Solver diagnostics reporting */ +#if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_DEBUG + SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, + "ARKODE::mriStep_TakeStepMRISR", "start-stage", + "step = %li, stage = %i, h = %" RSYM, ark_mem->nst, + stage, ark_mem->h); +#endif + + /* Determine if this is an "embedding" or "solution" stage */ + solution = (stage == step_mem->stages - 1); + embedding = (stage == step_mem->stages); + + /* Skip the embedding if we're using fixed time-stepping and + temporal error estimation is disabled */ + if (ark_mem->fixedstep && embedding && (ark_mem->AccumErrorType < 0)) + { + break; + } + + /* Set initial condition for this stage */ + N_VScale(ONE, ark_mem->yn, ark_mem->ycur); + + /* Set current stage abscissa */ + cstage = (embedding) ? ONE : step_mem->MRIC->c[stage]; + + /* Compute forcing function for inner solver: temporarily + force explicit_rhs and disable implicit_rhs flag since MRISR + methods ignore the G coefficients in the forcing function. */ + store_imprhs = step_mem->implicit_rhs; + store_exprhs = step_mem->explicit_rhs; + step_mem->implicit_rhs = SUNFALSE; + step_mem->explicit_rhs = SUNTRUE; + retval = mriStep_ComputeInnerForcing(ark_mem, step_mem, stage, ark_mem->tn, + ark_mem->tn + cstage * ark_mem->h); + if (retval != ARK_SUCCESS) + { + *nflagPtr = CONV_FAIL; + break; + } + step_mem->implicit_rhs = store_imprhs; + step_mem->explicit_rhs = store_exprhs; + + /* Evolve fast IVP for this stage: + force reset due to "stage-restart" structure + potentially get inner dsm on all non-embedding stages */ + retval = mriStep_StageERKFast(ark_mem, step_mem, stage, ark_mem->tn, + ark_mem->tn + cstage * ark_mem->h, + ark_mem->ycur, ytemp, SUNTRUE, + need_inner_dsm && !embedding); + if (retval != ARK_SUCCESS) { *nflagPtr = CONV_FAIL; } + + /* set current stage time for implicit correction, postprocessing + and RHS calls */ + ark_mem->tcur = ark_mem->tn + cstage * ark_mem->h; + + /* perform MRISR slow/implicit correction */ + impl_corr = SUNFALSE; + if (step_mem->implicit_rhs) + { + /* determine whether implicit RHS correction will require an implicit solve */ + impl_corr = SUNRabs(step_mem->MRIC->G[0][stage][stage]) > tol; + + /* perform implicit solve for correction */ + if (impl_corr) + { + /* store current stage index (for an "embedded" stage, subtract 1) */ + step_mem->istage = (stage == step_mem->stages) ? stage - 1 : stage; + + /* Call predictor for current stage solution (result placed in zpred) */ + retval = mriStep_Predict(ark_mem, step_mem->istage, step_mem->zpred); + if (retval != ARK_SUCCESS) { return (retval); } + + /* If a user-supplied predictor routine is provided, call that here + Note that mriStep_Predict is *still* called, so this user-supplied + routine can just "clean up" the built-in prediction, if desired. */ + if (step_mem->stage_predict) + { + retval = step_mem->stage_predict(ark_mem->tcur, step_mem->zpred, + ark_mem->user_data); + if (retval < 0) { return (ARK_USER_PREDICT_FAIL); } + if (retval > 0) { return (TRY_AGAIN); } + } + +#ifdef SUNDIALS_LOGGING_EXTRA_DEBUG + SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, + "ARKODE::mriStep_TakeStepMRISR", "predictor", + "zpred =", ""); + N_VPrintFile(step_mem->zpred, ARK_LOGGER->debug_fp); +#endif + + /* fill sdata with explicit contributions to correction */ + step_mem->cvals[0] = ONE; + step_mem->Xvecs[0] = ark_mem->ycur; + step_mem->cvals[1] = -ONE; + step_mem->Xvecs[1] = step_mem->zpred; + for (j = 0; j < stage; j++) + { + step_mem->cvals[j + 2] = ark_mem->h * step_mem->MRIC->G[0][stage][j]; + step_mem->Xvecs[j + 2] = step_mem->Fsi[j]; + } + retval = N_VLinearCombination(stage + 2, step_mem->cvals, + step_mem->Xvecs, step_mem->sdata); + if (retval != 0) { return (ARK_VECTOROP_ERR); } + +#ifdef SUNDIALS_LOGGING_EXTRA_DEBUG + SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, + "ARKODE::mriStep_TakeStepMRISR", "rhs data", + "sdata =", ""); + N_VPrintFile(step_mem->sdata, ARK_LOGGER->debug_fp); +#endif + + /* Update gamma for implicit solver */ + step_mem->gamma = ark_mem->h * step_mem->MRIC->G[0][stage][stage]; + if (ark_mem->firststage) { step_mem->gammap = step_mem->gamma; } + step_mem->gamrat = + (ark_mem->firststage) ? ONE : step_mem->gamma / step_mem->gammap; + + /* perform implicit solve (result is stored in ark_mem->ycur); return + with positive value on anything but success */ + *nflagPtr = mriStep_Nls(ark_mem, *nflagPtr); + if (*nflagPtr != ARK_SUCCESS) { return (TRY_AGAIN); } + } + /* perform explicit update for correction */ + else + { + step_mem->cvals[0] = ONE; + step_mem->Xvecs[0] = ark_mem->ycur; + for (j = 0; j < stage; j++) + { + step_mem->cvals[j + 1] = ark_mem->h * step_mem->MRIC->G[0][stage][j]; + step_mem->Xvecs[j + 1] = step_mem->Fsi[j]; + } + retval = N_VLinearCombination(stage + 1, step_mem->cvals, + step_mem->Xvecs, ark_mem->ycur); + if (retval != 0) { return (ARK_VECTOROP_ERR); } + } + } + +#ifdef SUNDIALS_LOGGING_EXTRA_DEBUG + SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, + "ARKODE::mriStep_TakeStepMRISR", "slow stage", + "z[%i] =", stage); + N_VPrintFile(ark_mem->ycur, ARK_LOGGER->debug_fp); +#endif + + /* apply user-supplied stage postprocessing function (if supplied), + and reset the inner integrator with the modified stage solution */ + if (ark_mem->ProcessStage != NULL) + { + retval = ark_mem->ProcessStage(ark_mem->tcur, ark_mem->ycur, + ark_mem->user_data); + if (retval != 0) { return (ARK_POSTPROCESS_STAGE_FAIL); } + retval = mriStepInnerStepper_Reset(step_mem->stepper, ark_mem->tcur, + ark_mem->ycur); + if (retval != ARK_SUCCESS) + { + arkProcessError(ark_mem, ARK_INNERSTEP_FAIL, __LINE__, __func__, + __FILE__, "Unable to reset the inner stepper"); + return (ARK_INNERSTEP_FAIL); + } + } + + /* Compute updated slow RHS (except for final solution or embedding) */ + if ((!solution) && (!embedding)) + { + /* store explicit slow rhs */ + if (step_mem->explicit_rhs) + { + retval = step_mem->fse(ark_mem->tcur, ark_mem->ycur, + step_mem->Fse[stage], ark_mem->user_data); + step_mem->nfse++; + if (retval < 0) { return (ARK_RHSFUNC_FAIL); } + if (retval > 0) { return (ARK_UNREC_RHSFUNC_ERR); } + +#ifdef SUNDIALS_LOGGING_EXTRA_DEBUG + SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, + "ARKODE::mriStep_TakeStepMRISR", "slow explicit RHS", + "Fse[%i] =", stage); + N_VPrintFile(step_mem->Fse[stage], ARK_LOGGER->debug_fp); +#endif + } + + /* store implicit slow rhs */ + if (step_mem->implicit_rhs) + { + if (!step_mem->deduce_rhs || !impl_corr) + { + retval = step_mem->fsi(ark_mem->tcur, ark_mem->ycur, + step_mem->Fsi[stage], ark_mem->user_data); + step_mem->nfsi++; + } + else + { + N_VLinearSum(ONE / step_mem->gamma, step_mem->zcor, + -ONE / step_mem->gamma, step_mem->sdata, + step_mem->Fsi[stage]); + } + + if (retval < 0) { return (ARK_RHSFUNC_FAIL); } + if (retval > 0) { return (ARK_UNREC_RHSFUNC_ERR); } + +#ifdef SUNDIALS_LOGGING_EXTRA_DEBUG + SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, + "ARKODE::mriStep_TakeStepMRISR", "slow implicit RHS", + "Fsi[%i] =", stage); + N_VPrintFile(step_mem->Fsi[stage], ARK_LOGGER->debug_fp); +#endif + } + + /* combine both RHS into Fse for ImEx problems */ + if (step_mem->implicit_rhs && step_mem->explicit_rhs) + { + N_VLinearSum(ONE, step_mem->Fse[stage], ONE, step_mem->Fsi[stage], + step_mem->Fse[stage]); + } + } + + /* If this is the solution stage, archive for error estimation */ + if (solution) { N_VScale(ONE, ark_mem->ycur, ytilde); } + + } /* loop over stages */ + +#ifdef SUNDIALS_LOGGING_EXTRA_DEBUG + SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, + "ARKODE::mriStep_TakeStepMRISR", "updated solution", + "ycur =", ""); + N_VPrintFile(ark_mem->ycur, ARK_LOGGER->debug_fp); +#endif + + /* if temporal error estimation is enabled: compute estimate via difference between + step solution and embedding, store in ark_mem->tempv1, store norm in dsmPtr, and + copy solution back to ycur */ + if (!ark_mem->fixedstep || (ark_mem->AccumErrorType >= 0)) + { + N_VLinearSum(ONE, ytilde, -ONE, ark_mem->ycur, ark_mem->tempv1); + *dsmPtr = N_VWrmsNorm(ark_mem->tempv1, ark_mem->ewt); + N_VScale(ONE, ytilde, ark_mem->ycur); + } + + /* Solver diagnostics reporting */ +#if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_DEBUG + SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, + "ARKODE::mriStep_TakeStepMRISR", "end-step", + "step = %li, t = %" RSYM ", h = %" RSYM ", dsm = %" RSYM, + ark_mem->nst, ark_mem->tn, ark_mem->h, *dsmPtr); +#endif + + return (ARK_SUCCESS); +} + +/*--------------------------------------------------------------- + mriStep_TakeStepMERK: + + This routine performs a single MERK step. + + The vector ark_mem->yn holds the previous time-step solution + on input, and the vector ark_mem->ycur should hold the result + of this step on output. + + If timestep adaptivity is enabled, this routine also computes + the error estimate y-ytilde, where ytilde is the + embedded solution, and the norm weights come from ark_ewt. + This esimate is stored in ark_mem->tempv1, in case the calling + routine wishes to examine the error locations. + + The output variable dsmPtr should contain a scalar-valued + estimate of the temporal error from this step, ||y-ytilde||_WRMS + if timestep adaptivity is enabled; otherwise it should be 0. + + The input/output variable nflagPtr is used to gauge convergence + of any algebraic solvers within the step. At the start of a new + time step, this will initially have the value FIRST_CALL. On + return from this function, nflagPtr should have a value: + 0 => algebraic solve completed successfully + >0 => solve did not converge at this step size + (but may with a smaller stepsize) + <0 => solve encountered an unrecoverable failure + Since the fast-scale evolution could be considered a different + type of "algebraic solver", we similarly report any fast-scale + evolution error as a recoverable nflagPtr value. + + The return value from this routine is: + 0 => step completed successfully + >0 => step encountered recoverable failure; + reduce step and retry (if possible) + <0 => step encountered unrecoverable failure + ---------------------------------------------------------------*/ +int mriStep_TakeStepMERK(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr) +{ + ARKodeMRIStepMem step_mem; /* outer stepper memory */ + int ig; /* current stage group index */ + int is; /* stage index in group */ + int stage, nextstage; /* current/next stages */ + int retval; /* reusable return flag */ + N_Vector ytilde; /* embedded solution */ + N_Vector ytemp; /* temporary vector */ + SUNAdaptController_Type adapt_type; /* timestep adaptivity type */ + sunrealtype t0, tf; /* start/end of each stage */ + sunbooleantype embedding; /* flag indicating embedding */ + sunbooleantype solution; /* or solution stages */ + sunrealtype cstage; /* current stage abscissa */ + sunbooleantype need_inner_dsm; + + /* access the MRIStep mem structure */ + retval = mriStep_AccessStepMem(ark_mem, __func__, &step_mem); + if (retval != ARK_SUCCESS) { return (retval); } + + /* initialize algebraic solver convergence flag to success; + error estimate to zero */ + *nflagPtr = ARK_SUCCESS; + *dsmPtr = ZERO; + + /* set N_Vector shortcuts */ + ytilde = ark_mem->tempv4; + ytemp = ark_mem->tempv2; + + /* initial time for step */ + t0 = ark_mem->tn; + + /* if MRI adaptivity is enabled: reset fast accumulated error, + and send appropriate control parameter to the fast integrator */ + adapt_type = SUNAdaptController_GetType(ark_mem->hadapt_mem->hcontroller); + need_inner_dsm = SUNFALSE; + if ((adapt_type == SUN_ADAPTCONTROLLER_MRI_H) || + (adapt_type == SUN_ADAPTCONTROLLER_MRI_TOL)) + { + need_inner_dsm = SUNTRUE; + step_mem->inner_dsm = ZERO; + retval = mriStepInnerStepper_ResetError(step_mem->stepper); + if (retval != ARK_SUCCESS) + { + arkProcessError(ark_mem, ARK_INNERSTEP_FAIL, __LINE__, __func__, __FILE__, + "Unable to reset the inner stepper error estimate"); + return (ARK_INNERSTEP_FAIL); + } + } + if (adapt_type == SUN_ADAPTCONTROLLER_MRI_H) + { + retval = mriStepInnerStepper_SetFixedStep(step_mem->stepper, + step_mem->inner_control); + if (retval != ARK_SUCCESS) + { + arkProcessError(ark_mem, ARK_INNERSTEP_FAIL, __LINE__, __func__, __FILE__, + "Unable to set a fixed stepsize in the inner stepper"); + return (ARK_INNERSTEP_FAIL); + } + } + if (adapt_type == SUN_ADAPTCONTROLLER_MRI_TOL) + { + retval = + mriStepInnerStepper_SetRTol(step_mem->stepper, + step_mem->inner_control * ark_mem->reltol); + if (retval != ARK_SUCCESS) + { + arkProcessError(ark_mem, ARK_INNERSTEP_FAIL, __LINE__, __func__, __FILE__, + "Unable to set the inner stepper tolerance"); + return (ARK_INNERSTEP_FAIL); + } + } + + /* if any temporal adaptivity is enabled: reset the inner integrator + to the beginning of this step (in case of recomputation) */ + if (!ark_mem->fixedstep) + { + retval = mriStepInnerStepper_Reset(step_mem->stepper, t0, ark_mem->yn); + if (retval != ARK_SUCCESS) + { + arkProcessError(ark_mem, ARK_INNERSTEP_FAIL, __LINE__, __func__, __FILE__, + "Unable to reset the inner stepper"); + return (ARK_INNERSTEP_FAIL); + } + } + + /* Evaluate the slow RHS if needed. NOTE: We do not use the full RHS here + (unlike ERKStep and ARKStep) since it does not need to check for FSAL + or SA methods and thus avoids potentially unnecessary evaluations of the + inner (fast) RHS function */ + if (!(ark_mem->fn_is_current)) + { + retval = step_mem->fse(t0, ark_mem->yn, step_mem->Fse[0], ark_mem->user_data); + step_mem->nfse++; + if (retval) { return ARK_RHSFUNC_FAIL; } + ark_mem->fn_is_current = SUNTRUE; + } + +#ifdef SUNDIALS_DEBUG + printf(" MRIStep step %li, stage 0, h = %" RSYM ", t_n = %" RSYM "\n", + ark_mem->nst, ark_mem->h, t0); +#endif + +#ifdef SUNDIALS_LOGGING_EXTRA_DEBUG + SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, + "ARKODE::mriStep_TakeStepMERK", "slow stage", "z[0] =", ""); + N_VPrintFile(ark_mem->yn, ARK_LOGGER->debug_fp); + + if (step_mem->explicit_rhs) + { + SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, + "ARKODE::mriStep_TakeStepMERK", "slow explicit RHS", + "Fse[0] =", ""); + N_VPrintFile(step_mem->Fse[0], ARK_LOGGER->debug_fp); + } +#endif + + /* The first stage is the previous time-step solution, so its RHS + is the [already-computed] slow RHS from the start of the step */ + + /* Loop over stage groups */ + for (ig = 0; ig < step_mem->MRIC->ngroup; ig++) + { + /* Solver diagnostics reporting */ +#if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_DEBUG + SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, + "ARKODE::mriStep_TakeStepMERK", "start-stage", + "step = %li, stage group = %i, h = %" RSYM, ark_mem->nst, + ig, ark_mem->h); +#endif + + /* Set up fast RHS for this stage group */ + retval = mriStep_ComputeInnerForcing(ark_mem, step_mem, + step_mem->MRIC->group[ig][0], + ark_mem->tn, ark_mem->tn + ark_mem->h); + if (retval != ARK_SUCCESS) { return (retval); } + + /* Set initial condition for this stage group */ + N_VScale(ONE, ark_mem->yn, ark_mem->ycur); + t0 = ark_mem->tn; + + /* Evolve fast IVP over each subinterval in stage group */ + for (is = 0; is < step_mem->stages; is++) + { + /* Get stage index from group; skip to the next group if + we've reached the end of this one */ + stage = step_mem->MRIC->group[ig][is]; + if (stage < 0) { break; } + nextstage = -1; + if (stage < step_mem->stages) + { + nextstage = step_mem->MRIC->group[ig][is + 1]; + } + + /* Determine if this is an "embedding" or "solution" stage */ + embedding = solution = SUNFALSE; + if (ig == step_mem->MRIC->ngroup - 2) + { + if ((stage >= 0) && (nextstage < 0)) { embedding = SUNTRUE; } + } + if (ig == step_mem->MRIC->ngroup - 1) + { + if ((stage >= 0) && (nextstage < 0)) { solution = SUNTRUE; } + } + + /* Skip the embedding if we're using fixed time-stepping and + temporal error estimation is disabled */ + if (ark_mem->fixedstep && embedding && (ark_mem->AccumErrorType < 0)) + { + break; + } + + /* Set current stage abscissa */ + cstage = (stage >= step_mem->stages) ? ONE : step_mem->MRIC->c[stage]; + + /* Set desired output time for subinterval */ + tf = ark_mem->tn + cstage * ark_mem->h; + + /* Evolve fast IVP for this stage: + force reset on first stage in group + potentially get inner dsm on all non-embedding stages */ + retval = mriStep_StageERKFast(ark_mem, step_mem, stage, t0, tf, + ark_mem->ycur, ytemp, is == 0, + need_inner_dsm && !embedding); + if (retval != ARK_SUCCESS) { *nflagPtr = CONV_FAIL; } + + /* Update "initial time" for next stage in group */ + t0 = tf; + + /* set current stage time for postprocessing and RHS calls */ + ark_mem->tcur = tf; + +#ifdef SUNDIALS_LOGGING_EXTRA_DEBUG + SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, + "ARKODE::mriStep_TakeStepMERK", "slow stage", + "z[%i] =", stage); + N_VPrintFile(ark_mem->ycur, ARK_LOGGER->debug_fp); +#endif + + /* apply user-supplied stage postprocessing function (if supplied), + and reset the inner integrator with the modified stage solution */ + if (ark_mem->ProcessStage != NULL) + { + retval = ark_mem->ProcessStage(ark_mem->tcur, ark_mem->ycur, + ark_mem->user_data); + if (retval != 0) { return (ARK_POSTPROCESS_STAGE_FAIL); } + retval = mriStepInnerStepper_Reset(step_mem->stepper, ark_mem->tcur, + ark_mem->ycur); + if (retval != ARK_SUCCESS) + { + arkProcessError(ark_mem, ARK_INNERSTEP_FAIL, __LINE__, __func__, + __FILE__, "Unable to reset the inner stepper"); + return (ARK_INNERSTEP_FAIL); + } + } + + /* Compute updated slow RHS (except for final solution or embedding) */ + if ((!solution) && (!embedding)) + { + /* store explicit slow rhs */ + retval = step_mem->fse(ark_mem->tcur, ark_mem->ycur, + step_mem->Fse[stage], ark_mem->user_data); + step_mem->nfse++; + if (retval < 0) { return (ARK_RHSFUNC_FAIL); } + if (retval > 0) { return (ARK_UNREC_RHSFUNC_ERR); } + +#ifdef SUNDIALS_LOGGING_EXTRA_DEBUG + SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, + "ARKODE::mriStep_TakeStepMERK", "slow explicit RHS", + "Fse[%i] =", is); + N_VPrintFile(step_mem->Fse[stage], ARK_LOGGER->debug_fp); +#endif + } + + /* If this is the embedding stage, archive solution for error estimation */ + if (embedding) { N_VScale(ONE, ark_mem->ycur, ytilde); } + + } /* loop over stages */ + + } /* loop over stage groups */ + +#ifdef SUNDIALS_LOGGING_EXTRA_DEBUG + SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, + "ARKODE::mriStep_TakeStepMERK", "updated solution", + "ycur =", ""); + N_VPrintFile(ark_mem->ycur, ARK_LOGGER->debug_fp); +#endif + + /* if temporal error estimation is enabled: compute estimate via difference between + step solution and embedding, store in ark_mem->tempv1, and store norm in dsmPtr */ + if (!ark_mem->fixedstep || (ark_mem->AccumErrorType >= 0)) + { + N_VLinearSum(ONE, ytilde, -ONE, ark_mem->ycur, ark_mem->tempv1); + *dsmPtr = N_VWrmsNorm(ark_mem->tempv1, ark_mem->ewt); + } + + /* Solver diagnostics reporting */ +#if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_DEBUG + SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, + "ARKODE::mriStep_TakeStepMERK", "end-step", + "step = %li, t = %" RSYM ", h = %" RSYM ", dsm = %" RSYM, + ark_mem->nst, ark_mem->tn, ark_mem->h, *dsmPtr); +#endif + + return (ARK_SUCCESS); +} + +/*=============================================================== + Internal utility routines + ===============================================================*/ + +/*--------------------------------------------------------------- + mriStep_AccessARKODEStepMem: + + Shortcut routine to unpack ark_mem and step_mem structures from + void* pointer. If either is missing it returns ARK_MEM_NULL. + ---------------------------------------------------------------*/ +int mriStep_AccessARKODEStepMem(void* arkode_mem, const char* fname, + ARKodeMem* ark_mem, ARKodeMRIStepMem* step_mem) +{ + /* access ARKodeMem structure */ + if (arkode_mem == NULL) + { + arkProcessError(NULL, ARK_MEM_NULL, __LINE__, fname, __FILE__, + MSG_ARK_NO_MEM); + return (ARK_MEM_NULL); + } + *ark_mem = (ARKodeMem)arkode_mem; + + /* access ARKodeMRIStepMem structure */ + if ((*ark_mem)->step_mem == NULL) + { + arkProcessError(*ark_mem, ARK_MEM_NULL, __LINE__, fname, __FILE__, MSG_MRISTEP_NO_MEM); return (ARK_MEM_NULL); } @@ -1721,14 +2895,13 @@ sunbooleantype mriStep_CheckNVector(N_Vector tmpl) mriStep_SetCoupling This routine determines the MRI method to use, based on the - desired accuracy. + desired accuracy and fixed/adaptive time stepping choice. ---------------------------------------------------------------*/ int mriStep_SetCoupling(ARKodeMem ark_mem) { ARKodeMRIStepMem step_mem; sunindextype Cliw, Clrw; - int q_actual; - ARKODE_MRITableID table_id; + ARKODE_MRITableID table_id = ARKODE_MRI_NONE; /* access ARKodeMRIStepMem structure */ if (ark_mem->step_mem == NULL) @@ -1738,55 +2911,82 @@ int mriStep_SetCoupling(ARKodeMem ark_mem) return (ARK_MEM_NULL); } step_mem = (ARKodeMRIStepMem)ark_mem->step_mem; - q_actual = step_mem->q; /* if coupling has already been specified, just return */ if (step_mem->MRIC != NULL) { return (ARK_SUCCESS); } - if (q_actual < 1 || q_actual > 4) - { - arkProcessError(ark_mem, ARK_ILL_INPUT, __LINE__, __func__, __FILE__, - "No MRI method at requested order, using q=3."); - q_actual = 3; - } - /* select method based on order and type */ - - /**** ImEx methods ****/ - if (step_mem->implicit_rhs && step_mem->explicit_rhs) + if (ark_mem->fixedstep) /**** fixed-step methods ****/ { - switch (q_actual) + if (step_mem->implicit_rhs && step_mem->explicit_rhs) /**** ImEx methods ****/ { - case 1: table_id = MRISTEP_DEFAULT_IMEX_SD_1; break; - case 2: table_id = MRISTEP_DEFAULT_IMEX_SD_2; break; - case 3: table_id = MRISTEP_DEFAULT_IMEX_SD_2; break; - case 4: table_id = MRISTEP_DEFAULT_IMEX_SD_2; break; + switch (step_mem->q) + { + case 1: table_id = MRISTEP_DEFAULT_IMEX_SD_1; break; + case 2: table_id = MRISTEP_DEFAULT_IMEX_SD_2; break; + case 3: table_id = MRISTEP_DEFAULT_IMEX_SD_3; break; + case 4: table_id = MRISTEP_DEFAULT_IMEX_SD_4; break; + } } - - /**** implicit methods ****/ - } - else if (step_mem->implicit_rhs) - { - switch (q_actual) + else if (step_mem->implicit_rhs) /**** implicit methods ****/ { - case 1: table_id = MRISTEP_DEFAULT_IMPL_SD_1; break; - case 2: table_id = MRISTEP_DEFAULT_IMPL_SD_2; break; - case 3: table_id = MRISTEP_DEFAULT_IMPL_SD_3; break; - case 4: table_id = MRISTEP_DEFAULT_IMPL_SD_4; break; + switch (step_mem->q) + { + case 1: table_id = MRISTEP_DEFAULT_IMPL_SD_1; break; + case 2: table_id = MRISTEP_DEFAULT_IMPL_SD_2; break; + case 3: table_id = MRISTEP_DEFAULT_IMPL_SD_3; break; + case 4: table_id = MRISTEP_DEFAULT_IMPL_SD_4; break; + } + } + else /**** explicit methods ****/ + { + switch (step_mem->q) + { + case 1: table_id = MRISTEP_DEFAULT_EXPL_1; break; + case 2: table_id = MRISTEP_DEFAULT_EXPL_2; break; + case 3: table_id = MRISTEP_DEFAULT_EXPL_3; break; + case 4: table_id = MRISTEP_DEFAULT_EXPL_4; break; + case 5: table_id = MRISTEP_DEFAULT_EXPL_5_AD; break; + } } - - /**** explicit methods ****/ } - else + else /**** adaptive methods ****/ { - switch (q_actual) + if (step_mem->implicit_rhs && step_mem->explicit_rhs) /**** ImEx methods ****/ + { + switch (step_mem->q) + { + case 2: table_id = MRISTEP_DEFAULT_IMEX_SD_2_AD; break; + case 3: table_id = MRISTEP_DEFAULT_IMEX_SD_3_AD; break; + case 4: table_id = MRISTEP_DEFAULT_IMEX_SD_4_AD; break; + } + } + else if (step_mem->implicit_rhs) /**** implicit methods ****/ { - case 1: table_id = MRISTEP_DEFAULT_EXPL_1; break; - case 2: table_id = MRISTEP_DEFAULT_EXPL_2; break; - case 3: table_id = MRISTEP_DEFAULT_EXPL_3; break; - case 4: table_id = MRISTEP_DEFAULT_EXPL_4; break; + switch (step_mem->q) + { + case 2: table_id = MRISTEP_DEFAULT_IMPL_SD_2; break; + case 3: table_id = MRISTEP_DEFAULT_IMPL_SD_3; break; + case 4: table_id = MRISTEP_DEFAULT_IMPL_SD_4; break; + } + } + else /**** explicit methods ****/ + { + switch (step_mem->q) + { + case 2: table_id = MRISTEP_DEFAULT_EXPL_2_AD; break; + case 3: table_id = MRISTEP_DEFAULT_EXPL_3_AD; break; + case 4: table_id = MRISTEP_DEFAULT_EXPL_4_AD; break; + case 5: table_id = MRISTEP_DEFAULT_EXPL_5_AD; break; + } } } + if (table_id == ARKODE_MRI_NONE) + { + arkProcessError(ark_mem, ARK_ILL_INPUT, __LINE__, __func__, + __FILE__, "No MRI method is available for the requested configuration."); + return (ARK_ILL_INPUT); + } step_mem->MRIC = MRIStepCoupling_LoadTable(table_id); if (step_mem->MRIC == NULL) @@ -1864,8 +3064,35 @@ int mriStep_CheckCoupling(ARKodeMem ark_mem) return (ARK_INVALID_TABLE); } + /* Check that coupling table has compatible type */ + if (step_mem->implicit_rhs && step_mem->explicit_rhs && + (step_mem->MRIC->type != MRISTEP_IMEX) && + (step_mem->MRIC->type != MRISTEP_MRISR)) + { + arkProcessError(ark_mem, ARK_ILL_INPUT, __LINE__, __func__, __FILE__, + "Invalid coupling table for an IMEX problem!"); + return (ARK_ILL_INPUT); + } + if (step_mem->explicit_rhs && (step_mem->MRIC->type != MRISTEP_EXPLICIT) && + (step_mem->MRIC->type != MRISTEP_IMEX) && + (step_mem->MRIC->type != MRISTEP_MERK) && + (step_mem->MRIC->type != MRISTEP_MRISR)) + { + arkProcessError(ark_mem, ARK_ILL_INPUT, __LINE__, __func__, __FILE__, + "Invalid coupling table for an explicit problem!"); + return (ARK_ILL_INPUT); + } + if (step_mem->implicit_rhs && (step_mem->MRIC->type != MRISTEP_IMPLICIT) && + (step_mem->MRIC->type != MRISTEP_IMEX) && + (step_mem->MRIC->type != MRISTEP_MRISR)) + { + arkProcessError(ark_mem, ARK_ILL_INPUT, __LINE__, __func__, __FILE__, + "Invalid coupling table for an implicit problem!"); + return (ARK_ILL_INPUT); + } + /* Check that the matrices are defined appropriately */ - if (step_mem->implicit_rhs && step_mem->explicit_rhs) + if (step_mem->MRIC->type == MRISTEP_IMEX) { /* ImEx */ if (!(step_mem->MRIC->W) || !(step_mem->MRIC->G)) @@ -1875,7 +3102,7 @@ int mriStep_CheckCoupling(ARKodeMem ark_mem) return (ARK_ILL_INPUT); } } - else if (step_mem->explicit_rhs) + else if (step_mem->MRIC->type == MRISTEP_EXPLICIT) { /* Explicit */ if (!(step_mem->MRIC->W) || step_mem->MRIC->G) @@ -1885,7 +3112,7 @@ int mriStep_CheckCoupling(ARKodeMem ark_mem) return (ARK_ILL_INPUT); } } - else + else if (step_mem->MRIC->type == MRISTEP_IMPLICIT) { /* Implicit */ if (step_mem->MRIC->W || !(step_mem->MRIC->G)) @@ -1956,20 +3183,25 @@ int mriStep_CheckCoupling(ARKodeMem ark_mem) return (ARK_INVALID_TABLE); } - /* check that stage times are sorted */ - okay = SUNTRUE; - for (i = 1; i < step_mem->MRIC->stages; i++) + /* check that MRI-GARK stage times are sorted */ + if ((step_mem->MRIC->type == MRISTEP_IMPLICIT) || + (step_mem->MRIC->type == MRISTEP_EXPLICIT) || + (step_mem->MRIC->type == MRISTEP_IMEX)) { - if ((step_mem->MRIC->c[i] - step_mem->MRIC->c[i - 1]) < -tol) + okay = SUNTRUE; + for (i = 1; i < step_mem->MRIC->stages; i++) { - okay = SUNFALSE; + if ((step_mem->MRIC->c[i] - step_mem->MRIC->c[i - 1]) < -tol) + { + okay = SUNFALSE; + } + } + if (!okay) + { + arkProcessError(ark_mem, ARK_INVALID_TABLE, __LINE__, __func__, __FILE__, + "Stage times must be sorted."); + return (ARK_INVALID_TABLE); } - } - if (!okay) - { - arkProcessError(ark_mem, ARK_INVALID_TABLE, __LINE__, __func__, __FILE__, - "Stage times must be sorted."); - return (ARK_INVALID_TABLE); } /* check that the first stage is just the old step solution */ @@ -2003,50 +3235,171 @@ int mriStep_CheckCoupling(ARKodeMem ark_mem) /*--------------------------------------------------------------- mriStep_StageERKFast - This routine performs a single MRI stage with explicit slow - time scale and fast time scale that requires evolution. + This routine performs a single MRI stage, is, with explicit + slow time scale and fast time scale that requires evolution. + + On input, ycur is the initial condition for the fast IVP at t0. + On output, ycur is the solution of the fast IVP at tf. + The vector ytemp is only used if temporal adaptivity is enabled, + and the fast error is not provided by the fast integrator. + + force_reset indicates whether ycur differs from the result of + the previous fast evolution, in which case the inner integrator + needs to be reset. + + get_inner_dsm indicates whether this stage is one that should + accumulate an inner temporal error estimate. ---------------------------------------------------------------*/ -int mriStep_StageERKFast(ARKodeMem ark_mem, ARKodeMRIStepMem step_mem, int is) +int mriStep_StageERKFast(ARKodeMem ark_mem, ARKodeMRIStepMem step_mem, int is, + sunrealtype t0, sunrealtype tf, N_Vector ycur, + N_Vector ytemp, sunbooleantype force_reset, + sunbooleantype get_inner_dsm) { - sunrealtype cdiff; /* stage time increment */ - sunrealtype t0; /* start time for stage */ - int retval; /* reusable return flag */ + int retval; /* reusable return flag */ + SUNAdaptController_Type adapt_type; /* timestep adaptivity type */ #ifdef SUNDIALS_DEBUG printf(" MRIStep ERK fast stage\n"); #endif - /* Set initial time for fast evolution */ - t0 = ark_mem->tn + step_mem->MRIC->c[is - 1] * ark_mem->h; + /* pre inner evolve function (if supplied) */ + if (step_mem->pre_inner_evolve) + { + retval = step_mem->pre_inner_evolve(t0, step_mem->stepper->forcing, + step_mem->stepper->nforcing, + ark_mem->user_data); + if (retval != 0) { return (ARK_OUTERTOINNER_FAIL); } + } + + /* if the input state has changed since last called, reset the inner integrator */ + if (force_reset) + { + retval = mriStepInnerStepper_Reset(step_mem->stepper, t0, ycur); + if (retval != ARK_SUCCESS) + { + arkProcessError(ark_mem, ARK_INNERSTEP_FAIL, __LINE__, __func__, __FILE__, + "Unable to reset the inner stepper"); + return (ARK_INNERSTEP_FAIL); + } + } + + /* Get the adaptivity type (if applicable) */ + adapt_type = (get_inner_dsm) + ? SUNAdaptController_GetType(ark_mem->hadapt_mem->hcontroller) + : SUN_ADAPTCONTROLLER_NONE; + + /* if we'll need to manually accumulate the fast error estimate, archive the + current state to provide an initial condition for the ``fast embedding'' */ + if ((get_inner_dsm) && (adapt_type == SUN_ADAPTCONTROLLER_MRI_H) && + (step_mem->inner_hfactor != ZERO)) + { + N_VScale(ONE, ycur, ytemp); + } + + /* advance inner method in time */ + retval = mriStepInnerStepper_Evolve(step_mem->stepper, t0, tf, ycur); + if (retval != ARK_SUCCESS) + { + arkProcessError(ark_mem, ARK_INNERSTEP_FAIL, __LINE__, __func__, __FILE__, + "Failure when evolving the inner stepper"); + return (ARK_INNERSTEP_FAIL); + } + + /* for normal stages with MRI adaptivity enabled, get an + estimate for the fast time scale error */ + if (get_inner_dsm) + { + /* if the fast integrator uses adaptive steps, retrieve the error estimate */ + if (adapt_type == SUN_ADAPTCONTROLLER_MRI_TOL) + { + retval = mriStepInnerStepper_GetError(step_mem->stepper, + &(step_mem->inner_dsm)); + if (retval != ARK_SUCCESS) + { + arkProcessError(ark_mem, ARK_INNERSTEP_FAIL, __LINE__, __func__, + __FILE__, "Unable to get accumulated error from the inner stepper"); + return (ARK_INNERSTEP_FAIL); + } + } + + /* the fast integrator uses fixed steps */ + if (adapt_type == SUN_ADAPTCONTROLLER_MRI_H) + { + /* if we trust inner integrator accumulated error estimate, call it here */ + if (step_mem->inner_hfactor == ZERO) + { + retval = mriStepInnerStepper_GetError(step_mem->stepper, + &(step_mem->inner_dsm)); + if (retval != ARK_SUCCESS) + { + arkProcessError(ark_mem, ARK_INNERSTEP_FAIL, __LINE__, __func__, + __FILE__, "Unable to get accumulated error from the inner stepper"); + return (ARK_INNERSTEP_FAIL); + } + } + else /* manually accumulate fast error estimate */ + { + /* reset fast integrator for time interval */ + retval = mriStepInnerStepper_Reset(step_mem->stepper, t0, ytemp); + if (retval != ARK_SUCCESS) + { + arkProcessError(ark_mem, ARK_INNERSTEP_FAIL, __LINE__, __func__, + __FILE__, "Unable to reset the inner stepper"); + return (ARK_INNERSTEP_FAIL); + } - /* compute the inner forcing */ - cdiff = step_mem->MRIC->c[is] - step_mem->MRIC->c[is - 1]; - retval = mriStep_ComputeInnerForcing(ark_mem, step_mem, is, cdiff); - if (retval != ARK_SUCCESS) { return (retval); } + /* update fixed-step size for fast integrator */ + retval = mriStepInnerStepper_SetFixedStep(step_mem->stepper, + step_mem->inner_control * + step_mem->inner_hfactor); + if (retval != ARK_SUCCESS) + { + arkProcessError(ark_mem, ARK_INNERSTEP_FAIL, __LINE__, __func__, + __FILE__, "Unable to set a fixed stepsize in the inner stepper"); + return (ARK_INNERSTEP_FAIL); + } - /* Set inner forcing time normalization constants */ - step_mem->stepper->tshift = t0; - step_mem->stepper->tscale = cdiff * ark_mem->h; + /* evolve fast integrator using modified step size */ + retval = mriStepInnerStepper_Evolve(step_mem->stepper, t0, tf, ytemp); + if (retval != ARK_SUCCESS) + { + arkProcessError(ark_mem, ARK_INNERSTEP_FAIL, __LINE__, __func__, + __FILE__, "Failure when evolving the inner stepper"); + return (ARK_INNERSTEP_FAIL); + } - /* pre inner evolve function (if supplied) */ - if (step_mem->pre_inner_evolve) - { - retval = step_mem->pre_inner_evolve(t0, step_mem->stepper->forcing, - step_mem->stepper->nforcing, - ark_mem->user_data); - if (retval != 0) { return (ARK_OUTERTOINNER_FAIL); } - } + /* compute solution difference */ + N_VLinearSum(ONE, ytemp, -ONE, ycur, ytemp); - /* advance inner method in time */ - retval = mriStepInnerStepper_Evolve(step_mem->stepper, t0, ark_mem->tcur, - ark_mem->ycur); - if (retval != 0) { return (ARK_INNERSTEP_FAIL); } + /* accumulate fast error estimate */ + step_mem->inner_dsm = + SUNMAX(step_mem->inner_dsm, + ark_mem->reltol * N_VWrmsNorm(ytemp, ark_mem->ewt)); + + /* reset fast integrator to the main evolution result */ + retval = mriStepInnerStepper_Reset(step_mem->stepper, tf, ycur); + if (retval != ARK_SUCCESS) + { + arkProcessError(ark_mem, ARK_INNERSTEP_FAIL, __LINE__, __func__, + __FILE__, "Unable to reset the inner stepper"); + return (ARK_INNERSTEP_FAIL); + } + retval = mriStepInnerStepper_SetFixedStep(step_mem->stepper, + step_mem->inner_control); + if (retval != ARK_SUCCESS) + { + arkProcessError(ark_mem, ARK_INNERSTEP_FAIL, __LINE__, __func__, + __FILE__, "Unable to set a fixed stepsize in the inner stepper"); + return (ARK_INNERSTEP_FAIL); + } + } /* if (step_mem->inner_hfactor == ZERO) */ + } /* if (adapt_type == SUN_ADAPTCONTROLLER_MRI_H) */ + } /* if (get_inner_dsm) */ /* post inner evolve function (if supplied) */ if (step_mem->post_inner_evolve) { - retval = step_mem->post_inner_evolve(ark_mem->tcur, ark_mem->ycur, - ark_mem->user_data); + retval = step_mem->post_inner_evolve(tf, ycur, ark_mem->user_data); if (retval != 0) { return (ARK_INNERTOOUTER_FAIL); } } @@ -2068,16 +3421,17 @@ int mriStep_StageERKNoFast(ARKodeMem ark_mem, ARKodeMRIStepMem step_mem, int is) printf(" MRIStep ERK stage\n"); #endif - /* determine effective ERK coefficients (store in cvals) */ + /* determine effective ERK coefficients (store in Ae_row and Ai_row) */ retval = mriStep_RKCoeffs(step_mem->MRIC, is, step_mem->stage_map, step_mem->Ae_row, step_mem->Ai_row); if (retval != ARK_SUCCESS) { return (retval); } - /* call fused vector operation to perform ERK update */ + /* call fused vector operation to perform ERK update -- bound on + j needs "SUNMIN" to handle the case of an "embedding" stage */ step_mem->cvals[0] = ONE; step_mem->Xvecs[0] = ark_mem->ycur; nvec = 1; - for (j = 0; j < is; j++) + for (j = 0; j < SUNMIN(is, step_mem->stages); j++) { if (step_mem->explicit_rhs && step_mem->stage_map[j] > -1) { @@ -2140,16 +3494,16 @@ int mriStep_StageDIRKNoFast(ARKodeMem ark_mem, ARKodeMRIStepMem step_mem, printf(" MRIStep DIRK stage\n"); #endif - /* store current stage index */ - step_mem->istage = is; + /* store current stage index (for an "embedded" stage, subtract 1) */ + step_mem->istage = (is == step_mem->stages) ? is - 1 : is; /* Call predictor for current stage solution (result placed in zpred) */ - retval = mriStep_Predict(ark_mem, is, step_mem->zpred); + retval = mriStep_Predict(ark_mem, step_mem->istage, step_mem->zpred); if (retval != ARK_SUCCESS) { return (retval); } /* If a user-supplied predictor routine is provided, call that here Note that mriStep_Predict is *still* called, so this user-supplied - routine can just 'clean up' the built-in prediction, if desired. */ + routine can just "clean up" the built-in prediction, if desired. */ if (step_mem->stage_predict) { retval = step_mem->stage_predict(ark_mem->tcur, step_mem->zpred, @@ -2161,7 +3515,7 @@ int mriStep_StageDIRKNoFast(ARKodeMem ark_mem, ARKodeMRIStepMem step_mem, #ifdef SUNDIALS_LOGGING_EXTRA_DEBUG SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, "ARKODE::mriStep_StageDIRKNoFast", "predictor", - "zpred(:) =", ""); + "zpred =", ""); N_VPrintFile(step_mem->zpred, ARK_LOGGER->debug_fp); #endif @@ -2177,7 +3531,7 @@ int mriStep_StageDIRKNoFast(ARKodeMem ark_mem, ARKodeMRIStepMem step_mem, #ifdef SUNDIALS_LOGGING_EXTRA_DEBUG SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, "ARKODE::mriStep_StageDIRKNoFast", "rhs data", - "sdata(:) =", ""); + "sdata =", ""); N_VPrintFile(step_mem->sdata, ARK_LOGGER->debug_fp); #endif @@ -2193,18 +3547,19 @@ int mriStep_StageDIRKNoFast(ARKodeMem ark_mem, ARKodeMRIStepMem step_mem, mriStep_ComputeInnerForcing Constructs the 'coefficient' vectors for the forcing polynomial - for a 'fast' outer MRI stage i: + for a 'fast' outer MRI-GARK stage i: p_i(theta) = sum_{k=0}^{n-1} forcing[k] * theta^k - where theta = (t - t0) / (cdiff*h) is the mapped 'time' for + where theta = (t - t0) / (tf-t0) is the mapped 'time' for each 'fast' MRIStep evolution, with: * t0 -- the start of this outer MRIStep stage - * cdiff*h, the temporal width of this MRIStep stage + * tf-t0, the temporal width of this MRIStep stage * n -- shorthand for MRIC->nmat - explicit and solve-decoupled implicit or IMEX MRI-based methods - define this forcing polynomial for each outer stage i > 0: + Defining cdiff = (tf-t0)/h, explicit and solve-decoupled + implicit or IMEX MRI-based methods define this forcing polynomial + for each outer stage i > 0: p_i(theta) = w_i,0(theta) * fse_0 + ... + w_i,{i-1}(theta) * fse_{i-1} + g_i,0(theta) * fsi_0 + ... + g_i,{i-1}(theta) * fsi_{i-1} @@ -2240,13 +3595,42 @@ int mriStep_StageDIRKNoFast(ARKodeMem ark_mem, ARKodeMRIStepMem step_mem, ( W[k][i][0] * fse_0 + ... + W[k][i][i-1] * fse_{i-1} + ( G[k][i][0] * fsi_0 + ... + G[k][i][i-1] * fsi_{i-1} ) + We may use an identical formula for MERK methods, so long as we set t0=tn, + tf=tn+h, stage_map[j]=j (identity map), and implicit_rhs=SUNFALSE. + With this configuration: tf-t0=h, theta = (t-tn)/h, and cdiff=1. MERK methods + define the forcing polynomial for each outer stage i > 0 as: + + p_i(theta) = w_i,0(theta) * fse_0 + ... + w_i,{i-1}(theta) * fse_{i-1} + + where + + w_i,j(theta) = w_0,i,j + w_1,i,j * theta + ... + w_n,i,j * theta^{n-1}, + w_k,i,j = MRIC->W[k][i][j] + + which is equivalent to the formula above. + + We may use a similar formula for MRISR methods, so long as we set t0=tn, + tf=tn+h*ci, stage_map[j]=j (identity map), and implicit_rhs=SUNFALSE. + With this configuration: tf-t0=ci*h, theta = (t-tn)/(ci*h), and cdiff=1/ci. + MRISR methods define the forcing polynomial for each outer stage i > 0 as: + + p_i(theta) = w_i,0(theta) * fs_0 + ... + w_i,{i-1}(theta) * fs_{i-1} + + where fs_j = fse_j + fsi_j and + + w_i,j(theta) = w_0,i,j + w_1,i,j * theta + ... + w_n,i,j * theta^{n-1}, + w_k,i,j = 1/ci * MRIC->W[k][i][j] + + which is equivalent to the formula above, so long as the stage RHS vectors + Fse[j] are repurposed to instead store (fse_j + fsi_j). + This routine additionally returns a success/failure flag: ARK_SUCCESS -- successful evaluation ---------------------------------------------------------------*/ int mriStep_ComputeInnerForcing(SUNDIALS_MAYBE_UNUSED ARKodeMem ark_mem, ARKodeMRIStepMem step_mem, int stage, - sunrealtype cdiff) + sunrealtype t0, sunrealtype tf) { sunrealtype rcdiff; int j, k, nmat, nstore, retval; @@ -2257,9 +3641,13 @@ int mriStep_ComputeInnerForcing(SUNDIALS_MAYBE_UNUSED ARKodeMem ark_mem, cvals = step_mem->cvals; Xvecs = step_mem->Xvecs; + /* Set inner forcing time normalization constants */ + step_mem->stepper->tshift = t0; + step_mem->stepper->tscale = tf - t0; + /* compute inner forcing vectors (assumes cdiff != 0) */ nstore = 0; - for (j = 0; j < stage; j++) + for (j = 0; j < SUNMIN(stage, step_mem->stages); j++) { if (step_mem->explicit_rhs && step_mem->stage_map[j] > -1) { @@ -2274,12 +3662,12 @@ int mriStep_ComputeInnerForcing(SUNDIALS_MAYBE_UNUSED ARKodeMem ark_mem, } nmat = step_mem->MRIC->nmat; - rcdiff = ONE / cdiff; + rcdiff = ark_mem->h / (tf - t0); for (k = 0; k < nmat; k++) { nstore = 0; - for (j = 0; j < stage; j++) + for (j = 0; j < SUNMIN(stage, step_mem->stages); j++) { if (step_mem->stage_map[j] > -1) { @@ -2316,7 +3704,7 @@ int mriStep_ComputeInnerForcing(SUNDIALS_MAYBE_UNUSED ARKodeMem ark_mem, { SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, "ARKODE::mriStep_ComputeInnerForcing", "forcing", - "forcing_%i(:) =", k); + "forcing[%i] =", k); N_VPrintFile(step_mem->stepper->forcing[k], ARK_LOGGER->debug_fp); } #endif @@ -2325,9 +3713,8 @@ int mriStep_ComputeInnerForcing(SUNDIALS_MAYBE_UNUSED ARKodeMem ark_mem, } /*--------------------------------------------------------------- - Compute/return the 'effective' RK coefficients for a 'nofast' - stage. It is assumed that the array 'A' has already been - allocated to have length MRIC->stages. + Compute/return the effective RK coefficients for a "nofast" + stage. We may assume that "A" has already been allocated. ---------------------------------------------------------------*/ int mriStep_RKCoeffs(MRIStepCoupling MRIC, int is, int* stage_map, @@ -2336,7 +3723,7 @@ int mriStep_RKCoeffs(MRIStepCoupling MRIC, int is, int* stage_map, int j, k; sunrealtype kconst; - if (is < 1 || is >= MRIC->stages || !stage_map || !Ae_row || !Ai_row) + if (is < 1 || is > MRIC->stages || !stage_map || !Ae_row || !Ai_row) { return ARK_INVALID_TABLE; } @@ -2348,13 +3735,14 @@ int mriStep_RKCoeffs(MRIStepCoupling MRIC, int is, int* stage_map, Ai_row[j] = ZERO; } - /* compute RK coefficients */ + /* compute RK coefficients -- note that bounds on j need + "SUNMIN" to handle the case of an "embedding" stage */ for (k = 0; k < MRIC->nmat; k++) { kconst = ONE / (k + ONE); if (MRIC->W) { - for (j = 0; j < is; j++) + for (j = 0; j < SUNMIN(is, MRIC->stages - 1); j++) { if (stage_map[j] > -1) { @@ -2364,7 +3752,7 @@ int mriStep_RKCoeffs(MRIStepCoupling MRIC, int is, int* stage_map, } if (MRIC->G) { - for (j = 0; j <= is; j++) + for (j = 0; j <= SUNMIN(is, MRIC->stages - 1); j++) { if (stage_map[j] > -1) { @@ -2554,10 +3942,8 @@ int mriStep_StageSetup(ARKodeMem ark_mem) step_mem->gamma = ark_mem->h * step_mem->Ai_row[step_mem->stage_map[i]]; if (ark_mem->firststage) { step_mem->gammap = step_mem->gamma; } - step_mem->gamrat = (ark_mem->firststage) - ? ONE - : step_mem->gamma / - step_mem->gammap; /* protect x/x != 1.0 */ + step_mem->gamrat = (ark_mem->firststage) ? ONE + : step_mem->gamma / step_mem->gammap; /* set cvals and Xvecs for setting stage data */ cvals[0] = ONE; @@ -2590,6 +3976,130 @@ int mriStep_StageSetup(ARKodeMem ark_mem) return (ARK_SUCCESS); } +/*--------------------------------------------------------------- + mriStep_SlowRHS: + + Wrapper routine to call the user-supplied slow RHS functions, + f(t,y) = fse(t,y) + fsi(t,y), with API matching + ARKTimestepFullRHSFn. This is only used to determine an + initial slow time-step size to use when one is not specified + by the user (i.e., mode should correspond with + ARK_FULLRHS_OTHER. + ---------------------------------------------------------------*/ +int mriStep_SlowRHS(ARKodeMem ark_mem, sunrealtype t, N_Vector y, N_Vector f, + int mode) +{ + ARKodeMRIStepMem step_mem; + int retval; + + /* access ARKodeMRIStepMem structure */ + retval = mriStep_AccessStepMem(ark_mem, __func__, &step_mem); + if (retval != ARK_SUCCESS) { return (retval); } + + /* call fse if the problem has an explicit component */ + if (step_mem->explicit_rhs) + { + retval = step_mem->fse(t, y, step_mem->Fse[0], ark_mem->user_data); + step_mem->nfse++; + if (retval != 0) + { + arkProcessError(ark_mem, ARK_RHSFUNC_FAIL, __LINE__, __func__, __FILE__, + MSG_ARK_RHSFUNC_FAILED, t); + return (ARK_RHSFUNC_FAIL); + } + } + + /* call fsi if the problem has an implicit component */ + if (step_mem->implicit_rhs) + { + retval = step_mem->fsi(t, y, step_mem->Fsi[0], ark_mem->user_data); + step_mem->nfsi++; + if (retval != 0) + { + arkProcessError(ark_mem, ARK_RHSFUNC_FAIL, __LINE__, __func__, __FILE__, + MSG_ARK_RHSFUNC_FAILED, t); + return (ARK_RHSFUNC_FAIL); + } + } + + /* combine RHS vectors into output */ + if (step_mem->explicit_rhs && step_mem->implicit_rhs) /* ImEx */ + { + N_VLinearSum(ONE, step_mem->Fse[0], ONE, step_mem->Fsi[0], f); + } + else + { + if (step_mem->implicit_rhs) { N_VScale(ONE, step_mem->Fsi[0], f); } + else { N_VScale(ONE, step_mem->Fse[0], f); } + } + + return (ARK_SUCCESS); +} + +/*--------------------------------------------------------------- + mriStep_FastRHS: + + This is just a wrapper to call the fast RHS function, + f(t,y) = ff(t,y), with API matching ARKTimestepFullRHSFn. This + is only used to determine an initial fast time-step size to use + when one is not specified by the user and H-H MRI time step + adaptivity is enabled. + ---------------------------------------------------------------*/ +int mriStep_FastRHS(ARKodeMem ark_mem, sunrealtype t, N_Vector y, N_Vector f, + int mode) +{ + ARKodeMRIStepMem step_mem; + int retval; + + /* access ARKodeMRIStepMem structure */ + retval = mriStep_AccessStepMem(ark_mem, __func__, &step_mem); + if (retval != ARK_SUCCESS) { return (retval); } + + /* call ff */ + retval = mriStepInnerStepper_FullRhs(step_mem->stepper, t, y, f, + ARK_FULLRHS_OTHER); + if (retval != ARK_SUCCESS) + { + arkProcessError(ark_mem, ARK_RHSFUNC_FAIL, __LINE__, __func__, __FILE__, + MSG_ARK_RHSFUNC_FAILED, t); + return (ARK_RHSFUNC_FAIL); + } + + return (ARK_SUCCESS); +} + +/*--------------------------------------------------------------- + mriStep_Hin + + This routine computes a tentative initial step size h0. This + employs the same safeguards as ARKODE's arkHin utility routine, + but employs a simpler algorithm that estimates the first step + such that an explicit Euler step (for only the slow RHS + routine(s)) would be within user-specified tolerances of the + initial condition. + ---------------------------------------------------------------*/ +int mriStep_Hin(ARKodeMem ark_mem, sunrealtype tcur, sunrealtype tout, + N_Vector ycur, N_Vector fcur, N_Vector ytmp, N_Vector temp1, + N_Vector temp2, ARKTimestepFullRHSFn rhs, sunrealtype* h) +{ + int sign; + sunrealtype tdiff, tdist, tround, fnorm, h0_inv; + + /* If tout is too close to tn, give up */ + if ((tdiff = tout - tcur) == ZERO) { return (ARK_TOO_CLOSE); } + sign = (tdiff > ZERO) ? 1 : -1; + tdist = SUNRabs(tdiff); + tround = ark_mem->uround * SUNMAX(SUNRabs(tcur), SUNRabs(tout)); + if (tdist < TWO * tround) { return (ARK_TOO_CLOSE); } + + /* h0 should bound the change due to a forward Euler step, and + include safeguard against "too-small" ||f(t0,y0)||: */ + fnorm = N_VWrmsNorm(fcur, ark_mem->ewt) / H0_BIAS; + h0_inv = SUNMAX(ONE / H0_UBFACTOR / tdist, fnorm); + *h = sign / h0_inv; + return (ARK_SUCCESS); +} + /*=============================================================== User-callable functions for a custom inner integrator ===============================================================*/ @@ -2734,6 +4244,94 @@ int MRIStepInnerStepper_SetResetFn(MRIStepInnerStepper stepper, return ARK_SUCCESS; } +int MRIStepInnerStepper_SetAccumulatedErrorGetFn(MRIStepInnerStepper stepper, + MRIStepInnerGetAccumulatedError fn) +{ + if (stepper == NULL) + { + arkProcessError(NULL, ARK_ILL_INPUT, __LINE__, __func__, __FILE__, + "Inner stepper memory is NULL"); + return ARK_ILL_INPUT; + } + + if (stepper->ops == NULL) + { + arkProcessError(NULL, ARK_ILL_INPUT, __LINE__, __func__, __FILE__, + "Inner stepper operations structure is NULL"); + return ARK_ILL_INPUT; + } + + stepper->ops->geterror = fn; + + return ARK_SUCCESS; +} + +int MRIStepInnerStepper_SetAccumulatedErrorResetFn( + MRIStepInnerStepper stepper, MRIStepInnerResetAccumulatedError fn) +{ + if (stepper == NULL) + { + arkProcessError(NULL, ARK_ILL_INPUT, __LINE__, __func__, __FILE__, + "Inner stepper memory is NULL"); + return ARK_ILL_INPUT; + } + + if (stepper->ops == NULL) + { + arkProcessError(NULL, ARK_ILL_INPUT, __LINE__, __func__, __FILE__, + "Inner stepper operations structure is NULL"); + return ARK_ILL_INPUT; + } + + stepper->ops->reseterror = fn; + + return ARK_SUCCESS; +} + +int MRIStepInnerStepper_SetFixedStepFn(MRIStepInnerStepper stepper, + MRIStepInnerSetFixedStep fn) +{ + if (stepper == NULL) + { + arkProcessError(NULL, ARK_ILL_INPUT, __LINE__, __func__, __FILE__, + "Inner stepper memory is NULL"); + return ARK_ILL_INPUT; + } + + if (stepper->ops == NULL) + { + arkProcessError(NULL, ARK_ILL_INPUT, __LINE__, __func__, __FILE__, + "Inner stepper operations structure is NULL"); + return ARK_ILL_INPUT; + } + + stepper->ops->setfixedstep = fn; + + return ARK_SUCCESS; +} + +int MRIStepInnerStepper_SetRTolFn(MRIStepInnerStepper stepper, + MRIStepInnerSetRTol fn) +{ + if (stepper == NULL) + { + arkProcessError(NULL, ARK_ILL_INPUT, __LINE__, __func__, __FILE__, + "Inner stepper memory is NULL"); + return ARK_ILL_INPUT; + } + + if (stepper->ops == NULL) + { + arkProcessError(NULL, ARK_ILL_INPUT, __LINE__, __func__, __FILE__, + "Inner stepper operations structure is NULL"); + return ARK_ILL_INPUT; + } + + stepper->ops->setrtol = fn; + + return ARK_SUCCESS; +} + int MRIStepInnerStepper_AddForcing(MRIStepInnerStepper stepper, sunrealtype t, N_Vector f) { @@ -2800,6 +4398,33 @@ int mriStepInnerStepper_HasRequiredOps(MRIStepInnerStepper stepper) else { return ARK_ILL_INPUT; } } +/* Check whether stepper supports fast/slow stepsize adaptivity */ +sunbooleantype mriStepInnerStepper_SupportsStepAdaptivity(MRIStepInnerStepper stepper) +{ + if (stepper == NULL) { return SUNFALSE; } + if (stepper->ops == NULL) { return SUNFALSE; } + + if (stepper->ops->geterror && stepper->ops->reseterror && + stepper->ops->setfixedstep) + { + return SUNTRUE; + } + else { return SUNFALSE; } +} + +/* Check whether stepper supports fast/slow tolerance adaptivity */ +sunbooleantype mriStepInnerStepper_SupportsRTolAdaptivity(MRIStepInnerStepper stepper) +{ + if (stepper == NULL) { return SUNFALSE; } + if (stepper->ops == NULL) { return SUNFALSE; } + + if (stepper->ops->geterror && stepper->ops->reseterror && stepper->ops->setrtol) + { + return SUNTRUE; + } + else { return SUNFALSE; } +} + /* Evolve the inner (fast) ODE */ int mriStepInnerStepper_Evolve(MRIStepInnerStepper stepper, sunrealtype t0, sunrealtype tout, N_Vector y) @@ -2808,7 +4433,7 @@ int mriStepInnerStepper_Evolve(MRIStepInnerStepper stepper, sunrealtype t0, if (stepper->ops == NULL) { return ARK_ILL_INPUT; } if (stepper->ops->evolve == NULL) { return ARK_ILL_INPUT; } -#if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_DEBUG +#if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_INFO SUNLogger_QueueMsg(stepper->sunctx->logger, SUN_LOGLEVEL_INFO, "ARKODE::mriStepInnerStepper_Evolve", "start-inner-evolve", "t0 = %" RSYM ", tout = %" RSYM, t0, tout); @@ -2816,7 +4441,7 @@ int mriStepInnerStepper_Evolve(MRIStepInnerStepper stepper, sunrealtype t0, stepper->last_flag = stepper->ops->evolve(stepper, t0, tout, y); -#if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_DEBUG +#if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_INFO SUNLogger_QueueMsg(stepper->sunctx->logger, SUN_LOGLEVEL_INFO, "ARKODE::mriStepInnerStepper_Evolve", "end-inner-evolve", "flag = %i", stepper->last_flag); @@ -2864,6 +4489,80 @@ int mriStepInnerStepper_Reset(MRIStepInnerStepper stepper, sunrealtype tR, } } +/* Gets the inner (fast) stepper accumulated error */ +int mriStepInnerStepper_GetError(MRIStepInnerStepper stepper, + sunrealtype* accum_error) +{ + if (stepper == NULL) { return ARK_ILL_INPUT; } + if (stepper->ops == NULL) { return ARK_ILL_INPUT; } + + if (stepper->ops->geterror) + { + stepper->last_flag = stepper->ops->geterror(stepper, accum_error); + return stepper->last_flag; + } + else + { + /* assume stepper provides exact solution */ + *accum_error = SUN_RCONST(0.0); + return ARK_SUCCESS; + } +} + +/* Resets the inner (fast) stepper accumulated error */ +int mriStepInnerStepper_ResetError(MRIStepInnerStepper stepper) +{ + if (stepper == NULL) { return ARK_ILL_INPUT; } + if (stepper->ops == NULL) { return ARK_ILL_INPUT; } + + if (stepper->ops->geterror) + { + stepper->last_flag = stepper->ops->reseterror(stepper); + return stepper->last_flag; + } + else + { + /* assume stepper provides exact solution and needs no reset */ + return ARK_SUCCESS; + } +} + +/* Sets the inner (fast) stepper fixed step size */ +int mriStepInnerStepper_SetFixedStep(MRIStepInnerStepper stepper, sunrealtype h) +{ + if (stepper == NULL) { return ARK_ILL_INPUT; } + if (stepper->ops == NULL) { return ARK_ILL_INPUT; } + + if (stepper->ops->setfixedstep) + { + stepper->last_flag = stepper->ops->setfixedstep(stepper, h); + return stepper->last_flag; + } + else + { + /* assume stepper provides exact solution using infinitesimally small step */ + return ARK_SUCCESS; + } +} + +/* Sets the inner (fast) stepper relative tolerance scaling factor */ +int mriStepInnerStepper_SetRTol(MRIStepInnerStepper stepper, sunrealtype rtol) +{ + if (stepper == NULL) { return ARK_ILL_INPUT; } + if (stepper->ops == NULL) { return ARK_ILL_INPUT; } + + if (stepper->ops->setrtol) + { + stepper->last_flag = stepper->ops->setrtol(stepper, rtol); + return stepper->last_flag; + } + else + { + /* assume stepper provides exact solution */ + return ARK_SUCCESS; + } +} + /* Allocate MRI forcing and fused op workspace vectors if necessary */ int mriStepInnerStepper_AllocVecs(MRIStepInnerStepper stepper, int count, N_Vector tmpl) diff --git a/src/arkode/arkode_mristep_controller.c b/src/arkode/arkode_mristep_controller.c new file mode 100644 index 0000000000..027184bdcf --- /dev/null +++ b/src/arkode/arkode_mristep_controller.c @@ -0,0 +1,197 @@ +/* ----------------------------------------------------------------------------- + * Programmer(s): David J. Gardner @ LLNL + * Daniel R. Reynolds @ SMU + * Rujeko Chinomona @ SMU + * ----------------------------------------------------------------------------- + * SUNDIALS Copyright Start + * Copyright (c) 2002-2024, 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 MRIStep's multirate adaptivity controller + * layer. + * ---------------------------------------------------------------------------*/ + +#include +#include +#include + +#include "arkode_impl.h" +#include "arkode_mristep_impl.h" + +/* SUNAdaptController_MRIStep heuristic constants */ +/* minimum estimated temporal error for inner solver */ +#define INNER_MIN_DSM SUNRsqrt(SUN_UNIT_ROUNDOFF) +/* maximum relative change for inner step size or tolerance */ +#define INNER_MAX_RELCH SUN_RCONST(20.0) +/* minimum tolerance sent to inner solver */ +#define INNER_MIN_RTOL (SUN_RCONST(100.0) * SUN_UNIT_ROUNDOFF) +/* maximum tolerance sent to inner solver */ +#define INNER_MAX_RTOL (SUN_RCONST(0.1)) +/* minimum step size for inner solver */ +#define INNER_MIN_H (SUN_RCONST(10.0) * SUN_UNIT_ROUNDOFF) +/* maximum step size for inner solver, as fraction of MRIStep H */ +#define INNER_MAX_H SUN_RCONST(0.5) + +/*-------------------------------------------- + MRIStep SUNAdaptController wrapper functions + --------------------------------------------*/ + +SUNAdaptController SUNAdaptController_MRIStep(void* arkode_mem, + SUNAdaptController CMRI) +{ + SUNAdaptController C; + mriStepControlContent content; + ARKodeMem ark_mem; + ARKodeMRIStepMem step_mem; + int retval; + + /* Return with failure if input controller is NULL or has + unsupported type */ + if (CMRI == NULL) { return (NULL); } + if ((SUNAdaptController_GetType(CMRI) != SUN_ADAPTCONTROLLER_MRI_H) && + (SUNAdaptController_GetType(CMRI) != SUN_ADAPTCONTROLLER_MRI_TOL)) + { + return (NULL); + } + + /* Return with failure if stepper is inaccessible */ + retval = mriStep_AccessARKODEStepMem(arkode_mem, __func__, &ark_mem, &step_mem); + if (retval != ARK_SUCCESS) return (NULL); + + /* Create an empty controller object */ + C = NULL; + C = SUNAdaptController_NewEmpty(CMRI->sunctx); + if (C == NULL) { return (NULL); } + + /* Attach operations */ + C->ops->gettype = SUNAdaptController_GetType_MRIStep; + C->ops->estimatestep = SUNAdaptController_EstimateStep_MRIStep; + C->ops->reset = SUNAdaptController_Reset_MRIStep; + C->ops->write = SUNAdaptController_Write_MRIStep; + C->ops->updateh = SUNAdaptController_UpdateH_MRIStep; + C->ops->space = SUNAdaptController_Space_MRIStep; + + /* Create content */ + content = NULL; + content = (mriStepControlContent)malloc(sizeof *content); + if (content == NULL) + { + SUNAdaptController_Destroy(C); + return (NULL); + } + + /* Attach ARKODE memory, MRI stepper memory and MRI controller objects */ + content->ark_mem = ark_mem; + content->step_mem = step_mem; + content->C = CMRI; + + /* Attach content and return */ + C->content = content; + return (C); +} + +int SUNAdaptController_EstimateStep_MRIStep(SUNAdaptController C, sunrealtype H, + int P, sunrealtype DSM, + sunrealtype* Hnew) +{ + /* Shortcuts to ARKODE and MRIStep memory */ + int retval; + ARKodeMem ark_mem = MRICONTROL_A(C); + ARKodeMRIStepMem step_mem = MRICONTROL_S(C); + if ((ark_mem == NULL) || (step_mem == NULL)) { return SUN_ERR_MEM_FAIL; } + + /* Enforce bound on inner_dsm */ + step_mem->inner_dsm = SUNMAX(step_mem->inner_dsm, INNER_MIN_DSM); + + /* Estimate slow stepsize based on MRI controller type, and enforce bounds on + controller-specified value for the inner solver */ + if (SUNAdaptController_GetType(MRICONTROL_C(C)) == SUN_ADAPTCONTROLLER_MRI_H) + { + retval = SUNAdaptController_EstimateMRISteps(MRICONTROL_C(C), H, + step_mem->inner_control, + step_mem->p, DSM, + step_mem->inner_dsm, Hnew, + &(step_mem->inner_control_new)); + step_mem->inner_control_new = SUNMAX(step_mem->inner_control_new, + INNER_MIN_H); + step_mem->inner_control_new = SUNMIN(step_mem->inner_control_new, + INNER_MAX_H); + step_mem->inner_control_new = + SUNMAX(step_mem->inner_control_new, + step_mem->inner_control / INNER_MAX_RELCH); + step_mem->inner_control_new = + SUNMIN(step_mem->inner_control_new, + step_mem->inner_control * INNER_MAX_RELCH); + } + else /* SUN_ADAPTCONTROLLER_MRI_TOL */ + { + retval = SUNAdaptController_EstimateStepTol(MRICONTROL_C(C), H, + step_mem->inner_control, + step_mem->p, DSM, + step_mem->inner_dsm, Hnew, + &(step_mem->inner_control_new)); + } + return retval; +} + +int SUNAdaptController_UpdateH_MRIStep(SUNAdaptController C, sunrealtype H, + sunrealtype DSM) +{ + /* Shortcuts to ARKODE and MRIStep memory */ + ARKodeMem ark_mem = MRICONTROL_A(C); + ARKodeMRIStepMem step_mem = MRICONTROL_S(C); + if ((ark_mem == NULL) || (step_mem == NULL)) { return SUN_ERR_MEM_FAIL; } + + /* Update MRI controller based on its type */ + int retval; + if (SUNAdaptController_GetType(MRICONTROL_C(C)) == SUN_ADAPTCONTROLLER_MRI_H) + { + retval = SUNAdaptController_UpdateMRIH(MRICONTROL_C(C), H, + step_mem->inner_control, DSM, + step_mem->inner_dsm); + } + else /* SUN_ADAPTCONTROLLER_MRI_TOL */ + { + retval = SUNAdaptController_UpdateMRITol(MRICONTROL_C(C), H, + step_mem->inner_control, DSM, + step_mem->inner_dsm); + } + if (retval != SUN_SUCCESS) { return (retval); } + + /* Update inner controller parameter to most-recent prediction */ + step_mem->inner_control = step_mem->inner_control_new; + + /* return with success*/ + return SUN_SUCCESS; +} + +SUNAdaptController_Type SUNAdaptController_GetType_MRIStep(SUNAdaptController C) +{ + return SUNAdaptController_GetType(MRICONTROL_C(C)); +} + +SUNErrCode SUNAdaptController_Reset_MRIStep(SUNAdaptController C) +{ + return SUNAdaptController_Reset(MRICONTROL_C(C)); +} + +SUNErrCode SUNAdaptController_Write_MRIStep(SUNAdaptController C, FILE* fptr) +{ + return SUNAdaptController_Write(MRICONTROL_C(C), fptr); +} + +SUNErrCode SUNAdaptController_Space_MRIStep(SUNAdaptController C, + long int* lenrw, long int* leniw) +{ + return SUNAdaptController_Space(MRICONTROL_C(C), lenrw, leniw); +} + +/*=============================================================== + EOF + ===============================================================*/ diff --git a/src/arkode/arkode_mristep_impl.h b/src/arkode/arkode_mristep_impl.h index 29caf263c3..07592e4745 100644 --- a/src/arkode/arkode_mristep_impl.h +++ b/src/arkode/arkode_mristep_impl.h @@ -31,11 +31,15 @@ extern "C" { #endif /* Stage type identifiers */ +#define MRISTAGE_STIFF_ACC -1 #define MRISTAGE_ERK_FAST 0 #define MRISTAGE_ERK_NOFAST 1 #define MRISTAGE_DIRK_NOFAST 2 #define MRISTAGE_DIRK_FAST 3 +/* Default inner_factor value */ +#define INNER_HFACTOR SUN_RCONST(2.0) + /* Implicit solver constants (duplicate from arkode_arkstep_impl.h) */ /* max number of nonlinear iterations */ #define MAXCOR 3 @@ -72,18 +76,19 @@ typedef struct ARKodeMRIStepMemRec a nonlinear solve */ /* Outer RK method storage and parameters */ - N_Vector* Fse; /* explicit RHS at each stage */ - N_Vector* Fsi; /* implicit RHS at each stage */ - MRIStepCoupling MRIC; /* slow->fast coupling table */ - int q; /* method order */ - int p; /* embedding order */ - int stages; /* total number of stages */ - int nstages_active; /* number of active stage RHS vectors */ - int nstages_allocated; /* number of stage RHS vectors allocated */ - int* stage_map; /* index map for storing stage RHS vectors */ - int* stagetypes; /* type flags for stages */ - sunrealtype* Ae_row; /* equivalent explicit RK coeffs */ - sunrealtype* Ai_row; /* equivalent implicit RK coeffs */ + N_Vector* Fse; /* explicit RHS at each stage */ + N_Vector* Fsi; /* implicit RHS at each stage */ + sunbooleantype unify_Fs; /* Fse and Fsi point at the same memory */ + MRIStepCoupling MRIC; /* slow->fast coupling table */ + int q; /* method order */ + int p; /* embedding order */ + int stages; /* total number of stages */ + int nstages_active; /* number of active stage RHS vectors */ + int nstages_allocated; /* number of stage RHS vectors allocated */ + int* stage_map; /* index map for storing stage RHS vectors */ + int* stagetypes; /* type flags for stages */ + sunrealtype* Ae_row; /* equivalent explicit RK coeffs */ + sunrealtype* Ai_row; /* equivalent implicit RK coeffs */ /* Algebraic solver data and parameters */ N_Vector sdata; /* old stage data in residual */ @@ -103,18 +108,18 @@ typedef struct ARKodeMRIStepMemRec sunrealtype crate; /* estimated nonlin convergence rate */ sunrealtype delp; /* norm of previous nonlinear solver update */ sunrealtype eRNrm; /* estimated residual norm, used in nonlin - and linear solver convergence tests */ + and linear solver convergence tests */ sunrealtype nlscoef; /* coefficient in nonlin. convergence test */ int msbp; /* positive => max # steps between lsetup - negative => call at each Newton iter */ + negative => call at each Newton iter */ long int nstlp; /* step number of last setup call */ int maxcor; /* max num iterations for solving the - nonlinear equation */ + nonlinear equation */ int convfail; /* NLS fail flag (for interface routines) */ sunbooleantype jcur; /* is Jacobian info for lin solver current? */ - ARKStagePredictFn stage_predict; /* User-supplied stage predictor */ + ARKStagePredictFn stage_predict; /* User-supplied stage predictor */ /* Linear Solver Data */ ARKLinsolInitFn linit; @@ -130,6 +135,12 @@ typedef struct ARKodeMRIStepMemRec MRIStepPreInnerFn pre_inner_evolve; MRIStepPostInnerFn post_inner_evolve; + /* MRI adaptivity parameters */ + sunrealtype inner_hfactor; /* h factor for inner stepper error estimation */ + sunrealtype inner_control; /* prev control parameter (h or tolfac) */ + sunrealtype inner_dsm; /* prev inner stepper accumulated error */ + sunrealtype inner_control_new; /* upcoming control parameter */ + /* Counters */ long int nfse; /* num fse calls */ long int nfsi; /* num fsi calls */ @@ -155,6 +166,10 @@ struct _MRIStepInnerStepper_Ops MRIStepInnerEvolveFn evolve; MRIStepInnerFullRhsFn fullrhs; MRIStepInnerResetFn reset; + MRIStepInnerGetAccumulatedError geterror; + MRIStepInnerResetAccumulatedError reseterror; + MRIStepInnerSetFixedStep setfixedstep; + MRIStepInnerSetRTol setrtol; }; struct _MRIStepInnerStepper @@ -202,7 +217,10 @@ int mriStep_GetGammas(ARKodeMem ark_mem, sunrealtype* gamma, sunrealtype* gamrat sunbooleantype** jcur, sunbooleantype* dgamma_fail); int mriStep_FullRHS(ARKodeMem ark_mem, sunrealtype t, N_Vector y, N_Vector f, int mode); -int mriStep_TakeStep(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr); +int mriStep_TakeStepMRIGARK(ARKodeMem ark_mem, sunrealtype* dsmPtr, + int* nflagPtr); +int mriStep_TakeStepMRISR(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr); +int mriStep_TakeStepMERK(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr); int mriStep_SetUserData(ARKodeMem ark_mem, void* user_data); int mriStep_SetDefaults(ARKodeMem ark_mem); int mriStep_SetOrder(ARKodeMem ark_mem, int ord); @@ -219,6 +237,7 @@ int mriStep_SetMaxNonlinIters(ARKodeMem ark_mem, int maxcor); int mriStep_SetNonlinConvCoef(ARKodeMem ark_mem, sunrealtype nlscoef); int mriStep_SetStagePredictFn(ARKodeMem ark_mem, ARKStagePredictFn PredictStage); int mriStep_SetDeduceImplicitRhs(ARKodeMem ark_mem, sunbooleantype deduce); +int mriStep_GetEstLocalErrors(ARKodeMem ark_mem, N_Vector ele); int mriStep_GetCurrentGamma(ARKodeMem ark_mem, sunrealtype* gamma); int mriStep_GetNonlinearSystemData(ARKodeMem ark_mem, sunrealtype* tcur, N_Vector* zpred, N_Vector* z, N_Vector* Fi, @@ -246,7 +265,10 @@ int mriStep_AccessStepMem(ARKodeMem ark_mem, const char* fname, sunbooleantype mriStep_CheckNVector(N_Vector tmpl); int mriStep_SetCoupling(ARKodeMem ark_mem); int mriStep_CheckCoupling(ARKodeMem ark_mem); -int mriStep_StageERKFast(ARKodeMem ark_mem, ARKodeMRIStepMem step_mem, int is); +int mriStep_StageERKFast(ARKodeMem ark_mem, ARKodeMRIStepMem step_mem, int is, + sunrealtype t0, sunrealtype tf, N_Vector ycur, + N_Vector ytemp, sunbooleantype force_reset, + sunbooleantype get_inner_dsm); int mriStep_StageERKNoFast(ARKodeMem ark_mem, ARKodeMRIStepMem step_mem, int is); int mriStep_StageDIRKFast(ARKodeMem ark_mem, ARKodeMRIStepMem step_mem, int is, int* nflagPtr); @@ -256,6 +278,13 @@ int mriStep_Predict(ARKodeMem ark_mem, int istage, N_Vector yguess); int mriStep_StageSetup(ARKodeMem ark_mem); int mriStep_NlsInit(ARKodeMem ark_mem); int mriStep_Nls(ARKodeMem ark_mem, int nflag); +int mriStep_SlowRHS(ARKodeMem ark_mem, sunrealtype t, N_Vector y, N_Vector f, + int mode); +int mriStep_FastRHS(ARKodeMem ark_mem, sunrealtype t, N_Vector y, N_Vector f, + int mode); +int mriStep_Hin(ARKodeMem ark_mem, sunrealtype tcur, sunrealtype tout, + N_Vector ycur, N_Vector fcur, N_Vector ytmp, N_Vector temp1, + N_Vector temp2, ARKTimestepFullRHSFn rhs, sunrealtype* h); /* private functions passed to nonlinear solver */ int mriStep_NlsResidual(N_Vector yy, N_Vector res, void* arkode_mem); @@ -268,12 +297,21 @@ int mriStep_NlsConvTest(SUNNonlinearSolver NLS, N_Vector y, N_Vector del, /* Inner stepper functions */ int mriStepInnerStepper_HasRequiredOps(MRIStepInnerStepper stepper); +sunbooleantype mriStepInnerStepper_SupportsStepAdaptivity( + MRIStepInnerStepper stepper); +sunbooleantype mriStepInnerStepper_SupportsRTolAdaptivity( + MRIStepInnerStepper stepper); int mriStepInnerStepper_Evolve(MRIStepInnerStepper stepper, sunrealtype t0, sunrealtype tout, N_Vector y); int mriStepInnerStepper_FullRhs(MRIStepInnerStepper stepper, sunrealtype t, N_Vector y, N_Vector f, int mode); int mriStepInnerStepper_Reset(MRIStepInnerStepper stepper, sunrealtype tR, N_Vector yR); +int mriStepInnerStepper_GetError(MRIStepInnerStepper stepper, + sunrealtype* accum_error); +int mriStepInnerStepper_ResetError(MRIStepInnerStepper stepper); +int mriStepInnerStepper_SetFixedStep(MRIStepInnerStepper stepper, sunrealtype h); +int mriStepInnerStepper_SetRTol(MRIStepInnerStepper stepper, sunrealtype rtol); int mriStepInnerStepper_AllocVecs(MRIStepInnerStepper stepper, int count, N_Vector tmpl); int mriStepInnerStepper_Resize(MRIStepInnerStepper stepper, ARKVecResizeFn resize, @@ -284,12 +322,51 @@ void mriStepInnerStepper_PrintMem(MRIStepInnerStepper stepper, FILE* outfile); /* Compute forcing for inner stepper */ int mriStep_ComputeInnerForcing(ARKodeMem ark_mem, ARKodeMRIStepMem step_mem, - int stage, sunrealtype cdiff); + int stage, sunrealtype t0, sunrealtype tf); /* Return effective RK coefficients (nofast stage) */ int mriStep_RKCoeffs(MRIStepCoupling MRIC, int is, int* stage_map, sunrealtype* Ae_row, sunrealtype* Ai_row); +/*=============================================================== + MRIStep SUNAdaptController wrapper module -- this is used to + insert MRIStep in-between ARKODE at the "slow" time scale, and + the inner-steppers that comprise the MRI time-step evolution. + Since ARKODE itself only calls single-scale controller + functions (e.g., EstimateStep and UpdateH), then this serves to + translate those single-rate controller functions to the multi- + rate context, leveraging MRIStep-specific knowledge of the + slow+fast time scale relationship to CALL multi-rate controller + functions (e.g., EstimateMRISteps, EstimateStepTol, UpdateMRIH, + and UpdateMRITol) provided by the underlying multi-rate + controller. + ===============================================================*/ + +typedef struct _mriStepControlContent +{ + ARKodeMem ark_mem; /* ARKODE memory pointer */ + ARKodeMRIStepMem step_mem; /* MRIStep memory pointer */ + SUNAdaptController C; /* attached controller pointer */ +}* mriStepControlContent; + +#define MRICONTROL_C(C) (((mriStepControlContent)(C->content))->C) +#define MRICONTROL_A(C) (((mriStepControlContent)(C->content))->ark_mem) +#define MRICONTROL_S(C) (((mriStepControlContent)(C->content))->step_mem) + +SUNAdaptController SUNAdaptController_MRIStep(void* arkode_mem, + SUNAdaptController C); +SUNAdaptController_Type SUNAdaptController_GetType_MRIStep(SUNAdaptController C); +SUNErrCode SUNAdaptController_EstimateStep_MRIStep(SUNAdaptController C, + sunrealtype H, int P, + sunrealtype DSM, + sunrealtype* Hnew); +SUNErrCode SUNAdaptController_Reset_MRIStep(SUNAdaptController C); +SUNErrCode SUNAdaptController_Write_MRIStep(SUNAdaptController C, FILE* fptr); +SUNErrCode SUNAdaptController_UpdateH_MRIStep(SUNAdaptController C, + sunrealtype h, sunrealtype dsm); +SUNErrCode SUNAdaptController_Space_MRIStep(SUNAdaptController C, + long int* lenrw, long int* leniw); + /*=============================================================== Reusable MRIStep Error Messages ===============================================================*/ diff --git a/src/arkode/arkode_mristep_io.c b/src/arkode/arkode_mristep_io.c index d803141044..10633a50de 100644 --- a/src/arkode/arkode_mristep_io.c +++ b/src/arkode/arkode_mristep_io.c @@ -124,6 +124,73 @@ int MRIStepSetPostInnerFn(void* arkode_mem, MRIStepPostInnerFn postfn) return (ARK_SUCCESS); } +/*--------------------------------------------------------------- + MRIStepSetFastErrorStepFactor: + + Specifies a fast stepsize factor to use when estimating the + accumulated fast time scale solution error when MRI adaptivity + is enabled. The fast integrator is run twice over each fast + time interval, once using the inner step size h, and again + using hfactor*h (typically hfactor=k or 1/k for an integer k>1). + This is only needed when the results from + mriStepInnerStepper_GetError() cannot be trusted. In our + tests, we found this to be the case when the inner integrator + uses fixed step sizes. + + An argument of 0 disables this fast error estimation strategy. + Arguments of hfactor < 0 or hfactor == 1 are illegal. + All other positive hfactor values will *attempt* to be used. + ---------------------------------------------------------------*/ +int MRIStepSetFastErrorStepFactor(void* arkode_mem, sunrealtype hfactor) +{ + ARKodeMem ark_mem; + ARKodeMRIStepMem step_mem; + int retval; + + /* access ARKodeMRIStepMem structure */ + retval = mriStep_AccessARKODEStepMem(arkode_mem, __func__, &ark_mem, &step_mem); + if (retval != ARK_SUCCESS) { return (retval); } + + /* return with error on illegal input */ + if ((hfactor < ZERO) || (hfactor == ONE)) + { + arkProcessError(ark_mem, ARK_ILL_INPUT, __LINE__, __func__, __FILE__, + "Illegal input; must be >0 and not identically 1"); + return (ARK_ILL_INPUT); + } + + /* set value and return */ + step_mem->inner_hfactor = hfactor; + return (ARK_SUCCESS); +} + +/*--------------------------------------------------------------- + MRIStepSetAdaptController: + + Specifies a temporal adaptivity controller for MRIStep to use. + If a non-MRI controller is provided, this just passes that + through to arkSetAdaptController. However, if an MRI + controller is provided, then this wraps that inside a + "SUNAdaptController_MRIStep" wrapper, which will properly + interact with the fast integration module. + ---------------------------------------------------------------*/ +int MRIStepSetAdaptController(void* arkode_mem, SUNAdaptController C) +{ + /* Retrieve the controller type */ + SUNAdaptController_Type ctype = SUNAdaptController_GetType(C); + + /* If this does not have MRI type, then just pass to ARKODE */ + if ((ctype != SUN_ADAPTCONTROLLER_MRI_H) && + (ctype != SUN_ADAPTCONTROLLER_MRI_TOL)) + { + return (ARKodeSetAdaptController(arkode_mem, C)); + } + + /* Create the mriStepControl wrapper, and pass that to ARKODE */ + SUNAdaptController Cwrapper = SUNAdaptController_MRIStep(arkode_mem, C); + return (ARKodeSetAdaptController(arkode_mem, Cwrapper)); +} + /*=============================================================== Exported optional output functions. ===============================================================*/ @@ -257,6 +324,8 @@ int mriStep_SetDefaults(ARKodeMem ark_mem) step_mem->jcur = SUNFALSE; step_mem->convfail = ARK_NO_FAILURES; step_mem->stage_predict = NULL; /* no user-supplied stage predictor */ + step_mem->inner_hfactor = -INNER_HFACTOR; + return (ARK_SUCCESS); } @@ -582,6 +651,28 @@ int mriStep_GetCurrentGamma(ARKodeMem ark_mem, sunrealtype* gamma) return (retval); } +/*--------------------------------------------------------------- + mriStep_GetEstLocalErrors: Returns the current local truncation + error estimate vector + ---------------------------------------------------------------*/ +int mriStep_GetEstLocalErrors(ARKodeMem ark_mem, N_Vector ele) +{ + int retval; + ARKodeMRIStepMem step_mem; + retval = mriStep_AccessStepMem(ark_mem, __func__, &step_mem); + if (retval != ARK_SUCCESS) { return (retval); } + + /* return an error if local truncation error is not computed */ + if (ark_mem->fixedstep && (ark_mem->AccumErrorType < 0)) + { + return (ARK_STEPPER_UNSUPPORTED); + } + + /* otherwise, copy local truncation error vector to output */ + N_VScale(ONE, ark_mem->tempv1, ele); + return (ARK_SUCCESS); +} + /*--------------------------------------------------------------- mriStep_GetNumLinSolvSetups: diff --git a/src/arkode/arkode_mristep_nls.c b/src/arkode/arkode_mristep_nls.c index 882eedad75..39119403ad 100644 --- a/src/arkode/arkode_mristep_nls.c +++ b/src/arkode/arkode_mristep_nls.c @@ -328,7 +328,7 @@ int mriStep_Nls(ARKodeMem ark_mem, int nflag) #ifdef SUNDIALS_LOGGING_EXTRA_DEBUG SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, "ARKODE::mriStep_Nls", - "correction", "zcor(:) =", ""); + "correction", "zcor =", ""); N_VPrintFile(step_mem->zcor, ARK_LOGGER->debug_fp); #endif diff --git a/src/arkode/arkode_relaxation.c b/src/arkode/arkode_relaxation.c index c911077580..e2307448b9 100644 --- a/src/arkode/arkode_relaxation.c +++ b/src/arkode/arkode_relaxation.c @@ -357,7 +357,7 @@ static int arkRelaxSolve(ARKodeMem ark_mem, ARKodeRelaxMem relax_mem, #ifdef SUNDIALS_LOGGING_EXTRA_DEBUG SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, "ARKODE::arkRelaxSolve", - "compute delta y", "delta_y(:) =", ""); + "compute delta y", "delta_y =", ""); N_VPrintFile(ark_mem->tempv2, ARK_LOGGER->debug_fp); #endif diff --git a/src/arkode/fmod_int32/farkode_erkstep_mod.c b/src/arkode/fmod_int32/farkode_erkstep_mod.c index 5def57befc..d475e25e44 100644 --- a/src/arkode/fmod_int32/farkode_erkstep_mod.c +++ b/src/arkode/fmod_int32/farkode_erkstep_mod.c @@ -361,6 +361,20 @@ SWIGEXPORT int _wrap_FERKStepGetTimestepperStats(void *farg1, long *farg2, long } +SWIGEXPORT int _wrap_FERKStepCreateMRIStepInnerStepper(void *farg1, void *farg2) { + int fresult ; + void *arg1 = (void *) 0 ; + MRIStepInnerStepper *arg2 = (MRIStepInnerStepper *) 0 ; + int result; + + arg1 = (void *)(farg1); + arg2 = (MRIStepInnerStepper *)(farg2); + result = (int)ERKStepCreateMRIStepInnerStepper(arg1,arg2); + fresult = (int)(result); + return fresult; +} + + SWIGEXPORT int _wrap_FERKStepResize(void *farg1, N_Vector farg2, double const *farg3, double const *farg4, ARKVecResizeFn farg5, void *farg6) { int fresult ; void *arg1 = (void *) 0 ; diff --git a/src/arkode/fmod_int32/farkode_erkstep_mod.f90 b/src/arkode/fmod_int32/farkode_erkstep_mod.f90 index 291dc643d5..147a7692ac 100644 --- a/src/arkode/fmod_int32/farkode_erkstep_mod.f90 +++ b/src/arkode/fmod_int32/farkode_erkstep_mod.f90 @@ -47,6 +47,7 @@ module farkode_erkstep_mod public :: FERKStepGetNumRhsEvals public :: FERKStepGetCurrentButcherTable public :: FERKStepGetTimestepperStats + public :: FERKStepCreateMRIStepInnerStepper public :: FERKStepResize public :: FERKStepReset public :: FERKStepSStolerances @@ -214,6 +215,15 @@ function swigc_FERKStepGetTimestepperStats(farg1, farg2, farg3, farg4, farg5, fa integer(C_INT) :: fresult end function +function swigc_FERKStepCreateMRIStepInnerStepper(farg1, farg2) & +bind(C, name="_wrap_FERKStepCreateMRIStepInnerStepper") & +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_FERKStepResize(farg1, farg2, farg3, farg4, farg5, farg6) & bind(C, name="_wrap_FERKStepResize") & result(fresult) @@ -1161,6 +1171,22 @@ function FERKStepGetTimestepperStats(arkode_mem, expsteps, accsteps, step_attemp swig_result = fresult end function +function FERKStepCreateMRIStepInnerStepper(arkode_mem, stepper) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(C_PTR) :: arkode_mem +type(C_PTR), target, intent(inout) :: stepper +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 + +farg1 = arkode_mem +farg2 = c_loc(stepper) +fresult = swigc_FERKStepCreateMRIStepInnerStepper(farg1, farg2) +swig_result = fresult +end function + function FERKStepResize(arkode_mem, ynew, hscale, t0, resize, resize_data) & result(swig_result) use, intrinsic :: ISO_C_BINDING diff --git a/src/arkode/fmod_int32/farkode_mod.c b/src/arkode/fmod_int32/farkode_mod.c index 1423d2e582..e4c0129c22 100644 --- a/src/arkode/fmod_int32/farkode_mod.c +++ b/src/arkode/fmod_int32/farkode_mod.c @@ -1139,6 +1139,32 @@ SWIGEXPORT int _wrap_FARKodeSetMaxNumConstrFails(void *farg1, int const *farg2) } +SWIGEXPORT int _wrap_FARKodeSetAccumulatedErrorType(void *farg1, int const *farg2) { + int fresult ; + void *arg1 = (void *) 0 ; + int arg2 ; + int result; + + arg1 = (void *)(farg1); + arg2 = (int)(*farg2); + result = (int)ARKodeSetAccumulatedErrorType(arg1,arg2); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FARKodeResetAccumulatedError(void *farg1) { + int fresult ; + void *arg1 = (void *) 0 ; + int result; + + arg1 = (void *)(farg1); + result = (int)ARKodeResetAccumulatedError(arg1); + fresult = (int)(result); + return fresult; +} + + SWIGEXPORT int _wrap_FARKodeEvolve(void *farg1, double const *farg2, N_Vector farg3, double *farg4, int const *farg5) { int fresult ; void *arg1 = (void *) 0 ; @@ -1484,6 +1510,20 @@ SWIGEXPORT int _wrap_FARKodeGetStepStats(void *farg1, long *farg2, double *farg3 } +SWIGEXPORT int _wrap_FARKodeGetAccumulatedError(void *farg1, double *farg2) { + int fresult ; + void *arg1 = (void *) 0 ; + sunrealtype *arg2 = (sunrealtype *) 0 ; + int result; + + arg1 = (void *)(farg1); + arg2 = (sunrealtype *)(farg2); + result = (int)ARKodeGetAccumulatedError(arg1,arg2); + fresult = (int)(result); + return fresult; +} + + SWIGEXPORT int _wrap_FARKodeGetNumLinSolvSetups(void *farg1, long *farg2) { int fresult ; void *arg1 = (void *) 0 ; diff --git a/src/arkode/fmod_int32/farkode_mod.f90 b/src/arkode/fmod_int32/farkode_mod.f90 index 366867f40a..8fa06ea70e 100644 --- a/src/arkode/fmod_int32/farkode_mod.f90 +++ b/src/arkode/fmod_int32/farkode_mod.f90 @@ -160,6 +160,8 @@ module farkode_mod public :: FARKodeSetMinStep public :: FARKodeSetMaxStep public :: FARKodeSetMaxNumConstrFails + public :: FARKodeSetAccumulatedErrorType + public :: FARKodeResetAccumulatedError public :: FARKodeEvolve public :: FARKodeGetDky public :: FARKodeComputeState @@ -187,6 +189,7 @@ module farkode_mod public :: FARKodeGetTolScaleFactor public :: FARKodeGetNumConstrFails public :: FARKodeGetStepStats + public :: FARKodeGetAccumulatedError public :: FARKodeGetNumLinSolvSetups public :: FARKodeGetCurrentTime public :: FARKodeGetCurrentState @@ -986,6 +989,23 @@ function swigc_FARKodeSetMaxNumConstrFails(farg1, farg2) & integer(C_INT) :: fresult end function +function swigc_FARKodeSetAccumulatedErrorType(farg1, farg2) & +bind(C, name="_wrap_FARKodeSetAccumulatedErrorType") & +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_FARKodeResetAccumulatedError(farg1) & +bind(C, name="_wrap_FARKodeResetAccumulatedError") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +type(C_PTR), value :: farg1 +integer(C_INT) :: fresult +end function + function swigc_FARKodeEvolve(farg1, farg2, farg3, farg4, farg5) & bind(C, name="_wrap_FARKodeEvolve") & result(fresult) @@ -1210,6 +1230,15 @@ function swigc_FARKodeGetStepStats(farg1, farg2, farg3, farg4, farg5, farg6) & integer(C_INT) :: fresult end function +function swigc_FARKodeGetAccumulatedError(farg1, farg2) & +bind(C, name="_wrap_FARKodeGetAccumulatedError") & +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_FARKodeGetNumLinSolvSetups(farg1, farg2) & bind(C, name="_wrap_FARKodeGetNumLinSolvSetups") & result(fresult) @@ -3315,6 +3344,35 @@ function FARKodeSetMaxNumConstrFails(arkode_mem, maxfails) & swig_result = fresult end function +function FARKodeSetAccumulatedErrorType(arkode_mem, accum_type) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(C_PTR) :: arkode_mem +integer(C_INT), intent(in) :: accum_type +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +integer(C_INT) :: farg2 + +farg1 = arkode_mem +farg2 = accum_type +fresult = swigc_FARKodeSetAccumulatedErrorType(farg1, farg2) +swig_result = fresult +end function + +function FARKodeResetAccumulatedError(arkode_mem) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(C_PTR) :: arkode_mem +integer(C_INT) :: fresult +type(C_PTR) :: farg1 + +farg1 = arkode_mem +fresult = swigc_FARKodeResetAccumulatedError(farg1) +swig_result = fresult +end function + function FARKodeEvolve(arkode_mem, tout, yout, tret, itask) & result(swig_result) use, intrinsic :: ISO_C_BINDING @@ -3731,6 +3789,22 @@ function FARKodeGetStepStats(arkode_mem, nsteps, hinused, hlast, hcur, tcur) & swig_result = fresult end function +function FARKodeGetAccumulatedError(arkode_mem, accum_error) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(C_PTR) :: arkode_mem +real(C_DOUBLE), dimension(*), target, intent(inout) :: accum_error +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 + +farg1 = arkode_mem +farg2 = c_loc(accum_error(1)) +fresult = swigc_FARKodeGetAccumulatedError(farg1, farg2) +swig_result = fresult +end function + function FARKodeGetNumLinSolvSetups(arkode_mem, nlinsetups) & result(swig_result) use, intrinsic :: ISO_C_BINDING diff --git a/src/arkode/fmod_int32/farkode_mristep_mod.c b/src/arkode/fmod_int32/farkode_mristep_mod.c index 35721938c4..ef40dcb987 100644 --- a/src/arkode/fmod_int32/farkode_mristep_mod.c +++ b/src/arkode/fmod_int32/farkode_mristep_mod.c @@ -308,6 +308,30 @@ SWIGINTERN SwigArrayWrapper SwigArrayWrapper_uninitialized() { return result; } +SWIGEXPORT void _wrap_MRIStepCouplingMem_type_set(SwigClassWrapper const *farg1, int const *farg2) { + struct MRIStepCouplingMem *arg1 = (struct MRIStepCouplingMem *) 0 ; + MRISTEP_METHOD_TYPE arg2 ; + + SWIG_check_mutable_nonnull(*farg1, "struct MRIStepCouplingMem *", "MRIStepCouplingMem", "MRIStepCouplingMem::type", return ); + arg1 = (struct MRIStepCouplingMem *)(farg1->cptr); + arg2 = (MRISTEP_METHOD_TYPE)(*farg2); + if (arg1) (arg1)->type = arg2; +} + + +SWIGEXPORT int _wrap_MRIStepCouplingMem_type_get(SwigClassWrapper const *farg1) { + int fresult ; + struct MRIStepCouplingMem *arg1 = (struct MRIStepCouplingMem *) 0 ; + MRISTEP_METHOD_TYPE result; + + SWIG_check_mutable_nonnull(*farg1, "struct MRIStepCouplingMem *", "MRIStepCouplingMem", "MRIStepCouplingMem::type", return 0); + arg1 = (struct MRIStepCouplingMem *)(farg1->cptr); + result = (MRISTEP_METHOD_TYPE) ((arg1)->type); + fresult = (int)(result); + return fresult; +} + + SWIGEXPORT void _wrap_MRIStepCouplingMem_nmat_set(SwigClassWrapper const *farg1, int const *farg2) { struct MRIStepCouplingMem *arg1 = (struct MRIStepCouplingMem *) 0 ; int arg2 ; @@ -476,6 +500,54 @@ SWIGEXPORT void * _wrap_MRIStepCouplingMem_G_get(SwigClassWrapper const *farg1) } +SWIGEXPORT void _wrap_MRIStepCouplingMem_ngroup_set(SwigClassWrapper const *farg1, int const *farg2) { + struct MRIStepCouplingMem *arg1 = (struct MRIStepCouplingMem *) 0 ; + int arg2 ; + + SWIG_check_mutable_nonnull(*farg1, "struct MRIStepCouplingMem *", "MRIStepCouplingMem", "MRIStepCouplingMem::ngroup", return ); + arg1 = (struct MRIStepCouplingMem *)(farg1->cptr); + arg2 = (int)(*farg2); + if (arg1) (arg1)->ngroup = arg2; +} + + +SWIGEXPORT int _wrap_MRIStepCouplingMem_ngroup_get(SwigClassWrapper const *farg1) { + int fresult ; + struct MRIStepCouplingMem *arg1 = (struct MRIStepCouplingMem *) 0 ; + int result; + + SWIG_check_mutable_nonnull(*farg1, "struct MRIStepCouplingMem *", "MRIStepCouplingMem", "MRIStepCouplingMem::ngroup", return 0); + arg1 = (struct MRIStepCouplingMem *)(farg1->cptr); + result = (int) ((arg1)->ngroup); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT void _wrap_MRIStepCouplingMem_group_set(SwigClassWrapper const *farg1, void *farg2) { + struct MRIStepCouplingMem *arg1 = (struct MRIStepCouplingMem *) 0 ; + int **arg2 = (int **) 0 ; + + SWIG_check_mutable_nonnull(*farg1, "struct MRIStepCouplingMem *", "MRIStepCouplingMem", "MRIStepCouplingMem::group", return ); + arg1 = (struct MRIStepCouplingMem *)(farg1->cptr); + arg2 = (int **)(farg2); + if (arg1) (arg1)->group = arg2; +} + + +SWIGEXPORT void * _wrap_MRIStepCouplingMem_group_get(SwigClassWrapper const *farg1) { + void * fresult ; + struct MRIStepCouplingMem *arg1 = (struct MRIStepCouplingMem *) 0 ; + int **result = 0 ; + + SWIG_check_mutable_nonnull(*farg1, "struct MRIStepCouplingMem *", "MRIStepCouplingMem", "MRIStepCouplingMem::group", return 0); + arg1 = (struct MRIStepCouplingMem *)(farg1->cptr); + result = (int **) ((arg1)->group); + fresult = result; + return fresult; +} + + SWIGEXPORT SwigClassWrapper _wrap_new_MRIStepCouplingMem() { SwigClassWrapper fresult ; struct MRIStepCouplingMem *result = 0 ; @@ -713,6 +785,34 @@ SWIGEXPORT int _wrap_FMRIStepSetPostInnerFn(void *farg1, MRIStepPostInnerFn farg } +SWIGEXPORT int _wrap_FMRIStepSetFastErrorStepFactor(void *farg1, double const *farg2) { + int fresult ; + void *arg1 = (void *) 0 ; + sunrealtype arg2 ; + int result; + + arg1 = (void *)(farg1); + arg2 = (sunrealtype)(*farg2); + result = (int)MRIStepSetFastErrorStepFactor(arg1,arg2); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FMRIStepSetAdaptController(void *farg1, SUNAdaptController farg2) { + int fresult ; + void *arg1 = (void *) 0 ; + SUNAdaptController arg2 = (SUNAdaptController) 0 ; + int result; + + arg1 = (void *)(farg1); + arg2 = (SUNAdaptController)(farg2); + result = (int)MRIStepSetAdaptController(arg1,arg2); + fresult = (int)(result); + return fresult; +} + + SWIGEXPORT int _wrap_FMRIStepGetNumRhsEvals(void *farg1, long *farg2, long *farg3) { int fresult ; void *arg1 = (void *) 0 ; @@ -853,6 +953,62 @@ SWIGEXPORT int _wrap_FMRIStepInnerStepper_SetResetFn(void *farg1, MRIStepInnerRe } +SWIGEXPORT int _wrap_FMRIStepInnerStepper_SetAccumulatedErrorGetFn(void *farg1, MRIStepInnerGetAccumulatedError farg2) { + int fresult ; + MRIStepInnerStepper arg1 = (MRIStepInnerStepper) 0 ; + MRIStepInnerGetAccumulatedError arg2 = (MRIStepInnerGetAccumulatedError) 0 ; + int result; + + arg1 = (MRIStepInnerStepper)(farg1); + arg2 = (MRIStepInnerGetAccumulatedError)(farg2); + result = (int)MRIStepInnerStepper_SetAccumulatedErrorGetFn(arg1,arg2); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FMRIStepInnerStepper_SetAccumulatedErrorResetFn(void *farg1, MRIStepInnerResetAccumulatedError farg2) { + int fresult ; + MRIStepInnerStepper arg1 = (MRIStepInnerStepper) 0 ; + MRIStepInnerResetAccumulatedError arg2 = (MRIStepInnerResetAccumulatedError) 0 ; + int result; + + arg1 = (MRIStepInnerStepper)(farg1); + arg2 = (MRIStepInnerResetAccumulatedError)(farg2); + result = (int)MRIStepInnerStepper_SetAccumulatedErrorResetFn(arg1,arg2); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FMRIStepInnerStepper_SetFixedStepFn(void *farg1, MRIStepInnerSetFixedStep farg2) { + int fresult ; + MRIStepInnerStepper arg1 = (MRIStepInnerStepper) 0 ; + MRIStepInnerSetFixedStep arg2 = (MRIStepInnerSetFixedStep) 0 ; + int result; + + arg1 = (MRIStepInnerStepper)(farg1); + arg2 = (MRIStepInnerSetFixedStep)(farg2); + result = (int)MRIStepInnerStepper_SetFixedStepFn(arg1,arg2); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FMRIStepInnerStepper_SetRTolFn(void *farg1, MRIStepInnerSetRTol farg2) { + int fresult ; + MRIStepInnerStepper arg1 = (MRIStepInnerStepper) 0 ; + MRIStepInnerSetRTol arg2 = (MRIStepInnerSetRTol) 0 ; + int result; + + arg1 = (MRIStepInnerStepper)(farg1); + arg2 = (MRIStepInnerSetRTol)(farg2); + result = (int)MRIStepInnerStepper_SetRTolFn(arg1,arg2); + fresult = (int)(result); + return fresult; +} + + SWIGEXPORT int _wrap_FMRIStepInnerStepper_AddForcing(void *farg1, double const *farg2, N_Vector farg3) { int fresult ; MRIStepInnerStepper arg1 = (MRIStepInnerStepper) 0 ; diff --git a/src/arkode/fmod_int32/farkode_mristep_mod.f90 b/src/arkode/fmod_int32/farkode_mristep_mod.f90 index 74a3de5637..66f05b4bea 100644 --- a/src/arkode/fmod_int32/farkode_mristep_mod.f90 +++ b/src/arkode/fmod_int32/farkode_mristep_mod.f90 @@ -31,9 +31,11 @@ module farkode_mristep_mod enumerator :: MRISTEP_EXPLICIT enumerator :: MRISTEP_IMPLICIT enumerator :: MRISTEP_IMEX + enumerator :: MRISTEP_MERK + enumerator :: MRISTEP_MRISR end enum integer, parameter, public :: MRISTEP_METHOD_TYPE = kind(MRISTEP_EXPLICIT) - public :: MRISTEP_EXPLICIT, MRISTEP_IMPLICIT, MRISTEP_IMEX + public :: MRISTEP_EXPLICIT, MRISTEP_IMPLICIT, MRISTEP_IMEX, MRISTEP_MERK, MRISTEP_MRISR ! typedef enum ARKODE_MRITableID enum, bind(c) enumerator :: ARKODE_MRI_NONE = -1 @@ -57,7 +59,14 @@ module farkode_mristep_mod enumerator :: ARKODE_IMEX_MRI_GARK_EULER enumerator :: ARKODE_IMEX_MRI_GARK_TRAPEZOIDAL enumerator :: ARKODE_IMEX_MRI_GARK_MIDPOINT - enumerator :: ARKODE_MAX_MRI_NUM = ARKODE_IMEX_MRI_GARK_MIDPOINT + enumerator :: ARKODE_MERK21 + enumerator :: ARKODE_MERK32 + enumerator :: ARKODE_MERK43 + enumerator :: ARKODE_MERK54 + enumerator :: ARKODE_IMEX_MRI_SR21 + enumerator :: ARKODE_IMEX_MRI_SR32 + enumerator :: ARKODE_IMEX_MRI_SR43 + enumerator :: ARKODE_MAX_MRI_NUM = ARKODE_IMEX_MRI_SR43 end enum integer, parameter, public :: ARKODE_MRITableID = kind(ARKODE_MRI_NONE) public :: ARKODE_MRI_NONE, ARKODE_MIN_MRI_NUM, ARKODE_MIS_KW3, ARKODE_MRI_GARK_ERK33a, ARKODE_MRI_GARK_ERK45a, & @@ -65,7 +74,8 @@ module farkode_mristep_mod ARKODE_IMEX_MRI_GARK3b, ARKODE_IMEX_MRI_GARK4, ARKODE_MRI_GARK_FORWARD_EULER, ARKODE_MRI_GARK_RALSTON2, & ARKODE_MRI_GARK_ERK22a, ARKODE_MRI_GARK_ERK22b, ARKODE_MRI_GARK_RALSTON3, ARKODE_MRI_GARK_BACKWARD_EULER, & ARKODE_MRI_GARK_IMPLICIT_MIDPOINT, ARKODE_IMEX_MRI_GARK_EULER, ARKODE_IMEX_MRI_GARK_TRAPEZOIDAL, & - ARKODE_IMEX_MRI_GARK_MIDPOINT, ARKODE_MAX_MRI_NUM + ARKODE_IMEX_MRI_GARK_MIDPOINT, ARKODE_MERK21, ARKODE_MERK32, ARKODE_MERK43, ARKODE_MERK54, ARKODE_IMEX_MRI_SR21, & + ARKODE_IMEX_MRI_SR32, ARKODE_IMEX_MRI_SR43, ARKODE_MAX_MRI_NUM integer(C_INT), parameter, public :: MRISTEP_DEFAULT_EXPL_1 = ARKODE_MRI_GARK_FORWARD_EULER integer(C_INT), parameter, public :: MRISTEP_DEFAULT_EXPL_2 = ARKODE_MRI_GARK_ERK22b integer(C_INT), parameter, public :: MRISTEP_DEFAULT_EXPL_3 = ARKODE_MIS_KW3 @@ -78,6 +88,13 @@ module farkode_mristep_mod integer(C_INT), parameter, public :: MRISTEP_DEFAULT_IMEX_SD_2 = ARKODE_IMEX_MRI_GARK_TRAPEZOIDAL integer(C_INT), parameter, public :: MRISTEP_DEFAULT_IMEX_SD_3 = ARKODE_IMEX_MRI_GARK3b integer(C_INT), parameter, public :: MRISTEP_DEFAULT_IMEX_SD_4 = ARKODE_IMEX_MRI_GARK4 + integer(C_INT), parameter, public :: MRISTEP_DEFAULT_EXPL_2_AD = ARKODE_MRI_GARK_ERK22a + integer(C_INT), parameter, public :: MRISTEP_DEFAULT_EXPL_3_AD = ARKODE_MRI_GARK_ERK33a + integer(C_INT), parameter, public :: MRISTEP_DEFAULT_EXPL_4_AD = ARKODE_MRI_GARK_ERK45a + integer(C_INT), parameter, public :: MRISTEP_DEFAULT_EXPL_5_AD = ARKODE_MERK54 + integer(C_INT), parameter, public :: MRISTEP_DEFAULT_IMEX_SD_2_AD = ARKODE_IMEX_MRI_SR21 + integer(C_INT), parameter, public :: MRISTEP_DEFAULT_IMEX_SD_3_AD = ARKODE_IMEX_MRI_SR32 + integer(C_INT), parameter, public :: MRISTEP_DEFAULT_IMEX_SD_4_AD = ARKODE_IMEX_MRI_SR43 integer, parameter :: swig_cmem_own_bit = 0 integer, parameter :: swig_cmem_rvalue_bit = 1 @@ -90,6 +107,8 @@ module farkode_mristep_mod type, public :: MRIStepCouplingMem type(SwigClassWrapper), public :: swigdata contains + procedure :: set_type => swigf_MRIStepCouplingMem_type_set + procedure :: get_type => swigf_MRIStepCouplingMem_type_get procedure :: set_nmat => swigf_MRIStepCouplingMem_nmat_set procedure :: get_nmat => swigf_MRIStepCouplingMem_nmat_get procedure :: set_stages => swigf_MRIStepCouplingMem_stages_set @@ -104,6 +123,10 @@ module farkode_mristep_mod procedure :: get_W => swigf_MRIStepCouplingMem_W_get procedure :: set_G => swigf_MRIStepCouplingMem_G_set procedure :: get_G => swigf_MRIStepCouplingMem_G_get + procedure :: set_ngroup => swigf_MRIStepCouplingMem_ngroup_set + procedure :: get_ngroup => swigf_MRIStepCouplingMem_ngroup_get + procedure :: set_group => swigf_MRIStepCouplingMem_group_set + procedure :: get_group => swigf_MRIStepCouplingMem_group_get procedure :: release => swigf_release_MRIStepCouplingMem procedure, private :: swigf_MRIStepCouplingMem_op_assign__ generic :: assignment(=) => swigf_MRIStepCouplingMem_op_assign__ @@ -129,6 +152,8 @@ module farkode_mristep_mod public :: FMRIStepSetCoupling public :: FMRIStepSetPreInnerFn public :: FMRIStepSetPostInnerFn + public :: FMRIStepSetFastErrorStepFactor + public :: FMRIStepSetAdaptController public :: FMRIStepGetNumRhsEvals public :: FMRIStepGetCurrentCoupling public :: FMRIStepGetLastInnerStepFlag @@ -139,6 +164,10 @@ module farkode_mristep_mod public :: FMRIStepInnerStepper_SetEvolveFn public :: FMRIStepInnerStepper_SetFullRhsFn public :: FMRIStepInnerStepper_SetResetFn + public :: FMRIStepInnerStepper_SetAccumulatedErrorGetFn + public :: FMRIStepInnerStepper_SetAccumulatedErrorResetFn + public :: FMRIStepInnerStepper_SetFixedStepFn + public :: FMRIStepInnerStepper_SetRTolFn public :: FMRIStepInnerStepper_AddForcing public :: FMRIStepInnerStepper_GetForcingData public :: FMRIStepResize @@ -229,6 +258,23 @@ module farkode_mristep_mod ! WRAPPER DECLARATIONS interface +subroutine swigc_MRIStepCouplingMem_type_set(farg1, farg2) & +bind(C, name="_wrap_MRIStepCouplingMem_type_set") +use, intrinsic :: ISO_C_BINDING +import :: swigclasswrapper +type(SwigClassWrapper) :: farg1 +integer(C_INT), intent(in) :: farg2 +end subroutine + +function swigc_MRIStepCouplingMem_type_get(farg1) & +bind(C, name="_wrap_MRIStepCouplingMem_type_get") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +import :: swigclasswrapper +type(SwigClassWrapper) :: farg1 +integer(C_INT) :: fresult +end function + subroutine swigc_MRIStepCouplingMem_nmat_set(farg1, farg2) & bind(C, name="_wrap_MRIStepCouplingMem_nmat_set") use, intrinsic :: ISO_C_BINDING @@ -348,6 +394,40 @@ function swigc_MRIStepCouplingMem_G_get(farg1) & type(C_PTR) :: fresult end function +subroutine swigc_MRIStepCouplingMem_ngroup_set(farg1, farg2) & +bind(C, name="_wrap_MRIStepCouplingMem_ngroup_set") +use, intrinsic :: ISO_C_BINDING +import :: swigclasswrapper +type(SwigClassWrapper) :: farg1 +integer(C_INT), intent(in) :: farg2 +end subroutine + +function swigc_MRIStepCouplingMem_ngroup_get(farg1) & +bind(C, name="_wrap_MRIStepCouplingMem_ngroup_get") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +import :: swigclasswrapper +type(SwigClassWrapper) :: farg1 +integer(C_INT) :: fresult +end function + +subroutine swigc_MRIStepCouplingMem_group_set(farg1, farg2) & +bind(C, name="_wrap_MRIStepCouplingMem_group_set") +use, intrinsic :: ISO_C_BINDING +import :: swigclasswrapper +type(SwigClassWrapper) :: farg1 +type(C_PTR), value :: farg2 +end subroutine + +function swigc_MRIStepCouplingMem_group_get(farg1) & +bind(C, name="_wrap_MRIStepCouplingMem_group_get") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +import :: swigclasswrapper +type(SwigClassWrapper) :: farg1 +type(C_PTR) :: fresult +end function + function swigc_new_MRIStepCouplingMem() & bind(C, name="_wrap_new_MRIStepCouplingMem") & result(fresult) @@ -503,6 +583,24 @@ function swigc_FMRIStepSetPostInnerFn(farg1, farg2) & integer(C_INT) :: fresult end function +function swigc_FMRIStepSetFastErrorStepFactor(farg1, farg2) & +bind(C, name="_wrap_FMRIStepSetFastErrorStepFactor") & +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_FMRIStepSetAdaptController(farg1, farg2) & +bind(C, name="_wrap_FMRIStepSetAdaptController") & +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_FMRIStepGetNumRhsEvals(farg1, farg2, farg3) & bind(C, name="_wrap_FMRIStepGetNumRhsEvals") & result(fresult) @@ -593,6 +691,42 @@ function swigc_FMRIStepInnerStepper_SetResetFn(farg1, farg2) & integer(C_INT) :: fresult end function +function swigc_FMRIStepInnerStepper_SetAccumulatedErrorGetFn(farg1, farg2) & +bind(C, name="_wrap_FMRIStepInnerStepper_SetAccumulatedErrorGetFn") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +type(C_PTR), value :: farg1 +type(C_FUNPTR), value :: farg2 +integer(C_INT) :: fresult +end function + +function swigc_FMRIStepInnerStepper_SetAccumulatedErrorResetFn(farg1, farg2) & +bind(C, name="_wrap_FMRIStepInnerStepper_SetAccumulatedErrorResetFn") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +type(C_PTR), value :: farg1 +type(C_FUNPTR), value :: farg2 +integer(C_INT) :: fresult +end function + +function swigc_FMRIStepInnerStepper_SetFixedStepFn(farg1, farg2) & +bind(C, name="_wrap_FMRIStepInnerStepper_SetFixedStepFn") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +type(C_PTR), value :: farg1 +type(C_FUNPTR), value :: farg2 +integer(C_INT) :: fresult +end function + +function swigc_FMRIStepInnerStepper_SetRTolFn(farg1, farg2) & +bind(C, name="_wrap_FMRIStepInnerStepper_SetRTolFn") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +type(C_PTR), value :: farg1 +type(C_FUNPTR), value :: farg2 +integer(C_INT) :: fresult +end function + function swigc_FMRIStepInnerStepper_AddForcing(farg1, farg2, farg3) & bind(C, name="_wrap_FMRIStepInnerStepper_AddForcing") & result(fresult) @@ -1407,6 +1541,31 @@ subroutine swigc_FMRIStepPrintMem(farg1, farg2) & contains ! MODULE SUBPROGRAMS +subroutine swigf_MRIStepCouplingMem_type_set(self, type) +use, intrinsic :: ISO_C_BINDING +class(MRIStepCouplingMem), intent(in) :: self +integer(MRISTEP_METHOD_TYPE), intent(in) :: type +type(SwigClassWrapper) :: farg1 +integer(C_INT) :: farg2 + +farg1 = self%swigdata +farg2 = type +call swigc_MRIStepCouplingMem_type_set(farg1, farg2) +end subroutine + +function swigf_MRIStepCouplingMem_type_get(self) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(MRISTEP_METHOD_TYPE) :: swig_result +class(MRIStepCouplingMem), intent(in) :: self +integer(C_INT) :: fresult +type(SwigClassWrapper) :: farg1 + +farg1 = self%swigdata +fresult = swigc_MRIStepCouplingMem_type_get(farg1) +swig_result = fresult +end function + subroutine swigf_MRIStepCouplingMem_nmat_set(self, nmat) use, intrinsic :: ISO_C_BINDING class(MRIStepCouplingMem), intent(in) :: self @@ -1582,6 +1741,56 @@ function swigf_MRIStepCouplingMem_G_get(self) & call c_f_pointer(fresult, swig_result) end function +subroutine swigf_MRIStepCouplingMem_ngroup_set(self, ngroup) +use, intrinsic :: ISO_C_BINDING +class(MRIStepCouplingMem), intent(in) :: self +integer(C_INT), intent(in) :: ngroup +type(SwigClassWrapper) :: farg1 +integer(C_INT) :: farg2 + +farg1 = self%swigdata +farg2 = ngroup +call swigc_MRIStepCouplingMem_ngroup_set(farg1, farg2) +end subroutine + +function swigf_MRIStepCouplingMem_ngroup_get(self) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +class(MRIStepCouplingMem), intent(in) :: self +integer(C_INT) :: fresult +type(SwigClassWrapper) :: farg1 + +farg1 = self%swigdata +fresult = swigc_MRIStepCouplingMem_ngroup_get(farg1) +swig_result = fresult +end function + +subroutine swigf_MRIStepCouplingMem_group_set(self, group) +use, intrinsic :: ISO_C_BINDING +class(MRIStepCouplingMem), intent(in) :: self +type(C_PTR), target, intent(inout) :: group +type(SwigClassWrapper) :: farg1 +type(C_PTR) :: farg2 + +farg1 = self%swigdata +farg2 = c_loc(group) +call swigc_MRIStepCouplingMem_group_set(farg1, farg2) +end subroutine + +function swigf_MRIStepCouplingMem_group_get(self) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +type(C_PTR), pointer :: swig_result +class(MRIStepCouplingMem), intent(in) :: self +type(C_PTR) :: fresult +type(SwigClassWrapper) :: farg1 + +farg1 = self%swigdata +fresult = swigc_MRIStepCouplingMem_group_get(farg1) +call c_f_pointer(fresult, swig_result) +end function + function swigf_create_MRIStepCouplingMem() & result(self) use, intrinsic :: ISO_C_BINDING @@ -1883,6 +2092,38 @@ function FMRIStepSetPostInnerFn(arkode_mem, postfn) & swig_result = fresult end function +function FMRIStepSetFastErrorStepFactor(arkode_mem, hfactor) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(C_PTR) :: arkode_mem +real(C_DOUBLE), intent(in) :: hfactor +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +real(C_DOUBLE) :: farg2 + +farg1 = arkode_mem +farg2 = hfactor +fresult = swigc_FMRIStepSetFastErrorStepFactor(farg1, farg2) +swig_result = fresult +end function + +function FMRIStepSetAdaptController(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_FMRIStepSetAdaptController(farg1, farg2) +swig_result = fresult +end function + function FMRIStepGetNumRhsEvals(arkode_mem, nfse_evals, nfsi_evals) & result(swig_result) use, intrinsic :: ISO_C_BINDING @@ -2043,6 +2284,70 @@ function FMRIStepInnerStepper_SetResetFn(stepper, fn) & swig_result = fresult end function +function FMRIStepInnerStepper_SetAccumulatedErrorGetFn(stepper, fn) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(C_PTR) :: stepper +type(C_FUNPTR), intent(in), value :: fn +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_FUNPTR) :: farg2 + +farg1 = stepper +farg2 = fn +fresult = swigc_FMRIStepInnerStepper_SetAccumulatedErrorGetFn(farg1, farg2) +swig_result = fresult +end function + +function FMRIStepInnerStepper_SetAccumulatedErrorResetFn(stepper, fn) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(C_PTR) :: stepper +type(C_FUNPTR), intent(in), value :: fn +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_FUNPTR) :: farg2 + +farg1 = stepper +farg2 = fn +fresult = swigc_FMRIStepInnerStepper_SetAccumulatedErrorResetFn(farg1, farg2) +swig_result = fresult +end function + +function FMRIStepInnerStepper_SetFixedStepFn(stepper, fn) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(C_PTR) :: stepper +type(C_FUNPTR), intent(in), value :: fn +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_FUNPTR) :: farg2 + +farg1 = stepper +farg2 = fn +fresult = swigc_FMRIStepInnerStepper_SetFixedStepFn(farg1, farg2) +swig_result = fresult +end function + +function FMRIStepInnerStepper_SetRTolFn(stepper, fn) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(C_PTR) :: stepper +type(C_FUNPTR), intent(in), value :: fn +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_FUNPTR) :: farg2 + +farg1 = stepper +farg2 = fn +fresult = swigc_FMRIStepInnerStepper_SetRTolFn(farg1, farg2) +swig_result = fresult +end function + function FMRIStepInnerStepper_AddForcing(stepper, t, f) & result(swig_result) use, intrinsic :: ISO_C_BINDING diff --git a/src/arkode/fmod_int64/farkode_erkstep_mod.c b/src/arkode/fmod_int64/farkode_erkstep_mod.c index 5def57befc..d475e25e44 100644 --- a/src/arkode/fmod_int64/farkode_erkstep_mod.c +++ b/src/arkode/fmod_int64/farkode_erkstep_mod.c @@ -361,6 +361,20 @@ SWIGEXPORT int _wrap_FERKStepGetTimestepperStats(void *farg1, long *farg2, long } +SWIGEXPORT int _wrap_FERKStepCreateMRIStepInnerStepper(void *farg1, void *farg2) { + int fresult ; + void *arg1 = (void *) 0 ; + MRIStepInnerStepper *arg2 = (MRIStepInnerStepper *) 0 ; + int result; + + arg1 = (void *)(farg1); + arg2 = (MRIStepInnerStepper *)(farg2); + result = (int)ERKStepCreateMRIStepInnerStepper(arg1,arg2); + fresult = (int)(result); + return fresult; +} + + SWIGEXPORT int _wrap_FERKStepResize(void *farg1, N_Vector farg2, double const *farg3, double const *farg4, ARKVecResizeFn farg5, void *farg6) { int fresult ; void *arg1 = (void *) 0 ; diff --git a/src/arkode/fmod_int64/farkode_erkstep_mod.f90 b/src/arkode/fmod_int64/farkode_erkstep_mod.f90 index 291dc643d5..147a7692ac 100644 --- a/src/arkode/fmod_int64/farkode_erkstep_mod.f90 +++ b/src/arkode/fmod_int64/farkode_erkstep_mod.f90 @@ -47,6 +47,7 @@ module farkode_erkstep_mod public :: FERKStepGetNumRhsEvals public :: FERKStepGetCurrentButcherTable public :: FERKStepGetTimestepperStats + public :: FERKStepCreateMRIStepInnerStepper public :: FERKStepResize public :: FERKStepReset public :: FERKStepSStolerances @@ -214,6 +215,15 @@ function swigc_FERKStepGetTimestepperStats(farg1, farg2, farg3, farg4, farg5, fa integer(C_INT) :: fresult end function +function swigc_FERKStepCreateMRIStepInnerStepper(farg1, farg2) & +bind(C, name="_wrap_FERKStepCreateMRIStepInnerStepper") & +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_FERKStepResize(farg1, farg2, farg3, farg4, farg5, farg6) & bind(C, name="_wrap_FERKStepResize") & result(fresult) @@ -1161,6 +1171,22 @@ function FERKStepGetTimestepperStats(arkode_mem, expsteps, accsteps, step_attemp swig_result = fresult end function +function FERKStepCreateMRIStepInnerStepper(arkode_mem, stepper) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(C_PTR) :: arkode_mem +type(C_PTR), target, intent(inout) :: stepper +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 + +farg1 = arkode_mem +farg2 = c_loc(stepper) +fresult = swigc_FERKStepCreateMRIStepInnerStepper(farg1, farg2) +swig_result = fresult +end function + function FERKStepResize(arkode_mem, ynew, hscale, t0, resize, resize_data) & result(swig_result) use, intrinsic :: ISO_C_BINDING diff --git a/src/arkode/fmod_int64/farkode_mod.c b/src/arkode/fmod_int64/farkode_mod.c index 7b2c3c9811..49be036eb3 100644 --- a/src/arkode/fmod_int64/farkode_mod.c +++ b/src/arkode/fmod_int64/farkode_mod.c @@ -1139,6 +1139,32 @@ SWIGEXPORT int _wrap_FARKodeSetMaxNumConstrFails(void *farg1, int const *farg2) } +SWIGEXPORT int _wrap_FARKodeSetAccumulatedErrorType(void *farg1, int const *farg2) { + int fresult ; + void *arg1 = (void *) 0 ; + int arg2 ; + int result; + + arg1 = (void *)(farg1); + arg2 = (int)(*farg2); + result = (int)ARKodeSetAccumulatedErrorType(arg1,arg2); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FARKodeResetAccumulatedError(void *farg1) { + int fresult ; + void *arg1 = (void *) 0 ; + int result; + + arg1 = (void *)(farg1); + result = (int)ARKodeResetAccumulatedError(arg1); + fresult = (int)(result); + return fresult; +} + + SWIGEXPORT int _wrap_FARKodeEvolve(void *farg1, double const *farg2, N_Vector farg3, double *farg4, int const *farg5) { int fresult ; void *arg1 = (void *) 0 ; @@ -1484,6 +1510,20 @@ SWIGEXPORT int _wrap_FARKodeGetStepStats(void *farg1, long *farg2, double *farg3 } +SWIGEXPORT int _wrap_FARKodeGetAccumulatedError(void *farg1, double *farg2) { + int fresult ; + void *arg1 = (void *) 0 ; + sunrealtype *arg2 = (sunrealtype *) 0 ; + int result; + + arg1 = (void *)(farg1); + arg2 = (sunrealtype *)(farg2); + result = (int)ARKodeGetAccumulatedError(arg1,arg2); + fresult = (int)(result); + return fresult; +} + + SWIGEXPORT int _wrap_FARKodeGetNumLinSolvSetups(void *farg1, long *farg2) { int fresult ; void *arg1 = (void *) 0 ; diff --git a/src/arkode/fmod_int64/farkode_mod.f90 b/src/arkode/fmod_int64/farkode_mod.f90 index e627472572..2148977b2c 100644 --- a/src/arkode/fmod_int64/farkode_mod.f90 +++ b/src/arkode/fmod_int64/farkode_mod.f90 @@ -160,6 +160,8 @@ module farkode_mod public :: FARKodeSetMinStep public :: FARKodeSetMaxStep public :: FARKodeSetMaxNumConstrFails + public :: FARKodeSetAccumulatedErrorType + public :: FARKodeResetAccumulatedError public :: FARKodeEvolve public :: FARKodeGetDky public :: FARKodeComputeState @@ -187,6 +189,7 @@ module farkode_mod public :: FARKodeGetTolScaleFactor public :: FARKodeGetNumConstrFails public :: FARKodeGetStepStats + public :: FARKodeGetAccumulatedError public :: FARKodeGetNumLinSolvSetups public :: FARKodeGetCurrentTime public :: FARKodeGetCurrentState @@ -986,6 +989,23 @@ function swigc_FARKodeSetMaxNumConstrFails(farg1, farg2) & integer(C_INT) :: fresult end function +function swigc_FARKodeSetAccumulatedErrorType(farg1, farg2) & +bind(C, name="_wrap_FARKodeSetAccumulatedErrorType") & +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_FARKodeResetAccumulatedError(farg1) & +bind(C, name="_wrap_FARKodeResetAccumulatedError") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +type(C_PTR), value :: farg1 +integer(C_INT) :: fresult +end function + function swigc_FARKodeEvolve(farg1, farg2, farg3, farg4, farg5) & bind(C, name="_wrap_FARKodeEvolve") & result(fresult) @@ -1210,6 +1230,15 @@ function swigc_FARKodeGetStepStats(farg1, farg2, farg3, farg4, farg5, farg6) & integer(C_INT) :: fresult end function +function swigc_FARKodeGetAccumulatedError(farg1, farg2) & +bind(C, name="_wrap_FARKodeGetAccumulatedError") & +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_FARKodeGetNumLinSolvSetups(farg1, farg2) & bind(C, name="_wrap_FARKodeGetNumLinSolvSetups") & result(fresult) @@ -3315,6 +3344,35 @@ function FARKodeSetMaxNumConstrFails(arkode_mem, maxfails) & swig_result = fresult end function +function FARKodeSetAccumulatedErrorType(arkode_mem, accum_type) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(C_PTR) :: arkode_mem +integer(C_INT), intent(in) :: accum_type +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +integer(C_INT) :: farg2 + +farg1 = arkode_mem +farg2 = accum_type +fresult = swigc_FARKodeSetAccumulatedErrorType(farg1, farg2) +swig_result = fresult +end function + +function FARKodeResetAccumulatedError(arkode_mem) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(C_PTR) :: arkode_mem +integer(C_INT) :: fresult +type(C_PTR) :: farg1 + +farg1 = arkode_mem +fresult = swigc_FARKodeResetAccumulatedError(farg1) +swig_result = fresult +end function + function FARKodeEvolve(arkode_mem, tout, yout, tret, itask) & result(swig_result) use, intrinsic :: ISO_C_BINDING @@ -3731,6 +3789,22 @@ function FARKodeGetStepStats(arkode_mem, nsteps, hinused, hlast, hcur, tcur) & swig_result = fresult end function +function FARKodeGetAccumulatedError(arkode_mem, accum_error) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(C_PTR) :: arkode_mem +real(C_DOUBLE), dimension(*), target, intent(inout) :: accum_error +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 + +farg1 = arkode_mem +farg2 = c_loc(accum_error(1)) +fresult = swigc_FARKodeGetAccumulatedError(farg1, farg2) +swig_result = fresult +end function + function FARKodeGetNumLinSolvSetups(arkode_mem, nlinsetups) & result(swig_result) use, intrinsic :: ISO_C_BINDING diff --git a/src/arkode/fmod_int64/farkode_mristep_mod.c b/src/arkode/fmod_int64/farkode_mristep_mod.c index c2e254fa54..dbb3438d16 100644 --- a/src/arkode/fmod_int64/farkode_mristep_mod.c +++ b/src/arkode/fmod_int64/farkode_mristep_mod.c @@ -308,6 +308,30 @@ SWIGINTERN SwigArrayWrapper SwigArrayWrapper_uninitialized() { return result; } +SWIGEXPORT void _wrap_MRIStepCouplingMem_type_set(SwigClassWrapper const *farg1, int const *farg2) { + struct MRIStepCouplingMem *arg1 = (struct MRIStepCouplingMem *) 0 ; + MRISTEP_METHOD_TYPE arg2 ; + + SWIG_check_mutable_nonnull(*farg1, "struct MRIStepCouplingMem *", "MRIStepCouplingMem", "MRIStepCouplingMem::type", return ); + arg1 = (struct MRIStepCouplingMem *)(farg1->cptr); + arg2 = (MRISTEP_METHOD_TYPE)(*farg2); + if (arg1) (arg1)->type = arg2; +} + + +SWIGEXPORT int _wrap_MRIStepCouplingMem_type_get(SwigClassWrapper const *farg1) { + int fresult ; + struct MRIStepCouplingMem *arg1 = (struct MRIStepCouplingMem *) 0 ; + MRISTEP_METHOD_TYPE result; + + SWIG_check_mutable_nonnull(*farg1, "struct MRIStepCouplingMem *", "MRIStepCouplingMem", "MRIStepCouplingMem::type", return 0); + arg1 = (struct MRIStepCouplingMem *)(farg1->cptr); + result = (MRISTEP_METHOD_TYPE) ((arg1)->type); + fresult = (int)(result); + return fresult; +} + + SWIGEXPORT void _wrap_MRIStepCouplingMem_nmat_set(SwigClassWrapper const *farg1, int const *farg2) { struct MRIStepCouplingMem *arg1 = (struct MRIStepCouplingMem *) 0 ; int arg2 ; @@ -476,6 +500,54 @@ SWIGEXPORT void * _wrap_MRIStepCouplingMem_G_get(SwigClassWrapper const *farg1) } +SWIGEXPORT void _wrap_MRIStepCouplingMem_ngroup_set(SwigClassWrapper const *farg1, int const *farg2) { + struct MRIStepCouplingMem *arg1 = (struct MRIStepCouplingMem *) 0 ; + int arg2 ; + + SWIG_check_mutable_nonnull(*farg1, "struct MRIStepCouplingMem *", "MRIStepCouplingMem", "MRIStepCouplingMem::ngroup", return ); + arg1 = (struct MRIStepCouplingMem *)(farg1->cptr); + arg2 = (int)(*farg2); + if (arg1) (arg1)->ngroup = arg2; +} + + +SWIGEXPORT int _wrap_MRIStepCouplingMem_ngroup_get(SwigClassWrapper const *farg1) { + int fresult ; + struct MRIStepCouplingMem *arg1 = (struct MRIStepCouplingMem *) 0 ; + int result; + + SWIG_check_mutable_nonnull(*farg1, "struct MRIStepCouplingMem *", "MRIStepCouplingMem", "MRIStepCouplingMem::ngroup", return 0); + arg1 = (struct MRIStepCouplingMem *)(farg1->cptr); + result = (int) ((arg1)->ngroup); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT void _wrap_MRIStepCouplingMem_group_set(SwigClassWrapper const *farg1, void *farg2) { + struct MRIStepCouplingMem *arg1 = (struct MRIStepCouplingMem *) 0 ; + int **arg2 = (int **) 0 ; + + SWIG_check_mutable_nonnull(*farg1, "struct MRIStepCouplingMem *", "MRIStepCouplingMem", "MRIStepCouplingMem::group", return ); + arg1 = (struct MRIStepCouplingMem *)(farg1->cptr); + arg2 = (int **)(farg2); + if (arg1) (arg1)->group = arg2; +} + + +SWIGEXPORT void * _wrap_MRIStepCouplingMem_group_get(SwigClassWrapper const *farg1) { + void * fresult ; + struct MRIStepCouplingMem *arg1 = (struct MRIStepCouplingMem *) 0 ; + int **result = 0 ; + + SWIG_check_mutable_nonnull(*farg1, "struct MRIStepCouplingMem *", "MRIStepCouplingMem", "MRIStepCouplingMem::group", return 0); + arg1 = (struct MRIStepCouplingMem *)(farg1->cptr); + result = (int **) ((arg1)->group); + fresult = result; + return fresult; +} + + SWIGEXPORT SwigClassWrapper _wrap_new_MRIStepCouplingMem() { SwigClassWrapper fresult ; struct MRIStepCouplingMem *result = 0 ; @@ -713,6 +785,34 @@ SWIGEXPORT int _wrap_FMRIStepSetPostInnerFn(void *farg1, MRIStepPostInnerFn farg } +SWIGEXPORT int _wrap_FMRIStepSetFastErrorStepFactor(void *farg1, double const *farg2) { + int fresult ; + void *arg1 = (void *) 0 ; + sunrealtype arg2 ; + int result; + + arg1 = (void *)(farg1); + arg2 = (sunrealtype)(*farg2); + result = (int)MRIStepSetFastErrorStepFactor(arg1,arg2); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FMRIStepSetAdaptController(void *farg1, SUNAdaptController farg2) { + int fresult ; + void *arg1 = (void *) 0 ; + SUNAdaptController arg2 = (SUNAdaptController) 0 ; + int result; + + arg1 = (void *)(farg1); + arg2 = (SUNAdaptController)(farg2); + result = (int)MRIStepSetAdaptController(arg1,arg2); + fresult = (int)(result); + return fresult; +} + + SWIGEXPORT int _wrap_FMRIStepGetNumRhsEvals(void *farg1, long *farg2, long *farg3) { int fresult ; void *arg1 = (void *) 0 ; @@ -853,6 +953,62 @@ SWIGEXPORT int _wrap_FMRIStepInnerStepper_SetResetFn(void *farg1, MRIStepInnerRe } +SWIGEXPORT int _wrap_FMRIStepInnerStepper_SetAccumulatedErrorGetFn(void *farg1, MRIStepInnerGetAccumulatedError farg2) { + int fresult ; + MRIStepInnerStepper arg1 = (MRIStepInnerStepper) 0 ; + MRIStepInnerGetAccumulatedError arg2 = (MRIStepInnerGetAccumulatedError) 0 ; + int result; + + arg1 = (MRIStepInnerStepper)(farg1); + arg2 = (MRIStepInnerGetAccumulatedError)(farg2); + result = (int)MRIStepInnerStepper_SetAccumulatedErrorGetFn(arg1,arg2); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FMRIStepInnerStepper_SetAccumulatedErrorResetFn(void *farg1, MRIStepInnerResetAccumulatedError farg2) { + int fresult ; + MRIStepInnerStepper arg1 = (MRIStepInnerStepper) 0 ; + MRIStepInnerResetAccumulatedError arg2 = (MRIStepInnerResetAccumulatedError) 0 ; + int result; + + arg1 = (MRIStepInnerStepper)(farg1); + arg2 = (MRIStepInnerResetAccumulatedError)(farg2); + result = (int)MRIStepInnerStepper_SetAccumulatedErrorResetFn(arg1,arg2); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FMRIStepInnerStepper_SetFixedStepFn(void *farg1, MRIStepInnerSetFixedStep farg2) { + int fresult ; + MRIStepInnerStepper arg1 = (MRIStepInnerStepper) 0 ; + MRIStepInnerSetFixedStep arg2 = (MRIStepInnerSetFixedStep) 0 ; + int result; + + arg1 = (MRIStepInnerStepper)(farg1); + arg2 = (MRIStepInnerSetFixedStep)(farg2); + result = (int)MRIStepInnerStepper_SetFixedStepFn(arg1,arg2); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FMRIStepInnerStepper_SetRTolFn(void *farg1, MRIStepInnerSetRTol farg2) { + int fresult ; + MRIStepInnerStepper arg1 = (MRIStepInnerStepper) 0 ; + MRIStepInnerSetRTol arg2 = (MRIStepInnerSetRTol) 0 ; + int result; + + arg1 = (MRIStepInnerStepper)(farg1); + arg2 = (MRIStepInnerSetRTol)(farg2); + result = (int)MRIStepInnerStepper_SetRTolFn(arg1,arg2); + fresult = (int)(result); + return fresult; +} + + SWIGEXPORT int _wrap_FMRIStepInnerStepper_AddForcing(void *farg1, double const *farg2, N_Vector farg3) { int fresult ; MRIStepInnerStepper arg1 = (MRIStepInnerStepper) 0 ; diff --git a/src/arkode/fmod_int64/farkode_mristep_mod.f90 b/src/arkode/fmod_int64/farkode_mristep_mod.f90 index 782c3c1df9..6654b0f9ae 100644 --- a/src/arkode/fmod_int64/farkode_mristep_mod.f90 +++ b/src/arkode/fmod_int64/farkode_mristep_mod.f90 @@ -31,9 +31,11 @@ module farkode_mristep_mod enumerator :: MRISTEP_EXPLICIT enumerator :: MRISTEP_IMPLICIT enumerator :: MRISTEP_IMEX + enumerator :: MRISTEP_MERK + enumerator :: MRISTEP_MRISR end enum integer, parameter, public :: MRISTEP_METHOD_TYPE = kind(MRISTEP_EXPLICIT) - public :: MRISTEP_EXPLICIT, MRISTEP_IMPLICIT, MRISTEP_IMEX + public :: MRISTEP_EXPLICIT, MRISTEP_IMPLICIT, MRISTEP_IMEX, MRISTEP_MERK, MRISTEP_MRISR ! typedef enum ARKODE_MRITableID enum, bind(c) enumerator :: ARKODE_MRI_NONE = -1 @@ -57,7 +59,14 @@ module farkode_mristep_mod enumerator :: ARKODE_IMEX_MRI_GARK_EULER enumerator :: ARKODE_IMEX_MRI_GARK_TRAPEZOIDAL enumerator :: ARKODE_IMEX_MRI_GARK_MIDPOINT - enumerator :: ARKODE_MAX_MRI_NUM = ARKODE_IMEX_MRI_GARK_MIDPOINT + enumerator :: ARKODE_MERK21 + enumerator :: ARKODE_MERK32 + enumerator :: ARKODE_MERK43 + enumerator :: ARKODE_MERK54 + enumerator :: ARKODE_IMEX_MRI_SR21 + enumerator :: ARKODE_IMEX_MRI_SR32 + enumerator :: ARKODE_IMEX_MRI_SR43 + enumerator :: ARKODE_MAX_MRI_NUM = ARKODE_IMEX_MRI_SR43 end enum integer, parameter, public :: ARKODE_MRITableID = kind(ARKODE_MRI_NONE) public :: ARKODE_MRI_NONE, ARKODE_MIN_MRI_NUM, ARKODE_MIS_KW3, ARKODE_MRI_GARK_ERK33a, ARKODE_MRI_GARK_ERK45a, & @@ -65,7 +74,8 @@ module farkode_mristep_mod ARKODE_IMEX_MRI_GARK3b, ARKODE_IMEX_MRI_GARK4, ARKODE_MRI_GARK_FORWARD_EULER, ARKODE_MRI_GARK_RALSTON2, & ARKODE_MRI_GARK_ERK22a, ARKODE_MRI_GARK_ERK22b, ARKODE_MRI_GARK_RALSTON3, ARKODE_MRI_GARK_BACKWARD_EULER, & ARKODE_MRI_GARK_IMPLICIT_MIDPOINT, ARKODE_IMEX_MRI_GARK_EULER, ARKODE_IMEX_MRI_GARK_TRAPEZOIDAL, & - ARKODE_IMEX_MRI_GARK_MIDPOINT, ARKODE_MAX_MRI_NUM + ARKODE_IMEX_MRI_GARK_MIDPOINT, ARKODE_MERK21, ARKODE_MERK32, ARKODE_MERK43, ARKODE_MERK54, ARKODE_IMEX_MRI_SR21, & + ARKODE_IMEX_MRI_SR32, ARKODE_IMEX_MRI_SR43, ARKODE_MAX_MRI_NUM integer(C_INT), parameter, public :: MRISTEP_DEFAULT_EXPL_1 = ARKODE_MRI_GARK_FORWARD_EULER integer(C_INT), parameter, public :: MRISTEP_DEFAULT_EXPL_2 = ARKODE_MRI_GARK_ERK22b integer(C_INT), parameter, public :: MRISTEP_DEFAULT_EXPL_3 = ARKODE_MIS_KW3 @@ -78,6 +88,13 @@ module farkode_mristep_mod integer(C_INT), parameter, public :: MRISTEP_DEFAULT_IMEX_SD_2 = ARKODE_IMEX_MRI_GARK_TRAPEZOIDAL integer(C_INT), parameter, public :: MRISTEP_DEFAULT_IMEX_SD_3 = ARKODE_IMEX_MRI_GARK3b integer(C_INT), parameter, public :: MRISTEP_DEFAULT_IMEX_SD_4 = ARKODE_IMEX_MRI_GARK4 + integer(C_INT), parameter, public :: MRISTEP_DEFAULT_EXPL_2_AD = ARKODE_MRI_GARK_ERK22a + integer(C_INT), parameter, public :: MRISTEP_DEFAULT_EXPL_3_AD = ARKODE_MRI_GARK_ERK33a + integer(C_INT), parameter, public :: MRISTEP_DEFAULT_EXPL_4_AD = ARKODE_MRI_GARK_ERK45a + integer(C_INT), parameter, public :: MRISTEP_DEFAULT_EXPL_5_AD = ARKODE_MERK54 + integer(C_INT), parameter, public :: MRISTEP_DEFAULT_IMEX_SD_2_AD = ARKODE_IMEX_MRI_SR21 + integer(C_INT), parameter, public :: MRISTEP_DEFAULT_IMEX_SD_3_AD = ARKODE_IMEX_MRI_SR32 + integer(C_INT), parameter, public :: MRISTEP_DEFAULT_IMEX_SD_4_AD = ARKODE_IMEX_MRI_SR43 integer, parameter :: swig_cmem_own_bit = 0 integer, parameter :: swig_cmem_rvalue_bit = 1 @@ -90,6 +107,8 @@ module farkode_mristep_mod type, public :: MRIStepCouplingMem type(SwigClassWrapper), public :: swigdata contains + procedure :: set_type => swigf_MRIStepCouplingMem_type_set + procedure :: get_type => swigf_MRIStepCouplingMem_type_get procedure :: set_nmat => swigf_MRIStepCouplingMem_nmat_set procedure :: get_nmat => swigf_MRIStepCouplingMem_nmat_get procedure :: set_stages => swigf_MRIStepCouplingMem_stages_set @@ -104,6 +123,10 @@ module farkode_mristep_mod procedure :: get_W => swigf_MRIStepCouplingMem_W_get procedure :: set_G => swigf_MRIStepCouplingMem_G_set procedure :: get_G => swigf_MRIStepCouplingMem_G_get + procedure :: set_ngroup => swigf_MRIStepCouplingMem_ngroup_set + procedure :: get_ngroup => swigf_MRIStepCouplingMem_ngroup_get + procedure :: set_group => swigf_MRIStepCouplingMem_group_set + procedure :: get_group => swigf_MRIStepCouplingMem_group_get procedure :: release => swigf_release_MRIStepCouplingMem procedure, private :: swigf_MRIStepCouplingMem_op_assign__ generic :: assignment(=) => swigf_MRIStepCouplingMem_op_assign__ @@ -129,6 +152,8 @@ module farkode_mristep_mod public :: FMRIStepSetCoupling public :: FMRIStepSetPreInnerFn public :: FMRIStepSetPostInnerFn + public :: FMRIStepSetFastErrorStepFactor + public :: FMRIStepSetAdaptController public :: FMRIStepGetNumRhsEvals public :: FMRIStepGetCurrentCoupling public :: FMRIStepGetLastInnerStepFlag @@ -139,6 +164,10 @@ module farkode_mristep_mod public :: FMRIStepInnerStepper_SetEvolveFn public :: FMRIStepInnerStepper_SetFullRhsFn public :: FMRIStepInnerStepper_SetResetFn + public :: FMRIStepInnerStepper_SetAccumulatedErrorGetFn + public :: FMRIStepInnerStepper_SetAccumulatedErrorResetFn + public :: FMRIStepInnerStepper_SetFixedStepFn + public :: FMRIStepInnerStepper_SetRTolFn public :: FMRIStepInnerStepper_AddForcing public :: FMRIStepInnerStepper_GetForcingData public :: FMRIStepResize @@ -229,6 +258,23 @@ module farkode_mristep_mod ! WRAPPER DECLARATIONS interface +subroutine swigc_MRIStepCouplingMem_type_set(farg1, farg2) & +bind(C, name="_wrap_MRIStepCouplingMem_type_set") +use, intrinsic :: ISO_C_BINDING +import :: swigclasswrapper +type(SwigClassWrapper) :: farg1 +integer(C_INT), intent(in) :: farg2 +end subroutine + +function swigc_MRIStepCouplingMem_type_get(farg1) & +bind(C, name="_wrap_MRIStepCouplingMem_type_get") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +import :: swigclasswrapper +type(SwigClassWrapper) :: farg1 +integer(C_INT) :: fresult +end function + subroutine swigc_MRIStepCouplingMem_nmat_set(farg1, farg2) & bind(C, name="_wrap_MRIStepCouplingMem_nmat_set") use, intrinsic :: ISO_C_BINDING @@ -348,6 +394,40 @@ function swigc_MRIStepCouplingMem_G_get(farg1) & type(C_PTR) :: fresult end function +subroutine swigc_MRIStepCouplingMem_ngroup_set(farg1, farg2) & +bind(C, name="_wrap_MRIStepCouplingMem_ngroup_set") +use, intrinsic :: ISO_C_BINDING +import :: swigclasswrapper +type(SwigClassWrapper) :: farg1 +integer(C_INT), intent(in) :: farg2 +end subroutine + +function swigc_MRIStepCouplingMem_ngroup_get(farg1) & +bind(C, name="_wrap_MRIStepCouplingMem_ngroup_get") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +import :: swigclasswrapper +type(SwigClassWrapper) :: farg1 +integer(C_INT) :: fresult +end function + +subroutine swigc_MRIStepCouplingMem_group_set(farg1, farg2) & +bind(C, name="_wrap_MRIStepCouplingMem_group_set") +use, intrinsic :: ISO_C_BINDING +import :: swigclasswrapper +type(SwigClassWrapper) :: farg1 +type(C_PTR), value :: farg2 +end subroutine + +function swigc_MRIStepCouplingMem_group_get(farg1) & +bind(C, name="_wrap_MRIStepCouplingMem_group_get") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +import :: swigclasswrapper +type(SwigClassWrapper) :: farg1 +type(C_PTR) :: fresult +end function + function swigc_new_MRIStepCouplingMem() & bind(C, name="_wrap_new_MRIStepCouplingMem") & result(fresult) @@ -503,6 +583,24 @@ function swigc_FMRIStepSetPostInnerFn(farg1, farg2) & integer(C_INT) :: fresult end function +function swigc_FMRIStepSetFastErrorStepFactor(farg1, farg2) & +bind(C, name="_wrap_FMRIStepSetFastErrorStepFactor") & +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_FMRIStepSetAdaptController(farg1, farg2) & +bind(C, name="_wrap_FMRIStepSetAdaptController") & +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_FMRIStepGetNumRhsEvals(farg1, farg2, farg3) & bind(C, name="_wrap_FMRIStepGetNumRhsEvals") & result(fresult) @@ -593,6 +691,42 @@ function swigc_FMRIStepInnerStepper_SetResetFn(farg1, farg2) & integer(C_INT) :: fresult end function +function swigc_FMRIStepInnerStepper_SetAccumulatedErrorGetFn(farg1, farg2) & +bind(C, name="_wrap_FMRIStepInnerStepper_SetAccumulatedErrorGetFn") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +type(C_PTR), value :: farg1 +type(C_FUNPTR), value :: farg2 +integer(C_INT) :: fresult +end function + +function swigc_FMRIStepInnerStepper_SetAccumulatedErrorResetFn(farg1, farg2) & +bind(C, name="_wrap_FMRIStepInnerStepper_SetAccumulatedErrorResetFn") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +type(C_PTR), value :: farg1 +type(C_FUNPTR), value :: farg2 +integer(C_INT) :: fresult +end function + +function swigc_FMRIStepInnerStepper_SetFixedStepFn(farg1, farg2) & +bind(C, name="_wrap_FMRIStepInnerStepper_SetFixedStepFn") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +type(C_PTR), value :: farg1 +type(C_FUNPTR), value :: farg2 +integer(C_INT) :: fresult +end function + +function swigc_FMRIStepInnerStepper_SetRTolFn(farg1, farg2) & +bind(C, name="_wrap_FMRIStepInnerStepper_SetRTolFn") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +type(C_PTR), value :: farg1 +type(C_FUNPTR), value :: farg2 +integer(C_INT) :: fresult +end function + function swigc_FMRIStepInnerStepper_AddForcing(farg1, farg2, farg3) & bind(C, name="_wrap_FMRIStepInnerStepper_AddForcing") & result(fresult) @@ -1407,6 +1541,31 @@ subroutine swigc_FMRIStepPrintMem(farg1, farg2) & contains ! MODULE SUBPROGRAMS +subroutine swigf_MRIStepCouplingMem_type_set(self, type) +use, intrinsic :: ISO_C_BINDING +class(MRIStepCouplingMem), intent(in) :: self +integer(MRISTEP_METHOD_TYPE), intent(in) :: type +type(SwigClassWrapper) :: farg1 +integer(C_INT) :: farg2 + +farg1 = self%swigdata +farg2 = type +call swigc_MRIStepCouplingMem_type_set(farg1, farg2) +end subroutine + +function swigf_MRIStepCouplingMem_type_get(self) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(MRISTEP_METHOD_TYPE) :: swig_result +class(MRIStepCouplingMem), intent(in) :: self +integer(C_INT) :: fresult +type(SwigClassWrapper) :: farg1 + +farg1 = self%swigdata +fresult = swigc_MRIStepCouplingMem_type_get(farg1) +swig_result = fresult +end function + subroutine swigf_MRIStepCouplingMem_nmat_set(self, nmat) use, intrinsic :: ISO_C_BINDING class(MRIStepCouplingMem), intent(in) :: self @@ -1582,6 +1741,56 @@ function swigf_MRIStepCouplingMem_G_get(self) & call c_f_pointer(fresult, swig_result) end function +subroutine swigf_MRIStepCouplingMem_ngroup_set(self, ngroup) +use, intrinsic :: ISO_C_BINDING +class(MRIStepCouplingMem), intent(in) :: self +integer(C_INT), intent(in) :: ngroup +type(SwigClassWrapper) :: farg1 +integer(C_INT) :: farg2 + +farg1 = self%swigdata +farg2 = ngroup +call swigc_MRIStepCouplingMem_ngroup_set(farg1, farg2) +end subroutine + +function swigf_MRIStepCouplingMem_ngroup_get(self) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +class(MRIStepCouplingMem), intent(in) :: self +integer(C_INT) :: fresult +type(SwigClassWrapper) :: farg1 + +farg1 = self%swigdata +fresult = swigc_MRIStepCouplingMem_ngroup_get(farg1) +swig_result = fresult +end function + +subroutine swigf_MRIStepCouplingMem_group_set(self, group) +use, intrinsic :: ISO_C_BINDING +class(MRIStepCouplingMem), intent(in) :: self +type(C_PTR), target, intent(inout) :: group +type(SwigClassWrapper) :: farg1 +type(C_PTR) :: farg2 + +farg1 = self%swigdata +farg2 = c_loc(group) +call swigc_MRIStepCouplingMem_group_set(farg1, farg2) +end subroutine + +function swigf_MRIStepCouplingMem_group_get(self) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +type(C_PTR), pointer :: swig_result +class(MRIStepCouplingMem), intent(in) :: self +type(C_PTR) :: fresult +type(SwigClassWrapper) :: farg1 + +farg1 = self%swigdata +fresult = swigc_MRIStepCouplingMem_group_get(farg1) +call c_f_pointer(fresult, swig_result) +end function + function swigf_create_MRIStepCouplingMem() & result(self) use, intrinsic :: ISO_C_BINDING @@ -1883,6 +2092,38 @@ function FMRIStepSetPostInnerFn(arkode_mem, postfn) & swig_result = fresult end function +function FMRIStepSetFastErrorStepFactor(arkode_mem, hfactor) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(C_PTR) :: arkode_mem +real(C_DOUBLE), intent(in) :: hfactor +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +real(C_DOUBLE) :: farg2 + +farg1 = arkode_mem +farg2 = hfactor +fresult = swigc_FMRIStepSetFastErrorStepFactor(farg1, farg2) +swig_result = fresult +end function + +function FMRIStepSetAdaptController(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_FMRIStepSetAdaptController(farg1, farg2) +swig_result = fresult +end function + function FMRIStepGetNumRhsEvals(arkode_mem, nfse_evals, nfsi_evals) & result(swig_result) use, intrinsic :: ISO_C_BINDING @@ -2043,6 +2284,70 @@ function FMRIStepInnerStepper_SetResetFn(stepper, fn) & swig_result = fresult end function +function FMRIStepInnerStepper_SetAccumulatedErrorGetFn(stepper, fn) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(C_PTR) :: stepper +type(C_FUNPTR), intent(in), value :: fn +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_FUNPTR) :: farg2 + +farg1 = stepper +farg2 = fn +fresult = swigc_FMRIStepInnerStepper_SetAccumulatedErrorGetFn(farg1, farg2) +swig_result = fresult +end function + +function FMRIStepInnerStepper_SetAccumulatedErrorResetFn(stepper, fn) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(C_PTR) :: stepper +type(C_FUNPTR), intent(in), value :: fn +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_FUNPTR) :: farg2 + +farg1 = stepper +farg2 = fn +fresult = swigc_FMRIStepInnerStepper_SetAccumulatedErrorResetFn(farg1, farg2) +swig_result = fresult +end function + +function FMRIStepInnerStepper_SetFixedStepFn(stepper, fn) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(C_PTR) :: stepper +type(C_FUNPTR), intent(in), value :: fn +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_FUNPTR) :: farg2 + +farg1 = stepper +farg2 = fn +fresult = swigc_FMRIStepInnerStepper_SetFixedStepFn(farg1, farg2) +swig_result = fresult +end function + +function FMRIStepInnerStepper_SetRTolFn(stepper, fn) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(C_PTR) :: stepper +type(C_FUNPTR), intent(in), value :: fn +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_FUNPTR) :: farg2 + +farg1 = stepper +farg2 = fn +fresult = swigc_FMRIStepInnerStepper_SetRTolFn(farg1, farg2) +swig_result = fresult +end function + function FMRIStepInnerStepper_AddForcing(stepper, t, f) & result(swig_result) use, intrinsic :: ISO_C_BINDING diff --git a/src/sunadaptcontroller/CMakeLists.txt b/src/sunadaptcontroller/CMakeLists.txt index f82df5e169..544a59d062 100644 --- a/src/sunadaptcontroller/CMakeLists.txt +++ b/src/sunadaptcontroller/CMakeLists.txt @@ -11,9 +11,14 @@ # SPDX-License-Identifier: BSD-3-Clause # SUNDIALS Copyright End # ------------------------------------------------------------------------------ -# controller level CMakeLists.txt for SUNDIALS +# adaptivity controller level CMakeLists.txt for SUNDIALS # ------------------------------------------------------------------------------ -# required native matrices +# required native adaptivity controllers add_subdirectory(imexgus) add_subdirectory(soderlind) +add_subdirectory(mricc) +add_subdirectory(mrihtol) +add_subdirectory(mrill) +add_subdirectory(mripi) +add_subdirectory(mripid) diff --git a/src/sunadaptcontroller/mricc/CMakeLists.txt b/src/sunadaptcontroller/mricc/CMakeLists.txt new file mode 100644 index 0000000000..7095010357 --- /dev/null +++ b/src/sunadaptcontroller/mricc/CMakeLists.txt @@ -0,0 +1,28 @@ +# --------------------------------------------------------------- +# Programmer(s): Daniel R. Reynolds @ SMU +# --------------------------------------------------------------- +# SUNDIALS Copyright Start +# Copyright (c) 2002-2024, 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_sunadaptcontrollermricc + SOURCES sunadaptcontroller_mricc.c + HEADERS + ${SUNDIALS_SOURCE_DIR}/include/sunadaptcontroller/sunadaptcontroller_mricc.h + LINK_LIBRARIES PUBLIC sundials_core + INCLUDE_SUBDIR sunadaptcontroller + OBJECT_LIB_ONLY) + +# Add F2003 module if the interface is enabled +if(BUILD_FORTRAN_MODULE_INTERFACE) + add_subdirectory("fmod_int${SUNDIALS_INDEX_SIZE}") +endif() diff --git a/src/sunadaptcontroller/mricc/fmod_int32/CMakeLists.txt b/src/sunadaptcontroller/mricc/fmod_int32/CMakeLists.txt new file mode 100644 index 0000000000..62a5a53deb --- /dev/null +++ b/src/sunadaptcontroller/mricc/fmod_int32/CMakeLists.txt @@ -0,0 +1,26 @@ +# --------------------------------------------------------------- +# Programmer(s): Daniel R. Reynolds @ SMU +# --------------------------------------------------------------- +# SUNDIALS Copyright Start +# Copyright (c) 2002-2024, 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_fsunadaptcontrollermricc_mod + SOURCES + fsunadaptcontroller_mricc_mod.f90 fsunadaptcontroller_mricc_mod.c + LINK_LIBRARIES + PUBLIC sundials_fcore_mod + OBJECT_LIBRARIES + OUTPUT_NAME + sundials_fsunadaptcontrollermricc_mod + OBJECT_LIB_ONLY +) + +message(STATUS "Added SUNAdaptController_MRICC F2003 interface") diff --git a/src/sunadaptcontroller/mricc/fmod_int32/fsunadaptcontroller_mricc_mod.c b/src/sunadaptcontroller/mricc/fmod_int32/fsunadaptcontroller_mricc_mod.c new file mode 100644 index 0000000000..4977082c1a --- /dev/null +++ b/src/sunadaptcontroller/mricc/fmod_int32/fsunadaptcontroller_mricc_mod.c @@ -0,0 +1,335 @@ +/* ---------------------------------------------------------------------------- + * 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-2024, 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_mricc.h" + +SWIGEXPORT SUNAdaptController _wrap_FSUNAdaptController_MRICC(void *farg1, int const *farg2) { + SUNAdaptController fresult ; + SUNContext arg1 = (SUNContext) 0 ; + int arg2 ; + SUNAdaptController result; + + arg1 = (SUNContext)(farg1); + arg2 = (int)(*farg2); + result = (SUNAdaptController)SUNAdaptController_MRICC(arg1,arg2); + fresult = result; + return fresult; +} + + +SWIGEXPORT int _wrap_FSUNAdaptController_SetParams_MRICC(SUNAdaptController farg1, double const *farg2, double const *farg3) { + int fresult ; + SUNAdaptController arg1 = (SUNAdaptController) 0 ; + sunrealtype arg2 ; + sunrealtype arg3 ; + int result; + + arg1 = (SUNAdaptController)(farg1); + arg2 = (sunrealtype)(*farg2); + arg3 = (sunrealtype)(*farg3); + result = (int)SUNAdaptController_SetParams_MRICC(arg1,arg2,arg3); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FSUNAdaptController_GetType_MRICC(SUNAdaptController farg1) { + int fresult ; + SUNAdaptController arg1 = (SUNAdaptController) 0 ; + SUNAdaptController_Type result; + + arg1 = (SUNAdaptController)(farg1); + result = (SUNAdaptController_Type)SUNAdaptController_GetType_MRICC(arg1); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FSUNAdaptController_EstimateMRISteps_MRICC(SUNAdaptController farg1, double const *farg2, double const *farg3, int const *farg4, double const *farg5, double const *farg6, double *farg7, double *farg8) { + int fresult ; + SUNAdaptController arg1 = (SUNAdaptController) 0 ; + sunrealtype arg2 ; + sunrealtype arg3 ; + int arg4 ; + sunrealtype arg5 ; + sunrealtype arg6 ; + sunrealtype *arg7 = (sunrealtype *) 0 ; + sunrealtype *arg8 = (sunrealtype *) 0 ; + int result; + + arg1 = (SUNAdaptController)(farg1); + arg2 = (sunrealtype)(*farg2); + arg3 = (sunrealtype)(*farg3); + arg4 = (int)(*farg4); + arg5 = (sunrealtype)(*farg5); + arg6 = (sunrealtype)(*farg6); + arg7 = (sunrealtype *)(farg7); + arg8 = (sunrealtype *)(farg8); + result = (int)SUNAdaptController_EstimateMRISteps_MRICC(arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FSUNAdaptController_SetDefaults_MRICC(SUNAdaptController farg1) { + int fresult ; + SUNAdaptController arg1 = (SUNAdaptController) 0 ; + int result; + + arg1 = (SUNAdaptController)(farg1); + result = (int)SUNAdaptController_SetDefaults_MRICC(arg1); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FSUNAdaptController_Write_MRICC(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_MRICC(arg1,arg2); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FSUNAdaptController_SetErrorBias_MRICC(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_MRICC(arg1,arg2); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FSUNAdaptController_Space_MRICC(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_MRICC(arg1,arg2,arg3); + fresult = (int)(result); + return fresult; +} + + + diff --git a/src/sunadaptcontroller/mricc/fmod_int32/fsunadaptcontroller_mricc_mod.f90 b/src/sunadaptcontroller/mricc/fmod_int32/fsunadaptcontroller_mricc_mod.f90 new file mode 100644 index 0000000000..288998e74f --- /dev/null +++ b/src/sunadaptcontroller/mricc/fmod_int32/fsunadaptcontroller_mricc_mod.f90 @@ -0,0 +1,269 @@ +! 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-2024, 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_mricc_mod + use, intrinsic :: ISO_C_BINDING + use fsundials_core_mod + implicit none + private + + ! DECLARATION CONSTRUCTS + public :: FSUNAdaptController_MRICC + public :: FSUNAdaptController_SetParams_MRICC + public :: FSUNAdaptController_GetType_MRICC + public :: FSUNAdaptController_EstimateMRISteps_MRICC + public :: FSUNAdaptController_SetDefaults_MRICC + public :: FSUNAdaptController_Write_MRICC + public :: FSUNAdaptController_SetErrorBias_MRICC + public :: FSUNAdaptController_Space_MRICC + +! WRAPPER DECLARATIONS +interface +function swigc_FSUNAdaptController_MRICC(farg1, farg2) & +bind(C, name="_wrap_FSUNAdaptController_MRICC") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +type(C_PTR), value :: farg1 +integer(C_INT), intent(in) :: farg2 +type(C_PTR) :: fresult +end function + +function swigc_FSUNAdaptController_SetParams_MRICC(farg1, farg2, farg3) & +bind(C, name="_wrap_FSUNAdaptController_SetParams_MRICC") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +type(C_PTR), value :: farg1 +real(C_DOUBLE), intent(in) :: farg2 +real(C_DOUBLE), intent(in) :: farg3 +integer(C_INT) :: fresult +end function + +function swigc_FSUNAdaptController_GetType_MRICC(farg1) & +bind(C, name="_wrap_FSUNAdaptController_GetType_MRICC") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +type(C_PTR), value :: farg1 +integer(C_INT) :: fresult +end function + +function swigc_FSUNAdaptController_EstimateMRISteps_MRICC(farg1, farg2, farg3, farg4, farg5, farg6, farg7, farg8) & +bind(C, name="_wrap_FSUNAdaptController_EstimateMRISteps_MRICC") & +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 +real(C_DOUBLE), intent(in) :: farg5 +real(C_DOUBLE), intent(in) :: farg6 +type(C_PTR), value :: farg7 +type(C_PTR), value :: farg8 +integer(C_INT) :: fresult +end function + +function swigc_FSUNAdaptController_SetDefaults_MRICC(farg1) & +bind(C, name="_wrap_FSUNAdaptController_SetDefaults_MRICC") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +type(C_PTR), value :: farg1 +integer(C_INT) :: fresult +end function + +function swigc_FSUNAdaptController_Write_MRICC(farg1, farg2) & +bind(C, name="_wrap_FSUNAdaptController_Write_MRICC") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +type(C_PTR), value :: farg1 +type(C_PTR), value :: farg2 +integer(C_INT) :: fresult +end function + +function swigc_FSUNAdaptController_SetErrorBias_MRICC(farg1, farg2) & +bind(C, name="_wrap_FSUNAdaptController_SetErrorBias_MRICC") & +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_MRICC(farg1, farg2, farg3) & +bind(C, name="_wrap_FSUNAdaptController_Space_MRICC") & +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_MRICC(sunctx, p) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +type(SUNAdaptController), pointer :: swig_result +type(C_PTR) :: sunctx +integer(C_INT), intent(in) :: p +type(C_PTR) :: fresult +type(C_PTR) :: farg1 +integer(C_INT) :: farg2 + +farg1 = sunctx +farg2 = p +fresult = swigc_FSUNAdaptController_MRICC(farg1, farg2) +call c_f_pointer(fresult, swig_result) +end function + +function FSUNAdaptController_SetParams_MRICC(c, k1, k2) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(SUNAdaptController), target, intent(inout) :: c +real(C_DOUBLE), intent(in) :: k1 +real(C_DOUBLE), intent(in) :: k2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +real(C_DOUBLE) :: farg2 +real(C_DOUBLE) :: farg3 + +farg1 = c_loc(c) +farg2 = k1 +farg3 = k2 +fresult = swigc_FSUNAdaptController_SetParams_MRICC(farg1, farg2, farg3) +swig_result = fresult +end function + +function FSUNAdaptController_GetType_MRICC(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_MRICC(farg1) +swig_result = fresult +end function + +function FSUNAdaptController_EstimateMRISteps_MRICC(c, h, h2, p, dsm, dsm5, hnew, hnew7) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(SUNAdaptController), target, intent(inout) :: c +real(C_DOUBLE), intent(in) :: h +real(C_DOUBLE), intent(in) :: h2 +integer(C_INT), intent(in) :: p +real(C_DOUBLE), intent(in) :: dsm +real(C_DOUBLE), intent(in) :: dsm5 +real(C_DOUBLE), dimension(*), target, intent(inout) :: hnew +real(C_DOUBLE), dimension(*), target, intent(inout) :: hnew7 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +real(C_DOUBLE) :: farg2 +real(C_DOUBLE) :: farg3 +integer(C_INT) :: farg4 +real(C_DOUBLE) :: farg5 +real(C_DOUBLE) :: farg6 +type(C_PTR) :: farg7 +type(C_PTR) :: farg8 + +farg1 = c_loc(c) +farg2 = h +farg3 = h2 +farg4 = p +farg5 = dsm +farg6 = dsm5 +farg7 = c_loc(hnew(1)) +farg8 = c_loc(hnew7(1)) +fresult = swigc_FSUNAdaptController_EstimateMRISteps_MRICC(farg1, farg2, farg3, farg4, farg5, farg6, farg7, farg8) +swig_result = fresult +end function + +function FSUNAdaptController_SetDefaults_MRICC(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_MRICC(farg1) +swig_result = fresult +end function + +function FSUNAdaptController_Write_MRICC(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_MRICC(farg1, farg2) +swig_result = fresult +end function + +function FSUNAdaptController_SetErrorBias_MRICC(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_MRICC(farg1, farg2) +swig_result = fresult +end function + +function FSUNAdaptController_Space_MRICC(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_MRICC(farg1, farg2, farg3) +swig_result = fresult +end function + + +end module diff --git a/src/sunadaptcontroller/mricc/fmod_int64/CMakeLists.txt b/src/sunadaptcontroller/mricc/fmod_int64/CMakeLists.txt new file mode 100644 index 0000000000..62a5a53deb --- /dev/null +++ b/src/sunadaptcontroller/mricc/fmod_int64/CMakeLists.txt @@ -0,0 +1,26 @@ +# --------------------------------------------------------------- +# Programmer(s): Daniel R. Reynolds @ SMU +# --------------------------------------------------------------- +# SUNDIALS Copyright Start +# Copyright (c) 2002-2024, 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_fsunadaptcontrollermricc_mod + SOURCES + fsunadaptcontroller_mricc_mod.f90 fsunadaptcontroller_mricc_mod.c + LINK_LIBRARIES + PUBLIC sundials_fcore_mod + OBJECT_LIBRARIES + OUTPUT_NAME + sundials_fsunadaptcontrollermricc_mod + OBJECT_LIB_ONLY +) + +message(STATUS "Added SUNAdaptController_MRICC F2003 interface") diff --git a/src/sunadaptcontroller/mricc/fmod_int64/fsunadaptcontroller_mricc_mod.c b/src/sunadaptcontroller/mricc/fmod_int64/fsunadaptcontroller_mricc_mod.c new file mode 100644 index 0000000000..4977082c1a --- /dev/null +++ b/src/sunadaptcontroller/mricc/fmod_int64/fsunadaptcontroller_mricc_mod.c @@ -0,0 +1,335 @@ +/* ---------------------------------------------------------------------------- + * 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-2024, 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_mricc.h" + +SWIGEXPORT SUNAdaptController _wrap_FSUNAdaptController_MRICC(void *farg1, int const *farg2) { + SUNAdaptController fresult ; + SUNContext arg1 = (SUNContext) 0 ; + int arg2 ; + SUNAdaptController result; + + arg1 = (SUNContext)(farg1); + arg2 = (int)(*farg2); + result = (SUNAdaptController)SUNAdaptController_MRICC(arg1,arg2); + fresult = result; + return fresult; +} + + +SWIGEXPORT int _wrap_FSUNAdaptController_SetParams_MRICC(SUNAdaptController farg1, double const *farg2, double const *farg3) { + int fresult ; + SUNAdaptController arg1 = (SUNAdaptController) 0 ; + sunrealtype arg2 ; + sunrealtype arg3 ; + int result; + + arg1 = (SUNAdaptController)(farg1); + arg2 = (sunrealtype)(*farg2); + arg3 = (sunrealtype)(*farg3); + result = (int)SUNAdaptController_SetParams_MRICC(arg1,arg2,arg3); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FSUNAdaptController_GetType_MRICC(SUNAdaptController farg1) { + int fresult ; + SUNAdaptController arg1 = (SUNAdaptController) 0 ; + SUNAdaptController_Type result; + + arg1 = (SUNAdaptController)(farg1); + result = (SUNAdaptController_Type)SUNAdaptController_GetType_MRICC(arg1); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FSUNAdaptController_EstimateMRISteps_MRICC(SUNAdaptController farg1, double const *farg2, double const *farg3, int const *farg4, double const *farg5, double const *farg6, double *farg7, double *farg8) { + int fresult ; + SUNAdaptController arg1 = (SUNAdaptController) 0 ; + sunrealtype arg2 ; + sunrealtype arg3 ; + int arg4 ; + sunrealtype arg5 ; + sunrealtype arg6 ; + sunrealtype *arg7 = (sunrealtype *) 0 ; + sunrealtype *arg8 = (sunrealtype *) 0 ; + int result; + + arg1 = (SUNAdaptController)(farg1); + arg2 = (sunrealtype)(*farg2); + arg3 = (sunrealtype)(*farg3); + arg4 = (int)(*farg4); + arg5 = (sunrealtype)(*farg5); + arg6 = (sunrealtype)(*farg6); + arg7 = (sunrealtype *)(farg7); + arg8 = (sunrealtype *)(farg8); + result = (int)SUNAdaptController_EstimateMRISteps_MRICC(arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FSUNAdaptController_SetDefaults_MRICC(SUNAdaptController farg1) { + int fresult ; + SUNAdaptController arg1 = (SUNAdaptController) 0 ; + int result; + + arg1 = (SUNAdaptController)(farg1); + result = (int)SUNAdaptController_SetDefaults_MRICC(arg1); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FSUNAdaptController_Write_MRICC(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_MRICC(arg1,arg2); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FSUNAdaptController_SetErrorBias_MRICC(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_MRICC(arg1,arg2); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FSUNAdaptController_Space_MRICC(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_MRICC(arg1,arg2,arg3); + fresult = (int)(result); + return fresult; +} + + + diff --git a/src/sunadaptcontroller/mricc/fmod_int64/fsunadaptcontroller_mricc_mod.f90 b/src/sunadaptcontroller/mricc/fmod_int64/fsunadaptcontroller_mricc_mod.f90 new file mode 100644 index 0000000000..288998e74f --- /dev/null +++ b/src/sunadaptcontroller/mricc/fmod_int64/fsunadaptcontroller_mricc_mod.f90 @@ -0,0 +1,269 @@ +! 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-2024, 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_mricc_mod + use, intrinsic :: ISO_C_BINDING + use fsundials_core_mod + implicit none + private + + ! DECLARATION CONSTRUCTS + public :: FSUNAdaptController_MRICC + public :: FSUNAdaptController_SetParams_MRICC + public :: FSUNAdaptController_GetType_MRICC + public :: FSUNAdaptController_EstimateMRISteps_MRICC + public :: FSUNAdaptController_SetDefaults_MRICC + public :: FSUNAdaptController_Write_MRICC + public :: FSUNAdaptController_SetErrorBias_MRICC + public :: FSUNAdaptController_Space_MRICC + +! WRAPPER DECLARATIONS +interface +function swigc_FSUNAdaptController_MRICC(farg1, farg2) & +bind(C, name="_wrap_FSUNAdaptController_MRICC") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +type(C_PTR), value :: farg1 +integer(C_INT), intent(in) :: farg2 +type(C_PTR) :: fresult +end function + +function swigc_FSUNAdaptController_SetParams_MRICC(farg1, farg2, farg3) & +bind(C, name="_wrap_FSUNAdaptController_SetParams_MRICC") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +type(C_PTR), value :: farg1 +real(C_DOUBLE), intent(in) :: farg2 +real(C_DOUBLE), intent(in) :: farg3 +integer(C_INT) :: fresult +end function + +function swigc_FSUNAdaptController_GetType_MRICC(farg1) & +bind(C, name="_wrap_FSUNAdaptController_GetType_MRICC") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +type(C_PTR), value :: farg1 +integer(C_INT) :: fresult +end function + +function swigc_FSUNAdaptController_EstimateMRISteps_MRICC(farg1, farg2, farg3, farg4, farg5, farg6, farg7, farg8) & +bind(C, name="_wrap_FSUNAdaptController_EstimateMRISteps_MRICC") & +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 +real(C_DOUBLE), intent(in) :: farg5 +real(C_DOUBLE), intent(in) :: farg6 +type(C_PTR), value :: farg7 +type(C_PTR), value :: farg8 +integer(C_INT) :: fresult +end function + +function swigc_FSUNAdaptController_SetDefaults_MRICC(farg1) & +bind(C, name="_wrap_FSUNAdaptController_SetDefaults_MRICC") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +type(C_PTR), value :: farg1 +integer(C_INT) :: fresult +end function + +function swigc_FSUNAdaptController_Write_MRICC(farg1, farg2) & +bind(C, name="_wrap_FSUNAdaptController_Write_MRICC") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +type(C_PTR), value :: farg1 +type(C_PTR), value :: farg2 +integer(C_INT) :: fresult +end function + +function swigc_FSUNAdaptController_SetErrorBias_MRICC(farg1, farg2) & +bind(C, name="_wrap_FSUNAdaptController_SetErrorBias_MRICC") & +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_MRICC(farg1, farg2, farg3) & +bind(C, name="_wrap_FSUNAdaptController_Space_MRICC") & +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_MRICC(sunctx, p) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +type(SUNAdaptController), pointer :: swig_result +type(C_PTR) :: sunctx +integer(C_INT), intent(in) :: p +type(C_PTR) :: fresult +type(C_PTR) :: farg1 +integer(C_INT) :: farg2 + +farg1 = sunctx +farg2 = p +fresult = swigc_FSUNAdaptController_MRICC(farg1, farg2) +call c_f_pointer(fresult, swig_result) +end function + +function FSUNAdaptController_SetParams_MRICC(c, k1, k2) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(SUNAdaptController), target, intent(inout) :: c +real(C_DOUBLE), intent(in) :: k1 +real(C_DOUBLE), intent(in) :: k2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +real(C_DOUBLE) :: farg2 +real(C_DOUBLE) :: farg3 + +farg1 = c_loc(c) +farg2 = k1 +farg3 = k2 +fresult = swigc_FSUNAdaptController_SetParams_MRICC(farg1, farg2, farg3) +swig_result = fresult +end function + +function FSUNAdaptController_GetType_MRICC(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_MRICC(farg1) +swig_result = fresult +end function + +function FSUNAdaptController_EstimateMRISteps_MRICC(c, h, h2, p, dsm, dsm5, hnew, hnew7) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(SUNAdaptController), target, intent(inout) :: c +real(C_DOUBLE), intent(in) :: h +real(C_DOUBLE), intent(in) :: h2 +integer(C_INT), intent(in) :: p +real(C_DOUBLE), intent(in) :: dsm +real(C_DOUBLE), intent(in) :: dsm5 +real(C_DOUBLE), dimension(*), target, intent(inout) :: hnew +real(C_DOUBLE), dimension(*), target, intent(inout) :: hnew7 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +real(C_DOUBLE) :: farg2 +real(C_DOUBLE) :: farg3 +integer(C_INT) :: farg4 +real(C_DOUBLE) :: farg5 +real(C_DOUBLE) :: farg6 +type(C_PTR) :: farg7 +type(C_PTR) :: farg8 + +farg1 = c_loc(c) +farg2 = h +farg3 = h2 +farg4 = p +farg5 = dsm +farg6 = dsm5 +farg7 = c_loc(hnew(1)) +farg8 = c_loc(hnew7(1)) +fresult = swigc_FSUNAdaptController_EstimateMRISteps_MRICC(farg1, farg2, farg3, farg4, farg5, farg6, farg7, farg8) +swig_result = fresult +end function + +function FSUNAdaptController_SetDefaults_MRICC(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_MRICC(farg1) +swig_result = fresult +end function + +function FSUNAdaptController_Write_MRICC(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_MRICC(farg1, farg2) +swig_result = fresult +end function + +function FSUNAdaptController_SetErrorBias_MRICC(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_MRICC(farg1, farg2) +swig_result = fresult +end function + +function FSUNAdaptController_Space_MRICC(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_MRICC(farg1, farg2, farg3) +swig_result = fresult +end function + + +end module diff --git a/src/sunadaptcontroller/mricc/sunadaptcontroller_mricc.c b/src/sunadaptcontroller/mricc/sunadaptcontroller_mricc.c new file mode 100644 index 0000000000..be379fd3b5 --- /dev/null +++ b/src/sunadaptcontroller/mricc/sunadaptcontroller_mricc.c @@ -0,0 +1,189 @@ +/* ----------------------------------------------------------------- + * Programmer(s): Daniel R. Reynolds @ SMU + * ----------------------------------------------------------------- + * SUNDIALS Copyright Start + * Copyright (c) 2002-2024, 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_MRICC module. + * -----------------------------------------------------------------*/ + +#include +#include +#include +#include + +#include "sundials/priv/sundials_errors_impl.h" +#include "sundials/sundials_errors.h" + +/* --------------- + * Macro accessors + * --------------- */ + +#define MRICC_CONTENT(C) ((SUNAdaptControllerContent_MRICC)(C->content)) +#define MRICC_K1(C) (MRICC_CONTENT(C)->k1) +#define MRICC_K2(C) (MRICC_CONTENT(C)->k2) +#define MRICC_BIAS(C) (MRICC_CONTENT(C)->bias) +#define MRICC_PFAST(C) (MRICC_CONTENT(C)->p) + +/* ------------------ + * Default parameters + * ------------------ */ + +#define DEFAULT_K1 SUN_RCONST(0.42) +#define DEFAULT_K2 SUN_RCONST(0.44) +#define DEFAULT_BIAS SUN_RCONST(1.5) +#define ONE SUN_RCONST(1.0) +#define TINY (SUN_RCONST(10.0) * SUN_UNIT_ROUNDOFF) + +/* ----------------------------------------------------------------- + * exported functions + * ----------------------------------------------------------------- */ + +/* ----------------------------------------------------------------- + * Function to create a new MRICC controller + */ + +SUNAdaptController SUNAdaptController_MRICC(SUNContext sunctx, int p) +{ + SUNFunctionBegin(sunctx); + + SUNAdaptController C; + SUNAdaptControllerContent_MRICC content; + + /* Create an empty controller object */ + C = NULL; + C = SUNAdaptController_NewEmpty(sunctx); + SUNCheckLastErrNull(); + + /* Attach operations */ + C->ops->gettype = SUNAdaptController_GetType_MRICC; + C->ops->estimatemristeps = SUNAdaptController_EstimateMRISteps_MRICC; + C->ops->setdefaults = SUNAdaptController_SetDefaults_MRICC; + C->ops->write = SUNAdaptController_Write_MRICC; + C->ops->seterrorbias = SUNAdaptController_SetErrorBias_MRICC; + C->ops->space = SUNAdaptController_Space_MRICC; + + /* Create content */ + content = NULL; + content = (SUNAdaptControllerContent_MRICC)malloc(sizeof *content); + SUNAssertNull(content, SUN_ERR_MALLOC_FAIL); + + /* Attach content */ + C->content = content; + + /* Set fast method order */ + content->p = p; + + /* Fill content with default/reset values */ + SUNCheckCallNull(SUNAdaptController_SetDefaults_MRICC(C)); + + return (C); +} + +/* ----------------------------------------------------------------- + * Function to set MRICC parameters + */ + +SUNErrCode SUNAdaptController_SetParams_MRICC(SUNAdaptController C, + sunrealtype k1, sunrealtype k2) +{ + SUNFunctionBegin(C->sunctx); + MRICC_K1(C) = k1; + MRICC_K2(C) = k2; + return SUN_SUCCESS; +} + +/* ----------------------------------------------------------------- + * implementation of controller operations + * ----------------------------------------------------------------- */ + +SUNAdaptController_Type SUNAdaptController_GetType_MRICC(SUNAdaptController C) +{ + return SUN_ADAPTCONTROLLER_MRI_H; +} + +SUNErrCode SUNAdaptController_EstimateMRISteps_MRICC( + SUNAdaptController C, sunrealtype H, sunrealtype h, int P, sunrealtype DSM, + sunrealtype dsm, sunrealtype* Hnew, sunrealtype* hnew) +{ + SUNFunctionBegin(C->sunctx); + SUNAssert(Hnew, SUN_ERR_ARG_CORRUPT); + SUNAssert(hnew, SUN_ERR_ARG_CORRUPT); + + /* set usable time-step adaptivity parameters */ + const int p = MRICC_PFAST(C); + const sunrealtype k1 = MRICC_K1(C); + const sunrealtype k2 = MRICC_K2(C); + const sunrealtype al = k1 / P; + const sunrealtype b1 = (p + 1) * k1 / (P * p); + const sunrealtype b2 = -k2 / p; + const sunrealtype es = ONE / SUNMAX(MRICC_BIAS(C) * DSM, TINY); + const sunrealtype ef = ONE / SUNMAX(MRICC_BIAS(C) * dsm, TINY); + const sunrealtype M = SUNRceil(H / h); + + /* compute estimated optimal time step size */ + *Hnew = H * SUNRpowerR(es, al); + const sunrealtype Mnew = M * SUNRpowerR(es, b1) * SUNRpowerR(ef, b2); + *hnew = (*Hnew) / Mnew; + + /* return with success */ + return SUN_SUCCESS; +} + +SUNErrCode SUNAdaptController_SetDefaults_MRICC(SUNAdaptController C) +{ + SUNFunctionBegin(C->sunctx); + MRICC_K1(C) = DEFAULT_K1; + MRICC_K2(C) = DEFAULT_K2; + MRICC_BIAS(C) = DEFAULT_BIAS; + return SUN_SUCCESS; +} + +SUNErrCode SUNAdaptController_Write_MRICC(SUNAdaptController C, FILE* fptr) +{ + SUNFunctionBegin(C->sunctx); + SUNAssert(fptr, SUN_ERR_ARG_CORRUPT); + fprintf(fptr, "Multirate constant-constant SUNAdaptController module:\n"); +#if defined(SUNDIALS_EXTENDED_PRECISION) + fprintf(fptr, " k1 = %32Lg\n", MRICC_K1(C)); + fprintf(fptr, " k2 = %32Lg\n", MRICC_K2(C)); + fprintf(fptr, " bias factor = %32Lg\n", MRICC_BIAS(C)); +#else + fprintf(fptr, " k1 = %16g\n", MRICC_K1(C)); + fprintf(fptr, " k2 = %16g\n", MRICC_K2(C)); + fprintf(fptr, " bias factor = %16g\n", MRICC_BIAS(C)); +#endif + fprintf(fptr, " p = %i (fast method order)\n", MRICC_PFAST(C)); + return SUN_SUCCESS; +} + +SUNErrCode SUNAdaptController_SetErrorBias_MRICC(SUNAdaptController C, + sunrealtype bias) +{ + SUNFunctionBegin(C->sunctx); + + /* set allowed value, otherwise set default */ + if (bias <= SUN_RCONST(0.0)) { MRICC_BIAS(C) = DEFAULT_BIAS; } + else { MRICC_BIAS(C) = bias; } + + return SUN_SUCCESS; +} + +SUNErrCode SUNAdaptController_Space_MRICC(SUNAdaptController C, long int* lenrw, + long int* leniw) +{ + SUNFunctionBegin(C->sunctx); + SUNAssert(lenrw, SUN_ERR_ARG_CORRUPT); + SUNAssert(leniw, SUN_ERR_ARG_CORRUPT); + *lenrw = 3; + *leniw = 1; + return SUN_SUCCESS; +} diff --git a/src/sunadaptcontroller/mrihtol/CMakeLists.txt b/src/sunadaptcontroller/mrihtol/CMakeLists.txt new file mode 100644 index 0000000000..1702a5f664 --- /dev/null +++ b/src/sunadaptcontroller/mrihtol/CMakeLists.txt @@ -0,0 +1,28 @@ +# --------------------------------------------------------------- +# Programmer(s): Daniel R. Reynolds @ SMU +# --------------------------------------------------------------- +# SUNDIALS Copyright Start +# Copyright (c) 2002-2024, 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_sunadaptcontrollermrihtol + SOURCES sunadaptcontroller_mrihtol.c + HEADERS + ${SUNDIALS_SOURCE_DIR}/include/sunadaptcontroller/sunadaptcontroller_mrihtol.h + LINK_LIBRARIES PUBLIC sundials_core + INCLUDE_SUBDIR sunadaptcontroller + OBJECT_LIB_ONLY) + +# Add F2003 module if the interface is enabled +if(BUILD_FORTRAN_MODULE_INTERFACE) + add_subdirectory("fmod_int${SUNDIALS_INDEX_SIZE}") +endif() diff --git a/src/sunadaptcontroller/mrihtol/fmod_int32/CMakeLists.txt b/src/sunadaptcontroller/mrihtol/fmod_int32/CMakeLists.txt new file mode 100644 index 0000000000..7f89cd14a6 --- /dev/null +++ b/src/sunadaptcontroller/mrihtol/fmod_int32/CMakeLists.txt @@ -0,0 +1,26 @@ +# --------------------------------------------------------------- +# Programmer(s): Daniel R. Reynolds @ SMU +# --------------------------------------------------------------- +# SUNDIALS Copyright Start +# Copyright (c) 2002-2024, 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_fsunadaptcontrollermrihtol_mod + SOURCES + fsunadaptcontroller_mrihtol_mod.f90 fsunadaptcontroller_mrihtol_mod.c + LINK_LIBRARIES + PUBLIC sundials_fcore_mod + OBJECT_LIBRARIES + OUTPUT_NAME + sundials_fsunadaptcontrollermrihtol_mod + OBJECT_LIB_ONLY +) + +message(STATUS "Added SUNAdaptController_MRIHTol F2003 interface") diff --git a/src/sunadaptcontroller/mrihtol/fmod_int32/fsunadaptcontroller_mrihtol_mod.c b/src/sunadaptcontroller/mrihtol/fmod_int32/fsunadaptcontroller_mrihtol_mod.c new file mode 100644 index 0000000000..4f01ed2426 --- /dev/null +++ b/src/sunadaptcontroller/mrihtol/fmod_int32/fsunadaptcontroller_mrihtol_mod.c @@ -0,0 +1,395 @@ +/* ---------------------------------------------------------------------------- + * 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-2024, 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_mrihtol.h" + +SWIGEXPORT SUNAdaptController _wrap_FSUNAdaptController_MRIHTol(void *farg1, SUNAdaptController farg2, SUNAdaptController farg3) { + SUNAdaptController fresult ; + SUNContext arg1 = (SUNContext) 0 ; + SUNAdaptController arg2 = (SUNAdaptController) 0 ; + SUNAdaptController arg3 = (SUNAdaptController) 0 ; + SUNAdaptController result; + + arg1 = (SUNContext)(farg1); + arg2 = (SUNAdaptController)(farg2); + arg3 = (SUNAdaptController)(farg3); + result = (SUNAdaptController)SUNAdaptController_MRIHTol(arg1,arg2,arg3); + fresult = result; + return fresult; +} + + +SWIGEXPORT int _wrap_FSUNAdaptController_SetParams_MRIHTol(SUNAdaptController farg1, double const *farg2, double const *farg3, double const *farg4) { + int fresult ; + SUNAdaptController arg1 = (SUNAdaptController) 0 ; + sunrealtype arg2 ; + sunrealtype arg3 ; + sunrealtype arg4 ; + SUNErrCode result; + + arg1 = (SUNAdaptController)(farg1); + arg2 = (sunrealtype)(*farg2); + arg3 = (sunrealtype)(*farg3); + arg4 = (sunrealtype)(*farg4); + result = (SUNErrCode)SUNAdaptController_SetParams_MRIHTol(arg1,arg2,arg3,arg4); + fresult = (SUNErrCode)(result); + return fresult; +} + + +SWIGEXPORT SUNAdaptController _wrap_FSUNAdaptController_GetSlowController_MRIHTol(SUNAdaptController farg1) { + SUNAdaptController fresult ; + SUNAdaptController arg1 = (SUNAdaptController) 0 ; + SUNAdaptController result; + + arg1 = (SUNAdaptController)(farg1); + result = (SUNAdaptController)SUNAdaptController_GetSlowController_MRIHTol(arg1); + fresult = result; + return fresult; +} + + +SWIGEXPORT SUNAdaptController _wrap_FSUNAdaptController_GetFastController_MRIHTol(SUNAdaptController farg1) { + SUNAdaptController fresult ; + SUNAdaptController arg1 = (SUNAdaptController) 0 ; + SUNAdaptController result; + + arg1 = (SUNAdaptController)(farg1); + result = (SUNAdaptController)SUNAdaptController_GetFastController_MRIHTol(arg1); + fresult = result; + return fresult; +} + + +SWIGEXPORT int _wrap_FSUNAdaptController_GetType_MRIHTol(SUNAdaptController farg1) { + int fresult ; + SUNAdaptController arg1 = (SUNAdaptController) 0 ; + SUNAdaptController_Type result; + + arg1 = (SUNAdaptController)(farg1); + result = (SUNAdaptController_Type)SUNAdaptController_GetType_MRIHTol(arg1); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FSUNAdaptController_EstimateStepTol_MRIHTol(SUNAdaptController farg1, double const *farg2, double const *farg3, int const *farg4, double const *farg5, double const *farg6, double *farg7, double *farg8) { + int fresult ; + SUNAdaptController arg1 = (SUNAdaptController) 0 ; + sunrealtype arg2 ; + sunrealtype arg3 ; + int arg4 ; + sunrealtype arg5 ; + sunrealtype arg6 ; + sunrealtype *arg7 = (sunrealtype *) 0 ; + sunrealtype *arg8 = (sunrealtype *) 0 ; + int result; + + arg1 = (SUNAdaptController)(farg1); + arg2 = (sunrealtype)(*farg2); + arg3 = (sunrealtype)(*farg3); + arg4 = (int)(*farg4); + arg5 = (sunrealtype)(*farg5); + arg6 = (sunrealtype)(*farg6); + arg7 = (sunrealtype *)(farg7); + arg8 = (sunrealtype *)(farg8); + result = (int)SUNAdaptController_EstimateStepTol_MRIHTol(arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FSUNAdaptController_Reset_MRIHTol(SUNAdaptController farg1) { + int fresult ; + SUNAdaptController arg1 = (SUNAdaptController) 0 ; + int result; + + arg1 = (SUNAdaptController)(farg1); + result = (int)SUNAdaptController_Reset_MRIHTol(arg1); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FSUNAdaptController_SetDefaults_MRIHTol(SUNAdaptController farg1) { + int fresult ; + SUNAdaptController arg1 = (SUNAdaptController) 0 ; + int result; + + arg1 = (SUNAdaptController)(farg1); + result = (int)SUNAdaptController_SetDefaults_MRIHTol(arg1); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FSUNAdaptController_Write_MRIHTol(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_MRIHTol(arg1,arg2); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FSUNAdaptController_SetErrorBias_MRIHTol(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_MRIHTol(arg1,arg2); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FSUNAdaptController_UpdateMRITol_MRIHTol(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_MRIHTol(arg1,arg2,arg3,arg4,arg5); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FSUNAdaptController_Space_MRIHTol(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_MRIHTol(arg1,arg2,arg3); + fresult = (int)(result); + return fresult; +} + + + diff --git a/src/sunadaptcontroller/mrihtol/fmod_int32/fsunadaptcontroller_mrihtol_mod.f90 b/src/sunadaptcontroller/mrihtol/fmod_int32/fsunadaptcontroller_mrihtol_mod.f90 new file mode 100644 index 0000000000..19ce2d9d6f --- /dev/null +++ b/src/sunadaptcontroller/mrihtol/fmod_int32/fsunadaptcontroller_mrihtol_mod.f90 @@ -0,0 +1,381 @@ +! 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-2024, 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_mrihtol_mod + use, intrinsic :: ISO_C_BINDING + use fsundials_core_mod + implicit none + private + + ! DECLARATION CONSTRUCTS + public :: FSUNAdaptController_MRIHTol + public :: FSUNAdaptController_SetParams_MRIHTol + public :: FSUNAdaptController_GetSlowController_MRIHTol + public :: FSUNAdaptController_GetFastController_MRIHTol + public :: FSUNAdaptController_GetType_MRIHTol + public :: FSUNAdaptController_EstimateStepTol_MRIHTol + public :: FSUNAdaptController_Reset_MRIHTol + public :: FSUNAdaptController_SetDefaults_MRIHTol + public :: FSUNAdaptController_Write_MRIHTol + public :: FSUNAdaptController_SetErrorBias_MRIHTol + public :: FSUNAdaptController_UpdateMRITol_MRIHTol + public :: FSUNAdaptController_Space_MRIHTol + +! WRAPPER DECLARATIONS +interface +function swigc_FSUNAdaptController_MRIHTol(farg1, farg2, farg3) & +bind(C, name="_wrap_FSUNAdaptController_MRIHTol") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +type(C_PTR), value :: farg1 +type(C_PTR), value :: farg2 +type(C_PTR), value :: farg3 +type(C_PTR) :: fresult +end function + +function swigc_FSUNAdaptController_SetParams_MRIHTol(farg1, farg2, farg3, farg4) & +bind(C, name="_wrap_FSUNAdaptController_SetParams_MRIHTol") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +type(C_PTR), value :: farg1 +real(C_DOUBLE), intent(in) :: farg2 +real(C_DOUBLE), intent(in) :: farg3 +real(C_DOUBLE), intent(in) :: farg4 +integer(C_INT) :: fresult +end function + +function swigc_FSUNAdaptController_GetSlowController_MRIHTol(farg1) & +bind(C, name="_wrap_FSUNAdaptController_GetSlowController_MRIHTol") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +type(C_PTR), value :: farg1 +type(C_PTR) :: fresult +end function + +function swigc_FSUNAdaptController_GetFastController_MRIHTol(farg1) & +bind(C, name="_wrap_FSUNAdaptController_GetFastController_MRIHTol") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +type(C_PTR), value :: farg1 +type(C_PTR) :: fresult +end function + +function swigc_FSUNAdaptController_GetType_MRIHTol(farg1) & +bind(C, name="_wrap_FSUNAdaptController_GetType_MRIHTol") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +type(C_PTR), value :: farg1 +integer(C_INT) :: fresult +end function + +function swigc_FSUNAdaptController_EstimateStepTol_MRIHTol(farg1, farg2, farg3, farg4, farg5, farg6, farg7, farg8) & +bind(C, name="_wrap_FSUNAdaptController_EstimateStepTol_MRIHTol") & +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 +real(C_DOUBLE), intent(in) :: farg5 +real(C_DOUBLE), intent(in) :: farg6 +type(C_PTR), value :: farg7 +type(C_PTR), value :: farg8 +integer(C_INT) :: fresult +end function + +function swigc_FSUNAdaptController_Reset_MRIHTol(farg1) & +bind(C, name="_wrap_FSUNAdaptController_Reset_MRIHTol") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +type(C_PTR), value :: farg1 +integer(C_INT) :: fresult +end function + +function swigc_FSUNAdaptController_SetDefaults_MRIHTol(farg1) & +bind(C, name="_wrap_FSUNAdaptController_SetDefaults_MRIHTol") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +type(C_PTR), value :: farg1 +integer(C_INT) :: fresult +end function + +function swigc_FSUNAdaptController_Write_MRIHTol(farg1, farg2) & +bind(C, name="_wrap_FSUNAdaptController_Write_MRIHTol") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +type(C_PTR), value :: farg1 +type(C_PTR), value :: farg2 +integer(C_INT) :: fresult +end function + +function swigc_FSUNAdaptController_SetErrorBias_MRIHTol(farg1, farg2) & +bind(C, name="_wrap_FSUNAdaptController_SetErrorBias_MRIHTol") & +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_UpdateMRITol_MRIHTol(farg1, farg2, farg3, farg4, farg5) & +bind(C, name="_wrap_FSUNAdaptController_UpdateMRITol_MRIHTol") & +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_MRIHTol(farg1, farg2, farg3) & +bind(C, name="_wrap_FSUNAdaptController_Space_MRIHTol") & +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_MRIHTol(sunctx, hcontrol, tolcontrol) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +type(SUNAdaptController), pointer :: swig_result +type(C_PTR) :: sunctx +type(SUNAdaptController), target, intent(inout) :: hcontrol +type(SUNAdaptController), target, intent(inout) :: tolcontrol +type(C_PTR) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 +type(C_PTR) :: farg3 + +farg1 = sunctx +farg2 = c_loc(hcontrol) +farg3 = c_loc(tolcontrol) +fresult = swigc_FSUNAdaptController_MRIHTol(farg1, farg2, farg3) +call c_f_pointer(fresult, swig_result) +end function + +function FSUNAdaptController_SetParams_MRIHTol(c, inner_max_relch, inner_min_tolfac, inner_max_tolfac) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(SUNAdaptController), target, intent(inout) :: c +real(C_DOUBLE), intent(in) :: inner_max_relch +real(C_DOUBLE), intent(in) :: inner_min_tolfac +real(C_DOUBLE), intent(in) :: inner_max_tolfac +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +real(C_DOUBLE) :: farg2 +real(C_DOUBLE) :: farg3 +real(C_DOUBLE) :: farg4 + +farg1 = c_loc(c) +farg2 = inner_max_relch +farg3 = inner_min_tolfac +farg4 = inner_max_tolfac +fresult = swigc_FSUNAdaptController_SetParams_MRIHTol(farg1, farg2, farg3, farg4) +swig_result = fresult +end function + +function FSUNAdaptController_GetSlowController_MRIHTol(c) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +type(SUNAdaptController), pointer :: swig_result +type(SUNAdaptController), target, intent(inout) :: c +type(C_PTR) :: fresult +type(C_PTR) :: farg1 + +farg1 = c_loc(c) +fresult = swigc_FSUNAdaptController_GetSlowController_MRIHTol(farg1) +call c_f_pointer(fresult, swig_result) +end function + +function FSUNAdaptController_GetFastController_MRIHTol(c) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +type(SUNAdaptController), pointer :: swig_result +type(SUNAdaptController), target, intent(inout) :: c +type(C_PTR) :: fresult +type(C_PTR) :: farg1 + +farg1 = c_loc(c) +fresult = swigc_FSUNAdaptController_GetFastController_MRIHTol(farg1) +call c_f_pointer(fresult, swig_result) +end function + +function FSUNAdaptController_GetType_MRIHTol(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_MRIHTol(farg1) +swig_result = fresult +end function + +function FSUNAdaptController_EstimateStepTol_MRIHTol(c, h, tolfac, p, dsm, dsm5, hnew, tolfacnew) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(SUNAdaptController), target, intent(inout) :: c +real(C_DOUBLE), intent(in) :: h +real(C_DOUBLE), intent(in) :: tolfac +integer(C_INT), intent(in) :: p +real(C_DOUBLE), intent(in) :: dsm +real(C_DOUBLE), intent(in) :: dsm5 +real(C_DOUBLE), dimension(*), target, intent(inout) :: hnew +real(C_DOUBLE), dimension(*), target, intent(inout) :: tolfacnew +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +real(C_DOUBLE) :: farg2 +real(C_DOUBLE) :: farg3 +integer(C_INT) :: farg4 +real(C_DOUBLE) :: farg5 +real(C_DOUBLE) :: farg6 +type(C_PTR) :: farg7 +type(C_PTR) :: farg8 + +farg1 = c_loc(c) +farg2 = h +farg3 = tolfac +farg4 = p +farg5 = dsm +farg6 = dsm5 +farg7 = c_loc(hnew(1)) +farg8 = c_loc(tolfacnew(1)) +fresult = swigc_FSUNAdaptController_EstimateStepTol_MRIHTol(farg1, farg2, farg3, farg4, farg5, farg6, farg7, farg8) +swig_result = fresult +end function + +function FSUNAdaptController_Reset_MRIHTol(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_MRIHTol(farg1) +swig_result = fresult +end function + +function FSUNAdaptController_SetDefaults_MRIHTol(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_MRIHTol(farg1) +swig_result = fresult +end function + +function FSUNAdaptController_Write_MRIHTol(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_MRIHTol(farg1, farg2) +swig_result = fresult +end function + +function FSUNAdaptController_SetErrorBias_MRIHTol(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_MRIHTol(farg1, farg2) +swig_result = fresult +end function + +function FSUNAdaptController_UpdateMRITol_MRIHTol(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_MRIHTol(farg1, farg2, farg3, farg4, farg5) +swig_result = fresult +end function + +function FSUNAdaptController_Space_MRIHTol(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_MRIHTol(farg1, farg2, farg3) +swig_result = fresult +end function + + +end module diff --git a/src/sunadaptcontroller/mrihtol/fmod_int64/CMakeLists.txt b/src/sunadaptcontroller/mrihtol/fmod_int64/CMakeLists.txt new file mode 100644 index 0000000000..7f89cd14a6 --- /dev/null +++ b/src/sunadaptcontroller/mrihtol/fmod_int64/CMakeLists.txt @@ -0,0 +1,26 @@ +# --------------------------------------------------------------- +# Programmer(s): Daniel R. Reynolds @ SMU +# --------------------------------------------------------------- +# SUNDIALS Copyright Start +# Copyright (c) 2002-2024, 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_fsunadaptcontrollermrihtol_mod + SOURCES + fsunadaptcontroller_mrihtol_mod.f90 fsunadaptcontroller_mrihtol_mod.c + LINK_LIBRARIES + PUBLIC sundials_fcore_mod + OBJECT_LIBRARIES + OUTPUT_NAME + sundials_fsunadaptcontrollermrihtol_mod + OBJECT_LIB_ONLY +) + +message(STATUS "Added SUNAdaptController_MRIHTol F2003 interface") diff --git a/src/sunadaptcontroller/mrihtol/fmod_int64/fsunadaptcontroller_mrihtol_mod.c b/src/sunadaptcontroller/mrihtol/fmod_int64/fsunadaptcontroller_mrihtol_mod.c new file mode 100644 index 0000000000..4f01ed2426 --- /dev/null +++ b/src/sunadaptcontroller/mrihtol/fmod_int64/fsunadaptcontroller_mrihtol_mod.c @@ -0,0 +1,395 @@ +/* ---------------------------------------------------------------------------- + * 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-2024, 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_mrihtol.h" + +SWIGEXPORT SUNAdaptController _wrap_FSUNAdaptController_MRIHTol(void *farg1, SUNAdaptController farg2, SUNAdaptController farg3) { + SUNAdaptController fresult ; + SUNContext arg1 = (SUNContext) 0 ; + SUNAdaptController arg2 = (SUNAdaptController) 0 ; + SUNAdaptController arg3 = (SUNAdaptController) 0 ; + SUNAdaptController result; + + arg1 = (SUNContext)(farg1); + arg2 = (SUNAdaptController)(farg2); + arg3 = (SUNAdaptController)(farg3); + result = (SUNAdaptController)SUNAdaptController_MRIHTol(arg1,arg2,arg3); + fresult = result; + return fresult; +} + + +SWIGEXPORT int _wrap_FSUNAdaptController_SetParams_MRIHTol(SUNAdaptController farg1, double const *farg2, double const *farg3, double const *farg4) { + int fresult ; + SUNAdaptController arg1 = (SUNAdaptController) 0 ; + sunrealtype arg2 ; + sunrealtype arg3 ; + sunrealtype arg4 ; + SUNErrCode result; + + arg1 = (SUNAdaptController)(farg1); + arg2 = (sunrealtype)(*farg2); + arg3 = (sunrealtype)(*farg3); + arg4 = (sunrealtype)(*farg4); + result = (SUNErrCode)SUNAdaptController_SetParams_MRIHTol(arg1,arg2,arg3,arg4); + fresult = (SUNErrCode)(result); + return fresult; +} + + +SWIGEXPORT SUNAdaptController _wrap_FSUNAdaptController_GetSlowController_MRIHTol(SUNAdaptController farg1) { + SUNAdaptController fresult ; + SUNAdaptController arg1 = (SUNAdaptController) 0 ; + SUNAdaptController result; + + arg1 = (SUNAdaptController)(farg1); + result = (SUNAdaptController)SUNAdaptController_GetSlowController_MRIHTol(arg1); + fresult = result; + return fresult; +} + + +SWIGEXPORT SUNAdaptController _wrap_FSUNAdaptController_GetFastController_MRIHTol(SUNAdaptController farg1) { + SUNAdaptController fresult ; + SUNAdaptController arg1 = (SUNAdaptController) 0 ; + SUNAdaptController result; + + arg1 = (SUNAdaptController)(farg1); + result = (SUNAdaptController)SUNAdaptController_GetFastController_MRIHTol(arg1); + fresult = result; + return fresult; +} + + +SWIGEXPORT int _wrap_FSUNAdaptController_GetType_MRIHTol(SUNAdaptController farg1) { + int fresult ; + SUNAdaptController arg1 = (SUNAdaptController) 0 ; + SUNAdaptController_Type result; + + arg1 = (SUNAdaptController)(farg1); + result = (SUNAdaptController_Type)SUNAdaptController_GetType_MRIHTol(arg1); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FSUNAdaptController_EstimateStepTol_MRIHTol(SUNAdaptController farg1, double const *farg2, double const *farg3, int const *farg4, double const *farg5, double const *farg6, double *farg7, double *farg8) { + int fresult ; + SUNAdaptController arg1 = (SUNAdaptController) 0 ; + sunrealtype arg2 ; + sunrealtype arg3 ; + int arg4 ; + sunrealtype arg5 ; + sunrealtype arg6 ; + sunrealtype *arg7 = (sunrealtype *) 0 ; + sunrealtype *arg8 = (sunrealtype *) 0 ; + int result; + + arg1 = (SUNAdaptController)(farg1); + arg2 = (sunrealtype)(*farg2); + arg3 = (sunrealtype)(*farg3); + arg4 = (int)(*farg4); + arg5 = (sunrealtype)(*farg5); + arg6 = (sunrealtype)(*farg6); + arg7 = (sunrealtype *)(farg7); + arg8 = (sunrealtype *)(farg8); + result = (int)SUNAdaptController_EstimateStepTol_MRIHTol(arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FSUNAdaptController_Reset_MRIHTol(SUNAdaptController farg1) { + int fresult ; + SUNAdaptController arg1 = (SUNAdaptController) 0 ; + int result; + + arg1 = (SUNAdaptController)(farg1); + result = (int)SUNAdaptController_Reset_MRIHTol(arg1); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FSUNAdaptController_SetDefaults_MRIHTol(SUNAdaptController farg1) { + int fresult ; + SUNAdaptController arg1 = (SUNAdaptController) 0 ; + int result; + + arg1 = (SUNAdaptController)(farg1); + result = (int)SUNAdaptController_SetDefaults_MRIHTol(arg1); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FSUNAdaptController_Write_MRIHTol(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_MRIHTol(arg1,arg2); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FSUNAdaptController_SetErrorBias_MRIHTol(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_MRIHTol(arg1,arg2); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FSUNAdaptController_UpdateMRITol_MRIHTol(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_MRIHTol(arg1,arg2,arg3,arg4,arg5); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FSUNAdaptController_Space_MRIHTol(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_MRIHTol(arg1,arg2,arg3); + fresult = (int)(result); + return fresult; +} + + + diff --git a/src/sunadaptcontroller/mrihtol/fmod_int64/fsunadaptcontroller_mrihtol_mod.f90 b/src/sunadaptcontroller/mrihtol/fmod_int64/fsunadaptcontroller_mrihtol_mod.f90 new file mode 100644 index 0000000000..19ce2d9d6f --- /dev/null +++ b/src/sunadaptcontroller/mrihtol/fmod_int64/fsunadaptcontroller_mrihtol_mod.f90 @@ -0,0 +1,381 @@ +! 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-2024, 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_mrihtol_mod + use, intrinsic :: ISO_C_BINDING + use fsundials_core_mod + implicit none + private + + ! DECLARATION CONSTRUCTS + public :: FSUNAdaptController_MRIHTol + public :: FSUNAdaptController_SetParams_MRIHTol + public :: FSUNAdaptController_GetSlowController_MRIHTol + public :: FSUNAdaptController_GetFastController_MRIHTol + public :: FSUNAdaptController_GetType_MRIHTol + public :: FSUNAdaptController_EstimateStepTol_MRIHTol + public :: FSUNAdaptController_Reset_MRIHTol + public :: FSUNAdaptController_SetDefaults_MRIHTol + public :: FSUNAdaptController_Write_MRIHTol + public :: FSUNAdaptController_SetErrorBias_MRIHTol + public :: FSUNAdaptController_UpdateMRITol_MRIHTol + public :: FSUNAdaptController_Space_MRIHTol + +! WRAPPER DECLARATIONS +interface +function swigc_FSUNAdaptController_MRIHTol(farg1, farg2, farg3) & +bind(C, name="_wrap_FSUNAdaptController_MRIHTol") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +type(C_PTR), value :: farg1 +type(C_PTR), value :: farg2 +type(C_PTR), value :: farg3 +type(C_PTR) :: fresult +end function + +function swigc_FSUNAdaptController_SetParams_MRIHTol(farg1, farg2, farg3, farg4) & +bind(C, name="_wrap_FSUNAdaptController_SetParams_MRIHTol") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +type(C_PTR), value :: farg1 +real(C_DOUBLE), intent(in) :: farg2 +real(C_DOUBLE), intent(in) :: farg3 +real(C_DOUBLE), intent(in) :: farg4 +integer(C_INT) :: fresult +end function + +function swigc_FSUNAdaptController_GetSlowController_MRIHTol(farg1) & +bind(C, name="_wrap_FSUNAdaptController_GetSlowController_MRIHTol") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +type(C_PTR), value :: farg1 +type(C_PTR) :: fresult +end function + +function swigc_FSUNAdaptController_GetFastController_MRIHTol(farg1) & +bind(C, name="_wrap_FSUNAdaptController_GetFastController_MRIHTol") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +type(C_PTR), value :: farg1 +type(C_PTR) :: fresult +end function + +function swigc_FSUNAdaptController_GetType_MRIHTol(farg1) & +bind(C, name="_wrap_FSUNAdaptController_GetType_MRIHTol") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +type(C_PTR), value :: farg1 +integer(C_INT) :: fresult +end function + +function swigc_FSUNAdaptController_EstimateStepTol_MRIHTol(farg1, farg2, farg3, farg4, farg5, farg6, farg7, farg8) & +bind(C, name="_wrap_FSUNAdaptController_EstimateStepTol_MRIHTol") & +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 +real(C_DOUBLE), intent(in) :: farg5 +real(C_DOUBLE), intent(in) :: farg6 +type(C_PTR), value :: farg7 +type(C_PTR), value :: farg8 +integer(C_INT) :: fresult +end function + +function swigc_FSUNAdaptController_Reset_MRIHTol(farg1) & +bind(C, name="_wrap_FSUNAdaptController_Reset_MRIHTol") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +type(C_PTR), value :: farg1 +integer(C_INT) :: fresult +end function + +function swigc_FSUNAdaptController_SetDefaults_MRIHTol(farg1) & +bind(C, name="_wrap_FSUNAdaptController_SetDefaults_MRIHTol") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +type(C_PTR), value :: farg1 +integer(C_INT) :: fresult +end function + +function swigc_FSUNAdaptController_Write_MRIHTol(farg1, farg2) & +bind(C, name="_wrap_FSUNAdaptController_Write_MRIHTol") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +type(C_PTR), value :: farg1 +type(C_PTR), value :: farg2 +integer(C_INT) :: fresult +end function + +function swigc_FSUNAdaptController_SetErrorBias_MRIHTol(farg1, farg2) & +bind(C, name="_wrap_FSUNAdaptController_SetErrorBias_MRIHTol") & +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_UpdateMRITol_MRIHTol(farg1, farg2, farg3, farg4, farg5) & +bind(C, name="_wrap_FSUNAdaptController_UpdateMRITol_MRIHTol") & +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_MRIHTol(farg1, farg2, farg3) & +bind(C, name="_wrap_FSUNAdaptController_Space_MRIHTol") & +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_MRIHTol(sunctx, hcontrol, tolcontrol) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +type(SUNAdaptController), pointer :: swig_result +type(C_PTR) :: sunctx +type(SUNAdaptController), target, intent(inout) :: hcontrol +type(SUNAdaptController), target, intent(inout) :: tolcontrol +type(C_PTR) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 +type(C_PTR) :: farg3 + +farg1 = sunctx +farg2 = c_loc(hcontrol) +farg3 = c_loc(tolcontrol) +fresult = swigc_FSUNAdaptController_MRIHTol(farg1, farg2, farg3) +call c_f_pointer(fresult, swig_result) +end function + +function FSUNAdaptController_SetParams_MRIHTol(c, inner_max_relch, inner_min_tolfac, inner_max_tolfac) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(SUNAdaptController), target, intent(inout) :: c +real(C_DOUBLE), intent(in) :: inner_max_relch +real(C_DOUBLE), intent(in) :: inner_min_tolfac +real(C_DOUBLE), intent(in) :: inner_max_tolfac +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +real(C_DOUBLE) :: farg2 +real(C_DOUBLE) :: farg3 +real(C_DOUBLE) :: farg4 + +farg1 = c_loc(c) +farg2 = inner_max_relch +farg3 = inner_min_tolfac +farg4 = inner_max_tolfac +fresult = swigc_FSUNAdaptController_SetParams_MRIHTol(farg1, farg2, farg3, farg4) +swig_result = fresult +end function + +function FSUNAdaptController_GetSlowController_MRIHTol(c) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +type(SUNAdaptController), pointer :: swig_result +type(SUNAdaptController), target, intent(inout) :: c +type(C_PTR) :: fresult +type(C_PTR) :: farg1 + +farg1 = c_loc(c) +fresult = swigc_FSUNAdaptController_GetSlowController_MRIHTol(farg1) +call c_f_pointer(fresult, swig_result) +end function + +function FSUNAdaptController_GetFastController_MRIHTol(c) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +type(SUNAdaptController), pointer :: swig_result +type(SUNAdaptController), target, intent(inout) :: c +type(C_PTR) :: fresult +type(C_PTR) :: farg1 + +farg1 = c_loc(c) +fresult = swigc_FSUNAdaptController_GetFastController_MRIHTol(farg1) +call c_f_pointer(fresult, swig_result) +end function + +function FSUNAdaptController_GetType_MRIHTol(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_MRIHTol(farg1) +swig_result = fresult +end function + +function FSUNAdaptController_EstimateStepTol_MRIHTol(c, h, tolfac, p, dsm, dsm5, hnew, tolfacnew) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(SUNAdaptController), target, intent(inout) :: c +real(C_DOUBLE), intent(in) :: h +real(C_DOUBLE), intent(in) :: tolfac +integer(C_INT), intent(in) :: p +real(C_DOUBLE), intent(in) :: dsm +real(C_DOUBLE), intent(in) :: dsm5 +real(C_DOUBLE), dimension(*), target, intent(inout) :: hnew +real(C_DOUBLE), dimension(*), target, intent(inout) :: tolfacnew +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +real(C_DOUBLE) :: farg2 +real(C_DOUBLE) :: farg3 +integer(C_INT) :: farg4 +real(C_DOUBLE) :: farg5 +real(C_DOUBLE) :: farg6 +type(C_PTR) :: farg7 +type(C_PTR) :: farg8 + +farg1 = c_loc(c) +farg2 = h +farg3 = tolfac +farg4 = p +farg5 = dsm +farg6 = dsm5 +farg7 = c_loc(hnew(1)) +farg8 = c_loc(tolfacnew(1)) +fresult = swigc_FSUNAdaptController_EstimateStepTol_MRIHTol(farg1, farg2, farg3, farg4, farg5, farg6, farg7, farg8) +swig_result = fresult +end function + +function FSUNAdaptController_Reset_MRIHTol(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_MRIHTol(farg1) +swig_result = fresult +end function + +function FSUNAdaptController_SetDefaults_MRIHTol(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_MRIHTol(farg1) +swig_result = fresult +end function + +function FSUNAdaptController_Write_MRIHTol(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_MRIHTol(farg1, farg2) +swig_result = fresult +end function + +function FSUNAdaptController_SetErrorBias_MRIHTol(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_MRIHTol(farg1, farg2) +swig_result = fresult +end function + +function FSUNAdaptController_UpdateMRITol_MRIHTol(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_MRIHTol(farg1, farg2, farg3, farg4, farg5) +swig_result = fresult +end function + +function FSUNAdaptController_Space_MRIHTol(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_MRIHTol(farg1, farg2, farg3) +swig_result = fresult +end function + + +end module diff --git a/src/sunadaptcontroller/mrihtol/sunadaptcontroller_mrihtol.c b/src/sunadaptcontroller/mrihtol/sunadaptcontroller_mrihtol.c new file mode 100644 index 0000000000..64f975b76f --- /dev/null +++ b/src/sunadaptcontroller/mrihtol/sunadaptcontroller_mrihtol.c @@ -0,0 +1,251 @@ +/* ----------------------------------------------------------------- + * Programmer(s): Daniel R. Reynolds @ SMU + * ----------------------------------------------------------------- + * SUNDIALS Copyright Start + * Copyright (c) 2002-2024, 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_MRIHTol module. + * -----------------------------------------------------------------*/ + +#include +#include +#include +#include + +#include "sundials/priv/sundials_errors_impl.h" +#include "sundials/sundials_errors.h" + +/* ------------------ + * Default parameters + * ------------------ */ + +/* maximum relative change for inner tolerance factor */ +#define INNER_MAX_RELCH SUN_RCONST(20.0) +/* minimum tolerance factor for inner solver */ +#define INNER_MIN_TOLFAC SUN_RCONST(1.e-5) +/* maximum tolerance factor for inner solver */ +#define INNER_MAX_TOLFAC SUN_RCONST(1.e0) + +/* --------------- + * Macro accessors + * --------------- */ + +#define MRIHTOL_CONTENT(C) ((SUNAdaptControllerContent_MRIHTol)(C->content)) +#define MRIHTOL_CSLOW(C) (MRIHTOL_CONTENT(C)->HControl) +#define MRIHTOL_CFAST(C) (MRIHTOL_CONTENT(C)->TolControl) +#define MRIHTOL_INNER_MAX_RELCH(C) (MRIHTOL_CONTENT(C)->inner_max_relch) +#define MRIHTOL_INNER_MIN_TOLFAC(C) (MRIHTOL_CONTENT(C)->inner_min_tolfac) +#define MRIHTOL_INNER_MAX_TOLFAC(C) (MRIHTOL_CONTENT(C)->inner_max_tolfac) + +/* ----------------------------------------------------------------- + * exported functions + * ----------------------------------------------------------------- */ + +/* ----------------------------------------------------------------- + * Function to create a new MRIHTol controller + */ + +SUNAdaptController SUNAdaptController_MRIHTol(SUNContext sunctx, + SUNAdaptController HControl, + SUNAdaptController TolControl) +{ + SUNFunctionBegin(sunctx); + + SUNAdaptController C; + SUNAdaptControllerContent_MRIHTol content; + + /* Verify that input controllers have the appropriate type */ + SUNAssertNull(SUNAdaptController_GetType(HControl) == SUN_ADAPTCONTROLLER_H, + SUN_ERR_ARG_INCOMPATIBLE); + SUNAssertNull(SUNAdaptController_GetType(TolControl) == SUN_ADAPTCONTROLLER_H, + SUN_ERR_ARG_INCOMPATIBLE); + + /* Create an empty controller object */ + C = NULL; + C = SUNAdaptController_NewEmpty(sunctx); + SUNCheckLastErrNull(); + + /* Attach operations */ + C->ops->gettype = SUNAdaptController_GetType_MRIHTol; + C->ops->estimatesteptol = SUNAdaptController_EstimateStepTol_MRIHTol; + C->ops->reset = SUNAdaptController_Reset_MRIHTol; + C->ops->setdefaults = SUNAdaptController_SetDefaults_MRIHTol; + C->ops->write = SUNAdaptController_Write_MRIHTol; + C->ops->seterrorbias = SUNAdaptController_SetErrorBias_MRIHTol; + C->ops->updatemritol = SUNAdaptController_UpdateMRITol_MRIHTol; + C->ops->space = SUNAdaptController_Space_MRIHTol; + + /* Create content */ + content = NULL; + content = (SUNAdaptControllerContent_MRIHTol)malloc(sizeof *content); + SUNAssertNull(content, SUN_ERR_MALLOC_FAIL); + + /* Attach input controllers */ + content->HControl = HControl; + content->TolControl = TolControl; + + /* Set parameters to default values */ + content->inner_max_relch = INNER_MAX_RELCH; + content->inner_min_tolfac = INNER_MIN_TOLFAC; + content->inner_max_tolfac = INNER_MAX_TOLFAC; + + /* Attach content */ + C->content = content; + + return (C); +} + +/* ----------------------------------------------------------------- + * Function to set MRIHTol parameters + */ + +SUNErrCode SUNAdaptController_SetParams_MRIHTol(SUNAdaptController C, + sunrealtype inner_max_relch, + sunrealtype inner_min_tolfac, + sunrealtype inner_max_tolfac) +{ + SUNFunctionBegin(C->sunctx); + if (inner_max_relch != 0) MRIHTOL_INNER_MAX_RELCH(C) = inner_max_relch; + if (inner_min_tolfac != 0) MRIHTOL_INNER_MIN_TOLFAC(C) = inner_min_tolfac; + if (inner_max_tolfac != 0) MRIHTOL_INNER_MAX_TOLFAC(C) = inner_max_tolfac; + return SUN_SUCCESS; +} + +/* ----------------------------------------------------------------- + * Function to get slow and fast sub-controllers + */ + +SUNAdaptController SUNAdaptController_GetSlowController_MRIHTol(SUNAdaptController C) +{ + SUNFunctionBegin(C->sunctx); + return MRIHTOL_CSLOW(C); +} + +SUNAdaptController SUNAdaptController_GetFastController_MRIHTol(SUNAdaptController C) +{ + SUNFunctionBegin(C->sunctx); + return MRIHTOL_CFAST(C); +} + +/* ----------------------------------------------------------------- + * implementation of controller operations + * ----------------------------------------------------------------- */ + +SUNAdaptController_Type SUNAdaptController_GetType_MRIHTol(SUNAdaptController C) +{ + return SUN_ADAPTCONTROLLER_MRI_TOL; +} + +SUNErrCode SUNAdaptController_EstimateStepTol_MRIHTol( + SUNAdaptController C, sunrealtype H, sunrealtype tolfac, int P, + sunrealtype DSM, sunrealtype dsm, sunrealtype* Hnew, sunrealtype* tolfacnew) +{ + SUNFunctionBegin(C->sunctx); + SUNAssert(Hnew, SUN_ERR_ARG_CORRUPT); + SUNAssert(tolfacnew, SUN_ERR_ARG_CORRUPT); + sunrealtype tolfacest; + + /* Call slow time scale sub-controller to fill Hnew -- note that all heuristics + bounds on Hnew will be enforced by the time integrator itself */ + SUNCheckCall(SUNAdaptController_EstimateStep(MRIHTOL_CSLOW(C), H, P, DSM, Hnew)); + + /* Call fast time scale sub-controller with order=1: no matter the integrator + order, we expect its error to be proportional to the tolerance factor */ + SUNCheckCall(SUNAdaptController_EstimateStep(MRIHTOL_CFAST(C), tolfac, 1, dsm, + &tolfacest)); + + /* Enforce bounds on estimated tolerance factor */ + /* keep relative change within bounds */ + tolfacest = SUNMAX(tolfacest, tolfac / MRIHTOL_INNER_MAX_RELCH(C)); + tolfacest = SUNMIN(tolfacest, tolfac * MRIHTOL_INNER_MAX_RELCH(C)); + /* enforce absolute min/max bounds */ + tolfacest = SUNMAX(tolfacest, MRIHTOL_INNER_MIN_TOLFAC(C)); + tolfacest = SUNMIN(tolfacest, MRIHTOL_INNER_MAX_TOLFAC(C)); + + /* Set result and return */ + *tolfacnew = tolfacest; + return SUN_SUCCESS; +} + +SUNErrCode SUNAdaptController_Reset_MRIHTol(SUNAdaptController C) +{ + SUNFunctionBegin(C->sunctx); + SUNCheckCall(SUNAdaptController_Reset(MRIHTOL_CSLOW(C))); + SUNCheckCall(SUNAdaptController_Reset(MRIHTOL_CFAST(C))); + return SUN_SUCCESS; +} + +SUNErrCode SUNAdaptController_SetDefaults_MRIHTol(SUNAdaptController C) +{ + SUNFunctionBegin(C->sunctx); + SUNCheckCall(SUNAdaptController_SetDefaults(MRIHTOL_CSLOW(C))); + SUNCheckCall(SUNAdaptController_SetDefaults(MRIHTOL_CFAST(C))); + MRIHTOL_INNER_MAX_RELCH(C) = INNER_MAX_RELCH; + MRIHTOL_INNER_MIN_TOLFAC(C) = INNER_MIN_TOLFAC; + MRIHTOL_INNER_MAX_TOLFAC(C) = INNER_MAX_TOLFAC; + return SUN_SUCCESS; +} + +SUNErrCode SUNAdaptController_Write_MRIHTol(SUNAdaptController C, FILE* fptr) +{ + SUNFunctionBegin(C->sunctx); + SUNAssert(fptr, SUN_ERR_ARG_CORRUPT); + fprintf(fptr, "Multirate H-Tol SUNAdaptController module:\n"); +#if defined(SUNDIALS_EXTENDED_PRECISION) + fprintf(fptr, " inner_max_relch = %32Lg\n", MRIHTOL_INNER_MAX_RELCH(C)); + fprintf(fptr, " inner_min_tolfac = %32Lg\n", MRIHTOL_INNER_MIN_TOLFAC(C)); + fprintf(fptr, " inner_max_tolfac = %32Lg\n", MRIHTOL_INNER_MAX_TOLFAC(C)); +#else + fprintf(fptr, " inner_max_relch = %16g\n", MRIHTOL_INNER_MAX_RELCH(C)); + fprintf(fptr, " inner_min_tolfac = %16g\n", MRIHTOL_INNER_MIN_TOLFAC(C)); + fprintf(fptr, " inner_max_tolfac = %16g\n", MRIHTOL_INNER_MAX_TOLFAC(C)); +#endif + fprintf(fptr, "\nSlow step controller:\n"); + SUNCheckCall(SUNAdaptController_Write(MRIHTOL_CSLOW(C), fptr)); + fprintf(fptr, "\nFast tolerance controller:\n"); + SUNCheckCall(SUNAdaptController_Write(MRIHTOL_CFAST(C), fptr)); + return SUN_SUCCESS; +} + +SUNErrCode SUNAdaptController_SetErrorBias_MRIHTol(SUNAdaptController C, + sunrealtype bias) +{ + SUNFunctionBegin(C->sunctx); + SUNCheckCall(SUNAdaptController_SetErrorBias(MRIHTOL_CSLOW(C), bias)); + SUNCheckCall(SUNAdaptController_SetErrorBias(MRIHTOL_CFAST(C), bias)); + return SUN_SUCCESS; +} + +SUNErrCode SUNAdaptController_UpdateMRITol_MRIHTol(SUNAdaptController C, + sunrealtype H, + sunrealtype tolfac, + sunrealtype DSM, + sunrealtype dsm) +{ + SUNFunctionBegin(C->sunctx); + SUNCheckCall(SUNAdaptController_UpdateH(MRIHTOL_CSLOW(C), H, DSM)); + SUNCheckCall(SUNAdaptController_UpdateH(MRIHTOL_CFAST(C), tolfac, dsm)); + return SUN_SUCCESS; +} + +SUNErrCode SUNAdaptController_Space_MRIHTol(SUNAdaptController C, + long int* lenrw, long int* leniw) +{ + SUNFunctionBegin(C->sunctx); + SUNAssert(lenrw, SUN_ERR_ARG_CORRUPT); + SUNAssert(leniw, SUN_ERR_ARG_CORRUPT); + long int lrw, liw; + SUNCheckCall(SUNAdaptController_Space(MRIHTOL_CSLOW(C), lenrw, leniw)); + SUNCheckCall(SUNAdaptController_Space(MRIHTOL_CFAST(C), &lrw, &liw)); + *lenrw += lrw; + *leniw += liw; + return SUN_SUCCESS; +} diff --git a/src/sunadaptcontroller/mrill/CMakeLists.txt b/src/sunadaptcontroller/mrill/CMakeLists.txt new file mode 100644 index 0000000000..b383a1d569 --- /dev/null +++ b/src/sunadaptcontroller/mrill/CMakeLists.txt @@ -0,0 +1,28 @@ +# --------------------------------------------------------------- +# Programmer(s): Daniel R. Reynolds @ SMU +# --------------------------------------------------------------- +# SUNDIALS Copyright Start +# Copyright (c) 2002-2024, 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_sunadaptcontrollermrill + SOURCES sunadaptcontroller_mrill.c + HEADERS + ${SUNDIALS_SOURCE_DIR}/include/sunadaptcontroller/sunadaptcontroller_mrill.h + LINK_LIBRARIES PUBLIC sundials_core + INCLUDE_SUBDIR sunadaptcontroller + OBJECT_LIB_ONLY) + +# Add F2003 module if the interface is enabled +if(BUILD_FORTRAN_MODULE_INTERFACE) + add_subdirectory("fmod_int${SUNDIALS_INDEX_SIZE}") +endif() diff --git a/src/sunadaptcontroller/mrill/fmod_int32/CMakeLists.txt b/src/sunadaptcontroller/mrill/fmod_int32/CMakeLists.txt new file mode 100644 index 0000000000..0c704c59b9 --- /dev/null +++ b/src/sunadaptcontroller/mrill/fmod_int32/CMakeLists.txt @@ -0,0 +1,26 @@ +# --------------------------------------------------------------- +# Programmer(s): Daniel R. Reynolds @ SMU +# --------------------------------------------------------------- +# SUNDIALS Copyright Start +# Copyright (c) 2002-2024, 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_fsunadaptcontrollermrill_mod + SOURCES + fsunadaptcontroller_mrill_mod.f90 fsunadaptcontroller_mrill_mod.c + LINK_LIBRARIES + PUBLIC sundials_fcore_mod + OBJECT_LIBRARIES + OUTPUT_NAME + sundials_fsunadaptcontrollermrill_mod + OBJECT_LIB_ONLY +) + +message(STATUS "Added SUNAdaptController_MRILL F2003 interface") diff --git a/src/sunadaptcontroller/mrill/fmod_int32/fsunadaptcontroller_mrill_mod.c b/src/sunadaptcontroller/mrill/fmod_int32/fsunadaptcontroller_mrill_mod.c new file mode 100644 index 0000000000..f48b7bf2b5 --- /dev/null +++ b/src/sunadaptcontroller/mrill/fmod_int32/fsunadaptcontroller_mrill_mod.c @@ -0,0 +1,371 @@ +/* ---------------------------------------------------------------------------- + * 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-2024, 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_mrill.h" + +SWIGEXPORT SUNAdaptController _wrap_FSUNAdaptController_MRILL(void *farg1, int const *farg2) { + SUNAdaptController fresult ; + SUNContext arg1 = (SUNContext) 0 ; + int arg2 ; + SUNAdaptController result; + + arg1 = (SUNContext)(farg1); + arg2 = (int)(*farg2); + result = (SUNAdaptController)SUNAdaptController_MRILL(arg1,arg2); + fresult = result; + return fresult; +} + + +SWIGEXPORT int _wrap_FSUNAdaptController_SetParams_MRILL(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_SetParams_MRILL(arg1,arg2,arg3,arg4,arg5); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FSUNAdaptController_GetType_MRILL(SUNAdaptController farg1) { + int fresult ; + SUNAdaptController arg1 = (SUNAdaptController) 0 ; + SUNAdaptController_Type result; + + arg1 = (SUNAdaptController)(farg1); + result = (SUNAdaptController_Type)SUNAdaptController_GetType_MRILL(arg1); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FSUNAdaptController_EstimateMRISteps_MRILL(SUNAdaptController farg1, double const *farg2, double const *farg3, int const *farg4, double const *farg5, double const *farg6, double *farg7, double *farg8) { + int fresult ; + SUNAdaptController arg1 = (SUNAdaptController) 0 ; + sunrealtype arg2 ; + sunrealtype arg3 ; + int arg4 ; + sunrealtype arg5 ; + sunrealtype arg6 ; + sunrealtype *arg7 = (sunrealtype *) 0 ; + sunrealtype *arg8 = (sunrealtype *) 0 ; + int result; + + arg1 = (SUNAdaptController)(farg1); + arg2 = (sunrealtype)(*farg2); + arg3 = (sunrealtype)(*farg3); + arg4 = (int)(*farg4); + arg5 = (sunrealtype)(*farg5); + arg6 = (sunrealtype)(*farg6); + arg7 = (sunrealtype *)(farg7); + arg8 = (sunrealtype *)(farg8); + result = (int)SUNAdaptController_EstimateMRISteps_MRILL(arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FSUNAdaptController_Reset_MRILL(SUNAdaptController farg1) { + int fresult ; + SUNAdaptController arg1 = (SUNAdaptController) 0 ; + int result; + + arg1 = (SUNAdaptController)(farg1); + result = (int)SUNAdaptController_Reset_MRILL(arg1); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FSUNAdaptController_SetDefaults_MRILL(SUNAdaptController farg1) { + int fresult ; + SUNAdaptController arg1 = (SUNAdaptController) 0 ; + int result; + + arg1 = (SUNAdaptController)(farg1); + result = (int)SUNAdaptController_SetDefaults_MRILL(arg1); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FSUNAdaptController_Write_MRILL(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_MRILL(arg1,arg2); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FSUNAdaptController_SetErrorBias_MRILL(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_MRILL(arg1,arg2); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FSUNAdaptController_UpdateMRIH_MRILL(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_MRILL(arg1,arg2,arg3,arg4,arg5); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FSUNAdaptController_Space_MRILL(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_MRILL(arg1,arg2,arg3); + fresult = (int)(result); + return fresult; +} + + + diff --git a/src/sunadaptcontroller/mrill/fmod_int32/fsunadaptcontroller_mrill_mod.f90 b/src/sunadaptcontroller/mrill/fmod_int32/fsunadaptcontroller_mrill_mod.f90 new file mode 100644 index 0000000000..c00a349f53 --- /dev/null +++ b/src/sunadaptcontroller/mrill/fmod_int32/fsunadaptcontroller_mrill_mod.f90 @@ -0,0 +1,337 @@ +! 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-2024, 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_mrill_mod + use, intrinsic :: ISO_C_BINDING + use fsundials_core_mod + implicit none + private + + ! DECLARATION CONSTRUCTS + public :: FSUNAdaptController_MRILL + public :: FSUNAdaptController_SetParams_MRILL + public :: FSUNAdaptController_GetType_MRILL + public :: FSUNAdaptController_EstimateMRISteps_MRILL + public :: FSUNAdaptController_Reset_MRILL + public :: FSUNAdaptController_SetDefaults_MRILL + public :: FSUNAdaptController_Write_MRILL + public :: FSUNAdaptController_SetErrorBias_MRILL + public :: FSUNAdaptController_UpdateMRIH_MRILL + public :: FSUNAdaptController_Space_MRILL + +! WRAPPER DECLARATIONS +interface +function swigc_FSUNAdaptController_MRILL(farg1, farg2) & +bind(C, name="_wrap_FSUNAdaptController_MRILL") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +type(C_PTR), value :: farg1 +integer(C_INT), intent(in) :: farg2 +type(C_PTR) :: fresult +end function + +function swigc_FSUNAdaptController_SetParams_MRILL(farg1, farg2, farg3, farg4, farg5) & +bind(C, name="_wrap_FSUNAdaptController_SetParams_MRILL") & +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_GetType_MRILL(farg1) & +bind(C, name="_wrap_FSUNAdaptController_GetType_MRILL") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +type(C_PTR), value :: farg1 +integer(C_INT) :: fresult +end function + +function swigc_FSUNAdaptController_EstimateMRISteps_MRILL(farg1, farg2, farg3, farg4, farg5, farg6, farg7, farg8) & +bind(C, name="_wrap_FSUNAdaptController_EstimateMRISteps_MRILL") & +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 +real(C_DOUBLE), intent(in) :: farg5 +real(C_DOUBLE), intent(in) :: farg6 +type(C_PTR), value :: farg7 +type(C_PTR), value :: farg8 +integer(C_INT) :: fresult +end function + +function swigc_FSUNAdaptController_Reset_MRILL(farg1) & +bind(C, name="_wrap_FSUNAdaptController_Reset_MRILL") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +type(C_PTR), value :: farg1 +integer(C_INT) :: fresult +end function + +function swigc_FSUNAdaptController_SetDefaults_MRILL(farg1) & +bind(C, name="_wrap_FSUNAdaptController_SetDefaults_MRILL") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +type(C_PTR), value :: farg1 +integer(C_INT) :: fresult +end function + +function swigc_FSUNAdaptController_Write_MRILL(farg1, farg2) & +bind(C, name="_wrap_FSUNAdaptController_Write_MRILL") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +type(C_PTR), value :: farg1 +type(C_PTR), value :: farg2 +integer(C_INT) :: fresult +end function + +function swigc_FSUNAdaptController_SetErrorBias_MRILL(farg1, farg2) & +bind(C, name="_wrap_FSUNAdaptController_SetErrorBias_MRILL") & +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_UpdateMRIH_MRILL(farg1, farg2, farg3, farg4, farg5) & +bind(C, name="_wrap_FSUNAdaptController_UpdateMRIH_MRILL") & +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_MRILL(farg1, farg2, farg3) & +bind(C, name="_wrap_FSUNAdaptController_Space_MRILL") & +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_MRILL(sunctx, p) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +type(SUNAdaptController), pointer :: swig_result +type(C_PTR) :: sunctx +integer(C_INT), intent(in) :: p +type(C_PTR) :: fresult +type(C_PTR) :: farg1 +integer(C_INT) :: farg2 + +farg1 = sunctx +farg2 = p +fresult = swigc_FSUNAdaptController_MRILL(farg1, farg2) +call c_f_pointer(fresult, swig_result) +end function + +function FSUNAdaptController_SetParams_MRILL(c, k11, k12, k21, k22) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(SUNAdaptController), target, intent(inout) :: c +real(C_DOUBLE), intent(in) :: k11 +real(C_DOUBLE), intent(in) :: k12 +real(C_DOUBLE), intent(in) :: k21 +real(C_DOUBLE), intent(in) :: k22 +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 = k11 +farg3 = k12 +farg4 = k21 +farg5 = k22 +fresult = swigc_FSUNAdaptController_SetParams_MRILL(farg1, farg2, farg3, farg4, farg5) +swig_result = fresult +end function + +function FSUNAdaptController_GetType_MRILL(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_MRILL(farg1) +swig_result = fresult +end function + +function FSUNAdaptController_EstimateMRISteps_MRILL(c, h, h2, p, dsm, dsm5, hnew, hnew7) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(SUNAdaptController), target, intent(inout) :: c +real(C_DOUBLE), intent(in) :: h +real(C_DOUBLE), intent(in) :: h2 +integer(C_INT), intent(in) :: p +real(C_DOUBLE), intent(in) :: dsm +real(C_DOUBLE), intent(in) :: dsm5 +real(C_DOUBLE), dimension(*), target, intent(inout) :: hnew +real(C_DOUBLE), dimension(*), target, intent(inout) :: hnew7 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +real(C_DOUBLE) :: farg2 +real(C_DOUBLE) :: farg3 +integer(C_INT) :: farg4 +real(C_DOUBLE) :: farg5 +real(C_DOUBLE) :: farg6 +type(C_PTR) :: farg7 +type(C_PTR) :: farg8 + +farg1 = c_loc(c) +farg2 = h +farg3 = h2 +farg4 = p +farg5 = dsm +farg6 = dsm5 +farg7 = c_loc(hnew(1)) +farg8 = c_loc(hnew7(1)) +fresult = swigc_FSUNAdaptController_EstimateMRISteps_MRILL(farg1, farg2, farg3, farg4, farg5, farg6, farg7, farg8) +swig_result = fresult +end function + +function FSUNAdaptController_Reset_MRILL(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_MRILL(farg1) +swig_result = fresult +end function + +function FSUNAdaptController_SetDefaults_MRILL(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_MRILL(farg1) +swig_result = fresult +end function + +function FSUNAdaptController_Write_MRILL(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_MRILL(farg1, farg2) +swig_result = fresult +end function + +function FSUNAdaptController_SetErrorBias_MRILL(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_MRILL(farg1, farg2) +swig_result = fresult +end function + +function FSUNAdaptController_UpdateMRIH_MRILL(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_MRILL(farg1, farg2, farg3, farg4, farg5) +swig_result = fresult +end function + +function FSUNAdaptController_Space_MRILL(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_MRILL(farg1, farg2, farg3) +swig_result = fresult +end function + + +end module diff --git a/src/sunadaptcontroller/mrill/fmod_int64/CMakeLists.txt b/src/sunadaptcontroller/mrill/fmod_int64/CMakeLists.txt new file mode 100644 index 0000000000..0c704c59b9 --- /dev/null +++ b/src/sunadaptcontroller/mrill/fmod_int64/CMakeLists.txt @@ -0,0 +1,26 @@ +# --------------------------------------------------------------- +# Programmer(s): Daniel R. Reynolds @ SMU +# --------------------------------------------------------------- +# SUNDIALS Copyright Start +# Copyright (c) 2002-2024, 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_fsunadaptcontrollermrill_mod + SOURCES + fsunadaptcontroller_mrill_mod.f90 fsunadaptcontroller_mrill_mod.c + LINK_LIBRARIES + PUBLIC sundials_fcore_mod + OBJECT_LIBRARIES + OUTPUT_NAME + sundials_fsunadaptcontrollermrill_mod + OBJECT_LIB_ONLY +) + +message(STATUS "Added SUNAdaptController_MRILL F2003 interface") diff --git a/src/sunadaptcontroller/mrill/fmod_int64/fsunadaptcontroller_mrill_mod.c b/src/sunadaptcontroller/mrill/fmod_int64/fsunadaptcontroller_mrill_mod.c new file mode 100644 index 0000000000..f48b7bf2b5 --- /dev/null +++ b/src/sunadaptcontroller/mrill/fmod_int64/fsunadaptcontroller_mrill_mod.c @@ -0,0 +1,371 @@ +/* ---------------------------------------------------------------------------- + * 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-2024, 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_mrill.h" + +SWIGEXPORT SUNAdaptController _wrap_FSUNAdaptController_MRILL(void *farg1, int const *farg2) { + SUNAdaptController fresult ; + SUNContext arg1 = (SUNContext) 0 ; + int arg2 ; + SUNAdaptController result; + + arg1 = (SUNContext)(farg1); + arg2 = (int)(*farg2); + result = (SUNAdaptController)SUNAdaptController_MRILL(arg1,arg2); + fresult = result; + return fresult; +} + + +SWIGEXPORT int _wrap_FSUNAdaptController_SetParams_MRILL(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_SetParams_MRILL(arg1,arg2,arg3,arg4,arg5); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FSUNAdaptController_GetType_MRILL(SUNAdaptController farg1) { + int fresult ; + SUNAdaptController arg1 = (SUNAdaptController) 0 ; + SUNAdaptController_Type result; + + arg1 = (SUNAdaptController)(farg1); + result = (SUNAdaptController_Type)SUNAdaptController_GetType_MRILL(arg1); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FSUNAdaptController_EstimateMRISteps_MRILL(SUNAdaptController farg1, double const *farg2, double const *farg3, int const *farg4, double const *farg5, double const *farg6, double *farg7, double *farg8) { + int fresult ; + SUNAdaptController arg1 = (SUNAdaptController) 0 ; + sunrealtype arg2 ; + sunrealtype arg3 ; + int arg4 ; + sunrealtype arg5 ; + sunrealtype arg6 ; + sunrealtype *arg7 = (sunrealtype *) 0 ; + sunrealtype *arg8 = (sunrealtype *) 0 ; + int result; + + arg1 = (SUNAdaptController)(farg1); + arg2 = (sunrealtype)(*farg2); + arg3 = (sunrealtype)(*farg3); + arg4 = (int)(*farg4); + arg5 = (sunrealtype)(*farg5); + arg6 = (sunrealtype)(*farg6); + arg7 = (sunrealtype *)(farg7); + arg8 = (sunrealtype *)(farg8); + result = (int)SUNAdaptController_EstimateMRISteps_MRILL(arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FSUNAdaptController_Reset_MRILL(SUNAdaptController farg1) { + int fresult ; + SUNAdaptController arg1 = (SUNAdaptController) 0 ; + int result; + + arg1 = (SUNAdaptController)(farg1); + result = (int)SUNAdaptController_Reset_MRILL(arg1); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FSUNAdaptController_SetDefaults_MRILL(SUNAdaptController farg1) { + int fresult ; + SUNAdaptController arg1 = (SUNAdaptController) 0 ; + int result; + + arg1 = (SUNAdaptController)(farg1); + result = (int)SUNAdaptController_SetDefaults_MRILL(arg1); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FSUNAdaptController_Write_MRILL(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_MRILL(arg1,arg2); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FSUNAdaptController_SetErrorBias_MRILL(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_MRILL(arg1,arg2); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FSUNAdaptController_UpdateMRIH_MRILL(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_MRILL(arg1,arg2,arg3,arg4,arg5); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FSUNAdaptController_Space_MRILL(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_MRILL(arg1,arg2,arg3); + fresult = (int)(result); + return fresult; +} + + + diff --git a/src/sunadaptcontroller/mrill/fmod_int64/fsunadaptcontroller_mrill_mod.f90 b/src/sunadaptcontroller/mrill/fmod_int64/fsunadaptcontroller_mrill_mod.f90 new file mode 100644 index 0000000000..c00a349f53 --- /dev/null +++ b/src/sunadaptcontroller/mrill/fmod_int64/fsunadaptcontroller_mrill_mod.f90 @@ -0,0 +1,337 @@ +! 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-2024, 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_mrill_mod + use, intrinsic :: ISO_C_BINDING + use fsundials_core_mod + implicit none + private + + ! DECLARATION CONSTRUCTS + public :: FSUNAdaptController_MRILL + public :: FSUNAdaptController_SetParams_MRILL + public :: FSUNAdaptController_GetType_MRILL + public :: FSUNAdaptController_EstimateMRISteps_MRILL + public :: FSUNAdaptController_Reset_MRILL + public :: FSUNAdaptController_SetDefaults_MRILL + public :: FSUNAdaptController_Write_MRILL + public :: FSUNAdaptController_SetErrorBias_MRILL + public :: FSUNAdaptController_UpdateMRIH_MRILL + public :: FSUNAdaptController_Space_MRILL + +! WRAPPER DECLARATIONS +interface +function swigc_FSUNAdaptController_MRILL(farg1, farg2) & +bind(C, name="_wrap_FSUNAdaptController_MRILL") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +type(C_PTR), value :: farg1 +integer(C_INT), intent(in) :: farg2 +type(C_PTR) :: fresult +end function + +function swigc_FSUNAdaptController_SetParams_MRILL(farg1, farg2, farg3, farg4, farg5) & +bind(C, name="_wrap_FSUNAdaptController_SetParams_MRILL") & +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_GetType_MRILL(farg1) & +bind(C, name="_wrap_FSUNAdaptController_GetType_MRILL") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +type(C_PTR), value :: farg1 +integer(C_INT) :: fresult +end function + +function swigc_FSUNAdaptController_EstimateMRISteps_MRILL(farg1, farg2, farg3, farg4, farg5, farg6, farg7, farg8) & +bind(C, name="_wrap_FSUNAdaptController_EstimateMRISteps_MRILL") & +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 +real(C_DOUBLE), intent(in) :: farg5 +real(C_DOUBLE), intent(in) :: farg6 +type(C_PTR), value :: farg7 +type(C_PTR), value :: farg8 +integer(C_INT) :: fresult +end function + +function swigc_FSUNAdaptController_Reset_MRILL(farg1) & +bind(C, name="_wrap_FSUNAdaptController_Reset_MRILL") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +type(C_PTR), value :: farg1 +integer(C_INT) :: fresult +end function + +function swigc_FSUNAdaptController_SetDefaults_MRILL(farg1) & +bind(C, name="_wrap_FSUNAdaptController_SetDefaults_MRILL") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +type(C_PTR), value :: farg1 +integer(C_INT) :: fresult +end function + +function swigc_FSUNAdaptController_Write_MRILL(farg1, farg2) & +bind(C, name="_wrap_FSUNAdaptController_Write_MRILL") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +type(C_PTR), value :: farg1 +type(C_PTR), value :: farg2 +integer(C_INT) :: fresult +end function + +function swigc_FSUNAdaptController_SetErrorBias_MRILL(farg1, farg2) & +bind(C, name="_wrap_FSUNAdaptController_SetErrorBias_MRILL") & +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_UpdateMRIH_MRILL(farg1, farg2, farg3, farg4, farg5) & +bind(C, name="_wrap_FSUNAdaptController_UpdateMRIH_MRILL") & +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_MRILL(farg1, farg2, farg3) & +bind(C, name="_wrap_FSUNAdaptController_Space_MRILL") & +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_MRILL(sunctx, p) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +type(SUNAdaptController), pointer :: swig_result +type(C_PTR) :: sunctx +integer(C_INT), intent(in) :: p +type(C_PTR) :: fresult +type(C_PTR) :: farg1 +integer(C_INT) :: farg2 + +farg1 = sunctx +farg2 = p +fresult = swigc_FSUNAdaptController_MRILL(farg1, farg2) +call c_f_pointer(fresult, swig_result) +end function + +function FSUNAdaptController_SetParams_MRILL(c, k11, k12, k21, k22) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(SUNAdaptController), target, intent(inout) :: c +real(C_DOUBLE), intent(in) :: k11 +real(C_DOUBLE), intent(in) :: k12 +real(C_DOUBLE), intent(in) :: k21 +real(C_DOUBLE), intent(in) :: k22 +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 = k11 +farg3 = k12 +farg4 = k21 +farg5 = k22 +fresult = swigc_FSUNAdaptController_SetParams_MRILL(farg1, farg2, farg3, farg4, farg5) +swig_result = fresult +end function + +function FSUNAdaptController_GetType_MRILL(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_MRILL(farg1) +swig_result = fresult +end function + +function FSUNAdaptController_EstimateMRISteps_MRILL(c, h, h2, p, dsm, dsm5, hnew, hnew7) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(SUNAdaptController), target, intent(inout) :: c +real(C_DOUBLE), intent(in) :: h +real(C_DOUBLE), intent(in) :: h2 +integer(C_INT), intent(in) :: p +real(C_DOUBLE), intent(in) :: dsm +real(C_DOUBLE), intent(in) :: dsm5 +real(C_DOUBLE), dimension(*), target, intent(inout) :: hnew +real(C_DOUBLE), dimension(*), target, intent(inout) :: hnew7 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +real(C_DOUBLE) :: farg2 +real(C_DOUBLE) :: farg3 +integer(C_INT) :: farg4 +real(C_DOUBLE) :: farg5 +real(C_DOUBLE) :: farg6 +type(C_PTR) :: farg7 +type(C_PTR) :: farg8 + +farg1 = c_loc(c) +farg2 = h +farg3 = h2 +farg4 = p +farg5 = dsm +farg6 = dsm5 +farg7 = c_loc(hnew(1)) +farg8 = c_loc(hnew7(1)) +fresult = swigc_FSUNAdaptController_EstimateMRISteps_MRILL(farg1, farg2, farg3, farg4, farg5, farg6, farg7, farg8) +swig_result = fresult +end function + +function FSUNAdaptController_Reset_MRILL(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_MRILL(farg1) +swig_result = fresult +end function + +function FSUNAdaptController_SetDefaults_MRILL(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_MRILL(farg1) +swig_result = fresult +end function + +function FSUNAdaptController_Write_MRILL(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_MRILL(farg1, farg2) +swig_result = fresult +end function + +function FSUNAdaptController_SetErrorBias_MRILL(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_MRILL(farg1, farg2) +swig_result = fresult +end function + +function FSUNAdaptController_UpdateMRIH_MRILL(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_MRILL(farg1, farg2, farg3, farg4, farg5) +swig_result = fresult +end function + +function FSUNAdaptController_Space_MRILL(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_MRILL(farg1, farg2, farg3) +swig_result = fresult +end function + + +end module diff --git a/src/sunadaptcontroller/mrill/sunadaptcontroller_mrill.c b/src/sunadaptcontroller/mrill/sunadaptcontroller_mrill.c new file mode 100644 index 0000000000..a573a308c3 --- /dev/null +++ b/src/sunadaptcontroller/mrill/sunadaptcontroller_mrill.c @@ -0,0 +1,265 @@ +/* ----------------------------------------------------------------- + * Programmer(s): Daniel R. Reynolds @ SMU + * ----------------------------------------------------------------- + * SUNDIALS Copyright Start + * Copyright (c) 2002-2024, 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_MRILL module. + * -----------------------------------------------------------------*/ + +#include +#include +#include +#include + +#include "sundials/priv/sundials_errors_impl.h" +#include "sundials/sundials_errors.h" + +/* --------------- + * Macro accessors + * --------------- */ + +#define MRILL_CONTENT(C) ((SUNAdaptControllerContent_MRILL)(C->content)) +#define MRILL_K11(C) (MRILL_CONTENT(C)->k11) +#define MRILL_K12(C) (MRILL_CONTENT(C)->k12) +#define MRILL_K21(C) (MRILL_CONTENT(C)->k21) +#define MRILL_K22(C) (MRILL_CONTENT(C)->k22) +#define MRILL_BIAS(C) (MRILL_CONTENT(C)->bias) +#define MRILL_ESP(C) (MRILL_CONTENT(C)->esp) +#define MRILL_EFP(C) (MRILL_CONTENT(C)->efp) +#define MRILL_HSP(C) (MRILL_CONTENT(C)->hsp) +#define MRILL_HFP(C) (MRILL_CONTENT(C)->hfp) +#define MRILL_PFAST(C) (MRILL_CONTENT(C)->p) +#define MRILL_FIRSTSTEP(C) (MRILL_CONTENT(C)->firststep) + +/* ------------------ + * Default parameters + * ------------------ */ + +#define DEFAULT_K11 SUN_RCONST(0.82) +#define DEFAULT_K12 SUN_RCONST(0.54) +#define DEFAULT_K21 SUN_RCONST(0.94) +#define DEFAULT_K22 SUN_RCONST(0.9) +#define DEFAULT_BIAS SUN_RCONST(1.5) +#define ONE SUN_RCONST(1.0) +#define TINY (SUN_RCONST(10.0) * SUN_UNIT_ROUNDOFF) + +/* ----------------------------------------------------------------- + * exported functions + * ----------------------------------------------------------------- */ + +/* ----------------------------------------------------------------- + * Function to create a new MRILL controller + */ + +SUNAdaptController SUNAdaptController_MRILL(SUNContext sunctx, int p) +{ + SUNFunctionBegin(sunctx); + + SUNAdaptController C; + SUNAdaptControllerContent_MRILL content; + + /* Create an empty controller object */ + C = NULL; + C = SUNAdaptController_NewEmpty(sunctx); + SUNCheckLastErrNull(); + + /* Attach operations */ + C->ops->gettype = SUNAdaptController_GetType_MRILL; + C->ops->estimatemristeps = SUNAdaptController_EstimateMRISteps_MRILL; + C->ops->reset = SUNAdaptController_Reset_MRILL; + C->ops->setdefaults = SUNAdaptController_SetDefaults_MRILL; + C->ops->write = SUNAdaptController_Write_MRILL; + C->ops->seterrorbias = SUNAdaptController_SetErrorBias_MRILL; + C->ops->updatemrih = SUNAdaptController_UpdateMRIH_MRILL; + C->ops->space = SUNAdaptController_Space_MRILL; + + /* Create content */ + content = NULL; + content = (SUNAdaptControllerContent_MRILL)malloc(sizeof *content); + SUNAssertNull(content, SUN_ERR_MALLOC_FAIL); + + /* Attach content */ + C->content = content; + + /* Set fast method order */ + content->p = p; + + /* Fill content with default/reset values */ + SUNCheckCallNull(SUNAdaptController_SetDefaults_MRILL(C)); + SUNCheckCallNull(SUNAdaptController_Reset_MRILL(C)); + + return (C); +} + +/* ----------------------------------------------------------------- + * Function to set MRILL parameters + */ + +SUNErrCode SUNAdaptController_SetParams_MRILL(SUNAdaptController C, + sunrealtype k11, sunrealtype k12, + sunrealtype k21, sunrealtype k22) +{ + SUNFunctionBegin(C->sunctx); + MRILL_K11(C) = k11; + MRILL_K12(C) = k12; + MRILL_K21(C) = k21; + MRILL_K22(C) = k22; + return SUN_SUCCESS; +} + +/* ----------------------------------------------------------------- + * implementation of controller operations + * ----------------------------------------------------------------- */ + +SUNAdaptController_Type SUNAdaptController_GetType_MRILL(SUNAdaptController C) +{ + return SUN_ADAPTCONTROLLER_MRI_H; +} + +SUNErrCode SUNAdaptController_EstimateMRISteps_MRILL( + SUNAdaptController C, sunrealtype H, sunrealtype h, int P, sunrealtype DSM, + sunrealtype dsm, sunrealtype* Hnew, sunrealtype* hnew) +{ + SUNFunctionBegin(C->sunctx); + SUNAssert(Hnew, SUN_ERR_ARG_CORRUPT); + SUNAssert(hnew, SUN_ERR_ARG_CORRUPT); + + /* set usable time-step adaptivity parameters */ + const int p = MRILL_PFAST(C); + const sunrealtype k11 = MRILL_K11(C); + const sunrealtype k12 = MRILL_K12(C); + const sunrealtype k21 = MRILL_K21(C); + const sunrealtype k22 = MRILL_K22(C); + const sunrealtype a1 = (k11 + k12) / (2 * P); + const sunrealtype a2 = -k11 / (2 * P); + const sunrealtype b11 = (p + 1) * (k11 + k12) / (2 * P * p); + const sunrealtype b12 = -(p + 1) * k11 / (2 * P * p); + const sunrealtype b21 = -(k21 + k22) / (2 * p); + const sunrealtype b22 = k21 / (2 * p); + const sunrealtype es1 = ONE / SUNMAX(MRILL_BIAS(C) * DSM, TINY); + const sunrealtype es2 = ONE / MRILL_ESP(C); + const sunrealtype ef1 = ONE / SUNMAX(MRILL_BIAS(C) * dsm, TINY); + const sunrealtype ef2 = ONE / MRILL_EFP(C); + const sunrealtype M = SUNRceil(H / h); + + /* handle first vs successive steps */ + sunrealtype Hfac, Mfac; + if (MRILL_FIRSTSTEP(C)) + { + Hfac = SUN_RCONST(1.0); + Mfac = SUN_RCONST(1.0); + } + else + { + const sunrealtype Mp = SUNRceil(MRILL_HSP(C) / MRILL_HFP(C)); + Hfac = H / MRILL_HSP(C); + Mfac = M / Mp; + } + + /* compute estimated optimal time step size */ + *Hnew = H * Hfac * SUNRpowerR(es1, a1) * SUNRpowerR(es2, a2); + const sunrealtype Mnew = M * Mfac * SUNRpowerR(es1, b11) * + SUNRpowerR(es2, b12) * SUNRpowerR(ef1, b21) * + SUNRpowerR(ef2, b22); + *hnew = (*Hnew) / Mnew; + + /* return with success */ + return SUN_SUCCESS; +} + +SUNErrCode SUNAdaptController_Reset_MRILL(SUNAdaptController C) +{ + SUNFunctionBegin(C->sunctx); + MRILL_ESP(C) = SUN_RCONST(1.0); + MRILL_EFP(C) = SUN_RCONST(1.0); + MRILL_HSP(C) = SUN_RCONST(1.0); + MRILL_HFP(C) = SUN_RCONST(1.0); + MRILL_FIRSTSTEP(C) = SUNTRUE; + return SUN_SUCCESS; +} + +SUNErrCode SUNAdaptController_SetDefaults_MRILL(SUNAdaptController C) +{ + SUNFunctionBegin(C->sunctx); + MRILL_K11(C) = DEFAULT_K11; + MRILL_K12(C) = DEFAULT_K12; + MRILL_K21(C) = DEFAULT_K21; + MRILL_K22(C) = DEFAULT_K22; + MRILL_BIAS(C) = DEFAULT_BIAS; + return SUN_SUCCESS; +} + +SUNErrCode SUNAdaptController_Write_MRILL(SUNAdaptController C, FILE* fptr) +{ + SUNFunctionBegin(C->sunctx); + SUNAssert(fptr, SUN_ERR_ARG_CORRUPT); + fprintf(fptr, "Multirate LL SUNAdaptController module:\n"); +#if defined(SUNDIALS_EXTENDED_PRECISION) + fprintf(fptr, " k11 = %32Lg\n", MRILL_K11(C)); + fprintf(fptr, " k12 = %32Lg\n", MRILL_K12(C)); + fprintf(fptr, " k21 = %32Lg\n", MRILL_K21(C)); + fprintf(fptr, " k22 = %32Lg\n", MRILL_K22(C)); + fprintf(fptr, " bias factor = %32Lg\n", MRILL_BIAS(C)); + fprintf(fptr, " previous slow error = %32Lg\n", MRILL_ESP(C)); + fprintf(fptr, " previous fast error = %32Lg\n", MRILL_EFP(C)); + fprintf(fptr, " previous slow step = %32Lg\n", MRILL_HSP(C)); + fprintf(fptr, " previous fast step = %32Lg\n", MRILL_HFP(C)); +#else + fprintf(fptr, " k11 = %16g\n", MRILL_K11(C)); + fprintf(fptr, " k12 = %16g\n", MRILL_K12(C)); + fprintf(fptr, " k21 = %16g\n", MRILL_K21(C)); + fprintf(fptr, " k22 = %16g\n", MRILL_K22(C)); + fprintf(fptr, " bias factor = %16g\n", MRILL_BIAS(C)); + fprintf(fptr, " previous slow error = %16g\n", MRILL_ESP(C)); + fprintf(fptr, " previous fast error = %16g\n", MRILL_EFP(C)); + fprintf(fptr, " previous slow step = %16g\n", MRILL_HSP(C)); + fprintf(fptr, " previous fast step = %16g\n", MRILL_HFP(C)); +#endif + fprintf(fptr, " p = %i (fast method order)\n", MRILL_PFAST(C)); + return SUN_SUCCESS; +} + +SUNErrCode SUNAdaptController_SetErrorBias_MRILL(SUNAdaptController C, + sunrealtype bias) +{ + SUNFunctionBegin(C->sunctx); + + /* set allowed value, otherwise set default */ + if (bias <= SUN_RCONST(0.0)) { MRILL_BIAS(C) = DEFAULT_BIAS; } + else { MRILL_BIAS(C) = bias; } + + return SUN_SUCCESS; +} + +SUNErrCode SUNAdaptController_UpdateMRIH_MRILL(SUNAdaptController C, + sunrealtype H, sunrealtype h, + sunrealtype DSM, sunrealtype dsm) +{ + SUNFunctionBegin(C->sunctx); + MRILL_ESP(C) = SUNMAX(MRILL_BIAS(C) * DSM, TINY); + MRILL_EFP(C) = SUNMAX(MRILL_BIAS(C) * dsm, TINY); + MRILL_HSP(C) = H; + MRILL_HFP(C) = h; + MRILL_FIRSTSTEP(C) = SUNFALSE; + return SUN_SUCCESS; +} + +SUNErrCode SUNAdaptController_Space_MRILL(SUNAdaptController C, long int* lenrw, + long int* leniw) +{ + SUNFunctionBegin(C->sunctx); + SUNAssert(lenrw, SUN_ERR_ARG_CORRUPT); + SUNAssert(leniw, SUN_ERR_ARG_CORRUPT); + *lenrw = 9; + *leniw = 2; + return SUN_SUCCESS; +} diff --git a/src/sunadaptcontroller/mripi/CMakeLists.txt b/src/sunadaptcontroller/mripi/CMakeLists.txt new file mode 100644 index 0000000000..477cd641af --- /dev/null +++ b/src/sunadaptcontroller/mripi/CMakeLists.txt @@ -0,0 +1,28 @@ +# --------------------------------------------------------------- +# Programmer(s): Daniel R. Reynolds @ SMU +# --------------------------------------------------------------- +# SUNDIALS Copyright Start +# Copyright (c) 2002-2024, 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_sunadaptcontrollermripi + SOURCES sunadaptcontroller_mripi.c + HEADERS + ${SUNDIALS_SOURCE_DIR}/include/sunadaptcontroller/sunadaptcontroller_mripi.h + LINK_LIBRARIES PUBLIC sundials_core + INCLUDE_SUBDIR sunadaptcontroller + OBJECT_LIB_ONLY) + +# Add F2003 module if the interface is enabled +if(BUILD_FORTRAN_MODULE_INTERFACE) + add_subdirectory("fmod_int${SUNDIALS_INDEX_SIZE}") +endif() diff --git a/src/sunadaptcontroller/mripi/fmod_int32/CMakeLists.txt b/src/sunadaptcontroller/mripi/fmod_int32/CMakeLists.txt new file mode 100644 index 0000000000..83a51e3d7c --- /dev/null +++ b/src/sunadaptcontroller/mripi/fmod_int32/CMakeLists.txt @@ -0,0 +1,26 @@ +# --------------------------------------------------------------- +# Programmer(s): Daniel R. Reynolds @ SMU +# --------------------------------------------------------------- +# SUNDIALS Copyright Start +# Copyright (c) 2002-2024, 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_fsunadaptcontrollermripi_mod + SOURCES + fsunadaptcontroller_mripi_mod.f90 fsunadaptcontroller_mripi_mod.c + LINK_LIBRARIES + PUBLIC sundials_fcore_mod + OBJECT_LIBRARIES + OUTPUT_NAME + sundials_fsunadaptcontrollermripi_mod + OBJECT_LIB_ONLY +) + +message(STATUS "Added SUNAdaptController_MRIPI F2003 interface") diff --git a/src/sunadaptcontroller/mripi/fmod_int32/fsunadaptcontroller_mripi_mod.c b/src/sunadaptcontroller/mripi/fmod_int32/fsunadaptcontroller_mripi_mod.c new file mode 100644 index 0000000000..9e05214eb8 --- /dev/null +++ b/src/sunadaptcontroller/mripi/fmod_int32/fsunadaptcontroller_mripi_mod.c @@ -0,0 +1,371 @@ +/* ---------------------------------------------------------------------------- + * 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-2024, 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_mripi.h" + +SWIGEXPORT SUNAdaptController _wrap_FSUNAdaptController_MRIPI(void *farg1, int const *farg2) { + SUNAdaptController fresult ; + SUNContext arg1 = (SUNContext) 0 ; + int arg2 ; + SUNAdaptController result; + + arg1 = (SUNContext)(farg1); + arg2 = (int)(*farg2); + result = (SUNAdaptController)SUNAdaptController_MRIPI(arg1,arg2); + fresult = result; + return fresult; +} + + +SWIGEXPORT int _wrap_FSUNAdaptController_SetParams_MRIPI(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_SetParams_MRIPI(arg1,arg2,arg3,arg4,arg5); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FSUNAdaptController_GetType_MRIPI(SUNAdaptController farg1) { + int fresult ; + SUNAdaptController arg1 = (SUNAdaptController) 0 ; + SUNAdaptController_Type result; + + arg1 = (SUNAdaptController)(farg1); + result = (SUNAdaptController_Type)SUNAdaptController_GetType_MRIPI(arg1); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FSUNAdaptController_EstimateMRISteps_MRIPI(SUNAdaptController farg1, double const *farg2, double const *farg3, int const *farg4, double const *farg5, double const *farg6, double *farg7, double *farg8) { + int fresult ; + SUNAdaptController arg1 = (SUNAdaptController) 0 ; + sunrealtype arg2 ; + sunrealtype arg3 ; + int arg4 ; + sunrealtype arg5 ; + sunrealtype arg6 ; + sunrealtype *arg7 = (sunrealtype *) 0 ; + sunrealtype *arg8 = (sunrealtype *) 0 ; + int result; + + arg1 = (SUNAdaptController)(farg1); + arg2 = (sunrealtype)(*farg2); + arg3 = (sunrealtype)(*farg3); + arg4 = (int)(*farg4); + arg5 = (sunrealtype)(*farg5); + arg6 = (sunrealtype)(*farg6); + arg7 = (sunrealtype *)(farg7); + arg8 = (sunrealtype *)(farg8); + result = (int)SUNAdaptController_EstimateMRISteps_MRIPI(arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FSUNAdaptController_Reset_MRIPI(SUNAdaptController farg1) { + int fresult ; + SUNAdaptController arg1 = (SUNAdaptController) 0 ; + int result; + + arg1 = (SUNAdaptController)(farg1); + result = (int)SUNAdaptController_Reset_MRIPI(arg1); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FSUNAdaptController_SetDefaults_MRIPI(SUNAdaptController farg1) { + int fresult ; + SUNAdaptController arg1 = (SUNAdaptController) 0 ; + int result; + + arg1 = (SUNAdaptController)(farg1); + result = (int)SUNAdaptController_SetDefaults_MRIPI(arg1); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FSUNAdaptController_Write_MRIPI(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_MRIPI(arg1,arg2); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FSUNAdaptController_SetErrorBias_MRIPI(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_MRIPI(arg1,arg2); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FSUNAdaptController_UpdateMRIH_MRIPI(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_MRIPI(arg1,arg2,arg3,arg4,arg5); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FSUNAdaptController_Space_MRIPI(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_MRIPI(arg1,arg2,arg3); + fresult = (int)(result); + return fresult; +} + + + diff --git a/src/sunadaptcontroller/mripi/fmod_int32/fsunadaptcontroller_mripi_mod.f90 b/src/sunadaptcontroller/mripi/fmod_int32/fsunadaptcontroller_mripi_mod.f90 new file mode 100644 index 0000000000..6aa546b4fa --- /dev/null +++ b/src/sunadaptcontroller/mripi/fmod_int32/fsunadaptcontroller_mripi_mod.f90 @@ -0,0 +1,337 @@ +! 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-2024, 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_mripi_mod + use, intrinsic :: ISO_C_BINDING + use fsundials_core_mod + implicit none + private + + ! DECLARATION CONSTRUCTS + public :: FSUNAdaptController_MRIPI + public :: FSUNAdaptController_SetParams_MRIPI + public :: FSUNAdaptController_GetType_MRIPI + public :: FSUNAdaptController_EstimateMRISteps_MRIPI + public :: FSUNAdaptController_Reset_MRIPI + public :: FSUNAdaptController_SetDefaults_MRIPI + public :: FSUNAdaptController_Write_MRIPI + public :: FSUNAdaptController_SetErrorBias_MRIPI + public :: FSUNAdaptController_UpdateMRIH_MRIPI + public :: FSUNAdaptController_Space_MRIPI + +! WRAPPER DECLARATIONS +interface +function swigc_FSUNAdaptController_MRIPI(farg1, farg2) & +bind(C, name="_wrap_FSUNAdaptController_MRIPI") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +type(C_PTR), value :: farg1 +integer(C_INT), intent(in) :: farg2 +type(C_PTR) :: fresult +end function + +function swigc_FSUNAdaptController_SetParams_MRIPI(farg1, farg2, farg3, farg4, farg5) & +bind(C, name="_wrap_FSUNAdaptController_SetParams_MRIPI") & +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_GetType_MRIPI(farg1) & +bind(C, name="_wrap_FSUNAdaptController_GetType_MRIPI") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +type(C_PTR), value :: farg1 +integer(C_INT) :: fresult +end function + +function swigc_FSUNAdaptController_EstimateMRISteps_MRIPI(farg1, farg2, farg3, farg4, farg5, farg6, farg7, farg8) & +bind(C, name="_wrap_FSUNAdaptController_EstimateMRISteps_MRIPI") & +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 +real(C_DOUBLE), intent(in) :: farg5 +real(C_DOUBLE), intent(in) :: farg6 +type(C_PTR), value :: farg7 +type(C_PTR), value :: farg8 +integer(C_INT) :: fresult +end function + +function swigc_FSUNAdaptController_Reset_MRIPI(farg1) & +bind(C, name="_wrap_FSUNAdaptController_Reset_MRIPI") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +type(C_PTR), value :: farg1 +integer(C_INT) :: fresult +end function + +function swigc_FSUNAdaptController_SetDefaults_MRIPI(farg1) & +bind(C, name="_wrap_FSUNAdaptController_SetDefaults_MRIPI") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +type(C_PTR), value :: farg1 +integer(C_INT) :: fresult +end function + +function swigc_FSUNAdaptController_Write_MRIPI(farg1, farg2) & +bind(C, name="_wrap_FSUNAdaptController_Write_MRIPI") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +type(C_PTR), value :: farg1 +type(C_PTR), value :: farg2 +integer(C_INT) :: fresult +end function + +function swigc_FSUNAdaptController_SetErrorBias_MRIPI(farg1, farg2) & +bind(C, name="_wrap_FSUNAdaptController_SetErrorBias_MRIPI") & +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_UpdateMRIH_MRIPI(farg1, farg2, farg3, farg4, farg5) & +bind(C, name="_wrap_FSUNAdaptController_UpdateMRIH_MRIPI") & +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_MRIPI(farg1, farg2, farg3) & +bind(C, name="_wrap_FSUNAdaptController_Space_MRIPI") & +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_MRIPI(sunctx, p) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +type(SUNAdaptController), pointer :: swig_result +type(C_PTR) :: sunctx +integer(C_INT), intent(in) :: p +type(C_PTR) :: fresult +type(C_PTR) :: farg1 +integer(C_INT) :: farg2 + +farg1 = sunctx +farg2 = p +fresult = swigc_FSUNAdaptController_MRIPI(farg1, farg2) +call c_f_pointer(fresult, swig_result) +end function + +function FSUNAdaptController_SetParams_MRIPI(c, k11, k12, k21, k22) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(SUNAdaptController), target, intent(inout) :: c +real(C_DOUBLE), intent(in) :: k11 +real(C_DOUBLE), intent(in) :: k12 +real(C_DOUBLE), intent(in) :: k21 +real(C_DOUBLE), intent(in) :: k22 +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 = k11 +farg3 = k12 +farg4 = k21 +farg5 = k22 +fresult = swigc_FSUNAdaptController_SetParams_MRIPI(farg1, farg2, farg3, farg4, farg5) +swig_result = fresult +end function + +function FSUNAdaptController_GetType_MRIPI(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_MRIPI(farg1) +swig_result = fresult +end function + +function FSUNAdaptController_EstimateMRISteps_MRIPI(c, h, h2, p, dsm, dsm5, hnew, hnew7) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(SUNAdaptController), target, intent(inout) :: c +real(C_DOUBLE), intent(in) :: h +real(C_DOUBLE), intent(in) :: h2 +integer(C_INT), intent(in) :: p +real(C_DOUBLE), intent(in) :: dsm +real(C_DOUBLE), intent(in) :: dsm5 +real(C_DOUBLE), dimension(*), target, intent(inout) :: hnew +real(C_DOUBLE), dimension(*), target, intent(inout) :: hnew7 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +real(C_DOUBLE) :: farg2 +real(C_DOUBLE) :: farg3 +integer(C_INT) :: farg4 +real(C_DOUBLE) :: farg5 +real(C_DOUBLE) :: farg6 +type(C_PTR) :: farg7 +type(C_PTR) :: farg8 + +farg1 = c_loc(c) +farg2 = h +farg3 = h2 +farg4 = p +farg5 = dsm +farg6 = dsm5 +farg7 = c_loc(hnew(1)) +farg8 = c_loc(hnew7(1)) +fresult = swigc_FSUNAdaptController_EstimateMRISteps_MRIPI(farg1, farg2, farg3, farg4, farg5, farg6, farg7, farg8) +swig_result = fresult +end function + +function FSUNAdaptController_Reset_MRIPI(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_MRIPI(farg1) +swig_result = fresult +end function + +function FSUNAdaptController_SetDefaults_MRIPI(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_MRIPI(farg1) +swig_result = fresult +end function + +function FSUNAdaptController_Write_MRIPI(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_MRIPI(farg1, farg2) +swig_result = fresult +end function + +function FSUNAdaptController_SetErrorBias_MRIPI(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_MRIPI(farg1, farg2) +swig_result = fresult +end function + +function FSUNAdaptController_UpdateMRIH_MRIPI(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_MRIPI(farg1, farg2, farg3, farg4, farg5) +swig_result = fresult +end function + +function FSUNAdaptController_Space_MRIPI(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_MRIPI(farg1, farg2, farg3) +swig_result = fresult +end function + + +end module diff --git a/src/sunadaptcontroller/mripi/fmod_int64/CMakeLists.txt b/src/sunadaptcontroller/mripi/fmod_int64/CMakeLists.txt new file mode 100644 index 0000000000..83a51e3d7c --- /dev/null +++ b/src/sunadaptcontroller/mripi/fmod_int64/CMakeLists.txt @@ -0,0 +1,26 @@ +# --------------------------------------------------------------- +# Programmer(s): Daniel R. Reynolds @ SMU +# --------------------------------------------------------------- +# SUNDIALS Copyright Start +# Copyright (c) 2002-2024, 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_fsunadaptcontrollermripi_mod + SOURCES + fsunadaptcontroller_mripi_mod.f90 fsunadaptcontroller_mripi_mod.c + LINK_LIBRARIES + PUBLIC sundials_fcore_mod + OBJECT_LIBRARIES + OUTPUT_NAME + sundials_fsunadaptcontrollermripi_mod + OBJECT_LIB_ONLY +) + +message(STATUS "Added SUNAdaptController_MRIPI F2003 interface") diff --git a/src/sunadaptcontroller/mripi/fmod_int64/fsunadaptcontroller_mripi_mod.c b/src/sunadaptcontroller/mripi/fmod_int64/fsunadaptcontroller_mripi_mod.c new file mode 100644 index 0000000000..9e05214eb8 --- /dev/null +++ b/src/sunadaptcontroller/mripi/fmod_int64/fsunadaptcontroller_mripi_mod.c @@ -0,0 +1,371 @@ +/* ---------------------------------------------------------------------------- + * 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-2024, 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_mripi.h" + +SWIGEXPORT SUNAdaptController _wrap_FSUNAdaptController_MRIPI(void *farg1, int const *farg2) { + SUNAdaptController fresult ; + SUNContext arg1 = (SUNContext) 0 ; + int arg2 ; + SUNAdaptController result; + + arg1 = (SUNContext)(farg1); + arg2 = (int)(*farg2); + result = (SUNAdaptController)SUNAdaptController_MRIPI(arg1,arg2); + fresult = result; + return fresult; +} + + +SWIGEXPORT int _wrap_FSUNAdaptController_SetParams_MRIPI(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_SetParams_MRIPI(arg1,arg2,arg3,arg4,arg5); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FSUNAdaptController_GetType_MRIPI(SUNAdaptController farg1) { + int fresult ; + SUNAdaptController arg1 = (SUNAdaptController) 0 ; + SUNAdaptController_Type result; + + arg1 = (SUNAdaptController)(farg1); + result = (SUNAdaptController_Type)SUNAdaptController_GetType_MRIPI(arg1); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FSUNAdaptController_EstimateMRISteps_MRIPI(SUNAdaptController farg1, double const *farg2, double const *farg3, int const *farg4, double const *farg5, double const *farg6, double *farg7, double *farg8) { + int fresult ; + SUNAdaptController arg1 = (SUNAdaptController) 0 ; + sunrealtype arg2 ; + sunrealtype arg3 ; + int arg4 ; + sunrealtype arg5 ; + sunrealtype arg6 ; + sunrealtype *arg7 = (sunrealtype *) 0 ; + sunrealtype *arg8 = (sunrealtype *) 0 ; + int result; + + arg1 = (SUNAdaptController)(farg1); + arg2 = (sunrealtype)(*farg2); + arg3 = (sunrealtype)(*farg3); + arg4 = (int)(*farg4); + arg5 = (sunrealtype)(*farg5); + arg6 = (sunrealtype)(*farg6); + arg7 = (sunrealtype *)(farg7); + arg8 = (sunrealtype *)(farg8); + result = (int)SUNAdaptController_EstimateMRISteps_MRIPI(arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FSUNAdaptController_Reset_MRIPI(SUNAdaptController farg1) { + int fresult ; + SUNAdaptController arg1 = (SUNAdaptController) 0 ; + int result; + + arg1 = (SUNAdaptController)(farg1); + result = (int)SUNAdaptController_Reset_MRIPI(arg1); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FSUNAdaptController_SetDefaults_MRIPI(SUNAdaptController farg1) { + int fresult ; + SUNAdaptController arg1 = (SUNAdaptController) 0 ; + int result; + + arg1 = (SUNAdaptController)(farg1); + result = (int)SUNAdaptController_SetDefaults_MRIPI(arg1); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FSUNAdaptController_Write_MRIPI(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_MRIPI(arg1,arg2); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FSUNAdaptController_SetErrorBias_MRIPI(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_MRIPI(arg1,arg2); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FSUNAdaptController_UpdateMRIH_MRIPI(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_MRIPI(arg1,arg2,arg3,arg4,arg5); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FSUNAdaptController_Space_MRIPI(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_MRIPI(arg1,arg2,arg3); + fresult = (int)(result); + return fresult; +} + + + diff --git a/src/sunadaptcontroller/mripi/fmod_int64/fsunadaptcontroller_mripi_mod.f90 b/src/sunadaptcontroller/mripi/fmod_int64/fsunadaptcontroller_mripi_mod.f90 new file mode 100644 index 0000000000..6aa546b4fa --- /dev/null +++ b/src/sunadaptcontroller/mripi/fmod_int64/fsunadaptcontroller_mripi_mod.f90 @@ -0,0 +1,337 @@ +! 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-2024, 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_mripi_mod + use, intrinsic :: ISO_C_BINDING + use fsundials_core_mod + implicit none + private + + ! DECLARATION CONSTRUCTS + public :: FSUNAdaptController_MRIPI + public :: FSUNAdaptController_SetParams_MRIPI + public :: FSUNAdaptController_GetType_MRIPI + public :: FSUNAdaptController_EstimateMRISteps_MRIPI + public :: FSUNAdaptController_Reset_MRIPI + public :: FSUNAdaptController_SetDefaults_MRIPI + public :: FSUNAdaptController_Write_MRIPI + public :: FSUNAdaptController_SetErrorBias_MRIPI + public :: FSUNAdaptController_UpdateMRIH_MRIPI + public :: FSUNAdaptController_Space_MRIPI + +! WRAPPER DECLARATIONS +interface +function swigc_FSUNAdaptController_MRIPI(farg1, farg2) & +bind(C, name="_wrap_FSUNAdaptController_MRIPI") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +type(C_PTR), value :: farg1 +integer(C_INT), intent(in) :: farg2 +type(C_PTR) :: fresult +end function + +function swigc_FSUNAdaptController_SetParams_MRIPI(farg1, farg2, farg3, farg4, farg5) & +bind(C, name="_wrap_FSUNAdaptController_SetParams_MRIPI") & +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_GetType_MRIPI(farg1) & +bind(C, name="_wrap_FSUNAdaptController_GetType_MRIPI") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +type(C_PTR), value :: farg1 +integer(C_INT) :: fresult +end function + +function swigc_FSUNAdaptController_EstimateMRISteps_MRIPI(farg1, farg2, farg3, farg4, farg5, farg6, farg7, farg8) & +bind(C, name="_wrap_FSUNAdaptController_EstimateMRISteps_MRIPI") & +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 +real(C_DOUBLE), intent(in) :: farg5 +real(C_DOUBLE), intent(in) :: farg6 +type(C_PTR), value :: farg7 +type(C_PTR), value :: farg8 +integer(C_INT) :: fresult +end function + +function swigc_FSUNAdaptController_Reset_MRIPI(farg1) & +bind(C, name="_wrap_FSUNAdaptController_Reset_MRIPI") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +type(C_PTR), value :: farg1 +integer(C_INT) :: fresult +end function + +function swigc_FSUNAdaptController_SetDefaults_MRIPI(farg1) & +bind(C, name="_wrap_FSUNAdaptController_SetDefaults_MRIPI") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +type(C_PTR), value :: farg1 +integer(C_INT) :: fresult +end function + +function swigc_FSUNAdaptController_Write_MRIPI(farg1, farg2) & +bind(C, name="_wrap_FSUNAdaptController_Write_MRIPI") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +type(C_PTR), value :: farg1 +type(C_PTR), value :: farg2 +integer(C_INT) :: fresult +end function + +function swigc_FSUNAdaptController_SetErrorBias_MRIPI(farg1, farg2) & +bind(C, name="_wrap_FSUNAdaptController_SetErrorBias_MRIPI") & +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_UpdateMRIH_MRIPI(farg1, farg2, farg3, farg4, farg5) & +bind(C, name="_wrap_FSUNAdaptController_UpdateMRIH_MRIPI") & +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_MRIPI(farg1, farg2, farg3) & +bind(C, name="_wrap_FSUNAdaptController_Space_MRIPI") & +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_MRIPI(sunctx, p) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +type(SUNAdaptController), pointer :: swig_result +type(C_PTR) :: sunctx +integer(C_INT), intent(in) :: p +type(C_PTR) :: fresult +type(C_PTR) :: farg1 +integer(C_INT) :: farg2 + +farg1 = sunctx +farg2 = p +fresult = swigc_FSUNAdaptController_MRIPI(farg1, farg2) +call c_f_pointer(fresult, swig_result) +end function + +function FSUNAdaptController_SetParams_MRIPI(c, k11, k12, k21, k22) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(SUNAdaptController), target, intent(inout) :: c +real(C_DOUBLE), intent(in) :: k11 +real(C_DOUBLE), intent(in) :: k12 +real(C_DOUBLE), intent(in) :: k21 +real(C_DOUBLE), intent(in) :: k22 +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 = k11 +farg3 = k12 +farg4 = k21 +farg5 = k22 +fresult = swigc_FSUNAdaptController_SetParams_MRIPI(farg1, farg2, farg3, farg4, farg5) +swig_result = fresult +end function + +function FSUNAdaptController_GetType_MRIPI(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_MRIPI(farg1) +swig_result = fresult +end function + +function FSUNAdaptController_EstimateMRISteps_MRIPI(c, h, h2, p, dsm, dsm5, hnew, hnew7) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(SUNAdaptController), target, intent(inout) :: c +real(C_DOUBLE), intent(in) :: h +real(C_DOUBLE), intent(in) :: h2 +integer(C_INT), intent(in) :: p +real(C_DOUBLE), intent(in) :: dsm +real(C_DOUBLE), intent(in) :: dsm5 +real(C_DOUBLE), dimension(*), target, intent(inout) :: hnew +real(C_DOUBLE), dimension(*), target, intent(inout) :: hnew7 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +real(C_DOUBLE) :: farg2 +real(C_DOUBLE) :: farg3 +integer(C_INT) :: farg4 +real(C_DOUBLE) :: farg5 +real(C_DOUBLE) :: farg6 +type(C_PTR) :: farg7 +type(C_PTR) :: farg8 + +farg1 = c_loc(c) +farg2 = h +farg3 = h2 +farg4 = p +farg5 = dsm +farg6 = dsm5 +farg7 = c_loc(hnew(1)) +farg8 = c_loc(hnew7(1)) +fresult = swigc_FSUNAdaptController_EstimateMRISteps_MRIPI(farg1, farg2, farg3, farg4, farg5, farg6, farg7, farg8) +swig_result = fresult +end function + +function FSUNAdaptController_Reset_MRIPI(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_MRIPI(farg1) +swig_result = fresult +end function + +function FSUNAdaptController_SetDefaults_MRIPI(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_MRIPI(farg1) +swig_result = fresult +end function + +function FSUNAdaptController_Write_MRIPI(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_MRIPI(farg1, farg2) +swig_result = fresult +end function + +function FSUNAdaptController_SetErrorBias_MRIPI(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_MRIPI(farg1, farg2) +swig_result = fresult +end function + +function FSUNAdaptController_UpdateMRIH_MRIPI(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_MRIPI(farg1, farg2, farg3, farg4, farg5) +swig_result = fresult +end function + +function FSUNAdaptController_Space_MRIPI(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_MRIPI(farg1, farg2, farg3) +swig_result = fresult +end function + + +end module diff --git a/src/sunadaptcontroller/mripi/sunadaptcontroller_mripi.c b/src/sunadaptcontroller/mripi/sunadaptcontroller_mripi.c new file mode 100644 index 0000000000..af5b02eaed --- /dev/null +++ b/src/sunadaptcontroller/mripi/sunadaptcontroller_mripi.c @@ -0,0 +1,237 @@ +/* ----------------------------------------------------------------- + * Programmer(s): Daniel R. Reynolds @ SMU + * ----------------------------------------------------------------- + * SUNDIALS Copyright Start + * Copyright (c) 2002-2024, 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_MRIPI module. + * -----------------------------------------------------------------*/ + +#include +#include +#include +#include + +#include "sundials/priv/sundials_errors_impl.h" +#include "sundials/sundials_errors.h" + +/* --------------- + * Macro accessors + * --------------- */ + +#define MRIPI_CONTENT(C) ((SUNAdaptControllerContent_MRIPI)(C->content)) +#define MRIPI_K11(C) (MRIPI_CONTENT(C)->k11) +#define MRIPI_K12(C) (MRIPI_CONTENT(C)->k12) +#define MRIPI_K21(C) (MRIPI_CONTENT(C)->k21) +#define MRIPI_K22(C) (MRIPI_CONTENT(C)->k22) +#define MRIPI_BIAS(C) (MRIPI_CONTENT(C)->bias) +#define MRIPI_ESP(C) (MRIPI_CONTENT(C)->esp) +#define MRIPI_EFP(C) (MRIPI_CONTENT(C)->efp) +#define MRIPI_PFAST(C) (MRIPI_CONTENT(C)->p) + +/* ------------------ + * Default parameters + * ------------------ */ + +#define DEFAULT_K11 SUN_RCONST(0.18) +#define DEFAULT_K12 SUN_RCONST(0.86) +#define DEFAULT_K21 SUN_RCONST(0.34) +#define DEFAULT_K22 SUN_RCONST(0.80) +#define DEFAULT_BIAS SUN_RCONST(1.5) +#define ONE SUN_RCONST(1.0) +#define TINY (SUN_RCONST(10.0) * SUN_UNIT_ROUNDOFF) + +/* ----------------------------------------------------------------- + * exported functions + * ----------------------------------------------------------------- */ + +/* ----------------------------------------------------------------- + * Function to create a new MRIPI controller + */ + +SUNAdaptController SUNAdaptController_MRIPI(SUNContext sunctx, int p) +{ + SUNFunctionBegin(sunctx); + + SUNAdaptController C; + SUNAdaptControllerContent_MRIPI content; + + /* Create an empty controller object */ + C = NULL; + C = SUNAdaptController_NewEmpty(sunctx); + SUNCheckLastErrNull(); + + /* Attach operations */ + C->ops->gettype = SUNAdaptController_GetType_MRIPI; + C->ops->estimatemristeps = SUNAdaptController_EstimateMRISteps_MRIPI; + C->ops->reset = SUNAdaptController_Reset_MRIPI; + C->ops->setdefaults = SUNAdaptController_SetDefaults_MRIPI; + C->ops->write = SUNAdaptController_Write_MRIPI; + C->ops->seterrorbias = SUNAdaptController_SetErrorBias_MRIPI; + C->ops->updatemrih = SUNAdaptController_UpdateMRIH_MRIPI; + C->ops->space = SUNAdaptController_Space_MRIPI; + + /* Create content */ + content = NULL; + content = (SUNAdaptControllerContent_MRIPI)malloc(sizeof *content); + SUNAssertNull(content, SUN_ERR_MALLOC_FAIL); + + /* Attach content */ + C->content = content; + + /* Set fast method order */ + content->p = p; + + /* Fill content with default/reset values */ + SUNCheckCallNull(SUNAdaptController_SetDefaults_MRIPI(C)); + SUNCheckCallNull(SUNAdaptController_Reset_MRIPI(C)); + + return (C); +} + +/* ----------------------------------------------------------------- + * Function to set MRIPI parameters + */ + +SUNErrCode SUNAdaptController_SetParams_MRIPI(SUNAdaptController C, + sunrealtype k11, sunrealtype k12, + sunrealtype k21, sunrealtype k22) +{ + SUNFunctionBegin(C->sunctx); + MRIPI_K11(C) = k11; + MRIPI_K12(C) = k12; + MRIPI_K21(C) = k21; + MRIPI_K22(C) = k22; + return SUN_SUCCESS; +} + +/* ----------------------------------------------------------------- + * implementation of controller operations + * ----------------------------------------------------------------- */ + +SUNAdaptController_Type SUNAdaptController_GetType_MRIPI(SUNAdaptController C) +{ + return SUN_ADAPTCONTROLLER_MRI_H; +} + +SUNErrCode SUNAdaptController_EstimateMRISteps_MRIPI( + SUNAdaptController C, sunrealtype H, sunrealtype h, int P, sunrealtype DSM, + sunrealtype dsm, sunrealtype* Hnew, sunrealtype* hnew) +{ + SUNFunctionBegin(C->sunctx); + SUNAssert(Hnew, SUN_ERR_ARG_CORRUPT); + SUNAssert(hnew, SUN_ERR_ARG_CORRUPT); + + /* set usable time-step adaptivity parameters */ + const int p = MRIPI_PFAST(C); + const sunrealtype k11 = MRIPI_K11(C); + const sunrealtype k12 = MRIPI_K12(C); + const sunrealtype k21 = MRIPI_K21(C); + const sunrealtype k22 = MRIPI_K22(C); + const sunrealtype a1 = (k11 + k12) / (2 * P); + const sunrealtype a2 = -k11 / (2 * P); + const sunrealtype b11 = (p + 1) * (k11 + k12) / (2 * P * p); + const sunrealtype b12 = -(p + 1) * k11 / (2 * P * p); + const sunrealtype b21 = -(k21 + k22) / (2 * p); + const sunrealtype b22 = k21 / (2 * p); + const sunrealtype es1 = ONE / SUNMAX(MRIPI_BIAS(C) * DSM, TINY); + const sunrealtype es2 = ONE / MRIPI_ESP(C); + const sunrealtype ef1 = ONE / SUNMAX(MRIPI_BIAS(C) * dsm, TINY); + const sunrealtype ef2 = ONE / MRIPI_EFP(C); + const sunrealtype M = SUNRceil(H / h); + + /* compute estimated optimal time step size */ + *Hnew = H * SUNRpowerR(es1, a1) * SUNRpowerR(es2, a2); + const sunrealtype Mnew = M * SUNRpowerR(es1, b11) * SUNRpowerR(es2, b12) * + SUNRpowerR(ef1, b21) * SUNRpowerR(ef2, b22); + *hnew = (*Hnew) / Mnew; + + /* return with success */ + return SUN_SUCCESS; +} + +SUNErrCode SUNAdaptController_Reset_MRIPI(SUNAdaptController C) +{ + SUNFunctionBegin(C->sunctx); + MRIPI_ESP(C) = SUN_RCONST(1.0); + MRIPI_EFP(C) = SUN_RCONST(1.0); + return SUN_SUCCESS; +} + +SUNErrCode SUNAdaptController_SetDefaults_MRIPI(SUNAdaptController C) +{ + SUNFunctionBegin(C->sunctx); + MRIPI_K11(C) = DEFAULT_K11; + MRIPI_K12(C) = DEFAULT_K12; + MRIPI_K21(C) = DEFAULT_K21; + MRIPI_K22(C) = DEFAULT_K22; + MRIPI_BIAS(C) = DEFAULT_BIAS; + return SUN_SUCCESS; +} + +SUNErrCode SUNAdaptController_Write_MRIPI(SUNAdaptController C, FILE* fptr) +{ + SUNFunctionBegin(C->sunctx); + SUNAssert(fptr, SUN_ERR_ARG_CORRUPT); + fprintf(fptr, "Multirate PI SUNAdaptController module:\n"); +#if defined(SUNDIALS_EXTENDED_PRECISION) + fprintf(fptr, " k11 = %32Lg\n", MRIPI_K11(C)); + fprintf(fptr, " k12 = %32Lg\n", MRIPI_K12(C)); + fprintf(fptr, " k21 = %32Lg\n", MRIPI_K21(C)); + fprintf(fptr, " k22 = %32Lg\n", MRIPI_K22(C)); + fprintf(fptr, " bias factor = %32Lg\n", MRIPI_BIAS(C)); + fprintf(fptr, " previous slow error = %32Lg\n", MRIPI_ESP(C)); + fprintf(fptr, " previous fast error = %32Lg\n", MRIPI_EFP(C)); +#else + fprintf(fptr, " k11 = %16g\n", MRIPI_K11(C)); + fprintf(fptr, " k12 = %16g\n", MRIPI_K12(C)); + fprintf(fptr, " k21 = %16g\n", MRIPI_K21(C)); + fprintf(fptr, " k22 = %16g\n", MRIPI_K22(C)); + fprintf(fptr, " bias factor = %16g\n", MRIPI_BIAS(C)); + fprintf(fptr, " previous slow error = %16g\n", MRIPI_ESP(C)); + fprintf(fptr, " previous fast error = %16g\n", MRIPI_EFP(C)); +#endif + fprintf(fptr, " p = %i (fast method order)\n", MRIPI_PFAST(C)); + return SUN_SUCCESS; +} + +SUNErrCode SUNAdaptController_SetErrorBias_MRIPI(SUNAdaptController C, + sunrealtype bias) +{ + SUNFunctionBegin(C->sunctx); + + /* set allowed value, otherwise set default */ + if (bias <= SUN_RCONST(0.0)) { MRIPI_BIAS(C) = DEFAULT_BIAS; } + else { MRIPI_BIAS(C) = bias; } + + return SUN_SUCCESS; +} + +SUNErrCode SUNAdaptController_UpdateMRIH_MRIPI(SUNAdaptController C, + sunrealtype H, sunrealtype h, + sunrealtype DSM, sunrealtype dsm) +{ + SUNFunctionBegin(C->sunctx); + MRIPI_ESP(C) = SUNMAX(MRIPI_BIAS(C) * DSM, TINY); + MRIPI_EFP(C) = SUNMAX(MRIPI_BIAS(C) * dsm, TINY); + return SUN_SUCCESS; +} + +SUNErrCode SUNAdaptController_Space_MRIPI(SUNAdaptController C, long int* lenrw, + long int* leniw) +{ + SUNFunctionBegin(C->sunctx); + SUNAssert(lenrw, SUN_ERR_ARG_CORRUPT); + SUNAssert(leniw, SUN_ERR_ARG_CORRUPT); + *lenrw = 7; + *leniw = 1; + return SUN_SUCCESS; +} diff --git a/src/sunadaptcontroller/mripid/CMakeLists.txt b/src/sunadaptcontroller/mripid/CMakeLists.txt new file mode 100644 index 0000000000..5c18b5d723 --- /dev/null +++ b/src/sunadaptcontroller/mripid/CMakeLists.txt @@ -0,0 +1,28 @@ +# --------------------------------------------------------------- +# Programmer(s): Daniel R. Reynolds @ SMU +# --------------------------------------------------------------- +# SUNDIALS Copyright Start +# Copyright (c) 2002-2024, 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_sunadaptcontrollermripid + SOURCES sunadaptcontroller_mripid.c + HEADERS + ${SUNDIALS_SOURCE_DIR}/include/sunadaptcontroller/sunadaptcontroller_mripid.h + LINK_LIBRARIES PUBLIC sundials_core + INCLUDE_SUBDIR sunadaptcontroller + OBJECT_LIB_ONLY) + +# Add F2003 module if the interface is enabled +if(BUILD_FORTRAN_MODULE_INTERFACE) + add_subdirectory("fmod_int${SUNDIALS_INDEX_SIZE}") +endif() diff --git a/src/sunadaptcontroller/mripid/fmod_int32/CMakeLists.txt b/src/sunadaptcontroller/mripid/fmod_int32/CMakeLists.txt new file mode 100644 index 0000000000..db31e1af04 --- /dev/null +++ b/src/sunadaptcontroller/mripid/fmod_int32/CMakeLists.txt @@ -0,0 +1,26 @@ +# --------------------------------------------------------------- +# Programmer(s): Daniel R. Reynolds @ SMU +# --------------------------------------------------------------- +# SUNDIALS Copyright Start +# Copyright (c) 2002-2024, 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_fsunadaptcontrollermripid_mod + SOURCES + fsunadaptcontroller_mripid_mod.f90 fsunadaptcontroller_mripid_mod.c + LINK_LIBRARIES + PUBLIC sundials_fcore_mod + OBJECT_LIBRARIES + OUTPUT_NAME + sundials_fsunadaptcontrollermripid_mod + OBJECT_LIB_ONLY +) + +message(STATUS "Added SUNAdaptController_MRIPID F2003 interface") diff --git a/src/sunadaptcontroller/mripid/fmod_int32/fsunadaptcontroller_mripid_mod.c b/src/sunadaptcontroller/mripid/fmod_int32/fsunadaptcontroller_mripid_mod.c new file mode 100644 index 0000000000..4414b22564 --- /dev/null +++ b/src/sunadaptcontroller/mripid/fmod_int32/fsunadaptcontroller_mripid_mod.c @@ -0,0 +1,375 @@ +/* ---------------------------------------------------------------------------- + * 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-2024, 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_mripid.h" + +SWIGEXPORT SUNAdaptController _wrap_FSUNAdaptController_MRIPID(void *farg1, int const *farg2) { + SUNAdaptController fresult ; + SUNContext arg1 = (SUNContext) 0 ; + int arg2 ; + SUNAdaptController result; + + arg1 = (SUNContext)(farg1); + arg2 = (int)(*farg2); + result = (SUNAdaptController)SUNAdaptController_MRIPID(arg1,arg2); + fresult = result; + return fresult; +} + + +SWIGEXPORT int _wrap_FSUNAdaptController_SetParams_MRIPID(SUNAdaptController farg1, double const *farg2, double const *farg3, double const *farg4, double const *farg5, double const *farg6, double const *farg7) { + int fresult ; + SUNAdaptController arg1 = (SUNAdaptController) 0 ; + sunrealtype arg2 ; + sunrealtype arg3 ; + sunrealtype arg4 ; + sunrealtype arg5 ; + sunrealtype arg6 ; + sunrealtype arg7 ; + 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_SetParams_MRIPID(arg1,arg2,arg3,arg4,arg5,arg6,arg7); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FSUNAdaptController_GetType_MRIPID(SUNAdaptController farg1) { + int fresult ; + SUNAdaptController arg1 = (SUNAdaptController) 0 ; + SUNAdaptController_Type result; + + arg1 = (SUNAdaptController)(farg1); + result = (SUNAdaptController_Type)SUNAdaptController_GetType_MRIPID(arg1); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FSUNAdaptController_EstimateMRISteps_MRIPID(SUNAdaptController farg1, double const *farg2, double const *farg3, int const *farg4, double const *farg5, double const *farg6, double *farg7, double *farg8) { + int fresult ; + SUNAdaptController arg1 = (SUNAdaptController) 0 ; + sunrealtype arg2 ; + sunrealtype arg3 ; + int arg4 ; + sunrealtype arg5 ; + sunrealtype arg6 ; + sunrealtype *arg7 = (sunrealtype *) 0 ; + sunrealtype *arg8 = (sunrealtype *) 0 ; + int result; + + arg1 = (SUNAdaptController)(farg1); + arg2 = (sunrealtype)(*farg2); + arg3 = (sunrealtype)(*farg3); + arg4 = (int)(*farg4); + arg5 = (sunrealtype)(*farg5); + arg6 = (sunrealtype)(*farg6); + arg7 = (sunrealtype *)(farg7); + arg8 = (sunrealtype *)(farg8); + result = (int)SUNAdaptController_EstimateMRISteps_MRIPID(arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FSUNAdaptController_Reset_MRIPID(SUNAdaptController farg1) { + int fresult ; + SUNAdaptController arg1 = (SUNAdaptController) 0 ; + int result; + + arg1 = (SUNAdaptController)(farg1); + result = (int)SUNAdaptController_Reset_MRIPID(arg1); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FSUNAdaptController_SetDefaults_MRIPID(SUNAdaptController farg1) { + int fresult ; + SUNAdaptController arg1 = (SUNAdaptController) 0 ; + int result; + + arg1 = (SUNAdaptController)(farg1); + result = (int)SUNAdaptController_SetDefaults_MRIPID(arg1); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FSUNAdaptController_Write_MRIPID(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_MRIPID(arg1,arg2); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FSUNAdaptController_SetErrorBias_MRIPID(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_MRIPID(arg1,arg2); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FSUNAdaptController_UpdateMRIH_MRIPID(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_MRIPID(arg1,arg2,arg3,arg4,arg5); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FSUNAdaptController_Space_MRIPID(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_MRIPID(arg1,arg2,arg3); + fresult = (int)(result); + return fresult; +} + + + diff --git a/src/sunadaptcontroller/mripid/fmod_int32/fsunadaptcontroller_mripid_mod.f90 b/src/sunadaptcontroller/mripid/fmod_int32/fsunadaptcontroller_mripid_mod.f90 new file mode 100644 index 0000000000..400002f9ce --- /dev/null +++ b/src/sunadaptcontroller/mripid/fmod_int32/fsunadaptcontroller_mripid_mod.f90 @@ -0,0 +1,345 @@ +! 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-2024, 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_mripid_mod + use, intrinsic :: ISO_C_BINDING + use fsundials_core_mod + implicit none + private + + ! DECLARATION CONSTRUCTS + public :: FSUNAdaptController_MRIPID + public :: FSUNAdaptController_SetParams_MRIPID + public :: FSUNAdaptController_GetType_MRIPID + public :: FSUNAdaptController_EstimateMRISteps_MRIPID + public :: FSUNAdaptController_Reset_MRIPID + public :: FSUNAdaptController_SetDefaults_MRIPID + public :: FSUNAdaptController_Write_MRIPID + public :: FSUNAdaptController_SetErrorBias_MRIPID + public :: FSUNAdaptController_UpdateMRIH_MRIPID + public :: FSUNAdaptController_Space_MRIPID + +! WRAPPER DECLARATIONS +interface +function swigc_FSUNAdaptController_MRIPID(farg1, farg2) & +bind(C, name="_wrap_FSUNAdaptController_MRIPID") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +type(C_PTR), value :: farg1 +integer(C_INT), intent(in) :: farg2 +type(C_PTR) :: fresult +end function + +function swigc_FSUNAdaptController_SetParams_MRIPID(farg1, farg2, farg3, farg4, farg5, farg6, farg7) & +bind(C, name="_wrap_FSUNAdaptController_SetParams_MRIPID") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +type(C_PTR), value :: farg1 +real(C_DOUBLE), intent(in) :: farg2 +real(C_DOUBLE), intent(in) :: farg3 +real(C_DOUBLE), intent(in) :: farg4 +real(C_DOUBLE), intent(in) :: farg5 +real(C_DOUBLE), intent(in) :: farg6 +real(C_DOUBLE), intent(in) :: farg7 +integer(C_INT) :: fresult +end function + +function swigc_FSUNAdaptController_GetType_MRIPID(farg1) & +bind(C, name="_wrap_FSUNAdaptController_GetType_MRIPID") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +type(C_PTR), value :: farg1 +integer(C_INT) :: fresult +end function + +function swigc_FSUNAdaptController_EstimateMRISteps_MRIPID(farg1, farg2, farg3, farg4, farg5, farg6, farg7, farg8) & +bind(C, name="_wrap_FSUNAdaptController_EstimateMRISteps_MRIPID") & +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 +real(C_DOUBLE), intent(in) :: farg5 +real(C_DOUBLE), intent(in) :: farg6 +type(C_PTR), value :: farg7 +type(C_PTR), value :: farg8 +integer(C_INT) :: fresult +end function + +function swigc_FSUNAdaptController_Reset_MRIPID(farg1) & +bind(C, name="_wrap_FSUNAdaptController_Reset_MRIPID") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +type(C_PTR), value :: farg1 +integer(C_INT) :: fresult +end function + +function swigc_FSUNAdaptController_SetDefaults_MRIPID(farg1) & +bind(C, name="_wrap_FSUNAdaptController_SetDefaults_MRIPID") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +type(C_PTR), value :: farg1 +integer(C_INT) :: fresult +end function + +function swigc_FSUNAdaptController_Write_MRIPID(farg1, farg2) & +bind(C, name="_wrap_FSUNAdaptController_Write_MRIPID") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +type(C_PTR), value :: farg1 +type(C_PTR), value :: farg2 +integer(C_INT) :: fresult +end function + +function swigc_FSUNAdaptController_SetErrorBias_MRIPID(farg1, farg2) & +bind(C, name="_wrap_FSUNAdaptController_SetErrorBias_MRIPID") & +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_UpdateMRIH_MRIPID(farg1, farg2, farg3, farg4, farg5) & +bind(C, name="_wrap_FSUNAdaptController_UpdateMRIH_MRIPID") & +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_MRIPID(farg1, farg2, farg3) & +bind(C, name="_wrap_FSUNAdaptController_Space_MRIPID") & +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_MRIPID(sunctx, p) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +type(SUNAdaptController), pointer :: swig_result +type(C_PTR) :: sunctx +integer(C_INT), intent(in) :: p +type(C_PTR) :: fresult +type(C_PTR) :: farg1 +integer(C_INT) :: farg2 + +farg1 = sunctx +farg2 = p +fresult = swigc_FSUNAdaptController_MRIPID(farg1, farg2) +call c_f_pointer(fresult, swig_result) +end function + +function FSUNAdaptController_SetParams_MRIPID(c, k11, k12, k13, k21, k22, k23) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(SUNAdaptController), target, intent(inout) :: c +real(C_DOUBLE), intent(in) :: k11 +real(C_DOUBLE), intent(in) :: k12 +real(C_DOUBLE), intent(in) :: k13 +real(C_DOUBLE), intent(in) :: k21 +real(C_DOUBLE), intent(in) :: k22 +real(C_DOUBLE), intent(in) :: k23 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +real(C_DOUBLE) :: farg2 +real(C_DOUBLE) :: farg3 +real(C_DOUBLE) :: farg4 +real(C_DOUBLE) :: farg5 +real(C_DOUBLE) :: farg6 +real(C_DOUBLE) :: farg7 + +farg1 = c_loc(c) +farg2 = k11 +farg3 = k12 +farg4 = k13 +farg5 = k21 +farg6 = k22 +farg7 = k23 +fresult = swigc_FSUNAdaptController_SetParams_MRIPID(farg1, farg2, farg3, farg4, farg5, farg6, farg7) +swig_result = fresult +end function + +function FSUNAdaptController_GetType_MRIPID(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_MRIPID(farg1) +swig_result = fresult +end function + +function FSUNAdaptController_EstimateMRISteps_MRIPID(c, h, h2, p, dsm, dsm5, hnew, hnew7) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(SUNAdaptController), target, intent(inout) :: c +real(C_DOUBLE), intent(in) :: h +real(C_DOUBLE), intent(in) :: h2 +integer(C_INT), intent(in) :: p +real(C_DOUBLE), intent(in) :: dsm +real(C_DOUBLE), intent(in) :: dsm5 +real(C_DOUBLE), dimension(*), target, intent(inout) :: hnew +real(C_DOUBLE), dimension(*), target, intent(inout) :: hnew7 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +real(C_DOUBLE) :: farg2 +real(C_DOUBLE) :: farg3 +integer(C_INT) :: farg4 +real(C_DOUBLE) :: farg5 +real(C_DOUBLE) :: farg6 +type(C_PTR) :: farg7 +type(C_PTR) :: farg8 + +farg1 = c_loc(c) +farg2 = h +farg3 = h2 +farg4 = p +farg5 = dsm +farg6 = dsm5 +farg7 = c_loc(hnew(1)) +farg8 = c_loc(hnew7(1)) +fresult = swigc_FSUNAdaptController_EstimateMRISteps_MRIPID(farg1, farg2, farg3, farg4, farg5, farg6, farg7, farg8) +swig_result = fresult +end function + +function FSUNAdaptController_Reset_MRIPID(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_MRIPID(farg1) +swig_result = fresult +end function + +function FSUNAdaptController_SetDefaults_MRIPID(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_MRIPID(farg1) +swig_result = fresult +end function + +function FSUNAdaptController_Write_MRIPID(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_MRIPID(farg1, farg2) +swig_result = fresult +end function + +function FSUNAdaptController_SetErrorBias_MRIPID(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_MRIPID(farg1, farg2) +swig_result = fresult +end function + +function FSUNAdaptController_UpdateMRIH_MRIPID(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_MRIPID(farg1, farg2, farg3, farg4, farg5) +swig_result = fresult +end function + +function FSUNAdaptController_Space_MRIPID(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_MRIPID(farg1, farg2, farg3) +swig_result = fresult +end function + + +end module diff --git a/src/sunadaptcontroller/mripid/fmod_int64/CMakeLists.txt b/src/sunadaptcontroller/mripid/fmod_int64/CMakeLists.txt new file mode 100644 index 0000000000..db31e1af04 --- /dev/null +++ b/src/sunadaptcontroller/mripid/fmod_int64/CMakeLists.txt @@ -0,0 +1,26 @@ +# --------------------------------------------------------------- +# Programmer(s): Daniel R. Reynolds @ SMU +# --------------------------------------------------------------- +# SUNDIALS Copyright Start +# Copyright (c) 2002-2024, 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_fsunadaptcontrollermripid_mod + SOURCES + fsunadaptcontroller_mripid_mod.f90 fsunadaptcontroller_mripid_mod.c + LINK_LIBRARIES + PUBLIC sundials_fcore_mod + OBJECT_LIBRARIES + OUTPUT_NAME + sundials_fsunadaptcontrollermripid_mod + OBJECT_LIB_ONLY +) + +message(STATUS "Added SUNAdaptController_MRIPID F2003 interface") diff --git a/src/sunadaptcontroller/mripid/fmod_int64/fsunadaptcontroller_mripid_mod.c b/src/sunadaptcontroller/mripid/fmod_int64/fsunadaptcontroller_mripid_mod.c new file mode 100644 index 0000000000..4414b22564 --- /dev/null +++ b/src/sunadaptcontroller/mripid/fmod_int64/fsunadaptcontroller_mripid_mod.c @@ -0,0 +1,375 @@ +/* ---------------------------------------------------------------------------- + * 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-2024, 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_mripid.h" + +SWIGEXPORT SUNAdaptController _wrap_FSUNAdaptController_MRIPID(void *farg1, int const *farg2) { + SUNAdaptController fresult ; + SUNContext arg1 = (SUNContext) 0 ; + int arg2 ; + SUNAdaptController result; + + arg1 = (SUNContext)(farg1); + arg2 = (int)(*farg2); + result = (SUNAdaptController)SUNAdaptController_MRIPID(arg1,arg2); + fresult = result; + return fresult; +} + + +SWIGEXPORT int _wrap_FSUNAdaptController_SetParams_MRIPID(SUNAdaptController farg1, double const *farg2, double const *farg3, double const *farg4, double const *farg5, double const *farg6, double const *farg7) { + int fresult ; + SUNAdaptController arg1 = (SUNAdaptController) 0 ; + sunrealtype arg2 ; + sunrealtype arg3 ; + sunrealtype arg4 ; + sunrealtype arg5 ; + sunrealtype arg6 ; + sunrealtype arg7 ; + 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_SetParams_MRIPID(arg1,arg2,arg3,arg4,arg5,arg6,arg7); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FSUNAdaptController_GetType_MRIPID(SUNAdaptController farg1) { + int fresult ; + SUNAdaptController arg1 = (SUNAdaptController) 0 ; + SUNAdaptController_Type result; + + arg1 = (SUNAdaptController)(farg1); + result = (SUNAdaptController_Type)SUNAdaptController_GetType_MRIPID(arg1); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FSUNAdaptController_EstimateMRISteps_MRIPID(SUNAdaptController farg1, double const *farg2, double const *farg3, int const *farg4, double const *farg5, double const *farg6, double *farg7, double *farg8) { + int fresult ; + SUNAdaptController arg1 = (SUNAdaptController) 0 ; + sunrealtype arg2 ; + sunrealtype arg3 ; + int arg4 ; + sunrealtype arg5 ; + sunrealtype arg6 ; + sunrealtype *arg7 = (sunrealtype *) 0 ; + sunrealtype *arg8 = (sunrealtype *) 0 ; + int result; + + arg1 = (SUNAdaptController)(farg1); + arg2 = (sunrealtype)(*farg2); + arg3 = (sunrealtype)(*farg3); + arg4 = (int)(*farg4); + arg5 = (sunrealtype)(*farg5); + arg6 = (sunrealtype)(*farg6); + arg7 = (sunrealtype *)(farg7); + arg8 = (sunrealtype *)(farg8); + result = (int)SUNAdaptController_EstimateMRISteps_MRIPID(arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FSUNAdaptController_Reset_MRIPID(SUNAdaptController farg1) { + int fresult ; + SUNAdaptController arg1 = (SUNAdaptController) 0 ; + int result; + + arg1 = (SUNAdaptController)(farg1); + result = (int)SUNAdaptController_Reset_MRIPID(arg1); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FSUNAdaptController_SetDefaults_MRIPID(SUNAdaptController farg1) { + int fresult ; + SUNAdaptController arg1 = (SUNAdaptController) 0 ; + int result; + + arg1 = (SUNAdaptController)(farg1); + result = (int)SUNAdaptController_SetDefaults_MRIPID(arg1); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FSUNAdaptController_Write_MRIPID(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_MRIPID(arg1,arg2); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FSUNAdaptController_SetErrorBias_MRIPID(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_MRIPID(arg1,arg2); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FSUNAdaptController_UpdateMRIH_MRIPID(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_MRIPID(arg1,arg2,arg3,arg4,arg5); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FSUNAdaptController_Space_MRIPID(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_MRIPID(arg1,arg2,arg3); + fresult = (int)(result); + return fresult; +} + + + diff --git a/src/sunadaptcontroller/mripid/fmod_int64/fsunadaptcontroller_mripid_mod.f90 b/src/sunadaptcontroller/mripid/fmod_int64/fsunadaptcontroller_mripid_mod.f90 new file mode 100644 index 0000000000..400002f9ce --- /dev/null +++ b/src/sunadaptcontroller/mripid/fmod_int64/fsunadaptcontroller_mripid_mod.f90 @@ -0,0 +1,345 @@ +! 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-2024, 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_mripid_mod + use, intrinsic :: ISO_C_BINDING + use fsundials_core_mod + implicit none + private + + ! DECLARATION CONSTRUCTS + public :: FSUNAdaptController_MRIPID + public :: FSUNAdaptController_SetParams_MRIPID + public :: FSUNAdaptController_GetType_MRIPID + public :: FSUNAdaptController_EstimateMRISteps_MRIPID + public :: FSUNAdaptController_Reset_MRIPID + public :: FSUNAdaptController_SetDefaults_MRIPID + public :: FSUNAdaptController_Write_MRIPID + public :: FSUNAdaptController_SetErrorBias_MRIPID + public :: FSUNAdaptController_UpdateMRIH_MRIPID + public :: FSUNAdaptController_Space_MRIPID + +! WRAPPER DECLARATIONS +interface +function swigc_FSUNAdaptController_MRIPID(farg1, farg2) & +bind(C, name="_wrap_FSUNAdaptController_MRIPID") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +type(C_PTR), value :: farg1 +integer(C_INT), intent(in) :: farg2 +type(C_PTR) :: fresult +end function + +function swigc_FSUNAdaptController_SetParams_MRIPID(farg1, farg2, farg3, farg4, farg5, farg6, farg7) & +bind(C, name="_wrap_FSUNAdaptController_SetParams_MRIPID") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +type(C_PTR), value :: farg1 +real(C_DOUBLE), intent(in) :: farg2 +real(C_DOUBLE), intent(in) :: farg3 +real(C_DOUBLE), intent(in) :: farg4 +real(C_DOUBLE), intent(in) :: farg5 +real(C_DOUBLE), intent(in) :: farg6 +real(C_DOUBLE), intent(in) :: farg7 +integer(C_INT) :: fresult +end function + +function swigc_FSUNAdaptController_GetType_MRIPID(farg1) & +bind(C, name="_wrap_FSUNAdaptController_GetType_MRIPID") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +type(C_PTR), value :: farg1 +integer(C_INT) :: fresult +end function + +function swigc_FSUNAdaptController_EstimateMRISteps_MRIPID(farg1, farg2, farg3, farg4, farg5, farg6, farg7, farg8) & +bind(C, name="_wrap_FSUNAdaptController_EstimateMRISteps_MRIPID") & +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 +real(C_DOUBLE), intent(in) :: farg5 +real(C_DOUBLE), intent(in) :: farg6 +type(C_PTR), value :: farg7 +type(C_PTR), value :: farg8 +integer(C_INT) :: fresult +end function + +function swigc_FSUNAdaptController_Reset_MRIPID(farg1) & +bind(C, name="_wrap_FSUNAdaptController_Reset_MRIPID") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +type(C_PTR), value :: farg1 +integer(C_INT) :: fresult +end function + +function swigc_FSUNAdaptController_SetDefaults_MRIPID(farg1) & +bind(C, name="_wrap_FSUNAdaptController_SetDefaults_MRIPID") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +type(C_PTR), value :: farg1 +integer(C_INT) :: fresult +end function + +function swigc_FSUNAdaptController_Write_MRIPID(farg1, farg2) & +bind(C, name="_wrap_FSUNAdaptController_Write_MRIPID") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +type(C_PTR), value :: farg1 +type(C_PTR), value :: farg2 +integer(C_INT) :: fresult +end function + +function swigc_FSUNAdaptController_SetErrorBias_MRIPID(farg1, farg2) & +bind(C, name="_wrap_FSUNAdaptController_SetErrorBias_MRIPID") & +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_UpdateMRIH_MRIPID(farg1, farg2, farg3, farg4, farg5) & +bind(C, name="_wrap_FSUNAdaptController_UpdateMRIH_MRIPID") & +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_MRIPID(farg1, farg2, farg3) & +bind(C, name="_wrap_FSUNAdaptController_Space_MRIPID") & +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_MRIPID(sunctx, p) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +type(SUNAdaptController), pointer :: swig_result +type(C_PTR) :: sunctx +integer(C_INT), intent(in) :: p +type(C_PTR) :: fresult +type(C_PTR) :: farg1 +integer(C_INT) :: farg2 + +farg1 = sunctx +farg2 = p +fresult = swigc_FSUNAdaptController_MRIPID(farg1, farg2) +call c_f_pointer(fresult, swig_result) +end function + +function FSUNAdaptController_SetParams_MRIPID(c, k11, k12, k13, k21, k22, k23) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(SUNAdaptController), target, intent(inout) :: c +real(C_DOUBLE), intent(in) :: k11 +real(C_DOUBLE), intent(in) :: k12 +real(C_DOUBLE), intent(in) :: k13 +real(C_DOUBLE), intent(in) :: k21 +real(C_DOUBLE), intent(in) :: k22 +real(C_DOUBLE), intent(in) :: k23 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +real(C_DOUBLE) :: farg2 +real(C_DOUBLE) :: farg3 +real(C_DOUBLE) :: farg4 +real(C_DOUBLE) :: farg5 +real(C_DOUBLE) :: farg6 +real(C_DOUBLE) :: farg7 + +farg1 = c_loc(c) +farg2 = k11 +farg3 = k12 +farg4 = k13 +farg5 = k21 +farg6 = k22 +farg7 = k23 +fresult = swigc_FSUNAdaptController_SetParams_MRIPID(farg1, farg2, farg3, farg4, farg5, farg6, farg7) +swig_result = fresult +end function + +function FSUNAdaptController_GetType_MRIPID(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_MRIPID(farg1) +swig_result = fresult +end function + +function FSUNAdaptController_EstimateMRISteps_MRIPID(c, h, h2, p, dsm, dsm5, hnew, hnew7) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(SUNAdaptController), target, intent(inout) :: c +real(C_DOUBLE), intent(in) :: h +real(C_DOUBLE), intent(in) :: h2 +integer(C_INT), intent(in) :: p +real(C_DOUBLE), intent(in) :: dsm +real(C_DOUBLE), intent(in) :: dsm5 +real(C_DOUBLE), dimension(*), target, intent(inout) :: hnew +real(C_DOUBLE), dimension(*), target, intent(inout) :: hnew7 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +real(C_DOUBLE) :: farg2 +real(C_DOUBLE) :: farg3 +integer(C_INT) :: farg4 +real(C_DOUBLE) :: farg5 +real(C_DOUBLE) :: farg6 +type(C_PTR) :: farg7 +type(C_PTR) :: farg8 + +farg1 = c_loc(c) +farg2 = h +farg3 = h2 +farg4 = p +farg5 = dsm +farg6 = dsm5 +farg7 = c_loc(hnew(1)) +farg8 = c_loc(hnew7(1)) +fresult = swigc_FSUNAdaptController_EstimateMRISteps_MRIPID(farg1, farg2, farg3, farg4, farg5, farg6, farg7, farg8) +swig_result = fresult +end function + +function FSUNAdaptController_Reset_MRIPID(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_MRIPID(farg1) +swig_result = fresult +end function + +function FSUNAdaptController_SetDefaults_MRIPID(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_MRIPID(farg1) +swig_result = fresult +end function + +function FSUNAdaptController_Write_MRIPID(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_MRIPID(farg1, farg2) +swig_result = fresult +end function + +function FSUNAdaptController_SetErrorBias_MRIPID(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_MRIPID(farg1, farg2) +swig_result = fresult +end function + +function FSUNAdaptController_UpdateMRIH_MRIPID(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_MRIPID(farg1, farg2, farg3, farg4, farg5) +swig_result = fresult +end function + +function FSUNAdaptController_Space_MRIPID(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_MRIPID(farg1, farg2, farg3) +swig_result = fresult +end function + + +end module diff --git a/src/sunadaptcontroller/mripid/sunadaptcontroller_mripid.c b/src/sunadaptcontroller/mripid/sunadaptcontroller_mripid.c new file mode 100644 index 0000000000..deb38c323d --- /dev/null +++ b/src/sunadaptcontroller/mripid/sunadaptcontroller_mripid.c @@ -0,0 +1,268 @@ +/* ----------------------------------------------------------------- + * Programmer(s): Daniel R. Reynolds @ SMU + * ----------------------------------------------------------------- + * SUNDIALS Copyright Start + * Copyright (c) 2002-2024, 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_MRIPID module. + * -----------------------------------------------------------------*/ + +#include +#include +#include +#include + +#include "sundials/priv/sundials_errors_impl.h" +#include "sundials/sundials_errors.h" + +/* --------------- + * Macro accessors + * --------------- */ + +#define MRIPID_CONTENT(C) ((SUNAdaptControllerContent_MRIPID)(C->content)) +#define MRIPID_K11(C) (MRIPID_CONTENT(C)->k11) +#define MRIPID_K12(C) (MRIPID_CONTENT(C)->k12) +#define MRIPID_K13(C) (MRIPID_CONTENT(C)->k13) +#define MRIPID_K21(C) (MRIPID_CONTENT(C)->k21) +#define MRIPID_K22(C) (MRIPID_CONTENT(C)->k22) +#define MRIPID_K23(C) (MRIPID_CONTENT(C)->k23) +#define MRIPID_BIAS(C) (MRIPID_CONTENT(C)->bias) +#define MRIPID_ESP(C) (MRIPID_CONTENT(C)->esp) +#define MRIPID_EFP(C) (MRIPID_CONTENT(C)->efp) +#define MRIPID_ESPP(C) (MRIPID_CONTENT(C)->espp) +#define MRIPID_EFPP(C) (MRIPID_CONTENT(C)->efpp) +#define MRIPID_PFAST(C) (MRIPID_CONTENT(C)->p) + +/* ------------------ + * Default parameters + * ------------------ */ + +#define DEFAULT_K11 SUN_RCONST(0.34) +#define DEFAULT_K12 SUN_RCONST(0.1) +#define DEFAULT_K13 SUN_RCONST(0.78) +#define DEFAULT_K21 SUN_RCONST(0.46) +#define DEFAULT_K22 SUN_RCONST(0.42) +#define DEFAULT_K23 SUN_RCONST(0.74) +#define DEFAULT_BIAS SUN_RCONST(1.5) +#define ONE SUN_RCONST(1.0) +#define TINY (SUN_RCONST(10.0) * SUN_UNIT_ROUNDOFF) + +/* ----------------------------------------------------------------- + * exported functions + * ----------------------------------------------------------------- */ + +/* ----------------------------------------------------------------- + * Function to create a new MRIPID controller + */ + +SUNAdaptController SUNAdaptController_MRIPID(SUNContext sunctx, int p) +{ + SUNFunctionBegin(sunctx); + + SUNAdaptController C; + SUNAdaptControllerContent_MRIPID content; + + /* Create an empty controller object */ + C = NULL; + C = SUNAdaptController_NewEmpty(sunctx); + SUNCheckLastErrNull(); + + /* Attach operations */ + C->ops->gettype = SUNAdaptController_GetType_MRIPID; + C->ops->estimatemristeps = SUNAdaptController_EstimateMRISteps_MRIPID; + C->ops->reset = SUNAdaptController_Reset_MRIPID; + C->ops->setdefaults = SUNAdaptController_SetDefaults_MRIPID; + C->ops->write = SUNAdaptController_Write_MRIPID; + C->ops->seterrorbias = SUNAdaptController_SetErrorBias_MRIPID; + C->ops->updatemrih = SUNAdaptController_UpdateMRIH_MRIPID; + C->ops->space = SUNAdaptController_Space_MRIPID; + + /* Create content */ + content = NULL; + content = (SUNAdaptControllerContent_MRIPID)malloc(sizeof *content); + SUNAssertNull(content, SUN_ERR_MALLOC_FAIL); + + /* Attach content */ + C->content = content; + + /* Set fast method order */ + content->p = p; + + /* Fill content with default/reset values */ + SUNCheckCallNull(SUNAdaptController_SetDefaults_MRIPID(C)); + SUNCheckCallNull(SUNAdaptController_Reset_MRIPID(C)); + + return (C); +} + +/* ----------------------------------------------------------------- + * Function to set MRIPID parameters + */ + +SUNErrCode SUNAdaptController_SetParams_MRIPID(SUNAdaptController C, + sunrealtype k11, sunrealtype k12, + sunrealtype k13, sunrealtype k21, + sunrealtype k22, sunrealtype k23) +{ + SUNFunctionBegin(C->sunctx); + MRIPID_K11(C) = k11; + MRIPID_K12(C) = k12; + MRIPID_K13(C) = k13; + MRIPID_K21(C) = k21; + MRIPID_K22(C) = k22; + MRIPID_K23(C) = k23; + return SUN_SUCCESS; +} + +/* ----------------------------------------------------------------- + * implementation of controller operations + * ----------------------------------------------------------------- */ + +SUNAdaptController_Type SUNAdaptController_GetType_MRIPID(SUNAdaptController C) +{ + return SUN_ADAPTCONTROLLER_MRI_H; +} + +SUNErrCode SUNAdaptController_EstimateMRISteps_MRIPID( + SUNAdaptController C, sunrealtype H, sunrealtype h, int P, sunrealtype DSM, + sunrealtype dsm, sunrealtype* Hnew, sunrealtype* hnew) +{ + SUNFunctionBegin(C->sunctx); + SUNAssert(Hnew, SUN_ERR_ARG_CORRUPT); + SUNAssert(hnew, SUN_ERR_ARG_CORRUPT); + + /* set usable time-step adaptivity parameters */ + const int p = MRIPID_PFAST(C); + const sunrealtype k11 = MRIPID_K11(C); + const sunrealtype k12 = MRIPID_K12(C); + const sunrealtype k13 = MRIPID_K13(C); + const sunrealtype k21 = MRIPID_K21(C); + const sunrealtype k22 = MRIPID_K22(C); + const sunrealtype k23 = MRIPID_K23(C); + const sunrealtype a1 = (k11 + k12 + k13) / (3 * P); + const sunrealtype a2 = -(k11 + k12) / (3 * P); + const sunrealtype a3 = k11 / (3 * P); + const sunrealtype b11 = (p + 1) * (k11 + k12 + k13) / (3 * P * p); + const sunrealtype b12 = -(p + 1) * (k11 + k12) / (3 * P * p); + const sunrealtype b13 = (p + 1) * k11 / (3 * P * p); + const sunrealtype b21 = -(k21 + k22 + k23) / (3 * p); + const sunrealtype b22 = (k21 + k22) / (3 * p); + const sunrealtype b23 = -k21 / (3 * p); + const sunrealtype es1 = ONE / SUNMAX(MRIPID_BIAS(C) * DSM, TINY); + const sunrealtype es2 = ONE / MRIPID_ESP(C); + const sunrealtype es3 = ONE / MRIPID_ESPP(C); + const sunrealtype ef1 = ONE / SUNMAX(MRIPID_BIAS(C) * dsm, TINY); + const sunrealtype ef2 = ONE / MRIPID_EFP(C); + const sunrealtype ef3 = ONE / MRIPID_EFPP(C); + const sunrealtype M = SUNRceil(H / h); + + /* compute estimated optimal time step size */ + *Hnew = H * SUNRpowerR(es1, a1) * SUNRpowerR(es2, a2) * SUNRpowerR(es3, a3); + const sunrealtype Mnew = M * SUNRpowerR(es1, b11) * SUNRpowerR(es2, b12) * + SUNRpowerR(es3, b13) * SUNRpowerR(ef1, b21) * + SUNRpowerR(ef2, b22) * SUNRpowerR(ef3, b23); + *hnew = (*Hnew) / Mnew; + + /* return with success */ + return SUN_SUCCESS; +} + +SUNErrCode SUNAdaptController_Reset_MRIPID(SUNAdaptController C) +{ + SUNFunctionBegin(C->sunctx); + MRIPID_ESP(C) = SUN_RCONST(1.0); + MRIPID_EFP(C) = SUN_RCONST(1.0); + MRIPID_ESPP(C) = SUN_RCONST(1.0); + MRIPID_EFPP(C) = SUN_RCONST(1.0); + return SUN_SUCCESS; +} + +SUNErrCode SUNAdaptController_SetDefaults_MRIPID(SUNAdaptController C) +{ + SUNFunctionBegin(C->sunctx); + MRIPID_K11(C) = DEFAULT_K11; + MRIPID_K12(C) = DEFAULT_K12; + MRIPID_K13(C) = DEFAULT_K13; + MRIPID_K21(C) = DEFAULT_K21; + MRIPID_K22(C) = DEFAULT_K22; + MRIPID_K23(C) = DEFAULT_K23; + MRIPID_BIAS(C) = DEFAULT_BIAS; + return SUN_SUCCESS; +} + +SUNErrCode SUNAdaptController_Write_MRIPID(SUNAdaptController C, FILE* fptr) +{ + SUNFunctionBegin(C->sunctx); + SUNAssert(fptr, SUN_ERR_ARG_CORRUPT); + fprintf(fptr, "Multirate PID SUNAdaptController module:\n"); +#if defined(SUNDIALS_EXTENDED_PRECISION) + fprintf(fptr, " k11 = %32Lg\n", MRIPID_K11(C)); + fprintf(fptr, " k12 = %32Lg\n", MRIPID_K12(C)); + fprintf(fptr, " k13 = %32Lg\n", MRIPID_K13(C)); + fprintf(fptr, " k21 = %32Lg\n", MRIPID_K21(C)); + fprintf(fptr, " k22 = %32Lg\n", MRIPID_K22(C)); + fprintf(fptr, " k23 = %32Lg\n", MRIPID_K23(C)); + fprintf(fptr, " bias factor = %32Lg\n", MRIPID_BIAS(C)); + fprintf(fptr, " previous slow errors = %32Lg %32Lg\n", MRIPID_ESP(C), + MRIPID_ESPP(C)); + fprintf(fptr, " previous fast errors = %32Lg %32Lg\n", MRIPID_EFP(C), + MRIPID_EFPP(C)); +#else + fprintf(fptr, " k11 = %16g\n", MRIPID_K11(C)); + fprintf(fptr, " k12 = %16g\n", MRIPID_K12(C)); + fprintf(fptr, " k13 = %16g\n", MRIPID_K13(C)); + fprintf(fptr, " k21 = %16g\n", MRIPID_K21(C)); + fprintf(fptr, " k22 = %16g\n", MRIPID_K22(C)); + fprintf(fptr, " k23 = %16g\n", MRIPID_K23(C)); + fprintf(fptr, " bias factor = %16g\n", MRIPID_BIAS(C)); + fprintf(fptr, " previous slow errors = %16g %16g\n", MRIPID_ESP(C), + MRIPID_ESPP(C)); + fprintf(fptr, " previous fast errors = %16g %16g\n", MRIPID_EFP(C), + MRIPID_EFPP(C)); +#endif + fprintf(fptr, " p = %i (fast method order)\n", MRIPID_PFAST(C)); + return SUN_SUCCESS; +} + +SUNErrCode SUNAdaptController_SetErrorBias_MRIPID(SUNAdaptController C, + sunrealtype bias) +{ + SUNFunctionBegin(C->sunctx); + + /* set allowed value, otherwise set default */ + if (bias <= SUN_RCONST(0.0)) { MRIPID_BIAS(C) = DEFAULT_BIAS; } + else { MRIPID_BIAS(C) = bias; } + + return SUN_SUCCESS; +} + +SUNErrCode SUNAdaptController_UpdateMRIH_MRIPID(SUNAdaptController C, + sunrealtype H, sunrealtype h, + sunrealtype DSM, sunrealtype dsm) +{ + SUNFunctionBegin(C->sunctx); + MRIPID_ESPP(C) = MRIPID_ESP(C); + MRIPID_EFPP(C) = MRIPID_EFP(C); + MRIPID_ESP(C) = SUNMAX(MRIPID_BIAS(C) * DSM, TINY); + MRIPID_EFP(C) = SUNMAX(MRIPID_BIAS(C) * dsm, TINY); + return SUN_SUCCESS; +} + +SUNErrCode SUNAdaptController_Space_MRIPID(SUNAdaptController C, + long int* lenrw, long int* leniw) +{ + SUNFunctionBegin(C->sunctx); + SUNAssert(lenrw, SUN_ERR_ARG_CORRUPT); + SUNAssert(leniw, SUN_ERR_ARG_CORRUPT); + *lenrw = 11; + *leniw = 1; + return SUN_SUCCESS; +} diff --git a/src/sundials/fmod_int32/fsundials_core_mod.c b/src/sundials/fmod_int32/fsundials_core_mod.c index 62e0215249..4f23389767 100644 --- a/src/sundials/fmod_int32/fsundials_core_mod.c +++ b/src/sundials/fmod_int32/fsundials_core_mod.c @@ -2557,6 +2557,58 @@ SWIGEXPORT int _wrap_FSUNAdaptController_EstimateStep(SUNAdaptController farg1, } +SWIGEXPORT int _wrap_FSUNAdaptController_EstimateMRISteps(SUNAdaptController farg1, double const *farg2, double const *farg3, int const *farg4, double const *farg5, double const *farg6, double *farg7, double *farg8) { + int fresult ; + SUNAdaptController arg1 = (SUNAdaptController) 0 ; + sunrealtype arg2 ; + sunrealtype arg3 ; + int arg4 ; + sunrealtype arg5 ; + sunrealtype arg6 ; + sunrealtype *arg7 = (sunrealtype *) 0 ; + sunrealtype *arg8 = (sunrealtype *) 0 ; + SUNErrCode result; + + arg1 = (SUNAdaptController)(farg1); + arg2 = (sunrealtype)(*farg2); + arg3 = (sunrealtype)(*farg3); + arg4 = (int)(*farg4); + arg5 = (sunrealtype)(*farg5); + arg6 = (sunrealtype)(*farg6); + arg7 = (sunrealtype *)(farg7); + arg8 = (sunrealtype *)(farg8); + result = (SUNErrCode)SUNAdaptController_EstimateMRISteps(arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8); + fresult = (SUNErrCode)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FSUNAdaptController_EstimateStepTol(SUNAdaptController farg1, double const *farg2, double const *farg3, int const *farg4, double const *farg5, double const *farg6, double *farg7, double *farg8) { + int fresult ; + SUNAdaptController arg1 = (SUNAdaptController) 0 ; + sunrealtype arg2 ; + sunrealtype arg3 ; + int arg4 ; + sunrealtype arg5 ; + sunrealtype arg6 ; + sunrealtype *arg7 = (sunrealtype *) 0 ; + sunrealtype *arg8 = (sunrealtype *) 0 ; + SUNErrCode result; + + arg1 = (SUNAdaptController)(farg1); + arg2 = (sunrealtype)(*farg2); + arg3 = (sunrealtype)(*farg3); + arg4 = (int)(*farg4); + arg5 = (sunrealtype)(*farg5); + arg6 = (sunrealtype)(*farg6); + arg7 = (sunrealtype *)(farg7); + arg8 = (sunrealtype *)(farg8); + result = (SUNErrCode)SUNAdaptController_EstimateStepTol(arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8); + fresult = (SUNErrCode)(result); + return fresult; +} + + SWIGEXPORT int _wrap_FSUNAdaptController_Reset(SUNAdaptController farg1) { int fresult ; SUNAdaptController arg1 = (SUNAdaptController) 0 ; @@ -2625,6 +2677,46 @@ SWIGEXPORT int _wrap_FSUNAdaptController_UpdateH(SUNAdaptController farg1, doubl } +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 ; + SUNErrCode result; + + arg1 = (SUNAdaptController)(farg1); + arg2 = (sunrealtype)(*farg2); + arg3 = (sunrealtype)(*farg3); + arg4 = (sunrealtype)(*farg4); + arg5 = (sunrealtype)(*farg5); + result = (SUNErrCode)SUNAdaptController_UpdateMRIH(arg1,arg2,arg3,arg4,arg5); + fresult = (SUNErrCode)(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 ; + SUNErrCode result; + + arg1 = (SUNAdaptController)(farg1); + arg2 = (sunrealtype)(*farg2); + arg3 = (sunrealtype)(*farg3); + arg4 = (sunrealtype)(*farg4); + arg5 = (sunrealtype)(*farg5); + result = (SUNErrCode)SUNAdaptController_UpdateMRITol(arg1,arg2,arg3,arg4,arg5); + fresult = (SUNErrCode)(result); + return fresult; +} + + SWIGEXPORT int _wrap_FSUNAdaptController_Space(SUNAdaptController farg1, long *farg2, long *farg3) { int fresult ; SUNAdaptController arg1 = (SUNAdaptController) 0 ; diff --git a/src/sundials/fmod_int32/fsundials_core_mod.f90 b/src/sundials/fmod_int32/fsundials_core_mod.f90 index 2bda4cb0fe..ac96636766 100644 --- a/src/sundials/fmod_int32/fsundials_core_mod.f90 +++ b/src/sundials/fmod_int32/fsundials_core_mod.f90 @@ -511,19 +511,25 @@ module fsundials_core_mod enum, bind(c) enumerator :: SUN_ADAPTCONTROLLER_NONE enumerator :: SUN_ADAPTCONTROLLER_H + 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 + public :: SUN_ADAPTCONTROLLER_NONE, SUN_ADAPTCONTROLLER_H, 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 :: estimatemristeps + type(C_FUNPTR), public :: estimatesteptol type(C_FUNPTR), public :: destroy type(C_FUNPTR), public :: reset type(C_FUNPTR), public :: setdefaults type(C_FUNPTR), public :: write type(C_FUNPTR), public :: seterrorbias type(C_FUNPTR), public :: updateh + type(C_FUNPTR), public :: updatemrih + type(C_FUNPTR), public :: updatemritol type(C_FUNPTR), public :: space end type SUNAdaptController_Ops ! struct struct _generic_SUNAdaptController @@ -537,11 +543,15 @@ module fsundials_core_mod public :: FSUNAdaptController_GetType public :: FSUNAdaptController_Destroy public :: FSUNAdaptController_EstimateStep + public :: FSUNAdaptController_EstimateMRISteps + public :: FSUNAdaptController_EstimateStepTol public :: FSUNAdaptController_Reset public :: FSUNAdaptController_SetDefaults public :: FSUNAdaptController_Write public :: FSUNAdaptController_SetErrorBias public :: FSUNAdaptController_UpdateH + public :: FSUNAdaptController_UpdateMRIH + public :: FSUNAdaptController_UpdateMRITol public :: FSUNAdaptController_Space ! WRAPPER DECLARATIONS @@ -1987,6 +1997,36 @@ function swigc_FSUNAdaptController_EstimateStep(farg1, farg2, farg3, farg4, farg integer(C_INT) :: fresult end function +function swigc_FSUNAdaptController_EstimateMRISteps(farg1, farg2, farg3, farg4, farg5, farg6, farg7, farg8) & +bind(C, name="_wrap_FSUNAdaptController_EstimateMRISteps") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +type(C_PTR), value :: farg1 +real(C_DOUBLE), intent(in) :: farg2 +real(C_DOUBLE), intent(in) :: farg3 +integer(C_INT), intent(in) :: farg4 +real(C_DOUBLE), intent(in) :: farg5 +real(C_DOUBLE), intent(in) :: farg6 +type(C_PTR), value :: farg7 +type(C_PTR), value :: farg8 +integer(C_INT) :: fresult +end function + +function swigc_FSUNAdaptController_EstimateStepTol(farg1, farg2, farg3, farg4, farg5, farg6, farg7, farg8) & +bind(C, name="_wrap_FSUNAdaptController_EstimateStepTol") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +type(C_PTR), value :: farg1 +real(C_DOUBLE), intent(in) :: farg2 +real(C_DOUBLE), intent(in) :: farg3 +integer(C_INT), intent(in) :: farg4 +real(C_DOUBLE), intent(in) :: farg5 +real(C_DOUBLE), intent(in) :: farg6 +type(C_PTR), value :: farg7 +type(C_PTR), value :: farg8 +integer(C_INT) :: fresult +end function + function swigc_FSUNAdaptController_Reset(farg1) & bind(C, name="_wrap_FSUNAdaptController_Reset") & result(fresult) @@ -2031,6 +2071,30 @@ function swigc_FSUNAdaptController_UpdateH(farg1, farg2, farg3) & integer(C_INT) :: fresult end function +function swigc_FSUNAdaptController_UpdateMRIH(farg1, farg2, farg3, farg4, farg5) & +bind(C, name="_wrap_FSUNAdaptController_UpdateMRIH") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +type(C_PTR), value :: farg1 +real(C_DOUBLE), intent(in) :: farg2 +real(C_DOUBLE), intent(in) :: farg3 +real(C_DOUBLE), intent(in) :: farg4 +real(C_DOUBLE), intent(in) :: farg5 +integer(C_INT) :: fresult +end function + +function swigc_FSUNAdaptController_UpdateMRITol(farg1, farg2, farg3, farg4, farg5) & +bind(C, name="_wrap_FSUNAdaptController_UpdateMRITol") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +type(C_PTR), value :: farg1 +real(C_DOUBLE), intent(in) :: farg2 +real(C_DOUBLE), intent(in) :: farg3 +real(C_DOUBLE), intent(in) :: farg4 +real(C_DOUBLE), intent(in) :: farg5 +integer(C_INT) :: fresult +end function + function swigc_FSUNAdaptController_Space(farg1, farg2, farg3) & bind(C, name="_wrap_FSUNAdaptController_Space") & result(fresult) @@ -4686,6 +4750,74 @@ function FSUNAdaptController_EstimateStep(c, h, p, dsm, hnew) & swig_result = fresult end function +function FSUNAdaptController_EstimateMRISteps(c, h, h2, p, dsm, dsm5, hnew, hnew7) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(SUNAdaptController), target, intent(inout) :: c +real(C_DOUBLE), intent(in) :: h +real(C_DOUBLE), intent(in) :: h2 +integer(C_INT), intent(in) :: p +real(C_DOUBLE), intent(in) :: dsm +real(C_DOUBLE), intent(in) :: dsm5 +real(C_DOUBLE), dimension(*), target, intent(inout) :: hnew +real(C_DOUBLE), dimension(*), target, intent(inout) :: hnew7 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +real(C_DOUBLE) :: farg2 +real(C_DOUBLE) :: farg3 +integer(C_INT) :: farg4 +real(C_DOUBLE) :: farg5 +real(C_DOUBLE) :: farg6 +type(C_PTR) :: farg7 +type(C_PTR) :: farg8 + +farg1 = c_loc(c) +farg2 = h +farg3 = h2 +farg4 = p +farg5 = dsm +farg6 = dsm5 +farg7 = c_loc(hnew(1)) +farg8 = c_loc(hnew7(1)) +fresult = swigc_FSUNAdaptController_EstimateMRISteps(farg1, farg2, farg3, farg4, farg5, farg6, farg7, farg8) +swig_result = fresult +end function + +function FSUNAdaptController_EstimateStepTol(c, h, tolfac, p, dsm, dsm5, hnew, tolfacnew) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(SUNAdaptController), target, intent(inout) :: c +real(C_DOUBLE), intent(in) :: h +real(C_DOUBLE), intent(in) :: tolfac +integer(C_INT), intent(in) :: p +real(C_DOUBLE), intent(in) :: dsm +real(C_DOUBLE), intent(in) :: dsm5 +real(C_DOUBLE), dimension(*), target, intent(inout) :: hnew +real(C_DOUBLE), dimension(*), target, intent(inout) :: tolfacnew +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +real(C_DOUBLE) :: farg2 +real(C_DOUBLE) :: farg3 +integer(C_INT) :: farg4 +real(C_DOUBLE) :: farg5 +real(C_DOUBLE) :: farg6 +type(C_PTR) :: farg7 +type(C_PTR) :: farg8 + +farg1 = c_loc(c) +farg2 = h +farg3 = tolfac +farg4 = p +farg5 = dsm +farg6 = dsm5 +farg7 = c_loc(hnew(1)) +farg8 = c_loc(tolfacnew(1)) +fresult = swigc_FSUNAdaptController_EstimateStepTol(farg1, farg2, farg3, farg4, farg5, farg6, farg7, farg8) +swig_result = fresult +end function + function FSUNAdaptController_Reset(c) & result(swig_result) use, intrinsic :: ISO_C_BINDING @@ -4763,6 +4895,56 @@ function FSUNAdaptController_UpdateH(c, h, dsm) & 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 diff --git a/src/sundials/fmod_int64/fsundials_core_mod.c b/src/sundials/fmod_int64/fsundials_core_mod.c index 2478b92d68..dd19d1aea7 100644 --- a/src/sundials/fmod_int64/fsundials_core_mod.c +++ b/src/sundials/fmod_int64/fsundials_core_mod.c @@ -2557,6 +2557,58 @@ SWIGEXPORT int _wrap_FSUNAdaptController_EstimateStep(SUNAdaptController farg1, } +SWIGEXPORT int _wrap_FSUNAdaptController_EstimateMRISteps(SUNAdaptController farg1, double const *farg2, double const *farg3, int const *farg4, double const *farg5, double const *farg6, double *farg7, double *farg8) { + int fresult ; + SUNAdaptController arg1 = (SUNAdaptController) 0 ; + sunrealtype arg2 ; + sunrealtype arg3 ; + int arg4 ; + sunrealtype arg5 ; + sunrealtype arg6 ; + sunrealtype *arg7 = (sunrealtype *) 0 ; + sunrealtype *arg8 = (sunrealtype *) 0 ; + SUNErrCode result; + + arg1 = (SUNAdaptController)(farg1); + arg2 = (sunrealtype)(*farg2); + arg3 = (sunrealtype)(*farg3); + arg4 = (int)(*farg4); + arg5 = (sunrealtype)(*farg5); + arg6 = (sunrealtype)(*farg6); + arg7 = (sunrealtype *)(farg7); + arg8 = (sunrealtype *)(farg8); + result = (SUNErrCode)SUNAdaptController_EstimateMRISteps(arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8); + fresult = (SUNErrCode)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FSUNAdaptController_EstimateStepTol(SUNAdaptController farg1, double const *farg2, double const *farg3, int const *farg4, double const *farg5, double const *farg6, double *farg7, double *farg8) { + int fresult ; + SUNAdaptController arg1 = (SUNAdaptController) 0 ; + sunrealtype arg2 ; + sunrealtype arg3 ; + int arg4 ; + sunrealtype arg5 ; + sunrealtype arg6 ; + sunrealtype *arg7 = (sunrealtype *) 0 ; + sunrealtype *arg8 = (sunrealtype *) 0 ; + SUNErrCode result; + + arg1 = (SUNAdaptController)(farg1); + arg2 = (sunrealtype)(*farg2); + arg3 = (sunrealtype)(*farg3); + arg4 = (int)(*farg4); + arg5 = (sunrealtype)(*farg5); + arg6 = (sunrealtype)(*farg6); + arg7 = (sunrealtype *)(farg7); + arg8 = (sunrealtype *)(farg8); + result = (SUNErrCode)SUNAdaptController_EstimateStepTol(arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8); + fresult = (SUNErrCode)(result); + return fresult; +} + + SWIGEXPORT int _wrap_FSUNAdaptController_Reset(SUNAdaptController farg1) { int fresult ; SUNAdaptController arg1 = (SUNAdaptController) 0 ; @@ -2625,6 +2677,46 @@ SWIGEXPORT int _wrap_FSUNAdaptController_UpdateH(SUNAdaptController farg1, doubl } +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 ; + SUNErrCode result; + + arg1 = (SUNAdaptController)(farg1); + arg2 = (sunrealtype)(*farg2); + arg3 = (sunrealtype)(*farg3); + arg4 = (sunrealtype)(*farg4); + arg5 = (sunrealtype)(*farg5); + result = (SUNErrCode)SUNAdaptController_UpdateMRIH(arg1,arg2,arg3,arg4,arg5); + fresult = (SUNErrCode)(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 ; + SUNErrCode result; + + arg1 = (SUNAdaptController)(farg1); + arg2 = (sunrealtype)(*farg2); + arg3 = (sunrealtype)(*farg3); + arg4 = (sunrealtype)(*farg4); + arg5 = (sunrealtype)(*farg5); + result = (SUNErrCode)SUNAdaptController_UpdateMRITol(arg1,arg2,arg3,arg4,arg5); + fresult = (SUNErrCode)(result); + return fresult; +} + + SWIGEXPORT int _wrap_FSUNAdaptController_Space(SUNAdaptController farg1, long *farg2, long *farg3) { int fresult ; SUNAdaptController arg1 = (SUNAdaptController) 0 ; diff --git a/src/sundials/fmod_int64/fsundials_core_mod.f90 b/src/sundials/fmod_int64/fsundials_core_mod.f90 index 7096d0c6ce..632cda7d30 100644 --- a/src/sundials/fmod_int64/fsundials_core_mod.f90 +++ b/src/sundials/fmod_int64/fsundials_core_mod.f90 @@ -511,19 +511,25 @@ module fsundials_core_mod enum, bind(c) enumerator :: SUN_ADAPTCONTROLLER_NONE enumerator :: SUN_ADAPTCONTROLLER_H + 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 + public :: SUN_ADAPTCONTROLLER_NONE, SUN_ADAPTCONTROLLER_H, 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 :: estimatemristeps + type(C_FUNPTR), public :: estimatesteptol type(C_FUNPTR), public :: destroy type(C_FUNPTR), public :: reset type(C_FUNPTR), public :: setdefaults type(C_FUNPTR), public :: write type(C_FUNPTR), public :: seterrorbias type(C_FUNPTR), public :: updateh + type(C_FUNPTR), public :: updatemrih + type(C_FUNPTR), public :: updatemritol type(C_FUNPTR), public :: space end type SUNAdaptController_Ops ! struct struct _generic_SUNAdaptController @@ -537,11 +543,15 @@ module fsundials_core_mod public :: FSUNAdaptController_GetType public :: FSUNAdaptController_Destroy public :: FSUNAdaptController_EstimateStep + public :: FSUNAdaptController_EstimateMRISteps + public :: FSUNAdaptController_EstimateStepTol public :: FSUNAdaptController_Reset public :: FSUNAdaptController_SetDefaults public :: FSUNAdaptController_Write public :: FSUNAdaptController_SetErrorBias public :: FSUNAdaptController_UpdateH + public :: FSUNAdaptController_UpdateMRIH + public :: FSUNAdaptController_UpdateMRITol public :: FSUNAdaptController_Space ! WRAPPER DECLARATIONS @@ -1987,6 +1997,36 @@ function swigc_FSUNAdaptController_EstimateStep(farg1, farg2, farg3, farg4, farg integer(C_INT) :: fresult end function +function swigc_FSUNAdaptController_EstimateMRISteps(farg1, farg2, farg3, farg4, farg5, farg6, farg7, farg8) & +bind(C, name="_wrap_FSUNAdaptController_EstimateMRISteps") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +type(C_PTR), value :: farg1 +real(C_DOUBLE), intent(in) :: farg2 +real(C_DOUBLE), intent(in) :: farg3 +integer(C_INT), intent(in) :: farg4 +real(C_DOUBLE), intent(in) :: farg5 +real(C_DOUBLE), intent(in) :: farg6 +type(C_PTR), value :: farg7 +type(C_PTR), value :: farg8 +integer(C_INT) :: fresult +end function + +function swigc_FSUNAdaptController_EstimateStepTol(farg1, farg2, farg3, farg4, farg5, farg6, farg7, farg8) & +bind(C, name="_wrap_FSUNAdaptController_EstimateStepTol") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +type(C_PTR), value :: farg1 +real(C_DOUBLE), intent(in) :: farg2 +real(C_DOUBLE), intent(in) :: farg3 +integer(C_INT), intent(in) :: farg4 +real(C_DOUBLE), intent(in) :: farg5 +real(C_DOUBLE), intent(in) :: farg6 +type(C_PTR), value :: farg7 +type(C_PTR), value :: farg8 +integer(C_INT) :: fresult +end function + function swigc_FSUNAdaptController_Reset(farg1) & bind(C, name="_wrap_FSUNAdaptController_Reset") & result(fresult) @@ -2031,6 +2071,30 @@ function swigc_FSUNAdaptController_UpdateH(farg1, farg2, farg3) & integer(C_INT) :: fresult end function +function swigc_FSUNAdaptController_UpdateMRIH(farg1, farg2, farg3, farg4, farg5) & +bind(C, name="_wrap_FSUNAdaptController_UpdateMRIH") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +type(C_PTR), value :: farg1 +real(C_DOUBLE), intent(in) :: farg2 +real(C_DOUBLE), intent(in) :: farg3 +real(C_DOUBLE), intent(in) :: farg4 +real(C_DOUBLE), intent(in) :: farg5 +integer(C_INT) :: fresult +end function + +function swigc_FSUNAdaptController_UpdateMRITol(farg1, farg2, farg3, farg4, farg5) & +bind(C, name="_wrap_FSUNAdaptController_UpdateMRITol") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +type(C_PTR), value :: farg1 +real(C_DOUBLE), intent(in) :: farg2 +real(C_DOUBLE), intent(in) :: farg3 +real(C_DOUBLE), intent(in) :: farg4 +real(C_DOUBLE), intent(in) :: farg5 +integer(C_INT) :: fresult +end function + function swigc_FSUNAdaptController_Space(farg1, farg2, farg3) & bind(C, name="_wrap_FSUNAdaptController_Space") & result(fresult) @@ -4686,6 +4750,74 @@ function FSUNAdaptController_EstimateStep(c, h, p, dsm, hnew) & swig_result = fresult end function +function FSUNAdaptController_EstimateMRISteps(c, h, h2, p, dsm, dsm5, hnew, hnew7) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(SUNAdaptController), target, intent(inout) :: c +real(C_DOUBLE), intent(in) :: h +real(C_DOUBLE), intent(in) :: h2 +integer(C_INT), intent(in) :: p +real(C_DOUBLE), intent(in) :: dsm +real(C_DOUBLE), intent(in) :: dsm5 +real(C_DOUBLE), dimension(*), target, intent(inout) :: hnew +real(C_DOUBLE), dimension(*), target, intent(inout) :: hnew7 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +real(C_DOUBLE) :: farg2 +real(C_DOUBLE) :: farg3 +integer(C_INT) :: farg4 +real(C_DOUBLE) :: farg5 +real(C_DOUBLE) :: farg6 +type(C_PTR) :: farg7 +type(C_PTR) :: farg8 + +farg1 = c_loc(c) +farg2 = h +farg3 = h2 +farg4 = p +farg5 = dsm +farg6 = dsm5 +farg7 = c_loc(hnew(1)) +farg8 = c_loc(hnew7(1)) +fresult = swigc_FSUNAdaptController_EstimateMRISteps(farg1, farg2, farg3, farg4, farg5, farg6, farg7, farg8) +swig_result = fresult +end function + +function FSUNAdaptController_EstimateStepTol(c, h, tolfac, p, dsm, dsm5, hnew, tolfacnew) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(SUNAdaptController), target, intent(inout) :: c +real(C_DOUBLE), intent(in) :: h +real(C_DOUBLE), intent(in) :: tolfac +integer(C_INT), intent(in) :: p +real(C_DOUBLE), intent(in) :: dsm +real(C_DOUBLE), intent(in) :: dsm5 +real(C_DOUBLE), dimension(*), target, intent(inout) :: hnew +real(C_DOUBLE), dimension(*), target, intent(inout) :: tolfacnew +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +real(C_DOUBLE) :: farg2 +real(C_DOUBLE) :: farg3 +integer(C_INT) :: farg4 +real(C_DOUBLE) :: farg5 +real(C_DOUBLE) :: farg6 +type(C_PTR) :: farg7 +type(C_PTR) :: farg8 + +farg1 = c_loc(c) +farg2 = h +farg3 = tolfac +farg4 = p +farg5 = dsm +farg6 = dsm5 +farg7 = c_loc(hnew(1)) +farg8 = c_loc(tolfacnew(1)) +fresult = swigc_FSUNAdaptController_EstimateStepTol(farg1, farg2, farg3, farg4, farg5, farg6, farg7, farg8) +swig_result = fresult +end function + function FSUNAdaptController_Reset(c) & result(swig_result) use, intrinsic :: ISO_C_BINDING @@ -4763,6 +4895,56 @@ function FSUNAdaptController_UpdateH(c, h, dsm) & 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 diff --git a/src/sundials/sundials_adaptcontroller.c b/src/sundials/sundials_adaptcontroller.c index 39a56480d0..033890e269 100644 --- a/src/sundials/sundials_adaptcontroller.c +++ b/src/sundials/sundials_adaptcontroller.c @@ -46,15 +46,19 @@ SUNAdaptController SUNAdaptController_NewEmpty(SUNContext sunctx) SUNAssertNull(ops, SUN_ERR_MALLOC_FAIL); /* initialize operations to NULL */ - ops->gettype = NULL; - ops->destroy = NULL; - ops->reset = NULL; - ops->estimatestep = NULL; - ops->setdefaults = NULL; - ops->write = NULL; - ops->seterrorbias = NULL; - ops->updateh = NULL; - ops->space = NULL; + ops->gettype = NULL; + ops->destroy = NULL; + ops->reset = NULL; + ops->estimatestep = NULL; + ops->estimatemristeps = NULL; + ops->estimatesteptol = NULL; + ops->setdefaults = NULL; + ops->write = NULL; + ops->seterrorbias = NULL; + ops->updateh = NULL; + ops->updatemrih = NULL; + ops->updatemritol = NULL; + ops->space = NULL; /* attach ops and initialize content to NULL */ C->ops = ops; @@ -137,6 +141,46 @@ SUNErrCode SUNAdaptController_EstimateStep(SUNAdaptController C, sunrealtype h, return (ier); } +SUNErrCode SUNAdaptController_EstimateMRISteps(SUNAdaptController C, + sunrealtype H, sunrealtype h, + int P, sunrealtype DSM, + sunrealtype dsm, sunrealtype* Hnew, + sunrealtype* hnew) +{ + SUNErrCode ier = SUN_SUCCESS; + if (C == NULL) { return SUN_ERR_ARG_CORRUPT; } + SUNFunctionBegin(C->sunctx); + SUNAssert(Hnew, SUN_ERR_ARG_CORRUPT); + SUNAssert(hnew, SUN_ERR_ARG_CORRUPT); + *Hnew = H; /* initialize outputs with identity */ + *hnew = h; + if (C->ops->estimatemristeps) + { + ier = C->ops->estimatemristeps(C, H, h, P, DSM, dsm, Hnew, hnew); + } + return (ier); +} + +SUNErrCode SUNAdaptController_EstimateStepTol(SUNAdaptController C, + sunrealtype H, sunrealtype tolfac, + int P, sunrealtype DSM, + sunrealtype dsm, sunrealtype* Hnew, + sunrealtype* tolfacnew) +{ + SUNErrCode ier = SUN_SUCCESS; + if (C == NULL) { return SUN_ERR_ARG_CORRUPT; } + SUNFunctionBegin(C->sunctx); + SUNAssert(Hnew, SUN_ERR_ARG_CORRUPT); + SUNAssert(tolfacnew, SUN_ERR_ARG_CORRUPT); + *Hnew = H; /* initialize outputs with identity */ + *tolfacnew = tolfac; + if (C->ops->estimatesteptol) + { + ier = C->ops->estimatesteptol(C, H, tolfac, P, DSM, dsm, Hnew, tolfacnew); + } + return (ier); +} + SUNErrCode SUNAdaptController_Reset(SUNAdaptController C) { SUNErrCode ier = SUN_SUCCESS; @@ -184,6 +228,31 @@ SUNErrCode SUNAdaptController_UpdateH(SUNAdaptController C, sunrealtype h, return (ier); } +SUNErrCode SUNAdaptController_UpdateMRIH(SUNAdaptController C, sunrealtype H, + sunrealtype h, sunrealtype DSM, + sunrealtype dsm) +{ + SUNErrCode ier = SUN_SUCCESS; + if (C == NULL) { return SUN_ERR_ARG_CORRUPT; } + SUNFunctionBegin(C->sunctx); + if (C->ops->updatemrih) { ier = C->ops->updatemrih(C, H, h, DSM, dsm); } + return (ier); +} + +SUNErrCode SUNAdaptController_UpdateMRITol(SUNAdaptController C, sunrealtype H, + sunrealtype tolfac, sunrealtype DSM, + sunrealtype dsm) +{ + SUNErrCode ier = SUN_SUCCESS; + if (C == NULL) { return SUN_ERR_ARG_CORRUPT; } + SUNFunctionBegin(C->sunctx); + if (C->ops->updatemritol) + { + ier = C->ops->updatemritol(C, H, tolfac, DSM, dsm); + } + return (ier); +} + SUNErrCode SUNAdaptController_Space(SUNAdaptController C, long int* lenrw, long int* leniw) { diff --git a/swig/sunadaptcontroller/fsunadaptcontroller_mricc_mod.i b/swig/sunadaptcontroller/fsunadaptcontroller_mricc_mod.i new file mode 100644 index 0000000000..c8bccf6abb --- /dev/null +++ b/swig/sunadaptcontroller/fsunadaptcontroller_mricc_mod.i @@ -0,0 +1,29 @@ +// --------------------------------------------------------------- +// Programmer: Daniel R. Reynolds @ SMU +// --------------------------------------------------------------- +// SUNDIALS Copyright Start +// Copyright (c) 2002-2024, 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_mricc_mod + +// include code common to all implementations +%include "fsunadaptcontroller.i" + +%{ +#include "sunadaptcontroller/sunadaptcontroller_mricc.h" +%} + +%sunadaptcontroller_impl(MRICC) + +// Process and wrap functions in the following files +%include "sunadaptcontroller/sunadaptcontroller_mricc.h" diff --git a/swig/sunadaptcontroller/fsunadaptcontroller_mrihtol_mod.i b/swig/sunadaptcontroller/fsunadaptcontroller_mrihtol_mod.i new file mode 100644 index 0000000000..feb54e4bf1 --- /dev/null +++ b/swig/sunadaptcontroller/fsunadaptcontroller_mrihtol_mod.i @@ -0,0 +1,29 @@ +// --------------------------------------------------------------- +// Programmer: Daniel R. Reynolds @ SMU +// --------------------------------------------------------------- +// SUNDIALS Copyright Start +// Copyright (c) 2002-2024, 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_mrihtol_mod + +// include code common to all implementations +%include "fsunadaptcontroller.i" + +%{ +#include "sunadaptcontroller/sunadaptcontroller_mrihtol.h" +%} + +%sunadaptcontroller_impl(MRIHTol) + +// Process and wrap functions in the following files +%include "sunadaptcontroller/sunadaptcontroller_mrihtol.h" diff --git a/swig/sunadaptcontroller/fsunadaptcontroller_mrill_mod.i b/swig/sunadaptcontroller/fsunadaptcontroller_mrill_mod.i new file mode 100644 index 0000000000..7ad44195c9 --- /dev/null +++ b/swig/sunadaptcontroller/fsunadaptcontroller_mrill_mod.i @@ -0,0 +1,29 @@ +// --------------------------------------------------------------- +// Programmer: Daniel R. Reynolds @ SMU +// --------------------------------------------------------------- +// SUNDIALS Copyright Start +// Copyright (c) 2002-2024, 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_mrill_mod + +// include code common to all implementations +%include "fsunadaptcontroller.i" + +%{ +#include "sunadaptcontroller/sunadaptcontroller_mrill.h" +%} + +%sunadaptcontroller_impl(MRILL) + +// Process and wrap functions in the following files +%include "sunadaptcontroller/sunadaptcontroller_mrill.h" diff --git a/swig/sunadaptcontroller/fsunadaptcontroller_mripi_mod.i b/swig/sunadaptcontroller/fsunadaptcontroller_mripi_mod.i new file mode 100644 index 0000000000..a217037c0f --- /dev/null +++ b/swig/sunadaptcontroller/fsunadaptcontroller_mripi_mod.i @@ -0,0 +1,29 @@ +// --------------------------------------------------------------- +// Programmer: Daniel R. Reynolds @ SMU +// --------------------------------------------------------------- +// SUNDIALS Copyright Start +// Copyright (c) 2002-2024, 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_mripi_mod + +// include code common to all implementations +%include "fsunadaptcontroller.i" + +%{ +#include "sunadaptcontroller/sunadaptcontroller_mripi.h" +%} + +%sunadaptcontroller_impl(MRIPI) + +// Process and wrap functions in the following files +%include "sunadaptcontroller/sunadaptcontroller_mripi.h" diff --git a/swig/sunadaptcontroller/fsunadaptcontroller_mripid_mod.i b/swig/sunadaptcontroller/fsunadaptcontroller_mripid_mod.i new file mode 100644 index 0000000000..9ca30ca5f7 --- /dev/null +++ b/swig/sunadaptcontroller/fsunadaptcontroller_mripid_mod.i @@ -0,0 +1,29 @@ +// --------------------------------------------------------------- +// Programmer: Daniel R. Reynolds @ SMU +// --------------------------------------------------------------- +// SUNDIALS Copyright Start +// Copyright (c) 2002-2024, 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_mripid_mod + +// include code common to all implementations +%include "fsunadaptcontroller.i" + +%{ +#include "sunadaptcontroller/sunadaptcontroller_mripid.h" +%} + +%sunadaptcontroller_impl(MRIPID) + +// Process and wrap functions in the following files +%include "sunadaptcontroller/sunadaptcontroller_mripid.h" diff --git a/test/unit_tests/arkode/CXX_serial/CMakeLists.txt b/test/unit_tests/arkode/CXX_serial/CMakeLists.txt index c1f22fc6bc..56e8ec0ea1 100644 --- a/test/unit_tests/arkode/CXX_serial/CMakeLists.txt +++ b/test/unit_tests/arkode/CXX_serial/CMakeLists.txt @@ -16,6 +16,12 @@ # List of test tuples of the form "name\;args" set(unit_tests + "ark_test_accumerror_brusselator.cpp\;20 3 1" + "ark_test_accumerror_brusselator.cpp\;20 -4 0" + "ark_test_accumerror_brusselator.cpp\;20 5 0" + "ark_test_accumerror_kpr.cpp\;20 2 0" + "ark_test_accumerror_kpr.cpp\;20 3 1" + "ark_test_accumerror_kpr.cpp\;20 -4 1" "ark_test_analytic_sys_mri.cpp\;0" "ark_test_analytic_sys_mri.cpp\;1" "ark_test_dahlquist_ark.cpp\;0 -1 0" @@ -41,7 +47,12 @@ set(unit_tests "ark_test_dahlquist_mri.cpp\;1" "ark_test_butcher.cpp\;" "ark_test_getjac.cpp\;" - "ark_test_getjac_mri.cpp\;") + "ark_test_getjac_mri.cpp\;" + "ark_test_kpr_mriadapt.cpp\;--hs 0.002 --rtol 0.000004 --scontrol 0" + "ark_test_brusselator_mriadapt.cpp\;--rtol 0.000004 --scontrol 0" + "ark_test_slowerror_brusselator.cpp\;" + "ark_test_slowerror_kpr.cpp\;" + "ark_test_slowerror_polynomial.cpp\;") # Add the build and install targets for each test foreach(test_tuple ${unit_tests}) @@ -67,7 +78,8 @@ foreach(test_tuple ${unit_tests}) target_include_directories( ${test_target} PRIVATE $ - ${CMAKE_SOURCE_DIR}/include ${CMAKE_SOURCE_DIR}/src) + ${PROJECT_SOURCE_DIR}/test/unit_tests/utilities + ${CMAKE_SOURCE_DIR}/include ${CMAKE_SOURCE_DIR}/src) # We explicitly choose which object libraries to link to and link in the # arkode objects so that we have access to private functions w/o changing @@ -83,6 +95,11 @@ foreach(test_tuple ${unit_tests}) sundials_sunnonlinsolfixedpoint_obj sundials_sunadaptcontrollerimexgus_obj sundials_sunadaptcontrollersoderlind_obj + sundials_sunadaptcontrollermricc_obj + sundials_sunadaptcontrollermrill_obj + sundials_sunadaptcontrollermrihtol_obj + sundials_sunadaptcontrollermripi_obj + sundials_sunadaptcontrollermripid_obj ${EXE_EXTRA_LINK_LIBS}) # Tell CMake that we depend on the ARKODE library since it does not pick diff --git a/test/unit_tests/arkode/CXX_serial/ark_test_accumerror_brusselator.cpp b/test/unit_tests/arkode/CXX_serial/ark_test_accumerror_brusselator.cpp new file mode 100644 index 0000000000..c1fd11cf25 --- /dev/null +++ b/test/unit_tests/arkode/CXX_serial/ark_test_accumerror_brusselator.cpp @@ -0,0 +1,706 @@ +/*----------------------------------------------------------------- + * Programmer(s): Daniel R. Reynolds @ SMU + *--------------------------------------------------------------- + * SUNDIALS Copyright Start + * Copyright (c) 2002-2024, 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 + *--------------------------------------------------------------- + * Routine to test the accumulated temporal error estimation + * approaches from ARKStep. Uses the + * "stiff Brusselator" test problem with 3 components, + * du/dt = a - (w+1)*u + v*u^2 + * dv/dt = w*u - v*u^2 + * dw/dt = (b-w)/ep - w*u + * for t in the interval [0.0, 10.0], with initial conditions + * Y0 = [u0,v0,w0]. + * + * The stiffness of the problem is essentially determined + * by ep, wherein if the dynamical time step is given by H and + * the explicit time step size is given by h, then H/h = 1/(100 ep), + * i.e., the stability-limited step takes over at values of + * ep < 1e-2. This file defaults to a moderately stiff setup with + * ep = 1/2500. + * + * We may run the problem in one of 3 different testing scenarios: + * + * Test 1: u0=3.9, v0=1.1, w0=2.8, a=1.2, b=2.5 + * Here, all three components exhibit a rapid transient change + * during the first 0.2 time units, followed by a slow and + * smooth evolution. + * + * Test 2 [default]: u0=1.2, v0=3.1, w0=3, a=1, b=3.5 + * Here, w experiences a fast initial transient, jumping 0.5 + * within a few steps. All values proceed smoothly until + * around t=6.5, when both u and v undergo a sharp transition, + * with u increaseing from around 0.5 to 5 and v decreasing + * from around 6 to 1 in less than 0.5 time units. After this + * transition, both u and v continue to evolve somewhat + * rapidly for another 1.4 time units, and finish off smoothly. + * + * Test 3: u0=3, v0=3, w0=3.5, a=0.5, b=3 + * Here, all components undergo very rapid initial transients + * during the first 0.3 time units, and all then proceed very + * smoothly for the remainder of the simulation. + * + * We partition the full time integration interval, 0 < t < 5, into + * Npart pieces, and run the accumulation test over each. + * + * We use either the ARKStep/DIRK/Newton/Dense solver (0) or + * the ARKStep/ERK solver (1). Either defaults to using a + * 4th-order method. + * + * By default, all runs use temporal adaptivity; however, if the + * requested 'ord' command-line input is negative, we run with + * order |ord|, using fixed step sizes. + * + * The program should be run with arguments in the following order: + * $ a.out Npart ord method ep test + * Not all arguments are required, but these must be omitted from + * end-to-beginning, i.e. any one of + * $ a.out Npart ord method ep + * $ a.out Npart ord method + * $ a.out Npart ord + * $ a.out Npart + * $ a.out + * are acceptable. We require: + * * method = {0, 1} + * * test = {1, 2, 3} + * * ep > 0 + * * Npart > 0 + * + * For either temporally adaptive (ord >= 0) or fixed-step (ord < 0) + * runs, we test a variety of tolerances/step sizes, and compare + * the error at the end of each partition (computed via a reference + * solution) against the integrator-reported accumulated error + * estimate. + *-----------------------------------------------------------------*/ + +// Header files +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#if defined(SUNDIALS_EXTENDED_PRECISION) +#define GSYM "Lg" +#define ESYM "Le" +#define FSYM "Lf" +#else +#define GSYM "g" +#define ESYM "e" +#define FSYM "f" +#endif + +#define ZERO SUN_RCONST(0.0) +#define ONE SUN_RCONST(1.0) +#define TWO SUN_RCONST(2.0) + +using namespace std; + +// User data structure +struct UserData +{ + sunrealtype a; + sunrealtype b; + sunrealtype ep; + int Npart; +}; + +// User-supplied Functions Called by the Solver +static int fn(sunrealtype t, N_Vector y, N_Vector ydot, void* user_data); +static int Jac(sunrealtype t, N_Vector y, N_Vector fy, SUNMatrix J, + void* user_data, N_Vector tmp1, N_Vector tmp2, N_Vector tmp3); + +// Private utility functions +static int adaptive_run(void* arkode_mem, N_Vector y, sunrealtype T0, + sunrealtype Tf, int rk_type, int order, N_Vector* yref, + UserData& udata); +static int fixed_run(void* arkode_mem, N_Vector y, sunrealtype T0, sunrealtype Tf, + int rk_type, int order, N_Vector* yref, UserData& udata); +static int computeErrorWeights(N_Vector ycur, N_Vector weight, sunrealtype rtol, + sunrealtype atol, N_Vector vtemp); +static int check_retval(void* returnvalue, const char* funcname, int opt); + +// Main Program +int main(int argc, char* argv[]) +{ + // general problem parameters + sunrealtype T0 = SUN_RCONST(0.0); // initial time + sunrealtype Tf = SUN_RCONST(10.0); // final time + sunindextype NEQ = 3; // number of dependent vars. + int rk_type = 1; // type of RK method [DIRK=0, ERK=1] + int order = 4; // order of accuracy for RK method + int test = 2; // test problem to run + sunbooleantype adaptive = SUNTRUE; // adaptive run vs convergence order + sunrealtype a, b, u0, v0, w0; // parameters + + // general problem variables + int retval; // reusable error-checking flag + N_Vector y = NULL; // empty vector for storing solution + N_Vector* yref = NULL; // empty vectors for storing reference solution + void* arkode_mem = NULL; // empty ARKStep memory structure + void* arkode_ref = NULL; // empty ARKStep memory structure for reference solution + SUNMatrix A = NULL; // empty matrix for solver + SUNLinearSolver LS = NULL; // empty linear solver object + UserData udata; // user-data structure + udata.ep = SUN_RCONST(0.0004); // stiffness parameter + udata.Npart = 20; // partition size + + // + // Initialization + // + + // Retrieve the command-line options: Npart ord method ep test + if (argc > 1) udata.Npart = (int)atoi(argv[1]); + if (argc > 2) order = (int)atoi(argv[2]); + if (argc > 3) rk_type = (int)atoi(argv[3]); + if (argc > 4) udata.ep = (sunrealtype)atof(argv[4]); + if (argc > 5) test = (int)atoi(argv[5]); + + // Check arguments for validity + // method = {0, 1} + // test = {1, 2, 3} + // ep > 0 + // Npart > 0 + if ((rk_type < 0) || (rk_type > 1)) + { + cerr << "ERROR: RK type be an integer in {0,1} \n"; + return (-1); + } + if ((test < 1) || (test > 3)) + { + cerr << "ERROR: test type be an integer in {1,2,3} \n"; + return (-1); + } + if (udata.ep <= ZERO) + { + cerr << "ERROR: ep must be a positive real number\n"; + return (-1); + } + if (udata.Npart < 1) + { + cerr << "ERROR: Npart must be a positive integer\n"; + return (-1); + } + + // Handle adaptive run vs order-of-convergence run + if (order < 0) + { + adaptive = SUNFALSE; + order = abs(order); + } + if (order == 0) order = 4; + + // set up the test problem according to the desired test + if (test == 1) + { + u0 = SUN_RCONST(3.9); + v0 = SUN_RCONST(1.1); + w0 = SUN_RCONST(2.8); + udata.a = SUN_RCONST(1.2); + udata.b = SUN_RCONST(2.5); + } + else if (test == 3) + { + u0 = SUN_RCONST(3.0); + v0 = SUN_RCONST(3.0); + w0 = SUN_RCONST(3.5); + udata.a = SUN_RCONST(0.5); + udata.b = SUN_RCONST(3.0); + } + else + { + u0 = SUN_RCONST(1.2); + v0 = SUN_RCONST(3.1); + w0 = SUN_RCONST(3.0); + udata.a = SUN_RCONST(1.0); + udata.b = SUN_RCONST(3.5); + } + + // Initial problem output (and set implicit solver tolerances as needed) + cout + << "\nAccumulated error estimation test (stiff Brusselator ODE problem):\n"; + cout << " time domain: (" << T0 << "," << Tf << "]\n"; + cout << " partition size = " << udata.Npart << endl; + cout << " initial conditions: u0 = " << u0 << ", v0 = " << v0 + << ", w0 = " << w0 << endl; + cout << " problem parameters: a = " << a << ", b = " << b + << ", ep = " << udata.ep << endl; + if (rk_type == 0) { cout << " DIRK solver, order = " << order << endl; } + else if (rk_type == 1) + { + cout << " ERK solver, order = " << order << endl; + } + + // + // Problem Setup + // + + // Create SUNDIALS context + sundials::Context ctx; + + // Create serial vectors for the solution and reference + y = N_VNew_Serial(NEQ, ctx); + if (check_retval((void*)y, "N_VNew_Serial", 0)) return 1; + yref = N_VCloneVectorArray(udata.Npart + 1, y); + if (check_retval((void*)yref, "N_VNew_Serial", 0)) return 1; + + // Generate reference solution + NV_Ith_S(y, 0) = u0; + NV_Ith_S(y, 1) = v0; + NV_Ith_S(y, 2) = w0; + arkode_ref = ARKStepCreate(fn, NULL, T0, y, ctx); + if (check_retval((void*)arkode_ref, "ARKStepCreate", 0)) return 1; + retval = ARKodeSetUserData(arkode_ref, (void*)&udata); + if (check_retval(&retval, "ARKodeSetUserData", 1)) return 1; + retval = ARKodeSetOrder(arkode_ref, 5); + if (check_retval(&retval, "ARKodeSetOrder", 1)) return 1; + retval = ARKodeSStolerances(arkode_ref, SUN_RCONST(1.e-10), SUN_RCONST(1.e-12)); + if (check_retval(&retval, "ARKodeSStolerances", 1)) return 1; + retval = ARKodeSetMaxNumSteps(arkode_ref, 1000000); + if (check_retval(&retval, "ARKodeSetMaxNumSteps", 1)) return (1); + N_VScale(ONE, y, yref[0]); + sunrealtype hpart = (Tf - T0) / udata.Npart; + for (int ipart = 0; ipart < udata.Npart; ipart++) + { + sunrealtype t = T0 + ipart * hpart; + retval = ARKodeSetStopTime(arkode_ref, t + hpart); + if (check_retval(&retval, "ARKodeSetStopTime", 1)) return 1; + retval = ARKodeEvolve(arkode_ref, t + hpart, y, &t, ARK_NORMAL); + if (check_retval(&retval, "ARKodeEvolve", 1)) return 1; + N_VScale(ONE, y, yref[ipart + 1]); + } + ARKodeFree(&arkode_ref); + + // Set up ARKStep integrator + NV_Ith_S(y, 0) = u0; + NV_Ith_S(y, 1) = v0; + NV_Ith_S(y, 2) = w0; + if (rk_type == 0) + { // DIRK method + arkode_mem = ARKStepCreate(NULL, fn, T0, y, ctx); + } + else + { // ERK method + arkode_mem = ARKStepCreate(fn, NULL, T0, y, ctx); + } + if (check_retval((void*)arkode_mem, "ARKStepCreate", 0)) return 1; + retval = ARKodeSetUserData(arkode_mem, (void*)&udata); + if (check_retval(&retval, "ARKodeSetUserData", 1)) return 1; + retval = ARKodeSetOrder(arkode_mem, order); + if (check_retval(&retval, "ARKodeSetOrder", 1)) return 1; + retval = ARKodeSStolerances(arkode_mem, SUN_RCONST(1.e-4), SUN_RCONST(1.e-9)); + if (check_retval(&retval, "ARKodeSStolerances", 1)) return 1; + if (rk_type == 0) + { // DIRK method + A = SUNDenseMatrix(NEQ, NEQ, ctx); + if (check_retval((void*)A, "SUNDenseMatrix", 0)) return 1; + LS = SUNLinSol_Dense(y, A, ctx); + if (check_retval((void*)LS, "SUNLinSol_Dense", 0)) return 1; + retval = ARKodeSetLinearSolver(arkode_mem, LS, A); + if (check_retval(&retval, "ARKodeSetLinearSolver", 1)) return 1; + retval = ARKodeSetJacFn(arkode_mem, Jac); + if (check_retval(&retval, "ARKodeSetJacFn", 1)) return 1; + } + else + { // ERK method + retval = ARKodeSetMaxNumSteps(arkode_mem, 1000000); + if (check_retval(&retval, "ARKodeSetMaxNumSteps", 1)) return (1); + } + + // Integrate ODE, based on run type + if (adaptive) + { + retval = adaptive_run(arkode_mem, y, T0, Tf, rk_type, order, yref, udata); + if (check_retval(&retval, "adaptive_run", 1)) return 1; + } + else + { + retval = fixed_run(arkode_mem, y, T0, Tf, rk_type, order, yref, udata); + if (check_retval(&retval, "fixed_run", 1)) return 1; + } + + // Clean up and return + ARKodeFree(&arkode_mem); + if (LS) { SUNLinSolFree(LS); } // free system linear solver + if (A) { SUNMatDestroy(A); } // free system matrix + N_VDestroy(y); // Free y and yref vectors + N_VDestroyVectorArray(yref, udata.Npart + 1); + return 0; +} + +//------------------------------ +// Functions called by the solver +//------------------------------ + +static int fn(sunrealtype t, N_Vector y, N_Vector ydot, void* user_data) +{ + UserData* udata = (UserData*)user_data; + sunrealtype u = NV_Ith_S(y, 0); // access solution values + sunrealtype v = NV_Ith_S(y, 1); + sunrealtype w = NV_Ith_S(y, 2); + + // fill in the RHS function + NV_Ith_S(ydot, 0) = udata->a - (w + ONE) * u + v * u * u; + NV_Ith_S(ydot, 1) = w * u - v * u * u; + NV_Ith_S(ydot, 2) = (udata->b - w) / udata->ep - w * u; + + // Return with success + return 0; +} + +static int Jac(sunrealtype t, N_Vector y, N_Vector fy, SUNMatrix J, + void* user_data, N_Vector tmp1, N_Vector tmp2, N_Vector tmp3) +{ + UserData* udata = (UserData*)user_data; + sunrealtype u = NV_Ith_S(y, 0); // access solution values + sunrealtype v = NV_Ith_S(y, 1); + sunrealtype w = NV_Ith_S(y, 2); + + // fill in the Jacobian + SM_ELEMENT_D(J, 0, 0) = -(w + ONE) + TWO * u * v; + SM_ELEMENT_D(J, 0, 1) = u * u; + SM_ELEMENT_D(J, 0, 2) = -u; + + SM_ELEMENT_D(J, 1, 0) = w - TWO * u * v; + SM_ELEMENT_D(J, 1, 1) = -u * u; + SM_ELEMENT_D(J, 1, 2) = u; + + SM_ELEMENT_D(J, 2, 0) = -w; + SM_ELEMENT_D(J, 2, 1) = ZERO; + SM_ELEMENT_D(J, 2, 2) = -ONE / udata->ep - u; + + // Return with success + return 0; +} + +/*------------------------------- + * Private helper functions + *-------------------------------*/ + +//------------------------------ +// Private helper functions +//------------------------------ + +static int adaptive_run(void* arkode_mem, N_Vector y, sunrealtype T0, + sunrealtype Tf, int rk_type, int order, N_Vector* yref, + UserData& udata) +{ + // Reused variables + int retval; + sunrealtype t; + sunrealtype hpart = (Tf - T0) / udata.Npart; + sunrealtype abstol = SUN_RCONST(1.e-12); + vector rtols = {SUN_RCONST(1.e-2), SUN_RCONST(1.e-4), + SUN_RCONST(1.e-6)}; + vector accum_types = {0, 1}; + vector dsm(udata.Npart); + vector dsm_est(udata.Npart); + vector Nsteps(udata.Npart); + + // Loop over tolerances + cout << "\nAdaptive-step runs:\n"; + for (int irtol = 0; irtol < rtols.size(); irtol++) + { + // Loop over accumulation types + for (int iaccum = 0; iaccum < accum_types.size(); iaccum++) + { + // Loop over partition + for (int ipart = 0; ipart < udata.Npart; ipart++) + { + // Reset integrator for this run, and evolve over partition interval + t = T0 + ipart * hpart; + N_VScale(ONE, yref[ipart], y); + if (rk_type == 0) + { // DIRK + retval = ARKStepReInit(arkode_mem, NULL, fn, t, y); + } + else + { // ERK + retval = ARKStepReInit(arkode_mem, fn, NULL, t, y); + } + if (check_retval(&retval, "ARKStepReInit", 1)) return 1; + retval = ARKodeSetAccumulatedErrorType(arkode_mem, accum_types[iaccum]); + if (check_retval(&retval, "ARKodeSetAccumulatedErrorType", 1)) return 1; + retval = ARKodeResetAccumulatedError(arkode_mem); + if (check_retval(&retval, "ARKodeResetAccumulatedError", 1)) return 1; + retval = ARKodeSStolerances(arkode_mem, rtols[irtol], abstol); + if (check_retval(&retval, "ARKodeSStolerances", 1)) return 1; + retval = ARKodeSetStopTime(arkode_mem, t + hpart); + if (check_retval(&retval, "ARKodeSetStopTime", 1)) return 1; + retval = ARKodeSetMaxNumSteps(arkode_mem, 1000000); + if (check_retval(&retval, "ARKodeSetMaxNumSteps", 1)) return (1); + retval = ARKodeEvolve(arkode_mem, t + hpart, y, &t, ARK_NORMAL); + if (check_retval(&retval, "ARKodeEvolve", 1)) break; + retval = ARKodeGetAccumulatedError(arkode_mem, &(dsm_est[ipart])); + if (check_retval(&retval, "ARKodeGetAccumulatedError", 1)) break; + retval = ARKodeGetNumSteps(arkode_mem, &(Nsteps[ipart])); + if (check_retval(&retval, "ARKodeGetNumSteps", 1)) break; + + // Compute/print solution error + sunrealtype uref = NV_Ith_S(yref[ipart + 1], 0); + sunrealtype vref = NV_Ith_S(yref[ipart + 1], 1); + sunrealtype wref = NV_Ith_S(yref[ipart + 1], 2); + sunrealtype udsm = abs(NV_Ith_S(y, 0) - uref) / + (abstol + rtols[irtol] * abs(uref)); + sunrealtype vdsm = abs(NV_Ith_S(y, 1) - vref) / + (abstol + rtols[irtol] * abs(vref)); + sunrealtype wdsm = abs(NV_Ith_S(y, 2) - wref) / + (abstol + rtols[irtol] * abs(wref)); + dsm[ipart] = + rtols[irtol] * + sqrt((udsm * udsm + vdsm * vdsm + wdsm * wdsm) / SUN_RCONST(3.0)); + cout << " rtol " << rtols[irtol] << " rk_type " << rk_type + << " order " << order << " acc " << accum_types[iaccum] << " t " + << t << " dsm " << dsm[ipart] << " dsm_est " << dsm_est[ipart] + << " nsteps " << Nsteps[ipart] << endl; + } + } + } + + return (0); +} + +static int fixed_run(void* arkode_mem, N_Vector y, sunrealtype T0, sunrealtype Tf, + int rk_type, int order, N_Vector* yref, UserData& udata) +{ + // Reused variables + int retval; + sunrealtype hpart = (Tf - T0) / udata.Npart; + long int nsteps2; + sunrealtype t, t2; + sunrealtype reltol = SUN_RCONST(1.e-9); + sunrealtype abstol = SUN_RCONST(1.e-12); + N_Vector y2 = N_VClone(y); + N_Vector ewt = N_VClone(y); + ; + N_Vector vtemp = N_VClone(y); + + // Set array of fixed step sizes to use, storage for corresponding errors/orders + sunrealtype hmax = (Tf - T0) / 400; + if (rk_type == 1) hmax = min(hmax, udata.ep); + vector hvals = {hmax, hmax / 4, hmax / 16, hmax / 64}; + vector accum_types = {0, 1}; + vector dsm(udata.Npart); + vector dsm_est(udata.Npart); + vector Nsteps(udata.Npart); + + // Loop over step sizes + cout << "\nFixed-step runs:\n"; + for (int ih = 0; ih < hvals.size(); ih++) + { + // Loop over built-in accumulation types + for (int iaccum = 0; iaccum < accum_types.size(); iaccum++) + { + // Loop over partition + for (int ipart = 0; ipart < udata.Npart; ipart++) + { + // Reset integrator for this run, and evolve to Tf + t = T0 + ipart * hpart; + N_VScale(ONE, yref[ipart], y); + if (rk_type == 0) + { // DIRK + retval = ARKStepReInit(arkode_mem, NULL, fn, t, y); + } + else + { // ERK + retval = ARKStepReInit(arkode_mem, fn, NULL, t, y); + } + if (check_retval(&retval, "ARKStepReInit", 1)) return 1; + retval = ARKodeSetAccumulatedErrorType(arkode_mem, accum_types[iaccum]); + if (check_retval(&retval, "ARKodeSetAccumulatedErrorType", 1)) return 1; + retval = ARKodeResetAccumulatedError(arkode_mem); + if (check_retval(&retval, "ARKodeResetAccumulatedError", 1)) return 1; + retval = ARKodeSetFixedStep(arkode_mem, hvals[ih]); + if (check_retval(&retval, "ARKodeSetFixedStep", 1)) return 1; + retval = ARKodeSetMaxNumSteps(arkode_mem, 1000000); + if (check_retval(&retval, "ARKodeSetMaxNumSteps", 1)) return (1); + retval = ARKodeSetStopTime(arkode_mem, t + hpart); + if (check_retval(&retval, "ARKodeSetStopTime", 1)) return 1; + retval = ARKodeSStolerances(arkode_mem, reltol, abstol); + if (check_retval(&retval, "ARKodeSStolerances", 1)) return 1; + if (rk_type == 0) + { + retval = ARKodeSetJacEvalFrequency(arkode_mem, 1); + if (check_retval(&retval, "ARKodeSetJacEvalFrequency", 1)) return 1; + retval = ARKodeSetLSetupFrequency(arkode_mem, 1); + if (check_retval(&retval, "ARKodeSetLSetupFrequency", 1)) return 1; + retval = ARKodeSetMaxNonlinIters(arkode_mem, 20); + if (check_retval(&retval, "ARKodeSetMaxNonlinIters", 1)) return 1; + } + retval = ARKodeEvolve(arkode_mem, t + hpart, y, &t, ARK_NORMAL); + if (check_retval(&retval, "ARKodeEvolve", 1)) break; + retval = ARKodeGetAccumulatedError(arkode_mem, &(dsm_est[ipart])); + if (check_retval(&retval, "ARKodeGetAccumulatedError", 1)) break; + retval = ARKodeGetNumSteps(arkode_mem, &(Nsteps[ipart])); + if (check_retval(&retval, "ARKodeGetNumSteps", 1)) break; + + // Compute/print solution error + sunrealtype udsm = abs(NV_Ith_S(y, 0) - NV_Ith_S(yref[ipart + 1], 0)) / + (abstol + reltol * abs(NV_Ith_S(yref[ipart + 1], 0))); + sunrealtype vdsm = abs(NV_Ith_S(y, 1) - NV_Ith_S(yref[ipart + 1], 1)) / + (abstol + reltol * abs(NV_Ith_S(yref[ipart + 1], 1))); + sunrealtype wdsm = abs(NV_Ith_S(y, 2) - NV_Ith_S(yref[ipart + 1], 2)) / + (abstol + reltol * abs(NV_Ith_S(yref[ipart + 1], 2))); + dsm[ipart] = reltol * sqrt((udsm * udsm + vdsm * vdsm + wdsm * wdsm) / + SUN_RCONST(3.0)); + cout << " h " << hvals[ih] << " rk_type " << rk_type << " order " + << order << " acc " << accum_types[iaccum] << " t " << t + << " dsm " << dsm[ipart] << " dsm_est " << dsm_est[ipart] + << " nsteps " << Nsteps[ipart] << endl; + } + } + + // Test double-step error estimator + + // Loop over partition + for (int ipart = 0; ipart < udata.Npart; ipart++) + { + // Reset integrator for this run, and evolve over partition interval + t = t2 = T0 + ipart * hpart; + N_VScale(ONE, yref[ipart], y); + N_VScale(ONE, yref[ipart], y2); + if (rk_type == 0) + { // DIRK + retval = ARKStepReInit(arkode_mem, NULL, fn, t, y); + } + else + { // ERK + retval = ARKStepReInit(arkode_mem, fn, NULL, t, y); + } + if (check_retval(&retval, "ARKStepReInit", 1)) return 1; + retval = ARKodeSetAccumulatedErrorType(arkode_mem, -1); + if (check_retval(&retval, "ARKodeSetAccumulatedErrorType", 1)) return 1; + retval = ARKodeSetFixedStep(arkode_mem, hvals[ih]); + if (check_retval(&retval, "ARKodeSetFixedStep", 1)) return 1; + retval = ARKodeSetMaxNumSteps(arkode_mem, 1000000); + if (check_retval(&retval, "ARKodeSetMaxNumSteps", 1)) return (1); + retval = ARKodeSetStopTime(arkode_mem, t + hpart); + if (check_retval(&retval, "ARKodeSetStopTime", 1)) return 1; + retval = ARKodeSStolerances(arkode_mem, reltol, abstol); + if (check_retval(&retval, "ARKodeSStolerances", 1)) return 1; + if (rk_type == 0) + { + retval = ARKodeSetJacEvalFrequency(arkode_mem, 1); + if (check_retval(&retval, "ARKodeSetJacEvalFrequency", 1)) return 1; + retval = ARKodeSetLSetupFrequency(arkode_mem, 1); + if (check_retval(&retval, "ARKodeSetLSetupFrequency", 1)) return 1; + retval = ARKodeSetMaxNonlinIters(arkode_mem, 20); + if (check_retval(&retval, "ARKodeSetMaxNonlinIters", 1)) return 1; + } + retval = ARKodeEvolve(arkode_mem, t + hpart, y, &t, ARK_NORMAL); + if (check_retval(&retval, "ARKodeEvolve", 1)) break; + retval = ARKodeGetNumSteps(arkode_mem, &(Nsteps[ipart])); + if (check_retval(&retval, "ARKodeGetNumSteps", 1)) break; + + if (rk_type == 0) + { // DIRK + retval = ARKStepReInit(arkode_mem, NULL, fn, t2, y2); + } + else + { // ERK + retval = ARKStepReInit(arkode_mem, fn, NULL, t2, y2); + } + if (check_retval(&retval, "ARKStepReInit", 1)) return 1; + retval = ARKodeSetFixedStep(arkode_mem, 2.0 * hvals[ih]); + if (check_retval(&retval, "ARKodeSetFixedStep", 1)) return 1; + retval = ARKodeSetStopTime(arkode_mem, t2 + hpart); + if (check_retval(&retval, "ARKodeSetStopTime", 1)) return 1; + retval = ARKodeEvolve(arkode_mem, t2 + hpart, y2, &t2, ARK_NORMAL); + if (check_retval(&retval, "ARKodeEvolve", 1)) break; + retval = ARKodeGetNumSteps(arkode_mem, &nsteps2); + if (check_retval(&retval, "ARKodeGetNumSteps", 1)) break; + + retval = computeErrorWeights(y2, ewt, reltol, abstol, vtemp); + if (check_retval(&retval, "computeErrorWeights", 1)) break; + N_VLinearSum(ONE, y2, -ONE, y, y2); + dsm_est[ipart] = reltol * N_VWrmsNorm(y2, ewt); + Nsteps[ipart] += nsteps2; + + sunrealtype udsm = abs(NV_Ith_S(y, 0) - NV_Ith_S(yref[ipart + 1], 0)) / + (abstol + reltol * abs(NV_Ith_S(yref[ipart + 1], 0))); + sunrealtype vdsm = abs(NV_Ith_S(y, 1) - NV_Ith_S(yref[ipart + 1], 1)) / + (abstol + reltol * abs(NV_Ith_S(yref[ipart + 1], 1))); + sunrealtype wdsm = abs(NV_Ith_S(y, 2) - NV_Ith_S(yref[ipart + 1], 2)) / + (abstol + reltol * abs(NV_Ith_S(yref[ipart + 1], 2))); + dsm[ipart] = reltol * sqrt((udsm * udsm + vdsm * vdsm + wdsm * wdsm) / + SUN_RCONST(3.0)); + cout << " h " << hvals[ih] << " rk_type " << rk_type << " order " + << order << " acc " << 2 << " t " << t << " dsm " << dsm[ipart] + << " dsm_est " << dsm_est[ipart] << " nsteps " << Nsteps[ipart] + << endl; + } + } + + N_VDestroy(y2); + N_VDestroy(ewt); + return (0); +} + +/* Error weight calculation routine (mimics what's in ARKODE already) */ +static int computeErrorWeights(N_Vector ycur, N_Vector weight, sunrealtype rtol, + sunrealtype atol, N_Vector vtemp) +{ + N_VAbs(ycur, vtemp); + N_VScale(rtol, vtemp, vtemp); + N_VAddConst(vtemp, atol, vtemp); + N_VInv(vtemp, weight); + return (0); +} + +/* Check function return value... + opt == 0 means SUNDIALS function allocates memory so check if + returned NULL pointer + opt == 1 means SUNDIALS function returns a retval so check if + retval >= 0 + opt == 2 means function allocates memory so check if returned + NULL pointer +*/ +static int check_retval(void* returnvalue, const char* funcname, int opt) +{ + int* retval; + + // Check if SUNDIALS function returned NULL pointer - no memory allocated + if (opt == 0 && returnvalue == NULL) + { + fprintf(stderr, "\nSUNDIALS_ERROR: %s() failed - returned NULL pointer\n\n", + funcname); + return 1; + } + + // Check if retval < 0 + else if (opt == 1) + { + retval = (int*)returnvalue; + if (*retval < 0) + { + fprintf(stderr, "\nSUNDIALS_ERROR: %s() failed with retval = %d\n\n", + funcname, *retval); + return 1; + } + } + + // Check if function returned NULL pointer - no memory allocated + else if (opt == 2 && returnvalue == NULL) + { + fprintf(stderr, "\nMEMORY_ERROR: %s() failed - returned NULL pointer\n\n", + funcname); + return 1; + } + + return 0; +} + +/*---- end of file ----*/ diff --git a/test/unit_tests/arkode/CXX_serial/ark_test_accumerror_brusselator_20_-4_0.out b/test/unit_tests/arkode/CXX_serial/ark_test_accumerror_brusselator_20_-4_0.out new file mode 100644 index 0000000000..2b1c57ba2c --- /dev/null +++ b/test/unit_tests/arkode/CXX_serial/ark_test_accumerror_brusselator_20_-4_0.out @@ -0,0 +1,249 @@ + +Accumulated error estimation test (stiff Brusselator ODE problem): + time domain: (0,10] + partition size = 20 + initial conditions: u0 = 1.2, v0 = 3.1, w0 = 3 + problem parameters: a = 0, b = 0, ep = 0.0004 + DIRK solver, order = 4 + +Fixed-step runs: + h 0.025 rk_type 0 order 4 acc 0 t 0.5 dsm 2.02741e-07 dsm_est 0.244873 nsteps 20 + h 0.025 rk_type 0 order 4 acc 0 t 1 dsm 4.36512e-10 dsm_est 9.15797e-10 nsteps 20 + h 0.025 rk_type 0 order 4 acc 0 t 1.5 dsm 1.47944e-09 dsm_est 1.03904e-09 nsteps 20 + h 0.025 rk_type 0 order 4 acc 0 t 2 dsm 3.07014e-09 dsm_est 7.16968e-10 nsteps 20 + h 0.025 rk_type 0 order 4 acc 0 t 2.5 dsm 2.41009e-09 dsm_est 9.26427e-10 nsteps 20 + h 0.025 rk_type 0 order 4 acc 0 t 3 dsm 2.2919e-10 dsm_est 1.68058e-09 nsteps 20 + h 0.025 rk_type 0 order 4 acc 0 t 3.5 dsm 2.10843e-11 dsm_est 1.6358e-09 nsteps 20 + h 0.025 rk_type 0 order 4 acc 0 t 4 dsm 4.85414e-11 dsm_est 8.11006e-10 nsteps 20 + h 0.025 rk_type 0 order 4 acc 0 t 4.5 dsm 1.96723e-10 dsm_est 1.90108e-10 nsteps 20 + h 0.025 rk_type 0 order 4 acc 0 t 5 dsm 8.22132e-10 dsm_est 5.32797e-10 nsteps 20 + h 0.025 rk_type 0 order 4 acc 0 t 5.5 dsm 1.54757e-09 dsm_est 9.55312e-10 nsteps 20 + h 0.025 rk_type 0 order 4 acc 0 t 6 dsm 1.4066e-09 dsm_est 5.43427e-09 nsteps 20 + h 0.025 rk_type 0 order 4 acc 0 t 6.5 dsm 1.53642e-07 dsm_est 8.50911e-07 nsteps 20 + h 0.025 rk_type 0 order 4 acc 0 t 7 dsm 4.94724e-06 dsm_est 0.000100467 nsteps 20 + h 0.025 rk_type 0 order 4 acc 0 t 7.5 dsm 4.18294e-08 dsm_est 1.0711e-05 nsteps 20 + h 0.025 rk_type 0 order 4 acc 0 t 8 dsm 1.04878e-08 dsm_est 1.1263e-07 nsteps 20 + h 0.025 rk_type 0 order 4 acc 0 t 8.5 dsm 2.79702e-09 dsm_est 2.16903e-08 nsteps 20 + h 0.025 rk_type 0 order 4 acc 0 t 9 dsm 1.60168e-09 dsm_est 1.38178e-08 nsteps 20 + h 0.025 rk_type 0 order 4 acc 0 t 9.5 dsm 1.4347e-09 dsm_est 1.88007e-08 nsteps 20 + h 0.025 rk_type 0 order 4 acc 0 t 10 dsm 5.54538e-10 dsm_est 1.51522e-08 nsteps 20 + h 0.025 rk_type 0 order 4 acc 1 t 0.5 dsm 2.02741e-07 dsm_est 0.0135207 nsteps 20 + h 0.025 rk_type 0 order 4 acc 1 t 1 dsm 4.36512e-10 dsm_est 5.08381e-10 nsteps 20 + h 0.025 rk_type 0 order 4 acc 1 t 1.5 dsm 1.47944e-09 dsm_est 9.58723e-10 nsteps 20 + h 0.025 rk_type 0 order 4 acc 1 t 2 dsm 3.07014e-09 dsm_est 3.90744e-10 nsteps 20 + h 0.025 rk_type 0 order 4 acc 1 t 2.5 dsm 2.41009e-09 dsm_est 3.67901e-10 nsteps 20 + h 0.025 rk_type 0 order 4 acc 1 t 3 dsm 2.2919e-10 dsm_est 1.47844e-09 nsteps 20 + h 0.025 rk_type 0 order 4 acc 1 t 3.5 dsm 2.10843e-11 dsm_est 1.28099e-09 nsteps 20 + h 0.025 rk_type 0 order 4 acc 1 t 4 dsm 4.85414e-11 dsm_est 4.55485e-10 nsteps 20 + h 0.025 rk_type 0 order 4 acc 1 t 4.5 dsm 1.96723e-10 dsm_est 9.4415e-11 nsteps 20 + h 0.025 rk_type 0 order 4 acc 1 t 5 dsm 8.22132e-10 dsm_est 3.5967e-10 nsteps 20 + h 0.025 rk_type 0 order 4 acc 1 t 5.5 dsm 1.54757e-09 dsm_est 7.71393e-10 nsteps 20 + h 0.025 rk_type 0 order 4 acc 1 t 6 dsm 1.4066e-09 dsm_est 1.38966e-09 nsteps 20 + h 0.025 rk_type 0 order 4 acc 1 t 6.5 dsm 1.53642e-07 dsm_est 1.71964e-07 nsteps 20 + h 0.025 rk_type 0 order 4 acc 1 t 7 dsm 4.94724e-06 dsm_est 2.68263e-05 nsteps 20 + h 0.025 rk_type 0 order 4 acc 1 t 7.5 dsm 4.18294e-08 dsm_est 1.40652e-06 nsteps 20 + h 0.025 rk_type 0 order 4 acc 1 t 8 dsm 1.04878e-08 dsm_est 5.45367e-08 nsteps 20 + h 0.025 rk_type 0 order 4 acc 1 t 8.5 dsm 2.79702e-09 dsm_est 1.40952e-08 nsteps 20 + h 0.025 rk_type 0 order 4 acc 1 t 9 dsm 1.60168e-09 dsm_est 6.13761e-09 nsteps 20 + h 0.025 rk_type 0 order 4 acc 1 t 9.5 dsm 1.4347e-09 dsm_est 1.74499e-08 nsteps 20 + h 0.025 rk_type 0 order 4 acc 1 t 10 dsm 5.54538e-10 dsm_est 9.89407e-09 nsteps 20 + h 0.025 rk_type 0 order 4 acc 2 t 0.5 dsm 2.02741e-07 dsm_est 2.04151e-07 nsteps 30 + h 0.025 rk_type 0 order 4 acc 2 t 1 dsm 4.36512e-10 dsm_est 1.51075e-09 nsteps 30 + h 0.025 rk_type 0 order 4 acc 2 t 1.5 dsm 1.47944e-09 dsm_est 1.30553e-09 nsteps 30 + h 0.025 rk_type 0 order 4 acc 2 t 2 dsm 3.07014e-09 dsm_est 6.93616e-10 nsteps 30 + h 0.025 rk_type 0 order 4 acc 2 t 2.5 dsm 2.41009e-09 dsm_est 3.64938e-09 nsteps 30 + h 0.025 rk_type 0 order 4 acc 2 t 3 dsm 2.2919e-10 dsm_est 1.30625e-09 nsteps 30 + h 0.025 rk_type 0 order 4 acc 2 t 3.5 dsm 2.10843e-11 dsm_est 3.14425e-10 nsteps 30 + h 0.025 rk_type 0 order 4 acc 2 t 4 dsm 4.85414e-11 dsm_est 7.33721e-10 nsteps 30 + h 0.025 rk_type 0 order 4 acc 2 t 4.5 dsm 1.96723e-10 dsm_est 6.03307e-11 nsteps 30 + h 0.025 rk_type 0 order 4 acc 2 t 5 dsm 8.22132e-10 dsm_est 6.73954e-10 nsteps 30 + h 0.025 rk_type 0 order 4 acc 2 t 5.5 dsm 1.54757e-09 dsm_est 2.31912e-10 nsteps 30 + h 0.025 rk_type 0 order 4 acc 2 t 6 dsm 1.4066e-09 dsm_est 2.44839e-08 nsteps 30 + h 0.025 rk_type 0 order 4 acc 2 t 6.5 dsm 1.53642e-07 dsm_est 2.36231e-06 nsteps 30 + h 0.025 rk_type 0 order 4 acc 2 t 7 dsm 4.94724e-06 dsm_est 8.33486e-05 nsteps 30 + h 0.025 rk_type 0 order 4 acc 2 t 7.5 dsm 4.18294e-08 dsm_est 5.85759e-07 nsteps 30 + h 0.025 rk_type 0 order 4 acc 2 t 8 dsm 1.04878e-08 dsm_est 1.52644e-07 nsteps 30 + h 0.025 rk_type 0 order 4 acc 2 t 8.5 dsm 2.79702e-09 dsm_est 5.7594e-08 nsteps 30 + h 0.025 rk_type 0 order 4 acc 2 t 9 dsm 1.60168e-09 dsm_est 3.77187e-08 nsteps 30 + h 0.025 rk_type 0 order 4 acc 2 t 9.5 dsm 1.4347e-09 dsm_est 2.25916e-09 nsteps 30 + h 0.025 rk_type 0 order 4 acc 2 t 10 dsm 5.54538e-10 dsm_est 8.39636e-09 nsteps 30 + h 0.00625 rk_type 0 order 4 acc 0 t 0.5 dsm 2.01526e-08 dsm_est 0.12061 nsteps 80 + h 0.00625 rk_type 0 order 4 acc 0 t 1 dsm 9.02564e-12 dsm_est 3.15224e-11 nsteps 80 + h 0.00625 rk_type 0 order 4 acc 0 t 1.5 dsm 6.18719e-12 dsm_est 1.15612e-11 nsteps 80 + h 0.00625 rk_type 0 order 4 acc 0 t 2 dsm 1.21264e-11 dsm_est 3.56333e-12 nsteps 80 + h 0.00625 rk_type 0 order 4 acc 0 t 2.5 dsm 9.39437e-12 dsm_est 3.71652e-12 nsteps 80 + h 0.00625 rk_type 0 order 4 acc 0 t 3 dsm 6.39567e-12 dsm_est 6.60675e-12 nsteps 80 + h 0.00625 rk_type 0 order 4 acc 0 t 3.5 dsm 4.31321e-12 dsm_est 1.02486e-11 nsteps 80 + h 0.00625 rk_type 0 order 4 acc 0 t 4 dsm 5.26346e-12 dsm_est 6.34128e-12 nsteps 80 + h 0.00625 rk_type 0 order 4 acc 0 t 4.5 dsm 3.00982e-11 dsm_est 6.6337e-12 nsteps 80 + h 0.00625 rk_type 0 order 4 acc 0 t 5 dsm 3.35644e-12 dsm_est 3.78322e-11 nsteps 80 + h 0.00625 rk_type 0 order 4 acc 0 t 5.5 dsm 1.37915e-11 dsm_est 3.71144e-12 nsteps 80 + h 0.00625 rk_type 0 order 4 acc 0 t 6 dsm 9.91766e-11 dsm_est 2.23847e-11 nsteps 80 + h 0.00625 rk_type 0 order 4 acc 0 t 6.5 dsm 3.01672e-09 dsm_est 3.42521e-09 nsteps 80 + h 0.00625 rk_type 0 order 4 acc 0 t 7 dsm 1.77811e-08 dsm_est 4.60341e-07 nsteps 80 + h 0.00625 rk_type 0 order 4 acc 0 t 7.5 dsm 7.42418e-10 dsm_est 6.0223e-08 nsteps 80 + h 0.00625 rk_type 0 order 4 acc 0 t 8 dsm 3.89202e-10 dsm_est 4.90508e-10 nsteps 80 + h 0.00625 rk_type 0 order 4 acc 0 t 8.5 dsm 3.7018e-11 dsm_est 2.41013e-10 nsteps 80 + h 0.00625 rk_type 0 order 4 acc 0 t 9 dsm 2.94415e-11 dsm_est 5.60347e-11 nsteps 80 + h 0.00625 rk_type 0 order 4 acc 0 t 9.5 dsm 1.42778e-11 dsm_est 7.48066e-11 nsteps 80 + h 0.00625 rk_type 0 order 4 acc 0 t 10 dsm 4.93463e-12 dsm_est 6.33468e-11 nsteps 80 + h 0.00625 rk_type 0 order 4 acc 1 t 0.5 dsm 2.01526e-08 dsm_est 0.00177442 nsteps 80 + h 0.00625 rk_type 0 order 4 acc 1 t 1 dsm 9.02564e-12 dsm_est 2.40701e-12 nsteps 80 + h 0.00625 rk_type 0 order 4 acc 1 t 1.5 dsm 6.18719e-12 dsm_est 3.87284e-12 nsteps 80 + h 0.00625 rk_type 0 order 4 acc 1 t 2 dsm 1.21264e-11 dsm_est 1.58498e-12 nsteps 80 + h 0.00625 rk_type 0 order 4 acc 1 t 2.5 dsm 9.39437e-12 dsm_est 1.44929e-12 nsteps 80 + h 0.00625 rk_type 0 order 4 acc 1 t 3 dsm 6.39567e-12 dsm_est 5.79442e-12 nsteps 80 + h 0.00625 rk_type 0 order 4 acc 1 t 3.5 dsm 4.31321e-12 dsm_est 5.09937e-12 nsteps 80 + h 0.00625 rk_type 0 order 4 acc 1 t 4 dsm 5.26346e-12 dsm_est 1.84452e-12 nsteps 80 + h 0.00625 rk_type 0 order 4 acc 1 t 4.5 dsm 3.00982e-11 dsm_est 4.51445e-13 nsteps 80 + h 0.00625 rk_type 0 order 4 acc 1 t 5 dsm 3.35644e-12 dsm_est 1.92957e-12 nsteps 80 + h 0.00625 rk_type 0 order 4 acc 1 t 5.5 dsm 1.37915e-11 dsm_est 2.9942e-12 nsteps 80 + h 0.00625 rk_type 0 order 4 acc 1 t 6 dsm 9.91766e-11 dsm_est 5.36083e-12 nsteps 80 + h 0.00625 rk_type 0 order 4 acc 1 t 6.5 dsm 3.01672e-09 dsm_est 6.26439e-10 nsteps 80 + h 0.00625 rk_type 0 order 4 acc 1 t 7 dsm 1.77811e-08 dsm_est 1.16445e-07 nsteps 80 + h 0.00625 rk_type 0 order 4 acc 1 t 7.5 dsm 7.42418e-10 dsm_est 6.32584e-09 nsteps 80 + h 0.00625 rk_type 0 order 4 acc 1 t 8 dsm 3.89202e-10 dsm_est 2.24093e-10 nsteps 80 + h 0.00625 rk_type 0 order 4 acc 1 t 8.5 dsm 3.7018e-11 dsm_est 5.81897e-11 nsteps 80 + h 0.00625 rk_type 0 order 4 acc 1 t 9 dsm 2.94415e-11 dsm_est 2.43467e-11 nsteps 80 + h 0.00625 rk_type 0 order 4 acc 1 t 9.5 dsm 1.42778e-11 dsm_est 6.94659e-11 nsteps 80 + h 0.00625 rk_type 0 order 4 acc 1 t 10 dsm 4.93463e-12 dsm_est 3.94313e-11 nsteps 80 + h 0.00625 rk_type 0 order 4 acc 2 t 0.5 dsm 2.01526e-08 dsm_est 5.96471e-08 nsteps 120 + h 0.00625 rk_type 0 order 4 acc 2 t 1 dsm 9.02564e-12 dsm_est 2.62428e-11 nsteps 120 + h 0.00625 rk_type 0 order 4 acc 2 t 1.5 dsm 6.18719e-12 dsm_est 8.82608e-11 nsteps 120 + h 0.00625 rk_type 0 order 4 acc 2 t 2 dsm 1.21264e-11 dsm_est 1.81216e-10 nsteps 120 + h 0.00625 rk_type 0 order 4 acc 2 t 2.5 dsm 9.39437e-12 dsm_est 1.39896e-10 nsteps 120 + h 0.00625 rk_type 0 order 4 acc 2 t 3 dsm 6.39567e-12 dsm_est 1.30298e-11 nsteps 120 + h 0.00625 rk_type 0 order 4 acc 2 t 3.5 dsm 4.31321e-12 dsm_est 1.17983e-12 nsteps 120 + h 0.00625 rk_type 0 order 4 acc 2 t 4 dsm 5.26346e-12 dsm_est 2.82746e-12 nsteps 120 + h 0.00625 rk_type 0 order 4 acc 2 t 4.5 dsm 3.00982e-11 dsm_est 1.13213e-11 nsteps 120 + h 0.00625 rk_type 0 order 4 acc 2 t 5 dsm 3.35644e-12 dsm_est 4.77357e-11 nsteps 120 + h 0.00625 rk_type 0 order 4 acc 2 t 5.5 dsm 1.37915e-11 dsm_est 1.78455e-10 nsteps 120 + h 0.00625 rk_type 0 order 4 acc 2 t 6 dsm 9.91766e-11 dsm_est 1.16563e-09 nsteps 120 + h 0.00625 rk_type 0 order 4 acc 2 t 6.5 dsm 3.01672e-09 dsm_est 1.01849e-08 nsteps 120 + h 0.00625 rk_type 0 order 4 acc 2 t 7 dsm 1.77811e-08 dsm_est 2.72392e-07 nsteps 120 + h 0.00625 rk_type 0 order 4 acc 2 t 7.5 dsm 7.42418e-10 dsm_est 3.28703e-09 nsteps 120 + h 0.00625 rk_type 0 order 4 acc 2 t 8 dsm 3.89202e-10 dsm_est 2.22651e-09 nsteps 120 + h 0.00625 rk_type 0 order 4 acc 2 t 8.5 dsm 3.7018e-11 dsm_est 5.88999e-10 nsteps 120 + h 0.00625 rk_type 0 order 4 acc 2 t 9 dsm 2.94415e-11 dsm_est 2.41758e-10 nsteps 120 + h 0.00625 rk_type 0 order 4 acc 2 t 9.5 dsm 1.42778e-11 dsm_est 9.06696e-11 nsteps 120 + h 0.00625 rk_type 0 order 4 acc 2 t 10 dsm 4.93463e-12 dsm_est 3.23538e-11 nsteps 120 + h 0.0015625 rk_type 0 order 4 acc 0 t 0.5 dsm 1.12995e-09 dsm_est 0.0161685 nsteps 320 + h 0.0015625 rk_type 0 order 4 acc 0 t 1 dsm 8.83314e-12 dsm_est 4.22807e-12 nsteps 320 + h 0.0015625 rk_type 0 order 4 acc 0 t 1.5 dsm 1.84069e-12 dsm_est 1.48779e-12 nsteps 320 + h 0.0015625 rk_type 0 order 4 acc 0 t 2 dsm 2.23198e-13 dsm_est 3.06e-13 nsteps 320 + h 0.0015625 rk_type 0 order 4 acc 0 t 2.5 dsm 5.57615e-13 dsm_est 3.16293e-14 nsteps 320 + h 0.0015625 rk_type 0 order 4 acc 0 t 3 dsm 6.33215e-12 dsm_est 9.28211e-14 nsteps 320 + h 0.0015625 rk_type 0 order 4 acc 0 t 3.5 dsm 4.31345e-12 dsm_est 1.06725e-12 nsteps 320 + h 0.0015625 rk_type 0 order 4 acc 0 t 4 dsm 5.25911e-12 dsm_est 7.27486e-13 nsteps 320 + h 0.0015625 rk_type 0 order 4 acc 0 t 4.5 dsm 3.00873e-11 dsm_est 8.86785e-13 nsteps 320 + h 0.0015625 rk_type 0 order 4 acc 0 t 5 dsm 1.04948e-12 dsm_est 5.07072e-12 nsteps 320 + h 0.0015625 rk_type 0 order 4 acc 0 t 5.5 dsm 6.97828e-12 dsm_est 1.75823e-13 nsteps 320 + h 0.0015625 rk_type 0 order 4 acc 0 t 6 dsm 5.98205e-11 dsm_est 1.17286e-12 nsteps 320 + h 0.0015625 rk_type 0 order 4 acc 0 t 6.5 dsm 1.87435e-11 dsm_est 1.34855e-11 nsteps 320 + h 0.0015625 rk_type 0 order 4 acc 0 t 7 dsm 6.39659e-10 dsm_est 1.86951e-09 nsteps 320 + h 0.0015625 rk_type 0 order 4 acc 0 t 7.5 dsm 1.83962e-11 dsm_est 2.58837e-10 nsteps 320 + h 0.0015625 rk_type 0 order 4 acc 0 t 8 dsm 1.77418e-10 dsm_est 3.6664e-12 nsteps 320 + h 0.0015625 rk_type 0 order 4 acc 0 t 8.5 dsm 2.78724e-12 dsm_est 2.99588e-11 nsteps 320 + h 0.0015625 rk_type 0 order 4 acc 0 t 9 dsm 2.4955e-11 dsm_est 5.0593e-13 nsteps 320 + h 0.0015625 rk_type 0 order 4 acc 0 t 9.5 dsm 1.29649e-11 dsm_est 4.22112e-12 nsteps 320 + h 0.0015625 rk_type 0 order 4 acc 0 t 10 dsm 4.44459e-12 dsm_est 2.19913e-12 nsteps 320 + h 0.0015625 rk_type 0 order 4 acc 1 t 0.5 dsm 1.12995e-09 dsm_est 5.29229e-05 nsteps 320 + h 0.0015625 rk_type 0 order 4 acc 1 t 1 dsm 8.83314e-12 dsm_est 2.17158e-14 nsteps 320 + h 0.0015625 rk_type 0 order 4 acc 1 t 1.5 dsm 1.84069e-12 dsm_est 1.99723e-14 nsteps 320 + h 0.0015625 rk_type 0 order 4 acc 1 t 2 dsm 2.23198e-13 dsm_est 8.79682e-15 nsteps 320 + h 0.0015625 rk_type 0 order 4 acc 1 t 2.5 dsm 5.57615e-13 dsm_est 7.03822e-15 nsteps 320 + h 0.0015625 rk_type 0 order 4 acc 1 t 3 dsm 6.33215e-12 dsm_est 2.29246e-14 nsteps 320 + h 0.0015625 rk_type 0 order 4 acc 1 t 3.5 dsm 4.31345e-12 dsm_est 2.31473e-14 nsteps 320 + h 0.0015625 rk_type 0 order 4 acc 1 t 4 dsm 5.25911e-12 dsm_est 9.40731e-15 nsteps 320 + h 0.0015625 rk_type 0 order 4 acc 1 t 4.5 dsm 3.00873e-11 dsm_est 4.42611e-15 nsteps 320 + h 0.0015625 rk_type 0 order 4 acc 1 t 5 dsm 1.04948e-12 dsm_est 2.21481e-14 nsteps 320 + h 0.0015625 rk_type 0 order 4 acc 1 t 5.5 dsm 6.97828e-12 dsm_est 1.2278e-14 nsteps 320 + h 0.0015625 rk_type 0 order 4 acc 1 t 6 dsm 5.98205e-11 dsm_est 2.51123e-14 nsteps 320 + h 0.0015625 rk_type 0 order 4 acc 1 t 6.5 dsm 1.87435e-11 dsm_est 2.43406e-12 nsteps 320 + h 0.0015625 rk_type 0 order 4 acc 1 t 7 dsm 6.39659e-10 dsm_est 4.6675e-10 nsteps 320 + h 0.0015625 rk_type 0 order 4 acc 1 t 7.5 dsm 1.83962e-11 dsm_est 2.56334e-11 nsteps 320 + h 0.0015625 rk_type 0 order 4 acc 1 t 8 dsm 1.77418e-10 dsm_est 8.92764e-13 nsteps 320 + h 0.0015625 rk_type 0 order 4 acc 1 t 8.5 dsm 2.78724e-12 dsm_est 3.18282e-13 nsteps 320 + h 0.0015625 rk_type 0 order 4 acc 1 t 9 dsm 2.4955e-11 dsm_est 9.93014e-14 nsteps 320 + h 0.0015625 rk_type 0 order 4 acc 1 t 9.5 dsm 1.29649e-11 dsm_est 2.84939e-13 nsteps 320 + h 0.0015625 rk_type 0 order 4 acc 1 t 10 dsm 4.44459e-12 dsm_est 1.6087e-13 nsteps 320 + h 0.0015625 rk_type 0 order 4 acc 2 t 0.5 dsm 1.12995e-09 dsm_est 2.29243e-09 nsteps 480 + h 0.0015625 rk_type 0 order 4 acc 2 t 1 dsm 8.83314e-12 dsm_est 1.01708e-13 nsteps 480 + h 0.0015625 rk_type 0 order 4 acc 2 t 1.5 dsm 1.84069e-12 dsm_est 3.46845e-13 nsteps 480 + h 0.0015625 rk_type 0 order 4 acc 2 t 2 dsm 2.23198e-13 dsm_est 7.13223e-13 nsteps 480 + h 0.0015625 rk_type 0 order 4 acc 2 t 2.5 dsm 5.57615e-13 dsm_est 5.5096e-13 nsteps 480 + h 0.0015625 rk_type 0 order 4 acc 2 t 3 dsm 6.33215e-12 dsm_est 5.10951e-14 nsteps 480 + h 0.0015625 rk_type 0 order 4 acc 2 t 3.5 dsm 4.31345e-12 dsm_est 4.40878e-15 nsteps 480 + h 0.0015625 rk_type 0 order 4 acc 2 t 4 dsm 5.25911e-12 dsm_est 1.13938e-14 nsteps 480 + h 0.0015625 rk_type 0 order 4 acc 2 t 4.5 dsm 3.00873e-11 dsm_est 3.76833e-14 nsteps 480 + h 0.0015625 rk_type 0 order 4 acc 2 t 5 dsm 1.04948e-12 dsm_est 1.75165e-13 nsteps 480 + h 0.0015625 rk_type 0 order 4 acc 2 t 5.5 dsm 6.97828e-12 dsm_est 6.76285e-13 nsteps 480 + h 0.0015625 rk_type 0 order 4 acc 2 t 6 dsm 5.98205e-11 dsm_est 4.58434e-12 nsteps 480 + h 0.0015625 rk_type 0 order 4 acc 2 t 6.5 dsm 1.87435e-11 dsm_est 1.80355e-10 nsteps 480 + h 0.0015625 rk_type 0 order 4 acc 2 t 7 dsm 6.39659e-10 dsm_est 7.2409e-10 nsteps 480 + h 0.0015625 rk_type 0 order 4 acc 2 t 7.5 dsm 1.83962e-11 dsm_est 3.9885e-11 nsteps 480 + h 0.0015625 rk_type 0 order 4 acc 2 t 8 dsm 1.77418e-10 dsm_est 1.97323e-11 nsteps 480 + h 0.0015625 rk_type 0 order 4 acc 2 t 8.5 dsm 2.78724e-12 dsm_est 2.15597e-12 nsteps 480 + h 0.0015625 rk_type 0 order 4 acc 2 t 9 dsm 2.4955e-11 dsm_est 9.29203e-13 nsteps 480 + h 0.0015625 rk_type 0 order 4 acc 2 t 9.5 dsm 1.29649e-11 dsm_est 3.52852e-13 nsteps 480 + h 0.0015625 rk_type 0 order 4 acc 2 t 10 dsm 4.44459e-12 dsm_est 1.2586e-13 nsteps 480 + h 0.000390625 rk_type 0 order 4 acc 0 t 0.5 dsm 4.75504e-11 dsm_est 0.000360159 nsteps 1281 + h 0.000390625 rk_type 0 order 4 acc 0 t 1 dsm 8.83253e-12 dsm_est 9.41667e-14 nsteps 1281 + h 0.000390625 rk_type 0 order 4 acc 0 t 1.5 dsm 1.8399e-12 dsm_est 3.31853e-14 nsteps 1280 + h 0.000390625 rk_type 0 order 4 acc 0 t 2 dsm 2.21232e-13 dsm_est 6.92196e-15 nsteps 1280 + h 0.000390625 rk_type 0 order 4 acc 0 t 2.5 dsm 5.57029e-13 dsm_est 7.49969e-16 nsteps 1280 + h 0.000390625 rk_type 0 order 4 acc 0 t 3 dsm 6.33194e-12 dsm_est 2.00962e-15 nsteps 1280 + h 0.000390625 rk_type 0 order 4 acc 0 t 3.5 dsm 4.31407e-12 dsm_est 2.37702e-14 nsteps 1280 + h 0.000390625 rk_type 0 order 4 acc 0 t 4 dsm 5.25853e-12 dsm_est 1.62111e-14 nsteps 1280 + h 0.000390625 rk_type 0 order 4 acc 0 t 4.5 dsm 3.00881e-11 dsm_est 1.97207e-14 nsteps 1281 + h 0.000390625 rk_type 0 order 4 acc 0 t 5 dsm 1.04964e-12 dsm_est 1.12957e-13 nsteps 1281 + h 0.000390625 rk_type 0 order 4 acc 0 t 5.5 dsm 6.97849e-12 dsm_est 3.92461e-15 nsteps 1281 + h 0.000390625 rk_type 0 order 4 acc 0 t 6 dsm 5.9817e-11 dsm_est 2.61272e-14 nsteps 1281 + h 0.000390625 rk_type 0 order 4 acc 0 t 6.5 dsm 1.43381e-11 dsm_est 2.24496e-13 nsteps 1281 + h 0.000390625 rk_type 0 order 4 acc 0 t 7 dsm 2.94602e-12 dsm_est 7.37178e-12 nsteps 1281 + h 0.000390625 rk_type 0 order 4 acc 0 t 7.5 dsm 1.82124e-11 dsm_est 1.0358e-12 nsteps 1281 + h 0.000390625 rk_type 0 order 4 acc 0 t 8 dsm 1.77421e-10 dsm_est 6.91895e-14 nsteps 1281 + h 0.000390625 rk_type 0 order 4 acc 0 t 8.5 dsm 2.81466e-12 dsm_est 6.67292e-13 nsteps 1281 + h 0.000390625 rk_type 0 order 4 acc 0 t 9 dsm 2.496e-11 dsm_est 1.06333e-14 nsteps 1281 + h 0.000390625 rk_type 0 order 4 acc 0 t 9.5 dsm 1.2967e-11 dsm_est 9.36985e-14 nsteps 1281 + h 0.000390625 rk_type 0 order 4 acc 0 t 10 dsm 4.44606e-12 dsm_est 4.86957e-14 nsteps 1281 + h 0.000390625 rk_type 0 order 4 acc 1 t 0.5 dsm 4.75504e-11 dsm_est 4.32867e-07 nsteps 1281 + h 0.000390625 rk_type 0 order 4 acc 1 t 1 dsm 8.83253e-12 dsm_est 1.65206e-16 nsteps 1281 + h 0.000390625 rk_type 0 order 4 acc 1 t 1.5 dsm 1.8399e-12 dsm_est 1.14767e-16 nsteps 1280 + h 0.000390625 rk_type 0 order 4 acc 1 t 2 dsm 2.21232e-13 dsm_est 6.3138e-17 nsteps 1280 + h 0.000390625 rk_type 0 order 4 acc 1 t 2.5 dsm 5.57029e-13 dsm_est 4.78256e-17 nsteps 1280 + h 0.000390625 rk_type 0 order 4 acc 1 t 3 dsm 6.33194e-12 dsm_est 9.84357e-17 nsteps 1280 + h 0.000390625 rk_type 0 order 4 acc 1 t 3.5 dsm 4.31407e-12 dsm_est 1.14709e-16 nsteps 1280 + h 0.000390625 rk_type 0 order 4 acc 1 t 4 dsm 5.25853e-12 dsm_est 6.48108e-17 nsteps 1280 + h 0.000390625 rk_type 0 order 4 acc 1 t 4.5 dsm 3.00881e-11 dsm_est 5.75437e-17 nsteps 1281 + h 0.000390625 rk_type 0 order 4 acc 1 t 5 dsm 1.04964e-12 dsm_est 1.8087e-16 nsteps 1281 + h 0.000390625 rk_type 0 order 4 acc 1 t 5.5 dsm 6.97849e-12 dsm_est 6.30545e-17 nsteps 1281 + h 0.000390625 rk_type 0 order 4 acc 1 t 6 dsm 5.9817e-11 dsm_est 1.32311e-16 nsteps 1281 + h 0.000390625 rk_type 0 order 4 acc 1 t 6.5 dsm 1.43381e-11 dsm_est 9.62831e-15 nsteps 1281 + h 0.000390625 rk_type 0 order 4 acc 1 t 7 dsm 2.94602e-12 dsm_est 1.83666e-12 nsteps 1281 + h 0.000390625 rk_type 0 order 4 acc 1 t 7.5 dsm 1.82124e-11 dsm_est 1.00979e-13 nsteps 1281 + h 0.000390625 rk_type 0 order 4 acc 1 t 8 dsm 1.77421e-10 dsm_est 3.54707e-15 nsteps 1281 + h 0.000390625 rk_type 0 order 4 acc 1 t 8.5 dsm 2.81466e-12 dsm_est 1.71467e-15 nsteps 1281 + h 0.000390625 rk_type 0 order 4 acc 1 t 9 dsm 2.496e-11 dsm_est 4.28593e-16 nsteps 1281 + h 0.000390625 rk_type 0 order 4 acc 1 t 9.5 dsm 1.2967e-11 dsm_est 1.17821e-15 nsteps 1281 + h 0.000390625 rk_type 0 order 4 acc 1 t 10 dsm 4.44606e-12 dsm_est 6.63078e-16 nsteps 1281 + h 0.000390625 rk_type 0 order 4 acc 2 t 0.5 dsm 4.75504e-11 dsm_est 2.63435e-10 nsteps 1921 + h 0.000390625 rk_type 0 order 4 acc 2 t 1 dsm 8.83253e-12 dsm_est 2.03794e-15 nsteps 1922 + h 0.000390625 rk_type 0 order 4 acc 2 t 1.5 dsm 1.8399e-12 dsm_est 3.00814e-14 nsteps 1920 + h 0.000390625 rk_type 0 order 4 acc 2 t 2 dsm 2.21232e-13 dsm_est 4.15128e-14 nsteps 1920 + h 0.000390625 rk_type 0 order 4 acc 2 t 2.5 dsm 5.57029e-13 dsm_est 1.58845e-15 nsteps 1920 + h 0.000390625 rk_type 0 order 4 acc 2 t 3 dsm 6.33194e-12 dsm_est 5.52712e-16 nsteps 1920 + h 0.000390625 rk_type 0 order 4 acc 2 t 3.5 dsm 4.31407e-12 dsm_est 1.6025e-15 nsteps 1920 + h 0.000390625 rk_type 0 order 4 acc 2 t 4 dsm 5.25853e-12 dsm_est 9.59599e-16 nsteps 1920 + h 0.000390625 rk_type 0 order 4 acc 2 t 4.5 dsm 3.00881e-11 dsm_est 5.29038e-14 nsteps 1921 + h 0.000390625 rk_type 0 order 4 acc 2 t 5 dsm 1.04964e-12 dsm_est 7.31539e-14 nsteps 1921 + h 0.000390625 rk_type 0 order 4 acc 2 t 5.5 dsm 6.97849e-12 dsm_est 1.08618e-13 nsteps 1921 + h 0.000390625 rk_type 0 order 4 acc 2 t 6 dsm 5.9817e-11 dsm_est 2.24477e-13 nsteps 1921 + h 0.000390625 rk_type 0 order 4 acc 2 t 6.5 dsm 1.43381e-11 dsm_est 1.46745e-12 nsteps 1921 + h 0.000390625 rk_type 0 order 4 acc 2 t 7 dsm 2.94602e-12 dsm_est 3.70208e-11 nsteps 1921 + h 0.000390625 rk_type 0 order 4 acc 2 t 7.5 dsm 1.82124e-11 dsm_est 5.47248e-13 nsteps 1921 + h 0.000390625 rk_type 0 order 4 acc 2 t 8 dsm 1.77421e-10 dsm_est 4.99362e-13 nsteps 1921 + h 0.000390625 rk_type 0 order 4 acc 2 t 8.5 dsm 2.81466e-12 dsm_est 6.74349e-15 nsteps 1922 + h 0.000390625 rk_type 0 order 4 acc 2 t 9 dsm 2.496e-11 dsm_est 1.91764e-15 nsteps 1922 + h 0.000390625 rk_type 0 order 4 acc 2 t 9.5 dsm 1.2967e-11 dsm_est 1.53261e-15 nsteps 1922 + h 0.000390625 rk_type 0 order 4 acc 2 t 10 dsm 4.44606e-12 dsm_est 7.50123e-16 nsteps 1922 diff --git a/test/unit_tests/arkode/CXX_serial/ark_test_accumerror_brusselator_20_3_1.out b/test/unit_tests/arkode/CXX_serial/ark_test_accumerror_brusselator_20_3_1.out new file mode 100644 index 0000000000..9ae57cd52a --- /dev/null +++ b/test/unit_tests/arkode/CXX_serial/ark_test_accumerror_brusselator_20_3_1.out @@ -0,0 +1,129 @@ + +Accumulated error estimation test (stiff Brusselator ODE problem): + time domain: (0,10] + partition size = 20 + initial conditions: u0 = 1.2, v0 = 3.1, w0 = 3 + problem parameters: a = 0, b = 0, ep = 0.0004 + ERK solver, order = 3 + +Adaptive-step runs: + rtol 0.01 rk_type 1 order 3 acc 0 t 0.5 dsm 0.00199866 dsm_est 0.00993779 nsteps 492 + rtol 0.01 rk_type 1 order 3 acc 0 t 1 dsm 0.00148824 dsm_est 0.00998004 nsteps 473 + rtol 0.01 rk_type 1 order 3 acc 0 t 1.5 dsm 0.00330184 dsm_est 0.00995476 nsteps 459 + rtol 0.01 rk_type 1 order 3 acc 0 t 2 dsm 0.000346469 dsm_est 0.00994631 nsteps 450 + rtol 0.01 rk_type 1 order 3 acc 0 t 2.5 dsm 0.0103541 dsm_est 0.00997759 nsteps 430 + rtol 0.01 rk_type 1 order 3 acc 0 t 3 dsm 0.0108871 dsm_est 0.00988341 nsteps 447 + rtol 0.01 rk_type 1 order 3 acc 0 t 3.5 dsm 0.00245302 dsm_est 0.00996656 nsteps 465 + rtol 0.01 rk_type 1 order 3 acc 0 t 4 dsm 0.00613073 dsm_est 0.00995474 nsteps 464 + rtol 0.01 rk_type 1 order 3 acc 0 t 4.5 dsm 0.00368671 dsm_est 0.00994184 nsteps 464 + rtol 0.01 rk_type 1 order 3 acc 0 t 5 dsm 0.000382639 dsm_est 0.0099621 nsteps 466 + rtol 0.01 rk_type 1 order 3 acc 0 t 5.5 dsm 0.00138001 dsm_est 0.00996202 nsteps 443 + rtol 0.01 rk_type 1 order 3 acc 0 t 6 dsm 0.00204504 dsm_est 0.00995126 nsteps 463 + rtol 0.01 rk_type 1 order 3 acc 0 t 6.5 dsm 0.00544154 dsm_est 0.00991159 nsteps 465 + rtol 0.01 rk_type 1 order 3 acc 0 t 7 dsm 0.00167909 dsm_est 0.00996267 nsteps 459 + rtol 0.01 rk_type 1 order 3 acc 0 t 7.5 dsm 0.00762228 dsm_est 0.0099702 nsteps 464 + rtol 0.01 rk_type 1 order 3 acc 0 t 8 dsm 0.00815849 dsm_est 0.00996685 nsteps 463 + rtol 0.01 rk_type 1 order 3 acc 0 t 8.5 dsm 0.00479833 dsm_est 0.00996162 nsteps 463 + rtol 0.01 rk_type 1 order 3 acc 0 t 9 dsm 0.00530688 dsm_est 0.00991151 nsteps 460 + rtol 0.01 rk_type 1 order 3 acc 0 t 9.5 dsm 0.00453492 dsm_est 0.00996905 nsteps 461 + rtol 0.01 rk_type 1 order 3 acc 0 t 10 dsm 0.000530102 dsm_est 0.00998737 nsteps 461 + rtol 0.01 rk_type 1 order 3 acc 1 t 0.5 dsm 0.00199866 dsm_est 0.00426439 nsteps 492 + rtol 0.01 rk_type 1 order 3 acc 1 t 1 dsm 0.00148824 dsm_est 0.00401684 nsteps 473 + rtol 0.01 rk_type 1 order 3 acc 1 t 1.5 dsm 0.00330184 dsm_est 0.00429906 nsteps 459 + rtol 0.01 rk_type 1 order 3 acc 1 t 2 dsm 0.000346469 dsm_est 0.00422221 nsteps 450 + rtol 0.01 rk_type 1 order 3 acc 1 t 2.5 dsm 0.0103541 dsm_est 0.0039254 nsteps 430 + rtol 0.01 rk_type 1 order 3 acc 1 t 3 dsm 0.0108871 dsm_est 0.00418766 nsteps 447 + rtol 0.01 rk_type 1 order 3 acc 1 t 3.5 dsm 0.00245302 dsm_est 0.00418645 nsteps 465 + rtol 0.01 rk_type 1 order 3 acc 1 t 4 dsm 0.00613073 dsm_est 0.00418211 nsteps 464 + rtol 0.01 rk_type 1 order 3 acc 1 t 4.5 dsm 0.00368671 dsm_est 0.00418783 nsteps 464 + rtol 0.01 rk_type 1 order 3 acc 1 t 5 dsm 0.000382639 dsm_est 0.00393723 nsteps 466 + rtol 0.01 rk_type 1 order 3 acc 1 t 5.5 dsm 0.00138001 dsm_est 0.00421341 nsteps 443 + rtol 0.01 rk_type 1 order 3 acc 1 t 6 dsm 0.00204504 dsm_est 0.00419418 nsteps 463 + rtol 0.01 rk_type 1 order 3 acc 1 t 6.5 dsm 0.00544154 dsm_est 0.00421996 nsteps 465 + rtol 0.01 rk_type 1 order 3 acc 1 t 7 dsm 0.00167909 dsm_est 0.00415345 nsteps 459 + rtol 0.01 rk_type 1 order 3 acc 1 t 7.5 dsm 0.00762228 dsm_est 0.00386309 nsteps 464 + rtol 0.01 rk_type 1 order 3 acc 1 t 8 dsm 0.00815849 dsm_est 0.0039821 nsteps 463 + rtol 0.01 rk_type 1 order 3 acc 1 t 8.5 dsm 0.00479833 dsm_est 0.00427435 nsteps 463 + rtol 0.01 rk_type 1 order 3 acc 1 t 9 dsm 0.00530688 dsm_est 0.004236 nsteps 460 + rtol 0.01 rk_type 1 order 3 acc 1 t 9.5 dsm 0.00453492 dsm_est 0.00415846 nsteps 461 + rtol 0.01 rk_type 1 order 3 acc 1 t 10 dsm 0.000530102 dsm_est 0.00414409 nsteps 461 + rtol 0.0001 rk_type 1 order 3 acc 0 t 0.5 dsm 4.52215e-05 dsm_est 9.69104e-05 nsteps 501 + rtol 0.0001 rk_type 1 order 3 acc 0 t 1 dsm 1.81631e-05 dsm_est 9.49781e-05 nsteps 474 + rtol 0.0001 rk_type 1 order 3 acc 0 t 1.5 dsm 2.77186e-05 dsm_est 9.49662e-05 nsteps 474 + rtol 0.0001 rk_type 1 order 3 acc 0 t 2 dsm 1.52803e-05 dsm_est 9.4909e-05 nsteps 470 + rtol 0.0001 rk_type 1 order 3 acc 0 t 2.5 dsm 4.78098e-05 dsm_est 9.49489e-05 nsteps 464 + rtol 0.0001 rk_type 1 order 3 acc 0 t 3 dsm 2.25476e-05 dsm_est 9.47509e-05 nsteps 465 + rtol 0.0001 rk_type 1 order 3 acc 0 t 3.5 dsm 5.07755e-05 dsm_est 9.47129e-05 nsteps 474 + rtol 0.0001 rk_type 1 order 3 acc 0 t 4 dsm 2.29469e-05 dsm_est 9.49709e-05 nsteps 474 + rtol 0.0001 rk_type 1 order 3 acc 0 t 4.5 dsm 3.88359e-05 dsm_est 9.46293e-05 nsteps 470 + rtol 0.0001 rk_type 1 order 3 acc 0 t 5 dsm 1.51443e-05 dsm_est 9.49444e-05 nsteps 469 + rtol 0.0001 rk_type 1 order 3 acc 0 t 5.5 dsm 1.12906e-05 dsm_est 9.45516e-05 nsteps 470 + rtol 0.0001 rk_type 1 order 3 acc 0 t 6 dsm 2.05734e-05 dsm_est 9.49206e-05 nsteps 474 + rtol 0.0001 rk_type 1 order 3 acc 0 t 6.5 dsm 2.51686e-05 dsm_est 9.49703e-05 nsteps 481 + rtol 0.0001 rk_type 1 order 3 acc 0 t 7 dsm 6.45125e-05 dsm_est 9.93155e-05 nsteps 481 + rtol 0.0001 rk_type 1 order 3 acc 0 t 7.5 dsm 6.30239e-05 dsm_est 9.4983e-05 nsteps 475 + rtol 0.0001 rk_type 1 order 3 acc 0 t 8 dsm 2.85855e-05 dsm_est 9.44898e-05 nsteps 478 + rtol 0.0001 rk_type 1 order 3 acc 0 t 8.5 dsm 4.15619e-05 dsm_est 9.47874e-05 nsteps 480 + rtol 0.0001 rk_type 1 order 3 acc 0 t 9 dsm 9.3894e-06 dsm_est 9.91602e-05 nsteps 475 + rtol 0.0001 rk_type 1 order 3 acc 0 t 9.5 dsm 1.95141e-05 dsm_est 9.49246e-05 nsteps 482 + rtol 0.0001 rk_type 1 order 3 acc 0 t 10 dsm 2.83938e-05 dsm_est 9.5044e-05 nsteps 479 + rtol 0.0001 rk_type 1 order 3 acc 1 t 0.5 dsm 4.52215e-05 dsm_est 4.08107e-05 nsteps 501 + rtol 0.0001 rk_type 1 order 3 acc 1 t 1 dsm 1.81631e-05 dsm_est 4.12007e-05 nsteps 474 + rtol 0.0001 rk_type 1 order 3 acc 1 t 1.5 dsm 2.77186e-05 dsm_est 3.92848e-05 nsteps 474 + rtol 0.0001 rk_type 1 order 3 acc 1 t 2 dsm 1.52803e-05 dsm_est 4.11758e-05 nsteps 470 + rtol 0.0001 rk_type 1 order 3 acc 1 t 2.5 dsm 4.78098e-05 dsm_est 4.06774e-05 nsteps 464 + rtol 0.0001 rk_type 1 order 3 acc 1 t 3 dsm 2.25476e-05 dsm_est 4.05186e-05 nsteps 465 + rtol 0.0001 rk_type 1 order 3 acc 1 t 3.5 dsm 5.07755e-05 dsm_est 3.94363e-05 nsteps 474 + rtol 0.0001 rk_type 1 order 3 acc 1 t 4 dsm 2.29469e-05 dsm_est 4.0612e-05 nsteps 474 + rtol 0.0001 rk_type 1 order 3 acc 1 t 4.5 dsm 3.88359e-05 dsm_est 4.04377e-05 nsteps 470 + rtol 0.0001 rk_type 1 order 3 acc 1 t 5 dsm 1.51443e-05 dsm_est 4.10883e-05 nsteps 469 + rtol 0.0001 rk_type 1 order 3 acc 1 t 5.5 dsm 1.12906e-05 dsm_est 4.03674e-05 nsteps 470 + rtol 0.0001 rk_type 1 order 3 acc 1 t 6 dsm 2.05734e-05 dsm_est 3.92226e-05 nsteps 474 + rtol 0.0001 rk_type 1 order 3 acc 1 t 6.5 dsm 2.51686e-05 dsm_est 4.05458e-05 nsteps 481 + rtol 0.0001 rk_type 1 order 3 acc 1 t 7 dsm 6.45125e-05 dsm_est 4.1002e-05 nsteps 481 + rtol 0.0001 rk_type 1 order 3 acc 1 t 7.5 dsm 6.30239e-05 dsm_est 3.79447e-05 nsteps 475 + rtol 0.0001 rk_type 1 order 3 acc 1 t 8 dsm 2.85855e-05 dsm_est 4.09141e-05 nsteps 478 + rtol 0.0001 rk_type 1 order 3 acc 1 t 8.5 dsm 4.15619e-05 dsm_est 4.07839e-05 nsteps 480 + rtol 0.0001 rk_type 1 order 3 acc 1 t 9 dsm 9.3894e-06 dsm_est 4.10757e-05 nsteps 475 + rtol 0.0001 rk_type 1 order 3 acc 1 t 9.5 dsm 1.95141e-05 dsm_est 3.99021e-05 nsteps 482 + rtol 0.0001 rk_type 1 order 3 acc 1 t 10 dsm 2.83938e-05 dsm_est 4.08542e-05 nsteps 479 + rtol 1e-06 rk_type 1 order 3 acc 0 t 0.5 dsm 6.49367e-08 dsm_est 9.89086e-07 nsteps 550 + rtol 1e-06 rk_type 1 order 3 acc 0 t 1 dsm 5.83524e-07 dsm_est 9.4678e-07 nsteps 488 + rtol 1e-06 rk_type 1 order 3 acc 0 t 1.5 dsm 2.01442e-08 dsm_est 9.47358e-07 nsteps 491 + rtol 1e-06 rk_type 1 order 3 acc 0 t 2 dsm 6.89174e-08 dsm_est 9.48104e-07 nsteps 485 + rtol 1e-06 rk_type 1 order 3 acc 0 t 2.5 dsm 3.25214e-07 dsm_est 9.49113e-07 nsteps 463 + rtol 1e-06 rk_type 1 order 3 acc 0 t 3 dsm 3.48745e-07 dsm_est 9.48334e-07 nsteps 481 + rtol 1e-06 rk_type 1 order 3 acc 0 t 3.5 dsm 1.27971e-06 dsm_est 9.46641e-07 nsteps 484 + rtol 1e-06 rk_type 1 order 3 acc 0 t 4 dsm 5.22124e-07 dsm_est 9.49243e-07 nsteps 485 + rtol 1e-06 rk_type 1 order 3 acc 0 t 4.5 dsm 6.25795e-07 dsm_est 9.48421e-07 nsteps 486 + rtol 1e-06 rk_type 1 order 3 acc 0 t 5 dsm 5.82624e-07 dsm_est 9.48091e-07 nsteps 487 + rtol 1e-06 rk_type 1 order 3 acc 0 t 5.5 dsm 5.29296e-07 dsm_est 9.82269e-07 nsteps 483 + rtol 1e-06 rk_type 1 order 3 acc 0 t 6 dsm 3.47222e-07 dsm_est 9.87002e-07 nsteps 484 + rtol 1e-06 rk_type 1 order 3 acc 0 t 6.5 dsm 8.05504e-07 dsm_est 9.48638e-07 nsteps 477 + rtol 1e-06 rk_type 1 order 3 acc 0 t 7 dsm 4.05624e-08 dsm_est 9.61095e-07 nsteps 487 + rtol 1e-06 rk_type 1 order 3 acc 0 t 7.5 dsm 7.28832e-08 dsm_est 9.4602e-07 nsteps 487 + rtol 1e-06 rk_type 1 order 3 acc 0 t 8 dsm 9.01356e-07 dsm_est 9.48084e-07 nsteps 485 + rtol 1e-06 rk_type 1 order 3 acc 0 t 8.5 dsm 9.82212e-07 dsm_est 9.4573e-07 nsteps 489 + rtol 1e-06 rk_type 1 order 3 acc 0 t 9 dsm 2.03978e-07 dsm_est 9.47478e-07 nsteps 468 + rtol 1e-06 rk_type 1 order 3 acc 0 t 9.5 dsm 2.77163e-07 dsm_est 9.49943e-07 nsteps 475 + rtol 1e-06 rk_type 1 order 3 acc 0 t 10 dsm 4.2482e-07 dsm_est 9.47165e-07 nsteps 476 + rtol 1e-06 rk_type 1 order 3 acc 1 t 0.5 dsm 6.49367e-08 dsm_est 3.45481e-07 nsteps 550 + rtol 1e-06 rk_type 1 order 3 acc 1 t 1 dsm 5.83524e-07 dsm_est 3.92843e-07 nsteps 488 + rtol 1e-06 rk_type 1 order 3 acc 1 t 1.5 dsm 2.01442e-08 dsm_est 3.15167e-07 nsteps 491 + rtol 1e-06 rk_type 1 order 3 acc 1 t 2 dsm 6.89174e-08 dsm_est 3.94168e-07 nsteps 485 + rtol 1e-06 rk_type 1 order 3 acc 1 t 2.5 dsm 3.25214e-07 dsm_est 4.0852e-07 nsteps 463 + rtol 1e-06 rk_type 1 order 3 acc 1 t 3 dsm 3.48745e-07 dsm_est 4.02669e-07 nsteps 481 + rtol 1e-06 rk_type 1 order 3 acc 1 t 3.5 dsm 1.27971e-06 dsm_est 4.10995e-07 nsteps 484 + rtol 1e-06 rk_type 1 order 3 acc 1 t 4 dsm 5.22124e-07 dsm_est 4.06335e-07 nsteps 485 + rtol 1e-06 rk_type 1 order 3 acc 1 t 4.5 dsm 6.25795e-07 dsm_est 3.93901e-07 nsteps 486 + rtol 1e-06 rk_type 1 order 3 acc 1 t 5 dsm 5.82624e-07 dsm_est 4.02844e-07 nsteps 487 + rtol 1e-06 rk_type 1 order 3 acc 1 t 5.5 dsm 5.29296e-07 dsm_est 4.12265e-07 nsteps 483 + rtol 1e-06 rk_type 1 order 3 acc 1 t 6 dsm 3.47222e-07 dsm_est 4.13091e-07 nsteps 484 + rtol 1e-06 rk_type 1 order 3 acc 1 t 6.5 dsm 8.05504e-07 dsm_est 4.05024e-07 nsteps 477 + rtol 1e-06 rk_type 1 order 3 acc 1 t 7 dsm 4.05624e-08 dsm_est 4.06655e-07 nsteps 487 + rtol 1e-06 rk_type 1 order 3 acc 1 t 7.5 dsm 7.28832e-08 dsm_est 4.09645e-07 nsteps 487 + rtol 1e-06 rk_type 1 order 3 acc 1 t 8 dsm 9.01356e-07 dsm_est 4.07695e-07 nsteps 485 + rtol 1e-06 rk_type 1 order 3 acc 1 t 8.5 dsm 9.82212e-07 dsm_est 3.86761e-07 nsteps 489 + rtol 1e-06 rk_type 1 order 3 acc 1 t 9 dsm 2.03978e-07 dsm_est 4.05711e-07 nsteps 468 + rtol 1e-06 rk_type 1 order 3 acc 1 t 9.5 dsm 2.77163e-07 dsm_est 4.05851e-07 nsteps 475 + rtol 1e-06 rk_type 1 order 3 acc 1 t 10 dsm 4.2482e-07 dsm_est 3.92237e-07 nsteps 476 diff --git a/test/unit_tests/arkode/CXX_serial/ark_test_accumerror_brusselator_20_5_0.out b/test/unit_tests/arkode/CXX_serial/ark_test_accumerror_brusselator_20_5_0.out new file mode 100644 index 0000000000..bca0f62a7b --- /dev/null +++ b/test/unit_tests/arkode/CXX_serial/ark_test_accumerror_brusselator_20_5_0.out @@ -0,0 +1,129 @@ + +Accumulated error estimation test (stiff Brusselator ODE problem): + time domain: (0,10] + partition size = 20 + initial conditions: u0 = 1.2, v0 = 3.1, w0 = 3 + problem parameters: a = 0, b = 0, ep = 0.0004 + DIRK solver, order = 5 + +Adaptive-step runs: + rtol 0.01 rk_type 0 order 5 acc 0 t 0.5 dsm 7.48644e-05 dsm_est 3.4373e-05 nsteps 9 + rtol 0.01 rk_type 0 order 5 acc 0 t 1 dsm 0.000110257 dsm_est 2.23308e-06 nsteps 5 + rtol 0.01 rk_type 0 order 5 acc 0 t 1.5 dsm 0.00132404 dsm_est 2.08137e-06 nsteps 6 + rtol 0.01 rk_type 0 order 5 acc 0 t 2 dsm 0.00110273 dsm_est 6.3665e-07 nsteps 6 + rtol 0.01 rk_type 0 order 5 acc 0 t 2.5 dsm 6.10485e-05 dsm_est 1.85399e-07 nsteps 6 + rtol 0.01 rk_type 0 order 5 acc 0 t 3 dsm 0.000275174 dsm_est 6.46876e-07 nsteps 6 + rtol 0.01 rk_type 0 order 5 acc 0 t 3.5 dsm 0.00032811 dsm_est 1.68426e-06 nsteps 6 + rtol 0.01 rk_type 0 order 5 acc 0 t 4 dsm 7.35974e-05 dsm_est 4.88814e-07 nsteps 6 + rtol 0.01 rk_type 0 order 5 acc 0 t 4.5 dsm 0.000394423 dsm_est 1.74045e-06 nsteps 6 + rtol 0.01 rk_type 0 order 5 acc 0 t 5 dsm 4.44693e-05 dsm_est 4.77027e-07 nsteps 6 + rtol 0.01 rk_type 0 order 5 acc 0 t 5.5 dsm 0.000153383 dsm_est 6.89334e-07 nsteps 5 + rtol 0.01 rk_type 0 order 5 acc 0 t 6 dsm 0.00039377 dsm_est 3.77896e-06 nsteps 6 + rtol 0.01 rk_type 0 order 5 acc 0 t 6.5 dsm 0.000506258 dsm_est 1.01998e-06 nsteps 6 + rtol 0.01 rk_type 0 order 5 acc 0 t 7 dsm 0.00148699 dsm_est 4.63864e-05 nsteps 12 + rtol 0.01 rk_type 0 order 5 acc 0 t 7.5 dsm 0.000435975 dsm_est 0.000225656 nsteps 4 + rtol 0.01 rk_type 0 order 5 acc 0 t 8 dsm 0.000824606 dsm_est 1.36787e-05 nsteps 7 + rtol 0.01 rk_type 0 order 5 acc 0 t 8.5 dsm 0.00100819 dsm_est 1.09309e-05 nsteps 6 + rtol 0.01 rk_type 0 order 5 acc 0 t 9 dsm 0.00058073 dsm_est 4.52926e-06 nsteps 6 + rtol 0.01 rk_type 0 order 5 acc 0 t 9.5 dsm 6.70214e-05 dsm_est 2.50118e-06 nsteps 6 + rtol 0.01 rk_type 0 order 5 acc 0 t 10 dsm 0.000490488 dsm_est 4.64334e-06 nsteps 6 + rtol 0.01 rk_type 0 order 5 acc 1 t 0.5 dsm 7.48644e-05 dsm_est 6.06577e-06 nsteps 9 + rtol 0.01 rk_type 0 order 5 acc 1 t 1 dsm 0.000110257 dsm_est 4.46624e-07 nsteps 5 + rtol 0.01 rk_type 0 order 5 acc 1 t 1.5 dsm 0.00132404 dsm_est 3.96295e-07 nsteps 6 + rtol 0.01 rk_type 0 order 5 acc 1 t 2 dsm 0.00110273 dsm_est 1.36233e-07 nsteps 6 + rtol 0.01 rk_type 0 order 5 acc 1 t 2.5 dsm 6.10485e-05 dsm_est 5.46756e-08 nsteps 6 + rtol 0.01 rk_type 0 order 5 acc 1 t 3 dsm 0.000275174 dsm_est 1.12723e-07 nsteps 6 + rtol 0.01 rk_type 0 order 5 acc 1 t 3.5 dsm 0.00032811 dsm_est 2.82543e-07 nsteps 6 + rtol 0.01 rk_type 0 order 5 acc 1 t 4 dsm 7.35974e-05 dsm_est 8.23161e-08 nsteps 6 + rtol 0.01 rk_type 0 order 5 acc 1 t 4.5 dsm 0.000394423 dsm_est 2.90774e-07 nsteps 6 + rtol 0.01 rk_type 0 order 5 acc 1 t 5 dsm 4.44693e-05 dsm_est 8.19327e-08 nsteps 6 + rtol 0.01 rk_type 0 order 5 acc 1 t 5.5 dsm 0.000153383 dsm_est 1.38044e-07 nsteps 5 + rtol 0.01 rk_type 0 order 5 acc 1 t 6 dsm 0.00039377 dsm_est 7.71683e-07 nsteps 6 + rtol 0.01 rk_type 0 order 5 acc 1 t 6.5 dsm 0.000506258 dsm_est 2.97917e-07 nsteps 6 + rtol 0.01 rk_type 0 order 5 acc 1 t 7 dsm 0.00148699 dsm_est 6.06974e-06 nsteps 12 + rtol 0.01 rk_type 0 order 5 acc 1 t 7.5 dsm 0.000435975 dsm_est 5.85078e-05 nsteps 4 + rtol 0.01 rk_type 0 order 5 acc 1 t 8 dsm 0.000824606 dsm_est 3.65766e-06 nsteps 7 + rtol 0.01 rk_type 0 order 5 acc 1 t 8.5 dsm 0.00100819 dsm_est 1.8302e-06 nsteps 6 + rtol 0.01 rk_type 0 order 5 acc 1 t 9 dsm 0.00058073 dsm_est 8.22737e-07 nsteps 6 + rtol 0.01 rk_type 0 order 5 acc 1 t 9.5 dsm 6.70214e-05 dsm_est 4.25553e-07 nsteps 6 + rtol 0.01 rk_type 0 order 5 acc 1 t 10 dsm 0.000490488 dsm_est 7.76906e-07 nsteps 6 + rtol 0.0001 rk_type 0 order 5 acc 0 t 0.5 dsm 1.9124e-05 dsm_est 4.10549e-06 nsteps 13 + rtol 0.0001 rk_type 0 order 5 acc 0 t 1 dsm 1.46639e-06 dsm_est 2.99051e-08 nsteps 3 + rtol 0.0001 rk_type 0 order 5 acc 0 t 1.5 dsm 1.49779e-06 dsm_est 2.8794e-08 nsteps 3 + rtol 0.0001 rk_type 0 order 5 acc 0 t 2 dsm 2.48711e-06 dsm_est 5.23997e-08 nsteps 3 + rtol 0.0001 rk_type 0 order 5 acc 0 t 2.5 dsm 8.68487e-07 dsm_est 8.11031e-09 nsteps 3 + rtol 0.0001 rk_type 0 order 5 acc 0 t 3 dsm 4.6854e-06 dsm_est 3.54429e-08 nsteps 4 + rtol 0.0001 rk_type 0 order 5 acc 0 t 3.5 dsm 4.86491e-06 dsm_est 1.27286e-08 nsteps 4 + rtol 0.0001 rk_type 0 order 5 acc 0 t 4 dsm 9.38226e-06 dsm_est 6.18062e-10 nsteps 3 + rtol 0.0001 rk_type 0 order 5 acc 0 t 4.5 dsm 3.64804e-06 dsm_est 5.92484e-10 nsteps 3 + rtol 0.0001 rk_type 0 order 5 acc 0 t 5 dsm 1.20837e-06 dsm_est 1.11283e-08 nsteps 3 + rtol 0.0001 rk_type 0 order 5 acc 0 t 5.5 dsm 1.96373e-05 dsm_est 1.16786e-08 nsteps 3 + rtol 0.0001 rk_type 0 order 5 acc 0 t 6 dsm 6.78601e-06 dsm_est 5.56249e-08 nsteps 4 + rtol 0.0001 rk_type 0 order 5 acc 0 t 6.5 dsm 3.28653e-05 dsm_est 5.49255e-08 nsteps 8 + rtol 0.0001 rk_type 0 order 5 acc 0 t 7 dsm 1.0851e-05 dsm_est 2.95421e-06 nsteps 17 + rtol 0.0001 rk_type 0 order 5 acc 0 t 7.5 dsm 8.11463e-06 dsm_est 7.59043e-08 nsteps 13 + rtol 0.0001 rk_type 0 order 5 acc 0 t 8 dsm 1.12113e-05 dsm_est 6.59216e-08 nsteps 7 + rtol 0.0001 rk_type 0 order 5 acc 0 t 8.5 dsm 7.59151e-06 dsm_est 8.65901e-08 nsteps 5 + rtol 0.0001 rk_type 0 order 5 acc 0 t 9 dsm 1.10466e-05 dsm_est 2.02617e-08 nsteps 4 + rtol 0.0001 rk_type 0 order 5 acc 0 t 9.5 dsm 1.12334e-05 dsm_est 1.10517e-07 nsteps 4 + rtol 0.0001 rk_type 0 order 5 acc 0 t 10 dsm 9.05222e-07 dsm_est 1.64841e-08 nsteps 4 + rtol 0.0001 rk_type 0 order 5 acc 1 t 0.5 dsm 1.9124e-05 dsm_est 4.39976e-07 nsteps 13 + rtol 0.0001 rk_type 0 order 5 acc 1 t 1 dsm 1.46639e-06 dsm_est 9.99964e-09 nsteps 3 + rtol 0.0001 rk_type 0 order 5 acc 1 t 1.5 dsm 1.49779e-06 dsm_est 9.65784e-09 nsteps 3 + rtol 0.0001 rk_type 0 order 5 acc 1 t 2 dsm 2.48711e-06 dsm_est 1.78583e-08 nsteps 3 + rtol 0.0001 rk_type 0 order 5 acc 1 t 2.5 dsm 8.68487e-07 dsm_est 3.53288e-09 nsteps 3 + rtol 0.0001 rk_type 0 order 5 acc 1 t 3 dsm 4.6854e-06 dsm_est 8.97419e-09 nsteps 4 + rtol 0.0001 rk_type 0 order 5 acc 1 t 3.5 dsm 4.86491e-06 dsm_est 3.82982e-09 nsteps 4 + rtol 0.0001 rk_type 0 order 5 acc 1 t 4 dsm 9.38226e-06 dsm_est 3.82569e-10 nsteps 3 + rtol 0.0001 rk_type 0 order 5 acc 1 t 4.5 dsm 3.64804e-06 dsm_est 2.71444e-10 nsteps 3 + rtol 0.0001 rk_type 0 order 5 acc 1 t 5 dsm 1.20837e-06 dsm_est 3.93773e-09 nsteps 3 + rtol 0.0001 rk_type 0 order 5 acc 1 t 5.5 dsm 1.96373e-05 dsm_est 5.04674e-09 nsteps 3 + rtol 0.0001 rk_type 0 order 5 acc 1 t 6 dsm 6.78601e-06 dsm_est 2.03601e-08 nsteps 4 + rtol 0.0001 rk_type 0 order 5 acc 1 t 6.5 dsm 3.28653e-05 dsm_est 1.42284e-08 nsteps 8 + rtol 0.0001 rk_type 0 order 5 acc 1 t 7 dsm 1.0851e-05 dsm_est 2.55057e-07 nsteps 17 + rtol 0.0001 rk_type 0 order 5 acc 1 t 7.5 dsm 8.11463e-06 dsm_est 1.57107e-08 nsteps 13 + rtol 0.0001 rk_type 0 order 5 acc 1 t 8 dsm 1.12113e-05 dsm_est 9.4603e-09 nsteps 7 + rtol 0.0001 rk_type 0 order 5 acc 1 t 8.5 dsm 7.59151e-06 dsm_est 1.73402e-08 nsteps 5 + rtol 0.0001 rk_type 0 order 5 acc 1 t 9 dsm 1.10466e-05 dsm_est 7.67057e-09 nsteps 4 + rtol 0.0001 rk_type 0 order 5 acc 1 t 9.5 dsm 1.12334e-05 dsm_est 3.41962e-08 nsteps 4 + rtol 0.0001 rk_type 0 order 5 acc 1 t 10 dsm 9.05222e-07 dsm_est 8.2015e-09 nsteps 4 + rtol 1e-06 rk_type 0 order 5 acc 0 t 0.5 dsm 1.88136e-07 dsm_est 1.26411e-07 nsteps 20 + rtol 1e-06 rk_type 0 order 5 acc 0 t 1 dsm 3.6815e-08 dsm_est 2.79712e-09 nsteps 5 + rtol 1e-06 rk_type 0 order 5 acc 0 t 1.5 dsm 3.46973e-08 dsm_est 3.51635e-09 nsteps 7 + rtol 1e-06 rk_type 0 order 5 acc 0 t 2 dsm 2.15722e-07 dsm_est 6.11647e-09 nsteps 7 + rtol 1e-06 rk_type 0 order 5 acc 0 t 2.5 dsm 9.55646e-08 dsm_est 1.88588e-09 nsteps 7 + rtol 1e-06 rk_type 0 order 5 acc 0 t 3 dsm 1.61192e-07 dsm_est 1.2608e-08 nsteps 5 + rtol 1e-06 rk_type 0 order 5 acc 0 t 3.5 dsm 4.89781e-08 dsm_est 3.86937e-09 nsteps 5 + rtol 1e-06 rk_type 0 order 5 acc 0 t 4 dsm 2.89671e-09 dsm_est 1.89611e-10 nsteps 5 + rtol 1e-06 rk_type 0 order 5 acc 0 t 4.5 dsm 1.33856e-07 dsm_est 1.34787e-10 nsteps 4 + rtol 1e-06 rk_type 0 order 5 acc 0 t 5 dsm 1.14768e-07 dsm_est 3.89832e-09 nsteps 5 + rtol 1e-06 rk_type 0 order 5 acc 0 t 5.5 dsm 3.35877e-07 dsm_est 5.30354e-09 nsteps 7 + rtol 1e-06 rk_type 0 order 5 acc 0 t 6 dsm 3.66079e-07 dsm_est 3.68188e-09 nsteps 9 + rtol 1e-06 rk_type 0 order 5 acc 0 t 6.5 dsm 1.18284e-06 dsm_est 5.36543e-09 nsteps 13 + rtol 1e-06 rk_type 0 order 5 acc 0 t 7 dsm 6.15151e-07 dsm_est 1.3137e-07 nsteps 32 + rtol 1e-06 rk_type 0 order 5 acc 0 t 7.5 dsm 7.6586e-08 dsm_est 5.37386e-09 nsteps 17 + rtol 1e-06 rk_type 0 order 5 acc 0 t 8 dsm 4.14322e-07 dsm_est 7.83969e-10 nsteps 13 + rtol 1e-06 rk_type 0 order 5 acc 0 t 8.5 dsm 2.50606e-07 dsm_est 1.87037e-08 nsteps 9 + rtol 1e-06 rk_type 0 order 5 acc 0 t 9 dsm 1.33343e-07 dsm_est 8.70204e-09 nsteps 7 + rtol 1e-06 rk_type 0 order 5 acc 0 t 9.5 dsm 1.44237e-07 dsm_est 1.59014e-08 nsteps 6 + rtol 1e-06 rk_type 0 order 5 acc 0 t 10 dsm 1.34853e-07 dsm_est 2.74315e-08 nsteps 6 + rtol 1e-06 rk_type 0 order 5 acc 1 t 0.5 dsm 1.88136e-07 dsm_est 1.55378e-08 nsteps 20 + rtol 1e-06 rk_type 0 order 5 acc 1 t 1 dsm 3.6815e-08 dsm_est 5.70344e-10 nsteps 5 + rtol 1e-06 rk_type 0 order 5 acc 1 t 1.5 dsm 3.46973e-08 dsm_est 5.04993e-10 nsteps 7 + rtol 1e-06 rk_type 0 order 5 acc 1 t 2 dsm 2.15722e-07 dsm_est 8.8739e-10 nsteps 7 + rtol 1e-06 rk_type 0 order 5 acc 1 t 2.5 dsm 9.55646e-08 dsm_est 2.79785e-10 nsteps 7 + rtol 1e-06 rk_type 0 order 5 acc 1 t 3 dsm 1.61192e-07 dsm_est 2.84751e-09 nsteps 5 + rtol 1e-06 rk_type 0 order 5 acc 1 t 3.5 dsm 4.89781e-08 dsm_est 1.08999e-09 nsteps 5 + rtol 1e-06 rk_type 0 order 5 acc 1 t 4 dsm 2.89671e-09 dsm_est 4.1169e-11 nsteps 5 + rtol 1e-06 rk_type 0 order 5 acc 1 t 4.5 dsm 1.33856e-07 dsm_est 3.63099e-11 nsteps 4 + rtol 1e-06 rk_type 0 order 5 acc 1 t 5 dsm 1.14768e-07 dsm_est 7.94799e-10 nsteps 5 + rtol 1e-06 rk_type 0 order 5 acc 1 t 5.5 dsm 3.35877e-07 dsm_est 7.7014e-10 nsteps 7 + rtol 1e-06 rk_type 0 order 5 acc 1 t 6 dsm 3.66079e-07 dsm_est 5.04916e-10 nsteps 9 + rtol 1e-06 rk_type 0 order 5 acc 1 t 6.5 dsm 1.18284e-06 dsm_est 1.10349e-09 nsteps 13 + rtol 1e-06 rk_type 0 order 5 acc 1 t 7 dsm 6.15151e-07 dsm_est 1.15991e-08 nsteps 32 + rtol 1e-06 rk_type 0 order 5 acc 1 t 7.5 dsm 7.6586e-08 dsm_est 6.18109e-10 nsteps 17 + rtol 1e-06 rk_type 0 order 5 acc 1 t 8 dsm 4.14322e-07 dsm_est 1.39091e-10 nsteps 13 + rtol 1e-06 rk_type 0 order 5 acc 1 t 8.5 dsm 2.50606e-07 dsm_est 2.08704e-09 nsteps 9 + rtol 1e-06 rk_type 0 order 5 acc 1 t 9 dsm 1.33343e-07 dsm_est 1.74354e-09 nsteps 7 + rtol 1e-06 rk_type 0 order 5 acc 1 t 9.5 dsm 1.44237e-07 dsm_est 5.67526e-09 nsteps 6 + rtol 1e-06 rk_type 0 order 5 acc 1 t 10 dsm 1.34853e-07 dsm_est 5.58746e-09 nsteps 6 diff --git a/test/unit_tests/arkode/CXX_serial/ark_test_accumerror_kpr.cpp b/test/unit_tests/arkode/CXX_serial/ark_test_accumerror_kpr.cpp new file mode 100644 index 0000000000..fe7c9b4c0e --- /dev/null +++ b/test/unit_tests/arkode/CXX_serial/ark_test_accumerror_kpr.cpp @@ -0,0 +1,721 @@ +/* ---------------------------------------------------------------- + * Programmer(s): Daniel R. Reynolds @ SMU + * ---------------------------------------------------------------- + * SUNDIALS Copyright Start + * Copyright (c) 2002-2024, 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 + * ---------------------------------------------------------------- + * Routine to test the accumulated temporal error estimation + * approaches from ARKStep and ERKStep. Uses a nonlinear + * Kvaerno-Prothero-Robinson ODE test problem with analytical + * solution, + * + * [u]' = [ G e ] [(u^2-p-1)/(2u)] + [ p'(t)/(2u) ] + * [v] [ e -1 ] [(v^2-q-2)/(2v)] [ q'(t)/(2v) ] + * + * where p(t) = cos(t), and q(t) = cos(omega*t*(1+exp(-(t-2)^2))). + * + * This problem has analytical solution given by + * u(t) = sqrt(2+p(t)), v(t) = sqrt(2+q(t)). + * We use the parameters: e = 0.1 and G = -10 [default] + * + * The stiffness of the problem is essentially determined + * by G, for |G| > 50 it is "stiff" and ideally suited to an + * implicit method. + * + * Coupling between the two components is determined by e, with + * coupling strength proportional to |e|. + * + * The "fast" variable, v, oscillates at a frequency "omega" times + * faster than u. + * + * We partition the full time integration interval, 0 < t < 5, into + * Npart pieces, and run the accumulation test over each. + * + * We use either the ARKStep/DIRK/Newton/Dense solver (0) or + * ERKStep (1). Either defaults to using a 4th-order method. + * + * By default, all runs use temporal adaptivity; however, if the + * requested 'ord' command-line input is negative, we run with + * order |ord|, using fixed step sizes. + * + * The program should be run with arguments in the following order: + * $ a.out Npart ord method G e omega + * Not all arguments are required, but these must be omitted from + * end-to-beginning, i.e. any one of + * $ a.out Npart ord method G e + * $ a.out Npart ord method G + * $ a.out Npart ord method + * $ a.out Npart ord + * $ a.out Npart + * $ a.out + * are acceptable. We require: + * * method = {0, 1} + * * G < 0.0 + * * omega > 0.0 + * * Npart > 0 + * + * For either temporally adaptive (ord >= 0) or fixed-step (ord < 0) + * runs, we test a variety of tolerances/step sizes, and compare + * the true error at the end of each partition against the + * integrator-reported accumulated error estimate. + * ----------------------------------------------------------------*/ + +// Header files +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#if defined(SUNDIALS_EXTENDED_PRECISION) +#define GSYM "Lg" +#define ESYM "Le" +#define FSYM "Lf" +#else +#define GSYM "g" +#define ESYM "e" +#define FSYM "f" +#endif + +#define ZERO SUN_RCONST(0.0) +#define ONE SUN_RCONST(1.0) +#define TWO SUN_RCONST(2.0) + +using namespace std; + +// User data structure +struct UserData +{ + sunrealtype G; + sunrealtype e; + sunrealtype omega; + int Npart; +}; + +// User-supplied functions called by the solver +static int fn(sunrealtype t, N_Vector y, N_Vector ydot, void* user_data); +static int Jn(sunrealtype t, N_Vector y, N_Vector fy, SUNMatrix J, + void* user_data, N_Vector tmp1, N_Vector tmp2, N_Vector tmp3); + +// Private utility functions +static int adaptive_run(void* arkode_mem, N_Vector y, sunrealtype T0, + sunrealtype Tf, int rk_type, int order, UserData& udata); +static int fixed_run(void* arkode_mem, N_Vector y, sunrealtype T0, + sunrealtype Tf, int rk_type, int order, UserData& udata); +static sunrealtype p(sunrealtype t); +static sunrealtype q(sunrealtype t, UserData& udata); +static sunrealtype pdot(sunrealtype t); +static sunrealtype qdot(sunrealtype t, UserData& udata); +static sunrealtype utrue(sunrealtype t); +static sunrealtype vtrue(sunrealtype t, UserData& udata); +static int Ytrue(sunrealtype t, N_Vector y, UserData& udata); +static int computeErrorWeights(N_Vector ycur, N_Vector weight, sunrealtype rtol, + sunrealtype atol, N_Vector vtemp); +static int check_retval(void* returnvalue, const char* funcname, int opt); + +// Main Program +int main(int argc, char* argv[]) +{ + // general problem parameters + sunrealtype T0 = SUN_RCONST(0.0); // initial time + sunrealtype Tf = SUN_RCONST(5.0); // final time + sunindextype NEQ = 2; // number of dependent vars. + int rk_type = 1; // type of RK method [DIRK=0, ERK=1] + int order = 4; // order of accuracy for RK method + sunbooleantype adaptive = SUNTRUE; // adaptive vs fixed-step run + + // general problem variables + int retval; // reusable error-checking flag + N_Vector y = NULL; // empty vector for the computed solution + void* arkode_mem = NULL; // empty ARKODE memory structure + SUNMatrix A = NULL; // empty system matrix + SUNLinearSolver LS = NULL; // empty system linear solver object + UserData udata; // user-data structure + udata.G = SUN_RCONST(-10.0); // stiffness parameter + udata.e = SUN_RCONST(0.1); // coupling strength + udata.omega = SUN_RCONST(5.0); // time scale ratio + udata.Npart = 20; // partition size + + // + // Initialization + // + + // Retrieve the command-line options: Npart ord method G e omega + if (argc > 1) udata.Npart = (int)atoi(argv[1]); + if (argc > 2) order = (int)atoi(argv[2]); + if (argc > 3) rk_type = (int)atoi(argv[3]); + if (argc > 4) udata.G = (sunrealtype)atof(argv[4]); + if (argc > 5) udata.e = (sunrealtype)atof(argv[5]); + if (argc > 6) udata.omega = (sunrealtype)atof(argv[6]); + + // Check arguments for validity + // 0 <= rk_type <= 1 + // G < 0.0 + // omega > 0.0 + // Npart > 0 + if ((rk_type < 0) || (rk_type > 1)) + { + cerr << "ERROR: RK type be an integer in {0,1} \n"; + return (-1); + } + if (udata.G >= ZERO) + { + cerr << "ERROR: G must be a negative real number\n"; + return (-1); + } + if (udata.omega <= ZERO) + { + cerr << "ERROR: omega must be a positive real number\n"; + return (-1); + } + if (udata.Npart < 1) + { + cerr << "ERROR: Npart must be a positive integer\n"; + return (-1); + } + + // Handle adaptive run vs order-of-convergence run + if (order < 0) + { + adaptive = SUNFALSE; + order = abs(order); + } + if (order == 0) order = 4; + + // Initial problem output (and set implicit solver tolerances as needed) + cout << "\nAccumulated error estimation test (Nonlinear " + "Kvaerno-Prothero-Robinson problem):\n"; + cout << " time domain: (" << T0 << "," << Tf << "]\n"; + cout << " partition size = " << udata.Npart << endl; + cout << " G = " << udata.G << endl; + cout << " e = " << udata.e << endl; + cout << " omega = " << udata.omega << endl; + if (rk_type == 0) { cout << " DIRK solver, order = " << order << endl; } + else if (rk_type == 1) + { + cout << " ERK solver, order = " << order << endl; + } + + // + // Problem Setup + // + + // Create SUNDIALS context + sundials::Context ctx; + + // Create and initialize serial vector for the solution + y = N_VNew_Serial(NEQ, ctx); + if (check_retval((void*)y, "N_VNew_Serial", 0)) return 1; + retval = Ytrue(T0, y, udata); + if (check_retval(&retval, "Ytrue", 1)) return 1; + + // Initialize ARKStep or ERKStep. + if (rk_type == 0) + { // DIRK method + + arkode_mem = ARKStepCreate(NULL, fn, T0, y, ctx); + if (check_retval((void*)arkode_mem, "ARKStepCreate", 0)) return 1; + + // Initialize/attach linear solvers (if required) + A = SUNDenseMatrix(NEQ, NEQ, ctx); + if (check_retval((void*)A, "SUNDenseMatrix", 0)) return 1; + LS = SUNLinSol_Dense(y, A, ctx); + if (check_retval((void*)LS, "SUNLinSol_Dense", 0)) return 1; + retval = ARKodeSetLinearSolver(arkode_mem, LS, A); + if (check_retval(&retval, "ARKodeSetLinearSolver", 1)) return (1); + retval = ARKodeSetJacFn(arkode_mem, Jn); + if (check_retval(&retval, "ARKodeSetJacFn", 1)) return 1; + + // Set desired solver order + retval = ARKodeSetOrder(arkode_mem, order); + if (check_retval(&retval, "ARKodeSetOrder", 1)) return 1; + + // Set the user data pointer + retval = ARKodeSetUserData(arkode_mem, (void*)&udata); + if (check_retval(&retval, "ARKodeSetUserData", 1)) return 1; + } + else + { // ERK method + + arkode_mem = ERKStepCreate(fn, T0, y, ctx); + if (check_retval((void*)arkode_mem, "ERKStepCreate", 0)) return 1; + + // Set maximum stepsize for ERK run + retval = ARKodeSetMaxStep(arkode_mem, ONE / abs(udata.G)); + if (check_retval(&retval, "ARKodeSetMaxStep", 1)) return (1); + + // Set desired solver order + retval = ARKodeSetOrder(arkode_mem, order); + if (check_retval(&retval, "ARKodeSetOrder", 1)) return 1; + + // Set the user data pointer + retval = ARKodeSetUserData(arkode_mem, (void*)&udata); + if (check_retval(&retval, "ARKodeSetUserData", 1)) return 1; + } + + // Integrate ODE, based on run type + if (adaptive) + { + retval = adaptive_run(arkode_mem, y, T0, Tf, rk_type, order, udata); + if (check_retval(&retval, "adaptive_run", 1)) return 1; + } + else + { + retval = fixed_run(arkode_mem, y, T0, Tf, rk_type, order, udata); + if (check_retval(&retval, "fixed_run", 1)) return 1; + } + + // Clean up and return + if (rk_type == 0) + { // Free integrator memory + ARKodeFree(&arkode_mem); + } + else { ARKodeFree(&arkode_mem); } + if (LS != NULL) SUNLinSolFree(LS); // free system linear solver + if (A != NULL) SUNMatDestroy(A); // free system matrix + N_VDestroy(y); // Free y vector + return 0; +} + +//------------------------------ +// Functions called by the solver +//------------------------------ + +static int fn(sunrealtype t, N_Vector y, N_Vector ydot, void* user_data) +{ + UserData* udata = (UserData*)user_data; + const sunrealtype u = NV_Ith_S(y, 0); + const sunrealtype v = NV_Ith_S(y, 1); + sunrealtype tmp1, tmp2; + + // fill in the RHS function: + // [G e]*[(-2+u^2-p(t))/(2*u)] + [pdot(t)/(2u)] + // [e -1] [(-2+v^2-s(t))/(2*v)] [qdot(t)/(2v)] + tmp1 = (-TWO + u * u - p(t)) / (TWO * u); + tmp2 = (-TWO + v * v - q(t, *udata)) / (TWO * v); + NV_Ith_S(ydot, 0) = udata->G * tmp1 + udata->e * tmp2 + pdot(t) / (TWO * u); + NV_Ith_S(ydot, 1) = udata->e * tmp1 - tmp2 + qdot(t, *udata) / (TWO * v); + + // Return with success + return 0; +} + +static int Jn(sunrealtype t, N_Vector y, N_Vector fy, SUNMatrix J, + void* user_data, N_Vector tmp1, N_Vector tmp2, N_Vector tmp3) +{ + UserData* udata = (UserData*)user_data; + const sunrealtype u = NV_Ith_S(y, 0); + const sunrealtype v = NV_Ith_S(y, 1); + sunrealtype t11, t22; + + // fill in the Jacobian: + // [G e]*[1-(u^2-p(t)-2)/(2*u^2), 0] + [-r'(t)/(2*u^2), 0] + // [e -1] [0, 1-(v^2-s(t)-2)/(2*v^2)] [0, -s'(t)/(2*v^2)] + t11 = ONE - (u * u - p(t) - TWO) / (TWO * u * u); + t22 = ONE - (v * v - q(t, *udata) - TWO) / (TWO * v * v); + SM_ELEMENT_D(J, 0, 0) = udata->G * t11 - pdot(t) / (TWO * u * u); + SM_ELEMENT_D(J, 0, 1) = udata->e * t22; + SM_ELEMENT_D(J, 1, 0) = udata->e * t11; + SM_ELEMENT_D(J, 1, 1) = -t22 - qdot(t, *udata) / (TWO * v * v); + + // Return with success + return 0; +} + +//------------------------------ +// Private helper functions +//------------------------------ + +static int adaptive_run(void* arkode_mem, N_Vector y, sunrealtype T0, + sunrealtype Tf, int rk_type, int order, UserData& udata) +{ + // Reused variables + int retval; + sunrealtype t; + sunrealtype hpart = (Tf - T0) / udata.Npart; + sunrealtype abstol = SUN_RCONST(1.e-12); + vector rtols = {SUN_RCONST(1.e-2), SUN_RCONST(1.e-4), + SUN_RCONST(1.e-6)}; + vector accum_types = {0, 1}; + vector dsm(udata.Npart); + vector dsm_est(udata.Npart); + vector Nsteps(udata.Npart); + + // Loop over tolerances + cout << "\nAdaptive-step runs:\n"; + for (int irtol = 0; irtol < rtols.size(); irtol++) + { + // Loop over accumulation types + for (int iaccum = 0; iaccum < accum_types.size(); iaccum++) + { + // Loop over partition + for (int ipart = 0; ipart < udata.Npart; ipart++) + { + // Reset integrator for this run, and evolve over partition interval + t = T0 + ipart * hpart; + retval = Ytrue(t, y, udata); + if (check_retval(&retval, "Ytrue", 1)) return 1; + if (rk_type == 0) + { // DIRK + retval = ARKStepReInit(arkode_mem, NULL, fn, t, y); + if (check_retval(&retval, "ARKStepReInit", 1)) return 1; + retval = ARKodeSetAccumulatedErrorType(arkode_mem, accum_types[iaccum]); + if (check_retval(&retval, "ARKodeSetAccumulatedErrorType", 1)) + return 1; + retval = ARKodeResetAccumulatedError(arkode_mem); + if (check_retval(&retval, "ARKodeResetAccumulatedError", 1)) return 1; + retval = ARKodeSStolerances(arkode_mem, rtols[irtol], abstol); + if (check_retval(&retval, "ARKodeSStolerances", 1)) return 1; + retval = ARKodeSetStopTime(arkode_mem, t + hpart); + if (check_retval(&retval, "ARKodeSetStopTime", 1)) return 1; + retval = ARKodeSetMaxNumSteps(arkode_mem, 1000000); + if (check_retval(&retval, "ARKodeSetMaxNumSteps", 1)) return (1); + retval = ARKodeEvolve(arkode_mem, t + hpart, y, &t, ARK_NORMAL); + if (check_retval(&retval, "ARKodeEvolve", 1)) break; + retval = ARKodeGetAccumulatedError(arkode_mem, &(dsm_est[ipart])); + if (check_retval(&retval, "ARKodeGetAccumulatedError", 1)) break; + retval = ARKodeGetNumSteps(arkode_mem, &(Nsteps[ipart])); + if (check_retval(&retval, "ARKodeGetNumSteps", 1)) break; + } + else + { // ERK + retval = ERKStepReInit(arkode_mem, fn, t, y); + if (check_retval(&retval, "ERKStepReInit", 1)) return 1; + retval = ARKodeSetAccumulatedErrorType(arkode_mem, accum_types[iaccum]); + if (check_retval(&retval, "ARKodeSetAccumulatedErrorType", 1)) + return 1; + retval = ARKodeResetAccumulatedError(arkode_mem); + if (check_retval(&retval, "ARKodeResetAccumulatedError", 1)) return 1; + retval = ARKodeSStolerances(arkode_mem, rtols[irtol], abstol); + if (check_retval(&retval, "ARKodeSStolerances", 1)) return 1; + retval = ARKodeSetStopTime(arkode_mem, t + hpart); + if (check_retval(&retval, "ARKodeSetStopTime", 1)) return 1; + retval = ARKodeSetMaxNumSteps(arkode_mem, 1000000); + if (check_retval(&retval, "ARKodeSetMaxNumSteps", 1)) return (1); + retval = ARKodeEvolve(arkode_mem, t + hpart, y, &t, ARK_NORMAL); + if (check_retval(&retval, "ARKodeEvolve", 1)) break; + retval = ARKodeGetAccumulatedError(arkode_mem, &(dsm_est[ipart])); + if (check_retval(&retval, "ARKodeGetAccumulatedError", 1)) break; + retval = ARKodeGetNumSteps(arkode_mem, &(Nsteps[ipart])); + if (check_retval(&retval, "ARKodeGetNumSteps", 1)) break; + } + + // Compute/print solution error + sunrealtype udsm = abs(NV_Ith_S(y, 0) - utrue(t)) / + (abstol + rtols[irtol] * abs(utrue(t))); + sunrealtype vdsm = abs(NV_Ith_S(y, 1) - vtrue(t, udata)) / + (abstol + rtols[irtol] * abs(vtrue(t, udata))); + dsm[ipart] = rtols[irtol] * sqrt(0.5 * (udsm * udsm + vdsm * vdsm)); + cout << " rtol " << rtols[irtol] << " rk_type " << rk_type + << " order " << order << " acc " << accum_types[iaccum] << " t " + << t << " dsm " << dsm[ipart] << " dsm_est " << dsm_est[ipart] + << " nsteps " << Nsteps[ipart] << endl; + } + } + } + + return (0); +} + +static int fixed_run(void* arkode_mem, N_Vector y, sunrealtype T0, + sunrealtype Tf, int rk_type, int order, UserData& udata) +{ + // local variables + int retval; + sunrealtype hpart = (Tf - T0) / udata.Npart; + long int nsteps2; + sunrealtype t, t2; + sunrealtype reltol = SUN_RCONST(1.e-9); + sunrealtype abstol = SUN_RCONST(1.e-12); + N_Vector y2 = N_VClone(y); + N_Vector ewt = N_VClone(y); + N_Vector vtemp = N_VClone(y); + + // Set array of fixed step sizes to use, storage for corresponding errors/orders + sunrealtype hmax = (Tf - T0) / 1000; + if (rk_type == 1) hmax = min(hmax, ONE / abs(udata.G)); + vector hvals = {hmax, hmax / 4, hmax / 16, hmax / 64}; + vector accum_types = {0, 1}; + vector dsm(udata.Npart); + vector dsm_est(udata.Npart); + vector Nsteps(udata.Npart); + + // Loop over step sizes + cout << "\nFixed-step runs:\n"; + for (int ih = 0; ih < hvals.size(); ih++) + { + // Loop over built-in accumulation types + for (int iaccum = 0; iaccum < accum_types.size(); iaccum++) + { + // Loop over partition + for (int ipart = 0; ipart < udata.Npart; ipart++) + { + // Reset integrator for this run, and evolve over partition interval + t = T0 + ipart * hpart; + retval = Ytrue(t, y, udata); + if (check_retval(&retval, "Ytrue", 1)) return 1; + if (rk_type == 0) + { // DIRK + retval = ARKStepReInit(arkode_mem, NULL, fn, t, y); + if (check_retval(&retval, "ARKStepReInit", 1)) return 1; + retval = ARKodeSetAccumulatedErrorType(arkode_mem, accum_types[iaccum]); + if (check_retval(&retval, "ARKodeSetAccumulatedErrorType", 1)) + return 1; + retval = ARKodeResetAccumulatedError(arkode_mem); + if (check_retval(&retval, "ARKodeResetAccumulatedError", 1)) return 1; + retval = ARKodeSetFixedStep(arkode_mem, hvals[ih]); + if (check_retval(&retval, "ARKodeSetFixedStep", 1)) return 1; + retval = ARKodeSetMaxNumSteps(arkode_mem, 1000000); + if (check_retval(&retval, "ARKodeSetMaxNumSteps", 1)) return (1); + retval = ARKodeSetStopTime(arkode_mem, t + hpart); + if (check_retval(&retval, "ARKodeSetStopTime", 1)) return 1; + retval = ARKodeSStolerances(arkode_mem, reltol, abstol); + if (check_retval(&retval, "ARKodeSStolerances", 1)) return 1; + retval = ARKodeSetJacEvalFrequency(arkode_mem, 1); + if (check_retval(&retval, "ARKodeSetJacEvalFrequency", 1)) return 1; + retval = ARKodeSetLSetupFrequency(arkode_mem, 1); + if (check_retval(&retval, "ARKodeSetLSetupFrequency", 1)) return 1; + retval = ARKodeSetMaxNonlinIters(arkode_mem, 20); + if (check_retval(&retval, "ARKodeSetMaxNonlinIters", 1)) return 1; + retval = ARKodeEvolve(arkode_mem, t + hpart, y, &t, ARK_NORMAL); + if (check_retval(&retval, "ARKodeEvolve", 1)) break; + retval = ARKodeGetAccumulatedError(arkode_mem, &(dsm_est[ipart])); + if (check_retval(&retval, "ARKodeGetAccumulatedError", 1)) break; + retval = ARKodeGetNumSteps(arkode_mem, &(Nsteps[ipart])); + if (check_retval(&retval, "ARKodeGetNumSteps", 1)) break; + } + else + { // ERK + retval = ERKStepReInit(arkode_mem, fn, t, y); + if (check_retval(&retval, "ERKStepReInit", 1)) return 1; + retval = ARKodeSetAccumulatedErrorType(arkode_mem, accum_types[iaccum]); + if (check_retval(&retval, "ARKodeSetAccumulatedErrorType", 1)) + return 1; + retval = ARKodeResetAccumulatedError(arkode_mem); + if (check_retval(&retval, "ARKodeResetAccumulatedError", 1)) return 1; + retval = ARKodeSetFixedStep(arkode_mem, hvals[ih]); + if (check_retval(&retval, "ARKodeSetFixedStep", 1)) return 1; + retval = ARKodeSetMaxNumSteps(arkode_mem, 1000000); + if (check_retval(&retval, "ARKodeSetMaxNumSteps", 1)) return (1); + retval = ARKodeSStolerances(arkode_mem, reltol, abstol); + if (check_retval(&retval, "ARKodeSStolerances", 1)) return 1; + retval = ARKodeSetStopTime(arkode_mem, t + hpart); + if (check_retval(&retval, "ARKodeSetStopTime", 1)) return 1; + retval = ARKodeEvolve(arkode_mem, t + hpart, y, &t, ARK_NORMAL); + if (check_retval(&retval, "ARKodeEvolve", 1)) break; + retval = ARKodeGetAccumulatedError(arkode_mem, &(dsm_est[ipart])); + if (check_retval(&retval, "ARKodeGetAccumulatedError", 1)) break; + retval = ARKodeGetNumSteps(arkode_mem, &(Nsteps[ipart])); + if (check_retval(&retval, "ARKodeGetNumSteps", 1)) break; + } + + // Compute/print solution error + sunrealtype udsm = abs(NV_Ith_S(y, 0) - utrue(t)) / + (abstol + reltol * abs(utrue(t))); + sunrealtype vdsm = abs(NV_Ith_S(y, 1) - vtrue(t, udata)) / + (abstol + reltol * abs(vtrue(t, udata))); + dsm[ipart] = reltol * sqrt(0.5 * (udsm * udsm + vdsm * vdsm)); + cout << " h " << hvals[ih] << " rk_type " << rk_type << " order " + << order << " acc " << accum_types[iaccum] << " t " << t + << " dsm " << dsm[ipart] << " dsm_est " << dsm_est[ipart] + << " nsteps " << Nsteps[ipart] << endl; + } + } + + // Test double-step error estimator + + // Loop over partition + for (int ipart = 0; ipart < udata.Npart; ipart++) + { + // Reset integrator for this run, and evolve over partition interval + t = t2 = T0 + ipart * hpart; + retval = Ytrue(t, y, udata); + if (check_retval(&retval, "Ytrue", 1)) return 1; + retval = Ytrue(t2, y2, udata); + if (check_retval(&retval, "Ytrue", 1)) return 1; + if (rk_type == 0) + { // DIRK + retval = ARKStepReInit(arkode_mem, NULL, fn, t, y); + if (check_retval(&retval, "ARKStepReInit", 1)) return 1; + retval = ARKodeSetAccumulatedErrorType(arkode_mem, -1); + if (check_retval(&retval, "ARKodeSetAccumulatedErrorType", 1)) return 1; + retval = ARKodeSetFixedStep(arkode_mem, hvals[ih]); + if (check_retval(&retval, "ARKodeSetFixedStep", 1)) return 1; + retval = ARKodeSetMaxNumSteps(arkode_mem, 1000000); + if (check_retval(&retval, "ARKodeSetMaxNumSteps", 1)) return (1); + retval = ARKodeSetStopTime(arkode_mem, t + hpart); + if (check_retval(&retval, "ARKodeSetStopTime", 1)) return 1; + retval = ARKodeSStolerances(arkode_mem, reltol, abstol); + if (check_retval(&retval, "ARKodeSStolerances", 1)) return 1; + retval = ARKodeSetJacEvalFrequency(arkode_mem, 1); + if (check_retval(&retval, "ARKodeSetJacEvalFrequency", 1)) return 1; + retval = ARKodeSetLSetupFrequency(arkode_mem, 1); + if (check_retval(&retval, "ARKodeSetLSetupFrequency", 1)) return 1; + retval = ARKodeSetMaxNonlinIters(arkode_mem, 20); + if (check_retval(&retval, "ARKodeSetMaxNonlinIters", 1)) return 1; + retval = ARKodeEvolve(arkode_mem, t + hpart, y, &t, ARK_NORMAL); + if (check_retval(&retval, "ARKodeEvolve", 1)) break; + retval = ARKodeGetNumSteps(arkode_mem, &(Nsteps[ipart])); + if (check_retval(&retval, "ARKodeGetNumSteps", 1)) break; + + retval = ARKStepReInit(arkode_mem, NULL, fn, t2, y2); + if (check_retval(&retval, "ARKStepReInit", 1)) return 1; + retval = ARKodeSetFixedStep(arkode_mem, 2.0 * hvals[ih]); + if (check_retval(&retval, "ARKodeSetFixedStep", 1)) return 1; + retval = ARKodeSetStopTime(arkode_mem, t2 + hpart); + if (check_retval(&retval, "ARKodeSetStopTime", 1)) return 1; + retval = ARKodeEvolve(arkode_mem, t2 + hpart, y2, &t2, ARK_NORMAL); + if (check_retval(&retval, "ARKodeEvolve", 1)) break; + retval = ARKodeGetNumSteps(arkode_mem, &nsteps2); + if (check_retval(&retval, "ARKodeGetNumSteps", 1)) break; + } + else + { // ERK + retval = ERKStepReInit(arkode_mem, fn, t, y); + if (check_retval(&retval, "ERKStepReInit", 1)) return 1; + retval = ARKodeSetAccumulatedErrorType(arkode_mem, -1); + if (check_retval(&retval, "ARKodeSetAccumulatedErrorType", 1)) return 1; + retval = ARKodeSetFixedStep(arkode_mem, hvals[ih]); + if (check_retval(&retval, "ARKodeSetFixedStep", 1)) return 1; + retval = ARKodeSetMaxNumSteps(arkode_mem, 1000000); + if (check_retval(&retval, "ARKodeSetMaxNumSteps", 1)) return (1); + retval = ARKodeSetStopTime(arkode_mem, t + hpart); + if (check_retval(&retval, "ARKodeSetStopTime", 1)) return 1; + retval = ARKodeSStolerances(arkode_mem, reltol, abstol); + if (check_retval(&retval, "ARKodeSStolerances", 1)) return 1; + retval = ARKodeEvolve(arkode_mem, t + hpart, y, &t, ARK_NORMAL); + if (check_retval(&retval, "ARKodeEvolve", 1)) break; + retval = ARKodeGetNumSteps(arkode_mem, &(Nsteps[ipart])); + if (check_retval(&retval, "ARKodeGetNumSteps", 1)) break; + + retval = ERKStepReInit(arkode_mem, fn, t2, y2); + if (check_retval(&retval, "ERKStepReInit", 1)) return 1; + retval = ARKodeSetFixedStep(arkode_mem, 2.0 * hvals[ih]); + if (check_retval(&retval, "ARKodeSetFixedStep", 1)) return 1; + retval = ARKodeSetStopTime(arkode_mem, t2 + hpart); + if (check_retval(&retval, "ARKodeSetStopTime", 1)) return 1; + retval = ARKodeEvolve(arkode_mem, t2 + hpart, y2, &t2, ARK_NORMAL); + if (check_retval(&retval, "ARKodeEvolve", 1)) break; + retval = ARKodeGetNumSteps(arkode_mem, &nsteps2); + if (check_retval(&retval, "ARKodeGetNumSteps", 1)) break; + } + retval = computeErrorWeights(y2, ewt, reltol, abstol, vtemp); + if (check_retval(&retval, "computeErrorWeights", 1)) break; + N_VLinearSum(ONE, y2, -ONE, y, y2); + dsm_est[ipart] = reltol * N_VWrmsNorm(y2, ewt); + Nsteps[ipart] += nsteps2; + sunrealtype udsm = abs(NV_Ith_S(y, 0) - utrue(t)) / + (abstol + reltol * abs(utrue(t))); + sunrealtype vdsm = abs(NV_Ith_S(y, 1) - vtrue(t, udata)) / + (abstol + reltol * abs(vtrue(t, udata))); + dsm[ipart] = reltol * sqrt(0.5 * (udsm * udsm + vdsm * vdsm)); + cout << " h " << hvals[ih] << " rk_type " << rk_type << " order " + << order << " acc " << 2 << " t " << t << " dsm " << dsm[ipart] + << " dsm_est " << dsm_est[ipart] << " nsteps " << Nsteps[ipart] + << endl; + } + } + + N_VDestroy(y2); + N_VDestroy(ewt); + return (0); +} + +static sunrealtype p(sunrealtype t) { return (cos(t)); } + +static sunrealtype q(sunrealtype t, UserData& udata) +{ + return (cos(udata.omega * t * (ONE + exp(-(t - 2) * (t - 2))))); +} + +static sunrealtype pdot(sunrealtype t) { return (-sin(t)); } + +static sunrealtype qdot(sunrealtype t, UserData& udata) +{ + return (-sin(udata.omega * t * (ONE + exp(-(t - 2) * (t - 2)))) * udata.omega * + (ONE + exp(-(t - 2) * (t - 2)) - + t * 2 * (t - 2) * (exp(-(t - 2) * (t - 2))))); +} + +static sunrealtype utrue(sunrealtype t) { return (SUNRsqrt(TWO + p(t))); } + +static sunrealtype vtrue(sunrealtype t, UserData& udata) +{ + return (SUNRsqrt(TWO + q(t, udata))); +} + +static int Ytrue(sunrealtype t, N_Vector y, UserData& udata) +{ + NV_Ith_S(y, 0) = utrue(t); + NV_Ith_S(y, 1) = vtrue(t, udata); + return (0); +} + +static int computeErrorWeights(N_Vector ycur, N_Vector weight, sunrealtype rtol, + sunrealtype atol, N_Vector vtemp) +{ + N_VAbs(ycur, vtemp); + N_VScale(rtol, vtemp, vtemp); + N_VAddConst(vtemp, atol, vtemp); + N_VInv(vtemp, weight); + return (0); +} + +/* Check function return value... + opt == 0 means SUNDIALS function allocates memory so check if + returned NULL pointer + opt == 1 means SUNDIALS function returns a retval so check if + retval < 0 + opt == 2 means function allocates memory so check if returned + NULL pointer +*/ +static int check_retval(void* returnvalue, const char* funcname, int opt) +{ + int* retval; + + // Check if SUNDIALS function returned NULL pointer - no memory allocated + if (opt == 0 && returnvalue == NULL) + { + fprintf(stderr, "\nSUNDIALS_ERROR: %s() failed - returned NULL pointer\n\n", + funcname); + return 1; + } + + // Check if retval < 0 + else if (opt == 1) + { + retval = (int*)returnvalue; + if (*retval < 0) + { + fprintf(stderr, "\nSUNDIALS_ERROR: %s() failed with retval = %d\n\n", + funcname, *retval); + return 1; + } + } + + // Check if function returned NULL pointer - no memory allocated + else if (opt == 2 && returnvalue == NULL) + { + fprintf(stderr, "\nMEMORY_ERROR: %s() failed - returned NULL pointer\n\n", + funcname); + return 1; + } + + return 0; +} + +//---- end of file ---- diff --git a/test/unit_tests/arkode/CXX_serial/ark_test_accumerror_kpr_20_-4_1.out b/test/unit_tests/arkode/CXX_serial/ark_test_accumerror_kpr_20_-4_1.out new file mode 100644 index 0000000000..05dbfd356a --- /dev/null +++ b/test/unit_tests/arkode/CXX_serial/ark_test_accumerror_kpr_20_-4_1.out @@ -0,0 +1,250 @@ + +Accumulated error estimation test (Nonlinear Kvaerno-Prothero-Robinson problem): + time domain: (0,5] + partition size = 20 + G = -10 + e = 0.1 + omega = 5 + ERK solver, order = 4 + +Fixed-step runs: + h 0.005 rk_type 1 order 4 acc 0 t 0.25 dsm 5.99625e-11 dsm_est 7.9246e-10 nsteps 50 + h 0.005 rk_type 1 order 4 acc 0 t 0.5 dsm 1.42974e-10 dsm_est 3.12286e-09 nsteps 50 + h 0.005 rk_type 1 order 4 acc 0 t 0.75 dsm 2.42719e-10 dsm_est 9.28141e-09 nsteps 50 + h 0.005 rk_type 1 order 4 acc 0 t 1 dsm 6.83162e-10 dsm_est 1.26647e-09 nsteps 50 + h 0.005 rk_type 1 order 4 acc 0 t 1.25 dsm 3.14281e-09 dsm_est 2.69129e-08 nsteps 50 + h 0.005 rk_type 1 order 4 acc 0 t 1.5 dsm 4.52762e-09 dsm_est 3.9027e-07 nsteps 50 + h 0.005 rk_type 1 order 4 acc 0 t 1.75 dsm 4.7305e-10 dsm_est 9.96347e-08 nsteps 50 + h 0.005 rk_type 1 order 4 acc 0 t 2 dsm 1.22724e-09 dsm_est 2.15168e-07 nsteps 50 + h 0.005 rk_type 1 order 4 acc 0 t 2.25 dsm 2.1725e-10 dsm_est 3.71812e-09 nsteps 50 + h 0.005 rk_type 1 order 4 acc 0 t 2.5 dsm 1.44845e-10 dsm_est 1.77141e-09 nsteps 50 + h 0.005 rk_type 1 order 4 acc 0 t 2.75 dsm 1.45894e-10 dsm_est 7.14815e-09 nsteps 50 + h 0.005 rk_type 1 order 4 acc 0 t 3 dsm 2.11123e-10 dsm_est 1.10902e-08 nsteps 50 + h 0.005 rk_type 1 order 4 acc 0 t 3.25 dsm 2.34671e-10 dsm_est 3.64116e-09 nsteps 50 + h 0.005 rk_type 1 order 4 acc 0 t 3.5 dsm 1.99557e-10 dsm_est 3.27436e-10 nsteps 50 + h 0.005 rk_type 1 order 4 acc 0 t 3.75 dsm 1.51624e-10 dsm_est 7.64317e-10 nsteps 50 + h 0.005 rk_type 1 order 4 acc 0 t 4 dsm 9.7978e-11 dsm_est 1.91259e-10 nsteps 50 + h 0.005 rk_type 1 order 4 acc 0 t 4.25 dsm 3.36113e-11 dsm_est 1.88739e-09 nsteps 50 + h 0.005 rk_type 1 order 4 acc 0 t 4.5 dsm 7.15711e-11 dsm_est 1.40472e-10 nsteps 50 + h 0.005 rk_type 1 order 4 acc 0 t 4.75 dsm 3.79788e-11 dsm_est 3.66885e-09 nsteps 50 + h 0.005 rk_type 1 order 4 acc 0 t 5 dsm 4.13058e-11 dsm_est 1.68612e-09 nsteps 50 + h 0.005 rk_type 1 order 4 acc 1 t 0.25 dsm 5.99625e-11 dsm_est 1.58492e-11 nsteps 50 + h 0.005 rk_type 1 order 4 acc 1 t 0.5 dsm 1.42974e-10 dsm_est 6.24572e-11 nsteps 50 + h 0.005 rk_type 1 order 4 acc 1 t 0.75 dsm 2.42719e-10 dsm_est 1.85628e-10 nsteps 50 + h 0.005 rk_type 1 order 4 acc 1 t 1 dsm 6.83162e-10 dsm_est 2.53294e-11 nsteps 50 + h 0.005 rk_type 1 order 4 acc 1 t 1.25 dsm 3.14281e-09 dsm_est 5.38258e-10 nsteps 50 + h 0.005 rk_type 1 order 4 acc 1 t 1.5 dsm 4.52762e-09 dsm_est 7.8054e-09 nsteps 50 + h 0.005 rk_type 1 order 4 acc 1 t 1.75 dsm 4.7305e-10 dsm_est 1.99269e-09 nsteps 50 + h 0.005 rk_type 1 order 4 acc 1 t 2 dsm 1.22724e-09 dsm_est 4.30336e-09 nsteps 50 + h 0.005 rk_type 1 order 4 acc 1 t 2.25 dsm 2.1725e-10 dsm_est 7.43624e-11 nsteps 50 + h 0.005 rk_type 1 order 4 acc 1 t 2.5 dsm 1.44845e-10 dsm_est 3.54281e-11 nsteps 50 + h 0.005 rk_type 1 order 4 acc 1 t 2.75 dsm 1.45894e-10 dsm_est 1.42963e-10 nsteps 50 + h 0.005 rk_type 1 order 4 acc 1 t 3 dsm 2.11123e-10 dsm_est 2.21804e-10 nsteps 50 + h 0.005 rk_type 1 order 4 acc 1 t 3.25 dsm 2.34671e-10 dsm_est 7.28233e-11 nsteps 50 + h 0.005 rk_type 1 order 4 acc 1 t 3.5 dsm 1.99557e-10 dsm_est 6.54871e-12 nsteps 50 + h 0.005 rk_type 1 order 4 acc 1 t 3.75 dsm 1.51624e-10 dsm_est 1.52863e-11 nsteps 50 + h 0.005 rk_type 1 order 4 acc 1 t 4 dsm 9.7978e-11 dsm_est 3.82518e-12 nsteps 50 + h 0.005 rk_type 1 order 4 acc 1 t 4.25 dsm 3.36113e-11 dsm_est 3.77478e-11 nsteps 50 + h 0.005 rk_type 1 order 4 acc 1 t 4.5 dsm 7.15711e-11 dsm_est 2.80944e-12 nsteps 50 + h 0.005 rk_type 1 order 4 acc 1 t 4.75 dsm 3.79788e-11 dsm_est 7.33771e-11 nsteps 50 + h 0.005 rk_type 1 order 4 acc 1 t 5 dsm 4.13058e-11 dsm_est 3.37224e-11 nsteps 50 + h 0.005 rk_type 1 order 4 acc 2 t 0.25 dsm 5.99625e-11 dsm_est 9.19534e-10 nsteps 75 + h 0.005 rk_type 1 order 4 acc 2 t 0.5 dsm 1.42974e-10 dsm_est 2.10629e-09 nsteps 75 + h 0.005 rk_type 1 order 4 acc 2 t 0.75 dsm 2.42719e-10 dsm_est 3.82746e-09 nsteps 75 + h 0.005 rk_type 1 order 4 acc 2 t 1 dsm 6.83162e-10 dsm_est 1.03061e-08 nsteps 75 + h 0.005 rk_type 1 order 4 acc 2 t 1.25 dsm 3.14281e-09 dsm_est 4.33257e-08 nsteps 75 + h 0.005 rk_type 1 order 4 acc 2 t 1.5 dsm 4.52762e-09 dsm_est 6.98227e-08 nsteps 75 + h 0.005 rk_type 1 order 4 acc 2 t 1.75 dsm 4.7305e-10 dsm_est 3.66571e-09 nsteps 75 + h 0.005 rk_type 1 order 4 acc 2 t 2 dsm 1.22724e-09 dsm_est 1.87356e-08 nsteps 75 + h 0.005 rk_type 1 order 4 acc 2 t 2.25 dsm 2.1725e-10 dsm_est 3.03702e-09 nsteps 75 + h 0.005 rk_type 1 order 4 acc 2 t 2.5 dsm 1.44845e-10 dsm_est 2.22121e-09 nsteps 75 + h 0.005 rk_type 1 order 4 acc 2 t 2.75 dsm 1.45894e-10 dsm_est 2.22678e-09 nsteps 75 + h 0.005 rk_type 1 order 4 acc 2 t 3 dsm 2.11123e-10 dsm_est 3.23991e-09 nsteps 75 + h 0.005 rk_type 1 order 4 acc 2 t 3.25 dsm 2.34671e-10 dsm_est 3.61593e-09 nsteps 75 + h 0.005 rk_type 1 order 4 acc 2 t 3.5 dsm 1.99557e-10 dsm_est 3.07907e-09 nsteps 75 + h 0.005 rk_type 1 order 4 acc 2 t 3.75 dsm 1.51624e-10 dsm_est 2.34121e-09 nsteps 75 + h 0.005 rk_type 1 order 4 acc 2 t 4 dsm 9.7978e-11 dsm_est 1.51474e-09 nsteps 75 + h 0.005 rk_type 1 order 4 acc 2 t 4.25 dsm 3.36113e-11 dsm_est 5.09945e-10 nsteps 75 + h 0.005 rk_type 1 order 4 acc 2 t 4.5 dsm 7.15711e-11 dsm_est 1.10419e-09 nsteps 75 + h 0.005 rk_type 1 order 4 acc 2 t 4.75 dsm 3.79788e-11 dsm_est 5.88316e-10 nsteps 75 + h 0.005 rk_type 1 order 4 acc 2 t 5 dsm 4.13058e-11 dsm_est 6.25891e-10 nsteps 75 + h 0.00125 rk_type 1 order 4 acc 0 t 0.25 dsm 2.30499e-13 dsm_est 3.07508e-12 nsteps 200 + h 0.00125 rk_type 1 order 4 acc 0 t 0.5 dsm 5.68219e-13 dsm_est 1.20112e-11 nsteps 200 + h 0.00125 rk_type 1 order 4 acc 0 t 0.75 dsm 9.09327e-13 dsm_est 3.22789e-11 nsteps 200 + h 0.00125 rk_type 1 order 4 acc 0 t 1 dsm 2.66412e-12 dsm_est 4.42072e-12 nsteps 200 + h 0.00125 rk_type 1 order 4 acc 0 t 1.25 dsm 1.30178e-11 dsm_est 1.0259e-10 nsteps 200 + h 0.00125 rk_type 1 order 4 acc 0 t 1.5 dsm 1.73534e-11 dsm_est 1.64905e-09 nsteps 200 + h 0.00125 rk_type 1 order 4 acc 0 t 1.75 dsm 3.44384e-12 dsm_est 3.87489e-10 nsteps 200 + h 0.00125 rk_type 1 order 4 acc 0 t 2 dsm 4.73982e-12 dsm_est 8.44242e-10 nsteps 200 + h 0.00125 rk_type 1 order 4 acc 0 t 2.25 dsm 8.24836e-13 dsm_est 1.15395e-11 nsteps 200 + h 0.00125 rk_type 1 order 4 acc 0 t 2.5 dsm 5.58183e-13 dsm_est 1.08294e-11 nsteps 200 + h 0.00125 rk_type 1 order 4 acc 0 t 2.75 dsm 5.66294e-13 dsm_est 2.82685e-11 nsteps 200 + h 0.00125 rk_type 1 order 4 acc 0 t 3 dsm 8.06614e-13 dsm_est 4.34752e-11 nsteps 200 + h 0.00125 rk_type 1 order 4 acc 0 t 3.25 dsm 8.98387e-13 dsm_est 1.4135e-11 nsteps 200 + h 0.00125 rk_type 1 order 4 acc 0 t 3.5 dsm 7.63217e-13 dsm_est 1.35855e-12 nsteps 200 + h 0.00125 rk_type 1 order 4 acc 0 t 3.75 dsm 5.78309e-13 dsm_est 2.99367e-12 nsteps 200 + h 0.00125 rk_type 1 order 4 acc 0 t 4 dsm 3.75531e-13 dsm_est 6.93024e-13 nsteps 200 + h 0.00125 rk_type 1 order 4 acc 0 t 4.25 dsm 1.33194e-13 dsm_est 7.31752e-12 nsteps 200 + h 0.00125 rk_type 1 order 4 acc 0 t 4.5 dsm 2.44986e-13 dsm_est 1.08546e-12 nsteps 200 + h 0.00125 rk_type 1 order 4 acc 0 t 4.75 dsm 1.41286e-13 dsm_est 1.51237e-11 nsteps 200 + h 0.00125 rk_type 1 order 4 acc 0 t 5 dsm 1.73009e-13 dsm_est 6.57848e-12 nsteps 200 + h 0.00125 rk_type 1 order 4 acc 1 t 0.25 dsm 2.30499e-13 dsm_est 1.53754e-14 nsteps 200 + h 0.00125 rk_type 1 order 4 acc 1 t 0.5 dsm 5.68219e-13 dsm_est 6.0056e-14 nsteps 200 + h 0.00125 rk_type 1 order 4 acc 1 t 0.75 dsm 9.09327e-13 dsm_est 1.61395e-13 nsteps 200 + h 0.00125 rk_type 1 order 4 acc 1 t 1 dsm 2.66412e-12 dsm_est 2.21036e-14 nsteps 200 + h 0.00125 rk_type 1 order 4 acc 1 t 1.25 dsm 1.30178e-11 dsm_est 5.12948e-13 nsteps 200 + h 0.00125 rk_type 1 order 4 acc 1 t 1.5 dsm 1.73534e-11 dsm_est 8.24527e-12 nsteps 200 + h 0.00125 rk_type 1 order 4 acc 1 t 1.75 dsm 3.44384e-12 dsm_est 1.93745e-12 nsteps 200 + h 0.00125 rk_type 1 order 4 acc 1 t 2 dsm 4.73982e-12 dsm_est 4.22121e-12 nsteps 200 + h 0.00125 rk_type 1 order 4 acc 1 t 2.25 dsm 8.24836e-13 dsm_est 5.76976e-14 nsteps 200 + h 0.00125 rk_type 1 order 4 acc 1 t 2.5 dsm 5.58183e-13 dsm_est 5.4147e-14 nsteps 200 + h 0.00125 rk_type 1 order 4 acc 1 t 2.75 dsm 5.66294e-13 dsm_est 1.41342e-13 nsteps 200 + h 0.00125 rk_type 1 order 4 acc 1 t 3 dsm 8.06614e-13 dsm_est 2.17376e-13 nsteps 200 + h 0.00125 rk_type 1 order 4 acc 1 t 3.25 dsm 8.98387e-13 dsm_est 7.06748e-14 nsteps 200 + h 0.00125 rk_type 1 order 4 acc 1 t 3.5 dsm 7.63217e-13 dsm_est 6.79273e-15 nsteps 200 + h 0.00125 rk_type 1 order 4 acc 1 t 3.75 dsm 5.78309e-13 dsm_est 1.49684e-14 nsteps 200 + h 0.00125 rk_type 1 order 4 acc 1 t 4 dsm 3.75531e-13 dsm_est 3.46512e-15 nsteps 200 + h 0.00125 rk_type 1 order 4 acc 1 t 4.25 dsm 1.33194e-13 dsm_est 3.65876e-14 nsteps 200 + h 0.00125 rk_type 1 order 4 acc 1 t 4.5 dsm 2.44986e-13 dsm_est 5.42731e-15 nsteps 200 + h 0.00125 rk_type 1 order 4 acc 1 t 4.75 dsm 1.41286e-13 dsm_est 7.56183e-14 nsteps 200 + h 0.00125 rk_type 1 order 4 acc 1 t 5 dsm 1.73009e-13 dsm_est 3.28924e-14 nsteps 200 + h 0.00125 rk_type 1 order 4 acc 2 t 0.25 dsm 2.30499e-13 dsm_est 3.47846e-12 nsteps 300 + h 0.00125 rk_type 1 order 4 acc 2 t 0.5 dsm 5.68219e-13 dsm_est 8.44621e-12 nsteps 300 + h 0.00125 rk_type 1 order 4 acc 2 t 0.75 dsm 9.09327e-13 dsm_est 1.38911e-11 nsteps 300 + h 0.00125 rk_type 1 order 4 acc 2 t 1 dsm 2.66412e-12 dsm_est 3.99292e-11 nsteps 300 + h 0.00125 rk_type 1 order 4 acc 2 t 1.25 dsm 1.30178e-11 dsm_est 1.91091e-10 nsteps 300 + h 0.00125 rk_type 1 order 4 acc 2 t 1.5 dsm 1.73534e-11 dsm_est 2.61959e-10 nsteps 300 + h 0.00125 rk_type 1 order 4 acc 2 t 1.75 dsm 3.44384e-12 dsm_est 4.28383e-11 nsteps 300 + h 0.00125 rk_type 1 order 4 acc 2 t 2 dsm 4.73982e-12 dsm_est 7.1306e-11 nsteps 300 + h 0.00125 rk_type 1 order 4 acc 2 t 2.25 dsm 8.24836e-13 dsm_est 1.31816e-11 nsteps 300 + h 0.00125 rk_type 1 order 4 acc 2 t 2.5 dsm 5.58183e-13 dsm_est 8.4007e-12 nsteps 300 + h 0.00125 rk_type 1 order 4 acc 2 t 2.75 dsm 5.66294e-13 dsm_est 8.47988e-12 nsteps 300 + h 0.00125 rk_type 1 order 4 acc 2 t 3 dsm 8.06614e-13 dsm_est 1.22473e-11 nsteps 300 + h 0.00125 rk_type 1 order 4 acc 2 t 3.25 dsm 8.98387e-13 dsm_est 1.35837e-11 nsteps 300 + h 0.00125 rk_type 1 order 4 acc 2 t 3.5 dsm 7.63217e-13 dsm_est 1.15437e-11 nsteps 300 + h 0.00125 rk_type 1 order 4 acc 2 t 3.75 dsm 5.78309e-13 dsm_est 8.76917e-12 nsteps 300 + h 0.00125 rk_type 1 order 4 acc 2 t 4 dsm 3.75531e-13 dsm_est 5.66133e-12 nsteps 300 + h 0.00125 rk_type 1 order 4 acc 2 t 4.25 dsm 1.33194e-13 dsm_est 1.9304e-12 nsteps 300 + h 0.00125 rk_type 1 order 4 acc 2 t 4.5 dsm 2.44986e-13 dsm_est 4.1717e-12 nsteps 300 + h 0.00125 rk_type 1 order 4 acc 2 t 4.75 dsm 1.41286e-13 dsm_est 2.17896e-12 nsteps 300 + h 0.00125 rk_type 1 order 4 acc 2 t 5 dsm 1.73009e-13 dsm_est 2.38734e-12 nsteps 300 + h 0.0003125 rk_type 1 order 4 acc 0 t 0.25 dsm 9.97977e-16 dsm_est 1.19921e-14 nsteps 800 + h 0.0003125 rk_type 1 order 4 acc 0 t 0.5 dsm 7.34738e-15 dsm_est 4.67384e-14 nsteps 800 + h 0.0003125 rk_type 1 order 4 acc 0 t 0.75 dsm 1.89479e-14 dsm_est 1.22245e-13 nsteps 800 + h 0.0003125 rk_type 1 order 4 acc 0 t 1 dsm 6.41345e-15 dsm_est 1.67508e-14 nsteps 800 + h 0.0003125 rk_type 1 order 4 acc 0 t 1.25 dsm 1.49538e-13 dsm_est 3.98278e-13 nsteps 801 + h 0.0003125 rk_type 1 order 4 acc 0 t 1.5 dsm 1.0257e-13 dsm_est 6.56125e-12 nsteps 801 + h 0.0003125 rk_type 1 order 4 acc 0 t 1.75 dsm 4.74681e-14 dsm_est 1.51192e-12 nsteps 801 + h 0.0003125 rk_type 1 order 4 acc 0 t 2 dsm 3.28771e-14 dsm_est 3.30065e-12 nsteps 801 + h 0.0003125 rk_type 1 order 4 acc 0 t 2.25 dsm 2.08777e-13 dsm_est 4.21238e-14 nsteps 800 + h 0.0003125 rk_type 1 order 4 acc 0 t 2.5 dsm 1.03256e-14 dsm_est 4.61805e-14 nsteps 800 + h 0.0003125 rk_type 1 order 4 acc 0 t 2.75 dsm 1.44079e-14 dsm_est 1.10761e-13 nsteps 800 + h 0.0003125 rk_type 1 order 4 acc 0 t 3 dsm 6.86653e-14 dsm_est 1.69952e-13 nsteps 800 + h 0.0003125 rk_type 1 order 4 acc 0 t 3.25 dsm 4.56716e-14 dsm_est 5.51242e-14 nsteps 800 + h 0.0003125 rk_type 1 order 4 acc 0 t 3.5 dsm 1.14798e-14 dsm_est 5.39133e-15 nsteps 800 + h 0.0003125 rk_type 1 order 4 acc 0 t 3.75 dsm 1.10427e-14 dsm_est 1.17036e-14 nsteps 800 + h 0.0003125 rk_type 1 order 4 acc 0 t 4 dsm 5.31806e-14 dsm_est 2.65473e-15 nsteps 800 + h 0.0003125 rk_type 1 order 4 acc 0 t 4.25 dsm 2.08119e-13 dsm_est 2.85291e-14 nsteps 801 + h 0.0003125 rk_type 1 order 4 acc 0 t 4.5 dsm 1.57233e-14 dsm_est 4.76197e-15 nsteps 801 + h 0.0003125 rk_type 1 order 4 acc 0 t 4.75 dsm 1.39902e-13 dsm_est 5.98529e-14 nsteps 801 + h 0.0003125 rk_type 1 order 4 acc 0 t 5 dsm 7.63042e-14 dsm_est 2.56897e-14 nsteps 801 + h 0.0003125 rk_type 1 order 4 acc 1 t 0.25 dsm 9.97977e-16 dsm_est 1.49901e-17 nsteps 800 + h 0.0003125 rk_type 1 order 4 acc 1 t 0.5 dsm 7.34738e-15 dsm_est 5.84231e-17 nsteps 800 + h 0.0003125 rk_type 1 order 4 acc 1 t 0.75 dsm 1.89479e-14 dsm_est 1.52806e-16 nsteps 800 + h 0.0003125 rk_type 1 order 4 acc 1 t 1 dsm 6.41345e-15 dsm_est 2.09385e-17 nsteps 800 + h 0.0003125 rk_type 1 order 4 acc 1 t 1.25 dsm 1.49538e-13 dsm_est 4.97226e-16 nsteps 801 + h 0.0003125 rk_type 1 order 4 acc 1 t 1.5 dsm 1.0257e-13 dsm_est 8.19133e-15 nsteps 801 + h 0.0003125 rk_type 1 order 4 acc 1 t 1.75 dsm 4.74681e-14 dsm_est 1.88754e-15 nsteps 801 + h 0.0003125 rk_type 1 order 4 acc 1 t 2 dsm 3.28771e-14 dsm_est 4.12066e-15 nsteps 801 + h 0.0003125 rk_type 1 order 4 acc 1 t 2.25 dsm 2.08777e-13 dsm_est 5.26547e-17 nsteps 800 + h 0.0003125 rk_type 1 order 4 acc 1 t 2.5 dsm 1.03256e-14 dsm_est 5.77257e-17 nsteps 800 + h 0.0003125 rk_type 1 order 4 acc 1 t 2.75 dsm 1.44079e-14 dsm_est 1.38452e-16 nsteps 800 + h 0.0003125 rk_type 1 order 4 acc 1 t 3 dsm 6.86653e-14 dsm_est 2.12439e-16 nsteps 800 + h 0.0003125 rk_type 1 order 4 acc 1 t 3.25 dsm 4.56716e-14 dsm_est 6.89052e-17 nsteps 800 + h 0.0003125 rk_type 1 order 4 acc 1 t 3.5 dsm 1.14798e-14 dsm_est 6.73916e-18 nsteps 800 + h 0.0003125 rk_type 1 order 4 acc 1 t 3.75 dsm 1.10427e-14 dsm_est 1.46294e-17 nsteps 800 + h 0.0003125 rk_type 1 order 4 acc 1 t 4 dsm 5.31806e-14 dsm_est 3.31841e-18 nsteps 800 + h 0.0003125 rk_type 1 order 4 acc 1 t 4.25 dsm 2.08119e-13 dsm_est 3.56169e-17 nsteps 801 + h 0.0003125 rk_type 1 order 4 acc 1 t 4.5 dsm 1.57233e-14 dsm_est 5.94504e-18 nsteps 801 + h 0.0003125 rk_type 1 order 4 acc 1 t 4.75 dsm 1.39902e-13 dsm_est 7.47228e-17 nsteps 801 + h 0.0003125 rk_type 1 order 4 acc 1 t 5 dsm 7.63042e-14 dsm_est 3.2072e-17 nsteps 801 + h 0.0003125 rk_type 1 order 4 acc 2 t 0.25 dsm 9.97977e-16 dsm_est 1.35296e-14 nsteps 1200 + h 0.0003125 rk_type 1 order 4 acc 2 t 0.5 dsm 7.34738e-15 dsm_est 3.14131e-14 nsteps 1200 + h 0.0003125 rk_type 1 order 4 acc 2 t 0.75 dsm 1.89479e-14 dsm_est 6.96153e-14 nsteps 1200 + h 0.0003125 rk_type 1 order 4 acc 2 t 1 dsm 6.41345e-15 dsm_est 1.77682e-13 nsteps 1200 + h 0.0003125 rk_type 1 order 4 acc 2 t 1.25 dsm 1.49538e-13 dsm_est 5.92376e-13 nsteps 1201 + h 0.0003125 rk_type 1 order 4 acc 2 t 1.5 dsm 1.0257e-13 dsm_est 9.50139e-13 nsteps 1201 + h 0.0003125 rk_type 1 order 4 acc 2 t 1.75 dsm 4.74681e-14 dsm_est 1.5963e-13 nsteps 1201 + h 0.0003125 rk_type 1 order 4 acc 2 t 2 dsm 3.28771e-14 dsm_est 2.52198e-13 nsteps 1201 + h 0.0003125 rk_type 1 order 4 acc 2 t 2.25 dsm 2.08777e-13 dsm_est 3.31346e-13 nsteps 1200 + h 0.0003125 rk_type 1 order 4 acc 2 t 2.5 dsm 1.03256e-14 dsm_est 3.26259e-14 nsteps 1200 + h 0.0003125 rk_type 1 order 4 acc 2 t 2.75 dsm 1.44079e-14 dsm_est 3.69706e-14 nsteps 1200 + h 0.0003125 rk_type 1 order 4 acc 2 t 3 dsm 6.86653e-14 dsm_est 8.29842e-14 nsteps 1200 + h 0.0003125 rk_type 1 order 4 acc 2 t 3.25 dsm 4.56716e-14 dsm_est 7.57076e-14 nsteps 1200 + h 0.0003125 rk_type 1 order 4 acc 2 t 3.5 dsm 1.14798e-14 dsm_est 4.72639e-14 nsteps 1200 + h 0.0003125 rk_type 1 order 4 acc 2 t 3.75 dsm 1.10427e-14 dsm_est 3.43678e-14 nsteps 1200 + h 0.0003125 rk_type 1 order 4 acc 2 t 4 dsm 5.31806e-14 dsm_est 4.43107e-14 nsteps 1200 + h 0.0003125 rk_type 1 order 4 acc 2 t 4.25 dsm 2.08119e-13 dsm_est 3.19466e-13 nsteps 1201 + h 0.0003125 rk_type 1 order 4 acc 2 t 4.5 dsm 1.57233e-14 dsm_est 3.54399e-14 nsteps 1201 + h 0.0003125 rk_type 1 order 4 acc 2 t 4.75 dsm 1.39902e-13 dsm_est 2.1045e-13 nsteps 1201 + h 0.0003125 rk_type 1 order 4 acc 2 t 5 dsm 7.63042e-14 dsm_est 1.1047e-13 nsteps 1201 + h 7.8125e-05 rk_type 1 order 4 acc 0 t 0.25 dsm 1.20076e-14 dsm_est 4.68152e-17 nsteps 3200 + h 7.8125e-05 rk_type 1 order 4 acc 0 t 0.5 dsm 6.92895e-14 dsm_est 1.82422e-16 nsteps 3201 + h 7.8125e-05 rk_type 1 order 4 acc 0 t 0.75 dsm 7.1887e-14 dsm_est 4.7344e-16 nsteps 3200 + h 7.8125e-05 rk_type 1 order 4 acc 0 t 1 dsm 5.29714e-14 dsm_est 6.51084e-17 nsteps 3200 + h 7.8125e-05 rk_type 1 order 4 acc 0 t 1.25 dsm 4.54758e-13 dsm_est 1.55315e-15 nsteps 3201 + h 7.8125e-05 rk_type 1 order 4 acc 0 t 1.5 dsm 1.61784e-13 dsm_est 2.57413e-14 nsteps 3201 + h 7.8125e-05 rk_type 1 order 4 acc 0 t 1.75 dsm 1.4649e-13 dsm_est 5.90317e-15 nsteps 3201 + h 7.8125e-05 rk_type 1 order 4 acc 0 t 2 dsm 6.85301e-14 dsm_est 1.28969e-14 nsteps 3201 + h 7.8125e-05 rk_type 1 order 4 acc 0 t 2.25 dsm 3.74507e-13 dsm_est 1.62039e-16 nsteps 3201 + h 7.8125e-05 rk_type 1 order 4 acc 0 t 2.5 dsm 1.92671e-14 dsm_est 1.8265e-16 nsteps 3201 + h 7.8125e-05 rk_type 1 order 4 acc 0 t 2.75 dsm 1.93516e-14 dsm_est 4.32788e-16 nsteps 3201 + h 7.8125e-05 rk_type 1 order 4 acc 0 t 3 dsm 1.23711e-13 dsm_est 6.63893e-16 nsteps 3201 + h 7.8125e-05 rk_type 1 order 4 acc 0 t 3.25 dsm 8.16997e-14 dsm_est 2.14904e-16 nsteps 3201 + h 7.8125e-05 rk_type 1 order 4 acc 0 t 3.5 dsm 1.95956e-14 dsm_est 2.1102e-17 nsteps 3201 + h 7.8125e-05 rk_type 1 order 4 acc 0 t 3.75 dsm 2.16401e-14 dsm_est 4.57959e-17 nsteps 3201 + h 7.8125e-05 rk_type 1 order 4 acc 0 t 4 dsm 9.37664e-14 dsm_est 1.0225e-17 nsteps 3201 + h 7.8125e-05 rk_type 1 order 4 acc 0 t 4.25 dsm 2.10442e-13 dsm_est 1.11615e-16 nsteps 3201 + h 7.8125e-05 rk_type 1 order 4 acc 0 t 4.5 dsm 1.64627e-14 dsm_est 1.89457e-17 nsteps 3201 + h 7.8125e-05 rk_type 1 order 4 acc 0 t 4.75 dsm 1.39177e-13 dsm_est 2.3562e-16 nsteps 3201 + h 7.8125e-05 rk_type 1 order 4 acc 0 t 5 dsm 7.51104e-14 dsm_est 1.00279e-16 nsteps 3201 + h 7.8125e-05 rk_type 1 order 4 acc 1 t 0.25 dsm 1.20076e-14 dsm_est 1.46298e-20 nsteps 3200 + h 7.8125e-05 rk_type 1 order 4 acc 1 t 0.5 dsm 6.92895e-14 dsm_est 5.69892e-20 nsteps 3201 + h 7.8125e-05 rk_type 1 order 4 acc 1 t 0.75 dsm 7.1887e-14 dsm_est 1.4795e-19 nsteps 3200 + h 7.8125e-05 rk_type 1 order 4 acc 1 t 1 dsm 5.29714e-14 dsm_est 2.03464e-20 nsteps 3200 + h 7.8125e-05 rk_type 1 order 4 acc 1 t 1.25 dsm 4.54758e-13 dsm_est 4.85208e-19 nsteps 3201 + h 7.8125e-05 rk_type 1 order 4 acc 1 t 1.5 dsm 1.61784e-13 dsm_est 8.04164e-18 nsteps 3201 + h 7.8125e-05 rk_type 1 order 4 acc 1 t 1.75 dsm 1.4649e-13 dsm_est 1.84416e-18 nsteps 3201 + h 7.8125e-05 rk_type 1 order 4 acc 1 t 2 dsm 6.85301e-14 dsm_est 4.02902e-18 nsteps 3201 + h 7.8125e-05 rk_type 1 order 4 acc 1 t 2.25 dsm 3.74507e-13 dsm_est 5.06214e-20 nsteps 3201 + h 7.8125e-05 rk_type 1 order 4 acc 1 t 2.5 dsm 1.92671e-14 dsm_est 5.70603e-20 nsteps 3201 + h 7.8125e-05 rk_type 1 order 4 acc 1 t 2.75 dsm 1.93516e-14 dsm_est 1.35204e-19 nsteps 3201 + h 7.8125e-05 rk_type 1 order 4 acc 1 t 3 dsm 1.23711e-13 dsm_est 2.07402e-19 nsteps 3201 + h 7.8125e-05 rk_type 1 order 4 acc 1 t 3.25 dsm 8.16997e-14 dsm_est 6.71366e-20 nsteps 3201 + h 7.8125e-05 rk_type 1 order 4 acc 1 t 3.5 dsm 1.95956e-14 dsm_est 6.5923e-21 nsteps 3201 + h 7.8125e-05 rk_type 1 order 4 acc 1 t 3.75 dsm 2.16401e-14 dsm_est 1.43067e-20 nsteps 3201 + h 7.8125e-05 rk_type 1 order 4 acc 1 t 4 dsm 9.37664e-14 dsm_est 3.19433e-21 nsteps 3201 + h 7.8125e-05 rk_type 1 order 4 acc 1 t 4.25 dsm 2.10442e-13 dsm_est 3.48687e-20 nsteps 3201 + h 7.8125e-05 rk_type 1 order 4 acc 1 t 4.5 dsm 1.64627e-14 dsm_est 5.91869e-21 nsteps 3201 + h 7.8125e-05 rk_type 1 order 4 acc 1 t 4.75 dsm 1.39177e-13 dsm_est 7.36081e-20 nsteps 3201 + h 7.8125e-05 rk_type 1 order 4 acc 1 t 5 dsm 7.51104e-14 dsm_est 3.13274e-20 nsteps 3201 + h 7.8125e-05 rk_type 1 order 4 acc 2 t 0.25 dsm 1.20076e-14 dsm_est 9.70841e-15 nsteps 4800 + h 7.8125e-05 rk_type 1 order 4 acc 2 t 0.5 dsm 6.92895e-14 dsm_est 1.22494e-13 nsteps 4801 + h 7.8125e-05 rk_type 1 order 4 acc 2 t 0.75 dsm 7.1887e-14 dsm_est 1.01008e-13 nsteps 4801 + h 7.8125e-05 rk_type 1 order 4 acc 2 t 1 dsm 5.29714e-14 dsm_est 7.31368e-14 nsteps 4801 + h 7.8125e-05 rk_type 1 order 4 acc 2 t 1.25 dsm 4.54758e-13 dsm_est 7.05734e-13 nsteps 4801 + h 7.8125e-05 rk_type 1 order 4 acc 2 t 1.5 dsm 1.61784e-13 dsm_est 2.49851e-13 nsteps 4801 + h 7.8125e-05 rk_type 1 order 4 acc 2 t 1.75 dsm 1.4649e-13 dsm_est 2.2764e-13 nsteps 4801 + h 7.8125e-05 rk_type 1 order 4 acc 2 t 2 dsm 6.85301e-14 dsm_est 1.06912e-13 nsteps 4801 + h 7.8125e-05 rk_type 1 order 4 acc 2 t 2.25 dsm 3.74507e-13 dsm_est 1.85903e-15 nsteps 4802 + h 7.8125e-05 rk_type 1 order 4 acc 2 t 2.5 dsm 1.92671e-14 dsm_est 4.28748e-15 nsteps 4802 + h 7.8125e-05 rk_type 1 order 4 acc 2 t 2.75 dsm 1.93516e-14 dsm_est 3.17803e-15 nsteps 4802 + h 7.8125e-05 rk_type 1 order 4 acc 2 t 3 dsm 1.23711e-13 dsm_est 2.14064e-15 nsteps 4802 + h 7.8125e-05 rk_type 1 order 4 acc 2 t 3.25 dsm 8.16997e-14 dsm_est 9.8125e-16 nsteps 4802 + h 7.8125e-05 rk_type 1 order 4 acc 2 t 3.5 dsm 1.95956e-14 dsm_est 1.42241e-15 nsteps 4802 + h 7.8125e-05 rk_type 1 order 4 acc 2 t 3.75 dsm 2.16401e-14 dsm_est 9.52702e-16 nsteps 4802 + h 7.8125e-05 rk_type 1 order 4 acc 2 t 4 dsm 9.37664e-14 dsm_est 1.67292e-15 nsteps 4802 + h 7.8125e-05 rk_type 1 order 4 acc 2 t 4.25 dsm 2.10442e-13 dsm_est 5.74872e-16 nsteps 4802 + h 7.8125e-05 rk_type 1 order 4 acc 2 t 4.5 dsm 1.64627e-14 dsm_est 2.39534e-15 nsteps 4802 + h 7.8125e-05 rk_type 1 order 4 acc 2 t 4.75 dsm 1.39177e-13 dsm_est 1.10424e-15 nsteps 4802 + h 7.8125e-05 rk_type 1 order 4 acc 2 t 5 dsm 7.51104e-14 dsm_est 1.21712e-15 nsteps 4802 diff --git a/test/unit_tests/arkode/CXX_serial/ark_test_accumerror_kpr_20_2_0.out b/test/unit_tests/arkode/CXX_serial/ark_test_accumerror_kpr_20_2_0.out new file mode 100644 index 0000000000..d6a9b75054 --- /dev/null +++ b/test/unit_tests/arkode/CXX_serial/ark_test_accumerror_kpr_20_2_0.out @@ -0,0 +1,130 @@ + +Accumulated error estimation test (Nonlinear Kvaerno-Prothero-Robinson problem): + time domain: (0,5] + partition size = 20 + G = -10 + e = 0.1 + omega = 5 + DIRK solver, order = 2 + +Adaptive-step runs: + rtol 0.01 rk_type 0 order 2 acc 0 t 0.25 dsm 5.77245e-05 dsm_est 0.00686971 nsteps 9 + rtol 0.01 rk_type 0 order 2 acc 0 t 0.5 dsm 0.00372257 dsm_est 0.00877859 nsteps 8 + rtol 0.01 rk_type 0 order 2 acc 0 t 0.75 dsm 0.000232425 dsm_est 0.0066976 nsteps 13 + rtol 0.01 rk_type 0 order 2 acc 0 t 1 dsm 0.00327055 dsm_est 0.00759421 nsteps 9 + rtol 0.01 rk_type 0 order 2 acc 0 t 1.25 dsm 0.00363058 dsm_est 0.00633487 nsteps 16 + rtol 0.01 rk_type 0 order 2 acc 0 t 1.5 dsm 0.00267076 dsm_est 0.00679482 nsteps 12 + rtol 0.01 rk_type 0 order 2 acc 0 t 1.75 dsm 0.00971976 dsm_est 0.00698823 nsteps 16 + rtol 0.01 rk_type 0 order 2 acc 0 t 2 dsm 0.000918207 dsm_est 0.00684032 nsteps 14 + rtol 0.01 rk_type 0 order 2 acc 0 t 2.25 dsm 0.0016944 dsm_est 0.00722321 nsteps 10 + rtol 0.01 rk_type 0 order 2 acc 0 t 2.5 dsm 0.0056199 dsm_est 0.00390805 nsteps 7 + rtol 0.01 rk_type 0 order 2 acc 0 t 2.75 dsm 0.00855479 dsm_est 0.00899318 nsteps 6 + rtol 0.01 rk_type 0 order 2 acc 0 t 3 dsm 0.0023308 dsm_est 0.00881185 nsteps 7 + rtol 0.01 rk_type 0 order 2 acc 0 t 3.25 dsm 0.000539467 dsm_est 0.00351937 nsteps 8 + rtol 0.01 rk_type 0 order 2 acc 0 t 3.5 dsm 0.000312605 dsm_est 0.00446438 nsteps 6 + rtol 0.01 rk_type 0 order 2 acc 0 t 3.75 dsm 0.00144605 dsm_est 0.00759178 nsteps 4 + rtol 0.01 rk_type 0 order 2 acc 0 t 4 dsm 0.00023147 dsm_est 0.0031488 nsteps 7 + rtol 0.01 rk_type 0 order 2 acc 0 t 4.25 dsm 0.00806953 dsm_est 0.00741572 nsteps 4 + rtol 0.01 rk_type 0 order 2 acc 0 t 4.5 dsm 0.000322019 dsm_est 0.00679423 nsteps 11 + rtol 0.01 rk_type 0 order 2 acc 0 t 4.75 dsm 0.00405487 dsm_est 0.00313156 nsteps 7 + rtol 0.01 rk_type 0 order 2 acc 0 t 5 dsm 0.000699178 dsm_est 0.0036148 nsteps 8 + rtol 0.01 rk_type 0 order 2 acc 1 t 0.25 dsm 5.77245e-05 dsm_est 0.00183312 nsteps 9 + rtol 0.01 rk_type 0 order 2 acc 1 t 0.5 dsm 0.00372257 dsm_est 0.0026276 nsteps 8 + rtol 0.01 rk_type 0 order 2 acc 1 t 0.75 dsm 0.000232425 dsm_est 0.00237463 nsteps 13 + rtol 0.01 rk_type 0 order 2 acc 1 t 1 dsm 0.00327055 dsm_est 0.00377797 nsteps 9 + rtol 0.01 rk_type 0 order 2 acc 1 t 1.25 dsm 0.00363058 dsm_est 0.00286963 nsteps 16 + rtol 0.01 rk_type 0 order 2 acc 1 t 1.5 dsm 0.00267076 dsm_est 0.00422946 nsteps 12 + rtol 0.01 rk_type 0 order 2 acc 1 t 1.75 dsm 0.00971976 dsm_est 0.00351813 nsteps 16 + rtol 0.01 rk_type 0 order 2 acc 1 t 2 dsm 0.000918207 dsm_est 0.00268129 nsteps 14 + rtol 0.01 rk_type 0 order 2 acc 1 t 2.25 dsm 0.0016944 dsm_est 0.0031166 nsteps 10 + rtol 0.01 rk_type 0 order 2 acc 1 t 2.5 dsm 0.0056199 dsm_est 0.00138151 nsteps 7 + rtol 0.01 rk_type 0 order 2 acc 1 t 2.75 dsm 0.00855479 dsm_est 0.00234303 nsteps 6 + rtol 0.01 rk_type 0 order 2 acc 1 t 3 dsm 0.0023308 dsm_est 0.00207814 nsteps 7 + rtol 0.01 rk_type 0 order 2 acc 1 t 3.25 dsm 0.000539467 dsm_est 0.00139745 nsteps 8 + rtol 0.01 rk_type 0 order 2 acc 1 t 3.5 dsm 0.000312605 dsm_est 0.00128426 nsteps 6 + rtol 0.01 rk_type 0 order 2 acc 1 t 3.75 dsm 0.00144605 dsm_est 0.00243161 nsteps 4 + rtol 0.01 rk_type 0 order 2 acc 1 t 4 dsm 0.00023147 dsm_est 0.00140273 nsteps 7 + rtol 0.01 rk_type 0 order 2 acc 1 t 4.25 dsm 0.00806953 dsm_est 0.00295759 nsteps 4 + rtol 0.01 rk_type 0 order 2 acc 1 t 4.5 dsm 0.000322019 dsm_est 0.00239066 nsteps 11 + rtol 0.01 rk_type 0 order 2 acc 1 t 4.75 dsm 0.00405487 dsm_est 0.00089527 nsteps 7 + rtol 0.01 rk_type 0 order 2 acc 1 t 5 dsm 0.000699178 dsm_est 0.00160895 nsteps 8 + rtol 0.0001 rk_type 0 order 2 acc 0 t 0.25 dsm 7.46709e-07 dsm_est 7.18663e-05 nsteps 49 + rtol 0.0001 rk_type 0 order 2 acc 0 t 0.5 dsm 6.50352e-05 dsm_est 7.49302e-05 nsteps 42 + rtol 0.0001 rk_type 0 order 2 acc 0 t 0.75 dsm 4.48379e-06 dsm_est 7.39118e-05 nsteps 84 + rtol 0.0001 rk_type 0 order 2 acc 0 t 1 dsm 3.76158e-05 dsm_est 7.93376e-05 nsteps 61 + rtol 0.0001 rk_type 0 order 2 acc 0 t 1.25 dsm 6.82164e-05 dsm_est 9.03489e-05 nsteps 110 + rtol 0.0001 rk_type 0 order 2 acc 0 t 1.5 dsm 3.68171e-05 dsm_est 8.51313e-05 nsteps 109 + rtol 0.0001 rk_type 0 order 2 acc 0 t 1.75 dsm 2.35133e-05 dsm_est 8.17961e-05 nsteps 136 + rtol 0.0001 rk_type 0 order 2 acc 0 t 2 dsm 1.61655e-05 dsm_est 6.74799e-05 nsteps 91 + rtol 0.0001 rk_type 0 order 2 acc 0 t 2.25 dsm 6.22229e-05 dsm_est 8.55795e-05 nsteps 65 + rtol 0.0001 rk_type 0 order 2 acc 0 t 2.5 dsm 4.95459e-05 dsm_est 9.95948e-05 nsteps 38 + rtol 0.0001 rk_type 0 order 2 acc 0 t 2.75 dsm 4.09894e-05 dsm_est 7.97659e-05 nsteps 35 + rtol 0.0001 rk_type 0 order 2 acc 0 t 3 dsm 3.51226e-05 dsm_est 9.83341e-05 nsteps 41 + rtol 0.0001 rk_type 0 order 2 acc 0 t 3.25 dsm 9.918e-06 dsm_est 7.80442e-05 nsteps 34 + rtol 0.0001 rk_type 0 order 2 acc 0 t 3.5 dsm 6.68205e-06 dsm_est 6.93297e-05 nsteps 29 + rtol 0.0001 rk_type 0 order 2 acc 0 t 3.75 dsm 1.12533e-05 dsm_est 7.07769e-05 nsteps 22 + rtol 0.0001 rk_type 0 order 2 acc 0 t 4 dsm 4.18856e-06 dsm_est 7.35665e-05 nsteps 31 + rtol 0.0001 rk_type 0 order 2 acc 0 t 4.25 dsm 5.65033e-05 dsm_est 9.50758e-05 nsteps 27 + rtol 0.0001 rk_type 0 order 2 acc 0 t 4.5 dsm 8.06381e-06 dsm_est 7.57142e-05 nsteps 60 + rtol 0.0001 rk_type 0 order 2 acc 0 t 4.75 dsm 3.08146e-05 dsm_est 7.53944e-05 nsteps 36 + rtol 0.0001 rk_type 0 order 2 acc 0 t 5 dsm 1.43844e-05 dsm_est 7.56604e-05 nsteps 37 + rtol 0.0001 rk_type 0 order 2 acc 1 t 0.25 dsm 7.46709e-07 dsm_est 3.89514e-05 nsteps 49 + rtol 0.0001 rk_type 0 order 2 acc 1 t 0.5 dsm 6.50352e-05 dsm_est 4.87422e-05 nsteps 42 + rtol 0.0001 rk_type 0 order 2 acc 1 t 0.75 dsm 4.48379e-06 dsm_est 4.52376e-05 nsteps 84 + rtol 0.0001 rk_type 0 order 2 acc 1 t 1 dsm 3.76158e-05 dsm_est 5.97057e-05 nsteps 61 + rtol 0.0001 rk_type 0 order 2 acc 1 t 1.25 dsm 6.82164e-05 dsm_est 5.09587e-05 nsteps 110 + rtol 0.0001 rk_type 0 order 2 acc 1 t 1.5 dsm 3.68171e-05 dsm_est 5.14096e-05 nsteps 109 + rtol 0.0001 rk_type 0 order 2 acc 1 t 1.75 dsm 2.35133e-05 dsm_est 4.76173e-05 nsteps 136 + rtol 0.0001 rk_type 0 order 2 acc 1 t 2 dsm 1.61655e-05 dsm_est 5.09324e-05 nsteps 91 + rtol 0.0001 rk_type 0 order 2 acc 1 t 2.25 dsm 6.22229e-05 dsm_est 5.36928e-05 nsteps 65 + rtol 0.0001 rk_type 0 order 2 acc 1 t 2.5 dsm 4.95459e-05 dsm_est 4.4449e-05 nsteps 38 + rtol 0.0001 rk_type 0 order 2 acc 1 t 2.75 dsm 4.09894e-05 dsm_est 5.85403e-05 nsteps 35 + rtol 0.0001 rk_type 0 order 2 acc 1 t 3 dsm 3.51226e-05 dsm_est 3.83191e-05 nsteps 41 + rtol 0.0001 rk_type 0 order 2 acc 1 t 3.25 dsm 9.918e-06 dsm_est 4.95986e-05 nsteps 34 + rtol 0.0001 rk_type 0 order 2 acc 1 t 3.5 dsm 6.68205e-06 dsm_est 3.60708e-05 nsteps 29 + rtol 0.0001 rk_type 0 order 2 acc 1 t 3.75 dsm 1.12533e-05 dsm_est 5.1455e-05 nsteps 22 + rtol 0.0001 rk_type 0 order 2 acc 1 t 4 dsm 4.18856e-06 dsm_est 4.77684e-05 nsteps 31 + rtol 0.0001 rk_type 0 order 2 acc 1 t 4.25 dsm 5.65033e-05 dsm_est 4.91962e-05 nsteps 27 + rtol 0.0001 rk_type 0 order 2 acc 1 t 4.5 dsm 8.06381e-06 dsm_est 5.56661e-05 nsteps 60 + rtol 0.0001 rk_type 0 order 2 acc 1 t 4.75 dsm 3.08146e-05 dsm_est 3.80468e-05 nsteps 36 + rtol 0.0001 rk_type 0 order 2 acc 1 t 5 dsm 1.43844e-05 dsm_est 5.58721e-05 nsteps 37 + rtol 1e-06 rk_type 0 order 2 acc 0 t 0.25 dsm 5.66725e-09 dsm_est 7.18787e-07 nsteps 488 + rtol 1e-06 rk_type 0 order 2 acc 0 t 0.5 dsm 9.92276e-07 dsm_est 8.1602e-07 nsteps 403 + rtol 1e-06 rk_type 0 order 2 acc 0 t 0.75 dsm 8.0717e-08 dsm_est 7.2088e-07 nsteps 823 + rtol 1e-06 rk_type 0 order 2 acc 0 t 1 dsm 5.67858e-07 dsm_est 9.90249e-07 nsteps 596 + rtol 1e-06 rk_type 0 order 2 acc 0 t 1.25 dsm 1.03484e-06 dsm_est 7.69939e-07 nsteps 1091 + rtol 1e-06 rk_type 0 order 2 acc 0 t 1.5 dsm 5.45182e-07 dsm_est 9.21351e-07 nsteps 1080 + rtol 1e-06 rk_type 0 order 2 acc 0 t 1.75 dsm 3.61096e-07 dsm_est 8.11495e-07 nsteps 1337 + rtol 1e-06 rk_type 0 order 2 acc 0 t 2 dsm 2.2003e-07 dsm_est 6.89881e-07 nsteps 898 + rtol 1e-06 rk_type 0 order 2 acc 0 t 2.25 dsm 9.38782e-07 dsm_est 7.22168e-07 nsteps 635 + rtol 1e-06 rk_type 0 order 2 acc 0 t 2.5 dsm 5.20042e-07 dsm_est 7.8752e-07 nsteps 372 + rtol 1e-06 rk_type 0 order 2 acc 0 t 2.75 dsm 4.66825e-07 dsm_est 7.09276e-07 nsteps 354 + rtol 1e-06 rk_type 0 order 2 acc 0 t 3 dsm 3.30086e-07 dsm_est 7.18289e-07 nsteps 409 + rtol 1e-06 rk_type 0 order 2 acc 0 t 3.25 dsm 1.19548e-07 dsm_est 7.25689e-07 nsteps 320 + rtol 1e-06 rk_type 0 order 2 acc 0 t 3.5 dsm 4.13474e-08 dsm_est 7.16259e-07 nsteps 288 + rtol 1e-06 rk_type 0 order 2 acc 0 t 3.75 dsm 1.02293e-07 dsm_est 7.17021e-07 nsteps 225 + rtol 1e-06 rk_type 0 order 2 acc 0 t 4 dsm 3.98477e-08 dsm_est 7.20467e-07 nsteps 304 + rtol 1e-06 rk_type 0 order 2 acc 0 t 4.25 dsm 7.93335e-07 dsm_est 7.48243e-07 nsteps 268 + rtol 1e-06 rk_type 0 order 2 acc 0 t 4.5 dsm 7.4366e-08 dsm_est 7.22713e-07 nsteps 597 + rtol 1e-06 rk_type 0 order 2 acc 0 t 4.75 dsm 5.08713e-07 dsm_est 8.6505e-07 nsteps 347 + rtol 1e-06 rk_type 0 order 2 acc 0 t 5 dsm 1.42752e-07 dsm_est 7.22893e-07 nsteps 366 + rtol 1e-06 rk_type 0 order 2 acc 1 t 0.25 dsm 5.66725e-09 dsm_est 3.91786e-07 nsteps 488 + rtol 1e-06 rk_type 0 order 2 acc 1 t 0.5 dsm 9.92276e-07 dsm_est 5.14717e-07 nsteps 403 + rtol 1e-06 rk_type 0 order 2 acc 1 t 0.75 dsm 8.0717e-08 dsm_est 4.71859e-07 nsteps 823 + rtol 1e-06 rk_type 0 order 2 acc 1 t 1 dsm 5.67858e-07 dsm_est 6.13342e-07 nsteps 596 + rtol 1e-06 rk_type 0 order 2 acc 1 t 1.25 dsm 1.03484e-06 dsm_est 5.1167e-07 nsteps 1091 + rtol 1e-06 rk_type 0 order 2 acc 1 t 1.5 dsm 5.45182e-07 dsm_est 5.19559e-07 nsteps 1080 + rtol 1e-06 rk_type 0 order 2 acc 1 t 1.75 dsm 3.61096e-07 dsm_est 4.83426e-07 nsteps 1337 + rtol 1e-06 rk_type 0 order 2 acc 1 t 2 dsm 2.2003e-07 dsm_est 5.21923e-07 nsteps 898 + rtol 1e-06 rk_type 0 order 2 acc 1 t 2.25 dsm 9.38782e-07 dsm_est 5.48693e-07 nsteps 635 + rtol 1e-06 rk_type 0 order 2 acc 1 t 2.5 dsm 5.20042e-07 dsm_est 4.49869e-07 nsteps 372 + rtol 1e-06 rk_type 0 order 2 acc 1 t 2.75 dsm 4.66825e-07 dsm_est 5.75673e-07 nsteps 354 + rtol 1e-06 rk_type 0 order 2 acc 1 t 3 dsm 3.30086e-07 dsm_est 3.88553e-07 nsteps 409 + rtol 1e-06 rk_type 0 order 2 acc 1 t 3.25 dsm 1.19548e-07 dsm_est 5.56086e-07 nsteps 320 + rtol 1e-06 rk_type 0 order 2 acc 1 t 3.5 dsm 4.13474e-08 dsm_est 3.61457e-07 nsteps 288 + rtol 1e-06 rk_type 0 order 2 acc 1 t 3.75 dsm 1.02293e-07 dsm_est 5.03828e-07 nsteps 225 + rtol 1e-06 rk_type 0 order 2 acc 1 t 4 dsm 3.98477e-08 dsm_est 4.97667e-07 nsteps 304 + rtol 1e-06 rk_type 0 order 2 acc 1 t 4.25 dsm 7.93335e-07 dsm_est 4.85132e-07 nsteps 268 + rtol 1e-06 rk_type 0 order 2 acc 1 t 4.5 dsm 7.4366e-08 dsm_est 5.62809e-07 nsteps 597 + rtol 1e-06 rk_type 0 order 2 acc 1 t 4.75 dsm 5.08713e-07 dsm_est 4.12187e-07 nsteps 347 + rtol 1e-06 rk_type 0 order 2 acc 1 t 5 dsm 1.42752e-07 dsm_est 5.76073e-07 nsteps 366 diff --git a/test/unit_tests/arkode/CXX_serial/ark_test_accumerror_kpr_20_3_1.out b/test/unit_tests/arkode/CXX_serial/ark_test_accumerror_kpr_20_3_1.out new file mode 100644 index 0000000000..bc52bf93d6 --- /dev/null +++ b/test/unit_tests/arkode/CXX_serial/ark_test_accumerror_kpr_20_3_1.out @@ -0,0 +1,130 @@ + +Accumulated error estimation test (Nonlinear Kvaerno-Prothero-Robinson problem): + time domain: (0,5] + partition size = 20 + G = -10 + e = 0.1 + omega = 5 + ERK solver, order = 3 + +Adaptive-step runs: + rtol 0.01 rk_type 1 order 3 acc 0 t 0.25 dsm 6.04149e-05 dsm_est 0.000128901 nsteps 5 + rtol 0.01 rk_type 1 order 3 acc 0 t 0.5 dsm 0.000268262 dsm_est 0.00122853 nsteps 5 + rtol 0.01 rk_type 1 order 3 acc 0 t 0.75 dsm 0.000162426 dsm_est 0.00195582 nsteps 5 + rtol 0.01 rk_type 1 order 3 acc 0 t 1 dsm 0.00010345 dsm_est 0.0018572 nsteps 5 + rtol 0.01 rk_type 1 order 3 acc 0 t 1.25 dsm 0.00145293 dsm_est 0.00223784 nsteps 7 + rtol 0.01 rk_type 1 order 3 acc 0 t 1.5 dsm 0.000475504 dsm_est 0.00220612 nsteps 6 + rtol 0.01 rk_type 1 order 3 acc 0 t 1.75 dsm 0.000953909 dsm_est 0.00848961 nsteps 5 + rtol 0.01 rk_type 1 order 3 acc 0 t 2 dsm 0.00190469 dsm_est 0.00438086 nsteps 6 + rtol 0.01 rk_type 1 order 3 acc 0 t 2.25 dsm 0.00091692 dsm_est 0.00242184 nsteps 5 + rtol 0.01 rk_type 1 order 3 acc 0 t 2.5 dsm 0.000303064 dsm_est 0.00155453 nsteps 5 + rtol 0.01 rk_type 1 order 3 acc 0 t 2.75 dsm 8.75302e-05 dsm_est 0.000628795 nsteps 5 + rtol 0.01 rk_type 1 order 3 acc 0 t 3 dsm 0.000106108 dsm_est 0.000628042 nsteps 5 + rtol 0.01 rk_type 1 order 3 acc 0 t 3.25 dsm 0.000146676 dsm_est 0.000206402 nsteps 5 + rtol 0.01 rk_type 1 order 3 acc 0 t 3.5 dsm 0.000132279 dsm_est 0.000121892 nsteps 5 + rtol 0.01 rk_type 1 order 3 acc 0 t 3.75 dsm 0.000106549 dsm_est 7.66243e-05 nsteps 5 + rtol 0.01 rk_type 1 order 3 acc 0 t 4 dsm 7.68783e-05 dsm_est 6.29323e-05 nsteps 5 + rtol 0.01 rk_type 1 order 3 acc 0 t 4.25 dsm 9.2941e-05 dsm_est 0.000487848 nsteps 5 + rtol 0.01 rk_type 1 order 3 acc 0 t 4.5 dsm 1.84821e-05 dsm_est 0.000635863 nsteps 5 + rtol 0.01 rk_type 1 order 3 acc 0 t 4.75 dsm 6.25225e-05 dsm_est 0.000713957 nsteps 5 + rtol 0.01 rk_type 1 order 3 acc 0 t 5 dsm 1.27772e-05 dsm_est 0.000232819 nsteps 5 + rtol 0.01 rk_type 1 order 3 acc 1 t 0.25 dsm 6.04149e-05 dsm_est 2.84962e-05 nsteps 5 + rtol 0.01 rk_type 1 order 3 acc 1 t 0.5 dsm 0.000268262 dsm_est 0.00035888 nsteps 5 + rtol 0.01 rk_type 1 order 3 acc 1 t 0.75 dsm 0.000162426 dsm_est 0.000612632 nsteps 5 + rtol 0.01 rk_type 1 order 3 acc 1 t 1 dsm 0.00010345 dsm_est 0.000591054 nsteps 5 + rtol 0.01 rk_type 1 order 3 acc 1 t 1.25 dsm 0.00145293 dsm_est 0.000651262 nsteps 7 + rtol 0.01 rk_type 1 order 3 acc 1 t 1.5 dsm 0.000475504 dsm_est 0.000619088 nsteps 6 + rtol 0.01 rk_type 1 order 3 acc 1 t 1.75 dsm 0.000953909 dsm_est 0.00225203 nsteps 5 + rtol 0.01 rk_type 1 order 3 acc 1 t 2 dsm 0.00190469 dsm_est 0.00106139 nsteps 6 + rtol 0.01 rk_type 1 order 3 acc 1 t 2.25 dsm 0.00091692 dsm_est 0.000519458 nsteps 5 + rtol 0.01 rk_type 1 order 3 acc 1 t 2.5 dsm 0.000303064 dsm_est 0.000373224 nsteps 5 + rtol 0.01 rk_type 1 order 3 acc 1 t 2.75 dsm 8.75302e-05 dsm_est 0.000251533 nsteps 5 + rtol 0.01 rk_type 1 order 3 acc 1 t 3 dsm 0.000106108 dsm_est 0.000216057 nsteps 5 + rtol 0.01 rk_type 1 order 3 acc 1 t 3.25 dsm 0.000146676 dsm_est 5.74422e-05 nsteps 5 + rtol 0.01 rk_type 1 order 3 acc 1 t 3.5 dsm 0.000132279 dsm_est 3.97606e-05 nsteps 5 + rtol 0.01 rk_type 1 order 3 acc 1 t 3.75 dsm 0.000106549 dsm_est 2.55114e-05 nsteps 5 + rtol 0.01 rk_type 1 order 3 acc 1 t 4 dsm 7.68783e-05 dsm_est 1.97574e-05 nsteps 5 + rtol 0.01 rk_type 1 order 3 acc 1 t 4.25 dsm 9.2941e-05 dsm_est 0.000147815 nsteps 5 + rtol 0.01 rk_type 1 order 3 acc 1 t 4.5 dsm 1.84821e-05 dsm_est 0.000156419 nsteps 5 + rtol 0.01 rk_type 1 order 3 acc 1 t 4.75 dsm 6.25225e-05 dsm_est 0.000247722 nsteps 5 + rtol 0.01 rk_type 1 order 3 acc 1 t 5 dsm 1.27772e-05 dsm_est 6.70899e-05 nsteps 5 + rtol 0.0001 rk_type 1 order 3 acc 0 t 0.25 dsm 2.72131e-05 dsm_est 1.82775e-05 nsteps 6 + rtol 0.0001 rk_type 1 order 3 acc 0 t 0.5 dsm 1.24325e-05 dsm_est 7.57337e-05 nsteps 10 + rtol 0.0001 rk_type 1 order 3 acc 0 t 0.75 dsm 3.04294e-06 dsm_est 5.32249e-05 nsteps 11 + rtol 0.0001 rk_type 1 order 3 acc 0 t 1 dsm 5.56473e-06 dsm_est 4.83864e-05 nsteps 10 + rtol 0.0001 rk_type 1 order 3 acc 0 t 1.25 dsm 2.64925e-05 dsm_est 9.09824e-05 nsteps 14 + rtol 0.0001 rk_type 1 order 3 acc 0 t 1.5 dsm 3.99013e-05 dsm_est 6.618e-05 nsteps 17 + rtol 0.0001 rk_type 1 order 3 acc 0 t 1.75 dsm 6.46566e-06 dsm_est 9.0814e-05 nsteps 20 + rtol 0.0001 rk_type 1 order 3 acc 0 t 2 dsm 2.27591e-05 dsm_est 4.33739e-05 nsteps 14 + rtol 0.0001 rk_type 1 order 3 acc 0 t 2.25 dsm 2.35987e-05 dsm_est 6.01739e-05 nsteps 12 + rtol 0.0001 rk_type 1 order 3 acc 0 t 2.5 dsm 1.9839e-05 dsm_est 5.21299e-05 nsteps 10 + rtol 0.0001 rk_type 1 order 3 acc 0 t 2.75 dsm 4.82543e-06 dsm_est 7.16519e-05 nsteps 9 + rtol 0.0001 rk_type 1 order 3 acc 0 t 3 dsm 1.42111e-05 dsm_est 8.44199e-05 nsteps 9 + rtol 0.0001 rk_type 1 order 3 acc 0 t 3.25 dsm 8.99237e-05 dsm_est 5.93926e-05 nsteps 6 + rtol 0.0001 rk_type 1 order 3 acc 0 t 3.5 dsm 7.05943e-05 dsm_est 2.57508e-05 nsteps 6 + rtol 0.0001 rk_type 1 order 3 acc 0 t 3.75 dsm 0.00011745 dsm_est 7.78236e-05 nsteps 5 + rtol 0.0001 rk_type 1 order 3 acc 0 t 4 dsm 8.6392e-05 dsm_est 6.06003e-05 nsteps 5 + rtol 0.0001 rk_type 1 order 3 acc 0 t 4.25 dsm 1.06282e-05 dsm_est 9.64146e-05 nsteps 8 + rtol 0.0001 rk_type 1 order 3 acc 0 t 4.5 dsm 3.00465e-06 dsm_est 6.91731e-05 nsteps 9 + rtol 0.0001 rk_type 1 order 3 acc 0 t 4.75 dsm 2.24177e-06 dsm_est 6.08731e-05 nsteps 9 + rtol 0.0001 rk_type 1 order 3 acc 0 t 5 dsm 4.61559e-06 dsm_est 3.8972e-05 nsteps 7 + rtol 0.0001 rk_type 1 order 3 acc 1 t 0.25 dsm 2.72131e-05 dsm_est 8.20667e-06 nsteps 6 + rtol 0.0001 rk_type 1 order 3 acc 1 t 0.5 dsm 1.24325e-05 dsm_est 2.77893e-05 nsteps 10 + rtol 0.0001 rk_type 1 order 3 acc 1 t 0.75 dsm 3.04294e-06 dsm_est 2.4191e-05 nsteps 11 + rtol 0.0001 rk_type 1 order 3 acc 1 t 1 dsm 5.56473e-06 dsm_est 2.1078e-05 nsteps 10 + rtol 0.0001 rk_type 1 order 3 acc 1 t 1.25 dsm 2.64925e-05 dsm_est 4.37622e-05 nsteps 14 + rtol 0.0001 rk_type 1 order 3 acc 1 t 1.5 dsm 3.99013e-05 dsm_est 2.21272e-05 nsteps 17 + rtol 0.0001 rk_type 1 order 3 acc 1 t 1.75 dsm 6.46566e-06 dsm_est 3.32327e-05 nsteps 20 + rtol 0.0001 rk_type 1 order 3 acc 1 t 2 dsm 2.27591e-05 dsm_est 1.88101e-05 nsteps 14 + rtol 0.0001 rk_type 1 order 3 acc 1 t 2.25 dsm 2.35987e-05 dsm_est 1.82395e-05 nsteps 12 + rtol 0.0001 rk_type 1 order 3 acc 1 t 2.5 dsm 1.9839e-05 dsm_est 1.44657e-05 nsteps 10 + rtol 0.0001 rk_type 1 order 3 acc 1 t 2.75 dsm 4.82543e-06 dsm_est 2.04852e-05 nsteps 9 + rtol 0.0001 rk_type 1 order 3 acc 1 t 3 dsm 1.42111e-05 dsm_est 2.59031e-05 nsteps 9 + rtol 0.0001 rk_type 1 order 3 acc 1 t 3.25 dsm 8.99237e-05 dsm_est 1.52677e-05 nsteps 6 + rtol 0.0001 rk_type 1 order 3 acc 1 t 3.5 dsm 7.05943e-05 dsm_est 1.07712e-05 nsteps 6 + rtol 0.0001 rk_type 1 order 3 acc 1 t 3.75 dsm 0.00011745 dsm_est 2.59539e-05 nsteps 5 + rtol 0.0001 rk_type 1 order 3 acc 1 t 4 dsm 8.6392e-05 dsm_est 2.17376e-05 nsteps 5 + rtol 0.0001 rk_type 1 order 3 acc 1 t 4.25 dsm 1.06282e-05 dsm_est 2.59085e-05 nsteps 8 + rtol 0.0001 rk_type 1 order 3 acc 1 t 4.5 dsm 3.00465e-06 dsm_est 1.89589e-05 nsteps 9 + rtol 0.0001 rk_type 1 order 3 acc 1 t 4.75 dsm 2.24177e-06 dsm_est 1.96451e-05 nsteps 9 + rtol 0.0001 rk_type 1 order 3 acc 1 t 5 dsm 4.61559e-06 dsm_est 1.20081e-05 nsteps 7 + rtol 1e-06 rk_type 1 order 3 acc 0 t 0.25 dsm 4.12033e-07 dsm_est 8.83529e-07 nsteps 17 + rtol 1e-06 rk_type 1 order 3 acc 0 t 0.5 dsm 2.46326e-07 dsm_est 8.87311e-07 nsteps 31 + rtol 1e-06 rk_type 1 order 3 acc 0 t 0.75 dsm 3.64026e-08 dsm_est 8.31388e-07 nsteps 39 + rtol 1e-06 rk_type 1 order 3 acc 0 t 1 dsm 2.25687e-07 dsm_est 5.06051e-07 nsteps 45 + rtol 1e-06 rk_type 1 order 3 acc 0 t 1.25 dsm 5.93423e-07 dsm_est 9.4211e-07 nsteps 53 + rtol 1e-06 rk_type 1 order 3 acc 0 t 1.5 dsm 6.11123e-07 dsm_est 7.4438e-07 nsteps 68 + rtol 1e-06 rk_type 1 order 3 acc 0 t 1.75 dsm 1.11041e-07 dsm_est 8.66272e-07 nsteps 76 + rtol 1e-06 rk_type 1 order 3 acc 0 t 2 dsm 4.68945e-07 dsm_est 8.0627e-07 nsteps 49 + rtol 1e-06 rk_type 1 order 3 acc 0 t 2.25 dsm 2.82077e-07 dsm_est 7.6683e-07 nsteps 46 + rtol 1e-06 rk_type 1 order 3 acc 0 t 2.5 dsm 3.42754e-07 dsm_est 6.52319e-07 nsteps 37 + rtol 1e-06 rk_type 1 order 3 acc 0 t 2.75 dsm 8.76441e-08 dsm_est 7.34826e-07 nsteps 30 + rtol 1e-06 rk_type 1 order 3 acc 0 t 3 dsm 9.61476e-08 dsm_est 8.15376e-07 nsteps 29 + rtol 1e-06 rk_type 1 order 3 acc 0 t 3.25 dsm 1.10578e-06 dsm_est 8.36809e-07 nsteps 19 + rtol 1e-06 rk_type 1 order 3 acc 0 t 3.5 dsm 8.13041e-07 dsm_est 6.57651e-07 nsteps 19 + rtol 1e-06 rk_type 1 order 3 acc 0 t 3.75 dsm 8.63105e-07 dsm_est 6.37719e-07 nsteps 15 + rtol 1e-06 rk_type 1 order 3 acc 0 t 4 dsm 6.24598e-07 dsm_est 6.02239e-07 nsteps 17 + rtol 1e-06 rk_type 1 order 3 acc 0 t 4.25 dsm 1.79535e-07 dsm_est 8.62348e-07 nsteps 24 + rtol 1e-06 rk_type 1 order 3 acc 0 t 4.5 dsm 4.23449e-08 dsm_est 8.85746e-07 nsteps 29 + rtol 1e-06 rk_type 1 order 3 acc 0 t 4.75 dsm 1.70945e-08 dsm_est 6.68877e-07 nsteps 35 + rtol 1e-06 rk_type 1 order 3 acc 0 t 5 dsm 4.21376e-08 dsm_est 6.1895e-07 nsteps 23 + rtol 1e-06 rk_type 1 order 3 acc 1 t 0.25 dsm 4.12033e-07 dsm_est 3.17288e-07 nsteps 17 + rtol 1e-06 rk_type 1 order 3 acc 1 t 0.5 dsm 2.46326e-07 dsm_est 6.20547e-07 nsteps 31 + rtol 1e-06 rk_type 1 order 3 acc 1 t 0.75 dsm 3.64026e-08 dsm_est 4.69255e-07 nsteps 39 + rtol 1e-06 rk_type 1 order 3 acc 1 t 1 dsm 2.25687e-07 dsm_est 2.13052e-07 nsteps 45 + rtol 1e-06 rk_type 1 order 3 acc 1 t 1.25 dsm 5.93423e-07 dsm_est 6.03951e-07 nsteps 53 + rtol 1e-06 rk_type 1 order 3 acc 1 t 1.5 dsm 6.11123e-07 dsm_est 2.8192e-07 nsteps 68 + rtol 1e-06 rk_type 1 order 3 acc 1 t 1.75 dsm 1.11041e-07 dsm_est 4.94913e-07 nsteps 76 + rtol 1e-06 rk_type 1 order 3 acc 1 t 2 dsm 4.68945e-07 dsm_est 3.61283e-07 nsteps 49 + rtol 1e-06 rk_type 1 order 3 acc 1 t 2.25 dsm 2.82077e-07 dsm_est 3.07636e-07 nsteps 46 + rtol 1e-06 rk_type 1 order 3 acc 1 t 2.5 dsm 3.42754e-07 dsm_est 2.3822e-07 nsteps 37 + rtol 1e-06 rk_type 1 order 3 acc 1 t 2.75 dsm 8.76441e-08 dsm_est 3.52094e-07 nsteps 30 + rtol 1e-06 rk_type 1 order 3 acc 1 t 3 dsm 9.61476e-08 dsm_est 3.53089e-07 nsteps 29 + rtol 1e-06 rk_type 1 order 3 acc 1 t 3.25 dsm 1.10578e-06 dsm_est 3.08489e-07 nsteps 19 + rtol 1e-06 rk_type 1 order 3 acc 1 t 3.5 dsm 8.13041e-07 dsm_est 2.17804e-07 nsteps 19 + rtol 1e-06 rk_type 1 order 3 acc 1 t 3.75 dsm 8.63105e-07 dsm_est 3.30737e-07 nsteps 15 + rtol 1e-06 rk_type 1 order 3 acc 1 t 4 dsm 6.24598e-07 dsm_est 2.01343e-07 nsteps 17 + rtol 1e-06 rk_type 1 order 3 acc 1 t 4.25 dsm 1.79535e-07 dsm_est 5.65678e-07 nsteps 24 + rtol 1e-06 rk_type 1 order 3 acc 1 t 4.5 dsm 4.23449e-08 dsm_est 3.44003e-07 nsteps 29 + rtol 1e-06 rk_type 1 order 3 acc 1 t 4.75 dsm 1.70945e-08 dsm_est 2.39733e-07 nsteps 35 + rtol 1e-06 rk_type 1 order 3 acc 1 t 5 dsm 4.21376e-08 dsm_est 2.14337e-07 nsteps 23 diff --git a/test/unit_tests/arkode/CXX_serial/ark_test_brusselator_mriadapt.cpp b/test/unit_tests/arkode/CXX_serial/ark_test_brusselator_mriadapt.cpp new file mode 100644 index 0000000000..75192b0ee3 --- /dev/null +++ b/test/unit_tests/arkode/CXX_serial/ark_test_brusselator_mriadapt.cpp @@ -0,0 +1,1463 @@ +/* ---------------------------------------------------------------- + * Programmer(s): Daniel R. Reynolds @ SMU + * ---------------------------------------------------------------- + * SUNDIALS Copyright Start + * Copyright (c) 2002-2024, 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 + * ---------------------------------------------------------------- + * Multirate stiff Brusselator ODE test problem: + * du/dt = a - (w+1)*u + v*u^2 + * dv/dt = w*u - v*u^2 + * dw/dt = (b-w)/ep - w*u + * for t in the interval [0.0, 10.0], with initial conditions + * u0=1.2, v0=3.1, w0=3, and parameters a=1, b=3.5. + * + * Problem stiffness is determined by ep, wherein if the dynamical + * time step is given by H and the explicit time step size is given + * by h, then H/h = 1/(100 ep), i.e., the stability-limited step + * takes over at values of ep < 1e-2. + * + * This program allows a single problem-defining input parameter: + * ep: stiffness factor [default = 1/2500] + * + * We perform a multirate splitting of this problem as + * f^s(t,u,v,w) = [a - (w+1)*u + v*u^2] + * [ w*u - v*u^2 ] + * [ -w*u ] + * f^f(t,u,v,w) = [ 0 ] + * [ 0 ] + * [(b-w)/ep] + * For methods that support ImEx treatment of the slow time scale, we + * further split the slow operator f^s into + * f^I(t,u,v,w) = [-(w+1)*u] + * [ w*u ] + * [ -w*u ] + * f^E(t,u,v,w) = [a + v*u^2] + * [ -v*u^2 ] + * [ 0 ] + * + * Additional input options may be used to select between various + * solver options: + * - slow fixed/initial step size: hs [default = 0.01] + * - fast fixed/initial step size: hf [default = 0.0001] + * - set initial adaptive step size as hs/hf above: set_h0 [default 0] + * - relative solution tolerance: rtol [default = 1e-4] + * - absolute solution tolerance: atol [default = 1e-11] + * - relative solution tolerance for fast integrator: fast_rtol [default = 1e-4] + * - use p (0) vs q (1) for slow adaptivity: slow_pq [default = 0] + * - use p (0) vs q (1) for fast adaptivity: fast_pq [default = 0] + * - "slow" MRI method: mri_method [default = ARKODE_MRI_GARK_ERK45a] + * - "fast" ERKStep method order: fast_order [default 4] + * To put all physics at the slow scale, use "0", otherwise + * specify a valid explicit method order. + * - "slow" MRI temporal adaptivity controller: scontrol [default = 6] + * 0: no controller [fixed time steps] + * 1: MRI-CC controller + * 2: MRI-LL controller + * 3: MRI-PI controller + * 4: MRI-PID controller + * 5: I controller (as part of MRI-HTOL) + * 6: I controller (alone) + * 7: PI controller (as part of MRI-HTOL) + * 8: PI controller (alone) + * 9: PID controller (as part of MRI-HTOL) + * 10: PID controller (alone) + * 11: ExpGus controller (as part of MRI-HTOL) + * 12: ExpGus controller (alone) + * 13: ImpGus controller (as part of MRI-HTOL) + * 14: ImpGus controller (alone) + * 15: ImExGus controller (as part of MRI-HTOL) + * 16: ImExGus controller (alone) + * - "fast" ERKStep temporal adaptivity controller: fcontrol [default = 1] + * Note that this will only be used for 5 <= scontrol <= 16. + * 0: no controller [fixed time steps] + * 1: I controller + * 2: PI controller + * 3: PID controller + * 4: ExpGus controller + * 5: ImpGus controller + * 6: ImExGus controller + * - "fast" ERKStep accumulated error type: faccum [default = 0] + * Note that this will only be used for multirate scontrol options + * -1: no accumulation + * 0: maximum accumulation + * 1: additive accumulation + * - controller parameters: (k1s, k2s, k3s, k4s, k5s, k6s, k1f, k2f, k3f, + * bias, htol_relch, htol_minfac, htol_maxfac) + * MRICC, MRILL, MRIPI, and MRIPID: use k1s through k6s, as appropriate. + * slow single-rate controllers: use k1s through k3s, as appropriate. + * fast single-rate controllers: use k1f through k3f, as appropriate. + * MRIHTol controllers: use htol_relch, htol_minfac, htol_maxfac. + * all controllers (fast and slow) use bias. + * ** if any one of a relevant set are "-1" then the defaults are used + * + * Outputs and solution error values are printed at equal intervals + * of 0.5 and run statistics are printed at the end. + * ----------------------------------------------------------------*/ + +// Header files +#include // prototypes for ERKStep fcts., consts +#include // prototypes for MRIStep fcts., consts +#include +#include +#include +#include +#include +#include // serial N_Vector type, fcts., macros +#include +#include +#include +#include +#include +#include +#include +#include +#include // dense linear solver +#include // dense matrix type, fcts., macros +#include // common utility functions + +#if defined(SUNDIALS_EXTENDED_PRECISION) +#define ESYM "Le" +#define FSYM "Lf" +#else +#define ESYM "e" +#define FSYM "f" +#endif + +#define ZERO SUN_RCONST(0.0) +#define ONE SUN_RCONST(1.0) +#define TWO SUN_RCONST(2.0) + +// Problem options +struct Options +{ + // Problem parameters + sunrealtype a = SUN_RCONST(1.0); + sunrealtype b = SUN_RCONST(3.5); + sunrealtype ep = SUN_RCONST(0.0004); + + // Step sizes and tolerances + int set_h0 = 0; + sunrealtype hs = SUN_RCONST(1.0e-2); + sunrealtype hf = SUN_RCONST(1.0e-4); + sunrealtype rtol = SUN_RCONST(1.0e-4); + sunrealtype atol = SUN_RCONST(1.0e-11); + sunrealtype fast_rtol = SUN_RCONST(1.0e-4); + + // Method selection + std::string mri_method = "ARKODE_MRI_GARK_ERK45a"; + int fast_order = 4; + int scontrol = 6; + int fcontrol = 1; + int faccum = 0; + int slow_pq = 0; + int fast_pq = 0; + + // controller parameters + sunrealtype k1s = SUN_RCONST(-1.0); + sunrealtype k2s = SUN_RCONST(-1.0); + sunrealtype k3s = SUN_RCONST(-1.0); + sunrealtype k4s = SUN_RCONST(-1.0); + sunrealtype k5s = SUN_RCONST(-1.0); + sunrealtype k6s = SUN_RCONST(-1.0); + sunrealtype k1f = SUN_RCONST(-1.0); + sunrealtype k2f = SUN_RCONST(-1.0); + sunrealtype k3f = SUN_RCONST(-1.0); + sunrealtype bias = SUN_RCONST(-1.0); + sunrealtype htol_relch = SUN_RCONST(-1.0); + sunrealtype htol_minfac = SUN_RCONST(-1.0); + sunrealtype htol_maxfac = SUN_RCONST(-1.0); +}; + +// User-supplied functions called by the solver +static int fse(sunrealtype t, N_Vector y, N_Vector ydot, void* user_data); +static int fsi(sunrealtype t, N_Vector y, N_Vector ydot, void* user_data); +static int fs(sunrealtype t, N_Vector y, N_Vector ydot, void* user_data); +static int ff(sunrealtype t, N_Vector y, N_Vector ydot, void* user_data); +static int fn(sunrealtype t, N_Vector y, N_Vector ydot, void* user_data); +static int f0(sunrealtype t, N_Vector y, N_Vector ydot, void* user_data); +static int Js(sunrealtype t, N_Vector y, N_Vector fy, SUNMatrix J, + void* user_data, N_Vector tmp1, N_Vector tmp2, N_Vector tmp3); +static int Jsi(sunrealtype t, N_Vector y, N_Vector fy, SUNMatrix J, + void* user_data, N_Vector tmp1, N_Vector tmp2, N_Vector tmp3); +static int Jn(sunrealtype t, N_Vector y, N_Vector fy, SUNMatrix J, + void* user_data, N_Vector tmp1, N_Vector tmp2, N_Vector tmp3); + +// Utility functions +static void InputHelp(); +static int ReadInputs(std::vector& args, Options& opts, + SUNContext ctx); +static void PrintSlowAdaptivity(Options opts); +static void PrintFastAdaptivity(Options opts); + +// Main Program +int main(int argc, char* argv[]) +{ + // SUNDIALS context object for this simulation + sundials::Context sunctx; + + // Read input options + Options opts; + std::vector args(argv + 1, argv + argc); + int flag = ReadInputs(args, opts, sunctx); + if (check_flag(flag, "ReadInputs")) return 1; + + // General problem parameters + sunrealtype T0 = SUN_RCONST(0.0); // initial time + sunrealtype Tf = SUN_RCONST(10.0); // final time + sunrealtype dTout = SUN_RCONST(0.5); // time between outputs + sunindextype NEQ = 3; // number of dependent vars. + int Nt = (int)ceil(Tf / dTout); // number of output times + + // Initial problem output + // While traversing these, set various function pointers, table constants, and method orders. + ARKRhsFn f_f, f_se, f_si; + ARKLsJacFn J_s; + int retval; + sunbooleantype slowimplicit, slowimex; + slowimplicit = slowimex = SUNFALSE; + f_si = NULL; + J_s = NULL; + f_f = (opts.fast_order == 0) ? f0 : ff; + f_se = (opts.fast_order == 0) ? fn : fs; + if ((opts.mri_method == "ARKODE_MRI_GARK_IRK21a") || + (opts.mri_method == "ARKODE_MRI_GARK_ESDIRK34a") || + (opts.mri_method == "ARKODE_MRI_GARK_ESDIRK46a")) + { + slowimplicit = SUNTRUE; + f_se = NULL; + f_si = (opts.fast_order == 0) ? fn : fs; + J_s = (opts.fast_order == 0) ? Jn : Js; + } + if ((opts.mri_method == "ARKODE_IMEX_MRI_SR21") || + (opts.mri_method == "ARKODE_IMEX_MRI_SR32") || + (opts.mri_method == "ARKODE_IMEX_MRI_SR43")) + { + slowimex = SUNTRUE; + slowimplicit = SUNTRUE; + f_se = (opts.fast_order == 0) ? f0 : fse; + f_si = (opts.fast_order == 0) ? fn : fsi; + J_s = (opts.fast_order == 0) ? Jn : Jsi; + } + std::cout << "\nAdaptive multirate stiff Brusselator test problem:\n"; + std::cout << " time domain: (" << T0 << "," << Tf << "]\n"; + std::cout << " ep = " << opts.ep << std::endl; + std::cout << "\n Slow integrator: " << opts.mri_method; + if (slowimex) { std::cout << " (ImEx)" << std::endl; } + else if (slowimplicit) { std::cout << " (implicit)" << std::endl; } + else { std::cout << " (explicit)" << std::endl; } + PrintSlowAdaptivity(opts); + if (opts.fast_order == 0) { std::cout << "\n Fast integrator disabled"; } + else { std::cout << "\n Fast order " << opts.fast_order << std::endl; } + PrintFastAdaptivity(opts); + + // Create and initialize serial vectors for the solution and reference + N_Vector y = N_VNew_Serial(NEQ, sunctx); + if (check_ptr((void*)y, "N_VNew_Serial")) return 1; + N_Vector yref = N_VClone(y); + if (check_ptr((void*)yref, "N_VClone")) return 1; + + // Set initial conditions + NV_Ith_S(y, 0) = SUN_RCONST(1.2); + NV_Ith_S(y, 1) = SUN_RCONST(3.1); + NV_Ith_S(y, 2) = SUN_RCONST(3.0); + N_VScale(ONE, y, yref); + + // Create and configure reference solver object + void* arkode_ref = ERKStepCreate(fn, T0, yref, sunctx); + if (check_ptr((void*)arkode_ref, "ERKStepCreate")) return 1; + retval = ARKodeSetUserData(arkode_ref, (void*)&opts); + if (check_flag(retval, "ARKodeSetUserData")) return 1; + retval = ARKodeSetOrder(arkode_ref, 5); + if (check_flag(retval, "ARKodeSetOrder")) return 1; + retval = ARKodeSStolerances(arkode_ref, SUN_RCONST(1.e-10), SUN_RCONST(1.e-12)); + if (check_flag(retval, "ARKodeSStolerances")) return 1; + retval = ARKodeSetMaxNumSteps(arkode_ref, 10000000); + if (check_flag(retval, "ARKodeSetMaxNumSteps")) return (1); + + // Create and configure fast controller object + SUNAdaptController fcontrol = NULL; + switch (opts.fcontrol) + { + case (1): + fcontrol = SUNAdaptController_I(sunctx); + if (check_ptr((void*)fcontrol, "SUNAdaptController_I")) return 1; + if (opts.k1f > -1) + { + retval = SUNAdaptController_SetParams_I(fcontrol, opts.k1f); + if (check_flag(retval, "SUNAdaptController_SetParams_I")) return 1; + } + break; + case (2): + fcontrol = SUNAdaptController_PI(sunctx); + if (check_ptr((void*)fcontrol, "SUNAdaptController_PI")) return 1; + if (std::min(opts.k1f, opts.k2f) > -1) + { + retval = SUNAdaptController_SetParams_PI(fcontrol, opts.k1f, opts.k2f); + if (check_flag(retval, "SUNAdaptController_SetParams_PI")) return 1; + } + break; + case (3): + fcontrol = SUNAdaptController_PID(sunctx); + if (check_ptr((void*)fcontrol, "SUNAdaptController_PID")) return 1; + if (std::min(opts.k1f, std::min(opts.k2f, opts.k3f)) > -1) + { + retval = SUNAdaptController_SetParams_PID(fcontrol, opts.k1f, opts.k2f, + opts.k3f); + if (check_flag(retval, "SUNAdaptController_SetParams_PID")) return 1; + } + break; + case (4): + fcontrol = SUNAdaptController_ExpGus(sunctx); + if (check_ptr((void*)fcontrol, "SUNAdaptController_ExpGus")) return 1; + if (std::min(opts.k1f, opts.k2f) > -1) + { + retval = SUNAdaptController_SetParams_ExpGus(fcontrol, opts.k1f, opts.k2f); + if (check_flag(retval, "SUNAdaptController_SetParams_ExpGus")) return 1; + } + break; + case (5): + fcontrol = SUNAdaptController_ImpGus(sunctx); + if (check_ptr((void*)fcontrol, "SUNAdaptController_ImpGus")) return 1; + if (std::min(opts.k1f, opts.k2f) > -1) + { + retval = SUNAdaptController_SetParams_ImpGus(fcontrol, opts.k1f, opts.k2f); + if (check_flag(retval, "SUNAdaptController_SetParams_ImpGus")) return 1; + } + break; + case (6): + fcontrol = SUNAdaptController_ImExGus(sunctx); + if (check_ptr((void*)fcontrol, "SUNAdaptController_ImExGus")) return 1; + break; + } + if ((opts.bias > -1) && (opts.fcontrol > 0)) + { + retval = SUNAdaptController_SetErrorBias(fcontrol, opts.bias); + if (check_flag(retval, "SUNAdaptController_SetErrorBias")) return 1; + } + + // Create ERKStep (fast) integrator + void* inner_arkode_mem = NULL; // ARKode memory structure + inner_arkode_mem = ERKStepCreate(f_f, T0, y, sunctx); + if (check_ptr((void*)inner_arkode_mem, "ERKStepCreate")) return 1; + retval = ARKodeSetOrder(inner_arkode_mem, opts.fast_order); + if (check_flag(retval, "ARKodeSetOrder")) return 1; + retval = ARKodeSStolerances(inner_arkode_mem, opts.fast_rtol, opts.atol); + if (check_flag(retval, "ARKodeSStolerances")) return 1; + if (opts.fcontrol != 0) + { + retval = ARKodeSetAdaptController(inner_arkode_mem, fcontrol); + if (check_flag(retval, "ARKodeSetAdaptController")) return 1; + if (opts.set_h0 != 0) + { + retval = ARKodeSetInitStep(inner_arkode_mem, opts.hf); + if (check_flag(retval, "ARKodeSetInitStep")) return 1; + } + if (opts.fast_pq == 1) + { + retval = ARKodeSetAdaptivityAdjustment(inner_arkode_mem, 0); + if (check_flag(retval, "ARKodeSetAdaptivityAdjustment")) return 1; + } + } + else + { + retval = ARKodeSetFixedStep(inner_arkode_mem, opts.hf); + if (check_flag(retval, "ARKodeSetFixedStep")) return 1; + } + retval = ARKodeSetAccumulatedErrorType(inner_arkode_mem, opts.faccum); + if (check_flag(retval, "ARKodeSetAccumulatedErrorType")) return 1; + retval = ARKodeSetMaxNumSteps(inner_arkode_mem, 1000000); + if (check_flag(retval, "ARKodeSetMaxNumSteps")) return 1; + retval = ARKodeSetUserData(inner_arkode_mem, (void*)&opts); + if (check_flag(retval, "ARKodeSetUserData")) return 1; + + // Create inner stepper + MRIStepInnerStepper inner_stepper = NULL; // inner stepper + retval = ERKStepCreateMRIStepInnerStepper(inner_arkode_mem, &inner_stepper); + if (check_flag(retval, "ERKStepCreateMRIStepInnerStepper")) return 1; + + // Create slow controller object, and select orders of accuracy as relevant + SUNAdaptController scontrol = NULL; + SUNAdaptController scontrol_H = NULL; + SUNAdaptController scontrol_Tol = NULL; + switch (opts.scontrol) + { + case (1): + scontrol = SUNAdaptController_MRICC(sunctx, + opts.fast_order + opts.fast_pq - 1); + if (check_ptr((void*)scontrol, "SUNAdaptController_MRICC")) return 1; + if (std::min(opts.k1s, opts.k2s) > -1) + { + retval = SUNAdaptController_SetParams_MRICC(scontrol, opts.k1s, opts.k2s); + if (check_flag(retval, "SUNAdaptController_SetParams_MRICC")) return 1; + } + break; + case (2): + scontrol = SUNAdaptController_MRILL(sunctx, + opts.fast_order + opts.fast_pq - 1); + if (check_ptr((void*)scontrol, "SUNAdaptController_MRILL")) return 1; + if (std::min(opts.k1s, std::min(opts.k2s, std::min(opts.k3s, opts.k4s))) > -1) + { + retval = SUNAdaptController_SetParams_MRILL(scontrol, opts.k1s, opts.k2s, + opts.k3s, opts.k4s); + if (check_flag(retval, "SUNAdaptController_SetParams_MRILL")) return 1; + } + break; + case (3): + scontrol = SUNAdaptController_MRIPI(sunctx, + opts.fast_order + opts.fast_pq - 1); + if (check_ptr((void*)scontrol, "SUNAdaptController_MRIPI")) return 1; + if (std::min(opts.k1s, std::min(opts.k2s, std::min(opts.k3s, opts.k4s))) > -1) + { + retval = SUNAdaptController_SetParams_MRIPI(scontrol, opts.k1s, opts.k2s, + opts.k3s, opts.k4s); + if (check_flag(retval, "SUNAdaptController_SetParams_MRIPI")) return 1; + } + break; + case (4): + scontrol = SUNAdaptController_MRIPID(sunctx, + opts.fast_order + opts.fast_pq - 1); + if (check_ptr((void*)scontrol, "SUNAdaptController_MRIPID")) return 1; + if (std::min(opts.k1s, + std::min(opts.k2s, + std::min(opts.k3s, + std::min(opts.k4s, + std::min(opts.k5s, opts.k6s))))) > -1) + { + retval = SUNAdaptController_SetParams_MRIPID(scontrol, opts.k1s, opts.k2s, + opts.k3s, opts.k4s, opts.k5s, + opts.k6s); + if (check_flag(retval, "SUNAdaptController_SetParams_MRIPID")) return 1; + } + break; + case (5): + scontrol_H = SUNAdaptController_I(sunctx); + if (check_ptr((void*)scontrol_H, "SUNAdaptController_I (slow H)")) return 1; + scontrol_Tol = SUNAdaptController_I(sunctx); + if (check_ptr((void*)scontrol_Tol, "SUNAdaptController_I (slow Tol)")) + return 1; + if (opts.k1s > -1) + { + retval = SUNAdaptController_SetParams_I(scontrol_H, opts.k1s); + if (check_flag(retval, "SUNAdaptController_SetParams_I")) return 1; + retval = SUNAdaptController_SetParams_I(scontrol_Tol, opts.k1s); + if (check_flag(retval, "SUNAdaptController_SetParams_I")) return 1; + } + scontrol = SUNAdaptController_MRIHTol(sunctx, scontrol_H, scontrol_Tol); + if (check_ptr((void*)scontrol, "SUNAdaptController_MRIHTol")) return 1; + if (std::min(opts.htol_relch, std::min(opts.htol_minfac, opts.htol_maxfac)) > + -1) + { + retval = SUNAdaptController_SetParams_MRIHTol(scontrol, opts.htol_relch, + opts.htol_minfac, + opts.htol_maxfac); + if (check_flag(retval, "SUNAdaptController_SetParams_MRIHTol")) return 1; + } + break; + case (6): + scontrol = SUNAdaptController_I(sunctx); + if (check_ptr((void*)scontrol, "SUNAdaptControllerI (slow)")) return 1; + if (opts.k1s > -1) + { + retval = SUNAdaptController_SetParams_I(scontrol, opts.k1s); + if (check_flag(retval, "SUNAdaptController_SetParams_I")) return 1; + } + break; + case (7): + scontrol_H = SUNAdaptController_PI(sunctx); + if (check_ptr((void*)scontrol_H, "SUNAdaptController_PI (slow H)")) + return 1; + scontrol_Tol = SUNAdaptController_PI(sunctx); + if (check_ptr((void*)scontrol_Tol, "SUNAdaptController_PI (slow Tol)")) + return 1; + if (std::min(opts.k1s, opts.k2s) > -1) + { + retval = SUNAdaptController_SetParams_PI(scontrol_H, opts.k1s, opts.k2s); + if (check_flag(retval, "SUNAdaptController_SetParams_PI")) return 1; + retval = SUNAdaptController_SetParams_PI(scontrol_Tol, opts.k1s, opts.k2s); + if (check_flag(retval, "SUNAdaptController_SetParams_PI")) return 1; + } + scontrol = SUNAdaptController_MRIHTol(sunctx, scontrol_H, scontrol_Tol); + if (check_ptr((void*)scontrol, "SUNAdaptController_MRIHTol")) return 1; + if (std::min(opts.htol_relch, std::min(opts.htol_minfac, opts.htol_maxfac)) > + -1) + { + retval = SUNAdaptController_SetParams_MRIHTol(scontrol, opts.htol_relch, + opts.htol_minfac, + opts.htol_maxfac); + if (check_flag(retval, "SUNAdaptController_SetParams_MRIHTol")) return 1; + } + break; + case (8): + scontrol = SUNAdaptController_PI(sunctx); + if (check_ptr((void*)scontrol, "SUNAdaptController_PI (slow)")) return 1; + if (std::min(opts.k1s, opts.k2s) > -1) + { + retval = SUNAdaptController_SetParams_PI(scontrol, opts.k1s, opts.k2s); + if (check_flag(retval, "SUNAdaptController_SetParams_PI")) return 1; + } + break; + case (9): + scontrol_H = SUNAdaptController_PID(sunctx); + if (check_ptr((void*)scontrol_H, "SUNAdaptController_PID (slow H)")) + return 1; + scontrol_Tol = SUNAdaptController_PID(sunctx); + if (check_ptr((void*)scontrol_Tol, "SUNAdaptController_PID (slow Tol)")) + return 1; + if (std::min(opts.k1s, std::min(opts.k2s, opts.k3s)) > -1) + { + retval = SUNAdaptController_SetParams_PID(scontrol_H, opts.k1s, opts.k2s, + opts.k3s); + if (check_flag(retval, "SUNAdaptController_SetParams_PID")) return 1; + retval = SUNAdaptController_SetParams_PID(scontrol_Tol, opts.k1s, + opts.k2s, opts.k3s); + if (check_flag(retval, "SUNAdaptController_SetParams_PID")) return 1; + } + scontrol = SUNAdaptController_MRIHTol(sunctx, scontrol_H, scontrol_Tol); + if (check_ptr((void*)scontrol, "SUNAdaptController_MRIHTol")) return 1; + if (std::min(opts.htol_relch, std::min(opts.htol_minfac, opts.htol_maxfac)) > + -1) + { + retval = SUNAdaptController_SetParams_MRIHTol(scontrol, opts.htol_relch, + opts.htol_minfac, + opts.htol_maxfac); + if (check_flag(retval, "SUNAdaptController_SetParams_MRIHTol")) return 1; + } + break; + case (10): + scontrol = SUNAdaptController_PID(sunctx); + if (check_ptr((void*)scontrol, "SUNAdaptController_PID (slow)")) return 1; + if (std::min(opts.k1s, std::min(opts.k2s, opts.k3s)) > -1) + { + retval = SUNAdaptController_SetParams_PID(scontrol, opts.k1s, opts.k2s, + opts.k3s); + if (check_flag(retval, "SUNAdaptController_SetParams_PID")) return 1; + } + break; + case (11): + scontrol_H = SUNAdaptController_ExpGus(sunctx); + if (check_ptr((void*)scontrol_H, "SUNAdaptController_ExpGus (slow H)")) + return 1; + scontrol_Tol = SUNAdaptController_ExpGus(sunctx); + if (check_ptr((void*)scontrol_Tol, "SUNAdaptController_ExpGus (slow Tol)")) + return 1; + if (std::min(opts.k1s, opts.k2s) > -1) + { + retval = SUNAdaptController_SetParams_ExpGus(scontrol_H, opts.k1s, + opts.k2s); + if (check_flag(retval, "SUNAdaptController_SetParams_ExpGus")) return 1; + retval = SUNAdaptController_SetParams_ExpGus(scontrol_Tol, opts.k1s, + opts.k2s); + if (check_flag(retval, "SUNAdaptController_SetParams_ExpGus")) return 1; + } + scontrol = SUNAdaptController_MRIHTol(sunctx, scontrol_H, scontrol_Tol); + if (check_ptr((void*)scontrol, "SUNAdaptController_MRIHTol")) return 1; + if (std::min(opts.htol_relch, std::min(opts.htol_minfac, opts.htol_maxfac)) > + -1) + { + retval = SUNAdaptController_SetParams_MRIHTol(scontrol, opts.htol_relch, + opts.htol_minfac, + opts.htol_maxfac); + if (check_flag(retval, "SUNAdaptController_SetParams_MRIHTol")) return 1; + } + break; + case (12): + scontrol = SUNAdaptController_ExpGus(sunctx); + if (check_ptr((void*)scontrol, "SUNAdaptController_ExpGus (slow)")) + return 1; + if (std::min(opts.k1s, opts.k2s) > -1) + { + retval = SUNAdaptController_SetParams_ExpGus(scontrol, opts.k1s, opts.k2s); + if (check_flag(retval, "SUNAdaptController_SetParams_ExpGus")) return 1; + } + break; + case (13): + scontrol_H = SUNAdaptController_ImpGus(sunctx); + if (check_ptr((void*)scontrol_H, "SUNAdaptController_ImpGus (slow H)")) + return 1; + scontrol_Tol = SUNAdaptController_ImpGus(sunctx); + if (check_ptr((void*)scontrol_Tol, "SUNAdaptController_ImpGus (slow Tol)")) + return 1; + if (std::min(opts.k1s, opts.k2s) > -1) + { + retval = SUNAdaptController_SetParams_ImpGus(scontrol_H, opts.k1s, + opts.k2s); + if (check_flag(retval, "SUNAdaptController_SetParams_ImpGus")) return 1; + retval = SUNAdaptController_SetParams_ImpGus(scontrol_Tol, opts.k1s, + opts.k2s); + if (check_flag(retval, "SUNAdaptController_SetParams_ImpGus")) return 1; + } + scontrol = SUNAdaptController_MRIHTol(sunctx, scontrol_H, scontrol_Tol); + if (check_ptr((void*)scontrol, "SUNAdaptController_MRIHTol")) return 1; + if (std::min(opts.htol_relch, std::min(opts.htol_minfac, opts.htol_maxfac)) > + -1) + { + retval = SUNAdaptController_SetParams_MRIHTol(scontrol, opts.htol_relch, + opts.htol_minfac, + opts.htol_maxfac); + if (check_flag(retval, "SUNAdaptController_SetParams_MRIHTol")) return 1; + } + break; + case (14): + scontrol = SUNAdaptController_ImpGus(sunctx); + if (check_ptr((void*)scontrol, "SUNAdaptController_ImpGus (slow)")) + return 1; + if (std::min(opts.k1s, opts.k2s) > -1) + { + retval = SUNAdaptController_SetParams_ImpGus(scontrol, opts.k1s, opts.k2s); + if (check_flag(retval, "SUNAdaptController_SetParams_ImpGus")) return 1; + } + break; + case (15): + scontrol_H = SUNAdaptController_ImExGus(sunctx); + if (check_ptr((void*)scontrol_H, "SUNAdaptController_ImExGus (slow H)")) + return 1; + scontrol_Tol = SUNAdaptController_ImExGus(sunctx); + if (check_ptr((void*)scontrol_Tol, "SUNAdaptController_ImExGus (slow Tol)")) + return 1; + scontrol = SUNAdaptController_MRIHTol(sunctx, scontrol_H, scontrol_Tol); + if (check_ptr((void*)scontrol, "SUNAdaptController_MRIHTol")) return 1; + if (std::min(opts.htol_relch, std::min(opts.htol_minfac, opts.htol_maxfac)) > + -1) + { + retval = SUNAdaptController_SetParams_MRIHTol(scontrol, opts.htol_relch, + opts.htol_minfac, + opts.htol_maxfac); + if (check_flag(retval, "SUNAdaptController_SetParams_MRIHTol")) return 1; + } + break; + case (16): + scontrol = SUNAdaptController_ImExGus(sunctx); + if (check_ptr((void*)scontrol, "SUNAdaptController_ImExGus (slow)")) + return 1; + break; + } + if ((opts.bias > -1) && (opts.scontrol > 0)) + { + retval = SUNAdaptController_SetErrorBias(scontrol, opts.bias); + if (check_flag(retval, "SUNAdaptController_SetErrorBias")) return 1; + } + + // Create MRI (slow) integrator + void* arkode_mem = NULL; // ARKode memory structure + arkode_mem = MRIStepCreate(f_se, f_si, T0, y, inner_stepper, sunctx); + if (check_ptr((void*)arkode_mem, "MRIStepCreate")) return 1; + MRIStepCoupling C = MRIStepCoupling_LoadTableByName((opts.mri_method).c_str()); + if (check_ptr((void*)C, "MRIStepCoupling_LoadTableByName")) return 1; + retval = MRIStepSetCoupling(arkode_mem, C); + if (check_flag(retval, "MRIStepSetCoupling")) return 1; + SUNMatrix As = NULL; // matrix for slow solver + SUNLinearSolver LSs = NULL; // slow linear solver object + if (slowimplicit) + { + As = SUNDenseMatrix(NEQ, NEQ, sunctx); + if (check_ptr((void*)As, "SUNDenseMatrix")) return 1; + LSs = SUNLinSol_Dense(y, As, sunctx); + if (check_ptr((void*)LSs, "SUNLinSol_Dense")) return 1; + retval = ARKodeSetLinearSolver(arkode_mem, LSs, As); + if (check_flag(retval, "ARKodeSetLinearSolver")) return 1; + retval = ARKodeSetJacFn(arkode_mem, J_s); + if (check_flag(retval, "ARKodeSetJacFn")) return 1; + } + retval = ARKodeSStolerances(arkode_mem, opts.rtol, opts.atol); + if (check_flag(retval, "ARKodeSStolerances")) return 1; + retval = ARKodeSetMaxNumSteps(arkode_mem, 100000); + if (check_flag(retval, "ARKodeSetMaxNumSteps")) return 1; + retval = ARKodeSetUserData(arkode_mem, (void*)&opts); + if (check_flag(retval, "ARKodeSetUserData")) return 1; + if (opts.scontrol != 0) + { + retval = MRIStepSetAdaptController(arkode_mem, scontrol); + if (check_flag(retval, "MRIStepSetAdaptController")) return 1; + if (opts.set_h0 != 0) + { + retval = ARKodeSetInitStep(arkode_mem, opts.hs); + if (check_flag(retval, "ARKodeSetInitStep")) return 1; + } + if (opts.slow_pq == 1) + { + retval = ARKodeSetAdaptivityAdjustment(arkode_mem, 0); + if (check_flag(retval, "ARKodeSetAdaptivityAdjustment")) return 1; + } + } + else + { + retval = ARKodeSetFixedStep(arkode_mem, opts.hs); + if (check_flag(retval, "ARKodeSetFixedStep")) return 1; + } + + // + // Integrate ODE + // + + // Main time-stepping loop: calls ARKodeEvolve to perform the + // integration, then prints results. Stops when the final time + // has been reached + sunrealtype t, tout; + sunrealtype uerr, verr, werr, uerrtot, verrtot, werrtot, errtot; + sunrealtype accuracy; + t = T0; + tout = T0 + dTout; + uerr = ZERO; + verr = ZERO; + werr = ZERO; + uerrtot = ZERO; + verrtot = ZERO; + werrtot = ZERO; + errtot = ZERO; + accuracy = ZERO; + printf(" t u v w uerr verr " + "werr\n"); + printf(" " + "---------------------------------------------------------------------" + "----\n"); + printf(" %10.6" FSYM " %10.6" FSYM " %10.6" FSYM " %10.6" FSYM " %.1" ESYM + " %.1" ESYM " %.1" ESYM "\n", + t, NV_Ith_S(y, 0), NV_Ith_S(y, 1), NV_Ith_S(y, 2), uerr, verr, werr); + + for (int iout = 0; iout < Nt; iout++) + { + // call reference solver + retval = ARKodeSetStopTime(arkode_ref, tout); + if (check_flag(retval, "ARKodeSetStopTime")) return 1; + retval = ARKodeEvolve(arkode_ref, tout, yref, &t, ARK_NORMAL); + if (retval < 0) + { + printf("ARKodeEvolve reference solution error (%i)\n", retval); + return 1; + } + + // call integrator + retval = ARKodeSetStopTime(arkode_mem, tout); + if (check_flag(retval, "ARKodeSetStopTime")) return 1; + retval = ARKodeEvolve(arkode_mem, tout, y, &t, ARK_NORMAL); + if (retval < 0) + { + printf("ARKodeEvolve error (%i)\n", retval); + return 1; + } + + // access/print solution and error + uerr = SUNRabs(NV_Ith_S(y, 0) - NV_Ith_S(yref, 0)); + verr = SUNRabs(NV_Ith_S(y, 1) - NV_Ith_S(yref, 1)); + werr = SUNRabs(NV_Ith_S(y, 2) - NV_Ith_S(yref, 2)); + printf(" %10.6" FSYM " %10.6" FSYM " %10.6" FSYM " %10.6" FSYM + " %.1" ESYM " %.1" ESYM " %.1" ESYM "\n", + t, NV_Ith_S(y, 0), NV_Ith_S(y, 1), NV_Ith_S(y, 2), uerr, verr, werr); + uerrtot += uerr * uerr; + verrtot += verr * verr; + werrtot += werr * werr; + errtot += uerr * uerr + verr * verr + werr * werr; + accuracy = std::max(accuracy, uerr / SUNRabs(opts.atol + + opts.rtol * NV_Ith_S(yref, 0))); + accuracy = std::max(accuracy, verr / SUNRabs(opts.atol + + opts.rtol * NV_Ith_S(yref, 1))); + accuracy = std::max(accuracy, werr / SUNRabs(opts.atol + + opts.rtol * NV_Ith_S(yref, 2))); + + // successful solve: update time + tout += dTout; + tout = (tout > Tf) ? Tf : tout; + } + uerrtot = SUNRsqrt(uerrtot / Nt); + verrtot = SUNRsqrt(verrtot / Nt); + werrtot = SUNRsqrt(werrtot / Nt); + errtot = SUNRsqrt(errtot / Nt / 3); + printf(" " + "---------------------------------------------------------------------" + "----\n"); + + // + // Finalize + // + + // Get some slow integrator statistics + long int nsts, natts, netfs, nfse, nfsi; + retval = ARKodeGetNumSteps(arkode_mem, &nsts); + check_flag(retval, "ARKodeGetNumSteps"); + retval = ARKodeGetNumStepAttempts(arkode_mem, &natts); + check_flag(retval, "ARKodeGetNumStepAttempts"); + retval = ARKodeGetNumErrTestFails(arkode_mem, &netfs); + check_flag(retval, "ARKodeGetNumErrTestFails"); + retval = MRIStepGetNumRhsEvals(arkode_mem, &nfse, &nfsi); + check_flag(retval, "MRIStepGetNumRhsEvals"); + + // Get some fast integrator statistics + long int nstf, nattf, netff, nff; + retval = ARKodeGetNumSteps(inner_arkode_mem, &nstf); + check_flag(retval, "ARKodeGetNumSteps"); + retval = ARKodeGetNumStepAttempts(inner_arkode_mem, &nattf); + check_flag(retval, "ARKodeGetNumStepAttempts"); + retval = ARKodeGetNumErrTestFails(inner_arkode_mem, &netff); + check_flag(retval, "ARKodeGetNumErrTestFails"); + retval = ERKStepGetNumRhsEvals(inner_arkode_mem, &nff); + check_flag(retval, "ERKStepGetNumRhsEvals"); + + // Print some final statistics + std::cout << "\nFinal Solver Statistics:\n"; + std::cout << " Slow steps = " << nsts << " (attempts = " << natts + << ", fails = " << netfs << ")\n"; + std::cout << " Fast steps = " << nstf << " (attempts = " << nattf + << ", fails = " << netff << ")\n"; + std::cout << " u error = " << uerrtot << ", v error = " << verrtot + << ", w error = " << werrtot << ", total error = " << errtot + << std::endl; + std::cout << " Relative accuracy = " << accuracy << std::endl; + std::cout << " Total RHS evals: Fse = " << nfse << ", Fsi = " << nfsi + << ", Ff = " << nff << std::endl; + + // Get/print slow integrator decoupled implicit solver statistics + if (slowimplicit) + { + long int nnis, nncs, njes; + retval = ARKodeGetNonlinSolvStats(arkode_mem, &nnis, &nncs); + check_flag(retval, "ARKodeGetNonlinSolvStats"); + retval = ARKodeGetNumJacEvals(arkode_mem, &njes); + check_flag(retval, "ARKodeGetNumJacEvals"); + std::cout << " Slow Newton iters = " << nnis << std::endl; + std::cout << " Slow Newton conv fails = " << nncs << std::endl; + std::cout << " Slow Jacobian evals = " << njes << std::endl; + } + + // Clean up and return + N_VDestroy(y); + MRIStepCoupling_Free(C); + if (As) { SUNMatDestroy(As); } + if (LSs) { SUNLinSolFree(LSs); } + if (scontrol) { SUNAdaptController_Destroy(scontrol); } + if (scontrol_H) { SUNAdaptController_Destroy(scontrol_H); } + if (scontrol_Tol) { SUNAdaptController_Destroy(scontrol_Tol); } + if (fcontrol) { SUNAdaptController_Destroy(fcontrol); } + ARKodeFree(&inner_arkode_mem); // Free fast integrator memory + MRIStepInnerStepper_Free(&inner_stepper); // Free inner stepper structure + ARKodeFree(&arkode_mem); // Free slow integrator memory + ARKodeFree(&arkode_ref); // Free reference solver memory + + return 0; +} + +// ------------------------------ +// Functions called by the solver +// ----------------------------- + +// ff routine to compute the fast portion of the ODE RHS. +static int ff(sunrealtype t, N_Vector y, N_Vector ydot, void* user_data) +{ + Options* opts = (Options*)user_data; + const sunrealtype u = NV_Ith_S(y, 0); + const sunrealtype v = NV_Ith_S(y, 1); + const sunrealtype w = NV_Ith_S(y, 2); + + // fill in the RHS function: + NV_Ith_S(ydot, 0) = ZERO; + NV_Ith_S(ydot, 1) = ZERO; + NV_Ith_S(ydot, 2) = (opts->b - w) / opts->ep; + + // Return with success + return 0; +} + +// fs routine to compute the slow portion of the ODE RHS. +static int fs(sunrealtype t, N_Vector y, N_Vector ydot, void* user_data) +{ + Options* opts = (Options*)user_data; + const sunrealtype u = NV_Ith_S(y, 0); + const sunrealtype v = NV_Ith_S(y, 1); + const sunrealtype w = NV_Ith_S(y, 2); + + // fill in the RHS function: + NV_Ith_S(ydot, 0) = opts->a - (w + ONE) * u + v * u * u; + NV_Ith_S(ydot, 1) = w * u - v * u * u; + NV_Ith_S(ydot, 2) = -w * u; + + // Return with success + return 0; +} + +// fse routine to compute the slow portion of the ODE RHS. +static int fse(sunrealtype t, N_Vector y, N_Vector ydot, void* user_data) +{ + Options* opts = (Options*)user_data; + const sunrealtype u = NV_Ith_S(y, 0); + const sunrealtype v = NV_Ith_S(y, 1); + const sunrealtype w = NV_Ith_S(y, 2); + + // fill in the RHS function: + NV_Ith_S(ydot, 0) = opts->a + v * u * u; + NV_Ith_S(ydot, 1) = -v * u * u; + NV_Ith_S(ydot, 2) = ZERO; + + // Return with success + return 0; +} + +// fsi routine to compute the slow portion of the ODE RHS.(currently same as fse) +static int fsi(sunrealtype t, N_Vector y, N_Vector ydot, void* user_data) +{ + Options* opts = (Options*)user_data; + const sunrealtype u = NV_Ith_S(y, 0); + const sunrealtype v = NV_Ith_S(y, 1); + const sunrealtype w = NV_Ith_S(y, 2); + + // fill in the RHS function: + NV_Ith_S(ydot, 0) = -(w + ONE) * u; + NV_Ith_S(ydot, 1) = w * u; + NV_Ith_S(ydot, 2) = -w * u; + + // Return with success + return 0; +} + +static int fn(sunrealtype t, N_Vector y, N_Vector ydot, void* user_data) +{ + Options* opts = (Options*)user_data; + const sunrealtype u = NV_Ith_S(y, 0); + const sunrealtype v = NV_Ith_S(y, 1); + const sunrealtype w = NV_Ith_S(y, 2); + + // fill in the RHS function: + NV_Ith_S(ydot, 0) = opts->a - (w + ONE) * u + v * u * u; + NV_Ith_S(ydot, 1) = w * u - v * u * u; + NV_Ith_S(ydot, 2) = (opts->b - w) / opts->ep - w * u; + + // Return with success + return 0; +} + +static int f0(sunrealtype t, N_Vector y, N_Vector ydot, void* user_data) +{ + N_VConst(ZERO, ydot); + return (0); +} + +static int Js(sunrealtype t, N_Vector y, N_Vector fy, SUNMatrix J, + void* user_data, N_Vector tmp1, N_Vector tmp2, N_Vector tmp3) +{ + Options* opts = (Options*)user_data; + const sunrealtype u = NV_Ith_S(y, 0); + const sunrealtype v = NV_Ith_S(y, 1); + const sunrealtype w = NV_Ith_S(y, 2); + + // fill in the Jacobian: + SM_ELEMENT_D(J, 0, 0) = -(w + ONE) + TWO * u * v; + SM_ELEMENT_D(J, 0, 1) = u * u; + SM_ELEMENT_D(J, 0, 2) = -u; + + SM_ELEMENT_D(J, 1, 0) = w - TWO * u * v; + SM_ELEMENT_D(J, 1, 1) = -u * u; + SM_ELEMENT_D(J, 1, 2) = u; + + SM_ELEMENT_D(J, 2, 0) = -w; + SM_ELEMENT_D(J, 2, 1) = ZERO; + SM_ELEMENT_D(J, 2, 2) = -u; + + // Return with success + return 0; +} + +static int Jsi(sunrealtype t, N_Vector y, N_Vector fy, SUNMatrix J, + void* user_data, N_Vector tmp1, N_Vector tmp2, N_Vector tmp3) +{ + Options* opts = (Options*)user_data; + const sunrealtype u = NV_Ith_S(y, 0); + const sunrealtype v = NV_Ith_S(y, 1); + const sunrealtype w = NV_Ith_S(y, 2); + + // fill in the Jacobian: + SM_ELEMENT_D(J, 0, 0) = -(w + ONE); + SM_ELEMENT_D(J, 0, 1) = ZERO; + SM_ELEMENT_D(J, 0, 2) = -u; + + SM_ELEMENT_D(J, 1, 0) = w; + SM_ELEMENT_D(J, 1, 1) = ZERO; + SM_ELEMENT_D(J, 1, 2) = u; + + SM_ELEMENT_D(J, 2, 0) = -w; + SM_ELEMENT_D(J, 2, 1) = ZERO; + SM_ELEMENT_D(J, 2, 2) = -u; + + // Return with success + return 0; +} + +static int Jn(sunrealtype t, N_Vector y, N_Vector fy, SUNMatrix J, + void* user_data, N_Vector tmp1, N_Vector tmp2, N_Vector tmp3) +{ + Options* opts = (Options*)user_data; + const sunrealtype u = NV_Ith_S(y, 0); + const sunrealtype v = NV_Ith_S(y, 1); + const sunrealtype w = NV_Ith_S(y, 2); + + // fill in the Jacobian: + SM_ELEMENT_D(J, 0, 0) = -(w + ONE) + TWO * u * v; + SM_ELEMENT_D(J, 0, 1) = u * u; + SM_ELEMENT_D(J, 0, 2) = -u; + + SM_ELEMENT_D(J, 1, 0) = w - TWO * u * v; + SM_ELEMENT_D(J, 1, 1) = -u * u; + SM_ELEMENT_D(J, 1, 2) = u; + + SM_ELEMENT_D(J, 2, 0) = -w; + SM_ELEMENT_D(J, 2, 1) = ZERO; + SM_ELEMENT_D(J, 2, 2) = -ONE / opts->ep - u; + + // Return with success + return 0; +} + +// ------------------------------ +// Private helper functions +// ----------------------------- + +// ----------------------------------------------------------------------------- +// Utility functions +// ----------------------------------------------------------------------------- + +// Print command line options +void InputHelp() +{ + std::cout << std::endl; + std::cout << "Command line options:" << std::endl; + std::cout << " --help : print options and exit\n"; + std::cout << " --ep : stiffness factor\n"; + std::cout << " --hs : slow (fixed/initial) step size\n"; + std::cout << " --hf : fast (fixed/initial) step size\n"; + std::cout + << " --set_h0 : use hs/hf above to set the initial step size\n"; + std::cout << " --rtol : relative solution tolerance\n"; + std::cout << " --atol : absolute solution tolerance\n"; + std::cout + << " --fast_rtol : relative solution tolerance for fast method\n"; + std::cout << " --mri_method : MRI method name (valid ARKODE_MRITableID)\n"; + std::cout << " --fast_order : fast RK method order\n"; + std::cout << " --scontrol : slow time step controller, int in [0,16] " + "(see source)\n"; + std::cout << " --fcontrol : fast time step controller, int in [0,6] " + "(see source)\n"; + std::cout << " --faccum : fast error accumulation type {-1,0,1}\n"; + std::cout << " --slow_pq : use p (0) vs q (1) for slow adaptivity\n"; + std::cout << " --fast_pq : use p (0) vs q (1) for fast adaptivity\n"; + std::cout << " --k1s, --k2s, ..., -k6s : slow controller parameters\n"; + std::cout << " --k1f, --k2f, -k3f : fast controller parameters\n"; + std::cout << " --bias : slow and fast controller bias factors\n"; + std::cout + << " --htol_relch : HTol controller maximum relative tolerance change\n"; + std::cout + << " --htol_minfac : HTol controller minimum relative tolerance factor\n"; + std::cout + << " --htol_maxfac : HTol controller maximum relative tolerance factor\n"; +} + +// Read input options +int ReadInputs(std::vector& args, Options& opts, SUNContext ctx) +{ + if (find(args.begin(), args.end(), "--help") != args.end()) + { + InputHelp(); + return 1; + } + + // Problem options + find_arg(args, "--ep", opts.ep); + find_arg(args, "--hs", opts.hs); + find_arg(args, "--hf", opts.hf); + find_arg(args, "--set_h0", opts.set_h0); + find_arg(args, "--rtol", opts.rtol); + find_arg(args, "--atol", opts.atol); + find_arg(args, "--fast_rtol", opts.fast_rtol); + find_arg(args, "--mri_method", opts.mri_method); + find_arg(args, "--fast_order", opts.fast_order); + find_arg(args, "--scontrol", opts.scontrol); + find_arg(args, "--fcontrol", opts.fcontrol); + find_arg(args, "--faccum", opts.faccum); + find_arg(args, "--slow_pq", opts.slow_pq); + find_arg(args, "--fast_pq", opts.fast_pq); + find_arg(args, "--k1s", opts.k1s); + find_arg(args, "--k2s", opts.k2s); + find_arg(args, "--k3s", opts.k3s); + find_arg(args, "--k4s", opts.k4s); + find_arg(args, "--k5s", opts.k5s); + find_arg(args, "--k6s", opts.k6s); + find_arg(args, "--k1f", opts.k1f); + find_arg(args, "--k2f", opts.k2f); + find_arg(args, "--k3f", opts.k3f); + find_arg(args, "--bias", opts.bias); + find_arg(args, "--htol_relch", opts.htol_relch); + find_arg(args, "--htol_minfac", opts.htol_minfac); + find_arg(args, "--htol_maxfac", opts.htol_maxfac); + + // Check inputs for validity + // 0 < rtol < 1 + if ((opts.rtol < ZERO) || (opts.rtol > ONE)) + { + std::cerr << "ERROR: rtol must be in (0,1), (" << opts.rtol << " input)\n"; + return -1; + } + // 0 < atol < 1 + if ((opts.atol < ZERO) || (opts.atol > ONE)) + { + std::cerr << "ERROR: atol must be in (0,1), (" << opts.atol << " input)\n"; + return -1; + } + // 0 < fast_rtol < 1 + if ((opts.fast_rtol < ZERO) || (opts.fast_rtol > ONE)) + { + std::cerr << "ERROR: fast_rtol must be in (0,1), (" << opts.fast_rtol + << " input)\n"; + return -1; + } + // slow_pq in {0,1} + if ((opts.slow_pq < 0) || (opts.slow_pq > 1)) + { + std::cerr << "ERROR: slow_pq must be in {0,1}, (" << opts.slow_pq + << " input)\n"; + return -1; + } + // fast_pq in {0,1} + if ((opts.fast_pq < 0) || (opts.fast_pq > 1)) + { + std::cerr << "ERROR: fast_pq must be in {0,1}, (" << opts.fast_pq + << " input)\n"; + return -1; + } + // scontrol in [0,16] + if ((opts.scontrol < 0) || (opts.scontrol > 16)) + { + std::cerr << "ERROR: scontrol must be in [0,16], (" << opts.scontrol + << " input)\n"; + return -1; + } + // fcontrol in [0,6] + if ((opts.fcontrol < 0) || (opts.fcontrol > 6)) + { + std::cerr << "ERROR: fcontrol must be in [0,6], (" << opts.fcontrol + << " input)\n"; + return -1; + } + // hs > 0 if scontrol == 0 + if ((opts.hs <= 0) && (opts.scontrol == 0)) + { + std::cerr << "ERROR: positive hs required with scontrol = 0, (" << opts.hs + << " input)\n"; + return -1; + } + // hf > 0 if fcontrol == 0 + if ((opts.hf <= 0) && (opts.fcontrol == 0)) + { + std::cerr << "ERROR: positive hf required with fcontrol = 0, (" << opts.hf + << " input)\n"; + return -1; + } + // ep > 0.0 + if (opts.ep <= ZERO) + { + std::cerr << "ERROR: ep must be a positive real number, (" << opts.ep + << " input)\n"; + return -1; + } + + return 0; +} + +static void PrintSlowAdaptivity(Options opts) +{ + switch (opts.scontrol) + { + case (0): + std::cout << " fixed steps, hs = " << opts.hs << std::endl; + std::cout << " rtol = " << opts.rtol << ", atol = " << opts.atol << "\n"; + break; + case (1): + std::cout << " MRI-CC controller based on order of MRI " + << ((opts.slow_pq == 1) ? "method\n" : "embedding\n"); + std::cout << " rtol = " << opts.rtol << ", atol = " << opts.atol << "\n"; + std::cout << " fast error accumulation strategy = " << opts.faccum << "\n"; + if (std::min(opts.k1s, opts.k2s) > -1) + { + std::cout << " controller parameters: " << opts.k1s << " " << opts.k2s + << "\n"; + } + break; + case (2): + std::cout << " MRI-LL controller based on order of MRI " + << ((opts.slow_pq == 1) ? "method\n" : "embedding\n"); + std::cout << " rtol = " << opts.rtol << ", atol = " << opts.atol << "\n"; + std::cout << " fast error accumulation strategy = " << opts.faccum << "\n"; + if (std::min(opts.k1s, std::min(opts.k2s, std::min(opts.k3s, opts.k4s))) > -1) + { + std::cout << " controller parameters: " << opts.k1s << " " << opts.k2s + << " " << opts.k3s << " " << opts.k4s << "\n"; + } + break; + case (3): + std::cout << " MRI-PI controller based on order of MRI " + << ((opts.slow_pq == 1) ? "method\n" : "embedding\n"); + std::cout << " rtol = " << opts.rtol << ", atol = " << opts.atol << "\n"; + std::cout << " fast error accumulation strategy = " << opts.faccum << "\n"; + if (std::min(opts.k1s, std::min(opts.k2s, std::min(opts.k3s, opts.k4s))) > -1) + { + std::cout << " controller parameters: " << opts.k1s << " " << opts.k2s + << " " << opts.k3s << " " << opts.k4s << "\n"; + } + break; + case (4): + std::cout << " MRI-PID controller based on order of MRI " + << ((opts.slow_pq == 1) ? "method\n" : "embedding\n"); + std::cout << " rtol = " << opts.rtol << ", atol = " << opts.atol << "\n"; + std::cout << " fast error accumulation strategy = " << opts.faccum << "\n"; + if (std::min(opts.k1s, + std::min(opts.k2s, + std::min(opts.k3s, + std::min(opts.k4s, + std::min(opts.k5s, opts.k6s))))) > -1) + { + std::cout << " controller parameters: " << opts.k1s << " " << opts.k2s + << " " << opts.k3s << " " << opts.k4s << " " << opts.k5s << " " + << opts.k6s << "\n"; + } + break; + case (5): + std::cout + << " MRI-HTOL controller (using I for H) based on order of MRI " + << ((opts.slow_pq == 1) ? "method\n" : "embedding\n"); + std::cout << " rtol = " << opts.rtol << ", atol = " << opts.atol << "\n"; + std::cout << " fast error accumulation strategy = " << opts.faccum << "\n"; + if (opts.k1s > -1) + { + std::cout << " slow controller parameter: " << opts.k1s << "\n"; + } + if (std::min(opts.htol_relch, std::min(opts.htol_minfac, opts.htol_maxfac)) > + -1) + { + std::cout << " HTol controller parameters: " << opts.htol_relch << " " + << opts.htol_minfac << " " << opts.htol_maxfac << "\n"; + } + break; + case (6): + std::cout << " Decoupled I controller for slow time scale, based on " + "order of MRI " + << ((opts.slow_pq == 1) ? "method\n" : "embedding\n"); + std::cout << " rtol = " << opts.rtol << ", atol = " << opts.atol << "\n"; + if (opts.k1s > -1) + { + std::cout << " slow controller parameter: " << opts.k1s << "\n"; + } + break; + case (7): + std::cout + << " MRI-HTOL controller (using PI for H) based on order of MRI " + << ((opts.slow_pq == 1) ? "method\n" : "embedding\n"); + std::cout << " rtol = " << opts.rtol << ", atol = " << opts.atol << "\n"; + std::cout << " fast error accumulation strategy = " << opts.faccum << "\n"; + if (std::min(opts.k1s, opts.k2s) > -1) + { + std::cout << " slow controller parameters: " << opts.k1s << " " + << opts.k2s << "\n"; + } + if (std::min(opts.htol_relch, std::min(opts.htol_minfac, opts.htol_maxfac)) > + -1) + { + std::cout << " HTol controller parameters: " << opts.htol_relch << " " + << opts.htol_minfac << " " << opts.htol_maxfac << "\n"; + } + break; + case (8): + std::cout << " Decoupled PI controller for slow time scale, based on " + "order of MRI " + << ((opts.slow_pq == 1) ? "method\n" : "embedding\n"); + std::cout << " rtol = " << opts.rtol << ", atol = " << opts.atol << "\n"; + if (std::min(opts.k1s, opts.k2s) > -1) + { + std::cout << " slow controller parameters: " << opts.k1s << " " + << opts.k2s << "\n"; + } + break; + case (9): + std::cout + << " MRI-HTOL controller (using PID for H) based on order of MRI " + << ((opts.slow_pq == 1) ? "method\n" : "embedding\n"); + std::cout << " rtol = " << opts.rtol << ", atol = " << opts.atol << "\n"; + std::cout << " fast error accumulation strategy = " << opts.faccum << "\n"; + if (std::min(opts.k1s, std::min(opts.k2s, opts.k3s)) > -1) + { + std::cout << " slow controller parameters: " << opts.k1s << " " + << opts.k2s << " " << opts.k3s << "\n"; + } + if (std::min(opts.htol_relch, std::min(opts.htol_minfac, opts.htol_maxfac)) > + -1) + { + std::cout << " HTol controller parameters: " << opts.htol_relch << " " + << opts.htol_minfac << " " << opts.htol_maxfac << "\n"; + } + break; + case (10): + std::cout << " Decoupled PID controller for slow time scale, based on " + "order of MRI " + << ((opts.slow_pq == 1) ? "method\n" : "embedding\n"); + std::cout << " rtol = " << opts.rtol << ", atol = " << opts.atol << "\n"; + if (std::min(opts.k1s, std::min(opts.k2s, opts.k3s)) > -1) + { + std::cout << " slow controller parameters: " << opts.k1s << " " + << opts.k2s << " " << opts.k3s << "\n"; + } + break; + case (11): + std::cout + << " MRI-HTOL controller (using ExpGus for H) based on order of MRI " + << ((opts.slow_pq == 1) ? "method\n" : "embedding\n"); + std::cout << " rtol = " << opts.rtol << ", atol = " << opts.atol << "\n"; + std::cout << " fast error accumulation strategy = " << opts.faccum << "\n"; + if (std::min(opts.k1s, opts.k2s) > -1) + { + std::cout << " slow controller parameters: " << opts.k1s << " " + << opts.k2s << "\n"; + } + if (std::min(opts.htol_relch, std::min(opts.htol_minfac, opts.htol_maxfac)) > + -1) + { + std::cout << " HTol controller parameters: " << opts.htol_relch << " " + << opts.htol_minfac << " " << opts.htol_maxfac << "\n"; + } + break; + case (12): + std::cout << " Decoupled ExpGus controller for slow time scale, based " + "on order of MRI " + << ((opts.slow_pq == 1) ? "method\n" : "embedding\n"); + std::cout << " rtol = " << opts.rtol << ", atol = " << opts.atol << "\n"; + if (std::min(opts.k1s, opts.k2s) > -1) + { + std::cout << " slow controller parameters: " << opts.k1s << " " + << opts.k2s << "\n"; + } + break; + case (13): + std::cout + << " MRI-HTOL controller (using ImpGus for H) based on order of MRI " + << ((opts.slow_pq == 1) ? "method\n" : "embedding\n"); + std::cout << " rtol = " << opts.rtol << ", atol = " << opts.atol << "\n"; + std::cout << " fast error accumulation strategy = " << opts.faccum << "\n"; + if (std::min(opts.k1s, opts.k2s) > -1) + { + std::cout << " slow controller parameters: " << opts.k1s << " " + << opts.k2s << "\n"; + } + if (std::min(opts.htol_relch, std::min(opts.htol_minfac, opts.htol_maxfac)) > + -1) + { + std::cout << " HTol controller parameters: " << opts.htol_relch << " " + << opts.htol_minfac << " " << opts.htol_maxfac << "\n"; + } + break; + case (14): + std::cout << " Decoupled ImpGus controller for slow time scale, based " + "on order of MRI " + << ((opts.slow_pq == 1) ? "method\n" : "embedding\n"); + std::cout << " rtol = " << opts.rtol << ", atol = " << opts.atol << "\n"; + if (std::min(opts.k1s, opts.k2s) > -1) + { + std::cout << " slow controller parameters: " << opts.k1s << " " + << opts.k2s << "\n"; + } + break; + case (15): + std::cout + << " MRI-HTOL controller (using ImExGus for H) based on order of MRI " + << ((opts.slow_pq == 1) ? "method\n" : "embedding\n"); + std::cout << " rtol = " << opts.rtol << ", atol = " << opts.atol << "\n"; + std::cout << " fast error accumulation strategy = " << opts.faccum << "\n"; + break; + case (16): + std::cout << " Decoupled ImExGus controller for slow time scale, based " + "on order of MRI " + << ((opts.slow_pq == 1) ? "method\n" : "embedding\n"); + std::cout << " rtol = " << opts.rtol << ", atol = " << opts.atol << "\n"; + break; + } + if (opts.bias > -1) + { + std::cout << " controller bias factor: " << opts.bias << "\n"; + } +} + +static void PrintFastAdaptivity(Options opts) +{ + switch (opts.fcontrol) + { + case (0): + std::cout << " fixed steps, hf = " << opts.hf << std::endl; + std::cout << " fast_rtol = " << opts.fast_rtol + << ", atol = " << opts.atol << "\n"; + break; + case (1): + std::cout << " I controller for fast time scale, based on order of RK " + << ((opts.fast_pq == 1) ? "method\n" : "embedding\n"); + std::cout << " fast_rtol = " << opts.fast_rtol + << ", atol = " << opts.atol << "\n"; + if (opts.k1f > -1) + { + std::cout << " fast controller parameter: " << opts.k1f << "\n"; + } + break; + case (2): + std::cout << " PI controller for fast time scale, based on order of RK " + << ((opts.fast_pq == 1) ? "method\n" : "embedding\n"); + std::cout << " fast_rtol = " << opts.fast_rtol + << ", atol = " << opts.atol << "\n"; + if (std::min(opts.k1f, opts.k2f) > -1) + { + std::cout << " fast controller parameters: " << opts.k1f << " " + << opts.k2f << "\n"; + } + break; + case (3): + std::cout << " PID controller for fast time scale, based on order of RK " + << ((opts.fast_pq == 1) ? "method\n" : "embedding\n"); + std::cout << " fast_rtol = " << opts.fast_rtol + << ", atol = " << opts.atol << "\n"; + if (std::min(opts.k1f, std::min(opts.k2f, opts.k3f)) > -1) + { + std::cout << " fast controller parameters: " << opts.k1f << " " + << opts.k2f << " " << opts.k3f << "\n"; + } + break; + case (4): + std::cout + << " ExpGus controller for fast time scale, based on order of RK " + << ((opts.fast_pq == 1) ? "method\n" : "embedding\n"); + std::cout << " fast_rtol = " << opts.fast_rtol + << ", atol = " << opts.atol << "\n"; + if (std::min(opts.k1f, opts.k2f) > -1) + { + std::cout << " fast controller parameters: " << opts.k1f << " " + << opts.k2f << "\n"; + } + break; + case (5): + std::cout + << " ImpGus controller for fast time scale, based on order of RK " + << ((opts.fast_pq == 1) ? "method\n" : "embedding\n"); + std::cout << " fast_rtol = " << opts.fast_rtol + << ", atol = " << opts.atol << "\n"; + if (std::min(opts.k1f, opts.k2f) > -1) + { + std::cout << " fast controller parameters: " << opts.k1f << " " + << opts.k2f << "\n"; + } + break; + case (6): + std::cout + << " ImExGus controller for fast time scale, based on order of RK " + << ((opts.fast_pq == 1) ? "method\n" : "embedding\n"); + std::cout << " fast_rtol = " << opts.fast_rtol + << ", atol = " << opts.atol << "\n"; + break; + } +} + +//---- end of file ----// diff --git a/test/unit_tests/arkode/CXX_serial/ark_test_brusselator_mriadapt_--rtol_0.000004_--scontrol_0.out b/test/unit_tests/arkode/CXX_serial/ark_test_brusselator_mriadapt_--rtol_0.000004_--scontrol_0.out new file mode 100644 index 0000000000..f1a60d2ab7 --- /dev/null +++ b/test/unit_tests/arkode/CXX_serial/ark_test_brusselator_mriadapt_--rtol_0.000004_--scontrol_0.out @@ -0,0 +1,43 @@ + +Adaptive multirate stiff Brusselator test problem: + time domain: (0,10] + ep = 0.0004 + + Slow integrator: ARKODE_MRI_GARK_ERK45a (explicit) + fixed steps, hs = 0.01 + rtol = 4e-06, atol = 1e-11 + + Fast order 4 + I controller for fast time scale, based on order of RK embedding + fast_rtol = 0.0001, atol = 1e-11 + t u v w uerr verr werr + ------------------------------------------------------------------------- + 0.000000 1.200000 3.100000 3.000000 0.0e+00 0.0e+00 0.0e+00 + 0.500000 1.200613 2.996066 3.498311 7.5e-05 8.8e-05 8.5e-06 + 1.000000 1.107158 3.008131 3.498438 9.3e-05 1.5e-04 1.3e-05 + 1.500000 0.917798 3.188082 3.498698 8.0e-05 1.8e-04 1.7e-05 + 2.000000 0.691486 3.512327 3.499015 4.5e-05 1.8e-04 1.6e-05 + 2.500000 0.510160 3.896431 3.499274 1.2e-05 1.6e-04 1.2e-05 + 3.000000 0.410222 4.269502 3.499416 6.6e-06 1.4e-04 9.6e-06 + 3.500000 0.372044 4.614020 3.499469 1.3e-05 1.3e-04 9.8e-06 + 4.000000 0.367587 4.934562 3.499472 1.6e-05 1.2e-04 1.3e-05 + 4.500000 0.382207 5.233152 3.499474 2.0e-05 1.1e-04 9.1e-06 + 5.000000 0.412957 5.504350 3.499431 2.3e-05 9.1e-05 8.5e-06 + 5.500000 0.467991 5.730484 3.499356 3.5e-05 6.6e-05 1.1e-05 + 6.000000 0.585319 5.854259 3.499196 7.8e-05 2.7e-06 1.5e-05 + 6.500000 1.060816 5.503421 3.498555 4.8e-04 5.0e-04 3.7e-05 + 7.000000 4.794985 0.734608 3.493240 6.9e-04 2.8e-05 5.7e-05 + 7.500000 3.037697 1.057906 3.495704 5.3e-04 1.3e-04 4.6e-05 + 8.000000 1.833967 1.562361 3.497406 3.6e-04 1.9e-04 2.7e-05 + 8.500000 1.008514 2.191339 3.498570 2.4e-04 2.1e-04 1.8e-05 + 9.000000 0.534095 2.794916 3.499237 1.1e-04 1.7e-04 1.5e-05 + 9.500000 0.352784 3.263323 3.499486 3.3e-05 1.3e-04 2.0e-05 + 10.000000 0.305955 3.648442 3.499562 6.1e-06 1.1e-04 9.8e-06 + ------------------------------------------------------------------------- + +Final Solver Statistics: + Slow steps = 1000 (attempts = 1000, fails = 0) + Fast steps = 11775 (attempts = 16695, fails = 4920) + u error = 0.000246767, v error = 0.000173197, w error = 2.26939e-05, total error = 0.000174553 + Relative accuracy = 112.835 + Total RHS evals: Fse = 5000, Fsi = 0, Ff = 78558 diff --git a/test/unit_tests/arkode/CXX_serial/ark_test_dahlquist_mri.cpp b/test/unit_tests/arkode/CXX_serial/ark_test_dahlquist_mri.cpp index 202e1780ef..994edd56cf 100644 --- a/test/unit_tests/arkode/CXX_serial/ark_test_dahlquist_mri.cpp +++ b/test/unit_tests/arkode/CXX_serial/ark_test_dahlquist_mri.cpp @@ -155,6 +155,8 @@ int main(int argc, char* argv[]) numfails += run_tests(MRISTEP_IMEX, prob_opts, prob_data, sunctx); + numfails += run_tests(MRISTEP_MERK, prob_opts, prob_data, sunctx); + if (numfails) { std::cout << "\n\nFailed " << numfails << " tests!\n"; } else { std::cout << "\n\nAll tests passed!\n"; } @@ -239,7 +241,7 @@ int run_tests(MRISTEP_METHOD_TYPE type, ProblemOptions& prob_opts, // Create slow integrator based on MRI type void* mristep_mem = nullptr; - if (type == MRISTEP_EXPLICIT) + if ((type == MRISTEP_EXPLICIT) || (type == MRISTEP_MERK)) { mristep_mem = MRIStepCreate(fe, nullptr, prob_opts.t0, y, inner_stepper, sunctx); @@ -317,6 +319,17 @@ int run_tests(MRISTEP_METHOD_TYPE type, ProblemOptions& prob_opts, {"ARKODE_MRI_GARK_RALSTON3", false}, {"ARKODE_MRI_GARK_ERK45a", false}}); } + else if (type == MRISTEP_MERK) + { + std::cout << "\n=================\n"; + std::cout << "Test MERK methods\n"; + std::cout << "=================\n"; + + methods.insert({{"ARKODE_MERK21", true}, + {"ARKODE_MERK32", true}, + {"ARKODE_MERK43", true}, + {"ARKODE_MERK54", true}}); + } else if (type == MRISTEP_IMPLICIT) { std::cout << "\n=========================\n"; @@ -346,6 +359,7 @@ int run_tests(MRISTEP_METHOD_TYPE type, ProblemOptions& prob_opts, for (const auto& pair : methods) { + int methodfails = 0; std::string id = pair.first; bool stiffly_accurate = pair.second; std::cout << "\nTesting method " << id << "\n"; @@ -424,7 +438,7 @@ int run_tests(MRISTEP_METHOD_TYPE type, ProblemOptions& prob_opts, } sunrealtype pow = prob_data.lambda_f; - if (type == MRISTEP_EXPLICIT || type == MRISTEP_IMEX) + if (type == MRISTEP_EXPLICIT || type == MRISTEP_IMEX || type == MRISTEP_MERK) { pow += prob_data.lambda_e; } @@ -464,14 +478,14 @@ int run_tests(MRISTEP_METHOD_TYPE type, ProblemOptions& prob_opts, int nstages_evaluated = nstages_stored; if (stiffly_accurate) nstages_evaluated--; long int fe_evals = 0; - if (type == MRISTEP_EXPLICIT || type == MRISTEP_IMEX) + if (type == MRISTEP_EXPLICIT || type == MRISTEP_IMEX || type == MRISTEP_MERK) { fe_evals = mri_nst * nstages_evaluated; } if (mri_nfse != fe_evals) { - numfails++; + methodfails++; std::cout << "Fe RHS evals: " << mri_nfse << " vs " << fe_evals << "\n"; } @@ -483,12 +497,13 @@ int run_tests(MRISTEP_METHOD_TYPE type, ProblemOptions& prob_opts, if (mri_nfsi != fi_evals) { - numfails++; + methodfails++; std::cout << "Fi RHS evals: " << mri_nfsi << " vs " << fi_evals << "\n"; } - if (numfails) { std::cout << "Failed " << numfails << " tests\n"; } + if (methodfails) { std::cout << "Failed " << methodfails << " tests\n"; } else { std::cout << "All checks passed\n"; } + numfails += methodfails; // ------------------- // Setup for next test @@ -505,7 +520,7 @@ int run_tests(MRISTEP_METHOD_TYPE type, ProblemOptions& prob_opts, if (check_flag(&flag, "ARKStepReInit", 1)) { return 1; } // Re-initialize slow integrator based on MRI type - if (type == MRISTEP_EXPLICIT) + if ((type == MRISTEP_EXPLICIT) || (type == MRISTEP_MERK)) { flag = MRIStepReInit(mristep_mem, fe, nullptr, prob_opts.t0, y); } diff --git a/test/unit_tests/arkode/CXX_serial/ark_test_dahlquist_mri_-1.out b/test/unit_tests/arkode/CXX_serial/ark_test_dahlquist_mri_-1.out index 9f09d86912..aac0cac006 100644 --- a/test/unit_tests/arkode/CXX_serial/ark_test_dahlquist_mri_-1.out +++ b/test/unit_tests/arkode/CXX_serial/ark_test_dahlquist_mri_-1.out @@ -14,6 +14,7 @@ Test explicit MRI methods ========================= Testing method ARKODE_MIS_KW3 + type = explicit MRI nmat = 1 stages = 4 method order (q) = 3 @@ -24,6 +25,7 @@ Testing method ARKODE_MIS_KW3 0.3333333333333333 0 0 0 -0.5208333333333333 0.9375 0 0 0.3541666666666666 -0.6375 0.5333333333333333 0 + 0 0 0 0 Stored stages = 3 @@ -40,15 +42,17 @@ Comparing Solver Statistics: All checks passed Testing method ARKODE_MRI_GARK_ERK22a + type = explicit MRI nmat = 1 stages = 3 method order (q) = 2 - embedding order (p) = 0 + embedding order (p) = 1 c = 0 0.5 1 W[0] = 0 0 0 0.5 0 0 -0.5 1 0 + 0.5 0 0 Stored stages = 2 @@ -65,15 +69,17 @@ Comparing Solver Statistics: All checks passed Testing method ARKODE_MRI_GARK_ERK22b + type = explicit MRI nmat = 1 stages = 3 method order (q) = 2 - embedding order (p) = 0 + embedding order (p) = 1 c = 0 1 1 W[0] = 0 0 0 1 0 0 -0.5 0.5 0 + 0 0 0 Stored stages = 2 @@ -90,22 +96,25 @@ Comparing Solver Statistics: All checks passed Testing method ARKODE_MRI_GARK_ERK33a + type = explicit MRI nmat = 2 stages = 4 method order (q) = 3 - embedding order (p) = 0 + embedding order (p) = 2 c = 0 0.3333333333333333 0.6666666666666666 1 W[0] = 0 0 0 0 0.3333333333333333 0 0 0 -0.3333333333333333 0.6666666666666666 0 0 0 -0.6666666666666666 1 0 + 0.08333333333333333 -0.3333333333333333 0.5833333333333334 0 W[1] = 0 0 0 0 0 0 0 0 0 0 0 0 0.5 0 -0.5 0 + 0 0 0 0 Stored stages = 3 @@ -122,10 +131,11 @@ Comparing Solver Statistics: All checks passed Testing method ARKODE_MRI_GARK_ERK45a + type = explicit MRI nmat = 2 stages = 6 method order (q) = 4 - embedding order (p) = 0 + embedding order (p) = 3 c = 0 0.2 0.4 0.6 0.8 1 W[0] = 0 0 0 0 0 0 @@ -134,6 +144,7 @@ Testing method ARKODE_MRI_GARK_ERK45a -0.5121234603937985 1.955496920787597 -1.243373460393798 0 0 0 -0.1068927211587161 -4.656693056981116 3.994968532757531 0.9686172453823019 0 0 0.911960843690752 -0.1837327083772207 -1.193926866090864 -2.611983006811319 3.277681737588653 0 + -1.952334369075205 2.468660908644056 -0.6939268660908644 -0.1119830068113194 0.4895833333333333 0 W[1] = 0 0 0 0 0 0 @@ -142,6 +153,7 @@ Testing method ARKODE_MRI_GARK_ERK45a -0.0382530792124029 0.6952561584248058 -0.6570030792124029 0 0 0 1.87616694642529 3.003768197383342 -3 -1.879935143808632 0 0 -2.423803191489362 2 1 5 -5.576196808510638 0 + 3.304787234042553 -3.304787234042553 0 0 0 0 Stored stages = 5 @@ -158,6 +170,7 @@ Comparing Solver Statistics: All checks passed Testing method ARKODE_MRI_GARK_FORWARD_EULER + type = explicit MRI nmat = 1 stages = 2 method order (q) = 1 @@ -166,6 +179,7 @@ Testing method ARKODE_MRI_GARK_FORWARD_EULER W[0] = 0 0 1 0 + 0 0 Stored stages = 1 @@ -182,15 +196,17 @@ Comparing Solver Statistics: All checks passed Testing method ARKODE_MRI_GARK_RALSTON2 + type = explicit MRI nmat = 1 stages = 3 method order (q) = 2 - embedding order (p) = 0 + embedding order (p) = 1 c = 0 0.6666666666666666 1 W[0] = 0 0 0 0.6666666666666666 0 0 -0.4166666666666666 0.75 0 + 0.3333333333333334 0 0 Stored stages = 2 @@ -207,6 +223,7 @@ Comparing Solver Statistics: All checks passed Testing method ARKODE_MRI_GARK_RALSTON3 + type = explicit MRI nmat = 2 stages = 4 method order (q) = 3 @@ -217,12 +234,14 @@ Testing method ARKODE_MRI_GARK_RALSTON3 0.5 0 0 0 -2.75 3 0 0 1.305555555555556 -0.1666666666666667 -0.8888888888888888 0 + 0 0 0 0 W[1] = 0 0 0 0 0 0 0 0 4.5 -4.5 0 0 -2.166666666666667 -0.5 2.666666666666667 0 + 0 0 0 0 Stored stages = 3 @@ -243,6 +262,7 @@ Test implicit MRI methods ========================= Testing method ARKODE_MRI_GARK_BACKWARD_EULER + type = implicit MRI nmat = 1 stages = 3 method order (q) = 1 @@ -252,6 +272,7 @@ Testing method ARKODE_MRI_GARK_BACKWARD_EULER 0 0 0 1 0 0 -1 0 1 + 0 0 0 Stored stages = 2 @@ -273,19 +294,22 @@ Comparing Solver Statistics: All checks passed Testing method ARKODE_MRI_GARK_ESDIRK34a + type = implicit MRI nmat = 1 - stages = 7 + stages = 8 method order (q) = 3 - embedding order (p) = 0 - c = 0 0.3333333333333333 0.3333333333333333 0.6666666666666666 0.6666666666666666 1 1 + embedding order (p) = 2 + c = 0 0.3333333333333333 0.3333333333333333 0.6666666666666666 0.6666666666666666 1 1 1 G[0] = - 0 0 0 0 0 0 0 - 0.3333333333333333 0 0 0 0 0 0 - -0.435866521508459 0 0.435866521508459 0 0 0 0 - -0.3045790611944505 0 0.6379123945277838 0 0 0 0 - 0.2116913105640267 0 -0.6475578320724856 0 0.435866521508459 0 0 - 0.4454209388055495 0 0.8813784805616198 0 -0.993466086033836 0 0 - -0.435866521508459 0 0 0 0 0 0.435866521508459 + 0 0 0 0 0 0 0 0 + 0.3333333333333333 0 0 0 0 0 0 0 + -0.435866521508459 0 0.435866521508459 0 0 0 0 0 + -0.3045790611944505 0 0.6379123945277838 0 0 0 0 0 + 0.2116913105640267 0 -0.6475578320724856 0 0.435866521508459 0 0 0 + 0.4454209388055495 0 0.8813784805616198 0 -0.993466086033836 0 0 0 + -0.435866521508459 0 0 0 0 0 0.435866521508459 0 + 0 0 0 0 0 0 0 0 + 0.2453831999117524 0 0.4204215033044045 0 -1.576992606344066 0 0.9111879031279093 0 Stored stages = 4 @@ -307,36 +331,41 @@ Comparing Solver Statistics: All checks passed Testing method ARKODE_MRI_GARK_ESDIRK46a + type = implicit MRI nmat = 2 - stages = 11 + stages = 12 method order (q) = 4 - embedding order (p) = 0 - c = 0 0.2 0.2 0.4 0.4 0.6 0.6 0.8 0.8 1 1 + embedding order (p) = 3 + c = 0 0.2 0.2 0.4 0.4 0.6 0.6 0.8 0.8 1 1 1 G[0] = - 0 0 0 0 0 0 0 0 0 0 0 - 0.2 0 0 0 0 0 0 0 0 0 0 - -0.25 0 0.25 0 0 0 0 0 0 0 0 - 0.9179311933794375 0 -0.7179311933794374 0 0 0 0 0 0 0 0 - 2.643172353961828 0 -2.893172353961828 0 0.25 0 0 0 0 0 0 - 0.501564151341775 0 0.06834736723773695 0 -0.369911518579512 0 0 0 0 0 0 - 4.342116951031425 0 0.03897604588394062 0 -4.631092996915365 0 0.25 0 0 0 0 - -1.690014953911908 0 0.7232372452056922 0 1.84784916447243 0 -0.681071455766214 0 0 0 0 - 3.315267994849762 0 1.086235127654301 0 -1.202424037428737 0 -3.449079085075326 0 0.25 0 0 - -1.563558636602688 0 1.020883954835773 0 2.489384426659126 0 -0.1865282766779755 0 -1.560181468214235 0 0 - 0.19 0 -0.2433333333333333 0 0.4233333333333333 0 0.4233333333333333 0 -1.043333333333333 0 0.25 + 0 0 0 0 0 0 0 0 0 0 0 0 + 0.2 0 0 0 0 0 0 0 0 0 0 0 + -0.25 0 0.25 0 0 0 0 0 0 0 0 0 + 0.9179311933794375 0 -0.7179311933794374 0 0 0 0 0 0 0 0 0 + 2.643172353961828 0 -2.893172353961828 0 0.25 0 0 0 0 0 0 0 + 0.501564151341775 0 0.06834736723773695 0 -0.369911518579512 0 0 0 0 0 0 0 + 4.342116951031425 0 0.03897604588394062 0 -4.631092996915365 0 0.25 0 0 0 0 0 + -1.690014953911908 0 0.7232372452056922 0 1.84784916447243 0 -0.681071455766214 0 0 0 0 0 + 3.315267994849762 0 1.086235127654301 0 -1.202424037428737 0 -3.449079085075326 0 0.25 0 0 0 + -1.563558636602688 0 1.020883954835773 0 2.489384426659126 0 -0.1865282766779755 0 -1.560181468214235 0 0 0 + 0.19 0 -0.2433333333333333 0 0.4233333333333333 0 0.4233333333333333 0 -1.043333333333333 0 0.25 0 + 0 0 0 0 0 0 0 0 0 0 0 0 + -0.25 0 0.6355065879145843 0 -0.2777146751476601 0 -0.4798955020445252 0 0.5009086778736938 0 -0.1288050885960927 0 G[1] = - 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 - -1.735862386758875 0 1.735862386758875 0 0 0 0 0 0 0 0 - -5.82844997108155 0 5.82844997108155 0 0 0 0 0 0 0 0 - -0.4610230395256553 0 -0.9787999976333687 0 1.439823037159024 0 0 0 0 0 0 - -7.403989721900906 0 0.06115468960863698 0 7.342835032292269 0 0 0 0 0 0 - 2.099785727661873 0 -1.585581271787903 0 -2.976347367406398 0 2.462142911532428 0 0 0 0 - -5.523652150637583 0 -1.829811152193671 0 1.834216697306453 0 5.519246605524801 0 0 0 0 - 2.020233434143436 0 -2.384427012786476 0 -4.40813747576723 0 0.1519681179818014 0 4.62036293642847 0 0 - 0.12 0 -0.09666666666666666 0 0.2366666666666667 0 0.2366666666666667 0 -0.4966666666666666 0 0 + 0 0 0 0 0 0 0 0 0 0 0 0 + 0 0 0 0 0 0 0 0 0 0 0 0 + 0 0 0 0 0 0 0 0 0 0 0 0 + -1.735862386758875 0 1.735862386758875 0 0 0 0 0 0 0 0 0 + -5.82844997108155 0 5.82844997108155 0 0 0 0 0 0 0 0 0 + -0.4610230395256553 0 -0.9787999976333687 0 1.439823037159024 0 0 0 0 0 0 0 + -7.403989721900906 0 0.06115468960863698 0 7.342835032292269 0 0 0 0 0 0 0 + 2.099785727661873 0 -1.585581271787903 0 -2.976347367406398 0 2.462142911532428 0 0 0 0 0 + -5.523652150637583 0 -1.829811152193671 0 1.834216697306453 0 5.519246605524801 0 0 0 0 0 + 2.020233434143436 0 -2.384427012786476 0 -4.40813747576723 0 0.1519681179818014 0 4.62036293642847 0 0 0 + 0.12 0 -0.09666666666666666 0 0.2366666666666667 0 0.2366666666666667 0 -0.4966666666666666 0 0 0 + 0 0 0 0 0 0 0 0 0 0 0 0 + 0 0 0 0 0 0 0 0 0 0 0 0 Stored stages = 6 @@ -358,6 +387,7 @@ Comparing Solver Statistics: All checks passed Testing method ARKODE_MRI_GARK_IMPLICIT_MIDPOINT + type = implicit MRI nmat = 1 stages = 4 method order (q) = 2 @@ -368,6 +398,7 @@ Testing method ARKODE_MRI_GARK_IMPLICIT_MIDPOINT 0.5 0 0 0 -0.5 0 0.5 0 0 0 0.5 0 + 0 0 0 0 Stored stages = 2 @@ -389,15 +420,18 @@ Comparing Solver Statistics: All checks passed Testing method ARKODE_MRI_GARK_IRK21a + type = implicit MRI nmat = 1 - stages = 3 + stages = 4 method order (q) = 2 - embedding order (p) = 0 - c = 0 1 1 + embedding order (p) = 1 + c = 0 1 1 1 G[0] = - 0 0 0 - 1 0 0 - -0.5 0 0.5 + 0 0 0 0 + 1 0 0 0 + -0.5 0 0.5 0 + 0 0 0 0 + -0.5 0 0.5 0 Stored stages = 2 @@ -423,6 +457,7 @@ Test IMEX MRI methods ===================== Testing method ARKODE_IMEX_MRI_GARK3a + type = ImEx MRI nmat = 1 stages = 8 method order (q) = 3 @@ -437,6 +472,7 @@ Testing method ARKODE_IMEX_MRI_GARK3a -0.4271371821005074 0 0.1562747733103381 0 0.5529291480359398 0 0 0 0 0 0 0 0 0 0 0 0.1058582960718796 0 0.6555675011400702 0 -1.197292318720409 0 0.435866521508459 0 + 0 0 0 0 0 0 0 0 G[0] = 0 0 0 0 0 0 0 0 @@ -447,6 +483,7 @@ Testing method ARKODE_IMEX_MRI_GARK3a 0.435866521508459 0 0.9264299099302395 0 -1.080229692192928 0 0 0 -0.435866521508459 0 0 0 0 0 0.435866521508459 0 0 0 0 0 0 0 0 0 + 0 0 0 0 0 0 0 0 Stored stages = 4 @@ -468,6 +505,7 @@ Comparing Solver Statistics: All checks passed Testing method ARKODE_IMEX_MRI_GARK3b + type = ImEx MRI nmat = 1 stages = 8 method order (q) = 3 @@ -482,6 +520,7 @@ Testing method ARKODE_IMEX_MRI_GARK3b 0.1195213959425454 0 -1.843725226689662 0 2.006270569992887 0 0 0 -0.5466585780430528 0 2 0 -1.453341421956947 0 0 0 0.1058582960718796 0 0.6555675011400702 0 -1.197292318720409 0 0.435866521508459 0 + 0 0 0 0 0 0 0 0 G[0] = 0 0 0 0 0 0 0 0 @@ -492,6 +531,7 @@ Testing method ARKODE_IMEX_MRI_GARK3b 0.1123373143006048 0 1.051807513648115 0 -0.8820780887029493 0 0 0 -0.1123373143006048 0 -0.1253776037178755 0 -0.1981516034899788 0 0.435866521508459 0 0 0 0 0 0 0 0 0 + 0 0 0 0 0 0 0 0 Stored stages = 4 @@ -513,6 +553,7 @@ Comparing Solver Statistics: All checks passed Testing method ARKODE_IMEX_MRI_GARK4 + type = ImEx MRI nmat = 2 stages = 12 method order (q) = 4 @@ -531,6 +572,7 @@ Testing method ARKODE_IMEX_MRI_GARK4 -2.424429547752048 0 2.430325019757162 0 1.905479301151525 0 -1.231139266635725 0 -0.5552355065209142 0 0 0 -0.01044135044479749 0 0.07260303614655074 0 -0.1288275951677261 0 0.1129355350093824 0 -0.04626962554340952 0 0 0 -0.8108522787762101 0 0.2560073199220492 0 0.8068294072697528 0 -0.4557148228721824 0 -0.04626962554340952 0 0.25 0 + 0 0 0 0 0 0 0 0 0 0 0 0 W[1] = 0 0 0 0 0 0 0 0 0 0 0 0 @@ -545,6 +587,7 @@ Testing method ARKODE_IMEX_MRI_GARK4 -1.110471013041828 0 0 0 0 0 0 0 1.110471013041828 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 + 0 0 0 0 0 0 0 0 0 0 0 0 G[0] = 0 0 0 0 0 0 0 0 0 0 0 0 @@ -559,6 +602,7 @@ Testing method ARKODE_IMEX_MRI_GARK4 3.337028151688726 0 1.547057811385124 0 -4.12988801314935 0 0.9260375565964145 0 -1.555235506520914 0 0 0 -0.8212936292210076 0 0.3286103560686 0 0.6780018121020267 0 -0.3427792878628 0 -0.09253925108681904 0 0.25 0 0 0 0 0 0 0 0 0 0 0 0 0 + 0 0 0 0 0 0 0 0 0 0 0 0 G[1] = 0 0 0 0 0 0 0 0 0 0 0 0 @@ -573,6 +617,7 @@ Testing method ARKODE_IMEX_MRI_GARK4 -2.610471013041828 0 0 0 0 0 0 0 2.610471013041828 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 + 0 0 0 0 0 0 0 0 0 0 0 0 Stored stages = 6 @@ -594,6 +639,7 @@ Comparing Solver Statistics: All checks passed Testing method ARKODE_IMEX_MRI_GARK_EULER + type = ImEx MRI nmat = 1 stages = 3 method order (q) = 1 @@ -603,11 +649,13 @@ Testing method ARKODE_IMEX_MRI_GARK_EULER 0 0 0 1 0 0 0 0 0 + 0 0 0 G[0] = 0 0 0 1 0 0 -1 0 1 + 0 0 0 Stored stages = 2 @@ -629,6 +677,7 @@ Comparing Solver Statistics: All checks passed Testing method ARKODE_IMEX_MRI_GARK_MIDPOINT + type = ImEx MRI nmat = 1 stages = 4 method order (q) = 2 @@ -639,12 +688,14 @@ Testing method ARKODE_IMEX_MRI_GARK_MIDPOINT 0.5 0 0 0 0 0 0 0 -0.5 0 1 0 + 0 0 0 0 G[0] = 0 0 0 0 0.5 0 0 0 -0.5 0 0.5 0 0 0 0.5 0 + 0 0 0 0 Stored stages = 2 @@ -666,6 +717,7 @@ Comparing Solver Statistics: All checks passed Testing method ARKODE_IMEX_MRI_GARK_TRAPEZOIDAL + type = ImEx MRI nmat = 1 stages = 4 method order (q) = 2 @@ -676,12 +728,14 @@ Testing method ARKODE_IMEX_MRI_GARK_TRAPEZOIDAL 1 0 0 0 0 0 0 0 -0.5 0 0.5 0 + 0 0 0 0 G[0] = 0 0 0 0 1 0 0 0 -0.5 0 0.5 0 0 0 0 0 + 0 0 0 0 Stored stages = 2 @@ -702,5 +756,223 @@ MRIStep Statistics: Comparing Solver Statistics: All checks passed +================= +Test MERK methods +================= + +Testing method ARKODE_MERK21 + type = MERK + nmat = 2 + stages = 3 + method order (q) = 2 + embedding order (p) = 1 + c = 0 0.5 1 + W[0] = + 0 0 0 + 1 0 0 + 1 0 0 + 1 0 0 + + W[1] = + 0 0 0 + 0 0 0 + -2 2 0 + 0 0 0 + + ngroup = 2 + group[0] = 1 3 + group[1] = 2 + Stored stages = 3 + +MRIStep Statistics: + Time = 0.01 + y(t) = 0.980199 + y_n = 0.980199 + Error = -4.12939e-07 + Steps = 1 + Fe evals = 2 + Fi evals = 0 + +Comparing Solver Statistics: +All checks passed + +Testing method ARKODE_MERK32 + type = MERK + nmat = 2 + stages = 4 + method order (q) = 3 + embedding order (p) = 2 + c = 0 0.5 0.6666666666666666 1 + W[0] = + 0 0 0 0 + 1 0 0 0 + 1 0 0 0 + 1 0 0 0 + 1 0 0 0 + + W[1] = + 0 0 0 0 + 0 0 0 0 + -2 2 0 0 + -1.5 0 1.5 0 + -2 2 0 0 + + ngroup = 3 + group[0] = 1 + group[1] = 2 4 + group[2] = 3 + Stored stages = 4 + +MRIStep Statistics: + Time = 0.01 + y(t) = 0.980199 + y_n = 0.980199 + Error = 4.5532e-10 + Steps = 1 + Fe evals = 3 + Fi evals = 0 + +Comparing Solver Statistics: +All checks passed + +Testing method ARKODE_MERK43 + type = MERK + nmat = 3 + stages = 7 + method order (q) = 4 + embedding order (p) = 3 + c = 0 0.5 0.5 0.3333333333333333 0.8333333333333334 0.3333333333333333 1 + W[0] = + 0 0 0 0 0 0 0 + 1 0 0 0 0 0 0 + 1 0 0 0 0 0 0 + 1 0 0 0 0 0 0 + 1 0 0 0 0 0 0 + 1 0 0 0 0 0 0 + 1 0 0 0 0 0 0 + 1 0 0 0 0 0 0 + + W[1] = + 0 0 0 0 0 0 0 + 0 0 0 0 0 0 0 + -2 2 0 0 0 0 0 + -2 2 0 0 0 0 0 + -4.999999999999998 0 -4 8.999999999999998 0 0 0 + -4.999999999999998 0 -4 8.999999999999998 0 0 0 + -4.200000000000001 0 0 0 -0.7999999999999999 5.000000000000001 0 + -4.999999999999998 0 -4 8.999999999999998 0 0 0 + + W[2] = + 0 0 0 0 0 0 0 + 0 0 0 0 0 0 0 + 0 0 0 0 0 0 0 + 0 0 0 0 0 0 0 + 5.999999999999998 0 12 -18 0 0 0 + 5.999999999999998 0 12 -18 0 0 0 + 3.6 0 0 0 2.4 -6 0 + 5.999999999999998 0 12 -18 0 0 0 + + ngroup = 4 + group[0] = 1 + group[1] = 3 2 + group[2] = 5 4 7 + group[3] = 6 + Stored stages = 7 + +MRIStep Statistics: + Time = 0.01 + y(t) = 0.980199 + y_n = 0.980199 + Error = -4.19176e-12 + Steps = 1 + Fe evals = 6 + Fi evals = 0 + +Comparing Solver Statistics: +All checks passed + +Testing method ARKODE_MERK54 + type = MERK + nmat = 4 + stages = 11 + method order (q) = 5 + embedding order (p) = 4 + c = 0 0.5 0.5 0.3333333333333333 0.5 0.3333333333333333 0.25 0.7 0.5 0.6666666666666666 1 + W[0] = + 0 0 0 0 0 0 0 0 0 0 0 + 1 0 0 0 0 0 0 0 0 0 0 + 1 0 0 0 0 0 0 0 0 0 0 + 1 0 0 0 0 0 0 0 0 0 0 + 1 0 0 0 0 0 0 0 0 0 0 + 1 0 0 0 0 0 0 0 0 0 0 + 1 0 0 0 0 0 0 0 0 0 0 + 1 0 0 0 0 0 0 0 0 0 0 + 1 0 0 0 0 0 0 0 0 0 0 + 1 0 0 0 0 0 0 0 0 0 0 + 1 0 0 0 0 0 0 0 0 0 0 + 1 0 0 0 0 0 0 0 0 0 0 + + W[1] = + 0 0 0 0 0 0 0 0 0 0 0 + 0 0 0 0 0 0 0 0 0 0 0 + -2 2 0 0 0 0 0 0 0 0 0 + -2 2 0 0 0 0 0 0 0 0 0 + -4.999999999999998 0 -4 8.999999999999998 0 0 0 0 0 0 0 + -4.999999999999998 0 -4 8.999999999999998 0 0 0 0 0 0 0 + -4.999999999999998 0 -4 8.999999999999998 0 0 0 0 0 0 0 + -9.000000000000007 0 0 0 4 -27 32.00000000000001 0 0 0 0 + -9.000000000000007 0 0 0 4 -27 32.00000000000001 0 0 0 0 + -9.000000000000007 0 0 0 4 -27 32.00000000000001 0 0 0 0 + -4.928571428571431 0 0 0 0 0 0 71.42857142857147 28.00000000000001 -94.50000000000004 0 + -9.000000000000007 0 0 0 4 -27 32.00000000000001 0 0 0 0 + + W[2] = + 0 0 0 0 0 0 0 0 0 0 0 + 0 0 0 0 0 0 0 0 0 0 0 + 0 0 0 0 0 0 0 0 0 0 0 + 0 0 0 0 0 0 0 0 0 0 0 + 5.999999999999998 0 12 -18 0 0 0 0 0 0 0 + 5.999999999999998 0 12 -18 0 0 0 0 0 0 0 + 5.999999999999998 0 12 -18 0 0 0 0 0 0 0 + 26 0 0 0 -27.99999999999999 162 -160 0 0 0 0 + 26 0 0 0 -27.99999999999999 162 -160 0 0 0 0 + 26 0 0 0 -27.99999999999999 162 -160 0 0 0 0 + 7.999999999999943 0 0 0 0 0 0 -250.0000000000001 -82.00000000000004 324.0000000000002 0 + 26 0 0 0 -27.99999999999999 162 -160 0 0 0 0 + + W[3] = + 0 0 0 0 0 0 0 0 0 0 0 + 0 0 0 0 0 0 0 0 0 0 0 + 0 0 0 0 0 0 0 0 0 0 0 + 0 0 0 0 0 0 0 0 0 0 0 + 0 0 0 0 0 0 0 0 0 0 0 + 0 0 0 0 0 0 0 0 0 0 0 + 0 0 0 0 0 0 0 0 0 0 0 + -24.00000000000006 0 0 0 47.99999999999999 -216 192.0000000000001 0 0 0 0 + -24.00000000000006 0 0 0 47.99999999999999 -216 192.0000000000001 0 0 0 0 + -24.00000000000006 0 0 0 47.99999999999999 -216 192.0000000000001 0 0 0 0 + -4.285714285714278 0 0 0 0 0 0 214.2857142857144 60.00000000000002 -270.0000000000001 0 + -24.00000000000006 0 0 0 47.99999999999999 -216 192.0000000000001 0 0 0 0 + + ngroup = 5 + group[0] = 1 + group[1] = 3 2 + group[2] = 6 5 4 + group[3] = 8 9 7 11 + group[4] = 10 + Stored stages = 11 + +MRIStep Statistics: + Time = 0.01 + y(t) = 0.980199 + y_n = 0.980199 + Error = -3.58946e-12 + Steps = 1 + Fe evals = 10 + Fi evals = 0 + +Comparing Solver Statistics: +All checks passed + All tests passed! diff --git a/test/unit_tests/arkode/CXX_serial/ark_test_dahlquist_mri_0.out b/test/unit_tests/arkode/CXX_serial/ark_test_dahlquist_mri_0.out index 4591cb3cd3..b1147d78c1 100644 --- a/test/unit_tests/arkode/CXX_serial/ark_test_dahlquist_mri_0.out +++ b/test/unit_tests/arkode/CXX_serial/ark_test_dahlquist_mri_0.out @@ -14,6 +14,7 @@ Test explicit MRI methods ========================= Testing method ARKODE_MIS_KW3 + type = explicit MRI nmat = 1 stages = 4 method order (q) = 3 @@ -24,6 +25,7 @@ Testing method ARKODE_MIS_KW3 0.3333333333333333 0 0 0 -0.5208333333333333 0.9375 0 0 0.3541666666666666 -0.6375 0.5333333333333333 0 + 0 0 0 0 Stored stages = 3 @@ -40,15 +42,17 @@ Comparing Solver Statistics: All checks passed Testing method ARKODE_MRI_GARK_ERK22a + type = explicit MRI nmat = 1 stages = 3 method order (q) = 2 - embedding order (p) = 0 + embedding order (p) = 1 c = 0 0.5 1 W[0] = 0 0 0 0.5 0 0 -0.5 1 0 + 0.5 0 0 Stored stages = 2 @@ -65,15 +69,17 @@ Comparing Solver Statistics: All checks passed Testing method ARKODE_MRI_GARK_ERK22b + type = explicit MRI nmat = 1 stages = 3 method order (q) = 2 - embedding order (p) = 0 + embedding order (p) = 1 c = 0 1 1 W[0] = 0 0 0 1 0 0 -0.5 0.5 0 + 0 0 0 Stored stages = 2 @@ -90,22 +96,25 @@ Comparing Solver Statistics: All checks passed Testing method ARKODE_MRI_GARK_ERK33a + type = explicit MRI nmat = 2 stages = 4 method order (q) = 3 - embedding order (p) = 0 + embedding order (p) = 2 c = 0 0.3333333333333333 0.6666666666666666 1 W[0] = 0 0 0 0 0.3333333333333333 0 0 0 -0.3333333333333333 0.6666666666666666 0 0 0 -0.6666666666666666 1 0 + 0.08333333333333333 -0.3333333333333333 0.5833333333333334 0 W[1] = 0 0 0 0 0 0 0 0 0 0 0 0 0.5 0 -0.5 0 + 0 0 0 0 Stored stages = 3 @@ -122,10 +131,11 @@ Comparing Solver Statistics: All checks passed Testing method ARKODE_MRI_GARK_ERK45a + type = explicit MRI nmat = 2 stages = 6 method order (q) = 4 - embedding order (p) = 0 + embedding order (p) = 3 c = 0 0.2 0.4 0.6 0.8 1 W[0] = 0 0 0 0 0 0 @@ -134,6 +144,7 @@ Testing method ARKODE_MRI_GARK_ERK45a -0.5121234603937985 1.955496920787597 -1.243373460393798 0 0 0 -0.1068927211587161 -4.656693056981116 3.994968532757531 0.9686172453823019 0 0 0.911960843690752 -0.1837327083772207 -1.193926866090864 -2.611983006811319 3.277681737588653 0 + -1.952334369075205 2.468660908644056 -0.6939268660908644 -0.1119830068113194 0.4895833333333333 0 W[1] = 0 0 0 0 0 0 @@ -142,6 +153,7 @@ Testing method ARKODE_MRI_GARK_ERK45a -0.0382530792124029 0.6952561584248058 -0.6570030792124029 0 0 0 1.87616694642529 3.003768197383342 -3 -1.879935143808632 0 0 -2.423803191489362 2 1 5 -5.576196808510638 0 + 3.304787234042553 -3.304787234042553 0 0 0 0 Stored stages = 5 @@ -158,6 +170,7 @@ Comparing Solver Statistics: All checks passed Testing method ARKODE_MRI_GARK_FORWARD_EULER + type = explicit MRI nmat = 1 stages = 2 method order (q) = 1 @@ -166,6 +179,7 @@ Testing method ARKODE_MRI_GARK_FORWARD_EULER W[0] = 0 0 1 0 + 0 0 Stored stages = 1 @@ -182,15 +196,17 @@ Comparing Solver Statistics: All checks passed Testing method ARKODE_MRI_GARK_RALSTON2 + type = explicit MRI nmat = 1 stages = 3 method order (q) = 2 - embedding order (p) = 0 + embedding order (p) = 1 c = 0 0.6666666666666666 1 W[0] = 0 0 0 0.6666666666666666 0 0 -0.4166666666666666 0.75 0 + 0.3333333333333334 0 0 Stored stages = 2 @@ -207,6 +223,7 @@ Comparing Solver Statistics: All checks passed Testing method ARKODE_MRI_GARK_RALSTON3 + type = explicit MRI nmat = 2 stages = 4 method order (q) = 3 @@ -217,12 +234,14 @@ Testing method ARKODE_MRI_GARK_RALSTON3 0.5 0 0 0 -2.75 3 0 0 1.305555555555556 -0.1666666666666667 -0.8888888888888888 0 + 0 0 0 0 W[1] = 0 0 0 0 0 0 0 0 4.5 -4.5 0 0 -2.166666666666667 -0.5 2.666666666666667 0 + 0 0 0 0 Stored stages = 3 @@ -243,6 +262,7 @@ Test implicit MRI methods ========================= Testing method ARKODE_MRI_GARK_BACKWARD_EULER + type = implicit MRI nmat = 1 stages = 3 method order (q) = 1 @@ -252,6 +272,7 @@ Testing method ARKODE_MRI_GARK_BACKWARD_EULER 0 0 0 1 0 0 -1 0 1 + 0 0 0 Stored stages = 2 @@ -273,19 +294,22 @@ Comparing Solver Statistics: All checks passed Testing method ARKODE_MRI_GARK_ESDIRK34a + type = implicit MRI nmat = 1 - stages = 7 + stages = 8 method order (q) = 3 - embedding order (p) = 0 - c = 0 0.3333333333333333 0.3333333333333333 0.6666666666666666 0.6666666666666666 1 1 + embedding order (p) = 2 + c = 0 0.3333333333333333 0.3333333333333333 0.6666666666666666 0.6666666666666666 1 1 1 G[0] = - 0 0 0 0 0 0 0 - 0.3333333333333333 0 0 0 0 0 0 - -0.435866521508459 0 0.435866521508459 0 0 0 0 - -0.3045790611944505 0 0.6379123945277838 0 0 0 0 - 0.2116913105640267 0 -0.6475578320724856 0 0.435866521508459 0 0 - 0.4454209388055495 0 0.8813784805616198 0 -0.993466086033836 0 0 - -0.435866521508459 0 0 0 0 0 0.435866521508459 + 0 0 0 0 0 0 0 0 + 0.3333333333333333 0 0 0 0 0 0 0 + -0.435866521508459 0 0.435866521508459 0 0 0 0 0 + -0.3045790611944505 0 0.6379123945277838 0 0 0 0 0 + 0.2116913105640267 0 -0.6475578320724856 0 0.435866521508459 0 0 0 + 0.4454209388055495 0 0.8813784805616198 0 -0.993466086033836 0 0 0 + -0.435866521508459 0 0 0 0 0 0.435866521508459 0 + 0 0 0 0 0 0 0 0 + 0.2453831999117524 0 0.4204215033044045 0 -1.576992606344066 0 0.9111879031279093 0 Stored stages = 4 @@ -307,36 +331,41 @@ Comparing Solver Statistics: All checks passed Testing method ARKODE_MRI_GARK_ESDIRK46a + type = implicit MRI nmat = 2 - stages = 11 + stages = 12 method order (q) = 4 - embedding order (p) = 0 - c = 0 0.2 0.2 0.4 0.4 0.6 0.6 0.8 0.8 1 1 + embedding order (p) = 3 + c = 0 0.2 0.2 0.4 0.4 0.6 0.6 0.8 0.8 1 1 1 G[0] = - 0 0 0 0 0 0 0 0 0 0 0 - 0.2 0 0 0 0 0 0 0 0 0 0 - -0.25 0 0.25 0 0 0 0 0 0 0 0 - 0.9179311933794375 0 -0.7179311933794374 0 0 0 0 0 0 0 0 - 2.643172353961828 0 -2.893172353961828 0 0.25 0 0 0 0 0 0 - 0.501564151341775 0 0.06834736723773695 0 -0.369911518579512 0 0 0 0 0 0 - 4.342116951031425 0 0.03897604588394062 0 -4.631092996915365 0 0.25 0 0 0 0 - -1.690014953911908 0 0.7232372452056922 0 1.84784916447243 0 -0.681071455766214 0 0 0 0 - 3.315267994849762 0 1.086235127654301 0 -1.202424037428737 0 -3.449079085075326 0 0.25 0 0 - -1.563558636602688 0 1.020883954835773 0 2.489384426659126 0 -0.1865282766779755 0 -1.560181468214235 0 0 - 0.19 0 -0.2433333333333333 0 0.4233333333333333 0 0.4233333333333333 0 -1.043333333333333 0 0.25 + 0 0 0 0 0 0 0 0 0 0 0 0 + 0.2 0 0 0 0 0 0 0 0 0 0 0 + -0.25 0 0.25 0 0 0 0 0 0 0 0 0 + 0.9179311933794375 0 -0.7179311933794374 0 0 0 0 0 0 0 0 0 + 2.643172353961828 0 -2.893172353961828 0 0.25 0 0 0 0 0 0 0 + 0.501564151341775 0 0.06834736723773695 0 -0.369911518579512 0 0 0 0 0 0 0 + 4.342116951031425 0 0.03897604588394062 0 -4.631092996915365 0 0.25 0 0 0 0 0 + -1.690014953911908 0 0.7232372452056922 0 1.84784916447243 0 -0.681071455766214 0 0 0 0 0 + 3.315267994849762 0 1.086235127654301 0 -1.202424037428737 0 -3.449079085075326 0 0.25 0 0 0 + -1.563558636602688 0 1.020883954835773 0 2.489384426659126 0 -0.1865282766779755 0 -1.560181468214235 0 0 0 + 0.19 0 -0.2433333333333333 0 0.4233333333333333 0 0.4233333333333333 0 -1.043333333333333 0 0.25 0 + 0 0 0 0 0 0 0 0 0 0 0 0 + -0.25 0 0.6355065879145843 0 -0.2777146751476601 0 -0.4798955020445252 0 0.5009086778736938 0 -0.1288050885960927 0 G[1] = - 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 - -1.735862386758875 0 1.735862386758875 0 0 0 0 0 0 0 0 - -5.82844997108155 0 5.82844997108155 0 0 0 0 0 0 0 0 - -0.4610230395256553 0 -0.9787999976333687 0 1.439823037159024 0 0 0 0 0 0 - -7.403989721900906 0 0.06115468960863698 0 7.342835032292269 0 0 0 0 0 0 - 2.099785727661873 0 -1.585581271787903 0 -2.976347367406398 0 2.462142911532428 0 0 0 0 - -5.523652150637583 0 -1.829811152193671 0 1.834216697306453 0 5.519246605524801 0 0 0 0 - 2.020233434143436 0 -2.384427012786476 0 -4.40813747576723 0 0.1519681179818014 0 4.62036293642847 0 0 - 0.12 0 -0.09666666666666666 0 0.2366666666666667 0 0.2366666666666667 0 -0.4966666666666666 0 0 + 0 0 0 0 0 0 0 0 0 0 0 0 + 0 0 0 0 0 0 0 0 0 0 0 0 + 0 0 0 0 0 0 0 0 0 0 0 0 + -1.735862386758875 0 1.735862386758875 0 0 0 0 0 0 0 0 0 + -5.82844997108155 0 5.82844997108155 0 0 0 0 0 0 0 0 0 + -0.4610230395256553 0 -0.9787999976333687 0 1.439823037159024 0 0 0 0 0 0 0 + -7.403989721900906 0 0.06115468960863698 0 7.342835032292269 0 0 0 0 0 0 0 + 2.099785727661873 0 -1.585581271787903 0 -2.976347367406398 0 2.462142911532428 0 0 0 0 0 + -5.523652150637583 0 -1.829811152193671 0 1.834216697306453 0 5.519246605524801 0 0 0 0 0 + 2.020233434143436 0 -2.384427012786476 0 -4.40813747576723 0 0.1519681179818014 0 4.62036293642847 0 0 0 + 0.12 0 -0.09666666666666666 0 0.2366666666666667 0 0.2366666666666667 0 -0.4966666666666666 0 0 0 + 0 0 0 0 0 0 0 0 0 0 0 0 + 0 0 0 0 0 0 0 0 0 0 0 0 Stored stages = 6 @@ -358,6 +387,7 @@ Comparing Solver Statistics: All checks passed Testing method ARKODE_MRI_GARK_IMPLICIT_MIDPOINT + type = implicit MRI nmat = 1 stages = 4 method order (q) = 2 @@ -368,6 +398,7 @@ Testing method ARKODE_MRI_GARK_IMPLICIT_MIDPOINT 0.5 0 0 0 -0.5 0 0.5 0 0 0 0.5 0 + 0 0 0 0 Stored stages = 2 @@ -389,15 +420,18 @@ Comparing Solver Statistics: All checks passed Testing method ARKODE_MRI_GARK_IRK21a + type = implicit MRI nmat = 1 - stages = 3 + stages = 4 method order (q) = 2 - embedding order (p) = 0 - c = 0 1 1 + embedding order (p) = 1 + c = 0 1 1 1 G[0] = - 0 0 0 - 1 0 0 - -0.5 0 0.5 + 0 0 0 0 + 1 0 0 0 + -0.5 0 0.5 0 + 0 0 0 0 + -0.5 0 0.5 0 Stored stages = 2 @@ -423,6 +457,7 @@ Test IMEX MRI methods ===================== Testing method ARKODE_IMEX_MRI_GARK3a + type = ImEx MRI nmat = 1 stages = 8 method order (q) = 3 @@ -437,6 +472,7 @@ Testing method ARKODE_IMEX_MRI_GARK3a -0.4271371821005074 0 0.1562747733103381 0 0.5529291480359398 0 0 0 0 0 0 0 0 0 0 0 0.1058582960718796 0 0.6555675011400702 0 -1.197292318720409 0 0.435866521508459 0 + 0 0 0 0 0 0 0 0 G[0] = 0 0 0 0 0 0 0 0 @@ -447,6 +483,7 @@ Testing method ARKODE_IMEX_MRI_GARK3a 0.435866521508459 0 0.9264299099302395 0 -1.080229692192928 0 0 0 -0.435866521508459 0 0 0 0 0 0.435866521508459 0 0 0 0 0 0 0 0 0 + 0 0 0 0 0 0 0 0 Stored stages = 4 @@ -468,6 +505,7 @@ Comparing Solver Statistics: All checks passed Testing method ARKODE_IMEX_MRI_GARK3b + type = ImEx MRI nmat = 1 stages = 8 method order (q) = 3 @@ -482,6 +520,7 @@ Testing method ARKODE_IMEX_MRI_GARK3b 0.1195213959425454 0 -1.843725226689662 0 2.006270569992887 0 0 0 -0.5466585780430528 0 2 0 -1.453341421956947 0 0 0 0.1058582960718796 0 0.6555675011400702 0 -1.197292318720409 0 0.435866521508459 0 + 0 0 0 0 0 0 0 0 G[0] = 0 0 0 0 0 0 0 0 @@ -492,6 +531,7 @@ Testing method ARKODE_IMEX_MRI_GARK3b 0.1123373143006048 0 1.051807513648115 0 -0.8820780887029493 0 0 0 -0.1123373143006048 0 -0.1253776037178755 0 -0.1981516034899788 0 0.435866521508459 0 0 0 0 0 0 0 0 0 + 0 0 0 0 0 0 0 0 Stored stages = 4 @@ -513,6 +553,7 @@ Comparing Solver Statistics: All checks passed Testing method ARKODE_IMEX_MRI_GARK4 + type = ImEx MRI nmat = 2 stages = 12 method order (q) = 4 @@ -531,6 +572,7 @@ Testing method ARKODE_IMEX_MRI_GARK4 -2.424429547752048 0 2.430325019757162 0 1.905479301151525 0 -1.231139266635725 0 -0.5552355065209142 0 0 0 -0.01044135044479749 0 0.07260303614655074 0 -0.1288275951677261 0 0.1129355350093824 0 -0.04626962554340952 0 0 0 -0.8108522787762101 0 0.2560073199220492 0 0.8068294072697528 0 -0.4557148228721824 0 -0.04626962554340952 0 0.25 0 + 0 0 0 0 0 0 0 0 0 0 0 0 W[1] = 0 0 0 0 0 0 0 0 0 0 0 0 @@ -545,6 +587,7 @@ Testing method ARKODE_IMEX_MRI_GARK4 -1.110471013041828 0 0 0 0 0 0 0 1.110471013041828 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 + 0 0 0 0 0 0 0 0 0 0 0 0 G[0] = 0 0 0 0 0 0 0 0 0 0 0 0 @@ -559,6 +602,7 @@ Testing method ARKODE_IMEX_MRI_GARK4 3.337028151688726 0 1.547057811385124 0 -4.12988801314935 0 0.9260375565964145 0 -1.555235506520914 0 0 0 -0.8212936292210076 0 0.3286103560686 0 0.6780018121020267 0 -0.3427792878628 0 -0.09253925108681904 0 0.25 0 0 0 0 0 0 0 0 0 0 0 0 0 + 0 0 0 0 0 0 0 0 0 0 0 0 G[1] = 0 0 0 0 0 0 0 0 0 0 0 0 @@ -573,6 +617,7 @@ Testing method ARKODE_IMEX_MRI_GARK4 -2.610471013041828 0 0 0 0 0 0 0 2.610471013041828 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 + 0 0 0 0 0 0 0 0 0 0 0 0 Stored stages = 6 @@ -594,6 +639,7 @@ Comparing Solver Statistics: All checks passed Testing method ARKODE_IMEX_MRI_GARK_EULER + type = ImEx MRI nmat = 1 stages = 3 method order (q) = 1 @@ -603,11 +649,13 @@ Testing method ARKODE_IMEX_MRI_GARK_EULER 0 0 0 1 0 0 0 0 0 + 0 0 0 G[0] = 0 0 0 1 0 0 -1 0 1 + 0 0 0 Stored stages = 2 @@ -629,6 +677,7 @@ Comparing Solver Statistics: All checks passed Testing method ARKODE_IMEX_MRI_GARK_MIDPOINT + type = ImEx MRI nmat = 1 stages = 4 method order (q) = 2 @@ -639,12 +688,14 @@ Testing method ARKODE_IMEX_MRI_GARK_MIDPOINT 0.5 0 0 0 0 0 0 0 -0.5 0 1 0 + 0 0 0 0 G[0] = 0 0 0 0 0.5 0 0 0 -0.5 0 0.5 0 0 0 0.5 0 + 0 0 0 0 Stored stages = 2 @@ -666,6 +717,7 @@ Comparing Solver Statistics: All checks passed Testing method ARKODE_IMEX_MRI_GARK_TRAPEZOIDAL + type = ImEx MRI nmat = 1 stages = 4 method order (q) = 2 @@ -676,12 +728,14 @@ Testing method ARKODE_IMEX_MRI_GARK_TRAPEZOIDAL 1 0 0 0 0 0 0 0 -0.5 0 0.5 0 + 0 0 0 0 G[0] = 0 0 0 0 1 0 0 0 -0.5 0 0.5 0 0 0 0 0 + 0 0 0 0 Stored stages = 2 @@ -702,5 +756,223 @@ MRIStep Statistics: Comparing Solver Statistics: All checks passed +================= +Test MERK methods +================= + +Testing method ARKODE_MERK21 + type = MERK + nmat = 2 + stages = 3 + method order (q) = 2 + embedding order (p) = 1 + c = 0 0.5 1 + W[0] = + 0 0 0 + 1 0 0 + 1 0 0 + 1 0 0 + + W[1] = + 0 0 0 + 0 0 0 + -2 2 0 + 0 0 0 + + ngroup = 2 + group[0] = 1 3 + group[1] = 2 + Stored stages = 3 + +MRIStep Statistics: + Time = 0.01 + y(t) = 0.980199 + y_n = 0.980199 + Error = -4.12939e-07 + Steps = 1 + Fe evals = 2 + Fi evals = 0 + +Comparing Solver Statistics: +All checks passed + +Testing method ARKODE_MERK32 + type = MERK + nmat = 2 + stages = 4 + method order (q) = 3 + embedding order (p) = 2 + c = 0 0.5 0.6666666666666666 1 + W[0] = + 0 0 0 0 + 1 0 0 0 + 1 0 0 0 + 1 0 0 0 + 1 0 0 0 + + W[1] = + 0 0 0 0 + 0 0 0 0 + -2 2 0 0 + -1.5 0 1.5 0 + -2 2 0 0 + + ngroup = 3 + group[0] = 1 + group[1] = 2 4 + group[2] = 3 + Stored stages = 4 + +MRIStep Statistics: + Time = 0.01 + y(t) = 0.980199 + y_n = 0.980199 + Error = 4.5532e-10 + Steps = 1 + Fe evals = 3 + Fi evals = 0 + +Comparing Solver Statistics: +All checks passed + +Testing method ARKODE_MERK43 + type = MERK + nmat = 3 + stages = 7 + method order (q) = 4 + embedding order (p) = 3 + c = 0 0.5 0.5 0.3333333333333333 0.8333333333333334 0.3333333333333333 1 + W[0] = + 0 0 0 0 0 0 0 + 1 0 0 0 0 0 0 + 1 0 0 0 0 0 0 + 1 0 0 0 0 0 0 + 1 0 0 0 0 0 0 + 1 0 0 0 0 0 0 + 1 0 0 0 0 0 0 + 1 0 0 0 0 0 0 + + W[1] = + 0 0 0 0 0 0 0 + 0 0 0 0 0 0 0 + -2 2 0 0 0 0 0 + -2 2 0 0 0 0 0 + -4.999999999999998 0 -4 8.999999999999998 0 0 0 + -4.999999999999998 0 -4 8.999999999999998 0 0 0 + -4.200000000000001 0 0 0 -0.7999999999999999 5.000000000000001 0 + -4.999999999999998 0 -4 8.999999999999998 0 0 0 + + W[2] = + 0 0 0 0 0 0 0 + 0 0 0 0 0 0 0 + 0 0 0 0 0 0 0 + 0 0 0 0 0 0 0 + 5.999999999999998 0 12 -18 0 0 0 + 5.999999999999998 0 12 -18 0 0 0 + 3.6 0 0 0 2.4 -6 0 + 5.999999999999998 0 12 -18 0 0 0 + + ngroup = 4 + group[0] = 1 + group[1] = 3 2 + group[2] = 5 4 7 + group[3] = 6 + Stored stages = 7 + +MRIStep Statistics: + Time = 0.01 + y(t) = 0.980199 + y_n = 0.980199 + Error = -4.19176e-12 + Steps = 1 + Fe evals = 6 + Fi evals = 0 + +Comparing Solver Statistics: +All checks passed + +Testing method ARKODE_MERK54 + type = MERK + nmat = 4 + stages = 11 + method order (q) = 5 + embedding order (p) = 4 + c = 0 0.5 0.5 0.3333333333333333 0.5 0.3333333333333333 0.25 0.7 0.5 0.6666666666666666 1 + W[0] = + 0 0 0 0 0 0 0 0 0 0 0 + 1 0 0 0 0 0 0 0 0 0 0 + 1 0 0 0 0 0 0 0 0 0 0 + 1 0 0 0 0 0 0 0 0 0 0 + 1 0 0 0 0 0 0 0 0 0 0 + 1 0 0 0 0 0 0 0 0 0 0 + 1 0 0 0 0 0 0 0 0 0 0 + 1 0 0 0 0 0 0 0 0 0 0 + 1 0 0 0 0 0 0 0 0 0 0 + 1 0 0 0 0 0 0 0 0 0 0 + 1 0 0 0 0 0 0 0 0 0 0 + 1 0 0 0 0 0 0 0 0 0 0 + + W[1] = + 0 0 0 0 0 0 0 0 0 0 0 + 0 0 0 0 0 0 0 0 0 0 0 + -2 2 0 0 0 0 0 0 0 0 0 + -2 2 0 0 0 0 0 0 0 0 0 + -4.999999999999998 0 -4 8.999999999999998 0 0 0 0 0 0 0 + -4.999999999999998 0 -4 8.999999999999998 0 0 0 0 0 0 0 + -4.999999999999998 0 -4 8.999999999999998 0 0 0 0 0 0 0 + -9.000000000000007 0 0 0 4 -27 32.00000000000001 0 0 0 0 + -9.000000000000007 0 0 0 4 -27 32.00000000000001 0 0 0 0 + -9.000000000000007 0 0 0 4 -27 32.00000000000001 0 0 0 0 + -4.928571428571431 0 0 0 0 0 0 71.42857142857147 28.00000000000001 -94.50000000000004 0 + -9.000000000000007 0 0 0 4 -27 32.00000000000001 0 0 0 0 + + W[2] = + 0 0 0 0 0 0 0 0 0 0 0 + 0 0 0 0 0 0 0 0 0 0 0 + 0 0 0 0 0 0 0 0 0 0 0 + 0 0 0 0 0 0 0 0 0 0 0 + 5.999999999999998 0 12 -18 0 0 0 0 0 0 0 + 5.999999999999998 0 12 -18 0 0 0 0 0 0 0 + 5.999999999999998 0 12 -18 0 0 0 0 0 0 0 + 26 0 0 0 -27.99999999999999 162 -160 0 0 0 0 + 26 0 0 0 -27.99999999999999 162 -160 0 0 0 0 + 26 0 0 0 -27.99999999999999 162 -160 0 0 0 0 + 7.999999999999943 0 0 0 0 0 0 -250.0000000000001 -82.00000000000004 324.0000000000002 0 + 26 0 0 0 -27.99999999999999 162 -160 0 0 0 0 + + W[3] = + 0 0 0 0 0 0 0 0 0 0 0 + 0 0 0 0 0 0 0 0 0 0 0 + 0 0 0 0 0 0 0 0 0 0 0 + 0 0 0 0 0 0 0 0 0 0 0 + 0 0 0 0 0 0 0 0 0 0 0 + 0 0 0 0 0 0 0 0 0 0 0 + 0 0 0 0 0 0 0 0 0 0 0 + -24.00000000000006 0 0 0 47.99999999999999 -216 192.0000000000001 0 0 0 0 + -24.00000000000006 0 0 0 47.99999999999999 -216 192.0000000000001 0 0 0 0 + -24.00000000000006 0 0 0 47.99999999999999 -216 192.0000000000001 0 0 0 0 + -4.285714285714278 0 0 0 0 0 0 214.2857142857144 60.00000000000002 -270.0000000000001 0 + -24.00000000000006 0 0 0 47.99999999999999 -216 192.0000000000001 0 0 0 0 + + ngroup = 5 + group[0] = 1 + group[1] = 3 2 + group[2] = 6 5 4 + group[3] = 8 9 7 11 + group[4] = 10 + Stored stages = 11 + +MRIStep Statistics: + Time = 0.01 + y(t) = 0.980199 + y_n = 0.980199 + Error = -3.58946e-12 + Steps = 1 + Fe evals = 10 + Fi evals = 0 + +Comparing Solver Statistics: +All checks passed + All tests passed! diff --git a/test/unit_tests/arkode/CXX_serial/ark_test_dahlquist_mri_1.out b/test/unit_tests/arkode/CXX_serial/ark_test_dahlquist_mri_1.out index 5311a51fcd..3e5d63bd34 100644 --- a/test/unit_tests/arkode/CXX_serial/ark_test_dahlquist_mri_1.out +++ b/test/unit_tests/arkode/CXX_serial/ark_test_dahlquist_mri_1.out @@ -14,6 +14,7 @@ Test explicit MRI methods ========================= Testing method ARKODE_MIS_KW3 + type = explicit MRI nmat = 1 stages = 4 method order (q) = 3 @@ -24,6 +25,7 @@ Testing method ARKODE_MIS_KW3 0.3333333333333333 0 0 0 -0.5208333333333333 0.9375 0 0 0.3541666666666666 -0.6375 0.5333333333333333 0 + 0 0 0 0 Stored stages = 3 @@ -40,15 +42,17 @@ Comparing Solver Statistics: All checks passed Testing method ARKODE_MRI_GARK_ERK22a + type = explicit MRI nmat = 1 stages = 3 method order (q) = 2 - embedding order (p) = 0 + embedding order (p) = 1 c = 0 0.5 1 W[0] = 0 0 0 0.5 0 0 -0.5 1 0 + 0.5 0 0 Stored stages = 2 @@ -65,15 +69,17 @@ Comparing Solver Statistics: All checks passed Testing method ARKODE_MRI_GARK_ERK22b + type = explicit MRI nmat = 1 stages = 3 method order (q) = 2 - embedding order (p) = 0 + embedding order (p) = 1 c = 0 1 1 W[0] = 0 0 0 1 0 0 -0.5 0.5 0 + 0 0 0 Stored stages = 2 @@ -90,22 +96,25 @@ Comparing Solver Statistics: All checks passed Testing method ARKODE_MRI_GARK_ERK33a + type = explicit MRI nmat = 2 stages = 4 method order (q) = 3 - embedding order (p) = 0 + embedding order (p) = 2 c = 0 0.3333333333333333 0.6666666666666666 1 W[0] = 0 0 0 0 0.3333333333333333 0 0 0 -0.3333333333333333 0.6666666666666666 0 0 0 -0.6666666666666666 1 0 + 0.08333333333333333 -0.3333333333333333 0.5833333333333334 0 W[1] = 0 0 0 0 0 0 0 0 0 0 0 0 0.5 0 -0.5 0 + 0 0 0 0 Stored stages = 3 @@ -122,10 +131,11 @@ Comparing Solver Statistics: All checks passed Testing method ARKODE_MRI_GARK_ERK45a + type = explicit MRI nmat = 2 stages = 6 method order (q) = 4 - embedding order (p) = 0 + embedding order (p) = 3 c = 0 0.2 0.4 0.6 0.8 1 W[0] = 0 0 0 0 0 0 @@ -134,6 +144,7 @@ Testing method ARKODE_MRI_GARK_ERK45a -0.5121234603937985 1.955496920787597 -1.243373460393798 0 0 0 -0.1068927211587161 -4.656693056981116 3.994968532757531 0.9686172453823019 0 0 0.911960843690752 -0.1837327083772207 -1.193926866090864 -2.611983006811319 3.277681737588653 0 + -1.952334369075205 2.468660908644056 -0.6939268660908644 -0.1119830068113194 0.4895833333333333 0 W[1] = 0 0 0 0 0 0 @@ -142,6 +153,7 @@ Testing method ARKODE_MRI_GARK_ERK45a -0.0382530792124029 0.6952561584248058 -0.6570030792124029 0 0 0 1.87616694642529 3.003768197383342 -3 -1.879935143808632 0 0 -2.423803191489362 2 1 5 -5.576196808510638 0 + 3.304787234042553 -3.304787234042553 0 0 0 0 Stored stages = 5 @@ -158,6 +170,7 @@ Comparing Solver Statistics: All checks passed Testing method ARKODE_MRI_GARK_FORWARD_EULER + type = explicit MRI nmat = 1 stages = 2 method order (q) = 1 @@ -166,6 +179,7 @@ Testing method ARKODE_MRI_GARK_FORWARD_EULER W[0] = 0 0 1 0 + 0 0 Stored stages = 1 @@ -182,15 +196,17 @@ Comparing Solver Statistics: All checks passed Testing method ARKODE_MRI_GARK_RALSTON2 + type = explicit MRI nmat = 1 stages = 3 method order (q) = 2 - embedding order (p) = 0 + embedding order (p) = 1 c = 0 0.6666666666666666 1 W[0] = 0 0 0 0.6666666666666666 0 0 -0.4166666666666666 0.75 0 + 0.3333333333333334 0 0 Stored stages = 2 @@ -207,6 +223,7 @@ Comparing Solver Statistics: All checks passed Testing method ARKODE_MRI_GARK_RALSTON3 + type = explicit MRI nmat = 2 stages = 4 method order (q) = 3 @@ -217,12 +234,14 @@ Testing method ARKODE_MRI_GARK_RALSTON3 0.5 0 0 0 -2.75 3 0 0 1.305555555555556 -0.1666666666666667 -0.8888888888888888 0 + 0 0 0 0 W[1] = 0 0 0 0 0 0 0 0 4.5 -4.5 0 0 -2.166666666666667 -0.5 2.666666666666667 0 + 0 0 0 0 Stored stages = 3 @@ -243,6 +262,7 @@ Test implicit MRI methods ========================= Testing method ARKODE_MRI_GARK_BACKWARD_EULER + type = implicit MRI nmat = 1 stages = 3 method order (q) = 1 @@ -252,6 +272,7 @@ Testing method ARKODE_MRI_GARK_BACKWARD_EULER 0 0 0 1 0 0 -1 0 1 + 0 0 0 Stored stages = 2 @@ -273,19 +294,22 @@ Comparing Solver Statistics: All checks passed Testing method ARKODE_MRI_GARK_ESDIRK34a + type = implicit MRI nmat = 1 - stages = 7 + stages = 8 method order (q) = 3 - embedding order (p) = 0 - c = 0 0.3333333333333333 0.3333333333333333 0.6666666666666666 0.6666666666666666 1 1 + embedding order (p) = 2 + c = 0 0.3333333333333333 0.3333333333333333 0.6666666666666666 0.6666666666666666 1 1 1 G[0] = - 0 0 0 0 0 0 0 - 0.3333333333333333 0 0 0 0 0 0 - -0.435866521508459 0 0.435866521508459 0 0 0 0 - -0.3045790611944505 0 0.6379123945277838 0 0 0 0 - 0.2116913105640267 0 -0.6475578320724856 0 0.435866521508459 0 0 - 0.4454209388055495 0 0.8813784805616198 0 -0.993466086033836 0 0 - -0.435866521508459 0 0 0 0 0 0.435866521508459 + 0 0 0 0 0 0 0 0 + 0.3333333333333333 0 0 0 0 0 0 0 + -0.435866521508459 0 0.435866521508459 0 0 0 0 0 + -0.3045790611944505 0 0.6379123945277838 0 0 0 0 0 + 0.2116913105640267 0 -0.6475578320724856 0 0.435866521508459 0 0 0 + 0.4454209388055495 0 0.8813784805616198 0 -0.993466086033836 0 0 0 + -0.435866521508459 0 0 0 0 0 0.435866521508459 0 + 0 0 0 0 0 0 0 0 + 0.2453831999117524 0 0.4204215033044045 0 -1.576992606344066 0 0.9111879031279093 0 Stored stages = 4 @@ -307,36 +331,41 @@ Comparing Solver Statistics: All checks passed Testing method ARKODE_MRI_GARK_ESDIRK46a + type = implicit MRI nmat = 2 - stages = 11 + stages = 12 method order (q) = 4 - embedding order (p) = 0 - c = 0 0.2 0.2 0.4 0.4 0.6 0.6 0.8 0.8 1 1 + embedding order (p) = 3 + c = 0 0.2 0.2 0.4 0.4 0.6 0.6 0.8 0.8 1 1 1 G[0] = - 0 0 0 0 0 0 0 0 0 0 0 - 0.2 0 0 0 0 0 0 0 0 0 0 - -0.25 0 0.25 0 0 0 0 0 0 0 0 - 0.9179311933794375 0 -0.7179311933794374 0 0 0 0 0 0 0 0 - 2.643172353961828 0 -2.893172353961828 0 0.25 0 0 0 0 0 0 - 0.501564151341775 0 0.06834736723773695 0 -0.369911518579512 0 0 0 0 0 0 - 4.342116951031425 0 0.03897604588394062 0 -4.631092996915365 0 0.25 0 0 0 0 - -1.690014953911908 0 0.7232372452056922 0 1.84784916447243 0 -0.681071455766214 0 0 0 0 - 3.315267994849762 0 1.086235127654301 0 -1.202424037428737 0 -3.449079085075326 0 0.25 0 0 - -1.563558636602688 0 1.020883954835773 0 2.489384426659126 0 -0.1865282766779755 0 -1.560181468214235 0 0 - 0.19 0 -0.2433333333333333 0 0.4233333333333333 0 0.4233333333333333 0 -1.043333333333333 0 0.25 + 0 0 0 0 0 0 0 0 0 0 0 0 + 0.2 0 0 0 0 0 0 0 0 0 0 0 + -0.25 0 0.25 0 0 0 0 0 0 0 0 0 + 0.9179311933794375 0 -0.7179311933794374 0 0 0 0 0 0 0 0 0 + 2.643172353961828 0 -2.893172353961828 0 0.25 0 0 0 0 0 0 0 + 0.501564151341775 0 0.06834736723773695 0 -0.369911518579512 0 0 0 0 0 0 0 + 4.342116951031425 0 0.03897604588394062 0 -4.631092996915365 0 0.25 0 0 0 0 0 + -1.690014953911908 0 0.7232372452056922 0 1.84784916447243 0 -0.681071455766214 0 0 0 0 0 + 3.315267994849762 0 1.086235127654301 0 -1.202424037428737 0 -3.449079085075326 0 0.25 0 0 0 + -1.563558636602688 0 1.020883954835773 0 2.489384426659126 0 -0.1865282766779755 0 -1.560181468214235 0 0 0 + 0.19 0 -0.2433333333333333 0 0.4233333333333333 0 0.4233333333333333 0 -1.043333333333333 0 0.25 0 + 0 0 0 0 0 0 0 0 0 0 0 0 + -0.25 0 0.6355065879145843 0 -0.2777146751476601 0 -0.4798955020445252 0 0.5009086778736938 0 -0.1288050885960927 0 G[1] = - 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 - -1.735862386758875 0 1.735862386758875 0 0 0 0 0 0 0 0 - -5.82844997108155 0 5.82844997108155 0 0 0 0 0 0 0 0 - -0.4610230395256553 0 -0.9787999976333687 0 1.439823037159024 0 0 0 0 0 0 - -7.403989721900906 0 0.06115468960863698 0 7.342835032292269 0 0 0 0 0 0 - 2.099785727661873 0 -1.585581271787903 0 -2.976347367406398 0 2.462142911532428 0 0 0 0 - -5.523652150637583 0 -1.829811152193671 0 1.834216697306453 0 5.519246605524801 0 0 0 0 - 2.020233434143436 0 -2.384427012786476 0 -4.40813747576723 0 0.1519681179818014 0 4.62036293642847 0 0 - 0.12 0 -0.09666666666666666 0 0.2366666666666667 0 0.2366666666666667 0 -0.4966666666666666 0 0 + 0 0 0 0 0 0 0 0 0 0 0 0 + 0 0 0 0 0 0 0 0 0 0 0 0 + 0 0 0 0 0 0 0 0 0 0 0 0 + -1.735862386758875 0 1.735862386758875 0 0 0 0 0 0 0 0 0 + -5.82844997108155 0 5.82844997108155 0 0 0 0 0 0 0 0 0 + -0.4610230395256553 0 -0.9787999976333687 0 1.439823037159024 0 0 0 0 0 0 0 + -7.403989721900906 0 0.06115468960863698 0 7.342835032292269 0 0 0 0 0 0 0 + 2.099785727661873 0 -1.585581271787903 0 -2.976347367406398 0 2.462142911532428 0 0 0 0 0 + -5.523652150637583 0 -1.829811152193671 0 1.834216697306453 0 5.519246605524801 0 0 0 0 0 + 2.020233434143436 0 -2.384427012786476 0 -4.40813747576723 0 0.1519681179818014 0 4.62036293642847 0 0 0 + 0.12 0 -0.09666666666666666 0 0.2366666666666667 0 0.2366666666666667 0 -0.4966666666666666 0 0 0 + 0 0 0 0 0 0 0 0 0 0 0 0 + 0 0 0 0 0 0 0 0 0 0 0 0 Stored stages = 6 @@ -358,6 +387,7 @@ Comparing Solver Statistics: All checks passed Testing method ARKODE_MRI_GARK_IMPLICIT_MIDPOINT + type = implicit MRI nmat = 1 stages = 4 method order (q) = 2 @@ -368,6 +398,7 @@ Testing method ARKODE_MRI_GARK_IMPLICIT_MIDPOINT 0.5 0 0 0 -0.5 0 0.5 0 0 0 0.5 0 + 0 0 0 0 Stored stages = 2 @@ -389,15 +420,18 @@ Comparing Solver Statistics: All checks passed Testing method ARKODE_MRI_GARK_IRK21a + type = implicit MRI nmat = 1 - stages = 3 + stages = 4 method order (q) = 2 - embedding order (p) = 0 - c = 0 1 1 + embedding order (p) = 1 + c = 0 1 1 1 G[0] = - 0 0 0 - 1 0 0 - -0.5 0 0.5 + 0 0 0 0 + 1 0 0 0 + -0.5 0 0.5 0 + 0 0 0 0 + -0.5 0 0.5 0 Stored stages = 2 @@ -423,6 +457,7 @@ Test IMEX MRI methods ===================== Testing method ARKODE_IMEX_MRI_GARK3a + type = ImEx MRI nmat = 1 stages = 8 method order (q) = 3 @@ -437,6 +472,7 @@ Testing method ARKODE_IMEX_MRI_GARK3a -0.4271371821005074 0 0.1562747733103381 0 0.5529291480359398 0 0 0 0 0 0 0 0 0 0 0 0.1058582960718796 0 0.6555675011400702 0 -1.197292318720409 0 0.435866521508459 0 + 0 0 0 0 0 0 0 0 G[0] = 0 0 0 0 0 0 0 0 @@ -447,6 +483,7 @@ Testing method ARKODE_IMEX_MRI_GARK3a 0.435866521508459 0 0.9264299099302395 0 -1.080229692192928 0 0 0 -0.435866521508459 0 0 0 0 0 0.435866521508459 0 0 0 0 0 0 0 0 0 + 0 0 0 0 0 0 0 0 Stored stages = 4 @@ -468,6 +505,7 @@ Comparing Solver Statistics: All checks passed Testing method ARKODE_IMEX_MRI_GARK3b + type = ImEx MRI nmat = 1 stages = 8 method order (q) = 3 @@ -482,6 +520,7 @@ Testing method ARKODE_IMEX_MRI_GARK3b 0.1195213959425454 0 -1.843725226689662 0 2.006270569992887 0 0 0 -0.5466585780430528 0 2 0 -1.453341421956947 0 0 0 0.1058582960718796 0 0.6555675011400702 0 -1.197292318720409 0 0.435866521508459 0 + 0 0 0 0 0 0 0 0 G[0] = 0 0 0 0 0 0 0 0 @@ -492,6 +531,7 @@ Testing method ARKODE_IMEX_MRI_GARK3b 0.1123373143006048 0 1.051807513648115 0 -0.8820780887029493 0 0 0 -0.1123373143006048 0 -0.1253776037178755 0 -0.1981516034899788 0 0.435866521508459 0 0 0 0 0 0 0 0 0 + 0 0 0 0 0 0 0 0 Stored stages = 4 @@ -513,6 +553,7 @@ Comparing Solver Statistics: All checks passed Testing method ARKODE_IMEX_MRI_GARK4 + type = ImEx MRI nmat = 2 stages = 12 method order (q) = 4 @@ -531,6 +572,7 @@ Testing method ARKODE_IMEX_MRI_GARK4 -2.424429547752048 0 2.430325019757162 0 1.905479301151525 0 -1.231139266635725 0 -0.5552355065209142 0 0 0 -0.01044135044479749 0 0.07260303614655074 0 -0.1288275951677261 0 0.1129355350093824 0 -0.04626962554340952 0 0 0 -0.8108522787762101 0 0.2560073199220492 0 0.8068294072697528 0 -0.4557148228721824 0 -0.04626962554340952 0 0.25 0 + 0 0 0 0 0 0 0 0 0 0 0 0 W[1] = 0 0 0 0 0 0 0 0 0 0 0 0 @@ -545,6 +587,7 @@ Testing method ARKODE_IMEX_MRI_GARK4 -1.110471013041828 0 0 0 0 0 0 0 1.110471013041828 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 + 0 0 0 0 0 0 0 0 0 0 0 0 G[0] = 0 0 0 0 0 0 0 0 0 0 0 0 @@ -559,6 +602,7 @@ Testing method ARKODE_IMEX_MRI_GARK4 3.337028151688726 0 1.547057811385124 0 -4.12988801314935 0 0.9260375565964145 0 -1.555235506520914 0 0 0 -0.8212936292210076 0 0.3286103560686 0 0.6780018121020267 0 -0.3427792878628 0 -0.09253925108681904 0 0.25 0 0 0 0 0 0 0 0 0 0 0 0 0 + 0 0 0 0 0 0 0 0 0 0 0 0 G[1] = 0 0 0 0 0 0 0 0 0 0 0 0 @@ -573,6 +617,7 @@ Testing method ARKODE_IMEX_MRI_GARK4 -2.610471013041828 0 0 0 0 0 0 0 2.610471013041828 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 + 0 0 0 0 0 0 0 0 0 0 0 0 Stored stages = 6 @@ -594,6 +639,7 @@ Comparing Solver Statistics: All checks passed Testing method ARKODE_IMEX_MRI_GARK_EULER + type = ImEx MRI nmat = 1 stages = 3 method order (q) = 1 @@ -603,11 +649,13 @@ Testing method ARKODE_IMEX_MRI_GARK_EULER 0 0 0 1 0 0 0 0 0 + 0 0 0 G[0] = 0 0 0 1 0 0 -1 0 1 + 0 0 0 Stored stages = 2 @@ -629,6 +677,7 @@ Comparing Solver Statistics: All checks passed Testing method ARKODE_IMEX_MRI_GARK_MIDPOINT + type = ImEx MRI nmat = 1 stages = 4 method order (q) = 2 @@ -639,12 +688,14 @@ Testing method ARKODE_IMEX_MRI_GARK_MIDPOINT 0.5 0 0 0 0 0 0 0 -0.5 0 1 0 + 0 0 0 0 G[0] = 0 0 0 0 0.5 0 0 0 -0.5 0 0.5 0 0 0 0.5 0 + 0 0 0 0 Stored stages = 2 @@ -666,6 +717,7 @@ Comparing Solver Statistics: All checks passed Testing method ARKODE_IMEX_MRI_GARK_TRAPEZOIDAL + type = ImEx MRI nmat = 1 stages = 4 method order (q) = 2 @@ -676,12 +728,14 @@ Testing method ARKODE_IMEX_MRI_GARK_TRAPEZOIDAL 1 0 0 0 0 0 0 0 -0.5 0 0.5 0 + 0 0 0 0 G[0] = 0 0 0 0 1 0 0 0 -0.5 0 0.5 0 0 0 0 0 + 0 0 0 0 Stored stages = 2 @@ -702,5 +756,223 @@ MRIStep Statistics: Comparing Solver Statistics: All checks passed +================= +Test MERK methods +================= + +Testing method ARKODE_MERK21 + type = MERK + nmat = 2 + stages = 3 + method order (q) = 2 + embedding order (p) = 1 + c = 0 0.5 1 + W[0] = + 0 0 0 + 1 0 0 + 1 0 0 + 1 0 0 + + W[1] = + 0 0 0 + 0 0 0 + -2 2 0 + 0 0 0 + + ngroup = 2 + group[0] = 1 3 + group[1] = 2 + Stored stages = 3 + +MRIStep Statistics: + Time = 0.01 + y(t) = 0.980199 + y_n = 0.980199 + Error = -4.12939e-07 + Steps = 1 + Fe evals = 2 + Fi evals = 0 + +Comparing Solver Statistics: +All checks passed + +Testing method ARKODE_MERK32 + type = MERK + nmat = 2 + stages = 4 + method order (q) = 3 + embedding order (p) = 2 + c = 0 0.5 0.6666666666666666 1 + W[0] = + 0 0 0 0 + 1 0 0 0 + 1 0 0 0 + 1 0 0 0 + 1 0 0 0 + + W[1] = + 0 0 0 0 + 0 0 0 0 + -2 2 0 0 + -1.5 0 1.5 0 + -2 2 0 0 + + ngroup = 3 + group[0] = 1 + group[1] = 2 4 + group[2] = 3 + Stored stages = 4 + +MRIStep Statistics: + Time = 0.01 + y(t) = 0.980199 + y_n = 0.980199 + Error = 4.5532e-10 + Steps = 1 + Fe evals = 3 + Fi evals = 0 + +Comparing Solver Statistics: +All checks passed + +Testing method ARKODE_MERK43 + type = MERK + nmat = 3 + stages = 7 + method order (q) = 4 + embedding order (p) = 3 + c = 0 0.5 0.5 0.3333333333333333 0.8333333333333334 0.3333333333333333 1 + W[0] = + 0 0 0 0 0 0 0 + 1 0 0 0 0 0 0 + 1 0 0 0 0 0 0 + 1 0 0 0 0 0 0 + 1 0 0 0 0 0 0 + 1 0 0 0 0 0 0 + 1 0 0 0 0 0 0 + 1 0 0 0 0 0 0 + + W[1] = + 0 0 0 0 0 0 0 + 0 0 0 0 0 0 0 + -2 2 0 0 0 0 0 + -2 2 0 0 0 0 0 + -4.999999999999998 0 -4 8.999999999999998 0 0 0 + -4.999999999999998 0 -4 8.999999999999998 0 0 0 + -4.200000000000001 0 0 0 -0.7999999999999999 5.000000000000001 0 + -4.999999999999998 0 -4 8.999999999999998 0 0 0 + + W[2] = + 0 0 0 0 0 0 0 + 0 0 0 0 0 0 0 + 0 0 0 0 0 0 0 + 0 0 0 0 0 0 0 + 5.999999999999998 0 12 -18 0 0 0 + 5.999999999999998 0 12 -18 0 0 0 + 3.6 0 0 0 2.4 -6 0 + 5.999999999999998 0 12 -18 0 0 0 + + ngroup = 4 + group[0] = 1 + group[1] = 3 2 + group[2] = 5 4 7 + group[3] = 6 + Stored stages = 7 + +MRIStep Statistics: + Time = 0.01 + y(t) = 0.980199 + y_n = 0.980199 + Error = -4.19176e-12 + Steps = 1 + Fe evals = 6 + Fi evals = 0 + +Comparing Solver Statistics: +All checks passed + +Testing method ARKODE_MERK54 + type = MERK + nmat = 4 + stages = 11 + method order (q) = 5 + embedding order (p) = 4 + c = 0 0.5 0.5 0.3333333333333333 0.5 0.3333333333333333 0.25 0.7 0.5 0.6666666666666666 1 + W[0] = + 0 0 0 0 0 0 0 0 0 0 0 + 1 0 0 0 0 0 0 0 0 0 0 + 1 0 0 0 0 0 0 0 0 0 0 + 1 0 0 0 0 0 0 0 0 0 0 + 1 0 0 0 0 0 0 0 0 0 0 + 1 0 0 0 0 0 0 0 0 0 0 + 1 0 0 0 0 0 0 0 0 0 0 + 1 0 0 0 0 0 0 0 0 0 0 + 1 0 0 0 0 0 0 0 0 0 0 + 1 0 0 0 0 0 0 0 0 0 0 + 1 0 0 0 0 0 0 0 0 0 0 + 1 0 0 0 0 0 0 0 0 0 0 + + W[1] = + 0 0 0 0 0 0 0 0 0 0 0 + 0 0 0 0 0 0 0 0 0 0 0 + -2 2 0 0 0 0 0 0 0 0 0 + -2 2 0 0 0 0 0 0 0 0 0 + -4.999999999999998 0 -4 8.999999999999998 0 0 0 0 0 0 0 + -4.999999999999998 0 -4 8.999999999999998 0 0 0 0 0 0 0 + -4.999999999999998 0 -4 8.999999999999998 0 0 0 0 0 0 0 + -9.000000000000007 0 0 0 4 -27 32.00000000000001 0 0 0 0 + -9.000000000000007 0 0 0 4 -27 32.00000000000001 0 0 0 0 + -9.000000000000007 0 0 0 4 -27 32.00000000000001 0 0 0 0 + -4.928571428571431 0 0 0 0 0 0 71.42857142857147 28.00000000000001 -94.50000000000004 0 + -9.000000000000007 0 0 0 4 -27 32.00000000000001 0 0 0 0 + + W[2] = + 0 0 0 0 0 0 0 0 0 0 0 + 0 0 0 0 0 0 0 0 0 0 0 + 0 0 0 0 0 0 0 0 0 0 0 + 0 0 0 0 0 0 0 0 0 0 0 + 5.999999999999998 0 12 -18 0 0 0 0 0 0 0 + 5.999999999999998 0 12 -18 0 0 0 0 0 0 0 + 5.999999999999998 0 12 -18 0 0 0 0 0 0 0 + 26 0 0 0 -27.99999999999999 162 -160 0 0 0 0 + 26 0 0 0 -27.99999999999999 162 -160 0 0 0 0 + 26 0 0 0 -27.99999999999999 162 -160 0 0 0 0 + 7.999999999999943 0 0 0 0 0 0 -250.0000000000001 -82.00000000000004 324.0000000000002 0 + 26 0 0 0 -27.99999999999999 162 -160 0 0 0 0 + + W[3] = + 0 0 0 0 0 0 0 0 0 0 0 + 0 0 0 0 0 0 0 0 0 0 0 + 0 0 0 0 0 0 0 0 0 0 0 + 0 0 0 0 0 0 0 0 0 0 0 + 0 0 0 0 0 0 0 0 0 0 0 + 0 0 0 0 0 0 0 0 0 0 0 + 0 0 0 0 0 0 0 0 0 0 0 + -24.00000000000006 0 0 0 47.99999999999999 -216 192.0000000000001 0 0 0 0 + -24.00000000000006 0 0 0 47.99999999999999 -216 192.0000000000001 0 0 0 0 + -24.00000000000006 0 0 0 47.99999999999999 -216 192.0000000000001 0 0 0 0 + -4.285714285714278 0 0 0 0 0 0 214.2857142857144 60.00000000000002 -270.0000000000001 0 + -24.00000000000006 0 0 0 47.99999999999999 -216 192.0000000000001 0 0 0 0 + + ngroup = 5 + group[0] = 1 + group[1] = 3 2 + group[2] = 6 5 4 + group[3] = 8 9 7 11 + group[4] = 10 + Stored stages = 11 + +MRIStep Statistics: + Time = 0.01 + y(t) = 0.980199 + y_n = 0.980199 + Error = -3.58946e-12 + Steps = 1 + Fe evals = 10 + Fi evals = 0 + +Comparing Solver Statistics: +All checks passed + All tests passed! diff --git a/test/unit_tests/arkode/CXX_serial/ark_test_kpr_mriadapt.cpp b/test/unit_tests/arkode/CXX_serial/ark_test_kpr_mriadapt.cpp new file mode 100644 index 0000000000..c9790af566 --- /dev/null +++ b/test/unit_tests/arkode/CXX_serial/ark_test_kpr_mriadapt.cpp @@ -0,0 +1,1478 @@ +/* ---------------------------------------------------------------- + * Programmer(s): Daniel R. Reynolds @ SMU + * Rujeko Chinomona @ SMU + * ---------------------------------------------------------------- + * SUNDIALS Copyright Start + * Copyright (c) 2002-2024, 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 + * ---------------------------------------------------------------- + * Multirate nonlinear Kvaerno-Prothero-Robinson ODE test problem: + * + * [u]' = [ G e ] [(u^2-r-1)/(2u)] + [ r'(t)/(2u) ] + * [v] [ e -1 ] [(v^2-s-2)/(2v)] [ s'(t)/(2v) ] + * = [ fs(t,u,v) ] + * [ ff(t,u,v) ] + * + * where r(t) = cos(t), and s(t) = cos(w*t*(1+exp(-(t-2)^2))). + * + * This problem has analytical solution given by + * u(t) = sqrt(2+r(t)), v(t) = sqrt(2+s(t)). + * + * This program allows a number of parameters: + * e: fast/slow coupling strength [default = 0.5] + * G: stiffness at slow time scale [default = -1e2] + * w: time-scale separation factor [default = 100] + * + * The stiffness of the slow time scale is essentially determined + * by G, for |G| > 50 it is 'stiff' and ideally suited to a + * multirate method that is implicit at the slow time scale. + * + * Coupling between the two components is determined by e, with + * coupling strength proportional to |e|. + * + * The "fast" variable, v, oscillates at a frequency "w" times + * faster than u. + * + * Additional input options may be used to select between various + * solver options: + * - slow fixed/initial step size: hs [default = 0.01] + * - fast fixed/initial step size: hf [default = 0.0001] + * - set initial adaptive step size as hs/hf above: set_h0 [default 0] + * - relative solution tolerance: rtol [default = 1e-4] + * - absolute solution tolerance: atol [default = 1e-11] + * - relative solution tolerance for fast integrator: fast_rtol [default = 1e-4] + * - use p (0) vs q (1) for slow adaptivity: slow_pq [default = 0] + * - use p (0) vs q (1) for fast adaptivity: fast_pq [default = 0] + * - "slow" MRI method: mri_method [default = ARKODE_MRI_GARK_ERK45a] + * - "fast" ERKStep method order: fast_order [default 4] + * To put all physics at the slow scale, use "0", otherwise + * specify a valid explicit method order. + * - "slow" MRI temporal adaptivity controller: scontrol [default = 6] + * 0: no controller [fixed time steps] + * 1: MRI-CC controller + * 2: MRI-LL controller + * 3: MRI-PI controller + * 4: MRI-PID controller + * 5: I controller (as part of MRI-HTOL) + * 6: I controller (alone) + * 7: PI controller (as part of MRI-HTOL) + * 8: PI controller (alone) + * 9: PID controller (as part of MRI-HTOL) + * 10: PID controller (alone) + * 11: ExpGus controller (as part of MRI-HTOL) + * 12: ExpGus controller (alone) + * 13: ImpGus controller (as part of MRI-HTOL) + * 14: ImpGus controller (alone) + * 15: ImExGus controller (as part of MRI-HTOL) + * 16: ImExGus controller (alone) + * - "fast" ERKStep temporal adaptivity controller: fcontrol [default = 1] + * Note that this will only be used for 5 <= scontrol <= 16. + * 0: no controller [fixed time steps] + * 1: I controller + * 2: PI controller + * 3: PID controller + * 4: ExpGus controller + * 5: ImpGus controller + * 6: ImExGus controller + * - "fast" ERKStep accumulated error type: faccum [default = 0] + * Note that this will only be used for multirate scontrol options + * -1: no accumulation + * 0: maximum accumulation + * 1: additive accumulation + * - controller parameters: (k1s, k2s, k3s, k4s, k5s, k6s, k1f, k2f, k3f, + * bias, htol_relch, htol_minfac, htol_maxfac) + * MRICC, MRILL, MRIPI, and MRIPID: use k1s through k6s, as appropriate. + * slow single-rate controllers: use k1s through k3s, as appropriate. + * fast single-rate controllers: use k1f through k3f, as appropriate. + * MRIHTol controllers: use htol_relch, htol_minfac, htol_maxfac. + * all controllers (fast and slow) use bias. + * ** if any one of a relevant set are "-1" then the defaults are used + * + * Outputs and solution error values are printed at equal intervals + * of 0.5 and run statistics are printed at the end. + * ----------------------------------------------------------------*/ + +// Header files +#include // prototypes for ERKStep fcts., consts +#include // prototypes for MRIStep fcts., consts +#include +#include +#include +#include +#include +#include // serial N_Vector type, fcts., macros +#include +#include +#include +#include +#include +#include +#include +#include +#include // dense linear solver +#include // dense matrix type, fcts., macros +#include // common utility functions + +#if defined(SUNDIALS_EXTENDED_PRECISION) +#define ESYM "Le" +#define FSYM "Lf" +#else +#define ESYM "e" +#define FSYM "f" +#endif + +#define ZERO SUN_RCONST(0.0) +#define ONE SUN_RCONST(1.0) +#define TWO SUN_RCONST(2.0) + +// Problem options +struct Options +{ + // Problem parameters + sunrealtype e = SUN_RCONST(0.5); + sunrealtype G = SUN_RCONST(-100.0); + sunrealtype w = SUN_RCONST(100.0); + + // Step sizes and tolerances + int set_h0 = 0; + sunrealtype hs = SUN_RCONST(1.0e-2); + sunrealtype hf = SUN_RCONST(1.0e-4); + sunrealtype rtol = SUN_RCONST(1.0e-4); + sunrealtype atol = SUN_RCONST(1.0e-11); + sunrealtype fast_rtol = SUN_RCONST(1.0e-4); + + // Method selection + std::string mri_method = "ARKODE_MRI_GARK_ERK45a"; + int fast_order = 4; + int scontrol = 6; + int fcontrol = 1; + int faccum = 0; + int slow_pq = 0; + int fast_pq = 0; + + // controller parameters + sunrealtype k1s = SUN_RCONST(-1.0); + sunrealtype k2s = SUN_RCONST(-1.0); + sunrealtype k3s = SUN_RCONST(-1.0); + sunrealtype k4s = SUN_RCONST(-1.0); + sunrealtype k5s = SUN_RCONST(-1.0); + sunrealtype k6s = SUN_RCONST(-1.0); + sunrealtype k1f = SUN_RCONST(-1.0); + sunrealtype k2f = SUN_RCONST(-1.0); + sunrealtype k3f = SUN_RCONST(-1.0); + sunrealtype bias = SUN_RCONST(-1.0); + sunrealtype htol_relch = SUN_RCONST(-1.0); + sunrealtype htol_minfac = SUN_RCONST(-1.0); + sunrealtype htol_maxfac = SUN_RCONST(-1.0); +}; + +// User-supplied functions called by the solver +static int fse(sunrealtype t, N_Vector y, N_Vector ydot, void* user_data); +static int fsi(sunrealtype t, N_Vector y, N_Vector ydot, void* user_data); +static int fs(sunrealtype t, N_Vector y, N_Vector ydot, void* user_data); +static int ff(sunrealtype t, N_Vector y, N_Vector ydot, void* user_data); +static int fn(sunrealtype t, N_Vector y, N_Vector ydot, void* user_data); +static int f0(sunrealtype t, N_Vector y, N_Vector ydot, void* user_data); +static int Js(sunrealtype t, N_Vector y, N_Vector fy, SUNMatrix J, + void* user_data, N_Vector tmp1, N_Vector tmp2, N_Vector tmp3); +static int Jsi(sunrealtype t, N_Vector y, N_Vector fy, SUNMatrix J, + void* user_data, N_Vector tmp1, N_Vector tmp2, N_Vector tmp3); +static int Jn(sunrealtype t, N_Vector y, N_Vector fy, SUNMatrix J, + void* user_data, N_Vector tmp1, N_Vector tmp2, N_Vector tmp3); + +// Utility functions +static void InputHelp(); +static int ReadInputs(std::vector& args, Options& opts, + SUNContext ctx); +static void PrintSlowAdaptivity(Options opts); +static void PrintFastAdaptivity(Options opts); + +// Private function to check function return values +static sunrealtype r(sunrealtype t, Options* opts); +static sunrealtype s(sunrealtype t, Options* opts); +static sunrealtype rdot(sunrealtype t, Options* opts); +static sunrealtype sdot(sunrealtype t, Options* opts); +static sunrealtype utrue(sunrealtype t, Options* opts); +static sunrealtype vtrue(sunrealtype t, Options* opts); +static int Ytrue(sunrealtype t, N_Vector y, Options* opts); + +// Main Program +int main(int argc, char* argv[]) +{ + // SUNDIALS context object for this simulation + sundials::Context sunctx; + + // Read input options + Options opts; + std::vector args(argv + 1, argv + argc); + int flag = ReadInputs(args, opts, sunctx); + if (check_flag(flag, "ReadInputs")) return 1; + + // General problem parameters + sunrealtype T0 = SUN_RCONST(0.0); // initial time + sunrealtype Tf = SUN_RCONST(5.0); // final time + sunrealtype dTout = SUN_RCONST(0.25); // time between outputs + sunindextype NEQ = 2; // number of dependent vars. + int Nt = (int)ceil(Tf / dTout); // number of output times + + // Initial problem output + // While traversing these, set various function pointers, table constants, and method orders. + ARKRhsFn f_f, f_se, f_si; + ARKLsJacFn J_s; + int retval; + sunbooleantype slowimplicit, slowimex; + slowimplicit = slowimex = SUNFALSE; + f_si = NULL; + J_s = NULL; + f_f = (opts.fast_order == 0) ? f0 : ff; + f_se = (opts.fast_order == 0) ? fn : fs; + if ((opts.mri_method == "ARKODE_MRI_GARK_IRK21a") || + (opts.mri_method == "ARKODE_MRI_GARK_ESDIRK34a") || + (opts.mri_method == "ARKODE_MRI_GARK_ESDIRK46a")) + { + slowimplicit = SUNTRUE; + f_se = NULL; + f_si = (opts.fast_order == 0) ? fn : fs; + J_s = (opts.fast_order == 0) ? Jn : Js; + } + if ((opts.mri_method == "ARKODE_IMEX_MRI_SR21") || + (opts.mri_method == "ARKODE_IMEX_MRI_SR32") || + (opts.mri_method == "ARKODE_IMEX_MRI_SR43")) + { + slowimex = SUNTRUE; + slowimplicit = SUNTRUE; + f_se = (opts.fast_order == 0) ? f0 : fse; + f_si = (opts.fast_order == 0) ? fn : fsi; + J_s = (opts.fast_order == 0) ? Jn : Jsi; + } + std::cout << "\nAdaptive multirate nonlinear Kvaerno-Prothero-Robinson test " + "problem:\n"; + std::cout << " time domain: (" << T0 << "," << Tf << "]\n"; + std::cout << " G = " << opts.G << std::endl; + std::cout << " w = " << opts.w << std::endl; + std::cout << " e = " << opts.e << std::endl; + std::cout << "\n Slow integrator: " << opts.mri_method; + if (slowimex) { std::cout << " (ImEx)" << std::endl; } + else if (slowimplicit) { std::cout << " (implicit)" << std::endl; } + else { std::cout << " (explicit)" << std::endl; } + PrintSlowAdaptivity(opts); + if (opts.fast_order == 0) { std::cout << "\n Fast integrator disabled"; } + else { std::cout << "\n Fast order " << opts.fast_order << std::endl; } + PrintFastAdaptivity(opts); + + // Create and initialize serial vector for the solution + N_Vector y = NULL; + y = N_VNew_Serial(NEQ, sunctx); + if (check_ptr((void*)y, "N_VNew_Serial")) return 1; + retval = Ytrue(T0, y, &opts); + if (check_flag(retval, "Ytrue")) return 1; + + // Create and configure fast controller object + SUNAdaptController fcontrol = NULL; + switch (opts.fcontrol) + { + case (1): + fcontrol = SUNAdaptController_I(sunctx); + if (check_ptr((void*)fcontrol, "SUNAdaptController_I")) return 1; + if (opts.k1f > -1) + { + retval = SUNAdaptController_SetParams_I(fcontrol, opts.k1f); + if (check_flag(retval, "SUNAdaptController_SetParams_I")) return 1; + } + break; + case (2): + fcontrol = SUNAdaptController_PI(sunctx); + if (check_ptr((void*)fcontrol, "SUNAdaptController_PI")) return 1; + if (std::min(opts.k1f, opts.k2f) > -1) + { + retval = SUNAdaptController_SetParams_PI(fcontrol, opts.k1f, opts.k2f); + if (check_flag(retval, "SUNAdaptController_SetParams_PI")) return 1; + } + break; + case (3): + fcontrol = SUNAdaptController_PID(sunctx); + if (check_ptr((void*)fcontrol, "SUNAdaptController_PID")) return 1; + if (std::min(opts.k1f, std::min(opts.k2f, opts.k3f)) > -1) + { + retval = SUNAdaptController_SetParams_PID(fcontrol, opts.k1f, opts.k2f, + opts.k3f); + if (check_flag(retval, "SUNAdaptController_SetParams_PID")) return 1; + } + break; + case (4): + fcontrol = SUNAdaptController_ExpGus(sunctx); + if (check_ptr((void*)fcontrol, "SUNAdaptController_ExpGus")) return 1; + if (std::min(opts.k1f, opts.k2f) > -1) + { + retval = SUNAdaptController_SetParams_ExpGus(fcontrol, opts.k1f, opts.k2f); + if (check_flag(retval, "SUNAdaptController_SetParams_ExpGus")) return 1; + } + break; + case (5): + fcontrol = SUNAdaptController_ImpGus(sunctx); + if (check_ptr((void*)fcontrol, "SUNAdaptController_ImpGus")) return 1; + if (std::min(opts.k1f, opts.k2f) > -1) + { + retval = SUNAdaptController_SetParams_ImpGus(fcontrol, opts.k1f, opts.k2f); + if (check_flag(retval, "SUNAdaptController_SetParams_ImpGus")) return 1; + } + break; + case (6): + fcontrol = SUNAdaptController_ImExGus(sunctx); + if (check_ptr((void*)fcontrol, "SUNAdaptController_ImExGus")) return 1; + break; + } + if ((opts.bias > -1) && (opts.fcontrol > 0)) + { + retval = SUNAdaptController_SetErrorBias(fcontrol, opts.bias); + if (check_flag(retval, "SUNAdaptController_SetErrorBias")) return 1; + } + + // Create ERKStep (fast) integrator + void* inner_arkode_mem = NULL; // ARKode memory structure + inner_arkode_mem = ERKStepCreate(f_f, T0, y, sunctx); + if (check_ptr((void*)inner_arkode_mem, "ERKStepCreate")) return 1; + retval = ARKodeSetOrder(inner_arkode_mem, opts.fast_order); + if (check_flag(retval, "ARKodeSetOrder")) return 1; + retval = ARKodeSStolerances(inner_arkode_mem, opts.fast_rtol, opts.atol); + if (check_flag(retval, "ARKodeSStolerances")) return 1; + if (opts.fcontrol != 0) + { + retval = ARKodeSetAdaptController(inner_arkode_mem, fcontrol); + if (check_flag(retval, "ARKodeSetAdaptController")) return 1; + if (opts.set_h0 != 0) + { + retval = ARKodeSetInitStep(inner_arkode_mem, opts.hf); + if (check_flag(retval, "ARKodeSetInitStep")) return 1; + } + if (opts.fast_pq == 1) + { + retval = ARKodeSetAdaptivityAdjustment(inner_arkode_mem, 0); + if (check_flag(retval, "ARKodeSetAdaptivityAdjustment")) return 1; + } + } + else + { + retval = ARKodeSetFixedStep(inner_arkode_mem, opts.hf); + if (check_flag(retval, "ARKodeSetFixedStep")) return 1; + } + retval = ARKodeSetAccumulatedErrorType(inner_arkode_mem, opts.faccum); + if (check_flag(retval, "ARKodeSetAccumulatedErrorType")) return 1; + retval = ARKodeSetMaxNumSteps(inner_arkode_mem, 1000000); + if (check_flag(retval, "ARKodeSetMaxNumSteps")) return 1; + retval = ARKodeSetUserData(inner_arkode_mem, (void*)&opts); + if (check_flag(retval, "ARKodeSetUserData")) return 1; + + // Create inner stepper + MRIStepInnerStepper inner_stepper = NULL; // inner stepper + retval = ERKStepCreateMRIStepInnerStepper(inner_arkode_mem, &inner_stepper); + if (check_flag(retval, "ERKStepCreateMRIStepInnerStepper")) return 1; + + // Create slow controller object, and select orders of accuracy as relevant + SUNAdaptController scontrol = NULL; + SUNAdaptController scontrol_H = NULL; + SUNAdaptController scontrol_Tol = NULL; + switch (opts.scontrol) + { + case (1): + scontrol = SUNAdaptController_MRICC(sunctx, + opts.fast_order + opts.fast_pq - 1); + if (check_ptr((void*)scontrol, "SUNAdaptController_MRICC")) return 1; + if (std::min(opts.k1s, opts.k2s) > -1) + { + retval = SUNAdaptController_SetParams_MRICC(scontrol, opts.k1s, opts.k2s); + if (check_flag(retval, "SUNAdaptController_SetParams_MRICC")) return 1; + } + break; + case (2): + scontrol = SUNAdaptController_MRILL(sunctx, + opts.fast_order + opts.fast_pq - 1); + if (check_ptr((void*)scontrol, "SUNAdaptController_MRILL")) return 1; + if (std::min(opts.k1s, std::min(opts.k2s, std::min(opts.k3s, opts.k4s))) > -1) + { + retval = SUNAdaptController_SetParams_MRILL(scontrol, opts.k1s, opts.k2s, + opts.k3s, opts.k4s); + if (check_flag(retval, "SUNAdaptController_SetParams_MRILL")) return 1; + } + break; + case (3): + scontrol = SUNAdaptController_MRIPI(sunctx, + opts.fast_order + opts.fast_pq - 1); + if (check_ptr((void*)scontrol, "SUNAdaptController_MRIPI")) return 1; + if (std::min(opts.k1s, std::min(opts.k2s, std::min(opts.k3s, opts.k4s))) > -1) + { + retval = SUNAdaptController_SetParams_MRIPI(scontrol, opts.k1s, opts.k2s, + opts.k3s, opts.k4s); + if (check_flag(retval, "SUNAdaptController_SetParams_MRIPI")) return 1; + } + break; + case (4): + scontrol = SUNAdaptController_MRIPID(sunctx, + opts.fast_order + opts.fast_pq - 1); + if (check_ptr((void*)scontrol, "SUNAdaptController_MRIPID")) return 1; + if (std::min(opts.k1s, + std::min(opts.k2s, + std::min(opts.k3s, + std::min(opts.k4s, + std::min(opts.k5s, opts.k6s))))) > -1) + { + retval = SUNAdaptController_SetParams_MRIPID(scontrol, opts.k1s, opts.k2s, + opts.k3s, opts.k4s, opts.k5s, + opts.k6s); + if (check_flag(retval, "SUNAdaptController_SetParams_MRIPID")) return 1; + } + break; + case (5): + scontrol_H = SUNAdaptController_I(sunctx); + if (check_ptr((void*)scontrol_H, "SUNAdaptController_I (slow H)")) return 1; + scontrol_Tol = SUNAdaptController_I(sunctx); + if (check_ptr((void*)scontrol_Tol, "SUNAdaptController_I (slow Tol)")) + return 1; + if (opts.k1s > -1) + { + retval = SUNAdaptController_SetParams_I(scontrol_H, opts.k1s); + if (check_flag(retval, "SUNAdaptController_SetParams_I")) return 1; + retval = SUNAdaptController_SetParams_I(scontrol_Tol, opts.k1s); + if (check_flag(retval, "SUNAdaptController_SetParams_I")) return 1; + } + scontrol = SUNAdaptController_MRIHTol(sunctx, scontrol_H, scontrol_Tol); + if (check_ptr((void*)scontrol, "SUNAdaptController_MRIHTol")) return 1; + if (std::min(opts.htol_relch, std::min(opts.htol_minfac, opts.htol_maxfac)) > + -1) + { + retval = SUNAdaptController_SetParams_MRIHTol(scontrol, opts.htol_relch, + opts.htol_minfac, + opts.htol_maxfac); + if (check_flag(retval, "SUNAdaptController_SetParams_MRIHTol")) return 1; + } + break; + case (6): + scontrol = SUNAdaptController_I(sunctx); + if (check_ptr((void*)scontrol, "SUNAdaptControllerI (slow)")) return 1; + if (opts.k1s > -1) + { + retval = SUNAdaptController_SetParams_I(scontrol, opts.k1s); + if (check_flag(retval, "SUNAdaptController_SetParams_I")) return 1; + } + break; + case (7): + scontrol_H = SUNAdaptController_PI(sunctx); + if (check_ptr((void*)scontrol_H, "SUNAdaptController_PI (slow H)")) + return 1; + scontrol_Tol = SUNAdaptController_PI(sunctx); + if (check_ptr((void*)scontrol_Tol, "SUNAdaptController_PI (slow Tol)")) + return 1; + if (std::min(opts.k1s, opts.k2s) > -1) + { + retval = SUNAdaptController_SetParams_PI(scontrol_H, opts.k1s, opts.k2s); + if (check_flag(retval, "SUNAdaptController_SetParams_PI")) return 1; + retval = SUNAdaptController_SetParams_PI(scontrol_Tol, opts.k1s, opts.k2s); + if (check_flag(retval, "SUNAdaptController_SetParams_PI")) return 1; + } + scontrol = SUNAdaptController_MRIHTol(sunctx, scontrol_H, scontrol_Tol); + if (check_ptr((void*)scontrol, "SUNAdaptController_MRIHTol")) return 1; + if (std::min(opts.htol_relch, std::min(opts.htol_minfac, opts.htol_maxfac)) > + -1) + { + retval = SUNAdaptController_SetParams_MRIHTol(scontrol, opts.htol_relch, + opts.htol_minfac, + opts.htol_maxfac); + if (check_flag(retval, "SUNAdaptController_SetParams_MRIHTol")) return 1; + } + break; + case (8): + scontrol = SUNAdaptController_PI(sunctx); + if (check_ptr((void*)scontrol, "SUNAdaptController_PI (slow)")) return 1; + if (std::min(opts.k1s, opts.k2s) > -1) + { + retval = SUNAdaptController_SetParams_PI(scontrol, opts.k1s, opts.k2s); + if (check_flag(retval, "SUNAdaptController_SetParams_PI")) return 1; + } + break; + case (9): + scontrol_H = SUNAdaptController_PID(sunctx); + if (check_ptr((void*)scontrol_H, "SUNAdaptController_PID (slow H)")) + return 1; + scontrol_Tol = SUNAdaptController_PID(sunctx); + if (check_ptr((void*)scontrol_Tol, "SUNAdaptController_PID (slow Tol)")) + return 1; + if (std::min(opts.k1s, std::min(opts.k2s, opts.k3s)) > -1) + { + retval = SUNAdaptController_SetParams_PID(scontrol_H, opts.k1s, opts.k2s, + opts.k3s); + if (check_flag(retval, "SUNAdaptController_SetParams_PID")) return 1; + retval = SUNAdaptController_SetParams_PID(scontrol_Tol, opts.k1s, + opts.k2s, opts.k3s); + if (check_flag(retval, "SUNAdaptController_SetParams_PID")) return 1; + } + scontrol = SUNAdaptController_MRIHTol(sunctx, scontrol_H, scontrol_Tol); + if (check_ptr((void*)scontrol, "SUNAdaptController_MRIHTol")) return 1; + if (std::min(opts.htol_relch, std::min(opts.htol_minfac, opts.htol_maxfac)) > + -1) + { + retval = SUNAdaptController_SetParams_MRIHTol(scontrol, opts.htol_relch, + opts.htol_minfac, + opts.htol_maxfac); + if (check_flag(retval, "SUNAdaptController_SetParams_MRIHTol")) return 1; + } + break; + case (10): + scontrol = SUNAdaptController_PID(sunctx); + if (check_ptr((void*)scontrol, "SUNAdaptController_PID (slow)")) return 1; + if (std::min(opts.k1s, std::min(opts.k2s, opts.k3s)) > -1) + { + retval = SUNAdaptController_SetParams_PID(scontrol, opts.k1s, opts.k2s, + opts.k3s); + if (check_flag(retval, "SUNAdaptController_SetParams_PID")) return 1; + } + break; + case (11): + scontrol_H = SUNAdaptController_ExpGus(sunctx); + if (check_ptr((void*)scontrol_H, "SUNAdaptController_ExpGus (slow H)")) + return 1; + scontrol_Tol = SUNAdaptController_ExpGus(sunctx); + if (check_ptr((void*)scontrol_Tol, "SUNAdaptController_ExpGus (slow Tol)")) + return 1; + if (std::min(opts.k1s, opts.k2s) > -1) + { + retval = SUNAdaptController_SetParams_ExpGus(scontrol_H, opts.k1s, + opts.k2s); + if (check_flag(retval, "SUNAdaptController_SetParams_ExpGus")) return 1; + retval = SUNAdaptController_SetParams_ExpGus(scontrol_Tol, opts.k1s, + opts.k2s); + if (check_flag(retval, "SUNAdaptController_SetParams_ExpGus")) return 1; + } + scontrol = SUNAdaptController_MRIHTol(sunctx, scontrol_H, scontrol_Tol); + if (check_ptr((void*)scontrol, "SUNAdaptController_MRIHTol")) return 1; + if (std::min(opts.htol_relch, std::min(opts.htol_minfac, opts.htol_maxfac)) > + -1) + { + retval = SUNAdaptController_SetParams_MRIHTol(scontrol, opts.htol_relch, + opts.htol_minfac, + opts.htol_maxfac); + if (check_flag(retval, "SUNAdaptController_SetParams_MRIHTol")) return 1; + } + break; + case (12): + scontrol = SUNAdaptController_ExpGus(sunctx); + if (check_ptr((void*)scontrol, "SUNAdaptController_ExpGus (slow)")) + return 1; + if (std::min(opts.k1s, opts.k2s) > -1) + { + retval = SUNAdaptController_SetParams_ExpGus(scontrol, opts.k1s, opts.k2s); + if (check_flag(retval, "SUNAdaptController_SetParams_ExpGus")) return 1; + } + break; + case (13): + scontrol_H = SUNAdaptController_ImpGus(sunctx); + if (check_ptr((void*)scontrol_H, "SUNAdaptController_ImpGus (slow H)")) + return 1; + scontrol_Tol = SUNAdaptController_ImpGus(sunctx); + if (check_ptr((void*)scontrol_Tol, "SUNAdaptController_ImpGus (slow Tol)")) + return 1; + if (std::min(opts.k1s, opts.k2s) > -1) + { + retval = SUNAdaptController_SetParams_ImpGus(scontrol_H, opts.k1s, + opts.k2s); + if (check_flag(retval, "SUNAdaptController_SetParams_ImpGus")) return 1; + retval = SUNAdaptController_SetParams_ImpGus(scontrol_Tol, opts.k1s, + opts.k2s); + if (check_flag(retval, "SUNAdaptController_SetParams_ImpGus")) return 1; + } + scontrol = SUNAdaptController_MRIHTol(sunctx, scontrol_H, scontrol_Tol); + if (check_ptr((void*)scontrol, "SUNAdaptController_MRIHTol")) return 1; + if (std::min(opts.htol_relch, std::min(opts.htol_minfac, opts.htol_maxfac)) > + -1) + { + retval = SUNAdaptController_SetParams_MRIHTol(scontrol, opts.htol_relch, + opts.htol_minfac, + opts.htol_maxfac); + if (check_flag(retval, "SUNAdaptController_SetParams_MRIHTol")) return 1; + } + break; + case (14): + scontrol = SUNAdaptController_ImpGus(sunctx); + if (check_ptr((void*)scontrol, "SUNAdaptController_ImpGus (slow)")) + return 1; + if (std::min(opts.k1s, opts.k2s) > -1) + { + retval = SUNAdaptController_SetParams_ImpGus(scontrol, opts.k1s, opts.k2s); + if (check_flag(retval, "SUNAdaptController_SetParams_ImpGus")) return 1; + } + break; + case (15): + scontrol_H = SUNAdaptController_ImExGus(sunctx); + if (check_ptr((void*)scontrol_H, "SUNAdaptController_ImExGus (slow H)")) + return 1; + scontrol_Tol = SUNAdaptController_ImExGus(sunctx); + if (check_ptr((void*)scontrol_Tol, "SUNAdaptController_ImExGus (slow Tol)")) + return 1; + scontrol = SUNAdaptController_MRIHTol(sunctx, scontrol_H, scontrol_Tol); + if (check_ptr((void*)scontrol, "SUNAdaptController_MRIHTol")) return 1; + if (std::min(opts.htol_relch, std::min(opts.htol_minfac, opts.htol_maxfac)) > + -1) + { + retval = SUNAdaptController_SetParams_MRIHTol(scontrol, opts.htol_relch, + opts.htol_minfac, + opts.htol_maxfac); + if (check_flag(retval, "SUNAdaptController_SetParams_MRIHTol")) return 1; + } + break; + case (16): + scontrol = SUNAdaptController_ImExGus(sunctx); + if (check_ptr((void*)scontrol, "SUNAdaptController_ImExGus (slow)")) + return 1; + break; + } + if ((opts.bias > -1) && (opts.scontrol > 0)) + { + retval = SUNAdaptController_SetErrorBias(scontrol, opts.bias); + if (check_flag(retval, "SUNAdaptController_SetErrorBias")) return 1; + } + + // Create MRI (slow) integrator + void* arkode_mem = NULL; // ARKode memory structure + arkode_mem = MRIStepCreate(f_se, f_si, T0, y, inner_stepper, sunctx); + if (check_ptr((void*)arkode_mem, "MRIStepCreate")) return 1; + MRIStepCoupling C = MRIStepCoupling_LoadTableByName((opts.mri_method).c_str()); + if (check_ptr((void*)C, "MRIStepCoupling_LoadTableByName")) return 1; + retval = MRIStepSetCoupling(arkode_mem, C); + if (check_flag(retval, "MRIStepSetCoupling")) return 1; + SUNMatrix As = NULL; // matrix for slow solver + SUNLinearSolver LSs = NULL; // slow linear solver object + if (slowimplicit) + { + As = SUNDenseMatrix(NEQ, NEQ, sunctx); + if (check_ptr((void*)As, "SUNDenseMatrix")) return 1; + LSs = SUNLinSol_Dense(y, As, sunctx); + if (check_ptr((void*)LSs, "SUNLinSol_Dense")) return 1; + retval = ARKodeSetLinearSolver(arkode_mem, LSs, As); + if (check_flag(retval, "ARKodeSetLinearSolver")) return 1; + retval = ARKodeSetJacFn(arkode_mem, J_s); + if (check_flag(retval, "ARKodeSetJacFn")) return 1; + } + retval = ARKodeSStolerances(arkode_mem, opts.rtol, opts.atol); + if (check_flag(retval, "ARKodeSStolerances")) return 1; + retval = ARKodeSetMaxNumSteps(arkode_mem, 100000); + if (check_flag(retval, "ARKodeSetMaxNumSteps")) return 1; + retval = ARKodeSetUserData(arkode_mem, (void*)&opts); + if (check_flag(retval, "ARKodeSetUserData")) return 1; + if (opts.scontrol != 0) + { + retval = MRIStepSetAdaptController(arkode_mem, scontrol); + if (check_flag(retval, "MRIStepSetAdaptController")) return 1; + if (opts.set_h0 != 0) + { + retval = ARKodeSetInitStep(arkode_mem, opts.hs); + if (check_flag(retval, "ARKodeSetInitStep")) return 1; + } + if (opts.slow_pq == 1) + { + retval = ARKodeSetAdaptivityAdjustment(arkode_mem, 0); + if (check_flag(retval, "ARKodeSetAdaptivityAdjustment")) return 1; + } + } + else + { + retval = ARKodeSetFixedStep(arkode_mem, opts.hs); + if (check_flag(retval, "ARKodeSetFixedStep")) return 1; + } + + // + // Integrate ODE + // + + // Main time-stepping loop: calls ARKodeEvolve to perform the + // integration, then prints results. Stops when the final time + // has been reached + sunrealtype t, tout; + sunrealtype uerr, verr, uerrtot, verrtot, errtot, accuracy; + t = T0; + tout = T0 + dTout; + uerr = ZERO; + verr = ZERO; + uerrtot = ZERO; + verrtot = ZERO; + errtot = ZERO; + accuracy = ZERO; + printf(" t u v uerr verr\n"); + printf(" ------------------------------------------------------\n"); + printf(" %10.6" FSYM " %10.6" FSYM " %10.6" FSYM " %.2" ESYM " %.2" ESYM + "\n", + t, NV_Ith_S(y, 0), NV_Ith_S(y, 1), uerr, verr); + + for (int iout = 0; iout < Nt; iout++) + { + // set stop time to ensure that solutions are reported to full accuracy + retval = ARKodeSetStopTime(arkode_mem, tout); + if (check_flag(retval, "ARKodeSetStopTime")) return 1; + + // call integrator + retval = ARKodeEvolve(arkode_mem, tout, y, &t, ARK_NORMAL); + if (retval < 0) + { + printf("ARKodeEvolve error (%i)\n", retval); + return 1; + } + + // access/print solution and error + uerr = SUNRabs(NV_Ith_S(y, 0) - utrue(t, &opts)); + verr = SUNRabs(NV_Ith_S(y, 1) - vtrue(t, &opts)); + printf(" %10.6" FSYM " %10.6" FSYM " %10.6" FSYM " %.2" ESYM + " %.2" ESYM "\n", + t, NV_Ith_S(y, 0), NV_Ith_S(y, 1), uerr, verr); + uerrtot += uerr * uerr; + verrtot += verr * verr; + errtot += uerr * uerr + verr * verr; + accuracy = std::max(accuracy, + uerr / SUNRabs(opts.atol + opts.rtol * utrue(t, &opts))); + accuracy = std::max(accuracy, + verr / SUNRabs(opts.atol + opts.rtol * vtrue(t, &opts))); + + // successful solve: update time + tout += dTout; + tout = (tout > Tf) ? Tf : tout; + } + uerrtot = SUNRsqrt(uerrtot / Nt); + verrtot = SUNRsqrt(verrtot / Nt); + errtot = SUNRsqrt(errtot / Nt / 2); + printf(" ------------------------------------------------------\n"); + + // + // Finalize + // + + // Get some slow integrator statistics + long int nsts, natts, netfs, nfse, nfsi; + retval = ARKodeGetNumSteps(arkode_mem, &nsts); + check_flag(retval, "ARKodeGetNumSteps"); + retval = ARKodeGetNumStepAttempts(arkode_mem, &natts); + check_flag(retval, "ARKodeGetNumStepAttempts"); + retval = ARKodeGetNumErrTestFails(arkode_mem, &netfs); + check_flag(retval, "ARKodeGetNumErrTestFails"); + retval = MRIStepGetNumRhsEvals(arkode_mem, &nfse, &nfsi); + check_flag(retval, "MRIStepGetNumRhsEvals"); + + // Get some fast integrator statistics + long int nstf, nattf, netff, nff; + retval = ARKodeGetNumSteps(inner_arkode_mem, &nstf); + check_flag(retval, "ARKodeGetNumSteps"); + retval = ARKodeGetNumStepAttempts(inner_arkode_mem, &nattf); + check_flag(retval, "ARKodeGetNumStepAttempts"); + retval = ARKodeGetNumErrTestFails(inner_arkode_mem, &netff); + check_flag(retval, "ARKodeGetNumErrTestFails"); + retval = ERKStepGetNumRhsEvals(inner_arkode_mem, &nff); + check_flag(retval, "ERKStepGetNumRhsEvals"); + + // Print some final statistics + std::cout << "\nFinal Solver Statistics:\n"; + std::cout << " Slow steps = " << nsts << " (attempts = " << natts + << ", fails = " << netfs << ")\n"; + std::cout << " Fast steps = " << nstf << " (attempts = " << nattf + << ", fails = " << netff << ")\n"; + std::cout << " u error = " << uerrtot << ", v error = " << verrtot + << ", total error = " << errtot << std::endl; + std::cout << " Relative accuracy = " << accuracy << std::endl; + std::cout << " Total RHS evals: Fse = " << nfse << ", Fsi = " << nfsi + << ", Ff = " << nff << std::endl; + + // Get/print slow integrator decoupled implicit solver statistics + if (slowimplicit) + { + long int nnis, nncs, njes; + retval = ARKodeGetNonlinSolvStats(arkode_mem, &nnis, &nncs); + check_flag(retval, "ARKodeGetNonlinSolvStats"); + retval = ARKodeGetNumJacEvals(arkode_mem, &njes); + check_flag(retval, "ARKodeGetNumJacEvals"); + std::cout << " Slow Newton iters = " << nnis << std::endl; + std::cout << " Slow Newton conv fails = " << nncs << std::endl; + std::cout << " Slow Jacobian evals = " << njes << std::endl; + } + + // Clean up and return + N_VDestroy(y); + MRIStepCoupling_Free(C); + if (As) { SUNMatDestroy(As); } + if (LSs) { SUNLinSolFree(LSs); } + if (scontrol) { SUNAdaptController_Destroy(scontrol); } + if (scontrol_H) { SUNAdaptController_Destroy(scontrol_H); } + if (scontrol_Tol) { SUNAdaptController_Destroy(scontrol_Tol); } + if (fcontrol) { SUNAdaptController_Destroy(fcontrol); } + ARKodeFree(&inner_arkode_mem); // Free fast integrator memory + MRIStepInnerStepper_Free(&inner_stepper); // Free inner stepper structure + ARKodeFree(&arkode_mem); // Free slow integrator memory + + return 0; +} + +// ------------------------------ +// Functions called by the solver +// ----------------------------- + +// ff routine to compute the fast portion of the ODE RHS. +static int ff(sunrealtype t, N_Vector y, N_Vector ydot, void* user_data) +{ + Options* opts = (Options*)user_data; + const sunrealtype u = NV_Ith_S(y, 0); + const sunrealtype v = NV_Ith_S(y, 1); + sunrealtype tmp1, tmp2; + + // fill in the RHS function: + // [0 0]*[(-2+u^2-r(t))/(2*u)] + [ 0 ] + // [e -1] [(-2+v^2-s(t))/(2*v)] [sdot(t)/(2v)] + tmp1 = (-TWO + u * u - r(t, opts)) / (TWO * u); + tmp2 = (-TWO + v * v - s(t, opts)) / (TWO * v); + NV_Ith_S(ydot, 0) = ZERO; + NV_Ith_S(ydot, 1) = opts->e * tmp1 - tmp2 + sdot(t, opts) / (TWO * v); + + // Return with success + return 0; +} + +// fs routine to compute the slow portion of the ODE RHS. +static int fs(sunrealtype t, N_Vector y, N_Vector ydot, void* user_data) +{ + Options* opts = (Options*)user_data; + const sunrealtype u = NV_Ith_S(y, 0); + const sunrealtype v = NV_Ith_S(y, 1); + sunrealtype tmp1, tmp2; + + // fill in the RHS function: + // [G e]*[(-2+u^2-r(t))/(2*u)] + [rdot(t)/(2u)] + // [0 0] [(-2+v^2-s(t))/(2*v)] [ 0 ] + tmp1 = (-TWO + u * u - r(t, opts)) / (TWO * u); + tmp2 = (-TWO + v * v - s(t, opts)) / (TWO * v); + NV_Ith_S(ydot, 0) = opts->G * tmp1 + opts->e * tmp2 + rdot(t, opts) / (TWO * u); + NV_Ith_S(ydot, 1) = ZERO; + + // Return with success + return 0; +} + +// fse routine to compute the slow portion of the ODE RHS. +static int fse(sunrealtype t, N_Vector y, N_Vector ydot, void* user_data) +{ + Options* opts = (Options*)user_data; + const sunrealtype u = NV_Ith_S(y, 0); + + // fill in the slow explicit RHS function: + // [rdot(t)/(2u)] + // [ 0 ] + NV_Ith_S(ydot, 0) = rdot(t, opts) / (TWO * u); + NV_Ith_S(ydot, 1) = ZERO; + + // Return with success + return 0; +} + +// fsi routine to compute the slow portion of the ODE RHS.(currently same as fse) +static int fsi(sunrealtype t, N_Vector y, N_Vector ydot, void* user_data) +{ + Options* opts = (Options*)user_data; + const sunrealtype u = NV_Ith_S(y, 0); + const sunrealtype v = NV_Ith_S(y, 1); + sunrealtype tmp1, tmp2; + + // fill in the slow implicit RHS function: + // [G e]*[(-2+u^2-r(t))/(2*u)] + // [0 0] [(-2+v^2-s(t))/(2*v)] + tmp1 = (-TWO + u * u - r(t, opts)) / (TWO * u); + tmp2 = (-TWO + v * v - s(t, opts)) / (TWO * v); + NV_Ith_S(ydot, 0) = opts->G * tmp1 + opts->e * tmp2; + NV_Ith_S(ydot, 1) = ZERO; + + // Return with success + return 0; +} + +static int fn(sunrealtype t, N_Vector y, N_Vector ydot, void* user_data) +{ + Options* opts = (Options*)user_data; + const sunrealtype u = NV_Ith_S(y, 0); + const sunrealtype v = NV_Ith_S(y, 1); + sunrealtype tmp1, tmp2; + + // fill in the RHS function: + // [G e]*[(-2+u^2-r(t))/(2*u)] + [rdot(t)/(2u)] + // [e -1] [(-2+v^2-s(t))/(2*v)] [sdot(t)/(2v)] + tmp1 = (-TWO + u * u - r(t, opts)) / (TWO * u); + tmp2 = (-TWO + v * v - s(t, opts)) / (TWO * v); + NV_Ith_S(ydot, 0) = opts->G * tmp1 + opts->e * tmp2 + rdot(t, opts) / (TWO * u); + NV_Ith_S(ydot, 1) = opts->e * tmp1 - tmp2 + sdot(t, opts) / (TWO * v); + + // Return with success + return 0; +} + +static int f0(sunrealtype t, N_Vector y, N_Vector ydot, void* user_data) +{ + N_VConst(ZERO, ydot); + return (0); +} + +static int Js(sunrealtype t, N_Vector y, N_Vector fy, SUNMatrix J, + void* user_data, N_Vector tmp1, N_Vector tmp2, N_Vector tmp3) +{ + Options* opts = (Options*)user_data; + const sunrealtype u = NV_Ith_S(y, 0); + const sunrealtype v = NV_Ith_S(y, 1); + sunrealtype t11, t22; + + // fill in the Jacobian: + // [G e]*[1-(u^2-r(t)-2)/(2*u^2), 0] + [-r'(t)/(2*u^2), 0] + // [0 0] [0, 1-(v^2-s(t)-2)/(2*v^2)] [0, 0] + t11 = ONE - (u * u - r(t, opts) - TWO) / (TWO * u * u); + t22 = ONE - (v * v - s(t, opts) - TWO) / (TWO * v * v); + SM_ELEMENT_D(J, 0, 0) = opts->G * t11 - rdot(t, opts) / (TWO * u * u); + SM_ELEMENT_D(J, 0, 1) = opts->e * t22; + SM_ELEMENT_D(J, 1, 0) = ZERO; + SM_ELEMENT_D(J, 1, 1) = ZERO; + + // Return with success + return 0; +} + +static int Jsi(sunrealtype t, N_Vector y, N_Vector fy, SUNMatrix J, + void* user_data, N_Vector tmp1, N_Vector tmp2, N_Vector tmp3) +{ + Options* opts = (Options*)user_data; + const sunrealtype u = NV_Ith_S(y, 0); + const sunrealtype v = NV_Ith_S(y, 1); + sunrealtype t11, t22; + + // fill in the Jacobian: + // [G e]*[1-(u^2-r(t)-2)/(2*u^2), 0] + // [0 0] [0, 1-(v^2-s(t)-2)/(2*v^2)] + t11 = ONE - (u * u - r(t, opts) - TWO) / (TWO * u * u); + t22 = ONE - (v * v - s(t, opts) - TWO) / (TWO * v * v); + SM_ELEMENT_D(J, 0, 0) = opts->G * t11; + SM_ELEMENT_D(J, 0, 1) = opts->e * t22; + SM_ELEMENT_D(J, 1, 0) = ZERO; + SM_ELEMENT_D(J, 1, 1) = ZERO; + + // Return with success + return 0; +} + +static int Jn(sunrealtype t, N_Vector y, N_Vector fy, SUNMatrix J, + void* user_data, N_Vector tmp1, N_Vector tmp2, N_Vector tmp3) +{ + Options* opts = (Options*)user_data; + const sunrealtype u = NV_Ith_S(y, 0); + const sunrealtype v = NV_Ith_S(y, 1); + sunrealtype t11, t22; + + // fill in the Jacobian: + // [G e]*[1-(u^2-r(t)-2)/(2*u^2), 0] + [-r'(t)/(2*u^2), 0] + // [e -1] [0, 1-(v^2-s(t)-2)/(2*v^2)] [0, -s'(t)/(2*v^2)] + t11 = ONE - (u * u - r(t, opts) - TWO) / (TWO * u * u); + t22 = ONE - (v * v - s(t, opts) - TWO) / (TWO * v * v); + SM_ELEMENT_D(J, 0, 0) = opts->G * t11 - rdot(t, opts) / (TWO * u * u); + SM_ELEMENT_D(J, 0, 1) = opts->e * t22; + SM_ELEMENT_D(J, 1, 0) = opts->e * t11; + SM_ELEMENT_D(J, 1, 1) = -t22 - sdot(t, opts) / (TWO * v * v); + + // Return with success + return 0; +} + +// ------------------------------ +// Private helper functions +// ----------------------------- + +static sunrealtype r(sunrealtype t, Options* opts) { return (cos(t)); } + +static sunrealtype s(sunrealtype t, Options* opts) +{ + return (cos(opts->w * t * (ONE + exp(-(t - TWO) * (t - TWO))))); +} + +static sunrealtype rdot(sunrealtype t, Options* opts) { return (-sin(t)); } + +static sunrealtype sdot(sunrealtype t, Options* opts) +{ + const sunrealtype tTwo = t - TWO; + const sunrealtype eterm = exp(-tTwo * tTwo); + return (-sin(opts->w * t * (ONE + eterm)) * opts->w * + (ONE + eterm * (ONE - TWO * t * tTwo))); +} + +static sunrealtype utrue(sunrealtype t, Options* opts) +{ + return (SUNRsqrt(TWO + r(t, opts))); +} + +static sunrealtype vtrue(sunrealtype t, Options* opts) +{ + return (SUNRsqrt(TWO + s(t, opts))); +} + +static int Ytrue(sunrealtype t, N_Vector y, Options* opts) +{ + NV_Ith_S(y, 0) = utrue(t, opts); + NV_Ith_S(y, 1) = vtrue(t, opts); + return (0); +} + +// ----------------------------------------------------------------------------- +// Utility functions +// ----------------------------------------------------------------------------- + +// Print command line options +void InputHelp() +{ + std::cout << std::endl; + std::cout << "Command line options:" << std::endl; + std::cout << " --help : print options and exit\n"; + std::cout << " --e : fast/slow coupling strength\n"; + std::cout << " --G : stiffness at slow time scale\n"; + std::cout << " --w : time-scale separation factor\n"; + std::cout << " --hs : slow (fixed/initial) step size\n"; + std::cout << " --hf : fast (fixed/initial) step size\n"; + std::cout + << " --set_h0 : use hs/hf above to set the initial step size\n"; + std::cout << " --rtol : relative solution tolerance\n"; + std::cout << " --atol : absolute solution tolerance\n"; + std::cout + << " --fast_rtol : relative solution tolerance for fast method\n"; + std::cout << " --mri_method : MRI method name (valid ARKODE_MRITableID)\n"; + std::cout << " --fast_order : fast RK method order\n"; + std::cout << " --scontrol : slow time step controller, int in [0,16] " + "(see source)\n"; + std::cout << " --fcontrol : fast time step controller, int in [0,6] " + "(see source)\n"; + std::cout << " --faccum : fast error accumulation type {-1,0,1}\n"; + std::cout << " --slow_pq : use p (0) vs q (1) for slow adaptivity\n"; + std::cout << " --fast_pq : use p (0) vs q (1) for fast adaptivity\n"; + std::cout << " --k1s, --k2s, ..., -k6s : slow controller parameters\n"; + std::cout << " --k1f, --k2f, -k3f : fast controller parameters\n"; + std::cout << " --bias : slow and fast controller bias factors\n"; + std::cout + << " --htol_relch : HTol controller maximum relative tolerance change\n"; + std::cout + << " --htol_minfac : HTol controller minimum relative tolerance factor\n"; + std::cout + << " --htol_maxfac : HTol controller maximum relative tolerance factor\n"; +} + +// Read input options +int ReadInputs(std::vector& args, Options& opts, SUNContext ctx) +{ + if (find(args.begin(), args.end(), "--help") != args.end()) + { + InputHelp(); + return 1; + } + + // Problem options + find_arg(args, "--e", opts.e); + find_arg(args, "--G", opts.G); + find_arg(args, "--w", opts.w); + find_arg(args, "--hs", opts.hs); + find_arg(args, "--hf", opts.hf); + find_arg(args, "--set_h0", opts.set_h0); + find_arg(args, "--rtol", opts.rtol); + find_arg(args, "--atol", opts.atol); + find_arg(args, "--fast_rtol", opts.fast_rtol); + find_arg(args, "--mri_method", opts.mri_method); + find_arg(args, "--fast_order", opts.fast_order); + find_arg(args, "--scontrol", opts.scontrol); + find_arg(args, "--fcontrol", opts.fcontrol); + find_arg(args, "--faccum", opts.faccum); + find_arg(args, "--slow_pq", opts.slow_pq); + find_arg(args, "--fast_pq", opts.fast_pq); + find_arg(args, "--k1s", opts.k1s); + find_arg(args, "--k2s", opts.k2s); + find_arg(args, "--k3s", opts.k3s); + find_arg(args, "--k4s", opts.k4s); + find_arg(args, "--k5s", opts.k5s); + find_arg(args, "--k6s", opts.k6s); + find_arg(args, "--k1f", opts.k1f); + find_arg(args, "--k2f", opts.k2f); + find_arg(args, "--k3f", opts.k3f); + find_arg(args, "--bias", opts.bias); + find_arg(args, "--htol_relch", opts.htol_relch); + find_arg(args, "--htol_minfac", opts.htol_minfac); + find_arg(args, "--htol_maxfac", opts.htol_maxfac); + + // Check inputs for validity + // 0 < rtol < 1 + if ((opts.rtol < ZERO) || (opts.rtol > ONE)) + { + std::cerr << "ERROR: rtol must be in (0,1), (" << opts.rtol << " input)\n"; + return -1; + } + // 0 < atol < 1 + if ((opts.atol < ZERO) || (opts.atol > ONE)) + { + std::cerr << "ERROR: atol must be in (0,1), (" << opts.atol << " input)\n"; + return -1; + } + // 0 < fast_rtol < 1 + if ((opts.fast_rtol < ZERO) || (opts.fast_rtol > ONE)) + { + std::cerr << "ERROR: fast_rtol must be in (0,1), (" << opts.fast_rtol + << " input)\n"; + return -1; + } + // slow_pq in {0,1} + if ((opts.slow_pq < 0) || (opts.slow_pq > 1)) + { + std::cerr << "ERROR: slow_pq must be in {0,1}, (" << opts.slow_pq + << " input)\n"; + return -1; + } + // fast_pq in {0,1} + if ((opts.fast_pq < 0) || (opts.fast_pq > 1)) + { + std::cerr << "ERROR: fast_pq must be in {0,1}, (" << opts.fast_pq + << " input)\n"; + return -1; + } + // scontrol in [0,16] + if ((opts.scontrol < 0) || (opts.scontrol > 16)) + { + std::cerr << "ERROR: scontrol must be in [0,16], (" << opts.scontrol + << " input)\n"; + return -1; + } + // fcontrol in [0,6] + if ((opts.fcontrol < 0) || (opts.fcontrol > 6)) + { + std::cerr << "ERROR: fcontrol must be in [0,6], (" << opts.fcontrol + << " input)\n"; + return -1; + } + // hs > 0 if scontrol == 0 + if ((opts.hs <= 0) && (opts.scontrol == 0)) + { + std::cerr << "ERROR: positive hs required with scontrol = 0, (" << opts.hs + << " input)\n"; + return -1; + } + // hf > 0 if fcontrol == 0 + if ((opts.hf <= 0) && (opts.fcontrol == 0)) + { + std::cerr << "ERROR: positive hf required with fcontrol = 0, (" << opts.hf + << " input)\n"; + return -1; + } + // G < 0.0 + if (opts.G >= ZERO) + { + std::cerr << "ERROR: G must be a negative real number, (" << opts.G + << " input)\n"; + return -1; + } + // w >= 1.0 + if (opts.w < ONE) + { + std::cerr << "ERROR: w must be >= 1.0, (" << opts.w << " input)\n"; + return -1; + } + + return 0; +} + +static void PrintSlowAdaptivity(Options opts) +{ + switch (opts.scontrol) + { + case (0): + std::cout << " fixed steps, hs = " << opts.hs << std::endl; + std::cout << " rtol = " << opts.rtol << ", atol = " << opts.atol << "\n"; + break; + case (1): + std::cout << " MRI-CC controller based on order of MRI " + << ((opts.slow_pq == 1) ? "method\n" : "embedding\n"); + std::cout << " rtol = " << opts.rtol << ", atol = " << opts.atol << "\n"; + std::cout << " fast error accumulation strategy = " << opts.faccum << "\n"; + if (std::min(opts.k1s, opts.k2s) > -1) + { + std::cout << " controller parameters: " << opts.k1s << " " << opts.k2s + << "\n"; + } + break; + case (2): + std::cout << " MRI-LL controller based on order of MRI " + << ((opts.slow_pq == 1) ? "method\n" : "embedding\n"); + std::cout << " rtol = " << opts.rtol << ", atol = " << opts.atol << "\n"; + std::cout << " fast error accumulation strategy = " << opts.faccum << "\n"; + if (std::min(opts.k1s, std::min(opts.k2s, std::min(opts.k3s, opts.k4s))) > -1) + { + std::cout << " controller parameters: " << opts.k1s << " " << opts.k2s + << " " << opts.k3s << " " << opts.k4s << "\n"; + } + break; + case (3): + std::cout << " MRI-PI controller based on order of MRI " + << ((opts.slow_pq == 1) ? "method\n" : "embedding\n"); + std::cout << " rtol = " << opts.rtol << ", atol = " << opts.atol << "\n"; + std::cout << " fast error accumulation strategy = " << opts.faccum << "\n"; + if (std::min(opts.k1s, std::min(opts.k2s, std::min(opts.k3s, opts.k4s))) > -1) + { + std::cout << " controller parameters: " << opts.k1s << " " << opts.k2s + << " " << opts.k3s << " " << opts.k4s << "\n"; + } + break; + case (4): + std::cout << " MRI-PID controller based on order of MRI " + << ((opts.slow_pq == 1) ? "method\n" : "embedding\n"); + std::cout << " rtol = " << opts.rtol << ", atol = " << opts.atol << "\n"; + std::cout << " fast error accumulation strategy = " << opts.faccum << "\n"; + if (std::min(opts.k1s, + std::min(opts.k2s, + std::min(opts.k3s, + std::min(opts.k4s, + std::min(opts.k5s, opts.k6s))))) > -1) + { + std::cout << " controller parameters: " << opts.k1s << " " << opts.k2s + << " " << opts.k3s << " " << opts.k4s << " " << opts.k5s << " " + << opts.k6s << "\n"; + } + break; + case (5): + std::cout + << " MRI-HTOL controller (using I for H) based on order of MRI " + << ((opts.slow_pq == 1) ? "method\n" : "embedding\n"); + std::cout << " rtol = " << opts.rtol << ", atol = " << opts.atol << "\n"; + std::cout << " fast error accumulation strategy = " << opts.faccum << "\n"; + if (opts.k1s > -1) + { + std::cout << " slow controller parameter: " << opts.k1s << "\n"; + } + if (std::min(opts.htol_relch, std::min(opts.htol_minfac, opts.htol_maxfac)) > + -1) + { + std::cout << " HTol controller parameters: " << opts.htol_relch << " " + << opts.htol_minfac << " " << opts.htol_maxfac << "\n"; + } + break; + case (6): + std::cout << " Decoupled I controller for slow time scale, based on " + "order of MRI " + << ((opts.slow_pq == 1) ? "method\n" : "embedding\n"); + std::cout << " rtol = " << opts.rtol << ", atol = " << opts.atol << "\n"; + if (opts.k1s > -1) + { + std::cout << " slow controller parameter: " << opts.k1s << "\n"; + } + break; + case (7): + std::cout + << " MRI-HTOL controller (using PI for H) based on order of MRI " + << ((opts.slow_pq == 1) ? "method\n" : "embedding\n"); + std::cout << " rtol = " << opts.rtol << ", atol = " << opts.atol << "\n"; + std::cout << " fast error accumulation strategy = " << opts.faccum << "\n"; + if (std::min(opts.k1s, opts.k2s) > -1) + { + std::cout << " slow controller parameters: " << opts.k1s << " " + << opts.k2s << "\n"; + } + if (std::min(opts.htol_relch, std::min(opts.htol_minfac, opts.htol_maxfac)) > + -1) + { + std::cout << " HTol controller parameters: " << opts.htol_relch << " " + << opts.htol_minfac << " " << opts.htol_maxfac << "\n"; + } + break; + case (8): + std::cout << " Decoupled PI controller for slow time scale, based on " + "order of MRI " + << ((opts.slow_pq == 1) ? "method\n" : "embedding\n"); + std::cout << " rtol = " << opts.rtol << ", atol = " << opts.atol << "\n"; + if (std::min(opts.k1s, opts.k2s) > -1) + { + std::cout << " slow controller parameters: " << opts.k1s << " " + << opts.k2s << "\n"; + } + break; + case (9): + std::cout + << " MRI-HTOL controller (using PID for H) based on order of MRI " + << ((opts.slow_pq == 1) ? "method\n" : "embedding\n"); + std::cout << " rtol = " << opts.rtol << ", atol = " << opts.atol << "\n"; + std::cout << " fast error accumulation strategy = " << opts.faccum << "\n"; + if (std::min(opts.k1s, std::min(opts.k2s, opts.k3s)) > -1) + { + std::cout << " slow controller parameters: " << opts.k1s << " " + << opts.k2s << " " << opts.k3s << "\n"; + } + if (std::min(opts.htol_relch, std::min(opts.htol_minfac, opts.htol_maxfac)) > + -1) + { + std::cout << " HTol controller parameters: " << opts.htol_relch << " " + << opts.htol_minfac << " " << opts.htol_maxfac << "\n"; + } + break; + case (10): + std::cout << " Decoupled PID controller for slow time scale, based on " + "order of MRI " + << ((opts.slow_pq == 1) ? "method\n" : "embedding\n"); + std::cout << " rtol = " << opts.rtol << ", atol = " << opts.atol << "\n"; + if (std::min(opts.k1s, std::min(opts.k2s, opts.k3s)) > -1) + { + std::cout << " slow controller parameters: " << opts.k1s << " " + << opts.k2s << " " << opts.k3s << "\n"; + } + break; + case (11): + std::cout + << " MRI-HTOL controller (using ExpGus for H) based on order of MRI " + << ((opts.slow_pq == 1) ? "method\n" : "embedding\n"); + std::cout << " rtol = " << opts.rtol << ", atol = " << opts.atol << "\n"; + std::cout << " fast error accumulation strategy = " << opts.faccum << "\n"; + if (std::min(opts.k1s, opts.k2s) > -1) + { + std::cout << " slow controller parameters: " << opts.k1s << " " + << opts.k2s << "\n"; + } + if (std::min(opts.htol_relch, std::min(opts.htol_minfac, opts.htol_maxfac)) > + -1) + { + std::cout << " HTol controller parameters: " << opts.htol_relch << " " + << opts.htol_minfac << " " << opts.htol_maxfac << "\n"; + } + break; + case (12): + std::cout << " Decoupled ExpGus controller for slow time scale, based " + "on order of MRI " + << ((opts.slow_pq == 1) ? "method\n" : "embedding\n"); + std::cout << " rtol = " << opts.rtol << ", atol = " << opts.atol << "\n"; + if (std::min(opts.k1s, opts.k2s) > -1) + { + std::cout << " slow controller parameters: " << opts.k1s << " " + << opts.k2s << "\n"; + } + break; + case (13): + std::cout + << " MRI-HTOL controller (using ImpGus for H) based on order of MRI " + << ((opts.slow_pq == 1) ? "method\n" : "embedding\n"); + std::cout << " rtol = " << opts.rtol << ", atol = " << opts.atol << "\n"; + std::cout << " fast error accumulation strategy = " << opts.faccum << "\n"; + if (std::min(opts.k1s, opts.k2s) > -1) + { + std::cout << " slow controller parameters: " << opts.k1s << " " + << opts.k2s << "\n"; + } + if (std::min(opts.htol_relch, std::min(opts.htol_minfac, opts.htol_maxfac)) > + -1) + { + std::cout << " HTol controller parameters: " << opts.htol_relch << " " + << opts.htol_minfac << " " << opts.htol_maxfac << "\n"; + } + break; + case (14): + std::cout << " Decoupled ImpGus controller for slow time scale, based " + "on order of MRI " + << ((opts.slow_pq == 1) ? "method\n" : "embedding\n"); + std::cout << " rtol = " << opts.rtol << ", atol = " << opts.atol << "\n"; + if (std::min(opts.k1s, opts.k2s) > -1) + { + std::cout << " slow controller parameters: " << opts.k1s << " " + << opts.k2s << "\n"; + } + break; + case (15): + std::cout + << " MRI-HTOL controller (using ImExGus for H) based on order of MRI " + << ((opts.slow_pq == 1) ? "method\n" : "embedding\n"); + std::cout << " rtol = " << opts.rtol << ", atol = " << opts.atol << "\n"; + std::cout << " fast error accumulation strategy = " << opts.faccum << "\n"; + break; + case (16): + std::cout << " Decoupled ImExGus controller for slow time scale, based " + "on order of MRI " + << ((opts.slow_pq == 1) ? "method\n" : "embedding\n"); + std::cout << " rtol = " << opts.rtol << ", atol = " << opts.atol << "\n"; + break; + } + if (opts.bias > -1) + { + std::cout << " controller bias factor: " << opts.bias << "\n"; + } +} + +static void PrintFastAdaptivity(Options opts) +{ + switch (opts.fcontrol) + { + case (0): + std::cout << " fixed steps, hf = " << opts.hf << std::endl; + std::cout << " fast_rtol = " << opts.fast_rtol + << ", atol = " << opts.atol << "\n"; + break; + case (1): + std::cout << " I controller for fast time scale, based on order of RK " + << ((opts.fast_pq == 1) ? "method\n" : "embedding\n"); + std::cout << " fast_rtol = " << opts.fast_rtol + << ", atol = " << opts.atol << "\n"; + if (opts.k1f > -1) + { + std::cout << " fast controller parameter: " << opts.k1f << "\n"; + } + break; + case (2): + std::cout << " PI controller for fast time scale, based on order of RK " + << ((opts.fast_pq == 1) ? "method\n" : "embedding\n"); + std::cout << " fast_rtol = " << opts.fast_rtol + << ", atol = " << opts.atol << "\n"; + if (std::min(opts.k1f, opts.k2f) > -1) + { + std::cout << " fast controller parameters: " << opts.k1f << " " + << opts.k2f << "\n"; + } + break; + case (3): + std::cout << " PID controller for fast time scale, based on order of RK " + << ((opts.fast_pq == 1) ? "method\n" : "embedding\n"); + std::cout << " fast_rtol = " << opts.fast_rtol + << ", atol = " << opts.atol << "\n"; + if (std::min(opts.k1f, std::min(opts.k2f, opts.k3f)) > -1) + { + std::cout << " fast controller parameters: " << opts.k1f << " " + << opts.k2f << " " << opts.k3f << "\n"; + } + break; + case (4): + std::cout + << " ExpGus controller for fast time scale, based on order of RK " + << ((opts.fast_pq == 1) ? "method\n" : "embedding\n"); + std::cout << " fast_rtol = " << opts.fast_rtol + << ", atol = " << opts.atol << "\n"; + if (std::min(opts.k1f, opts.k2f) > -1) + { + std::cout << " fast controller parameters: " << opts.k1f << " " + << opts.k2f << "\n"; + } + break; + case (5): + std::cout + << " ImpGus controller for fast time scale, based on order of RK " + << ((opts.fast_pq == 1) ? "method\n" : "embedding\n"); + std::cout << " fast_rtol = " << opts.fast_rtol + << ", atol = " << opts.atol << "\n"; + if (std::min(opts.k1f, opts.k2f) > -1) + { + std::cout << " fast controller parameters: " << opts.k1f << " " + << opts.k2f << "\n"; + } + break; + case (6): + std::cout + << " ImExGus controller for fast time scale, based on order of RK " + << ((opts.fast_pq == 1) ? "method\n" : "embedding\n"); + std::cout << " fast_rtol = " << opts.fast_rtol + << ", atol = " << opts.atol << "\n"; + break; + } +} + +//---- end of file ----// diff --git a/test/unit_tests/arkode/CXX_serial/ark_test_kpr_mriadapt_--hs_0.002_--rtol_0.000004_--scontrol_0.out b/test/unit_tests/arkode/CXX_serial/ark_test_kpr_mriadapt_--hs_0.002_--rtol_0.000004_--scontrol_0.out new file mode 100644 index 0000000000..9416e34adc --- /dev/null +++ b/test/unit_tests/arkode/CXX_serial/ark_test_kpr_mriadapt_--hs_0.002_--rtol_0.000004_--scontrol_0.out @@ -0,0 +1,45 @@ + +Adaptive multirate nonlinear Kvaerno-Prothero-Robinson test problem: + time domain: (0,5] + G = -100 + w = 100 + e = 0.5 + + Slow integrator: ARKODE_MRI_GARK_ERK45a (explicit) + fixed steps, hs = 0.002 + rtol = 4e-06, atol = 1e-11 + + Fast order 4 + I controller for fast time scale, based on order of RK embedding + fast_rtol = 0.0001, atol = 1e-11 + t u v uerr verr + ------------------------------------------------------ + 0.000000 1.732051 1.732051 0.00e+00 0.00e+00 + 0.250000 1.723053 1.584050 2.46e-10 4.03e-10 + 0.500000 1.696344 1.512598 2.34e-10 1.45e-09 + 0.750000 1.652782 1.036015 2.00e-10 1.13e-09 + 1.000000 1.593833 1.458873 1.33e-10 1.72e-08 + 1.250000 1.521618 1.458201 1.63e-10 6.16e-08 + 1.500000 1.439006 1.011474 7.31e-10 1.39e-07 + 1.750000 1.349724 1.730452 1.32e-09 2.50e-07 + 2.000000 1.258512 1.214374 1.58e-09 3.01e-07 + 2.250000 1.171250 1.024071 1.36e-09 2.86e-07 + 2.500000 1.094923 1.471085 1.02e-09 1.56e-07 + 2.750000 1.037158 1.313348 9.56e-10 1.36e-07 + 3.000000 1.004991 1.274175 1.04e-09 1.09e-07 + 3.250000 1.002931 1.043458 9.00e-10 1.04e-07 + 3.500000 1.031282 1.053648 7.83e-10 8.07e-08 + 3.750000 1.086021 1.006374 5.90e-10 6.59e-08 + 4.000000 1.160326 1.571824 3.69e-10 3.30e-08 + 4.250000 1.246560 1.705136 2.00e-10 2.42e-08 + 4.500000 1.337611 1.431830 1.20e-10 2.26e-08 + 4.750000 1.427446 1.162908 3.11e-11 2.19e-08 + 5.000000 1.511179 1.070831 4.69e-11 1.87e-08 + ------------------------------------------------------ + +Final Solver Statistics: + Slow steps = 2500 (attempts = 2500, fails = 0) + Fast steps = 12502 (attempts = 12502, fails = 0) + u error = 7.68153e-10, v error = 1.29958e-07, total error = 9.1896e-08 + Relative accuracy = 0.0698426 + Total RHS evals: Fse = 12500, Fsi = 0, Ff = 62513 diff --git a/test/unit_tests/arkode/CXX_serial/ark_test_slowerror_brusselator.cpp b/test/unit_tests/arkode/CXX_serial/ark_test_slowerror_brusselator.cpp new file mode 100644 index 0000000000..c412938fe6 --- /dev/null +++ b/test/unit_tests/arkode/CXX_serial/ark_test_slowerror_brusselator.cpp @@ -0,0 +1,611 @@ +/*----------------------------------------------------------------- + * Programmer(s): Daniel R. Reynolds @ SMU + *--------------------------------------------------------------- + * SUNDIALS Copyright Start + * Copyright (c) 2002-2024, 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 + *--------------------------------------------------------------- + * Routine to test an MRI method's embedding-based error + * estimate. Uses the "stiff Brusselator" test problem with 3 + * components, + * du/dt = a - (w+1)*u + v*u^2 + * dv/dt = w*u - v*u^2 + * dw/dt = (b-w)/ep - w*u + * for t in the interval [0.0, 10.0], with initial conditions + * Y0 = [u0,v0,w0]. + * + * The stiffness of the problem is essentially determined + * by ep, wherein if the dynamical time step is given by H and + * the explicit time step size is given by h, then H/h = 1/(100 ep), + * i.e., the stability-limited step takes over at values of + * ep < 1e-2. This file defaults to a moderately stiff setup with + * ep = 1/2500. + * + * We may run the problem in one of 3 different testing scenarios: + * + * Test 1: u0=3.9, v0=1.1, w0=2.8, a=1.2, b=2.5 + * Here, all three components exhibit a rapid transient change + * during the first 0.2 time units, followed by a slow and + * smooth evolution. + * + * Test 2 [default]: u0=1.2, v0=3.1, w0=3, a=1, b=3.5 + * Here, w experiences a fast initial transient, jumping 0.5 + * within a few steps. All values proceed smoothly until + * around t=6.5, when both u and v undergo a sharp transition, + * with u increaseing from around 0.5 to 5 and v decreasing + * from around 6 to 1 in less than 0.5 time units. After this + * transition, both u and v continue to evolve somewhat + * rapidly for another 1.4 time units, and finish off smoothly. + * + * Test 3: u0=3, v0=3, w0=3.5, a=0.5, b=3 + * Here, all components undergo very rapid initial transients + * during the first 0.3 time units, and all then proceed very + * smoothly for the remainder of the simulation. + * + * We partition the full time integration interval, 0 < t < 5, into + * Npart pieces. We then run a single time step starting at the + * beginning of each partition, using a variety of slow step sizes, + * H = {hmax, hmax/4, hmax/16, hmax/64, hmax/256} with + * hmax=(t_f-t_0)/20/Npart. + * + * We place the entire ODE in the "slow" RHS partition. For IMEX + * methods, thw third row is treated implicitly, and the first two + * are treated explicitly. For the fast time scale, all tests use + * ARKODE's default fifth-order ERK method, with relative and + * absolute tolerances set to 1e-10 and 1e-12, respectively. + * + * We select the slow integrator based on a command-line argument, + * with the default being ARKODE_MRI_GARK_ERK33a. + * + * The program should be run with arguments in the following order: + * $ a.out method Npart ep test + * Not all arguments are required, but these must be omitted from + * end-to-beginning, i.e. any one of + * $ a.out method Npart ep + * $ a.out method Npart + * $ a.out method + * $ a.out + * are acceptable. We require: + * * method = string corresponding to a valid embedded ARKODE_MRITableID + * * Npart > 0 + * * ep > 0 + * * test = {1, 2, 3} + *-----------------------------------------------------------------*/ + +// Header files +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#if defined(SUNDIALS_EXTENDED_PRECISION) +#define GSYM "Lg" +#define ESYM "Le" +#define FSYM "Lf" +#else +#define GSYM "g" +#define ESYM "e" +#define FSYM "f" +#endif + +#define ZERO SUN_RCONST(0.0) +#define ONE SUN_RCONST(1.0) +#define TWO SUN_RCONST(2.0) + +using namespace std; + +// User data structure +struct UserData +{ + sunrealtype a; + sunrealtype b; + sunrealtype ep; + int Npart; +}; + +// User-supplied Functions Called by the Solver +static int f0(sunrealtype t, N_Vector y, N_Vector ydot, void* user_data); +static int fn(sunrealtype t, N_Vector y, N_Vector ydot, void* user_data); +static int fi(sunrealtype t, N_Vector y, N_Vector ydot, void* user_data); +static int fe(sunrealtype t, N_Vector y, N_Vector ydot, void* user_data); +static int Jn(sunrealtype t, N_Vector y, N_Vector fy, SUNMatrix J, + void* user_data, N_Vector tmp1, N_Vector tmp2, N_Vector tmp3); +static int Ji(sunrealtype t, N_Vector y, N_Vector fy, SUNMatrix J, + void* user_data, N_Vector tmp1, N_Vector tmp2, N_Vector tmp3); + +// Private utility functions +static int computeErrorWeights(N_Vector ycur, N_Vector weight, sunrealtype rtol, + sunrealtype atol, N_Vector vtemp); +static int check_retval(void* returnvalue, const char* funcname, int opt); +static int run_test(void* mristep_mem, void* arkode_ref, N_Vector y, + sunrealtype T0, sunrealtype Tf, N_Vector* yref, + vector Hvals, char* method, sunrealtype reltol, + sunrealtype abstol, UserData& udata); + +// Main Program +int main(int argc, char* argv[]) +{ + // general problem parameters + sunrealtype T0 = SUN_RCONST(0.0); // initial time + sunrealtype Tf = SUN_RCONST(10.0); // final time + sunindextype NEQ = 3; // number of dependent vars. + char* method; // MRI method name + int test = 2; // test problem to run + sunrealtype a, b, u0, v0, w0; // parameters + sunrealtype reltol = SUN_RCONST(1.e-10); // fast solver tolerances + sunrealtype abstol = SUN_RCONST(1.e-12); + + // general problem variables + int retval; // reusable error-checking flag + UserData udata; // user-data structure + udata.ep = SUN_RCONST(0.0004); // stiffness parameter + udata.Npart = 20; // partition size + + // + // Initialization + // + + // Retrieve the command-line options: method Npart ep test + if (argc > 1) { method = argv[1]; } + else { method = "ARKODE_MRI_GARK_ERK33a"; } + if (argc > 2) udata.Npart = (int)atoi(argv[2]); + if (argc > 3) udata.ep = (sunrealtype)atof(argv[3]); + if (argc > 4) test = (int)atoi(argv[4]); + + // Check arguments for validity + // Npart > 0 + // ep > 0 + // test = {1, 2, 3} + if (udata.Npart < 1) + { + cerr << "ERROR: Npart must be a positive integer\n"; + return (-1); + } + if (udata.ep <= ZERO) + { + cerr << "ERROR: ep must be a positive real number\n"; + return (-1); + } + if ((test < 1) || (test > 3)) + { + cerr << "ERROR: test type be an integer in {1,2,3} \n"; + return (-1); + } + + // set up the test problem according to the desired test + if (test == 1) + { + u0 = SUN_RCONST(3.9); + v0 = SUN_RCONST(1.1); + w0 = SUN_RCONST(2.8); + udata.a = SUN_RCONST(1.2); + udata.b = SUN_RCONST(2.5); + } + else if (test == 3) + { + u0 = SUN_RCONST(3.0); + v0 = SUN_RCONST(3.0); + w0 = SUN_RCONST(3.5); + udata.a = SUN_RCONST(0.5); + udata.b = SUN_RCONST(3.0); + } + else + { + u0 = SUN_RCONST(1.2); + v0 = SUN_RCONST(3.1); + w0 = SUN_RCONST(3.0); + udata.a = SUN_RCONST(1.0); + udata.b = SUN_RCONST(3.5); + } + + sunbooleantype implicit = SUNFALSE; + sunbooleantype imex = SUNFALSE; + if ((strcmp(method, "ARKODE_MRI_GARK_IRK21a") == 0) || + (strcmp(method, "ARKODE_MRI_GARK_ESDIRK34a") == 0) || + (strcmp(method, "ARKODE_MRI_GARK_ESDIRK46a") == 0)) + { + implicit = SUNTRUE; + } + if ((strcmp(method, "ARKODE_IMEX_MRI_SR21") == 0) || + (strcmp(method, "ARKODE_IMEX_MRI_SR32") == 0) || + (strcmp(method, "ARKODE_IMEX_MRI_SR43") == 0)) + { + imex = SUNTRUE; + implicit = SUNTRUE; + } + + // Initial problem output (and set implicit solver tolerances as needed) + cout << "\nSlow error estimation test (stiff Brusselator ODE problem):\n"; + cout << " time domain: (" << T0 << "," << Tf << "]\n"; + cout << " partition size = " << udata.Npart << endl; + cout << " initial conditions: u0 = " << u0 << ", v0 = " << v0 + << ", w0 = " << w0 << endl; + cout << " problem parameters: a = " << a << ", b = " << b + << ", ep = " << udata.ep << endl; + cout << " MRI method: " << method; + if (imex) { cout << " (ImEx)" << endl; } + else if (implicit) { cout << " (implicit)" << endl; } + else { cout << " (explicit)" << endl; } + + // + // Problem Setup + // + + // Create SUNDIALS context + sundials::Context ctx; + + // Create serial vectors for the solution and reference + N_Vector y = N_VNew_Serial(NEQ, ctx); + if (check_retval((void*)y, "N_VNew_Serial", 0)) return 1; + N_Vector* yref = N_VCloneVectorArray(udata.Npart + 1, y); + if (check_retval((void*)yref, "N_VNew_Serial", 0)) return 1; + + // Generate reference solution + NV_Ith_S(y, 0) = u0; + NV_Ith_S(y, 1) = v0; + NV_Ith_S(y, 2) = w0; + void* arkode_ref = ERKStepCreate(fn, T0, y, ctx); + if (check_retval((void*)arkode_ref, "ERKStepCreate", 0)) return 1; + retval = ARKodeSetUserData(arkode_ref, (void*)&udata); + if (check_retval(&retval, "ARKodeSetUserData", 1)) return 1; + retval = ARKodeSetOrder(arkode_ref, 5); + if (check_retval(&retval, "ARKodeSetOrder", 1)) return 1; + retval = ARKodeSStolerances(arkode_ref, reltol, abstol); + if (check_retval(&retval, "ARKodeSStolerances", 1)) return 1; + retval = ARKodeSetMaxNumSteps(arkode_ref, 1000000); + if (check_retval(&retval, "ARKodeSetMaxNumSteps", 1)) return (1); + N_VScale(ONE, y, yref[0]); + sunrealtype hpart = (Tf - T0) / udata.Npart; + for (int ipart = 0; ipart < udata.Npart; ipart++) + { + sunrealtype t = T0 + ipart * hpart; + retval = ARKodeSetStopTime(arkode_ref, t + hpart); + if (check_retval(&retval, "ARKodeSetStopTime", 1)) return 1; + retval = ARKodeEvolve(arkode_ref, t + hpart, y, &t, ARK_NORMAL); + if (check_retval(&retval, "ARKodeEvolve", 1)) return 1; + N_VScale(ONE, y, yref[ipart + 1]); + } + + // Set up fast ERKStep integrator as fifth-order adaptive method + NV_Ith_S(y, 0) = u0; + NV_Ith_S(y, 1) = v0; + NV_Ith_S(y, 2) = w0; + void* inner_arkode_mem = ERKStepCreate(f0, T0, y, ctx); + if (check_retval((void*)inner_arkode_mem, "ERKStepCreate", 0)) return 1; + retval = ARKodeSetOrder(inner_arkode_mem, 5); + if (check_retval(&retval, "ARKodeSetOrder", 1)) return 1; + retval = ARKodeSStolerances(inner_arkode_mem, reltol, abstol); + if (check_retval(&retval, "ARKodeSStolerances", 1)) return 1; + retval = ARKodeSetMaxNumSteps(inner_arkode_mem, 1000000); + if (check_retval(&retval, "ARKodeSetMaxNumSteps", 1)) return (1); + + // Create inner stepper wrapper + MRIStepInnerStepper inner_stepper = NULL; // inner stepper + retval = ERKStepCreateMRIStepInnerStepper(inner_arkode_mem, &inner_stepper); + if (check_retval(&retval, "ERKStepCreateMRIStepInnerStepper", 1)) return 1; + + // Set up slow MRIStep integrator + void* mristep_mem = NULL; + if (imex) { mristep_mem = MRIStepCreate(fe, fi, T0, y, inner_stepper, ctx); } + else if (implicit) + { + mristep_mem = MRIStepCreate(NULL, fn, T0, y, inner_stepper, ctx); + } + else { mristep_mem = MRIStepCreate(fn, NULL, T0, y, inner_stepper, ctx); } + if (check_retval((void*)mristep_mem, "MRIStepCreate", 0)) return 1; + MRIStepCoupling C = MRIStepCoupling_LoadTableByName(method); + if (check_retval((void*)C, "MRIStepCoupling_LoadTableByName", 0)) return 1; + retval = MRIStepSetCoupling(mristep_mem, C); + if (check_retval(&retval, "MRIStepSetCoupling", 1)) return 1; + SUNMatrix A = NULL; // matrix for slow solver + SUNLinearSolver LS = NULL; // slow linear solver object + if (implicit) + { + A = SUNDenseMatrix(NEQ, NEQ, ctx); + if (check_retval((void*)A, "SUNDenseMatrix", 0)) return 1; + LS = SUNLinSol_Dense(y, A, ctx); + if (check_retval((void*)LS, "SUNLinSol_Dense", 0)) return 1; + retval = ARKodeSetLinearSolver(mristep_mem, LS, A); + if (check_retval(&retval, "ARKodeSetLinearSolver", 1)) return 1; + if (imex) { retval = ARKodeSetJacFn(mristep_mem, Ji); } + else { retval = ARKodeSetJacFn(mristep_mem, Jn); } + if (check_retval(&retval, "ARKodeSetJacFn", 1)) return 1; + retval = ARKodeSetJacEvalFrequency(mristep_mem, 1); + if (check_retval(&retval, "ARKodeSetJacEvalFrequency", 1)) return 1; + retval = ARKodeSetLSetupFrequency(mristep_mem, 1); + if (check_retval(&retval, "ARKodeSetLSetupFrequency", 1)) return 1; + retval = ARKodeSetMaxNonlinIters(mristep_mem, 50); + if (check_retval(&retval, "ARKodeSetMaxNonlinIters", 1)) return 1; + } + retval = ARKodeSStolerances(mristep_mem, reltol, abstol); + if (check_retval(&retval, "ARKodeSStolerances", 1)) return 1; + retval = ARKodeSetUserData(mristep_mem, (void*)&udata); + if (check_retval(&retval, "ARKodeSetUserData", 1)) return 1; + retval = ARKodeSetAccumulatedErrorType(mristep_mem, 0); + if (check_retval(&retval, "ARKodeSetAccumulatedErrorType", 1)) return 1; + + // Run test for various H values + sunrealtype hmax = (Tf - T0) / 20.0 / udata.Npart; + vector Hvals = {hmax, hmax / 4.0, hmax / 16.0, hmax / 64.0, + hmax / 256.0}; + retval = run_test(mristep_mem, arkode_ref, y, T0, Tf, yref, Hvals, method, + reltol, abstol, udata); + if (check_retval(&retval, "run_test", 1)) return 1; + + // Clean up and return + MRIStepCoupling_Free(C); + ARKodeFree(&arkode_ref); + ARKodeFree(&inner_arkode_mem); + MRIStepInnerStepper_Free(&inner_stepper); + ARKodeFree(&mristep_mem); + if (LS) { SUNLinSolFree(LS); } // free system linear solver + if (A) { SUNMatDestroy(A); } // free system matrix + N_VDestroy(y); // Free y and yref vectors + N_VDestroyVectorArray(yref, udata.Npart + 1); + return 0; +} + +//------------------------------ +// Functions called by the solver +//------------------------------ + +static int f0(sunrealtype t, N_Vector y, N_Vector ydot, void* user_data) +{ + // fill in the RHS function with zeros and return with success + N_VConst(ZERO, ydot); + return 0; +} + +static int fn(sunrealtype t, N_Vector y, N_Vector ydot, void* user_data) +{ + UserData* udata = (UserData*)user_data; + sunrealtype u = NV_Ith_S(y, 0); // access solution values + sunrealtype v = NV_Ith_S(y, 1); + sunrealtype w = NV_Ith_S(y, 2); + + // fill in the RHS function + NV_Ith_S(ydot, 0) = udata->a - (w + ONE) * u + v * u * u; + NV_Ith_S(ydot, 1) = w * u - v * u * u; + NV_Ith_S(ydot, 2) = (udata->b - w) / udata->ep - w * u; + + // Return with success + return 0; +} + +static int fi(sunrealtype t, N_Vector y, N_Vector ydot, void* user_data) +{ + UserData* udata = (UserData*)user_data; + sunrealtype u = NV_Ith_S(y, 0); // access solution values + sunrealtype v = NV_Ith_S(y, 1); + sunrealtype w = NV_Ith_S(y, 2); + + // fill in the RHS function + NV_Ith_S(ydot, 0) = ZERO; + NV_Ith_S(ydot, 1) = ZERO; + NV_Ith_S(ydot, 2) = (udata->b - w) / udata->ep - w * u; + + // Return with success + return 0; +} + +static int fe(sunrealtype t, N_Vector y, N_Vector ydot, void* user_data) +{ + UserData* udata = (UserData*)user_data; + sunrealtype u = NV_Ith_S(y, 0); // access solution values + sunrealtype v = NV_Ith_S(y, 1); + sunrealtype w = NV_Ith_S(y, 2); + + // fill in the RHS function + NV_Ith_S(ydot, 0) = udata->a - (w + ONE) * u + v * u * u; + NV_Ith_S(ydot, 1) = w * u - v * u * u; + NV_Ith_S(ydot, 2) = ZERO; + + // Return with success + return 0; +} + +static int Jn(sunrealtype t, N_Vector y, N_Vector fy, SUNMatrix J, + void* user_data, N_Vector tmp1, N_Vector tmp2, N_Vector tmp3) +{ + UserData* udata = (UserData*)user_data; + sunrealtype u = NV_Ith_S(y, 0); // access solution values + sunrealtype v = NV_Ith_S(y, 1); + sunrealtype w = NV_Ith_S(y, 2); + + // fill in the Jacobian + SM_ELEMENT_D(J, 0, 0) = -(w + ONE) + TWO * u * v; + SM_ELEMENT_D(J, 0, 1) = u * u; + SM_ELEMENT_D(J, 0, 2) = -u; + + SM_ELEMENT_D(J, 1, 0) = w - TWO * u * v; + SM_ELEMENT_D(J, 1, 1) = -u * u; + SM_ELEMENT_D(J, 1, 2) = u; + + SM_ELEMENT_D(J, 2, 0) = -w; + SM_ELEMENT_D(J, 2, 1) = ZERO; + SM_ELEMENT_D(J, 2, 2) = -ONE / udata->ep - u; + + // Return with success + return 0; +} + +static int Ji(sunrealtype t, N_Vector y, N_Vector fy, SUNMatrix J, + void* user_data, N_Vector tmp1, N_Vector tmp2, N_Vector tmp3) +{ + UserData* udata = (UserData*)user_data; + sunrealtype u = NV_Ith_S(y, 0); // access solution values + sunrealtype v = NV_Ith_S(y, 1); + sunrealtype w = NV_Ith_S(y, 2); + + // fill in the Jacobian + SM_ELEMENT_D(J, 0, 0) = ZERO; + SM_ELEMENT_D(J, 0, 1) = ZERO; + SM_ELEMENT_D(J, 0, 2) = ZERO; + + SM_ELEMENT_D(J, 1, 0) = ZERO; + SM_ELEMENT_D(J, 1, 1) = ZERO; + SM_ELEMENT_D(J, 1, 2) = ZERO; + + SM_ELEMENT_D(J, 2, 0) = -w; + SM_ELEMENT_D(J, 2, 1) = ZERO; + SM_ELEMENT_D(J, 2, 2) = -ONE / udata->ep - u; + + // Return with success + return 0; +} + +//------------------------------ +// Private helper functions +//------------------------------ + +static int run_test(void* mristep_mem, void* arkode_ref, N_Vector y, + sunrealtype T0, sunrealtype Tf, N_Vector* yref, + vector Hvals, char* method, sunrealtype reltol, + sunrealtype abstol, UserData& udata) +{ + // Reused variables + int retval; + sunrealtype hpart = (Tf - T0) / udata.Npart; + sunrealtype t, t2; + N_Vector y2 = N_VClone(y); + N_Vector ele = N_VClone(y); + N_Vector ewt = N_VClone(y); + N_Vector vtemp = N_VClone(y); + + // Set storage for errors + vector> dsm(Hvals.size(), + vector(udata.Npart, ZERO)); + vector> dsm_est(Hvals.size(), + vector(udata.Npart, ZERO)); + + // Loop over step sizes + for (int iH = 0; iH < Hvals.size(); iH++) + { + // Loop over partition + for (int ipart = 0; ipart < udata.Npart; ipart++) + { + // Reset integrators for this run + t = t2 = T0 + ipart * hpart; + N_VScale(ONE, yref[ipart], y); + retval = ARKodeReset(mristep_mem, t, y); + if (check_retval(&retval, "ARKodeReset", 1)) return 1; + retval = ARKodeSetFixedStep(mristep_mem, Hvals[iH]); + if (check_retval(&retval, "ARKodeSetFixedStep", 1)) return 1; + retval = ARKodeResetAccumulatedError(mristep_mem); + if (check_retval(&retval, "ARKodeResetAccumulatedError", 1)) return 1; + N_VScale(ONE, yref[ipart], y2); + retval = ARKodeReset(arkode_ref, t2, y2); + if (check_retval(&retval, "ARKodeReset", 1)) return 1; + retval = ARKodeSetStopTime(arkode_ref, t2 + Hvals[iH]); + if (check_retval(&retval, "ARKodeSetStopTime", 1)) return 1; + + // Run ERKStep to compute reference solution, and MRIStep to compute one step + retval = ARKodeEvolve(arkode_ref, t2 + Hvals[iH], y2, &t2, ARK_NORMAL); + if (check_retval(&retval, "ARKodeEvolve", 1)) return 1; + retval = ARKodeEvolve(mristep_mem, t + Hvals[iH], y, &t, ARK_ONE_STEP); + if (check_retval(&retval, "ARKodeEvolve", 1)) return 1; + retval = ARKodeGetEstLocalErrors(mristep_mem, ele); + if (check_retval(&retval, "ARKodeGetEstLocalErrors", 1)) return 1; + retval = computeErrorWeights(y, ewt, reltol, abstol, vtemp); + if (check_retval(&retval, "computeErrorWeights", 1)) return 1; + dsm_est[iH][ipart] = N_VWrmsNorm(ewt, ele); + + // Compute/print solution error + sunrealtype udsm = abs(NV_Ith_S(y, 0) - NV_Ith_S(y2, 0)) / + (abstol + reltol * abs(NV_Ith_S(y2, 0))); + sunrealtype vdsm = abs(NV_Ith_S(y, 1) - NV_Ith_S(y2, 1)) / + (abstol + reltol * abs(NV_Ith_S(y2, 1))); + sunrealtype wdsm = abs(NV_Ith_S(y, 2) - NV_Ith_S(y2, 2)) / + (abstol + reltol * abs(NV_Ith_S(y2, 2))); + dsm[iH][ipart] = + sqrt((udsm * udsm + vdsm * vdsm + wdsm * wdsm) / SUN_RCONST(3.0)); + cout << " H " << Hvals[iH] << " method " << method << " t " << t + << " dsm " << dsm[iH][ipart] << " dsm_est " << dsm_est[iH][ipart] + << endl; + } + } + + cout << endl << method << " summary:" << endl; + for (int iH = 0; iH < Hvals.size(); iH++) + { + cout << " Stepsize " << Hvals[iH] << " \tmaxdsm " + << *max_element(dsm[iH].begin(), dsm[iH].end()) << " \tmaxdsmest " + << *max_element(dsm_est[iH].begin(), dsm_est[iH].end()) << endl; + } + + N_VDestroy(ele); + N_VDestroy(ewt); + N_VDestroy(vtemp); + N_VDestroy(y2); + return (0); +} + +/* Error weight calculation routine (mimics what's in ARKODE already) */ +static int computeErrorWeights(N_Vector ycur, N_Vector weight, sunrealtype rtol, + sunrealtype atol, N_Vector vtemp) +{ + N_VAbs(ycur, vtemp); + N_VScale(rtol, vtemp, vtemp); + N_VAddConst(vtemp, atol, vtemp); + N_VInv(vtemp, weight); + return (0); +} + +/* Check function return value... + opt == 0 means SUNDIALS function allocates memory so check if + returned NULL pointer + opt == 1 means SUNDIALS function returns a retval so check if + retval >= 0 + opt == 2 means function allocates memory so check if returned + NULL pointer +*/ +static int check_retval(void* returnvalue, const char* funcname, int opt) +{ + int* retval; + + // Check if SUNDIALS function returned NULL pointer - no memory allocated + if (opt == 0 && returnvalue == NULL) + { + fprintf(stderr, "\nSUNDIALS_ERROR: %s() failed - returned NULL pointer\n\n", + funcname); + return 1; + } + + // Check if retval < 0 + else if (opt == 1) + { + retval = (int*)returnvalue; + if (*retval < 0) + { + fprintf(stderr, "\nSUNDIALS_ERROR: %s() failed with retval = %d\n\n", + funcname, *retval); + return 1; + } + } + + // Check if function returned NULL pointer - no memory allocated + else if (opt == 2 && returnvalue == NULL) + { + fprintf(stderr, "\nMEMORY_ERROR: %s() failed - returned NULL pointer\n\n", + funcname); + return 1; + } + + return 0; +} + +/*---- end of file ----*/ diff --git a/test/unit_tests/arkode/CXX_serial/ark_test_slowerror_brusselator.out b/test/unit_tests/arkode/CXX_serial/ark_test_slowerror_brusselator.out new file mode 100644 index 0000000000..451e0ff65b --- /dev/null +++ b/test/unit_tests/arkode/CXX_serial/ark_test_slowerror_brusselator.out @@ -0,0 +1,114 @@ + +Slow error estimation test (stiff Brusselator ODE problem): + time domain: (0,10] + partition size = 20 + initial conditions: u0 = 1.2, v0 = 3.1, w0 = 3 + problem parameters: a = 0, b = 0, ep = 0.0004 + MRI method: ARKODE_MRI_GARK_ERK33a (explicit) + H 0.025 method ARKODE_MRI_GARK_ERK33a t 0.025 dsm 3.18615e+13 dsm_est 2.87651e+09 + H 0.025 method ARKODE_MRI_GARK_ERK33a t 0.525 dsm 9710.21 dsm_est 2563.86 + H 0.025 method ARKODE_MRI_GARK_ERK33a t 1.025 dsm 3395.18 dsm_est 924.465 + H 0.025 method ARKODE_MRI_GARK_ERK33a t 1.525 dsm 664.284 dsm_est 1834.33 + H 0.025 method ARKODE_MRI_GARK_ERK33a t 2.025 dsm 45.486 dsm_est 1966.18 + H 0.025 method ARKODE_MRI_GARK_ERK33a t 2.525 dsm 194.704 dsm_est 800.323 + H 0.025 method ARKODE_MRI_GARK_ERK33a t 3.025 dsm 2450.84 dsm_est 2266.61 + H 0.025 method ARKODE_MRI_GARK_ERK33a t 3.525 dsm 1673.06 dsm_est 1473.74 + H 0.025 method ARKODE_MRI_GARK_ERK33a t 4.025 dsm 2037.27 dsm_est 761.723 + H 0.025 method ARKODE_MRI_GARK_ERK33a t 4.525 dsm 11645.3 dsm_est 2717.1 + H 0.025 method ARKODE_MRI_GARK_ERK33a t 5.025 dsm 396.447 dsm_est 385.357 + H 0.025 method ARKODE_MRI_GARK_ERK33a t 5.525 dsm 2677.65 dsm_est 2152.57 + H 0.025 method ARKODE_MRI_GARK_ERK33a t 6.025 dsm 23061.5 dsm_est 15279.7 + H 0.025 method ARKODE_MRI_GARK_ERK33a t 6.525 dsm 62044.8 dsm_est 330409 + H 0.025 method ARKODE_MRI_GARK_ERK33a t 7.025 dsm 742178 dsm_est 1.51629e+06 + H 0.025 method ARKODE_MRI_GARK_ERK33a t 7.525 dsm 8906.12 dsm_est 19929.1 + H 0.025 method ARKODE_MRI_GARK_ERK33a t 8.025 dsm 69031 dsm_est 17339.3 + H 0.025 method ARKODE_MRI_GARK_ERK33a t 8.525 dsm 1343.85 dsm_est 2289.77 + H 0.025 method ARKODE_MRI_GARK_ERK33a t 9.025 dsm 9763.15 dsm_est 11148.1 + H 0.025 method ARKODE_MRI_GARK_ERK33a t 9.525 dsm 5068.11 dsm_est 10742.2 + H 0.00625 method ARKODE_MRI_GARK_ERK33a t 0.00625 dsm 4.33933e+11 dsm_est 1.53179e+09 + H 0.00625 method ARKODE_MRI_GARK_ERK33a t 0.50625 dsm 132.32 dsm_est 40.1278 + H 0.00625 method ARKODE_MRI_GARK_ERK33a t 1.00625 dsm 46.7529 dsm_est 14.476 + H 0.00625 method ARKODE_MRI_GARK_ERK33a t 1.50625 dsm 9.95461 dsm_est 28.4157 + H 0.00625 method ARKODE_MRI_GARK_ERK33a t 2.00625 dsm 1.33577 dsm_est 30.7309 + H 0.00625 method ARKODE_MRI_GARK_ERK33a t 2.50625 dsm 3.44185 dsm_est 11.9088 + H 0.00625 method ARKODE_MRI_GARK_ERK33a t 3.00625 dsm 33.4688 dsm_est 35.0999 + H 0.00625 method ARKODE_MRI_GARK_ERK33a t 3.50625 dsm 22.8901 dsm_est 23.0456 + H 0.00625 method ARKODE_MRI_GARK_ERK33a t 4.00625 dsm 27.7324 dsm_est 11.9605 + H 0.00625 method ARKODE_MRI_GARK_ERK33a t 4.50625 dsm 159.5 dsm_est 42.4689 + H 0.00625 method ARKODE_MRI_GARK_ERK33a t 5.00625 dsm 5.51044 dsm_est 5.88584 + H 0.00625 method ARKODE_MRI_GARK_ERK33a t 5.50625 dsm 36.8279 dsm_est 33.2228 + H 0.00625 method ARKODE_MRI_GARK_ERK33a t 6.00625 dsm 315.007 dsm_est 236.943 + H 0.00625 method ARKODE_MRI_GARK_ERK33a t 6.50625 dsm 246.006 dsm_est 5222.77 + H 0.00625 method ARKODE_MRI_GARK_ERK33a t 7.00625 dsm 3236.65 dsm_est 24290.3 + H 0.00625 method ARKODE_MRI_GARK_ERK33a t 7.50625 dsm 99.9089 dsm_est 304.834 + H 0.00625 method ARKODE_MRI_GARK_ERK33a t 8.00625 dsm 938.001 dsm_est 270.44 + H 0.00625 method ARKODE_MRI_GARK_ERK33a t 8.50625 dsm 15.7881 dsm_est 36.4011 + H 0.00625 method ARKODE_MRI_GARK_ERK33a t 9.00625 dsm 132.241 dsm_est 168.298 + H 0.00625 method ARKODE_MRI_GARK_ERK33a t 9.50625 dsm 68.8352 dsm_est 165.971 + H 0.0015625 method ARKODE_MRI_GARK_ERK33a t 0.0015625 dsm 4.30937e+09 dsm_est 1.04109e+09 + H 0.0015625 method ARKODE_MRI_GARK_ERK33a t 0.501563 dsm 1.31042 dsm_est 0.627262 + H 0.0015625 method ARKODE_MRI_GARK_ERK33a t 1.00156 dsm 0.497356 dsm_est 0.226316 + H 0.0015625 method ARKODE_MRI_GARK_ERK33a t 1.50156 dsm 0.119634 dsm_est 0.443054 + H 0.0015625 method ARKODE_MRI_GARK_ERK33a t 2.00156 dsm 0.0107271 dsm_est 0.480195 + H 0.0015625 method ARKODE_MRI_GARK_ERK33a t 2.50156 dsm 0.0359355 dsm_est 0.183783 + H 0.0015625 method ARKODE_MRI_GARK_ERK33a t 3.00156 dsm 0.414754 dsm_est 0.547189 + H 0.0015625 method ARKODE_MRI_GARK_ERK33a t 3.50156 dsm 0.282576 dsm_est 0.36015 + H 0.0015625 method ARKODE_MRI_GARK_ERK33a t 4.00156 dsm 0.344442 dsm_est 0.187109 + H 0.0015625 method ARKODE_MRI_GARK_ERK33a t 4.50156 dsm 1.97083 dsm_est 0.663632 + H 0.0015625 method ARKODE_MRI_GARK_ERK33a t 5.00156 dsm 0.0684921 dsm_est 0.0914409 + H 0.0015625 method ARKODE_MRI_GARK_ERK33a t 5.50156 dsm 0.456656 dsm_est 0.517502 + H 0.0015625 method ARKODE_MRI_GARK_ERK33a t 6.00156 dsm 3.91728 dsm_est 3.69502 + H 0.0015625 method ARKODE_MRI_GARK_ERK33a t 6.50156 dsm 1.31633 dsm_est 81.802 + H 0.0015625 method ARKODE_MRI_GARK_ERK33a t 7.00156 dsm 12.9885 dsm_est 381.511 + H 0.0015625 method ARKODE_MRI_GARK_ERK33a t 7.50156 dsm 1.20582 dsm_est 4.73474 + H 0.0015625 method ARKODE_MRI_GARK_ERK33a t 8.00156 dsm 9.73269 dsm_est 4.22374 + H 0.0015625 method ARKODE_MRI_GARK_ERK33a t 8.50156 dsm 0.150084 dsm_est 0.571209 + H 0.0015625 method ARKODE_MRI_GARK_ERK33a t 9.00156 dsm 1.63694 dsm_est 2.60698 + H 0.0015625 method ARKODE_MRI_GARK_ERK33a t 9.50156 dsm 0.68322 dsm_est 2.58585 + H 0.000390625 method ARKODE_MRI_GARK_ERK33a t 0.000390625 dsm 2.73843e+07 dsm_est 2.97866e+07 + H 0.000390625 method ARKODE_MRI_GARK_ERK33a t 0.500391 dsm 0.00790675 dsm_est 0.00980231 + H 0.000390625 method ARKODE_MRI_GARK_ERK33a t 1.00039 dsm 0.00278359 dsm_est 0.00353684 + H 0.000390625 method ARKODE_MRI_GARK_ERK33a t 1.50039 dsm 0.000577287 dsm_est 0.00691933 + H 0.000390625 method ARKODE_MRI_GARK_ERK33a t 2.00039 dsm 6.43416e-05 dsm_est 0.0075032 + H 0.000390625 method ARKODE_MRI_GARK_ERK33a t 2.50039 dsm 0.000173927 dsm_est 0.00286286 + H 0.000390625 method ARKODE_MRI_GARK_ERK33a t 3.00039 dsm 0.00199524 dsm_est 0.00854497 + H 0.000390625 method ARKODE_MRI_GARK_ERK33a t 3.50039 dsm 0.00135961 dsm_est 0.00562669 + H 0.000390625 method ARKODE_MRI_GARK_ERK33a t 4.00039 dsm 0.00165695 dsm_est 0.00292461 + H 0.000390625 method ARKODE_MRI_GARK_ERK33a t 4.50039 dsm 0.00948223 dsm_est 0.0103697 + H 0.000390625 method ARKODE_MRI_GARK_ERK33a t 5.00039 dsm 0.000328768 dsm_est 0.00142679 + H 0.000390625 method ARKODE_MRI_GARK_ERK33a t 5.50039 dsm 0.00219767 dsm_est 0.00807905 + H 0.000390625 method ARKODE_MRI_GARK_ERK33a t 6.00039 dsm 0.0188505 dsm_est 0.0577057 + H 0.000390625 method ARKODE_MRI_GARK_ERK33a t 6.50039 dsm 0.00584 dsm_est 1.27889 + H 0.000390625 method ARKODE_MRI_GARK_ERK33a t 7.00039 dsm 0.0510766 dsm_est 5.96838 + H 0.000390625 method ARKODE_MRI_GARK_ERK33a t 7.50039 dsm 0.00578518 dsm_est 0.0738676 + H 0.000390625 method ARKODE_MRI_GARK_ERK33a t 8.00039 dsm 0.0560528 dsm_est 0.0659878 + H 0.000390625 method ARKODE_MRI_GARK_ERK33a t 8.50039 dsm 0.000893002 dsm_est 0.008934 + H 0.000390625 method ARKODE_MRI_GARK_ERK33a t 9.00039 dsm 0.00787258 dsm_est 0.0406446 + H 0.000390625 method ARKODE_MRI_GARK_ERK33a t 9.50039 dsm 0.00408635 dsm_est 0.0403739 + H 9.76563e-05 method ARKODE_MRI_GARK_ERK33a t 9.76563e-05 dsm 130431 dsm_est 498019 + H 9.76563e-05 method ARKODE_MRI_GARK_ERK33a t 0.500098 dsm 3.50953e-05 dsm_est 0.000152579 + H 9.76563e-05 method ARKODE_MRI_GARK_ERK33a t 1.0001 dsm 1.24764e-05 dsm_est 5.49428e-05 + H 9.76563e-05 method ARKODE_MRI_GARK_ERK33a t 1.5001 dsm 2.33422e-06 dsm_est 0.000108153 + H 9.76563e-05 method ARKODE_MRI_GARK_ERK33a t 2.0001 dsm 7.27936e-07 dsm_est 0.000117276 + H 9.76563e-05 method ARKODE_MRI_GARK_ERK33a t 2.5001 dsm 9.82143e-07 dsm_est 4.49931e-05 + H 9.76563e-05 method ARKODE_MRI_GARK_ERK33a t 3.0001 dsm 8.84859e-06 dsm_est 0.000133946 + H 9.76563e-05 method ARKODE_MRI_GARK_ERK33a t 3.5001 dsm 6.72064e-06 dsm_est 8.87346e-05 + H 9.76563e-05 method ARKODE_MRI_GARK_ERK33a t 4.0001 dsm 8.08105e-06 dsm_est 4.63154e-05 + H 9.76563e-05 method ARKODE_MRI_GARK_ERK33a t 4.5001 dsm 4.2385e-05 dsm_est 0.000162368 + H 9.76563e-05 method ARKODE_MRI_GARK_ERK33a t 5.0001 dsm 1.89051e-06 dsm_est 2.23151e-05 + H 9.76563e-05 method ARKODE_MRI_GARK_ERK33a t 5.5001 dsm 1.09591e-05 dsm_est 0.000126182 + H 9.76563e-05 method ARKODE_MRI_GARK_ERK33a t 6.0001 dsm 8.40237e-05 dsm_est 0.00090171 + H 9.76563e-05 method ARKODE_MRI_GARK_ERK33a t 6.5001 dsm 2.61573e-05 dsm_est 0.0199867 + H 9.76563e-05 method ARKODE_MRI_GARK_ERK33a t 7.0001 dsm 0.000200076 dsm_est 0.0932838 + H 9.76563e-05 method ARKODE_MRI_GARK_ERK33a t 7.5001 dsm 2.64767e-05 dsm_est 0.00115263 + H 9.76563e-05 method ARKODE_MRI_GARK_ERK33a t 8.0001 dsm 0.000250009 dsm_est 0.00103107 + H 9.76563e-05 method ARKODE_MRI_GARK_ERK33a t 8.5001 dsm 5.56659e-06 dsm_est 0.000140649 + H 9.76563e-05 method ARKODE_MRI_GARK_ERK33a t 9.0001 dsm 3.51966e-05 dsm_est 0.000633732 + H 9.76563e-05 method ARKODE_MRI_GARK_ERK33a t 9.5001 dsm 1.83527e-05 dsm_est 0.000631456 + +ARKODE_MRI_GARK_ERK33a summary: + Stepsize 0.025 maxdsm 3.18615e+13 maxdsmest 2.87651e+09 + Stepsize 0.00625 maxdsm 4.33933e+11 maxdsmest 1.53179e+09 + Stepsize 0.0015625 maxdsm 4.30937e+09 maxdsmest 1.04109e+09 + Stepsize 0.000390625 maxdsm 2.73843e+07 maxdsmest 2.97866e+07 + Stepsize 9.76563e-05 maxdsm 130431 maxdsmest 498019 diff --git a/test/unit_tests/arkode/CXX_serial/ark_test_slowerror_kpr.cpp b/test/unit_tests/arkode/CXX_serial/ark_test_slowerror_kpr.cpp new file mode 100644 index 0000000000..c31f6e5e80 --- /dev/null +++ b/test/unit_tests/arkode/CXX_serial/ark_test_slowerror_kpr.cpp @@ -0,0 +1,564 @@ +/* ---------------------------------------------------------------- + * Programmer(s): Daniel R. Reynolds @ SMU + * ---------------------------------------------------------------- + * SUNDIALS Copyright Start + * Copyright (c) 2002-2024, 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 + * ---------------------------------------------------------------- + * Routine to test an MRI method's embedding-based error + * estimate. Uses a nonlinear Kvaerno-Prothero-Robinson ODE test + * problem with analytical solution, + * + * [u]' = [ G e ] [(u^2-p-1)/(2u)] + [ p'(t)/(2u) ] + * [v] [ e -1 ] [(v^2-q-2)/(2v)] [ q'(t)/(2v) ] + * + * where p(t) = cos(t), and q(t) = cos(omega*t*(1+exp(-(t-2)^2))). + * This problem has analytical solution given by + * u(t) = sqrt(2+p(t)), v(t) = sqrt(2+q(t)). + * We use the parameters: e = 0.1 and G = -10 [default] + * + * The stiffness of the problem is essentially determined + * by G, for |G| > 50 it is "stiff" and ideally suited to an + * implicit method. + * + * Coupling between the two components is determined by e, with + * coupling strength proportional to |e|. + * + * The "fast" variable, v, oscillates at a frequency "omega" times + * faster than u. + * + * We partition the full time integration interval, 0 < t < 5, into + * Npart pieces. We then run a single time step starting at the + * beginning of each partition, using a variety of slow step sizes, + * H = {hmax, hmax/4, hmax/16, hmax/64, hmax/256} with + * hmax=(t_f-t_0)/20/Npart. + * + * We place the entire ODE in the "slow" RHS partition. For IMEX + * methods, thw first row is treated implicitly, and the second is + * treated explicitly. For the fast time scale, all tests use + * ARKODE's default fifth-order ERK method, with relative and + * absolute tolerances set to 1e-10 and 1e-12, respectively. + * + * We select the slow integrator based on a command-line argument, + * with the default being ARKODE_MRI_GARK_ERK33a. + * + * The program should be run with arguments in the following order: + * $ a.out method Npart G e omega + * Not all arguments are required, but these must be omitted from + * end-to-beginning, i.e. any one of + * $ a.out method Npart G e + * $ a.out method Npart G + * $ a.out method Npart + * $ a.out method + * $ a.out + * are acceptable. We require: + * * method = string corresponding to a valid embedded ARKODE_MRITableID + * * Npart > 0 + * * G < 0.0 + * * omega > 0.0 + * ----------------------------------------------------------------*/ + +// Header files +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#if defined(SUNDIALS_EXTENDED_PRECISION) +#define GSYM "Lg" +#define ESYM "Le" +#define FSYM "Lf" +#else +#define GSYM "g" +#define ESYM "e" +#define FSYM "f" +#endif + +#define ZERO SUN_RCONST(0.0) +#define ONE SUN_RCONST(1.0) +#define TWO SUN_RCONST(2.0) + +using namespace std; + +// User data structure +struct UserData +{ + sunrealtype G; + sunrealtype e; + sunrealtype omega; + int Npart; +}; + +// User-supplied functions called by the solver +static int f0(sunrealtype t, N_Vector y, N_Vector ydot, void* user_data); +static int fn(sunrealtype t, N_Vector y, N_Vector ydot, void* user_data); +static int fe(sunrealtype t, N_Vector y, N_Vector ydot, void* user_data); +static int fi(sunrealtype t, N_Vector y, N_Vector ydot, void* user_data); +static int Jn(sunrealtype t, N_Vector y, N_Vector fy, SUNMatrix J, + void* user_data, N_Vector tmp1, N_Vector tmp2, N_Vector tmp3); +static int Ji(sunrealtype t, N_Vector y, N_Vector fy, SUNMatrix J, + void* user_data, N_Vector tmp1, N_Vector tmp2, N_Vector tmp3); + +// Private utility functions +static sunrealtype p(sunrealtype t); +static sunrealtype q(sunrealtype t, UserData& udata); +static sunrealtype pdot(sunrealtype t); +static sunrealtype qdot(sunrealtype t, UserData& udata); +static sunrealtype utrue(sunrealtype t); +static sunrealtype vtrue(sunrealtype t, UserData& udata); +static int Ytrue(sunrealtype t, N_Vector y, UserData& udata); +static int computeErrorWeights(N_Vector ycur, N_Vector weight, sunrealtype rtol, + sunrealtype atol, N_Vector vtemp); +static int check_retval(void* returnvalue, const char* funcname, int opt); +static int run_test(void* mristep_mem, N_Vector y, sunrealtype T0, + sunrealtype Tf, vector Hvals, char* method, + sunrealtype reltol, sunrealtype abstol, UserData& udata); + +// Main Program +int main(int argc, char* argv[]) +{ + // general problem parameters + sunrealtype T0 = SUN_RCONST(0.0); // initial time + sunrealtype Tf = SUN_RCONST(5.0); // final time + sunindextype NEQ = 2; // number of dependent vars. + char* method; // MRI method name + sunrealtype reltol = SUN_RCONST(1.e-10); // fast solver tolerances + sunrealtype abstol = SUN_RCONST(1.e-12); + + // general problem variables + int retval; // reusable error-checking flag + UserData udata; // user-data structure + udata.G = SUN_RCONST(-10.0); // stiffness parameter + udata.e = SUN_RCONST(0.1); // coupling strength + udata.omega = SUN_RCONST(5.0); // time scale ratio + udata.Npart = 20; // partition size + + // + // Initialization + // + + // Retrieve the command-line options: method Npart G e omega + if (argc > 1) { method = argv[1]; } + else { method = "ARKODE_MRI_GARK_ERK33a"; } + if (argc > 2) udata.Npart = (int)atoi(argv[2]); + if (argc > 3) udata.G = (sunrealtype)atof(argv[3]); + if (argc > 4) udata.e = (sunrealtype)atof(argv[4]); + if (argc > 5) udata.omega = (sunrealtype)atof(argv[5]); + + // Check arguments for validity + // G < 0.0 + // omega > 0.0 + // Npart > 0 + if (udata.G >= ZERO) + { + cerr << "ERROR: G must be a negative real number\n"; + return (-1); + } + if (udata.omega <= ZERO) + { + cerr << "ERROR: omega must be a positive real number\n"; + return (-1); + } + if (udata.Npart < 1) + { + cerr << "ERROR: Npart must be a positive integer\n"; + return (-1); + } + + sunbooleantype implicit = SUNFALSE; + sunbooleantype imex = SUNFALSE; + if ((strcmp(method, "ARKODE_MRI_GARK_IRK21a") == 0) || + (strcmp(method, "ARKODE_MRI_GARK_ESDIRK34a") == 0) || + (strcmp(method, "ARKODE_MRI_GARK_ESDIRK46a") == 0)) + { + implicit = SUNTRUE; + } + if ((strcmp(method, "ARKODE_IMEX_MRI_SR21") == 0) || + (strcmp(method, "ARKODE_IMEX_MRI_SR32") == 0) || + (strcmp(method, "ARKODE_IMEX_MRI_SR43") == 0)) + { + imex = SUNTRUE; + implicit = SUNTRUE; + } + + // Initial problem output (and set implicit solver tolerances as needed) + cout << "\nSlow error estimation test (Nonlinear Kvaerno-Prothero-Robinson " + "problem):\n"; + cout << " time domain: (" << T0 << "," << Tf << "]\n"; + cout << " partition size = " << udata.Npart << endl; + cout << " problem parameters: G = " << udata.G << ", e = " << udata.e + << ", omega = " << udata.omega << endl; + cout << " MRI method: " << method; + if (imex) { cout << " (ImEx)" << endl; } + else if (implicit) { cout << " (implicit)" << endl; } + else { cout << " (explicit)" << endl; } + + // + // Problem Setup + // + + // Create SUNDIALS context + sundials::Context ctx; + + // Create and initialize serial vector for the solution + N_Vector y = N_VNew_Serial(NEQ, ctx); + if (check_retval((void*)y, "N_VNew_Serial", 0)) return 1; + retval = Ytrue(T0, y, udata); + if (check_retval(&retval, "Ytrue", 1)) return 1; + + // Set up fast ERKStep integrator as fifth-order adaptive method + void* inner_arkode_mem = ERKStepCreate(f0, T0, y, ctx); + if (check_retval((void*)inner_arkode_mem, "ERKStepCreate", 0)) return 1; + retval = ARKodeSetOrder(inner_arkode_mem, 5); + if (check_retval(&retval, "ARKodeSetOrder", 1)) return 1; + retval = ARKodeSStolerances(inner_arkode_mem, reltol, abstol); + if (check_retval(&retval, "ARKodeSStolerances", 1)) return 1; + retval = ARKodeSetMaxNumSteps(inner_arkode_mem, 1000000); + if (check_retval(&retval, "ARKodeSetMaxNumSteps", 1)) return (1); + + // Create inner stepper wrapper + MRIStepInnerStepper inner_stepper = NULL; // inner stepper + retval = ERKStepCreateMRIStepInnerStepper(inner_arkode_mem, &inner_stepper); + if (check_retval(&retval, "ERKStepCreateMRIStepInnerStepper", 1)) return 1; + + // Set up slow MRIStep integrator + void* mristep_mem = NULL; + if (imex) { mristep_mem = MRIStepCreate(fe, fi, T0, y, inner_stepper, ctx); } + else if (implicit) + { + mristep_mem = MRIStepCreate(NULL, fn, T0, y, inner_stepper, ctx); + } + else { mristep_mem = MRIStepCreate(fn, NULL, T0, y, inner_stepper, ctx); } + if (check_retval((void*)mristep_mem, "MRIStepCreate", 0)) return 1; + MRIStepCoupling C = MRIStepCoupling_LoadTableByName(method); + if (check_retval((void*)C, "MRIStepCoupling_LoadTableByName", 0)) return 1; + retval = MRIStepSetCoupling(mristep_mem, C); + if (check_retval(&retval, "MRIStepSetCoupling", 1)) return 1; + SUNMatrix A = NULL; // matrix for slow solver + SUNLinearSolver LS = NULL; // slow linear solver object + if (implicit) + { + A = SUNDenseMatrix(NEQ, NEQ, ctx); + if (check_retval((void*)A, "SUNDenseMatrix", 0)) return 1; + LS = SUNLinSol_Dense(y, A, ctx); + if (check_retval((void*)LS, "SUNLinSol_Dense", 0)) return 1; + retval = ARKodeSetLinearSolver(mristep_mem, LS, A); + if (check_retval(&retval, "ARKodeSetLinearSolver", 1)) return 1; + if (imex) { retval = ARKodeSetJacFn(mristep_mem, Ji); } + else { retval = ARKodeSetJacFn(mristep_mem, Jn); } + if (check_retval(&retval, "ARKodeSetJacFn", 1)) return 1; + retval = ARKodeSetJacEvalFrequency(mristep_mem, 1); + if (check_retval(&retval, "ARKodeSetJacEvalFrequency", 1)) return 1; + retval = ARKodeSetLSetupFrequency(mristep_mem, 1); + if (check_retval(&retval, "ARKodeSetLSetupFrequency", 1)) return 1; + retval = ARKodeSetMaxNonlinIters(mristep_mem, 50); + if (check_retval(&retval, "ARKodeSetMaxNonlinIters", 1)) return 1; + } + retval = ARKodeSStolerances(mristep_mem, reltol, abstol); + if (check_retval(&retval, "ARKodeSStolerances", 1)) return 1; + retval = ARKodeSetUserData(mristep_mem, (void*)&udata); + if (check_retval(&retval, "ARKodeSetUserData", 1)) return 1; + retval = ARKodeSetAccumulatedErrorType(mristep_mem, 0); + if (check_retval(&retval, "ARKodeSetAccumulatedErrorType", 1)) return 1; + + // Run test for various H values + sunrealtype hmax = (Tf - T0) / 20 / udata.Npart; + vector Hvals = {hmax, hmax / 4.0, hmax / 16.0, hmax / 64.0, + hmax / 256.0}; + retval = run_test(mristep_mem, y, T0, Tf, Hvals, method, reltol, abstol, udata); + if (check_retval(&retval, "run_test", 1)) return 1; + + // Clean up and return + MRIStepCoupling_Free(C); + ARKodeFree(&inner_arkode_mem); + MRIStepInnerStepper_Free(&inner_stepper); + ARKodeFree(&mristep_mem); + if (LS) { SUNLinSolFree(LS); } // free system linear solver + if (A) { SUNMatDestroy(A); } // free system matrix + N_VDestroy(y); // Free y vector + return 0; +} + +//------------------------------ +// Functions called by the solver +//------------------------------ + +static int f0(sunrealtype t, N_Vector y, N_Vector ydot, void* user_data) +{ + // fill in the RHS function with zeros and return with success + N_VConst(ZERO, ydot); + return 0; +} + +static int fn(sunrealtype t, N_Vector y, N_Vector ydot, void* user_data) +{ + UserData* udata = (UserData*)user_data; + const sunrealtype u = NV_Ith_S(y, 0); + const sunrealtype v = NV_Ith_S(y, 1); + sunrealtype tmp1, tmp2; + + // fill in the RHS function: + // [G e]*[(-2+u^2-p(t))/(2*u)] + [pdot(t)/(2u)] + // [e -1] [(-2+v^2-s(t))/(2*v)] [qdot(t)/(2v)] + tmp1 = (-TWO + u * u - p(t)) / (TWO * u); + tmp2 = (-TWO + v * v - q(t, *udata)) / (TWO * v); + NV_Ith_S(ydot, 0) = udata->G * tmp1 + udata->e * tmp2 + pdot(t) / (TWO * u); + NV_Ith_S(ydot, 1) = udata->e * tmp1 - tmp2 + qdot(t, *udata) / (TWO * v); + + // Return with success + return 0; +} + +static int fi(sunrealtype t, N_Vector y, N_Vector ydot, void* user_data) +{ + UserData* udata = (UserData*)user_data; + const sunrealtype u = NV_Ith_S(y, 0); + const sunrealtype v = NV_Ith_S(y, 1); + sunrealtype tmp1, tmp2; + + // fill in the RHS function: + // [G e]*[(-2+u^2-p(t))/(2*u)] + [pdot(t)/(2u)] + // [0 0] [(-2+v^2-s(t))/(2*v)] [ 0 ] + tmp1 = (-TWO + u * u - p(t)) / (TWO * u); + tmp2 = (-TWO + v * v - q(t, *udata)) / (TWO * v); + NV_Ith_S(ydot, 0) = udata->G * tmp1 + udata->e * tmp2 + pdot(t) / (TWO * u); + NV_Ith_S(ydot, 1) = ZERO; + + // Return with success + return 0; +} + +static int fe(sunrealtype t, N_Vector y, N_Vector ydot, void* user_data) +{ + UserData* udata = (UserData*)user_data; + const sunrealtype u = NV_Ith_S(y, 0); + const sunrealtype v = NV_Ith_S(y, 1); + sunrealtype tmp1, tmp2; + + // fill in the RHS function: + // [0 0]*[(-2+u^2-p(t))/(2*u)] + [ 0 ] + // [e -1] [(-2+v^2-s(t))/(2*v)] [qdot(t)/(2v)] + tmp1 = (-TWO + u * u - p(t)) / (TWO * u); + tmp2 = (-TWO + v * v - q(t, *udata)) / (TWO * v); + NV_Ith_S(ydot, 0) = ZERO; + NV_Ith_S(ydot, 1) = udata->e * tmp1 - tmp2 + qdot(t, *udata) / (TWO * v); + + // Return with success + return 0; +} + +static int Jn(sunrealtype t, N_Vector y, N_Vector fy, SUNMatrix J, + void* user_data, N_Vector tmp1, N_Vector tmp2, N_Vector tmp3) +{ + UserData* udata = (UserData*)user_data; + const sunrealtype u = NV_Ith_S(y, 0); + const sunrealtype v = NV_Ith_S(y, 1); + sunrealtype t11, t22; + + // fill in the Jacobian: + // [G e]*[1-(u^2-p(t)-2)/(2*u^2), 0] + [-p'(t)/(2*u^2), 0] + // [e -1] [0, 1-(v^2-q(t)-2)/(2*v^2)] [0, -q'(t)/(2*v^2)] + t11 = ONE - (u * u - p(t) - TWO) / (TWO * u * u); + t22 = ONE - (v * v - q(t, *udata) - TWO) / (TWO * v * v); + SM_ELEMENT_D(J, 0, 0) = udata->G * t11 - pdot(t) / (TWO * u * u); + SM_ELEMENT_D(J, 0, 1) = udata->e * t22; + SM_ELEMENT_D(J, 1, 0) = udata->e * t11; + SM_ELEMENT_D(J, 1, 1) = -t22 - qdot(t, *udata) / (TWO * v * v); + + // Return with success + return 0; +} + +static int Ji(sunrealtype t, N_Vector y, N_Vector fy, SUNMatrix J, + void* user_data, N_Vector tmp1, N_Vector tmp2, N_Vector tmp3) +{ + UserData* udata = (UserData*)user_data; + const sunrealtype u = NV_Ith_S(y, 0); + const sunrealtype v = NV_Ith_S(y, 1); + + // fill in the Jacobian: + // [G/2 + (G*(1+p(t))-pdot(t))/(2*u^2) e/2+e*(2+s(t))/(2*v^2)] + // [ 0 0 ] + SM_ELEMENT_D(J, 0, 0) = udata->G / TWO + + (udata->G * (ONE + p(t)) - pdot(t)) / (TWO * u * u); + SM_ELEMENT_D(J, 0, 1) = udata->e / TWO + + udata->e * (TWO + q(t, *udata)) / (TWO * v * v); + SM_ELEMENT_D(J, 1, 0) = ZERO; + SM_ELEMENT_D(J, 1, 1) = ZERO; + + // Return with success + return 0; +} + +//------------------------------ +// Private helper functions +//------------------------------ + +static int run_test(void* mristep_mem, N_Vector y, sunrealtype T0, + sunrealtype Tf, vector Hvals, char* method, + sunrealtype reltol, sunrealtype abstol, UserData& udata) +{ + // Reused variables + int retval; + sunrealtype hpart = (Tf - T0) / udata.Npart; + sunrealtype t; + N_Vector ele = N_VClone(y); + N_Vector ewt = N_VClone(y); + N_Vector vtemp = N_VClone(y); + + // Set storage for errors + vector> dsm(Hvals.size(), + vector(udata.Npart, ZERO)); + vector> dsm_est(Hvals.size(), + vector(udata.Npart, ZERO)); + + // Loop over step sizes + for (int iH = 0; iH < Hvals.size(); iH++) + { + // Loop over partition + for (int ipart = 0; ipart < udata.Npart; ipart++) + { + // Reset integrator for this run + t = T0 + ipart * hpart; + retval = Ytrue(t, y, udata); + if (check_retval(&retval, "Ytrue", 1)) return 1; + retval = ARKodeReset(mristep_mem, t, y); + if (check_retval(&retval, "ARKodeReset", 1)) return 1; + retval = ARKodeSetFixedStep(mristep_mem, Hvals[iH]); + if (check_retval(&retval, "ARKodeSetFixedStep", 1)) return 1; + retval = ARKodeResetAccumulatedError(mristep_mem); + if (check_retval(&retval, "ARKodeResetAccumulatedError", 1)) return 1; + + // Run ARKodeEvolve to compute one step + retval = ARKodeEvolve(mristep_mem, t + Hvals[iH], y, &t, ARK_ONE_STEP); + if (check_retval(&retval, "ARKodeEvolve", 1)) return 1; + retval = ARKodeGetEstLocalErrors(mristep_mem, ele); + if (check_retval(&retval, "ARKodeGetEstLocalErrors", 1)) return 1; + retval = computeErrorWeights(y, ewt, reltol, abstol, vtemp); + if (check_retval(&retval, "computeErrorWeights", 1)) return 1; + dsm_est[iH][ipart] = N_VWrmsNorm(ewt, ele); + + // Compute/print solution error + sunrealtype udsm = abs(NV_Ith_S(y, 0) - utrue(t)) / + (abstol + reltol * abs(utrue(t))); + sunrealtype vdsm = abs(NV_Ith_S(y, 1) - vtrue(t, udata)) / + (abstol + reltol * abs(vtrue(t, udata))); + dsm[iH][ipart] = sqrt(0.5 * (udsm * udsm + vdsm * vdsm)); + cout << " H " << Hvals[iH] << " method " << method << " t " << t + << " dsm " << dsm[iH][ipart] << " dsm_est " << dsm_est[iH][ipart] + << endl; + } + } + + cout << endl << method << " summary:" << endl; + for (int iH = 0; iH < Hvals.size(); iH++) + { + cout << " Stepsize " << Hvals[iH] << " \tmaxdsm " + << *max_element(dsm[iH].begin(), dsm[iH].end()) << " \tmaxdsmest " + << *max_element(dsm_est[iH].begin(), dsm_est[iH].end()) << endl; + } + + N_VDestroy(ele); + N_VDestroy(ewt); + N_VDestroy(vtemp); + return (0); +} + +static sunrealtype p(sunrealtype t) { return (cos(t)); } + +static sunrealtype q(sunrealtype t, UserData& udata) +{ + return (cos(udata.omega * t * (ONE + exp(-(t - 2) * (t - 2))))); +} + +static sunrealtype pdot(sunrealtype t) { return (-sin(t)); } + +static sunrealtype qdot(sunrealtype t, UserData& udata) +{ + return (-sin(udata.omega * t * (ONE + exp(-(t - 2) * (t - 2)))) * udata.omega * + (ONE + exp(-(t - 2) * (t - 2)) - + t * 2 * (t - 2) * (exp(-(t - 2) * (t - 2))))); +} + +static sunrealtype utrue(sunrealtype t) { return (SUNRsqrt(TWO + p(t))); } + +static sunrealtype vtrue(sunrealtype t, UserData& udata) +{ + return (SUNRsqrt(TWO + q(t, udata))); +} + +static int Ytrue(sunrealtype t, N_Vector y, UserData& udata) +{ + NV_Ith_S(y, 0) = utrue(t); + NV_Ith_S(y, 1) = vtrue(t, udata); + return (0); +} + +static int computeErrorWeights(N_Vector ycur, N_Vector weight, sunrealtype rtol, + sunrealtype atol, N_Vector vtemp) +{ + N_VAbs(ycur, vtemp); + N_VScale(rtol, vtemp, vtemp); + N_VAddConst(vtemp, atol, vtemp); + N_VInv(vtemp, weight); + return (0); +} + +/* Check function return value... + opt == 0 means SUNDIALS function allocates memory so check if + returned NULL pointer + opt == 1 means SUNDIALS function returns a retval so check if + retval < 0 + opt == 2 means function allocates memory so check if returned + NULL pointer +*/ +static int check_retval(void* returnvalue, const char* funcname, int opt) +{ + int* retval; + + // Check if SUNDIALS function returned NULL pointer - no memory allocated + if (opt == 0 && returnvalue == NULL) + { + fprintf(stderr, "\nSUNDIALS_ERROR: %s() failed - returned NULL pointer\n\n", + funcname); + return 1; + } + + // Check if retval < 0 + else if (opt == 1) + { + retval = (int*)returnvalue; + if (*retval < 0) + { + fprintf(stderr, "\nSUNDIALS_ERROR: %s() failed with retval = %d\n\n", + funcname, *retval); + return 1; + } + } + + // Check if function returned NULL pointer - no memory allocated + else if (opt == 2 && returnvalue == NULL) + { + fprintf(stderr, "\nMEMORY_ERROR: %s() failed - returned NULL pointer\n\n", + funcname); + return 1; + } + + return 0; +} + +//---- end of file ---- diff --git a/test/unit_tests/arkode/CXX_serial/ark_test_slowerror_kpr.out b/test/unit_tests/arkode/CXX_serial/ark_test_slowerror_kpr.out new file mode 100644 index 0000000000..390ca5a056 --- /dev/null +++ b/test/unit_tests/arkode/CXX_serial/ark_test_slowerror_kpr.out @@ -0,0 +1,113 @@ + +Slow error estimation test (Nonlinear Kvaerno-Prothero-Robinson problem): + time domain: (0,5] + partition size = 20 + problem parameters: G = -10, e = 0.1, omega = 5 + MRI method: ARKODE_MRI_GARK_ERK33a (explicit) + H 0.0125 method ARKODE_MRI_GARK_ERK33a t 0.0125 dsm 59.7276 dsm_est 727.532 + H 0.0125 method ARKODE_MRI_GARK_ERK33a t 0.2625 dsm 159.194 dsm_est 4712.03 + H 0.0125 method ARKODE_MRI_GARK_ERK33a t 0.5125 dsm 496.974 dsm_est 33493.8 + H 0.0125 method ARKODE_MRI_GARK_ERK33a t 0.7625 dsm 712.688 dsm_est 32624.2 + H 0.0125 method ARKODE_MRI_GARK_ERK33a t 1.0125 dsm 1224.36 dsm_est 1716.11 + H 0.0125 method ARKODE_MRI_GARK_ERK33a t 1.2625 dsm 5167.32 dsm_est 267128 + H 0.0125 method ARKODE_MRI_GARK_ERK33a t 1.5125 dsm 4827.92 dsm_est 54878.4 + H 0.0125 method ARKODE_MRI_GARK_ERK33a t 1.7625 dsm 13680.4 dsm_est 176534 + H 0.0125 method ARKODE_MRI_GARK_ERK33a t 2.0125 dsm 130.837 dsm_est 49597.7 + H 0.0125 method ARKODE_MRI_GARK_ERK33a t 2.2625 dsm 162.492 dsm_est 34976.3 + H 0.0125 method ARKODE_MRI_GARK_ERK33a t 2.5125 dsm 287.688 dsm_est 7113.08 + H 0.0125 method ARKODE_MRI_GARK_ERK33a t 2.7625 dsm 382.02 dsm_est 4317.48 + H 0.0125 method ARKODE_MRI_GARK_ERK33a t 3.0125 dsm 301.235 dsm_est 4949.38 + H 0.0125 method ARKODE_MRI_GARK_ERK33a t 3.2625 dsm 258.571 dsm_est 2977.9 + H 0.0125 method ARKODE_MRI_GARK_ERK33a t 3.5125 dsm 218.068 dsm_est 1269.3 + H 0.0125 method ARKODE_MRI_GARK_ERK33a t 3.7625 dsm 162.764 dsm_est 1320.67 + H 0.0125 method ARKODE_MRI_GARK_ERK33a t 4.0125 dsm 130.736 dsm_est 2369.28 + H 0.0125 method ARKODE_MRI_GARK_ERK33a t 4.2625 dsm 20.6137 dsm_est 12728.2 + H 0.0125 method ARKODE_MRI_GARK_ERK33a t 4.5125 dsm 176.78 dsm_est 15676.7 + H 0.0125 method ARKODE_MRI_GARK_ERK33a t 4.7625 dsm 90.7369 dsm_est 3719.41 + H 0.003125 method ARKODE_MRI_GARK_ERK33a t 0.003125 dsm 0.232651 dsm_est 10.9877 + H 0.003125 method ARKODE_MRI_GARK_ERK33a t 0.253125 dsm 0.594785 dsm_est 70.8981 + H 0.003125 method ARKODE_MRI_GARK_ERK33a t 0.503125 dsm 1.46693 dsm_est 527.764 + H 0.003125 method ARKODE_MRI_GARK_ERK33a t 0.753125 dsm 2.86452 dsm_est 520.741 + H 0.003125 method ARKODE_MRI_GARK_ERK33a t 1.00313 dsm 4.48531 dsm_est 12.8296 + H 0.003125 method ARKODE_MRI_GARK_ERK33a t 1.25313 dsm 37.2232 dsm_est 3954.15 + H 0.003125 method ARKODE_MRI_GARK_ERK33a t 1.50313 dsm 17.7805 dsm_est 786.062 + H 0.003125 method ARKODE_MRI_GARK_ERK33a t 1.75313 dsm 58.1561 dsm_est 2999.34 + H 0.003125 method ARKODE_MRI_GARK_ERK33a t 2.00312 dsm 0.615846 dsm_est 764.348 + H 0.003125 method ARKODE_MRI_GARK_ERK33a t 2.25312 dsm 0.208735 dsm_est 542.352 + H 0.003125 method ARKODE_MRI_GARK_ERK33a t 2.50312 dsm 1.15342 dsm_est 106.225 + H 0.003125 method ARKODE_MRI_GARK_ERK33a t 2.75312 dsm 1.54621 dsm_est 59.6688 + H 0.003125 method ARKODE_MRI_GARK_ERK33a t 3.00312 dsm 1.18391 dsm_est 80.2941 + H 0.003125 method ARKODE_MRI_GARK_ERK33a t 3.25312 dsm 1.00984 dsm_est 46.1362 + H 0.003125 method ARKODE_MRI_GARK_ERK33a t 3.50312 dsm 0.853891 dsm_est 19.4476 + H 0.003125 method ARKODE_MRI_GARK_ERK33a t 3.75312 dsm 0.637603 dsm_est 20.4096 + H 0.003125 method ARKODE_MRI_GARK_ERK33a t 4.00312 dsm 0.50676 dsm_est 35.5067 + H 0.003125 method ARKODE_MRI_GARK_ERK33a t 4.25312 dsm 0.0997811 dsm_est 197.159 + H 0.003125 method ARKODE_MRI_GARK_ERK33a t 4.50312 dsm 0.602658 dsm_est 244.1 + H 0.003125 method ARKODE_MRI_GARK_ERK33a t 4.75312 dsm 0.3657 dsm_est 59.8484 + H 0.00078125 method ARKODE_MRI_GARK_ERK33a t 0.00078125 dsm 0.000906789 dsm_est 0.1702 + H 0.00078125 method ARKODE_MRI_GARK_ERK33a t 0.250781 dsm 0.00229725 dsm_est 1.09748 + H 0.00078125 method ARKODE_MRI_GARK_ERK33a t 0.500781 dsm 0.00528907 dsm_est 8.25834 + H 0.00078125 method ARKODE_MRI_GARK_ERK33a t 0.750781 dsm 0.0112664 dsm_est 8.18019 + H 0.00078125 method ARKODE_MRI_GARK_ERK33a t 1.00078 dsm 0.0172485 dsm_est 0.149038 + H 0.00078125 method ARKODE_MRI_GARK_ERK33a t 1.25078 dsm 0.162364 dsm_est 60.7616 + H 0.00078125 method ARKODE_MRI_GARK_ERK33a t 1.50078 dsm 0.0684956 dsm_est 12.019 + H 0.00078125 method ARKODE_MRI_GARK_ERK33a t 1.75078 dsm 0.231817 dsm_est 47.8533 + H 0.00078125 method ARKODE_MRI_GARK_ERK33a t 2.00078 dsm 0.00251159 dsm_est 11.9018 + H 0.00078125 method ARKODE_MRI_GARK_ERK33a t 2.25078 dsm 0.000388484 dsm_est 8.4539 + H 0.00078125 method ARKODE_MRI_GARK_ERK33a t 2.50078 dsm 0.00453393 dsm_est 1.64038 + H 0.00078125 method ARKODE_MRI_GARK_ERK33a t 2.75078 dsm 0.00608412 dsm_est 0.901588 + H 0.00078125 method ARKODE_MRI_GARK_ERK33a t 3.00078 dsm 0.00463348 dsm_est 1.26635 + H 0.00078125 method ARKODE_MRI_GARK_ERK33a t 3.25078 dsm 0.00394414 dsm_est 0.719303 + H 0.00078125 method ARKODE_MRI_GARK_ERK33a t 3.50078 dsm 0.00333765 dsm_est 0.302408 + H 0.00078125 method ARKODE_MRI_GARK_ERK33a t 3.75078 dsm 0.00249229 dsm_est 0.318005 + H 0.00078125 method ARKODE_MRI_GARK_ERK33a t 4.00078 dsm 0.00197527 dsm_est 0.548996 + H 0.00078125 method ARKODE_MRI_GARK_ERK33a t 4.25078 dsm 0.000423031 dsm_est 3.07331 + H 0.00078125 method ARKODE_MRI_GARK_ERK33a t 4.50078 dsm 0.00226465 dsm_est 3.80981 + H 0.00078125 method ARKODE_MRI_GARK_ERK33a t 4.75078 dsm 0.00143499 dsm_est 0.942031 + H 0.000195313 method ARKODE_MRI_GARK_ERK33a t 0.000195313 dsm 2.85013e-06 dsm_est 0.00265424 + H 0.000195313 method ARKODE_MRI_GARK_ERK33a t 0.250195 dsm 9.05953e-06 dsm_est 0.0171084 + H 0.000195313 method ARKODE_MRI_GARK_ERK33a t 0.500195 dsm 2.05759e-05 dsm_est 0.129079 + H 0.000195313 method ARKODE_MRI_GARK_ERK33a t 0.750195 dsm 4.6605e-05 dsm_est 0.127987 + H 0.000195313 method ARKODE_MRI_GARK_ERK33a t 1.0002 dsm 6.66547e-05 dsm_est 0.00213263 + H 0.000195313 method ARKODE_MRI_GARK_ERK33a t 1.2502 dsm 0.000653038 dsm_est 0.945246 + H 0.000195313 method ARKODE_MRI_GARK_ERK33a t 1.5002 dsm 0.000267427 dsm_est 0.186783 + H 0.000195313 method ARKODE_MRI_GARK_ERK33a t 1.7502 dsm 0.000909834 dsm_est 0.751614 + H 0.000195313 method ARKODE_MRI_GARK_ERK33a t 2.0002 dsm 1.02331e-05 dsm_est 0.185807 + H 0.000195313 method ARKODE_MRI_GARK_ERK33a t 2.2502 dsm 1.54333e-06 dsm_est 0.132009 + H 0.000195313 method ARKODE_MRI_GARK_ERK33a t 2.5002 dsm 1.7004e-05 dsm_est 0.0255566 + H 0.000195313 method ARKODE_MRI_GARK_ERK33a t 2.7502 dsm 2.75731e-05 dsm_est 0.0139673 + H 0.000195313 method ARKODE_MRI_GARK_ERK33a t 3.0002 dsm 1.60122e-05 dsm_est 0.0198318 + H 0.000195313 method ARKODE_MRI_GARK_ERK33a t 3.2502 dsm 1.59604e-05 dsm_est 0.0112328 + H 0.000195313 method ARKODE_MRI_GARK_ERK33a t 3.5002 dsm 1.2611e-05 dsm_est 0.00471821 + H 0.000195313 method ARKODE_MRI_GARK_ERK33a t 3.7502 dsm 1.0072e-05 dsm_est 0.00496521 + H 0.000195313 method ARKODE_MRI_GARK_ERK33a t 4.0002 dsm 7.64165e-06 dsm_est 0.00855534 + H 0.000195313 method ARKODE_MRI_GARK_ERK33a t 4.2502 dsm 3.12732e-06 dsm_est 0.0479914 + H 0.000195313 method ARKODE_MRI_GARK_ERK33a t 4.5002 dsm 6.25467e-06 dsm_est 0.0595107 + H 0.000195313 method ARKODE_MRI_GARK_ERK33a t 4.7502 dsm 1.05712e-05 dsm_est 0.0147462 + H 4.88281e-05 method ARKODE_MRI_GARK_ERK33a t 4.88281e-05 dsm 2.01535e-06 dsm_est 4.1115e-05 + H 4.88281e-05 method ARKODE_MRI_GARK_ERK33a t 0.250049 dsm 0 dsm_est 0.000267507 + H 4.88281e-05 method ARKODE_MRI_GARK_ERK33a t 0.500049 dsm 1.50297e-06 dsm_est 0.00201586 + H 4.88281e-05 method ARKODE_MRI_GARK_ERK33a t 0.750049 dsm 1.49086e-06 dsm_est 0.00200068 + H 4.88281e-05 method ARKODE_MRI_GARK_ERK33a t 1.00005 dsm 9.78971e-07 dsm_est 3.2652e-05 + H 4.88281e-05 method ARKODE_MRI_GARK_ERK33a t 1.25005 dsm 3.17142e-06 dsm_est 0.0147541 + H 4.88281e-05 method ARKODE_MRI_GARK_ERK33a t 1.50005 dsm 2.18254e-06 dsm_est 0.0029151 + H 4.88281e-05 method ARKODE_MRI_GARK_ERK33a t 1.75005 dsm 2.39243e-06 dsm_est 0.0117588 + H 4.88281e-05 method ARKODE_MRI_GARK_ERK33a t 2.00005 dsm 1.0054e-06 dsm_est 0.00290265 + H 4.88281e-05 method ARKODE_MRI_GARK_ERK33a t 2.25005 dsm 2.03676e-06 dsm_est 0.00206178 + H 4.88281e-05 method ARKODE_MRI_GARK_ERK33a t 2.50005 dsm 3.37798e-06 dsm_est 0.000398446 + H 4.88281e-05 method ARKODE_MRI_GARK_ERK33a t 2.75005 dsm 4.72989e-06 dsm_est 0.000217912 + H 4.88281e-05 method ARKODE_MRI_GARK_ERK33a t 3.00005 dsm 6.95491e-06 dsm_est 0.000310377 + H 4.88281e-05 method ARKODE_MRI_GARK_ERK33a t 3.25005 dsm 1.55004e-06 dsm_est 0.000175458 + H 4.88281e-05 method ARKODE_MRI_GARK_ERK33a t 3.50005 dsm 9.19766e-07 dsm_est 7.37004e-05 + H 4.88281e-05 method ARKODE_MRI_GARK_ERK33a t 3.75005 dsm 0 dsm_est 7.66833e-05 + H 4.88281e-05 method ARKODE_MRI_GARK_ERK33a t 4.00005 dsm 1.08798e-06 dsm_est 0.000134086 + H 4.88281e-05 method ARKODE_MRI_GARK_ERK33a t 4.25005 dsm 3.12694e-06 dsm_est 0.000748179 + H 4.88281e-05 method ARKODE_MRI_GARK_ERK33a t 4.50005 dsm 1.16508e-06 dsm_est 0.000930348 + H 4.88281e-05 method ARKODE_MRI_GARK_ERK33a t 4.75005 dsm 6.40365e-06 dsm_est 0.000231401 + +ARKODE_MRI_GARK_ERK33a summary: + Stepsize 0.0125 maxdsm 13680.4 maxdsmest 267128 + Stepsize 0.003125 maxdsm 58.1561 maxdsmest 3954.15 + Stepsize 0.00078125 maxdsm 0.231817 maxdsmest 60.7616 + Stepsize 0.000195313 maxdsm 0.000909834 maxdsmest 0.945246 + Stepsize 4.88281e-05 maxdsm 6.95491e-06 maxdsmest 0.0147541 diff --git a/test/unit_tests/arkode/CXX_serial/ark_test_slowerror_polynomial.cpp b/test/unit_tests/arkode/CXX_serial/ark_test_slowerror_polynomial.cpp new file mode 100644 index 0000000000..e31739abdf --- /dev/null +++ b/test/unit_tests/arkode/CXX_serial/ark_test_slowerror_polynomial.cpp @@ -0,0 +1,410 @@ +/*----------------------------------------------------------------- + * Programmer(s): Daniel R. Reynolds @ SMU + *--------------------------------------------------------------- + * SUNDIALS Copyright Start + * Copyright (c) 2002-2024, 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 + *--------------------------------------------------------------- + * Routine to test an MRI method's embedding-based error + * estimate. Uses a simple polynomial test problem with 1 + * component, + * dy/dt = a*t^2 + b*t + c, y(0) = 1. + * + * We run a single time step, using a variety of slow step sizes, + * H = {1, 1/2, 1/4, 1/8, 1/16}. + * + * We place the entire ODE in the "slow" RHS partition. All tests + * use ARKODE's default fifth-order ERK method, with relative and + * absolute tolerances set to 1e-10 and 1e-12, respectively. + * + * When using an IMEX method (e.g., IMEX-MRI-SR), the entire slow + * partition is treated implicitly. + * + * We select the slow integrator based on a command-line argument, + * with the default being ARKODE_MRI_GARK_ERK22a. + * + * The program should be run with arguments in the following order: + * $ a.out method a b c + * Not all arguments are required, but these must be omitted from + * end-to-beginning, i.e. any one of + * $ a.out method a b + * $ a.out method a + * $ a.out method + * $ a.out + * are acceptable. We require that the "method" argument be a + * string corresponding to a valid embedded ARKODE_MRITableID. + *-----------------------------------------------------------------*/ + +// Header files +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#if defined(SUNDIALS_EXTENDED_PRECISION) +#define GSYM "Lg" +#define ESYM "Le" +#define FSYM "Lf" +#else +#define GSYM "g" +#define ESYM "e" +#define FSYM "f" +#endif + +#define ZERO SUN_RCONST(0.0) +#define ONE SUN_RCONST(1.0) +#define TWO SUN_RCONST(2.0) + +using namespace std; + +// User data structure +struct UserData +{ + sunrealtype a; + sunrealtype b; + sunrealtype c; +}; + +// User-supplied Functions Called by the Solver +static int f0(sunrealtype t, N_Vector y, N_Vector ydot, void* user_data); +static int fn(sunrealtype t, N_Vector y, N_Vector ydot, void* user_data); +static int Jn(sunrealtype t, N_Vector y, N_Vector fy, SUNMatrix J, + void* user_data, N_Vector tmp1, N_Vector tmp2, N_Vector tmp3); + +// Private utility functions +static int Ytrue(sunrealtype t, N_Vector y, UserData& udata); +static int computeErrorWeights(N_Vector ycur, N_Vector weight, sunrealtype rtol, + sunrealtype atol, N_Vector vtemp); +static int check_retval(void* returnvalue, const char* funcname, int opt); +static int run_test(void* mristep_mem, N_Vector y, sunrealtype T0, + vector& Hvals, char* method, + sunrealtype reltol, sunrealtype abstol, UserData& udata); + +// Main Program +int main(int argc, char* argv[]) +{ + // general problem parameters + sunrealtype T0 = ZERO; // initial time + sunindextype NEQ = 1; // number of dependent vars. + char* method; // MRI method name + sunrealtype reltol = SUN_RCONST(1.e-10); // fast solver tolerances + sunrealtype abstol = SUN_RCONST(1.e-12); + + // general problem variables + int retval; // reusable error-checking flag + UserData udata; // user-data structure + + // + // Initialization + // + + // Retrieve the command-line options: method Npart ep test + if (argc > 1) { method = argv[1]; } + else { method = "ARKODE_MRI_GARK_ERK22a"; } + if (argc > 2) { udata.a = (sunrealtype)atof(argv[2]); } + else { udata.a = ONE; } + if (argc > 3) { udata.b = (sunrealtype)atof(argv[3]); } + else { udata.b = ONE; } + if (argc > 4) { udata.c = (sunrealtype)atof(argv[4]); } + else { udata.c = ONE; } + + sunbooleantype implicit = SUNFALSE; + if ((strcmp(method, "ARKODE_MRI_GARK_IRK21a") == 0) || + (strcmp(method, "ARKODE_MRI_GARK_ESDIRK34a") == 0) || + (strcmp(method, "ARKODE_MRI_GARK_ESDIRK46a") == 0) || + (strcmp(method, "ARKODE_IMEX_MRI_SR21") == 0) || + (strcmp(method, "ARKODE_IMEX_MRI_SR32") == 0) || + (strcmp(method, "ARKODE_IMEX_MRI_SR43") == 0)) + { + implicit = SUNTRUE; + } + + // Initial problem output (and set implicit solver tolerances as needed) + cout << "\nSlow error estimation test (polynomial ODE problem):\n"; + cout << " problem parameters: a = " << udata.a << ", b = " << udata.b + << ", c = " << udata.c << endl; + cout << " MRI method: " << method; + if (implicit) { cout << " (implicit)" << endl; } + else { cout << " (explicit)" << endl; } + + // + // Problem Setup + // + + // Create SUNDIALS context + sundials::Context ctx; + + // Create serial vectors for the solution and reference + N_Vector y = N_VNew_Serial(NEQ, ctx); + if (check_retval((void*)y, "N_VNew_Serial", 0)) return 1; + retval = Ytrue(T0, y, udata); + if (check_retval(&retval, "Ytrue", 1)) return 1; + + // Set up fast ARKStep integrator as fifth-order adaptive ERK + void* inner_arkode_mem = ARKStepCreate(f0, NULL, T0, y, ctx); + if (check_retval((void*)inner_arkode_mem, "ARKStepCreate", 0)) return 1; + retval = ARKodeSetOrder(inner_arkode_mem, 5); + if (check_retval(&retval, "ARKodeSetOrder", 1)) return 1; + retval = ARKodeSStolerances(inner_arkode_mem, reltol, abstol); + if (check_retval(&retval, "ARKodeSStolerances", 1)) return 1; + retval = ARKodeSetMaxNumSteps(inner_arkode_mem, 1000000); + if (check_retval(&retval, "ARKodeSetMaxNumSteps", 1)) return (1); + + // Create inner stepper wrapper + MRIStepInnerStepper inner_stepper = NULL; // inner stepper + retval = ARKStepCreateMRIStepInnerStepper(inner_arkode_mem, &inner_stepper); + if (check_retval(&retval, "ARKStepCreateMRIStepInnerStepper", 1)) return 1; + + // Set up slow MRIStep integrator + void* mristep_mem = NULL; + if (implicit) + { + mristep_mem = MRIStepCreate(NULL, fn, T0, y, inner_stepper, ctx); + } + else { mristep_mem = MRIStepCreate(fn, NULL, T0, y, inner_stepper, ctx); } + if (check_retval((void*)mristep_mem, "MRIStepCreate", 0)) return 1; + MRIStepCoupling C = MRIStepCoupling_LoadTableByName(method); + if (check_retval((void*)C, "MRIStepCoupling_LoadTableByName", 0)) return 1; + retval = MRIStepSetCoupling(mristep_mem, C); + if (check_retval(&retval, "MRIStepSetCoupling", 1)) return 1; + SUNMatrix A = NULL; // matrix for slow solver + SUNLinearSolver LS = NULL; // slow linear solver object + if (implicit) + { + A = SUNDenseMatrix(NEQ, NEQ, ctx); + if (check_retval((void*)A, "SUNDenseMatrix", 0)) return 1; + LS = SUNLinSol_Dense(y, A, ctx); + if (check_retval((void*)LS, "SUNLinSol_Dense", 0)) return 1; + retval = ARKodeSetLinearSolver(mristep_mem, LS, A); + if (check_retval(&retval, "ARKodeSetLinearSolver", 1)) return 1; + retval = ARKodeSetJacFn(mristep_mem, Jn); + if (check_retval(&retval, "ARKodeSetJacFn", 1)) return 1; + retval = ARKodeSetJacEvalFrequency(mristep_mem, 1); + if (check_retval(&retval, "ARKodeSetJacEvalFrequency", 1)) return 1; + retval = ARKodeSetLSetupFrequency(mristep_mem, 1); + if (check_retval(&retval, "ARKodeSetLSetupFrequency", 1)) return 1; + retval = ARKodeSetMaxNonlinIters(mristep_mem, 20); + if (check_retval(&retval, "ARKodeSetMaxNonlinIters", 1)) return 1; + } + retval = ARKodeSStolerances(mristep_mem, reltol, abstol); + if (check_retval(&retval, "ARKodeSStolerances", 1)) return 1; + retval = ARKodeSetUserData(mristep_mem, (void*)&udata); + if (check_retval(&retval, "ARKodeSetUserData", 1)) return 1; + retval = ARKodeSetAccumulatedErrorType(mristep_mem, 0); + if (check_retval(&retval, "ARKodeSetAccumulatedErrorType", 1)) return 1; + + // Run test for various H values + // vector Hvals = {ONE, ONE/2.0, ONE/4.0, ONE/8.0, ONE/16.0}; + vector Hvals = {ONE / 100.0, ONE / 200.0, ONE / 400.0, + ONE / 800.0, ONE / 1600.0}; + retval = run_test(mristep_mem, y, T0, Hvals, method, reltol, abstol, udata); + if (check_retval(&retval, "run_test", 1)) return 1; + + // Clean up and return + MRIStepCoupling_Free(C); + ARKodeFree(&inner_arkode_mem); + MRIStepInnerStepper_Free(&inner_stepper); + ARKodeFree(&mristep_mem); + if (LS) { SUNLinSolFree(LS); } // free system linear solver + if (A) { SUNMatDestroy(A); } // free system matrix + N_VDestroy(y); // Free y and yref vectors + return 0; +} + +//------------------------------ +// Functions called by the solver +//------------------------------ + +static int f0(sunrealtype t, N_Vector y, N_Vector ydot, void* user_data) +{ + // fill in the RHS function with zeros and return with success + N_VConst(ZERO, ydot); + return 0; +} + +static int fn(sunrealtype t, N_Vector y, N_Vector ydot, void* user_data) +{ + // fill in the RHS function and return with success + UserData* udata = (UserData*)user_data; + NV_Ith_S(ydot, 0) = udata->a * t * t + udata->b * t + udata->c; + return 0; +} + +static int Jn(sunrealtype t, N_Vector y, N_Vector fy, SUNMatrix J, + void* user_data, N_Vector tmp1, N_Vector tmp2, N_Vector tmp3) +{ + // fill in the Jacobian and return with success + SM_ELEMENT_D(J, 0, 0) = ZERO; + return 0; +} + +//------------------------------ +// Private helper functions +//------------------------------ + +static int run_test(void* mristep_mem, N_Vector y, sunrealtype T0, + vector& Hvals, char* method, + sunrealtype reltol, sunrealtype abstol, UserData& udata) +{ + // Reused variables + int retval; + sunrealtype t; + N_Vector vtemp = N_VClone(y); + N_Vector ele = N_VClone(y); + N_Vector ewt = N_VClone(y); + + // Set storage for errors + vector dsm(Hvals.size(), ZERO); + vector dsm_est(Hvals.size(), ZERO); + + // Loop over step sizes + for (int iH = 0; iH < Hvals.size(); iH++) + { + // Reset integrator for this run + t = T0; + retval = Ytrue(t, y, udata); + if (check_retval(&retval, "Ytrue", 1)) return 1; + retval = ARKodeReset(mristep_mem, t, y); + if (check_retval(&retval, "ARKodeReset", 1)) return 1; + retval = ARKodeSetFixedStep(mristep_mem, Hvals[iH]); + if (check_retval(&retval, "ARKodeSetFixedStep", 1)) return 1; + retval = ARKodeResetAccumulatedError(mristep_mem); + if (check_retval(&retval, "ARKodeResetAccumulatedError", 1)) return 1; + + // Run ARKodeEvolve to compute one step + retval = ARKodeEvolve(mristep_mem, t + Hvals[iH], y, &t, ARK_ONE_STEP); + if (check_retval(&retval, "ARKodeEvolve", 1)) return 1; + retval = ARKodeGetEstLocalErrors(mristep_mem, ele); + if (check_retval(&retval, "ARKodeGetEstLocalErrors", 1)) return 1; + retval = computeErrorWeights(y, ewt, reltol, abstol, vtemp); + if (check_retval(&retval, "computeErrorWeights", 1)) return 1; + dsm_est[iH] = N_VWrmsNorm(ewt, ele); + + // Compute/print solution error + retval = Ytrue(t, vtemp, udata); + if (check_retval(&retval, "Ytrue", 1)) return 1; + dsm[iH] = abs(NV_Ith_S(y, 0) - NV_Ith_S(vtemp, 0)) / + (abstol + reltol * abs(NV_Ith_S(vtemp, 0))); + if (strcmp(method, "ARKODE_MRI_GARK_ERK22a") == 0) + { + printf(" H %.5f dsm %.2e dsm_est %.2e dsm_anal %.2e " + " dsm_est_anal %.2e\n", + Hvals[iH], dsm[iH], dsm_est[iH], + Hvals[iH] * Hvals[iH] * Hvals[iH] * abs(udata.a / 12.0) / + (abstol + reltol * abs(NV_Ith_S(vtemp, 0))), + Hvals[iH] * Hvals[iH] * + abs(udata.a * Hvals[iH] / 4.0 + udata.b / 2.0) / + (abstol + reltol * abs(NV_Ith_S(vtemp, 0)))); + } + else if (strcmp(method, "ARKODE_MRI_GARK_IRK21a") == 0) + { + printf(" H %.5f dsm %.2e dsm_est %.2e dsm_anal %.2e " + " dsm_est_anal %.2e\n", + Hvals[iH], dsm[iH], dsm_est[iH], + Hvals[iH] * Hvals[iH] * Hvals[iH] * abs(udata.a / 6.0) / + (abstol + reltol * abs(NV_Ith_S(vtemp, 0))), + Hvals[iH] * Hvals[iH] * + abs(udata.a * Hvals[iH] / 2.0 + udata.b / 2.0) / + (abstol + reltol * abs(NV_Ith_S(vtemp, 0)))); + } + else if (strcmp(method, "ARKODE_IMEX_MRI_SR21") == 0) + { + printf(" H %.5f dsm %.2e dsm_est %.2e dsm_anal %.2e " + " dsm_est_anal %.2e\n", + Hvals[iH], dsm[iH], dsm_est[iH], + Hvals[iH] * Hvals[iH] * Hvals[iH] * abs(udata.a * 3137.0 / 50370.0) / + (abstol + reltol * abs(NV_Ith_S(vtemp, 0))), + Hvals[iH] * Hvals[iH] * + abs(udata.a * Hvals[iH] * 20191.0 / 755550.0 - + udata.b * 19.0 / 30.0) / + (abstol + reltol * abs(NV_Ith_S(vtemp, 0)))); + } + else + { + printf(" H %.5f dsm %.2e dsm_est %.2e\n", Hvals[iH], + dsm[iH], dsm_est[iH]); + } + } + + N_VDestroy(ele); + N_VDestroy(ewt); + N_VDestroy(vtemp); + return (0); +} + +static int Ytrue(sunrealtype t, N_Vector y, UserData& udata) +{ + NV_Ith_S(y, 0) = udata.a / SUN_RCONST(3.0) * t * t * t + + udata.b / SUN_RCONST(2.0) * t * t + udata.c * t + ONE; + return (0); +} + +/* Error weight calculation routine (mimics what's in ARKODE already) */ +static int computeErrorWeights(N_Vector ycur, N_Vector weight, sunrealtype rtol, + sunrealtype atol, N_Vector vtemp) +{ + N_VAbs(ycur, vtemp); + N_VScale(rtol, vtemp, vtemp); + N_VAddConst(vtemp, atol, vtemp); + N_VInv(vtemp, weight); + return (0); +} + +/* Check function return value... + opt == 0 means SUNDIALS function allocates memory so check if + returned NULL pointer + opt == 1 means SUNDIALS function returns a retval so check if + retval >= 0 + opt == 2 means function allocates memory so check if returned + NULL pointer +*/ +static int check_retval(void* returnvalue, const char* funcname, int opt) +{ + int* retval; + + // Check if SUNDIALS function returned NULL pointer - no memory allocated + if (opt == 0 && returnvalue == NULL) + { + fprintf(stderr, "\nSUNDIALS_ERROR: %s() failed - returned NULL pointer\n\n", + funcname); + return 1; + } + + // Check if retval < 0 + else if (opt == 1) + { + retval = (int*)returnvalue; + if (*retval < 0) + { + fprintf(stderr, "\nSUNDIALS_ERROR: %s() failed with retval = %d\n\n", + funcname, *retval); + return 1; + } + } + + // Check if function returned NULL pointer - no memory allocated + else if (opt == 2 && returnvalue == NULL) + { + fprintf(stderr, "\nMEMORY_ERROR: %s() failed - returned NULL pointer\n\n", + funcname); + return 1; + } + + return 0; +} + +/*---- end of file ----*/ diff --git a/test/unit_tests/arkode/CXX_serial/ark_test_slowerror_polynomial.out b/test/unit_tests/arkode/CXX_serial/ark_test_slowerror_polynomial.out new file mode 100644 index 0000000000..25faa25bff --- /dev/null +++ b/test/unit_tests/arkode/CXX_serial/ark_test_slowerror_polynomial.out @@ -0,0 +1,9 @@ + +Slow error estimation test (polynomial ODE problem): + problem parameters: a = 1, b = 1, c = 1 + MRI method: ARKODE_MRI_GARK_ERK22a (explicit) + H 0.01000 dsm 8.17e+02 dsm_est 4.93e+05 dsm_anal 8.17e+02 dsm_est_anal 4.93e+05 + H 0.00500 dsm 1.03e+02 dsm_est 1.23e+05 dsm_anal 1.03e+02 dsm_est_anal 1.23e+05 + H 0.00250 dsm 1.29e+01 dsm_est 3.09e+04 dsm_anal 1.29e+01 dsm_est_anal 3.09e+04 + H 0.00125 dsm 1.61e+00 dsm_est 7.73e+03 dsm_anal 1.61e+00 dsm_est_anal 7.73e+03 + H 0.00063 dsm 2.01e-01 dsm_est 1.93e+03 dsm_anal 2.01e-01 dsm_est_anal 1.93e+03 diff --git a/test/unit_tests/arkode/C_serial/ark_test_erkstepsetforcing.c b/test/unit_tests/arkode/C_serial/ark_test_erkstepsetforcing.c new file mode 100644 index 0000000000..b80198444e --- /dev/null +++ b/test/unit_tests/arkode/C_serial/ark_test_erkstepsetforcing.c @@ -0,0 +1,386 @@ +/* ----------------------------------------------------------------------------- + * 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 + * ----------------------------------------------------------------------------- + * Unit test for erkStep_SetInnerForcing + * + * erkStep_SetInnerForcing is used to provide a polynomial forcing term in + * ERKStep when it is used as the inner integrator under MRIStep. To check that + * the forcing is computed and applied correctly we integrate an ODE in time + * with ERKStep where to RHS consists of only the polynomial forcing term. The + * solution should be exact when the method order is greater than or equal to + * the polynomial order. + * ---------------------------------------------------------------------------*/ + +#include +#include +#include + +#include "arkode/arkode_erkstep.h" +#include "arkode/arkode_erkstep_impl.h" +#include "nvector/nvector_serial.h" +#include "sundials/sundials_math.h" +#include "sundials/sundials_types.h" + +#if defined(SUNDIALS_EXTENDED_PRECISION) +#define GSYM "Lg" +#define ESYM "Le" +#define FSYM "Lf" +#else +#define GSYM "g" +#define ESYM "e" +#define FSYM "f" +#endif + +/* User-supplied Functions Called by the Solver */ +static int f(realtype t, N_Vector y, N_Vector ydot, void* user_data); + +/* Private function to check function return values */ +static int check_flag(void* flagvalue, const char* funcname, int opt); + +/* Private function to check computed solution */ +static int compute_ans(realtype t, realtype tshift, realtype tscale, + N_Vector* forcing, int order, N_Vector ans); +static int compute_error(N_Vector y, N_Vector ans, N_Vector tmp, realtype rtol, + realtype atol); + +/* Main Program */ +int main(int argc, char* argv[]) +{ + SUNContext sunctx = NULL; + + /* default input values */ + sunindextype NEQ = 1; /* number of dependent vars. */ + int order = 3; /* order of polynomial forcing */ + realtype T0 = RCONST(0.0); /* initial time */ + realtype Tf = RCONST(1.0); /* final time */ + realtype tshift = T0; /* time shift for normalization */ + realtype tscale = Tf; /* time scale for normalization */ + + /* tolerances */ + realtype reltol = SUNRsqrt(UNIT_ROUNDOFF); + realtype abstol = SUNRsqrt(UNIT_ROUNDOFF) / 100; + + /* general problem variables */ + int flag; /* reusable error-checking flag */ + N_Vector y = NULL; /* vector for storing the computed solution */ + N_Vector ans = NULL; /* vector for storing the true solution */ + N_Vector tmp = NULL; /* temporary workspace vector */ + N_Vector* forcing = NULL; /* array of forcing vectors */ + void* arkode_mem = NULL; /* ARKode memory structure */ + int i, j; /* loop counters */ + realtype tret; /* integrator return time */ + realtype* data; /* array for accessing vector data */ + long int nst, nst_a; /* number of integrator steps */ + long int mxsteps = 100000; /* max steps before output */ + + /* check inputs */ + if (argc > 1) + { + NEQ = (sunindextype)atol(argv[1]); + if (NEQ <= 0) + { + printf("ERROR: The problem size must be a positive integer\n"); + return (1); + } + } + + if (argc > 2) + { + order = (int)atol(argv[2]); + if (order < 0) + { + printf("ERROR: The polynomial order must be a non-negative integer\n"); + return (1); + } + } + + if (argc > 3) + { + if (argc < 5) + { + printf("ERROR: Both the initial and final time are required\n"); + return (1); + } + T0 = (realtype)atof(argv[3]); + Tf = (realtype)atof(argv[4]); + if (SUNRabs(T0) >= SUNRabs(Tf)) + { + printf("ERROR: |T0| must be less than |Tf|\n"); + return (1); + } + } + + if (argc > 5) + { + if (argc < 7) + { + printf("ERROR: Both tshift and tscale are required\n"); + return (1); + } + tshift = (realtype)atof(argv[5]); + tscale = (realtype)atof(argv[6]); + if (SUNRabs(tscale) < TINY) + { + printf("ERROR: |tscale| must be greater than %" GSYM "\n", TINY); + return (1); + } + } + + /* Output test setup */ + printf("\nerkStep_SetInnerForcing unit test:\n"); + printf(" NEQ = %li\n", (long int)NEQ); + printf(" order = %i\n", order); + printf(" t0 = %.1" GSYM "\n", T0); + printf(" tf = %.1" GSYM "\n", Tf); + printf(" tshift = %.1" GSYM "\n", tshift); + printf(" tscale = %.1" GSYM "\n", tscale); + printf(" reltol = %.1" ESYM "\n", reltol); + printf(" abstol = %.1" ESYM "\n\n", abstol); + + /* Create the SUNDIALS context object for this simulation. */ + SUNContext_Create(NULL, &sunctx); + + /* Create solution vector and initialize to zero */ + y = N_VNew_Serial(NEQ, sunctx); + if (check_flag((void*)y, "N_VNew_Serial", 0)) return 1; + + ans = N_VClone(y); + if (check_flag((void*)ans, "N_VClone", 0)) return 1; + + tmp = N_VClone(y); + if (check_flag((void*)tmp, "N_VClone", 0)) return 1; + + /* allocate vector array for polynomial forcing */ + forcing = N_VCloneVectorArray(order + 1, y); + if (check_flag((void*)forcing, "N_VCloneVectorArray", 0)) return 1; + for (i = 0; i < order + 1; i++) + { + if (check_flag((void*)forcing[i], "N_VCloneVectorArray", 0)) return 1; + } + + /* fill forcing vectors with random data */ + for (i = 0; i < order + 1; i++) + { + data = N_VGetArrayPointer(forcing[i]); + for (j = 0; j < NEQ; j++) + { + data[j] = (realtype)rand() / (realtype)RAND_MAX; + } + } + + /* compute the true solution */ + flag = compute_ans(Tf, tshift, tscale, forcing, order, ans); + if (check_flag(&flag, "compute_ans", 1)) return 1; + + printf("True solution:\n"); + N_VPrint_Serial(ans); + + /* --------------------------------------------------------------------------- + * explicit test + * -------------------------------------------------------------------------*/ + + /* initialize solution vector */ + flag = compute_ans(T0, tshift, tscale, forcing, order, y); + if (check_flag(&flag, "compute_ans", 1)) return 1; + + /* Create ARKode mem structure */ + arkode_mem = ERKStepCreate(f, T0, y, sunctx); + if (check_flag((void*)arkode_mem, "ERKStepCreate", 0)) return 1; + + /* Specify tolerances */ + flag = ERKStepSStolerances(arkode_mem, reltol, abstol); + if (check_flag(&flag, "ERKStepSStolerances", 1)) return 1; + + /* Set stop time */ + flag = ERKStepSetStopTime(arkode_mem, Tf); + if (check_flag(&flag, "ERKStepSetStopTime", 1)) return 1; + + /* Set max steps before output */ + flag = ERKStepSetMaxNumSteps(arkode_mem, mxsteps); + if (check_flag(&flag, "ERKStepSetMaxNumSteps", 1)) return 1; + + /* Set forcing */ + flag = erkStep_SetInnerForcing(arkode_mem, tshift, tscale, forcing, order + 1); + if (check_flag(&flag, "erkStep_SetInnerForcing", 1)) return 1; + + /* Integrate the problem */ + flag = ERKStepEvolve(arkode_mem, Tf, y, &tret, ARK_NORMAL); + + /* check for errors */ + if (flag < 0) + { + fprintf(stderr, "ERKStep failure, flag = %d\n", flag); + return 1; + } + + /* get some integrator stats */ + flag = ERKStepGetNumSteps(arkode_mem, &nst); + check_flag(&flag, "ERKStepGetNumSteps", 1); + + flag = ERKStepGetNumStepAttempts(arkode_mem, &nst_a); + check_flag(&flag, "ERKStepGetNumStepAttempts", 1); + + printf("Stats:\n"); + printf("Steps = %li (attempted = %li)\n\n", nst, nst_a); + + /* Free integrator memory */ + ERKStepFree(&arkode_mem); + arkode_mem = NULL; + + /* print solution */ + printf("Explicit solution:\n"); + N_VPrint_Serial(y); + + /* check the solution error */ + flag = compute_error(y, ans, tmp, reltol, abstol); + if (flag != 0) return (1); + + /* --------------------------------------------------------------------------- + * Clean up and return + * -------------------------------------------------------------------------*/ + + N_VDestroy(y); /* Free vectors */ + N_VDestroy(ans); + N_VDestroy(tmp); + + N_VDestroyVectorArray(forcing, order + 1); + + SUNContext_Free(&sunctx); + return flag; +} + +/*------------------------------- + * Functions called by the solver + *-------------------------------*/ + +/* ODE RHS function */ +static int f(realtype t, N_Vector y, N_Vector ydot, void* user_data) +{ + N_VConst(ZERO, ydot); + return 0; +} + +/*------------------------------- + * Private helper functions + *-------------------------------*/ + +/* Check function return value... + opt == 0 means SUNDIALS function allocates memory so check if + returned NULL pointer + opt == 1 means SUNDIALS function returns a flag so check if + flag < 0 + opt == 2 means function allocates memory so check if returned + NULL pointer +*/ +static int check_flag(void* flagvalue, const char* funcname, int opt) +{ + int* errflag; + + /* Check if SUNDIALS function returned NULL pointer - no memory allocated */ + if (opt == 0 && flagvalue == NULL) + { + fprintf(stderr, "\nSUNDIALS_ERROR: %s() failed - returned NULL pointer\n\n", + funcname); + return 1; + } + + /* Check if flag < 0 */ + else if (opt == 1) + { + errflag = (int*)flagvalue; + if (*errflag < 0) + { + fprintf(stderr, "\nSUNDIALS_ERROR: %s() failed with flag = %d\n\n", + funcname, *errflag); + return 1; + } + } + + /* Check if function returned NULL pointer - no memory allocated */ + else if (opt == 2 && flagvalue == NULL) + { + fprintf(stderr, "\nMEMORY_ERROR: %s() failed - returned NULL pointer\n\n", + funcname); + return 1; + } + + return 0; +} + +/* computed the true solution at a given time */ +static int compute_ans(realtype t, realtype tshift, realtype tscale, + N_Vector* forcing, int order, N_Vector ans) +{ + int i; + realtype tau; + N_Vector* vecs; + realtype* vals; + + vals = NULL; + vals = (realtype*)calloc(order + 1, sizeof(realtype)); + if (vals == NULL) return (1); + + vecs = NULL; + vecs = (N_Vector*)calloc(order + 1, sizeof(N_Vector)); + if (vecs == NULL) return (1); + + /* compute normalized time */ + tau = (t - tshift) / tscale; + + /* compute true solution */ + for (i = 0; i < order + 1; i++) + { + vals[i] = ((SUNRpowerI(tau, i + 1)) / (i + 1)) * tscale; + vecs[i] = forcing[i]; + } + N_VLinearCombination(order + 1, vals, vecs, ans); + + free(vals); + free(vecs); + + return (0); +} + +/* compure the weighted max norm of the difference of two vectors */ +static int compute_error(N_Vector y, N_Vector ans, N_Vector tmp, realtype rtol, + realtype atol) +{ + int status; /* success (0) or failure (1) flag */ + realtype error; + + /* compute the error in y */ + N_VLinearSum(ONE, y, -ONE, ans, y); + + /* compute error weights */ + N_VAbs(ans, tmp); + N_VScale(rtol, tmp, tmp); + N_VAddConst(tmp, atol, tmp); + N_VInv(tmp, tmp); + + /* compute weighted max norm */ + N_VProd(tmp, y, y); + error = N_VMaxNorm(y); + + /* is the solution within the tolerances? */ + status = (error < ONE) ? 0 : 1; + + if (status) + fprintf(stdout, "ERROR: Test failed with wmax error = %" GSYM "\n\n", error); + else + fprintf(stdout, "SUCCESS: Test passed with wmax error = %" GSYM "\n\n", + error); + + return (status); +} + +/*---- end of file ----*/ diff --git a/test/unit_tests/arkode/C_serial/ark_test_reset.c b/test/unit_tests/arkode/C_serial/ark_test_reset.c index 529a3d62cf..f6fc22dc25 100644 --- a/test/unit_tests/arkode/C_serial/ark_test_reset.c +++ b/test/unit_tests/arkode/C_serial/ark_test_reset.c @@ -125,7 +125,7 @@ int main(void) check_retval(&retval, "ARKodeSetStopTime", 1); retval = ARKodeEvolve(arkode_mem, t + dTout, y, &t, ARK_NORMAL); if (check_retval(&retval, "ARKodeEvolve", 1)) { return 1; } - if (check_ans(y, t, SUN_RCONST(0.001), SUN_RCONST(0.000001))) + if (check_ans(y, t, rtol, atol)) { printf(" Initial ARKodeEvolve had insufficient accuracy\n"); printf(" t = %" GSYM "\n", t); @@ -143,7 +143,7 @@ int main(void) check_retval(&retval, "ARKodeReset", 1); retval = ARKodeEvolve(arkode_mem, t + dTout, y, &t, ARK_NORMAL); if (check_retval(&retval, "ARKodeEvolve", 1)) { return 1; } - if (check_ans(y, t, SUN_RCONST(0.001), SUN_RCONST(0.000001))) + if (check_ans(y, t, rtol, atol)) { printf(" Second ARKodeEvolve call had insufficient accuracy\n"); printf(" t = %" GSYM "\n", t); @@ -161,7 +161,7 @@ int main(void) check_retval(&retval, "ARKodeReset", 1); retval = ARKodeEvolve(arkode_mem, t + dTout, y, &t, ARK_NORMAL); if (check_retval(&retval, "ARKodeEvolve", 1)) { return 1; } - if (check_ans(y, t, SUN_RCONST(0.001), SUN_RCONST(0.000001))) + if (check_ans(y, t, rtol, atol)) { printf(" Third ARKodeEvolve call had insufficient accuracy\n"); printf(" t = %" GSYM "\n", t); @@ -179,7 +179,7 @@ int main(void) check_retval(&retval, "ARKodeReset", 1); retval = ARKodeEvolve(arkode_mem, t + dTout, y, &t, ARK_NORMAL); if (check_retval(&retval, "ARKodeEvolve", 1)) { return 1; } - if (check_ans(y, t, SUN_RCONST(0.001), SUN_RCONST(0.000001))) + if (check_ans(y, t, rtol, atol)) { printf(" Fourth ARKodeEvolve call had insufficient accuracy\n"); printf(" t = %" GSYM "\n", t); @@ -218,7 +218,7 @@ int main(void) /* Initially evolve to dTout, and check result */ retval = ARKodeEvolve(arkode_mem, t + dTout, y, &t, ARK_NORMAL); if (check_retval(&retval, "ARKodeEvolve", 1)) { return 1; } - if (check_ans(y, t, SUN_RCONST(0.001), SUN_RCONST(0.000001))) + if (check_ans(y, t, rtol, atol)) { printf(" Initial ARKodeEvolve had insufficient accuracy\n"); printf(" t = %" GSYM "\n", t); @@ -236,7 +236,7 @@ int main(void) check_retval(&retval, "ARKodeReset", 1); retval = ARKodeEvolve(arkode_mem, t + dTout, y, &t, ARK_NORMAL); if (check_retval(&retval, "ARKodeEvolve", 1)) { return 1; } - if (check_ans(y, t, SUN_RCONST(0.001), SUN_RCONST(0.000001))) + if (check_ans(y, t, rtol, atol)) { printf(" Second ARKodeEvolve call had insufficient accuracy\n"); printf(" t = %" GSYM "\n", t); @@ -254,7 +254,7 @@ int main(void) check_retval(&retval, "ARKodeReset", 1); retval = ARKodeEvolve(arkode_mem, t + dTout, y, &t, ARK_NORMAL); if (check_retval(&retval, "ARKodeEvolve", 1)) { return 1; } - if (check_ans(y, t, SUN_RCONST(0.001), SUN_RCONST(0.000001))) + if (check_ans(y, t, rtol, atol)) { printf(" Third ARKodeEvolve call had insufficient accuracy\n"); printf(" t = %" GSYM "\n", t); @@ -272,7 +272,7 @@ int main(void) check_retval(&retval, "ARKodeReset", 1); retval = ARKodeEvolve(arkode_mem, t + dTout, y, &t, ARK_NORMAL); if (check_retval(&retval, "ARKodeEvolve", 1)) { return 1; } - if (check_ans(y, t, SUN_RCONST(0.001), SUN_RCONST(0.000001))) + if (check_ans(y, t, rtol, atol)) { printf(" Fourth ARKodeEvolve call had insufficient accuracy\n"); printf(" t = %" GSYM "\n", t); @@ -316,13 +316,13 @@ int main(void) if (check_retval(&retval, "ARKodeSetLinear", 1)) { return 1; } retval = ARKodeSetMaxNumSteps(mristep_mem, 100); check_retval(&retval, "ARKodeSetMaxNumSteps", 1); - retval = ARKodeSetFixedStep(mristep_mem, dTout * SUN_RCONST(0.105)); + retval = ARKodeSetFixedStep(mristep_mem, dTout * SUN_RCONST(0.100)); check_retval(&retval, "ARKodeSetFixedStep", 1); /* Initially evolve to dTout, and check result */ retval = ARKodeEvolve(mristep_mem, t + dTout, y, &t, ARK_NORMAL); if (check_retval(&retval, "ARKodeEvolve", 1)) { return 1; } - if (check_ans(y, t, SUN_RCONST(0.001), SUN_RCONST(0.000001))) + if (check_ans(y, t, rtol, atol)) { printf(" Initial ARKodeEvolve had insufficient accuracy\n"); printf(" t = %" GSYM "\n", t); @@ -340,7 +340,7 @@ int main(void) check_retval(&retval, "ARKodeReset", 1); retval = ARKodeEvolve(mristep_mem, t + dTout, y, &t, ARK_NORMAL); if (check_retval(&retval, "ARKodeEvolve", 1)) { return 1; } - if (check_ans(y, t, SUN_RCONST(0.001), SUN_RCONST(0.000001))) + if (check_ans(y, t, rtol, atol)) { printf(" Second ARKodeEvolve call had insufficient accuracy\n"); printf(" t = %" GSYM "\n", t); @@ -358,7 +358,7 @@ int main(void) check_retval(&retval, "ARKodeReset", 1); retval = ARKodeEvolve(mristep_mem, t + dTout, y, &t, ARK_NORMAL); if (check_retval(&retval, "ARKodeEvolve", 1)) { return 1; } - if (check_ans(y, t, SUN_RCONST(0.001), SUN_RCONST(0.000001))) + if (check_ans(y, t, rtol, atol)) { printf(" Third ARKodeEvolve call had insufficient accuracy\n"); printf(" t = %" GSYM "\n", t); @@ -376,7 +376,7 @@ int main(void) check_retval(&retval, "ARKodeReset", 1); retval = ARKodeEvolve(mristep_mem, t + dTout, y, &t, ARK_NORMAL); if (check_retval(&retval, "ARKodeEvolve", 1)) { return 1; } - if (check_ans(y, t, SUN_RCONST(0.001), SUN_RCONST(0.000001))) + if (check_ans(y, t, rtol, atol)) { printf(" Fourth ARKodeEvolve call had insufficient accuracy\n"); printf(" t = %" GSYM "\n", t); diff --git a/test/unit_tests/utilities/test_utilities.hpp b/test/unit_tests/utilities/test_utilities.hpp new file mode 100644 index 0000000000..e624fefda2 --- /dev/null +++ b/test/unit_tests/utilities/test_utilities.hpp @@ -0,0 +1,108 @@ +/* ----------------------------------------------------------------------------- + * Programmer(s): David J. Gardner @ LLNL + * ----------------------------------------------------------------------------- + * 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 + * ----------------------------------------------------------------------------- + * Utility functions for C++ examples + * ---------------------------------------------------------------------------*/ + +#include +#include +#include + +// Check function return flag +int check_flag(const int flag, const std::string funcname) +{ + if (!flag) return 0; + if (flag < 0) std::cerr << "ERROR: "; + std::cerr << funcname << " returned " << flag << std::endl; + return 1; +} + +// Check if a function returned a NULL pointer +int check_ptr(const void* ptr, const std::string funcname) +{ + if (ptr) return 0; + std::cerr << "ERROR: " << funcname << " returned NULL" << std::endl; + return 1; +} + +inline void find_arg(std::vector& args, const std::string key, + sunrealtype& dest) +{ + auto it = std::find(args.begin(), args.end(), key); + if (it != args.end()) + { +#if defined(SUNDIALS_SINGLE_PRECISION) + dest = stof(*(it + 1)); +#elif defined(SUNDIALS_DOUBLE_PRECISION) + dest = stod(*(it + 1)); +#elif defined(SUNDIALS_EXTENDED_PRECISION) + dest = stold(*(it + 1)); +#endif + args.erase(it, it + 2); + } +} + +inline void find_arg(std::vector& args, const std::string key, + long long& dest) +{ + auto it = std::find(args.begin(), args.end(), key); + if (it != args.end()) + { + dest = stoll(*(it + 1)); + args.erase(it, it + 2); + } +} + +inline void find_arg(std::vector& args, const std::string key, + long int& dest) +{ + auto it = std::find(args.begin(), args.end(), key); + if (it != args.end()) + { + dest = stol(*(it + 1)); + args.erase(it, it + 2); + } +} + +inline void find_arg(std::vector& args, const std::string key, + int& dest) +{ + auto it = std::find(args.begin(), args.end(), key); + if (it != args.end()) + { + dest = stoi(*(it + 1)); + args.erase(it, it + 2); + } +} + +inline void find_arg(std::vector& args, const std::string key, + bool& dest, bool store = true) +{ + auto it = std::find(args.begin(), args.end(), key); + if (it != args.end()) + { + dest = store; + args.erase(it); + } +} + +inline void find_arg(std::vector& args, const std::string key, + std::string& dest) +{ + auto it = std::find(args.begin(), args.end(), key); + if (it != args.end()) + { + dest = *(it + 1); + args.erase(it, it + 2); + } +} From faa4f9126109a98b0d392f637797ebcbb283f2ed Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Thu, 25 Jul 2024 08:39:03 -0500 Subject: [PATCH 002/286] Fixed coefficients for MRI-GARK-ERK45a (from Sandu's corrected manuscript on arXiv) --- src/arkode/arkode_mri_tables.def | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/arkode/arkode_mri_tables.def b/src/arkode/arkode_mri_tables.def index 68220c7a4b..5444070b62 100644 --- a/src/arkode/arkode_mri_tables.def +++ b/src/arkode/arkode_mri_tables.def @@ -181,11 +181,11 @@ ARK_MRI_TABLE(ARKODE_MRI_GARK_ERK45a, { /* A. Sandu, SINUM 57:2300-2327, 2019 */ C->W[0][5][2] = -SUN_RCONST(1360217.0)/SUN_RCONST(1139280.0); C->W[0][5][3] = -SUN_RCONST(148789.0)/SUN_RCONST(56964.0); C->W[0][5][4] = SUN_RCONST(147889.0)/SUN_RCONST(45120.0); - C->W[0][6][0] = -SUN_RCONST(1482837.0)/SUN_RCONST(759520.0); - C->W[0][6][1] = SUN_RCONST(175781.0)/SUN_RCONST(71205.0); - C->W[0][6][2] = -SUN_RCONST(790577.0)/SUN_RCONST(1139280.0); - C->W[0][6][3] = -SUN_RCONST(6379.0)/SUN_RCONST(56964.0); - C->W[0][6][4] = SUN_RCONST(47.0)/SUN_RCONST(96.0); + C->W[0][6][0] = -SUN_RCONST(88227.0)/SUN_RCONST(47470.0); + C->W[0][6][1] = SUN_RCONST(756870829.0)/SUN_RCONST(340217490.0); + C->W[0][6][2] = -SUN_RCONST(713704111.0)/SUN_RCONST(1360869960.0); + C->W[0][6][3] = -SUN_RCONST(31967827.0)/SUN_RCONST(340217490.0); + C->W[0][6][4] = SUN_RCONST(129673.0)/SUN_RCONST(286680.0); C->W[1][2][0] = SUN_RCONST(503.0)/SUN_RCONST(80.0); C->W[1][2][1] = -SUN_RCONST(503.0)/SUN_RCONST(80.0); From 355b87a8cceb12abd0b579512576531dc8fd5357 Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Fri, 26 Jul 2024 10:17:50 -0500 Subject: [PATCH 003/286] Documentation updates --- doc/arkode/guide/source/Mathematics.rst | 448 +++++++++++++----- .../source/Usage/ERKStep/User_callable.rst | 54 ++- .../source/Usage/MRIStep/User_callable.rst | 150 +++--- 3 files changed, 484 insertions(+), 168 deletions(-) diff --git a/doc/arkode/guide/source/Mathematics.rst b/doc/arkode/guide/source/Mathematics.rst index 076c311bb4..9d69b9a842 100644 --- a/doc/arkode/guide/source/Mathematics.rst +++ b/doc/arkode/guide/source/Mathematics.rst @@ -548,7 +548,7 @@ can be ignored). Optionally, a different algorithm leveraging compensated summation can be used that is more robust to roundoff error at the expense of 2 extra vector operations per stage and an additional 5 per time step. It also requires one extra vector to -be stored. However, it is significantly more robust to roundoff error accumulation +be stored. However, it is signficantly more robust to roundoff error accumulation :cite:p:`Sof:02`. When compensated summation is enabled, the following incremental form is used to compute a time step: @@ -605,130 +605,112 @@ nonstiff terms (:math:`f^I \equiv 0`), only stiff terms (:math:`f^E \equiv 0`), or both nonstiff and stiff terms. For cases with only a single slow right-hand side function (i.e., -:math:`f^E \equiv 0` or :math:`f^I \equiv 0`), MRIStep provides fixed-slow-step -multirate infinitesimal step (MIS) :cite:p:`Schlegel:09, Schlegel:12a, -Schlegel:12b` and multirate infinitesimal GARK (MRI-GARK) :cite:p:`Sandu:19` -methods. For problems with an additively split slow right-hand side MRIStep -provides fixed-slow-step implicit-explicit MRI-GARK (IMEX-MRI-GARK) -:cite:p:`ChiRen:21` methods. The slow (outer) method derives from an :math:`s` -stage Runge--Kutta method for MIS and MRI-GARK methods or an additive Runge--Kutta -method for IMEX-MRI-GARK methods. In either case, the stage values and the new -solution are computed by solving an auxiliary ODE with a fast (inner) time -integration method. This corresponds to the following algorithm for a single -step: +:math:`f^E \equiv 0` or :math:`f^I \equiv 0`), MRIStep provides multirate +infinitesimal step (MIS) :cite:p:`Schlegel:09, Schlegel:12a, Schlegel:12b`, +multirate infinitesimal GARK (MRI-GARK) :cite:p:`Sandu:19`, and +multirate exponential Runge--Kutta (MERK) :cite:p:`Luan:20` methods. For +problems with an additively split slow right-hand side, MRIStep +provides implicit-explicit MRI-GARK (IMEX-MRI-GARK) +:cite:p:`ChiRen:21` and implicit-explicit multirate infinitesimal stage-restart +(IMEX-MRI-SR) :cite:p:`Fish:24` methods. Generally, the slow (outer) method for each +family derives from an :math:`s` stage single-rate method: MIS and MRI-GARK methods +derive from explicit or diagonally-implicit Runge--Kutta methods, MERK methods derive +from exponential Runge--Kutta methods, while IMEX-MRI-GARK and IMEX-MRI-SR methods +derive from additive Runge--Kutta methods. In each case, the "infinitesimal" nature +of the multirate methods derives from the fact that slow stages are computed by solving +a set of auxiliary ODEs with a fast (inner) time integration method. Generally speaking, +an :math:`s`-stage method from of each family adheres to the following algorithm for a +single step: #. Set :math:`z_1 = y_{n-1}`. -#. For :math:`i = 2,\ldots,s+1` do: +#. For :math:`i = 2,\ldots,s` do: - #. Let :math:`t_{n,i-1}^S = t_{n-1} + c_{i-1}^S h^S` and - :math:`v(t_{n,i-1}^S) = z_{i-1}`. + #. Either - #. Let :math:`r_i(t) = - \frac{1}{\Delta c_i^S} - \sum\limits_{j=1}^{i-1} \omega_{i,j}(\tau) f^E(t_{n,j}^I, z_j) + - \frac{1}{\Delta c_i^S} - \sum\limits_{j=1}^i \gamma_{i,j}(\tau) f^I(t_{n,j}^I, z_j)` - where :math:`\Delta c_i^S=\left(c^S_i - c^S_{i-1}\right)` and the - normalized time is :math:`\tau = (t - t_{n,i-1}^S)/(h^S \Delta c_i^S)`. + #. evolve a fast IVP - #. For :math:`t \in [t_{n,i-1}^S, t_{n,i}^S]` solve - :math:`\dot{v}(t) = f^F(t, v) + r_i(t)`. + .. math:: + {v}_i'(t) = f^F(t, v_i) + r_i(t) \quad\text{for}\quad t \in [t_{0,i},t_{F,i}] \quad\text{with}\quad v_i(t_{0,i}) = v_{0,i} + :label: MRI_fast_IVP - #. Set :math:`z_i = v(t_{n,i}^S)`. + and let :math:`z_i = v(t_{F,i})`, or -#. Set :math:`y_{n} = z_{s+1}`. + #. perform a standard explicit, diagonally-implicit, or additive Runge--Kutta stage update, -The fast (inner) IVP solve can be carried out using either the ARKStep module -(allowing for explicit, implicit, or ImEx treatments of the fast time scale with -fixed or adaptive steps), or a user-defined integration method (see section -:numref:`ARKODE.Usage.MRIStep.CustomInnerStepper`). + .. math:: + z_i - \gamma_{i,i} h^S f^I(t_{n-1}+c_i^S h^s, z_i) = a_i. + :label: MRI_implicit_solve -The final abscissa is :math:`c^S_{s+1}=1` and the coefficients -:math:`\omega_{i,j}` and :math:`\gamma_{i,j}` are polynomials in time that -dictate the couplings from the slow to the fast time scale; these can be -expressed as in :cite:p:`ChiRen:21` and :cite:p:`Sandu:19` as +#. Set :math:`y_{n} = z_{s}`. -.. math:: - \omega_{i,j}(\tau) = \sum_{k\geq 0} \omega_{i,j}^{\{k\}} \tau^k - \quad\text{and}\quad - \gamma_{i,j}(\tau) = \sum_{k\geq 0} \gamma_{i,j}^{\{k\}} \tau^k, - :label: ARKODE_MRI_coupling +#. (Optional embedded solution) either -and where the tables :math:`\Omega^{\{k\}}\in\mathbb{R}^{(s+1)\times(s+1)}` and -:math:`\Gamma^{\{k\}}\in\mathbb{R}^{(s+1)\times(s+1)}` define the slow-to-fast -coupling for the explicit and implicit components respectively. + #. evolve a fast IVP -For traditional MIS methods, the coupling coefficients are uniquely defined -based on a slow Butcher table :math:`(A^S,b^S,c^S)` having an explicit first -stage (i.e., :math:`c^S_1=0` and :math:`A^S_{1,j}=0` for :math:`1\le j\le s`), -sorted abscissae (i.e., :math:`c^S_{i} \ge c^S_{i-1}` for :math:`2\le i\le s`), -and the final abscissa is :math:`c^S_s \leq 1`. With these properties met, the -coupling coefficients for an explicit-slow method are given as + .. math:: + \tilde{v}'(t) = f^F(t, \tilde{v}) + \tilde{r}(t) \quad\text{for}\quad t \in [\tilde{t}_{0},\tilde{t}_{F}] \quad\text{with}\quad \tilde{v}(\tilde{t}_{0}) = \tilde{v}_{0} + :label: MRI_embedding_fast_IVP -.. math:: - \omega_{i,j}^{\{0\}} = \begin{cases} - 0, & \text{if}\; i=1,\\ - A^S_{i,j} - A^S_{i-1,j}, & \text{if}\; 2\le i\le s,\\ - b^S_j - A^S_{s,j}, & \text{if}\; i=s+1. - \end{cases} - :label: ARKODE_MIS_to_MRI + and let :math:`\tilde{y}_{n} = \tilde{v}(\tilde{t}_{F})`, or -For general slow tables :math:`(A^S,b^S,c^S)` with at least second-order -accuracy, the corresponding MIS method will be second order. However, if this -slow table is at least third order and satisfies the additional condition + #. perform a standard explicit, diagonally-implicit, or additive Runge--Kutta stage update, -.. math:: - \sum_{i=2}^{s} \left(c_i^S-c_{i-1}^S\right) - \left(\mathbf{e}_i+\mathbf{e}_{i-1}\right)^T A^S c^S - + \left(1-c_{s}^S\right) \left( \frac12+\mathbf{e}_{s}^T A^S c^S \right) - = \frac13, - :label: ARKODE_MIS_order3 + .. math:: + \tilde{y}_n - \tilde{\gamma} h^S f^I(t_n, \tilde{y}_n) = \tilde{a}. + :label: MRI_embedding_implicit_solve -where :math:`\mathbf{e}_j` corresponds to the :math:`j`-th column from the -:math:`s \times s` identity matrix, then the overall MIS method will be third -order. +.. note:: -In the above algorithm, when the slow (outer) method has repeated abscissa, i.e. -:math:`\Delta c_i^S = 0` for stage :math:`i`, the fast (inner) IVP can be -rescaled and integrated analytically. In this case the stage is computed as + **MIS**, **MRI-GARK** and **IMEX-MRI-GARK** methods follow the above pattern, with non-overlapping + fast IVP time intervals :math:`[t_{0,i},t_{F,i}] = [t_{n-1}+c_{i-1}h^S, t_{n-1}+c_ih^S]` and + :math:`[\tilde{t}_{0},\tilde{t}_{F}] = [t_{n-1}+c_{s-1}h^S, t_{n}]`, and initial conditions + :math:`v_{0,i}=z_{i-1}` and :math:`\tilde{v}_0=z_{s-1}`. + + **MERK** and **IMEX-MRI-SR** methods evolve the fast IVPs :eq:`MRI_fast_IVP` and :eq:`MRI_embedding_fast_IVP` + on overlapping time intervals :math:`[t_{0,i},t_{F,i}] = [t_{n-1}, t_{n-1}+c_i h^S]` and + :math:`[\tilde{t}_{0},\tilde{t}_{F}] = [t_{n-1}, t_{n}]`, using initial conditions + :math:`v_{0,i}=y_{n-1}` and :math:`\tilde{v}_0=y_{n-1}`. + + **MERK** methods never include the stage updates :eq:`MRI_implicit_solve` or + :eq:`MRI_embedding_implicit_solve`. + + **IMEX-MRI-SR** methods perform *both* the fast IVP evolution (:eq:`MRI_fast_IVP` or + :eq:`MRI_embedding_fast_IVP`) *and* stage update (:eq:`MRI_implicit_solve` + or :eq:`MRI_embedding_implicit_solve`) in every stage (but typically have far fewer + stages than implicit MRI-GARK or IMEX-MRI-GARK methods). -.. math:: - z_i = z_{i-1} - + h^S \sum_{j=1}^{i-1} \left(\sum_{k\geq 0} - \frac{\omega_{i,j}^{\{k\}}}{k+1}\right) f^E(t_{n,j}^S, z_j) - + h^S \sum_{j=1}^i \left(\sum_{k\geq 0} - \frac{\gamma_{i,j}^{\{k\}}}{k+1}\right) f^I(t_{n,j}^S, z_j), - :label: ARKODE_MRI_delta_c_zero -which corresponds to a standard ARK, DIRK, or ERK stage computation depending on -whether the summations over :math:`k` are zero or nonzero. +The specific aspects of the fast IVP forcing function (:math:`r_i(t)` or :math:`\tilde{r}(t)`) +and Runge--Kutta stage coefficient and data (:math:`\gamma_{i,i}`, :math:`\tilde{\gamma}`, +:math:`a_i` and :math:`\tilde{a}`), are determined by the method family (MRI-GARK, MERK, etc.). +Generally, however, the forcing functions and RK stage update data, :math:`r_i(t)`, +:math:`\tilde{r}(t)`, :math:`a_i` and :math:`\tilde{a}`, are constructed using evaluations of +the slow RHS functions :math:`f^E` and :math:`f^I` at preceding stages, :math:`z_j`. +For specific details, please see the references for each method family listed above. + +The fast (inner) IVP solves can be carried out using either the ARKStep module +(allowing for explicit, implicit, or ImEx treatments of the fast time scale with +fixed or adaptive steps), or a user-defined integration method (see section +:numref:`ARKODE.Usage.MRIStep.CustomInnerStepper`). As with standard ARK and DIRK methods, implicitness at the slow time scale is -characterized by nonzero values on or above the diagonal of the matrices -:math:`\Gamma^{\{k\}}`. Typically, MRI-GARK and IMEX-MRI-GARK methods are at -most diagonally-implicit (i.e., :math:`\gamma_{i,j}^{\{k\}}=0` for all -:math:`j>i`). Furthermore, diagonally-implicit stages are characterized as being -"solve-decoupled" if :math:`\Delta c_i^S = 0` when :math:`\gamma_{i,i}^{\{k\}} \ne 0`, -in which case the stage is computed as standard ARK or DIRK update. Alternately, -a diagonally-implicit stage :math:`i` is considered "solve-coupled" if -:math:`\Delta c^S_i \gamma_{i,j}^{\{k\}} \ne 0`, in which -case the stage solution :math:`z_i` is *both* an input to :math:`r(t)` and the -result of time-evolution of the fast IVP, necessitating an implicit solve that -is coupled to the fast (inner) solver. At present, only "solve-decoupled" -diagonally-implicit MRI-GARK and IMEX-MRI-GARK methods are supported. +characterized by nonzero coefficient values :math:`\gamma_{i,i}` or :math:`\tilde{\gamma}`. For problems with only a slow-nonstiff term (:math:`f^I \equiv 0`), MRIStep -provides third and fourth order explicit MRI-GARK methods. In cases with only a -slow-stiff term (:math:`f^E \equiv 0`), MRIStep supplies second, third, and -fourth order implicit solve-decoupled MRI-GARK methods. For applications +provides first through fourth order explicit MRI-GARK methods, as well as explicit MERK methods +of orders two through five. In cases with only a slow-stiff term (:math:`f^E \equiv 0`), MRIStep +supplies first through fourth order implicit MRI-GARK methods. For applications with both stiff and nonstiff slow terms, MRIStep implements third and fourth -order IMEX-MRI-GARK methods. For a complete list of the methods available in +order IMEX-MRI-GARK methods, as well as IMEX-MRI-SR methods of orders two through four. We note +that ImEx methods may also be applied to problems with simpler structure through specification of +either :math:`f^I=0` or :math:`f^E=0`. For a complete list of the methods available in MRIStep see :numref:`ARKODE.Usage.MRIStep.MRIStepCoupling.Tables`. Additionally, users may supply their own method by defining and attaching a coupling table, see :numref:`ARKODE.Usage.MRIStep.MRIStepCoupling` for more information. + .. _ARKODE.Mathematics.Error.Norm: Error norms @@ -790,13 +772,15 @@ time-steppers) is their adaptive control of local truncation error (LTE). At every step, we estimate the local error, and ensure that it satisfies tolerance conditions. If this local error test fails, then the step is recomputed with a reduced step size. To this end, the -Runge--Kutta methods packaged within both the ARKStep and ERKStep -modules admit an embedded solution :math:`\tilde{y}_n`, as shown in -equations :eq:`ARKODE_ARK` and :eq:`ARKODE_ERK`. Generally, these embedded -solutions attain a slightly lower order of accuracy than the computed -solution :math:`y_n`. Denoting the order of accuracy for :math:`y_n` -as :math:`q` and for :math:`\tilde{y}_n` as :math:`p`, most of these -embedded methods satisfy :math:`p = q-1`. These values of :math:`q` +majority of Runge--Kutta methods packaged within both the ARKStep and +ERKStep modules, as well as many of the MRI methods packaged within MRIStep, +admit an embedded solution :math:`\tilde{y}_n`, as shown in +equations :eq:`ARKODE_ARK`, :eq:`ARKODE_ERK`, and +:eq:`MRI_embedding_fast_IVP`-:eq:`MRI_embedding_implicit_solve`. Generally, +these embedded solutions attain a slightly lower order of accuracy than the +computed solution :math:`y_n`. Denoting the order of accuracy for +:math:`y_n` as :math:`q` and for :math:`\tilde{y}_n` as :math:`p`, most of +these embedded methods satisfy :math:`p = q-1`. These values of :math:`q` and :math:`p` correspond to the *global* orders of accuracy for the method and embedding, hence each admit local truncation errors satisfying :cite:p:`HWN:87` @@ -926,6 +910,236 @@ support has been deprecated in favor of the SUNAdaptController class, and will be removed in a future release. +.. _ARKODE.Mathematics.MultirateAdaptivity: + +Multirate time step adaptivity (MRIStep) +---------------------------------------- + +Since multirate applications evolve on multiple time scales, +MRIStep supports additional forms of temporal adaptivity. Specifically, +we consider time steps at two adjacent levels, :math:`h^S > h^F`, where +:math:`h^S` is the step size used by MRIStep, and :math:`h^F` is the +step size used to solve the corresponding fast-time-scale IVPs in +MRIStep, :eq:`MRI_fast_IVP` and :eq:`MRI_embedding_fast_IVP`. + + +.. _ARKODE.Mathematics.MultirateControllers: + +Multirate temporal controls +^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +We consider three categories of temporal controllers that may be used within MRI +methods. The first (and simplest), are "decoupled" controllers, that consist of +two separate single-rate temporal controllers: one that adapts the slow time scale +step size, :math:`h^S`, and the other that adapts the fast time scale step size, +:math:`h^F`. As these ignore any coupling between the two time scales, these +methods should work well for multirate problems where the time scales are somewhat +decoupled, and that errors introduced at one scale do not "pollute" the other. + +The second category of controllers we consider are :math:`h^S-h^F` multirate +controllers that adapt both the slow and fast step sizes simultaneously. We +implement four controllers of this type that were introduced in :cite:p:`Fish:23`: +MRI-CC, MRI-LL, MRI-PI, and MRI-PID. We note that this group of multirate +controllers adapts these values only between slow time steps, and thus individual +"fast" IVP solves over :math:`[t_{0,i},t_{F,i}]` or +:math:`[\tilde{t}_{0},\tilde{t}_{F}]` use fixed step sizes :math:`h^F`. + +The third category of controllers that we provide are :math:`h^S-Tol` multirate +controllers. The basic idea is that at any given time scale, an integrator will +attempt to adapt step sizes to control the *local error* within each step to +achieve a requested tolerance. However, MRI methods must ask another adaptive +fast-scale solver to produce the stage solutions :math:`v_i(t_{F,i})` and +:math:`\tilde{v}(\tilde{t}_{F})`, that result from sub-stepping over fast intervals +:math:`[t_{0,i},t_{F,i}]` or :math:`[\tilde{t}_{0},\tilde{t}_{F}]`, respectively. +Local errors within the fast integrator may accumulate, resulting in an overall +fast-solver error :math:`\varepsilon^f_n` that exceeds the requested tolerance. +If that next-fastest solver can produce *both* :math:`v_i(t_{F,i})` and +an estimation of the accumulated error, :math:`\varepsilon^f_{n,approx}`, then the +tolerances provided to that next-fastest solver can be adjusted accordingly to +ensure stage solutions that are within the overall tolerances requested of the MRI +method. + +To this end, we assume that the next-fastest solver will provide accumulated errors +over each fast interval having the form + +.. math:: + \varepsilon^f_{n} = c(t_n) \left(\text{reltol}_n^f\right) \left(t_{F,i}-t_{0,i}\right), + :label: fast_error_accumulation_assumption + +where :math:`c(t)` is independent of the tolerance or subinterval width, but may vary in time. +Single-scale adaptive controllers assume that the local error at a step :math:`n` with step +size :math:`h^S` has order :math:`p`, i.e., + +.. math:: + LTE_n = c(t_n) (h^S)^p, + +to predict candidate values :math:`h^S_{n+1}`. We may therefore repurpose an existing single-scale controller to predict candidate values :math:`\text{reltol}^f_{n+1}` by +supplying an "order" :math:`p=1` and a "control parameter" :math:`h^S_n=\left(\text{reltol}_n^f\right) \left(t_{F,i}-t_{0,i}\right)`, and scaling +the output by the subinterval width. + +Thus to construct an :math:`h^S-Tol` controller, we require three separate single-rate +adaptivity controllers: + +* scontrol-H -- this is a single-rate controller that adapts :math:`h^S_n` within the + slow integrator to achieve user-requested solution tolerances. + +* scontrol-Tol -- this is a single-rate controller that adapts :math:`\text{reltol}^f_n` using the strategy described above. + +* fcontrol -- this adapts time steps :math:`h^F` within the fast integrator to achieve the current tolerance, :math:`\text{reltol}^f_n`. + +We note that of the three classes of controllers considered here, the :math:`h^S-h^F` controllers are only amenable to problems with two time scales. On the other hand, both the decoupled and :math:`h^S-Tol` controllers may be used in multirate calculations with an arbitrary number of time scales, since these focus on only one scale at a time, or on how a given time scale relates to the next-faster scale. + + +.. _ARKODE.Mathematics.MultirateInitialSteps: + +Initial multirate step size estimation +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +Before time step adaptivity can be accomplished, an initial step must be taken. As is +typical with adaptive methods, the first step should be chosen conservatively to ensure +that it succeeds both in its internal solver algorithms, and its eventual temporal error +test. However, if this initial step is too conservative then its computational cost will +essentially be wasted. We thus strive to construct a conservative step that will succeed +while also progressing toward the eventual solution. + +In MRI methods, initial time step selection is complicated by the fact that not only must +an initial slow step size, :math:`h_0^S`, be chosen, but a smaller initial step, +:math:`h_0^F`, must also be selected. Additionally, it is typically assumed that within +MRI methods, evaluation of :math:`f^S` is significantly more costly than evaluation of :math:`f^f`, and thus we wish to construct these initial steps accordingly. + +Before examining MRI initial time step estimation, we first summarize two common +approaches to initial step size selection. To this end, consider a simple +single-time-scale ODE, + +.. math:: + y'(t) = f(t,y), \quad y(t_0) = y_0 + :label: IVP_single + +For this, we may consider two Taylor series expansions of :math:`y(t_0+h^S)` around the +initial time, + +.. math:: + y(t_0+h^S) = y_0 + h^S f(t_0,y_0) + \frac{(h^S)^2}{2} \frac{\mathrm d}{\mathrm dt} f(t_0+\tau,y_0+\eta),\\ + :label: TSExp1 + +and + +.. math:: + y(t_0+h^S) = y_0 + h^S f(t_0+\tau,y_0+\eta), + :label: TSExp0 + +where :math:`t_0+\tau` is between :math:`t_0` and :math:`t_0+h^S`, and :math:`y_0+\eta` +is on the line segment connecting :math:`y_0` and :math:`y(t_0+h^S)`. + +Initial step size estimation based on the first-order Taylor expansion :eq:`TSExp1` +typically attempts to determine a step size such that an explicit Euler method +for :eq:`IVP_single` would be sufficiently accurate, i.e., + +.. math:: + \|y(t_0+h^S_0) - \left(y_0 + h^S_0 f(t_0,y_0)\right)\| \approx \left\|\frac{(h^S)^2}{2} \frac{\mathrm d}{\mathrm dt} f(t_0,y_0)\right\| < 1, + +where we have assumed that :math:`y(t)` is sufficiently differentiable, and that the +norms include user-specified tolerances such that an error with norm less than one is +deemed "acceptable." Satisfying this inequality with a value of :math:`\frac12` and +solving for :math:`h^S_0`, we have + +.. math:: + |h^S_0| = \frac{1}{\left\|\frac{\mathrm d}{\mathrm dt} f(t_0,y_0)\right\|^{1/2}}. + +Finally, by estimating the time derivative via use of finite-differences, + +.. math:: + \frac{\mathrm d}{\mathrm dt} f(t_0,y_0) \approx \frac{1}{\delta t} \left(f(t_0+\delta t,y_0+\delta t f(t_0,y_0)) - f(t_0,y_0)\right), + +we obtain + +.. math:: + |h^S_0| = \frac{(\delta t)^{1/2}}{\|f(t_0+\delta t,y_0+\delta t f(t_0,y_0)) - f(t_0,y_0)\|^{1/2}}. + :label: H0_TSExp1 + +Initial step size estimation based on the simpler Taylor expansion :eq:`TSExp0` +instead assumes that the first calculated time step should be "close" to the +initial state, + +.. math:: + &\|y(t_0+h^S_0) - y_0 \| \approx \left\|h^S_0 f(t_0,y_0)\right\| < 1,\\ + \Rightarrow\quad&\\ + &|h^S_0| = \frac{1}{2\left\| f(t_0,y_0)\right\|}, + :label: H0_TSExp0 + +where we again satisfy the inequality with a value of :math:`\frac12`. + +Comparing the two estimates :eq:`H0_TSExp0` and :eq:`H0_TSExp1`, we see that the +former has double the number of :math:`f` evaluations, but that it has a less +conservative estimate of :math:`h^S_0`, particularly since we expect any valid +time integration method to have at least :math:`\mathcal{O}(h^S)` accuracy. + +Under an assumption that conservative steps will be selected for both time scales, +the error arising from temporal coupling between the slow and fast methods may be +negligible. Thus, we estimate initial values of :math:`h^S_0` and :math:`h^F_0` +independently. Due to our assumed higher cost of :math:`f^s`, then for the slow +time scale we employ the initial estimate :eq:`H0_TSExp0` for :math:`h^S_0` using +:math:`f = f^s`. Since the function :math:`f^f` is assumed to be cheaper, we +instead apply the estimate :eq:`H0_TSExp1` for :math:`h^F_0` using :math:`f=f^f`, +and enforce an upper bound :math:`|h^F_0| \le \frac{|h^S_0|}{10}`. + +.. note:: + + If the fast integrator does not supply its "full RHS function" :math:`f^f` + for the MRI method to call, then we simply initialize :math:`h^F_0 = \frac{h^S_0}{100}`. + +.. _ARKODE.Mathematics.MultirateFastError: + +Fast temporal error estimation +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +MRI temporal adaptivity requires estimation of the temporal errors that +arise at *both* the slow and fast time scales, which we denote here as +:math:`\varepsilon^s` and :math:`\varepsilon^f`, respectively. While the +slow error may be estimated as :math:`\varepsilon^s = \|y_n - \tilde{y}_n\|`, +non-intrusive approaches for estimating :math:`\varepsilon^f` are more +challenging. ARKODE provides three strategies within ARKODE to help provide +this estimate. The first two assume that at each sub-step of the fast +integrator :math:`t_{n,m}`, the method computes an estimate of the local +temporal error, :math:`\varepsilon^f_{n,m}` (this typically results from its +own time step solution and embedding), and that the fast integrator itself is +temporally adaptive. In this case, we assume that the fast integrator was +run with the same absolute tolerances as the slow integrator, but that it may +have used a potentially different relative solution tolerance, :math:`\text{reltol}^f`. +The fast integrator then accumulates these local error estimates using either +a "maximum accumulation: strategy, + +.. math:: + \varepsilon^f_{max} = \text{reltol}^f \max_{m\in M} \|\varepsilon^f_{n,m}\|_{WRMS}, + :label: maximum_accumulation + +or using an "averaged accumulation" strategy, + +.. math:: + \varepsilon^f_{avg} = \frac{\text{reltol}^f}{|M|} \sum_{m\in M} \|\varepsilon^f_{n,m}\|_{WRMS}, + :label: average_accumulation + +where the norm is taken using the tolerance-informed error-weight vector. In +both cases, the sum or the maximum is taken over the set of all steps :math:`M` +since the fast error accumulator has been reset. + +The third, "full step accumulation," approach for fast error estimation uses +fixed time steps of size :math:`h^F` and :math:`2h^F` to achieve fast solutions +:math:`y_{h^f}^f` and :math:`y_{sh^f}^f`, which it then subtracts to estimate +the fast temporal error + +.. math:: + \varepsilon^f_{full} = \text{reltol}^f \|y_h^f - y_{2h}^f\|_{WRMS}. + :label: full_step_accumulation + + +We note here that the factor "2" is the default for the full step accumulation +strategy, but alternate values may be specified by the user. +Here, although the fast integrator is run using fixed step sizes, it is still +provided with appropriate relative and absolute tolerances, as these are used +when determining implicit algebraic solver norms and tolerances within the fast +integrator. + @@ -1011,7 +1225,8 @@ information. In this mode, all internal time step adaptivity is disabled: size by default. .. note:: - Fixed-step mode is currently required for the slow time scale in the MRIStep module. + Any methods that do not provide embedding coefficients (ERK, DIRK, ARK, + or MRI) are required to be run in fixed-step mode. Additional information on this mode is provided in the section @@ -1048,8 +1263,9 @@ Nonlinear solver methods For the DIRK and ARK methods corresponding to :eq:`ARKODE_IMEX_IVP` and -:eq:`ARKODE_IVP_implicit` in ARKStep, and the solve-decoupled implicit slow -stages :eq:`ARKODE_MRI_delta_c_zero` in MRIStep, an implicit system +:eq:`ARKODE_IVP_implicit` in ARKStep, and the implicit slow stages +:eq:`MRI_implicit_solve` or :eq:`MRI_embedding_implicit_solve` in MRIStep, +an implicit system .. math:: G(z_i) = 0 @@ -1113,18 +1329,34 @@ based on the type of mass-matrix supplied by the user. As above, this form of the residual is chosen to remove excessive mass-matrix solves from the nonlinear solve process. -* Similarly, in MRIStep (that always assumes :math:`M=I`), we have the residual +* Similarly, in MRIStep (that always assumes :math:`M=I`), MRI-GARK and IMEX-MRI-GARK methods + have the residual .. math:: G(z_i) \equiv z_i - h^S \left(\sum_{k\geq 0} \frac{\gamma_{i,i}^{\{k\}}}{k+1}\right) f^I(t_{n,i}^S, z_i) - a_i = 0 - :label: ARKODE_MRIStep_Residual + :label: ARKODE_IMEX-MRI-GARK_Residual where .. math:: a_i \equiv z_{i-1} + h^S \sum_{j=1}^{i-1} \left(\sum_{k\geq 0} - \frac{\gamma_{i,j}^{\{k\}}}{k+1}\right)f^I(t_{n,j}^S, z_j). + \frac{\gamma_{i,j}^{\{k\}}}{k+1}\right)f^I(t_{n,j}^S, z_j), + + and the tables :math:`\Omega^{\{k\}}` and :math:`\Gamma^{\{k\}}` store the slow-to-fast coupling + coefficients for the explicit and implicit components, respectively. Similarly, IMEX-MRI-SR + methods have the residual + + .. math:: + G(z_i) \equiv z_i - h^S \gamma_{i,i} f^I(t_{n,i}^S, z_i) - a_i = 0 + :label: ARKODE_IMEX-MRI-SR_Residual + + where + + .. math:: + a_i \equiv z_{i-1} + h^S \sum_{j=1}^{i-1} \gamma_{i,j} f^I(t_{n,j}^S, z_j), + + and where the table :math:`\Gamma` stores the slow implicit stage coefficients. Upon solving for :math:`z_i`, method stages must store diff --git a/doc/arkode/guide/source/Usage/ERKStep/User_callable.rst b/doc/arkode/guide/source/Usage/ERKStep/User_callable.rst index 5bbb3e1f63..6b6107781c 100644 --- a/doc/arkode/guide/source/Usage/ERKStep/User_callable.rst +++ b/doc/arkode/guide/source/Usage/ERKStep/User_callable.rst @@ -1780,9 +1780,9 @@ Main solver optional output functions typedef struct ARKodeButcherTableMem { - int q; /* method order of accuracy */ - int p; /* embedding order of accuracy */ - int stages; /* number of stages */ + int q; /* method order of accuracy */ + int p; /* embedding order of accuracy */ + int stages; /* number of stages */ sunrealtype **A; /* Butcher table coefficients */ sunrealtype *c; /* canopy node coefficients */ sunrealtype *b; /* root node coefficients */ @@ -2157,3 +2157,51 @@ ERKStep system resize function .. deprecated:: 6.1.0 Use :c:func:`ARKodeResize` instead. + + +.. _ERKStep_CInterface.MRIStepInterface: + +Interfacing with MRIStep +------------------------ + +When using ERKStep as the inner (fast) integrator with MRIStep, the +utility function :c:func:`ERKStepCreateMRIStepInnerStepper` should be used to +wrap an ERKStep memory block as an :c:type:`MRIStepInnerStepper`. + +.. c:function:: int ERKStepCreateMRIStepInnerStepper(void *inner_arkode_mem, MRIStepInnerStepper *stepper) + + Wraps an ERKStep memory block as an :c:type:`MRIStepInnerStepper` for use + with MRIStep. + + **Arguments:** + * *arkode_mem* -- pointer to the ERKStep memory block. + * *stepper* -- the :c:type:`MRIStepInnerStepper` object. + + **Return value:** + * *ARK_SUCCESS* if successful + * *ARK_MEM_FAIL* if a memory allocation failed + * *ARK_ILL_INPUT* if an argument has an illegal value. + + **Example usage:** + .. code-block:: C + + /* fast (inner) and slow (outer) ARKODE objects */ + void *inner_arkode_mem = NULL; + void *outer_arkode_mem = NULL; + + /* MRIStepInnerStepper to wrap the inner (fast) ERKStep object */ + MRIStepInnerStepper stepper = NULL; + + /* create an ERKStep object, setting fast (inner) right-hand side + functions and the initial condition */ + inner_arkode_mem = ERKStepCreate(ff, t0, y0, sunctx); + + /* setup ERKStep */ + . . . + + /* create MRIStepInnerStepper wrapper for the ARKStep memory block */ + flag = ERKStepCreateMRIStepInnerStepper(inner_arkode_mem, &stepper); + + /* create an MRIStep object, setting the slow (outer) right-hand side + functions and the initial condition */ + outer_arkode_mem = MRIStepCreate(fse, fsi, t0, y0, stepper, sunctx) diff --git a/doc/arkode/guide/source/Usage/MRIStep/User_callable.rst b/doc/arkode/guide/source/Usage/MRIStep/User_callable.rst index 6424e09793..3ff8c3f526 100644 --- a/doc/arkode/guide/source/Usage/MRIStep/User_callable.rst +++ b/doc/arkode/guide/source/Usage/MRIStep/User_callable.rst @@ -178,6 +178,99 @@ MRIStep tolerance specification functions +.. _ARKODE.Usage.MRIStep.StepAdaptivity: + +Multirate temporal adaptivity specification functions +------------------------------------------------------ + +As described in Section :numref:`ARKODE.Mathematics.MultirateAdaptivity`, MRIStep +supports additional forms of temporal adaptivity due to its evolution of multiple +time scales. + +For the simplest form of multirate temporal adaptivity, corresponding to +"decoupled" multirate control, users should merely specify a single-rate +controller to MRIStep using the :c:func:`ARKodeSetAdaptController` function. +The time step controller for the inner integrator may be specified independently. + +However, specification of either the :math:`h^S-h^F` or :math:`h^S-Tol` types of +multirate controllers requires additional steps. + +First, a SUNAdaptController with :c:type:`SUNAdaptController_Type` type either +``SUN_ADAPTCONTROLLER_MRI_H`` or ``SUN_ADAPTCONTROLLER_MRI_TOL`` should be +constructed, following the documentation in Section :numref:`SUNAdaptController`. +This controller should then be passed as an input to the MRIStep function +:c:func:`MRIStepSetAdaptController`, as follows. + + +.. c:function:: int MRIStepSetAdaptController(void* arkode_mem, SUNAdaptController C) + + Sets a user-supplied multirate time-step controller object. + + :param arkode_mem: pointer to the MRIStep memory block. + :param C: user-supplied time adaptivity controller. If ``NULL`` then this routine + will just call :c:func:`ARKodeSetAdaptController` to specify that the + default ARKODE controller should be created. + + :retval ARK_SUCCESS: the function exited successfully. + :retval ARK_MEM_NULL: ``arkode_mem`` was ``NULL``. + :retval ARK_MEM_FAIL: *C* was ``NULL`` and a default controller could not be allocated. + + .. note:: + + If the input *C* has :c:type:`SUNAdaptController_Type` type ``SUN_ADAPTCONTROLLER_MRI_H`` + or ``SUN_ADAPTCONTROLLER_MRI_TOL`` then this creates an MRIStep-specific adaptivity + controller that couples the slow and fast time scales, and that leverages *C* to perform + multirate temporal adaptivity. + + If *C* has :c:type:`SUNAdaptController_Type` type ``SUN_ADAPTCONTROLLER_H`` + or ``SUN_ADAPTCONTROLLER_NONE`` then this routine merely passes *C* to the ARKODE-level + routine :c:func:`ARKodeSetAdaptController`. + + .. versionadded:: x.y.z + + +Second, if the multirate controller had type ``SUN_ADAPTCONTROLLER_MRI_H``, then fast time +scale error will be estimated using the "full step accumulation" strategy described in +Section :numref:`ARKODE.Mathematics.MultirateFastError`, where by default the fast integrator +is called with step sizes :math:`h^F` and :math:`2h^F`. If the user wishes to adjust the +factor "2" to something else, they may call the function :c:func:`MRIStepSetFastErrorStepFactor`, +as follows. + +.. c:function:: int MRIStepSetFastErrorStepFactor(void* arkode_mem, sunrealtype hfactor) + + This function specifies a time step factor + + If this value is nonzero and MRI temporal adaptivity is enabled, then MRIStep will + compute the fast temporal error using the "full step accumulation" stragegy (see + Section :numref:`ARKODE.Mathematics.MultirateFastError`). Here, the fast integrator + is run twice over each fast time interval, once using the inner step size ``h``, and + again using ``hfactor*h`` (typically ``hfactor`` will be either :math:`k` or + :math:`1/k` for an integer :math:`k>1`). This routine should only be used when the + results from the fast-integrator-provided :c:type:`MRIStepInnerGetAccumulatedError` + cannot be trusted. In testing, we found this to be the case when the inner integrator + uses fixed step sizes. + + An argument of 0 disables this fast error estimation strategy. + Arguments less than zero or exactly equal to one are illegal. + All other positive ``hfactor`` values will *attempt* to be used. + + :param arkode_mem: pointer to the MRIStep memory block. + :param hfactor: user-supplied fast stepsize factor. + + :retval ARK_SUCCESS: the function exited successfully. + :retval ARK_MEM_NULL: ``arkode_mem`` was ``NULL``. + :retval ARK_ILL_INPUT: the value of ``hfactor`` was illegal. + + .. note:: + + This routine should only be called directly when using a "multirate" + :c:type:`SUNAdaptController` of type ``SUN_ADAPTCONTROLLER_MRI_H``. + + .. versionadded:: x.y.z + + + + .. _ARKODE.Usage.MRIStep.LinearSolvers: Linear solver interface functions @@ -424,63 +517,6 @@ Optional inputs for MRIStep ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -.. c:function:: int MRIStepSetAdaptController(void* arkode_mem, SUNAdaptController C) - - Sets a user-supplied multirate time-step controller object. - - :param arkode_mem: pointer to the ARKODE memory block. - :param C: user-supplied time adaptivity controller. If ``NULL`` then this routine - will just call :c:func:`ARKodeSetAdaptController` to specify that the - default ARKODE controller should be created. - - :retval ARK_SUCCESS: the function exited successfully. - :retval ARK_MEM_NULL: ``arkode_mem`` was ``NULL``. - :retval ARK_MEM_FAIL: *C* was ``NULL`` and the PID controller could not be allocated. - :retval ARK_STEPPER_UNSUPPORTED: adaptive step sizes are not supported - by the current time-stepping module. - - .. note:: - - This routine should only be called directly when using a "multirate" - :c:type:`SUNAdaptController`, i.e., one with type ``SUN_ADAPTCONTROLLER_MRI_H`` - or ``SUN_ADAPTCONTROLLER_MRI_TOL``. Otherwise, it is more efficient to call - :c:func:`ARKodeSetAdaptController` directly. - - .. versionadded:: x.y.z - - -.. c:function:: int MRIStepSetFastErrorStepFactor(void* arkode_mem, sunrealtype hfactor) - - Specifies a fast stepsize factor for MRIStep to use within a "brute force" fast - time scale error estimation strategy. If this value is nonzero and MRI temporal - adaptivity is enabled, then the fast integrator is run twice over each fast time - interval, once using the inner step size ``h``, and again using ``hfactor*h`` - (typically ``hfactor`` will be either :math:`k` or :math:`1/k` for an integer - :math:`k>1`). This is only needed when the results from the fast-integrator-provided - :c:type:`MRIStepInnerGetAccumulatedError` cannot be trusted. In testing, we found - this to be the case when the inner integrator uses fixed step sizes. - - An argument of 0 disables this fast error estimation strategy. - Arguments less than zero or exactly equal to one are illegal. - All other positive ``hfactor`` values will *attempt* to be used. - - :param arkode_mem: pointer to the ARKODE memory block. - :param hfactor: user-supplied fast stepsize factor. - - :retval ARK_SUCCESS: the function exited successfully. - :retval ARK_MEM_NULL: ``arkode_mem`` was ``NULL``. - :retval ARK_ILL_INPUT: the value of ``hfactor`` was illegal. - - .. note:: - - This routine should only be called directly when using a "multirate" - :c:type:`SUNAdaptController` of type ``SUN_ADAPTCONTROLLER_MRI_H``. - - .. versionadded:: x.y.z - - - - .. c:function:: int MRIStepSetDefaults(void* arkode_mem) Resets all optional input parameters to MRIStep's original From ce22dffdf336b9a2565a334615f8f14db2a0e964 Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Fri, 26 Jul 2024 11:05:11 -0500 Subject: [PATCH 004/286] Documentation updates --- CHANGELOG.md | 8 ++--- .../Custom_Inner_Stepper/Description.rst | 8 ++--- .../guide/source/Usage/User_callable.rst | 6 ++-- doc/shared/RecentChanges.rst | 8 ++--- doc/shared/sundials.bib | 31 +++++++++++++++++++ 5 files changed, 44 insertions(+), 17 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 47e9f31db6..42fea6811c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,11 +9,9 @@ Added Multirate time step adaptivity controllers, based on the recently introduced `SUNAdaptController` base class, to ARKODE's MRIStep module. -Added functionality to ARKStep and ERKStep to accumulate a temporal error -estimate over multiple time steps. See the routines `ARKStepSetAccumulatedErrorType`, -`ARKStepResetAccumulatedError`, `ARKStepGetAccumulatedError`, -`ERKStepSetAccumulatedErrorType`, `ERKStepResetAccumulatedError`, -and `ERKStepGetAccumulatedError` for details. +Added functionality to ARKODE to accumulate a temporal error +estimate over multiple time steps. See the routines `ARKodeSetAccumulatedErrorType`, +`ARKodeResetAccumulatedError`, and `ARKodeGetAccumulatedError` for details. ### Bug Fixes diff --git a/doc/arkode/guide/source/Usage/MRIStep/Custom_Inner_Stepper/Description.rst b/doc/arkode/guide/source/Usage/MRIStep/Custom_Inner_Stepper/Description.rst index ec100d56c2..9cabb9a79f 100644 --- a/doc/arkode/guide/source/Usage/MRIStep/Custom_Inner_Stepper/Description.rst +++ b/doc/arkode/guide/source/Usage/MRIStep/Custom_Inner_Stepper/Description.rst @@ -498,7 +498,7 @@ following member functions: **Notes:** This function is only called when multirate temporal adaptivity has been enabled, - using a :c:type:`SUNControl` module having type ``SUNDIALS_CONTROL_MRI_H`` or + using a :c:type:`SUNAdaptController` module having type ``SUNDIALS_CONTROL_MRI_H`` or ``SUNDIALS_CONTROL_MRI_TOL``. If provided, the :c:type:`MRIStepInnerGetAccumulatedError` function will always @@ -524,7 +524,7 @@ following member functions: **Notes:** This function is only called when multirate temporal adaptivity has been enabled, - using a :c:type:`SUNControl` module having type ``SUNDIALS_CONTROL_MRI_H`` or + using a :c:type:`SUNAdaptController` module having type ``SUNDIALS_CONTROL_MRI_H`` or ``SUNDIALS_CONTROL_MRI_TOL``. The :c:type:`MRIStepInnerResetAccumulatedError` function will always be called @@ -554,7 +554,7 @@ following member functions: **Notes:** This function is only called when multirate temporal adaptivity has been enabled - using a :c:type:`SUNControl` module having type ``SUNDIALS_CONTROL_MRI_H``. + using a :c:type:`SUNAdaptController` module having type ``SUNDIALS_CONTROL_MRI_H``. .. c:type:: int (*MRIStepInnerSetRTol)(MRIStepInnerStepper stepper, sunrealtype rtol) @@ -572,7 +572,7 @@ following member functions: **Notes:** This function is only called when multirate temporal adaptivity has been enabled - using a :c:type:`SUNControl` module having type ``SUNDIALS_CONTROL_MRI_TOL``. + using a :c:type:`SUNAdaptController` module having type ``SUNDIALS_CONTROL_MRI_TOL``. It is assumed that if the inner stepper supports absolute tolerances as well, then these have been set up directly by the user to indicate the "noise" level for diff --git a/doc/arkode/guide/source/Usage/User_callable.rst b/doc/arkode/guide/source/Usage/User_callable.rst index b235c4e7d2..0b72f94a50 100644 --- a/doc/arkode/guide/source/Usage/User_callable.rst +++ b/doc/arkode/guide/source/Usage/User_callable.rst @@ -970,8 +970,8 @@ Set max number of constraint failures :c:func:`ARKodeSetMaxNumConstr Disabling interpolation will reduce the memory footprint of an integrator by two or more state vectors (depending on the interpolant type and degree) which can be beneficial when interpolation is not needed e.g., when - integrating to a final time without output in between or using ARKStep as an - explicit fast time scale integrator with MRI methods. + integrating to a final time without output in between or using a solver from + ARKODE as a fast time scale integrator with MRI methods. This routine frees any previously-allocated interpolation module, and re-creates one according to the specified argument. @@ -3628,7 +3628,7 @@ Retrieve the accumulated temporal error estimate :c:func:`ARKodeGetAccumul .. versionadded:: 6.1.0 -.. c:function:: int ARKStepGetAccumulatedError(void* arkode_mem, sunrealtype* accum_error) +.. c:function:: int ARKodeGetAccumulatedError(void* arkode_mem, sunrealtype* accum_error) Returns the accumulated temporal error estimate. diff --git a/doc/shared/RecentChanges.rst b/doc/shared/RecentChanges.rst index 183b793459..42956d0600 100644 --- a/doc/shared/RecentChanges.rst +++ b/doc/shared/RecentChanges.rst @@ -5,11 +5,9 @@ Added Multirate time step adaptivity controllers, based on the recently introduced `SUNAdaptController` base class, to ARKODE's MRIStep module. -Added functionality to ARKStep and ERKStep to accumulate a temporal error -estimate over multiple time steps. See the routines :c:func:`ARKStepSetAccumulatedErrorType`, -:c:func:`ARKStepResetAccumulatedError`, :c:func:`ARKStepGetAccumulatedError`, -:c:func:`ERKStepSetAccumulatedErrorType`, :c:func:`ERKStepResetAccumulatedError`, -and :c:func:`ERKStepGetAccumulatedError` for details. +Added functionality to ARKODE to accumulate a temporal error +estimate over multiple time steps. See the routines :c:func:`ARKodeSetAccumulatedErrorType`, +:c:func:`ARKodeResetAccumulatedError`, and :c:func:`ARKodeGetAccumulatedError` for details. **Bug Fixes** diff --git a/doc/shared/sundials.bib b/doc/shared/sundials.bib index 1f9d585a91..1a3e3a1947 100644 --- a/doc/shared/sundials.bib +++ b/doc/shared/sundials.bib @@ -1845,6 +1845,26 @@ @techreport{Fehlberg:69 year = {1969} } +@article{Fish:23, + title = {Adaptive time step control for multirate infinitesimal methods}, + volume = {45}, + doi = {10.1137/22M1479798}, + number = {2}, + journal = {SIAM Journal of Scientific Computing}, + author = {Fish, Alex C. and Reynolds, Daniel R.}, + year = {2023}, + pages = {A958--A984}, +} + +@article{Fish:24, + title = {Implicit–explicit multirate infinitesimal stage-restart methods}, + volume = {438}, + doi = {10.1016/j.cam.2023.115534}, + journal = {Journal of Computational and Applied Mathematics}, + author = {Fish, Alex C. and Reynolds, Daniel R. and Roberts, Steven B.}, + year = {2024}, + pages = {115534}, +} @article{giraldo2013implicit, title = {Implicit-explicit formulations of a three-dimensional nonhydrostatic unified model of the atmosphere (NUMA)}, @@ -1941,6 +1961,17 @@ @article{Kva:04 doi = {10.1023/B:BITN.0000046811.70614.38} } +@article{Luan:20, + title = {A new class of high-order methods for multirate differential equations}, + volume = {42}, + doi = {10.1137/19M125621X}, + number = {2}, + journal = {SIAM Journal of Scientific Computing}, + author = {Luan, Vu Thai and Chinomona, Rujeko and Reynolds, Daniel R.}, + year = {2020}, + pages = {A1245--A1268}, +} + @article{Mclachlan:92, author = {Mclachlan, Robert I AND Atela, Pau}, title = {The accuracy of symplectic integrators}, From c734e81ccfcb346dc8d145abc5a6d6349a150869 Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Fri, 26 Jul 2024 11:17:13 -0500 Subject: [PATCH 005/286] Documentation updates --- .../source/Usage/MRIStep/MRIStepCoupling.rst | 51 +++++++++++++++---- 1 file changed, 41 insertions(+), 10 deletions(-) diff --git a/doc/arkode/guide/source/Usage/MRIStep/MRIStepCoupling.rst b/doc/arkode/guide/source/Usage/MRIStep/MRIStepCoupling.rst index 2f4622374f..ab6a78eb84 100644 --- a/doc/arkode/guide/source/Usage/MRIStep/MRIStepCoupling.rst +++ b/doc/arkode/guide/source/Usage/MRIStep/MRIStepCoupling.rst @@ -196,7 +196,7 @@ are defined ``arkode/arkode_mristep.h``. .. c:function:: MRIStepCoupling MRIStepCoupling_MIStoMRI(ARKodeButcherTable B, int q, int p) Creates an MRI coupling table for a traditional MIS method based on the slow - Butcher table *B*, following the formula shown in :eq:`ARKODE_MIS_to_MRI` + Butcher table *B*. :param B: the :c:type:`ARKodeButcherTable` for the "slow" MIS method. :param q: the overall order of the MIS/MRI method. @@ -208,14 +208,45 @@ are defined ``arkode/arkode_mristep.h``. .. note:: The :math:`s`-stage slow Butcher table must have an explicit first stage - (i.e., :math:`c_1=0` and :math:`A_{1,j}=0` for :math:`1\le j\le s`) and - sorted abscissae (i.e., :math:`c_{i} \ge c_{i-1}` for :math:`2\le i\le s`). + (i.e., :math:`c_1=0` and :math:`A_{1,j}=0` for :math:`1\le j\le s`), + sorted abscissae (i.e., :math:`c_{i} \ge c_{i-1}` for :math:`2\le i\le s`), + and a final abscissa value :math:`c_s \le 1`. In this case, the + :math:`(s+1)`-stage coupling table is computed as - Since an MIS method is at most third order accurate, and even then only if - it meets certain compatibility criteria (see :eq:`ARKODE_MIS_order3`), the values - of *q* and *p* may differ from the method and embedding orders of accuracy - for the Runge--Kutta method encoded in *B*, which is why these arguments - should be supplied separately. + .. math:: + + \omega_{i,j}^{\{0\}} \;\text{or}\; \gamma_{i,j}^{\{0\}} = \begin{cases} + 0, & \text{if}\; i=1,\\ + A_{i,j}-A_{i-1,j}, & \text{if}\; 2\le i\le s,\\ + b_{j}-A_{s,j}, & \text{if}\; i= s+1. + \end{cases} + + and the embedding coefficients (if applicable) are computed as + + .. math:: + + \tilde{\omega}_{i,j}^{\{0\}} \;\text{or}\; \tilde{\gamma}_{i,j}^{\{0\}} = \tilde{b}_{j}-A_{s,j}. + + We note that only one of :math:`\Omega^{\{0\}}` or :math:`\Gamma^{\{0\}}` will + be filled in. If *B* corresponded to an explicit method, then this routine + fills :math:`\Omega^{\{0\}}`; if *B* is diagonally-implicit, then this routine + inserts redundant "padding" stages to ensure a solve-decoupled structure and + then uses the above formula to fill :math:`\Gamma^{\{0\}}`. + + For general slow tables with a least second-order accuracy, the MIS method will + be second order. However, if the slow table is at least third order and + additionally satisfies + + .. math:: + + \sum_{i=2}^s (c_i-c_{i-1})(\mathbf{e}_i+\mathbf{e}_{i-1})^T A c + (1-c_s) \left(\frac12 + \mathbf{e}_s^T A c\right) = \frac13, + + where :math:`\mathbf{e}_j` corresponds to the :math:`j`-th column from the + :math:`s \times s` identity matrix, then the overall MIS method will be third order. + + As a result, the values of *q* and *p* may differ from the method and + embedding orders of accuracy for the Runge--Kutta method encoded in *B*, + which is why these arguments should be supplied separately. If *p>0* is input, then the table *B* must include embedding coefficients. @@ -297,10 +328,10 @@ with values specified for each method below (e.g., ``ARKODE_MIS_KW3``). ``ARKODE_MRI_GARK_FORWARD_EULER`` :math:`1^*` 0 ``ARKODE_MRI_GARK_ERK22b`` :math:`2^*` 0 :cite:p:`Sandu:19` ``ARKODE_MRI_GARK_ERK22a`` 2 1 :cite:p:`Sandu:19` - ``ARKODE_MRI_GARK_RALSTON2`` 2 0 :cite:p:`Roberts:22` + ``ARKODE_MRI_GARK_RALSTON2`` 2 0 :cite:p:`Roberts:22` ``ARKODE_MIS_KW3`` :math:`3^*` 0 :cite:p:`Schlegel:09` ``ARKODE_MRI_GARK_ERK33a`` 3 2 :cite:p:`Sandu:19` - ``ARKODE_MRI_GARK_RALSTON3`` 3 0 :cite:p:`Roberts:22` + ``ARKODE_MRI_GARK_RALSTON3`` 3 0 :cite:p:`Roberts:22` ``ARKODE_MRI_GARK_ERK45a`` :math:`4^*` 3 :cite:p:`Sandu:19` ================================= ============ =============== ===================== From 8ce94ca9ed032034831c1ff16a820feac4dce9a3 Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Fri, 26 Jul 2024 11:18:26 -0500 Subject: [PATCH 006/286] Documentation updates --- doc/arkode/guide/source/Usage/MRIStep/User_callable.rst | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/doc/arkode/guide/source/Usage/MRIStep/User_callable.rst b/doc/arkode/guide/source/Usage/MRIStep/User_callable.rst index 3ff8c3f526..b64b17d424 100644 --- a/doc/arkode/guide/source/Usage/MRIStep/User_callable.rst +++ b/doc/arkode/guide/source/Usage/MRIStep/User_callable.rst @@ -1869,7 +1869,7 @@ Main solver optional output functions .. note:: The *MRIStepCoupling* data structure is defined in - the header file ``arkode/arkode_mristep.h``. For more details + the header file ``arkode/arkode_mristep.h``. For more details see :numref:`ARKODE.Usage.MRIStep.MRIStepCoupling`. @@ -2637,8 +2637,7 @@ MRIStep system resize function vector will be invalid after the call to :c:func:`MRIStepResize()`, so the new absolute tolerance vector should be re-set **following** each call to :c:func:`MRIStepResize()` through a new call to - :c:func:`MRIStepSVtolerances()` and possibly - :c:func:`MRIStepResVtolerance()` if applicable. + :c:func:`MRIStepSVtolerances()`. If scalar-valued tolerances or a tolerance function was specified through either :c:func:`MRIStepSStolerances()` or From 7e5e60c61f3fd5e2bdf34614832d3b249c6e5fe0 Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Fri, 26 Jul 2024 13:46:46 -0500 Subject: [PATCH 007/286] Renamed type enum for MRI coupling tables --- include/arkode/arkode_mristep.h | 16 +++---- src/arkode/arkode_mri_tables.c | 8 ++-- src/arkode/arkode_mri_tables.def | 4 +- src/arkode/fmod_int32/farkode_mristep_mod.c | 12 ++--- src/arkode/fmod_int32/farkode_mristep_mod.f90 | 18 ++++---- src/arkode/fmod_int64/farkode_mristep_mod.c | 12 ++--- src/arkode/fmod_int64/farkode_mristep_mod.f90 | 18 ++++---- .../CXX_serial/ark_test_dahlquist_mri.cpp | 44 ++++++++++++------- 8 files changed, 72 insertions(+), 60 deletions(-) diff --git a/include/arkode/arkode_mristep.h b/include/arkode/arkode_mristep.h index 551493c561..20f98dcf62 100644 --- a/include/arkode/arkode_mristep.h +++ b/include/arkode/arkode_mristep.h @@ -39,7 +39,7 @@ typedef enum MRISTEP_IMEX, MRISTEP_MERK, MRISTEP_MRISR -} MRISTEP_METHOD_TYPE; +} ARKODE_MRIType; typedef enum { @@ -80,6 +80,11 @@ static const int MRISTEP_DEFAULT_EXPL_2 = ARKODE_MRI_GARK_ERK22b; static const int MRISTEP_DEFAULT_EXPL_3 = ARKODE_MIS_KW3; static const int MRISTEP_DEFAULT_EXPL_4 = ARKODE_MRI_GARK_ERK45a; +static const int MRISTEP_DEFAULT_EXPL_2_AD = ARKODE_MRI_GARK_ERK22a; +static const int MRISTEP_DEFAULT_EXPL_3_AD = ARKODE_MRI_GARK_ERK33a; +static const int MRISTEP_DEFAULT_EXPL_4_AD = ARKODE_MRI_GARK_ERK45a; +static const int MRISTEP_DEFAULT_EXPL_5_AD = ARKODE_MERK54; + static const int MRISTEP_DEFAULT_IMPL_SD_1 = ARKODE_MRI_GARK_BACKWARD_EULER; static const int MRISTEP_DEFAULT_IMPL_SD_2 = ARKODE_MRI_GARK_IRK21a; static const int MRISTEP_DEFAULT_IMPL_SD_3 = ARKODE_MRI_GARK_ESDIRK34a; @@ -90,11 +95,6 @@ static const int MRISTEP_DEFAULT_IMEX_SD_2 = ARKODE_IMEX_MRI_GARK_TRAPEZOIDAL; static const int MRISTEP_DEFAULT_IMEX_SD_3 = ARKODE_IMEX_MRI_GARK3b; static const int MRISTEP_DEFAULT_IMEX_SD_4 = ARKODE_IMEX_MRI_GARK4; -static const int MRISTEP_DEFAULT_EXPL_2_AD = ARKODE_MRI_GARK_ERK22a; -static const int MRISTEP_DEFAULT_EXPL_3_AD = ARKODE_MRI_GARK_ERK33a; -static const int MRISTEP_DEFAULT_EXPL_4_AD = ARKODE_MRI_GARK_ERK45a; -static const int MRISTEP_DEFAULT_EXPL_5_AD = ARKODE_MERK54; - static const int MRISTEP_DEFAULT_IMEX_SD_2_AD = ARKODE_IMEX_MRI_SR21; static const int MRISTEP_DEFAULT_IMEX_SD_3_AD = ARKODE_IMEX_MRI_SR32; static const int MRISTEP_DEFAULT_IMEX_SD_4_AD = ARKODE_IMEX_MRI_SR43; @@ -127,7 +127,7 @@ typedef int (*MRIStepInnerSetRTol)(MRIStepInnerStepper stepper, sunrealtype rtol ---------------------------------------------------------------*/ struct MRIStepCouplingMem { - MRISTEP_METHOD_TYPE type; /* flag to encode the MRI method type */ + ARKODE_MRIType type; /* flag to encode the MRI method type */ int nmat; /* number of MRI coupling matrices */ int stages; /* size of coupling matrices ((stages+1) * stages) */ int q; /* method order of accuracy */ @@ -150,7 +150,7 @@ SUNDIALS_EXPORT MRIStepCoupling MRIStepCoupling_LoadTableByName(const char* meth /* Utility routines to allocate/free/output coupling table structures */ SUNDIALS_EXPORT MRIStepCoupling MRIStepCoupling_Alloc(int nmat, int stages, - MRISTEP_METHOD_TYPE type); + ARKODE_MRIType type); SUNDIALS_EXPORT MRIStepCoupling MRIStepCoupling_Create(int nmat, int stages, int q, int p, sunrealtype* W, diff --git a/src/arkode/arkode_mri_tables.c b/src/arkode/arkode_mri_tables.c index 010f05a873..31812c7685 100644 --- a/src/arkode/arkode_mri_tables.c +++ b/src/arkode/arkode_mri_tables.c @@ -70,7 +70,7 @@ MRIStepCoupling MRIStepCoupling_LoadTableByName(const char* method) Routine to allocate an empty MRIStepCoupling structure ---------------------------------------------------------------*/ MRIStepCoupling MRIStepCoupling_Alloc(int nmat, int stages, - MRISTEP_METHOD_TYPE type) + ARKODE_MRIType type) { int i, j; sunbooleantype hasOmegas, hasGammas; @@ -235,7 +235,7 @@ MRIStepCoupling MRIStepCoupling_Create(int nmat, int stages, int q, int p, sunrealtype* c) { int i, j, k; - MRISTEP_METHOD_TYPE type; + ARKODE_MRIType type; MRIStepCoupling MRIC = NULL; /* Check for legal inputs */ @@ -341,7 +341,7 @@ MRIStepCoupling MRIStepCoupling_MIStoMRI(ARKodeButcherTable B, int q, int p) sunbooleantype padding; sunrealtype Asum; sunrealtype*** C; - MRISTEP_METHOD_TYPE type; + ARKODE_MRIType type; MRIStepCoupling MRIC; const sunrealtype tol = SUN_RCONST(100.0) * SUN_UNIT_ROUNDOFF; @@ -478,7 +478,7 @@ MRIStepCoupling MRIStepCoupling_MIStoMRI(ARKodeButcherTable B, int q, int p) MRIStepCoupling MRIStepCoupling_Copy(MRIStepCoupling MRIC) { int i, j, k, nmat, stages; - MRISTEP_METHOD_TYPE type; + ARKODE_MRIType type; MRIStepCoupling MRICcopy; /* Check for legal input */ diff --git a/src/arkode/arkode_mri_tables.def b/src/arkode/arkode_mri_tables.def index 5444070b62..13d2e8b5da 100644 --- a/src/arkode/arkode_mri_tables.def +++ b/src/arkode/arkode_mri_tables.def @@ -36,10 +36,10 @@ imeth order order type QP ---------------------------------------------------------------- ARKODE_MRI_GARK_FORWARD_EULER 1 0 E Y - ARKODE_MRI_GARK_RALSTON2 2 1 E Y - ARKODE_MIS_KW3 3 0 E Y ARKODE_MRI_GARK_ERK22a 2 1 E Y ARKODE_MRI_GARK_ERK22b 2 1 E Y + ARKODE_MRI_GARK_RALSTON2 2 1 E Y + ARKODE_MIS_KW3 3 0 E Y ARKODE_MRI_GARK_ERK33a 3 2 E Y ARKODE_MRI_GARK_RALSTON3 3 0 E Y ARKODE_MRI_GARK_ERK45a 4 3 E Y diff --git a/src/arkode/fmod_int32/farkode_mristep_mod.c b/src/arkode/fmod_int32/farkode_mristep_mod.c index ef40dcb987..7b094666f2 100644 --- a/src/arkode/fmod_int32/farkode_mristep_mod.c +++ b/src/arkode/fmod_int32/farkode_mristep_mod.c @@ -310,11 +310,11 @@ SWIGINTERN SwigArrayWrapper SwigArrayWrapper_uninitialized() { SWIGEXPORT void _wrap_MRIStepCouplingMem_type_set(SwigClassWrapper const *farg1, int const *farg2) { struct MRIStepCouplingMem *arg1 = (struct MRIStepCouplingMem *) 0 ; - MRISTEP_METHOD_TYPE arg2 ; + ARKODE_MRIType arg2 ; SWIG_check_mutable_nonnull(*farg1, "struct MRIStepCouplingMem *", "MRIStepCouplingMem", "MRIStepCouplingMem::type", return ); arg1 = (struct MRIStepCouplingMem *)(farg1->cptr); - arg2 = (MRISTEP_METHOD_TYPE)(*farg2); + arg2 = (ARKODE_MRIType)(*farg2); if (arg1) (arg1)->type = arg2; } @@ -322,11 +322,11 @@ SWIGEXPORT void _wrap_MRIStepCouplingMem_type_set(SwigClassWrapper const *farg1, SWIGEXPORT int _wrap_MRIStepCouplingMem_type_get(SwigClassWrapper const *farg1) { int fresult ; struct MRIStepCouplingMem *arg1 = (struct MRIStepCouplingMem *) 0 ; - MRISTEP_METHOD_TYPE result; + ARKODE_MRIType result; SWIG_check_mutable_nonnull(*farg1, "struct MRIStepCouplingMem *", "MRIStepCouplingMem", "MRIStepCouplingMem::type", return 0); arg1 = (struct MRIStepCouplingMem *)(farg1->cptr); - result = (MRISTEP_METHOD_TYPE) ((arg1)->type); + result = (ARKODE_MRIType) ((arg1)->type); fresult = (int)(result); return fresult; } @@ -607,12 +607,12 @@ SWIGEXPORT void * _wrap_FMRIStepCoupling_Alloc(int const *farg1, int const *farg void * fresult ; int arg1 ; int arg2 ; - MRISTEP_METHOD_TYPE arg3 ; + ARKODE_MRIType arg3 ; MRIStepCoupling result; arg1 = (int)(*farg1); arg2 = (int)(*farg2); - arg3 = (MRISTEP_METHOD_TYPE)(*farg3); + arg3 = (ARKODE_MRIType)(*farg3); result = (MRIStepCoupling)MRIStepCoupling_Alloc(arg1,arg2,arg3); fresult = result; return fresult; diff --git a/src/arkode/fmod_int32/farkode_mristep_mod.f90 b/src/arkode/fmod_int32/farkode_mristep_mod.f90 index 66f05b4bea..4cec198030 100644 --- a/src/arkode/fmod_int32/farkode_mristep_mod.f90 +++ b/src/arkode/fmod_int32/farkode_mristep_mod.f90 @@ -26,7 +26,7 @@ module farkode_mristep_mod private ! DECLARATION CONSTRUCTS - ! typedef enum MRISTEP_METHOD_TYPE + ! typedef enum ARKODE_MRIType enum, bind(c) enumerator :: MRISTEP_EXPLICIT enumerator :: MRISTEP_IMPLICIT @@ -34,7 +34,7 @@ module farkode_mristep_mod enumerator :: MRISTEP_MERK enumerator :: MRISTEP_MRISR end enum - integer, parameter, public :: MRISTEP_METHOD_TYPE = kind(MRISTEP_EXPLICIT) + integer, parameter, public :: ARKODE_MRIType = kind(MRISTEP_EXPLICIT) public :: MRISTEP_EXPLICIT, MRISTEP_IMPLICIT, MRISTEP_IMEX, MRISTEP_MERK, MRISTEP_MRISR ! typedef enum ARKODE_MRITableID enum, bind(c) @@ -80,6 +80,10 @@ module farkode_mristep_mod integer(C_INT), parameter, public :: MRISTEP_DEFAULT_EXPL_2 = ARKODE_MRI_GARK_ERK22b integer(C_INT), parameter, public :: MRISTEP_DEFAULT_EXPL_3 = ARKODE_MIS_KW3 integer(C_INT), parameter, public :: MRISTEP_DEFAULT_EXPL_4 = ARKODE_MRI_GARK_ERK45a + integer(C_INT), parameter, public :: MRISTEP_DEFAULT_EXPL_2_AD = ARKODE_MRI_GARK_ERK22a + integer(C_INT), parameter, public :: MRISTEP_DEFAULT_EXPL_3_AD = ARKODE_MRI_GARK_ERK33a + integer(C_INT), parameter, public :: MRISTEP_DEFAULT_EXPL_4_AD = ARKODE_MRI_GARK_ERK45a + integer(C_INT), parameter, public :: MRISTEP_DEFAULT_EXPL_5_AD = ARKODE_MERK54 integer(C_INT), parameter, public :: MRISTEP_DEFAULT_IMPL_SD_1 = ARKODE_MRI_GARK_BACKWARD_EULER integer(C_INT), parameter, public :: MRISTEP_DEFAULT_IMPL_SD_2 = ARKODE_MRI_GARK_IRK21a integer(C_INT), parameter, public :: MRISTEP_DEFAULT_IMPL_SD_3 = ARKODE_MRI_GARK_ESDIRK34a @@ -88,10 +92,6 @@ module farkode_mristep_mod integer(C_INT), parameter, public :: MRISTEP_DEFAULT_IMEX_SD_2 = ARKODE_IMEX_MRI_GARK_TRAPEZOIDAL integer(C_INT), parameter, public :: MRISTEP_DEFAULT_IMEX_SD_3 = ARKODE_IMEX_MRI_GARK3b integer(C_INT), parameter, public :: MRISTEP_DEFAULT_IMEX_SD_4 = ARKODE_IMEX_MRI_GARK4 - integer(C_INT), parameter, public :: MRISTEP_DEFAULT_EXPL_2_AD = ARKODE_MRI_GARK_ERK22a - integer(C_INT), parameter, public :: MRISTEP_DEFAULT_EXPL_3_AD = ARKODE_MRI_GARK_ERK33a - integer(C_INT), parameter, public :: MRISTEP_DEFAULT_EXPL_4_AD = ARKODE_MRI_GARK_ERK45a - integer(C_INT), parameter, public :: MRISTEP_DEFAULT_EXPL_5_AD = ARKODE_MERK54 integer(C_INT), parameter, public :: MRISTEP_DEFAULT_IMEX_SD_2_AD = ARKODE_IMEX_MRI_SR21 integer(C_INT), parameter, public :: MRISTEP_DEFAULT_IMEX_SD_3_AD = ARKODE_IMEX_MRI_SR32 integer(C_INT), parameter, public :: MRISTEP_DEFAULT_IMEX_SD_4_AD = ARKODE_IMEX_MRI_SR43 @@ -1544,7 +1544,7 @@ subroutine swigc_FMRIStepPrintMem(farg1, farg2) & subroutine swigf_MRIStepCouplingMem_type_set(self, type) use, intrinsic :: ISO_C_BINDING class(MRIStepCouplingMem), intent(in) :: self -integer(MRISTEP_METHOD_TYPE), intent(in) :: type +integer(ARKODE_MRIType), intent(in) :: type type(SwigClassWrapper) :: farg1 integer(C_INT) :: farg2 @@ -1556,7 +1556,7 @@ subroutine swigf_MRIStepCouplingMem_type_set(self, type) function swigf_MRIStepCouplingMem_type_get(self) & result(swig_result) use, intrinsic :: ISO_C_BINDING -integer(MRISTEP_METHOD_TYPE) :: swig_result +integer(ARKODE_MRIType) :: swig_result class(MRIStepCouplingMem), intent(in) :: self integer(C_INT) :: fresult type(SwigClassWrapper) :: farg1 @@ -1879,7 +1879,7 @@ function FMRIStepCoupling_Alloc(nmat, stages, type) & type(C_PTR) :: swig_result integer(C_INT), intent(in) :: nmat integer(C_INT), intent(in) :: stages -integer(MRISTEP_METHOD_TYPE), intent(in) :: type +integer(ARKODE_MRIType), intent(in) :: type type(C_PTR) :: fresult integer(C_INT) :: farg1 integer(C_INT) :: farg2 diff --git a/src/arkode/fmod_int64/farkode_mristep_mod.c b/src/arkode/fmod_int64/farkode_mristep_mod.c index dbb3438d16..8ffaac9e94 100644 --- a/src/arkode/fmod_int64/farkode_mristep_mod.c +++ b/src/arkode/fmod_int64/farkode_mristep_mod.c @@ -310,11 +310,11 @@ SWIGINTERN SwigArrayWrapper SwigArrayWrapper_uninitialized() { SWIGEXPORT void _wrap_MRIStepCouplingMem_type_set(SwigClassWrapper const *farg1, int const *farg2) { struct MRIStepCouplingMem *arg1 = (struct MRIStepCouplingMem *) 0 ; - MRISTEP_METHOD_TYPE arg2 ; + ARKODE_MRIType arg2 ; SWIG_check_mutable_nonnull(*farg1, "struct MRIStepCouplingMem *", "MRIStepCouplingMem", "MRIStepCouplingMem::type", return ); arg1 = (struct MRIStepCouplingMem *)(farg1->cptr); - arg2 = (MRISTEP_METHOD_TYPE)(*farg2); + arg2 = (ARKODE_MRIType)(*farg2); if (arg1) (arg1)->type = arg2; } @@ -322,11 +322,11 @@ SWIGEXPORT void _wrap_MRIStepCouplingMem_type_set(SwigClassWrapper const *farg1, SWIGEXPORT int _wrap_MRIStepCouplingMem_type_get(SwigClassWrapper const *farg1) { int fresult ; struct MRIStepCouplingMem *arg1 = (struct MRIStepCouplingMem *) 0 ; - MRISTEP_METHOD_TYPE result; + ARKODE_MRIType result; SWIG_check_mutable_nonnull(*farg1, "struct MRIStepCouplingMem *", "MRIStepCouplingMem", "MRIStepCouplingMem::type", return 0); arg1 = (struct MRIStepCouplingMem *)(farg1->cptr); - result = (MRISTEP_METHOD_TYPE) ((arg1)->type); + result = (ARKODE_MRIType) ((arg1)->type); fresult = (int)(result); return fresult; } @@ -607,12 +607,12 @@ SWIGEXPORT void * _wrap_FMRIStepCoupling_Alloc(int const *farg1, int const *farg void * fresult ; int arg1 ; int arg2 ; - MRISTEP_METHOD_TYPE arg3 ; + ARKODE_MRIType arg3 ; MRIStepCoupling result; arg1 = (int)(*farg1); arg2 = (int)(*farg2); - arg3 = (MRISTEP_METHOD_TYPE)(*farg3); + arg3 = (ARKODE_MRIType)(*farg3); result = (MRIStepCoupling)MRIStepCoupling_Alloc(arg1,arg2,arg3); fresult = result; return fresult; diff --git a/src/arkode/fmod_int64/farkode_mristep_mod.f90 b/src/arkode/fmod_int64/farkode_mristep_mod.f90 index 6654b0f9ae..8e2b98b4dc 100644 --- a/src/arkode/fmod_int64/farkode_mristep_mod.f90 +++ b/src/arkode/fmod_int64/farkode_mristep_mod.f90 @@ -26,7 +26,7 @@ module farkode_mristep_mod private ! DECLARATION CONSTRUCTS - ! typedef enum MRISTEP_METHOD_TYPE + ! typedef enum ARKODE_MRIType enum, bind(c) enumerator :: MRISTEP_EXPLICIT enumerator :: MRISTEP_IMPLICIT @@ -34,7 +34,7 @@ module farkode_mristep_mod enumerator :: MRISTEP_MERK enumerator :: MRISTEP_MRISR end enum - integer, parameter, public :: MRISTEP_METHOD_TYPE = kind(MRISTEP_EXPLICIT) + integer, parameter, public :: ARKODE_MRIType = kind(MRISTEP_EXPLICIT) public :: MRISTEP_EXPLICIT, MRISTEP_IMPLICIT, MRISTEP_IMEX, MRISTEP_MERK, MRISTEP_MRISR ! typedef enum ARKODE_MRITableID enum, bind(c) @@ -80,6 +80,10 @@ module farkode_mristep_mod integer(C_INT), parameter, public :: MRISTEP_DEFAULT_EXPL_2 = ARKODE_MRI_GARK_ERK22b integer(C_INT), parameter, public :: MRISTEP_DEFAULT_EXPL_3 = ARKODE_MIS_KW3 integer(C_INT), parameter, public :: MRISTEP_DEFAULT_EXPL_4 = ARKODE_MRI_GARK_ERK45a + integer(C_INT), parameter, public :: MRISTEP_DEFAULT_EXPL_2_AD = ARKODE_MRI_GARK_ERK22a + integer(C_INT), parameter, public :: MRISTEP_DEFAULT_EXPL_3_AD = ARKODE_MRI_GARK_ERK33a + integer(C_INT), parameter, public :: MRISTEP_DEFAULT_EXPL_4_AD = ARKODE_MRI_GARK_ERK45a + integer(C_INT), parameter, public :: MRISTEP_DEFAULT_EXPL_5_AD = ARKODE_MERK54 integer(C_INT), parameter, public :: MRISTEP_DEFAULT_IMPL_SD_1 = ARKODE_MRI_GARK_BACKWARD_EULER integer(C_INT), parameter, public :: MRISTEP_DEFAULT_IMPL_SD_2 = ARKODE_MRI_GARK_IRK21a integer(C_INT), parameter, public :: MRISTEP_DEFAULT_IMPL_SD_3 = ARKODE_MRI_GARK_ESDIRK34a @@ -88,10 +92,6 @@ module farkode_mristep_mod integer(C_INT), parameter, public :: MRISTEP_DEFAULT_IMEX_SD_2 = ARKODE_IMEX_MRI_GARK_TRAPEZOIDAL integer(C_INT), parameter, public :: MRISTEP_DEFAULT_IMEX_SD_3 = ARKODE_IMEX_MRI_GARK3b integer(C_INT), parameter, public :: MRISTEP_DEFAULT_IMEX_SD_4 = ARKODE_IMEX_MRI_GARK4 - integer(C_INT), parameter, public :: MRISTEP_DEFAULT_EXPL_2_AD = ARKODE_MRI_GARK_ERK22a - integer(C_INT), parameter, public :: MRISTEP_DEFAULT_EXPL_3_AD = ARKODE_MRI_GARK_ERK33a - integer(C_INT), parameter, public :: MRISTEP_DEFAULT_EXPL_4_AD = ARKODE_MRI_GARK_ERK45a - integer(C_INT), parameter, public :: MRISTEP_DEFAULT_EXPL_5_AD = ARKODE_MERK54 integer(C_INT), parameter, public :: MRISTEP_DEFAULT_IMEX_SD_2_AD = ARKODE_IMEX_MRI_SR21 integer(C_INT), parameter, public :: MRISTEP_DEFAULT_IMEX_SD_3_AD = ARKODE_IMEX_MRI_SR32 integer(C_INT), parameter, public :: MRISTEP_DEFAULT_IMEX_SD_4_AD = ARKODE_IMEX_MRI_SR43 @@ -1544,7 +1544,7 @@ subroutine swigc_FMRIStepPrintMem(farg1, farg2) & subroutine swigf_MRIStepCouplingMem_type_set(self, type) use, intrinsic :: ISO_C_BINDING class(MRIStepCouplingMem), intent(in) :: self -integer(MRISTEP_METHOD_TYPE), intent(in) :: type +integer(ARKODE_MRIType), intent(in) :: type type(SwigClassWrapper) :: farg1 integer(C_INT) :: farg2 @@ -1556,7 +1556,7 @@ subroutine swigf_MRIStepCouplingMem_type_set(self, type) function swigf_MRIStepCouplingMem_type_get(self) & result(swig_result) use, intrinsic :: ISO_C_BINDING -integer(MRISTEP_METHOD_TYPE) :: swig_result +integer(ARKODE_MRIType) :: swig_result class(MRIStepCouplingMem), intent(in) :: self integer(C_INT) :: fresult type(SwigClassWrapper) :: farg1 @@ -1879,7 +1879,7 @@ function FMRIStepCoupling_Alloc(nmat, stages, type) & type(C_PTR) :: swig_result integer(C_INT), intent(in) :: nmat integer(C_INT), intent(in) :: stages -integer(MRISTEP_METHOD_TYPE), intent(in) :: type +integer(ARKODE_MRIType), intent(in) :: type type(C_PTR) :: fresult integer(C_INT) :: farg1 integer(C_INT) :: farg2 diff --git a/test/unit_tests/arkode/CXX_serial/ark_test_dahlquist_mri.cpp b/test/unit_tests/arkode/CXX_serial/ark_test_dahlquist_mri.cpp index 994edd56cf..19a2c2bbf4 100644 --- a/test/unit_tests/arkode/CXX_serial/ark_test_dahlquist_mri.cpp +++ b/test/unit_tests/arkode/CXX_serial/ark_test_dahlquist_mri.cpp @@ -93,7 +93,7 @@ static int Ji(sunrealtype t, N_Vector y, N_Vector fy, SUNMatrix J, static int check_flag(void* flagvalue, const std::string funcname, int opt); // Test drivers -static int run_tests(MRISTEP_METHOD_TYPE type, ProblemOptions& prob_opts, +static int run_tests(ARKODE_MRIType type, ProblemOptions& prob_opts, ProblemData& prob_data, SUNContext ctx); // ----------------------------------------------------------------------------- @@ -157,6 +157,8 @@ int main(int argc, char* argv[]) numfails += run_tests(MRISTEP_MERK, prob_opts, prob_data, sunctx); + numfails += run_tests(MRISTEP_MRISR, prob_opts, prob_data, sunctx); + if (numfails) { std::cout << "\n\nFailed " << numfails << " tests!\n"; } else { std::cout << "\n\nAll tests passed!\n"; } @@ -168,7 +170,7 @@ int main(int argc, char* argv[]) // Test drivers // ----------------------------------------------------------------------------- -int run_tests(MRISTEP_METHOD_TYPE type, ProblemOptions& prob_opts, +int run_tests(ARKODE_MRIType type, ProblemOptions& prob_opts, ProblemData& prob_data, SUNContext sunctx) { // Reusable error-checking flag @@ -187,7 +189,7 @@ int run_tests(MRISTEP_METHOD_TYPE type, ProblemOptions& prob_opts, SUNMatrix A = nullptr; SUNLinearSolver LS = nullptr; - if (type == MRISTEP_IMPLICIT || type == MRISTEP_IMEX) + if (type == MRISTEP_IMPLICIT || type == MRISTEP_IMEX || type == MRISTEP_MRISR) { // Initialize dense matrix data structures and solvers A = SUNDenseMatrix(1, 1, sunctx); @@ -251,7 +253,7 @@ int run_tests(MRISTEP_METHOD_TYPE type, ProblemOptions& prob_opts, mristep_mem = MRIStepCreate(nullptr, fi, prob_opts.t0, y, inner_stepper, sunctx); } - else if (type == MRISTEP_IMEX) + else if ((type == MRISTEP_IMEX) || (type == MRISTEP_MRISR)) { mristep_mem = MRIStepCreate(fe, fi, prob_opts.t0, y, inner_stepper, sunctx); } @@ -270,7 +272,7 @@ int run_tests(MRISTEP_METHOD_TYPE type, ProblemOptions& prob_opts, flag = ARKodeSetFixedStep(mristep_mem, prob_opts.hs); if (check_flag(&flag, "ARKodeSetFixedStep", 1)) { return 1; } - if (type == MRISTEP_IMPLICIT || type == MRISTEP_IMEX) + if (type == MRISTEP_IMPLICIT || type == MRISTEP_IMEX || type == MRISTEP_MRISR) { // Attach linear solver flag = ARKodeSetLinearSolver(mristep_mem, LS, A); @@ -297,9 +299,9 @@ int run_tests(MRISTEP_METHOD_TYPE type, ProblemOptions& prob_opts, if (check_flag(&flag, "ARKStepSetInterpolantType", 1)) { return 1; } } - // ------------------------------------ - // Evolve with various IMEX MRI methods - // ------------------------------------ + // ------------------------------- + // Evolve with various MRI methods + // ------------------------------- // Methods to test paired with whether they are stiffly accurate std::map methods; @@ -355,6 +357,16 @@ int run_tests(MRISTEP_METHOD_TYPE type, ProblemOptions& prob_opts, {"ARKODE_IMEX_MRI_GARK3b", false}, {"ARKODE_IMEX_MRI_GARK4", false}}); } + else if (type == MRISTEP_MRISR) + { + std::cout << "\n========================\n"; + std::cout << "Test IMEX MRI SR methods\n"; + std::cout << "========================\n"; + + methods.insert({{"ARKODE_IMEX_MRISR21", true}, + {"ARKODE_IMEX_MRISR32", true}, + {"ARKODE_IMEX_MRISR43", true}}); + } else { return 1; } for (const auto& pair : methods) @@ -419,7 +431,7 @@ int run_tests(MRISTEP_METHOD_TYPE type, ProblemOptions& prob_opts, flag = MRIStepGetNumRhsEvals(mristep_mem, &mri_nfse, &mri_nfsi); if (check_flag(&flag, "MRIStepGetNumRhsEvals", 1)) { return 1; } - if (type == MRISTEP_IMPLICIT || type == MRISTEP_IMEX) + if (type == MRISTEP_IMPLICIT || type == MRISTEP_IMEX || type == MRISTEP_MRISR) { flag = ARKodeGetNumNonlinSolvIters(mristep_mem, &mri_nni); if (check_flag(&flag, "ARKodeGetNumNonlinSolvIters", 1)) { return 1; } @@ -438,11 +450,11 @@ int run_tests(MRISTEP_METHOD_TYPE type, ProblemOptions& prob_opts, } sunrealtype pow = prob_data.lambda_f; - if (type == MRISTEP_EXPLICIT || type == MRISTEP_IMEX || type == MRISTEP_MERK) + if (type != MRISTEP_IMPLICIT) { pow += prob_data.lambda_e; } - if (type == MRISTEP_IMPLICIT || type == MRISTEP_IMEX) + if (type == MRISTEP_IMPLICIT || type == MRISTEP_IMEX || type == MRISTEP_MRISR) { pow += prob_data.lambda_i; } @@ -460,7 +472,7 @@ int run_tests(MRISTEP_METHOD_TYPE type, ProblemOptions& prob_opts, std::cout << " Fe evals = " << mri_nfse << "\n"; std::cout << " Fi evals = " << mri_nfsi << "\n"; - if (type == MRISTEP_IMPLICIT || type == MRISTEP_IMEX) + if (type == MRISTEP_IMPLICIT || type == MRISTEP_IMEX || type == MRISTEP_MRISR) { std::cout << " NLS iters = " << mri_nni << "\n"; std::cout << " NLS fails = " << mri_ncfn << "\n"; @@ -478,7 +490,7 @@ int run_tests(MRISTEP_METHOD_TYPE type, ProblemOptions& prob_opts, int nstages_evaluated = nstages_stored; if (stiffly_accurate) nstages_evaluated--; long int fe_evals = 0; - if (type == MRISTEP_EXPLICIT || type == MRISTEP_IMEX || type == MRISTEP_MERK) + if (type != MRISTEP_IMPLICIT) { fe_evals = mri_nst * nstages_evaluated; } @@ -490,7 +502,7 @@ int run_tests(MRISTEP_METHOD_TYPE type, ProblemOptions& prob_opts, } long int fi_evals = 0; - if (type == MRISTEP_IMPLICIT || type == MRISTEP_IMEX) + if (type == MRISTEP_IMPLICIT || type == MRISTEP_IMEX || type == MRISTEP_MRISR) { fi_evals = mri_nst * nstages_evaluated + mri_nni; } @@ -528,7 +540,7 @@ int run_tests(MRISTEP_METHOD_TYPE type, ProblemOptions& prob_opts, { flag = MRIStepReInit(mristep_mem, nullptr, fi, prob_opts.t0, y); } - else if (type == MRISTEP_IMEX) + else if (type == MRISTEP_IMEX || type == MRISTEP_MRISR) { flag = MRIStepReInit(mristep_mem, fe, fi, prob_opts.t0, y); } @@ -540,7 +552,7 @@ int run_tests(MRISTEP_METHOD_TYPE type, ProblemOptions& prob_opts, MRIStepInnerStepper_Free(&inner_stepper); ARKodeFree(&mristep_mem); ARKodeFree(&arkstep_mem); - if (type == MRISTEP_IMPLICIT || type == MRISTEP_IMEX) + if (type == MRISTEP_IMPLICIT || type == MRISTEP_IMEX || type == MRISTEP_MRISR) { SUNLinSolFree(LS); SUNMatDestroy(A); From a400707af2176da3420a7a1534ccd300688c7f42 Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Fri, 26 Jul 2024 13:46:58 -0500 Subject: [PATCH 008/286] Documentation updates --- doc/arkode/guide/source/Constants.rst | 76 +++++-- .../source/Usage/MRIStep/MRIStepCoupling.rst | 210 +++++++++++------- 2 files changed, 189 insertions(+), 97 deletions(-) diff --git a/doc/arkode/guide/source/Constants.rst b/doc/arkode/guide/source/Constants.rst index 99f76ddcec..5f415ba17c 100644 --- a/doc/arkode/guide/source/Constants.rst +++ b/doc/arkode/guide/source/Constants.rst @@ -64,7 +64,7 @@ contains the ARKODE output constants. +-----------------------------------------------+------------------------------------------------------------+ | | | +-----------------------------------------------+------------------------------------------------------------+ - | **Relaxtion module input constants** | | + | **Relaxation module input constants** | | +-----------------------------------------------+------------------------------------------------------------+ | :index:`ARK_RELAX_BRENT` | Specifies Brent's method as the relaxation nonlinear | | | solver. | @@ -331,10 +331,10 @@ contains the ARKODE output constants. +-----------------------------------------------+------------------------------------------------------------+ | :index:`ARKODE_MRI_GARK_FORWARD_EULER` | Use the forward Euler MRI-GARK method. | +-----------------------------------------------+------------------------------------------------------------+ - | :index:`ARKODE_MRI_GARK_ERK22b` | Use the ERK22b MRI-GARK method. | - +-----------------------------------------------+------------------------------------------------------------+ | :index:`ARKODE_MRI_GARK_ERK22a` | Use the ERK22a MRI-GARK method. | +-----------------------------------------------+------------------------------------------------------------+ + | :index:`ARKODE_MRI_GARK_ERK22b` | Use the ERK22b MRI-GARK method. | + +-----------------------------------------------+------------------------------------------------------------+ | :index:`ARKODE_MRI_GARK_RALSTON2` | Use the second order Ralston MRI-GARK method. | +-----------------------------------------------+------------------------------------------------------------+ | :index:`ARKODE_MIS_KW3` | Use the Knoth-Wolke-3 MIS method (non-embedded). | @@ -345,6 +345,14 @@ contains the ARKODE output constants. +-----------------------------------------------+------------------------------------------------------------+ | :index:`ARKODE_MRI_GARK_ERK45a` | Use the ERK45a MRI-GARK method. | +-----------------------------------------------+------------------------------------------------------------+ + | :index:`ARKODE_MERK21` | Use the MERK21 method. | + +-----------------------------------------------+------------------------------------------------------------+ + | :index:`ARKODE_MERK32` | Use the MERK32 method. | + +-----------------------------------------------+------------------------------------------------------------+ + | :index:`ARKODE_MERK43` | Use the MERK43 method. | + +-----------------------------------------------+------------------------------------------------------------+ + | :index:`ARKODE_MERK54` | Use the MERK54 method. | + +-----------------------------------------------+------------------------------------------------------------+ | :index:`ARKODE_MRI_GARK_BACKWARD_EULER` | Use the backward Euler MRI-GARK method. | +-----------------------------------------------+------------------------------------------------------------+ | :index:`ARKODE_MRI_GARK_IRK21a` | Use the IRK21a MRI-GARK method. | @@ -367,45 +375,69 @@ contains the ARKODE output constants. +-----------------------------------------------+------------------------------------------------------------+ | :index:`ARKODE_IMEX_MRI_GARK4` | Use the IMEX-MRI-GARK4 method (non-embedded). | +-----------------------------------------------+------------------------------------------------------------+ - | :index:`MRISTEP_DEFAULT_EXPL_TABLE_1` | Use MRIStep's default 1st-order explicit method | - | | (MRI_GARK_FORWARD_EULER). | + | :index:`ARKODE_IMEX_MRI_SR21` | Use the IMEX-MRI-SR21 method. | + +-----------------------------------------------+------------------------------------------------------------+ + | :index:`ARKODE_IMEX_MRI_SR32` | Use the IMEX-MRI-SR32 method. | +-----------------------------------------------+------------------------------------------------------------+ - | :index:`MRISTEP_DEFAULT_EXPL_TABLE_2` | Use MRIStep's default 2nd-order explicit method | - | | (MRI_GARK_ERK22b). | + | :index:`ARKODE_IMEX_MRI_SR43` | Use the IMEX-MRI-SR43 method. | +-----------------------------------------------+------------------------------------------------------------+ - | :index:`MRISTEP_DEFAULT_EXPL_TABLE_3` | Use MRIStep's default 3rd-order explicit method | + | :index:`MRISTEP_DEFAULT_EXPL_1` | Use MRIStep's default 1st-order explicit method | + | | (ARKODE_MRI_GARK_FORWARD_EULER). | + +-----------------------------------------------+------------------------------------------------------------+ + | :index:`MRISTEP_DEFAULT_EXPL_2` | Use MRIStep's default 2nd-order explicit method | + | | (ARKODE_MRI_GARK_ERK22b). | + +-----------------------------------------------+------------------------------------------------------------+ + | :index:`MRISTEP_DEFAULT_EXPL_3` | Use MRIStep's default 3rd-order explicit method | | | (ARKODE_MIS_KW3). | +-----------------------------------------------+------------------------------------------------------------+ - | :index:`MRISTEP_DEFAULT_EXPL_TABLE_3_AD` | Use MRIStep's default 3rd-order adaptive explicit method | + | :index:`MRISTEP_DEFAULT_EXPL_4` | Use MRIStep's default 4th-order explicit method | + | | (ARKODE_MRI_GARK_ERK45a). | + +-----------------------------------------------+------------------------------------------------------------+ + | :index:`MRISTEP_DEFAULT_EXPL_2_AD` | Use MRIStep's default 2nd-order adaptive explicit method | + | | (ARKODE_MRI_GARK_ERK22a). | + +-----------------------------------------------+------------------------------------------------------------+ + | :index:`MRISTEP_DEFAULT_EXPL_3_AD` | Use MRIStep's default 3rd-order adaptive explicit method | | | (ARKODE_MRI_GARK_ERK33a). | +-----------------------------------------------+------------------------------------------------------------+ - | :index:`MRISTEP_DEFAULT_EXPL_TABLE_4` | Use MRIStep's default 4th-order explicit method | - | | (MRI_GARK_ERK45a). | + | :index:`MRISTEP_DEFAULT_EXPL_4_AD` | Use MRIStep's default 4th-order adaptive explicit method | + | | (ARKODE_MRI_GARK_ERK45a). | +-----------------------------------------------+------------------------------------------------------------+ - | :index:`MRISTEP_DEFAULT_IMPL_SD_TABLE_1` | Use MRIStep's default 1st-order solve-decoupled implicit | - | | method (MRI_GARK_BACKWARD_EULER). | + | :index:`MRISTEP_DEFAULT_EXPL_5_AD` | Use MRIStep's default 5th-order adaptive explicit method | + | | (ARKODE_MERK54). | +-----------------------------------------------+------------------------------------------------------------+ - | :index:`MRISTEP_DEFAULT_IMPL_SD_TABLE_2` | Use MRIStep's default 2nd-order solve-decoupled implicit | + | :index:`MRISTEP_DEFAULT_IMPL_SD_1` | Use MRIStep's default 1st-order solve-decoupled implicit | + | | method (ARKODE_MRI_GARK_BACKWARD_EULER). | + +-----------------------------------------------+------------------------------------------------------------+ + | :index:`MRISTEP_DEFAULT_IMPL_SD_2` | Use MRIStep's default 2nd-order solve-decoupled implicit | | | method (ARKODE_MRI_GARK_IRK21a). | +-----------------------------------------------+------------------------------------------------------------+ - | :index:`MRISTEP_DEFAULT_IMPL_SD_TABLE_3` | Use MRIStep's default 3rd-order solve-decoupled implicit | + | :index:`MRISTEP_DEFAULT_IMPL_SD_3` | Use MRIStep's default 3rd-order solve-decoupled implicit | | | method (ARKODE_MRI_GARK_ESDIRK34a). | +-----------------------------------------------+------------------------------------------------------------+ - | :index:`MRISTEP_DEFAULT_IMPL_SD_TABLE_4` | Use MRIStep's default 4th-order solve-decoupled implicit | - | | method (MRI_GARK_ESDIRK46a). | + | :index:`MRISTEP_DEFAULT_IMPL_SD_4` | Use MRIStep's default 4th-order solve-decoupled implicit | + | | method (ARKODE_MRI_GARK_ESDIRK46a). | +-----------------------------------------------+------------------------------------------------------------+ - | :index:`MRISTEP_DEFAULT_IMEX_SD_TABLE_1` | Use MRIStep's default 1st-order solve-decoupled ImEx | - | | method (IMEX_MRI_GARK_EULER). | + | :index:`MRISTEP_DEFAULT_IMEX_SD_1` | Use MRIStep's default 1st-order solve-decoupled ImEx | + | | method (ARKODE_IMEX_MRI_GARK_EULER). | +-----------------------------------------------+------------------------------------------------------------+ - | :index:`MRISTEP_DEFAULT_IMEX_SD_TABLE_2` | Use MRIStep's default 2nd-order solve-decoupled ImEx | + | :index:`MRISTEP_DEFAULT_IMEX_SD_2` | Use MRIStep's default 2nd-order solve-decoupled ImEx | | | method (ARKODE_IMEX_MRI_GARK_TRAPEZOIDAL). | +-----------------------------------------------+------------------------------------------------------------+ - | :index:`MRISTEP_DEFAULT_IMEX_SD_TABLE_3` | Use MRIStep's default 3rd-order solve-decoupled ImEx | + | :index:`MRISTEP_DEFAULT_IMEX_SD_3` | Use MRIStep's default 3rd-order solve-decoupled ImEx | | | method (ARKODE_IMEX_MRI_GARK3b). | +-----------------------------------------------+------------------------------------------------------------+ - | :index:`MRISTEP_DEFAULT_IMEX_SD_TABLE_4` | Use MRIStep's default 4th-order solve-decoupled ImEx | + | :index:`MRISTEP_DEFAULT_IMEX_SD_4` | Use MRIStep's default 4th-order solve-decoupled ImEx | | | method (ARKODE_IMEX_MRI_GARK4). | +-----------------------------------------------+------------------------------------------------------------+ + | :index:`MRISTEP_DEFAULT_IMEX_SD_2_AD` | Use MRIStep's default 2nd-order solve-decoupled adaptive | + | | ImEx method (ARKODE_IMEX_MRI_SR21). | + +-----------------------------------------------+------------------------------------------------------------+ + | :index:`MRISTEP_DEFAULT_IMEX_SD_3_AD` | Use MRIStep's default 3rd-order solve-decoupled adaptive | + | | ImEx method (ARKODE_IMEX_MRI_SR32). | + +-----------------------------------------------+------------------------------------------------------------+ + | :index:`MRISTEP_DEFAULT_IMEX_SD_4_AD` | Use MRIStep's default 4th-order solve-decoupled adaptive | + | | ImEx method (ARKODE_IMEX_MRI_SR43). | + +-----------------------------------------------+------------------------------------------------------------+ diff --git a/doc/arkode/guide/source/Usage/MRIStep/MRIStepCoupling.rst b/doc/arkode/guide/source/Usage/MRIStep/MRIStepCoupling.rst index ab6a78eb84..abb7d7ed28 100644 --- a/doc/arkode/guide/source/Usage/MRIStep/MRIStepCoupling.rst +++ b/doc/arkode/guide/source/Usage/MRIStep/MRIStepCoupling.rst @@ -22,7 +22,29 @@ MRIStep supplies several built-in MIS, MRI-GARK, and IMEX-MRI-GARK methods, see coupling tables and their corresponding identifiers. Additionally, a user may supply a custom set of slow-to-fast time scale coupling coefficients by constructing a coupling table and attaching it with -:c:func:`MRIStepSetCoupling`. The MRI coupling tables are stored in an +:c:func:`MRIStepSetCoupling`. A given MRI coupling table can encode any of +the MRI methods supported by MRIStep. These types are determined by an +enumerated type, :c:type:`ARKODE_MRIType`: + +.. c:type:: ARKODE_MRIType + + This may take any of the following constants: + + * :index:`MRISTEP_EXPLICIT` -- indicates an MRI-GARK method that + does not include a slow implicit operator, :math:`f^I`. + + * :index:`MRISTEP_IMPLICIT` -- indicates an MRI-GARK method that + does not include a slow explicit operator, :math:`f^E`. + + * :index:`MRISTEP_IMEX` -- indicates an IMEX-MRK-GARK method. + + * :index:`MRISTEP_MERK` -- indicates a MERK method, that by definition + does not include a slow implicit operator, :math:`f^I`. + + * :index:`MRISTEP_MRISR` -- indicates an IMEX-MRI-SR method, with time + scale that is any one of explicit, implicit, or implicit-explicit. + +The MRI coupling tables themselves are stored in an :c:func:`MRIStepCoupling` object which is a pointer to a :c:struct:`MRIStepCouplingMem` structure: @@ -39,6 +61,10 @@ constructing a coupling table and attaching it with matrices :math:`\Gamma^{\{k\}}\in\mathbb{R}^{(s+1)\times(s+1)}` and :math:`\Omega^{\{k\}}\in\mathbb{R}^{(s+1)\times(s+1)}`. + .. c:member:: ARKODE_MRIType type + + Flag indicating the type of MRI method encoded by this table, + .. c:member:: int nmat The number of coupling matrices :math:`\Omega^{\{k\}}` for the @@ -57,6 +83,11 @@ constructing a coupling table and attaching it with The embedding order of accuracy + .. c:member:: sunrealtype* c + + An array of length ``[stages]`` containing the slow abscissae :math:`c^S` + for the method + .. c:member:: sunrealtype*** W A three-dimensional array with dimensions ``[nmat][stages+1][stages]`` @@ -69,10 +100,15 @@ constructing a coupling table and attaching it with containing the method's :math:`\Gamma^{\{k\}}` coupling matrices for the slow-stiff (implicit) terms in :eq:`ARKODE_IVP_two_rate` - .. c:member:: sunrealtype* c + .. c:member:: int ngroup - An array of length ``[stages]`` containing the slow abscissae :math:`c^S` - for the method + Number of stage groups for the method (only relevant for MERK methods). + + .. c:member:: int** group + + A two-dimensional array with dimensions ``[stages][stages]`` that encodes + which stages should be combined together within fast integration groups + (only relevant for MERK methods). .. _ARKODE.Usage.MRIStep.MRIStepCoupling.Functions: @@ -87,27 +123,27 @@ are defined ``arkode/arkode_mristep.h``. .. _ARKODE.Usage.MRIStep.MRIStepCoupling.Functions.Table: .. table:: MRIStepCoupling functions - +---------------------------------------------+--------------------------------------------------------------------+ - | Function name | Description | - +=============================================+====================================================================+ - | :c:func:`MRIStepCoupling_LoadTable()` | Loads a pre-defined MRIStepCoupling table by ID | - +---------------------------------------------+--------------------------------------------------------------------+ - | :c:func:`MRIStepCoupling_LoadTableByName()` | Loads a pre-defined MRIStepCoupling table by name | - +---------------------------------------------+--------------------------------------------------------------------+ - | :c:func:`MRIStepCoupling_Alloc()` | Allocate an empty MRIStepCoupling table | - +---------------------------------------------+--------------------------------------------------------------------+ - | :c:func:`MRIStepCoupling_Create()` | Create a new MRIStepCoupling table from coefficients | - +---------------------------------------------+--------------------------------------------------------------------+ - | :c:func:`MRIStepCoupling_MIStoMRI()` | Create a new MRIStepCoupling table from a slow Butcher table | - +---------------------------------------------+--------------------------------------------------------------------+ - | :c:func:`MRIStepCoupling_Copy()` | Create a copy of a MRIStepCoupling table | - +---------------------------------------------+--------------------------------------------------------------------+ - | :c:func:`MRIStepCoupling_Space()` | Get the MRIStepCoupling table real and integer workspace sizes | - +---------------------------------------------+--------------------------------------------------------------------+ - | :c:func:`MRIStepCoupling_Free()` | Deallocate a MRIStepCoupling table | - +---------------------------------------------+--------------------------------------------------------------------+ - | :c:func:`MRIStepCoupling_Write()` | Write the MRIStepCoupling table to an output file | - +---------------------------------------------+--------------------------------------------------------------------+ + +-------------------------------------------+--------------------------------------------------------------------+ + | Function name | Description | + +===========================================+====================================================================+ + | :c:func:`MRIStepCoupling_LoadTable` | Loads a pre-defined MRIStepCoupling table by ID | + +-------------------------------------------+--------------------------------------------------------------------+ + | :c:func:`MRIStepCoupling_LoadTableByName` | Loads a pre-defined MRIStepCoupling table by name | + +-------------------------------------------+--------------------------------------------------------------------+ + | :c:func:`MRIStepCoupling_Alloc` | Allocate an empty MRIStepCoupling table | + +-------------------------------------------+--------------------------------------------------------------------+ + | :c:func:`MRIStepCoupling_Create` | Create a new MRIStepCoupling table from coefficients | + +-------------------------------------------+--------------------------------------------------------------------+ + | :c:func:`MRIStepCoupling_MIStoMRI` | Create a new MRIStepCoupling table from a slow Butcher table | + +-------------------------------------------+--------------------------------------------------------------------+ + | :c:func:`MRIStepCoupling_Copy` | Create a copy of a MRIStepCoupling table | + +-------------------------------------------+--------------------------------------------------------------------+ + | :c:func:`MRIStepCoupling_Space` | Get the MRIStepCoupling table real and integer workspace sizes | + +-------------------------------------------+--------------------------------------------------------------------+ + | :c:func:`MRIStepCoupling_Free` | Deallocate a MRIStepCoupling table | + +-------------------------------------------+--------------------------------------------------------------------+ + | :c:func:`MRIStepCoupling_Write` | Write the MRIStepCoupling table to an output file | + +-------------------------------------------+--------------------------------------------------------------------+ .. c:function:: MRIStepCoupling MRIStepCoupling_LoadTable(ARKODE_MRITableID method) @@ -122,7 +158,7 @@ are defined ``arkode/arkode_mristep.h``. pointer if *method* was invalid or an allocation error occurred. -.. c:function:: MRIStepCoupling MRIStepCoupling_LoadTableByName(const char *method) +.. c:function:: MRIStepCoupling MRIStepCoupling_LoadTableByName(const char* method) Retrieves a specified coupling table. For further information on the current set of coupling tables and their corresponding name, see @@ -139,14 +175,14 @@ are defined ``arkode/arkode_mristep.h``. This function is case sensitive. -.. c:function:: MRIStepCoupling MRIStepCoupling_Alloc(int nmat, int stages, int type) +.. c:function:: MRIStepCoupling MRIStepCoupling_Alloc(int nmat, int stages, ARKODE_MRIType type) Allocates an empty MRIStepCoupling table. :param nmat: number of :math:`\Omega^{\{k\}}` and/or :math:`\Gamma^{\{k\}}` matrices in the coupling table. :param stages: number of stages in the coupling table. - :param type: the method type: explicit (0), implicit (1), or ImEx (2). + :param type: the type of MRI method the table will encode. :return value: An :c:type:`MRIStepCoupling` structure if successful. A ``NULL`` pointer if *stages* or *type* was invalid or an allocation error @@ -154,9 +190,15 @@ are defined ``arkode/arkode_mristep.h``. .. note:: - For explicit methods only the W array is allocated, with implicit methods - only the G array is allocated, and for ImEx methods both W and G are - allocated. + For MRISTEP_EXPLICIT tables, the *G* and *group* arrays are not allocated. + + For MRISTEP_IMPLICIT tables, the *W* and *group* arrays are not allocated. + + For MRISTEP_IMEX tables, the *group* array is not allocated. + + For MRISTEP_MERK tables, the *G* array is not allocated. + + For MRISTEP_MRISR tables, the *group* array is not allocated. .. c:function:: MRIStepCoupling MRIStepCoupling_Create(int nmat, int stages, int q, int p, sunrealtype *W, sunrealtype *G, sunrealtype *c) @@ -193,6 +235,7 @@ are defined ``arkode/arkode_mristep.h``. ``nmat * (stages+1) * stages``, in row-major order. The additional "row" is assumed to hold the embedding coefficients. + .. c:function:: MRIStepCoupling MRIStepCoupling_MIStoMRI(ARKodeButcherTable B, int q, int p) Creates an MRI coupling table for a traditional MIS method based on the slow @@ -233,7 +276,7 @@ are defined ``arkode/arkode_mristep.h``. inserts redundant "padding" stages to ensure a solve-decoupled structure and then uses the above formula to fill :math:`\Gamma^{\{0\}}`. - For general slow tables with a least second-order accuracy, the MIS method will + For general slow tables with at least second-order accuracy, the MIS method will be second order. However, if the slow table is at least third order and additionally satisfies @@ -280,6 +323,7 @@ are defined ``arkode/arkode_mristep.h``. :param C: the coupling table. + .. c:function:: void MRIStepCoupling_Write(MRIStepCoupling C, FILE *outfile) Write the coupling table to the provided file pointer. @@ -319,49 +363,65 @@ with values specified for each method below (e.g., ``ARKODE_MIS_KW3``). -.. table:: Explicit MRI-GARK coupling tables. The default method for each order - is marked with an asterisk (:math:`^*`). - - ================================= ============ =============== ===================== - Table name Method Order Embedding Order Reference - ================================= ============ =============== ===================== - ``ARKODE_MRI_GARK_FORWARD_EULER`` :math:`1^*` 0 - ``ARKODE_MRI_GARK_ERK22b`` :math:`2^*` 0 :cite:p:`Sandu:19` - ``ARKODE_MRI_GARK_ERK22a`` 2 1 :cite:p:`Sandu:19` - ``ARKODE_MRI_GARK_RALSTON2`` 2 0 :cite:p:`Roberts:22` - ``ARKODE_MIS_KW3`` :math:`3^*` 0 :cite:p:`Schlegel:09` - ``ARKODE_MRI_GARK_ERK33a`` 3 2 :cite:p:`Sandu:19` - ``ARKODE_MRI_GARK_RALSTON3`` 3 0 :cite:p:`Roberts:22` - ``ARKODE_MRI_GARK_ERK45a`` :math:`4^*` 3 :cite:p:`Sandu:19` - ================================= ============ =============== ===================== - - -.. table:: Diagonally-implicit, solve-decoupled MRI-GARK coupling tables. The - default method for each order is marked with an asterisk - (:math:`^*`). - - ===================================== ============ =============== =============== ================== - Table name Method Order Embedding Order Implicit Solves Reference - ===================================== ============ =============== =============== ================== - ``ARKODE_MRI_GARK_BACKWARD_EULER`` :math:`1^*` 0 1 - ``ARKODE_MRI_GARK_IRK21a`` :math:`2^*` 1 1 :cite:p:`Sandu:19` - ``ARKODE_MRI_GARK_IMPLICIT_MIDPOINT`` 2 0 2 - ``ARKODE_MRI_GARK_ESDIRK34a`` :math:`3^*` 2 3 :cite:p:`Sandu:19` - ``ARKODE_MRI_GARK_ESDIRK46a`` :math:`4^*` 3 5 :cite:p:`Sandu:19` - ===================================== ============ =============== =============== ================== +.. table:: Explicit MRIStep coupling tables. The default method for each order when using + fixed step sizes is marked with an asterisk (:math:`^*`); the default method + for each order when using adaptive time stepping is marked with a circle + (:math:`^\circ`). The "Slow RHS Calls" column corresponds to the number of + calls to the slow right-hand side function, :math:`f^E`, per time step. + + ====================================== ================== =============== ============== ===================== + Table name Method Order Embedding Order Slow RHS Calls Reference + ====================================== ================== =============== ============== ===================== + :index:`ARKODE_MRI_GARK_FORWARD_EULER` :math:`1^*` 0 1 + :index:`ARKODE_MRI_GARK_ERK22a` :math:`2^{\circ}` 1 2 :cite:p:`Sandu:19` + :index:`ARKODE_MRI_GARK_ERK22b` :math:`2^*` 1 2 :cite:p:`Sandu:19` + :index:`ARKODE_MRI_GARK_RALSTON2` 2 0 2 :cite:p:`Roberts:22` + :index:`ARKODE_MERK21` 2 1 2 :cite:p:`Luan:20` + :index:`ARKODE_MIS_KW3` :math:`3^*` 0 3 :cite:p:`Schlegel:09` + :index:`ARKODE_MRI_GARK_ERK33a` :math:`3^{\circ}` 2 3 :cite:p:`Sandu:19` + :index:`ARKODE_MRI_GARK_RALSTON3` 3 0 3 :cite:p:`Roberts:22` + :index:`ARKODE_MERK32` 3 2 3 :cite:p:`Luan:20` + :index:`ARKODE_MRI_GARK_ERK45a` :math:`4^{*\circ}` 3 5 :cite:p:`Sandu:19` + :index:`ARKODE_MERK43` 4 3 6 :cite:p:`Luan:20` + :index:`ARKODE_MERK54` 5 4 10 :cite:p:`Luan:20` + ====================================== ================== =============== ============== ===================== + + +.. table:: Diagonally-implicit, solve-decoupled MRI-GARK coupling tables. The default + method for each order when using fixed step sizes is marked with an asterisk + (:math:`^*`); the default method for each order when using adaptive time + stepping is marked with a circle (:math:`^\circ`). The "Implicit Solves" + column corresponds to the number of slow implicit (non)linear solves required + per time step. + + ========================================== ================== =============== =============== ================== + Table name Method Order Embedding Order Implicit Solves Reference + ========================================== ================== =============== =============== ================== + :index:`ARKODE_MRI_GARK_BACKWARD_EULER` :math:`1^{*\circ}` 0 1 + :index:`ARKODE_MRI_GARK_IRK21a` :math:`2^{*\circ}` 1 1 :cite:p:`Sandu:19` + :index:`ARKODE_MRI_GARK_IMPLICIT_MIDPOINT` 2 0 2 + :index:`ARKODE_MRI_GARK_ESDIRK34a` :math:`3^{*\circ}` 2 3 :cite:p:`Sandu:19` + :index:`ARKODE_MRI_GARK_ESDIRK46a` :math:`4^{*\circ}` 3 5 :cite:p:`Sandu:19` + ========================================== ================== =============== =============== ================== .. table:: Diagonally-implicit, solve-decoupled IMEX-MRI-GARK coupling tables. - The default method for each order is marked with an asterisk - (:math:`^*`). - - ==================================== =========== =============== =================== - Table name Order Implicit Solves Reference - ==================================== =========== =============== =================== - ``ARKODE_IMEX_MRI_GARK_EULER`` :math:`1^*` 1 - ``ARKODE_IMEX_MRI_GARK_TRAPEZOIDAL`` :math:`2^*` 1 - ``ARKODE_IMEX_MRI_GARK_MIDPOINT`` 2 2 - ``ARKODE_IMEX_MRI_GARK3a`` :math:`3^*` 2 :cite:p:`ChiRen:21` - ``ARKODE_IMEX_MRI_GARK3b`` 3 2 :cite:p:`ChiRen:21` - ``ARKODE_IMEX_MRI_GARK4`` :math:`4^*` 5 :cite:p:`ChiRen:21` - ==================================== =========== =============== =================== + The default method for each order when using fixed step sizes is marked + with an asterisk (:math:`^*`); the default method for each order when using + adaptive time stepping is marked with a circle (:math:`^\circ`). The + "Implicit Solves" column corresponds to the number of slow implicit + (non)linear solves required per time step. + + ========================================= ================= =============== =============== =================== + Table name Method Order Embedding Order Implicit Solves Reference + ========================================= ================= =============== =============== =================== + :index:`ARKODE_IMEX_MRI_GARK_EULER` :math:`1^*` 0 1 + :index:`ARKODE_IMEX_MRI_GARK_TRAPEZOIDAL` :math:`2^*` 0 1 + :index:`ARKODE_IMEX_MRI_GARK_MIDPOINT` 2 0 2 + :index:`ARKODE_IMEX_MRI_SR21` :math:`2^{\circ}` 1 3 :cite:p:`Fish:24` + :index:`ARKODE_IMEX_MRI_GARK3a` :math:`3^*` 0 2 :cite:p:`ChiRen:21` + :index:`ARKODE_IMEX_MRI_GARK3b` 3 0 2 :cite:p:`ChiRen:21` + :index:`ARKODE_IMEX_MRI_SR32` :math:`3^{\circ}` 2 4 :cite:p:`Fish:24` + :index:`ARKODE_IMEX_MRI_GARK4` :math:`4^*` 0 5 :cite:p:`ChiRen:21` + :index:`ARKODE_IMEX_MRI_SR43` :math:`4^{\circ}` 3 5 :cite:p:`Fish:24` + ========================================= ================= =============== =============== =================== From f6ff36da3d47c75a4db0f81410d38549242e6354 Mon Sep 17 00:00:00 2001 From: Steven Roberts Date: Fri, 26 Jul 2024 13:50:38 -0700 Subject: [PATCH 009/286] Update default RK methods by order --- include/arkode/arkode_arkstep.h | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/include/arkode/arkode_arkstep.h b/include/arkode/arkode_arkstep.h index f7a6f112f5..960839a805 100644 --- a/include/arkode/arkode_arkstep.h +++ b/include/arkode/arkode_arkstep.h @@ -36,31 +36,33 @@ extern "C" { /* explicit */ static const int ARKSTEP_DEFAULT_ERK_1 = ARKODE_FORWARD_EULER_1_1; -static const int ARKSTEP_DEFAULT_ERK_2 = ARKODE_HEUN_EULER_2_1_2; +// TODO(SBR): replace with FSAL Ralston method +static const int ARKSTEP_DEFAULT_ERK_2 = ARKODE_RALSTON_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_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_4 = ARKODE_SOFRONIOU_SPALETTA_5_3_4; +// TODO(SBR): Consider https://doi.org/10.1016/j.camwa.2011.06.002. Needs extension to quad precision +static const int ARKSTEP_DEFAULT_ERK_5 = ARKODE_DORMAND_PRINCE_7_4_5; +static const int ARKSTEP_DEFAULT_ERK_6 = ARKODE_VERNER_9_5_6; static const int ARKSTEP_DEFAULT_ERK_7 = ARKODE_VERNER_10_6_7; -static const int ARKSTEP_DEFAULT_ERK_8 = ARKODE_FEHLBERG_13_7_8; +static const int ARKSTEP_DEFAULT_ERK_8 = ARKODE_VERNER_13_7_8; static const int ARKSTEP_DEFAULT_ERK_9 = ARKODE_VERNER_16_8_9; /* implicit */ static const int ARKSTEP_DEFAULT_DIRK_1 = ARKODE_BACKWARD_EULER_1_1; -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_5 = ARKODE_ARK548L2SA_DIRK_8_4_5; +static const int ARKSTEP_DEFAULT_DIRK_2 = ARKODE_ARK2_DIRK_3_1_2; +static const int ARKSTEP_DEFAULT_DIRK_3 = ARKODE_ESDIRK325L2SA_5_2_3; +static const int ARKSTEP_DEFAULT_DIRK_4 = ARKODE_ESDIRK436L2SA_6_3_4; +static const int ARKSTEP_DEFAULT_DIRK_5 = ARKODE_ESDIRK547L2SA2_7_4_5; /* ImEx */ static const int ARKSTEP_DEFAULT_ARK_ETABLE_2 = ARKODE_ARK2_ERK_3_1_2; static const int ARKSTEP_DEFAULT_ARK_ETABLE_3 = ARKODE_ARK324L2SA_ERK_4_2_3; -static const int ARKSTEP_DEFAULT_ARK_ETABLE_4 = ARKODE_ARK436L2SA_ERK_6_3_4; -static const int ARKSTEP_DEFAULT_ARK_ETABLE_5 = ARKODE_ARK548L2SA_ERK_8_4_5; +static const int ARKSTEP_DEFAULT_ARK_ETABLE_4 = ARKODE_ARK437L2SA_ERK_7_3_4; +static const int ARKSTEP_DEFAULT_ARK_ETABLE_5 = ARKODE_ARK548L2SAb_ERK_8_4_5; static const int ARKSTEP_DEFAULT_ARK_ITABLE_2 = ARKODE_ARK2_DIRK_3_1_2; static const int ARKSTEP_DEFAULT_ARK_ITABLE_3 = ARKODE_ARK324L2SA_DIRK_4_2_3; -static const int ARKSTEP_DEFAULT_ARK_ITABLE_4 = ARKODE_ARK436L2SA_DIRK_6_3_4; -static const int ARKSTEP_DEFAULT_ARK_ITABLE_5 = ARKODE_ARK548L2SA_DIRK_8_4_5; +static const int ARKSTEP_DEFAULT_ARK_ITABLE_4 = ARKODE_ARK437L2SA_DIRK_7_3_4; +static const int ARKSTEP_DEFAULT_ARK_ITABLE_5 = ARKODE_ARK548L2SAb_DIRK_8_4_5; /* ------------------- * Exported Functions From 6152fce58e0350429eec0993c5121d9235ac4890 Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Fri, 26 Jul 2024 17:04:12 -0500 Subject: [PATCH 010/286] Documentation updates --- .../source/Usage/MRIStep/MRIStepCoupling.rst | 43 +++--- .../SUNAdaptController_links.rst | 5 + .../SUNAdaptController_Description.rst | 126 ++++++++++++++++- .../SUNAdaptController_MRICC.rst | 102 ++++++++++++++ .../SUNAdaptController_MRIHTol.rst | 109 +++++++++++++++ .../SUNAdaptController_MRILL.rst | 131 ++++++++++++++++++ .../SUNAdaptController_MRIPI.rst | 119 ++++++++++++++++ .../SUNAdaptController_MRIPID.rst | 130 +++++++++++++++++ 8 files changed, 747 insertions(+), 18 deletions(-) create mode 100644 doc/shared/sunadaptcontroller/SUNAdaptController_MRICC.rst create mode 100644 doc/shared/sunadaptcontroller/SUNAdaptController_MRIHTol.rst create mode 100644 doc/shared/sunadaptcontroller/SUNAdaptController_MRILL.rst create mode 100644 doc/shared/sunadaptcontroller/SUNAdaptController_MRIPI.rst create mode 100644 doc/shared/sunadaptcontroller/SUNAdaptController_MRIPID.rst diff --git a/doc/arkode/guide/source/Usage/MRIStep/MRIStepCoupling.rst b/doc/arkode/guide/source/Usage/MRIStep/MRIStepCoupling.rst index abb7d7ed28..da7479dfcc 100644 --- a/doc/arkode/guide/source/Usage/MRIStep/MRIStepCoupling.rst +++ b/doc/arkode/guide/source/Usage/MRIStep/MRIStepCoupling.rst @@ -23,26 +23,25 @@ coupling tables and their corresponding identifiers. Additionally, a user may supply a custom set of slow-to-fast time scale coupling coefficients by constructing a coupling table and attaching it with :c:func:`MRIStepSetCoupling`. A given MRI coupling table can encode any of -the MRI methods supported by MRIStep. These types are determined by an -enumerated type, :c:type:`ARKODE_MRIType`: +the MRI methods supported by MRIStep. The family of MRI method encoded +by the table is determined by an enumerated type, :c:type:`ARKODE_MRIType`: .. c:type:: ARKODE_MRIType This may take any of the following constants: * :index:`MRISTEP_EXPLICIT` -- indicates an MRI-GARK method that - does not include a slow implicit operator, :math:`f^I`. + does not support a slow implicit operator, :math:`f^I`. * :index:`MRISTEP_IMPLICIT` -- indicates an MRI-GARK method that - does not include a slow explicit operator, :math:`f^E`. + does not support a slow explicit operator, :math:`f^E`. * :index:`MRISTEP_IMEX` -- indicates an IMEX-MRK-GARK method. * :index:`MRISTEP_MERK` -- indicates a MERK method, that by definition - does not include a slow implicit operator, :math:`f^I`. + does not support a slow implicit operator, :math:`f^I`. - * :index:`MRISTEP_MRISR` -- indicates an IMEX-MRI-SR method, with time - scale that is any one of explicit, implicit, or implicit-explicit. + * :index:`MRISTEP_MRISR` -- indicates an IMEX-MRI-SR method. The MRI coupling tables themselves are stored in an :c:func:`MRIStepCoupling` object which is a pointer to a @@ -200,6 +199,11 @@ are defined ``arkode/arkode_mristep.h``. For MRISTEP_MRISR tables, the *group* array is not allocated. + .. versionchanged:: x.y.z + + In previous releases, this function did not include the *type* argument. + + .. c:function:: MRIStepCoupling MRIStepCoupling_Create(int nmat, int stages, int q, int p, sunrealtype *W, sunrealtype *G, sunrealtype *c) @@ -223,17 +227,24 @@ are defined ``arkode/arkode_mristep.h``. .. note:: - The arrays *W* and *G* are assumed to have different sizes depending - on the embedding input, *p*. + This routine can only be used to create coupling tables with type + ``MRISTEP_EXPLICIT``, ``MRISTEP_IMPLICIT``, or ``MRISTEP_IMEX``. The + routine determines the relevant type based on whether either of the + arguments *W* and *G* are ``NULL``. Users who wish to create MRI + methods of type ``MRISTEP_MERK`` or ``MRISTEP_MRISR`` must currently + do so manually. + + The assumed size of the input arrays *W* and *G* depends on the + input value for the embedding order of accuracy, *p*. - Non-embedded methods should be indicated by an input *p=0*, in which - case *W* and/or *G* should have entries stored as a 1D array of size - ``nmat * stages * stages``, in row-major order. + * Non-embedded methods should be indicated by an input *p=0*, in which + case *W* and/or *G* should have entries stored as a 1D array of size + ``nmat * stages * stages``, in row-major order. - Embedded methods should be indicated by an input *p>0*, in which - case *W* and/or *G* should have entries stored as a 1D array of size - ``nmat * (stages+1) * stages``, in row-major order. The additional - "row" is assumed to hold the embedding coefficients. + * Embedded methods should be indicated by an input *p>0*, in which + case *W* and/or *G* should have entries stored as a 1D array of size + ``nmat * (stages+1) * stages``, in row-major order. The additional + "row" is assumed to hold the embedding coefficients. .. c:function:: MRIStepCoupling MRIStepCoupling_MIStoMRI(ARKodeButcherTable B, int q, int p) diff --git a/doc/arkode/guide/source/sunadaptcontroller/SUNAdaptController_links.rst b/doc/arkode/guide/source/sunadaptcontroller/SUNAdaptController_links.rst index 081cb80650..7e1ec4d919 100644 --- a/doc/arkode/guide/source/sunadaptcontroller/SUNAdaptController_links.rst +++ b/doc/arkode/guide/source/sunadaptcontroller/SUNAdaptController_links.rst @@ -13,3 +13,8 @@ .. include:: ../../../../shared/sunadaptcontroller/SUNAdaptController_Description.rst .. include:: ../../../../shared/sunadaptcontroller/SUNAdaptController_Soderlind.rst .. include:: ../../../../shared/sunadaptcontroller/SUNAdaptController_ImExGus.rst +.. include:: ../../../../shared/sunadaptcontroller/SUNAdaptController_MRIHTol.rst +.. include:: ../../../../shared/sunadaptcontroller/SUNAdaptController_MRICC.rst +.. include:: ../../../../shared/sunadaptcontroller/SUNAdaptController_MRILL.rst +.. include:: ../../../../shared/sunadaptcontroller/SUNAdaptController_MRIPI.rst +.. include:: ../../../../shared/sunadaptcontroller/SUNAdaptController_MRIPID.rst diff --git a/doc/shared/sunadaptcontroller/SUNAdaptController_Description.rst b/doc/shared/sunadaptcontroller/SUNAdaptController_Description.rst index 91e94abbf0..971d231dca 100644 --- a/doc/shared/sunadaptcontroller/SUNAdaptController_Description.rst +++ b/doc/shared/sunadaptcontroller/SUNAdaptController_Description.rst @@ -18,6 +18,8 @@ The SUNAdaptController API .. versionadded:: 6.7.0 +.. versionchanged:: x.y.z + 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 @@ -75,10 +77,18 @@ The virtual table structure is defined as The function implementing :c:func:`SUNAdaptController_Destroy` - .. c:member:: SUNErrCode (*estimatestep)(SUNAdaptController C, sunrealtype h, int p, sunrealtype dsm, sunrealtype* hnew); + .. c:member:: SUNErrCode (*estimatestep)(SUNAdaptController C, sunrealtype h, int p, sunrealtype dsm, sunrealtype* hnew) The function implementing :c:func:`SUNAdaptController_EstimateStep` + .. c:member:: SUNErrCode (*estimatemristeps)(SUNAdaptController C, sunrealtype H, sunrealtype h, int P, sunrealtype DSM, sunrealtype dsm, sunrealtype* Hnew, sunrealtype* hnew) + + The function implementing :c:func:`SUNAdaptController_EstimateMRISteps` + + .. c:member:: SUNErrCode (*estimatesteptol)(SUNAdaptController C, sunrealtype H, sunrealtype tolfac, int P, sunrealtype DSM, sunrealtype dsm, sunrealtype* Hnew, sunrealtype* tolfacnew) + + The function implementing :c:func:`SUNAdaptController_EstimateStepTol` + .. c:member:: SUNErrCode (*reset)(SUNAdaptController C) The function implementing :c:func:`SUNAdaptController_Reset` @@ -99,6 +109,14 @@ The virtual table structure is defined as The function implementing :c:func:`SUNAdaptController_UpdateH` + .. c:member:: SUNErrCode (*updatemrih)(SUNAdaptController C, sunrealtype H, sunrealtype h, sunrealtype DSM, sunrealtype dsm) + + The function implementing :c:func:`SUNAdaptController_UpdateMRIH` + + .. c:member:: SUNErrCode (*updatemritol)(SUNAdaptController C, sunrealtype H, sunrealtype tolfac, sunrealtype DSM, sunrealtype dsm) + + The function implementing :c:func:`SUNAdaptController_UpdateMRITol` + .. c:member:: SUNErrCode (*space)(SUNAdaptController C, long int *lenrw, long int *leniw) The function implementing :c:func:`SUNAdaptController_Space` @@ -128,6 +146,16 @@ following set of SUNAdaptController types: Controls a single-rate step size. +.. c:enumerator:: SUN_ADAPTCONTROLLER_MRI_H + + Controls both slow and fast time steps within a multirate simulation that has + two time scales. + +.. c:enumerator:: SUN_ADAPTCONTROLLER_MRI_TOL + + Controls both a slow time step and a tolerance factor to apply on the next-faster + time scale within a multirate simulation that has an arbitrary number of time scales. + .. _SUNAdaptController.Description.operations: @@ -225,6 +253,58 @@ note these requirements below. Additionally, we note the behavior of the base SU retval = SUNAdaptController_EstimateStep(C, hcur, p, dsm, &hnew); +.. c:function:: SUNErrCode SUNAdaptController_EstimateMRISteps(SUNAdaptController C, sunrealtype H, sunrealtype h, int P, sunrealtype DSM, sunrealtype dsm, sunrealtype* Hnew, sunrealtype* hnew) + + Estimates slow and fast step sizes within a two-time-scale multirate application. + This routine is required for controllers of type ``SUN_ADAPTCONTROLLER_MRI_H``. + If this is not provided by the implementation, the base class method will set + ``*Hnew = H`` and ``*hnew = h`` and return. + + :param C: the :c:type:`SUNAdaptController` object. + :param H: the slow step size from the previous step attempt. + :param h: the fast size from the previous step attempt. + :param P: the current order of accuracy for the slow time scale integration method. + :param DSM: the slow time scale local temporal estimate from the previous step attempt. + :param dsm: the fast time scale local temporal estimate from the previous step attempt. + :param Hnew: (output) the estimated slow step size. + :param hnew: (output) the estimated fast step size. + :return: :c:type:`SUNErrCode` indicating success or failure. + + Usage: + + .. code-block:: c + + retval = SUNAdaptController_EstimateMRISteps(C, Hcur, hcur, P, DSM, dsm, &Hnew, &hnew); + +.. c:function:: SUNErrCode SUNAdaptController_EstimateStepTol(SUNAdaptController C, sunrealtype H, sunrealtype tolfac, int P, sunrealtype DSM, sunrealtype dsm, sunrealtype* Hnew, sunrealtype* tolfacnew) + + Estimates a slow step size and a fast tolerance multiplication factor + for two adjacent time scales within a multirate application. This + routine is required for controllers of type ``SUN_ADAPTCONTROLLER_MRI_TOL``. + If this is not provided by the implementation, the base class method will set + ``*Hnew = H`` and ``*tolfacnew = tolfac`` and return. + + :param C: the :c:type:`SUNAdaptController` object. + :param H: the slow step size from the previous step attempt. + :param tolfac: the current relative tolerance factor for the next-faster time scale. + :param P: the current order of accuracy for the slow time scale integration method. + :param DSM: the slow time scale local temporal estimate from the previous step attempt. + :param dsm: the fast time scale local temporal estimate from the previous step attempt. + :param Hnew: (output) the estimated slow step size. + :param tolfacnew: (output) the estimated relative tolerance factor. + :return: :c:type:`SUNErrCode` indicating success or failure. + + .. note:: + + If the current [slow] time scale has relative tolerance :math:`rtol`, then the + next-faster time scale will be called with relative tolerance :math:`tolfac * rtol`. + + Usage: + + .. code-block:: c + + retval = SUNAdaptController_EstimateStepTol(C, Hcur, tolfac, P, DSM, dsm, &Hnew, &tolfacnew); + .. c:function:: SUNErrCode SUNAdaptController_Reset(SUNAdaptController C) Resets the controller to its initial state, e.g., if it stores a small number @@ -285,7 +365,7 @@ note these requirements below. Additionally, we note the behavior of the base SU .. c:function:: SUNErrCode SUNAdaptController_UpdateH(SUNAdaptController C, sunrealtype h, sunrealtype dsm) - Notifies a controller of type SUN_ADAPTCONTROLLER_H that a successful time step + Notifies a controller of type ``SUN_ADAPTCONTROLLER_H`` that a successful time step was taken with stepsize *h* and local error factor *dsm*, indicating that these can be saved for subsequent controller functions. This is typically relevant for controllers that store a history of either step sizes or error estimates for @@ -302,6 +382,48 @@ note these requirements below. Additionally, we note the behavior of the base SU retval = SUNAdaptController_UpdateH(C, h, dsm); +.. c:function:: SUNErrCode SUNAdaptController_UpdateMRIH(SUNAdaptController C, sunrealtype H, sunrealtype h, sunrealtype DSM, sunrealtype dsm) + + Notifies a controller of type ``SUN_ADAPTCONTROLLER_MRI_H`` that a successful time step + was taken with slow stepsize *H* and fast stepsize *h*, and that the step had slow and + fast local error factors *DSM* and *dsm*, indicating that these can be saved for + subsequent controller functions. This is typically relevant for controllers that store a + history of either step sizes or error estimates for performing the estimation process. + + :param C: the :c:type:`SUNAdaptController` object. + :param H: the successful 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: :c:type:`SUNErrCode` indicating success or failure. + + Usage: + + .. code-block:: c + + retval = SUNAdaptController_UpdateMRIH(C, H, h, DSM, dsm); + +.. c:function:: SUNErrCode SUNAdaptController_UpdateMRITol(SUNAdaptController C, sunrealtype H, sunrealtype tolfac, sunrealtype DSM, sunrealtype dsm) + + Notifies a controller of type ``SUN_ADAPTCONTROLLER_MRI_TOL`` that a successful time step + was taken with slow stepsize *H* and fast relative tolerance factor *tolfac*, and that the + step had slow and fast local error factors *DSM* and *dsm*, indicating that these can be + saved for subsequent controller functions. This is typically relevant for controllers that + store a history of either step sizes or error estimates for performing the estimation process. + + :param C: the :c:type:`SUNAdaptController` object. + :param H: the successful slow step size. + :param tolfac: the successful fast time scale relative tolerance factor. + :param DSM: the successful slow temporal error estimate. + :param dsm: the successful fast temporal error estimate. + :return: :c:type:`SUNErrCode` indicating success or failure. + + Usage: + + .. code-block:: c + + retval = SUNAdaptController_UpdateMRITol(C, H, tolfac, DSM, dsm); + .. c:function:: SUNErrCode SUNAdaptController_Space(SUNAdaptController C, long int *lenrw, long int *leniw) Informative routine that returns the memory requirements of the diff --git a/doc/shared/sunadaptcontroller/SUNAdaptController_MRICC.rst b/doc/shared/sunadaptcontroller/SUNAdaptController_MRICC.rst new file mode 100644 index 0000000000..fe91617e58 --- /dev/null +++ b/doc/shared/sunadaptcontroller/SUNAdaptController_MRICC.rst @@ -0,0 +1,102 @@ +.. + Programmer(s): Daniel R. Reynolds @ SMU + ---------------------------------------------------------------- + SUNDIALS Copyright Start + Copyright (c) 2002-2024, 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.MRICC: + +The SUNAdaptController_MRICC Module +======================================= + +.. versionadded:: x.y.z + +The MRICC implementation of the SUNAdaptController class, +SUNAdaptController_MRICC, implements the "constant-constant" multirate temporal +controller proposed in :cite:p:`Fish:23`. This controller has the form + +.. math:: + H' &= H_n \left(\varepsilon^s_n\right)^{\alpha},\\ + M' &= \left\lceil\frac{H_n}{h_n}\right\rceil \left(\varepsilon^s_n\right)^{\beta_1} \left(\varepsilon^f_n\right)^{\beta_2},\\ + h' &= H'/M' + +where :math:`\alpha = \frac{k_1}{P}`, :math:`\beta_1 = \frac{(p+1)k_1}{Pp}`, and +:math:`\beta_2 = -\frac{k_2}{p}`, and where :math:`P` and :math:`p` are the global +orders of accuracy for the slow and fast time integration methods, respectively. +The default parameter values are :math:`k_1 = 0.42` and :math:`k_2 = 0.44`. In +these estimate, a floor of :math:`\varepsilon^*_* > 10\epsilon_{mach}` is enforced +to avoid division-by-zero errors, where :math:`\epsilon_{mach}` is floating point +roundoff for the current working precision. + +The SUNAdaptController_MRICC controller is implemented as a derived +SUNAdaptController class having type ``SUN_ADAPTCONTROLLER_MRI_H``, and its +*content* field is: + +.. code-block:: c + + struct _SUNAdaptControllerContent_MRICC { + sunrealtype k1; + sunrealtype k2; + sunrealtype bias; + int p; + }; + +These entries of the *content* field contain the following information: + +* ``k1, k2`` - controller parameters above. + +* ``bias`` - error bias factor, that converts from input temporal error + estimates via :math:`\varepsilon^s = \text{bias}*\text{DSM}` and + :math:`\varepsilon^f = \text{bias}*\text{dsm}`. The default bias value is 1.5. + +* ``p`` - global order of accuracy for the fast time scale solver. + +The header file to be included when using this module is +``sunadaptcontroller/sunadaptcontroller_mricc.h``. + +The SUNAdaptController_MRICC class provides implementations of all operations +relevant to a ``SUN_ADAPTCONTROLLER_MRI_H`` controller listed in +:numref:`SUNAdaptController.Description.operations`. This class +also provides the following additional user-callable routines: + + +.. c:function:: SUNAdaptController SUNAdaptController_MRICC(SUNContext sunctx, int p) + + This constructor creates and allocates memory for a SUNAdaptController_MRICC + object, and inserts its default parameters. + + :param sunctx: the current :c:type:`SUNContext` object. + :param p: the global order of accuracy for the fast time scale solver. + :return: if successful, a usable :c:type:`SUNAdaptController` object; + otherwise it will return ``NULL``. + + Usage: + + .. code-block:: c + + SUNAdaptController C = SUNAdaptController_MRICC(sunctx, 3); + +.. c:function:: SUNErrCode SUNAdaptController_SetParams_MRICC(SUNAdaptController C, sunrealtype k1, sunrealtype k2) + + This user-callable function provides control over the relevant parameters + above. This should be called *before* the time integrator is called to evolve + the problem. + + :param C: the SUNAdaptController_MRICC object. + :param k1: parameter used within the controller time step estimate. + :param k2: parameter used within the controller time step estimate. + :return: :c:type:`SUNErrCode` indicating success or failure. + + Usage: + + .. code-block:: c + + retval = SUNAdaptController_SetParams_MRICC(C, 0.42, 0.44); diff --git a/doc/shared/sunadaptcontroller/SUNAdaptController_MRIHTol.rst b/doc/shared/sunadaptcontroller/SUNAdaptController_MRIHTol.rst new file mode 100644 index 0000000000..cad898f97a --- /dev/null +++ b/doc/shared/sunadaptcontroller/SUNAdaptController_MRIHTol.rst @@ -0,0 +1,109 @@ +.. + Programmer(s): Daniel R. Reynolds @ SMU + ---------------------------------------------------------------- + SUNDIALS Copyright Start + Copyright (c) 2002-2024, 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.MRIHTol: + +The SUNAdaptController_MRIHTol Module +======================================= + +.. versionadded:: x.y.z + +The MRIHTol implementation of the SUNAdaptController class, +SUNAdaptController_MRIHTol, implements a general structure for telescopic +multirate temporal control. This controller has the form + +.. math:: + h' = h_n \varepsilon_n^{-k_1/(p+1)} \varepsilon_{n-1}^{-k_2/(p+1)} \varepsilon_{n-2}^{-k_3/(p+1)} \left(\dfrac{h_n}{h_{n-1}}\right)^{k_4} \left(\dfrac{h_{n-1}}{h_{n-2}}\right)^{k_5} + +with default parameter values :math:`k_1 = 1.25`, :math:`k_2 = 0.5`, +:math:`k_3 = -0.75`, :math:`k_4 = 0.25`, and :math:`k_5 = 0.75`, where +:math:`p` is the global order of the time integration method. In this estimate, +a floor of :math:`\varepsilon_* > 10^{-10}` is enforced to avoid division-by-zero +errors. During the first two steps (when :math:`\varepsilon_{n-2}`, +:math:`\varepsilon_{n-1}`, :math:`h_{n-2}`, and :math:`h_{n-2}` may be unavailable), +the corresponding terms are merely omitted during estimation of :math:`h'`. + +The SUNAdaptController_Soderlind controller is implemented as a derived +SUNAdaptController class, and defines its *content* field as: + +.. code-block:: c + + struct _SUNAdaptControllerContent_Soderlind { + SUNAdaptController HControl; + SUNAdaptController TolControl; + sunrealtype inner_max_relch; + sunrealtype inner_min_tolfac; + sunrealtype inner_max_tolfac; + }; + +These entries of the *content* field contain the following information: + +* ``HControl`` - single time-scale SUNAdaptController object to adapt + the current step size, :math:`H`. + +* ``TolControl`` - single time-scale SUNAdaptController object to adapt + the fast time scale relative tolerance factor, :math:`reltol`. + +* ``inner_max_relch`` - bound on the relative change in :math:`tolfac` from one + step to the next. + +* ``inner_min_tolfac`` - absolute lower bound on :math:`tolfac`, to avoid calling + the inner integrator with an arbitrarily small tolerance. + +* ``inner_max_tolfac`` - absolute upper bound on :math:`tolfac`, to avoid calling + the inner integrator with too loose of a tolerance. + +The header file to be included when using this module is +``sunadaptcontroller/sunadaptcontroller_mrihtol.h``. + +The SUNAdaptController_Soderlind class provides implementations of all operations +relevant to a ``SUN_ADAPTCONTROLLER_MRI_TOL`` controller listed in +:numref:`SUNAdaptController.Description.operations`. This class +also provides the following additional user-callable routines: + + +.. c:function:: SUNAdaptController SUNAdaptController_MRIHTol(SUNContext sunctx, SUNAdaptController HControl, SUNAdaptController TolControl) + + This constructor creates and allocates memory for a SUNAdaptController_MRIHTol + object, and inserts its default parameters. + + :param sunctx: the current :c:type:`SUNContext` object. + :param HControl: the slow time step adaptivity controller object. + :param TolControl: the fast time scale tolerance factor adaptivity controller object. + :return: if successful, a usable :c:type:`SUNAdaptController` object; + otherwise it will return ``NULL``. + + Usage: + + .. code-block:: c + + SUNAdaptController C = SUNAdaptController_MRIHTol(sunctx, HControl, TolControl); + +.. c:function:: SUNErrCode SUNAdaptController_SetParams_MRIHTol(SUNAdaptController C, sunrealtype inner_max_relch, sunrealtype inner_min_tolfac, sunrealtype inner_max_tolfac) + + 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_MRIHTol object. + :param inner_max_relch: parameter used within the controller time step estimate. + :param inner_min_tolfac: parameter used within the controller time step estimate. + :param inner_max_tolfac: parameter used within the controller time step estimate. + :return: :c:type:`SUNErrCode` indicating success or failure. + + Usage: + + .. code-block:: c + + retval = SUNAdaptController_SetParams_MRIHTol(C, 20.0, 1e-4, 1.0); diff --git a/doc/shared/sunadaptcontroller/SUNAdaptController_MRILL.rst b/doc/shared/sunadaptcontroller/SUNAdaptController_MRILL.rst new file mode 100644 index 0000000000..13d2de9428 --- /dev/null +++ b/doc/shared/sunadaptcontroller/SUNAdaptController_MRILL.rst @@ -0,0 +1,131 @@ +.. + Programmer(s): Daniel R. Reynolds @ SMU + ---------------------------------------------------------------- + SUNDIALS Copyright Start + Copyright (c) 2002-2024, 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.MRILL: + +The SUNAdaptController_MRILL Module +======================================= + +.. versionadded:: x.y.z + +The MRILL implementation of the SUNAdaptController class, +SUNAdaptController_MRILL, implements the "linear-linear" multirate temporal +controller proposed in :cite:p:`Fish:23`. This controller has the form + +.. math:: + H' &= H_n \left(\frac{H_n}{H_{n-1}}\right) \left(\varepsilon^s_n\right)^{\alpha_1} \left(\varepsilon^s_{n-1}\right)^{\alpha_2},\\ + M' &= M_n \left(\frac{M_n}{M_{n-1}}\right) \left(\varepsilon^s_n\right)^{\beta_{11}} \left(\varepsilon^s_{n-1}\right)^{\beta_{12}} \left(\varepsilon^f_n\right)^{\beta_{21}} \left(\varepsilon^f_{n-1}\right)^{\beta_{22}},\\ + h' &= H'/M' + +where :math:`M_n = \left\lceil\frac{H_n}{h_n}\right\rceil`, +:math:`M_{n-1} = \left\lceil\frac{H_{n-1}}{h_{n-1}}\right\rceil`, +:math:`\alpha_1 = \frac{k_{11}+k_{12}}{2P}`, :math:`\alpha_2 = -\frac{k_{11}}{2P}`, +:math:`\beta_{11} = \frac{(p+1)(k_{11}+k_{12})}{2Pp}`, +:math:`\beta_{12} = -\frac{(p+1)k_{11}}{2Pp}`, +:math:`\beta_{21} = -\frac{k_{21}+k_{22}}{2p}`, and +:math:`\beta_{22} = \frac{k_{21}}{2p}`, and where :math:`P` and :math:`p` are the global +orders of accuracy for the slow and fast time integration methods, respectively. +The default parameter values are :math:`k_{11} = 0.82`, :math:`k_{12} = 0.54`, +:math:`k_{21} = 0.94` and :math:`k_{22} = 0.9`. In these estimate, a floor of +:math:`\varepsilon^*_* > 10\epsilon_{mach}` is enforced to avoid division-by-zero errors, +where :math:`\epsilon_{mach}` is floating point roundoff for the current working precision. +During the first step (when :math:`\varepsilon^s_{n-1}`, +:math:`\varepsilon^f_{n-1}`, :math:`H_{n-1}`, and :math:`h_{n-1}` are unavailable), +the corresponding temporal errors and step size and multirate ratios, +:math:`\varepsilon^s_{n-1}`, :math:`\varepsilon^f_{n-1}`, +:math:`\left(\frac{H_n}{H_{n-1}}\right)` and :math:`\left(\frac{M_n}{M_{n-1}}\right)`, are +set to 1, effectively removing them from the estimation formula. + +The SUNAdaptController_MRILL controller is implemented as a derived +SUNAdaptController class having type ``SUN_ADAPTCONTROLLER_MRI_H``, and its +*content* field is: + +.. code-block:: c + + struct _SUNAdaptControllerContent_MRILL { + sunrealtype k11; + sunrealtype k12; + sunrealtype k21; + sunrealtype k22; + sunrealtype bias; + sunrealtype esp; + sunrealtype efp; + sunrealtype hsp; + sunrealtype hfp; + int p; + sunbooleantype firststep; + }; + +These entries of the *content* field contain the following information: + +* ``k11, k12, k21, k22`` - controller parameters above. + +* ``bias`` - error bias factor, that converts from input temporal error + estimates via :math:`\varepsilon^s = \text{bias}*\text{DSM}` and + :math:`\varepsilon^f = \text{bias}*\text{dsm}`. The default bias value is 1.5. + +* ``esp, efp`` - storage for the previous slow and fast error estimates, + :math:`\varepsilon^s_{n-1}` and :math:`\varepsilon^f_{n-1}`. + +* ``hsp, hfp`` - storage for the previous slow and fast step sizes, :math:`H_{n-1}` + and :math:`h_{n-1}`. + +* ``p`` - global order of accuracy for the fast time scale solver. + +* ``firststep`` - counter to handle first (where the previous step + sizes and errors are unavailable). + +The header file to be included when using this module is +``sunadaptcontroller/sunadaptcontroller_mrill.h``. + +The SUNAdaptController_MRILL class provides implementations of all operations +relevant to a ``SUN_ADAPTCONTROLLER_MRI_H`` controller listed in +:numref:`SUNAdaptController.Description.operations`. This class +also provides the following additional user-callable routines: + + +.. c:function:: SUNAdaptController SUNAdaptController_MRILL(SUNContext sunctx, int p) + + This constructor creates and allocates memory for a SUNAdaptController_MRILL + object, and inserts its default parameters. + + :param sunctx: the current :c:type:`SUNContext` object. + :param p: the global order of accuracy for the fast time scale solver. + :return: if successful, a usable :c:type:`SUNAdaptController` object; + otherwise it will return ``NULL``. + + Usage: + + .. code-block:: c + + SUNAdaptController C = SUNAdaptController_MRILL(sunctx, 3); + +.. c:function:: SUNErrCode SUNAdaptController_SetParams_MRILL(SUNAdaptController C, sunrealtype k11, sunrealtype k12, sunrealtype k21, sunrealtype k22) + + 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_MRILL object. + :param k11: parameter used within the controller time step estimate. + :param k12: parameter used within the controller time step estimate. + :param k21: parameter used within the controller time step estimate. + :param k22: parameter used within the controller time step estimate. + :return: :c:type:`SUNErrCode` indicating success or failure. + + Usage: + + .. code-block:: c + + retval = SUNAdaptController_SetParams_MRILL(C, 0.82, 0.54, 0.94, 0.9); diff --git a/doc/shared/sunadaptcontroller/SUNAdaptController_MRIPI.rst b/doc/shared/sunadaptcontroller/SUNAdaptController_MRIPI.rst new file mode 100644 index 0000000000..e46db95bbb --- /dev/null +++ b/doc/shared/sunadaptcontroller/SUNAdaptController_MRIPI.rst @@ -0,0 +1,119 @@ +.. + Programmer(s): Daniel R. Reynolds @ SMU + ---------------------------------------------------------------- + SUNDIALS Copyright Start + Copyright (c) 2002-2024, 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.MRIPI: + +The SUNAdaptController_MRIPI Module +======================================= + +.. versionadded:: x.y.z + +The MRIPI implementation of the SUNAdaptController class, +SUNAdaptController_MRIPI, implements the "PIMR" multirate temporal +controller proposed in :cite:p:`Fish:23`. This controller has the form + +.. math:: + H' &= H_n \left(\varepsilon^s_n\right)^{\alpha_1} \left(\varepsilon^s_{n-1}\right)^{\alpha_2},\\ + M' &= M_n \left(\varepsilon^s_n\right)^{\beta_{11}} \left(\varepsilon^s_{n-1}\right)^{\beta_{12}} \left(\varepsilon^f_n\right)^{\beta_{21}} \left(\varepsilon^f_{n-1}\right)^{\beta_{22}},\\ + h' &= H'/M' + +where :math:`M_n = \left\lceil\frac{H_n}{h_n}\right\rceil`, +:math:`\alpha_1 = \frac{k_{11}+k_{12}}{2P}`, :math:`\alpha_2 = -\frac{k_{11}}{2P}`, +:math:`\beta_{11} = \frac{(p+1)(k_{11}+k_{12})}{2Pp}`, +:math:`\beta_{12} = -\frac{(p+1)k_{11}}{2Pp}`, +:math:`\beta_{21} = -\frac{k_{21}+k_{22}}{2p}`, and +:math:`\beta_{22} = \frac{k_{21}}{2p}`, and where :math:`P` and :math:`p` are the global +orders of accuracy for the slow and fast time integration methods, respectively. +The default parameter values are :math:`k_{11} = 0.18`, :math:`k_{12} = 0.86`, +:math:`k_{21} = 0.34` and :math:`k_{22} = 0.8`. In these estimate, a floor of +:math:`\varepsilon^*_* > 10\epsilon_{mach}` is enforced to avoid division-by-zero errors, +where :math:`\epsilon_{mach}` is floating point roundoff for the current working precision. +During the first step (when :math:`\varepsilon^s_{n-1}`, +:math:`\varepsilon^f_{n-1}` are unavailable), +the corresponding temporal errors :math:`\varepsilon^s_{n-1}` and :math:`\varepsilon^f_{n-1}` are +set to 1, effectively removing them from the estimation formula. + +The SUNAdaptController_MRIPI controller is implemented as a derived +SUNAdaptController class having type ``SUN_ADAPTCONTROLLER_MRI_H``, and its +*content* field is: + +.. code-block:: c + + struct _SUNAdaptControllerContent_MRIPI { + sunrealtype k11; + sunrealtype k12; + sunrealtype k21; + sunrealtype k22; + sunrealtype bias; + sunrealtype esp; + sunrealtype efp; + int p; + }; + +These entries of the *content* field contain the following information: + +* ``k11, k12, k21, k22`` - controller parameters above. + +* ``bias`` - error bias factor, that converts from input temporal error + estimates via :math:`\varepsilon^s = \text{bias}*\text{DSM}` and + :math:`\varepsilon^f = \text{bias}*\text{dsm}`. The default bias value is 1.5. + +* ``esp, efp`` - storage for the previous slow and fast error estimates, + :math:`\varepsilon^s_{n-1}` and :math:`\varepsilon^f_{n-1}`. + +* ``p`` - global order of accuracy for the fast time scale solver. + +The header file to be included when using this module is +``sunadaptcontroller/sunadaptcontroller_mripi.h``. + +The SUNAdaptController_MRIPI class provides implementations of all operations +relevant to a ``SUN_ADAPTCONTROLLER_MRI_H`` controller listed in +:numref:`SUNAdaptController.Description.operations`. This class +also provides the following additional user-callable routines: + + +.. c:function:: SUNAdaptController SUNAdaptController_MRIPI(SUNContext sunctx, int p) + + This constructor creates and allocates memory for a SUNAdaptController_MRIPI + object, and inserts its default parameters. + + :param sunctx: the current :c:type:`SUNContext` object. + :param p: the global order of accuracy for the fast time scale solver. + :return: if successful, a usable :c:type:`SUNAdaptController` object; + otherwise it will return ``NULL``. + + Usage: + + .. code-block:: c + + SUNAdaptController C = SUNAdaptController_MRIPI(sunctx, 3); + +.. c:function:: SUNErrCode SUNAdaptController_SetParams_MRIPI(SUNAdaptController C, sunrealtype k11, sunrealtype k12, sunrealtype k21, sunrealtype k22) + + 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_MRIPI object. + :param k11: parameter used within the controller time step estimate. + :param k12: parameter used within the controller time step estimate. + :param k21: parameter used within the controller time step estimate. + :param k22: parameter used within the controller time step estimate. + :return: :c:type:`SUNErrCode` indicating success or failure. + + Usage: + + .. code-block:: c + + retval = SUNAdaptController_SetParams_MRIPI(C, 0.18, 0.86, 0.34, 0.9); diff --git a/doc/shared/sunadaptcontroller/SUNAdaptController_MRIPID.rst b/doc/shared/sunadaptcontroller/SUNAdaptController_MRIPID.rst new file mode 100644 index 0000000000..2de4884f08 --- /dev/null +++ b/doc/shared/sunadaptcontroller/SUNAdaptController_MRIPID.rst @@ -0,0 +1,130 @@ +.. + Programmer(s): Daniel R. Reynolds @ SMU + ---------------------------------------------------------------- + SUNDIALS Copyright Start + Copyright (c) 2002-2024, 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.MRIPID: + +The SUNAdaptController_MRIPID Module +======================================= + +.. versionadded:: x.y.z + +The MRIPID implementation of the SUNAdaptController class, +SUNAdaptController_MRIPID, implements the "PIDMR" multirate temporal +controller proposed in :cite:p:`Fish:23`. This controller has the form + +.. math:: + H' &= H_n \left(\varepsilon^s_n\right)^{\alpha_1} \left(\varepsilon^s_{n-1}\right)^{\alpha_2} \left(\varepsilon^s_{n-2}\right)^{\alpha_3},\\ + M' &= M_n \left(\varepsilon^s_n\right)^{\beta_{11}} \left(\varepsilon^s_{n-1}\right)^{\beta_{12}} \left(\varepsilon^s_{n-2}\right)^{\beta_{13}} \left(\varepsilon^f_n\right)^{\beta_{21}} \left(\varepsilon^f_{n-1}\right)^{\beta_{22}} \left(\varepsilon^f_{n-2}\right)^{\beta_{23}},\\ + h' &= H'/M' + +where :math:`M_n = \left\lceil\frac{H_n}{h_n}\right\rceil`, +:math:`\alpha_1 = \frac{k_{11}+k_{12}+k_{13}}{3P}`, +:math:`\alpha_2 = -\frac{k_{11}+k_{12}}{3P}`, +:math:`\alpha_3 = \frac{k_{11}}{3P}`, +:math:`\beta_{11} = \frac{(p+1)(k_{11}+k_{12}+k_{13})}{3Pp}`, +:math:`\beta_{12} = -\frac{(p+1)(k_{11}+k_{12})}{3Pp}`, +:math:`\beta_{13} = \frac{(p+1)k_{11}}{3Pp}`, +:math:`\beta_{21} = -\frac{k_{21}+k_{22}+k_{23}}{3p}`, +:math:`\beta_{22} = \frac{k_{21}+k_{22}}{3p}`, +and :math:`\beta_{23} = -\frac{k_{21}}{3p}`, and where :math:`P` and :math:`p` +are the global orders of accuracy for the slow and fast time integration methods, +respectively. The default parameter values are :math:`k_{11} = 0.34`, :math:`k_{12} = 0.1`, +:math:`k_{13} = 0.78`, :math:`k_{21} = 0.46`, :math:`k_{22} = 0.42`, and :math:`k_{23} = 0.74`. +In these estimate, a floor of :math:`\varepsilon^*_* > 10\epsilon_{mach}` is enforced to avoid +division-by-zero errors, where :math:`\epsilon_{mach}` is floating point roundoff for the +current working precision. During the first steps (when :math:`\varepsilon^s_{n-1}`, +:math:`\varepsilon^s_{n-2}`, :math:`\varepsilon^f_{n-1}`, and :math:`\varepsilon^f_{n-2}` +may be unavailable), those corresponding values are set to 1, effectively removing them from +the estimation formula. + +The SUNAdaptController_MRIPID controller is implemented as a derived +SUNAdaptController class having type ``SUN_ADAPTCONTROLLER_MRI_H``, and its +*content* field is: + +.. code-block:: c + + struct _SUNAdaptControllerContent_MRIPID { + sunrealtype k11; + sunrealtype k12; + sunrealtype k13; + sunrealtype k21; + sunrealtype k22; + sunrealtype k23; + sunrealtype bias; + sunrealtype esp; + sunrealtype efp; + sunrealtype espp; + sunrealtype efpp; + int p; + }; + +These entries of the *content* field contain the following information: + +* ``k11, k12, k13, k21, k22, k23`` - controller parameters above. + +* ``bias`` - error bias factor, that converts from input temporal error + estimates via :math:`\varepsilon^s = \text{bias}*\text{DSM}` and + :math:`\varepsilon^f = \text{bias}*\text{dsm}`. The default bias value is 1.5. + +* ``esp, efp, espp, efpp`` - storage for the two previous slow and fast error + estimates, :math:`\varepsilon^s_{n-1}`, :math:`\varepsilon^f_{n-1}`, + :math:`\varepsilon^s_{n-2}`, and :math:`\varepsilon^f_{n-2}`. + +* ``p`` - global order of accuracy for the fast time scale solver. + +The header file to be included when using this module is +``sunadaptcontroller/sunadaptcontroller_mripid.h``. + +The SUNAdaptController_MRIPID class provides implementations of all operations +relevant to a ``SUN_ADAPTCONTROLLER_MRI_H`` controller listed in +:numref:`SUNAdaptController.Description.operations`. This class +also provides the following additional user-callable routines: + + +.. c:function:: SUNAdaptController SUNAdaptController_MRIPID(SUNContext sunctx, int p) + + This constructor creates and allocates memory for a SUNAdaptController_MRIPID + object, and inserts its default parameters. + + :param sunctx: the current :c:type:`SUNContext` object. + :param p: the global order of accuracy for the fast time scale solver. + :return: if successful, a usable :c:type:`SUNAdaptController` object; + otherwise it will return ``NULL``. + + Usage: + + .. code-block:: c + + SUNAdaptController C = SUNAdaptController_MRIPID(sunctx, 3); + +.. c:function:: SUNErrCode SUNAdaptController_SetParams_MRIPID(SUNAdaptController C, sunrealtype k11, sunrealtype k12, sunrealtype k13, sunrealtype k21, sunrealtype k22, sunrealtype k23) + + 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_MRIPID object. + :param k11: parameter used within the controller time step estimate. + :param k12: parameter used within the controller time step estimate. + :param k13: parameter used within the controller time step estimate. + :param k21: parameter used within the controller time step estimate. + :param k22: parameter used within the controller time step estimate. + :param k23: parameter used within the controller time step estimate. + :return: :c:type:`SUNErrCode` indicating success or failure. + + Usage: + + .. code-block:: c + + retval = SUNAdaptController_SetParams_MRIPID(C, 0.34 0.1, 0.78, 0.46, 0.42, 0.74); From 2bc4fb07883a7f1004c6798980521ee16e9ca052 Mon Sep 17 00:00:00 2001 From: Steven Roberts Date: Fri, 26 Jul 2024 16:06:30 -0700 Subject: [PATCH 011/286] Add 5th order ERK of Tsitouras --- include/arkode/arkode_arkstep.h | 3 +- include/arkode/arkode_butcher_erk.h | 3 +- src/arkode/arkode_butcher_erk.def | 53 +++++++++++++++++++++++++++++ 3 files changed, 56 insertions(+), 3 deletions(-) diff --git a/include/arkode/arkode_arkstep.h b/include/arkode/arkode_arkstep.h index 960839a805..c67d81d329 100644 --- a/include/arkode/arkode_arkstep.h +++ b/include/arkode/arkode_arkstep.h @@ -40,8 +40,7 @@ static const int ARKSTEP_DEFAULT_ERK_1 = ARKODE_FORWARD_EULER_1_1; static const int ARKSTEP_DEFAULT_ERK_2 = ARKODE_RALSTON_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_SOFRONIOU_SPALETTA_5_3_4; -// TODO(SBR): Consider https://doi.org/10.1016/j.camwa.2011.06.002. Needs extension to quad precision -static const int ARKSTEP_DEFAULT_ERK_5 = ARKODE_DORMAND_PRINCE_7_4_5; +static const int ARKSTEP_DEFAULT_ERK_5 = ARKODE_TSITOURAS_7_4_5; static const int ARKSTEP_DEFAULT_ERK_6 = ARKODE_VERNER_9_5_6; static const int ARKSTEP_DEFAULT_ERK_7 = ARKODE_VERNER_10_6_7; static const int ARKSTEP_DEFAULT_ERK_8 = ARKODE_VERNER_13_7_8; diff --git a/include/arkode/arkode_butcher_erk.h b/include/arkode/arkode_butcher_erk.h index c6c0373510..9b210038da 100644 --- a/include/arkode/arkode_butcher_erk.h +++ b/include/arkode/arkode_butcher_erk.h @@ -52,7 +52,8 @@ typedef enum ARKODE_FORWARD_EULER_1_1, ARKODE_RALSTON_EULER_2_1_2, ARKODE_EXPLICIT_MIDPOINT_EULER_2_1_2, - ARKODE_MAX_ERK_NUM = ARKODE_EXPLICIT_MIDPOINT_EULER_2_1_2 + ARKODE_TSITOURAS_7_4_5, + ARKODE_MAX_ERK_NUM = ARKODE_TSITOURAS_7_4_5 } ARKODE_ERKTableID; /* Accessor routine to load built-in ERK table */ diff --git a/src/arkode/arkode_butcher_erk.def b/src/arkode/arkode_butcher_erk.def index 4da35f9d07..94cb4d6068 100644 --- a/src/arkode/arkode_butcher_erk.def +++ b/src/arkode/arkode_butcher_erk.def @@ -50,6 +50,7 @@ ARKODE_ARK436L2SA_ERK_6_3_4* N ARKODE_ARK437L2SA_ERK_7_3_4* N ARKODE_SAYFY_ABURUB_6_3_4 N + ARKODE_TSITOURAS_7_4_5 Y ARKODE_CASH_KARP_6_4_5 Y ARKODE_FEHLBERG_6_4_5 Y ARKODE_DORMAND_PRINCE_7_4_5 Y @@ -424,6 +425,58 @@ ARK_BUTCHER_TABLE(ARKODE_SAYFY_ABURUB_6_3_4, { /* Sayfy-Aburub-4-3-ERK */ return B; }) +ARK_BUTCHER_TABLE(ARKODE_TSITOURAS_7_4_5, { /* Tsitouras-ERK */ + ARKodeButcherTable B = ARKodeButcherTable_Alloc(7, SUNTRUE); + B->q = 5; + B->p = 4; + B->A[1][0] = SUN_RCONST(0.161); + B->A[2][0] = SUN_RCONST(-0.008480655492356988544426874250230774675121); + B->A[2][1] = SUN_RCONST(0.3354806554923569885444268742502307746751); + B->A[3][0] = SUN_RCONST(2.897153057105493432130432594192938764925); + B->A[3][1] = SUN_RCONST(-6.359448489975074843148159912383825625953); + B->A[3][2] = SUN_RCONST(4.362295432869581411017727318190886861028); + B->A[4][0] = SUN_RCONST(5.325864828439256604428877920840511317836); + B->A[4][1] = SUN_RCONST(-11.74888356406282787774717033978577296189); + B->A[4][2] = SUN_RCONST(7.495539342889836208304604784564358155659); + B->A[4][3] = SUN_RCONST(-0.0924950663617552492565020793320719161135); + B->A[5][0] = SUN_RCONST(5.861455442946420028659251486982647890394); + B->A[5][1] = SUN_RCONST(-12.92096931784710929170611868178335939542); + B->A[5][2] = SUN_RCONST(8.159367898576158643180400794539253485182); + B->A[5][3] = SUN_RCONST(-0.07158497328140099722453054252582973869127); + B->A[5][4] = SUN_RCONST(-0.02826905039406838290900305721271224146718); + B->A[6][0] = SUN_RCONST(0.09646076681806522951816731316512876333712); + B->A[6][1] = SUN_RCONST(0.01); + B->A[6][2] = SUN_RCONST(0.479889650414499574775249532290596519913); + B->A[6][3] = SUN_RCONST(1.379008574103741893192274821856872770756); + B->A[6][4] = SUN_RCONST(-3.290069515436080679901047585711363850116); + B->A[6][5] = SUN_RCONST(2.324710524099773982415355918398765796109); + + B->b[0] = SUN_RCONST(0.09646076681806522951816731316512876333712); + B->b[1] = SUN_RCONST(0.01); + B->b[2] = SUN_RCONST(0.479889650414499574775249532290596519913); + B->b[3] = SUN_RCONST(1.379008574103741893192274821856872770756); + B->b[4] = SUN_RCONST(-3.290069515436080679901047585711363850116); + B->b[5] = SUN_RCONST(2.324710524099773982415355918398765796109); + B->b[6] = SUN_RCONST(0.0); + + B->d[0] = SUN_RCONST(0.09352374858189270663659270466268853095681); + B->d[1] = SUN_RCONST(0.008652883141566367609681000495464767703693); + B->d[2] = SUN_RCONST(0.4928930991314318681922688329502649219068); + B->d[3] = SUN_RCONST(1.140235412267858095755952327702024828167); + B->d[4] = SUN_RCONST(-2.329180192439364558618150528135494254063); + B->d[5] = SUN_RCONST(1.568875049316615520423655662325051205328); + B->d[6] = SUN_RCONST(0.025); + + B->c[0] = SUN_RCONST(0.0); + B->c[1] = SUN_RCONST(0.161); + B->c[2] = SUN_RCONST(0.327); + B->c[3] = SUN_RCONST(0.9); + B->c[4] = SUN_RCONST(0.9800255409045096857298102862870245954942); + B->c[5] = SUN_RCONST(1.0); + B->c[6] = SUN_RCONST(1.0); + return B; + }) + ARK_BUTCHER_TABLE(ARKODE_CASH_KARP_6_4_5, { /* Cash-Karp-ERK */ ARKodeButcherTable B = ARKodeButcherTable_Alloc(6, SUNTRUE); B->q = 5; From 6acabdc7b93648854dc10a4dbf8b54c757421ee1 Mon Sep 17 00:00:00 2001 From: Steven Roberts Date: Fri, 26 Jul 2024 16:20:43 -0700 Subject: [PATCH 012/286] Add FSAL 2nd order Ralston method --- include/arkode/arkode_arkstep.h | 4 ++-- include/arkode/arkode_butcher_erk.h | 1 + src/arkode/arkode_butcher_erk.def | 23 +++++++++++++++++++++++ 3 files changed, 26 insertions(+), 2 deletions(-) diff --git a/include/arkode/arkode_arkstep.h b/include/arkode/arkode_arkstep.h index c67d81d329..6124c4670d 100644 --- a/include/arkode/arkode_arkstep.h +++ b/include/arkode/arkode_arkstep.h @@ -36,8 +36,8 @@ extern "C" { /* explicit */ static const int ARKSTEP_DEFAULT_ERK_1 = ARKODE_FORWARD_EULER_1_1; -// TODO(SBR): replace with FSAL Ralston method -static const int ARKSTEP_DEFAULT_ERK_2 = ARKODE_RALSTON_EULER_2_1_2; +//TODO(SBR): Check if this is better than ARKODE_HEUN_EULER_2_1_2 +static const int ARKSTEP_DEFAULT_ERK_2 = ARKODE_RALSTON_3_1_2; static const int ARKSTEP_DEFAULT_ERK_3 = ARKODE_BOGACKI_SHAMPINE_4_2_3; static const int ARKSTEP_DEFAULT_ERK_4 = ARKODE_SOFRONIOU_SPALETTA_5_3_4; static const int ARKSTEP_DEFAULT_ERK_5 = ARKODE_TSITOURAS_7_4_5; diff --git a/include/arkode/arkode_butcher_erk.h b/include/arkode/arkode_butcher_erk.h index 9b210038da..9e079c6a5a 100644 --- a/include/arkode/arkode_butcher_erk.h +++ b/include/arkode/arkode_butcher_erk.h @@ -52,6 +52,7 @@ typedef enum ARKODE_FORWARD_EULER_1_1, ARKODE_RALSTON_EULER_2_1_2, ARKODE_EXPLICIT_MIDPOINT_EULER_2_1_2, + ARKODE_RALSTON_3_1_2, ARKODE_TSITOURAS_7_4_5, ARKODE_MAX_ERK_NUM = ARKODE_TSITOURAS_7_4_5 } ARKODE_ERKTableID; diff --git a/src/arkode/arkode_butcher_erk.def b/src/arkode/arkode_butcher_erk.def index 94cb4d6068..e2337b8527 100644 --- a/src/arkode/arkode_butcher_erk.def +++ b/src/arkode/arkode_butcher_erk.def @@ -81,6 +81,29 @@ ARK_BUTCHER_TABLE(ARKODE_FORWARD_EULER_1_1, { /* Euler-ERK */ return B; }) +ARK_BUTCHER_TABLE(ARKODE_RALSTON_3_1_2, { /* Ralston-ERK */ + ARKodeButcherTable B = ARKodeButcherTable_Alloc(3, SUNTRUE); + B->q = 2; + B->p = 1; + + B->A[1][0] = SUN_RCONST(2.0)/SUN_RCONST(3.0); + B->A[2][0] = SUN_RCONST(1.0)/SUN_RCONST(4.0); + B->A[2][1] = SUN_RCONST(3.0)/SUN_RCONST(4.0); + + B->b[0] = SUN_RCONST(1.0)/SUN_RCONST(4.0); + B->b[1] = SUN_RCONST(3.0)/SUN_RCONST(4.0); + B->b[2] = SUN_RCONST(0.0); + + B->d[0] = SUN_RCONST(5.0)/SUN_RCONST(37.0); + B->d[1] = SUN_RCONST(2.0)/SUN_RCONST(3.0); + B->d[2] = SUN_RCONST(22.0)/SUN_RCONST(111.0); + + B->c[1] = SUN_RCONST(2.0)/SUN_RCONST(3.0); + B->c[2] = SUN_RCONST(1.0); + + return B; + }) + ARK_BUTCHER_TABLE(ARKODE_HEUN_EULER_2_1_2, { /* Heun-Euler-ERK */ ARKodeButcherTable B = ARKodeButcherTable_Alloc(2, SUNTRUE); B->q = 2; From c5aeea6f87bd8b8a9c557a95052071ea09cb25c4 Mon Sep 17 00:00:00 2001 From: Steven Roberts Date: Fri, 26 Jul 2024 16:21:54 -0700 Subject: [PATCH 013/286] Add Ralston to table in def file --- src/arkode/arkode_butcher_erk.def | 1 + 1 file changed, 1 insertion(+) diff --git a/src/arkode/arkode_butcher_erk.def b/src/arkode/arkode_butcher_erk.def index e2337b8527..b7daadd20a 100644 --- a/src/arkode/arkode_butcher_erk.def +++ b/src/arkode/arkode_butcher_erk.def @@ -39,6 +39,7 @@ imeth QP --------------------------------------- ARKODE_FORWARD_EULER_1_1 Y + ARKODE_RALSTON_3_1_2 Y ARKODE_HEUN_EULER_2_1_2 Y ARKODE_RALSTON_EULER_2_1_2 Y ARKODE_EXPLICIT_MIDPOINT_EULER_2_1_2 Y From 609abba8ad5bbb5d7cde14ead93b379918066828 Mon Sep 17 00:00:00 2001 From: Steven Roberts Date: Fri, 26 Jul 2024 16:27:28 -0700 Subject: [PATCH 014/286] Update Fortran interfaces --- src/arkode/fmod_int32/farkode_arkstep_mod.f90 | 26 +++++++++---------- src/arkode/fmod_int32/farkode_mod.f90 | 7 +++-- src/arkode/fmod_int64/farkode_arkstep_mod.f90 | 26 +++++++++---------- src/arkode/fmod_int64/farkode_mod.f90 | 7 +++-- 4 files changed, 36 insertions(+), 30 deletions(-) diff --git a/src/arkode/fmod_int32/farkode_arkstep_mod.f90 b/src/arkode/fmod_int32/farkode_arkstep_mod.f90 index cc0373f1eb..3708886004 100644 --- a/src/arkode/fmod_int32/farkode_arkstep_mod.f90 +++ b/src/arkode/fmod_int32/farkode_arkstep_mod.f90 @@ -27,27 +27,27 @@ module farkode_arkstep_mod ! DECLARATION CONSTRUCTS integer(C_INT), parameter, public :: ARKSTEP_DEFAULT_ERK_1 = ARKODE_FORWARD_EULER_1_1 - integer(C_INT), parameter, public :: ARKSTEP_DEFAULT_ERK_2 = ARKODE_HEUN_EULER_2_1_2 + integer(C_INT), parameter, public :: ARKSTEP_DEFAULT_ERK_2 = ARKODE_RALSTON_3_1_2 integer(C_INT), parameter, public :: ARKSTEP_DEFAULT_ERK_3 = ARKODE_BOGACKI_SHAMPINE_4_2_3 - integer(C_INT), parameter, public :: ARKSTEP_DEFAULT_ERK_4 = ARKODE_ZONNEVELD_5_3_4 - integer(C_INT), parameter, public :: ARKSTEP_DEFAULT_ERK_5 = ARKODE_CASH_KARP_6_4_5 - integer(C_INT), parameter, public :: ARKSTEP_DEFAULT_ERK_6 = ARKODE_VERNER_8_5_6 + integer(C_INT), parameter, public :: ARKSTEP_DEFAULT_ERK_4 = ARKODE_SOFRONIOU_SPALETTA_5_3_4 + integer(C_INT), parameter, public :: ARKSTEP_DEFAULT_ERK_5 = ARKODE_TSITOURAS_7_4_5 + integer(C_INT), parameter, public :: ARKSTEP_DEFAULT_ERK_6 = ARKODE_VERNER_9_5_6 integer(C_INT), parameter, public :: ARKSTEP_DEFAULT_ERK_7 = ARKODE_VERNER_10_6_7 - integer(C_INT), parameter, public :: ARKSTEP_DEFAULT_ERK_8 = ARKODE_FEHLBERG_13_7_8 + integer(C_INT), parameter, public :: ARKSTEP_DEFAULT_ERK_8 = ARKODE_VERNER_13_7_8 integer(C_INT), parameter, public :: ARKSTEP_DEFAULT_ERK_9 = ARKODE_VERNER_16_8_9 integer(C_INT), parameter, public :: ARKSTEP_DEFAULT_DIRK_1 = ARKODE_BACKWARD_EULER_1_1 - integer(C_INT), parameter, public :: ARKSTEP_DEFAULT_DIRK_2 = ARKODE_SDIRK_2_1_2 - integer(C_INT), parameter, public :: ARKSTEP_DEFAULT_DIRK_3 = ARKODE_ARK324L2SA_DIRK_4_2_3 - integer(C_INT), parameter, public :: ARKSTEP_DEFAULT_DIRK_4 = ARKODE_SDIRK_5_3_4 - integer(C_INT), parameter, public :: ARKSTEP_DEFAULT_DIRK_5 = ARKODE_ARK548L2SA_DIRK_8_4_5 + integer(C_INT), parameter, public :: ARKSTEP_DEFAULT_DIRK_2 = ARKODE_ARK2_DIRK_3_1_2 + integer(C_INT), parameter, public :: ARKSTEP_DEFAULT_DIRK_3 = ARKODE_ESDIRK325L2SA_5_2_3 + integer(C_INT), parameter, public :: ARKSTEP_DEFAULT_DIRK_4 = ARKODE_ESDIRK436L2SA_6_3_4 + integer(C_INT), parameter, public :: ARKSTEP_DEFAULT_DIRK_5 = ARKODE_ESDIRK547L2SA2_7_4_5 integer(C_INT), parameter, public :: ARKSTEP_DEFAULT_ARK_ETABLE_2 = ARKODE_ARK2_ERK_3_1_2 integer(C_INT), parameter, public :: ARKSTEP_DEFAULT_ARK_ETABLE_3 = ARKODE_ARK324L2SA_ERK_4_2_3 - integer(C_INT), parameter, public :: ARKSTEP_DEFAULT_ARK_ETABLE_4 = ARKODE_ARK436L2SA_ERK_6_3_4 - integer(C_INT), parameter, public :: ARKSTEP_DEFAULT_ARK_ETABLE_5 = ARKODE_ARK548L2SA_ERK_8_4_5 + integer(C_INT), parameter, public :: ARKSTEP_DEFAULT_ARK_ETABLE_4 = ARKODE_ARK437L2SA_ERK_7_3_4 + integer(C_INT), parameter, public :: ARKSTEP_DEFAULT_ARK_ETABLE_5 = ARKODE_ARK548L2SAb_ERK_8_4_5 integer(C_INT), parameter, public :: ARKSTEP_DEFAULT_ARK_ITABLE_2 = ARKODE_ARK2_DIRK_3_1_2 integer(C_INT), parameter, public :: ARKSTEP_DEFAULT_ARK_ITABLE_3 = ARKODE_ARK324L2SA_DIRK_4_2_3 - integer(C_INT), parameter, public :: ARKSTEP_DEFAULT_ARK_ITABLE_4 = ARKODE_ARK436L2SA_DIRK_6_3_4 - integer(C_INT), parameter, public :: ARKSTEP_DEFAULT_ARK_ITABLE_5 = ARKODE_ARK548L2SA_DIRK_8_4_5 + integer(C_INT), parameter, public :: ARKSTEP_DEFAULT_ARK_ITABLE_4 = ARKODE_ARK437L2SA_DIRK_7_3_4 + integer(C_INT), parameter, public :: ARKSTEP_DEFAULT_ARK_ITABLE_5 = ARKODE_ARK548L2SAb_DIRK_8_4_5 public :: FARKStepCreate public :: FARKStepReInit public :: FARKStepSetExplicit diff --git a/src/arkode/fmod_int32/farkode_mod.f90 b/src/arkode/fmod_int32/farkode_mod.f90 index 366867f40a..70e4d51066 100644 --- a/src/arkode/fmod_int32/farkode_mod.f90 +++ b/src/arkode/fmod_int32/farkode_mod.f90 @@ -362,7 +362,9 @@ module farkode_mod enumerator :: ARKODE_FORWARD_EULER_1_1 enumerator :: ARKODE_RALSTON_EULER_2_1_2 enumerator :: ARKODE_EXPLICIT_MIDPOINT_EULER_2_1_2 - enumerator :: ARKODE_MAX_ERK_NUM = ARKODE_EXPLICIT_MIDPOINT_EULER_2_1_2 + enumerator :: ARKODE_RALSTON_3_1_2 + enumerator :: ARKODE_TSITOURAS_7_4_5 + enumerator :: ARKODE_MAX_ERK_NUM = ARKODE_TSITOURAS_7_4_5 end enum integer, parameter, public :: ARKODE_ERKTableID = kind(ARKODE_ERK_NONE) public :: ARKODE_ERK_NONE, ARKODE_MIN_ERK_NUM, ARKODE_HEUN_EULER_2_1_2, ARKODE_BOGACKI_SHAMPINE_4_2_3, & @@ -371,7 +373,8 @@ module farkode_mod ARKODE_VERNER_8_5_6, ARKODE_FEHLBERG_13_7_8, ARKODE_KNOTH_WOLKE_3_3, ARKODE_ARK437L2SA_ERK_7_3_4, & ARKODE_ARK548L2SAb_ERK_8_4_5, ARKODE_ARK2_ERK_3_1_2, ARKODE_SOFRONIOU_SPALETTA_5_3_4, ARKODE_SHU_OSHER_3_2_3, & ARKODE_VERNER_9_5_6, ARKODE_VERNER_10_6_7, ARKODE_VERNER_13_7_8, ARKODE_VERNER_16_8_9, ARKODE_FORWARD_EULER_1_1, & - ARKODE_RALSTON_EULER_2_1_2, ARKODE_EXPLICIT_MIDPOINT_EULER_2_1_2, ARKODE_MAX_ERK_NUM + ARKODE_RALSTON_EULER_2_1_2, ARKODE_EXPLICIT_MIDPOINT_EULER_2_1_2, ARKODE_RALSTON_3_1_2, ARKODE_TSITOURAS_7_4_5, & + ARKODE_MAX_ERK_NUM public :: FARKodeButcherTable_LoadERK public :: FARKodeButcherTable_LoadERKByName public :: FARKodeButcherTable_ERKIDToName diff --git a/src/arkode/fmod_int64/farkode_arkstep_mod.f90 b/src/arkode/fmod_int64/farkode_arkstep_mod.f90 index cc0373f1eb..3708886004 100644 --- a/src/arkode/fmod_int64/farkode_arkstep_mod.f90 +++ b/src/arkode/fmod_int64/farkode_arkstep_mod.f90 @@ -27,27 +27,27 @@ module farkode_arkstep_mod ! DECLARATION CONSTRUCTS integer(C_INT), parameter, public :: ARKSTEP_DEFAULT_ERK_1 = ARKODE_FORWARD_EULER_1_1 - integer(C_INT), parameter, public :: ARKSTEP_DEFAULT_ERK_2 = ARKODE_HEUN_EULER_2_1_2 + integer(C_INT), parameter, public :: ARKSTEP_DEFAULT_ERK_2 = ARKODE_RALSTON_3_1_2 integer(C_INT), parameter, public :: ARKSTEP_DEFAULT_ERK_3 = ARKODE_BOGACKI_SHAMPINE_4_2_3 - integer(C_INT), parameter, public :: ARKSTEP_DEFAULT_ERK_4 = ARKODE_ZONNEVELD_5_3_4 - integer(C_INT), parameter, public :: ARKSTEP_DEFAULT_ERK_5 = ARKODE_CASH_KARP_6_4_5 - integer(C_INT), parameter, public :: ARKSTEP_DEFAULT_ERK_6 = ARKODE_VERNER_8_5_6 + integer(C_INT), parameter, public :: ARKSTEP_DEFAULT_ERK_4 = ARKODE_SOFRONIOU_SPALETTA_5_3_4 + integer(C_INT), parameter, public :: ARKSTEP_DEFAULT_ERK_5 = ARKODE_TSITOURAS_7_4_5 + integer(C_INT), parameter, public :: ARKSTEP_DEFAULT_ERK_6 = ARKODE_VERNER_9_5_6 integer(C_INT), parameter, public :: ARKSTEP_DEFAULT_ERK_7 = ARKODE_VERNER_10_6_7 - integer(C_INT), parameter, public :: ARKSTEP_DEFAULT_ERK_8 = ARKODE_FEHLBERG_13_7_8 + integer(C_INT), parameter, public :: ARKSTEP_DEFAULT_ERK_8 = ARKODE_VERNER_13_7_8 integer(C_INT), parameter, public :: ARKSTEP_DEFAULT_ERK_9 = ARKODE_VERNER_16_8_9 integer(C_INT), parameter, public :: ARKSTEP_DEFAULT_DIRK_1 = ARKODE_BACKWARD_EULER_1_1 - integer(C_INT), parameter, public :: ARKSTEP_DEFAULT_DIRK_2 = ARKODE_SDIRK_2_1_2 - integer(C_INT), parameter, public :: ARKSTEP_DEFAULT_DIRK_3 = ARKODE_ARK324L2SA_DIRK_4_2_3 - integer(C_INT), parameter, public :: ARKSTEP_DEFAULT_DIRK_4 = ARKODE_SDIRK_5_3_4 - integer(C_INT), parameter, public :: ARKSTEP_DEFAULT_DIRK_5 = ARKODE_ARK548L2SA_DIRK_8_4_5 + integer(C_INT), parameter, public :: ARKSTEP_DEFAULT_DIRK_2 = ARKODE_ARK2_DIRK_3_1_2 + integer(C_INT), parameter, public :: ARKSTEP_DEFAULT_DIRK_3 = ARKODE_ESDIRK325L2SA_5_2_3 + integer(C_INT), parameter, public :: ARKSTEP_DEFAULT_DIRK_4 = ARKODE_ESDIRK436L2SA_6_3_4 + integer(C_INT), parameter, public :: ARKSTEP_DEFAULT_DIRK_5 = ARKODE_ESDIRK547L2SA2_7_4_5 integer(C_INT), parameter, public :: ARKSTEP_DEFAULT_ARK_ETABLE_2 = ARKODE_ARK2_ERK_3_1_2 integer(C_INT), parameter, public :: ARKSTEP_DEFAULT_ARK_ETABLE_3 = ARKODE_ARK324L2SA_ERK_4_2_3 - integer(C_INT), parameter, public :: ARKSTEP_DEFAULT_ARK_ETABLE_4 = ARKODE_ARK436L2SA_ERK_6_3_4 - integer(C_INT), parameter, public :: ARKSTEP_DEFAULT_ARK_ETABLE_5 = ARKODE_ARK548L2SA_ERK_8_4_5 + integer(C_INT), parameter, public :: ARKSTEP_DEFAULT_ARK_ETABLE_4 = ARKODE_ARK437L2SA_ERK_7_3_4 + integer(C_INT), parameter, public :: ARKSTEP_DEFAULT_ARK_ETABLE_5 = ARKODE_ARK548L2SAb_ERK_8_4_5 integer(C_INT), parameter, public :: ARKSTEP_DEFAULT_ARK_ITABLE_2 = ARKODE_ARK2_DIRK_3_1_2 integer(C_INT), parameter, public :: ARKSTEP_DEFAULT_ARK_ITABLE_3 = ARKODE_ARK324L2SA_DIRK_4_2_3 - integer(C_INT), parameter, public :: ARKSTEP_DEFAULT_ARK_ITABLE_4 = ARKODE_ARK436L2SA_DIRK_6_3_4 - integer(C_INT), parameter, public :: ARKSTEP_DEFAULT_ARK_ITABLE_5 = ARKODE_ARK548L2SA_DIRK_8_4_5 + integer(C_INT), parameter, public :: ARKSTEP_DEFAULT_ARK_ITABLE_4 = ARKODE_ARK437L2SA_DIRK_7_3_4 + integer(C_INT), parameter, public :: ARKSTEP_DEFAULT_ARK_ITABLE_5 = ARKODE_ARK548L2SAb_DIRK_8_4_5 public :: FARKStepCreate public :: FARKStepReInit public :: FARKStepSetExplicit diff --git a/src/arkode/fmod_int64/farkode_mod.f90 b/src/arkode/fmod_int64/farkode_mod.f90 index e627472572..cf37c6eb1c 100644 --- a/src/arkode/fmod_int64/farkode_mod.f90 +++ b/src/arkode/fmod_int64/farkode_mod.f90 @@ -362,7 +362,9 @@ module farkode_mod enumerator :: ARKODE_FORWARD_EULER_1_1 enumerator :: ARKODE_RALSTON_EULER_2_1_2 enumerator :: ARKODE_EXPLICIT_MIDPOINT_EULER_2_1_2 - enumerator :: ARKODE_MAX_ERK_NUM = ARKODE_EXPLICIT_MIDPOINT_EULER_2_1_2 + enumerator :: ARKODE_RALSTON_3_1_2 + enumerator :: ARKODE_TSITOURAS_7_4_5 + enumerator :: ARKODE_MAX_ERK_NUM = ARKODE_TSITOURAS_7_4_5 end enum integer, parameter, public :: ARKODE_ERKTableID = kind(ARKODE_ERK_NONE) public :: ARKODE_ERK_NONE, ARKODE_MIN_ERK_NUM, ARKODE_HEUN_EULER_2_1_2, ARKODE_BOGACKI_SHAMPINE_4_2_3, & @@ -371,7 +373,8 @@ module farkode_mod ARKODE_VERNER_8_5_6, ARKODE_FEHLBERG_13_7_8, ARKODE_KNOTH_WOLKE_3_3, ARKODE_ARK437L2SA_ERK_7_3_4, & ARKODE_ARK548L2SAb_ERK_8_4_5, ARKODE_ARK2_ERK_3_1_2, ARKODE_SOFRONIOU_SPALETTA_5_3_4, ARKODE_SHU_OSHER_3_2_3, & ARKODE_VERNER_9_5_6, ARKODE_VERNER_10_6_7, ARKODE_VERNER_13_7_8, ARKODE_VERNER_16_8_9, ARKODE_FORWARD_EULER_1_1, & - ARKODE_RALSTON_EULER_2_1_2, ARKODE_EXPLICIT_MIDPOINT_EULER_2_1_2, ARKODE_MAX_ERK_NUM + ARKODE_RALSTON_EULER_2_1_2, ARKODE_EXPLICIT_MIDPOINT_EULER_2_1_2, ARKODE_RALSTON_3_1_2, ARKODE_TSITOURAS_7_4_5, & + ARKODE_MAX_ERK_NUM public :: FARKodeButcherTable_LoadERK public :: FARKodeButcherTable_LoadERKByName public :: FARKodeButcherTable_ERKIDToName From e76d939f9b204c1143de652e2d1c3d785c8f5bbd Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Mon, 29 Jul 2024 21:48:17 -0500 Subject: [PATCH 015/286] Added documentation for MRIHTol controller --- doc/arkode/guide/source/Mathematics.rst | 21 +++- .../SUNAdaptController_MRIHTol.rst | 104 ++++++++++++++---- 2 files changed, 95 insertions(+), 30 deletions(-) diff --git a/doc/arkode/guide/source/Mathematics.rst b/doc/arkode/guide/source/Mathematics.rst index 9d69b9a842..5e727f772f 100644 --- a/doc/arkode/guide/source/Mathematics.rst +++ b/doc/arkode/guide/source/Mathematics.rst @@ -973,8 +973,10 @@ size :math:`h^S` has order :math:`p`, i.e., .. math:: LTE_n = c(t_n) (h^S)^p, -to predict candidate values :math:`h^S_{n+1}`. We may therefore repurpose an existing single-scale controller to predict candidate values :math:`\text{reltol}^f_{n+1}` by -supplying an "order" :math:`p=1` and a "control parameter" :math:`h^S_n=\left(\text{reltol}_n^f\right) \left(t_{F,i}-t_{0,i}\right)`, and scaling +to predict candidate values :math:`h^S_{n+1}`. We may therefore repurpose an existing +single-scale controller to predict candidate values :math:`\text{reltol}^f_{n+1}` by +supplying an "order" :math:`p=1` and a "control parameter" +:math:`h^S_n=\left(\text{reltol}_n^f\right) \left(t_{F,i}-t_{0,i}\right)`, and scaling the output by the subinterval width. Thus to construct an :math:`h^S-Tol` controller, we require three separate single-rate @@ -983,11 +985,17 @@ adaptivity controllers: * scontrol-H -- this is a single-rate controller that adapts :math:`h^S_n` within the slow integrator to achieve user-requested solution tolerances. -* scontrol-Tol -- this is a single-rate controller that adapts :math:`\text{reltol}^f_n` using the strategy described above. +* scontrol-Tol -- this is a single-rate controller that adapts :math:`\text{reltol}^f_n` + using the strategy described above. -* fcontrol -- this adapts time steps :math:`h^F` within the fast integrator to achieve the current tolerance, :math:`\text{reltol}^f_n`. +* fcontrol -- this adapts time steps :math:`h^F` within the fast integrator to achieve + the current tolerance, :math:`\text{reltol}^f_n`. -We note that of the three classes of controllers considered here, the :math:`h^S-h^F` controllers are only amenable to problems with two time scales. On the other hand, both the decoupled and :math:`h^S-Tol` controllers may be used in multirate calculations with an arbitrary number of time scales, since these focus on only one scale at a time, or on how a given time scale relates to the next-faster scale. +We note that of the three classes of controllers considered here, the :math:`h^S-h^F` +controllers are only amenable to problems with two time scales. On the other hand, both +the decoupled and :math:`h^S-Tol` controllers may be used in multirate calculations with +an arbitrary number of time scales, since these focus on only one scale at a time, or on +how a given time scale relates to the next-faster scale. .. _ARKODE.Mathematics.MultirateInitialSteps: @@ -1005,7 +1013,8 @@ while also progressing toward the eventual solution. In MRI methods, initial time step selection is complicated by the fact that not only must an initial slow step size, :math:`h_0^S`, be chosen, but a smaller initial step, :math:`h_0^F`, must also be selected. Additionally, it is typically assumed that within -MRI methods, evaluation of :math:`f^S` is significantly more costly than evaluation of :math:`f^f`, and thus we wish to construct these initial steps accordingly. +MRI methods, evaluation of :math:`f^S` is significantly more costly than evaluation of +:math:`f^f`, and thus we wish to construct these initial steps accordingly. Before examining MRI initial time step estimation, we first summarize two common approaches to initial step size selection. To this end, consider a simple diff --git a/doc/shared/sunadaptcontroller/SUNAdaptController_MRIHTol.rst b/doc/shared/sunadaptcontroller/SUNAdaptController_MRIHTol.rst index cad898f97a..819404c40d 100644 --- a/doc/shared/sunadaptcontroller/SUNAdaptController_MRIHTol.rst +++ b/doc/shared/sunadaptcontroller/SUNAdaptController_MRIHTol.rst @@ -19,27 +19,86 @@ The SUNAdaptController_MRIHTol Module .. versionadded:: x.y.z +Mathematical motivation +----------------------- + The MRIHTol implementation of the SUNAdaptController class, SUNAdaptController_MRIHTol, implements a general structure for telescopic -multirate temporal control. This controller has the form +multirate temporal control. A SUNAdaptController_MRIHTol object is constructed +using two single-rate controller objects, *HControl* and *TolControl*. The +MRIHTol controller assumes that overall solution error at a given time scale +results from two types of error: + +#. "Slow" temporal errors introduced at the current time scale, + + .. math:: + \varepsilon^s_{n} = C(t_n) \left(h_n^s\right)^P, + :label: slow_error_assumption + + where :math:`C(t)` is independent of the current time scale step size :math:`h^s` + but may vary in time. + +#. "Fast" errors introduced through calls to the next-fastest ("inner") solver, + :math:`\varepsilon^f_{n}`. If this inner solver is called to evolve IVPs over + time intervals :math:`[t_{0,i}, t_{F,i}]` with a relative tolerance + :math:`\text{reltol}_n^f`, then it will result in accumulated errors over these + intervals of the form + + .. math:: + \varepsilon^f_{n} = c(t_n) \left(\text{reltol}_n^f\right) \left(t_{F,i}-t_{0,i}\right), + + where :math:`c(t)` is independent of the tolerance or subinterval width but may vary in + time, or equivalently, + + .. math:: + \varepsilon^f_{n} = \kappa(t_n) \left(\text{tolfac}_n^f\right), + :label: inner_solver_assumption + + where :math:`\text{reltol}_n^f = \text{reltol}^s \text{tolfac}_n^f`, + :math:`\text{reltol}^s` is the relative tolerance that was supplied to the + current time scale solver, and where + :math:`\kappa(t_n) = c(t_n) \text{reltol}^s \left(t_{F,i}-t_{0,i}\right)` is + independent of the relative tolerance factor, :math:`\text{tolfac}_n^f`. + +Single-rate controllers are constructed to adapt a single order parameter, e.g., +:math:`\delta`, under an assumption that solution error :math:`\varepsilon` depends +asymptotically on this parameter via the form + +.. math:: + \varepsilon = \mathcal{O}(\delta^q). + +Both :eq:`slow_error_assumption` and :eq:`inner_solver_assumption` fit this form, +with control parameters :math:`h^s` and :math:`\text{tolfac}^f_n`, and "orders" +:math:`P` and :math:`1`, respectively. Thus an MRIHTol controller employs +*HControl* to adapt :math:`h_n^s` to control the current time scale error +:math:`\varepsilon^s_n`, and it employs *TolControl* to adapt +:math:`\text{tolfac}_n^f` to control the accumulated inner solver error +:math:`\varepsilon^f_n`. + +To avoid overly large changes in calls to the inner solver, we apply bounds on the +results from *TolControl*. If *TolControl* predicts a control parameter +:math:`\text{tolfac}'`, we obtain the eventual tolerance factor via +enforcing the following bounds: .. math:: - h' = h_n \varepsilon_n^{-k_1/(p+1)} \varepsilon_{n-1}^{-k_2/(p+1)} \varepsilon_{n-2}^{-k_3/(p+1)} \left(\dfrac{h_n}{h_{n-1}}\right)^{k_4} \left(\dfrac{h_{n-1}}{h_{n-2}}\right)^{k_5} + \frac{\text{tolfac}_{n}^f}{\text{tolfac}'} &\le \text{max}_{relch},\\ + \frac{\text{tolfac}'}{\text{tolfac}_{n}^f} &\le \text{max}_{relch},\\ + \text{tolfac}_{min} &\le \text{tolfac}' \le \text{tolfac}_{max}. + +The default values for these bounds are :math:`\text{max}_{relch} = 20`, +:math:`\text{tolfac}_{min} = 10^{-5}`, and :math:`\text{tolfac}_{max} = 1`. + -with default parameter values :math:`k_1 = 1.25`, :math:`k_2 = 0.5`, -:math:`k_3 = -0.75`, :math:`k_4 = 0.25`, and :math:`k_5 = 0.75`, where -:math:`p` is the global order of the time integration method. In this estimate, -a floor of :math:`\varepsilon_* > 10^{-10}` is enforced to avoid division-by-zero -errors. During the first two steps (when :math:`\varepsilon_{n-2}`, -:math:`\varepsilon_{n-1}`, :math:`h_{n-2}`, and :math:`h_{n-2}` may be unavailable), -the corresponding terms are merely omitted during estimation of :math:`h'`. +Implementation +-------------- -The SUNAdaptController_Soderlind controller is implemented as a derived +The SUNAdaptController_MRIHTol controller is implemented as a derived SUNAdaptController class, and defines its *content* field as: .. code-block:: c - struct _SUNAdaptControllerContent_Soderlind { + struct _SUNAdaptControllerContent_MRIHTol + { SUNAdaptController HControl; SUNAdaptController TolControl; sunrealtype inner_max_relch; @@ -50,24 +109,21 @@ SUNAdaptController class, and defines its *content* field as: These entries of the *content* field contain the following information: * ``HControl`` - single time-scale SUNAdaptController object to adapt - the current step size, :math:`H`. + the current step size, :math:`h^s_n`. * ``TolControl`` - single time-scale SUNAdaptController object to adapt - the fast time scale relative tolerance factor, :math:`reltol`. + the inner solver relative tolerance factor, :math:`\text{reltol}^f_n`. -* ``inner_max_relch`` - bound on the relative change in :math:`tolfac` from one - step to the next. +* ``inner_max_relch`` - the parameter :math:`\text{max}_{relch}` above. -* ``inner_min_tolfac`` - absolute lower bound on :math:`tolfac`, to avoid calling - the inner integrator with an arbitrarily small tolerance. +* ``inner_min_tolfac`` - the parameter :math:`\text{tolfac}_{min}` above. -* ``inner_max_tolfac`` - absolute upper bound on :math:`tolfac`, to avoid calling - the inner integrator with too loose of a tolerance. +* ``inner_max_tolfac`` - the parameter :math:`\text{tolfac}_{max}` above. The header file to be included when using this module is ``sunadaptcontroller/sunadaptcontroller_mrihtol.h``. -The SUNAdaptController_Soderlind class provides implementations of all operations +The SUNAdaptController_MRIHTol class provides implementations of all operations relevant to a ``SUN_ADAPTCONTROLLER_MRI_TOL`` controller listed in :numref:`SUNAdaptController.Description.operations`. This class also provides the following additional user-callable routines: @@ -80,7 +136,7 @@ also provides the following additional user-callable routines: :param sunctx: the current :c:type:`SUNContext` object. :param HControl: the slow time step adaptivity controller object. - :param TolControl: the fast time scale tolerance factor adaptivity controller object. + :param TolControl: the inner solver tolerance factor adaptivity controller object. :return: if successful, a usable :c:type:`SUNAdaptController` object; otherwise it will return ``NULL``. @@ -97,9 +153,9 @@ also provides the following additional user-callable routines: the problem. :param C: the SUNAdaptController_MRIHTol object. - :param inner_max_relch: parameter used within the controller time step estimate. - :param inner_min_tolfac: parameter used within the controller time step estimate. - :param inner_max_tolfac: parameter used within the controller time step estimate. + :param inner_max_relch: the parameter :math:`\text{max}_{relch}`. + :param inner_min_tolfac: the parameter :math:`\text{tolfac}_{min}`. + :param inner_max_tolfac: the parameter :math:`\text{tolfac}_{max}`. :return: :c:type:`SUNErrCode` indicating success or failure. Usage: From fa91d1dedbb526c87dd967b96b86bb283da6150e Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Tue, 30 Jul 2024 09:10:25 -0500 Subject: [PATCH 016/286] Minor fix for default value --- doc/shared/sunadaptcontroller/SUNAdaptController_MRIHTol.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/shared/sunadaptcontroller/SUNAdaptController_MRIHTol.rst b/doc/shared/sunadaptcontroller/SUNAdaptController_MRIHTol.rst index cad898f97a..55baf4eaa2 100644 --- a/doc/shared/sunadaptcontroller/SUNAdaptController_MRIHTol.rst +++ b/doc/shared/sunadaptcontroller/SUNAdaptController_MRIHTol.rst @@ -106,4 +106,4 @@ also provides the following additional user-callable routines: .. code-block:: c - retval = SUNAdaptController_SetParams_MRIHTol(C, 20.0, 1e-4, 1.0); + retval = SUNAdaptController_SetParams_MRIHTol(C, 20.0, 1e-5, 1.0); From 2d8855a8e1faee0dd633b1f486b2a244e23ed265 Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Mon, 19 Aug 2024 08:07:56 -0500 Subject: [PATCH 017/286] Added control over slow time scale adaptivity safety factor --- .../CXX_serial/ark_test_brusselator_mriadapt.cpp | 15 ++++++++++++++- .../arkode/CXX_serial/ark_test_kpr_mriadapt.cpp | 13 +++++++++++++ 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/test/unit_tests/arkode/CXX_serial/ark_test_brusselator_mriadapt.cpp b/test/unit_tests/arkode/CXX_serial/ark_test_brusselator_mriadapt.cpp index 75192b0ee3..7a637d3688 100644 --- a/test/unit_tests/arkode/CXX_serial/ark_test_brusselator_mriadapt.cpp +++ b/test/unit_tests/arkode/CXX_serial/ark_test_brusselator_mriadapt.cpp @@ -49,6 +49,7 @@ * - set initial adaptive step size as hs/hf above: set_h0 [default 0] * - relative solution tolerance: rtol [default = 1e-4] * - absolute solution tolerance: atol [default = 1e-11] + * - slow stepsize safety factor: safety [default = 0.96] * - relative solution tolerance for fast integrator: fast_rtol [default = 1e-4] * - use p (0) vs q (1) for slow adaptivity: slow_pq [default = 0] * - use p (0) vs q (1) for fast adaptivity: fast_pq [default = 0] @@ -173,6 +174,7 @@ struct Options sunrealtype htol_relch = SUN_RCONST(-1.0); sunrealtype htol_minfac = SUN_RCONST(-1.0); sunrealtype htol_maxfac = SUN_RCONST(-1.0); + sunrealtype slow_safety = SUN_RCONST(-1.0); }; // User-supplied functions called by the solver @@ -685,7 +687,12 @@ int main(int argc, char* argv[]) retval = ARKodeSetAdaptivityAdjustment(arkode_mem, 0); if (check_flag(retval, "ARKodeSetAdaptivityAdjustment")) return 1; } - } + if (opts.slow_safety > -1) + { + retval = ARKodeSetSafetyFactor(arkode_mem, opts.slow_safety); + if (check_flag(retval, "ARKodeSetSafetyFactor")) return 1; + } +} else { retval = ARKodeSetFixedStep(arkode_mem, opts.hs); @@ -1046,6 +1053,7 @@ void InputHelp() std::cout << " --k1s, --k2s, ..., -k6s : slow controller parameters\n"; std::cout << " --k1f, --k2f, -k3f : fast controller parameters\n"; std::cout << " --bias : slow and fast controller bias factors\n"; + std::cout << " --safety : slow time step safety factor\n"; std::cout << " --htol_relch : HTol controller maximum relative tolerance change\n"; std::cout @@ -1088,6 +1096,7 @@ int ReadInputs(std::vector& args, Options& opts, SUNContext ctx) find_arg(args, "--k2f", opts.k2f); find_arg(args, "--k3f", opts.k3f); find_arg(args, "--bias", opts.bias); + find_arg(args, "--safety", opts.slow_safety); find_arg(args, "--htol_relch", opts.htol_relch); find_arg(args, "--htol_minfac", opts.htol_minfac); find_arg(args, "--htol_maxfac", opts.htol_maxfac); @@ -1383,6 +1392,10 @@ static void PrintSlowAdaptivity(Options opts) { std::cout << " controller bias factor: " << opts.bias << "\n"; } + if (opts.slow_safety > -1) + { + std::cout << " slow step safety factor: " << opts.slow_safety << "\n"; + } } static void PrintFastAdaptivity(Options opts) diff --git a/test/unit_tests/arkode/CXX_serial/ark_test_kpr_mriadapt.cpp b/test/unit_tests/arkode/CXX_serial/ark_test_kpr_mriadapt.cpp index c9790af566..1b6d3b82e9 100644 --- a/test/unit_tests/arkode/CXX_serial/ark_test_kpr_mriadapt.cpp +++ b/test/unit_tests/arkode/CXX_serial/ark_test_kpr_mriadapt.cpp @@ -49,6 +49,7 @@ * - relative solution tolerance for fast integrator: fast_rtol [default = 1e-4] * - use p (0) vs q (1) for slow adaptivity: slow_pq [default = 0] * - use p (0) vs q (1) for fast adaptivity: fast_pq [default = 0] + * - slow stepsize safety factor: safety [default = 0.96] * - "slow" MRI method: mri_method [default = ARKODE_MRI_GARK_ERK45a] * - "fast" ERKStep method order: fast_order [default 4] * To put all physics at the slow scale, use "0", otherwise @@ -170,6 +171,7 @@ struct Options sunrealtype htol_relch = SUN_RCONST(-1.0); sunrealtype htol_minfac = SUN_RCONST(-1.0); sunrealtype htol_maxfac = SUN_RCONST(-1.0); + sunrealtype slow_safety = SUN_RCONST(-1.0); }; // User-supplied functions called by the solver @@ -677,6 +679,11 @@ int main(int argc, char* argv[]) retval = ARKodeSetAdaptivityAdjustment(arkode_mem, 0); if (check_flag(retval, "ARKodeSetAdaptivityAdjustment")) return 1; } + if (opts.slow_safety > -1) + { + retval = ARKodeSetSafetyFactor(arkode_mem, opts.slow_safety); + if (check_flag(retval, "ARKodeSetSafetyFactor")) return 1; + } } else { @@ -1053,6 +1060,7 @@ void InputHelp() std::cout << " --k1s, --k2s, ..., -k6s : slow controller parameters\n"; std::cout << " --k1f, --k2f, -k3f : fast controller parameters\n"; std::cout << " --bias : slow and fast controller bias factors\n"; + std::cout << " --safety : slow time step safety factor\n"; std::cout << " --htol_relch : HTol controller maximum relative tolerance change\n"; std::cout @@ -1097,6 +1105,7 @@ int ReadInputs(std::vector& args, Options& opts, SUNContext ctx) find_arg(args, "--k2f", opts.k2f); find_arg(args, "--k3f", opts.k3f); find_arg(args, "--bias", opts.bias); + find_arg(args, "--safety", opts.slow_safety); find_arg(args, "--htol_relch", opts.htol_relch); find_arg(args, "--htol_minfac", opts.htol_minfac); find_arg(args, "--htol_maxfac", opts.htol_maxfac); @@ -1398,6 +1407,10 @@ static void PrintSlowAdaptivity(Options opts) { std::cout << " controller bias factor: " << opts.bias << "\n"; } + if (opts.slow_safety > -1) + { + std::cout << " slow step safety factor: " << opts.slow_safety << "\n"; + } } static void PrintFastAdaptivity(Options opts) From b5fabd341634b3233779fff0c8cf5084c79fbb84 Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Wed, 21 Aug 2024 15:07:59 -0500 Subject: [PATCH 018/286] Updated accuracy calculation for mri-adaptivity test problems. --- .../ark_test_brusselator_mriadapt.cpp | 84 +++++++-------- .../CXX_serial/ark_test_kpr_mriadapt.cpp | 102 +++++++++++------- 2 files changed, 106 insertions(+), 80 deletions(-) diff --git a/test/unit_tests/arkode/CXX_serial/ark_test_brusselator_mriadapt.cpp b/test/unit_tests/arkode/CXX_serial/ark_test_brusselator_mriadapt.cpp index 75192b0ee3..1177bae780 100644 --- a/test/unit_tests/arkode/CXX_serial/ark_test_brusselator_mriadapt.cpp +++ b/test/unit_tests/arkode/CXX_serial/ark_test_brusselator_mriadapt.cpp @@ -211,9 +211,8 @@ int main(int argc, char* argv[]) // General problem parameters sunrealtype T0 = SUN_RCONST(0.0); // initial time sunrealtype Tf = SUN_RCONST(10.0); // final time - sunrealtype dTout = SUN_RCONST(0.5); // time between outputs sunindextype NEQ = 3; // number of dependent vars. - int Nt = (int)ceil(Tf / dTout); // number of output times + int Nt = 20; // number of output times // Initial problem output // While traversing these, set various function pointers, table constants, and method orders. @@ -359,11 +358,8 @@ int main(int argc, char* argv[]) retval = ARKodeSetInitStep(inner_arkode_mem, opts.hf); if (check_flag(retval, "ARKodeSetInitStep")) return 1; } - if (opts.fast_pq == 1) - { - retval = ARKodeSetAdaptivityAdjustment(inner_arkode_mem, 0); - if (check_flag(retval, "ARKodeSetAdaptivityAdjustment")) return 1; - } + retval = ARKodeSetAdaptivityAdjustment(inner_arkode_mem, opts.fast_pq-1); + if (check_flag(retval, "ARKodeSetAdaptivityAdjustment")) return 1; } else { @@ -680,11 +676,8 @@ int main(int argc, char* argv[]) retval = ARKodeSetInitStep(arkode_mem, opts.hs); if (check_flag(retval, "ARKodeSetInitStep")) return 1; } - if (opts.slow_pq == 1) - { - retval = ARKodeSetAdaptivityAdjustment(arkode_mem, 0); - if (check_flag(retval, "ARKodeSetAdaptivityAdjustment")) return 1; - } + retval = ARKodeSetAdaptivityAdjustment(arkode_mem, opts.slow_pq-1); + if (check_flag(retval, "ARKodeSetAdaptivityAdjustment")) return 1; } else { @@ -699,19 +692,13 @@ int main(int argc, char* argv[]) // Main time-stepping loop: calls ARKodeEvolve to perform the // integration, then prints results. Stops when the final time // has been reached - sunrealtype t, tout; - sunrealtype uerr, verr, werr, uerrtot, verrtot, werrtot, errtot; + sunrealtype t = T0; + sunrealtype t2 = T0; + sunrealtype dTout = (Tf-T0)/Nt; + sunrealtype tout = T0+dTout; + sunrealtype u, v, w, uerr, verr, werr, uerrtot, verrtot, werrtot, errtot; sunrealtype accuracy; - t = T0; - tout = T0 + dTout; - uerr = ZERO; - verr = ZERO; - werr = ZERO; - uerrtot = ZERO; - verrtot = ZERO; - werrtot = ZERO; - errtot = ZERO; - accuracy = ZERO; + uerr = verr = werr = uerrtot = verrtot = werrtot = errtot = accuracy = ZERO; printf(" t u v w uerr verr " "werr\n"); printf(" " @@ -720,36 +707,40 @@ int main(int argc, char* argv[]) printf(" %10.6" FSYM " %10.6" FSYM " %10.6" FSYM " %10.6" FSYM " %.1" ESYM " %.1" ESYM " %.1" ESYM "\n", t, NV_Ith_S(y, 0), NV_Ith_S(y, 1), NV_Ith_S(y, 2), uerr, verr, werr); - - for (int iout = 0; iout < Nt; iout++) + int Nout = 0; + while (Tf - t > 1.0e-8) { - // call reference solver - retval = ARKodeSetStopTime(arkode_ref, tout); + + // reset reference solver so that it begins with identical state + retval = ARKodeReset(arkode_ref, t, y); + + // evolve solution in one-step mode + retval = ARKodeSetStopTime(arkode_mem, tout); if (check_flag(retval, "ARKodeSetStopTime")) return 1; - retval = ARKodeEvolve(arkode_ref, tout, yref, &t, ARK_NORMAL); + retval = ARKodeEvolve(arkode_mem, tout, y, &t, ARK_ONE_STEP); if (retval < 0) { - printf("ARKodeEvolve reference solution error (%i)\n", retval); + printf("ARKodeEvolve error (%i)\n", retval); return 1; } - // call integrator - retval = ARKodeSetStopTime(arkode_mem, tout); + // evolve reference solver to same time in "normal" mode + retval = ARKodeSetStopTime(arkode_ref, t); if (check_flag(retval, "ARKodeSetStopTime")) return 1; - retval = ARKodeEvolve(arkode_mem, tout, y, &t, ARK_NORMAL); + retval = ARKodeEvolve(arkode_ref, t, yref, &t2, ARK_NORMAL); if (retval < 0) { - printf("ARKodeEvolve error (%i)\n", retval); + printf("ARKodeEvolve reference solution error (%i)\n", retval); return 1; } // access/print solution and error - uerr = SUNRabs(NV_Ith_S(y, 0) - NV_Ith_S(yref, 0)); - verr = SUNRabs(NV_Ith_S(y, 1) - NV_Ith_S(yref, 1)); - werr = SUNRabs(NV_Ith_S(y, 2) - NV_Ith_S(yref, 2)); - printf(" %10.6" FSYM " %10.6" FSYM " %10.6" FSYM " %10.6" FSYM - " %.1" ESYM " %.1" ESYM " %.1" ESYM "\n", - t, NV_Ith_S(y, 0), NV_Ith_S(y, 1), NV_Ith_S(y, 2), uerr, verr, werr); + u = NV_Ith_S(y,0); + v = NV_Ith_S(y,1); + w = NV_Ith_S(y,2); + uerr = SUNRabs(NV_Ith_S(yref, 0) - u); + verr = SUNRabs(NV_Ith_S(yref, 1) - v); + werr = SUNRabs(NV_Ith_S(yref, 2) - w); uerrtot += uerr * uerr; verrtot += verr * verr; werrtot += werr * werr; @@ -760,10 +751,17 @@ int main(int argc, char* argv[]) opts.rtol * NV_Ith_S(yref, 1))); accuracy = std::max(accuracy, werr / SUNRabs(opts.atol + opts.rtol * NV_Ith_S(yref, 2))); + Nout++; - // successful solve: update time - tout += dTout; - tout = (tout > Tf) ? Tf : tout; + // Periodically output current results to screen + if (t >= tout) + { + tout += dTout; + tout = (tout > Tf) ? Tf : tout; + printf(" %10.6" FSYM " %10.6" FSYM " %10.6" FSYM " %10.6" FSYM + " %.1" ESYM " %.1" ESYM " %.1" ESYM "\n", + t, u, v, w, uerr, verr, werr); + } } uerrtot = SUNRsqrt(uerrtot / Nt); verrtot = SUNRsqrt(verrtot / Nt); diff --git a/test/unit_tests/arkode/CXX_serial/ark_test_kpr_mriadapt.cpp b/test/unit_tests/arkode/CXX_serial/ark_test_kpr_mriadapt.cpp index c9790af566..ef30514c78 100644 --- a/test/unit_tests/arkode/CXX_serial/ark_test_kpr_mriadapt.cpp +++ b/test/unit_tests/arkode/CXX_serial/ark_test_kpr_mriadapt.cpp @@ -1,6 +1,5 @@ /* ---------------------------------------------------------------- * Programmer(s): Daniel R. Reynolds @ SMU - * Rujeko Chinomona @ SMU * ---------------------------------------------------------------- * SUNDIALS Copyright Start * Copyright (c) 2002-2024, Lawrence Livermore National Security @@ -23,6 +22,8 @@ * * This problem has analytical solution given by * u(t) = sqrt(2+r(t)), v(t) = sqrt(2+s(t)). + * However, we use a reference solver here to assess performance + * of the local multirate adaptivity controller. * * This program allows a number of parameters: * e: fast/slow coupling strength [default = 0.5] @@ -192,8 +193,6 @@ static int ReadInputs(std::vector& args, Options& opts, SUNContext ctx); static void PrintSlowAdaptivity(Options opts); static void PrintFastAdaptivity(Options opts); - -// Private function to check function return values static sunrealtype r(sunrealtype t, Options* opts); static sunrealtype s(sunrealtype t, Options* opts); static sunrealtype rdot(sunrealtype t, Options* opts); @@ -217,9 +216,8 @@ int main(int argc, char* argv[]) // General problem parameters sunrealtype T0 = SUN_RCONST(0.0); // initial time sunrealtype Tf = SUN_RCONST(5.0); // final time - sunrealtype dTout = SUN_RCONST(0.25); // time between outputs sunindextype NEQ = 2; // number of dependent vars. - int Nt = (int)ceil(Tf / dTout); // number of output times + int Nt = 20; // number of output times // Initial problem output // While traversing these, set various function pointers, table constants, and method orders. @@ -266,12 +264,28 @@ int main(int argc, char* argv[]) else { std::cout << "\n Fast order " << opts.fast_order << std::endl; } PrintFastAdaptivity(opts); - // Create and initialize serial vector for the solution - N_Vector y = NULL; - y = N_VNew_Serial(NEQ, sunctx); + // Create and initialize serial vectors for the solution and reference + N_Vector y = N_VNew_Serial(NEQ, sunctx); if (check_ptr((void*)y, "N_VNew_Serial")) return 1; + N_Vector yref = N_VClone(y); + if (check_ptr((void*)yref, "N_VClone")) return 1; + + // Set initial conditions retval = Ytrue(T0, y, &opts); if (check_flag(retval, "Ytrue")) return 1; + N_VScale(ONE, y, yref); + + // Create and configure reference solver object + void* arkode_ref = ERKStepCreate(fn, T0, yref, sunctx); + if (check_ptr((void*)arkode_ref, "ERKStepCreate")) return 1; + retval = ARKodeSetUserData(arkode_ref, (void*)&opts); + if (check_flag(retval, "ARKodeSetUserData")) return 1; + retval = ARKodeSetOrder(arkode_ref, 5); + if (check_flag(retval, "ARKodeSetOrder")) return 1; + retval = ARKodeSStolerances(arkode_ref, SUN_RCONST(1.e-10), SUN_RCONST(1.e-12)); + if (check_flag(retval, "ARKodeSStolerances")) return 1; + retval = ARKodeSetMaxNumSteps(arkode_ref, 10000000); + if (check_flag(retval, "ARKodeSetMaxNumSteps")) return (1); // Create and configure fast controller object SUNAdaptController fcontrol = NULL; @@ -691,53 +705,66 @@ int main(int argc, char* argv[]) // Main time-stepping loop: calls ARKodeEvolve to perform the // integration, then prints results. Stops when the final time // has been reached - sunrealtype t, tout; - sunrealtype uerr, verr, uerrtot, verrtot, errtot, accuracy; - t = T0; - tout = T0 + dTout; - uerr = ZERO; - verr = ZERO; - uerrtot = ZERO; - verrtot = ZERO; - errtot = ZERO; - accuracy = ZERO; + sunrealtype t = T0; + sunrealtype t2 = T0; + sunrealtype dTout = (Tf-T0)/Nt; + sunrealtype tout = T0+dTout; + sunrealtype u, v, uerr, verr, uerrtot, verrtot, errtot, accuracy; + uerr = verr = uerrtot = verrtot = errtot = accuracy = ZERO; printf(" t u v uerr verr\n"); printf(" ------------------------------------------------------\n"); printf(" %10.6" FSYM " %10.6" FSYM " %10.6" FSYM " %.2" ESYM " %.2" ESYM "\n", t, NV_Ith_S(y, 0), NV_Ith_S(y, 1), uerr, verr); - - for (int iout = 0; iout < Nt; iout++) + int Nout = 0; + while (Tf - t > 1.0e-8) { - // set stop time to ensure that solutions are reported to full accuracy + + // reset reference solver so that it begins with identical state + retval = ARKodeReset(arkode_ref, t, y); + + // evolve solution in one-step mode retval = ARKodeSetStopTime(arkode_mem, tout); if (check_flag(retval, "ARKodeSetStopTime")) return 1; - - // call integrator - retval = ARKodeEvolve(arkode_mem, tout, y, &t, ARK_NORMAL); + retval = ARKodeEvolve(arkode_mem, tout, y, &t, ARK_ONE_STEP); if (retval < 0) { printf("ARKodeEvolve error (%i)\n", retval); return 1; } + // evolve reference solver to same time in "normal" mode + retval = ARKodeSetStopTime(arkode_ref, t); + if (check_flag(retval, "ARKodeSetStopTime")) return 1; + retval = ARKodeEvolve(arkode_ref, t, yref, &t2, ARK_NORMAL); + if (retval < 0) + { + printf("ARKodeEvolve reference solution error (%i)\n", retval); + return 1; + } + // access/print solution and error - uerr = SUNRabs(NV_Ith_S(y, 0) - utrue(t, &opts)); - verr = SUNRabs(NV_Ith_S(y, 1) - vtrue(t, &opts)); - printf(" %10.6" FSYM " %10.6" FSYM " %10.6" FSYM " %.2" ESYM - " %.2" ESYM "\n", - t, NV_Ith_S(y, 0), NV_Ith_S(y, 1), uerr, verr); + u = NV_Ith_S(y,0); + v = NV_Ith_S(y,1); + uerr = SUNRabs(NV_Ith_S(yref, 0) - u); + verr = SUNRabs(NV_Ith_S(yref, 1) - v); uerrtot += uerr * uerr; verrtot += verr * verr; errtot += uerr * uerr + verr * verr; - accuracy = std::max(accuracy, - uerr / SUNRabs(opts.atol + opts.rtol * utrue(t, &opts))); - accuracy = std::max(accuracy, - verr / SUNRabs(opts.atol + opts.rtol * vtrue(t, &opts))); - - // successful solve: update time - tout += dTout; - tout = (tout > Tf) ? Tf : tout; + accuracy = std::max(accuracy, uerr / SUNRabs(opts.atol + + opts.rtol * NV_Ith_S(yref, 0))); + accuracy = std::max(accuracy, verr / SUNRabs(opts.atol + + opts.rtol * NV_Ith_S(yref, 1))); + Nout++; + + // Periodically output current results to screen + if (t >= tout) + { + tout += dTout; + tout = (tout > Tf) ? Tf : tout; + printf(" %10.6" FSYM " %10.6" FSYM " %10.6" FSYM " %.2" ESYM + " %.2" ESYM "\n", t, u, v, uerr, verr); + } } uerrtot = SUNRsqrt(uerrtot / Nt); verrtot = SUNRsqrt(verrtot / Nt); @@ -807,6 +834,7 @@ int main(int argc, char* argv[]) ARKodeFree(&inner_arkode_mem); // Free fast integrator memory MRIStepInnerStepper_Free(&inner_stepper); // Free inner stepper structure ARKodeFree(&arkode_mem); // Free slow integrator memory + ARKodeFree(&arkode_ref); // Free reference solver memory return 0; } From 2d1de72b9c375115f8a60aa6d6ac365288e330ad Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Tue, 27 Aug 2024 12:32:30 -0500 Subject: [PATCH 019/286] Removed logging from reference solver --- .../ark_test_brusselator_mriadapt.cpp | 22 ++++++++++++++----- .../CXX_serial/ark_test_kpr_mriadapt.cpp | 22 ++++++++++++++----- 2 files changed, 34 insertions(+), 10 deletions(-) diff --git a/test/unit_tests/arkode/CXX_serial/ark_test_brusselator_mriadapt.cpp b/test/unit_tests/arkode/CXX_serial/ark_test_brusselator_mriadapt.cpp index b0a11d2269..7454f8a24b 100644 --- a/test/unit_tests/arkode/CXX_serial/ark_test_brusselator_mriadapt.cpp +++ b/test/unit_tests/arkode/CXX_serial/ark_test_brusselator_mriadapt.cpp @@ -121,6 +121,7 @@ #include #include // dense linear solver #include // dense matrix type, fcts., macros +#include #include // common utility functions #if defined(SUNDIALS_EXTENDED_PRECISION) @@ -201,8 +202,9 @@ static void PrintFastAdaptivity(Options opts); // Main Program int main(int argc, char* argv[]) { - // SUNDIALS context object for this simulation - sundials::Context sunctx; + // SUNDIALS context objects + sundials::Context sunctx; // main solver + sundials::Context refctx; // reference solver // Read input options Options opts; @@ -258,11 +260,20 @@ int main(int argc, char* argv[]) else { std::cout << "\n Fast order " << opts.fast_order << std::endl; } PrintFastAdaptivity(opts); + // If SUNLogger is enabled, manually disable it for the reference solver + SUNLogger logger = NULL; + retval = SUNLogger_Create(SUN_COMM_NULL, 0, &logger); + retval = SUNContext_SetLogger(refctx, logger); + retval = SUNLogger_SetErrorFilename(logger, "/dev/null"); + retval = SUNLogger_SetWarningFilename(logger, "/dev/null"); + retval = SUNLogger_SetInfoFilename(logger, "/dev/null"); + retval = SUNLogger_SetDebugFilename(logger, "/dev/null"); + // Create and initialize serial vectors for the solution and reference N_Vector y = N_VNew_Serial(NEQ, sunctx); if (check_ptr((void*)y, "N_VNew_Serial")) return 1; - N_Vector yref = N_VClone(y); - if (check_ptr((void*)yref, "N_VClone")) return 1; + N_Vector yref = N_VNew_Serial(NEQ, refctx); + if (check_ptr((void*)yref, "N_VNew_Serial")) return 1; // Set initial conditions NV_Ith_S(y, 0) = SUN_RCONST(1.2); @@ -271,7 +282,7 @@ int main(int argc, char* argv[]) N_VScale(ONE, y, yref); // Create and configure reference solver object - void* arkode_ref = ERKStepCreate(fn, T0, yref, sunctx); + void* arkode_ref = ERKStepCreate(fn, T0, yref, refctx); if (check_ptr((void*)arkode_ref, "ERKStepCreate")) return 1; retval = ARKodeSetUserData(arkode_ref, (void*)&opts); if (check_flag(retval, "ARKodeSetUserData")) return 1; @@ -846,6 +857,7 @@ int main(int argc, char* argv[]) MRIStepInnerStepper_Free(&inner_stepper); // Free inner stepper structure ARKodeFree(&arkode_mem); // Free slow integrator memory ARKodeFree(&arkode_ref); // Free reference solver memory + SUNLogger_Destroy(&logger); // Free logger return 0; } diff --git a/test/unit_tests/arkode/CXX_serial/ark_test_kpr_mriadapt.cpp b/test/unit_tests/arkode/CXX_serial/ark_test_kpr_mriadapt.cpp index 3a4ba7c374..b2f28e8489 100644 --- a/test/unit_tests/arkode/CXX_serial/ark_test_kpr_mriadapt.cpp +++ b/test/unit_tests/arkode/CXX_serial/ark_test_kpr_mriadapt.cpp @@ -119,6 +119,7 @@ #include #include // dense linear solver #include // dense matrix type, fcts., macros +#include #include // common utility functions #if defined(SUNDIALS_EXTENDED_PRECISION) @@ -206,8 +207,9 @@ static int Ytrue(sunrealtype t, N_Vector y, Options* opts); // Main Program int main(int argc, char* argv[]) { - // SUNDIALS context object for this simulation - sundials::Context sunctx; + // SUNDIALS context objects + sundials::Context sunctx; // main solver + sundials::Context refctx; // reference solver // Read input options Options opts; @@ -266,11 +268,20 @@ int main(int argc, char* argv[]) else { std::cout << "\n Fast order " << opts.fast_order << std::endl; } PrintFastAdaptivity(opts); + // If SUNLogger is enabled, manually disable it for the reference solver + SUNLogger logger = NULL; + retval = SUNLogger_Create(SUN_COMM_NULL, 0, &logger); + retval = SUNContext_SetLogger(refctx, logger); + retval = SUNLogger_SetErrorFilename(logger, "/dev/null"); + retval = SUNLogger_SetWarningFilename(logger, "/dev/null"); + retval = SUNLogger_SetInfoFilename(logger, "/dev/null"); + retval = SUNLogger_SetDebugFilename(logger, "/dev/null"); + // Create and initialize serial vectors for the solution and reference N_Vector y = N_VNew_Serial(NEQ, sunctx); if (check_ptr((void*)y, "N_VNew_Serial")) return 1; - N_Vector yref = N_VClone(y); - if (check_ptr((void*)yref, "N_VClone")) return 1; + N_Vector yref = N_VNew_Serial(NEQ, refctx); + if (check_ptr((void*)yref, "N_VNew_Serial")) return 1; // Set initial conditions retval = Ytrue(T0, y, &opts); @@ -278,7 +289,7 @@ int main(int argc, char* argv[]) N_VScale(ONE, y, yref); // Create and configure reference solver object - void* arkode_ref = ERKStepCreate(fn, T0, yref, sunctx); + void* arkode_ref = ERKStepCreate(fn, T0, yref, refctx); if (check_ptr((void*)arkode_ref, "ERKStepCreate")) return 1; retval = ARKodeSetUserData(arkode_ref, (void*)&opts); if (check_flag(retval, "ARKodeSetUserData")) return 1; @@ -842,6 +853,7 @@ int main(int argc, char* argv[]) MRIStepInnerStepper_Free(&inner_stepper); // Free inner stepper structure ARKodeFree(&arkode_mem); // Free slow integrator memory ARKodeFree(&arkode_ref); // Free reference solver memory + SUNLogger_Destroy(&logger); // Free logger return 0; } From a104e7e2db83c9e5d71453678558ab8bb8fc5d84 Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Wed, 28 Aug 2024 15:02:32 -0500 Subject: [PATCH 020/286] Ran code formatter; added initial implementation for MRIStep to serve as its own inner stepper --- include/arkode/arkode_mristep.h | 18 +- src/arkode/arkode_erkstep.c | 3 +- src/arkode/arkode_mri_tables.c | 3 +- src/arkode/arkode_mristep.c | 657 ++++++++++++++++-- src/arkode/arkode_mristep_impl.h | 25 + src/arkode/fmod_int32/farkode_mristep_mod.c | 14 + src/arkode/fmod_int32/farkode_mristep_mod.f90 | 26 + src/arkode/fmod_int64/farkode_mristep_mod.c | 14 + src/arkode/fmod_int64/farkode_mristep_mod.f90 | 26 + .../ark_test_brusselator_mriadapt.cpp | 27 +- .../CXX_serial/ark_test_dahlquist_mri.cpp | 10 +- .../CXX_serial/ark_test_kpr_mriadapt.cpp | 26 +- 12 files changed, 749 insertions(+), 100 deletions(-) diff --git a/include/arkode/arkode_mristep.h b/include/arkode/arkode_mristep.h index 20f98dcf62..548bea7247 100644 --- a/include/arkode/arkode_mristep.h +++ b/include/arkode/arkode_mristep.h @@ -128,13 +128,13 @@ typedef int (*MRIStepInnerSetRTol)(MRIStepInnerStepper stepper, sunrealtype rtol struct MRIStepCouplingMem { ARKODE_MRIType type; /* flag to encode the MRI method type */ - int nmat; /* number of MRI coupling matrices */ - int stages; /* size of coupling matrices ((stages+1) * stages) */ - int q; /* method order of accuracy */ - int p; /* embedding order of accuracy */ - sunrealtype* c; /* stage abscissae */ - sunrealtype*** W; /* explicit coupling matrices [nmat][stages+1][stages] */ - sunrealtype*** G; /* implicit coupling matrices [nmat][stages+1][stages] */ + int nmat; /* number of MRI coupling matrices */ + int stages; /* size of coupling matrices ((stages+1) * stages) */ + int q; /* method order of accuracy */ + int p; /* embedding order of accuracy */ + sunrealtype* c; /* stage abscissae */ + sunrealtype*** W; /* explicit coupling matrices [nmat][stages+1][stages] */ + sunrealtype*** G; /* implicit coupling matrices [nmat][stages+1][stages] */ int ngroup; /* number of stage groups (MERK-specific) */ int** group; /* stages to integrate together (MERK-specific) */ @@ -230,6 +230,10 @@ SUNDIALS_EXPORT int MRIStepInnerStepper_GetForcingData( MRIStepInnerStepper stepper, sunrealtype* tshift, sunrealtype* tscale, N_Vector** forcing, int* nforcing); +/* Utility to wrap ERKStep as an MRIStepInnerStepper */ +SUNDIALS_EXPORT int MRIStepCreateMRIStepInnerStepper(void* arkode_mem, + MRIStepInnerStepper* stepper); + /* -------------------------------------------------------------------------- * Deprecated Functions -- all are superseded by shared ARKODE-level routines * -------------------------------------------------------------------------- */ diff --git a/src/arkode/arkode_erkstep.c b/src/arkode/arkode_erkstep.c index 42f3dd09b5..beb73a098a 100644 --- a/src/arkode/arkode_erkstep.c +++ b/src/arkode/arkode_erkstep.c @@ -1502,8 +1502,7 @@ int erkStep_SetInnerForcing(void* arkode_mem, sunrealtype tshift, int retval; /* access ARKodeERKStepMem structure */ - retval = erkStep_AccessARKODEStepMem(arkode_mem, "erkStep_SetInnerForcing", - &ark_mem, &step_mem); + retval = erkStep_AccessARKODEStepMem(arkode_mem, __func__, &ark_mem, &step_mem); if (retval != ARK_SUCCESS) { return (retval); } if (nvecs > 0) diff --git a/src/arkode/arkode_mri_tables.c b/src/arkode/arkode_mri_tables.c index 31812c7685..a1b7bcc35d 100644 --- a/src/arkode/arkode_mri_tables.c +++ b/src/arkode/arkode_mri_tables.c @@ -69,8 +69,7 @@ MRIStepCoupling MRIStepCoupling_LoadTableByName(const char* method) /*--------------------------------------------------------------- Routine to allocate an empty MRIStepCoupling structure ---------------------------------------------------------------*/ -MRIStepCoupling MRIStepCoupling_Alloc(int nmat, int stages, - ARKODE_MRIType type) +MRIStepCoupling MRIStepCoupling_Alloc(int nmat, int stages, ARKODE_MRIType type) { int i, j; sunbooleantype hasOmegas, hasGammas; diff --git a/src/arkode/arkode_mristep.c b/src/arkode/arkode_mristep.c index dfbd3fd456..1be5da17f3 100644 --- a/src/arkode/arkode_mristep.c +++ b/src/arkode/arkode_mristep.c @@ -226,6 +226,12 @@ void* MRIStepCreate(ARKRhsFn fse, ARKRhsFn fsi, sunrealtype t0, N_Vector y0, step_mem->pre_inner_evolve = NULL; step_mem->post_inner_evolve = NULL; + /* Initialize external polynomial forcing data */ + step_mem->expforcing = SUNFALSE; + step_mem->impforcing = SUNFALSE; + step_mem->forcing = NULL; + step_mem->nforcing = 0; + /* Initialize main ARKODE infrastructure (allocates vectors) */ retval = arkInit(ark_mem, t0, y0, FIRST_INIT); if (retval != ARK_SUCCESS) @@ -1048,9 +1054,9 @@ int mriStep_Init(ARKodeMem ark_mem, int init_type) free(step_mem->Xvecs); ark_mem->liw -= step_mem->nfusedopvecs; } - step_mem->nfusedopvecs = 2 * step_mem->MRIC->stages + 2; - step_mem->cvals = (sunrealtype*)calloc(step_mem->nfusedopvecs, - sizeof(*step_mem->cvals)); + step_mem->nfusedopvecs = 2 * step_mem->MRIC->stages + 2 + step_mem->nforcing; + step_mem->cvals = (sunrealtype*)calloc(step_mem->nfusedopvecs, + sizeof(*step_mem->cvals)); if (step_mem->cvals == NULL) { arkProcessError(ark_mem, ARK_MEM_FAIL, __LINE__, __func__, __FILE__, @@ -1403,7 +1409,7 @@ int mriStep_FullRHS(ARKodeMem ark_mem, sunrealtype t, N_Vector y, N_Vector f, int mode) { ARKodeMRIStepMem step_mem; - int i, sa_stage, retval; + int i, sa_stage, nvec, retval; /* access ARKodeMRIStepMem structure */ retval = mriStep_AccessStepMem(ark_mem, __func__, &step_mem); @@ -1451,23 +1457,49 @@ int mriStep_FullRHS(ARKodeMem ark_mem, sunrealtype t, N_Vector y, N_Vector f, } } - /* compute the fast component (force new RHS computation) */ - retval = mriStepInnerStepper_FullRhs(step_mem->stepper, t, y, f, - ARK_FULLRHS_OTHER); - if (retval != ARK_SUCCESS) + /* Add external forcing to Fse[0] or Fsi[0], if applicable */ + if (step_mem->expforcing) { - arkProcessError(ark_mem, ARK_RHSFUNC_FAIL, __LINE__, __func__, __FILE__, - MSG_ARK_RHSFUNC_FAILED, t); - return (ARK_RHSFUNC_FAIL); + step_mem->cvals[0] = ONE; + step_mem->Xvecs[0] = step_mem->Fse[0]; + nvec = 1; + mriStep_ApplyForcing(step_mem, t, ONE, &nvec); + N_VLinearCombination(nvec, step_mem->cvals, step_mem->Xvecs, + step_mem->Fse[0]); } + if (step_mem->impforcing) + { + step_mem->cvals[0] = ONE; + step_mem->Xvecs[0] = step_mem->Fsi[0]; + nvec = 1; + mriStep_ApplyForcing(step_mem, t, ONE, &nvec); + N_VLinearCombination(nvec, step_mem->cvals, step_mem->Xvecs, + step_mem->Fsi[0]); + } + } + + /* compute the fast component (force new RHS computation) */ + retval = mriStepInnerStepper_FullRhs(step_mem->stepper, t, y, f, + ARK_FULLRHS_OTHER); + if (retval != ARK_SUCCESS) + { + arkProcessError(ark_mem, ARK_RHSFUNC_FAIL, __LINE__, __func__, __FILE__, + MSG_ARK_RHSFUNC_FAILED, t); + return (ARK_RHSFUNC_FAIL); } /* combine RHS vectors into output */ if (step_mem->explicit_rhs && step_mem->implicit_rhs) { /* ImEx */ - N_VLinearSum(ONE, step_mem->Fse[0], ONE, f, f); - N_VLinearSum(ONE, step_mem->Fsi[0], ONE, f, f); + step_mem->cvals[0] = ONE; + step_mem->Xvecs[0] = f; + step_mem->cvals[1] = ONE; + step_mem->Xvecs[1] = step_mem->Fse[0]; + step_mem->cvals[2] = ONE; + step_mem->Xvecs[2] = step_mem->Fsi[0]; + nvec = 3; + N_VLinearCombination(nvec, step_mem->cvals, step_mem->Xvecs, f); } else if (step_mem->implicit_rhs) { @@ -1538,19 +1570,39 @@ int mriStep_FullRHS(ARKodeMem ark_mem, sunrealtype t, N_Vector y, N_Vector f, return (ARK_RHSFUNC_FAIL); } } - } - /* compute the fast component (force new RHS computation) */ - retval = mriStepInnerStepper_FullRhs(step_mem->stepper, t, y, f, - ARK_FULLRHS_OTHER); - if (retval != ARK_SUCCESS) - { - arkProcessError(ark_mem, ARK_RHSFUNC_FAIL, __LINE__, __func__, __FILE__, - MSG_ARK_RHSFUNC_FAILED, t); - return (ARK_RHSFUNC_FAIL); + /* Add external forcing to Fse[0] or Fsi[0], as appropriate */ + if (step_mem->expforcing) + { + step_mem->cvals[0] = ONE; + step_mem->Xvecs[0] = step_mem->Fse[0]; + nvec = 1; + mriStep_ApplyForcing(step_mem, t, ONE, &nvec); + N_VLinearCombination(nvec, step_mem->cvals, step_mem->Xvecs, + step_mem->Fse[0]); + } + if (step_mem->impforcing) + { + step_mem->cvals[0] = ONE; + step_mem->Xvecs[0] = step_mem->Fsi[0]; + nvec = 1; + mriStep_ApplyForcing(step_mem, t, ONE, &nvec); + N_VLinearCombination(nvec, step_mem->cvals, step_mem->Xvecs, + step_mem->Fsi[0]); + } } } + /* compute the fast component (force new RHS computation) */ + retval = mriStepInnerStepper_FullRhs(step_mem->stepper, t, y, f, + ARK_FULLRHS_OTHER); + if (retval != ARK_SUCCESS) + { + arkProcessError(ark_mem, ARK_RHSFUNC_FAIL, __LINE__, __func__, __FILE__, + MSG_ARK_RHSFUNC_FAILED, t); + return (ARK_RHSFUNC_FAIL); + } + /* combine RHS vectors into output */ if (step_mem->explicit_rhs && step_mem->implicit_rhs) { @@ -1573,6 +1625,20 @@ int mriStep_FullRHS(ARKodeMem ark_mem, sunrealtype t, N_Vector y, N_Vector f, case ARK_FULLRHS_OTHER: + /* compute the fast component (force new RHS computation) */ + nvec = 0; + retval = mriStepInnerStepper_FullRhs(step_mem->stepper, t, y, f, + ARK_FULLRHS_OTHER); + if (retval != ARK_SUCCESS) + { + arkProcessError(ark_mem, ARK_RHSFUNC_FAIL, __LINE__, __func__, __FILE__, + MSG_ARK_RHSFUNC_FAILED, t); + return (ARK_RHSFUNC_FAIL); + } + step_mem->cvals[nvec] = ONE; + step_mem->Xvecs[nvec] = f; + nvec++; + /* compute the explicit component and store in ark_tempv2 */ if (step_mem->explicit_rhs) { @@ -1584,6 +1650,9 @@ int mriStep_FullRHS(ARKodeMem ark_mem, sunrealtype t, N_Vector y, N_Vector f, MSG_ARK_RHSFUNC_FAILED, t); return (ARK_RHSFUNC_FAIL); } + step_mem->cvals[nvec] = ONE; + step_mem->Xvecs[nvec] = ark_mem->tempv2; + nvec++; } /* compute the implicit component and store in sdata */ @@ -1597,35 +1666,19 @@ int mriStep_FullRHS(ARKodeMem ark_mem, sunrealtype t, N_Vector y, N_Vector f, MSG_ARK_RHSFUNC_FAILED, t); return (ARK_RHSFUNC_FAIL); } + step_mem->cvals[nvec] = ONE; + step_mem->Xvecs[nvec] = step_mem->sdata; + nvec++; } - /* compute the fast component (force new RHS computation) */ - retval = mriStepInnerStepper_FullRhs(step_mem->stepper, t, y, f, - ARK_FULLRHS_OTHER); - if (retval != ARK_SUCCESS) + /* Add external forcing components to linear combination */ + if (step_mem->expforcing || step_mem->impforcing) { - arkProcessError(ark_mem, ARK_RHSFUNC_FAIL, __LINE__, __func__, __FILE__, - MSG_ARK_RHSFUNC_FAILED, t); - return (ARK_RHSFUNC_FAIL); + mriStep_ApplyForcing(step_mem, t, ONE, &nvec); } /* combine RHS vectors into output */ - if (step_mem->explicit_rhs && step_mem->implicit_rhs) - { - /* ImEx */ - N_VLinearSum(ONE, ark_mem->tempv2, ONE, f, f); - N_VLinearSum(ONE, step_mem->sdata, ONE, f, f); - } - else if (step_mem->implicit_rhs) - { - /* implicit */ - N_VLinearSum(ONE, step_mem->sdata, ONE, f, f); - } - else - { - /* explicit */ - N_VLinearSum(ONE, ark_mem->tempv2, ONE, f, f); - } + N_VLinearCombination(nvec, step_mem->cvals, step_mem->Xvecs, f); break; @@ -1688,6 +1741,7 @@ int mriStep_TakeStepMRIGARK(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPt sunbooleantype calc_fslow; sunbooleantype need_inner_dsm; sunbooleantype do_embedding; + int nvec; /* access the MRIStep mem structure */ retval = mriStep_AccessStepMem(ark_mem, __func__, &step_mem); @@ -1707,12 +1761,12 @@ int mriStep_TakeStepMRIGARK(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPt /* if MRI adaptivity is enabled: reset fast accumulated error, and send appropriate control parameter to the fast integrator */ - adapt_type = SUNAdaptController_GetType(ark_mem->hadapt_mem->hcontroller); + adapt_type = SUNAdaptController_GetType(ark_mem->hadapt_mem->hcontroller); need_inner_dsm = SUNFALSE; if ((adapt_type == SUN_ADAPTCONTROLLER_MRI_H) || (adapt_type == SUN_ADAPTCONTROLLER_MRI_TOL)) { - need_inner_dsm = SUNTRUE; + need_inner_dsm = SUNTRUE; step_mem->inner_dsm = ZERO; retval = mriStepInnerStepper_ResetError(step_mem->stepper); if (retval != ARK_SUCCESS) @@ -1775,7 +1829,6 @@ int mriStep_TakeStepMRIGARK(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPt function here (unlike ERKStep and ARKStep) since it does not need to check for FSAL or SA methods and thus avoids potentially unnecessary evaluations of the inner (fast) RHS function */ - if (!(ark_mem->fn_is_current)) { /* compute the explicit component */ @@ -1796,6 +1849,26 @@ int mriStep_TakeStepMRIGARK(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPt if (retval) { return ARK_RHSFUNC_FAIL; } } + /* Add external forcing to Fse[0] or Fsi[0], if appropriate */ + if (step_mem->expforcing) + { + step_mem->cvals[0] = ONE; + step_mem->Xvecs[0] = step_mem->Fse[0]; + nvec = 1; + mriStep_ApplyForcing(step_mem, t0, ONE, &nvec); + N_VLinearCombination(nvec, step_mem->cvals, step_mem->Xvecs, + step_mem->Fse[0]); + } + if (step_mem->impforcing) + { + step_mem->cvals[0] = ONE; + step_mem->Xvecs[0] = step_mem->Fsi[0]; + nvec = 1; + mriStep_ApplyForcing(step_mem, t0, ONE, &nvec); + N_VLinearCombination(nvec, step_mem->cvals, step_mem->Xvecs, + step_mem->Fsi[0]); + } + ark_mem->fn_is_current = SUNTRUE; } @@ -1932,6 +2005,17 @@ int mriStep_TakeStepMRIGARK(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPt if (retval < 0) { return (ARK_RHSFUNC_FAIL); } if (retval > 0) { return (ARK_UNREC_RHSFUNC_ERR); } + /* Add external forcing to Fse, if applicable */ + if (step_mem->expforcing) + { + step_mem->cvals[0] = ONE; + step_mem->Xvecs[0] = step_mem->Fse[step_mem->stage_map[is]]; + nvec = 1; + mriStep_ApplyForcing(step_mem, tf, ONE, &nvec); + N_VLinearCombination(nvec, step_mem->cvals, step_mem->Xvecs, + step_mem->Fse[step_mem->stage_map[is]]); + } + #ifdef SUNDIALS_LOGGING_EXTRA_DEBUG SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, "ARKODE::mriStep_TakeStepMRIGARK", @@ -1951,6 +2035,17 @@ int mriStep_TakeStepMRIGARK(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPt step_mem->Fsi[step_mem->stage_map[is]], ark_mem->user_data); step_mem->nfsi++; + + /* Add external forcing to Fsi, if applicable */ + if (step_mem->impforcing) + { + step_mem->cvals[0] = ONE; + step_mem->Xvecs[0] = step_mem->Fsi[step_mem->stage_map[is]]; + nvec = 1; + mriStep_ApplyForcing(step_mem, tf, ONE, &nvec); + N_VLinearCombination(nvec, step_mem->cvals, step_mem->Xvecs, + step_mem->Fsi[step_mem->stage_map[is]]); + } } else { @@ -2128,8 +2223,9 @@ int mriStep_TakeStepMRISR(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr) sunbooleantype impl_corr; /* is slow correct. implicit? */ sunbooleantype store_imprhs; /* temporary storage */ sunbooleantype store_exprhs; - sunrealtype cstage; /* current stage abscissa */ + sunrealtype cstage; /* current stage abscissa */ sunbooleantype need_inner_dsm; + int nvec; const sunrealtype tol = SUN_RCONST(100.0) * SUN_UNIT_ROUNDOFF; /* access the MRIStep mem structure */ @@ -2147,12 +2243,12 @@ int mriStep_TakeStepMRISR(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr) /* if MRI adaptivity is enabled: reset fast accumulated error, and send appropriate control parameter to the fast integrator */ - adapt_type = SUNAdaptController_GetType(ark_mem->hadapt_mem->hcontroller); + adapt_type = SUNAdaptController_GetType(ark_mem->hadapt_mem->hcontroller); need_inner_dsm = SUNFALSE; if ((adapt_type == SUN_ADAPTCONTROLLER_MRI_H) || (adapt_type == SUN_ADAPTCONTROLLER_MRI_TOL)) { - need_inner_dsm = SUNTRUE; + need_inner_dsm = SUNTRUE; step_mem->inner_dsm = ZERO; retval = mriStepInnerStepper_ResetError(step_mem->stepper); if (retval != ARK_SUCCESS) @@ -2224,6 +2320,26 @@ int mriStep_TakeStepMRISR(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr) if (retval) { return ARK_RHSFUNC_FAIL; } } + /* Add external forcing to Fse[0] or Fse[0], if applicable */ + if (step_mem->expforcing) + { + step_mem->cvals[0] = ONE; + step_mem->Xvecs[0] = step_mem->Fse[0]; + nvec = 1; + mriStep_ApplyForcing(step_mem, ark_mem->tn, ONE, &nvec); + N_VLinearCombination(nvec, step_mem->cvals, step_mem->Xvecs, + step_mem->Fse[0]); + } + if (step_mem->impforcing) + { + step_mem->cvals[0] = ONE; + step_mem->Xvecs[0] = step_mem->Fsi[0]; + nvec = 1; + mriStep_ApplyForcing(step_mem, ark_mem->tn, ONE, &nvec); + N_VLinearCombination(nvec, step_mem->cvals, step_mem->Xvecs, + step_mem->Fsi[0]); + } + /* combine both RHS into Fse for ImEx problems */ if (step_mem->implicit_rhs && step_mem->explicit_rhs) { @@ -2441,6 +2557,17 @@ int mriStep_TakeStepMRISR(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr) if (retval < 0) { return (ARK_RHSFUNC_FAIL); } if (retval > 0) { return (ARK_UNREC_RHSFUNC_ERR); } + /* Add external forcing to Fse[stage], if applicable */ + if (step_mem->expforcing) + { + step_mem->cvals[0] = ONE; + step_mem->Xvecs[0] = step_mem->Fse[stage]; + nvec = 1; + mriStep_ApplyForcing(step_mem, ark_mem->tcur, ONE, &nvec); + N_VLinearCombination(nvec, step_mem->cvals, step_mem->Xvecs, + step_mem->Fse[stage]); + } + #ifdef SUNDIALS_LOGGING_EXTRA_DEBUG SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, "ARKODE::mriStep_TakeStepMRISR", "slow explicit RHS", @@ -2457,6 +2584,17 @@ int mriStep_TakeStepMRISR(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr) retval = step_mem->fsi(ark_mem->tcur, ark_mem->ycur, step_mem->Fsi[stage], ark_mem->user_data); step_mem->nfsi++; + + /* Add external forcing to Fsi[stage], if applicable */ + if (step_mem->impforcing) + { + step_mem->cvals[0] = ONE; + step_mem->Xvecs[0] = step_mem->Fsi[stage]; + nvec = 1; + mriStep_ApplyForcing(step_mem, ark_mem->tcur, ONE, &nvec); + N_VLinearCombination(nvec, step_mem->cvals, step_mem->Xvecs, + step_mem->Fsi[stage]); + } } else { @@ -2569,6 +2707,7 @@ int mriStep_TakeStepMERK(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr) sunbooleantype solution; /* or solution stages */ sunrealtype cstage; /* current stage abscissa */ sunbooleantype need_inner_dsm; + int nvec; /* access the MRIStep mem structure */ retval = mriStep_AccessStepMem(ark_mem, __func__, &step_mem); @@ -2588,12 +2727,12 @@ int mriStep_TakeStepMERK(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr) /* if MRI adaptivity is enabled: reset fast accumulated error, and send appropriate control parameter to the fast integrator */ - adapt_type = SUNAdaptController_GetType(ark_mem->hadapt_mem->hcontroller); + adapt_type = SUNAdaptController_GetType(ark_mem->hadapt_mem->hcontroller); need_inner_dsm = SUNFALSE; if ((adapt_type == SUN_ADAPTCONTROLLER_MRI_H) || (adapt_type == SUN_ADAPTCONTROLLER_MRI_TOL)) { - need_inner_dsm = SUNTRUE; + need_inner_dsm = SUNTRUE; step_mem->inner_dsm = ZERO; retval = mriStepInnerStepper_ResetError(step_mem->stepper); if (retval != ARK_SUCCESS) @@ -2650,6 +2789,17 @@ int mriStep_TakeStepMERK(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr) step_mem->nfse++; if (retval) { return ARK_RHSFUNC_FAIL; } ark_mem->fn_is_current = SUNTRUE; + + /* Add external forcing to Fse[0], if applicable */ + if (step_mem->expforcing) + { + step_mem->cvals[0] = ONE; + step_mem->Xvecs[0] = step_mem->Fse[0]; + nvec = 1; + mriStep_ApplyForcing(step_mem, t0, ONE, &nvec); + N_VLinearCombination(nvec, step_mem->cvals, step_mem->Xvecs, + step_mem->Fse[0]); + } } #ifdef SUNDIALS_DEBUG @@ -2780,6 +2930,17 @@ int mriStep_TakeStepMERK(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr) if (retval < 0) { return (ARK_RHSFUNC_FAIL); } if (retval > 0) { return (ARK_UNREC_RHSFUNC_ERR); } + /* Add external forcing to Fse[stage], if applicable */ + if (step_mem->expforcing) + { + step_mem->cvals[0] = ONE; + step_mem->Xvecs[0] = step_mem->Fse[stage]; + nvec = 1; + mriStep_ApplyForcing(step_mem, ark_mem->tcur, ONE, &nvec); + N_VLinearCombination(nvec, step_mem->cvals, step_mem->Xvecs, + step_mem->Fse[stage]); + } + #ifdef SUNDIALS_LOGGING_EXTRA_DEBUG SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, "ARKODE::mriStep_TakeStepMERK", "slow explicit RHS", @@ -3990,7 +4151,7 @@ int mriStep_SlowRHS(ARKodeMem ark_mem, sunrealtype t, N_Vector y, N_Vector f, int mode) { ARKodeMRIStepMem step_mem; - int retval; + int nvec, retval; /* access ARKodeMRIStepMem structure */ retval = mriStep_AccessStepMem(ark_mem, __func__, &step_mem); @@ -4022,6 +4183,26 @@ int mriStep_SlowRHS(ARKodeMem ark_mem, sunrealtype t, N_Vector y, N_Vector f, } } + /* Add external forcing to Fse[0] or Fsi[0], if applicable */ + if (step_mem->expforcing) + { + step_mem->cvals[0] = ONE; + step_mem->Xvecs[0] = step_mem->Fse[0]; + nvec = 1; + mriStep_ApplyForcing(step_mem, t, ONE, &nvec); + N_VLinearCombination(nvec, step_mem->cvals, step_mem->Xvecs, + step_mem->Fse[0]); + } + if (step_mem->impforcing) + { + step_mem->cvals[0] = ONE; + step_mem->Xvecs[0] = step_mem->Fsi[0]; + nvec = 1; + mriStep_ApplyForcing(step_mem, t, ONE, &nvec); + N_VLinearCombination(nvec, step_mem->cvals, step_mem->Xvecs, + step_mem->Fsi[0]); + } + /* combine RHS vectors into output */ if (step_mem->explicit_rhs && step_mem->implicit_rhs) /* ImEx */ { @@ -4693,6 +4874,374 @@ void mriStepInnerStepper_PrintMem(MRIStepInnerStepper stepper, FILE* outfile) return; } +/*--------------------------------------------------------------- + Utility routines for MRIStep to serve as an MRIStepInnerStepper + ---------------------------------------------------------------*/ + +/*------------------------------------------------------------------------------ + MRiStepCreateMRIStepInnerStepper + + Wraps an MRIStep memory structure as an MRIStep inner stepper. + ----------------------------------------------------------------------------*/ + +int MRIStepCreateMRIStepInnerStepper(void* inner_arkode_mem, + MRIStepInnerStepper* stepper) +{ + int retval; + ARKodeMem ark_mem; + ARKodeMRIStepMem step_mem; + + retval = mriStep_AccessARKODEStepMem(inner_arkode_mem, __func__, &ark_mem, + &step_mem); + if (retval) + { + arkProcessError(NULL, ARK_ILL_INPUT, __LINE__, __func__, __FILE__, + "The MRIStep memory pointer is NULL"); + return ARK_ILL_INPUT; + } + + retval = MRIStepInnerStepper_Create(ark_mem->sunctx, stepper); + if (retval != ARK_SUCCESS) { return (retval); } + + retval = MRIStepInnerStepper_SetContent(*stepper, inner_arkode_mem); + if (retval != ARK_SUCCESS) { return (retval); } + + retval = MRIStepInnerStepper_SetEvolveFn(*stepper, mriStep_MRIStepInnerEvolve); + if (retval != ARK_SUCCESS) { return (retval); } + + retval = MRIStepInnerStepper_SetFullRhsFn(*stepper, + mriStep_MRIStepInnerFullRhs); + if (retval != ARK_SUCCESS) { return (retval); } + + retval = MRIStepInnerStepper_SetResetFn(*stepper, mriStep_MRIStepInnerReset); + if (retval != ARK_SUCCESS) { return (retval); } + + retval = + MRIStepInnerStepper_SetAccumulatedErrorGetFn(*stepper, + mriStep_MRIStepInnerGetAccumulatedError); + if (retval != ARK_SUCCESS) { return (retval); } + + retval = + MRIStepInnerStepper_SetAccumulatedErrorResetFn(*stepper, + mriStep_MRIStepInnerResetAccumulatedError); + if (retval != ARK_SUCCESS) { return (retval); } + + retval = MRIStepInnerStepper_SetFixedStepFn(*stepper, + mriStep_MRIStepInnerSetFixedStep); + if (retval != ARK_SUCCESS) { return (retval); } + + retval = MRIStepInnerStepper_SetRTolFn(*stepper, mriStep_MRIStepInnerSetRTol); + if (retval != ARK_SUCCESS) { return (retval); } + + return (ARK_SUCCESS); +} + +/*------------------------------------------------------------------------------ + mriStep_MRIStepInnerEvolve + + Implementation of MRIStepInnerStepperEvolveFn to advance the inner (fast) + ODE IVP. + ----------------------------------------------------------------------------*/ + +int mriStep_MRIStepInnerEvolve(MRIStepInnerStepper stepper, sunrealtype t0, + sunrealtype tout, N_Vector y) +{ + void* arkode_mem; /* arkode memory */ + sunrealtype tret; /* return time */ + sunrealtype tshift, tscale; /* time normalization values */ + N_Vector* forcing; /* forcing vectors */ + int nforcing; /* number of forcing vectors */ + int retval; /* return value */ + + /* extract the ARKODE memory struct */ + retval = MRIStepInnerStepper_GetContent(stepper, &arkode_mem); + if (retval != ARK_SUCCESS) { return (retval); } + + /* get the forcing data */ + retval = MRIStepInnerStepper_GetForcingData(stepper, &tshift, &tscale, + &forcing, &nforcing); + if (retval != ARK_SUCCESS) { return (retval); } + + /* set the inner forcing data */ + retval = mriStep_SetInnerForcing(arkode_mem, tshift, tscale, forcing, nforcing); + if (retval != ARK_SUCCESS) { return (retval); } + + /* set the stop time */ + retval = ARKodeSetStopTime(arkode_mem, tout); + if (retval != ARK_SUCCESS) { return (retval); } + + /* evolve inner ODE */ + retval = ARKodeEvolve(arkode_mem, tout, y, &tret, ARK_NORMAL); + if (retval < 0) { return (retval); } + + /* disable inner forcing */ + retval = mriStep_SetInnerForcing(arkode_mem, ZERO, ONE, NULL, 0); + if (retval != ARK_SUCCESS) { return (retval); } + + return (ARK_SUCCESS); +} + +/*------------------------------------------------------------------------------ + mriStep_MRIStepInnerFullRhs + + Implementation of MRIStepInnerStepperFullRhsFn to compute the full inner + (fast) ODE IVP RHS. + ----------------------------------------------------------------------------*/ + +int mriStep_MRIStepInnerFullRhs(MRIStepInnerStepper stepper, sunrealtype t, + N_Vector y, N_Vector f, int mode) +{ + void* arkode_mem; + int retval; + + /* extract the ARKODE memory struct */ + retval = MRIStepInnerStepper_GetContent(stepper, &arkode_mem); + if (retval != ARK_SUCCESS) { return (retval); } + + return (mriStep_FullRHS(arkode_mem, t, y, f, mode)); +} + +/*------------------------------------------------------------------------------ + mriStep_MRIStepInnerReset + + Implementation of MRIStepInnerStepperResetFn to reset the inner (fast) stepper + state. + ----------------------------------------------------------------------------*/ + +int mriStep_MRIStepInnerReset(MRIStepInnerStepper stepper, sunrealtype tR, + N_Vector yR) +{ + void* arkode_mem; + int retval; + + /* extract the ARKODE memory struct */ + retval = MRIStepInnerStepper_GetContent(stepper, &arkode_mem); + if (retval != ARK_SUCCESS) { return (retval); } + + return (ARKodeReset(arkode_mem, tR, yR)); +} + +/*------------------------------------------------------------------------------ + mriStep_MRIStepInnerGetAccumulatedError + + Implementation of MRIStepInnerGetAccumulatedError to retrieve the accumulated + temporal error estimate from the inner (fast) stepper. + ----------------------------------------------------------------------------*/ + +int mriStep_MRIStepInnerGetAccumulatedError(MRIStepInnerStepper stepper, + sunrealtype* accum_error) +{ + void* arkode_mem; + int retval; + + /* extract the ARKODE memory struct */ + retval = MRIStepInnerStepper_GetContent(stepper, &arkode_mem); + if (retval != ARK_SUCCESS) { return (retval); } + + return (ARKodeGetAccumulatedError(arkode_mem, accum_error)); +} + +/*------------------------------------------------------------------------------ + mriStep_MRIStepInnerResetAccumulatedError + + Implementation of MRIStepInnerResetAccumulatedError to reset the accumulated + temporal error estimator in the inner (fast) stepper. + ----------------------------------------------------------------------------*/ + +int mriStep_MRIStepInnerResetAccumulatedError(MRIStepInnerStepper stepper) +{ + void* arkode_mem; + int retval; + + /* extract the ARKODE memory struct */ + retval = MRIStepInnerStepper_GetContent(stepper, &arkode_mem); + if (retval != ARK_SUCCESS) { return (retval); } + + return (ARKodeResetAccumulatedError(arkode_mem)); +} + +/*------------------------------------------------------------------------------ + mriStep_MRIStepInnerSetFixedStep + + Implementation of MRIStepInnerSetFixedStep to set a fixed step size for + the upcoming evolution using the inner (fast) stepper. + ----------------------------------------------------------------------------*/ + +int mriStep_MRIStepInnerSetFixedStep(MRIStepInnerStepper stepper, sunrealtype h) +{ + void* arkode_mem; + int retval; + + /* extract the ARKODE memory struct */ + retval = MRIStepInnerStepper_GetContent(stepper, &arkode_mem); + if (retval != ARK_SUCCESS) { return (retval); } + + return (ARKodeSetFixedStep(arkode_mem, h)); +} + +/*------------------------------------------------------------------------------ + mriStep_MRIStepInnerSetRTol + + Implementation of MRIStepInnerSetRTol to set a relative tolerance for the + upcoming evolution using the inner (fast) stepper. + ----------------------------------------------------------------------------*/ + +int mriStep_MRIStepInnerSetRTol(MRIStepInnerStepper stepper, sunrealtype rtol) +{ + void* arkode_mem; + ARKodeMem ark_mem; + int retval; + + /* extract the ARKODE memory struct */ + retval = MRIStepInnerStepper_GetContent(stepper, &arkode_mem); + if (retval != ARK_SUCCESS) { return (retval); } + if (arkode_mem == NULL) + { + arkProcessError(NULL, ARK_MEM_NULL, __LINE__, __func__, __FILE__, + MSG_MRISTEP_NO_MEM); + return ARK_MEM_NULL; + } + ark_mem = (ARKodeMem)arkode_mem; + + if (rtol > ZERO) + { + ark_mem->reltol = rtol; + return (ARK_SUCCESS); + } + else { return (ARK_ILL_INPUT); } +} + +/*------------------------------------------------------------------------------ + mriStep_ApplyForcing + + Determines the linear combination coefficients and vectors to apply forcing + at a given value of the independent variable (t). This occurs through + appending coefficients and N_Vector pointers to the underlying cvals and Xvecs + arrays in the step_mem structure. The dereferenced input *nvec should indicate + the next available entry in the cvals/Xvecs arrays. The input 's' is a + scaling factor that should be applied to each of these coefficients. + ----------------------------------------------------------------------------*/ + +void mriStep_ApplyForcing(ARKodeMRIStepMem step_mem, sunrealtype t, + sunrealtype s, int* nvec) +{ + sunrealtype tau, taui; + int i; + + /* always append the constant forcing term */ + step_mem->cvals[*nvec] = s; + step_mem->Xvecs[*nvec] = step_mem->forcing[0]; + (*nvec) += 1; + + /* compute normalized time tau and initialize tau^i */ + tau = (t - step_mem->tshift) / (step_mem->tscale); + taui = tau; + for (i = 1; i < step_mem->nforcing; i++) + { + step_mem->cvals[*nvec] = s * taui; + step_mem->Xvecs[*nvec] = step_mem->forcing[i]; + taui *= tau; + (*nvec) += 1; + } +} + +/*------------------------------------------------------------------------------ + mriStep_SetInnerForcing + + Sets an array of coefficient vectors for a time-dependent external polynomial + forcing term in the ODE RHS i.e., y' = f(t,y) + p(t). This function is + primarily intended for using MRIStep as an inner integrator within another + [outer] instance of MRIStep, where this instance is is used to solve a + modified ODE at a fast time scale. The polynomial is of the form + + p(t) = sum_{i = 0}^{nvecs - 1} forcing[i] * ((t - tshift) / (tscale))^i + + where tshift and tscale are used to normalize the time t (e.g., with MRIGARK + methods). + ----------------------------------------------------------------------------*/ + +int mriStep_SetInnerForcing(void* arkode_mem, sunrealtype tshift, + sunrealtype tscale, N_Vector* forcing, int nvecs) +{ + ARKodeMem ark_mem; + ARKodeMRIStepMem step_mem; + int retval; + + /* access ARKodeMRIStepMem structure */ + retval = mriStep_AccessARKODEStepMem(arkode_mem, __func__, &ark_mem, &step_mem); + if (retval != ARK_SUCCESS) { return (retval); } + + if (nvecs > 0) + { + /* enable forcing */ + if (step_mem->explicit_rhs) + { + step_mem->expforcing = SUNTRUE; + step_mem->impforcing = SUNFALSE; + } + else + { + step_mem->expforcing = SUNFALSE; + step_mem->impforcing = SUNTRUE; + } + step_mem->tshift = tshift; + step_mem->tscale = tscale; + step_mem->forcing = forcing; + step_mem->nforcing = nvecs; + + /* If cvals and Xvecs are not allocated then mriStep_Init has not been + called and the number of stages has not been set yet. These arrays will + be allocated in mriStep_Init and take into account the value of nforcing. + On subsequent calls will check if enough space has allocated in case + nforcing has increased since the original allocation. */ + if (step_mem->cvals != NULL && step_mem->Xvecs != NULL) + { + /* check if there are enough reusable arrays for fused operations */ + if ((step_mem->nfusedopvecs - nvecs) < (2 * step_mem->MRIC->stages + 2)) + { + /* free current work space */ + if (step_mem->cvals != NULL) + { + free(step_mem->cvals); + ark_mem->lrw -= step_mem->nfusedopvecs; + } + if (step_mem->Xvecs != NULL) + { + free(step_mem->Xvecs); + ark_mem->liw -= step_mem->nfusedopvecs; + } + + /* allocate reusable arrays for fused vector operations */ + step_mem->nfusedopvecs = 2 * step_mem->MRIC->stages + 2 + nvecs; + + step_mem->cvals = NULL; + step_mem->cvals = (sunrealtype*)calloc(step_mem->nfusedopvecs, + sizeof(sunrealtype)); + if (step_mem->cvals == NULL) { return (ARK_MEM_FAIL); } + ark_mem->lrw += step_mem->nfusedopvecs; + + step_mem->Xvecs = NULL; + step_mem->Xvecs = (N_Vector*)calloc(step_mem->nfusedopvecs, + sizeof(N_Vector)); + if (step_mem->Xvecs == NULL) { return (ARK_MEM_FAIL); } + ark_mem->liw += step_mem->nfusedopvecs; + } + } + } + else + { + /* disable forcing */ + step_mem->expforcing = SUNFALSE; + step_mem->impforcing = SUNFALSE; + step_mem->tshift = ZERO; + step_mem->tscale = ONE; + step_mem->forcing = NULL; + step_mem->nforcing = 0; + } + + return (ARK_SUCCESS); +} + /*=============================================================== EOF ===============================================================*/ diff --git a/src/arkode/arkode_mristep_impl.h b/src/arkode/arkode_mristep_impl.h index 07592e4745..3dea6a5efc 100644 --- a/src/arkode/arkode_mristep_impl.h +++ b/src/arkode/arkode_mristep_impl.h @@ -149,6 +149,14 @@ typedef struct ARKodeMRIStepMemRec long int nls_fails; /* num nonlinear solver fails */ int nfusedopvecs; /* length of cvals and Xvecs arrays */ + /* Data for using ERKStep with external polynomial forcing */ + sunbooleantype expforcing; /* add forcing to explicit RHS */ + sunbooleantype impforcing; /* add forcing to implicit RHS */ + sunrealtype tshift; /* time normalization shift */ + sunrealtype tscale; /* time normalization scaling */ + N_Vector* forcing; /* array of forcing vectors */ + int nforcing; /* number of forcing vectors */ + /* Reusable arrays for fused vector operations */ sunrealtype* cvals; N_Vector* Xvecs; @@ -285,6 +293,8 @@ int mriStep_FastRHS(ARKodeMem ark_mem, sunrealtype t, N_Vector y, N_Vector f, int mriStep_Hin(ARKodeMem ark_mem, sunrealtype tcur, sunrealtype tout, N_Vector ycur, N_Vector fcur, N_Vector ytmp, N_Vector temp1, N_Vector temp2, ARKTimestepFullRHSFn rhs, sunrealtype* h); +void mriStep_ApplyForcing(ARKodeMRIStepMem step_mem, sunrealtype t, + sunrealtype s, int* nvec); /* private functions passed to nonlinear solver */ int mriStep_NlsResidual(N_Vector yy, N_Vector res, void* arkode_mem); @@ -328,6 +338,21 @@ int mriStep_ComputeInnerForcing(ARKodeMem ark_mem, ARKodeMRIStepMem step_mem, int mriStep_RKCoeffs(MRIStepCoupling MRIC, int is, int* stage_map, sunrealtype* Ae_row, sunrealtype* Ai_row); +/* private functions for serving as an MRIStepInnerStepper */ +int mriStep_SetInnerForcing(void* arkode_mem, sunrealtype tshift, + sunrealtype tscale, N_Vector* f, int nvecs); +int mriStep_MRIStepInnerEvolve(MRIStepInnerStepper stepper, sunrealtype t0, + sunrealtype tout, N_Vector y); +int mriStep_MRIStepInnerFullRhs(MRIStepInnerStepper stepper, sunrealtype t, + N_Vector y, N_Vector f, int mode); +int mriStep_MRIStepInnerReset(MRIStepInnerStepper stepper, sunrealtype tR, + N_Vector yR); +int mriStep_MRIStepInnerGetAccumulatedError(MRIStepInnerStepper stepper, + sunrealtype* accum_error); +int mriStep_MRIStepInnerResetAccumulatedError(MRIStepInnerStepper stepper); +int mriStep_MRIStepInnerSetFixedStep(MRIStepInnerStepper stepper, sunrealtype h); +int mriStep_MRIStepInnerSetRTol(MRIStepInnerStepper stepper, sunrealtype rtol); + /*=============================================================== MRIStep SUNAdaptController wrapper module -- this is used to insert MRIStep in-between ARKODE at the "slow" time scale, and diff --git a/src/arkode/fmod_int32/farkode_mristep_mod.c b/src/arkode/fmod_int32/farkode_mristep_mod.c index 7b094666f2..059645a69f 100644 --- a/src/arkode/fmod_int32/farkode_mristep_mod.c +++ b/src/arkode/fmod_int32/farkode_mristep_mod.c @@ -1045,6 +1045,20 @@ SWIGEXPORT int _wrap_FMRIStepInnerStepper_GetForcingData(void *farg1, double *fa } +SWIGEXPORT int _wrap_FMRIStepCreateMRIStepInnerStepper(void *farg1, void *farg2) { + int fresult ; + void *arg1 = (void *) 0 ; + MRIStepInnerStepper *arg2 = (MRIStepInnerStepper *) 0 ; + int result; + + arg1 = (void *)(farg1); + arg2 = (MRIStepInnerStepper *)(farg2); + result = (int)MRIStepCreateMRIStepInnerStepper(arg1,arg2); + fresult = (int)(result); + return fresult; +} + + SWIGEXPORT int _wrap_FMRIStepResize(void *farg1, N_Vector farg2, double const *farg3, ARKVecResizeFn farg4, void *farg5) { int fresult ; void *arg1 = (void *) 0 ; diff --git a/src/arkode/fmod_int32/farkode_mristep_mod.f90 b/src/arkode/fmod_int32/farkode_mristep_mod.f90 index 4cec198030..c0fcefa521 100644 --- a/src/arkode/fmod_int32/farkode_mristep_mod.f90 +++ b/src/arkode/fmod_int32/farkode_mristep_mod.f90 @@ -170,6 +170,7 @@ module farkode_mristep_mod public :: FMRIStepInnerStepper_SetRTolFn public :: FMRIStepInnerStepper_AddForcing public :: FMRIStepInnerStepper_GetForcingData + public :: FMRIStepCreateMRIStepInnerStepper public :: FMRIStepResize public :: FMRIStepReset public :: FMRIStepSStolerances @@ -749,6 +750,15 @@ function swigc_FMRIStepInnerStepper_GetForcingData(farg1, farg2, farg3, farg4, f integer(C_INT) :: fresult end function +function swigc_FMRIStepCreateMRIStepInnerStepper(farg1, farg2) & +bind(C, name="_wrap_FMRIStepCreateMRIStepInnerStepper") & +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_FMRIStepResize(farg1, farg2, farg3, farg4, farg5) & bind(C, name="_wrap_FMRIStepResize") & result(fresult) @@ -2392,6 +2402,22 @@ function FMRIStepInnerStepper_GetForcingData(stepper, tshift, tscale, forcing, n swig_result = fresult end function +function FMRIStepCreateMRIStepInnerStepper(arkode_mem, stepper) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(C_PTR) :: arkode_mem +type(C_PTR), target, intent(inout) :: stepper +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 + +farg1 = arkode_mem +farg2 = c_loc(stepper) +fresult = swigc_FMRIStepCreateMRIStepInnerStepper(farg1, farg2) +swig_result = fresult +end function + function FMRIStepResize(arkode_mem, ynew, t0, resize, resize_data) & result(swig_result) use, intrinsic :: ISO_C_BINDING diff --git a/src/arkode/fmod_int64/farkode_mristep_mod.c b/src/arkode/fmod_int64/farkode_mristep_mod.c index 8ffaac9e94..03e9bb8af1 100644 --- a/src/arkode/fmod_int64/farkode_mristep_mod.c +++ b/src/arkode/fmod_int64/farkode_mristep_mod.c @@ -1045,6 +1045,20 @@ SWIGEXPORT int _wrap_FMRIStepInnerStepper_GetForcingData(void *farg1, double *fa } +SWIGEXPORT int _wrap_FMRIStepCreateMRIStepInnerStepper(void *farg1, void *farg2) { + int fresult ; + void *arg1 = (void *) 0 ; + MRIStepInnerStepper *arg2 = (MRIStepInnerStepper *) 0 ; + int result; + + arg1 = (void *)(farg1); + arg2 = (MRIStepInnerStepper *)(farg2); + result = (int)MRIStepCreateMRIStepInnerStepper(arg1,arg2); + fresult = (int)(result); + return fresult; +} + + SWIGEXPORT int _wrap_FMRIStepResize(void *farg1, N_Vector farg2, double const *farg3, ARKVecResizeFn farg4, void *farg5) { int fresult ; void *arg1 = (void *) 0 ; diff --git a/src/arkode/fmod_int64/farkode_mristep_mod.f90 b/src/arkode/fmod_int64/farkode_mristep_mod.f90 index 8e2b98b4dc..2c348f0c08 100644 --- a/src/arkode/fmod_int64/farkode_mristep_mod.f90 +++ b/src/arkode/fmod_int64/farkode_mristep_mod.f90 @@ -170,6 +170,7 @@ module farkode_mristep_mod public :: FMRIStepInnerStepper_SetRTolFn public :: FMRIStepInnerStepper_AddForcing public :: FMRIStepInnerStepper_GetForcingData + public :: FMRIStepCreateMRIStepInnerStepper public :: FMRIStepResize public :: FMRIStepReset public :: FMRIStepSStolerances @@ -749,6 +750,15 @@ function swigc_FMRIStepInnerStepper_GetForcingData(farg1, farg2, farg3, farg4, f integer(C_INT) :: fresult end function +function swigc_FMRIStepCreateMRIStepInnerStepper(farg1, farg2) & +bind(C, name="_wrap_FMRIStepCreateMRIStepInnerStepper") & +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_FMRIStepResize(farg1, farg2, farg3, farg4, farg5) & bind(C, name="_wrap_FMRIStepResize") & result(fresult) @@ -2392,6 +2402,22 @@ function FMRIStepInnerStepper_GetForcingData(stepper, tshift, tscale, forcing, n swig_result = fresult end function +function FMRIStepCreateMRIStepInnerStepper(arkode_mem, stepper) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(C_PTR) :: arkode_mem +type(C_PTR), target, intent(inout) :: stepper +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 + +farg1 = arkode_mem +farg2 = c_loc(stepper) +fresult = swigc_FMRIStepCreateMRIStepInnerStepper(farg1, farg2) +swig_result = fresult +end function + function FMRIStepResize(arkode_mem, ynew, t0, resize, resize_data) & result(swig_result) use, intrinsic :: ISO_C_BINDING diff --git a/test/unit_tests/arkode/CXX_serial/ark_test_brusselator_mriadapt.cpp b/test/unit_tests/arkode/CXX_serial/ark_test_brusselator_mriadapt.cpp index b0a11d2269..3d69d47fe4 100644 --- a/test/unit_tests/arkode/CXX_serial/ark_test_brusselator_mriadapt.cpp +++ b/test/unit_tests/arkode/CXX_serial/ark_test_brusselator_mriadapt.cpp @@ -211,10 +211,10 @@ int main(int argc, char* argv[]) if (check_flag(flag, "ReadInputs")) return 1; // General problem parameters - sunrealtype T0 = SUN_RCONST(0.0); // initial time - sunrealtype Tf = SUN_RCONST(10.0); // final time - sunindextype NEQ = 3; // number of dependent vars. - int Nt = 20; // number of output times + sunrealtype T0 = SUN_RCONST(0.0); // initial time + sunrealtype Tf = SUN_RCONST(10.0); // final time + sunindextype NEQ = 3; // number of dependent vars. + int Nt = 20; // number of output times // Initial problem output // While traversing these, set various function pointers, table constants, and method orders. @@ -360,7 +360,7 @@ int main(int argc, char* argv[]) retval = ARKodeSetInitStep(inner_arkode_mem, opts.hf); if (check_flag(retval, "ARKodeSetInitStep")) return 1; } - retval = ARKodeSetAdaptivityAdjustment(inner_arkode_mem, opts.fast_pq-1); + retval = ARKodeSetAdaptivityAdjustment(inner_arkode_mem, opts.fast_pq - 1); if (check_flag(retval, "ARKodeSetAdaptivityAdjustment")) return 1; } else @@ -686,7 +686,7 @@ int main(int argc, char* argv[]) if (opts.slow_safety > -1) { retval = ARKodeSetSafetyFactor(arkode_mem, opts.slow_safety); - if (check_flag(retval, "ARKodeSetSafetyFactor")) return 1; + if (check_flag(retval, "ARKodeSetSafetyFactor")) return 1; } } else @@ -702,10 +702,10 @@ int main(int argc, char* argv[]) // Main time-stepping loop: calls ARKodeEvolve to perform the // integration, then prints results. Stops when the final time // has been reached - sunrealtype t = T0; - sunrealtype t2 = T0; - sunrealtype dTout = (Tf-T0)/Nt; - sunrealtype tout = T0+dTout; + sunrealtype t = T0; + sunrealtype t2 = T0; + sunrealtype dTout = (Tf - T0) / Nt; + sunrealtype tout = T0 + dTout; sunrealtype u, v, w, uerr, verr, werr, uerrtot, verrtot, werrtot, errtot; sunrealtype accuracy; uerr = verr = werr = uerrtot = verrtot = werrtot = errtot = accuracy = ZERO; @@ -720,7 +720,6 @@ int main(int argc, char* argv[]) int Nout = 0; while (Tf - t > 1.0e-8) { - // reset reference solver so that it begins with identical state retval = ARKodeReset(arkode_ref, t, y); @@ -745,9 +744,9 @@ int main(int argc, char* argv[]) } // access/print solution and error - u = NV_Ith_S(y,0); - v = NV_Ith_S(y,1); - w = NV_Ith_S(y,2); + u = NV_Ith_S(y, 0); + v = NV_Ith_S(y, 1); + w = NV_Ith_S(y, 2); uerr = SUNRabs(NV_Ith_S(yref, 0) - u); verr = SUNRabs(NV_Ith_S(yref, 1) - v); werr = SUNRabs(NV_Ith_S(yref, 2) - w); diff --git a/test/unit_tests/arkode/CXX_serial/ark_test_dahlquist_mri.cpp b/test/unit_tests/arkode/CXX_serial/ark_test_dahlquist_mri.cpp index 19a2c2bbf4..c574e8f989 100644 --- a/test/unit_tests/arkode/CXX_serial/ark_test_dahlquist_mri.cpp +++ b/test/unit_tests/arkode/CXX_serial/ark_test_dahlquist_mri.cpp @@ -450,10 +450,7 @@ int run_tests(ARKODE_MRIType type, ProblemOptions& prob_opts, } sunrealtype pow = prob_data.lambda_f; - if (type != MRISTEP_IMPLICIT) - { - pow += prob_data.lambda_e; - } + if (type != MRISTEP_IMPLICIT) { pow += prob_data.lambda_e; } if (type == MRISTEP_IMPLICIT || type == MRISTEP_IMEX || type == MRISTEP_MRISR) { pow += prob_data.lambda_i; @@ -490,10 +487,7 @@ int run_tests(ARKODE_MRIType type, ProblemOptions& prob_opts, int nstages_evaluated = nstages_stored; if (stiffly_accurate) nstages_evaluated--; long int fe_evals = 0; - if (type != MRISTEP_IMPLICIT) - { - fe_evals = mri_nst * nstages_evaluated; - } + if (type != MRISTEP_IMPLICIT) { fe_evals = mri_nst * nstages_evaluated; } if (mri_nfse != fe_evals) { diff --git a/test/unit_tests/arkode/CXX_serial/ark_test_kpr_mriadapt.cpp b/test/unit_tests/arkode/CXX_serial/ark_test_kpr_mriadapt.cpp index 3a4ba7c374..c90ceabee5 100644 --- a/test/unit_tests/arkode/CXX_serial/ark_test_kpr_mriadapt.cpp +++ b/test/unit_tests/arkode/CXX_serial/ark_test_kpr_mriadapt.cpp @@ -216,10 +216,10 @@ int main(int argc, char* argv[]) if (check_flag(flag, "ReadInputs")) return 1; // General problem parameters - sunrealtype T0 = SUN_RCONST(0.0); // initial time - sunrealtype Tf = SUN_RCONST(5.0); // final time - sunindextype NEQ = 2; // number of dependent vars. - int Nt = 20; // number of output times + sunrealtype T0 = SUN_RCONST(0.0); // initial time + sunrealtype Tf = SUN_RCONST(5.0); // final time + sunindextype NEQ = 2; // number of dependent vars. + int Nt = 20; // number of output times // Initial problem output // While traversing these, set various function pointers, table constants, and method orders. @@ -696,7 +696,7 @@ int main(int argc, char* argv[]) if (opts.slow_safety > -1) { retval = ARKodeSetSafetyFactor(arkode_mem, opts.slow_safety); - if (check_flag(retval, "ARKodeSetSafetyFactor")) return 1; + if (check_flag(retval, "ARKodeSetSafetyFactor")) return 1; } } else @@ -712,10 +712,10 @@ int main(int argc, char* argv[]) // Main time-stepping loop: calls ARKodeEvolve to perform the // integration, then prints results. Stops when the final time // has been reached - sunrealtype t = T0; - sunrealtype t2 = T0; - sunrealtype dTout = (Tf-T0)/Nt; - sunrealtype tout = T0+dTout; + sunrealtype t = T0; + sunrealtype t2 = T0; + sunrealtype dTout = (Tf - T0) / Nt; + sunrealtype tout = T0 + dTout; sunrealtype u, v, uerr, verr, uerrtot, verrtot, errtot, accuracy; uerr = verr = uerrtot = verrtot = errtot = accuracy = ZERO; printf(" t u v uerr verr\n"); @@ -726,7 +726,6 @@ int main(int argc, char* argv[]) int Nout = 0; while (Tf - t > 1.0e-8) { - // reset reference solver so that it begins with identical state retval = ARKodeReset(arkode_ref, t, y); @@ -751,8 +750,8 @@ int main(int argc, char* argv[]) } // access/print solution and error - u = NV_Ith_S(y,0); - v = NV_Ith_S(y,1); + u = NV_Ith_S(y, 0); + v = NV_Ith_S(y, 1); uerr = SUNRabs(NV_Ith_S(yref, 0) - u); verr = SUNRabs(NV_Ith_S(yref, 1) - v); uerrtot += uerr * uerr; @@ -770,7 +769,8 @@ int main(int argc, char* argv[]) tout += dTout; tout = (tout > Tf) ? Tf : tout; printf(" %10.6" FSYM " %10.6" FSYM " %10.6" FSYM " %.2" ESYM - " %.2" ESYM "\n", t, u, v, uerr, verr); + " %.2" ESYM "\n", + t, u, v, uerr, verr); } } uerrtot = SUNRsqrt(uerrtot / Nt); From 20593d6caf55af1ea0e84e214a3dd07645f87e4e Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Fri, 30 Aug 2024 10:07:30 -0500 Subject: [PATCH 021/286] Minor cleanup --- src/arkode/arkode_mristep.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/arkode/arkode_mristep.c b/src/arkode/arkode_mristep.c index 1be5da17f3..913640d8d7 100644 --- a/src/arkode/arkode_mristep.c +++ b/src/arkode/arkode_mristep.c @@ -140,7 +140,6 @@ void* MRIStepCreate(ARKRhsFn fse, ARKRhsFn fsi, sunrealtype t0, N_Vector y0, ark_mem->step_getnonlinsolvstats = mriStep_GetNonlinSolvStats; ark_mem->step_supports_adaptive = SUNTRUE; ark_mem->step_supports_implicit = SUNTRUE; - ark_mem->step_supports_relaxation = SUNTRUE; ark_mem->step_mem = (void*)step_mem; /* Set default values for optional inputs */ @@ -5189,6 +5188,10 @@ int mriStep_SetInnerForcing(void* arkode_mem, sunrealtype tshift, step_mem->forcing = forcing; step_mem->nforcing = nvecs; + /* Signal that any pre-existing RHS vector is no longer current, since it + has a stale forcing function */ + ark_mem->fn_is_current = SUNFALSE; + /* If cvals and Xvecs are not allocated then mriStep_Init has not been called and the number of stages has not been set yet. These arrays will be allocated in mriStep_Init and take into account the value of nforcing. From 11f03d507e24adb41419d45fa1c3e90541530239 Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Fri, 30 Aug 2024 10:08:32 -0500 Subject: [PATCH 022/286] Added nested MRI test --- .../arkode/CXX_serial/CMakeLists.txt | 1 + .../CXX_serial/ark_test_kpr_nestedmri.cpp | 1925 +++++++++++++++++ .../CXX_serial/ark_test_kpr_nestedmri.out | 51 + 3 files changed, 1977 insertions(+) create mode 100644 test/unit_tests/arkode/CXX_serial/ark_test_kpr_nestedmri.cpp create mode 100644 test/unit_tests/arkode/CXX_serial/ark_test_kpr_nestedmri.out diff --git a/test/unit_tests/arkode/CXX_serial/CMakeLists.txt b/test/unit_tests/arkode/CXX_serial/CMakeLists.txt index 56e8ec0ea1..e814329796 100644 --- a/test/unit_tests/arkode/CXX_serial/CMakeLists.txt +++ b/test/unit_tests/arkode/CXX_serial/CMakeLists.txt @@ -49,6 +49,7 @@ set(unit_tests "ark_test_getjac.cpp\;" "ark_test_getjac_mri.cpp\;" "ark_test_kpr_mriadapt.cpp\;--hs 0.002 --rtol 0.000004 --scontrol 0" + "ark_test_kpr_nestedmri.cpp\;" "ark_test_brusselator_mriadapt.cpp\;--rtol 0.000004 --scontrol 0" "ark_test_slowerror_brusselator.cpp\;" "ark_test_slowerror_kpr.cpp\;" diff --git a/test/unit_tests/arkode/CXX_serial/ark_test_kpr_nestedmri.cpp b/test/unit_tests/arkode/CXX_serial/ark_test_kpr_nestedmri.cpp new file mode 100644 index 0000000000..87bd7a8594 --- /dev/null +++ b/test/unit_tests/arkode/CXX_serial/ark_test_kpr_nestedmri.cpp @@ -0,0 +1,1925 @@ +/* ---------------------------------------------------------------- + * Programmer(s): Daniel R. Reynolds @ SMU + * ---------------------------------------------------------------- + * SUNDIALS Copyright Start + * Copyright (c) 2002-2024, 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 + * ---------------------------------------------------------------- + * Nested multirate nonlinear Kvaerno-Prothero-Robinson ODE test + * problem: + * + * [u]' = [ G e e ] [(u^2-p-2)/(2u)] + [ p'(t)/(2u) ] + * [v] [ e al be ] [(v^2-q-2)/(2v)] [ q'(t)/(2v) ] + * [w] [ e -be al ] [(w^2-r-2)/(2w)] [ r'(t)/(2w) ] + * + * where p(t) = 0.5*cos(t), q(t) = cos(om*t*(1+exp(-(t-2)^2))), + * and r(t) = cos(om*om*t*(1+exp(-(t-3)^2))). + * + * When the slow time scale is implicit or explicit, the entire first row + * is placed appropriately; however, when it is ImEx we set + * + * fsi = [ G e e ] [(u^2-p-2)/(2u)] + * [ 0 0 0 ] [(v^2-q-2)/(2v)] + * [ 0 0 0 ] [(w^2-r-2)/(2w)] + * + * fse = [ p'(t)/(2u) ] + * [ 0 ] + * [ 0 ] + * + * When the intermediate time scale is implicit or explicit, the entire + * second row is placed appropriately; however, when it is ImEx we set + * + * fmi = [ 0 0 0 ] [(u^2-p-2)/(2u)] + * [ e al be ] [(v^2-q-2)/(2v)] + * [ 0 0 0 ] [(w^2-r-2)/(2w)] + * + * fme = [ 0 ] + * [ q'(t)/(2v) ] + * [ 0 ] + * + * The fast RHS is always just the full third row of the IVP. + * + * This problem has analytical solution given by + * u(t) = sqrt(2+p(t)), v(t) = sqrt(2+q(t)), w(t) = sqrt(2+r(t)). + * However, we use a reference solver here to assess performance + * of the local multirate adaptivity controller. + * + * This program allows a number of parameters: + * G: stiffness at slow time scale [default = -10] + * e: fast/slow coupling strength [default = 0.5] + * al,be: oscillatory coupling between v and w [default al = -1, be = 1] + * om: time-scale separation factor [default = 50] + * + * The stiffness of the slow time scale is essentially determined + * by G, for |G| > 50 it is 'stiff' and ideally suited to a + * multirate method that is implicit at the slow time scale. + * + * Coupling between the slow and faster components is determined by e, with + * coupling strength proportional to |e|. Coupling between the intermediate + * and fast components is determined by (al,be). + * + * The "intermediate" variable, v, oscillates at a frequency "om" times + * faster than u, and the "fast" variable, w, oscillates at a frequency + * "om" times faster than v. + * + * Additional input options may be used to select between various + * solver options: + * - slow fixed/initial step size: hs [default = 0.01] + * - intermediate fixed/initial step size: hm [default = 0.001] + * - fast fixed/initial step size: hf [default = 0.0001] + * - set initial adaptive step size as hs/hm/hf above: set_h0 [default 0] + * - relative solution tolerance: rtol [default = 1e-4] + * - absolute solution tolerance: atol [default = 1e-11] + * - relative solution tolerance for each fast integrator (as compared + * to next-slower integrator): fast_rtol [default = 1e-4] + * - use p (0) vs q (1) for slow and intermediate adaptivity: slow_pq [default = 0] + * - use p (0) vs q (1) for fast adaptivity: fast_pq [default = 0] + * - slow stepsize safety factor: safety [default = 0.96] + * - "slow" MRI method: mri_method [default = ARKODE_MRI_GARK_ERK45a] + * - "intermediate" MRI method: mid_method [default = ARKODE_MRI_GARK_ERK45a] + * - "fast" ERKStep method order: fast_order [default 4] + * - "slow" and "intermediate" MRI temporal adaptivity controllers: scontrol [default = 1] + * 0: no controller [fixed time steps] + * 1: I controller (as part of MRI-HTOL) + * 2: PI controller (as part of MRI-HTOL) + * 3: PID controller (as part of MRI-HTOL) + * 4: ExpGus controller (as part of MRI-HTOL) + * 5: ImpGus controller (as part of MRI-HTOL) + * 6: ImExGus controller (as part of MRI-HTOL) + * 7: I controller (alone) + * 8: PI controller (alone) + * 9: PID controller (alone) + * 10: ExpGus controller (alone) + * 11: ImpGus controller (alone) + * 12: ImExGus controller (alone) + * - "fast" ERKStep temporal adaptivity controller: fcontrol [default = 1] + * 0: no controller [fixed time steps] + * 1: I controller + * 2: PI controller + * 3: PID controller + * 4: ExpGus controller + * 5: ImpGus controller + * 6: ImExGus controller + * - "intermediate" and "fast" accumulated error type: faccum [default = 0] + * -1: no accumulation + * 0: maximum accumulation + * 1: additive accumulation + * - controller parameters: (k1s, k2s, k3s, k1f, k2f, k3f, + * bias, htol_relch, htol_minfac, htol_maxfac) + * slow and intermediate single-rate controllers: use k1s through k3s, + * as appropriate. fast single-rate controllers: use k1f through k3f, + * as appropriate. MRIHTol controllers: use htol_relch, htol_minfac, + * htol_maxfac. all controllers use bias. + * ** if any one of a relevant set are "-1" then the defaults are used + * + * Outputs and solution error values are printed at equal intervals + * of 0.5 and run statistics are printed at the end. + * ----------------------------------------------------------------*/ + +// Header files +#include // prototypes for ERKStep fcts., consts +#include // prototypes for MRIStep fcts., consts +#include +#include +#include +#include +#include +#include // serial N_Vector type, fcts., macros +#include +#include +#include +#include +#include // dense linear solver +#include // dense matrix type, fcts., macros +#include // common utility functions + +#if defined(SUNDIALS_EXTENDED_PRECISION) +#define ESYM "Le" +#define FSYM "Lf" +#else +#define ESYM "e" +#define FSYM "f" +#endif + +#define ZERO SUN_RCONST(0.0) +#define HALF SUN_RCONST(0.5) +#define ONE SUN_RCONST(1.0) +#define TWO SUN_RCONST(2.0) +#define THREE SUN_RCONST(3.0) + +// Problem options +struct Options +{ + // Problem parameters + sunrealtype e = SUN_RCONST(0.5); + sunrealtype G = SUN_RCONST(-10.0); + sunrealtype om = SUN_RCONST(50.0); + sunrealtype al = SUN_RCONST(-1.0); + sunrealtype be = SUN_RCONST(1.0); + + // Step sizes and tolerances + int set_h0 = 0; + sunrealtype hs = SUN_RCONST(1.0e-2); + sunrealtype hm = SUN_RCONST(1.0e-3); + sunrealtype hf = SUN_RCONST(1.0e-4); + sunrealtype rtol = SUN_RCONST(1.0e-4); + sunrealtype atol = SUN_RCONST(1.0e-11); + sunrealtype fast_rtol = SUN_RCONST(1.0e-4); + + // Method selection + std::string mri_method = "ARKODE_MRI_GARK_ERK45a"; + std::string mid_method = "ARKODE_MRI_GARK_ERK45a"; + int fast_order = 4; + int scontrol = 1; + int fcontrol = 1; + int faccum = 0; + int slow_pq = 0; + int fast_pq = 0; + + // controller parameters + sunrealtype k1s = SUN_RCONST(-1.0); + sunrealtype k2s = SUN_RCONST(-1.0); + sunrealtype k3s = SUN_RCONST(-1.0); + sunrealtype k1f = SUN_RCONST(-1.0); + sunrealtype k2f = SUN_RCONST(-1.0); + sunrealtype k3f = SUN_RCONST(-1.0); + sunrealtype bias = SUN_RCONST(-1.0); + sunrealtype htol_relch = SUN_RCONST(-1.0); + sunrealtype htol_minfac = SUN_RCONST(-1.0); + sunrealtype htol_maxfac = SUN_RCONST(-1.0); + sunrealtype slow_safety = SUN_RCONST(-1.0); +}; + +// User-supplied functions called by the solver +static int fse(sunrealtype t, N_Vector y, N_Vector ydot, void* user_data); +static int fsi(sunrealtype t, N_Vector y, N_Vector ydot, void* user_data); +static int fs( sunrealtype t, N_Vector y, N_Vector ydot, void* user_data); +static int fmi(sunrealtype t, N_Vector y, N_Vector ydot, void* user_data); +static int fme(sunrealtype t, N_Vector y, N_Vector ydot, void* user_data); +static int fm( sunrealtype t, N_Vector y, N_Vector ydot, void* user_data); +static int ff( sunrealtype t, N_Vector y, N_Vector ydot, void* user_data); +static int fn( sunrealtype t, N_Vector y, N_Vector ydot, void* user_data); +static int f0( sunrealtype t, N_Vector y, N_Vector ydot, void* user_data); +static int Js( sunrealtype t, N_Vector y, N_Vector fy, SUNMatrix J, + void* user_data, N_Vector tmp1, N_Vector tmp2, N_Vector tmp3); +static int Jsi(sunrealtype t, N_Vector y, N_Vector fy, SUNMatrix J, + void* user_data, N_Vector tmp1, N_Vector tmp2, N_Vector tmp3); +static int Jm( sunrealtype t, N_Vector y, N_Vector fy, SUNMatrix J, + void* user_data, N_Vector tmp1, N_Vector tmp2, N_Vector tmp3); +static int Jmi(sunrealtype t, N_Vector y, N_Vector fy, SUNMatrix J, + void* user_data, N_Vector tmp1, N_Vector tmp2, N_Vector tmp3); +static int Jn( sunrealtype t, N_Vector y, N_Vector fy, SUNMatrix J, + void* user_data, N_Vector tmp1, N_Vector tmp2, N_Vector tmp3); + +// Utility functions +static void InputHelp(); +static int ReadInputs(std::vector& args, Options& opts, + SUNContext ctx); +static void PrintSlowAdaptivity(Options opts); +static void PrintFastAdaptivity(Options opts); +static sunrealtype p(sunrealtype t, Options* opts); +static sunrealtype q(sunrealtype t, Options* opts); +static sunrealtype r(sunrealtype t, Options* opts); +static sunrealtype pdot(sunrealtype t, Options* opts); +static sunrealtype qdot(sunrealtype t, Options* opts); +static sunrealtype rdot(sunrealtype t, Options* opts); +static sunrealtype utrue(sunrealtype t, Options* opts); +static sunrealtype vtrue(sunrealtype t, Options* opts); +static sunrealtype wtrue(sunrealtype t, Options* opts); +static int Ytrue(sunrealtype t, N_Vector y, Options* opts); + +// Main Program +int main(int argc, char* argv[]) +{ + // SUNDIALS context object for this simulation + sundials::Context sunctx; + + // Read input options + Options opts; + std::vector args(argv + 1, argv + argc); + int flag = ReadInputs(args, opts, sunctx); + if (check_flag(flag, "ReadInputs")) return 1; + + // General problem parameters + sunrealtype T0 = SUN_RCONST(0.0); // initial time + sunrealtype Tf = SUN_RCONST(5.0); // final time + sunindextype NEQ = 3; // number of dependent vars. + int Nt = 20; // number of output times + + // Initial problem output + // While traversing these, set various function pointers, table constants, and method orders. + ARKRhsFn f_f, f_me, f_mi, f_se, f_si; + ARKLsJacFn J_s, J_m; + int retval; + sunbooleantype slowimplicit, slowimex, midimplicit, midimex; + slowimplicit = slowimex = midimplicit = midimex = SUNFALSE; + f_mi = NULL; + f_me = fm; + f_si = NULL; + f_se = fs; + J_m = NULL; + J_s = NULL; + f_f = ff; + if ((opts.mri_method == "ARKODE_MRI_GARK_IRK21a") || + (opts.mri_method == "ARKODE_MRI_GARK_ESDIRK34a") || + (opts.mri_method == "ARKODE_MRI_GARK_ESDIRK46a")) + { + slowimplicit = SUNTRUE; + f_se = NULL; + f_si = fs; + J_s = Js; + } + if ((opts.mri_method == "ARKODE_IMEX_MRI_SR21") || + (opts.mri_method == "ARKODE_IMEX_MRI_SR32") || + (opts.mri_method == "ARKODE_IMEX_MRI_SR43")) + { + slowimex = SUNTRUE; + slowimplicit = SUNTRUE; + f_se = fse; + f_si = fsi; + J_s = Jsi; + } + if ((opts.mid_method == "ARKODE_MRI_GARK_IRK21a") || + (opts.mid_method == "ARKODE_MRI_GARK_ESDIRK34a") || + (opts.mid_method == "ARKODE_MRI_GARK_ESDIRK46a")) + { + midimplicit = SUNTRUE; + f_me = NULL; + f_mi = fm; + J_m = Jm; + } + if ((opts.mid_method == "ARKODE_IMEX_MRI_SR21") || + (opts.mid_method == "ARKODE_IMEX_MRI_SR32") || + (opts.mid_method == "ARKODE_IMEX_MRI_SR43")) + { + midimex = SUNTRUE; + midimplicit = SUNTRUE; + f_me = fme; + f_mi = fmi; + J_m = Jmi; + } + std::cout << "\nAdaptive nested multirate nonlinear Kvaerno-Prothero-Robinson test " + "problem:\n"; + std::cout << " time domain: (" << T0 << "," << Tf << "]\n"; + std::cout << " G = " << opts.G << std::endl; + std::cout << " e = " << opts.e << std::endl; + std::cout << " al = " << opts.al << std::endl; + std::cout << " be = " << opts.be << std::endl; + std::cout << " om = " << opts.om << std::endl; + std::cout << "\n Slow integrator: " << opts.mri_method; + if (slowimex) { std::cout << " (ImEx)" << std::endl; } + else if (slowimplicit) { std::cout << " (implicit)" << std::endl; } + else { std::cout << " (explicit)" << std::endl; } + std::cout << "\n Intermediate integrator: " << opts.mid_method; + if (midimex) { std::cout << " (ImEx)" << std::endl; } + else if (midimplicit) { std::cout << " (implicit)" << std::endl; } + else { std::cout << " (explicit)" << std::endl; } + PrintSlowAdaptivity(opts); + std::cout << "\n Fast order " << opts.fast_order << std::endl; + PrintFastAdaptivity(opts); + + // Create and initialize serial vectors for the solution and reference + N_Vector y = N_VNew_Serial(NEQ, sunctx); + if (check_ptr((void*)y, "N_VNew_Serial")) return 1; + N_Vector yref = N_VClone(y); + if (check_ptr((void*)yref, "N_VClone")) return 1; + + // Set initial conditions + retval = Ytrue(T0, y, &opts); + if (check_flag(retval, "Ytrue")) return 1; + N_VScale(ONE, y, yref); + + // Create and configure reference solver object + void* arkode_ref = ERKStepCreate(fn, T0, yref, sunctx); + if (check_ptr((void*)arkode_ref, "ERKStepCreate")) return 1; + retval = ARKodeSetUserData(arkode_ref, (void*)&opts); + if (check_flag(retval, "ARKodeSetUserData")) return 1; + retval = ARKodeSetOrder(arkode_ref, 5); + if (check_flag(retval, "ARKodeSetOrder")) return 1; + retval = ARKodeSStolerances(arkode_ref, SUN_RCONST(1.e-10), SUN_RCONST(1.e-12)); + if (check_flag(retval, "ARKodeSStolerances")) return 1; + retval = ARKodeSetMaxNumSteps(arkode_ref, 10000000); + if (check_flag(retval, "ARKodeSetMaxNumSteps")) return (1); + + // Create and configure fast controller object + SUNAdaptController fcontrol = NULL; + switch (opts.fcontrol) + { + case (1): + fcontrol = SUNAdaptController_I(sunctx); + if (check_ptr((void*)fcontrol, "SUNAdaptController_I")) return 1; + if (opts.k1f > -1) + { + retval = SUNAdaptController_SetParams_I(fcontrol, opts.k1f); + if (check_flag(retval, "SUNAdaptController_SetParams_I")) return 1; + } + break; + case (2): + fcontrol = SUNAdaptController_PI(sunctx); + if (check_ptr((void*)fcontrol, "SUNAdaptController_PI")) return 1; + if (std::min(opts.k1f, opts.k2f) > -1) + { + retval = SUNAdaptController_SetParams_PI(fcontrol, opts.k1f, opts.k2f); + if (check_flag(retval, "SUNAdaptController_SetParams_PI")) return 1; + } + break; + case (3): + fcontrol = SUNAdaptController_PID(sunctx); + if (check_ptr((void*)fcontrol, "SUNAdaptController_PID")) return 1; + if (std::min(opts.k1f, std::min(opts.k2f, opts.k3f)) > -1) + { + retval = SUNAdaptController_SetParams_PID(fcontrol, opts.k1f, opts.k2f, + opts.k3f); + if (check_flag(retval, "SUNAdaptController_SetParams_PID")) return 1; + } + break; + case (4): + fcontrol = SUNAdaptController_ExpGus(sunctx); + if (check_ptr((void*)fcontrol, "SUNAdaptController_ExpGus")) return 1; + if (std::min(opts.k1f, opts.k2f) > -1) + { + retval = SUNAdaptController_SetParams_ExpGus(fcontrol, opts.k1f, opts.k2f); + if (check_flag(retval, "SUNAdaptController_SetParams_ExpGus")) return 1; + } + break; + case (5): + fcontrol = SUNAdaptController_ImpGus(sunctx); + if (check_ptr((void*)fcontrol, "SUNAdaptController_ImpGus")) return 1; + if (std::min(opts.k1f, opts.k2f) > -1) + { + retval = SUNAdaptController_SetParams_ImpGus(fcontrol, opts.k1f, opts.k2f); + if (check_flag(retval, "SUNAdaptController_SetParams_ImpGus")) return 1; + } + break; + case (6): + fcontrol = SUNAdaptController_ImExGus(sunctx); + if (check_ptr((void*)fcontrol, "SUNAdaptController_ImExGus")) return 1; + break; + } + if ((opts.bias > -1) && (opts.fcontrol > 0)) + { + retval = SUNAdaptController_SetErrorBias(fcontrol, opts.bias); + if (check_flag(retval, "SUNAdaptController_SetErrorBias")) return 1; + } + + // Create ERKStep (fast) integrator + void* inner_arkode_mem = NULL; // ARKode memory structure + inner_arkode_mem = ERKStepCreate(f_f, T0, y, sunctx); + if (check_ptr((void*)inner_arkode_mem, "ERKStepCreate")) return 1; + retval = ARKodeSetOrder(inner_arkode_mem, opts.fast_order); + if (check_flag(retval, "ARKodeSetOrder")) return 1; + retval = ARKodeSStolerances(inner_arkode_mem, opts.fast_rtol, opts.atol); + if (check_flag(retval, "ARKodeSStolerances")) return 1; + if (opts.fcontrol != 0) + { + retval = ARKodeSetAdaptController(inner_arkode_mem, fcontrol); + if (check_flag(retval, "ARKodeSetAdaptController")) return 1; + if (opts.set_h0 != 0) + { + retval = ARKodeSetInitStep(inner_arkode_mem, opts.hf); + if (check_flag(retval, "ARKodeSetInitStep")) return 1; + } + if (opts.fast_pq == 1) + { + retval = ARKodeSetAdaptivityAdjustment(inner_arkode_mem, 0); + if (check_flag(retval, "ARKodeSetAdaptivityAdjustment")) return 1; + } + } + else + { + retval = ARKodeSetFixedStep(inner_arkode_mem, opts.hf); + if (check_flag(retval, "ARKodeSetFixedStep")) return 1; + } + retval = ARKodeSetAccumulatedErrorType(inner_arkode_mem, opts.faccum); + if (check_flag(retval, "ARKodeSetAccumulatedErrorType")) return 1; + retval = ARKodeSetMaxNumSteps(inner_arkode_mem, 1000000); + if (check_flag(retval, "ARKodeSetMaxNumSteps")) return 1; + retval = ARKodeSetUserData(inner_arkode_mem, (void*)&opts); + if (check_flag(retval, "ARKodeSetUserData")) return 1; + + // Create inner stepper + MRIStepInnerStepper inner_stepper = NULL; + retval = ERKStepCreateMRIStepInnerStepper(inner_arkode_mem, &inner_stepper); + if (check_flag(retval, "ERKStepCreateMRIStepInnerStepper")) return 1; + + // Create intermediate and slow controller objects, and select orders of accuracy as relevant + SUNAdaptController scontrol = NULL; + SUNAdaptController scontrol_H = NULL; + SUNAdaptController scontrol_Tol = NULL; + SUNAdaptController mcontrol = NULL; + SUNAdaptController mcontrol_H = NULL; + SUNAdaptController mcontrol_Tol = NULL; + switch (opts.scontrol) + { + case (1): + scontrol_H = SUNAdaptController_I(sunctx); + if (check_ptr((void*)scontrol_H, "SUNAdaptController_I (slow H)")) return 1; + scontrol_Tol = SUNAdaptController_I(sunctx); + if (check_ptr((void*)scontrol_Tol, "SUNAdaptController_I (slow Tol)")) + return 1; + mcontrol_H = SUNAdaptController_I(sunctx); + if (check_ptr((void*)mcontrol_H, "SUNAdaptController_I (mid H)")) return 1; + mcontrol_Tol = SUNAdaptController_I(sunctx); + if (check_ptr((void*)mcontrol_Tol, "SUNAdaptController_I (mid Tol)")) + return 1; + if (opts.k1s > -1) + { + retval = SUNAdaptController_SetParams_I(scontrol_H, opts.k1s); + if (check_flag(retval, "SUNAdaptController_SetParams_I")) return 1; + retval = SUNAdaptController_SetParams_I(scontrol_Tol, opts.k1s); + if (check_flag(retval, "SUNAdaptController_SetParams_I")) return 1; + retval = SUNAdaptController_SetParams_I(mcontrol_H, opts.k1s); + if (check_flag(retval, "SUNAdaptController_SetParams_I")) return 1; + retval = SUNAdaptController_SetParams_I(mcontrol_Tol, opts.k1s); + if (check_flag(retval, "SUNAdaptController_SetParams_I")) return 1; + } + scontrol = SUNAdaptController_MRIHTol(sunctx, scontrol_H, scontrol_Tol); + if (check_ptr((void*)scontrol, "SUNAdaptController_MRIHTol")) return 1; + mcontrol = SUNAdaptController_MRIHTol(sunctx, mcontrol_H, mcontrol_Tol); + if (check_ptr((void*)mcontrol, "SUNAdaptController_MRIHTol")) return 1; + if (std::min(opts.htol_relch, std::min(opts.htol_minfac, opts.htol_maxfac)) > -1) + { + retval = SUNAdaptController_SetParams_MRIHTol(scontrol, opts.htol_relch, + opts.htol_minfac, + opts.htol_maxfac); + if (check_flag(retval, "SUNAdaptController_SetParams_MRIHTol")) return 1; + retval = SUNAdaptController_SetParams_MRIHTol(mcontrol, opts.htol_relch, + opts.htol_minfac, + opts.htol_maxfac); + if (check_flag(retval, "SUNAdaptController_SetParams_MRIHTol")) return 1; + } + break; + case (2): + scontrol_H = SUNAdaptController_PI(sunctx); + if (check_ptr((void*)scontrol_H, "SUNAdaptController_PI (slow H)")) + return 1; + scontrol_Tol = SUNAdaptController_PI(sunctx); + if (check_ptr((void*)scontrol_Tol, "SUNAdaptController_PI (slow Tol)")) + return 1; + mcontrol_H = SUNAdaptController_PI(sunctx); + if (check_ptr((void*)mcontrol_H, "SUNAdaptController_PI (mid H)")) + return 1; + mcontrol_Tol = SUNAdaptController_PI(sunctx); + if (check_ptr((void*)mcontrol_Tol, "SUNAdaptController_PI (mid Tol)")) + return 1; + if (std::min(opts.k1s, opts.k2s) > -1) + { + retval = SUNAdaptController_SetParams_PI(scontrol_H, opts.k1s, opts.k2s); + if (check_flag(retval, "SUNAdaptController_SetParams_PI")) return 1; + retval = SUNAdaptController_SetParams_PI(scontrol_Tol, opts.k1s, opts.k2s); + if (check_flag(retval, "SUNAdaptController_SetParams_PI")) return 1; + retval = SUNAdaptController_SetParams_PI(mcontrol_H, opts.k1s, opts.k2s); + if (check_flag(retval, "SUNAdaptController_SetParams_PI")) return 1; + retval = SUNAdaptController_SetParams_PI(mcontrol_Tol, opts.k1s, opts.k2s); + if (check_flag(retval, "SUNAdaptController_SetParams_PI")) return 1; + } + scontrol = SUNAdaptController_MRIHTol(sunctx, scontrol_H, scontrol_Tol); + if (check_ptr((void*)scontrol, "SUNAdaptController_MRIHTol")) return 1; + mcontrol = SUNAdaptController_MRIHTol(sunctx, mcontrol_H, mcontrol_Tol); + if (check_ptr((void*)mcontrol, "SUNAdaptController_MRIHTol")) return 1; + if (std::min(opts.htol_relch, std::min(opts.htol_minfac, opts.htol_maxfac)) > + -1) + { + retval = SUNAdaptController_SetParams_MRIHTol(scontrol, opts.htol_relch, + opts.htol_minfac, + opts.htol_maxfac); + if (check_flag(retval, "SUNAdaptController_SetParams_MRIHTol")) return 1; + retval = SUNAdaptController_SetParams_MRIHTol(mcontrol, opts.htol_relch, + opts.htol_minfac, + opts.htol_maxfac); + if (check_flag(retval, "SUNAdaptController_SetParams_MRIHTol")) return 1; + } + break; + case (3): + scontrol_H = SUNAdaptController_PID(sunctx); + if (check_ptr((void*)scontrol_H, "SUNAdaptController_PID (slow H)")) + return 1; + scontrol_Tol = SUNAdaptController_PID(sunctx); + if (check_ptr((void*)scontrol_Tol, "SUNAdaptController_PID (slow Tol)")) + return 1; + mcontrol_H = SUNAdaptController_PID(sunctx); + if (check_ptr((void*)mcontrol_H, "SUNAdaptController_PID (mid H)")) + return 1; + mcontrol_Tol = SUNAdaptController_PID(sunctx); + if (check_ptr((void*)mcontrol_Tol, "SUNAdaptController_PID (mid Tol)")) + return 1; + if (std::min(opts.k1s, std::min(opts.k2s, opts.k3s)) > -1) + { + retval = SUNAdaptController_SetParams_PID(scontrol_H, opts.k1s, opts.k2s, + opts.k3s); + if (check_flag(retval, "SUNAdaptController_SetParams_PID")) return 1; + retval = SUNAdaptController_SetParams_PID(scontrol_Tol, opts.k1s, + opts.k2s, opts.k3s); + if (check_flag(retval, "SUNAdaptController_SetParams_PID")) return 1; + retval = SUNAdaptController_SetParams_PID(mcontrol_H, opts.k1s, opts.k2s, + opts.k3s); + if (check_flag(retval, "SUNAdaptController_SetParams_PID")) return 1; + retval = SUNAdaptController_SetParams_PID(mcontrol_Tol, opts.k1s, + opts.k2s, opts.k3s); + if (check_flag(retval, "SUNAdaptController_SetParams_PID")) return 1; + } + scontrol = SUNAdaptController_MRIHTol(sunctx, scontrol_H, scontrol_Tol); + if (check_ptr((void*)scontrol, "SUNAdaptController_MRIHTol")) return 1; + mcontrol = SUNAdaptController_MRIHTol(sunctx, mcontrol_H, mcontrol_Tol); + if (check_ptr((void*)mcontrol, "SUNAdaptController_MRIHTol")) return 1; + if (std::min(opts.htol_relch, std::min(opts.htol_minfac, opts.htol_maxfac)) > + -1) + { + retval = SUNAdaptController_SetParams_MRIHTol(scontrol, opts.htol_relch, + opts.htol_minfac, + opts.htol_maxfac); + if (check_flag(retval, "SUNAdaptController_SetParams_MRIHTol")) return 1; + retval = SUNAdaptController_SetParams_MRIHTol(mcontrol, opts.htol_relch, + opts.htol_minfac, + opts.htol_maxfac); + if (check_flag(retval, "SUNAdaptController_SetParams_MRIHTol")) return 1; + } + break; + case (4): + scontrol_H = SUNAdaptController_ExpGus(sunctx); + if (check_ptr((void*)scontrol_H, "SUNAdaptController_ExpGus (slow H)")) + return 1; + scontrol_Tol = SUNAdaptController_ExpGus(sunctx); + if (check_ptr((void*)scontrol_Tol, "SUNAdaptController_ExpGus (slow Tol)")) + return 1; + mcontrol_H = SUNAdaptController_ExpGus(sunctx); + if (check_ptr((void*)mcontrol_H, "SUNAdaptController_ExpGus (mid H)")) + return 1; + mcontrol_Tol = SUNAdaptController_ExpGus(sunctx); + if (check_ptr((void*)mcontrol_Tol, "SUNAdaptController_ExpGus (mid Tol)")) + return 1; + if (std::min(opts.k1s, opts.k2s) > -1) + { + retval = SUNAdaptController_SetParams_ExpGus(scontrol_H, opts.k1s, + opts.k2s); + if (check_flag(retval, "SUNAdaptController_SetParams_ExpGus")) return 1; + retval = SUNAdaptController_SetParams_ExpGus(scontrol_Tol, opts.k1s, + opts.k2s); + if (check_flag(retval, "SUNAdaptController_SetParams_ExpGus")) return 1; + retval = SUNAdaptController_SetParams_ExpGus(mcontrol_H, opts.k1s, + opts.k2s); + if (check_flag(retval, "SUNAdaptController_SetParams_ExpGus")) return 1; + retval = SUNAdaptController_SetParams_ExpGus(mcontrol_Tol, opts.k1s, + opts.k2s); + if (check_flag(retval, "SUNAdaptController_SetParams_ExpGus")) return 1; + } + scontrol = SUNAdaptController_MRIHTol(sunctx, scontrol_H, scontrol_Tol); + if (check_ptr((void*)scontrol, "SUNAdaptController_MRIHTol")) return 1; + mcontrol = SUNAdaptController_MRIHTol(sunctx, mcontrol_H, mcontrol_Tol); + if (check_ptr((void*)mcontrol, "SUNAdaptController_MRIHTol")) return 1; + if (std::min(opts.htol_relch, std::min(opts.htol_minfac, opts.htol_maxfac)) > + -1) + { + retval = SUNAdaptController_SetParams_MRIHTol(scontrol, opts.htol_relch, + opts.htol_minfac, + opts.htol_maxfac); + if (check_flag(retval, "SUNAdaptController_SetParams_MRIHTol")) return 1; + retval = SUNAdaptController_SetParams_MRIHTol(mcontrol, opts.htol_relch, + opts.htol_minfac, + opts.htol_maxfac); + if (check_flag(retval, "SUNAdaptController_SetParams_MRIHTol")) return 1; + } + break; + case (5): + scontrol_H = SUNAdaptController_ImpGus(sunctx); + if (check_ptr((void*)scontrol_H, "SUNAdaptController_ImpGus (slow H)")) + return 1; + scontrol_Tol = SUNAdaptController_ImpGus(sunctx); + if (check_ptr((void*)scontrol_Tol, "SUNAdaptController_ImpGus (slow Tol)")) + return 1; + mcontrol_H = SUNAdaptController_ImpGus(sunctx); + if (check_ptr((void*)mcontrol_H, "SUNAdaptController_ImpGus (mid H)")) + return 1; + mcontrol_Tol = SUNAdaptController_ImpGus(sunctx); + if (check_ptr((void*)mcontrol_Tol, "SUNAdaptController_ImpGus (mid Tol)")) + return 1; + if (std::min(opts.k1s, opts.k2s) > -1) + { + retval = SUNAdaptController_SetParams_ImpGus(scontrol_H, opts.k1s, + opts.k2s); + if (check_flag(retval, "SUNAdaptController_SetParams_ImpGus")) return 1; + retval = SUNAdaptController_SetParams_ImpGus(scontrol_Tol, opts.k1s, + opts.k2s); + if (check_flag(retval, "SUNAdaptController_SetParams_ImpGus")) return 1; + retval = SUNAdaptController_SetParams_ImpGus(mcontrol_H, opts.k1s, + opts.k2s); + if (check_flag(retval, "SUNAdaptController_SetParams_ImpGus")) return 1; + retval = SUNAdaptController_SetParams_ImpGus(mcontrol_Tol, opts.k1s, + opts.k2s); + if (check_flag(retval, "SUNAdaptController_SetParams_ImpGus")) return 1; + } + scontrol = SUNAdaptController_MRIHTol(sunctx, scontrol_H, scontrol_Tol); + if (check_ptr((void*)scontrol, "SUNAdaptController_MRIHTol")) return 1; + mcontrol = SUNAdaptController_MRIHTol(sunctx, mcontrol_H, mcontrol_Tol); + if (check_ptr((void*)mcontrol, "SUNAdaptController_MRIHTol")) return 1; + if (std::min(opts.htol_relch, std::min(opts.htol_minfac, opts.htol_maxfac)) > + -1) + { + retval = SUNAdaptController_SetParams_MRIHTol(scontrol, opts.htol_relch, + opts.htol_minfac, + opts.htol_maxfac); + if (check_flag(retval, "SUNAdaptController_SetParams_MRIHTol")) return 1; + retval = SUNAdaptController_SetParams_MRIHTol(mcontrol, opts.htol_relch, + opts.htol_minfac, + opts.htol_maxfac); + if (check_flag(retval, "SUNAdaptController_SetParams_MRIHTol")) return 1; + } + break; + case (6): + scontrol_H = SUNAdaptController_ImExGus(sunctx); + if (check_ptr((void*)scontrol_H, "SUNAdaptController_ImExGus (slow H)")) + return 1; + scontrol_Tol = SUNAdaptController_ImExGus(sunctx); + if (check_ptr((void*)scontrol_Tol, "SUNAdaptController_ImExGus (slow Tol)")) + return 1; + mcontrol_H = SUNAdaptController_ImExGus(sunctx); + if (check_ptr((void*)mcontrol_H, "SUNAdaptController_ImExGus (mid H)")) + return 1; + mcontrol_Tol = SUNAdaptController_ImExGus(sunctx); + if (check_ptr((void*)mcontrol_Tol, "SUNAdaptController_ImExGus (mid Tol)")) + return 1; + scontrol = SUNAdaptController_MRIHTol(sunctx, scontrol_H, scontrol_Tol); + if (check_ptr((void*)scontrol, "SUNAdaptController_MRIHTol")) return 1; + mcontrol = SUNAdaptController_MRIHTol(sunctx, scontrol_H, scontrol_Tol); + if (check_ptr((void*)mcontrol, "SUNAdaptController_MRIHTol")) return 1; + if (std::min(opts.htol_relch, std::min(opts.htol_minfac, opts.htol_maxfac)) > + -1) + { + retval = SUNAdaptController_SetParams_MRIHTol(scontrol, opts.htol_relch, + opts.htol_minfac, + opts.htol_maxfac); + if (check_flag(retval, "SUNAdaptController_SetParams_MRIHTol")) return 1; + retval = SUNAdaptController_SetParams_MRIHTol(mcontrol, opts.htol_relch, + opts.htol_minfac, + opts.htol_maxfac); + if (check_flag(retval, "SUNAdaptController_SetParams_MRIHTol")) return 1; + } + break; + case (7): + scontrol = SUNAdaptController_I(sunctx); + if (check_ptr((void*)scontrol, "SUNAdaptControllerI (slow)")) return 1; + mcontrol = SUNAdaptController_I(sunctx); + if (check_ptr((void*)mcontrol, "SUNAdaptControllerI (mid)")) return 1; + if (opts.k1s > -1) + { + retval = SUNAdaptController_SetParams_I(scontrol, opts.k1s); + if (check_flag(retval, "SUNAdaptController_SetParams_I")) return 1; + retval = SUNAdaptController_SetParams_I(mcontrol, opts.k1s); + if (check_flag(retval, "SUNAdaptController_SetParams_I")) return 1; + } + break; + case (8): + scontrol = SUNAdaptController_PI(sunctx); + if (check_ptr((void*)scontrol, "SUNAdaptController_PI (slow)")) return 1; + mcontrol = SUNAdaptController_PI(sunctx); + if (check_ptr((void*)mcontrol, "SUNAdaptController_PI (mid)")) return 1; + if (std::min(opts.k1s, opts.k2s) > -1) + { + retval = SUNAdaptController_SetParams_PI(scontrol, opts.k1s, opts.k2s); + if (check_flag(retval, "SUNAdaptController_SetParams_PI")) return 1; + retval = SUNAdaptController_SetParams_PI(mcontrol, opts.k1s, opts.k2s); + if (check_flag(retval, "SUNAdaptController_SetParams_PI")) return 1; + } + break; + case (9): + scontrol = SUNAdaptController_PID(sunctx); + if (check_ptr((void*)scontrol, "SUNAdaptController_PID (slow)")) return 1; + mcontrol = SUNAdaptController_PID(sunctx); + if (check_ptr((void*)mcontrol, "SUNAdaptController_PID (mid)")) return 1; + if (std::min(opts.k1s, std::min(opts.k2s, opts.k3s)) > -1) + { + retval = SUNAdaptController_SetParams_PID(scontrol, opts.k1s, opts.k2s, + opts.k3s); + if (check_flag(retval, "SUNAdaptController_SetParams_PID")) return 1; + retval = SUNAdaptController_SetParams_PID(mcontrol, opts.k1s, opts.k2s, + opts.k3s); + if (check_flag(retval, "SUNAdaptController_SetParams_PID")) return 1; + } + break; + case (10): + scontrol = SUNAdaptController_ExpGus(sunctx); + if (check_ptr((void*)scontrol, "SUNAdaptController_ExpGus (slow)")) + return 1; + mcontrol = SUNAdaptController_ExpGus(sunctx); + if (check_ptr((void*)mcontrol, "SUNAdaptController_ExpGus (mid)")) + return 1; + if (std::min(opts.k1s, opts.k2s) > -1) + { + retval = SUNAdaptController_SetParams_ExpGus(scontrol, opts.k1s, opts.k2s); + if (check_flag(retval, "SUNAdaptController_SetParams_ExpGus")) return 1; + retval = SUNAdaptController_SetParams_ExpGus(mcontrol, opts.k1s, opts.k2s); + if (check_flag(retval, "SUNAdaptController_SetParams_ExpGus")) return 1; + } + break; + case (11): + scontrol = SUNAdaptController_ImpGus(sunctx); + if (check_ptr((void*)scontrol, "SUNAdaptController_ImpGus (slow)")) + return 1; + mcontrol = SUNAdaptController_ImpGus(sunctx); + if (check_ptr((void*)mcontrol, "SUNAdaptController_ImpGus (mid)")) + return 1; + if (std::min(opts.k1s, opts.k2s) > -1) + { + retval = SUNAdaptController_SetParams_ImpGus(scontrol, opts.k1s, opts.k2s); + if (check_flag(retval, "SUNAdaptController_SetParams_ImpGus")) return 1; + retval = SUNAdaptController_SetParams_ImpGus(mcontrol, opts.k1s, opts.k2s); + if (check_flag(retval, "SUNAdaptController_SetParams_ImpGus")) return 1; + } + break; + case (16): + scontrol = SUNAdaptController_ImExGus(sunctx); + if (check_ptr((void*)scontrol, "SUNAdaptController_ImExGus (slow)")) + return 1; + mcontrol = SUNAdaptController_ImExGus(sunctx); + if (check_ptr((void*)scontrol, "SUNAdaptController_ImExGus (mid)")) + return 1; + break; + } + if ((opts.bias > -1) && (opts.scontrol > 0)) + { + retval = SUNAdaptController_SetErrorBias(scontrol, opts.bias); + if (check_flag(retval, "SUNAdaptController_SetErrorBias")) return 1; + retval = SUNAdaptController_SetErrorBias(mcontrol, opts.bias); + if (check_flag(retval, "SUNAdaptController_SetErrorBias")) return 1; + } + + // Create MRI (intermediate) integrator + void* mid_arkode_mem = NULL; // ARKode memory structure + mid_arkode_mem = MRIStepCreate(f_me, f_mi, T0, y, inner_stepper, sunctx); + if (check_ptr((void*)mid_arkode_mem, "MRIStepCreate")) return 1; + MRIStepCoupling Cm = MRIStepCoupling_LoadTableByName((opts.mid_method).c_str()); + if (check_ptr((void*)Cm, "MRIStepCoupling_LoadTableByName")) return 1; + retval = MRIStepSetCoupling(mid_arkode_mem, Cm); + if (check_flag(retval, "MRIStepSetCoupling")) return 1; + SUNMatrix Am = NULL; // matrix for intermediate solver + SUNLinearSolver LSm = NULL; // intermediate linear solver object + if (midimplicit) + { + Am = SUNDenseMatrix(NEQ, NEQ, sunctx); + if (check_ptr((void*)Am, "SUNDenseMatrix")) return 1; + LSm = SUNLinSol_Dense(y, Am, sunctx); + if (check_ptr((void*)LSm, "SUNLinSol_Dense")) return 1; + retval = ARKodeSetLinearSolver(mid_arkode_mem, LSm, Am); + if (check_flag(retval, "ARKodeSetLinearSolver")) return 1; + retval = ARKodeSetJacFn(mid_arkode_mem, J_m); + if (check_flag(retval, "ARKodeSetJacFn")) return 1; + } + retval = ARKodeSStolerances(mid_arkode_mem, opts.rtol, opts.atol); + if (check_flag(retval, "ARKodeSStolerances")) return 1; + retval = ARKodeSetMaxNumSteps(mid_arkode_mem, 100000); + if (check_flag(retval, "ARKodeSetMaxNumSteps")) return 1; + retval = ARKodeSetAccumulatedErrorType(mid_arkode_mem, opts.faccum); + if (check_flag(retval, "ARKodeSetAccumulatedErrorType")) return 1; + retval = ARKodeSetUserData(mid_arkode_mem, (void*)&opts); + if (check_flag(retval, "ARKodeSetUserData")) return 1; + if (opts.scontrol != 0) + { + retval = MRIStepSetAdaptController(mid_arkode_mem, mcontrol); + if (check_flag(retval, "MRIStepSetAdaptController")) return 1; + if (opts.set_h0 != 0) + { + retval = ARKodeSetInitStep(mid_arkode_mem, opts.hm); + if (check_flag(retval, "ARKodeSetInitStep")) return 1; + } + if (opts.slow_pq == 1) + { + retval = ARKodeSetAdaptivityAdjustment(mid_arkode_mem, 0); + if (check_flag(retval, "ARKodeSetAdaptivityAdjustment")) return 1; + } + if (opts.slow_safety > -1) + { + retval = ARKodeSetSafetyFactor(mid_arkode_mem, opts.slow_safety); + if (check_flag(retval, "ARKodeSetSafetyFactor")) return 1; + } + } + else + { + retval = ARKodeSetFixedStep(mid_arkode_mem, opts.hm); + if (check_flag(retval, "ARKodeSetFixedStep")) return 1; + } + + // Create intermediate stepper + MRIStepInnerStepper intermediate_stepper = NULL; + retval = MRIStepCreateMRIStepInnerStepper(mid_arkode_mem, &intermediate_stepper); + if (check_flag(retval, "MRIStepCreateMRIStepInnerStepper")) return 1; + + // Create MRI (slow) integrator + void* arkode_mem = NULL; // ARKode memory structure + arkode_mem = MRIStepCreate(f_se, f_si, T0, y, intermediate_stepper, sunctx); + if (check_ptr((void*)arkode_mem, "MRIStepCreate")) return 1; + MRIStepCoupling Cs = MRIStepCoupling_LoadTableByName((opts.mri_method).c_str()); + if (check_ptr((void*)Cs, "MRIStepCoupling_LoadTableByName")) return 1; + retval = MRIStepSetCoupling(arkode_mem, Cs); + if (check_flag(retval, "MRIStepSetCoupling")) return 1; + SUNMatrix As = NULL; // matrix for slow solver + SUNLinearSolver LSs = NULL; // slow linear solver object + if (slowimplicit) + { + As = SUNDenseMatrix(NEQ, NEQ, sunctx); + if (check_ptr((void*)As, "SUNDenseMatrix")) return 1; + LSs = SUNLinSol_Dense(y, As, sunctx); + if (check_ptr((void*)LSs, "SUNLinSol_Dense")) return 1; + retval = ARKodeSetLinearSolver(arkode_mem, LSs, As); + if (check_flag(retval, "ARKodeSetLinearSolver")) return 1; + retval = ARKodeSetJacFn(arkode_mem, J_s); + if (check_flag(retval, "ARKodeSetJacFn")) return 1; + } + retval = ARKodeSStolerances(arkode_mem, opts.rtol, opts.atol); + if (check_flag(retval, "ARKodeSStolerances")) return 1; + retval = ARKodeSetMaxNumSteps(arkode_mem, 100000); + if (check_flag(retval, "ARKodeSetMaxNumSteps")) return 1; + retval = ARKodeSetUserData(arkode_mem, (void*)&opts); + if (check_flag(retval, "ARKodeSetUserData")) return 1; + if (opts.scontrol != 0) + { + retval = MRIStepSetAdaptController(arkode_mem, scontrol); + if (check_flag(retval, "MRIStepSetAdaptController")) return 1; + if (opts.set_h0 != 0) + { + retval = ARKodeSetInitStep(arkode_mem, opts.hs); + if (check_flag(retval, "ARKodeSetInitStep")) return 1; + } + if (opts.slow_pq == 1) + { + retval = ARKodeSetAdaptivityAdjustment(arkode_mem, 0); + if (check_flag(retval, "ARKodeSetAdaptivityAdjustment")) return 1; + } + if (opts.slow_safety > -1) + { + retval = ARKodeSetSafetyFactor(arkode_mem, opts.slow_safety); + if (check_flag(retval, "ARKodeSetSafetyFactor")) return 1; + } + } + else + { + retval = ARKodeSetFixedStep(arkode_mem, opts.hs); + if (check_flag(retval, "ARKodeSetFixedStep")) return 1; + } + + // + // Integrate ODE + // + + // Main time-stepping loop: calls ARKodeEvolve to perform the + // integration, then prints results. Stops when the final time + // has been reached + sunrealtype t = T0; + sunrealtype t2 = T0; + sunrealtype dTout = (Tf - T0) / Nt; + sunrealtype tout = T0 + dTout; + sunrealtype u, v, w, uerr, verr, werr, uerrtot, verrtot, werrtot, errtot, accuracy; + uerr = verr = werr = uerrtot = verrtot = werrtot = errtot = accuracy = ZERO; + printf(" t u v w uerr verr werr\n"); + printf(" ----------------------------------------------------------------------------\n"); + printf(" %10.6" FSYM " %10.6" FSYM " %10.6" FSYM " %10.6" FSYM " %.2" ESYM " %.2" ESYM " %.2" ESYM "\n", + t, NV_Ith_S(y, 0), NV_Ith_S(y, 1), NV_Ith_S(y, 2), uerr, verr, werr); + int Nout = 0; + while (Tf - t > 1.0e-8) + { + // reset reference solver so that it begins with identical state + retval = ARKodeReset(arkode_ref, t, y); + + // evolve solution in one-step mode + retval = ARKodeSetStopTime(arkode_mem, tout); + if (check_flag(retval, "ARKodeSetStopTime")) return 1; + retval = ARKodeEvolve(arkode_mem, tout, y, &t, ARK_ONE_STEP); + if (retval < 0) + { + printf("ARKodeEvolve error (%i)\n", retval); + return 1; + } + + // evolve reference solver to same time in "normal" mode + retval = ARKodeSetStopTime(arkode_ref, t); + if (check_flag(retval, "ARKodeSetStopTime")) return 1; + retval = ARKodeEvolve(arkode_ref, t, yref, &t2, ARK_NORMAL); + if (retval < 0) + { + printf("ARKodeEvolve reference solution error (%i)\n", retval); + return 1; + } + + // access/print solution and error + u = NV_Ith_S(y, 0); + v = NV_Ith_S(y, 1); + w = NV_Ith_S(y, 2); + uerr = SUNRabs(NV_Ith_S(yref, 0) - u); + verr = SUNRabs(NV_Ith_S(yref, 1) - v); + werr = SUNRabs(NV_Ith_S(yref, 2) - w); + uerrtot += uerr * uerr; + verrtot += verr * verr; + werrtot += werr * werr; + errtot += uerr * uerr + verr * verr + werr * werr; + accuracy = std::max(accuracy, uerr / SUNRabs(opts.atol + + opts.rtol * NV_Ith_S(yref, 0))); + accuracy = std::max(accuracy, verr / SUNRabs(opts.atol + + opts.rtol * NV_Ith_S(yref, 1))); + accuracy = std::max(accuracy, werr / SUNRabs(opts.atol + + opts.rtol * NV_Ith_S(yref, 2))); + Nout++; + + // Periodically output current results to screen + if (t >= tout) + { + tout += dTout; + tout = (tout > Tf) ? Tf : tout; + printf(" %10.6" FSYM " %10.6" FSYM " %10.6" FSYM " %10.6" FSYM " %.2" ESYM " %.2" ESYM " %.2" ESYM "\n", + t, u, v, w, uerr, verr, werr); + } + } + uerrtot = SUNRsqrt(uerrtot / Nt); + verrtot = SUNRsqrt(verrtot / Nt); + werrtot = SUNRsqrt(werrtot / Nt); + errtot = SUNRsqrt(errtot / Nt / 3); + printf(" ----------------------------------------------------------------------------\n"); + + // + // Finalize + // + + // Get some slow integrator statistics + long int nsts, natts, netfs, nfse, nfsi; + retval = ARKodeGetNumSteps(arkode_mem, &nsts); + check_flag(retval, "ARKodeGetNumSteps"); + retval = ARKodeGetNumStepAttempts(arkode_mem, &natts); + check_flag(retval, "ARKodeGetNumStepAttempts"); + retval = ARKodeGetNumErrTestFails(arkode_mem, &netfs); + check_flag(retval, "ARKodeGetNumErrTestFails"); + retval = MRIStepGetNumRhsEvals(arkode_mem, &nfse, &nfsi); + check_flag(retval, "MRIStepGetNumRhsEvals"); + + // Get some intermediate integrator statistics + long int nstm, nattm, netfm, nfme, nfmi; + retval = ARKodeGetNumSteps(mid_arkode_mem, &nstm); + check_flag(retval, "ARKodeGetNumSteps"); + retval = ARKodeGetNumStepAttempts(mid_arkode_mem, &nattm); + check_flag(retval, "ARKodeGetNumStepAttempts"); + retval = ARKodeGetNumErrTestFails(mid_arkode_mem, &netfm); + check_flag(retval, "ARKodeGetNumErrTestFails"); + retval = MRIStepGetNumRhsEvals(mid_arkode_mem, &nfme, &nfmi); + check_flag(retval, "MRIStepGetNumRhsEvals"); + + // Get some fast integrator statistics + long int nstf, nattf, netff, nff; + retval = ARKodeGetNumSteps(inner_arkode_mem, &nstf); + check_flag(retval, "ARKodeGetNumSteps"); + retval = ARKodeGetNumStepAttempts(inner_arkode_mem, &nattf); + check_flag(retval, "ARKodeGetNumStepAttempts"); + retval = ARKodeGetNumErrTestFails(inner_arkode_mem, &netff); + check_flag(retval, "ARKodeGetNumErrTestFails"); + retval = ERKStepGetNumRhsEvals(inner_arkode_mem, &nff); + check_flag(retval, "ERKStepGetNumRhsEvals"); + + // Print some final statistics + std::cout << "\nFinal Solver Statistics:\n"; + std::cout << " Slow steps = " << nsts << " (attempts = " << natts + << ", fails = " << netfs << ")\n"; + std::cout << " Intermediate steps = " << nstm << " (attempts = " << nattm + << ", fails = " << netfm << ")\n"; + std::cout << " Fast steps = " << nstf << " (attempts = " << nattf + << ", fails = " << netff << ")\n"; + std::cout << " u error = " << uerrtot << ", v error = " << verrtot + << ", total error = " << errtot << std::endl; + std::cout << " Relative accuracy = " << accuracy << std::endl; + std::cout << " Total RHS evals: Fse = " << nfse << ", Fsi = " << nfsi + << ", Fme = " << nfme << ", Fmi = " << nfmi + << ", Ff = " << nff << std::endl; + + // Get/print slow integrator implicit solver statistics + if (slowimplicit) + { + long int nnis, nncs, njes; + retval = ARKodeGetNonlinSolvStats(arkode_mem, &nnis, &nncs); + check_flag(retval, "ARKodeGetNonlinSolvStats"); + retval = ARKodeGetNumJacEvals(arkode_mem, &njes); + check_flag(retval, "ARKodeGetNumJacEvals"); + std::cout << " Slow Newton iters = " << nnis << std::endl; + std::cout << " Slow Newton conv fails = " << nncs << std::endl; + std::cout << " Slow Jacobian evals = " << njes << std::endl; + } + + // Get/print intermediate integrator implicit solver statistics + if (midimplicit) + { + long int nnim, nncm, njem; + retval = ARKodeGetNonlinSolvStats(mid_arkode_mem, &nnim, &nncm); + check_flag(retval, "ARKodeGetNonlinSolvStats"); + retval = ARKodeGetNumJacEvals(mid_arkode_mem, &njem); + check_flag(retval, "ARKodeGetNumJacEvals"); + std::cout << " Intermediate Newton iters = " << nnim << std::endl; + std::cout << " Intermediate Newton conv fails = " << nncm << std::endl; + std::cout << " Intermediate Jacobian evals = " << njem << std::endl; + } + + // Clean up and return + N_VDestroy(y); + MRIStepCoupling_Free(Cs); + MRIStepCoupling_Free(Cm); + if (As) { SUNMatDestroy(As); } + if (LSs) { SUNLinSolFree(LSs); } + if (Am) { SUNMatDestroy(Am); } + if (LSm) { SUNLinSolFree(LSm); } + if (scontrol) { SUNAdaptController_Destroy(scontrol); } + if (scontrol_H) { SUNAdaptController_Destroy(scontrol_H); } + if (scontrol_Tol) { SUNAdaptController_Destroy(scontrol_Tol); } + if (mcontrol) { SUNAdaptController_Destroy(mcontrol); } + if (mcontrol_H) { SUNAdaptController_Destroy(mcontrol_H); } + if (mcontrol_Tol) { SUNAdaptController_Destroy(mcontrol_Tol); } + if (fcontrol) { SUNAdaptController_Destroy(fcontrol); } + ARKodeFree(&inner_arkode_mem); // Free fast integrator memory + ARKodeFree(&mid_arkode_mem) ; // Free intermediate integrator memory + MRIStepInnerStepper_Free(&inner_stepper); // Free inner stepper structures + MRIStepInnerStepper_Free(&intermediate_stepper); + ARKodeFree(&arkode_mem); // Free slow integrator memory + ARKodeFree(&arkode_ref); // Free reference solver memory + + return 0; +} + +// ------------------------------ +// Functions called by the solver +// ----------------------------- + +// fn routine to compute the full ODE RHS. +static int fn(sunrealtype t, N_Vector y, N_Vector ydot, void* user_data) +{ + Options* opts = (Options*)user_data; + const sunrealtype u = NV_Ith_S(y, 0); + const sunrealtype v = NV_Ith_S(y, 1); + const sunrealtype w = NV_Ith_S(y, 2); + const sunrealtype G = opts->G; + const sunrealtype e = opts->e; + const sunrealtype al = opts->al; + const sunrealtype be = opts->be; + sunrealtype tmp1, tmp2, tmp3; + + // fill in the RHS function: + // [ G e e ] [(u^2-p-2)/(2u)] + [ pdot(t)/(2u) ] + // [ e al be ] [(v^2-q-2)/(2v)] [ qdot(t)/(2v) ] + // [ e -be al ] [(w^2-r-2)/(2w)] [ rdot(t)/(2w) ] + tmp1 = (-TWO + u * u - p(t, opts)) / (TWO * u); + tmp2 = (-TWO + v * v - q(t, opts)) / (TWO * v); + tmp3 = (-TWO + w * w - r(t, opts)) / (TWO * w); + NV_Ith_S(ydot, 0) = G * tmp1 + e * tmp2 + e * tmp3 + pdot(t, opts) / (TWO * u); + NV_Ith_S(ydot, 1) = e * tmp1 + al * tmp2 + be * tmp3 + qdot(t, opts) / (TWO * v); + NV_Ith_S(ydot, 2) = e * tmp1 - be * tmp2 + al * tmp3 + rdot(t, opts) / (TWO * w); + + // Return with success + return 0; +} + +// ff routine to compute the fast portion of the ODE RHS. +static int ff(sunrealtype t, N_Vector y, N_Vector ydot, void* user_data) +{ + Options* opts = (Options*)user_data; + const sunrealtype u = NV_Ith_S(y, 0); + const sunrealtype v = NV_Ith_S(y, 1); + const sunrealtype w = NV_Ith_S(y, 2); + const sunrealtype e = opts->e; + const sunrealtype al = opts->al; + const sunrealtype be = opts->be; + sunrealtype tmp1, tmp2, tmp3; + + // fill in the RHS function: + // [ 0 0 0 ] [(u^2-p-2)/(2u)] + [ 0 ] + // [ 0 0 0 ] [(v^2-q-2)/(2v)] [ 0 ] + // [ e -be al ] [(w^2-r-2)/(2w)] [ rdot(t)/(2w) ] + tmp1 = (-TWO + u * u - p(t, opts)) / (TWO * u); + tmp2 = (-TWO + v * v - q(t, opts)) / (TWO * v); + tmp3 = (-TWO + w * w - r(t, opts)) / (TWO * w); + NV_Ith_S(ydot, 0) = ZERO; + NV_Ith_S(ydot, 1) = ZERO; + NV_Ith_S(ydot, 2) = e * tmp1 - be * tmp2 + al * tmp3 + rdot(t, opts) / (TWO * w); + + // Return with success + return 0; +} + +// fm routine to compute the intermediate portion of the ODE RHS. +static int fm(sunrealtype t, N_Vector y, N_Vector ydot, void* user_data) +{ + Options* opts = (Options*)user_data; + const sunrealtype u = NV_Ith_S(y, 0); + const sunrealtype v = NV_Ith_S(y, 1); + const sunrealtype w = NV_Ith_S(y, 2); + const sunrealtype e = opts->e; + const sunrealtype al = opts->al; + const sunrealtype be = opts->be; + sunrealtype tmp1, tmp2, tmp3; + + // fill in the RHS function: + // [ 0 0 0 ] [(u^2-p-2)/(2u)] + [ 0 ] + // [ e al be ] [(v^2-q-2)/(2v)] [ qdot(t)/(2v) ] + // [ 0 0 0 ] [(w^2-r-2)/(2w)] [ 0 ] + tmp1 = (-TWO + u * u - p(t, opts)) / (TWO * u); + tmp2 = (-TWO + v * v - q(t, opts)) / (TWO * v); + tmp3 = (-TWO + w * w - r(t, opts)) / (TWO * w); + NV_Ith_S(ydot, 0) = ZERO; + NV_Ith_S(ydot, 1) = e * tmp1 + al * tmp2 + be * tmp3 + qdot(t, opts) / (TWO * v); + NV_Ith_S(ydot, 2) = ZERO; + + return 0; +} + +// fme routine to compute the explicit intermediate portion of the ODE RHS. +static int fme(sunrealtype t, N_Vector y, N_Vector ydot, void* user_data) +{ + Options* opts = (Options*)user_data; + const sunrealtype v = NV_Ith_S(y, 1); + + // fill in the RHS function: + // [ 0 ] + // [ qdot(t)/(2v) ] + // [ 0 ] + NV_Ith_S(ydot, 0) = ZERO; + NV_Ith_S(ydot, 1) = qdot(t, opts) / (TWO * v); + NV_Ith_S(ydot, 2) = ZERO; + + return 0; +} + +// fmi routine to compute the implicit intermediate portion of the ODE RHS. +static int fmi(sunrealtype t, N_Vector y, N_Vector ydot, void* user_data) +{ + Options* opts = (Options*)user_data; + const sunrealtype u = NV_Ith_S(y, 0); + const sunrealtype v = NV_Ith_S(y, 1); + const sunrealtype w = NV_Ith_S(y, 2); + const sunrealtype e = opts->e; + const sunrealtype al = opts->al; + const sunrealtype be = opts->be; + sunrealtype tmp1, tmp2, tmp3; + + // fill in the RHS function: + // [ 0 0 0 ] [(u^2-p-2)/(2u)] + // [ e al be ] [(v^2-q-2)/(2v)] + // [ 0 0 0 ] [(w^2-r-2)/(2w)] + tmp1 = (-TWO + u * u - p(t, opts)) / (TWO * u); + tmp2 = (-TWO + v * v - q(t, opts)) / (TWO * v); + tmp3 = (-TWO + w * w - r(t, opts)) / (TWO * w); + NV_Ith_S(ydot, 0) = ZERO; + NV_Ith_S(ydot, 1) = e * tmp1 + al * tmp2 + be * tmp3; + NV_Ith_S(ydot, 2) = ZERO; + + // Return with success + return 0; +} + +// fs routine to compute the slow portion of the ODE RHS. +static int fs(sunrealtype t, N_Vector y, N_Vector ydot, void* user_data) +{ + Options* opts = (Options*)user_data; + const sunrealtype u = NV_Ith_S(y, 0); + const sunrealtype v = NV_Ith_S(y, 1); + const sunrealtype w = NV_Ith_S(y, 2); + const sunrealtype G = opts->G; + const sunrealtype e = opts->e; + sunrealtype tmp1, tmp2, tmp3; + + // fill in the RHS function: + // [ G e e ] [(u^2-p-2)/(2u)] + [ pdot(t)/(2u) ] + // [ 0 0 0 ] [(v^2-q-2)/(2v)] [ 0 ] + // [ 0 0 0 ] [(w^2-r-2)/(2w)] [ 0 ] + tmp1 = (-TWO + u * u - p(t, opts)) / (TWO * u); + tmp2 = (-TWO + v * v - q(t, opts)) / (TWO * v); + tmp3 = (-TWO + w * w - r(t, opts)) / (TWO * w); + NV_Ith_S(ydot, 0) = G * tmp1 + e * tmp2 + e * tmp3 + pdot(t, opts) / (TWO * u); + NV_Ith_S(ydot, 1) = ZERO; + NV_Ith_S(ydot, 2) = ZERO; + + return 0; +} + +// fse routine to compute the explicit slow portion of the ODE RHS. +static int fse(sunrealtype t, N_Vector y, N_Vector ydot, void* user_data) +{ + Options* opts = (Options*)user_data; + const sunrealtype u = NV_Ith_S(y, 0); + + // fill in the RHS function: + // [ pdot(t)/(2u) ] + // [ 0 ] + // [ 0 ] + NV_Ith_S(ydot, 0) = pdot(t, opts) / (TWO * u); + NV_Ith_S(ydot, 1) = ZERO; + NV_Ith_S(ydot, 2) = ZERO; + + return 0; +} + +// fsi routine to compute the implicit slow portion of the ODE RHS. +static int fsi(sunrealtype t, N_Vector y, N_Vector ydot, void* user_data) +{ + Options* opts = (Options*)user_data; + const sunrealtype u = NV_Ith_S(y, 0); + const sunrealtype v = NV_Ith_S(y, 1); + const sunrealtype w = NV_Ith_S(y, 2); + const sunrealtype G = opts->G; + const sunrealtype e = opts->e; + sunrealtype tmp1, tmp2, tmp3; + + // fill in the RHS function: + // [ G e e ] [(u^2-p-2)/(2u)] + // [ 0 0 0 ] [(v^2-q-2)/(2v)] + // [ 0 0 0 ] [(w^2-r-2)/(2w)] + tmp1 = (-TWO + u * u - p(t, opts)) / (TWO * u); + tmp2 = (-TWO + v * v - q(t, opts)) / (TWO * v); + tmp3 = (-TWO + w * w - r(t, opts)) / (TWO * w); + NV_Ith_S(ydot, 0) = G * tmp1 + e * tmp2 + e * tmp3; + NV_Ith_S(ydot, 1) = ZERO; + NV_Ith_S(ydot, 2) = ZERO; + + // Return with success + return 0; +} + +static int f0(sunrealtype t, N_Vector y, N_Vector ydot, void* user_data) +{ + N_VConst(ZERO, ydot); + return (0); +} + +// Jacobian of fn +static int Jn(sunrealtype t, N_Vector y, N_Vector fy, SUNMatrix J, + void* user_data, N_Vector tmp1, N_Vector tmp2, N_Vector tmp3) +{ + Options* opts = (Options*)user_data; + const sunrealtype u = NV_Ith_S(y, 0); + const sunrealtype v = NV_Ith_S(y, 1); + const sunrealtype w = NV_Ith_S(y, 2); + sunrealtype t11, t22, t33; + + // fill in the Jacobian: + // [G e e]*[1-(u^2-p(t)-2)/(2*u^2), 0, 0] + [-p'(t)/(2*u^2), 0, 0] + // [e al be] [0, 1-(v^2-q(t)-2)/(2*v^2), 0] [0, -q'(t)/(2*v^2), 0] + // [e -be al] [0, 0, 1-(w^2-r(t)-2)/(2*w^2)] [0, 0, -r'(t)/(2*w^2)] + t11 = ONE - (u * u - p(t, opts) - TWO) / (TWO * u * u); + t22 = ONE - (v * v - q(t, opts) - TWO) / (TWO * v * v); + t33 = ONE - (w * w - r(t, opts) - TWO) / (TWO * w * w); + SM_ELEMENT_D(J, 0, 0) = opts->G * t11 - pdot(t, opts) / (TWO * u * u); + SM_ELEMENT_D(J, 0, 1) = opts->e * t22; + SM_ELEMENT_D(J, 0, 2) = opts->e * t33; + SM_ELEMENT_D(J, 1, 0) = opts->e * t11; + SM_ELEMENT_D(J, 1, 1) = opts->al * t22 - qdot(t, opts) / (TWO * v * v); + SM_ELEMENT_D(J, 1, 2) = opts->be * t33; + SM_ELEMENT_D(J, 2, 0) = opts->e * t11; + SM_ELEMENT_D(J, 2, 1) = -opts->be * t22; + SM_ELEMENT_D(J, 2, 2) = opts->al * t33 - rdot(t, opts) / (TWO * w * w); + + // Return with success + return 0; +} + +// Jacobian of fm +static int Jm(sunrealtype t, N_Vector y, N_Vector fy, SUNMatrix J, + void* user_data, N_Vector tmp1, N_Vector tmp2, N_Vector tmp3) +{ + Options* opts = (Options*)user_data; + const sunrealtype u = NV_Ith_S(y, 0); + const sunrealtype v = NV_Ith_S(y, 1); + const sunrealtype w = NV_Ith_S(y, 2); + sunrealtype t11, t22, t33; + + // fill in the Jacobian: + // [0 0 0]*[1-(u^2-p(t)-2)/(2*u^2), 0, 0] + [0, 0, 0] + // [e al be] [0, 1-(v^2-q(t)-2)/(2*v^2), 0] [0, -q'(t)/(2*v^2), 0] + // [0 0 0] [0, 0, 1-(w^2-r(t)-2)/(2*w^2)] [0, 0, 0] + t11 = ONE - (u * u - p(t, opts) - TWO) / (TWO * u * u); + t22 = ONE - (v * v - q(t, opts) - TWO) / (TWO * v * v); + t33 = ONE - (w * w - r(t, opts) - TWO) / (TWO * w * w); + SM_ELEMENT_D(J, 0, 0) = ZERO; + SM_ELEMENT_D(J, 0, 1) = ZERO; + SM_ELEMENT_D(J, 0, 2) = ZERO; + SM_ELEMENT_D(J, 1, 0) = opts->e * t11; + SM_ELEMENT_D(J, 1, 1) = opts->al * t22 - qdot(t, opts) / (TWO * v * v); + SM_ELEMENT_D(J, 1, 2) = opts->be * t33; + SM_ELEMENT_D(J, 2, 0) = ZERO; + SM_ELEMENT_D(J, 2, 1) = ZERO; + SM_ELEMENT_D(J, 2, 2) = ZERO; + + // Return with success + return 0; +} + +// Jacobian of fmi +static int Jmi(sunrealtype t, N_Vector y, N_Vector fy, SUNMatrix J, + void* user_data, N_Vector tmp1, N_Vector tmp2, N_Vector tmp3) +{ + Options* opts = (Options*)user_data; + const sunrealtype u = NV_Ith_S(y, 0); + const sunrealtype v = NV_Ith_S(y, 1); + const sunrealtype w = NV_Ith_S(y, 2); + sunrealtype t11, t22, t33; + + // fill in the Jacobian: + // [0 0 0]*[1-(u^2-p(t)-2)/(2*u^2), 0, 0] + // [e al be] [0, 1-(v^2-q(t)-2)/(2*v^2), 0] + // [0 0 0] [0, 0, 1-(w^2-r(t)-2)/(2*w^2)] + t11 = ONE - (u * u - p(t, opts) - TWO) / (TWO * u * u); + t22 = ONE - (v * v - q(t, opts) - TWO) / (TWO * v * v); + t33 = ONE - (w * w - r(t, opts) - TWO) / (TWO * w * w); + SM_ELEMENT_D(J, 0, 0) = ZERO; + SM_ELEMENT_D(J, 0, 1) = ZERO; + SM_ELEMENT_D(J, 0, 2) = ZERO; + SM_ELEMENT_D(J, 1, 0) = opts->e * t11; + SM_ELEMENT_D(J, 1, 1) = opts->al * t22; + SM_ELEMENT_D(J, 1, 2) = opts->be * t33; + SM_ELEMENT_D(J, 2, 0) = ZERO; + SM_ELEMENT_D(J, 2, 1) = ZERO; + SM_ELEMENT_D(J, 2, 2) = ZERO; + + // Return with success + return 0; +} + + +// Jacobian of fs +static int Js(sunrealtype t, N_Vector y, N_Vector fy, SUNMatrix J, + void* user_data, N_Vector tmp1, N_Vector tmp2, N_Vector tmp3) +{ + Options* opts = (Options*)user_data; + const sunrealtype u = NV_Ith_S(y, 0); + const sunrealtype v = NV_Ith_S(y, 1); + const sunrealtype w = NV_Ith_S(y, 2); + sunrealtype t11, t22, t33; + + // fill in the Jacobian: + // [G e e]*[1-(u^2-p(t)-2)/(2*u^2), 0, 0] + [-p'(t)/(2*u^2), 0, 0] + // [0 0 0] [0, 1-(v^2-q(t)-2)/(2*v^2), 0] [0, 0, 0] + // [0 0 0] [0, 0, 1-(w^2-r(t)-2)/(2*w^2)] [0, 0, 0] + t11 = ONE - (u * u - p(t, opts) - TWO) / (TWO * u * u); + t22 = ONE - (v * v - q(t, opts) - TWO) / (TWO * v * v); + t33 = ONE - (w * w - r(t, opts) - TWO) / (TWO * w * w); + SM_ELEMENT_D(J, 0, 0) = opts->G * t11 - pdot(t, opts) / (TWO * u * u); + SM_ELEMENT_D(J, 0, 1) = opts->e * t22; + SM_ELEMENT_D(J, 0, 2) = opts->e * t33; + SM_ELEMENT_D(J, 1, 0) = ZERO; + SM_ELEMENT_D(J, 1, 1) = ZERO; + SM_ELEMENT_D(J, 1, 2) = ZERO; + SM_ELEMENT_D(J, 2, 0) = ZERO; + SM_ELEMENT_D(J, 2, 1) = ZERO; + SM_ELEMENT_D(J, 2, 2) = ZERO; + + // Return with success + return 0; +} + +// Jacobian of fsi +static int Jsi(sunrealtype t, N_Vector y, N_Vector fy, SUNMatrix J, + void* user_data, N_Vector tmp1, N_Vector tmp2, N_Vector tmp3) +{ + Options* opts = (Options*)user_data; + const sunrealtype u = NV_Ith_S(y, 0); + const sunrealtype v = NV_Ith_S(y, 1); + const sunrealtype w = NV_Ith_S(y, 2); + sunrealtype t11, t22, t33; + + // fill in the Jacobian: + // [G e e]*[1-(u^2-p(t)-2)/(2*u^2), 0, 0] + // [0 0 0] [0, 1-(v^2-q(t)-2)/(2*v^2), 0] + // [0 0 0] [0, 0, 1-(w^2-r(t)-2)/(2*w^2)] + t11 = ONE - (u * u - p(t, opts) - TWO) / (TWO * u * u); + t22 = ONE - (v * v - q(t, opts) - TWO) / (TWO * v * v); + t33 = ONE - (w * w - r(t, opts) - TWO) / (TWO * w * w); + SM_ELEMENT_D(J, 0, 0) = opts->G * t11; + SM_ELEMENT_D(J, 0, 1) = opts->e * t22; + SM_ELEMENT_D(J, 0, 2) = opts->e * t33; + SM_ELEMENT_D(J, 1, 0) = ZERO; + SM_ELEMENT_D(J, 1, 1) = ZERO; + SM_ELEMENT_D(J, 1, 2) = ZERO; + SM_ELEMENT_D(J, 2, 0) = ZERO; + SM_ELEMENT_D(J, 2, 1) = ZERO; + SM_ELEMENT_D(J, 2, 2) = ZERO; + + // Return with success + return 0; +} + +// ------------------------------ +// Private helper functions +// ----------------------------- + +static sunrealtype p(sunrealtype t, Options* opts) { return HALF*cos(t); } + +static sunrealtype q(sunrealtype t, Options* opts) +{ + return (cos(opts->om * t * (ONE + exp(-(t - TWO) * (t - TWO))))); +} + +static sunrealtype r(sunrealtype t, Options* opts) +{ + return (cos(opts->om * opts->om * t * (ONE + exp(-(t - THREE) * (t - THREE))))); +} + +static sunrealtype pdot(sunrealtype t, Options* opts) { return -HALF*sin(t); } + +static sunrealtype qdot(sunrealtype t, Options* opts) +{ + const sunrealtype tTwo = t - TWO; + const sunrealtype eterm = exp(-tTwo * tTwo); + return (-sin(opts->om * t * (ONE + eterm)) * opts->om * + (ONE + eterm * (ONE - TWO * t * tTwo))); +} + +static sunrealtype rdot(sunrealtype t, Options* opts) +{ + const sunrealtype tThree = t - THREE; + const sunrealtype eterm = exp(-tThree * tThree); + return (-sin(opts->om * opts->om * t * (ONE + eterm)) * opts->om * opts->om * + (ONE + eterm * (ONE - TWO * t * tThree))); +} + +static sunrealtype utrue(sunrealtype t, Options* opts) +{ + return (SUNRsqrt(TWO + p(t, opts))); +} + +static sunrealtype vtrue(sunrealtype t, Options* opts) +{ + return (SUNRsqrt(TWO + q(t, opts))); +} + +static sunrealtype wtrue(sunrealtype t, Options* opts) +{ + return (SUNRsqrt(TWO + r(t, opts))); +} + +static int Ytrue(sunrealtype t, N_Vector y, Options* opts) +{ + NV_Ith_S(y, 0) = utrue(t, opts); + NV_Ith_S(y, 1) = vtrue(t, opts); + NV_Ith_S(y, 2) = wtrue(t, opts); + return (0); +} + +// ----------------------------------------------------------------------------- +// Utility functions +// ----------------------------------------------------------------------------- + +// Print command line options +void InputHelp() +{ + std::cout << std::endl; + std::cout << "Command line options:" << std::endl; + std::cout << " --help : print options and exit\n"; + std::cout << " --G : stiffness at slow time scale\n"; + std::cout << " --e : fast/slow coupling strength\n"; + std::cout << " --al : med/fast oscillation term\n"; + std::cout << " --be : med/fast oscillation term\n"; + std::cout << " --om : time-scale separation factor\n"; + std::cout << " --hs : slow (fixed/initial) step size\n"; + std::cout << " --hm : intermediate (fixed/initial) step size\n"; + std::cout << " --hf : fast (fixed/initial) step size\n"; + std::cout + << " --set_h0 : use hs/hf above to set the initial step size\n"; + std::cout << " --rtol : relative solution tolerance\n"; + std::cout << " --atol : absolute solution tolerance\n"; + std::cout + << " --fast_rtol : relative solution tolerance for fast method\n"; + std::cout << " --safety : slow time step safety factor\n"; + std::cout << " --mri_method : slow MRI method name (valid ARKODE_MRITableID)\n"; + std::cout << " --mid_method : intemediate MRI method name (valid ARKODE_MRITableID)\n"; + std::cout << " --fast_order : fast RK method order\n"; + std::cout << " --scontrol : slow/intermeidate time step controllers, int in [0,12] " + "(see source)\n"; + std::cout << " --fcontrol : fast time step controller, int in [0,6] " + "(see source)\n"; + std::cout << " --faccum : fast error accumulation type {-1,0,1}\n"; + std::cout << " --slow_pq : use p (0) vs q (1) for slow/intermediate adaptivity\n"; + std::cout << " --fast_pq : use p (0) vs q (1) for fast adaptivity\n"; + std::cout << " --k1s, --k2s, -k3s : slow/intermediate controller parameters\n"; + std::cout << " --k1f, --k2f, -k3f : fast controller parameters\n"; + std::cout << " --bias : slow and fast controller bias factors\n"; + std::cout + << " --htol_relch : HTol controller maximum relative tolerance change\n"; + std::cout + << " --htol_minfac : HTol controller minimum relative tolerance factor\n"; + std::cout + << " --htol_maxfac : HTol controller maximum relative tolerance factor\n"; +} + +// Read input options +int ReadInputs(std::vector& args, Options& opts, SUNContext ctx) +{ + if (find(args.begin(), args.end(), "--help") != args.end()) + { + InputHelp(); + return 1; + } + + // Problem options + find_arg(args, "--G", opts.G); + find_arg(args, "--e", opts.e); + find_arg(args, "--al", opts.al); + find_arg(args, "--be", opts.be); + find_arg(args, "--om", opts.om); + find_arg(args, "--hs", opts.hs); + find_arg(args, "--hm", opts.hm); + find_arg(args, "--hf", opts.hf); + find_arg(args, "--set_h0", opts.set_h0); + find_arg(args, "--rtol", opts.rtol); + find_arg(args, "--atol", opts.atol); + find_arg(args, "--fast_rtol", opts.fast_rtol); + find_arg(args, "--safety", opts.slow_safety); + find_arg(args, "--mri_method", opts.mri_method); + find_arg(args, "--mid_method", opts.mid_method); + find_arg(args, "--fast_order", opts.fast_order); + find_arg(args, "--scontrol", opts.scontrol); + find_arg(args, "--fcontrol", opts.fcontrol); + find_arg(args, "--faccum", opts.faccum); + find_arg(args, "--slow_pq", opts.slow_pq); + find_arg(args, "--fast_pq", opts.fast_pq); + find_arg(args, "--k1s", opts.k1s); + find_arg(args, "--k2s", opts.k2s); + find_arg(args, "--k3s", opts.k3s); + find_arg(args, "--k1f", opts.k1f); + find_arg(args, "--k2f", opts.k2f); + find_arg(args, "--k3f", opts.k3f); + find_arg(args, "--bias", opts.bias); + find_arg(args, "--htol_relch", opts.htol_relch); + find_arg(args, "--htol_minfac", opts.htol_minfac); + find_arg(args, "--htol_maxfac", opts.htol_maxfac); + + // Check inputs for validity + // 0 < rtol < 1 + if ((opts.rtol < ZERO) || (opts.rtol > ONE)) + { + std::cerr << "ERROR: rtol must be in (0,1), (" << opts.rtol << " input)\n"; + return -1; + } + // 0 < atol < 1 + if ((opts.atol < ZERO) || (opts.atol > ONE)) + { + std::cerr << "ERROR: atol must be in (0,1), (" << opts.atol << " input)\n"; + return -1; + } + // 0 < fast_rtol < 1 + if ((opts.fast_rtol < ZERO) || (opts.fast_rtol > ONE)) + { + std::cerr << "ERROR: fast_rtol must be in (0,1), (" << opts.fast_rtol + << " input)\n"; + return -1; + } + // 0 < fast_order + if (opts.fast_order <= 0) + { + std::cerr << "ERROR: fast_order must be at least 1, (" << opts.fast_order + << " input)\n"; + return -1; + } + // slow_pq in {0,1} + if ((opts.slow_pq < 0) || (opts.slow_pq > 1)) + { + std::cerr << "ERROR: slow_pq must be in {0,1}, (" << opts.slow_pq + << " input)\n"; + return -1; + } + // fast_pq in {0,1} + if ((opts.fast_pq < 0) || (opts.fast_pq > 1)) + { + std::cerr << "ERROR: fast_pq must be in {0,1}, (" << opts.fast_pq + << " input)\n"; + return -1; + } + // scontrol in [0,16] + if ((opts.scontrol < 0) || (opts.scontrol > 12)) + { + std::cerr << "ERROR: scontrol must be in [0,16], (" << opts.scontrol + << " input)\n"; + return -1; + } + // fcontrol in [0,6] + if ((opts.fcontrol < 0) || (opts.fcontrol > 6)) + { + std::cerr << "ERROR: fcontrol must be in [0,6], (" << opts.fcontrol + << " input)\n"; + return -1; + } + // hs > 0 and hm > 0 if scontrol == 0 + if (((opts.hs <= 0) || (opts.hm <= 0)) && (opts.scontrol == 0)) + { + std::cerr << "ERROR: positive hs required with scontrol = 0, (" << opts.hs + << " input)\n"; + return -1; + } + // hf > 0 if fcontrol == 0 + if ((opts.hf <= 0) && (opts.fcontrol == 0)) + { + std::cerr << "ERROR: positive hf required with fcontrol = 0, (" << opts.hf + << " input)\n"; + return -1; + } + // G < 0.0 + if (opts.G >= ZERO) + { + std::cerr << "ERROR: G must be a negative real number, (" << opts.G + << " input)\n"; + return -1; + } + // om >= 1.0 + if (opts.om < ONE) + { + std::cerr << "ERROR: w must be >= 1.0, (" << opts.om << " input)\n"; + return -1; + } + + return 0; +} + +static void PrintSlowAdaptivity(Options opts) +{ + switch (opts.scontrol) + { + case (0): + std::cout << " fixed steps, hs = " << opts.hs << ", hm = " << opts.hm << std::endl; + std::cout << " rtol = " << opts.rtol << ", atol = " << opts.atol << "\n"; + break; + case (1): + std::cout + << " MRI-HTOL controller (using I for H) based on order of MRI " + << ((opts.slow_pq == 1) ? "method\n" : "embedding\n"); + std::cout << " rtol = " << opts.rtol << ", atol = " << opts.atol << "\n"; + std::cout << " fast error accumulation strategy = " << opts.faccum << "\n"; + if (opts.k1s > -1) + { + std::cout << " slow/intermediate controller parameter: " << opts.k1s << "\n"; + } + if (std::min(opts.htol_relch, std::min(opts.htol_minfac, opts.htol_maxfac)) > + -1) + { + std::cout << " HTol controller parameters: " << opts.htol_relch << " " + << opts.htol_minfac << " " << opts.htol_maxfac << "\n"; + } + break; + case (2): + std::cout + << " MRI-HTOL controller (using PI for H) based on order of MRI " + << ((opts.slow_pq == 1) ? "method\n" : "embedding\n"); + std::cout << " rtol = " << opts.rtol << ", atol = " << opts.atol << "\n"; + std::cout << " fast error accumulation strategy = " << opts.faccum << "\n"; + if (std::min(opts.k1s, opts.k2s) > -1) + { + std::cout << " slow/intermediate controller parameters: " << opts.k1s << " " + << opts.k2s << "\n"; + } + if (std::min(opts.htol_relch, std::min(opts.htol_minfac, opts.htol_maxfac)) > + -1) + { + std::cout << " HTol controller parameters: " << opts.htol_relch << " " + << opts.htol_minfac << " " << opts.htol_maxfac << "\n"; + } + break; + case (3): + std::cout + << " MRI-HTOL controller (using PID for H) based on order of MRI " + << ((opts.slow_pq == 1) ? "method\n" : "embedding\n"); + std::cout << " rtol = " << opts.rtol << ", atol = " << opts.atol << "\n"; + std::cout << " fast error accumulation strategy = " << opts.faccum << "\n"; + if (std::min(opts.k1s, std::min(opts.k2s, opts.k3s)) > -1) + { + std::cout << " slow/intermediate controller parameters: " << opts.k1s << " " + << opts.k2s << " " << opts.k3s << "\n"; + } + if (std::min(opts.htol_relch, std::min(opts.htol_minfac, opts.htol_maxfac)) > + -1) + { + std::cout << " HTol controller parameters: " << opts.htol_relch << " " + << opts.htol_minfac << " " << opts.htol_maxfac << "\n"; + } + break; + case (4): + std::cout + << " MRI-HTOL controller (using ExpGus for H) based on order of MRI " + << ((opts.slow_pq == 1) ? "method\n" : "embedding\n"); + std::cout << " rtol = " << opts.rtol << ", atol = " << opts.atol << "\n"; + std::cout << " fast error accumulation strategy = " << opts.faccum << "\n"; + if (std::min(opts.k1s, opts.k2s) > -1) + { + std::cout << " slow/intermediate controller parameters: " << opts.k1s << " " + << opts.k2s << "\n"; + } + if (std::min(opts.htol_relch, std::min(opts.htol_minfac, opts.htol_maxfac)) > + -1) + { + std::cout << " HTol controller parameters: " << opts.htol_relch << " " + << opts.htol_minfac << " " << opts.htol_maxfac << "\n"; + } + break; + case (5): + std::cout + << " MRI-HTOL controller (using ImpGus for H) based on order of MRI " + << ((opts.slow_pq == 1) ? "method\n" : "embedding\n"); + std::cout << " rtol = " << opts.rtol << ", atol = " << opts.atol << "\n"; + std::cout << " fast error accumulation strategy = " << opts.faccum << "\n"; + if (std::min(opts.k1s, opts.k2s) > -1) + { + std::cout << " slow/intermediate controller parameters: " << opts.k1s << " " + << opts.k2s << "\n"; + } + if (std::min(opts.htol_relch, std::min(opts.htol_minfac, opts.htol_maxfac)) > + -1) + { + std::cout << " HTol controller parameters: " << opts.htol_relch << " " + << opts.htol_minfac << " " << opts.htol_maxfac << "\n"; + } + break; + case (6): + std::cout + << " MRI-HTOL controller (using ImExGus for H) based on order of MRI " + << ((opts.slow_pq == 1) ? "method\n" : "embedding\n"); + std::cout << " rtol = " << opts.rtol << ", atol = " << opts.atol << "\n"; + std::cout << " fast error accumulation strategy = " << opts.faccum << "\n"; + break; + case (7): + std::cout << " Decoupled I controller for slow time scale, based on " + "order of MRI " + << ((opts.slow_pq == 1) ? "method\n" : "embedding\n"); + std::cout << " rtol = " << opts.rtol << ", atol = " << opts.atol << "\n"; + if (opts.k1s > -1) + { + std::cout << " slow/intermediate controller parameter: " << opts.k1s << "\n"; + } + break; + case (8): + std::cout << " Decoupled PI controller for slow time scale, based on " + "order of MRI " + << ((opts.slow_pq == 1) ? "method\n" : "embedding\n"); + std::cout << " rtol = " << opts.rtol << ", atol = " << opts.atol << "\n"; + if (std::min(opts.k1s, opts.k2s) > -1) + { + std::cout << " slow/intermediate controller parameters: " << opts.k1s << " " + << opts.k2s << "\n"; + } + break; + case (9): + std::cout << " Decoupled PID controller for slow time scale, based on " + "order of MRI " + << ((opts.slow_pq == 1) ? "method\n" : "embedding\n"); + std::cout << " rtol = " << opts.rtol << ", atol = " << opts.atol << "\n"; + if (std::min(opts.k1s, std::min(opts.k2s, opts.k3s)) > -1) + { + std::cout << " slow/intermediate controller parameters: " << opts.k1s << " " + << opts.k2s << " " << opts.k3s << "\n"; + } + break; + case (10): + std::cout << " Decoupled ExpGus controller for slow time scale, based " + "on order of MRI " + << ((opts.slow_pq == 1) ? "method\n" : "embedding\n"); + std::cout << " rtol = " << opts.rtol << ", atol = " << opts.atol << "\n"; + if (std::min(opts.k1s, opts.k2s) > -1) + { + std::cout << " slow/intermediate controller parameters: " << opts.k1s << " " + << opts.k2s << "\n"; + } + break; + case (11): + std::cout << " Decoupled ImpGus controller for slow time scale, based " + "on order of MRI " + << ((opts.slow_pq == 1) ? "method\n" : "embedding\n"); + std::cout << " rtol = " << opts.rtol << ", atol = " << opts.atol << "\n"; + if (std::min(opts.k1s, opts.k2s) > -1) + { + std::cout << " slow/intermediate controller parameters: " << opts.k1s << " " + << opts.k2s << "\n"; + } + break; + case (12): + std::cout << " Decoupled ImExGus controller for slow time scale, based " + "on order of MRI " + << ((opts.slow_pq == 1) ? "method\n" : "embedding\n"); + std::cout << " rtol = " << opts.rtol << ", atol = " << opts.atol << "\n"; + break; + } + if (opts.bias > -1) + { + std::cout << " controller bias factor: " << opts.bias << "\n"; + } + if (opts.slow_safety > -1) + { + std::cout << " slow step safety factor: " << opts.slow_safety << "\n"; + } +} + +static void PrintFastAdaptivity(Options opts) +{ + switch (opts.fcontrol) + { + case (0): + std::cout << " fixed steps, hf = " << opts.hf << std::endl; + std::cout << " fast_rtol = " << opts.fast_rtol + << ", atol = " << opts.atol << "\n"; + break; + case (1): + std::cout << " I controller for fast time scale, based on order of RK " + << ((opts.fast_pq == 1) ? "method\n" : "embedding\n"); + std::cout << " fast_rtol = " << opts.fast_rtol + << ", atol = " << opts.atol << "\n"; + if (opts.k1f > -1) + { + std::cout << " fast controller parameter: " << opts.k1f << "\n"; + } + break; + case (2): + std::cout << " PI controller for fast time scale, based on order of RK " + << ((opts.fast_pq == 1) ? "method\n" : "embedding\n"); + std::cout << " fast_rtol = " << opts.fast_rtol + << ", atol = " << opts.atol << "\n"; + if (std::min(opts.k1f, opts.k2f) > -1) + { + std::cout << " fast controller parameters: " << opts.k1f << " " + << opts.k2f << "\n"; + } + break; + case (3): + std::cout << " PID controller for fast time scale, based on order of RK " + << ((opts.fast_pq == 1) ? "method\n" : "embedding\n"); + std::cout << " fast_rtol = " << opts.fast_rtol + << ", atol = " << opts.atol << "\n"; + if (std::min(opts.k1f, std::min(opts.k2f, opts.k3f)) > -1) + { + std::cout << " fast controller parameters: " << opts.k1f << " " + << opts.k2f << " " << opts.k3f << "\n"; + } + break; + case (4): + std::cout + << " ExpGus controller for fast time scale, based on order of RK " + << ((opts.fast_pq == 1) ? "method\n" : "embedding\n"); + std::cout << " fast_rtol = " << opts.fast_rtol + << ", atol = " << opts.atol << "\n"; + if (std::min(opts.k1f, opts.k2f) > -1) + { + std::cout << " fast controller parameters: " << opts.k1f << " " + << opts.k2f << "\n"; + } + break; + case (5): + std::cout + << " ImpGus controller for fast time scale, based on order of RK " + << ((opts.fast_pq == 1) ? "method\n" : "embedding\n"); + std::cout << " fast_rtol = " << opts.fast_rtol + << ", atol = " << opts.atol << "\n"; + if (std::min(opts.k1f, opts.k2f) > -1) + { + std::cout << " fast controller parameters: " << opts.k1f << " " + << opts.k2f << "\n"; + } + break; + case (6): + std::cout + << " ImExGus controller for fast time scale, based on order of RK " + << ((opts.fast_pq == 1) ? "method\n" : "embedding\n"); + std::cout << " fast_rtol = " << opts.fast_rtol + << ", atol = " << opts.atol << "\n"; + break; + } +} + +//---- end of file ----// diff --git a/test/unit_tests/arkode/CXX_serial/ark_test_kpr_nestedmri.out b/test/unit_tests/arkode/CXX_serial/ark_test_kpr_nestedmri.out new file mode 100644 index 0000000000..95e0f7c44e --- /dev/null +++ b/test/unit_tests/arkode/CXX_serial/ark_test_kpr_nestedmri.out @@ -0,0 +1,51 @@ + +Adaptive nested multirate nonlinear Kvaerno-Prothero-Robinson test problem: + time domain: (0,5] + G = -10 + e = 0.5 + al = -1 + be = 1 + om = 50 + + Slow integrator: ARKODE_MRI_GARK_ERK45a (explicit) + + Intermediate integrator: ARKODE_MRI_GARK_ERK45a (explicit) + MRI-HTOL controller (using I for H) based on order of MRI embedding + rtol = 0.0001, atol = 1e-11 + fast error accumulation strategy = 0 + + Fast order 4 + I controller for fast time scale, based on order of RK embedding + fast_rtol = 0.0001, atol = 1e-11 + t u v w uerr verr werr + ---------------------------------------------------------------------------- + 0.000000 1.581139 1.732051 1.732051 0.00e+00 0.00e+00 0.00e+00 + 0.250000 1.576211 1.693761 1.005220 9.29e-07 5.67e-05 6.93e-05 + 0.500000 1.561599 1.094201 1.236938 6.40e-06 7.10e-05 8.20e-05 + 0.750000 1.538091 1.480215 1.289928 3.15e-06 7.57e-05 4.66e-05 + 1.000000 1.506678 1.658588 1.566388 1.86e-06 8.12e-05 6.89e-06 + 1.250000 1.468874 1.117572 1.128939 4.86e-07 8.50e-05 3.56e-05 + 1.500000 1.426630 1.451349 1.383721 1.73e-07 6.82e-05 3.51e-05 + 1.750000 1.382317 1.731537 1.400664 5.24e-06 1.42e-04 8.50e-05 + 2.000000 1.338583 1.576792 1.004753 9.92e-07 7.73e-05 6.02e-05 + 2.250000 1.298343 1.357630 1.203255 3.15e-05 2.22e-04 3.28e-04 + 2.500000 1.265157 1.111803 1.080348 5.76e-08 2.91e-09 3.16e-07 + 2.750000 1.240078 1.181758 1.688613 3.74e-07 1.13e-07 1.82e-05 + 3.000000 1.226708 1.199800 1.243898 1.03e-07 2.74e-05 1.47e-04 + 3.250000 1.225891 1.336847 1.695845 3.83e-05 4.66e-05 6.62e-05 + 3.500000 1.237704 1.494163 1.577915 5.90e-07 3.39e-07 1.38e-05 + 3.750000 1.260835 1.441462 1.440583 3.72e-05 1.97e-05 1.14e-04 + 4.000000 1.293784 1.067928 1.718725 4.24e-07 1.12e-06 8.69e-06 + 4.250000 1.333018 1.724738 1.003916 2.75e-06 1.16e-05 6.63e-05 + 4.500000 1.376563 1.650128 1.499923 3.22e-07 2.16e-07 8.96e-07 + 4.750000 1.420823 1.555111 1.167594 1.04e-06 5.84e-06 5.16e-06 + 5.000000 1.463470 1.506592 1.644722 6.82e-06 4.07e-05 8.05e-05 + ---------------------------------------------------------------------------- + +Final Solver Statistics: + Slow steps = 56 (attempts = 56, fails = 0) + Intermediate steps = 728 (attempts = 806, fails = 78) + Fast steps = 108912 (attempts = 122048, fails = 13136) + u error = 0.000170499, v error = 0.00011944, total error = 0.000173095 + Relative accuracy = 5.36137 + Total RHS evals: Fse = 281, Fsi = 0, Fme = 3953, Fmi = 0, Ff = 597107 From f83c2ded7a9f099ad9902d47e82ee64b53cd647f Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Fri, 30 Aug 2024 16:12:18 -0500 Subject: [PATCH 023/286] Updated double-step fast error accumulation formula --- src/arkode/arkode_mristep.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/arkode/arkode_mristep.c b/src/arkode/arkode_mristep.c index dfbd3fd456..53a93c576a 100644 --- a/src/arkode/arkode_mristep.c +++ b/src/arkode/arkode_mristep.c @@ -3257,6 +3257,7 @@ int mriStep_StageERKFast(ARKodeMem ark_mem, ARKodeMRIStepMem step_mem, int is, { int retval; /* reusable return flag */ SUNAdaptController_Type adapt_type; /* timestep adaptivity type */ + sunrealtype inner_error_factor; #ifdef SUNDIALS_DEBUG printf(" MRIStep ERK fast stage\n"); @@ -3371,10 +3372,13 @@ int mriStep_StageERKFast(ARKodeMem ark_mem, ARKodeMRIStepMem step_mem, int is, /* compute solution difference */ N_VLinearSum(ONE, ytemp, -ONE, ycur, ytemp); - /* accumulate fast error estimate */ + /* accumulate fast error estimate -- this assumes that the inner + integrator has the same asymptotic order of accuracy as the MRI method */ + inner_error_factor = ark_mem->reltol / + SUNRabs(ONE - SUNRpowerI(step_mem->inner_hfactor, step_mem->q)); step_mem->inner_dsm = SUNMAX(step_mem->inner_dsm, - ark_mem->reltol * N_VWrmsNorm(ytemp, ark_mem->ewt)); + inner_error_factor * N_VWrmsNorm(ytemp, ark_mem->ewt)); /* reset fast integrator to the main evolution result */ retval = mriStepInnerStepper_Reset(step_mem->stepper, tf, ycur); From 997964d6a946468ef700adff31e80e703fb973ed Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Thu, 5 Sep 2024 08:29:24 -0500 Subject: [PATCH 024/286] Initial pass at removing MRI-Hh controllers --- doc/arkode/guide/source/Mathematics.rst | 56 +-- .../source/Usage/ARKStep/User_callable.rst | 2 +- .../Custom_Inner_Stepper/Description.rst | 36 -- .../MRIStep/Custom_Inner_Stepper/index.rst | 13 +- .../source/Usage/MRIStep/User_callable.rst | 130 +++--- .../guide/source/Usage/User_callable.rst | 2 +- .../SUNAdaptController_links.rst | 4 - .../SUNAdaptController_Description.rst | 57 --- .../SUNAdaptController_MRICC.rst | 102 ----- .../SUNAdaptController_MRILL.rst | 131 ------ .../SUNAdaptController_MRIPI.rst | 119 ------ .../SUNAdaptController_MRIPID.rst | 130 ------ .../SUNAdaptController_links.rst | 1 + examples/arkode/CXX_serial/CMakeLists.txt | 1 + .../arkode/CXX_serial/ark_kpr_nestedmri.cpp | 2 +- .../arkode/CXX_serial/ark_kpr_nestedmri.out | 0 examples/utilities/example_utilities.hpp | 11 + include/arkode/arkode_mristep.h | 4 - .../sunadaptcontroller_mricc.h | 72 ---- .../sunadaptcontroller_mrill.h | 86 ---- .../sunadaptcontroller_mripi.h | 83 ---- .../sunadaptcontroller_mripid.h | 89 ----- include/sundials/sundials_adaptcontroller.h | 33 -- src/arkode/CMakeLists.txt | 6 +- src/arkode/arkode_arkstep.c | 23 -- src/arkode/arkode_arkstep_impl.h | 1 - src/arkode/arkode_erkstep.c | 23 -- src/arkode/arkode_erkstep_impl.h | 1 - src/arkode/arkode_mristep.c | 281 +------------ src/arkode/arkode_mristep_controller.c | 66 +-- src/arkode/arkode_mristep_impl.h | 11 +- src/arkode/arkode_mristep_io.c | 44 +- src/arkode/fmod_int32/farkode_mristep_mod.c | 28 -- src/arkode/fmod_int32/farkode_mristep_mod.f90 | 52 --- src/arkode/fmod_int64/farkode_mristep_mod.c | 28 -- src/arkode/fmod_int64/farkode_mristep_mod.f90 | 52 --- src/sunadaptcontroller/CMakeLists.txt | 4 - src/sunadaptcontroller/mricc/CMakeLists.txt | 28 -- .../mricc/fmod_int32/CMakeLists.txt | 26 -- .../fsunadaptcontroller_mricc_mod.c | 335 ---------------- .../fsunadaptcontroller_mricc_mod.f90 | 269 ------------- .../mricc/fmod_int64/CMakeLists.txt | 26 -- .../fsunadaptcontroller_mricc_mod.c | 335 ---------------- .../fsunadaptcontroller_mricc_mod.f90 | 269 ------------- .../mricc/sunadaptcontroller_mricc.c | 189 --------- src/sunadaptcontroller/mrill/CMakeLists.txt | 28 -- .../mrill/fmod_int32/CMakeLists.txt | 26 -- .../fsunadaptcontroller_mrill_mod.c | 371 ----------------- .../fsunadaptcontroller_mrill_mod.f90 | 337 ---------------- .../mrill/fmod_int64/CMakeLists.txt | 26 -- .../fsunadaptcontroller_mrill_mod.c | 371 ----------------- .../fsunadaptcontroller_mrill_mod.f90 | 337 ---------------- .../mrill/sunadaptcontroller_mrill.c | 265 ------------- src/sunadaptcontroller/mripi/CMakeLists.txt | 28 -- .../mripi/fmod_int32/CMakeLists.txt | 26 -- .../fsunadaptcontroller_mripi_mod.c | 371 ----------------- .../fsunadaptcontroller_mripi_mod.f90 | 337 ---------------- .../mripi/fmod_int64/CMakeLists.txt | 26 -- .../fsunadaptcontroller_mripi_mod.c | 371 ----------------- .../fsunadaptcontroller_mripi_mod.f90 | 337 ---------------- .../mripi/sunadaptcontroller_mripi.c | 237 ----------- src/sunadaptcontroller/mripid/CMakeLists.txt | 28 -- .../mripid/fmod_int32/CMakeLists.txt | 26 -- .../fsunadaptcontroller_mripid_mod.c | 375 ------------------ .../fsunadaptcontroller_mripid_mod.f90 | 345 ---------------- .../mripid/fmod_int64/CMakeLists.txt | 26 -- .../fsunadaptcontroller_mripid_mod.c | 375 ------------------ .../fsunadaptcontroller_mripid_mod.f90 | 345 ---------------- .../mripid/sunadaptcontroller_mripid.c | 268 ------------- src/sundials/fmod_int32/fsundials_core_mod.c | 46 --- .../fmod_int32/fsundials_core_mod.f90 | 93 +---- src/sundials/fmod_int64/fsundials_core_mod.c | 46 --- .../fmod_int64/fsundials_core_mod.f90 | 93 +---- src/sundials/sundials_adaptcontroller.c | 33 -- swig/Makefile | 2 +- .../fsunadaptcontroller_mricc_mod.i | 29 -- .../fsunadaptcontroller_mrill_mod.i | 29 -- .../fsunadaptcontroller_mripi_mod.i | 29 -- .../fsunadaptcontroller_mripid_mod.i | 29 -- .../arkode/CXX_serial/CMakeLists.txt | 5 - .../ark_test_brusselator_mriadapt.cpp | 116 +----- .../CXX_serial/ark_test_kpr_mriadapt.cpp | 116 +----- 82 files changed, 142 insertions(+), 9067 deletions(-) delete mode 100644 doc/shared/sunadaptcontroller/SUNAdaptController_MRICC.rst delete mode 100644 doc/shared/sunadaptcontroller/SUNAdaptController_MRILL.rst delete mode 100644 doc/shared/sunadaptcontroller/SUNAdaptController_MRIPI.rst delete mode 100644 doc/shared/sunadaptcontroller/SUNAdaptController_MRIPID.rst rename test/unit_tests/arkode/CXX_serial/ark_test_kpr_nestedmri.cpp => examples/arkode/CXX_serial/ark_kpr_nestedmri.cpp (99%) rename test/unit_tests/arkode/CXX_serial/ark_test_kpr_nestedmri.out => examples/arkode/CXX_serial/ark_kpr_nestedmri.out (100%) delete mode 100644 include/sunadaptcontroller/sunadaptcontroller_mricc.h delete mode 100644 include/sunadaptcontroller/sunadaptcontroller_mrill.h delete mode 100644 include/sunadaptcontroller/sunadaptcontroller_mripi.h delete mode 100644 include/sunadaptcontroller/sunadaptcontroller_mripid.h delete mode 100644 src/sunadaptcontroller/mricc/CMakeLists.txt delete mode 100644 src/sunadaptcontroller/mricc/fmod_int32/CMakeLists.txt delete mode 100644 src/sunadaptcontroller/mricc/fmod_int32/fsunadaptcontroller_mricc_mod.c delete mode 100644 src/sunadaptcontroller/mricc/fmod_int32/fsunadaptcontroller_mricc_mod.f90 delete mode 100644 src/sunadaptcontroller/mricc/fmod_int64/CMakeLists.txt delete mode 100644 src/sunadaptcontroller/mricc/fmod_int64/fsunadaptcontroller_mricc_mod.c delete mode 100644 src/sunadaptcontroller/mricc/fmod_int64/fsunadaptcontroller_mricc_mod.f90 delete mode 100644 src/sunadaptcontroller/mricc/sunadaptcontroller_mricc.c delete mode 100644 src/sunadaptcontroller/mrill/CMakeLists.txt delete mode 100644 src/sunadaptcontroller/mrill/fmod_int32/CMakeLists.txt delete mode 100644 src/sunadaptcontroller/mrill/fmod_int32/fsunadaptcontroller_mrill_mod.c delete mode 100644 src/sunadaptcontroller/mrill/fmod_int32/fsunadaptcontroller_mrill_mod.f90 delete mode 100644 src/sunadaptcontroller/mrill/fmod_int64/CMakeLists.txt delete mode 100644 src/sunadaptcontroller/mrill/fmod_int64/fsunadaptcontroller_mrill_mod.c delete mode 100644 src/sunadaptcontroller/mrill/fmod_int64/fsunadaptcontroller_mrill_mod.f90 delete mode 100644 src/sunadaptcontroller/mrill/sunadaptcontroller_mrill.c delete mode 100644 src/sunadaptcontroller/mripi/CMakeLists.txt delete mode 100644 src/sunadaptcontroller/mripi/fmod_int32/CMakeLists.txt delete mode 100644 src/sunadaptcontroller/mripi/fmod_int32/fsunadaptcontroller_mripi_mod.c delete mode 100644 src/sunadaptcontroller/mripi/fmod_int32/fsunadaptcontroller_mripi_mod.f90 delete mode 100644 src/sunadaptcontroller/mripi/fmod_int64/CMakeLists.txt delete mode 100644 src/sunadaptcontroller/mripi/fmod_int64/fsunadaptcontroller_mripi_mod.c delete mode 100644 src/sunadaptcontroller/mripi/fmod_int64/fsunadaptcontroller_mripi_mod.f90 delete mode 100644 src/sunadaptcontroller/mripi/sunadaptcontroller_mripi.c delete mode 100644 src/sunadaptcontroller/mripid/CMakeLists.txt delete mode 100644 src/sunadaptcontroller/mripid/fmod_int32/CMakeLists.txt delete mode 100644 src/sunadaptcontroller/mripid/fmod_int32/fsunadaptcontroller_mripid_mod.c delete mode 100644 src/sunadaptcontroller/mripid/fmod_int32/fsunadaptcontroller_mripid_mod.f90 delete mode 100644 src/sunadaptcontroller/mripid/fmod_int64/CMakeLists.txt delete mode 100644 src/sunadaptcontroller/mripid/fmod_int64/fsunadaptcontroller_mripid_mod.c delete mode 100644 src/sunadaptcontroller/mripid/fmod_int64/fsunadaptcontroller_mripid_mod.f90 delete mode 100644 src/sunadaptcontroller/mripid/sunadaptcontroller_mripid.c delete mode 100644 swig/sunadaptcontroller/fsunadaptcontroller_mricc_mod.i delete mode 100644 swig/sunadaptcontroller/fsunadaptcontroller_mrill_mod.i delete mode 100644 swig/sunadaptcontroller/fsunadaptcontroller_mripi_mod.i delete mode 100644 swig/sunadaptcontroller/fsunadaptcontroller_mripid_mod.i diff --git a/doc/arkode/guide/source/Mathematics.rst b/doc/arkode/guide/source/Mathematics.rst index 5e727f772f..287114a381 100644 --- a/doc/arkode/guide/source/Mathematics.rst +++ b/doc/arkode/guide/source/Mathematics.rst @@ -928,7 +928,7 @@ MRIStep, :eq:`MRI_fast_IVP` and :eq:`MRI_embedding_fast_IVP`. Multirate temporal controls ^^^^^^^^^^^^^^^^^^^^^^^^^^^ -We consider three categories of temporal controllers that may be used within MRI +We consider two categories of temporal controllers that may be used within MRI methods. The first (and simplest), are "decoupled" controllers, that consist of two separate single-rate temporal controllers: one that adapts the slow time scale step size, :math:`h^S`, and the other that adapts the fast time scale step size, @@ -936,15 +936,7 @@ step size, :math:`h^S`, and the other that adapts the fast time scale step size, methods should work well for multirate problems where the time scales are somewhat decoupled, and that errors introduced at one scale do not "pollute" the other. -The second category of controllers we consider are :math:`h^S-h^F` multirate -controllers that adapt both the slow and fast step sizes simultaneously. We -implement four controllers of this type that were introduced in :cite:p:`Fish:23`: -MRI-CC, MRI-LL, MRI-PI, and MRI-PID. We note that this group of multirate -controllers adapts these values only between slow time steps, and thus individual -"fast" IVP solves over :math:`[t_{0,i},t_{F,i}]` or -:math:`[\tilde{t}_{0},\tilde{t}_{F}]` use fixed step sizes :math:`h^F`. - -The third category of controllers that we provide are :math:`h^S-Tol` multirate +The second category of controllers that we provide are :math:`h^S-Tol` multirate controllers. The basic idea is that at any given time scale, an integrator will attempt to adapt step sizes to control the *local error* within each step to achieve a requested tolerance. However, MRI methods must ask another adaptive @@ -991,11 +983,9 @@ adaptivity controllers: * fcontrol -- this adapts time steps :math:`h^F` within the fast integrator to achieve the current tolerance, :math:`\text{reltol}^f_n`. -We note that of the three classes of controllers considered here, the :math:`h^S-h^F` -controllers are only amenable to problems with two time scales. On the other hand, both -the decoupled and :math:`h^S-Tol` controllers may be used in multirate calculations with -an arbitrary number of time scales, since these focus on only one scale at a time, or on -how a given time scale relates to the next-faster scale. +We note that both the decoupled and :math:`h^S-Tol` controller families may be used in +multirate calculations with an arbitrary number of time scales, since these focus on only +one scale at a time, or on how a given time scale relates to the next-faster scale. .. _ARKODE.Mathematics.MultirateInitialSteps: @@ -1107,16 +1097,15 @@ arise at *both* the slow and fast time scales, which we denote here as :math:`\varepsilon^s` and :math:`\varepsilon^f`, respectively. While the slow error may be estimated as :math:`\varepsilon^s = \|y_n - \tilde{y}_n\|`, non-intrusive approaches for estimating :math:`\varepsilon^f` are more -challenging. ARKODE provides three strategies within ARKODE to help provide -this estimate. The first two assume that at each sub-step of the fast -integrator :math:`t_{n,m}`, the method computes an estimate of the local -temporal error, :math:`\varepsilon^f_{n,m}` (this typically results from its -own time step solution and embedding), and that the fast integrator itself is -temporally adaptive. In this case, we assume that the fast integrator was -run with the same absolute tolerances as the slow integrator, but that it may -have used a potentially different relative solution tolerance, :math:`\text{reltol}^f`. -The fast integrator then accumulates these local error estimates using either -a "maximum accumulation: strategy, +challenging. ARKODE provides two strategies to help provide this estimate, both +of which assume that at each sub-step of the fast integrator :math:`t_{n,m}`, the +method computes an estimate of the local temporal error, :math:`\varepsilon^f_{n,m}` +(this typically results from its own time step solution and embedding), and that +the fast integrator itself is temporally adaptive. In this case, we assume that the +fast integrator was run with the same absolute tolerances as the slow integrator, but +that it may have used a potentially different relative solution tolerance, +:math:`\text{reltol}^f`. The fast integrator then accumulates these local error +estimates using either a "maximum accumulation: strategy, .. math:: \varepsilon^f_{max} = \text{reltol}^f \max_{m\in M} \|\varepsilon^f_{n,m}\|_{WRMS}, @@ -1132,23 +1121,6 @@ where the norm is taken using the tolerance-informed error-weight vector. In both cases, the sum or the maximum is taken over the set of all steps :math:`M` since the fast error accumulator has been reset. -The third, "full step accumulation," approach for fast error estimation uses -fixed time steps of size :math:`h^F` and :math:`2h^F` to achieve fast solutions -:math:`y_{h^f}^f` and :math:`y_{sh^f}^f`, which it then subtracts to estimate -the fast temporal error - -.. math:: - \varepsilon^f_{full} = \text{reltol}^f \|y_h^f - y_{2h}^f\|_{WRMS}. - :label: full_step_accumulation - - -We note here that the factor "2" is the default for the full step accumulation -strategy, but alternate values may be specified by the user. -Here, although the fast integrator is run using fixed step sizes, it is still -provided with appropriate relative and absolute tolerances, as these are used -when determining implicit algebraic solver norms and tolerances within the fast -integrator. - diff --git a/doc/arkode/guide/source/Usage/ARKStep/User_callable.rst b/doc/arkode/guide/source/Usage/ARKStep/User_callable.rst index 5a21f7ea15..a5589a9cdc 100644 --- a/doc/arkode/guide/source/Usage/ARKStep/User_callable.rst +++ b/doc/arkode/guide/source/Usage/ARKStep/User_callable.rst @@ -4396,7 +4396,7 @@ wrap an ARKStep memory block as an :c:type:`MRIStepInnerStepper`. /* create an MRIStep object, setting the slow (outer) right-hand side functions and the initial condition */ - outer_arkode_mem = MRIStepCreate(fse, fsi, t0, y0, stepper, sunctx) + outer_arkode_mem = MRIStepCreate(fse, fsi, t0, y0, stepper, sunctx); **Example codes:** * ``examples/arkode/CXX_parallel/ark_diffusion_reaction_p.cpp`` diff --git a/doc/arkode/guide/source/Usage/MRIStep/Custom_Inner_Stepper/Description.rst b/doc/arkode/guide/source/Usage/MRIStep/Custom_Inner_Stepper/Description.rst index 9cabb9a79f..96495dd8ae 100644 --- a/doc/arkode/guide/source/Usage/MRIStep/Custom_Inner_Stepper/Description.rst +++ b/doc/arkode/guide/source/Usage/MRIStep/Custom_Inner_Stepper/Description.rst @@ -264,24 +264,6 @@ Setting Member Functions /* set the inner stepper accumulated error 'reset' function */ flag = MRIStepInnerStepper_SetAccumulatedErrorResetFn(inner_stepper, MyResetAccumErr); -.. c:function:: int MRIStepInnerStepper_SetFixedStepFn(MRIStepInnerStepper stepper, MRIStepInnerSetFixedStep fn) - - This function attaches an :c:type:`MRIStepInnerSetFixedStep` function to an - :c:type:`MRIStepInnerStepper` object. - - :param stepper: an inner stepper object. - :param fn: the :c:type:`MRIStepInnerSetFixedStep` function to attach. - - :retval ARK_SUCCESS: if successful - :retval ARK_ILL_INPUT: if the stepper is ``NULL`` - - **Example usage:** - - .. code-block:: C - - /* set the inner stepper fixed step size function */ - flag = MRIStepInnerStepper_SetFixedStep(inner_stepper, MySetFixedStep); - .. c:function:: int MRIStepInnerStepper_SetRTolFn(MRIStepInnerStepper stepper, MRIStepInnerSetRTol fn) This function attaches an :c:type:`MRIStepInnerSetRTol` function to an @@ -539,24 +521,6 @@ following member functions: assumptions about the frequency/ordering of calls to either. -.. c:type:: int (*MRIStepInnerSetFixedStep)(MRIStepInnerStepper stepper, sunrealtype h) - - This function accepts a fixed step size for the inner stepper to use. - - **Arguments:** - * *stepper* -- the inner stepper object. - * *h* -- fixed step size to use on the upcoming solve. - - **Return value:** - An :c:type:`MRIStepInnerSetFixedStep` should return 0 if successful, a positive - value if a recoverable error occurred, or a negative value if it failed - unrecoverably. - - **Notes:** - This function is only called when multirate temporal adaptivity has been enabled - using a :c:type:`SUNAdaptController` module having type ``SUNDIALS_CONTROL_MRI_H``. - - .. c:type:: int (*MRIStepInnerSetRTol)(MRIStepInnerStepper stepper, sunrealtype rtol) This function accepts a relative tolerance for the inner stepper to use in its upcoming adaptive solve. diff --git a/doc/arkode/guide/source/Usage/MRIStep/Custom_Inner_Stepper/index.rst b/doc/arkode/guide/source/Usage/MRIStep/Custom_Inner_Stepper/index.rst index 22a3fcda7c..f1ffa424d3 100644 --- a/doc/arkode/guide/source/Usage/MRIStep/Custom_Inner_Stepper/index.rst +++ b/doc/arkode/guide/source/Usage/MRIStep/Custom_Inner_Stepper/index.rst @@ -17,15 +17,15 @@ MRIStep Custom Inner Steppers ============================= -Recall that MIS, MRI-GARK, and IMEX-MRI-GARK methods require solving a set of auxiliary IVPs +Recall that infinitesimal multirate methods require solving a set of auxiliary IVPs .. math:: \dot{v}(t) = f^F(t, v) + r_i(t), \qquad v(t_{i,0}) = v_{i,0}, :label: ARKODE_MRI_IVP -on intervals :math:`t \in [t_{i,0}, t_{i,f}]`. For MIS, MRI-GARK and IMEX-MRI-GARK methods, -the forcing term :math:`r_i(t)` presented in :numref:`ARKODE.Mathematics.MRIStep` can be -equivalently written as +on intervals :math:`t \in [t_{i,0}, t_{i,f}]`. For the MIS, MRI-GARK and IMEX-MRI-GARK +methods implemented in MRIStep, the forcing term :math:`r_i(t)` +presented in :numref:`ARKODE.Mathematics.MRIStep` can be equivalently written as .. math:: r_i(t) = @@ -47,6 +47,11 @@ vectors are \gamma^{\{k\}}_{i,j} f^I(t_{n,j}^S, z_j). :label: ARKODE_MRI_forcing_coefficients +The MERK and IMEX-MRI-SR methods included in MRIStep compute the forcing polynomial +:eq:`ARKODE_MRI_forcing_poly` similarly, with appropriate modifications to +:math:`\Delta c_i^S`, :math:`t_{n,i-1}^S`, and the coefficients +:eq:`ARKODE_MRI_forcing_coefficients`. + To evolve the IVP :eq:`ARKODE_MRI_IVP` MRIStep utilizes a generic time integrator interface defined by the :c:type:`MRIStepInnerStepper` base class. This section presents the :c:type:`MRIStepInnerStepper` base class and methods that define diff --git a/doc/arkode/guide/source/Usage/MRIStep/User_callable.rst b/doc/arkode/guide/source/Usage/MRIStep/User_callable.rst index b64b17d424..0ca2251539 100644 --- a/doc/arkode/guide/source/Usage/MRIStep/User_callable.rst +++ b/doc/arkode/guide/source/Usage/MRIStep/User_callable.rst @@ -23,7 +23,7 @@ by the user to setup and then solve an IVP using the MRIStep time-stepping module. The large majority of these routines merely wrap :ref:`underlying ARKODE functions `, and are now deprecated -- each of these are clearly marked. However, some -of these user-callable functions are specific to ERKStep, as explained +of these user-callable functions are specific to MRIStep, as explained below. As discussed in the main :ref:`ARKODE user-callable function introduction @@ -31,6 +31,7 @@ As discussed in the main :ref:`ARKODE user-callable function introduction clarifies the categories of user-callable functions that it supports. MRIStep supports the following categories: +* temporal adaptivity * implicit nonlinear and/or linear solvers @@ -192,14 +193,11 @@ For the simplest form of multirate temporal adaptivity, corresponding to controller to MRIStep using the :c:func:`ARKodeSetAdaptController` function. The time step controller for the inner integrator may be specified independently. -However, specification of either the :math:`h^S-h^F` or :math:`h^S-Tol` types of -multirate controllers requires additional steps. - -First, a SUNAdaptController with :c:type:`SUNAdaptController_Type` type either -``SUN_ADAPTCONTROLLER_MRI_H`` or ``SUN_ADAPTCONTROLLER_MRI_TOL`` should be -constructed, following the documentation in Section :numref:`SUNAdaptController`. -This controller should then be passed as an input to the MRIStep function -:c:func:`MRIStepSetAdaptController`, as follows. +However, specification of the :math:`h^S-Tol` type of multirate controller requires +an additional step. First, a SUNAdaptController with :c:type:`SUNAdaptController_Type` type +``SUN_ADAPTCONTROLLER_MRI_TOL`` should be constructed, following the documentation in +Section :numref:`SUNAdaptController.MRIHTol`. This controller should then be passed as an +input to the MRIStep function :c:func:`MRIStepSetAdaptController`, as follows. .. c:function:: int MRIStepSetAdaptController(void* arkode_mem, SUNAdaptController C) @@ -217,10 +215,9 @@ This controller should then be passed as an input to the MRIStep function .. note:: - If the input *C* has :c:type:`SUNAdaptController_Type` type ``SUN_ADAPTCONTROLLER_MRI_H`` - or ``SUN_ADAPTCONTROLLER_MRI_TOL`` then this creates an MRIStep-specific adaptivity - controller that couples the slow and fast time scales, and that leverages *C* to perform - multirate temporal adaptivity. + If the input *C* has :c:type:`SUNAdaptController_Type` type ``SUN_ADAPTCONTROLLER_MRI_TOL`` + then this creates an MRIStep-specific adaptivity controller that couples the slow and fast + time scales, and that leverages *C* to perform multirate temporal adaptivity. If *C* has :c:type:`SUNAdaptController_Type` type ``SUN_ADAPTCONTROLLER_H`` or ``SUN_ADAPTCONTROLLER_NONE`` then this routine merely passes *C* to the ARKODE-level @@ -229,46 +226,6 @@ This controller should then be passed as an input to the MRIStep function .. versionadded:: x.y.z -Second, if the multirate controller had type ``SUN_ADAPTCONTROLLER_MRI_H``, then fast time -scale error will be estimated using the "full step accumulation" strategy described in -Section :numref:`ARKODE.Mathematics.MultirateFastError`, where by default the fast integrator -is called with step sizes :math:`h^F` and :math:`2h^F`. If the user wishes to adjust the -factor "2" to something else, they may call the function :c:func:`MRIStepSetFastErrorStepFactor`, -as follows. - -.. c:function:: int MRIStepSetFastErrorStepFactor(void* arkode_mem, sunrealtype hfactor) - - This function specifies a time step factor - - If this value is nonzero and MRI temporal adaptivity is enabled, then MRIStep will - compute the fast temporal error using the "full step accumulation" stragegy (see - Section :numref:`ARKODE.Mathematics.MultirateFastError`). Here, the fast integrator - is run twice over each fast time interval, once using the inner step size ``h``, and - again using ``hfactor*h`` (typically ``hfactor`` will be either :math:`k` or - :math:`1/k` for an integer :math:`k>1`). This routine should only be used when the - results from the fast-integrator-provided :c:type:`MRIStepInnerGetAccumulatedError` - cannot be trusted. In testing, we found this to be the case when the inner integrator - uses fixed step sizes. - - An argument of 0 disables this fast error estimation strategy. - Arguments less than zero or exactly equal to one are illegal. - All other positive ``hfactor`` values will *attempt* to be used. - - :param arkode_mem: pointer to the MRIStep memory block. - :param hfactor: user-supplied fast stepsize factor. - - :retval ARK_SUCCESS: the function exited successfully. - :retval ARK_MEM_NULL: ``arkode_mem`` was ``NULL``. - :retval ARK_ILL_INPUT: the value of ``hfactor`` was illegal. - - .. note:: - - This routine should only be called directly when using a "multirate" - :c:type:`SUNAdaptController` of type ``SUN_ADAPTCONTROLLER_MRI_H``. - - .. versionadded:: x.y.z - - .. _ARKODE.Usage.MRIStep.LinearSolvers: @@ -2652,3 +2609,70 @@ MRIStep system resize function .. deprecated:: 6.1.0 Use :c:func:`ARKodeResize` instead. + + + + +.. _ARKStep_CInterface.MRIStepInterface: + +Nested multirate calculations +----------------------------- + +It is possible to use MRIStep as an inner integrator within a slower time scale +MRIStep integration, thereby allowing for nested multirate calculations with more than +two time scales. Here, the inner MRIStep integrator can be wrapped as an +:c:type:`MRIStepInnerStepper` by calling the utility function +:c:func:`MRIStepCreateMRIStepInnerStepper`. + +.. c:function:: int MRIStepCreateMRIStepInnerStepper(void *inner_arkode_mem, MRIStepInnerStepper *stepper) + + Wraps an MRIStep memory block as an :c:type:`MRIStepInnerStepper` for use + with an outer MRIStep instance. + + **Arguments:** + * *arkode_mem* -- pointer to the inner MRIStep memory block. + * *stepper* -- the :c:type:`MRIStepInnerStepper` object. + + **Return value:** + * *ARK_SUCCESS* if successful + * *ARK_MEM_FAIL* if a memory allocation failed + * *ARK_ILL_INPUT* if an argument has an illegal value. + + **Example usage:** + .. code-block:: C + + /* fast, intermediate, and slow ARKODE objects */ + void *fast_arkode_mem = NULL; + void *mid_arkode_mem = NULL; + void *outer_arkode_mem = NULL; + + /* MRIStepInnerSteppers to wrap the fast ARKStep and intermediate MRIStep objects */ + MRIStepInnerStepper faststepper = NULL; + MRIStepInnerStepper midstepper = NULL; + + /* create an ARKStep object, setting fast (inner) right-hand side + functions and the initial condition */ + fast_arkode_mem = ARKStepCreate(ffe, ffi, t0, y0, sunctx); + + /* setup ARKStep */ + . . . + + /* create MRIStepInnerStepper wrapper for the ARKStep memory block */ + flag = ARKStepCreateMRIStepInnerStepper(fast_arkode_mem, &faststepper); + + /* create an MRIStep object, setting the intermediate right-hand side + functions and the initial condition */ + mid_arkode_mem = MRIStepCreate(fme, fmi, t0, y0, faststepper, sunctx); + + /* setup MRIStep */ + . . . + + /* create MRIStepInnerStepper wrapper for the MRIStep memory block */ + flag = MRIStepCreateMRIStepInnerStepper(mid_arkode_mem, &midstepper); + + /* create an MRIStep object, setting the slow (outer) right-hand side + functions and the initial condition */ + outer_arkode_mem = MRIStepCreate(fse, fsi, t0, y0, midstepper, sunctx); + + **Example codes:** + * ``examples/arkode/CXX_serial/ark_test_kpr_nestedmri.cpp`` diff --git a/doc/arkode/guide/source/Usage/User_callable.rst b/doc/arkode/guide/source/Usage/User_callable.rst index 0b72f94a50..cc335a58c4 100644 --- a/doc/arkode/guide/source/Usage/User_callable.rst +++ b/doc/arkode/guide/source/Usage/User_callable.rst @@ -1422,7 +1422,7 @@ Maximum first step growth factor :c:func:`ARKodeSetMa Maximum allowed general step growth factor :c:func:`ARKodeSetMaxGrowth` 20.0 Minimum allowed step reduction factor on error test fail :c:func:`ARKodeSetMinReduction` 0.1 Time step safety factor :c:func:`ARKodeSetSafetyFactor` 0.96 -Error fails before MaxEFailGrowth takes effect :c:func:`ARKodeSetSmallNumEFails` 2 +Error fails before ``MaxEFailGrowth`` takes effect :c:func:`ARKodeSetSmallNumEFails` 2 Explicit stability function :c:func:`ARKodeSetStabilityFn` none Set accumulated error estimation type :c:func:`ARKodeSetAccumulatedErrorType` none Reset accumulated error :c:func:`ARKodeResetAccumulatedError` diff --git a/doc/arkode/guide/source/sunadaptcontroller/SUNAdaptController_links.rst b/doc/arkode/guide/source/sunadaptcontroller/SUNAdaptController_links.rst index 7e1ec4d919..9c90434a0c 100644 --- a/doc/arkode/guide/source/sunadaptcontroller/SUNAdaptController_links.rst +++ b/doc/arkode/guide/source/sunadaptcontroller/SUNAdaptController_links.rst @@ -14,7 +14,3 @@ .. include:: ../../../../shared/sunadaptcontroller/SUNAdaptController_Soderlind.rst .. include:: ../../../../shared/sunadaptcontroller/SUNAdaptController_ImExGus.rst .. include:: ../../../../shared/sunadaptcontroller/SUNAdaptController_MRIHTol.rst -.. include:: ../../../../shared/sunadaptcontroller/SUNAdaptController_MRICC.rst -.. include:: ../../../../shared/sunadaptcontroller/SUNAdaptController_MRILL.rst -.. include:: ../../../../shared/sunadaptcontroller/SUNAdaptController_MRIPI.rst -.. include:: ../../../../shared/sunadaptcontroller/SUNAdaptController_MRIPID.rst diff --git a/doc/shared/sunadaptcontroller/SUNAdaptController_Description.rst b/doc/shared/sunadaptcontroller/SUNAdaptController_Description.rst index 971d231dca..3ac3add4e6 100644 --- a/doc/shared/sunadaptcontroller/SUNAdaptController_Description.rst +++ b/doc/shared/sunadaptcontroller/SUNAdaptController_Description.rst @@ -81,10 +81,6 @@ The virtual table structure is defined as The function implementing :c:func:`SUNAdaptController_EstimateStep` - .. c:member:: SUNErrCode (*estimatemristeps)(SUNAdaptController C, sunrealtype H, sunrealtype h, int P, sunrealtype DSM, sunrealtype dsm, sunrealtype* Hnew, sunrealtype* hnew) - - The function implementing :c:func:`SUNAdaptController_EstimateMRISteps` - .. c:member:: SUNErrCode (*estimatesteptol)(SUNAdaptController C, sunrealtype H, sunrealtype tolfac, int P, sunrealtype DSM, sunrealtype dsm, sunrealtype* Hnew, sunrealtype* tolfacnew) The function implementing :c:func:`SUNAdaptController_EstimateStepTol` @@ -109,10 +105,6 @@ The virtual table structure is defined as The function implementing :c:func:`SUNAdaptController_UpdateH` - .. c:member:: SUNErrCode (*updatemrih)(SUNAdaptController C, sunrealtype H, sunrealtype h, sunrealtype DSM, sunrealtype dsm) - - The function implementing :c:func:`SUNAdaptController_UpdateMRIH` - .. c:member:: SUNErrCode (*updatemritol)(SUNAdaptController C, sunrealtype H, sunrealtype tolfac, sunrealtype DSM, sunrealtype dsm) The function implementing :c:func:`SUNAdaptController_UpdateMRITol` @@ -146,11 +138,6 @@ following set of SUNAdaptController types: Controls a single-rate step size. -.. c:enumerator:: SUN_ADAPTCONTROLLER_MRI_H - - Controls both slow and fast time steps within a multirate simulation that has - two time scales. - .. c:enumerator:: SUN_ADAPTCONTROLLER_MRI_TOL Controls both a slow time step and a tolerance factor to apply on the next-faster @@ -253,29 +240,6 @@ note these requirements below. Additionally, we note the behavior of the base SU retval = SUNAdaptController_EstimateStep(C, hcur, p, dsm, &hnew); -.. c:function:: SUNErrCode SUNAdaptController_EstimateMRISteps(SUNAdaptController C, sunrealtype H, sunrealtype h, int P, sunrealtype DSM, sunrealtype dsm, sunrealtype* Hnew, sunrealtype* hnew) - - Estimates slow and fast step sizes within a two-time-scale multirate application. - This routine is required for controllers of type ``SUN_ADAPTCONTROLLER_MRI_H``. - If this is not provided by the implementation, the base class method will set - ``*Hnew = H`` and ``*hnew = h`` and return. - - :param C: the :c:type:`SUNAdaptController` object. - :param H: the slow step size from the previous step attempt. - :param h: the fast size from the previous step attempt. - :param P: the current order of accuracy for the slow time scale integration method. - :param DSM: the slow time scale local temporal estimate from the previous step attempt. - :param dsm: the fast time scale local temporal estimate from the previous step attempt. - :param Hnew: (output) the estimated slow step size. - :param hnew: (output) the estimated fast step size. - :return: :c:type:`SUNErrCode` indicating success or failure. - - Usage: - - .. code-block:: c - - retval = SUNAdaptController_EstimateMRISteps(C, Hcur, hcur, P, DSM, dsm, &Hnew, &hnew); - .. c:function:: SUNErrCode SUNAdaptController_EstimateStepTol(SUNAdaptController C, sunrealtype H, sunrealtype tolfac, int P, sunrealtype DSM, sunrealtype dsm, sunrealtype* Hnew, sunrealtype* tolfacnew) Estimates a slow step size and a fast tolerance multiplication factor @@ -382,27 +346,6 @@ note these requirements below. Additionally, we note the behavior of the base SU retval = SUNAdaptController_UpdateH(C, h, dsm); -.. c:function:: SUNErrCode SUNAdaptController_UpdateMRIH(SUNAdaptController C, sunrealtype H, sunrealtype h, sunrealtype DSM, sunrealtype dsm) - - Notifies a controller of type ``SUN_ADAPTCONTROLLER_MRI_H`` that a successful time step - was taken with slow stepsize *H* and fast stepsize *h*, and that the step had slow and - fast local error factors *DSM* and *dsm*, indicating that these can be saved for - subsequent controller functions. This is typically relevant for controllers that store a - history of either step sizes or error estimates for performing the estimation process. - - :param C: the :c:type:`SUNAdaptController` object. - :param H: the successful 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: :c:type:`SUNErrCode` indicating success or failure. - - Usage: - - .. code-block:: c - - retval = SUNAdaptController_UpdateMRIH(C, H, h, DSM, dsm); - .. c:function:: SUNErrCode SUNAdaptController_UpdateMRITol(SUNAdaptController C, sunrealtype H, sunrealtype tolfac, sunrealtype DSM, sunrealtype dsm) Notifies a controller of type ``SUN_ADAPTCONTROLLER_MRI_TOL`` that a successful time step diff --git a/doc/shared/sunadaptcontroller/SUNAdaptController_MRICC.rst b/doc/shared/sunadaptcontroller/SUNAdaptController_MRICC.rst deleted file mode 100644 index fe91617e58..0000000000 --- a/doc/shared/sunadaptcontroller/SUNAdaptController_MRICC.rst +++ /dev/null @@ -1,102 +0,0 @@ -.. - Programmer(s): Daniel R. Reynolds @ SMU - ---------------------------------------------------------------- - SUNDIALS Copyright Start - Copyright (c) 2002-2024, 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.MRICC: - -The SUNAdaptController_MRICC Module -======================================= - -.. versionadded:: x.y.z - -The MRICC implementation of the SUNAdaptController class, -SUNAdaptController_MRICC, implements the "constant-constant" multirate temporal -controller proposed in :cite:p:`Fish:23`. This controller has the form - -.. math:: - H' &= H_n \left(\varepsilon^s_n\right)^{\alpha},\\ - M' &= \left\lceil\frac{H_n}{h_n}\right\rceil \left(\varepsilon^s_n\right)^{\beta_1} \left(\varepsilon^f_n\right)^{\beta_2},\\ - h' &= H'/M' - -where :math:`\alpha = \frac{k_1}{P}`, :math:`\beta_1 = \frac{(p+1)k_1}{Pp}`, and -:math:`\beta_2 = -\frac{k_2}{p}`, and where :math:`P` and :math:`p` are the global -orders of accuracy for the slow and fast time integration methods, respectively. -The default parameter values are :math:`k_1 = 0.42` and :math:`k_2 = 0.44`. In -these estimate, a floor of :math:`\varepsilon^*_* > 10\epsilon_{mach}` is enforced -to avoid division-by-zero errors, where :math:`\epsilon_{mach}` is floating point -roundoff for the current working precision. - -The SUNAdaptController_MRICC controller is implemented as a derived -SUNAdaptController class having type ``SUN_ADAPTCONTROLLER_MRI_H``, and its -*content* field is: - -.. code-block:: c - - struct _SUNAdaptControllerContent_MRICC { - sunrealtype k1; - sunrealtype k2; - sunrealtype bias; - int p; - }; - -These entries of the *content* field contain the following information: - -* ``k1, k2`` - controller parameters above. - -* ``bias`` - error bias factor, that converts from input temporal error - estimates via :math:`\varepsilon^s = \text{bias}*\text{DSM}` and - :math:`\varepsilon^f = \text{bias}*\text{dsm}`. The default bias value is 1.5. - -* ``p`` - global order of accuracy for the fast time scale solver. - -The header file to be included when using this module is -``sunadaptcontroller/sunadaptcontroller_mricc.h``. - -The SUNAdaptController_MRICC class provides implementations of all operations -relevant to a ``SUN_ADAPTCONTROLLER_MRI_H`` controller listed in -:numref:`SUNAdaptController.Description.operations`. This class -also provides the following additional user-callable routines: - - -.. c:function:: SUNAdaptController SUNAdaptController_MRICC(SUNContext sunctx, int p) - - This constructor creates and allocates memory for a SUNAdaptController_MRICC - object, and inserts its default parameters. - - :param sunctx: the current :c:type:`SUNContext` object. - :param p: the global order of accuracy for the fast time scale solver. - :return: if successful, a usable :c:type:`SUNAdaptController` object; - otherwise it will return ``NULL``. - - Usage: - - .. code-block:: c - - SUNAdaptController C = SUNAdaptController_MRICC(sunctx, 3); - -.. c:function:: SUNErrCode SUNAdaptController_SetParams_MRICC(SUNAdaptController C, sunrealtype k1, sunrealtype k2) - - This user-callable function provides control over the relevant parameters - above. This should be called *before* the time integrator is called to evolve - the problem. - - :param C: the SUNAdaptController_MRICC object. - :param k1: parameter used within the controller time step estimate. - :param k2: parameter used within the controller time step estimate. - :return: :c:type:`SUNErrCode` indicating success or failure. - - Usage: - - .. code-block:: c - - retval = SUNAdaptController_SetParams_MRICC(C, 0.42, 0.44); diff --git a/doc/shared/sunadaptcontroller/SUNAdaptController_MRILL.rst b/doc/shared/sunadaptcontroller/SUNAdaptController_MRILL.rst deleted file mode 100644 index 13d2de9428..0000000000 --- a/doc/shared/sunadaptcontroller/SUNAdaptController_MRILL.rst +++ /dev/null @@ -1,131 +0,0 @@ -.. - Programmer(s): Daniel R. Reynolds @ SMU - ---------------------------------------------------------------- - SUNDIALS Copyright Start - Copyright (c) 2002-2024, 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.MRILL: - -The SUNAdaptController_MRILL Module -======================================= - -.. versionadded:: x.y.z - -The MRILL implementation of the SUNAdaptController class, -SUNAdaptController_MRILL, implements the "linear-linear" multirate temporal -controller proposed in :cite:p:`Fish:23`. This controller has the form - -.. math:: - H' &= H_n \left(\frac{H_n}{H_{n-1}}\right) \left(\varepsilon^s_n\right)^{\alpha_1} \left(\varepsilon^s_{n-1}\right)^{\alpha_2},\\ - M' &= M_n \left(\frac{M_n}{M_{n-1}}\right) \left(\varepsilon^s_n\right)^{\beta_{11}} \left(\varepsilon^s_{n-1}\right)^{\beta_{12}} \left(\varepsilon^f_n\right)^{\beta_{21}} \left(\varepsilon^f_{n-1}\right)^{\beta_{22}},\\ - h' &= H'/M' - -where :math:`M_n = \left\lceil\frac{H_n}{h_n}\right\rceil`, -:math:`M_{n-1} = \left\lceil\frac{H_{n-1}}{h_{n-1}}\right\rceil`, -:math:`\alpha_1 = \frac{k_{11}+k_{12}}{2P}`, :math:`\alpha_2 = -\frac{k_{11}}{2P}`, -:math:`\beta_{11} = \frac{(p+1)(k_{11}+k_{12})}{2Pp}`, -:math:`\beta_{12} = -\frac{(p+1)k_{11}}{2Pp}`, -:math:`\beta_{21} = -\frac{k_{21}+k_{22}}{2p}`, and -:math:`\beta_{22} = \frac{k_{21}}{2p}`, and where :math:`P` and :math:`p` are the global -orders of accuracy for the slow and fast time integration methods, respectively. -The default parameter values are :math:`k_{11} = 0.82`, :math:`k_{12} = 0.54`, -:math:`k_{21} = 0.94` and :math:`k_{22} = 0.9`. In these estimate, a floor of -:math:`\varepsilon^*_* > 10\epsilon_{mach}` is enforced to avoid division-by-zero errors, -where :math:`\epsilon_{mach}` is floating point roundoff for the current working precision. -During the first step (when :math:`\varepsilon^s_{n-1}`, -:math:`\varepsilon^f_{n-1}`, :math:`H_{n-1}`, and :math:`h_{n-1}` are unavailable), -the corresponding temporal errors and step size and multirate ratios, -:math:`\varepsilon^s_{n-1}`, :math:`\varepsilon^f_{n-1}`, -:math:`\left(\frac{H_n}{H_{n-1}}\right)` and :math:`\left(\frac{M_n}{M_{n-1}}\right)`, are -set to 1, effectively removing them from the estimation formula. - -The SUNAdaptController_MRILL controller is implemented as a derived -SUNAdaptController class having type ``SUN_ADAPTCONTROLLER_MRI_H``, and its -*content* field is: - -.. code-block:: c - - struct _SUNAdaptControllerContent_MRILL { - sunrealtype k11; - sunrealtype k12; - sunrealtype k21; - sunrealtype k22; - sunrealtype bias; - sunrealtype esp; - sunrealtype efp; - sunrealtype hsp; - sunrealtype hfp; - int p; - sunbooleantype firststep; - }; - -These entries of the *content* field contain the following information: - -* ``k11, k12, k21, k22`` - controller parameters above. - -* ``bias`` - error bias factor, that converts from input temporal error - estimates via :math:`\varepsilon^s = \text{bias}*\text{DSM}` and - :math:`\varepsilon^f = \text{bias}*\text{dsm}`. The default bias value is 1.5. - -* ``esp, efp`` - storage for the previous slow and fast error estimates, - :math:`\varepsilon^s_{n-1}` and :math:`\varepsilon^f_{n-1}`. - -* ``hsp, hfp`` - storage for the previous slow and fast step sizes, :math:`H_{n-1}` - and :math:`h_{n-1}`. - -* ``p`` - global order of accuracy for the fast time scale solver. - -* ``firststep`` - counter to handle first (where the previous step - sizes and errors are unavailable). - -The header file to be included when using this module is -``sunadaptcontroller/sunadaptcontroller_mrill.h``. - -The SUNAdaptController_MRILL class provides implementations of all operations -relevant to a ``SUN_ADAPTCONTROLLER_MRI_H`` controller listed in -:numref:`SUNAdaptController.Description.operations`. This class -also provides the following additional user-callable routines: - - -.. c:function:: SUNAdaptController SUNAdaptController_MRILL(SUNContext sunctx, int p) - - This constructor creates and allocates memory for a SUNAdaptController_MRILL - object, and inserts its default parameters. - - :param sunctx: the current :c:type:`SUNContext` object. - :param p: the global order of accuracy for the fast time scale solver. - :return: if successful, a usable :c:type:`SUNAdaptController` object; - otherwise it will return ``NULL``. - - Usage: - - .. code-block:: c - - SUNAdaptController C = SUNAdaptController_MRILL(sunctx, 3); - -.. c:function:: SUNErrCode SUNAdaptController_SetParams_MRILL(SUNAdaptController C, sunrealtype k11, sunrealtype k12, sunrealtype k21, sunrealtype k22) - - 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_MRILL object. - :param k11: parameter used within the controller time step estimate. - :param k12: parameter used within the controller time step estimate. - :param k21: parameter used within the controller time step estimate. - :param k22: parameter used within the controller time step estimate. - :return: :c:type:`SUNErrCode` indicating success or failure. - - Usage: - - .. code-block:: c - - retval = SUNAdaptController_SetParams_MRILL(C, 0.82, 0.54, 0.94, 0.9); diff --git a/doc/shared/sunadaptcontroller/SUNAdaptController_MRIPI.rst b/doc/shared/sunadaptcontroller/SUNAdaptController_MRIPI.rst deleted file mode 100644 index e46db95bbb..0000000000 --- a/doc/shared/sunadaptcontroller/SUNAdaptController_MRIPI.rst +++ /dev/null @@ -1,119 +0,0 @@ -.. - Programmer(s): Daniel R. Reynolds @ SMU - ---------------------------------------------------------------- - SUNDIALS Copyright Start - Copyright (c) 2002-2024, 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.MRIPI: - -The SUNAdaptController_MRIPI Module -======================================= - -.. versionadded:: x.y.z - -The MRIPI implementation of the SUNAdaptController class, -SUNAdaptController_MRIPI, implements the "PIMR" multirate temporal -controller proposed in :cite:p:`Fish:23`. This controller has the form - -.. math:: - H' &= H_n \left(\varepsilon^s_n\right)^{\alpha_1} \left(\varepsilon^s_{n-1}\right)^{\alpha_2},\\ - M' &= M_n \left(\varepsilon^s_n\right)^{\beta_{11}} \left(\varepsilon^s_{n-1}\right)^{\beta_{12}} \left(\varepsilon^f_n\right)^{\beta_{21}} \left(\varepsilon^f_{n-1}\right)^{\beta_{22}},\\ - h' &= H'/M' - -where :math:`M_n = \left\lceil\frac{H_n}{h_n}\right\rceil`, -:math:`\alpha_1 = \frac{k_{11}+k_{12}}{2P}`, :math:`\alpha_2 = -\frac{k_{11}}{2P}`, -:math:`\beta_{11} = \frac{(p+1)(k_{11}+k_{12})}{2Pp}`, -:math:`\beta_{12} = -\frac{(p+1)k_{11}}{2Pp}`, -:math:`\beta_{21} = -\frac{k_{21}+k_{22}}{2p}`, and -:math:`\beta_{22} = \frac{k_{21}}{2p}`, and where :math:`P` and :math:`p` are the global -orders of accuracy for the slow and fast time integration methods, respectively. -The default parameter values are :math:`k_{11} = 0.18`, :math:`k_{12} = 0.86`, -:math:`k_{21} = 0.34` and :math:`k_{22} = 0.8`. In these estimate, a floor of -:math:`\varepsilon^*_* > 10\epsilon_{mach}` is enforced to avoid division-by-zero errors, -where :math:`\epsilon_{mach}` is floating point roundoff for the current working precision. -During the first step (when :math:`\varepsilon^s_{n-1}`, -:math:`\varepsilon^f_{n-1}` are unavailable), -the corresponding temporal errors :math:`\varepsilon^s_{n-1}` and :math:`\varepsilon^f_{n-1}` are -set to 1, effectively removing them from the estimation formula. - -The SUNAdaptController_MRIPI controller is implemented as a derived -SUNAdaptController class having type ``SUN_ADAPTCONTROLLER_MRI_H``, and its -*content* field is: - -.. code-block:: c - - struct _SUNAdaptControllerContent_MRIPI { - sunrealtype k11; - sunrealtype k12; - sunrealtype k21; - sunrealtype k22; - sunrealtype bias; - sunrealtype esp; - sunrealtype efp; - int p; - }; - -These entries of the *content* field contain the following information: - -* ``k11, k12, k21, k22`` - controller parameters above. - -* ``bias`` - error bias factor, that converts from input temporal error - estimates via :math:`\varepsilon^s = \text{bias}*\text{DSM}` and - :math:`\varepsilon^f = \text{bias}*\text{dsm}`. The default bias value is 1.5. - -* ``esp, efp`` - storage for the previous slow and fast error estimates, - :math:`\varepsilon^s_{n-1}` and :math:`\varepsilon^f_{n-1}`. - -* ``p`` - global order of accuracy for the fast time scale solver. - -The header file to be included when using this module is -``sunadaptcontroller/sunadaptcontroller_mripi.h``. - -The SUNAdaptController_MRIPI class provides implementations of all operations -relevant to a ``SUN_ADAPTCONTROLLER_MRI_H`` controller listed in -:numref:`SUNAdaptController.Description.operations`. This class -also provides the following additional user-callable routines: - - -.. c:function:: SUNAdaptController SUNAdaptController_MRIPI(SUNContext sunctx, int p) - - This constructor creates and allocates memory for a SUNAdaptController_MRIPI - object, and inserts its default parameters. - - :param sunctx: the current :c:type:`SUNContext` object. - :param p: the global order of accuracy for the fast time scale solver. - :return: if successful, a usable :c:type:`SUNAdaptController` object; - otherwise it will return ``NULL``. - - Usage: - - .. code-block:: c - - SUNAdaptController C = SUNAdaptController_MRIPI(sunctx, 3); - -.. c:function:: SUNErrCode SUNAdaptController_SetParams_MRIPI(SUNAdaptController C, sunrealtype k11, sunrealtype k12, sunrealtype k21, sunrealtype k22) - - 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_MRIPI object. - :param k11: parameter used within the controller time step estimate. - :param k12: parameter used within the controller time step estimate. - :param k21: parameter used within the controller time step estimate. - :param k22: parameter used within the controller time step estimate. - :return: :c:type:`SUNErrCode` indicating success or failure. - - Usage: - - .. code-block:: c - - retval = SUNAdaptController_SetParams_MRIPI(C, 0.18, 0.86, 0.34, 0.9); diff --git a/doc/shared/sunadaptcontroller/SUNAdaptController_MRIPID.rst b/doc/shared/sunadaptcontroller/SUNAdaptController_MRIPID.rst deleted file mode 100644 index 2de4884f08..0000000000 --- a/doc/shared/sunadaptcontroller/SUNAdaptController_MRIPID.rst +++ /dev/null @@ -1,130 +0,0 @@ -.. - Programmer(s): Daniel R. Reynolds @ SMU - ---------------------------------------------------------------- - SUNDIALS Copyright Start - Copyright (c) 2002-2024, 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.MRIPID: - -The SUNAdaptController_MRIPID Module -======================================= - -.. versionadded:: x.y.z - -The MRIPID implementation of the SUNAdaptController class, -SUNAdaptController_MRIPID, implements the "PIDMR" multirate temporal -controller proposed in :cite:p:`Fish:23`. This controller has the form - -.. math:: - H' &= H_n \left(\varepsilon^s_n\right)^{\alpha_1} \left(\varepsilon^s_{n-1}\right)^{\alpha_2} \left(\varepsilon^s_{n-2}\right)^{\alpha_3},\\ - M' &= M_n \left(\varepsilon^s_n\right)^{\beta_{11}} \left(\varepsilon^s_{n-1}\right)^{\beta_{12}} \left(\varepsilon^s_{n-2}\right)^{\beta_{13}} \left(\varepsilon^f_n\right)^{\beta_{21}} \left(\varepsilon^f_{n-1}\right)^{\beta_{22}} \left(\varepsilon^f_{n-2}\right)^{\beta_{23}},\\ - h' &= H'/M' - -where :math:`M_n = \left\lceil\frac{H_n}{h_n}\right\rceil`, -:math:`\alpha_1 = \frac{k_{11}+k_{12}+k_{13}}{3P}`, -:math:`\alpha_2 = -\frac{k_{11}+k_{12}}{3P}`, -:math:`\alpha_3 = \frac{k_{11}}{3P}`, -:math:`\beta_{11} = \frac{(p+1)(k_{11}+k_{12}+k_{13})}{3Pp}`, -:math:`\beta_{12} = -\frac{(p+1)(k_{11}+k_{12})}{3Pp}`, -:math:`\beta_{13} = \frac{(p+1)k_{11}}{3Pp}`, -:math:`\beta_{21} = -\frac{k_{21}+k_{22}+k_{23}}{3p}`, -:math:`\beta_{22} = \frac{k_{21}+k_{22}}{3p}`, -and :math:`\beta_{23} = -\frac{k_{21}}{3p}`, and where :math:`P` and :math:`p` -are the global orders of accuracy for the slow and fast time integration methods, -respectively. The default parameter values are :math:`k_{11} = 0.34`, :math:`k_{12} = 0.1`, -:math:`k_{13} = 0.78`, :math:`k_{21} = 0.46`, :math:`k_{22} = 0.42`, and :math:`k_{23} = 0.74`. -In these estimate, a floor of :math:`\varepsilon^*_* > 10\epsilon_{mach}` is enforced to avoid -division-by-zero errors, where :math:`\epsilon_{mach}` is floating point roundoff for the -current working precision. During the first steps (when :math:`\varepsilon^s_{n-1}`, -:math:`\varepsilon^s_{n-2}`, :math:`\varepsilon^f_{n-1}`, and :math:`\varepsilon^f_{n-2}` -may be unavailable), those corresponding values are set to 1, effectively removing them from -the estimation formula. - -The SUNAdaptController_MRIPID controller is implemented as a derived -SUNAdaptController class having type ``SUN_ADAPTCONTROLLER_MRI_H``, and its -*content* field is: - -.. code-block:: c - - struct _SUNAdaptControllerContent_MRIPID { - sunrealtype k11; - sunrealtype k12; - sunrealtype k13; - sunrealtype k21; - sunrealtype k22; - sunrealtype k23; - sunrealtype bias; - sunrealtype esp; - sunrealtype efp; - sunrealtype espp; - sunrealtype efpp; - int p; - }; - -These entries of the *content* field contain the following information: - -* ``k11, k12, k13, k21, k22, k23`` - controller parameters above. - -* ``bias`` - error bias factor, that converts from input temporal error - estimates via :math:`\varepsilon^s = \text{bias}*\text{DSM}` and - :math:`\varepsilon^f = \text{bias}*\text{dsm}`. The default bias value is 1.5. - -* ``esp, efp, espp, efpp`` - storage for the two previous slow and fast error - estimates, :math:`\varepsilon^s_{n-1}`, :math:`\varepsilon^f_{n-1}`, - :math:`\varepsilon^s_{n-2}`, and :math:`\varepsilon^f_{n-2}`. - -* ``p`` - global order of accuracy for the fast time scale solver. - -The header file to be included when using this module is -``sunadaptcontroller/sunadaptcontroller_mripid.h``. - -The SUNAdaptController_MRIPID class provides implementations of all operations -relevant to a ``SUN_ADAPTCONTROLLER_MRI_H`` controller listed in -:numref:`SUNAdaptController.Description.operations`. This class -also provides the following additional user-callable routines: - - -.. c:function:: SUNAdaptController SUNAdaptController_MRIPID(SUNContext sunctx, int p) - - This constructor creates and allocates memory for a SUNAdaptController_MRIPID - object, and inserts its default parameters. - - :param sunctx: the current :c:type:`SUNContext` object. - :param p: the global order of accuracy for the fast time scale solver. - :return: if successful, a usable :c:type:`SUNAdaptController` object; - otherwise it will return ``NULL``. - - Usage: - - .. code-block:: c - - SUNAdaptController C = SUNAdaptController_MRIPID(sunctx, 3); - -.. c:function:: SUNErrCode SUNAdaptController_SetParams_MRIPID(SUNAdaptController C, sunrealtype k11, sunrealtype k12, sunrealtype k13, sunrealtype k21, sunrealtype k22, sunrealtype k23) - - 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_MRIPID object. - :param k11: parameter used within the controller time step estimate. - :param k12: parameter used within the controller time step estimate. - :param k13: parameter used within the controller time step estimate. - :param k21: parameter used within the controller time step estimate. - :param k22: parameter used within the controller time step estimate. - :param k23: parameter used within the controller time step estimate. - :return: :c:type:`SUNErrCode` indicating success or failure. - - Usage: - - .. code-block:: c - - retval = SUNAdaptController_SetParams_MRIPID(C, 0.34 0.1, 0.78, 0.46, 0.42, 0.74); diff --git a/doc/superbuild/source/sunadaptcontroller/SUNAdaptController_links.rst b/doc/superbuild/source/sunadaptcontroller/SUNAdaptController_links.rst index 716fccb705..a3841b0376 100644 --- a/doc/superbuild/source/sunadaptcontroller/SUNAdaptController_links.rst +++ b/doc/superbuild/source/sunadaptcontroller/SUNAdaptController_links.rst @@ -13,3 +13,4 @@ .. include:: ../../../shared/sunadaptcontroller/SUNAdaptController_Description.rst .. include:: ../../../shared/sunadaptcontroller/SUNAdaptController_Soderlind.rst .. include:: ../../../shared/sunadaptcontroller/SUNAdaptController_ImExGus.rst +.. include:: ../../../shared/sunadaptcontroller/SUNAdaptController_MRIHTol.rst diff --git a/examples/arkode/CXX_serial/CMakeLists.txt b/examples/arkode/CXX_serial/CMakeLists.txt index cdd673c777..59bbcaec9f 100644 --- a/examples/arkode/CXX_serial/CMakeLists.txt +++ b/examples/arkode/CXX_serial/CMakeLists.txt @@ -34,6 +34,7 @@ set(ARKODE_examples "ark_kpr_Mt.cpp\;2 4 0 -10 0\;develop" "ark_kpr_Mt.cpp\;0 4 0 -10 1 10 1\;develop" "ark_kpr_Mt.cpp\;0 4 0 -10 0 10 1\;develop" + "ark_kpr_nestedmri.cpp\;\;develop" "ark_pendulum.cpp\;\;develop") # Header files to install diff --git a/test/unit_tests/arkode/CXX_serial/ark_test_kpr_nestedmri.cpp b/examples/arkode/CXX_serial/ark_kpr_nestedmri.cpp similarity index 99% rename from test/unit_tests/arkode/CXX_serial/ark_test_kpr_nestedmri.cpp rename to examples/arkode/CXX_serial/ark_kpr_nestedmri.cpp index 87bd7a8594..5f07fb9aec 100644 --- a/test/unit_tests/arkode/CXX_serial/ark_test_kpr_nestedmri.cpp +++ b/examples/arkode/CXX_serial/ark_kpr_nestedmri.cpp @@ -137,7 +137,7 @@ #include #include // dense linear solver #include // dense matrix type, fcts., macros -#include // common utility functions +#include // common utility functions #if defined(SUNDIALS_EXTENDED_PRECISION) #define ESYM "Le" diff --git a/test/unit_tests/arkode/CXX_serial/ark_test_kpr_nestedmri.out b/examples/arkode/CXX_serial/ark_kpr_nestedmri.out similarity index 100% rename from test/unit_tests/arkode/CXX_serial/ark_test_kpr_nestedmri.out rename to examples/arkode/CXX_serial/ark_kpr_nestedmri.out diff --git a/examples/utilities/example_utilities.hpp b/examples/utilities/example_utilities.hpp index 00b4d843fc..1dd30c037c 100644 --- a/examples/utilities/example_utilities.hpp +++ b/examples/utilities/example_utilities.hpp @@ -116,3 +116,14 @@ inline void find_arg(std::vector& args, const std::string key, args.erase(it); } } + +inline void find_arg(std::vector& args, const std::string key, + std::string& dest) +{ + auto it = std::find(args.begin(), args.end(), key); + if (it != args.end()) + { + dest = *(it + 1); + args.erase(it, it + 2); + } +} diff --git a/include/arkode/arkode_mristep.h b/include/arkode/arkode_mristep.h index 548bea7247..5f67b4f0b2 100644 --- a/include/arkode/arkode_mristep.h +++ b/include/arkode/arkode_mristep.h @@ -190,8 +190,6 @@ SUNDIALS_EXPORT int MRIStepSetPreInnerFn(void* arkode_mem, MRIStepPreInnerFn prefn); SUNDIALS_EXPORT int MRIStepSetPostInnerFn(void* arkode_mem, MRIStepPostInnerFn postfn); -SUNDIALS_EXPORT int MRIStepSetFastErrorStepFactor(void* arkode_mem, - sunrealtype hfactor); SUNDIALS_EXPORT int MRIStepSetAdaptController(void* arkode_mem, SUNAdaptController C); @@ -220,8 +218,6 @@ SUNDIALS_EXPORT int MRIStepInnerStepper_SetAccumulatedErrorGetFn( MRIStepInnerStepper stepper, MRIStepInnerGetAccumulatedError fn); SUNDIALS_EXPORT int MRIStepInnerStepper_SetAccumulatedErrorResetFn( MRIStepInnerStepper stepper, MRIStepInnerResetAccumulatedError fn); -SUNDIALS_EXPORT int MRIStepInnerStepper_SetFixedStepFn( - MRIStepInnerStepper stepper, MRIStepInnerSetFixedStep fn); SUNDIALS_EXPORT int MRIStepInnerStepper_SetRTolFn(MRIStepInnerStepper stepper, MRIStepInnerSetRTol fn); SUNDIALS_EXPORT int MRIStepInnerStepper_AddForcing(MRIStepInnerStepper stepper, diff --git a/include/sunadaptcontroller/sunadaptcontroller_mricc.h b/include/sunadaptcontroller/sunadaptcontroller_mricc.h deleted file mode 100644 index 685ca5e7bf..0000000000 --- a/include/sunadaptcontroller/sunadaptcontroller_mricc.h +++ /dev/null @@ -1,72 +0,0 @@ -/* ----------------------------------------------------------------- - * Programmer(s): Daniel R. Reynolds @ SMU - * ----------------------------------------------------------------- - * SUNDIALS Copyright Start - * Copyright (c) 2002-2024, 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_MRICC module. - * -----------------------------------------------------------------*/ - -#ifndef _SUNADAPTCONTROLLER_MRICC_H -#define _SUNADAPTCONTROLLER_MRICC_H - -#include -#include - -#ifdef __cplusplus /* wrapper to enable C++ usage */ -extern "C" { -#endif - -/* -------------------------------------------------- - * MRI constant-constant implementation of SUNAdaptController - * -------------------------------------------------- */ - -struct _SUNAdaptControllerContent_MRICC -{ - sunrealtype k1; /* internal controller parameters */ - sunrealtype k2; - sunrealtype bias; /* error bias factor */ - int p; /* fast order of accuracy to use */ -}; - -typedef struct _SUNAdaptControllerContent_MRICC* SUNAdaptControllerContent_MRICC; - -/* ------------------ - * Exported Functions - * ------------------ */ - -SUNDIALS_EXPORT -SUNAdaptController SUNAdaptController_MRICC(SUNContext sunctx, int p); -SUNDIALS_EXPORT -int SUNAdaptController_SetParams_MRICC(SUNAdaptController C, sunrealtype k1, - sunrealtype k2); -SUNDIALS_EXPORT -SUNAdaptController_Type SUNAdaptController_GetType_MRICC(SUNAdaptController C); -SUNDIALS_EXPORT -int SUNAdaptController_EstimateMRISteps_MRICC(SUNAdaptController C, - sunrealtype H, sunrealtype h, - int P, sunrealtype DSM, - sunrealtype dsm, sunrealtype* Hnew, - sunrealtype* hnew); -SUNDIALS_EXPORT -int SUNAdaptController_SetDefaults_MRICC(SUNAdaptController C); -SUNDIALS_EXPORT -int SUNAdaptController_Write_MRICC(SUNAdaptController C, FILE* fptr); -SUNDIALS_EXPORT -int SUNAdaptController_SetErrorBias_MRICC(SUNAdaptController C, sunrealtype bias); -SUNDIALS_EXPORT -int SUNAdaptController_Space_MRICC(SUNAdaptController C, long int* lenrw, - long int* leniw); - -#ifdef __cplusplus -} -#endif - -#endif /* _SUNADAPTCONTROLLER_MRICC_H */ diff --git a/include/sunadaptcontroller/sunadaptcontroller_mrill.h b/include/sunadaptcontroller/sunadaptcontroller_mrill.h deleted file mode 100644 index 49457cfbb0..0000000000 --- a/include/sunadaptcontroller/sunadaptcontroller_mrill.h +++ /dev/null @@ -1,86 +0,0 @@ -/* ----------------------------------------------------------------- - * Programmer(s): Daniel R. Reynolds @ SMU - * ----------------------------------------------------------------- - * SUNDIALS Copyright Start - * Copyright (c) 2002-2024, 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_MRILL module. - * -----------------------------------------------------------------*/ - -#ifndef _SUNADAPTCONTROLLER_MRILL_H -#define _SUNADAPTCONTROLLER_MRILL_H - -#include -#include - -#ifdef __cplusplus /* wrapper to enable C++ usage */ -extern "C" { -#endif - -/* ---------------------------------------------- - * MRI linear-linear implementation of SUNAdaptController - * ---------------------------------------------- */ - -struct _SUNAdaptControllerContent_MRILL -{ - sunrealtype k11; /* internal controller parameters */ - sunrealtype k12; - sunrealtype k21; - sunrealtype k22; - sunrealtype bias; /* error bias factor */ - sunrealtype esp; /* slow error from previous step */ - sunrealtype efp; /* fast error from previous step */ - sunrealtype hsp; /* slow previous step size */ - sunrealtype hfp; /* fast previous step size */ - int p; /* fast order of accuracy to use */ - sunbooleantype firststep; /* flag indicating first step */ -}; - -typedef struct _SUNAdaptControllerContent_MRILL* SUNAdaptControllerContent_MRILL; - -/* ------------------ - * Exported Functions - * ------------------ */ - -SUNDIALS_EXPORT -SUNAdaptController SUNAdaptController_MRILL(SUNContext sunctx, int p); -SUNDIALS_EXPORT -int SUNAdaptController_SetParams_MRILL(SUNAdaptController C, sunrealtype k11, - sunrealtype k12, sunrealtype k21, - sunrealtype k22); -SUNDIALS_EXPORT -SUNAdaptController_Type SUNAdaptController_GetType_MRILL(SUNAdaptController C); -SUNDIALS_EXPORT -int SUNAdaptController_EstimateMRISteps_MRILL(SUNAdaptController C, - sunrealtype H, sunrealtype h, - int P, sunrealtype DSM, - sunrealtype dsm, sunrealtype* Hnew, - sunrealtype* hnew); -SUNDIALS_EXPORT -int SUNAdaptController_Reset_MRILL(SUNAdaptController C); -SUNDIALS_EXPORT -int SUNAdaptController_SetDefaults_MRILL(SUNAdaptController C); -SUNDIALS_EXPORT -int SUNAdaptController_Write_MRILL(SUNAdaptController C, FILE* fptr); -SUNDIALS_EXPORT -int SUNAdaptController_SetErrorBias_MRILL(SUNAdaptController C, sunrealtype bias); -SUNDIALS_EXPORT -int SUNAdaptController_UpdateMRIH_MRILL(SUNAdaptController C, sunrealtype H, - sunrealtype h, sunrealtype DSM, - sunrealtype dsm); -SUNDIALS_EXPORT -int SUNAdaptController_Space_MRILL(SUNAdaptController C, long int* lenrw, - long int* leniw); - -#ifdef __cplusplus -} -#endif - -#endif /* _SUNADAPTCONTROLLER_MRILL_H */ diff --git a/include/sunadaptcontroller/sunadaptcontroller_mripi.h b/include/sunadaptcontroller/sunadaptcontroller_mripi.h deleted file mode 100644 index 80cdd0e88b..0000000000 --- a/include/sunadaptcontroller/sunadaptcontroller_mripi.h +++ /dev/null @@ -1,83 +0,0 @@ -/* ----------------------------------------------------------------- - * Programmer(s): Daniel R. Reynolds @ SMU - * ----------------------------------------------------------------- - * SUNDIALS Copyright Start - * Copyright (c) 2002-2024, 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_MRIPI module. - * -----------------------------------------------------------------*/ - -#ifndef _SUNADAPTCONTROLLER_MRIPI_H -#define _SUNADAPTCONTROLLER_MRIPI_H - -#include -#include - -#ifdef __cplusplus /* wrapper to enable C++ usage */ -extern "C" { -#endif - -/* ----------------------------------- - * MRI PI implementation of SUNAdaptController - * ----------------------------------- */ - -struct _SUNAdaptControllerContent_MRIPI -{ - sunrealtype k11; /* internal controller parameters */ - sunrealtype k12; - sunrealtype k21; - sunrealtype k22; - sunrealtype bias; /* error bias factor */ - sunrealtype esp; /* slow error from previous step */ - sunrealtype efp; /* fast error from previous step */ - int p; /* fast order of accuracy to use */ -}; - -typedef struct _SUNAdaptControllerContent_MRIPI* SUNAdaptControllerContent_MRIPI; - -/* ------------------ - * Exported Functions - * ------------------ */ - -SUNDIALS_EXPORT -SUNAdaptController SUNAdaptController_MRIPI(SUNContext sunctx, int p); -SUNDIALS_EXPORT -int SUNAdaptController_SetParams_MRIPI(SUNAdaptController C, sunrealtype k11, - sunrealtype k12, sunrealtype k21, - sunrealtype k22); -SUNDIALS_EXPORT -SUNAdaptController_Type SUNAdaptController_GetType_MRIPI(SUNAdaptController C); -SUNDIALS_EXPORT -int SUNAdaptController_EstimateMRISteps_MRIPI(SUNAdaptController C, - sunrealtype H, sunrealtype h, - int P, sunrealtype DSM, - sunrealtype dsm, sunrealtype* Hnew, - sunrealtype* hnew); -SUNDIALS_EXPORT -int SUNAdaptController_Reset_MRIPI(SUNAdaptController C); -SUNDIALS_EXPORT -int SUNAdaptController_SetDefaults_MRIPI(SUNAdaptController C); -SUNDIALS_EXPORT -int SUNAdaptController_Write_MRIPI(SUNAdaptController C, FILE* fptr); -SUNDIALS_EXPORT -int SUNAdaptController_SetErrorBias_MRIPI(SUNAdaptController C, sunrealtype bias); -SUNDIALS_EXPORT -int SUNAdaptController_UpdateMRIH_MRIPI(SUNAdaptController C, sunrealtype H, - sunrealtype h, sunrealtype DSM, - sunrealtype dsm); -SUNDIALS_EXPORT -int SUNAdaptController_Space_MRIPI(SUNAdaptController C, long int* lenrw, - long int* leniw); - -#ifdef __cplusplus -} -#endif - -#endif /* _SUNADAPTCONTROLLER_MRIPI_H */ diff --git a/include/sunadaptcontroller/sunadaptcontroller_mripid.h b/include/sunadaptcontroller/sunadaptcontroller_mripid.h deleted file mode 100644 index 1adb128f45..0000000000 --- a/include/sunadaptcontroller/sunadaptcontroller_mripid.h +++ /dev/null @@ -1,89 +0,0 @@ -/* ----------------------------------------------------------------- - * Programmer(s): Daniel R. Reynolds @ SMU - * ----------------------------------------------------------------- - * SUNDIALS Copyright Start - * Copyright (c) 2002-2024, 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_MRIPID module. - * -----------------------------------------------------------------*/ - -#ifndef _SUNADAPTCONTROLLER_MRIPID_H -#define _SUNADAPTCONTROLLER_MRIPID_H - -#include -#include - -#ifdef __cplusplus /* wrapper to enable C++ usage */ -extern "C" { -#endif - -/* ----------------------------------- - * MRI PI implementation of SUNAdaptController - * ----------------------------------- */ - -struct _SUNAdaptControllerContent_MRIPID -{ - sunrealtype k11; /* internal controller parameters */ - sunrealtype k12; - sunrealtype k13; - sunrealtype k21; - sunrealtype k22; - sunrealtype k23; - sunrealtype bias; /* error bias factor */ - sunrealtype esp; /* slow error from previous step */ - sunrealtype efp; /* fast error from previous step */ - sunrealtype espp; /* slow error from two previous steps ago */ - sunrealtype efpp; /* fast error from two previous steps ago */ - int p; /* fast order of accuracy to use */ -}; - -typedef struct _SUNAdaptControllerContent_MRIPID* SUNAdaptControllerContent_MRIPID; - -/* ------------------ - * Exported Functions - * ------------------ */ - -SUNDIALS_EXPORT -SUNAdaptController SUNAdaptController_MRIPID(SUNContext sunctx, int p); -SUNDIALS_EXPORT -int SUNAdaptController_SetParams_MRIPID(SUNAdaptController C, sunrealtype k11, - sunrealtype k12, sunrealtype k13, - sunrealtype k21, sunrealtype k22, - sunrealtype k23); -SUNDIALS_EXPORT -SUNAdaptController_Type SUNAdaptController_GetType_MRIPID(SUNAdaptController C); -SUNDIALS_EXPORT -int SUNAdaptController_EstimateMRISteps_MRIPID(SUNAdaptController C, - sunrealtype H, sunrealtype h, - int P, sunrealtype DSM, - sunrealtype dsm, sunrealtype* Hnew, - sunrealtype* hnew); -SUNDIALS_EXPORT -int SUNAdaptController_Reset_MRIPID(SUNAdaptController C); -SUNDIALS_EXPORT -int SUNAdaptController_SetDefaults_MRIPID(SUNAdaptController C); -SUNDIALS_EXPORT -int SUNAdaptController_Write_MRIPID(SUNAdaptController C, FILE* fptr); -SUNDIALS_EXPORT -int SUNAdaptController_SetErrorBias_MRIPID(SUNAdaptController C, - sunrealtype bias); -SUNDIALS_EXPORT -int SUNAdaptController_UpdateMRIH_MRIPID(SUNAdaptController C, sunrealtype H, - sunrealtype h, sunrealtype DSM, - sunrealtype dsm); -SUNDIALS_EXPORT -int SUNAdaptController_Space_MRIPID(SUNAdaptController C, long int* lenrw, - long int* leniw); - -#ifdef __cplusplus -} -#endif - -#endif /* _SUNADAPTCONTROLLER_MRIPID_H */ diff --git a/include/sundials/sundials_adaptcontroller.h b/include/sundials/sundials_adaptcontroller.h index 77a06a4748..dc3572e12b 100644 --- a/include/sundials/sundials_adaptcontroller.h +++ b/include/sundials/sundials_adaptcontroller.h @@ -34,7 +34,6 @@ extern "C" { * SUNAdaptController types: * NONE - empty controller (does nothing) * H - controls a single-rate step size - * MRI_H - controls two multirate step sizes * MRI_TOL - controls slow and fast relative tolerances * ----------------------------------------------------------------- */ @@ -42,7 +41,6 @@ typedef enum { SUN_ADAPTCONTROLLER_NONE, SUN_ADAPTCONTROLLER_H, - SUN_ADAPTCONTROLLER_MRI_H, SUN_ADAPTCONTROLLER_MRI_TOL } SUNAdaptController_Type; @@ -66,12 +64,6 @@ struct _generic_SUNAdaptController_Ops SUNErrCode (*estimatestep)(SUNAdaptController C, sunrealtype h, int p, sunrealtype dsm, sunrealtype* hnew); - /* REQUIRED for controllers of SUN_ADAPTCONTROLLER_MRI_H type. */ - SUNErrCode (*estimatemristeps)(SUNAdaptController C, sunrealtype H, - sunrealtype h, int P, sunrealtype DSM, - sunrealtype dsm, sunrealtype* Hnew, - sunrealtype* hnew); - /* REQUIRED for controllers of SUN_ADAPTCONTROLLER_MRI_TOL type. */ SUNErrCode (*estimatesteptol)(SUNAdaptController C, sunrealtype H, sunrealtype tolfac, int P, sunrealtype DSM, @@ -85,8 +77,6 @@ struct _generic_SUNAdaptController_Ops SUNErrCode (*write)(SUNAdaptController C, FILE* fptr); SUNErrCode (*seterrorbias)(SUNAdaptController C, sunrealtype bias); SUNErrCode (*updateh)(SUNAdaptController C, sunrealtype h, sunrealtype dsm); - SUNErrCode (*updatemrih)(SUNAdaptController C, sunrealtype H, sunrealtype h, - sunrealtype DSM, sunrealtype dsm); SUNErrCode (*updatemritol)(SUNAdaptController C, sunrealtype H, sunrealtype tolfac, sunrealtype DSM, sunrealtype dsm); @@ -138,20 +128,6 @@ SUNErrCode SUNAdaptController_EstimateStep(SUNAdaptController C, sunrealtype h, int p, sunrealtype dsm, sunrealtype* hnew); -/* 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 -SUNErrCode SUNAdaptController_EstimateMRISteps(SUNAdaptController C, - sunrealtype H, sunrealtype h, - int P, sunrealtype DSM, - sunrealtype dsm, sunrealtype* Hnew, - sunrealtype* hnew); - /* Combined slow step/fast tolerance multirate controller function. This is called following a slow multirate time step with size 'H' and fast/slow relative tolerance ratio 'tolfac', and error factors @@ -193,15 +169,6 @@ SUNDIALS_EXPORT SUNErrCode SUNAdaptController_UpdateH(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 -SUNErrCode 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 diff --git a/src/arkode/CMakeLists.txt b/src/arkode/CMakeLists.txt index 8f2d296d58..8fbc833fa4 100644 --- a/src/arkode/CMakeLists.txt +++ b/src/arkode/CMakeLists.txt @@ -73,12 +73,8 @@ sundials_add_library( OBJECT_LIBRARIES sundials_sunmemsys_obj sundials_nvecserial_obj - sundials_sunadaptcontrollerimexgus_obj sundials_sunadaptcontrollersoderlind_obj - sundials_sunadaptcontrollermrill_obj - sundials_sunadaptcontrollermricc_obj - sundials_sunadaptcontrollermripi_obj - sundials_sunadaptcontrollermripid_obj + sundials_sunadaptcontrollerimexgus_obj sundials_sunadaptcontrollermrihtol_obj sundials_sunmatrixband_obj sundials_sunmatrixdense_obj diff --git a/src/arkode/arkode_arkstep.c b/src/arkode/arkode_arkstep.c index 26646000fb..154d25988b 100644 --- a/src/arkode/arkode_arkstep.c +++ b/src/arkode/arkode_arkstep.c @@ -389,10 +389,6 @@ int ARKStepCreateMRIStepInnerStepper(void* inner_arkode_mem, arkStep_MRIStepInnerResetAccumulatedError); if (retval != ARK_SUCCESS) { return (retval); } - retval = MRIStepInnerStepper_SetFixedStepFn(*stepper, - arkStep_MRIStepInnerSetFixedStep); - if (retval != ARK_SUCCESS) { return (retval); } - retval = MRIStepInnerStepper_SetRTolFn(*stepper, arkStep_MRIStepInnerSetRTol); if (retval != ARK_SUCCESS) { return (retval); } @@ -3307,25 +3303,6 @@ int arkStep_MRIStepInnerResetAccumulatedError(MRIStepInnerStepper stepper) return (ARKodeResetAccumulatedError(arkode_mem)); } -/*------------------------------------------------------------------------------ - arkStep_MRIStepInnerSetFixedStep - - Implementation of MRIStepInnerSetFixedStep to set a fixed step size for - the upcoming evolution using the inner (fast) stepper. - ----------------------------------------------------------------------------*/ - -int arkStep_MRIStepInnerSetFixedStep(MRIStepInnerStepper stepper, sunrealtype h) -{ - void* arkode_mem; - int retval; - - /* extract the ARKODE memory struct */ - retval = MRIStepInnerStepper_GetContent(stepper, &arkode_mem); - if (retval != ARK_SUCCESS) { return (retval); } - - return (ARKodeSetFixedStep(arkode_mem, h)); -} - /*------------------------------------------------------------------------------ arkStep_MRIStepInnerSetRTol diff --git a/src/arkode/arkode_arkstep_impl.h b/src/arkode/arkode_arkstep_impl.h index 190fe8ce5f..e53f244824 100644 --- a/src/arkode/arkode_arkstep_impl.h +++ b/src/arkode/arkode_arkstep_impl.h @@ -280,7 +280,6 @@ int arkStep_MRIStepInnerReset(MRIStepInnerStepper stepper, sunrealtype tR, int arkStep_MRIStepInnerGetAccumulatedError(MRIStepInnerStepper stepper, sunrealtype* accum_error); int arkStep_MRIStepInnerResetAccumulatedError(MRIStepInnerStepper stepper); -int arkStep_MRIStepInnerSetFixedStep(MRIStepInnerStepper stepper, sunrealtype h); int arkStep_MRIStepInnerSetRTol(MRIStepInnerStepper stepper, sunrealtype rtol); /* private functions for relaxation */ diff --git a/src/arkode/arkode_erkstep.c b/src/arkode/arkode_erkstep.c index beb73a098a..c088472a4a 100644 --- a/src/arkode/arkode_erkstep.c +++ b/src/arkode/arkode_erkstep.c @@ -1260,10 +1260,6 @@ int ERKStepCreateMRIStepInnerStepper(void* inner_arkode_mem, erkStep_MRIStepInnerResetAccumulatedError); if (retval != ARK_SUCCESS) { return (retval); } - retval = MRIStepInnerStepper_SetFixedStepFn(*stepper, - erkStep_MRIStepInnerSetFixedStep); - if (retval != ARK_SUCCESS) { return (retval); } - retval = MRIStepInnerStepper_SetRTolFn(*stepper, erkStep_MRIStepInnerSetRTol); if (retval != ARK_SUCCESS) { return (retval); } @@ -1394,25 +1390,6 @@ int erkStep_MRIStepInnerResetAccumulatedError(MRIStepInnerStepper stepper) return (ARKodeResetAccumulatedError(arkode_mem)); } -/*------------------------------------------------------------------------------ - erkStep_MRIStepInnerSetFixedStep - - Implementation of MRIStepInnerSetFixedStep to set a fixed step size for - the upcoming evolution using the inner (fast) stepper. - ----------------------------------------------------------------------------*/ - -int erkStep_MRIStepInnerSetFixedStep(MRIStepInnerStepper stepper, sunrealtype h) -{ - void* arkode_mem; - int retval; - - /* extract the ARKODE memory struct */ - retval = MRIStepInnerStepper_GetContent(stepper, &arkode_mem); - if (retval != ARK_SUCCESS) { return (retval); } - - return (ARKodeSetFixedStep(arkode_mem, h)); -} - /*------------------------------------------------------------------------------ erkStep_MRIStepInnerSetRTol diff --git a/src/arkode/arkode_erkstep_impl.h b/src/arkode/arkode_erkstep_impl.h index b0ad2e1448..bdcbe66a85 100644 --- a/src/arkode/arkode_erkstep_impl.h +++ b/src/arkode/arkode_erkstep_impl.h @@ -118,7 +118,6 @@ int erkStep_MRIStepInnerReset(MRIStepInnerStepper stepper, sunrealtype tR, int erkStep_MRIStepInnerGetAccumulatedError(MRIStepInnerStepper stepper, sunrealtype* accum_error); int erkStep_MRIStepInnerResetAccumulatedError(MRIStepInnerStepper stepper); -int erkStep_MRIStepInnerSetFixedStep(MRIStepInnerStepper stepper, sunrealtype h); int erkStep_MRIStepInnerSetRTol(MRIStepInnerStepper stepper, sunrealtype rtol); /* private functions for relaxation */ diff --git a/src/arkode/arkode_mristep.c b/src/arkode/arkode_mristep.c index df6de52062..20b2d65f29 100644 --- a/src/arkode/arkode_mristep.c +++ b/src/arkode/arkode_mristep.c @@ -1236,8 +1236,7 @@ int mriStep_Init(ARKodeMem ark_mem, int init_type) /* get timestep adaptivity type, and return an error if an incompatible type is detected */ adapt_type = SUNAdaptController_GetType(ark_mem->hadapt_mem->hcontroller); - if ((adapt_type != SUN_ADAPTCONTROLLER_MRI_H) && - (adapt_type != SUN_ADAPTCONTROLLER_MRI_TOL) && + if ((adapt_type != SUN_ADAPTCONTROLLER_MRI_TOL) && (adapt_type != SUN_ADAPTCONTROLLER_H)) { arkProcessError(ark_mem, ARK_ILL_INPUT, __LINE__, __func__, __FILE__, @@ -1305,70 +1304,6 @@ int mriStep_Init(ARKodeMem ark_mem, int init_type) step_mem->inner_control = ONE; } - /* Perform additional setup for (H,h) controller */ - if (adapt_type == SUN_ADAPTCONTROLLER_MRI_H) - { - /* verify that adaptivity type is supported by inner stepper */ - if (!mriStepInnerStepper_SupportsStepAdaptivity(step_mem->stepper)) - { - arkProcessError(ark_mem, ARK_ILL_INPUT, __LINE__, __func__, - __FILE__, "MRI-H SUNAdaptController provided, but unsupported by inner stepper"); - return (ARK_ILL_INPUT); - } - - /* If user has left inner_hfactor unset, reset to our default to indicate - that we **do not trust** fixed-stepsize fast error estimates. */ - if (step_mem->inner_hfactor < ZERO) - { - step_mem->inner_hfactor = INNER_HFACTOR; - } - - /* initialize fast stepper fixed step size (store in step_mem->inner_control) */ - if (step_mem->stepper->ops->fullrhs) - { - /* tempv1 = ffast(t0, y0) */ - if (mriStep_FastRHS(ark_mem, ark_mem->tcur, ark_mem->yn, ark_mem->tempv1, - ARK_FULLRHS_START) != ARK_SUCCESS) - { - arkProcessError(ark_mem, ARK_RHSFUNC_FAIL, __LINE__, __func__, __FILE__, - "error calling fast RHS function(s)"); - return (ARK_RHSFUNC_FAIL); - } - - /* compute initial fast step size */ - retval = arkHin(ark_mem, ark_mem->tcur, ark_mem->tout, ark_mem->yn, - ark_mem->tempv1, ark_mem->ycur, ark_mem->tempv2, - ark_mem->tempv3, mriStep_FastRHS, - &(step_mem->inner_control)); - if (retval != ARK_SUCCESS) - { - retval = arkHandleFailure(ark_mem, retval); - return (retval); - } - } - else - { - /* set step_mem->inner_control to equal H/100 */ - step_mem->inner_control = SUN_RCONST(0.01) * ark_mem->hin; - } - /* Pass fixed stepsize to inner stepper */ - retval = mriStepInnerStepper_SetFixedStep(step_mem->stepper, - step_mem->inner_control); - if (retval != ARK_SUCCESS) - { - arkProcessError(ark_mem, ARK_INNERSTEP_FAIL, __LINE__, __func__, __FILE__, - "error setting fast fixed step"); - return (ARK_INNERSTEP_FAIL); - } - } - else - { - /* If user has left inner_hfactor unset, reset to zero to indicate - either that we **trust** tolerance-based adaptive fast error - estimates, or that the method does not use fast error estimates. */ - if (step_mem->inner_hfactor < ZERO) { step_mem->inner_hfactor = ZERO; } - } - /* /\* Signal to shared arkode module that fullrhs is required after each step *\/ */ /* /\* TO-DO: verify whether this is actually required *\/ */ /* ark_mem->call_fullrhs = SUNTRUE; */ @@ -1762,8 +1697,7 @@ int mriStep_TakeStepMRIGARK(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPt and send appropriate control parameter to the fast integrator */ adapt_type = SUNAdaptController_GetType(ark_mem->hadapt_mem->hcontroller); need_inner_dsm = SUNFALSE; - if ((adapt_type == SUN_ADAPTCONTROLLER_MRI_H) || - (adapt_type == SUN_ADAPTCONTROLLER_MRI_TOL)) + if (adapt_type == SUN_ADAPTCONTROLLER_MRI_TOL) { need_inner_dsm = SUNTRUE; step_mem->inner_dsm = ZERO; @@ -1774,20 +1708,6 @@ int mriStep_TakeStepMRIGARK(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPt "Unable to reset the inner stepper error estimate"); return (ARK_INNERSTEP_FAIL); } - } - if (adapt_type == SUN_ADAPTCONTROLLER_MRI_H) - { - retval = mriStepInnerStepper_SetFixedStep(step_mem->stepper, - step_mem->inner_control); - if (retval != ARK_SUCCESS) - { - arkProcessError(ark_mem, ARK_INNERSTEP_FAIL, __LINE__, __func__, __FILE__, - "Unable to set a fixed stepsize in the inner stepper"); - return (ARK_INNERSTEP_FAIL); - } - } - if (adapt_type == SUN_ADAPTCONTROLLER_MRI_TOL) - { retval = mriStepInnerStepper_SetRTol(step_mem->stepper, step_mem->inner_control * ark_mem->reltol); @@ -2244,8 +2164,7 @@ int mriStep_TakeStepMRISR(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr) and send appropriate control parameter to the fast integrator */ adapt_type = SUNAdaptController_GetType(ark_mem->hadapt_mem->hcontroller); need_inner_dsm = SUNFALSE; - if ((adapt_type == SUN_ADAPTCONTROLLER_MRI_H) || - (adapt_type == SUN_ADAPTCONTROLLER_MRI_TOL)) + if (adapt_type == SUN_ADAPTCONTROLLER_MRI_TOL) { need_inner_dsm = SUNTRUE; step_mem->inner_dsm = ZERO; @@ -2256,20 +2175,6 @@ int mriStep_TakeStepMRISR(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr) "Unable to reset the inner stepper error estimate"); return (ARK_INNERSTEP_FAIL); } - } - if (adapt_type == SUN_ADAPTCONTROLLER_MRI_H) - { - retval = mriStepInnerStepper_SetFixedStep(step_mem->stepper, - step_mem->inner_control); - if (retval != ARK_SUCCESS) - { - arkProcessError(ark_mem, ARK_INNERSTEP_FAIL, __LINE__, __func__, __FILE__, - "Unable to set a fixed stepsize in the inner stepper"); - return (ARK_INNERSTEP_FAIL); - } - } - if (adapt_type == SUN_ADAPTCONTROLLER_MRI_TOL) - { retval = mriStepInnerStepper_SetRTol(step_mem->stepper, step_mem->inner_control * ark_mem->reltol); @@ -2728,8 +2633,7 @@ int mriStep_TakeStepMERK(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr) and send appropriate control parameter to the fast integrator */ adapt_type = SUNAdaptController_GetType(ark_mem->hadapt_mem->hcontroller); need_inner_dsm = SUNFALSE; - if ((adapt_type == SUN_ADAPTCONTROLLER_MRI_H) || - (adapt_type == SUN_ADAPTCONTROLLER_MRI_TOL)) + if (adapt_type == SUN_ADAPTCONTROLLER_MRI_TOL) { need_inner_dsm = SUNTRUE; step_mem->inner_dsm = ZERO; @@ -2740,20 +2644,6 @@ int mriStep_TakeStepMERK(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr) "Unable to reset the inner stepper error estimate"); return (ARK_INNERSTEP_FAIL); } - } - if (adapt_type == SUN_ADAPTCONTROLLER_MRI_H) - { - retval = mriStepInnerStepper_SetFixedStep(step_mem->stepper, - step_mem->inner_control); - if (retval != ARK_SUCCESS) - { - arkProcessError(ark_mem, ARK_INNERSTEP_FAIL, __LINE__, __func__, __FILE__, - "Unable to set a fixed stepsize in the inner stepper"); - return (ARK_INNERSTEP_FAIL); - } - } - if (adapt_type == SUN_ADAPTCONTROLLER_MRI_TOL) - { retval = mriStepInnerStepper_SetRTol(step_mem->stepper, step_mem->inner_control * ark_mem->reltol); @@ -3449,14 +3339,6 @@ int mriStep_StageERKFast(ARKodeMem ark_mem, ARKodeMRIStepMem step_mem, int is, ? SUNAdaptController_GetType(ark_mem->hadapt_mem->hcontroller) : SUN_ADAPTCONTROLLER_NONE; - /* if we'll need to manually accumulate the fast error estimate, archive the - current state to provide an initial condition for the ``fast embedding'' */ - if ((get_inner_dsm) && (adapt_type == SUN_ADAPTCONTROLLER_MRI_H) && - (step_mem->inner_hfactor != ZERO)) - { - N_VScale(ONE, ycur, ytemp); - } - /* advance inner method in time */ retval = mriStepInnerStepper_Evolve(step_mem->stepper, t0, tf, ycur); if (retval != ARK_SUCCESS) @@ -3482,83 +3364,7 @@ int mriStep_StageERKFast(ARKodeMem ark_mem, ARKodeMRIStepMem step_mem, int is, return (ARK_INNERSTEP_FAIL); } } - - /* the fast integrator uses fixed steps */ - if (adapt_type == SUN_ADAPTCONTROLLER_MRI_H) - { - /* if we trust inner integrator accumulated error estimate, call it here */ - if (step_mem->inner_hfactor == ZERO) - { - retval = mriStepInnerStepper_GetError(step_mem->stepper, - &(step_mem->inner_dsm)); - if (retval != ARK_SUCCESS) - { - arkProcessError(ark_mem, ARK_INNERSTEP_FAIL, __LINE__, __func__, - __FILE__, "Unable to get accumulated error from the inner stepper"); - return (ARK_INNERSTEP_FAIL); - } - } - else /* manually accumulate fast error estimate */ - { - /* reset fast integrator for time interval */ - retval = mriStepInnerStepper_Reset(step_mem->stepper, t0, ytemp); - if (retval != ARK_SUCCESS) - { - arkProcessError(ark_mem, ARK_INNERSTEP_FAIL, __LINE__, __func__, - __FILE__, "Unable to reset the inner stepper"); - return (ARK_INNERSTEP_FAIL); - } - - /* update fixed-step size for fast integrator */ - retval = mriStepInnerStepper_SetFixedStep(step_mem->stepper, - step_mem->inner_control * - step_mem->inner_hfactor); - if (retval != ARK_SUCCESS) - { - arkProcessError(ark_mem, ARK_INNERSTEP_FAIL, __LINE__, __func__, - __FILE__, "Unable to set a fixed stepsize in the inner stepper"); - return (ARK_INNERSTEP_FAIL); - } - - /* evolve fast integrator using modified step size */ - retval = mriStepInnerStepper_Evolve(step_mem->stepper, t0, tf, ytemp); - if (retval != ARK_SUCCESS) - { - arkProcessError(ark_mem, ARK_INNERSTEP_FAIL, __LINE__, __func__, - __FILE__, "Failure when evolving the inner stepper"); - return (ARK_INNERSTEP_FAIL); - } - - /* compute solution difference */ - N_VLinearSum(ONE, ytemp, -ONE, ycur, ytemp); - - /* accumulate fast error estimate -- this assumes that the inner - integrator has the same asymptotic order of accuracy as the MRI method */ - inner_error_factor = ark_mem->reltol / - SUNRabs(ONE - SUNRpowerI(step_mem->inner_hfactor, step_mem->q)); - step_mem->inner_dsm = - SUNMAX(step_mem->inner_dsm, - inner_error_factor * N_VWrmsNorm(ytemp, ark_mem->ewt)); - - /* reset fast integrator to the main evolution result */ - retval = mriStepInnerStepper_Reset(step_mem->stepper, tf, ycur); - if (retval != ARK_SUCCESS) - { - arkProcessError(ark_mem, ARK_INNERSTEP_FAIL, __LINE__, __func__, - __FILE__, "Unable to reset the inner stepper"); - return (ARK_INNERSTEP_FAIL); - } - retval = mriStepInnerStepper_SetFixedStep(step_mem->stepper, - step_mem->inner_control); - if (retval != ARK_SUCCESS) - { - arkProcessError(ark_mem, ARK_INNERSTEP_FAIL, __LINE__, __func__, - __FILE__, "Unable to set a fixed stepsize in the inner stepper"); - return (ARK_INNERSTEP_FAIL); - } - } /* if (step_mem->inner_hfactor == ZERO) */ - } /* if (adapt_type == SUN_ADAPTCONTROLLER_MRI_H) */ - } /* if (get_inner_dsm) */ + } /* post inner evolve function (if supplied) */ if (step_mem->post_inner_evolve) @@ -4472,28 +4278,6 @@ int MRIStepInnerStepper_SetAccumulatedErrorResetFn( return ARK_SUCCESS; } -int MRIStepInnerStepper_SetFixedStepFn(MRIStepInnerStepper stepper, - MRIStepInnerSetFixedStep fn) -{ - if (stepper == NULL) - { - arkProcessError(NULL, ARK_ILL_INPUT, __LINE__, __func__, __FILE__, - "Inner stepper memory is NULL"); - return ARK_ILL_INPUT; - } - - if (stepper->ops == NULL) - { - arkProcessError(NULL, ARK_ILL_INPUT, __LINE__, __func__, __FILE__, - "Inner stepper operations structure is NULL"); - return ARK_ILL_INPUT; - } - - stepper->ops->setfixedstep = fn; - - return ARK_SUCCESS; -} - int MRIStepInnerStepper_SetRTolFn(MRIStepInnerStepper stepper, MRIStepInnerSetRTol fn) { @@ -4582,20 +4366,6 @@ int mriStepInnerStepper_HasRequiredOps(MRIStepInnerStepper stepper) else { return ARK_ILL_INPUT; } } -/* Check whether stepper supports fast/slow stepsize adaptivity */ -sunbooleantype mriStepInnerStepper_SupportsStepAdaptivity(MRIStepInnerStepper stepper) -{ - if (stepper == NULL) { return SUNFALSE; } - if (stepper->ops == NULL) { return SUNFALSE; } - - if (stepper->ops->geterror && stepper->ops->reseterror && - stepper->ops->setfixedstep) - { - return SUNTRUE; - } - else { return SUNFALSE; } -} - /* Check whether stepper supports fast/slow tolerance adaptivity */ sunbooleantype mriStepInnerStepper_SupportsRTolAdaptivity(MRIStepInnerStepper stepper) { @@ -4711,24 +4481,6 @@ int mriStepInnerStepper_ResetError(MRIStepInnerStepper stepper) } } -/* Sets the inner (fast) stepper fixed step size */ -int mriStepInnerStepper_SetFixedStep(MRIStepInnerStepper stepper, sunrealtype h) -{ - if (stepper == NULL) { return ARK_ILL_INPUT; } - if (stepper->ops == NULL) { return ARK_ILL_INPUT; } - - if (stepper->ops->setfixedstep) - { - stepper->last_flag = stepper->ops->setfixedstep(stepper, h); - return stepper->last_flag; - } - else - { - /* assume stepper provides exact solution using infinitesimally small step */ - return ARK_SUCCESS; - } -} - /* Sets the inner (fast) stepper relative tolerance scaling factor */ int mriStepInnerStepper_SetRTol(MRIStepInnerStepper stepper, sunrealtype rtol) { @@ -4929,10 +4681,6 @@ int MRIStepCreateMRIStepInnerStepper(void* inner_arkode_mem, mriStep_MRIStepInnerResetAccumulatedError); if (retval != ARK_SUCCESS) { return (retval); } - retval = MRIStepInnerStepper_SetFixedStepFn(*stepper, - mriStep_MRIStepInnerSetFixedStep); - if (retval != ARK_SUCCESS) { return (retval); } - retval = MRIStepInnerStepper_SetRTolFn(*stepper, mriStep_MRIStepInnerSetRTol); if (retval != ARK_SUCCESS) { return (retval); } @@ -5063,25 +4811,6 @@ int mriStep_MRIStepInnerResetAccumulatedError(MRIStepInnerStepper stepper) return (ARKodeResetAccumulatedError(arkode_mem)); } -/*------------------------------------------------------------------------------ - mriStep_MRIStepInnerSetFixedStep - - Implementation of MRIStepInnerSetFixedStep to set a fixed step size for - the upcoming evolution using the inner (fast) stepper. - ----------------------------------------------------------------------------*/ - -int mriStep_MRIStepInnerSetFixedStep(MRIStepInnerStepper stepper, sunrealtype h) -{ - void* arkode_mem; - int retval; - - /* extract the ARKODE memory struct */ - retval = MRIStepInnerStepper_GetContent(stepper, &arkode_mem); - if (retval != ARK_SUCCESS) { return (retval); } - - return (ARKodeSetFixedStep(arkode_mem, h)); -} - /*------------------------------------------------------------------------------ mriStep_MRIStepInnerSetRTol diff --git a/src/arkode/arkode_mristep_controller.c b/src/arkode/arkode_mristep_controller.c index 027184bdcf..a1aaf4c88d 100644 --- a/src/arkode/arkode_mristep_controller.c +++ b/src/arkode/arkode_mristep_controller.c @@ -1,7 +1,5 @@ /* ----------------------------------------------------------------------------- - * Programmer(s): David J. Gardner @ LLNL - * Daniel R. Reynolds @ SMU - * Rujeko Chinomona @ SMU + * Programmer(s): Daniel R. Reynolds @ SMU * ----------------------------------------------------------------------------- * SUNDIALS Copyright Start * Copyright (c) 2002-2024, Lawrence Livermore National Security @@ -24,19 +22,9 @@ #include "arkode_impl.h" #include "arkode_mristep_impl.h" -/* SUNAdaptController_MRIStep heuristic constants */ +/* SUNAdaptController_MRIStep heuristic constant: */ /* minimum estimated temporal error for inner solver */ #define INNER_MIN_DSM SUNRsqrt(SUN_UNIT_ROUNDOFF) -/* maximum relative change for inner step size or tolerance */ -#define INNER_MAX_RELCH SUN_RCONST(20.0) -/* minimum tolerance sent to inner solver */ -#define INNER_MIN_RTOL (SUN_RCONST(100.0) * SUN_UNIT_ROUNDOFF) -/* maximum tolerance sent to inner solver */ -#define INNER_MAX_RTOL (SUN_RCONST(0.1)) -/* minimum step size for inner solver */ -#define INNER_MIN_H (SUN_RCONST(10.0) * SUN_UNIT_ROUNDOFF) -/* maximum step size for inner solver, as fraction of MRIStep H */ -#define INNER_MAX_H SUN_RCONST(0.5) /*-------------------------------------------- MRIStep SUNAdaptController wrapper functions @@ -54,8 +42,7 @@ SUNAdaptController SUNAdaptController_MRIStep(void* arkode_mem, /* Return with failure if input controller is NULL or has unsupported type */ if (CMRI == NULL) { return (NULL); } - if ((SUNAdaptController_GetType(CMRI) != SUN_ADAPTCONTROLLER_MRI_H) && - (SUNAdaptController_GetType(CMRI) != SUN_ADAPTCONTROLLER_MRI_TOL)) + if (SUNAdaptController_GetType(CMRI) != SUN_ADAPTCONTROLLER_MRI_TOL) { return (NULL); } @@ -109,34 +96,12 @@ int SUNAdaptController_EstimateStep_MRIStep(SUNAdaptController C, sunrealtype H, /* Enforce bound on inner_dsm */ step_mem->inner_dsm = SUNMAX(step_mem->inner_dsm, INNER_MIN_DSM); - /* Estimate slow stepsize based on MRI controller type, and enforce bounds on - controller-specified value for the inner solver */ - if (SUNAdaptController_GetType(MRICONTROL_C(C)) == SUN_ADAPTCONTROLLER_MRI_H) - { - retval = SUNAdaptController_EstimateMRISteps(MRICONTROL_C(C), H, - step_mem->inner_control, - step_mem->p, DSM, - step_mem->inner_dsm, Hnew, - &(step_mem->inner_control_new)); - step_mem->inner_control_new = SUNMAX(step_mem->inner_control_new, - INNER_MIN_H); - step_mem->inner_control_new = SUNMIN(step_mem->inner_control_new, - INNER_MAX_H); - step_mem->inner_control_new = - SUNMAX(step_mem->inner_control_new, - step_mem->inner_control / INNER_MAX_RELCH); - step_mem->inner_control_new = - SUNMIN(step_mem->inner_control_new, - step_mem->inner_control * INNER_MAX_RELCH); - } - else /* SUN_ADAPTCONTROLLER_MRI_TOL */ - { - retval = SUNAdaptController_EstimateStepTol(MRICONTROL_C(C), H, - step_mem->inner_control, - step_mem->p, DSM, - step_mem->inner_dsm, Hnew, - &(step_mem->inner_control_new)); - } + /* Estimate slow stepsize from MRI controller */ + retval = SUNAdaptController_EstimateStepTol(MRICONTROL_C(C), H, + step_mem->inner_control, + step_mem->p, DSM, + step_mem->inner_dsm, Hnew, + &(step_mem->inner_control_new)); return retval; } @@ -148,20 +113,11 @@ int SUNAdaptController_UpdateH_MRIStep(SUNAdaptController C, sunrealtype H, ARKodeMRIStepMem step_mem = MRICONTROL_S(C); if ((ark_mem == NULL) || (step_mem == NULL)) { return SUN_ERR_MEM_FAIL; } - /* Update MRI controller based on its type */ + /* Update MRI controller */ int retval; - if (SUNAdaptController_GetType(MRICONTROL_C(C)) == SUN_ADAPTCONTROLLER_MRI_H) - { - retval = SUNAdaptController_UpdateMRIH(MRICONTROL_C(C), H, + retval = SUNAdaptController_UpdateMRITol(MRICONTROL_C(C), H, step_mem->inner_control, DSM, step_mem->inner_dsm); - } - else /* SUN_ADAPTCONTROLLER_MRI_TOL */ - { - retval = SUNAdaptController_UpdateMRITol(MRICONTROL_C(C), H, - step_mem->inner_control, DSM, - step_mem->inner_dsm); - } if (retval != SUN_SUCCESS) { return (retval); } /* Update inner controller parameter to most-recent prediction */ diff --git a/src/arkode/arkode_mristep_impl.h b/src/arkode/arkode_mristep_impl.h index 3dea6a5efc..393aa12cf6 100644 --- a/src/arkode/arkode_mristep_impl.h +++ b/src/arkode/arkode_mristep_impl.h @@ -37,9 +37,6 @@ extern "C" { #define MRISTAGE_DIRK_NOFAST 2 #define MRISTAGE_DIRK_FAST 3 -/* Default inner_factor value */ -#define INNER_HFACTOR SUN_RCONST(2.0) - /* Implicit solver constants (duplicate from arkode_arkstep_impl.h) */ /* max number of nonlinear iterations */ #define MAXCOR 3 @@ -136,8 +133,7 @@ typedef struct ARKodeMRIStepMemRec MRIStepPostInnerFn post_inner_evolve; /* MRI adaptivity parameters */ - sunrealtype inner_hfactor; /* h factor for inner stepper error estimation */ - sunrealtype inner_control; /* prev control parameter (h or tolfac) */ + sunrealtype inner_control; /* prev control parameter */ sunrealtype inner_dsm; /* prev inner stepper accumulated error */ sunrealtype inner_control_new; /* upcoming control parameter */ @@ -176,7 +172,6 @@ struct _MRIStepInnerStepper_Ops MRIStepInnerResetFn reset; MRIStepInnerGetAccumulatedError geterror; MRIStepInnerResetAccumulatedError reseterror; - MRIStepInnerSetFixedStep setfixedstep; MRIStepInnerSetRTol setrtol; }; @@ -307,8 +302,6 @@ int mriStep_NlsConvTest(SUNNonlinearSolver NLS, N_Vector y, N_Vector del, /* Inner stepper functions */ int mriStepInnerStepper_HasRequiredOps(MRIStepInnerStepper stepper); -sunbooleantype mriStepInnerStepper_SupportsStepAdaptivity( - MRIStepInnerStepper stepper); sunbooleantype mriStepInnerStepper_SupportsRTolAdaptivity( MRIStepInnerStepper stepper); int mriStepInnerStepper_Evolve(MRIStepInnerStepper stepper, sunrealtype t0, @@ -320,7 +313,6 @@ int mriStepInnerStepper_Reset(MRIStepInnerStepper stepper, sunrealtype tR, int mriStepInnerStepper_GetError(MRIStepInnerStepper stepper, sunrealtype* accum_error); int mriStepInnerStepper_ResetError(MRIStepInnerStepper stepper); -int mriStepInnerStepper_SetFixedStep(MRIStepInnerStepper stepper, sunrealtype h); int mriStepInnerStepper_SetRTol(MRIStepInnerStepper stepper, sunrealtype rtol); int mriStepInnerStepper_AllocVecs(MRIStepInnerStepper stepper, int count, N_Vector tmpl); @@ -350,7 +342,6 @@ int mriStep_MRIStepInnerReset(MRIStepInnerStepper stepper, sunrealtype tR, int mriStep_MRIStepInnerGetAccumulatedError(MRIStepInnerStepper stepper, sunrealtype* accum_error); int mriStep_MRIStepInnerResetAccumulatedError(MRIStepInnerStepper stepper); -int mriStep_MRIStepInnerSetFixedStep(MRIStepInnerStepper stepper, sunrealtype h); int mriStep_MRIStepInnerSetRTol(MRIStepInnerStepper stepper, sunrealtype rtol); /*=============================================================== diff --git a/src/arkode/arkode_mristep_io.c b/src/arkode/arkode_mristep_io.c index 10633a50de..b82145ba38 100644 --- a/src/arkode/arkode_mristep_io.c +++ b/src/arkode/arkode_mristep_io.c @@ -124,46 +124,6 @@ int MRIStepSetPostInnerFn(void* arkode_mem, MRIStepPostInnerFn postfn) return (ARK_SUCCESS); } -/*--------------------------------------------------------------- - MRIStepSetFastErrorStepFactor: - - Specifies a fast stepsize factor to use when estimating the - accumulated fast time scale solution error when MRI adaptivity - is enabled. The fast integrator is run twice over each fast - time interval, once using the inner step size h, and again - using hfactor*h (typically hfactor=k or 1/k for an integer k>1). - This is only needed when the results from - mriStepInnerStepper_GetError() cannot be trusted. In our - tests, we found this to be the case when the inner integrator - uses fixed step sizes. - - An argument of 0 disables this fast error estimation strategy. - Arguments of hfactor < 0 or hfactor == 1 are illegal. - All other positive hfactor values will *attempt* to be used. - ---------------------------------------------------------------*/ -int MRIStepSetFastErrorStepFactor(void* arkode_mem, sunrealtype hfactor) -{ - ARKodeMem ark_mem; - ARKodeMRIStepMem step_mem; - int retval; - - /* access ARKodeMRIStepMem structure */ - retval = mriStep_AccessARKODEStepMem(arkode_mem, __func__, &ark_mem, &step_mem); - if (retval != ARK_SUCCESS) { return (retval); } - - /* return with error on illegal input */ - if ((hfactor < ZERO) || (hfactor == ONE)) - { - arkProcessError(ark_mem, ARK_ILL_INPUT, __LINE__, __func__, __FILE__, - "Illegal input; must be >0 and not identically 1"); - return (ARK_ILL_INPUT); - } - - /* set value and return */ - step_mem->inner_hfactor = hfactor; - return (ARK_SUCCESS); -} - /*--------------------------------------------------------------- MRIStepSetAdaptController: @@ -180,8 +140,7 @@ int MRIStepSetAdaptController(void* arkode_mem, SUNAdaptController C) SUNAdaptController_Type ctype = SUNAdaptController_GetType(C); /* If this does not have MRI type, then just pass to ARKODE */ - if ((ctype != SUN_ADAPTCONTROLLER_MRI_H) && - (ctype != SUN_ADAPTCONTROLLER_MRI_TOL)) + if (ctype != SUN_ADAPTCONTROLLER_MRI_TOL) { return (ARKodeSetAdaptController(arkode_mem, C)); } @@ -324,7 +283,6 @@ int mriStep_SetDefaults(ARKodeMem ark_mem) step_mem->jcur = SUNFALSE; step_mem->convfail = ARK_NO_FAILURES; step_mem->stage_predict = NULL; /* no user-supplied stage predictor */ - step_mem->inner_hfactor = -INNER_HFACTOR; return (ARK_SUCCESS); } diff --git a/src/arkode/fmod_int32/farkode_mristep_mod.c b/src/arkode/fmod_int32/farkode_mristep_mod.c index 059645a69f..947c6d14b1 100644 --- a/src/arkode/fmod_int32/farkode_mristep_mod.c +++ b/src/arkode/fmod_int32/farkode_mristep_mod.c @@ -785,20 +785,6 @@ SWIGEXPORT int _wrap_FMRIStepSetPostInnerFn(void *farg1, MRIStepPostInnerFn farg } -SWIGEXPORT int _wrap_FMRIStepSetFastErrorStepFactor(void *farg1, double const *farg2) { - int fresult ; - void *arg1 = (void *) 0 ; - sunrealtype arg2 ; - int result; - - arg1 = (void *)(farg1); - arg2 = (sunrealtype)(*farg2); - result = (int)MRIStepSetFastErrorStepFactor(arg1,arg2); - fresult = (int)(result); - return fresult; -} - - SWIGEXPORT int _wrap_FMRIStepSetAdaptController(void *farg1, SUNAdaptController farg2) { int fresult ; void *arg1 = (void *) 0 ; @@ -981,20 +967,6 @@ SWIGEXPORT int _wrap_FMRIStepInnerStepper_SetAccumulatedErrorResetFn(void *farg1 } -SWIGEXPORT int _wrap_FMRIStepInnerStepper_SetFixedStepFn(void *farg1, MRIStepInnerSetFixedStep farg2) { - int fresult ; - MRIStepInnerStepper arg1 = (MRIStepInnerStepper) 0 ; - MRIStepInnerSetFixedStep arg2 = (MRIStepInnerSetFixedStep) 0 ; - int result; - - arg1 = (MRIStepInnerStepper)(farg1); - arg2 = (MRIStepInnerSetFixedStep)(farg2); - result = (int)MRIStepInnerStepper_SetFixedStepFn(arg1,arg2); - fresult = (int)(result); - return fresult; -} - - SWIGEXPORT int _wrap_FMRIStepInnerStepper_SetRTolFn(void *farg1, MRIStepInnerSetRTol farg2) { int fresult ; MRIStepInnerStepper arg1 = (MRIStepInnerStepper) 0 ; diff --git a/src/arkode/fmod_int32/farkode_mristep_mod.f90 b/src/arkode/fmod_int32/farkode_mristep_mod.f90 index c0fcefa521..34961cddba 100644 --- a/src/arkode/fmod_int32/farkode_mristep_mod.f90 +++ b/src/arkode/fmod_int32/farkode_mristep_mod.f90 @@ -152,7 +152,6 @@ module farkode_mristep_mod public :: FMRIStepSetCoupling public :: FMRIStepSetPreInnerFn public :: FMRIStepSetPostInnerFn - public :: FMRIStepSetFastErrorStepFactor public :: FMRIStepSetAdaptController public :: FMRIStepGetNumRhsEvals public :: FMRIStepGetCurrentCoupling @@ -166,7 +165,6 @@ module farkode_mristep_mod public :: FMRIStepInnerStepper_SetResetFn public :: FMRIStepInnerStepper_SetAccumulatedErrorGetFn public :: FMRIStepInnerStepper_SetAccumulatedErrorResetFn - public :: FMRIStepInnerStepper_SetFixedStepFn public :: FMRIStepInnerStepper_SetRTolFn public :: FMRIStepInnerStepper_AddForcing public :: FMRIStepInnerStepper_GetForcingData @@ -584,15 +582,6 @@ function swigc_FMRIStepSetPostInnerFn(farg1, farg2) & integer(C_INT) :: fresult end function -function swigc_FMRIStepSetFastErrorStepFactor(farg1, farg2) & -bind(C, name="_wrap_FMRIStepSetFastErrorStepFactor") & -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_FMRIStepSetAdaptController(farg1, farg2) & bind(C, name="_wrap_FMRIStepSetAdaptController") & result(fresult) @@ -710,15 +699,6 @@ function swigc_FMRIStepInnerStepper_SetAccumulatedErrorResetFn(farg1, farg2) & integer(C_INT) :: fresult end function -function swigc_FMRIStepInnerStepper_SetFixedStepFn(farg1, farg2) & -bind(C, name="_wrap_FMRIStepInnerStepper_SetFixedStepFn") & -result(fresult) -use, intrinsic :: ISO_C_BINDING -type(C_PTR), value :: farg1 -type(C_FUNPTR), value :: farg2 -integer(C_INT) :: fresult -end function - function swigc_FMRIStepInnerStepper_SetRTolFn(farg1, farg2) & bind(C, name="_wrap_FMRIStepInnerStepper_SetRTolFn") & result(fresult) @@ -2102,22 +2082,6 @@ function FMRIStepSetPostInnerFn(arkode_mem, postfn) & swig_result = fresult end function -function FMRIStepSetFastErrorStepFactor(arkode_mem, hfactor) & -result(swig_result) -use, intrinsic :: ISO_C_BINDING -integer(C_INT) :: swig_result -type(C_PTR) :: arkode_mem -real(C_DOUBLE), intent(in) :: hfactor -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -real(C_DOUBLE) :: farg2 - -farg1 = arkode_mem -farg2 = hfactor -fresult = swigc_FMRIStepSetFastErrorStepFactor(farg1, farg2) -swig_result = fresult -end function - function FMRIStepSetAdaptController(arkode_mem, c) & result(swig_result) use, intrinsic :: ISO_C_BINDING @@ -2326,22 +2290,6 @@ function FMRIStepInnerStepper_SetAccumulatedErrorResetFn(stepper, fn) & swig_result = fresult end function -function FMRIStepInnerStepper_SetFixedStepFn(stepper, fn) & -result(swig_result) -use, intrinsic :: ISO_C_BINDING -integer(C_INT) :: swig_result -type(C_PTR) :: stepper -type(C_FUNPTR), intent(in), value :: fn -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_FUNPTR) :: farg2 - -farg1 = stepper -farg2 = fn -fresult = swigc_FMRIStepInnerStepper_SetFixedStepFn(farg1, farg2) -swig_result = fresult -end function - function FMRIStepInnerStepper_SetRTolFn(stepper, fn) & result(swig_result) use, intrinsic :: ISO_C_BINDING diff --git a/src/arkode/fmod_int64/farkode_mristep_mod.c b/src/arkode/fmod_int64/farkode_mristep_mod.c index 03e9bb8af1..0e4d347155 100644 --- a/src/arkode/fmod_int64/farkode_mristep_mod.c +++ b/src/arkode/fmod_int64/farkode_mristep_mod.c @@ -785,20 +785,6 @@ SWIGEXPORT int _wrap_FMRIStepSetPostInnerFn(void *farg1, MRIStepPostInnerFn farg } -SWIGEXPORT int _wrap_FMRIStepSetFastErrorStepFactor(void *farg1, double const *farg2) { - int fresult ; - void *arg1 = (void *) 0 ; - sunrealtype arg2 ; - int result; - - arg1 = (void *)(farg1); - arg2 = (sunrealtype)(*farg2); - result = (int)MRIStepSetFastErrorStepFactor(arg1,arg2); - fresult = (int)(result); - return fresult; -} - - SWIGEXPORT int _wrap_FMRIStepSetAdaptController(void *farg1, SUNAdaptController farg2) { int fresult ; void *arg1 = (void *) 0 ; @@ -981,20 +967,6 @@ SWIGEXPORT int _wrap_FMRIStepInnerStepper_SetAccumulatedErrorResetFn(void *farg1 } -SWIGEXPORT int _wrap_FMRIStepInnerStepper_SetFixedStepFn(void *farg1, MRIStepInnerSetFixedStep farg2) { - int fresult ; - MRIStepInnerStepper arg1 = (MRIStepInnerStepper) 0 ; - MRIStepInnerSetFixedStep arg2 = (MRIStepInnerSetFixedStep) 0 ; - int result; - - arg1 = (MRIStepInnerStepper)(farg1); - arg2 = (MRIStepInnerSetFixedStep)(farg2); - result = (int)MRIStepInnerStepper_SetFixedStepFn(arg1,arg2); - fresult = (int)(result); - return fresult; -} - - SWIGEXPORT int _wrap_FMRIStepInnerStepper_SetRTolFn(void *farg1, MRIStepInnerSetRTol farg2) { int fresult ; MRIStepInnerStepper arg1 = (MRIStepInnerStepper) 0 ; diff --git a/src/arkode/fmod_int64/farkode_mristep_mod.f90 b/src/arkode/fmod_int64/farkode_mristep_mod.f90 index 2c348f0c08..ea97add0e3 100644 --- a/src/arkode/fmod_int64/farkode_mristep_mod.f90 +++ b/src/arkode/fmod_int64/farkode_mristep_mod.f90 @@ -152,7 +152,6 @@ module farkode_mristep_mod public :: FMRIStepSetCoupling public :: FMRIStepSetPreInnerFn public :: FMRIStepSetPostInnerFn - public :: FMRIStepSetFastErrorStepFactor public :: FMRIStepSetAdaptController public :: FMRIStepGetNumRhsEvals public :: FMRIStepGetCurrentCoupling @@ -166,7 +165,6 @@ module farkode_mristep_mod public :: FMRIStepInnerStepper_SetResetFn public :: FMRIStepInnerStepper_SetAccumulatedErrorGetFn public :: FMRIStepInnerStepper_SetAccumulatedErrorResetFn - public :: FMRIStepInnerStepper_SetFixedStepFn public :: FMRIStepInnerStepper_SetRTolFn public :: FMRIStepInnerStepper_AddForcing public :: FMRIStepInnerStepper_GetForcingData @@ -584,15 +582,6 @@ function swigc_FMRIStepSetPostInnerFn(farg1, farg2) & integer(C_INT) :: fresult end function -function swigc_FMRIStepSetFastErrorStepFactor(farg1, farg2) & -bind(C, name="_wrap_FMRIStepSetFastErrorStepFactor") & -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_FMRIStepSetAdaptController(farg1, farg2) & bind(C, name="_wrap_FMRIStepSetAdaptController") & result(fresult) @@ -710,15 +699,6 @@ function swigc_FMRIStepInnerStepper_SetAccumulatedErrorResetFn(farg1, farg2) & integer(C_INT) :: fresult end function -function swigc_FMRIStepInnerStepper_SetFixedStepFn(farg1, farg2) & -bind(C, name="_wrap_FMRIStepInnerStepper_SetFixedStepFn") & -result(fresult) -use, intrinsic :: ISO_C_BINDING -type(C_PTR), value :: farg1 -type(C_FUNPTR), value :: farg2 -integer(C_INT) :: fresult -end function - function swigc_FMRIStepInnerStepper_SetRTolFn(farg1, farg2) & bind(C, name="_wrap_FMRIStepInnerStepper_SetRTolFn") & result(fresult) @@ -2102,22 +2082,6 @@ function FMRIStepSetPostInnerFn(arkode_mem, postfn) & swig_result = fresult end function -function FMRIStepSetFastErrorStepFactor(arkode_mem, hfactor) & -result(swig_result) -use, intrinsic :: ISO_C_BINDING -integer(C_INT) :: swig_result -type(C_PTR) :: arkode_mem -real(C_DOUBLE), intent(in) :: hfactor -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -real(C_DOUBLE) :: farg2 - -farg1 = arkode_mem -farg2 = hfactor -fresult = swigc_FMRIStepSetFastErrorStepFactor(farg1, farg2) -swig_result = fresult -end function - function FMRIStepSetAdaptController(arkode_mem, c) & result(swig_result) use, intrinsic :: ISO_C_BINDING @@ -2326,22 +2290,6 @@ function FMRIStepInnerStepper_SetAccumulatedErrorResetFn(stepper, fn) & swig_result = fresult end function -function FMRIStepInnerStepper_SetFixedStepFn(stepper, fn) & -result(swig_result) -use, intrinsic :: ISO_C_BINDING -integer(C_INT) :: swig_result -type(C_PTR) :: stepper -type(C_FUNPTR), intent(in), value :: fn -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_FUNPTR) :: farg2 - -farg1 = stepper -farg2 = fn -fresult = swigc_FMRIStepInnerStepper_SetFixedStepFn(farg1, farg2) -swig_result = fresult -end function - function FMRIStepInnerStepper_SetRTolFn(stepper, fn) & result(swig_result) use, intrinsic :: ISO_C_BINDING diff --git a/src/sunadaptcontroller/CMakeLists.txt b/src/sunadaptcontroller/CMakeLists.txt index 544a59d062..2a5c3db1a5 100644 --- a/src/sunadaptcontroller/CMakeLists.txt +++ b/src/sunadaptcontroller/CMakeLists.txt @@ -17,8 +17,4 @@ # required native adaptivity controllers add_subdirectory(imexgus) add_subdirectory(soderlind) -add_subdirectory(mricc) add_subdirectory(mrihtol) -add_subdirectory(mrill) -add_subdirectory(mripi) -add_subdirectory(mripid) diff --git a/src/sunadaptcontroller/mricc/CMakeLists.txt b/src/sunadaptcontroller/mricc/CMakeLists.txt deleted file mode 100644 index 7095010357..0000000000 --- a/src/sunadaptcontroller/mricc/CMakeLists.txt +++ /dev/null @@ -1,28 +0,0 @@ -# --------------------------------------------------------------- -# Programmer(s): Daniel R. Reynolds @ SMU -# --------------------------------------------------------------- -# SUNDIALS Copyright Start -# Copyright (c) 2002-2024, 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_sunadaptcontrollermricc - SOURCES sunadaptcontroller_mricc.c - HEADERS - ${SUNDIALS_SOURCE_DIR}/include/sunadaptcontroller/sunadaptcontroller_mricc.h - LINK_LIBRARIES PUBLIC sundials_core - INCLUDE_SUBDIR sunadaptcontroller - OBJECT_LIB_ONLY) - -# Add F2003 module if the interface is enabled -if(BUILD_FORTRAN_MODULE_INTERFACE) - add_subdirectory("fmod_int${SUNDIALS_INDEX_SIZE}") -endif() diff --git a/src/sunadaptcontroller/mricc/fmod_int32/CMakeLists.txt b/src/sunadaptcontroller/mricc/fmod_int32/CMakeLists.txt deleted file mode 100644 index 62a5a53deb..0000000000 --- a/src/sunadaptcontroller/mricc/fmod_int32/CMakeLists.txt +++ /dev/null @@ -1,26 +0,0 @@ -# --------------------------------------------------------------- -# Programmer(s): Daniel R. Reynolds @ SMU -# --------------------------------------------------------------- -# SUNDIALS Copyright Start -# Copyright (c) 2002-2024, 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_fsunadaptcontrollermricc_mod - SOURCES - fsunadaptcontroller_mricc_mod.f90 fsunadaptcontroller_mricc_mod.c - LINK_LIBRARIES - PUBLIC sundials_fcore_mod - OBJECT_LIBRARIES - OUTPUT_NAME - sundials_fsunadaptcontrollermricc_mod - OBJECT_LIB_ONLY -) - -message(STATUS "Added SUNAdaptController_MRICC F2003 interface") diff --git a/src/sunadaptcontroller/mricc/fmod_int32/fsunadaptcontroller_mricc_mod.c b/src/sunadaptcontroller/mricc/fmod_int32/fsunadaptcontroller_mricc_mod.c deleted file mode 100644 index 4977082c1a..0000000000 --- a/src/sunadaptcontroller/mricc/fmod_int32/fsunadaptcontroller_mricc_mod.c +++ /dev/null @@ -1,335 +0,0 @@ -/* ---------------------------------------------------------------------------- - * This file was automatically generated by SWIG (http://www.swig.org). - * Version 4.0.0 - * - * This file is not intended to be easily readable and contains a number of - * coding conventions designed to improve portability and efficiency. Do not make - * changes to this file unless you know what you are doing--modify the SWIG - * interface file instead. - * ----------------------------------------------------------------------------- */ - -/* --------------------------------------------------------------- - * Programmer(s): Auto-generated by swig. - * --------------------------------------------------------------- - * SUNDIALS Copyright Start - * Copyright (c) 2002-2024, 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_mricc.h" - -SWIGEXPORT SUNAdaptController _wrap_FSUNAdaptController_MRICC(void *farg1, int const *farg2) { - SUNAdaptController fresult ; - SUNContext arg1 = (SUNContext) 0 ; - int arg2 ; - SUNAdaptController result; - - arg1 = (SUNContext)(farg1); - arg2 = (int)(*farg2); - result = (SUNAdaptController)SUNAdaptController_MRICC(arg1,arg2); - fresult = result; - return fresult; -} - - -SWIGEXPORT int _wrap_FSUNAdaptController_SetParams_MRICC(SUNAdaptController farg1, double const *farg2, double const *farg3) { - int fresult ; - SUNAdaptController arg1 = (SUNAdaptController) 0 ; - sunrealtype arg2 ; - sunrealtype arg3 ; - int result; - - arg1 = (SUNAdaptController)(farg1); - arg2 = (sunrealtype)(*farg2); - arg3 = (sunrealtype)(*farg3); - result = (int)SUNAdaptController_SetParams_MRICC(arg1,arg2,arg3); - fresult = (int)(result); - return fresult; -} - - -SWIGEXPORT int _wrap_FSUNAdaptController_GetType_MRICC(SUNAdaptController farg1) { - int fresult ; - SUNAdaptController arg1 = (SUNAdaptController) 0 ; - SUNAdaptController_Type result; - - arg1 = (SUNAdaptController)(farg1); - result = (SUNAdaptController_Type)SUNAdaptController_GetType_MRICC(arg1); - fresult = (int)(result); - return fresult; -} - - -SWIGEXPORT int _wrap_FSUNAdaptController_EstimateMRISteps_MRICC(SUNAdaptController farg1, double const *farg2, double const *farg3, int const *farg4, double const *farg5, double const *farg6, double *farg7, double *farg8) { - int fresult ; - SUNAdaptController arg1 = (SUNAdaptController) 0 ; - sunrealtype arg2 ; - sunrealtype arg3 ; - int arg4 ; - sunrealtype arg5 ; - sunrealtype arg6 ; - sunrealtype *arg7 = (sunrealtype *) 0 ; - sunrealtype *arg8 = (sunrealtype *) 0 ; - int result; - - arg1 = (SUNAdaptController)(farg1); - arg2 = (sunrealtype)(*farg2); - arg3 = (sunrealtype)(*farg3); - arg4 = (int)(*farg4); - arg5 = (sunrealtype)(*farg5); - arg6 = (sunrealtype)(*farg6); - arg7 = (sunrealtype *)(farg7); - arg8 = (sunrealtype *)(farg8); - result = (int)SUNAdaptController_EstimateMRISteps_MRICC(arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8); - fresult = (int)(result); - return fresult; -} - - -SWIGEXPORT int _wrap_FSUNAdaptController_SetDefaults_MRICC(SUNAdaptController farg1) { - int fresult ; - SUNAdaptController arg1 = (SUNAdaptController) 0 ; - int result; - - arg1 = (SUNAdaptController)(farg1); - result = (int)SUNAdaptController_SetDefaults_MRICC(arg1); - fresult = (int)(result); - return fresult; -} - - -SWIGEXPORT int _wrap_FSUNAdaptController_Write_MRICC(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_MRICC(arg1,arg2); - fresult = (int)(result); - return fresult; -} - - -SWIGEXPORT int _wrap_FSUNAdaptController_SetErrorBias_MRICC(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_MRICC(arg1,arg2); - fresult = (int)(result); - return fresult; -} - - -SWIGEXPORT int _wrap_FSUNAdaptController_Space_MRICC(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_MRICC(arg1,arg2,arg3); - fresult = (int)(result); - return fresult; -} - - - diff --git a/src/sunadaptcontroller/mricc/fmod_int32/fsunadaptcontroller_mricc_mod.f90 b/src/sunadaptcontroller/mricc/fmod_int32/fsunadaptcontroller_mricc_mod.f90 deleted file mode 100644 index 288998e74f..0000000000 --- a/src/sunadaptcontroller/mricc/fmod_int32/fsunadaptcontroller_mricc_mod.f90 +++ /dev/null @@ -1,269 +0,0 @@ -! This file was automatically generated by SWIG (http://www.swig.org). -! Version 4.0.0 -! -! Do not make changes to this file unless you know what you are doing--modify -! the SWIG interface file instead. - -! --------------------------------------------------------------- -! Programmer(s): Auto-generated by swig. -! --------------------------------------------------------------- -! SUNDIALS Copyright Start -! Copyright (c) 2002-2024, 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_mricc_mod - use, intrinsic :: ISO_C_BINDING - use fsundials_core_mod - implicit none - private - - ! DECLARATION CONSTRUCTS - public :: FSUNAdaptController_MRICC - public :: FSUNAdaptController_SetParams_MRICC - public :: FSUNAdaptController_GetType_MRICC - public :: FSUNAdaptController_EstimateMRISteps_MRICC - public :: FSUNAdaptController_SetDefaults_MRICC - public :: FSUNAdaptController_Write_MRICC - public :: FSUNAdaptController_SetErrorBias_MRICC - public :: FSUNAdaptController_Space_MRICC - -! WRAPPER DECLARATIONS -interface -function swigc_FSUNAdaptController_MRICC(farg1, farg2) & -bind(C, name="_wrap_FSUNAdaptController_MRICC") & -result(fresult) -use, intrinsic :: ISO_C_BINDING -type(C_PTR), value :: farg1 -integer(C_INT), intent(in) :: farg2 -type(C_PTR) :: fresult -end function - -function swigc_FSUNAdaptController_SetParams_MRICC(farg1, farg2, farg3) & -bind(C, name="_wrap_FSUNAdaptController_SetParams_MRICC") & -result(fresult) -use, intrinsic :: ISO_C_BINDING -type(C_PTR), value :: farg1 -real(C_DOUBLE), intent(in) :: farg2 -real(C_DOUBLE), intent(in) :: farg3 -integer(C_INT) :: fresult -end function - -function swigc_FSUNAdaptController_GetType_MRICC(farg1) & -bind(C, name="_wrap_FSUNAdaptController_GetType_MRICC") & -result(fresult) -use, intrinsic :: ISO_C_BINDING -type(C_PTR), value :: farg1 -integer(C_INT) :: fresult -end function - -function swigc_FSUNAdaptController_EstimateMRISteps_MRICC(farg1, farg2, farg3, farg4, farg5, farg6, farg7, farg8) & -bind(C, name="_wrap_FSUNAdaptController_EstimateMRISteps_MRICC") & -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 -real(C_DOUBLE), intent(in) :: farg5 -real(C_DOUBLE), intent(in) :: farg6 -type(C_PTR), value :: farg7 -type(C_PTR), value :: farg8 -integer(C_INT) :: fresult -end function - -function swigc_FSUNAdaptController_SetDefaults_MRICC(farg1) & -bind(C, name="_wrap_FSUNAdaptController_SetDefaults_MRICC") & -result(fresult) -use, intrinsic :: ISO_C_BINDING -type(C_PTR), value :: farg1 -integer(C_INT) :: fresult -end function - -function swigc_FSUNAdaptController_Write_MRICC(farg1, farg2) & -bind(C, name="_wrap_FSUNAdaptController_Write_MRICC") & -result(fresult) -use, intrinsic :: ISO_C_BINDING -type(C_PTR), value :: farg1 -type(C_PTR), value :: farg2 -integer(C_INT) :: fresult -end function - -function swigc_FSUNAdaptController_SetErrorBias_MRICC(farg1, farg2) & -bind(C, name="_wrap_FSUNAdaptController_SetErrorBias_MRICC") & -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_MRICC(farg1, farg2, farg3) & -bind(C, name="_wrap_FSUNAdaptController_Space_MRICC") & -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_MRICC(sunctx, p) & -result(swig_result) -use, intrinsic :: ISO_C_BINDING -type(SUNAdaptController), pointer :: swig_result -type(C_PTR) :: sunctx -integer(C_INT), intent(in) :: p -type(C_PTR) :: fresult -type(C_PTR) :: farg1 -integer(C_INT) :: farg2 - -farg1 = sunctx -farg2 = p -fresult = swigc_FSUNAdaptController_MRICC(farg1, farg2) -call c_f_pointer(fresult, swig_result) -end function - -function FSUNAdaptController_SetParams_MRICC(c, k1, k2) & -result(swig_result) -use, intrinsic :: ISO_C_BINDING -integer(C_INT) :: swig_result -type(SUNAdaptController), target, intent(inout) :: c -real(C_DOUBLE), intent(in) :: k1 -real(C_DOUBLE), intent(in) :: k2 -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -real(C_DOUBLE) :: farg2 -real(C_DOUBLE) :: farg3 - -farg1 = c_loc(c) -farg2 = k1 -farg3 = k2 -fresult = swigc_FSUNAdaptController_SetParams_MRICC(farg1, farg2, farg3) -swig_result = fresult -end function - -function FSUNAdaptController_GetType_MRICC(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_MRICC(farg1) -swig_result = fresult -end function - -function FSUNAdaptController_EstimateMRISteps_MRICC(c, h, h2, p, dsm, dsm5, hnew, hnew7) & -result(swig_result) -use, intrinsic :: ISO_C_BINDING -integer(C_INT) :: swig_result -type(SUNAdaptController), target, intent(inout) :: c -real(C_DOUBLE), intent(in) :: h -real(C_DOUBLE), intent(in) :: h2 -integer(C_INT), intent(in) :: p -real(C_DOUBLE), intent(in) :: dsm -real(C_DOUBLE), intent(in) :: dsm5 -real(C_DOUBLE), dimension(*), target, intent(inout) :: hnew -real(C_DOUBLE), dimension(*), target, intent(inout) :: hnew7 -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -real(C_DOUBLE) :: farg2 -real(C_DOUBLE) :: farg3 -integer(C_INT) :: farg4 -real(C_DOUBLE) :: farg5 -real(C_DOUBLE) :: farg6 -type(C_PTR) :: farg7 -type(C_PTR) :: farg8 - -farg1 = c_loc(c) -farg2 = h -farg3 = h2 -farg4 = p -farg5 = dsm -farg6 = dsm5 -farg7 = c_loc(hnew(1)) -farg8 = c_loc(hnew7(1)) -fresult = swigc_FSUNAdaptController_EstimateMRISteps_MRICC(farg1, farg2, farg3, farg4, farg5, farg6, farg7, farg8) -swig_result = fresult -end function - -function FSUNAdaptController_SetDefaults_MRICC(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_MRICC(farg1) -swig_result = fresult -end function - -function FSUNAdaptController_Write_MRICC(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_MRICC(farg1, farg2) -swig_result = fresult -end function - -function FSUNAdaptController_SetErrorBias_MRICC(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_MRICC(farg1, farg2) -swig_result = fresult -end function - -function FSUNAdaptController_Space_MRICC(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_MRICC(farg1, farg2, farg3) -swig_result = fresult -end function - - -end module diff --git a/src/sunadaptcontroller/mricc/fmod_int64/CMakeLists.txt b/src/sunadaptcontroller/mricc/fmod_int64/CMakeLists.txt deleted file mode 100644 index 62a5a53deb..0000000000 --- a/src/sunadaptcontroller/mricc/fmod_int64/CMakeLists.txt +++ /dev/null @@ -1,26 +0,0 @@ -# --------------------------------------------------------------- -# Programmer(s): Daniel R. Reynolds @ SMU -# --------------------------------------------------------------- -# SUNDIALS Copyright Start -# Copyright (c) 2002-2024, 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_fsunadaptcontrollermricc_mod - SOURCES - fsunadaptcontroller_mricc_mod.f90 fsunadaptcontroller_mricc_mod.c - LINK_LIBRARIES - PUBLIC sundials_fcore_mod - OBJECT_LIBRARIES - OUTPUT_NAME - sundials_fsunadaptcontrollermricc_mod - OBJECT_LIB_ONLY -) - -message(STATUS "Added SUNAdaptController_MRICC F2003 interface") diff --git a/src/sunadaptcontroller/mricc/fmod_int64/fsunadaptcontroller_mricc_mod.c b/src/sunadaptcontroller/mricc/fmod_int64/fsunadaptcontroller_mricc_mod.c deleted file mode 100644 index 4977082c1a..0000000000 --- a/src/sunadaptcontroller/mricc/fmod_int64/fsunadaptcontroller_mricc_mod.c +++ /dev/null @@ -1,335 +0,0 @@ -/* ---------------------------------------------------------------------------- - * This file was automatically generated by SWIG (http://www.swig.org). - * Version 4.0.0 - * - * This file is not intended to be easily readable and contains a number of - * coding conventions designed to improve portability and efficiency. Do not make - * changes to this file unless you know what you are doing--modify the SWIG - * interface file instead. - * ----------------------------------------------------------------------------- */ - -/* --------------------------------------------------------------- - * Programmer(s): Auto-generated by swig. - * --------------------------------------------------------------- - * SUNDIALS Copyright Start - * Copyright (c) 2002-2024, 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_mricc.h" - -SWIGEXPORT SUNAdaptController _wrap_FSUNAdaptController_MRICC(void *farg1, int const *farg2) { - SUNAdaptController fresult ; - SUNContext arg1 = (SUNContext) 0 ; - int arg2 ; - SUNAdaptController result; - - arg1 = (SUNContext)(farg1); - arg2 = (int)(*farg2); - result = (SUNAdaptController)SUNAdaptController_MRICC(arg1,arg2); - fresult = result; - return fresult; -} - - -SWIGEXPORT int _wrap_FSUNAdaptController_SetParams_MRICC(SUNAdaptController farg1, double const *farg2, double const *farg3) { - int fresult ; - SUNAdaptController arg1 = (SUNAdaptController) 0 ; - sunrealtype arg2 ; - sunrealtype arg3 ; - int result; - - arg1 = (SUNAdaptController)(farg1); - arg2 = (sunrealtype)(*farg2); - arg3 = (sunrealtype)(*farg3); - result = (int)SUNAdaptController_SetParams_MRICC(arg1,arg2,arg3); - fresult = (int)(result); - return fresult; -} - - -SWIGEXPORT int _wrap_FSUNAdaptController_GetType_MRICC(SUNAdaptController farg1) { - int fresult ; - SUNAdaptController arg1 = (SUNAdaptController) 0 ; - SUNAdaptController_Type result; - - arg1 = (SUNAdaptController)(farg1); - result = (SUNAdaptController_Type)SUNAdaptController_GetType_MRICC(arg1); - fresult = (int)(result); - return fresult; -} - - -SWIGEXPORT int _wrap_FSUNAdaptController_EstimateMRISteps_MRICC(SUNAdaptController farg1, double const *farg2, double const *farg3, int const *farg4, double const *farg5, double const *farg6, double *farg7, double *farg8) { - int fresult ; - SUNAdaptController arg1 = (SUNAdaptController) 0 ; - sunrealtype arg2 ; - sunrealtype arg3 ; - int arg4 ; - sunrealtype arg5 ; - sunrealtype arg6 ; - sunrealtype *arg7 = (sunrealtype *) 0 ; - sunrealtype *arg8 = (sunrealtype *) 0 ; - int result; - - arg1 = (SUNAdaptController)(farg1); - arg2 = (sunrealtype)(*farg2); - arg3 = (sunrealtype)(*farg3); - arg4 = (int)(*farg4); - arg5 = (sunrealtype)(*farg5); - arg6 = (sunrealtype)(*farg6); - arg7 = (sunrealtype *)(farg7); - arg8 = (sunrealtype *)(farg8); - result = (int)SUNAdaptController_EstimateMRISteps_MRICC(arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8); - fresult = (int)(result); - return fresult; -} - - -SWIGEXPORT int _wrap_FSUNAdaptController_SetDefaults_MRICC(SUNAdaptController farg1) { - int fresult ; - SUNAdaptController arg1 = (SUNAdaptController) 0 ; - int result; - - arg1 = (SUNAdaptController)(farg1); - result = (int)SUNAdaptController_SetDefaults_MRICC(arg1); - fresult = (int)(result); - return fresult; -} - - -SWIGEXPORT int _wrap_FSUNAdaptController_Write_MRICC(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_MRICC(arg1,arg2); - fresult = (int)(result); - return fresult; -} - - -SWIGEXPORT int _wrap_FSUNAdaptController_SetErrorBias_MRICC(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_MRICC(arg1,arg2); - fresult = (int)(result); - return fresult; -} - - -SWIGEXPORT int _wrap_FSUNAdaptController_Space_MRICC(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_MRICC(arg1,arg2,arg3); - fresult = (int)(result); - return fresult; -} - - - diff --git a/src/sunadaptcontroller/mricc/fmod_int64/fsunadaptcontroller_mricc_mod.f90 b/src/sunadaptcontroller/mricc/fmod_int64/fsunadaptcontroller_mricc_mod.f90 deleted file mode 100644 index 288998e74f..0000000000 --- a/src/sunadaptcontroller/mricc/fmod_int64/fsunadaptcontroller_mricc_mod.f90 +++ /dev/null @@ -1,269 +0,0 @@ -! This file was automatically generated by SWIG (http://www.swig.org). -! Version 4.0.0 -! -! Do not make changes to this file unless you know what you are doing--modify -! the SWIG interface file instead. - -! --------------------------------------------------------------- -! Programmer(s): Auto-generated by swig. -! --------------------------------------------------------------- -! SUNDIALS Copyright Start -! Copyright (c) 2002-2024, 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_mricc_mod - use, intrinsic :: ISO_C_BINDING - use fsundials_core_mod - implicit none - private - - ! DECLARATION CONSTRUCTS - public :: FSUNAdaptController_MRICC - public :: FSUNAdaptController_SetParams_MRICC - public :: FSUNAdaptController_GetType_MRICC - public :: FSUNAdaptController_EstimateMRISteps_MRICC - public :: FSUNAdaptController_SetDefaults_MRICC - public :: FSUNAdaptController_Write_MRICC - public :: FSUNAdaptController_SetErrorBias_MRICC - public :: FSUNAdaptController_Space_MRICC - -! WRAPPER DECLARATIONS -interface -function swigc_FSUNAdaptController_MRICC(farg1, farg2) & -bind(C, name="_wrap_FSUNAdaptController_MRICC") & -result(fresult) -use, intrinsic :: ISO_C_BINDING -type(C_PTR), value :: farg1 -integer(C_INT), intent(in) :: farg2 -type(C_PTR) :: fresult -end function - -function swigc_FSUNAdaptController_SetParams_MRICC(farg1, farg2, farg3) & -bind(C, name="_wrap_FSUNAdaptController_SetParams_MRICC") & -result(fresult) -use, intrinsic :: ISO_C_BINDING -type(C_PTR), value :: farg1 -real(C_DOUBLE), intent(in) :: farg2 -real(C_DOUBLE), intent(in) :: farg3 -integer(C_INT) :: fresult -end function - -function swigc_FSUNAdaptController_GetType_MRICC(farg1) & -bind(C, name="_wrap_FSUNAdaptController_GetType_MRICC") & -result(fresult) -use, intrinsic :: ISO_C_BINDING -type(C_PTR), value :: farg1 -integer(C_INT) :: fresult -end function - -function swigc_FSUNAdaptController_EstimateMRISteps_MRICC(farg1, farg2, farg3, farg4, farg5, farg6, farg7, farg8) & -bind(C, name="_wrap_FSUNAdaptController_EstimateMRISteps_MRICC") & -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 -real(C_DOUBLE), intent(in) :: farg5 -real(C_DOUBLE), intent(in) :: farg6 -type(C_PTR), value :: farg7 -type(C_PTR), value :: farg8 -integer(C_INT) :: fresult -end function - -function swigc_FSUNAdaptController_SetDefaults_MRICC(farg1) & -bind(C, name="_wrap_FSUNAdaptController_SetDefaults_MRICC") & -result(fresult) -use, intrinsic :: ISO_C_BINDING -type(C_PTR), value :: farg1 -integer(C_INT) :: fresult -end function - -function swigc_FSUNAdaptController_Write_MRICC(farg1, farg2) & -bind(C, name="_wrap_FSUNAdaptController_Write_MRICC") & -result(fresult) -use, intrinsic :: ISO_C_BINDING -type(C_PTR), value :: farg1 -type(C_PTR), value :: farg2 -integer(C_INT) :: fresult -end function - -function swigc_FSUNAdaptController_SetErrorBias_MRICC(farg1, farg2) & -bind(C, name="_wrap_FSUNAdaptController_SetErrorBias_MRICC") & -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_MRICC(farg1, farg2, farg3) & -bind(C, name="_wrap_FSUNAdaptController_Space_MRICC") & -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_MRICC(sunctx, p) & -result(swig_result) -use, intrinsic :: ISO_C_BINDING -type(SUNAdaptController), pointer :: swig_result -type(C_PTR) :: sunctx -integer(C_INT), intent(in) :: p -type(C_PTR) :: fresult -type(C_PTR) :: farg1 -integer(C_INT) :: farg2 - -farg1 = sunctx -farg2 = p -fresult = swigc_FSUNAdaptController_MRICC(farg1, farg2) -call c_f_pointer(fresult, swig_result) -end function - -function FSUNAdaptController_SetParams_MRICC(c, k1, k2) & -result(swig_result) -use, intrinsic :: ISO_C_BINDING -integer(C_INT) :: swig_result -type(SUNAdaptController), target, intent(inout) :: c -real(C_DOUBLE), intent(in) :: k1 -real(C_DOUBLE), intent(in) :: k2 -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -real(C_DOUBLE) :: farg2 -real(C_DOUBLE) :: farg3 - -farg1 = c_loc(c) -farg2 = k1 -farg3 = k2 -fresult = swigc_FSUNAdaptController_SetParams_MRICC(farg1, farg2, farg3) -swig_result = fresult -end function - -function FSUNAdaptController_GetType_MRICC(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_MRICC(farg1) -swig_result = fresult -end function - -function FSUNAdaptController_EstimateMRISteps_MRICC(c, h, h2, p, dsm, dsm5, hnew, hnew7) & -result(swig_result) -use, intrinsic :: ISO_C_BINDING -integer(C_INT) :: swig_result -type(SUNAdaptController), target, intent(inout) :: c -real(C_DOUBLE), intent(in) :: h -real(C_DOUBLE), intent(in) :: h2 -integer(C_INT), intent(in) :: p -real(C_DOUBLE), intent(in) :: dsm -real(C_DOUBLE), intent(in) :: dsm5 -real(C_DOUBLE), dimension(*), target, intent(inout) :: hnew -real(C_DOUBLE), dimension(*), target, intent(inout) :: hnew7 -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -real(C_DOUBLE) :: farg2 -real(C_DOUBLE) :: farg3 -integer(C_INT) :: farg4 -real(C_DOUBLE) :: farg5 -real(C_DOUBLE) :: farg6 -type(C_PTR) :: farg7 -type(C_PTR) :: farg8 - -farg1 = c_loc(c) -farg2 = h -farg3 = h2 -farg4 = p -farg5 = dsm -farg6 = dsm5 -farg7 = c_loc(hnew(1)) -farg8 = c_loc(hnew7(1)) -fresult = swigc_FSUNAdaptController_EstimateMRISteps_MRICC(farg1, farg2, farg3, farg4, farg5, farg6, farg7, farg8) -swig_result = fresult -end function - -function FSUNAdaptController_SetDefaults_MRICC(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_MRICC(farg1) -swig_result = fresult -end function - -function FSUNAdaptController_Write_MRICC(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_MRICC(farg1, farg2) -swig_result = fresult -end function - -function FSUNAdaptController_SetErrorBias_MRICC(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_MRICC(farg1, farg2) -swig_result = fresult -end function - -function FSUNAdaptController_Space_MRICC(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_MRICC(farg1, farg2, farg3) -swig_result = fresult -end function - - -end module diff --git a/src/sunadaptcontroller/mricc/sunadaptcontroller_mricc.c b/src/sunadaptcontroller/mricc/sunadaptcontroller_mricc.c deleted file mode 100644 index be379fd3b5..0000000000 --- a/src/sunadaptcontroller/mricc/sunadaptcontroller_mricc.c +++ /dev/null @@ -1,189 +0,0 @@ -/* ----------------------------------------------------------------- - * Programmer(s): Daniel R. Reynolds @ SMU - * ----------------------------------------------------------------- - * SUNDIALS Copyright Start - * Copyright (c) 2002-2024, 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_MRICC module. - * -----------------------------------------------------------------*/ - -#include -#include -#include -#include - -#include "sundials/priv/sundials_errors_impl.h" -#include "sundials/sundials_errors.h" - -/* --------------- - * Macro accessors - * --------------- */ - -#define MRICC_CONTENT(C) ((SUNAdaptControllerContent_MRICC)(C->content)) -#define MRICC_K1(C) (MRICC_CONTENT(C)->k1) -#define MRICC_K2(C) (MRICC_CONTENT(C)->k2) -#define MRICC_BIAS(C) (MRICC_CONTENT(C)->bias) -#define MRICC_PFAST(C) (MRICC_CONTENT(C)->p) - -/* ------------------ - * Default parameters - * ------------------ */ - -#define DEFAULT_K1 SUN_RCONST(0.42) -#define DEFAULT_K2 SUN_RCONST(0.44) -#define DEFAULT_BIAS SUN_RCONST(1.5) -#define ONE SUN_RCONST(1.0) -#define TINY (SUN_RCONST(10.0) * SUN_UNIT_ROUNDOFF) - -/* ----------------------------------------------------------------- - * exported functions - * ----------------------------------------------------------------- */ - -/* ----------------------------------------------------------------- - * Function to create a new MRICC controller - */ - -SUNAdaptController SUNAdaptController_MRICC(SUNContext sunctx, int p) -{ - SUNFunctionBegin(sunctx); - - SUNAdaptController C; - SUNAdaptControllerContent_MRICC content; - - /* Create an empty controller object */ - C = NULL; - C = SUNAdaptController_NewEmpty(sunctx); - SUNCheckLastErrNull(); - - /* Attach operations */ - C->ops->gettype = SUNAdaptController_GetType_MRICC; - C->ops->estimatemristeps = SUNAdaptController_EstimateMRISteps_MRICC; - C->ops->setdefaults = SUNAdaptController_SetDefaults_MRICC; - C->ops->write = SUNAdaptController_Write_MRICC; - C->ops->seterrorbias = SUNAdaptController_SetErrorBias_MRICC; - C->ops->space = SUNAdaptController_Space_MRICC; - - /* Create content */ - content = NULL; - content = (SUNAdaptControllerContent_MRICC)malloc(sizeof *content); - SUNAssertNull(content, SUN_ERR_MALLOC_FAIL); - - /* Attach content */ - C->content = content; - - /* Set fast method order */ - content->p = p; - - /* Fill content with default/reset values */ - SUNCheckCallNull(SUNAdaptController_SetDefaults_MRICC(C)); - - return (C); -} - -/* ----------------------------------------------------------------- - * Function to set MRICC parameters - */ - -SUNErrCode SUNAdaptController_SetParams_MRICC(SUNAdaptController C, - sunrealtype k1, sunrealtype k2) -{ - SUNFunctionBegin(C->sunctx); - MRICC_K1(C) = k1; - MRICC_K2(C) = k2; - return SUN_SUCCESS; -} - -/* ----------------------------------------------------------------- - * implementation of controller operations - * ----------------------------------------------------------------- */ - -SUNAdaptController_Type SUNAdaptController_GetType_MRICC(SUNAdaptController C) -{ - return SUN_ADAPTCONTROLLER_MRI_H; -} - -SUNErrCode SUNAdaptController_EstimateMRISteps_MRICC( - SUNAdaptController C, sunrealtype H, sunrealtype h, int P, sunrealtype DSM, - sunrealtype dsm, sunrealtype* Hnew, sunrealtype* hnew) -{ - SUNFunctionBegin(C->sunctx); - SUNAssert(Hnew, SUN_ERR_ARG_CORRUPT); - SUNAssert(hnew, SUN_ERR_ARG_CORRUPT); - - /* set usable time-step adaptivity parameters */ - const int p = MRICC_PFAST(C); - const sunrealtype k1 = MRICC_K1(C); - const sunrealtype k2 = MRICC_K2(C); - const sunrealtype al = k1 / P; - const sunrealtype b1 = (p + 1) * k1 / (P * p); - const sunrealtype b2 = -k2 / p; - const sunrealtype es = ONE / SUNMAX(MRICC_BIAS(C) * DSM, TINY); - const sunrealtype ef = ONE / SUNMAX(MRICC_BIAS(C) * dsm, TINY); - const sunrealtype M = SUNRceil(H / h); - - /* compute estimated optimal time step size */ - *Hnew = H * SUNRpowerR(es, al); - const sunrealtype Mnew = M * SUNRpowerR(es, b1) * SUNRpowerR(ef, b2); - *hnew = (*Hnew) / Mnew; - - /* return with success */ - return SUN_SUCCESS; -} - -SUNErrCode SUNAdaptController_SetDefaults_MRICC(SUNAdaptController C) -{ - SUNFunctionBegin(C->sunctx); - MRICC_K1(C) = DEFAULT_K1; - MRICC_K2(C) = DEFAULT_K2; - MRICC_BIAS(C) = DEFAULT_BIAS; - return SUN_SUCCESS; -} - -SUNErrCode SUNAdaptController_Write_MRICC(SUNAdaptController C, FILE* fptr) -{ - SUNFunctionBegin(C->sunctx); - SUNAssert(fptr, SUN_ERR_ARG_CORRUPT); - fprintf(fptr, "Multirate constant-constant SUNAdaptController module:\n"); -#if defined(SUNDIALS_EXTENDED_PRECISION) - fprintf(fptr, " k1 = %32Lg\n", MRICC_K1(C)); - fprintf(fptr, " k2 = %32Lg\n", MRICC_K2(C)); - fprintf(fptr, " bias factor = %32Lg\n", MRICC_BIAS(C)); -#else - fprintf(fptr, " k1 = %16g\n", MRICC_K1(C)); - fprintf(fptr, " k2 = %16g\n", MRICC_K2(C)); - fprintf(fptr, " bias factor = %16g\n", MRICC_BIAS(C)); -#endif - fprintf(fptr, " p = %i (fast method order)\n", MRICC_PFAST(C)); - return SUN_SUCCESS; -} - -SUNErrCode SUNAdaptController_SetErrorBias_MRICC(SUNAdaptController C, - sunrealtype bias) -{ - SUNFunctionBegin(C->sunctx); - - /* set allowed value, otherwise set default */ - if (bias <= SUN_RCONST(0.0)) { MRICC_BIAS(C) = DEFAULT_BIAS; } - else { MRICC_BIAS(C) = bias; } - - return SUN_SUCCESS; -} - -SUNErrCode SUNAdaptController_Space_MRICC(SUNAdaptController C, long int* lenrw, - long int* leniw) -{ - SUNFunctionBegin(C->sunctx); - SUNAssert(lenrw, SUN_ERR_ARG_CORRUPT); - SUNAssert(leniw, SUN_ERR_ARG_CORRUPT); - *lenrw = 3; - *leniw = 1; - return SUN_SUCCESS; -} diff --git a/src/sunadaptcontroller/mrill/CMakeLists.txt b/src/sunadaptcontroller/mrill/CMakeLists.txt deleted file mode 100644 index b383a1d569..0000000000 --- a/src/sunadaptcontroller/mrill/CMakeLists.txt +++ /dev/null @@ -1,28 +0,0 @@ -# --------------------------------------------------------------- -# Programmer(s): Daniel R. Reynolds @ SMU -# --------------------------------------------------------------- -# SUNDIALS Copyright Start -# Copyright (c) 2002-2024, 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_sunadaptcontrollermrill - SOURCES sunadaptcontroller_mrill.c - HEADERS - ${SUNDIALS_SOURCE_DIR}/include/sunadaptcontroller/sunadaptcontroller_mrill.h - LINK_LIBRARIES PUBLIC sundials_core - INCLUDE_SUBDIR sunadaptcontroller - OBJECT_LIB_ONLY) - -# Add F2003 module if the interface is enabled -if(BUILD_FORTRAN_MODULE_INTERFACE) - add_subdirectory("fmod_int${SUNDIALS_INDEX_SIZE}") -endif() diff --git a/src/sunadaptcontroller/mrill/fmod_int32/CMakeLists.txt b/src/sunadaptcontroller/mrill/fmod_int32/CMakeLists.txt deleted file mode 100644 index 0c704c59b9..0000000000 --- a/src/sunadaptcontroller/mrill/fmod_int32/CMakeLists.txt +++ /dev/null @@ -1,26 +0,0 @@ -# --------------------------------------------------------------- -# Programmer(s): Daniel R. Reynolds @ SMU -# --------------------------------------------------------------- -# SUNDIALS Copyright Start -# Copyright (c) 2002-2024, 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_fsunadaptcontrollermrill_mod - SOURCES - fsunadaptcontroller_mrill_mod.f90 fsunadaptcontroller_mrill_mod.c - LINK_LIBRARIES - PUBLIC sundials_fcore_mod - OBJECT_LIBRARIES - OUTPUT_NAME - sundials_fsunadaptcontrollermrill_mod - OBJECT_LIB_ONLY -) - -message(STATUS "Added SUNAdaptController_MRILL F2003 interface") diff --git a/src/sunadaptcontroller/mrill/fmod_int32/fsunadaptcontroller_mrill_mod.c b/src/sunadaptcontroller/mrill/fmod_int32/fsunadaptcontroller_mrill_mod.c deleted file mode 100644 index f48b7bf2b5..0000000000 --- a/src/sunadaptcontroller/mrill/fmod_int32/fsunadaptcontroller_mrill_mod.c +++ /dev/null @@ -1,371 +0,0 @@ -/* ---------------------------------------------------------------------------- - * This file was automatically generated by SWIG (http://www.swig.org). - * Version 4.0.0 - * - * This file is not intended to be easily readable and contains a number of - * coding conventions designed to improve portability and efficiency. Do not make - * changes to this file unless you know what you are doing--modify the SWIG - * interface file instead. - * ----------------------------------------------------------------------------- */ - -/* --------------------------------------------------------------- - * Programmer(s): Auto-generated by swig. - * --------------------------------------------------------------- - * SUNDIALS Copyright Start - * Copyright (c) 2002-2024, 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_mrill.h" - -SWIGEXPORT SUNAdaptController _wrap_FSUNAdaptController_MRILL(void *farg1, int const *farg2) { - SUNAdaptController fresult ; - SUNContext arg1 = (SUNContext) 0 ; - int arg2 ; - SUNAdaptController result; - - arg1 = (SUNContext)(farg1); - arg2 = (int)(*farg2); - result = (SUNAdaptController)SUNAdaptController_MRILL(arg1,arg2); - fresult = result; - return fresult; -} - - -SWIGEXPORT int _wrap_FSUNAdaptController_SetParams_MRILL(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_SetParams_MRILL(arg1,arg2,arg3,arg4,arg5); - fresult = (int)(result); - return fresult; -} - - -SWIGEXPORT int _wrap_FSUNAdaptController_GetType_MRILL(SUNAdaptController farg1) { - int fresult ; - SUNAdaptController arg1 = (SUNAdaptController) 0 ; - SUNAdaptController_Type result; - - arg1 = (SUNAdaptController)(farg1); - result = (SUNAdaptController_Type)SUNAdaptController_GetType_MRILL(arg1); - fresult = (int)(result); - return fresult; -} - - -SWIGEXPORT int _wrap_FSUNAdaptController_EstimateMRISteps_MRILL(SUNAdaptController farg1, double const *farg2, double const *farg3, int const *farg4, double const *farg5, double const *farg6, double *farg7, double *farg8) { - int fresult ; - SUNAdaptController arg1 = (SUNAdaptController) 0 ; - sunrealtype arg2 ; - sunrealtype arg3 ; - int arg4 ; - sunrealtype arg5 ; - sunrealtype arg6 ; - sunrealtype *arg7 = (sunrealtype *) 0 ; - sunrealtype *arg8 = (sunrealtype *) 0 ; - int result; - - arg1 = (SUNAdaptController)(farg1); - arg2 = (sunrealtype)(*farg2); - arg3 = (sunrealtype)(*farg3); - arg4 = (int)(*farg4); - arg5 = (sunrealtype)(*farg5); - arg6 = (sunrealtype)(*farg6); - arg7 = (sunrealtype *)(farg7); - arg8 = (sunrealtype *)(farg8); - result = (int)SUNAdaptController_EstimateMRISteps_MRILL(arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8); - fresult = (int)(result); - return fresult; -} - - -SWIGEXPORT int _wrap_FSUNAdaptController_Reset_MRILL(SUNAdaptController farg1) { - int fresult ; - SUNAdaptController arg1 = (SUNAdaptController) 0 ; - int result; - - arg1 = (SUNAdaptController)(farg1); - result = (int)SUNAdaptController_Reset_MRILL(arg1); - fresult = (int)(result); - return fresult; -} - - -SWIGEXPORT int _wrap_FSUNAdaptController_SetDefaults_MRILL(SUNAdaptController farg1) { - int fresult ; - SUNAdaptController arg1 = (SUNAdaptController) 0 ; - int result; - - arg1 = (SUNAdaptController)(farg1); - result = (int)SUNAdaptController_SetDefaults_MRILL(arg1); - fresult = (int)(result); - return fresult; -} - - -SWIGEXPORT int _wrap_FSUNAdaptController_Write_MRILL(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_MRILL(arg1,arg2); - fresult = (int)(result); - return fresult; -} - - -SWIGEXPORT int _wrap_FSUNAdaptController_SetErrorBias_MRILL(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_MRILL(arg1,arg2); - fresult = (int)(result); - return fresult; -} - - -SWIGEXPORT int _wrap_FSUNAdaptController_UpdateMRIH_MRILL(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_MRILL(arg1,arg2,arg3,arg4,arg5); - fresult = (int)(result); - return fresult; -} - - -SWIGEXPORT int _wrap_FSUNAdaptController_Space_MRILL(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_MRILL(arg1,arg2,arg3); - fresult = (int)(result); - return fresult; -} - - - diff --git a/src/sunadaptcontroller/mrill/fmod_int32/fsunadaptcontroller_mrill_mod.f90 b/src/sunadaptcontroller/mrill/fmod_int32/fsunadaptcontroller_mrill_mod.f90 deleted file mode 100644 index c00a349f53..0000000000 --- a/src/sunadaptcontroller/mrill/fmod_int32/fsunadaptcontroller_mrill_mod.f90 +++ /dev/null @@ -1,337 +0,0 @@ -! This file was automatically generated by SWIG (http://www.swig.org). -! Version 4.0.0 -! -! Do not make changes to this file unless you know what you are doing--modify -! the SWIG interface file instead. - -! --------------------------------------------------------------- -! Programmer(s): Auto-generated by swig. -! --------------------------------------------------------------- -! SUNDIALS Copyright Start -! Copyright (c) 2002-2024, 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_mrill_mod - use, intrinsic :: ISO_C_BINDING - use fsundials_core_mod - implicit none - private - - ! DECLARATION CONSTRUCTS - public :: FSUNAdaptController_MRILL - public :: FSUNAdaptController_SetParams_MRILL - public :: FSUNAdaptController_GetType_MRILL - public :: FSUNAdaptController_EstimateMRISteps_MRILL - public :: FSUNAdaptController_Reset_MRILL - public :: FSUNAdaptController_SetDefaults_MRILL - public :: FSUNAdaptController_Write_MRILL - public :: FSUNAdaptController_SetErrorBias_MRILL - public :: FSUNAdaptController_UpdateMRIH_MRILL - public :: FSUNAdaptController_Space_MRILL - -! WRAPPER DECLARATIONS -interface -function swigc_FSUNAdaptController_MRILL(farg1, farg2) & -bind(C, name="_wrap_FSUNAdaptController_MRILL") & -result(fresult) -use, intrinsic :: ISO_C_BINDING -type(C_PTR), value :: farg1 -integer(C_INT), intent(in) :: farg2 -type(C_PTR) :: fresult -end function - -function swigc_FSUNAdaptController_SetParams_MRILL(farg1, farg2, farg3, farg4, farg5) & -bind(C, name="_wrap_FSUNAdaptController_SetParams_MRILL") & -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_GetType_MRILL(farg1) & -bind(C, name="_wrap_FSUNAdaptController_GetType_MRILL") & -result(fresult) -use, intrinsic :: ISO_C_BINDING -type(C_PTR), value :: farg1 -integer(C_INT) :: fresult -end function - -function swigc_FSUNAdaptController_EstimateMRISteps_MRILL(farg1, farg2, farg3, farg4, farg5, farg6, farg7, farg8) & -bind(C, name="_wrap_FSUNAdaptController_EstimateMRISteps_MRILL") & -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 -real(C_DOUBLE), intent(in) :: farg5 -real(C_DOUBLE), intent(in) :: farg6 -type(C_PTR), value :: farg7 -type(C_PTR), value :: farg8 -integer(C_INT) :: fresult -end function - -function swigc_FSUNAdaptController_Reset_MRILL(farg1) & -bind(C, name="_wrap_FSUNAdaptController_Reset_MRILL") & -result(fresult) -use, intrinsic :: ISO_C_BINDING -type(C_PTR), value :: farg1 -integer(C_INT) :: fresult -end function - -function swigc_FSUNAdaptController_SetDefaults_MRILL(farg1) & -bind(C, name="_wrap_FSUNAdaptController_SetDefaults_MRILL") & -result(fresult) -use, intrinsic :: ISO_C_BINDING -type(C_PTR), value :: farg1 -integer(C_INT) :: fresult -end function - -function swigc_FSUNAdaptController_Write_MRILL(farg1, farg2) & -bind(C, name="_wrap_FSUNAdaptController_Write_MRILL") & -result(fresult) -use, intrinsic :: ISO_C_BINDING -type(C_PTR), value :: farg1 -type(C_PTR), value :: farg2 -integer(C_INT) :: fresult -end function - -function swigc_FSUNAdaptController_SetErrorBias_MRILL(farg1, farg2) & -bind(C, name="_wrap_FSUNAdaptController_SetErrorBias_MRILL") & -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_UpdateMRIH_MRILL(farg1, farg2, farg3, farg4, farg5) & -bind(C, name="_wrap_FSUNAdaptController_UpdateMRIH_MRILL") & -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_MRILL(farg1, farg2, farg3) & -bind(C, name="_wrap_FSUNAdaptController_Space_MRILL") & -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_MRILL(sunctx, p) & -result(swig_result) -use, intrinsic :: ISO_C_BINDING -type(SUNAdaptController), pointer :: swig_result -type(C_PTR) :: sunctx -integer(C_INT), intent(in) :: p -type(C_PTR) :: fresult -type(C_PTR) :: farg1 -integer(C_INT) :: farg2 - -farg1 = sunctx -farg2 = p -fresult = swigc_FSUNAdaptController_MRILL(farg1, farg2) -call c_f_pointer(fresult, swig_result) -end function - -function FSUNAdaptController_SetParams_MRILL(c, k11, k12, k21, k22) & -result(swig_result) -use, intrinsic :: ISO_C_BINDING -integer(C_INT) :: swig_result -type(SUNAdaptController), target, intent(inout) :: c -real(C_DOUBLE), intent(in) :: k11 -real(C_DOUBLE), intent(in) :: k12 -real(C_DOUBLE), intent(in) :: k21 -real(C_DOUBLE), intent(in) :: k22 -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 = k11 -farg3 = k12 -farg4 = k21 -farg5 = k22 -fresult = swigc_FSUNAdaptController_SetParams_MRILL(farg1, farg2, farg3, farg4, farg5) -swig_result = fresult -end function - -function FSUNAdaptController_GetType_MRILL(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_MRILL(farg1) -swig_result = fresult -end function - -function FSUNAdaptController_EstimateMRISteps_MRILL(c, h, h2, p, dsm, dsm5, hnew, hnew7) & -result(swig_result) -use, intrinsic :: ISO_C_BINDING -integer(C_INT) :: swig_result -type(SUNAdaptController), target, intent(inout) :: c -real(C_DOUBLE), intent(in) :: h -real(C_DOUBLE), intent(in) :: h2 -integer(C_INT), intent(in) :: p -real(C_DOUBLE), intent(in) :: dsm -real(C_DOUBLE), intent(in) :: dsm5 -real(C_DOUBLE), dimension(*), target, intent(inout) :: hnew -real(C_DOUBLE), dimension(*), target, intent(inout) :: hnew7 -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -real(C_DOUBLE) :: farg2 -real(C_DOUBLE) :: farg3 -integer(C_INT) :: farg4 -real(C_DOUBLE) :: farg5 -real(C_DOUBLE) :: farg6 -type(C_PTR) :: farg7 -type(C_PTR) :: farg8 - -farg1 = c_loc(c) -farg2 = h -farg3 = h2 -farg4 = p -farg5 = dsm -farg6 = dsm5 -farg7 = c_loc(hnew(1)) -farg8 = c_loc(hnew7(1)) -fresult = swigc_FSUNAdaptController_EstimateMRISteps_MRILL(farg1, farg2, farg3, farg4, farg5, farg6, farg7, farg8) -swig_result = fresult -end function - -function FSUNAdaptController_Reset_MRILL(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_MRILL(farg1) -swig_result = fresult -end function - -function FSUNAdaptController_SetDefaults_MRILL(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_MRILL(farg1) -swig_result = fresult -end function - -function FSUNAdaptController_Write_MRILL(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_MRILL(farg1, farg2) -swig_result = fresult -end function - -function FSUNAdaptController_SetErrorBias_MRILL(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_MRILL(farg1, farg2) -swig_result = fresult -end function - -function FSUNAdaptController_UpdateMRIH_MRILL(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_MRILL(farg1, farg2, farg3, farg4, farg5) -swig_result = fresult -end function - -function FSUNAdaptController_Space_MRILL(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_MRILL(farg1, farg2, farg3) -swig_result = fresult -end function - - -end module diff --git a/src/sunadaptcontroller/mrill/fmod_int64/CMakeLists.txt b/src/sunadaptcontroller/mrill/fmod_int64/CMakeLists.txt deleted file mode 100644 index 0c704c59b9..0000000000 --- a/src/sunadaptcontroller/mrill/fmod_int64/CMakeLists.txt +++ /dev/null @@ -1,26 +0,0 @@ -# --------------------------------------------------------------- -# Programmer(s): Daniel R. Reynolds @ SMU -# --------------------------------------------------------------- -# SUNDIALS Copyright Start -# Copyright (c) 2002-2024, 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_fsunadaptcontrollermrill_mod - SOURCES - fsunadaptcontroller_mrill_mod.f90 fsunadaptcontroller_mrill_mod.c - LINK_LIBRARIES - PUBLIC sundials_fcore_mod - OBJECT_LIBRARIES - OUTPUT_NAME - sundials_fsunadaptcontrollermrill_mod - OBJECT_LIB_ONLY -) - -message(STATUS "Added SUNAdaptController_MRILL F2003 interface") diff --git a/src/sunadaptcontroller/mrill/fmod_int64/fsunadaptcontroller_mrill_mod.c b/src/sunadaptcontroller/mrill/fmod_int64/fsunadaptcontroller_mrill_mod.c deleted file mode 100644 index f48b7bf2b5..0000000000 --- a/src/sunadaptcontroller/mrill/fmod_int64/fsunadaptcontroller_mrill_mod.c +++ /dev/null @@ -1,371 +0,0 @@ -/* ---------------------------------------------------------------------------- - * This file was automatically generated by SWIG (http://www.swig.org). - * Version 4.0.0 - * - * This file is not intended to be easily readable and contains a number of - * coding conventions designed to improve portability and efficiency. Do not make - * changes to this file unless you know what you are doing--modify the SWIG - * interface file instead. - * ----------------------------------------------------------------------------- */ - -/* --------------------------------------------------------------- - * Programmer(s): Auto-generated by swig. - * --------------------------------------------------------------- - * SUNDIALS Copyright Start - * Copyright (c) 2002-2024, 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_mrill.h" - -SWIGEXPORT SUNAdaptController _wrap_FSUNAdaptController_MRILL(void *farg1, int const *farg2) { - SUNAdaptController fresult ; - SUNContext arg1 = (SUNContext) 0 ; - int arg2 ; - SUNAdaptController result; - - arg1 = (SUNContext)(farg1); - arg2 = (int)(*farg2); - result = (SUNAdaptController)SUNAdaptController_MRILL(arg1,arg2); - fresult = result; - return fresult; -} - - -SWIGEXPORT int _wrap_FSUNAdaptController_SetParams_MRILL(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_SetParams_MRILL(arg1,arg2,arg3,arg4,arg5); - fresult = (int)(result); - return fresult; -} - - -SWIGEXPORT int _wrap_FSUNAdaptController_GetType_MRILL(SUNAdaptController farg1) { - int fresult ; - SUNAdaptController arg1 = (SUNAdaptController) 0 ; - SUNAdaptController_Type result; - - arg1 = (SUNAdaptController)(farg1); - result = (SUNAdaptController_Type)SUNAdaptController_GetType_MRILL(arg1); - fresult = (int)(result); - return fresult; -} - - -SWIGEXPORT int _wrap_FSUNAdaptController_EstimateMRISteps_MRILL(SUNAdaptController farg1, double const *farg2, double const *farg3, int const *farg4, double const *farg5, double const *farg6, double *farg7, double *farg8) { - int fresult ; - SUNAdaptController arg1 = (SUNAdaptController) 0 ; - sunrealtype arg2 ; - sunrealtype arg3 ; - int arg4 ; - sunrealtype arg5 ; - sunrealtype arg6 ; - sunrealtype *arg7 = (sunrealtype *) 0 ; - sunrealtype *arg8 = (sunrealtype *) 0 ; - int result; - - arg1 = (SUNAdaptController)(farg1); - arg2 = (sunrealtype)(*farg2); - arg3 = (sunrealtype)(*farg3); - arg4 = (int)(*farg4); - arg5 = (sunrealtype)(*farg5); - arg6 = (sunrealtype)(*farg6); - arg7 = (sunrealtype *)(farg7); - arg8 = (sunrealtype *)(farg8); - result = (int)SUNAdaptController_EstimateMRISteps_MRILL(arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8); - fresult = (int)(result); - return fresult; -} - - -SWIGEXPORT int _wrap_FSUNAdaptController_Reset_MRILL(SUNAdaptController farg1) { - int fresult ; - SUNAdaptController arg1 = (SUNAdaptController) 0 ; - int result; - - arg1 = (SUNAdaptController)(farg1); - result = (int)SUNAdaptController_Reset_MRILL(arg1); - fresult = (int)(result); - return fresult; -} - - -SWIGEXPORT int _wrap_FSUNAdaptController_SetDefaults_MRILL(SUNAdaptController farg1) { - int fresult ; - SUNAdaptController arg1 = (SUNAdaptController) 0 ; - int result; - - arg1 = (SUNAdaptController)(farg1); - result = (int)SUNAdaptController_SetDefaults_MRILL(arg1); - fresult = (int)(result); - return fresult; -} - - -SWIGEXPORT int _wrap_FSUNAdaptController_Write_MRILL(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_MRILL(arg1,arg2); - fresult = (int)(result); - return fresult; -} - - -SWIGEXPORT int _wrap_FSUNAdaptController_SetErrorBias_MRILL(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_MRILL(arg1,arg2); - fresult = (int)(result); - return fresult; -} - - -SWIGEXPORT int _wrap_FSUNAdaptController_UpdateMRIH_MRILL(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_MRILL(arg1,arg2,arg3,arg4,arg5); - fresult = (int)(result); - return fresult; -} - - -SWIGEXPORT int _wrap_FSUNAdaptController_Space_MRILL(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_MRILL(arg1,arg2,arg3); - fresult = (int)(result); - return fresult; -} - - - diff --git a/src/sunadaptcontroller/mrill/fmod_int64/fsunadaptcontroller_mrill_mod.f90 b/src/sunadaptcontroller/mrill/fmod_int64/fsunadaptcontroller_mrill_mod.f90 deleted file mode 100644 index c00a349f53..0000000000 --- a/src/sunadaptcontroller/mrill/fmod_int64/fsunadaptcontroller_mrill_mod.f90 +++ /dev/null @@ -1,337 +0,0 @@ -! This file was automatically generated by SWIG (http://www.swig.org). -! Version 4.0.0 -! -! Do not make changes to this file unless you know what you are doing--modify -! the SWIG interface file instead. - -! --------------------------------------------------------------- -! Programmer(s): Auto-generated by swig. -! --------------------------------------------------------------- -! SUNDIALS Copyright Start -! Copyright (c) 2002-2024, 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_mrill_mod - use, intrinsic :: ISO_C_BINDING - use fsundials_core_mod - implicit none - private - - ! DECLARATION CONSTRUCTS - public :: FSUNAdaptController_MRILL - public :: FSUNAdaptController_SetParams_MRILL - public :: FSUNAdaptController_GetType_MRILL - public :: FSUNAdaptController_EstimateMRISteps_MRILL - public :: FSUNAdaptController_Reset_MRILL - public :: FSUNAdaptController_SetDefaults_MRILL - public :: FSUNAdaptController_Write_MRILL - public :: FSUNAdaptController_SetErrorBias_MRILL - public :: FSUNAdaptController_UpdateMRIH_MRILL - public :: FSUNAdaptController_Space_MRILL - -! WRAPPER DECLARATIONS -interface -function swigc_FSUNAdaptController_MRILL(farg1, farg2) & -bind(C, name="_wrap_FSUNAdaptController_MRILL") & -result(fresult) -use, intrinsic :: ISO_C_BINDING -type(C_PTR), value :: farg1 -integer(C_INT), intent(in) :: farg2 -type(C_PTR) :: fresult -end function - -function swigc_FSUNAdaptController_SetParams_MRILL(farg1, farg2, farg3, farg4, farg5) & -bind(C, name="_wrap_FSUNAdaptController_SetParams_MRILL") & -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_GetType_MRILL(farg1) & -bind(C, name="_wrap_FSUNAdaptController_GetType_MRILL") & -result(fresult) -use, intrinsic :: ISO_C_BINDING -type(C_PTR), value :: farg1 -integer(C_INT) :: fresult -end function - -function swigc_FSUNAdaptController_EstimateMRISteps_MRILL(farg1, farg2, farg3, farg4, farg5, farg6, farg7, farg8) & -bind(C, name="_wrap_FSUNAdaptController_EstimateMRISteps_MRILL") & -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 -real(C_DOUBLE), intent(in) :: farg5 -real(C_DOUBLE), intent(in) :: farg6 -type(C_PTR), value :: farg7 -type(C_PTR), value :: farg8 -integer(C_INT) :: fresult -end function - -function swigc_FSUNAdaptController_Reset_MRILL(farg1) & -bind(C, name="_wrap_FSUNAdaptController_Reset_MRILL") & -result(fresult) -use, intrinsic :: ISO_C_BINDING -type(C_PTR), value :: farg1 -integer(C_INT) :: fresult -end function - -function swigc_FSUNAdaptController_SetDefaults_MRILL(farg1) & -bind(C, name="_wrap_FSUNAdaptController_SetDefaults_MRILL") & -result(fresult) -use, intrinsic :: ISO_C_BINDING -type(C_PTR), value :: farg1 -integer(C_INT) :: fresult -end function - -function swigc_FSUNAdaptController_Write_MRILL(farg1, farg2) & -bind(C, name="_wrap_FSUNAdaptController_Write_MRILL") & -result(fresult) -use, intrinsic :: ISO_C_BINDING -type(C_PTR), value :: farg1 -type(C_PTR), value :: farg2 -integer(C_INT) :: fresult -end function - -function swigc_FSUNAdaptController_SetErrorBias_MRILL(farg1, farg2) & -bind(C, name="_wrap_FSUNAdaptController_SetErrorBias_MRILL") & -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_UpdateMRIH_MRILL(farg1, farg2, farg3, farg4, farg5) & -bind(C, name="_wrap_FSUNAdaptController_UpdateMRIH_MRILL") & -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_MRILL(farg1, farg2, farg3) & -bind(C, name="_wrap_FSUNAdaptController_Space_MRILL") & -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_MRILL(sunctx, p) & -result(swig_result) -use, intrinsic :: ISO_C_BINDING -type(SUNAdaptController), pointer :: swig_result -type(C_PTR) :: sunctx -integer(C_INT), intent(in) :: p -type(C_PTR) :: fresult -type(C_PTR) :: farg1 -integer(C_INT) :: farg2 - -farg1 = sunctx -farg2 = p -fresult = swigc_FSUNAdaptController_MRILL(farg1, farg2) -call c_f_pointer(fresult, swig_result) -end function - -function FSUNAdaptController_SetParams_MRILL(c, k11, k12, k21, k22) & -result(swig_result) -use, intrinsic :: ISO_C_BINDING -integer(C_INT) :: swig_result -type(SUNAdaptController), target, intent(inout) :: c -real(C_DOUBLE), intent(in) :: k11 -real(C_DOUBLE), intent(in) :: k12 -real(C_DOUBLE), intent(in) :: k21 -real(C_DOUBLE), intent(in) :: k22 -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 = k11 -farg3 = k12 -farg4 = k21 -farg5 = k22 -fresult = swigc_FSUNAdaptController_SetParams_MRILL(farg1, farg2, farg3, farg4, farg5) -swig_result = fresult -end function - -function FSUNAdaptController_GetType_MRILL(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_MRILL(farg1) -swig_result = fresult -end function - -function FSUNAdaptController_EstimateMRISteps_MRILL(c, h, h2, p, dsm, dsm5, hnew, hnew7) & -result(swig_result) -use, intrinsic :: ISO_C_BINDING -integer(C_INT) :: swig_result -type(SUNAdaptController), target, intent(inout) :: c -real(C_DOUBLE), intent(in) :: h -real(C_DOUBLE), intent(in) :: h2 -integer(C_INT), intent(in) :: p -real(C_DOUBLE), intent(in) :: dsm -real(C_DOUBLE), intent(in) :: dsm5 -real(C_DOUBLE), dimension(*), target, intent(inout) :: hnew -real(C_DOUBLE), dimension(*), target, intent(inout) :: hnew7 -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -real(C_DOUBLE) :: farg2 -real(C_DOUBLE) :: farg3 -integer(C_INT) :: farg4 -real(C_DOUBLE) :: farg5 -real(C_DOUBLE) :: farg6 -type(C_PTR) :: farg7 -type(C_PTR) :: farg8 - -farg1 = c_loc(c) -farg2 = h -farg3 = h2 -farg4 = p -farg5 = dsm -farg6 = dsm5 -farg7 = c_loc(hnew(1)) -farg8 = c_loc(hnew7(1)) -fresult = swigc_FSUNAdaptController_EstimateMRISteps_MRILL(farg1, farg2, farg3, farg4, farg5, farg6, farg7, farg8) -swig_result = fresult -end function - -function FSUNAdaptController_Reset_MRILL(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_MRILL(farg1) -swig_result = fresult -end function - -function FSUNAdaptController_SetDefaults_MRILL(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_MRILL(farg1) -swig_result = fresult -end function - -function FSUNAdaptController_Write_MRILL(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_MRILL(farg1, farg2) -swig_result = fresult -end function - -function FSUNAdaptController_SetErrorBias_MRILL(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_MRILL(farg1, farg2) -swig_result = fresult -end function - -function FSUNAdaptController_UpdateMRIH_MRILL(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_MRILL(farg1, farg2, farg3, farg4, farg5) -swig_result = fresult -end function - -function FSUNAdaptController_Space_MRILL(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_MRILL(farg1, farg2, farg3) -swig_result = fresult -end function - - -end module diff --git a/src/sunadaptcontroller/mrill/sunadaptcontroller_mrill.c b/src/sunadaptcontroller/mrill/sunadaptcontroller_mrill.c deleted file mode 100644 index a573a308c3..0000000000 --- a/src/sunadaptcontroller/mrill/sunadaptcontroller_mrill.c +++ /dev/null @@ -1,265 +0,0 @@ -/* ----------------------------------------------------------------- - * Programmer(s): Daniel R. Reynolds @ SMU - * ----------------------------------------------------------------- - * SUNDIALS Copyright Start - * Copyright (c) 2002-2024, 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_MRILL module. - * -----------------------------------------------------------------*/ - -#include -#include -#include -#include - -#include "sundials/priv/sundials_errors_impl.h" -#include "sundials/sundials_errors.h" - -/* --------------- - * Macro accessors - * --------------- */ - -#define MRILL_CONTENT(C) ((SUNAdaptControllerContent_MRILL)(C->content)) -#define MRILL_K11(C) (MRILL_CONTENT(C)->k11) -#define MRILL_K12(C) (MRILL_CONTENT(C)->k12) -#define MRILL_K21(C) (MRILL_CONTENT(C)->k21) -#define MRILL_K22(C) (MRILL_CONTENT(C)->k22) -#define MRILL_BIAS(C) (MRILL_CONTENT(C)->bias) -#define MRILL_ESP(C) (MRILL_CONTENT(C)->esp) -#define MRILL_EFP(C) (MRILL_CONTENT(C)->efp) -#define MRILL_HSP(C) (MRILL_CONTENT(C)->hsp) -#define MRILL_HFP(C) (MRILL_CONTENT(C)->hfp) -#define MRILL_PFAST(C) (MRILL_CONTENT(C)->p) -#define MRILL_FIRSTSTEP(C) (MRILL_CONTENT(C)->firststep) - -/* ------------------ - * Default parameters - * ------------------ */ - -#define DEFAULT_K11 SUN_RCONST(0.82) -#define DEFAULT_K12 SUN_RCONST(0.54) -#define DEFAULT_K21 SUN_RCONST(0.94) -#define DEFAULT_K22 SUN_RCONST(0.9) -#define DEFAULT_BIAS SUN_RCONST(1.5) -#define ONE SUN_RCONST(1.0) -#define TINY (SUN_RCONST(10.0) * SUN_UNIT_ROUNDOFF) - -/* ----------------------------------------------------------------- - * exported functions - * ----------------------------------------------------------------- */ - -/* ----------------------------------------------------------------- - * Function to create a new MRILL controller - */ - -SUNAdaptController SUNAdaptController_MRILL(SUNContext sunctx, int p) -{ - SUNFunctionBegin(sunctx); - - SUNAdaptController C; - SUNAdaptControllerContent_MRILL content; - - /* Create an empty controller object */ - C = NULL; - C = SUNAdaptController_NewEmpty(sunctx); - SUNCheckLastErrNull(); - - /* Attach operations */ - C->ops->gettype = SUNAdaptController_GetType_MRILL; - C->ops->estimatemristeps = SUNAdaptController_EstimateMRISteps_MRILL; - C->ops->reset = SUNAdaptController_Reset_MRILL; - C->ops->setdefaults = SUNAdaptController_SetDefaults_MRILL; - C->ops->write = SUNAdaptController_Write_MRILL; - C->ops->seterrorbias = SUNAdaptController_SetErrorBias_MRILL; - C->ops->updatemrih = SUNAdaptController_UpdateMRIH_MRILL; - C->ops->space = SUNAdaptController_Space_MRILL; - - /* Create content */ - content = NULL; - content = (SUNAdaptControllerContent_MRILL)malloc(sizeof *content); - SUNAssertNull(content, SUN_ERR_MALLOC_FAIL); - - /* Attach content */ - C->content = content; - - /* Set fast method order */ - content->p = p; - - /* Fill content with default/reset values */ - SUNCheckCallNull(SUNAdaptController_SetDefaults_MRILL(C)); - SUNCheckCallNull(SUNAdaptController_Reset_MRILL(C)); - - return (C); -} - -/* ----------------------------------------------------------------- - * Function to set MRILL parameters - */ - -SUNErrCode SUNAdaptController_SetParams_MRILL(SUNAdaptController C, - sunrealtype k11, sunrealtype k12, - sunrealtype k21, sunrealtype k22) -{ - SUNFunctionBegin(C->sunctx); - MRILL_K11(C) = k11; - MRILL_K12(C) = k12; - MRILL_K21(C) = k21; - MRILL_K22(C) = k22; - return SUN_SUCCESS; -} - -/* ----------------------------------------------------------------- - * implementation of controller operations - * ----------------------------------------------------------------- */ - -SUNAdaptController_Type SUNAdaptController_GetType_MRILL(SUNAdaptController C) -{ - return SUN_ADAPTCONTROLLER_MRI_H; -} - -SUNErrCode SUNAdaptController_EstimateMRISteps_MRILL( - SUNAdaptController C, sunrealtype H, sunrealtype h, int P, sunrealtype DSM, - sunrealtype dsm, sunrealtype* Hnew, sunrealtype* hnew) -{ - SUNFunctionBegin(C->sunctx); - SUNAssert(Hnew, SUN_ERR_ARG_CORRUPT); - SUNAssert(hnew, SUN_ERR_ARG_CORRUPT); - - /* set usable time-step adaptivity parameters */ - const int p = MRILL_PFAST(C); - const sunrealtype k11 = MRILL_K11(C); - const sunrealtype k12 = MRILL_K12(C); - const sunrealtype k21 = MRILL_K21(C); - const sunrealtype k22 = MRILL_K22(C); - const sunrealtype a1 = (k11 + k12) / (2 * P); - const sunrealtype a2 = -k11 / (2 * P); - const sunrealtype b11 = (p + 1) * (k11 + k12) / (2 * P * p); - const sunrealtype b12 = -(p + 1) * k11 / (2 * P * p); - const sunrealtype b21 = -(k21 + k22) / (2 * p); - const sunrealtype b22 = k21 / (2 * p); - const sunrealtype es1 = ONE / SUNMAX(MRILL_BIAS(C) * DSM, TINY); - const sunrealtype es2 = ONE / MRILL_ESP(C); - const sunrealtype ef1 = ONE / SUNMAX(MRILL_BIAS(C) * dsm, TINY); - const sunrealtype ef2 = ONE / MRILL_EFP(C); - const sunrealtype M = SUNRceil(H / h); - - /* handle first vs successive steps */ - sunrealtype Hfac, Mfac; - if (MRILL_FIRSTSTEP(C)) - { - Hfac = SUN_RCONST(1.0); - Mfac = SUN_RCONST(1.0); - } - else - { - const sunrealtype Mp = SUNRceil(MRILL_HSP(C) / MRILL_HFP(C)); - Hfac = H / MRILL_HSP(C); - Mfac = M / Mp; - } - - /* compute estimated optimal time step size */ - *Hnew = H * Hfac * SUNRpowerR(es1, a1) * SUNRpowerR(es2, a2); - const sunrealtype Mnew = M * Mfac * SUNRpowerR(es1, b11) * - SUNRpowerR(es2, b12) * SUNRpowerR(ef1, b21) * - SUNRpowerR(ef2, b22); - *hnew = (*Hnew) / Mnew; - - /* return with success */ - return SUN_SUCCESS; -} - -SUNErrCode SUNAdaptController_Reset_MRILL(SUNAdaptController C) -{ - SUNFunctionBegin(C->sunctx); - MRILL_ESP(C) = SUN_RCONST(1.0); - MRILL_EFP(C) = SUN_RCONST(1.0); - MRILL_HSP(C) = SUN_RCONST(1.0); - MRILL_HFP(C) = SUN_RCONST(1.0); - MRILL_FIRSTSTEP(C) = SUNTRUE; - return SUN_SUCCESS; -} - -SUNErrCode SUNAdaptController_SetDefaults_MRILL(SUNAdaptController C) -{ - SUNFunctionBegin(C->sunctx); - MRILL_K11(C) = DEFAULT_K11; - MRILL_K12(C) = DEFAULT_K12; - MRILL_K21(C) = DEFAULT_K21; - MRILL_K22(C) = DEFAULT_K22; - MRILL_BIAS(C) = DEFAULT_BIAS; - return SUN_SUCCESS; -} - -SUNErrCode SUNAdaptController_Write_MRILL(SUNAdaptController C, FILE* fptr) -{ - SUNFunctionBegin(C->sunctx); - SUNAssert(fptr, SUN_ERR_ARG_CORRUPT); - fprintf(fptr, "Multirate LL SUNAdaptController module:\n"); -#if defined(SUNDIALS_EXTENDED_PRECISION) - fprintf(fptr, " k11 = %32Lg\n", MRILL_K11(C)); - fprintf(fptr, " k12 = %32Lg\n", MRILL_K12(C)); - fprintf(fptr, " k21 = %32Lg\n", MRILL_K21(C)); - fprintf(fptr, " k22 = %32Lg\n", MRILL_K22(C)); - fprintf(fptr, " bias factor = %32Lg\n", MRILL_BIAS(C)); - fprintf(fptr, " previous slow error = %32Lg\n", MRILL_ESP(C)); - fprintf(fptr, " previous fast error = %32Lg\n", MRILL_EFP(C)); - fprintf(fptr, " previous slow step = %32Lg\n", MRILL_HSP(C)); - fprintf(fptr, " previous fast step = %32Lg\n", MRILL_HFP(C)); -#else - fprintf(fptr, " k11 = %16g\n", MRILL_K11(C)); - fprintf(fptr, " k12 = %16g\n", MRILL_K12(C)); - fprintf(fptr, " k21 = %16g\n", MRILL_K21(C)); - fprintf(fptr, " k22 = %16g\n", MRILL_K22(C)); - fprintf(fptr, " bias factor = %16g\n", MRILL_BIAS(C)); - fprintf(fptr, " previous slow error = %16g\n", MRILL_ESP(C)); - fprintf(fptr, " previous fast error = %16g\n", MRILL_EFP(C)); - fprintf(fptr, " previous slow step = %16g\n", MRILL_HSP(C)); - fprintf(fptr, " previous fast step = %16g\n", MRILL_HFP(C)); -#endif - fprintf(fptr, " p = %i (fast method order)\n", MRILL_PFAST(C)); - return SUN_SUCCESS; -} - -SUNErrCode SUNAdaptController_SetErrorBias_MRILL(SUNAdaptController C, - sunrealtype bias) -{ - SUNFunctionBegin(C->sunctx); - - /* set allowed value, otherwise set default */ - if (bias <= SUN_RCONST(0.0)) { MRILL_BIAS(C) = DEFAULT_BIAS; } - else { MRILL_BIAS(C) = bias; } - - return SUN_SUCCESS; -} - -SUNErrCode SUNAdaptController_UpdateMRIH_MRILL(SUNAdaptController C, - sunrealtype H, sunrealtype h, - sunrealtype DSM, sunrealtype dsm) -{ - SUNFunctionBegin(C->sunctx); - MRILL_ESP(C) = SUNMAX(MRILL_BIAS(C) * DSM, TINY); - MRILL_EFP(C) = SUNMAX(MRILL_BIAS(C) * dsm, TINY); - MRILL_HSP(C) = H; - MRILL_HFP(C) = h; - MRILL_FIRSTSTEP(C) = SUNFALSE; - return SUN_SUCCESS; -} - -SUNErrCode SUNAdaptController_Space_MRILL(SUNAdaptController C, long int* lenrw, - long int* leniw) -{ - SUNFunctionBegin(C->sunctx); - SUNAssert(lenrw, SUN_ERR_ARG_CORRUPT); - SUNAssert(leniw, SUN_ERR_ARG_CORRUPT); - *lenrw = 9; - *leniw = 2; - return SUN_SUCCESS; -} diff --git a/src/sunadaptcontroller/mripi/CMakeLists.txt b/src/sunadaptcontroller/mripi/CMakeLists.txt deleted file mode 100644 index 477cd641af..0000000000 --- a/src/sunadaptcontroller/mripi/CMakeLists.txt +++ /dev/null @@ -1,28 +0,0 @@ -# --------------------------------------------------------------- -# Programmer(s): Daniel R. Reynolds @ SMU -# --------------------------------------------------------------- -# SUNDIALS Copyright Start -# Copyright (c) 2002-2024, 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_sunadaptcontrollermripi - SOURCES sunadaptcontroller_mripi.c - HEADERS - ${SUNDIALS_SOURCE_DIR}/include/sunadaptcontroller/sunadaptcontroller_mripi.h - LINK_LIBRARIES PUBLIC sundials_core - INCLUDE_SUBDIR sunadaptcontroller - OBJECT_LIB_ONLY) - -# Add F2003 module if the interface is enabled -if(BUILD_FORTRAN_MODULE_INTERFACE) - add_subdirectory("fmod_int${SUNDIALS_INDEX_SIZE}") -endif() diff --git a/src/sunadaptcontroller/mripi/fmod_int32/CMakeLists.txt b/src/sunadaptcontroller/mripi/fmod_int32/CMakeLists.txt deleted file mode 100644 index 83a51e3d7c..0000000000 --- a/src/sunadaptcontroller/mripi/fmod_int32/CMakeLists.txt +++ /dev/null @@ -1,26 +0,0 @@ -# --------------------------------------------------------------- -# Programmer(s): Daniel R. Reynolds @ SMU -# --------------------------------------------------------------- -# SUNDIALS Copyright Start -# Copyright (c) 2002-2024, 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_fsunadaptcontrollermripi_mod - SOURCES - fsunadaptcontroller_mripi_mod.f90 fsunadaptcontroller_mripi_mod.c - LINK_LIBRARIES - PUBLIC sundials_fcore_mod - OBJECT_LIBRARIES - OUTPUT_NAME - sundials_fsunadaptcontrollermripi_mod - OBJECT_LIB_ONLY -) - -message(STATUS "Added SUNAdaptController_MRIPI F2003 interface") diff --git a/src/sunadaptcontroller/mripi/fmod_int32/fsunadaptcontroller_mripi_mod.c b/src/sunadaptcontroller/mripi/fmod_int32/fsunadaptcontroller_mripi_mod.c deleted file mode 100644 index 9e05214eb8..0000000000 --- a/src/sunadaptcontroller/mripi/fmod_int32/fsunadaptcontroller_mripi_mod.c +++ /dev/null @@ -1,371 +0,0 @@ -/* ---------------------------------------------------------------------------- - * This file was automatically generated by SWIG (http://www.swig.org). - * Version 4.0.0 - * - * This file is not intended to be easily readable and contains a number of - * coding conventions designed to improve portability and efficiency. Do not make - * changes to this file unless you know what you are doing--modify the SWIG - * interface file instead. - * ----------------------------------------------------------------------------- */ - -/* --------------------------------------------------------------- - * Programmer(s): Auto-generated by swig. - * --------------------------------------------------------------- - * SUNDIALS Copyright Start - * Copyright (c) 2002-2024, 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_mripi.h" - -SWIGEXPORT SUNAdaptController _wrap_FSUNAdaptController_MRIPI(void *farg1, int const *farg2) { - SUNAdaptController fresult ; - SUNContext arg1 = (SUNContext) 0 ; - int arg2 ; - SUNAdaptController result; - - arg1 = (SUNContext)(farg1); - arg2 = (int)(*farg2); - result = (SUNAdaptController)SUNAdaptController_MRIPI(arg1,arg2); - fresult = result; - return fresult; -} - - -SWIGEXPORT int _wrap_FSUNAdaptController_SetParams_MRIPI(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_SetParams_MRIPI(arg1,arg2,arg3,arg4,arg5); - fresult = (int)(result); - return fresult; -} - - -SWIGEXPORT int _wrap_FSUNAdaptController_GetType_MRIPI(SUNAdaptController farg1) { - int fresult ; - SUNAdaptController arg1 = (SUNAdaptController) 0 ; - SUNAdaptController_Type result; - - arg1 = (SUNAdaptController)(farg1); - result = (SUNAdaptController_Type)SUNAdaptController_GetType_MRIPI(arg1); - fresult = (int)(result); - return fresult; -} - - -SWIGEXPORT int _wrap_FSUNAdaptController_EstimateMRISteps_MRIPI(SUNAdaptController farg1, double const *farg2, double const *farg3, int const *farg4, double const *farg5, double const *farg6, double *farg7, double *farg8) { - int fresult ; - SUNAdaptController arg1 = (SUNAdaptController) 0 ; - sunrealtype arg2 ; - sunrealtype arg3 ; - int arg4 ; - sunrealtype arg5 ; - sunrealtype arg6 ; - sunrealtype *arg7 = (sunrealtype *) 0 ; - sunrealtype *arg8 = (sunrealtype *) 0 ; - int result; - - arg1 = (SUNAdaptController)(farg1); - arg2 = (sunrealtype)(*farg2); - arg3 = (sunrealtype)(*farg3); - arg4 = (int)(*farg4); - arg5 = (sunrealtype)(*farg5); - arg6 = (sunrealtype)(*farg6); - arg7 = (sunrealtype *)(farg7); - arg8 = (sunrealtype *)(farg8); - result = (int)SUNAdaptController_EstimateMRISteps_MRIPI(arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8); - fresult = (int)(result); - return fresult; -} - - -SWIGEXPORT int _wrap_FSUNAdaptController_Reset_MRIPI(SUNAdaptController farg1) { - int fresult ; - SUNAdaptController arg1 = (SUNAdaptController) 0 ; - int result; - - arg1 = (SUNAdaptController)(farg1); - result = (int)SUNAdaptController_Reset_MRIPI(arg1); - fresult = (int)(result); - return fresult; -} - - -SWIGEXPORT int _wrap_FSUNAdaptController_SetDefaults_MRIPI(SUNAdaptController farg1) { - int fresult ; - SUNAdaptController arg1 = (SUNAdaptController) 0 ; - int result; - - arg1 = (SUNAdaptController)(farg1); - result = (int)SUNAdaptController_SetDefaults_MRIPI(arg1); - fresult = (int)(result); - return fresult; -} - - -SWIGEXPORT int _wrap_FSUNAdaptController_Write_MRIPI(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_MRIPI(arg1,arg2); - fresult = (int)(result); - return fresult; -} - - -SWIGEXPORT int _wrap_FSUNAdaptController_SetErrorBias_MRIPI(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_MRIPI(arg1,arg2); - fresult = (int)(result); - return fresult; -} - - -SWIGEXPORT int _wrap_FSUNAdaptController_UpdateMRIH_MRIPI(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_MRIPI(arg1,arg2,arg3,arg4,arg5); - fresult = (int)(result); - return fresult; -} - - -SWIGEXPORT int _wrap_FSUNAdaptController_Space_MRIPI(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_MRIPI(arg1,arg2,arg3); - fresult = (int)(result); - return fresult; -} - - - diff --git a/src/sunadaptcontroller/mripi/fmod_int32/fsunadaptcontroller_mripi_mod.f90 b/src/sunadaptcontroller/mripi/fmod_int32/fsunadaptcontroller_mripi_mod.f90 deleted file mode 100644 index 6aa546b4fa..0000000000 --- a/src/sunadaptcontroller/mripi/fmod_int32/fsunadaptcontroller_mripi_mod.f90 +++ /dev/null @@ -1,337 +0,0 @@ -! This file was automatically generated by SWIG (http://www.swig.org). -! Version 4.0.0 -! -! Do not make changes to this file unless you know what you are doing--modify -! the SWIG interface file instead. - -! --------------------------------------------------------------- -! Programmer(s): Auto-generated by swig. -! --------------------------------------------------------------- -! SUNDIALS Copyright Start -! Copyright (c) 2002-2024, 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_mripi_mod - use, intrinsic :: ISO_C_BINDING - use fsundials_core_mod - implicit none - private - - ! DECLARATION CONSTRUCTS - public :: FSUNAdaptController_MRIPI - public :: FSUNAdaptController_SetParams_MRIPI - public :: FSUNAdaptController_GetType_MRIPI - public :: FSUNAdaptController_EstimateMRISteps_MRIPI - public :: FSUNAdaptController_Reset_MRIPI - public :: FSUNAdaptController_SetDefaults_MRIPI - public :: FSUNAdaptController_Write_MRIPI - public :: FSUNAdaptController_SetErrorBias_MRIPI - public :: FSUNAdaptController_UpdateMRIH_MRIPI - public :: FSUNAdaptController_Space_MRIPI - -! WRAPPER DECLARATIONS -interface -function swigc_FSUNAdaptController_MRIPI(farg1, farg2) & -bind(C, name="_wrap_FSUNAdaptController_MRIPI") & -result(fresult) -use, intrinsic :: ISO_C_BINDING -type(C_PTR), value :: farg1 -integer(C_INT), intent(in) :: farg2 -type(C_PTR) :: fresult -end function - -function swigc_FSUNAdaptController_SetParams_MRIPI(farg1, farg2, farg3, farg4, farg5) & -bind(C, name="_wrap_FSUNAdaptController_SetParams_MRIPI") & -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_GetType_MRIPI(farg1) & -bind(C, name="_wrap_FSUNAdaptController_GetType_MRIPI") & -result(fresult) -use, intrinsic :: ISO_C_BINDING -type(C_PTR), value :: farg1 -integer(C_INT) :: fresult -end function - -function swigc_FSUNAdaptController_EstimateMRISteps_MRIPI(farg1, farg2, farg3, farg4, farg5, farg6, farg7, farg8) & -bind(C, name="_wrap_FSUNAdaptController_EstimateMRISteps_MRIPI") & -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 -real(C_DOUBLE), intent(in) :: farg5 -real(C_DOUBLE), intent(in) :: farg6 -type(C_PTR), value :: farg7 -type(C_PTR), value :: farg8 -integer(C_INT) :: fresult -end function - -function swigc_FSUNAdaptController_Reset_MRIPI(farg1) & -bind(C, name="_wrap_FSUNAdaptController_Reset_MRIPI") & -result(fresult) -use, intrinsic :: ISO_C_BINDING -type(C_PTR), value :: farg1 -integer(C_INT) :: fresult -end function - -function swigc_FSUNAdaptController_SetDefaults_MRIPI(farg1) & -bind(C, name="_wrap_FSUNAdaptController_SetDefaults_MRIPI") & -result(fresult) -use, intrinsic :: ISO_C_BINDING -type(C_PTR), value :: farg1 -integer(C_INT) :: fresult -end function - -function swigc_FSUNAdaptController_Write_MRIPI(farg1, farg2) & -bind(C, name="_wrap_FSUNAdaptController_Write_MRIPI") & -result(fresult) -use, intrinsic :: ISO_C_BINDING -type(C_PTR), value :: farg1 -type(C_PTR), value :: farg2 -integer(C_INT) :: fresult -end function - -function swigc_FSUNAdaptController_SetErrorBias_MRIPI(farg1, farg2) & -bind(C, name="_wrap_FSUNAdaptController_SetErrorBias_MRIPI") & -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_UpdateMRIH_MRIPI(farg1, farg2, farg3, farg4, farg5) & -bind(C, name="_wrap_FSUNAdaptController_UpdateMRIH_MRIPI") & -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_MRIPI(farg1, farg2, farg3) & -bind(C, name="_wrap_FSUNAdaptController_Space_MRIPI") & -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_MRIPI(sunctx, p) & -result(swig_result) -use, intrinsic :: ISO_C_BINDING -type(SUNAdaptController), pointer :: swig_result -type(C_PTR) :: sunctx -integer(C_INT), intent(in) :: p -type(C_PTR) :: fresult -type(C_PTR) :: farg1 -integer(C_INT) :: farg2 - -farg1 = sunctx -farg2 = p -fresult = swigc_FSUNAdaptController_MRIPI(farg1, farg2) -call c_f_pointer(fresult, swig_result) -end function - -function FSUNAdaptController_SetParams_MRIPI(c, k11, k12, k21, k22) & -result(swig_result) -use, intrinsic :: ISO_C_BINDING -integer(C_INT) :: swig_result -type(SUNAdaptController), target, intent(inout) :: c -real(C_DOUBLE), intent(in) :: k11 -real(C_DOUBLE), intent(in) :: k12 -real(C_DOUBLE), intent(in) :: k21 -real(C_DOUBLE), intent(in) :: k22 -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 = k11 -farg3 = k12 -farg4 = k21 -farg5 = k22 -fresult = swigc_FSUNAdaptController_SetParams_MRIPI(farg1, farg2, farg3, farg4, farg5) -swig_result = fresult -end function - -function FSUNAdaptController_GetType_MRIPI(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_MRIPI(farg1) -swig_result = fresult -end function - -function FSUNAdaptController_EstimateMRISteps_MRIPI(c, h, h2, p, dsm, dsm5, hnew, hnew7) & -result(swig_result) -use, intrinsic :: ISO_C_BINDING -integer(C_INT) :: swig_result -type(SUNAdaptController), target, intent(inout) :: c -real(C_DOUBLE), intent(in) :: h -real(C_DOUBLE), intent(in) :: h2 -integer(C_INT), intent(in) :: p -real(C_DOUBLE), intent(in) :: dsm -real(C_DOUBLE), intent(in) :: dsm5 -real(C_DOUBLE), dimension(*), target, intent(inout) :: hnew -real(C_DOUBLE), dimension(*), target, intent(inout) :: hnew7 -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -real(C_DOUBLE) :: farg2 -real(C_DOUBLE) :: farg3 -integer(C_INT) :: farg4 -real(C_DOUBLE) :: farg5 -real(C_DOUBLE) :: farg6 -type(C_PTR) :: farg7 -type(C_PTR) :: farg8 - -farg1 = c_loc(c) -farg2 = h -farg3 = h2 -farg4 = p -farg5 = dsm -farg6 = dsm5 -farg7 = c_loc(hnew(1)) -farg8 = c_loc(hnew7(1)) -fresult = swigc_FSUNAdaptController_EstimateMRISteps_MRIPI(farg1, farg2, farg3, farg4, farg5, farg6, farg7, farg8) -swig_result = fresult -end function - -function FSUNAdaptController_Reset_MRIPI(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_MRIPI(farg1) -swig_result = fresult -end function - -function FSUNAdaptController_SetDefaults_MRIPI(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_MRIPI(farg1) -swig_result = fresult -end function - -function FSUNAdaptController_Write_MRIPI(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_MRIPI(farg1, farg2) -swig_result = fresult -end function - -function FSUNAdaptController_SetErrorBias_MRIPI(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_MRIPI(farg1, farg2) -swig_result = fresult -end function - -function FSUNAdaptController_UpdateMRIH_MRIPI(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_MRIPI(farg1, farg2, farg3, farg4, farg5) -swig_result = fresult -end function - -function FSUNAdaptController_Space_MRIPI(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_MRIPI(farg1, farg2, farg3) -swig_result = fresult -end function - - -end module diff --git a/src/sunadaptcontroller/mripi/fmod_int64/CMakeLists.txt b/src/sunadaptcontroller/mripi/fmod_int64/CMakeLists.txt deleted file mode 100644 index 83a51e3d7c..0000000000 --- a/src/sunadaptcontroller/mripi/fmod_int64/CMakeLists.txt +++ /dev/null @@ -1,26 +0,0 @@ -# --------------------------------------------------------------- -# Programmer(s): Daniel R. Reynolds @ SMU -# --------------------------------------------------------------- -# SUNDIALS Copyright Start -# Copyright (c) 2002-2024, 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_fsunadaptcontrollermripi_mod - SOURCES - fsunadaptcontroller_mripi_mod.f90 fsunadaptcontroller_mripi_mod.c - LINK_LIBRARIES - PUBLIC sundials_fcore_mod - OBJECT_LIBRARIES - OUTPUT_NAME - sundials_fsunadaptcontrollermripi_mod - OBJECT_LIB_ONLY -) - -message(STATUS "Added SUNAdaptController_MRIPI F2003 interface") diff --git a/src/sunadaptcontroller/mripi/fmod_int64/fsunadaptcontroller_mripi_mod.c b/src/sunadaptcontroller/mripi/fmod_int64/fsunadaptcontroller_mripi_mod.c deleted file mode 100644 index 9e05214eb8..0000000000 --- a/src/sunadaptcontroller/mripi/fmod_int64/fsunadaptcontroller_mripi_mod.c +++ /dev/null @@ -1,371 +0,0 @@ -/* ---------------------------------------------------------------------------- - * This file was automatically generated by SWIG (http://www.swig.org). - * Version 4.0.0 - * - * This file is not intended to be easily readable and contains a number of - * coding conventions designed to improve portability and efficiency. Do not make - * changes to this file unless you know what you are doing--modify the SWIG - * interface file instead. - * ----------------------------------------------------------------------------- */ - -/* --------------------------------------------------------------- - * Programmer(s): Auto-generated by swig. - * --------------------------------------------------------------- - * SUNDIALS Copyright Start - * Copyright (c) 2002-2024, 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_mripi.h" - -SWIGEXPORT SUNAdaptController _wrap_FSUNAdaptController_MRIPI(void *farg1, int const *farg2) { - SUNAdaptController fresult ; - SUNContext arg1 = (SUNContext) 0 ; - int arg2 ; - SUNAdaptController result; - - arg1 = (SUNContext)(farg1); - arg2 = (int)(*farg2); - result = (SUNAdaptController)SUNAdaptController_MRIPI(arg1,arg2); - fresult = result; - return fresult; -} - - -SWIGEXPORT int _wrap_FSUNAdaptController_SetParams_MRIPI(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_SetParams_MRIPI(arg1,arg2,arg3,arg4,arg5); - fresult = (int)(result); - return fresult; -} - - -SWIGEXPORT int _wrap_FSUNAdaptController_GetType_MRIPI(SUNAdaptController farg1) { - int fresult ; - SUNAdaptController arg1 = (SUNAdaptController) 0 ; - SUNAdaptController_Type result; - - arg1 = (SUNAdaptController)(farg1); - result = (SUNAdaptController_Type)SUNAdaptController_GetType_MRIPI(arg1); - fresult = (int)(result); - return fresult; -} - - -SWIGEXPORT int _wrap_FSUNAdaptController_EstimateMRISteps_MRIPI(SUNAdaptController farg1, double const *farg2, double const *farg3, int const *farg4, double const *farg5, double const *farg6, double *farg7, double *farg8) { - int fresult ; - SUNAdaptController arg1 = (SUNAdaptController) 0 ; - sunrealtype arg2 ; - sunrealtype arg3 ; - int arg4 ; - sunrealtype arg5 ; - sunrealtype arg6 ; - sunrealtype *arg7 = (sunrealtype *) 0 ; - sunrealtype *arg8 = (sunrealtype *) 0 ; - int result; - - arg1 = (SUNAdaptController)(farg1); - arg2 = (sunrealtype)(*farg2); - arg3 = (sunrealtype)(*farg3); - arg4 = (int)(*farg4); - arg5 = (sunrealtype)(*farg5); - arg6 = (sunrealtype)(*farg6); - arg7 = (sunrealtype *)(farg7); - arg8 = (sunrealtype *)(farg8); - result = (int)SUNAdaptController_EstimateMRISteps_MRIPI(arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8); - fresult = (int)(result); - return fresult; -} - - -SWIGEXPORT int _wrap_FSUNAdaptController_Reset_MRIPI(SUNAdaptController farg1) { - int fresult ; - SUNAdaptController arg1 = (SUNAdaptController) 0 ; - int result; - - arg1 = (SUNAdaptController)(farg1); - result = (int)SUNAdaptController_Reset_MRIPI(arg1); - fresult = (int)(result); - return fresult; -} - - -SWIGEXPORT int _wrap_FSUNAdaptController_SetDefaults_MRIPI(SUNAdaptController farg1) { - int fresult ; - SUNAdaptController arg1 = (SUNAdaptController) 0 ; - int result; - - arg1 = (SUNAdaptController)(farg1); - result = (int)SUNAdaptController_SetDefaults_MRIPI(arg1); - fresult = (int)(result); - return fresult; -} - - -SWIGEXPORT int _wrap_FSUNAdaptController_Write_MRIPI(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_MRIPI(arg1,arg2); - fresult = (int)(result); - return fresult; -} - - -SWIGEXPORT int _wrap_FSUNAdaptController_SetErrorBias_MRIPI(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_MRIPI(arg1,arg2); - fresult = (int)(result); - return fresult; -} - - -SWIGEXPORT int _wrap_FSUNAdaptController_UpdateMRIH_MRIPI(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_MRIPI(arg1,arg2,arg3,arg4,arg5); - fresult = (int)(result); - return fresult; -} - - -SWIGEXPORT int _wrap_FSUNAdaptController_Space_MRIPI(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_MRIPI(arg1,arg2,arg3); - fresult = (int)(result); - return fresult; -} - - - diff --git a/src/sunadaptcontroller/mripi/fmod_int64/fsunadaptcontroller_mripi_mod.f90 b/src/sunadaptcontroller/mripi/fmod_int64/fsunadaptcontroller_mripi_mod.f90 deleted file mode 100644 index 6aa546b4fa..0000000000 --- a/src/sunadaptcontroller/mripi/fmod_int64/fsunadaptcontroller_mripi_mod.f90 +++ /dev/null @@ -1,337 +0,0 @@ -! This file was automatically generated by SWIG (http://www.swig.org). -! Version 4.0.0 -! -! Do not make changes to this file unless you know what you are doing--modify -! the SWIG interface file instead. - -! --------------------------------------------------------------- -! Programmer(s): Auto-generated by swig. -! --------------------------------------------------------------- -! SUNDIALS Copyright Start -! Copyright (c) 2002-2024, 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_mripi_mod - use, intrinsic :: ISO_C_BINDING - use fsundials_core_mod - implicit none - private - - ! DECLARATION CONSTRUCTS - public :: FSUNAdaptController_MRIPI - public :: FSUNAdaptController_SetParams_MRIPI - public :: FSUNAdaptController_GetType_MRIPI - public :: FSUNAdaptController_EstimateMRISteps_MRIPI - public :: FSUNAdaptController_Reset_MRIPI - public :: FSUNAdaptController_SetDefaults_MRIPI - public :: FSUNAdaptController_Write_MRIPI - public :: FSUNAdaptController_SetErrorBias_MRIPI - public :: FSUNAdaptController_UpdateMRIH_MRIPI - public :: FSUNAdaptController_Space_MRIPI - -! WRAPPER DECLARATIONS -interface -function swigc_FSUNAdaptController_MRIPI(farg1, farg2) & -bind(C, name="_wrap_FSUNAdaptController_MRIPI") & -result(fresult) -use, intrinsic :: ISO_C_BINDING -type(C_PTR), value :: farg1 -integer(C_INT), intent(in) :: farg2 -type(C_PTR) :: fresult -end function - -function swigc_FSUNAdaptController_SetParams_MRIPI(farg1, farg2, farg3, farg4, farg5) & -bind(C, name="_wrap_FSUNAdaptController_SetParams_MRIPI") & -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_GetType_MRIPI(farg1) & -bind(C, name="_wrap_FSUNAdaptController_GetType_MRIPI") & -result(fresult) -use, intrinsic :: ISO_C_BINDING -type(C_PTR), value :: farg1 -integer(C_INT) :: fresult -end function - -function swigc_FSUNAdaptController_EstimateMRISteps_MRIPI(farg1, farg2, farg3, farg4, farg5, farg6, farg7, farg8) & -bind(C, name="_wrap_FSUNAdaptController_EstimateMRISteps_MRIPI") & -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 -real(C_DOUBLE), intent(in) :: farg5 -real(C_DOUBLE), intent(in) :: farg6 -type(C_PTR), value :: farg7 -type(C_PTR), value :: farg8 -integer(C_INT) :: fresult -end function - -function swigc_FSUNAdaptController_Reset_MRIPI(farg1) & -bind(C, name="_wrap_FSUNAdaptController_Reset_MRIPI") & -result(fresult) -use, intrinsic :: ISO_C_BINDING -type(C_PTR), value :: farg1 -integer(C_INT) :: fresult -end function - -function swigc_FSUNAdaptController_SetDefaults_MRIPI(farg1) & -bind(C, name="_wrap_FSUNAdaptController_SetDefaults_MRIPI") & -result(fresult) -use, intrinsic :: ISO_C_BINDING -type(C_PTR), value :: farg1 -integer(C_INT) :: fresult -end function - -function swigc_FSUNAdaptController_Write_MRIPI(farg1, farg2) & -bind(C, name="_wrap_FSUNAdaptController_Write_MRIPI") & -result(fresult) -use, intrinsic :: ISO_C_BINDING -type(C_PTR), value :: farg1 -type(C_PTR), value :: farg2 -integer(C_INT) :: fresult -end function - -function swigc_FSUNAdaptController_SetErrorBias_MRIPI(farg1, farg2) & -bind(C, name="_wrap_FSUNAdaptController_SetErrorBias_MRIPI") & -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_UpdateMRIH_MRIPI(farg1, farg2, farg3, farg4, farg5) & -bind(C, name="_wrap_FSUNAdaptController_UpdateMRIH_MRIPI") & -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_MRIPI(farg1, farg2, farg3) & -bind(C, name="_wrap_FSUNAdaptController_Space_MRIPI") & -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_MRIPI(sunctx, p) & -result(swig_result) -use, intrinsic :: ISO_C_BINDING -type(SUNAdaptController), pointer :: swig_result -type(C_PTR) :: sunctx -integer(C_INT), intent(in) :: p -type(C_PTR) :: fresult -type(C_PTR) :: farg1 -integer(C_INT) :: farg2 - -farg1 = sunctx -farg2 = p -fresult = swigc_FSUNAdaptController_MRIPI(farg1, farg2) -call c_f_pointer(fresult, swig_result) -end function - -function FSUNAdaptController_SetParams_MRIPI(c, k11, k12, k21, k22) & -result(swig_result) -use, intrinsic :: ISO_C_BINDING -integer(C_INT) :: swig_result -type(SUNAdaptController), target, intent(inout) :: c -real(C_DOUBLE), intent(in) :: k11 -real(C_DOUBLE), intent(in) :: k12 -real(C_DOUBLE), intent(in) :: k21 -real(C_DOUBLE), intent(in) :: k22 -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 = k11 -farg3 = k12 -farg4 = k21 -farg5 = k22 -fresult = swigc_FSUNAdaptController_SetParams_MRIPI(farg1, farg2, farg3, farg4, farg5) -swig_result = fresult -end function - -function FSUNAdaptController_GetType_MRIPI(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_MRIPI(farg1) -swig_result = fresult -end function - -function FSUNAdaptController_EstimateMRISteps_MRIPI(c, h, h2, p, dsm, dsm5, hnew, hnew7) & -result(swig_result) -use, intrinsic :: ISO_C_BINDING -integer(C_INT) :: swig_result -type(SUNAdaptController), target, intent(inout) :: c -real(C_DOUBLE), intent(in) :: h -real(C_DOUBLE), intent(in) :: h2 -integer(C_INT), intent(in) :: p -real(C_DOUBLE), intent(in) :: dsm -real(C_DOUBLE), intent(in) :: dsm5 -real(C_DOUBLE), dimension(*), target, intent(inout) :: hnew -real(C_DOUBLE), dimension(*), target, intent(inout) :: hnew7 -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -real(C_DOUBLE) :: farg2 -real(C_DOUBLE) :: farg3 -integer(C_INT) :: farg4 -real(C_DOUBLE) :: farg5 -real(C_DOUBLE) :: farg6 -type(C_PTR) :: farg7 -type(C_PTR) :: farg8 - -farg1 = c_loc(c) -farg2 = h -farg3 = h2 -farg4 = p -farg5 = dsm -farg6 = dsm5 -farg7 = c_loc(hnew(1)) -farg8 = c_loc(hnew7(1)) -fresult = swigc_FSUNAdaptController_EstimateMRISteps_MRIPI(farg1, farg2, farg3, farg4, farg5, farg6, farg7, farg8) -swig_result = fresult -end function - -function FSUNAdaptController_Reset_MRIPI(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_MRIPI(farg1) -swig_result = fresult -end function - -function FSUNAdaptController_SetDefaults_MRIPI(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_MRIPI(farg1) -swig_result = fresult -end function - -function FSUNAdaptController_Write_MRIPI(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_MRIPI(farg1, farg2) -swig_result = fresult -end function - -function FSUNAdaptController_SetErrorBias_MRIPI(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_MRIPI(farg1, farg2) -swig_result = fresult -end function - -function FSUNAdaptController_UpdateMRIH_MRIPI(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_MRIPI(farg1, farg2, farg3, farg4, farg5) -swig_result = fresult -end function - -function FSUNAdaptController_Space_MRIPI(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_MRIPI(farg1, farg2, farg3) -swig_result = fresult -end function - - -end module diff --git a/src/sunadaptcontroller/mripi/sunadaptcontroller_mripi.c b/src/sunadaptcontroller/mripi/sunadaptcontroller_mripi.c deleted file mode 100644 index af5b02eaed..0000000000 --- a/src/sunadaptcontroller/mripi/sunadaptcontroller_mripi.c +++ /dev/null @@ -1,237 +0,0 @@ -/* ----------------------------------------------------------------- - * Programmer(s): Daniel R. Reynolds @ SMU - * ----------------------------------------------------------------- - * SUNDIALS Copyright Start - * Copyright (c) 2002-2024, 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_MRIPI module. - * -----------------------------------------------------------------*/ - -#include -#include -#include -#include - -#include "sundials/priv/sundials_errors_impl.h" -#include "sundials/sundials_errors.h" - -/* --------------- - * Macro accessors - * --------------- */ - -#define MRIPI_CONTENT(C) ((SUNAdaptControllerContent_MRIPI)(C->content)) -#define MRIPI_K11(C) (MRIPI_CONTENT(C)->k11) -#define MRIPI_K12(C) (MRIPI_CONTENT(C)->k12) -#define MRIPI_K21(C) (MRIPI_CONTENT(C)->k21) -#define MRIPI_K22(C) (MRIPI_CONTENT(C)->k22) -#define MRIPI_BIAS(C) (MRIPI_CONTENT(C)->bias) -#define MRIPI_ESP(C) (MRIPI_CONTENT(C)->esp) -#define MRIPI_EFP(C) (MRIPI_CONTENT(C)->efp) -#define MRIPI_PFAST(C) (MRIPI_CONTENT(C)->p) - -/* ------------------ - * Default parameters - * ------------------ */ - -#define DEFAULT_K11 SUN_RCONST(0.18) -#define DEFAULT_K12 SUN_RCONST(0.86) -#define DEFAULT_K21 SUN_RCONST(0.34) -#define DEFAULT_K22 SUN_RCONST(0.80) -#define DEFAULT_BIAS SUN_RCONST(1.5) -#define ONE SUN_RCONST(1.0) -#define TINY (SUN_RCONST(10.0) * SUN_UNIT_ROUNDOFF) - -/* ----------------------------------------------------------------- - * exported functions - * ----------------------------------------------------------------- */ - -/* ----------------------------------------------------------------- - * Function to create a new MRIPI controller - */ - -SUNAdaptController SUNAdaptController_MRIPI(SUNContext sunctx, int p) -{ - SUNFunctionBegin(sunctx); - - SUNAdaptController C; - SUNAdaptControllerContent_MRIPI content; - - /* Create an empty controller object */ - C = NULL; - C = SUNAdaptController_NewEmpty(sunctx); - SUNCheckLastErrNull(); - - /* Attach operations */ - C->ops->gettype = SUNAdaptController_GetType_MRIPI; - C->ops->estimatemristeps = SUNAdaptController_EstimateMRISteps_MRIPI; - C->ops->reset = SUNAdaptController_Reset_MRIPI; - C->ops->setdefaults = SUNAdaptController_SetDefaults_MRIPI; - C->ops->write = SUNAdaptController_Write_MRIPI; - C->ops->seterrorbias = SUNAdaptController_SetErrorBias_MRIPI; - C->ops->updatemrih = SUNAdaptController_UpdateMRIH_MRIPI; - C->ops->space = SUNAdaptController_Space_MRIPI; - - /* Create content */ - content = NULL; - content = (SUNAdaptControllerContent_MRIPI)malloc(sizeof *content); - SUNAssertNull(content, SUN_ERR_MALLOC_FAIL); - - /* Attach content */ - C->content = content; - - /* Set fast method order */ - content->p = p; - - /* Fill content with default/reset values */ - SUNCheckCallNull(SUNAdaptController_SetDefaults_MRIPI(C)); - SUNCheckCallNull(SUNAdaptController_Reset_MRIPI(C)); - - return (C); -} - -/* ----------------------------------------------------------------- - * Function to set MRIPI parameters - */ - -SUNErrCode SUNAdaptController_SetParams_MRIPI(SUNAdaptController C, - sunrealtype k11, sunrealtype k12, - sunrealtype k21, sunrealtype k22) -{ - SUNFunctionBegin(C->sunctx); - MRIPI_K11(C) = k11; - MRIPI_K12(C) = k12; - MRIPI_K21(C) = k21; - MRIPI_K22(C) = k22; - return SUN_SUCCESS; -} - -/* ----------------------------------------------------------------- - * implementation of controller operations - * ----------------------------------------------------------------- */ - -SUNAdaptController_Type SUNAdaptController_GetType_MRIPI(SUNAdaptController C) -{ - return SUN_ADAPTCONTROLLER_MRI_H; -} - -SUNErrCode SUNAdaptController_EstimateMRISteps_MRIPI( - SUNAdaptController C, sunrealtype H, sunrealtype h, int P, sunrealtype DSM, - sunrealtype dsm, sunrealtype* Hnew, sunrealtype* hnew) -{ - SUNFunctionBegin(C->sunctx); - SUNAssert(Hnew, SUN_ERR_ARG_CORRUPT); - SUNAssert(hnew, SUN_ERR_ARG_CORRUPT); - - /* set usable time-step adaptivity parameters */ - const int p = MRIPI_PFAST(C); - const sunrealtype k11 = MRIPI_K11(C); - const sunrealtype k12 = MRIPI_K12(C); - const sunrealtype k21 = MRIPI_K21(C); - const sunrealtype k22 = MRIPI_K22(C); - const sunrealtype a1 = (k11 + k12) / (2 * P); - const sunrealtype a2 = -k11 / (2 * P); - const sunrealtype b11 = (p + 1) * (k11 + k12) / (2 * P * p); - const sunrealtype b12 = -(p + 1) * k11 / (2 * P * p); - const sunrealtype b21 = -(k21 + k22) / (2 * p); - const sunrealtype b22 = k21 / (2 * p); - const sunrealtype es1 = ONE / SUNMAX(MRIPI_BIAS(C) * DSM, TINY); - const sunrealtype es2 = ONE / MRIPI_ESP(C); - const sunrealtype ef1 = ONE / SUNMAX(MRIPI_BIAS(C) * dsm, TINY); - const sunrealtype ef2 = ONE / MRIPI_EFP(C); - const sunrealtype M = SUNRceil(H / h); - - /* compute estimated optimal time step size */ - *Hnew = H * SUNRpowerR(es1, a1) * SUNRpowerR(es2, a2); - const sunrealtype Mnew = M * SUNRpowerR(es1, b11) * SUNRpowerR(es2, b12) * - SUNRpowerR(ef1, b21) * SUNRpowerR(ef2, b22); - *hnew = (*Hnew) / Mnew; - - /* return with success */ - return SUN_SUCCESS; -} - -SUNErrCode SUNAdaptController_Reset_MRIPI(SUNAdaptController C) -{ - SUNFunctionBegin(C->sunctx); - MRIPI_ESP(C) = SUN_RCONST(1.0); - MRIPI_EFP(C) = SUN_RCONST(1.0); - return SUN_SUCCESS; -} - -SUNErrCode SUNAdaptController_SetDefaults_MRIPI(SUNAdaptController C) -{ - SUNFunctionBegin(C->sunctx); - MRIPI_K11(C) = DEFAULT_K11; - MRIPI_K12(C) = DEFAULT_K12; - MRIPI_K21(C) = DEFAULT_K21; - MRIPI_K22(C) = DEFAULT_K22; - MRIPI_BIAS(C) = DEFAULT_BIAS; - return SUN_SUCCESS; -} - -SUNErrCode SUNAdaptController_Write_MRIPI(SUNAdaptController C, FILE* fptr) -{ - SUNFunctionBegin(C->sunctx); - SUNAssert(fptr, SUN_ERR_ARG_CORRUPT); - fprintf(fptr, "Multirate PI SUNAdaptController module:\n"); -#if defined(SUNDIALS_EXTENDED_PRECISION) - fprintf(fptr, " k11 = %32Lg\n", MRIPI_K11(C)); - fprintf(fptr, " k12 = %32Lg\n", MRIPI_K12(C)); - fprintf(fptr, " k21 = %32Lg\n", MRIPI_K21(C)); - fprintf(fptr, " k22 = %32Lg\n", MRIPI_K22(C)); - fprintf(fptr, " bias factor = %32Lg\n", MRIPI_BIAS(C)); - fprintf(fptr, " previous slow error = %32Lg\n", MRIPI_ESP(C)); - fprintf(fptr, " previous fast error = %32Lg\n", MRIPI_EFP(C)); -#else - fprintf(fptr, " k11 = %16g\n", MRIPI_K11(C)); - fprintf(fptr, " k12 = %16g\n", MRIPI_K12(C)); - fprintf(fptr, " k21 = %16g\n", MRIPI_K21(C)); - fprintf(fptr, " k22 = %16g\n", MRIPI_K22(C)); - fprintf(fptr, " bias factor = %16g\n", MRIPI_BIAS(C)); - fprintf(fptr, " previous slow error = %16g\n", MRIPI_ESP(C)); - fprintf(fptr, " previous fast error = %16g\n", MRIPI_EFP(C)); -#endif - fprintf(fptr, " p = %i (fast method order)\n", MRIPI_PFAST(C)); - return SUN_SUCCESS; -} - -SUNErrCode SUNAdaptController_SetErrorBias_MRIPI(SUNAdaptController C, - sunrealtype bias) -{ - SUNFunctionBegin(C->sunctx); - - /* set allowed value, otherwise set default */ - if (bias <= SUN_RCONST(0.0)) { MRIPI_BIAS(C) = DEFAULT_BIAS; } - else { MRIPI_BIAS(C) = bias; } - - return SUN_SUCCESS; -} - -SUNErrCode SUNAdaptController_UpdateMRIH_MRIPI(SUNAdaptController C, - sunrealtype H, sunrealtype h, - sunrealtype DSM, sunrealtype dsm) -{ - SUNFunctionBegin(C->sunctx); - MRIPI_ESP(C) = SUNMAX(MRIPI_BIAS(C) * DSM, TINY); - MRIPI_EFP(C) = SUNMAX(MRIPI_BIAS(C) * dsm, TINY); - return SUN_SUCCESS; -} - -SUNErrCode SUNAdaptController_Space_MRIPI(SUNAdaptController C, long int* lenrw, - long int* leniw) -{ - SUNFunctionBegin(C->sunctx); - SUNAssert(lenrw, SUN_ERR_ARG_CORRUPT); - SUNAssert(leniw, SUN_ERR_ARG_CORRUPT); - *lenrw = 7; - *leniw = 1; - return SUN_SUCCESS; -} diff --git a/src/sunadaptcontroller/mripid/CMakeLists.txt b/src/sunadaptcontroller/mripid/CMakeLists.txt deleted file mode 100644 index 5c18b5d723..0000000000 --- a/src/sunadaptcontroller/mripid/CMakeLists.txt +++ /dev/null @@ -1,28 +0,0 @@ -# --------------------------------------------------------------- -# Programmer(s): Daniel R. Reynolds @ SMU -# --------------------------------------------------------------- -# SUNDIALS Copyright Start -# Copyright (c) 2002-2024, 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_sunadaptcontrollermripid - SOURCES sunadaptcontroller_mripid.c - HEADERS - ${SUNDIALS_SOURCE_DIR}/include/sunadaptcontroller/sunadaptcontroller_mripid.h - LINK_LIBRARIES PUBLIC sundials_core - INCLUDE_SUBDIR sunadaptcontroller - OBJECT_LIB_ONLY) - -# Add F2003 module if the interface is enabled -if(BUILD_FORTRAN_MODULE_INTERFACE) - add_subdirectory("fmod_int${SUNDIALS_INDEX_SIZE}") -endif() diff --git a/src/sunadaptcontroller/mripid/fmod_int32/CMakeLists.txt b/src/sunadaptcontroller/mripid/fmod_int32/CMakeLists.txt deleted file mode 100644 index db31e1af04..0000000000 --- a/src/sunadaptcontroller/mripid/fmod_int32/CMakeLists.txt +++ /dev/null @@ -1,26 +0,0 @@ -# --------------------------------------------------------------- -# Programmer(s): Daniel R. Reynolds @ SMU -# --------------------------------------------------------------- -# SUNDIALS Copyright Start -# Copyright (c) 2002-2024, 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_fsunadaptcontrollermripid_mod - SOURCES - fsunadaptcontroller_mripid_mod.f90 fsunadaptcontroller_mripid_mod.c - LINK_LIBRARIES - PUBLIC sundials_fcore_mod - OBJECT_LIBRARIES - OUTPUT_NAME - sundials_fsunadaptcontrollermripid_mod - OBJECT_LIB_ONLY -) - -message(STATUS "Added SUNAdaptController_MRIPID F2003 interface") diff --git a/src/sunadaptcontroller/mripid/fmod_int32/fsunadaptcontroller_mripid_mod.c b/src/sunadaptcontroller/mripid/fmod_int32/fsunadaptcontroller_mripid_mod.c deleted file mode 100644 index 4414b22564..0000000000 --- a/src/sunadaptcontroller/mripid/fmod_int32/fsunadaptcontroller_mripid_mod.c +++ /dev/null @@ -1,375 +0,0 @@ -/* ---------------------------------------------------------------------------- - * This file was automatically generated by SWIG (http://www.swig.org). - * Version 4.0.0 - * - * This file is not intended to be easily readable and contains a number of - * coding conventions designed to improve portability and efficiency. Do not make - * changes to this file unless you know what you are doing--modify the SWIG - * interface file instead. - * ----------------------------------------------------------------------------- */ - -/* --------------------------------------------------------------- - * Programmer(s): Auto-generated by swig. - * --------------------------------------------------------------- - * SUNDIALS Copyright Start - * Copyright (c) 2002-2024, 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_mripid.h" - -SWIGEXPORT SUNAdaptController _wrap_FSUNAdaptController_MRIPID(void *farg1, int const *farg2) { - SUNAdaptController fresult ; - SUNContext arg1 = (SUNContext) 0 ; - int arg2 ; - SUNAdaptController result; - - arg1 = (SUNContext)(farg1); - arg2 = (int)(*farg2); - result = (SUNAdaptController)SUNAdaptController_MRIPID(arg1,arg2); - fresult = result; - return fresult; -} - - -SWIGEXPORT int _wrap_FSUNAdaptController_SetParams_MRIPID(SUNAdaptController farg1, double const *farg2, double const *farg3, double const *farg4, double const *farg5, double const *farg6, double const *farg7) { - int fresult ; - SUNAdaptController arg1 = (SUNAdaptController) 0 ; - sunrealtype arg2 ; - sunrealtype arg3 ; - sunrealtype arg4 ; - sunrealtype arg5 ; - sunrealtype arg6 ; - sunrealtype arg7 ; - 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_SetParams_MRIPID(arg1,arg2,arg3,arg4,arg5,arg6,arg7); - fresult = (int)(result); - return fresult; -} - - -SWIGEXPORT int _wrap_FSUNAdaptController_GetType_MRIPID(SUNAdaptController farg1) { - int fresult ; - SUNAdaptController arg1 = (SUNAdaptController) 0 ; - SUNAdaptController_Type result; - - arg1 = (SUNAdaptController)(farg1); - result = (SUNAdaptController_Type)SUNAdaptController_GetType_MRIPID(arg1); - fresult = (int)(result); - return fresult; -} - - -SWIGEXPORT int _wrap_FSUNAdaptController_EstimateMRISteps_MRIPID(SUNAdaptController farg1, double const *farg2, double const *farg3, int const *farg4, double const *farg5, double const *farg6, double *farg7, double *farg8) { - int fresult ; - SUNAdaptController arg1 = (SUNAdaptController) 0 ; - sunrealtype arg2 ; - sunrealtype arg3 ; - int arg4 ; - sunrealtype arg5 ; - sunrealtype arg6 ; - sunrealtype *arg7 = (sunrealtype *) 0 ; - sunrealtype *arg8 = (sunrealtype *) 0 ; - int result; - - arg1 = (SUNAdaptController)(farg1); - arg2 = (sunrealtype)(*farg2); - arg3 = (sunrealtype)(*farg3); - arg4 = (int)(*farg4); - arg5 = (sunrealtype)(*farg5); - arg6 = (sunrealtype)(*farg6); - arg7 = (sunrealtype *)(farg7); - arg8 = (sunrealtype *)(farg8); - result = (int)SUNAdaptController_EstimateMRISteps_MRIPID(arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8); - fresult = (int)(result); - return fresult; -} - - -SWIGEXPORT int _wrap_FSUNAdaptController_Reset_MRIPID(SUNAdaptController farg1) { - int fresult ; - SUNAdaptController arg1 = (SUNAdaptController) 0 ; - int result; - - arg1 = (SUNAdaptController)(farg1); - result = (int)SUNAdaptController_Reset_MRIPID(arg1); - fresult = (int)(result); - return fresult; -} - - -SWIGEXPORT int _wrap_FSUNAdaptController_SetDefaults_MRIPID(SUNAdaptController farg1) { - int fresult ; - SUNAdaptController arg1 = (SUNAdaptController) 0 ; - int result; - - arg1 = (SUNAdaptController)(farg1); - result = (int)SUNAdaptController_SetDefaults_MRIPID(arg1); - fresult = (int)(result); - return fresult; -} - - -SWIGEXPORT int _wrap_FSUNAdaptController_Write_MRIPID(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_MRIPID(arg1,arg2); - fresult = (int)(result); - return fresult; -} - - -SWIGEXPORT int _wrap_FSUNAdaptController_SetErrorBias_MRIPID(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_MRIPID(arg1,arg2); - fresult = (int)(result); - return fresult; -} - - -SWIGEXPORT int _wrap_FSUNAdaptController_UpdateMRIH_MRIPID(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_MRIPID(arg1,arg2,arg3,arg4,arg5); - fresult = (int)(result); - return fresult; -} - - -SWIGEXPORT int _wrap_FSUNAdaptController_Space_MRIPID(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_MRIPID(arg1,arg2,arg3); - fresult = (int)(result); - return fresult; -} - - - diff --git a/src/sunadaptcontroller/mripid/fmod_int32/fsunadaptcontroller_mripid_mod.f90 b/src/sunadaptcontroller/mripid/fmod_int32/fsunadaptcontroller_mripid_mod.f90 deleted file mode 100644 index 400002f9ce..0000000000 --- a/src/sunadaptcontroller/mripid/fmod_int32/fsunadaptcontroller_mripid_mod.f90 +++ /dev/null @@ -1,345 +0,0 @@ -! This file was automatically generated by SWIG (http://www.swig.org). -! Version 4.0.0 -! -! Do not make changes to this file unless you know what you are doing--modify -! the SWIG interface file instead. - -! --------------------------------------------------------------- -! Programmer(s): Auto-generated by swig. -! --------------------------------------------------------------- -! SUNDIALS Copyright Start -! Copyright (c) 2002-2024, 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_mripid_mod - use, intrinsic :: ISO_C_BINDING - use fsundials_core_mod - implicit none - private - - ! DECLARATION CONSTRUCTS - public :: FSUNAdaptController_MRIPID - public :: FSUNAdaptController_SetParams_MRIPID - public :: FSUNAdaptController_GetType_MRIPID - public :: FSUNAdaptController_EstimateMRISteps_MRIPID - public :: FSUNAdaptController_Reset_MRIPID - public :: FSUNAdaptController_SetDefaults_MRIPID - public :: FSUNAdaptController_Write_MRIPID - public :: FSUNAdaptController_SetErrorBias_MRIPID - public :: FSUNAdaptController_UpdateMRIH_MRIPID - public :: FSUNAdaptController_Space_MRIPID - -! WRAPPER DECLARATIONS -interface -function swigc_FSUNAdaptController_MRIPID(farg1, farg2) & -bind(C, name="_wrap_FSUNAdaptController_MRIPID") & -result(fresult) -use, intrinsic :: ISO_C_BINDING -type(C_PTR), value :: farg1 -integer(C_INT), intent(in) :: farg2 -type(C_PTR) :: fresult -end function - -function swigc_FSUNAdaptController_SetParams_MRIPID(farg1, farg2, farg3, farg4, farg5, farg6, farg7) & -bind(C, name="_wrap_FSUNAdaptController_SetParams_MRIPID") & -result(fresult) -use, intrinsic :: ISO_C_BINDING -type(C_PTR), value :: farg1 -real(C_DOUBLE), intent(in) :: farg2 -real(C_DOUBLE), intent(in) :: farg3 -real(C_DOUBLE), intent(in) :: farg4 -real(C_DOUBLE), intent(in) :: farg5 -real(C_DOUBLE), intent(in) :: farg6 -real(C_DOUBLE), intent(in) :: farg7 -integer(C_INT) :: fresult -end function - -function swigc_FSUNAdaptController_GetType_MRIPID(farg1) & -bind(C, name="_wrap_FSUNAdaptController_GetType_MRIPID") & -result(fresult) -use, intrinsic :: ISO_C_BINDING -type(C_PTR), value :: farg1 -integer(C_INT) :: fresult -end function - -function swigc_FSUNAdaptController_EstimateMRISteps_MRIPID(farg1, farg2, farg3, farg4, farg5, farg6, farg7, farg8) & -bind(C, name="_wrap_FSUNAdaptController_EstimateMRISteps_MRIPID") & -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 -real(C_DOUBLE), intent(in) :: farg5 -real(C_DOUBLE), intent(in) :: farg6 -type(C_PTR), value :: farg7 -type(C_PTR), value :: farg8 -integer(C_INT) :: fresult -end function - -function swigc_FSUNAdaptController_Reset_MRIPID(farg1) & -bind(C, name="_wrap_FSUNAdaptController_Reset_MRIPID") & -result(fresult) -use, intrinsic :: ISO_C_BINDING -type(C_PTR), value :: farg1 -integer(C_INT) :: fresult -end function - -function swigc_FSUNAdaptController_SetDefaults_MRIPID(farg1) & -bind(C, name="_wrap_FSUNAdaptController_SetDefaults_MRIPID") & -result(fresult) -use, intrinsic :: ISO_C_BINDING -type(C_PTR), value :: farg1 -integer(C_INT) :: fresult -end function - -function swigc_FSUNAdaptController_Write_MRIPID(farg1, farg2) & -bind(C, name="_wrap_FSUNAdaptController_Write_MRIPID") & -result(fresult) -use, intrinsic :: ISO_C_BINDING -type(C_PTR), value :: farg1 -type(C_PTR), value :: farg2 -integer(C_INT) :: fresult -end function - -function swigc_FSUNAdaptController_SetErrorBias_MRIPID(farg1, farg2) & -bind(C, name="_wrap_FSUNAdaptController_SetErrorBias_MRIPID") & -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_UpdateMRIH_MRIPID(farg1, farg2, farg3, farg4, farg5) & -bind(C, name="_wrap_FSUNAdaptController_UpdateMRIH_MRIPID") & -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_MRIPID(farg1, farg2, farg3) & -bind(C, name="_wrap_FSUNAdaptController_Space_MRIPID") & -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_MRIPID(sunctx, p) & -result(swig_result) -use, intrinsic :: ISO_C_BINDING -type(SUNAdaptController), pointer :: swig_result -type(C_PTR) :: sunctx -integer(C_INT), intent(in) :: p -type(C_PTR) :: fresult -type(C_PTR) :: farg1 -integer(C_INT) :: farg2 - -farg1 = sunctx -farg2 = p -fresult = swigc_FSUNAdaptController_MRIPID(farg1, farg2) -call c_f_pointer(fresult, swig_result) -end function - -function FSUNAdaptController_SetParams_MRIPID(c, k11, k12, k13, k21, k22, k23) & -result(swig_result) -use, intrinsic :: ISO_C_BINDING -integer(C_INT) :: swig_result -type(SUNAdaptController), target, intent(inout) :: c -real(C_DOUBLE), intent(in) :: k11 -real(C_DOUBLE), intent(in) :: k12 -real(C_DOUBLE), intent(in) :: k13 -real(C_DOUBLE), intent(in) :: k21 -real(C_DOUBLE), intent(in) :: k22 -real(C_DOUBLE), intent(in) :: k23 -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -real(C_DOUBLE) :: farg2 -real(C_DOUBLE) :: farg3 -real(C_DOUBLE) :: farg4 -real(C_DOUBLE) :: farg5 -real(C_DOUBLE) :: farg6 -real(C_DOUBLE) :: farg7 - -farg1 = c_loc(c) -farg2 = k11 -farg3 = k12 -farg4 = k13 -farg5 = k21 -farg6 = k22 -farg7 = k23 -fresult = swigc_FSUNAdaptController_SetParams_MRIPID(farg1, farg2, farg3, farg4, farg5, farg6, farg7) -swig_result = fresult -end function - -function FSUNAdaptController_GetType_MRIPID(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_MRIPID(farg1) -swig_result = fresult -end function - -function FSUNAdaptController_EstimateMRISteps_MRIPID(c, h, h2, p, dsm, dsm5, hnew, hnew7) & -result(swig_result) -use, intrinsic :: ISO_C_BINDING -integer(C_INT) :: swig_result -type(SUNAdaptController), target, intent(inout) :: c -real(C_DOUBLE), intent(in) :: h -real(C_DOUBLE), intent(in) :: h2 -integer(C_INT), intent(in) :: p -real(C_DOUBLE), intent(in) :: dsm -real(C_DOUBLE), intent(in) :: dsm5 -real(C_DOUBLE), dimension(*), target, intent(inout) :: hnew -real(C_DOUBLE), dimension(*), target, intent(inout) :: hnew7 -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -real(C_DOUBLE) :: farg2 -real(C_DOUBLE) :: farg3 -integer(C_INT) :: farg4 -real(C_DOUBLE) :: farg5 -real(C_DOUBLE) :: farg6 -type(C_PTR) :: farg7 -type(C_PTR) :: farg8 - -farg1 = c_loc(c) -farg2 = h -farg3 = h2 -farg4 = p -farg5 = dsm -farg6 = dsm5 -farg7 = c_loc(hnew(1)) -farg8 = c_loc(hnew7(1)) -fresult = swigc_FSUNAdaptController_EstimateMRISteps_MRIPID(farg1, farg2, farg3, farg4, farg5, farg6, farg7, farg8) -swig_result = fresult -end function - -function FSUNAdaptController_Reset_MRIPID(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_MRIPID(farg1) -swig_result = fresult -end function - -function FSUNAdaptController_SetDefaults_MRIPID(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_MRIPID(farg1) -swig_result = fresult -end function - -function FSUNAdaptController_Write_MRIPID(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_MRIPID(farg1, farg2) -swig_result = fresult -end function - -function FSUNAdaptController_SetErrorBias_MRIPID(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_MRIPID(farg1, farg2) -swig_result = fresult -end function - -function FSUNAdaptController_UpdateMRIH_MRIPID(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_MRIPID(farg1, farg2, farg3, farg4, farg5) -swig_result = fresult -end function - -function FSUNAdaptController_Space_MRIPID(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_MRIPID(farg1, farg2, farg3) -swig_result = fresult -end function - - -end module diff --git a/src/sunadaptcontroller/mripid/fmod_int64/CMakeLists.txt b/src/sunadaptcontroller/mripid/fmod_int64/CMakeLists.txt deleted file mode 100644 index db31e1af04..0000000000 --- a/src/sunadaptcontroller/mripid/fmod_int64/CMakeLists.txt +++ /dev/null @@ -1,26 +0,0 @@ -# --------------------------------------------------------------- -# Programmer(s): Daniel R. Reynolds @ SMU -# --------------------------------------------------------------- -# SUNDIALS Copyright Start -# Copyright (c) 2002-2024, 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_fsunadaptcontrollermripid_mod - SOURCES - fsunadaptcontroller_mripid_mod.f90 fsunadaptcontroller_mripid_mod.c - LINK_LIBRARIES - PUBLIC sundials_fcore_mod - OBJECT_LIBRARIES - OUTPUT_NAME - sundials_fsunadaptcontrollermripid_mod - OBJECT_LIB_ONLY -) - -message(STATUS "Added SUNAdaptController_MRIPID F2003 interface") diff --git a/src/sunadaptcontroller/mripid/fmod_int64/fsunadaptcontroller_mripid_mod.c b/src/sunadaptcontroller/mripid/fmod_int64/fsunadaptcontroller_mripid_mod.c deleted file mode 100644 index 4414b22564..0000000000 --- a/src/sunadaptcontroller/mripid/fmod_int64/fsunadaptcontroller_mripid_mod.c +++ /dev/null @@ -1,375 +0,0 @@ -/* ---------------------------------------------------------------------------- - * This file was automatically generated by SWIG (http://www.swig.org). - * Version 4.0.0 - * - * This file is not intended to be easily readable and contains a number of - * coding conventions designed to improve portability and efficiency. Do not make - * changes to this file unless you know what you are doing--modify the SWIG - * interface file instead. - * ----------------------------------------------------------------------------- */ - -/* --------------------------------------------------------------- - * Programmer(s): Auto-generated by swig. - * --------------------------------------------------------------- - * SUNDIALS Copyright Start - * Copyright (c) 2002-2024, 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_mripid.h" - -SWIGEXPORT SUNAdaptController _wrap_FSUNAdaptController_MRIPID(void *farg1, int const *farg2) { - SUNAdaptController fresult ; - SUNContext arg1 = (SUNContext) 0 ; - int arg2 ; - SUNAdaptController result; - - arg1 = (SUNContext)(farg1); - arg2 = (int)(*farg2); - result = (SUNAdaptController)SUNAdaptController_MRIPID(arg1,arg2); - fresult = result; - return fresult; -} - - -SWIGEXPORT int _wrap_FSUNAdaptController_SetParams_MRIPID(SUNAdaptController farg1, double const *farg2, double const *farg3, double const *farg4, double const *farg5, double const *farg6, double const *farg7) { - int fresult ; - SUNAdaptController arg1 = (SUNAdaptController) 0 ; - sunrealtype arg2 ; - sunrealtype arg3 ; - sunrealtype arg4 ; - sunrealtype arg5 ; - sunrealtype arg6 ; - sunrealtype arg7 ; - 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_SetParams_MRIPID(arg1,arg2,arg3,arg4,arg5,arg6,arg7); - fresult = (int)(result); - return fresult; -} - - -SWIGEXPORT int _wrap_FSUNAdaptController_GetType_MRIPID(SUNAdaptController farg1) { - int fresult ; - SUNAdaptController arg1 = (SUNAdaptController) 0 ; - SUNAdaptController_Type result; - - arg1 = (SUNAdaptController)(farg1); - result = (SUNAdaptController_Type)SUNAdaptController_GetType_MRIPID(arg1); - fresult = (int)(result); - return fresult; -} - - -SWIGEXPORT int _wrap_FSUNAdaptController_EstimateMRISteps_MRIPID(SUNAdaptController farg1, double const *farg2, double const *farg3, int const *farg4, double const *farg5, double const *farg6, double *farg7, double *farg8) { - int fresult ; - SUNAdaptController arg1 = (SUNAdaptController) 0 ; - sunrealtype arg2 ; - sunrealtype arg3 ; - int arg4 ; - sunrealtype arg5 ; - sunrealtype arg6 ; - sunrealtype *arg7 = (sunrealtype *) 0 ; - sunrealtype *arg8 = (sunrealtype *) 0 ; - int result; - - arg1 = (SUNAdaptController)(farg1); - arg2 = (sunrealtype)(*farg2); - arg3 = (sunrealtype)(*farg3); - arg4 = (int)(*farg4); - arg5 = (sunrealtype)(*farg5); - arg6 = (sunrealtype)(*farg6); - arg7 = (sunrealtype *)(farg7); - arg8 = (sunrealtype *)(farg8); - result = (int)SUNAdaptController_EstimateMRISteps_MRIPID(arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8); - fresult = (int)(result); - return fresult; -} - - -SWIGEXPORT int _wrap_FSUNAdaptController_Reset_MRIPID(SUNAdaptController farg1) { - int fresult ; - SUNAdaptController arg1 = (SUNAdaptController) 0 ; - int result; - - arg1 = (SUNAdaptController)(farg1); - result = (int)SUNAdaptController_Reset_MRIPID(arg1); - fresult = (int)(result); - return fresult; -} - - -SWIGEXPORT int _wrap_FSUNAdaptController_SetDefaults_MRIPID(SUNAdaptController farg1) { - int fresult ; - SUNAdaptController arg1 = (SUNAdaptController) 0 ; - int result; - - arg1 = (SUNAdaptController)(farg1); - result = (int)SUNAdaptController_SetDefaults_MRIPID(arg1); - fresult = (int)(result); - return fresult; -} - - -SWIGEXPORT int _wrap_FSUNAdaptController_Write_MRIPID(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_MRIPID(arg1,arg2); - fresult = (int)(result); - return fresult; -} - - -SWIGEXPORT int _wrap_FSUNAdaptController_SetErrorBias_MRIPID(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_MRIPID(arg1,arg2); - fresult = (int)(result); - return fresult; -} - - -SWIGEXPORT int _wrap_FSUNAdaptController_UpdateMRIH_MRIPID(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_MRIPID(arg1,arg2,arg3,arg4,arg5); - fresult = (int)(result); - return fresult; -} - - -SWIGEXPORT int _wrap_FSUNAdaptController_Space_MRIPID(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_MRIPID(arg1,arg2,arg3); - fresult = (int)(result); - return fresult; -} - - - diff --git a/src/sunadaptcontroller/mripid/fmod_int64/fsunadaptcontroller_mripid_mod.f90 b/src/sunadaptcontroller/mripid/fmod_int64/fsunadaptcontroller_mripid_mod.f90 deleted file mode 100644 index 400002f9ce..0000000000 --- a/src/sunadaptcontroller/mripid/fmod_int64/fsunadaptcontroller_mripid_mod.f90 +++ /dev/null @@ -1,345 +0,0 @@ -! This file was automatically generated by SWIG (http://www.swig.org). -! Version 4.0.0 -! -! Do not make changes to this file unless you know what you are doing--modify -! the SWIG interface file instead. - -! --------------------------------------------------------------- -! Programmer(s): Auto-generated by swig. -! --------------------------------------------------------------- -! SUNDIALS Copyright Start -! Copyright (c) 2002-2024, 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_mripid_mod - use, intrinsic :: ISO_C_BINDING - use fsundials_core_mod - implicit none - private - - ! DECLARATION CONSTRUCTS - public :: FSUNAdaptController_MRIPID - public :: FSUNAdaptController_SetParams_MRIPID - public :: FSUNAdaptController_GetType_MRIPID - public :: FSUNAdaptController_EstimateMRISteps_MRIPID - public :: FSUNAdaptController_Reset_MRIPID - public :: FSUNAdaptController_SetDefaults_MRIPID - public :: FSUNAdaptController_Write_MRIPID - public :: FSUNAdaptController_SetErrorBias_MRIPID - public :: FSUNAdaptController_UpdateMRIH_MRIPID - public :: FSUNAdaptController_Space_MRIPID - -! WRAPPER DECLARATIONS -interface -function swigc_FSUNAdaptController_MRIPID(farg1, farg2) & -bind(C, name="_wrap_FSUNAdaptController_MRIPID") & -result(fresult) -use, intrinsic :: ISO_C_BINDING -type(C_PTR), value :: farg1 -integer(C_INT), intent(in) :: farg2 -type(C_PTR) :: fresult -end function - -function swigc_FSUNAdaptController_SetParams_MRIPID(farg1, farg2, farg3, farg4, farg5, farg6, farg7) & -bind(C, name="_wrap_FSUNAdaptController_SetParams_MRIPID") & -result(fresult) -use, intrinsic :: ISO_C_BINDING -type(C_PTR), value :: farg1 -real(C_DOUBLE), intent(in) :: farg2 -real(C_DOUBLE), intent(in) :: farg3 -real(C_DOUBLE), intent(in) :: farg4 -real(C_DOUBLE), intent(in) :: farg5 -real(C_DOUBLE), intent(in) :: farg6 -real(C_DOUBLE), intent(in) :: farg7 -integer(C_INT) :: fresult -end function - -function swigc_FSUNAdaptController_GetType_MRIPID(farg1) & -bind(C, name="_wrap_FSUNAdaptController_GetType_MRIPID") & -result(fresult) -use, intrinsic :: ISO_C_BINDING -type(C_PTR), value :: farg1 -integer(C_INT) :: fresult -end function - -function swigc_FSUNAdaptController_EstimateMRISteps_MRIPID(farg1, farg2, farg3, farg4, farg5, farg6, farg7, farg8) & -bind(C, name="_wrap_FSUNAdaptController_EstimateMRISteps_MRIPID") & -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 -real(C_DOUBLE), intent(in) :: farg5 -real(C_DOUBLE), intent(in) :: farg6 -type(C_PTR), value :: farg7 -type(C_PTR), value :: farg8 -integer(C_INT) :: fresult -end function - -function swigc_FSUNAdaptController_Reset_MRIPID(farg1) & -bind(C, name="_wrap_FSUNAdaptController_Reset_MRIPID") & -result(fresult) -use, intrinsic :: ISO_C_BINDING -type(C_PTR), value :: farg1 -integer(C_INT) :: fresult -end function - -function swigc_FSUNAdaptController_SetDefaults_MRIPID(farg1) & -bind(C, name="_wrap_FSUNAdaptController_SetDefaults_MRIPID") & -result(fresult) -use, intrinsic :: ISO_C_BINDING -type(C_PTR), value :: farg1 -integer(C_INT) :: fresult -end function - -function swigc_FSUNAdaptController_Write_MRIPID(farg1, farg2) & -bind(C, name="_wrap_FSUNAdaptController_Write_MRIPID") & -result(fresult) -use, intrinsic :: ISO_C_BINDING -type(C_PTR), value :: farg1 -type(C_PTR), value :: farg2 -integer(C_INT) :: fresult -end function - -function swigc_FSUNAdaptController_SetErrorBias_MRIPID(farg1, farg2) & -bind(C, name="_wrap_FSUNAdaptController_SetErrorBias_MRIPID") & -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_UpdateMRIH_MRIPID(farg1, farg2, farg3, farg4, farg5) & -bind(C, name="_wrap_FSUNAdaptController_UpdateMRIH_MRIPID") & -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_MRIPID(farg1, farg2, farg3) & -bind(C, name="_wrap_FSUNAdaptController_Space_MRIPID") & -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_MRIPID(sunctx, p) & -result(swig_result) -use, intrinsic :: ISO_C_BINDING -type(SUNAdaptController), pointer :: swig_result -type(C_PTR) :: sunctx -integer(C_INT), intent(in) :: p -type(C_PTR) :: fresult -type(C_PTR) :: farg1 -integer(C_INT) :: farg2 - -farg1 = sunctx -farg2 = p -fresult = swigc_FSUNAdaptController_MRIPID(farg1, farg2) -call c_f_pointer(fresult, swig_result) -end function - -function FSUNAdaptController_SetParams_MRIPID(c, k11, k12, k13, k21, k22, k23) & -result(swig_result) -use, intrinsic :: ISO_C_BINDING -integer(C_INT) :: swig_result -type(SUNAdaptController), target, intent(inout) :: c -real(C_DOUBLE), intent(in) :: k11 -real(C_DOUBLE), intent(in) :: k12 -real(C_DOUBLE), intent(in) :: k13 -real(C_DOUBLE), intent(in) :: k21 -real(C_DOUBLE), intent(in) :: k22 -real(C_DOUBLE), intent(in) :: k23 -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -real(C_DOUBLE) :: farg2 -real(C_DOUBLE) :: farg3 -real(C_DOUBLE) :: farg4 -real(C_DOUBLE) :: farg5 -real(C_DOUBLE) :: farg6 -real(C_DOUBLE) :: farg7 - -farg1 = c_loc(c) -farg2 = k11 -farg3 = k12 -farg4 = k13 -farg5 = k21 -farg6 = k22 -farg7 = k23 -fresult = swigc_FSUNAdaptController_SetParams_MRIPID(farg1, farg2, farg3, farg4, farg5, farg6, farg7) -swig_result = fresult -end function - -function FSUNAdaptController_GetType_MRIPID(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_MRIPID(farg1) -swig_result = fresult -end function - -function FSUNAdaptController_EstimateMRISteps_MRIPID(c, h, h2, p, dsm, dsm5, hnew, hnew7) & -result(swig_result) -use, intrinsic :: ISO_C_BINDING -integer(C_INT) :: swig_result -type(SUNAdaptController), target, intent(inout) :: c -real(C_DOUBLE), intent(in) :: h -real(C_DOUBLE), intent(in) :: h2 -integer(C_INT), intent(in) :: p -real(C_DOUBLE), intent(in) :: dsm -real(C_DOUBLE), intent(in) :: dsm5 -real(C_DOUBLE), dimension(*), target, intent(inout) :: hnew -real(C_DOUBLE), dimension(*), target, intent(inout) :: hnew7 -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -real(C_DOUBLE) :: farg2 -real(C_DOUBLE) :: farg3 -integer(C_INT) :: farg4 -real(C_DOUBLE) :: farg5 -real(C_DOUBLE) :: farg6 -type(C_PTR) :: farg7 -type(C_PTR) :: farg8 - -farg1 = c_loc(c) -farg2 = h -farg3 = h2 -farg4 = p -farg5 = dsm -farg6 = dsm5 -farg7 = c_loc(hnew(1)) -farg8 = c_loc(hnew7(1)) -fresult = swigc_FSUNAdaptController_EstimateMRISteps_MRIPID(farg1, farg2, farg3, farg4, farg5, farg6, farg7, farg8) -swig_result = fresult -end function - -function FSUNAdaptController_Reset_MRIPID(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_MRIPID(farg1) -swig_result = fresult -end function - -function FSUNAdaptController_SetDefaults_MRIPID(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_MRIPID(farg1) -swig_result = fresult -end function - -function FSUNAdaptController_Write_MRIPID(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_MRIPID(farg1, farg2) -swig_result = fresult -end function - -function FSUNAdaptController_SetErrorBias_MRIPID(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_MRIPID(farg1, farg2) -swig_result = fresult -end function - -function FSUNAdaptController_UpdateMRIH_MRIPID(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_MRIPID(farg1, farg2, farg3, farg4, farg5) -swig_result = fresult -end function - -function FSUNAdaptController_Space_MRIPID(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_MRIPID(farg1, farg2, farg3) -swig_result = fresult -end function - - -end module diff --git a/src/sunadaptcontroller/mripid/sunadaptcontroller_mripid.c b/src/sunadaptcontroller/mripid/sunadaptcontroller_mripid.c deleted file mode 100644 index deb38c323d..0000000000 --- a/src/sunadaptcontroller/mripid/sunadaptcontroller_mripid.c +++ /dev/null @@ -1,268 +0,0 @@ -/* ----------------------------------------------------------------- - * Programmer(s): Daniel R. Reynolds @ SMU - * ----------------------------------------------------------------- - * SUNDIALS Copyright Start - * Copyright (c) 2002-2024, 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_MRIPID module. - * -----------------------------------------------------------------*/ - -#include -#include -#include -#include - -#include "sundials/priv/sundials_errors_impl.h" -#include "sundials/sundials_errors.h" - -/* --------------- - * Macro accessors - * --------------- */ - -#define MRIPID_CONTENT(C) ((SUNAdaptControllerContent_MRIPID)(C->content)) -#define MRIPID_K11(C) (MRIPID_CONTENT(C)->k11) -#define MRIPID_K12(C) (MRIPID_CONTENT(C)->k12) -#define MRIPID_K13(C) (MRIPID_CONTENT(C)->k13) -#define MRIPID_K21(C) (MRIPID_CONTENT(C)->k21) -#define MRIPID_K22(C) (MRIPID_CONTENT(C)->k22) -#define MRIPID_K23(C) (MRIPID_CONTENT(C)->k23) -#define MRIPID_BIAS(C) (MRIPID_CONTENT(C)->bias) -#define MRIPID_ESP(C) (MRIPID_CONTENT(C)->esp) -#define MRIPID_EFP(C) (MRIPID_CONTENT(C)->efp) -#define MRIPID_ESPP(C) (MRIPID_CONTENT(C)->espp) -#define MRIPID_EFPP(C) (MRIPID_CONTENT(C)->efpp) -#define MRIPID_PFAST(C) (MRIPID_CONTENT(C)->p) - -/* ------------------ - * Default parameters - * ------------------ */ - -#define DEFAULT_K11 SUN_RCONST(0.34) -#define DEFAULT_K12 SUN_RCONST(0.1) -#define DEFAULT_K13 SUN_RCONST(0.78) -#define DEFAULT_K21 SUN_RCONST(0.46) -#define DEFAULT_K22 SUN_RCONST(0.42) -#define DEFAULT_K23 SUN_RCONST(0.74) -#define DEFAULT_BIAS SUN_RCONST(1.5) -#define ONE SUN_RCONST(1.0) -#define TINY (SUN_RCONST(10.0) * SUN_UNIT_ROUNDOFF) - -/* ----------------------------------------------------------------- - * exported functions - * ----------------------------------------------------------------- */ - -/* ----------------------------------------------------------------- - * Function to create a new MRIPID controller - */ - -SUNAdaptController SUNAdaptController_MRIPID(SUNContext sunctx, int p) -{ - SUNFunctionBegin(sunctx); - - SUNAdaptController C; - SUNAdaptControllerContent_MRIPID content; - - /* Create an empty controller object */ - C = NULL; - C = SUNAdaptController_NewEmpty(sunctx); - SUNCheckLastErrNull(); - - /* Attach operations */ - C->ops->gettype = SUNAdaptController_GetType_MRIPID; - C->ops->estimatemristeps = SUNAdaptController_EstimateMRISteps_MRIPID; - C->ops->reset = SUNAdaptController_Reset_MRIPID; - C->ops->setdefaults = SUNAdaptController_SetDefaults_MRIPID; - C->ops->write = SUNAdaptController_Write_MRIPID; - C->ops->seterrorbias = SUNAdaptController_SetErrorBias_MRIPID; - C->ops->updatemrih = SUNAdaptController_UpdateMRIH_MRIPID; - C->ops->space = SUNAdaptController_Space_MRIPID; - - /* Create content */ - content = NULL; - content = (SUNAdaptControllerContent_MRIPID)malloc(sizeof *content); - SUNAssertNull(content, SUN_ERR_MALLOC_FAIL); - - /* Attach content */ - C->content = content; - - /* Set fast method order */ - content->p = p; - - /* Fill content with default/reset values */ - SUNCheckCallNull(SUNAdaptController_SetDefaults_MRIPID(C)); - SUNCheckCallNull(SUNAdaptController_Reset_MRIPID(C)); - - return (C); -} - -/* ----------------------------------------------------------------- - * Function to set MRIPID parameters - */ - -SUNErrCode SUNAdaptController_SetParams_MRIPID(SUNAdaptController C, - sunrealtype k11, sunrealtype k12, - sunrealtype k13, sunrealtype k21, - sunrealtype k22, sunrealtype k23) -{ - SUNFunctionBegin(C->sunctx); - MRIPID_K11(C) = k11; - MRIPID_K12(C) = k12; - MRIPID_K13(C) = k13; - MRIPID_K21(C) = k21; - MRIPID_K22(C) = k22; - MRIPID_K23(C) = k23; - return SUN_SUCCESS; -} - -/* ----------------------------------------------------------------- - * implementation of controller operations - * ----------------------------------------------------------------- */ - -SUNAdaptController_Type SUNAdaptController_GetType_MRIPID(SUNAdaptController C) -{ - return SUN_ADAPTCONTROLLER_MRI_H; -} - -SUNErrCode SUNAdaptController_EstimateMRISteps_MRIPID( - SUNAdaptController C, sunrealtype H, sunrealtype h, int P, sunrealtype DSM, - sunrealtype dsm, sunrealtype* Hnew, sunrealtype* hnew) -{ - SUNFunctionBegin(C->sunctx); - SUNAssert(Hnew, SUN_ERR_ARG_CORRUPT); - SUNAssert(hnew, SUN_ERR_ARG_CORRUPT); - - /* set usable time-step adaptivity parameters */ - const int p = MRIPID_PFAST(C); - const sunrealtype k11 = MRIPID_K11(C); - const sunrealtype k12 = MRIPID_K12(C); - const sunrealtype k13 = MRIPID_K13(C); - const sunrealtype k21 = MRIPID_K21(C); - const sunrealtype k22 = MRIPID_K22(C); - const sunrealtype k23 = MRIPID_K23(C); - const sunrealtype a1 = (k11 + k12 + k13) / (3 * P); - const sunrealtype a2 = -(k11 + k12) / (3 * P); - const sunrealtype a3 = k11 / (3 * P); - const sunrealtype b11 = (p + 1) * (k11 + k12 + k13) / (3 * P * p); - const sunrealtype b12 = -(p + 1) * (k11 + k12) / (3 * P * p); - const sunrealtype b13 = (p + 1) * k11 / (3 * P * p); - const sunrealtype b21 = -(k21 + k22 + k23) / (3 * p); - const sunrealtype b22 = (k21 + k22) / (3 * p); - const sunrealtype b23 = -k21 / (3 * p); - const sunrealtype es1 = ONE / SUNMAX(MRIPID_BIAS(C) * DSM, TINY); - const sunrealtype es2 = ONE / MRIPID_ESP(C); - const sunrealtype es3 = ONE / MRIPID_ESPP(C); - const sunrealtype ef1 = ONE / SUNMAX(MRIPID_BIAS(C) * dsm, TINY); - const sunrealtype ef2 = ONE / MRIPID_EFP(C); - const sunrealtype ef3 = ONE / MRIPID_EFPP(C); - const sunrealtype M = SUNRceil(H / h); - - /* compute estimated optimal time step size */ - *Hnew = H * SUNRpowerR(es1, a1) * SUNRpowerR(es2, a2) * SUNRpowerR(es3, a3); - const sunrealtype Mnew = M * SUNRpowerR(es1, b11) * SUNRpowerR(es2, b12) * - SUNRpowerR(es3, b13) * SUNRpowerR(ef1, b21) * - SUNRpowerR(ef2, b22) * SUNRpowerR(ef3, b23); - *hnew = (*Hnew) / Mnew; - - /* return with success */ - return SUN_SUCCESS; -} - -SUNErrCode SUNAdaptController_Reset_MRIPID(SUNAdaptController C) -{ - SUNFunctionBegin(C->sunctx); - MRIPID_ESP(C) = SUN_RCONST(1.0); - MRIPID_EFP(C) = SUN_RCONST(1.0); - MRIPID_ESPP(C) = SUN_RCONST(1.0); - MRIPID_EFPP(C) = SUN_RCONST(1.0); - return SUN_SUCCESS; -} - -SUNErrCode SUNAdaptController_SetDefaults_MRIPID(SUNAdaptController C) -{ - SUNFunctionBegin(C->sunctx); - MRIPID_K11(C) = DEFAULT_K11; - MRIPID_K12(C) = DEFAULT_K12; - MRIPID_K13(C) = DEFAULT_K13; - MRIPID_K21(C) = DEFAULT_K21; - MRIPID_K22(C) = DEFAULT_K22; - MRIPID_K23(C) = DEFAULT_K23; - MRIPID_BIAS(C) = DEFAULT_BIAS; - return SUN_SUCCESS; -} - -SUNErrCode SUNAdaptController_Write_MRIPID(SUNAdaptController C, FILE* fptr) -{ - SUNFunctionBegin(C->sunctx); - SUNAssert(fptr, SUN_ERR_ARG_CORRUPT); - fprintf(fptr, "Multirate PID SUNAdaptController module:\n"); -#if defined(SUNDIALS_EXTENDED_PRECISION) - fprintf(fptr, " k11 = %32Lg\n", MRIPID_K11(C)); - fprintf(fptr, " k12 = %32Lg\n", MRIPID_K12(C)); - fprintf(fptr, " k13 = %32Lg\n", MRIPID_K13(C)); - fprintf(fptr, " k21 = %32Lg\n", MRIPID_K21(C)); - fprintf(fptr, " k22 = %32Lg\n", MRIPID_K22(C)); - fprintf(fptr, " k23 = %32Lg\n", MRIPID_K23(C)); - fprintf(fptr, " bias factor = %32Lg\n", MRIPID_BIAS(C)); - fprintf(fptr, " previous slow errors = %32Lg %32Lg\n", MRIPID_ESP(C), - MRIPID_ESPP(C)); - fprintf(fptr, " previous fast errors = %32Lg %32Lg\n", MRIPID_EFP(C), - MRIPID_EFPP(C)); -#else - fprintf(fptr, " k11 = %16g\n", MRIPID_K11(C)); - fprintf(fptr, " k12 = %16g\n", MRIPID_K12(C)); - fprintf(fptr, " k13 = %16g\n", MRIPID_K13(C)); - fprintf(fptr, " k21 = %16g\n", MRIPID_K21(C)); - fprintf(fptr, " k22 = %16g\n", MRIPID_K22(C)); - fprintf(fptr, " k23 = %16g\n", MRIPID_K23(C)); - fprintf(fptr, " bias factor = %16g\n", MRIPID_BIAS(C)); - fprintf(fptr, " previous slow errors = %16g %16g\n", MRIPID_ESP(C), - MRIPID_ESPP(C)); - fprintf(fptr, " previous fast errors = %16g %16g\n", MRIPID_EFP(C), - MRIPID_EFPP(C)); -#endif - fprintf(fptr, " p = %i (fast method order)\n", MRIPID_PFAST(C)); - return SUN_SUCCESS; -} - -SUNErrCode SUNAdaptController_SetErrorBias_MRIPID(SUNAdaptController C, - sunrealtype bias) -{ - SUNFunctionBegin(C->sunctx); - - /* set allowed value, otherwise set default */ - if (bias <= SUN_RCONST(0.0)) { MRIPID_BIAS(C) = DEFAULT_BIAS; } - else { MRIPID_BIAS(C) = bias; } - - return SUN_SUCCESS; -} - -SUNErrCode SUNAdaptController_UpdateMRIH_MRIPID(SUNAdaptController C, - sunrealtype H, sunrealtype h, - sunrealtype DSM, sunrealtype dsm) -{ - SUNFunctionBegin(C->sunctx); - MRIPID_ESPP(C) = MRIPID_ESP(C); - MRIPID_EFPP(C) = MRIPID_EFP(C); - MRIPID_ESP(C) = SUNMAX(MRIPID_BIAS(C) * DSM, TINY); - MRIPID_EFP(C) = SUNMAX(MRIPID_BIAS(C) * dsm, TINY); - return SUN_SUCCESS; -} - -SUNErrCode SUNAdaptController_Space_MRIPID(SUNAdaptController C, - long int* lenrw, long int* leniw) -{ - SUNFunctionBegin(C->sunctx); - SUNAssert(lenrw, SUN_ERR_ARG_CORRUPT); - SUNAssert(leniw, SUN_ERR_ARG_CORRUPT); - *lenrw = 11; - *leniw = 1; - return SUN_SUCCESS; -} diff --git a/src/sundials/fmod_int32/fsundials_core_mod.c b/src/sundials/fmod_int32/fsundials_core_mod.c index 4f23389767..8590361c6a 100644 --- a/src/sundials/fmod_int32/fsundials_core_mod.c +++ b/src/sundials/fmod_int32/fsundials_core_mod.c @@ -2557,32 +2557,6 @@ SWIGEXPORT int _wrap_FSUNAdaptController_EstimateStep(SUNAdaptController farg1, } -SWIGEXPORT int _wrap_FSUNAdaptController_EstimateMRISteps(SUNAdaptController farg1, double const *farg2, double const *farg3, int const *farg4, double const *farg5, double const *farg6, double *farg7, double *farg8) { - int fresult ; - SUNAdaptController arg1 = (SUNAdaptController) 0 ; - sunrealtype arg2 ; - sunrealtype arg3 ; - int arg4 ; - sunrealtype arg5 ; - sunrealtype arg6 ; - sunrealtype *arg7 = (sunrealtype *) 0 ; - sunrealtype *arg8 = (sunrealtype *) 0 ; - SUNErrCode result; - - arg1 = (SUNAdaptController)(farg1); - arg2 = (sunrealtype)(*farg2); - arg3 = (sunrealtype)(*farg3); - arg4 = (int)(*farg4); - arg5 = (sunrealtype)(*farg5); - arg6 = (sunrealtype)(*farg6); - arg7 = (sunrealtype *)(farg7); - arg8 = (sunrealtype *)(farg8); - result = (SUNErrCode)SUNAdaptController_EstimateMRISteps(arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8); - fresult = (SUNErrCode)(result); - return fresult; -} - - SWIGEXPORT int _wrap_FSUNAdaptController_EstimateStepTol(SUNAdaptController farg1, double const *farg2, double const *farg3, int const *farg4, double const *farg5, double const *farg6, double *farg7, double *farg8) { int fresult ; SUNAdaptController arg1 = (SUNAdaptController) 0 ; @@ -2677,26 +2651,6 @@ SWIGEXPORT int _wrap_FSUNAdaptController_UpdateH(SUNAdaptController farg1, doubl } -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 ; - SUNErrCode result; - - arg1 = (SUNAdaptController)(farg1); - arg2 = (sunrealtype)(*farg2); - arg3 = (sunrealtype)(*farg3); - arg4 = (sunrealtype)(*farg4); - arg5 = (sunrealtype)(*farg5); - result = (SUNErrCode)SUNAdaptController_UpdateMRIH(arg1,arg2,arg3,arg4,arg5); - fresult = (SUNErrCode)(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 ; diff --git a/src/sundials/fmod_int32/fsundials_core_mod.f90 b/src/sundials/fmod_int32/fsundials_core_mod.f90 index ac96636766..ff9ffaa91c 100644 --- a/src/sundials/fmod_int32/fsundials_core_mod.f90 +++ b/src/sundials/fmod_int32/fsundials_core_mod.f90 @@ -511,16 +511,14 @@ module fsundials_core_mod enum, bind(c) enumerator :: SUN_ADAPTCONTROLLER_NONE enumerator :: SUN_ADAPTCONTROLLER_H - 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_MRI_H, SUN_ADAPTCONTROLLER_MRI_TOL + public :: SUN_ADAPTCONTROLLER_NONE, SUN_ADAPTCONTROLLER_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 :: estimatemristeps type(C_FUNPTR), public :: estimatesteptol type(C_FUNPTR), public :: destroy type(C_FUNPTR), public :: reset @@ -528,7 +526,6 @@ module fsundials_core_mod type(C_FUNPTR), public :: write type(C_FUNPTR), public :: seterrorbias type(C_FUNPTR), public :: updateh - type(C_FUNPTR), public :: updatemrih type(C_FUNPTR), public :: updatemritol type(C_FUNPTR), public :: space end type SUNAdaptController_Ops @@ -543,14 +540,12 @@ module fsundials_core_mod public :: FSUNAdaptController_GetType public :: FSUNAdaptController_Destroy public :: FSUNAdaptController_EstimateStep - public :: FSUNAdaptController_EstimateMRISteps public :: FSUNAdaptController_EstimateStepTol public :: FSUNAdaptController_Reset public :: FSUNAdaptController_SetDefaults public :: FSUNAdaptController_Write public :: FSUNAdaptController_SetErrorBias public :: FSUNAdaptController_UpdateH - public :: FSUNAdaptController_UpdateMRIH public :: FSUNAdaptController_UpdateMRITol public :: FSUNAdaptController_Space @@ -1997,21 +1992,6 @@ function swigc_FSUNAdaptController_EstimateStep(farg1, farg2, farg3, farg4, farg integer(C_INT) :: fresult end function -function swigc_FSUNAdaptController_EstimateMRISteps(farg1, farg2, farg3, farg4, farg5, farg6, farg7, farg8) & -bind(C, name="_wrap_FSUNAdaptController_EstimateMRISteps") & -result(fresult) -use, intrinsic :: ISO_C_BINDING -type(C_PTR), value :: farg1 -real(C_DOUBLE), intent(in) :: farg2 -real(C_DOUBLE), intent(in) :: farg3 -integer(C_INT), intent(in) :: farg4 -real(C_DOUBLE), intent(in) :: farg5 -real(C_DOUBLE), intent(in) :: farg6 -type(C_PTR), value :: farg7 -type(C_PTR), value :: farg8 -integer(C_INT) :: fresult -end function - function swigc_FSUNAdaptController_EstimateStepTol(farg1, farg2, farg3, farg4, farg5, farg6, farg7, farg8) & bind(C, name="_wrap_FSUNAdaptController_EstimateStepTol") & result(fresult) @@ -2071,18 +2051,6 @@ function swigc_FSUNAdaptController_UpdateH(farg1, farg2, farg3) & integer(C_INT) :: fresult end function -function swigc_FSUNAdaptController_UpdateMRIH(farg1, farg2, farg3, farg4, farg5) & -bind(C, name="_wrap_FSUNAdaptController_UpdateMRIH") & -result(fresult) -use, intrinsic :: ISO_C_BINDING -type(C_PTR), value :: farg1 -real(C_DOUBLE), intent(in) :: farg2 -real(C_DOUBLE), intent(in) :: farg3 -real(C_DOUBLE), intent(in) :: farg4 -real(C_DOUBLE), intent(in) :: farg5 -integer(C_INT) :: fresult -end function - function swigc_FSUNAdaptController_UpdateMRITol(farg1, farg2, farg3, farg4, farg5) & bind(C, name="_wrap_FSUNAdaptController_UpdateMRITol") & result(fresult) @@ -4750,40 +4718,6 @@ function FSUNAdaptController_EstimateStep(c, h, p, dsm, hnew) & swig_result = fresult end function -function FSUNAdaptController_EstimateMRISteps(c, h, h2, p, dsm, dsm5, hnew, hnew7) & -result(swig_result) -use, intrinsic :: ISO_C_BINDING -integer(C_INT) :: swig_result -type(SUNAdaptController), target, intent(inout) :: c -real(C_DOUBLE), intent(in) :: h -real(C_DOUBLE), intent(in) :: h2 -integer(C_INT), intent(in) :: p -real(C_DOUBLE), intent(in) :: dsm -real(C_DOUBLE), intent(in) :: dsm5 -real(C_DOUBLE), dimension(*), target, intent(inout) :: hnew -real(C_DOUBLE), dimension(*), target, intent(inout) :: hnew7 -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -real(C_DOUBLE) :: farg2 -real(C_DOUBLE) :: farg3 -integer(C_INT) :: farg4 -real(C_DOUBLE) :: farg5 -real(C_DOUBLE) :: farg6 -type(C_PTR) :: farg7 -type(C_PTR) :: farg8 - -farg1 = c_loc(c) -farg2 = h -farg3 = h2 -farg4 = p -farg5 = dsm -farg6 = dsm5 -farg7 = c_loc(hnew(1)) -farg8 = c_loc(hnew7(1)) -fresult = swigc_FSUNAdaptController_EstimateMRISteps(farg1, farg2, farg3, farg4, farg5, farg6, farg7, farg8) -swig_result = fresult -end function - function FSUNAdaptController_EstimateStepTol(c, h, tolfac, p, dsm, dsm5, hnew, tolfacnew) & result(swig_result) use, intrinsic :: ISO_C_BINDING @@ -4895,31 +4829,6 @@ function FSUNAdaptController_UpdateH(c, h, dsm) & 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 diff --git a/src/sundials/fmod_int64/fsundials_core_mod.c b/src/sundials/fmod_int64/fsundials_core_mod.c index dd19d1aea7..98cb592e42 100644 --- a/src/sundials/fmod_int64/fsundials_core_mod.c +++ b/src/sundials/fmod_int64/fsundials_core_mod.c @@ -2557,32 +2557,6 @@ SWIGEXPORT int _wrap_FSUNAdaptController_EstimateStep(SUNAdaptController farg1, } -SWIGEXPORT int _wrap_FSUNAdaptController_EstimateMRISteps(SUNAdaptController farg1, double const *farg2, double const *farg3, int const *farg4, double const *farg5, double const *farg6, double *farg7, double *farg8) { - int fresult ; - SUNAdaptController arg1 = (SUNAdaptController) 0 ; - sunrealtype arg2 ; - sunrealtype arg3 ; - int arg4 ; - sunrealtype arg5 ; - sunrealtype arg6 ; - sunrealtype *arg7 = (sunrealtype *) 0 ; - sunrealtype *arg8 = (sunrealtype *) 0 ; - SUNErrCode result; - - arg1 = (SUNAdaptController)(farg1); - arg2 = (sunrealtype)(*farg2); - arg3 = (sunrealtype)(*farg3); - arg4 = (int)(*farg4); - arg5 = (sunrealtype)(*farg5); - arg6 = (sunrealtype)(*farg6); - arg7 = (sunrealtype *)(farg7); - arg8 = (sunrealtype *)(farg8); - result = (SUNErrCode)SUNAdaptController_EstimateMRISteps(arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8); - fresult = (SUNErrCode)(result); - return fresult; -} - - SWIGEXPORT int _wrap_FSUNAdaptController_EstimateStepTol(SUNAdaptController farg1, double const *farg2, double const *farg3, int const *farg4, double const *farg5, double const *farg6, double *farg7, double *farg8) { int fresult ; SUNAdaptController arg1 = (SUNAdaptController) 0 ; @@ -2677,26 +2651,6 @@ SWIGEXPORT int _wrap_FSUNAdaptController_UpdateH(SUNAdaptController farg1, doubl } -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 ; - SUNErrCode result; - - arg1 = (SUNAdaptController)(farg1); - arg2 = (sunrealtype)(*farg2); - arg3 = (sunrealtype)(*farg3); - arg4 = (sunrealtype)(*farg4); - arg5 = (sunrealtype)(*farg5); - result = (SUNErrCode)SUNAdaptController_UpdateMRIH(arg1,arg2,arg3,arg4,arg5); - fresult = (SUNErrCode)(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 ; diff --git a/src/sundials/fmod_int64/fsundials_core_mod.f90 b/src/sundials/fmod_int64/fsundials_core_mod.f90 index 632cda7d30..117f0567a3 100644 --- a/src/sundials/fmod_int64/fsundials_core_mod.f90 +++ b/src/sundials/fmod_int64/fsundials_core_mod.f90 @@ -511,16 +511,14 @@ module fsundials_core_mod enum, bind(c) enumerator :: SUN_ADAPTCONTROLLER_NONE enumerator :: SUN_ADAPTCONTROLLER_H - 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_MRI_H, SUN_ADAPTCONTROLLER_MRI_TOL + public :: SUN_ADAPTCONTROLLER_NONE, SUN_ADAPTCONTROLLER_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 :: estimatemristeps type(C_FUNPTR), public :: estimatesteptol type(C_FUNPTR), public :: destroy type(C_FUNPTR), public :: reset @@ -528,7 +526,6 @@ module fsundials_core_mod type(C_FUNPTR), public :: write type(C_FUNPTR), public :: seterrorbias type(C_FUNPTR), public :: updateh - type(C_FUNPTR), public :: updatemrih type(C_FUNPTR), public :: updatemritol type(C_FUNPTR), public :: space end type SUNAdaptController_Ops @@ -543,14 +540,12 @@ module fsundials_core_mod public :: FSUNAdaptController_GetType public :: FSUNAdaptController_Destroy public :: FSUNAdaptController_EstimateStep - public :: FSUNAdaptController_EstimateMRISteps public :: FSUNAdaptController_EstimateStepTol public :: FSUNAdaptController_Reset public :: FSUNAdaptController_SetDefaults public :: FSUNAdaptController_Write public :: FSUNAdaptController_SetErrorBias public :: FSUNAdaptController_UpdateH - public :: FSUNAdaptController_UpdateMRIH public :: FSUNAdaptController_UpdateMRITol public :: FSUNAdaptController_Space @@ -1997,21 +1992,6 @@ function swigc_FSUNAdaptController_EstimateStep(farg1, farg2, farg3, farg4, farg integer(C_INT) :: fresult end function -function swigc_FSUNAdaptController_EstimateMRISteps(farg1, farg2, farg3, farg4, farg5, farg6, farg7, farg8) & -bind(C, name="_wrap_FSUNAdaptController_EstimateMRISteps") & -result(fresult) -use, intrinsic :: ISO_C_BINDING -type(C_PTR), value :: farg1 -real(C_DOUBLE), intent(in) :: farg2 -real(C_DOUBLE), intent(in) :: farg3 -integer(C_INT), intent(in) :: farg4 -real(C_DOUBLE), intent(in) :: farg5 -real(C_DOUBLE), intent(in) :: farg6 -type(C_PTR), value :: farg7 -type(C_PTR), value :: farg8 -integer(C_INT) :: fresult -end function - function swigc_FSUNAdaptController_EstimateStepTol(farg1, farg2, farg3, farg4, farg5, farg6, farg7, farg8) & bind(C, name="_wrap_FSUNAdaptController_EstimateStepTol") & result(fresult) @@ -2071,18 +2051,6 @@ function swigc_FSUNAdaptController_UpdateH(farg1, farg2, farg3) & integer(C_INT) :: fresult end function -function swigc_FSUNAdaptController_UpdateMRIH(farg1, farg2, farg3, farg4, farg5) & -bind(C, name="_wrap_FSUNAdaptController_UpdateMRIH") & -result(fresult) -use, intrinsic :: ISO_C_BINDING -type(C_PTR), value :: farg1 -real(C_DOUBLE), intent(in) :: farg2 -real(C_DOUBLE), intent(in) :: farg3 -real(C_DOUBLE), intent(in) :: farg4 -real(C_DOUBLE), intent(in) :: farg5 -integer(C_INT) :: fresult -end function - function swigc_FSUNAdaptController_UpdateMRITol(farg1, farg2, farg3, farg4, farg5) & bind(C, name="_wrap_FSUNAdaptController_UpdateMRITol") & result(fresult) @@ -4750,40 +4718,6 @@ function FSUNAdaptController_EstimateStep(c, h, p, dsm, hnew) & swig_result = fresult end function -function FSUNAdaptController_EstimateMRISteps(c, h, h2, p, dsm, dsm5, hnew, hnew7) & -result(swig_result) -use, intrinsic :: ISO_C_BINDING -integer(C_INT) :: swig_result -type(SUNAdaptController), target, intent(inout) :: c -real(C_DOUBLE), intent(in) :: h -real(C_DOUBLE), intent(in) :: h2 -integer(C_INT), intent(in) :: p -real(C_DOUBLE), intent(in) :: dsm -real(C_DOUBLE), intent(in) :: dsm5 -real(C_DOUBLE), dimension(*), target, intent(inout) :: hnew -real(C_DOUBLE), dimension(*), target, intent(inout) :: hnew7 -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -real(C_DOUBLE) :: farg2 -real(C_DOUBLE) :: farg3 -integer(C_INT) :: farg4 -real(C_DOUBLE) :: farg5 -real(C_DOUBLE) :: farg6 -type(C_PTR) :: farg7 -type(C_PTR) :: farg8 - -farg1 = c_loc(c) -farg2 = h -farg3 = h2 -farg4 = p -farg5 = dsm -farg6 = dsm5 -farg7 = c_loc(hnew(1)) -farg8 = c_loc(hnew7(1)) -fresult = swigc_FSUNAdaptController_EstimateMRISteps(farg1, farg2, farg3, farg4, farg5, farg6, farg7, farg8) -swig_result = fresult -end function - function FSUNAdaptController_EstimateStepTol(c, h, tolfac, p, dsm, dsm5, hnew, tolfacnew) & result(swig_result) use, intrinsic :: ISO_C_BINDING @@ -4895,31 +4829,6 @@ function FSUNAdaptController_UpdateH(c, h, dsm) & 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 diff --git a/src/sundials/sundials_adaptcontroller.c b/src/sundials/sundials_adaptcontroller.c index 033890e269..b44358289b 100644 --- a/src/sundials/sundials_adaptcontroller.c +++ b/src/sundials/sundials_adaptcontroller.c @@ -50,13 +50,11 @@ SUNAdaptController SUNAdaptController_NewEmpty(SUNContext sunctx) ops->destroy = NULL; ops->reset = NULL; ops->estimatestep = NULL; - ops->estimatemristeps = NULL; ops->estimatesteptol = NULL; ops->setdefaults = NULL; ops->write = NULL; ops->seterrorbias = NULL; ops->updateh = NULL; - ops->updatemrih = NULL; ops->updatemritol = NULL; ops->space = NULL; @@ -141,26 +139,6 @@ SUNErrCode SUNAdaptController_EstimateStep(SUNAdaptController C, sunrealtype h, return (ier); } -SUNErrCode SUNAdaptController_EstimateMRISteps(SUNAdaptController C, - sunrealtype H, sunrealtype h, - int P, sunrealtype DSM, - sunrealtype dsm, sunrealtype* Hnew, - sunrealtype* hnew) -{ - SUNErrCode ier = SUN_SUCCESS; - if (C == NULL) { return SUN_ERR_ARG_CORRUPT; } - SUNFunctionBegin(C->sunctx); - SUNAssert(Hnew, SUN_ERR_ARG_CORRUPT); - SUNAssert(hnew, SUN_ERR_ARG_CORRUPT); - *Hnew = H; /* initialize outputs with identity */ - *hnew = h; - if (C->ops->estimatemristeps) - { - ier = C->ops->estimatemristeps(C, H, h, P, DSM, dsm, Hnew, hnew); - } - return (ier); -} - SUNErrCode SUNAdaptController_EstimateStepTol(SUNAdaptController C, sunrealtype H, sunrealtype tolfac, int P, sunrealtype DSM, @@ -228,17 +206,6 @@ SUNErrCode SUNAdaptController_UpdateH(SUNAdaptController C, sunrealtype h, return (ier); } -SUNErrCode SUNAdaptController_UpdateMRIH(SUNAdaptController C, sunrealtype H, - sunrealtype h, sunrealtype DSM, - sunrealtype dsm) -{ - SUNErrCode ier = SUN_SUCCESS; - if (C == NULL) { return SUN_ERR_ARG_CORRUPT; } - SUNFunctionBegin(C->sunctx); - if (C->ops->updatemrih) { ier = C->ops->updatemrih(C, H, h, DSM, dsm); } - return (ier); -} - SUNErrCode SUNAdaptController_UpdateMRITol(SUNAdaptController C, sunrealtype H, sunrealtype tolfac, sunrealtype DSM, sunrealtype dsm) diff --git a/swig/Makefile b/swig/Makefile index eb772623e9..af5b22a161 100644 --- a/swig/Makefile +++ b/swig/Makefile @@ -27,7 +27,7 @@ NVECTOR=openmp pthreads serial parallel manyvector mpiplusx SUNMATRIX=band dense sparse SUNLINSOL=band dense lapackdense klu spbcgs spfgmr spgmr sptfqmr pcg SUNNONLINSOL=newton fixedpoint -SUNADAPTCONTROLLER=imexgus soderlind +SUNADAPTCONTROLLER=imexgus soderlind mrihtol INCLUDES=-I../include diff --git a/swig/sunadaptcontroller/fsunadaptcontroller_mricc_mod.i b/swig/sunadaptcontroller/fsunadaptcontroller_mricc_mod.i deleted file mode 100644 index c8bccf6abb..0000000000 --- a/swig/sunadaptcontroller/fsunadaptcontroller_mricc_mod.i +++ /dev/null @@ -1,29 +0,0 @@ -// --------------------------------------------------------------- -// Programmer: Daniel R. Reynolds @ SMU -// --------------------------------------------------------------- -// SUNDIALS Copyright Start -// Copyright (c) 2002-2024, 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_mricc_mod - -// include code common to all implementations -%include "fsunadaptcontroller.i" - -%{ -#include "sunadaptcontroller/sunadaptcontroller_mricc.h" -%} - -%sunadaptcontroller_impl(MRICC) - -// Process and wrap functions in the following files -%include "sunadaptcontroller/sunadaptcontroller_mricc.h" diff --git a/swig/sunadaptcontroller/fsunadaptcontroller_mrill_mod.i b/swig/sunadaptcontroller/fsunadaptcontroller_mrill_mod.i deleted file mode 100644 index 7ad44195c9..0000000000 --- a/swig/sunadaptcontroller/fsunadaptcontroller_mrill_mod.i +++ /dev/null @@ -1,29 +0,0 @@ -// --------------------------------------------------------------- -// Programmer: Daniel R. Reynolds @ SMU -// --------------------------------------------------------------- -// SUNDIALS Copyright Start -// Copyright (c) 2002-2024, 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_mrill_mod - -// include code common to all implementations -%include "fsunadaptcontroller.i" - -%{ -#include "sunadaptcontroller/sunadaptcontroller_mrill.h" -%} - -%sunadaptcontroller_impl(MRILL) - -// Process and wrap functions in the following files -%include "sunadaptcontroller/sunadaptcontroller_mrill.h" diff --git a/swig/sunadaptcontroller/fsunadaptcontroller_mripi_mod.i b/swig/sunadaptcontroller/fsunadaptcontroller_mripi_mod.i deleted file mode 100644 index a217037c0f..0000000000 --- a/swig/sunadaptcontroller/fsunadaptcontroller_mripi_mod.i +++ /dev/null @@ -1,29 +0,0 @@ -// --------------------------------------------------------------- -// Programmer: Daniel R. Reynolds @ SMU -// --------------------------------------------------------------- -// SUNDIALS Copyright Start -// Copyright (c) 2002-2024, 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_mripi_mod - -// include code common to all implementations -%include "fsunadaptcontroller.i" - -%{ -#include "sunadaptcontroller/sunadaptcontroller_mripi.h" -%} - -%sunadaptcontroller_impl(MRIPI) - -// Process and wrap functions in the following files -%include "sunadaptcontroller/sunadaptcontroller_mripi.h" diff --git a/swig/sunadaptcontroller/fsunadaptcontroller_mripid_mod.i b/swig/sunadaptcontroller/fsunadaptcontroller_mripid_mod.i deleted file mode 100644 index 9ca30ca5f7..0000000000 --- a/swig/sunadaptcontroller/fsunadaptcontroller_mripid_mod.i +++ /dev/null @@ -1,29 +0,0 @@ -// --------------------------------------------------------------- -// Programmer: Daniel R. Reynolds @ SMU -// --------------------------------------------------------------- -// SUNDIALS Copyright Start -// Copyright (c) 2002-2024, 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_mripid_mod - -// include code common to all implementations -%include "fsunadaptcontroller.i" - -%{ -#include "sunadaptcontroller/sunadaptcontroller_mripid.h" -%} - -%sunadaptcontroller_impl(MRIPID) - -// Process and wrap functions in the following files -%include "sunadaptcontroller/sunadaptcontroller_mripid.h" diff --git a/test/unit_tests/arkode/CXX_serial/CMakeLists.txt b/test/unit_tests/arkode/CXX_serial/CMakeLists.txt index e814329796..19b602a188 100644 --- a/test/unit_tests/arkode/CXX_serial/CMakeLists.txt +++ b/test/unit_tests/arkode/CXX_serial/CMakeLists.txt @@ -49,7 +49,6 @@ set(unit_tests "ark_test_getjac.cpp\;" "ark_test_getjac_mri.cpp\;" "ark_test_kpr_mriadapt.cpp\;--hs 0.002 --rtol 0.000004 --scontrol 0" - "ark_test_kpr_nestedmri.cpp\;" "ark_test_brusselator_mriadapt.cpp\;--rtol 0.000004 --scontrol 0" "ark_test_slowerror_brusselator.cpp\;" "ark_test_slowerror_kpr.cpp\;" @@ -96,11 +95,7 @@ foreach(test_tuple ${unit_tests}) sundials_sunnonlinsolfixedpoint_obj sundials_sunadaptcontrollerimexgus_obj sundials_sunadaptcontrollersoderlind_obj - sundials_sunadaptcontrollermricc_obj - sundials_sunadaptcontrollermrill_obj sundials_sunadaptcontrollermrihtol_obj - sundials_sunadaptcontrollermripi_obj - sundials_sunadaptcontrollermripid_obj ${EXE_EXTRA_LINK_LIBS}) # Tell CMake that we depend on the ARKODE library since it does not pick diff --git a/test/unit_tests/arkode/CXX_serial/ark_test_brusselator_mriadapt.cpp b/test/unit_tests/arkode/CXX_serial/ark_test_brusselator_mriadapt.cpp index 2a55e6392f..0b0c504f2b 100644 --- a/test/unit_tests/arkode/CXX_serial/ark_test_brusselator_mriadapt.cpp +++ b/test/unit_tests/arkode/CXX_serial/ark_test_brusselator_mriadapt.cpp @@ -59,10 +59,6 @@ * specify a valid explicit method order. * - "slow" MRI temporal adaptivity controller: scontrol [default = 6] * 0: no controller [fixed time steps] - * 1: MRI-CC controller - * 2: MRI-LL controller - * 3: MRI-PI controller - * 4: MRI-PID controller * 5: I controller (as part of MRI-HTOL) * 6: I controller (alone) * 7: PI controller (as part of MRI-HTOL) @@ -89,9 +85,8 @@ * -1: no accumulation * 0: maximum accumulation * 1: additive accumulation - * - controller parameters: (k1s, k2s, k3s, k4s, k5s, k6s, k1f, k2f, k3f, + * - controller parameters: (k1s, k2s, k3s, k1f, k2f, k3f, * bias, htol_relch, htol_minfac, htol_maxfac) - * MRICC, MRILL, MRIPI, and MRIPID: use k1s through k6s, as appropriate. * slow single-rate controllers: use k1s through k3s, as appropriate. * fast single-rate controllers: use k1f through k3f, as appropriate. * MRIHTol controllers: use htol_relch, htol_minfac, htol_maxfac. @@ -111,13 +106,9 @@ #include #include #include // serial N_Vector type, fcts., macros +#include #include -#include #include -#include -#include -#include -#include #include #include // dense linear solver #include // dense matrix type, fcts., macros @@ -165,9 +156,6 @@ struct Options sunrealtype k1s = SUN_RCONST(-1.0); sunrealtype k2s = SUN_RCONST(-1.0); sunrealtype k3s = SUN_RCONST(-1.0); - sunrealtype k4s = SUN_RCONST(-1.0); - sunrealtype k5s = SUN_RCONST(-1.0); - sunrealtype k6s = SUN_RCONST(-1.0); sunrealtype k1f = SUN_RCONST(-1.0); sunrealtype k2f = SUN_RCONST(-1.0); sunrealtype k3f = SUN_RCONST(-1.0); @@ -397,54 +385,6 @@ int main(int argc, char* argv[]) SUNAdaptController scontrol_Tol = NULL; switch (opts.scontrol) { - case (1): - scontrol = SUNAdaptController_MRICC(sunctx, - opts.fast_order + opts.fast_pq - 1); - if (check_ptr((void*)scontrol, "SUNAdaptController_MRICC")) return 1; - if (std::min(opts.k1s, opts.k2s) > -1) - { - retval = SUNAdaptController_SetParams_MRICC(scontrol, opts.k1s, opts.k2s); - if (check_flag(retval, "SUNAdaptController_SetParams_MRICC")) return 1; - } - break; - case (2): - scontrol = SUNAdaptController_MRILL(sunctx, - opts.fast_order + opts.fast_pq - 1); - if (check_ptr((void*)scontrol, "SUNAdaptController_MRILL")) return 1; - if (std::min(opts.k1s, std::min(opts.k2s, std::min(opts.k3s, opts.k4s))) > -1) - { - retval = SUNAdaptController_SetParams_MRILL(scontrol, opts.k1s, opts.k2s, - opts.k3s, opts.k4s); - if (check_flag(retval, "SUNAdaptController_SetParams_MRILL")) return 1; - } - break; - case (3): - scontrol = SUNAdaptController_MRIPI(sunctx, - opts.fast_order + opts.fast_pq - 1); - if (check_ptr((void*)scontrol, "SUNAdaptController_MRIPI")) return 1; - if (std::min(opts.k1s, std::min(opts.k2s, std::min(opts.k3s, opts.k4s))) > -1) - { - retval = SUNAdaptController_SetParams_MRIPI(scontrol, opts.k1s, opts.k2s, - opts.k3s, opts.k4s); - if (check_flag(retval, "SUNAdaptController_SetParams_MRIPI")) return 1; - } - break; - case (4): - scontrol = SUNAdaptController_MRIPID(sunctx, - opts.fast_order + opts.fast_pq - 1); - if (check_ptr((void*)scontrol, "SUNAdaptController_MRIPID")) return 1; - if (std::min(opts.k1s, - std::min(opts.k2s, - std::min(opts.k3s, - std::min(opts.k4s, - std::min(opts.k5s, opts.k6s))))) > -1) - { - retval = SUNAdaptController_SetParams_MRIPID(scontrol, opts.k1s, opts.k2s, - opts.k3s, opts.k4s, opts.k5s, - opts.k6s); - if (check_flag(retval, "SUNAdaptController_SetParams_MRIPID")) return 1; - } - break; case (5): scontrol_H = SUNAdaptController_I(sunctx); if (check_ptr((void*)scontrol_H, "SUNAdaptController_I (slow H)")) return 1; @@ -1101,9 +1041,6 @@ int ReadInputs(std::vector& args, Options& opts, SUNContext ctx) find_arg(args, "--k1s", opts.k1s); find_arg(args, "--k2s", opts.k2s); find_arg(args, "--k3s", opts.k3s); - find_arg(args, "--k4s", opts.k4s); - find_arg(args, "--k5s", opts.k5s); - find_arg(args, "--k6s", opts.k6s); find_arg(args, "--k1f", opts.k1f); find_arg(args, "--k2f", opts.k2f); find_arg(args, "--k3f", opts.k3f); @@ -1194,55 +1131,6 @@ static void PrintSlowAdaptivity(Options opts) std::cout << " fixed steps, hs = " << opts.hs << std::endl; std::cout << " rtol = " << opts.rtol << ", atol = " << opts.atol << "\n"; break; - case (1): - std::cout << " MRI-CC controller based on order of MRI " - << ((opts.slow_pq == 1) ? "method\n" : "embedding\n"); - std::cout << " rtol = " << opts.rtol << ", atol = " << opts.atol << "\n"; - std::cout << " fast error accumulation strategy = " << opts.faccum << "\n"; - if (std::min(opts.k1s, opts.k2s) > -1) - { - std::cout << " controller parameters: " << opts.k1s << " " << opts.k2s - << "\n"; - } - break; - case (2): - std::cout << " MRI-LL controller based on order of MRI " - << ((opts.slow_pq == 1) ? "method\n" : "embedding\n"); - std::cout << " rtol = " << opts.rtol << ", atol = " << opts.atol << "\n"; - std::cout << " fast error accumulation strategy = " << opts.faccum << "\n"; - if (std::min(opts.k1s, std::min(opts.k2s, std::min(opts.k3s, opts.k4s))) > -1) - { - std::cout << " controller parameters: " << opts.k1s << " " << opts.k2s - << " " << opts.k3s << " " << opts.k4s << "\n"; - } - break; - case (3): - std::cout << " MRI-PI controller based on order of MRI " - << ((opts.slow_pq == 1) ? "method\n" : "embedding\n"); - std::cout << " rtol = " << opts.rtol << ", atol = " << opts.atol << "\n"; - std::cout << " fast error accumulation strategy = " << opts.faccum << "\n"; - if (std::min(opts.k1s, std::min(opts.k2s, std::min(opts.k3s, opts.k4s))) > -1) - { - std::cout << " controller parameters: " << opts.k1s << " " << opts.k2s - << " " << opts.k3s << " " << opts.k4s << "\n"; - } - break; - case (4): - std::cout << " MRI-PID controller based on order of MRI " - << ((opts.slow_pq == 1) ? "method\n" : "embedding\n"); - std::cout << " rtol = " << opts.rtol << ", atol = " << opts.atol << "\n"; - std::cout << " fast error accumulation strategy = " << opts.faccum << "\n"; - if (std::min(opts.k1s, - std::min(opts.k2s, - std::min(opts.k3s, - std::min(opts.k4s, - std::min(opts.k5s, opts.k6s))))) > -1) - { - std::cout << " controller parameters: " << opts.k1s << " " << opts.k2s - << " " << opts.k3s << " " << opts.k4s << " " << opts.k5s << " " - << opts.k6s << "\n"; - } - break; case (5): std::cout << " MRI-HTOL controller (using I for H) based on order of MRI " diff --git a/test/unit_tests/arkode/CXX_serial/ark_test_kpr_mriadapt.cpp b/test/unit_tests/arkode/CXX_serial/ark_test_kpr_mriadapt.cpp index 53c705cc4b..088913ba0d 100644 --- a/test/unit_tests/arkode/CXX_serial/ark_test_kpr_mriadapt.cpp +++ b/test/unit_tests/arkode/CXX_serial/ark_test_kpr_mriadapt.cpp @@ -57,10 +57,6 @@ * specify a valid explicit method order. * - "slow" MRI temporal adaptivity controller: scontrol [default = 6] * 0: no controller [fixed time steps] - * 1: MRI-CC controller - * 2: MRI-LL controller - * 3: MRI-PI controller - * 4: MRI-PID controller * 5: I controller (as part of MRI-HTOL) * 6: I controller (alone) * 7: PI controller (as part of MRI-HTOL) @@ -87,9 +83,8 @@ * -1: no accumulation * 0: maximum accumulation * 1: additive accumulation - * - controller parameters: (k1s, k2s, k3s, k4s, k5s, k6s, k1f, k2f, k3f, + * - controller parameters: (k1s, k2s, k3s, k1f, k2f, k3f, * bias, htol_relch, htol_minfac, htol_maxfac) - * MRICC, MRILL, MRIPI, and MRIPID: use k1s through k6s, as appropriate. * slow single-rate controllers: use k1s through k3s, as appropriate. * fast single-rate controllers: use k1f through k3f, as appropriate. * MRIHTol controllers: use htol_relch, htol_minfac, htol_maxfac. @@ -109,13 +104,9 @@ #include #include #include // serial N_Vector type, fcts., macros +#include #include -#include #include -#include -#include -#include -#include #include #include // dense linear solver #include // dense matrix type, fcts., macros @@ -163,9 +154,6 @@ struct Options sunrealtype k1s = SUN_RCONST(-1.0); sunrealtype k2s = SUN_RCONST(-1.0); sunrealtype k3s = SUN_RCONST(-1.0); - sunrealtype k4s = SUN_RCONST(-1.0); - sunrealtype k5s = SUN_RCONST(-1.0); - sunrealtype k6s = SUN_RCONST(-1.0); sunrealtype k1f = SUN_RCONST(-1.0); sunrealtype k2f = SUN_RCONST(-1.0); sunrealtype k3f = SUN_RCONST(-1.0); @@ -407,54 +395,6 @@ int main(int argc, char* argv[]) SUNAdaptController scontrol_Tol = NULL; switch (opts.scontrol) { - case (1): - scontrol = SUNAdaptController_MRICC(sunctx, - opts.fast_order + opts.fast_pq - 1); - if (check_ptr((void*)scontrol, "SUNAdaptController_MRICC")) return 1; - if (std::min(opts.k1s, opts.k2s) > -1) - { - retval = SUNAdaptController_SetParams_MRICC(scontrol, opts.k1s, opts.k2s); - if (check_flag(retval, "SUNAdaptController_SetParams_MRICC")) return 1; - } - break; - case (2): - scontrol = SUNAdaptController_MRILL(sunctx, - opts.fast_order + opts.fast_pq - 1); - if (check_ptr((void*)scontrol, "SUNAdaptController_MRILL")) return 1; - if (std::min(opts.k1s, std::min(opts.k2s, std::min(opts.k3s, opts.k4s))) > -1) - { - retval = SUNAdaptController_SetParams_MRILL(scontrol, opts.k1s, opts.k2s, - opts.k3s, opts.k4s); - if (check_flag(retval, "SUNAdaptController_SetParams_MRILL")) return 1; - } - break; - case (3): - scontrol = SUNAdaptController_MRIPI(sunctx, - opts.fast_order + opts.fast_pq - 1); - if (check_ptr((void*)scontrol, "SUNAdaptController_MRIPI")) return 1; - if (std::min(opts.k1s, std::min(opts.k2s, std::min(opts.k3s, opts.k4s))) > -1) - { - retval = SUNAdaptController_SetParams_MRIPI(scontrol, opts.k1s, opts.k2s, - opts.k3s, opts.k4s); - if (check_flag(retval, "SUNAdaptController_SetParams_MRIPI")) return 1; - } - break; - case (4): - scontrol = SUNAdaptController_MRIPID(sunctx, - opts.fast_order + opts.fast_pq - 1); - if (check_ptr((void*)scontrol, "SUNAdaptController_MRIPID")) return 1; - if (std::min(opts.k1s, - std::min(opts.k2s, - std::min(opts.k3s, - std::min(opts.k4s, - std::min(opts.k5s, opts.k6s))))) > -1) - { - retval = SUNAdaptController_SetParams_MRIPID(scontrol, opts.k1s, opts.k2s, - opts.k3s, opts.k4s, opts.k5s, - opts.k6s); - if (check_flag(retval, "SUNAdaptController_SetParams_MRIPID")) return 1; - } - break; case (5): scontrol_H = SUNAdaptController_I(sunctx); if (check_ptr((void*)scontrol_H, "SUNAdaptController_I (slow H)")) return 1; @@ -1138,9 +1078,6 @@ int ReadInputs(std::vector& args, Options& opts, SUNContext ctx) find_arg(args, "--k1s", opts.k1s); find_arg(args, "--k2s", opts.k2s); find_arg(args, "--k3s", opts.k3s); - find_arg(args, "--k4s", opts.k4s); - find_arg(args, "--k5s", opts.k5s); - find_arg(args, "--k6s", opts.k6s); find_arg(args, "--k1f", opts.k1f); find_arg(args, "--k2f", opts.k2f); find_arg(args, "--k3f", opts.k3f); @@ -1237,55 +1174,6 @@ static void PrintSlowAdaptivity(Options opts) std::cout << " fixed steps, hs = " << opts.hs << std::endl; std::cout << " rtol = " << opts.rtol << ", atol = " << opts.atol << "\n"; break; - case (1): - std::cout << " MRI-CC controller based on order of MRI " - << ((opts.slow_pq == 1) ? "method\n" : "embedding\n"); - std::cout << " rtol = " << opts.rtol << ", atol = " << opts.atol << "\n"; - std::cout << " fast error accumulation strategy = " << opts.faccum << "\n"; - if (std::min(opts.k1s, opts.k2s) > -1) - { - std::cout << " controller parameters: " << opts.k1s << " " << opts.k2s - << "\n"; - } - break; - case (2): - std::cout << " MRI-LL controller based on order of MRI " - << ((opts.slow_pq == 1) ? "method\n" : "embedding\n"); - std::cout << " rtol = " << opts.rtol << ", atol = " << opts.atol << "\n"; - std::cout << " fast error accumulation strategy = " << opts.faccum << "\n"; - if (std::min(opts.k1s, std::min(opts.k2s, std::min(opts.k3s, opts.k4s))) > -1) - { - std::cout << " controller parameters: " << opts.k1s << " " << opts.k2s - << " " << opts.k3s << " " << opts.k4s << "\n"; - } - break; - case (3): - std::cout << " MRI-PI controller based on order of MRI " - << ((opts.slow_pq == 1) ? "method\n" : "embedding\n"); - std::cout << " rtol = " << opts.rtol << ", atol = " << opts.atol << "\n"; - std::cout << " fast error accumulation strategy = " << opts.faccum << "\n"; - if (std::min(opts.k1s, std::min(opts.k2s, std::min(opts.k3s, opts.k4s))) > -1) - { - std::cout << " controller parameters: " << opts.k1s << " " << opts.k2s - << " " << opts.k3s << " " << opts.k4s << "\n"; - } - break; - case (4): - std::cout << " MRI-PID controller based on order of MRI " - << ((opts.slow_pq == 1) ? "method\n" : "embedding\n"); - std::cout << " rtol = " << opts.rtol << ", atol = " << opts.atol << "\n"; - std::cout << " fast error accumulation strategy = " << opts.faccum << "\n"; - if (std::min(opts.k1s, - std::min(opts.k2s, - std::min(opts.k3s, - std::min(opts.k4s, - std::min(opts.k5s, opts.k6s))))) > -1) - { - std::cout << " controller parameters: " << opts.k1s << " " << opts.k2s - << " " << opts.k3s << " " << opts.k4s << " " << opts.k5s << " " - << opts.k6s << "\n"; - } - break; case (5): std::cout << " MRI-HTOL controller (using I for H) based on order of MRI " From 0e8e5c74523c7fdf02a0dbea1f3edd2d525f0f64 Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Thu, 5 Sep 2024 08:47:47 -0500 Subject: [PATCH 025/286] Fixed IMEX-MRI-SR method names --- .../unit_tests/arkode/CXX_serial/ark_test_dahlquist_mri.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/unit_tests/arkode/CXX_serial/ark_test_dahlquist_mri.cpp b/test/unit_tests/arkode/CXX_serial/ark_test_dahlquist_mri.cpp index c574e8f989..e831dcb2e7 100644 --- a/test/unit_tests/arkode/CXX_serial/ark_test_dahlquist_mri.cpp +++ b/test/unit_tests/arkode/CXX_serial/ark_test_dahlquist_mri.cpp @@ -363,9 +363,9 @@ int run_tests(ARKODE_MRIType type, ProblemOptions& prob_opts, std::cout << "Test IMEX MRI SR methods\n"; std::cout << "========================\n"; - methods.insert({{"ARKODE_IMEX_MRISR21", true}, - {"ARKODE_IMEX_MRISR32", true}, - {"ARKODE_IMEX_MRISR43", true}}); + methods.insert({{"ARKODE_IMEX_MRI_SR21", true}, + {"ARKODE_IMEX_MRI_SR32", true}, + {"ARKODE_IMEX_MRI_SR43", true}}); } else { return 1; } From 67bb63432ca4092c0f5e4ad605c67168ab9e90cd Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Thu, 5 Sep 2024 08:52:33 -0500 Subject: [PATCH 026/286] Ran code formatter --- .../arkode/CXX_serial/ark_kpr_nestedmri.cpp | 289 ++++++++++-------- src/arkode/arkode_mristep_impl.h | 4 +- src/sundials/sundials_adaptcontroller.c | 22 +- .../ark_test_brusselator_mriadapt.cpp | 20 +- .../CXX_serial/ark_test_kpr_mriadapt.cpp | 20 +- 5 files changed, 187 insertions(+), 168 deletions(-) diff --git a/examples/arkode/CXX_serial/ark_kpr_nestedmri.cpp b/examples/arkode/CXX_serial/ark_kpr_nestedmri.cpp index 5f07fb9aec..0214b3675a 100644 --- a/examples/arkode/CXX_serial/ark_kpr_nestedmri.cpp +++ b/examples/arkode/CXX_serial/ark_kpr_nestedmri.cpp @@ -127,6 +127,7 @@ #include // prototypes for MRIStep fcts., consts #include #include +#include // common utility functions #include #include #include @@ -137,7 +138,6 @@ #include #include // dense linear solver #include // dense matrix type, fcts., macros -#include // common utility functions #if defined(SUNDIALS_EXTENDED_PRECISION) #define ESYM "Le" @@ -199,23 +199,23 @@ struct Options // User-supplied functions called by the solver static int fse(sunrealtype t, N_Vector y, N_Vector ydot, void* user_data); static int fsi(sunrealtype t, N_Vector y, N_Vector ydot, void* user_data); -static int fs( sunrealtype t, N_Vector y, N_Vector ydot, void* user_data); +static int fs(sunrealtype t, N_Vector y, N_Vector ydot, void* user_data); static int fmi(sunrealtype t, N_Vector y, N_Vector ydot, void* user_data); static int fme(sunrealtype t, N_Vector y, N_Vector ydot, void* user_data); -static int fm( sunrealtype t, N_Vector y, N_Vector ydot, void* user_data); -static int ff( sunrealtype t, N_Vector y, N_Vector ydot, void* user_data); -static int fn( sunrealtype t, N_Vector y, N_Vector ydot, void* user_data); -static int f0( sunrealtype t, N_Vector y, N_Vector ydot, void* user_data); -static int Js( sunrealtype t, N_Vector y, N_Vector fy, SUNMatrix J, - void* user_data, N_Vector tmp1, N_Vector tmp2, N_Vector tmp3); +static int fm(sunrealtype t, N_Vector y, N_Vector ydot, void* user_data); +static int ff(sunrealtype t, N_Vector y, N_Vector ydot, void* user_data); +static int fn(sunrealtype t, N_Vector y, N_Vector ydot, void* user_data); +static int f0(sunrealtype t, N_Vector y, N_Vector ydot, void* user_data); +static int Js(sunrealtype t, N_Vector y, N_Vector fy, SUNMatrix J, + void* user_data, N_Vector tmp1, N_Vector tmp2, N_Vector tmp3); static int Jsi(sunrealtype t, N_Vector y, N_Vector fy, SUNMatrix J, void* user_data, N_Vector tmp1, N_Vector tmp2, N_Vector tmp3); -static int Jm( sunrealtype t, N_Vector y, N_Vector fy, SUNMatrix J, - void* user_data, N_Vector tmp1, N_Vector tmp2, N_Vector tmp3); +static int Jm(sunrealtype t, N_Vector y, N_Vector fy, SUNMatrix J, + void* user_data, N_Vector tmp1, N_Vector tmp2, N_Vector tmp3); static int Jmi(sunrealtype t, N_Vector y, N_Vector fy, SUNMatrix J, void* user_data, N_Vector tmp1, N_Vector tmp2, N_Vector tmp3); -static int Jn( sunrealtype t, N_Vector y, N_Vector fy, SUNMatrix J, - void* user_data, N_Vector tmp1, N_Vector tmp2, N_Vector tmp3); +static int Jn(sunrealtype t, N_Vector y, N_Vector fy, SUNMatrix J, + void* user_data, N_Vector tmp1, N_Vector tmp2, N_Vector tmp3); // Utility functions static void InputHelp(); @@ -259,21 +259,21 @@ int main(int argc, char* argv[]) int retval; sunbooleantype slowimplicit, slowimex, midimplicit, midimex; slowimplicit = slowimex = midimplicit = midimex = SUNFALSE; - f_mi = NULL; - f_me = fm; - f_si = NULL; - f_se = fs; - J_m = NULL; - J_s = NULL; - f_f = ff; + f_mi = NULL; + f_me = fm; + f_si = NULL; + f_se = fs; + J_m = NULL; + J_s = NULL; + f_f = ff; if ((opts.mri_method == "ARKODE_MRI_GARK_IRK21a") || (opts.mri_method == "ARKODE_MRI_GARK_ESDIRK34a") || (opts.mri_method == "ARKODE_MRI_GARK_ESDIRK46a")) { slowimplicit = SUNTRUE; - f_se = NULL; - f_si = fs; - J_s = Js; + f_se = NULL; + f_si = fs; + J_s = Js; } if ((opts.mri_method == "ARKODE_IMEX_MRI_SR21") || (opts.mri_method == "ARKODE_IMEX_MRI_SR32") || @@ -281,18 +281,18 @@ int main(int argc, char* argv[]) { slowimex = SUNTRUE; slowimplicit = SUNTRUE; - f_se = fse; - f_si = fsi; - J_s = Jsi; + f_se = fse; + f_si = fsi; + J_s = Jsi; } if ((opts.mid_method == "ARKODE_MRI_GARK_IRK21a") || (opts.mid_method == "ARKODE_MRI_GARK_ESDIRK34a") || (opts.mid_method == "ARKODE_MRI_GARK_ESDIRK46a")) { midimplicit = SUNTRUE; - f_me = NULL; - f_mi = fm; - J_m = Jm; + f_me = NULL; + f_mi = fm; + J_m = Jm; } if ((opts.mid_method == "ARKODE_IMEX_MRI_SR21") || (opts.mid_method == "ARKODE_IMEX_MRI_SR32") || @@ -300,12 +300,13 @@ int main(int argc, char* argv[]) { midimex = SUNTRUE; midimplicit = SUNTRUE; - f_me = fme; - f_mi = fmi; - J_m = Jmi; + f_me = fme; + f_mi = fmi; + J_m = Jmi; } - std::cout << "\nAdaptive nested multirate nonlinear Kvaerno-Prothero-Robinson test " - "problem:\n"; + std::cout + << "\nAdaptive nested multirate nonlinear Kvaerno-Prothero-Robinson test " + "problem:\n"; std::cout << " time domain: (" << T0 << "," << Tf << "]\n"; std::cout << " G = " << opts.G << std::endl; std::cout << " e = " << opts.e << std::endl; @@ -483,7 +484,8 @@ int main(int argc, char* argv[]) if (check_ptr((void*)scontrol, "SUNAdaptController_MRIHTol")) return 1; mcontrol = SUNAdaptController_MRIHTol(sunctx, mcontrol_H, mcontrol_Tol); if (check_ptr((void*)mcontrol, "SUNAdaptController_MRIHTol")) return 1; - if (std::min(opts.htol_relch, std::min(opts.htol_minfac, opts.htol_maxfac)) > -1) + if (std::min(opts.htol_relch, std::min(opts.htol_minfac, opts.htol_maxfac)) > + -1) { retval = SUNAdaptController_SetParams_MRIHTol(scontrol, opts.htol_relch, opts.htol_minfac, @@ -503,8 +505,7 @@ int main(int argc, char* argv[]) if (check_ptr((void*)scontrol_Tol, "SUNAdaptController_PI (slow Tol)")) return 1; mcontrol_H = SUNAdaptController_PI(sunctx); - if (check_ptr((void*)mcontrol_H, "SUNAdaptController_PI (mid H)")) - return 1; + if (check_ptr((void*)mcontrol_H, "SUNAdaptController_PI (mid H)")) return 1; mcontrol_Tol = SUNAdaptController_PI(sunctx); if (check_ptr((void*)mcontrol_Tol, "SUNAdaptController_PI (mid Tol)")) return 1; @@ -747,8 +748,7 @@ int main(int argc, char* argv[]) if (check_ptr((void*)scontrol, "SUNAdaptController_ExpGus (slow)")) return 1; mcontrol = SUNAdaptController_ExpGus(sunctx); - if (check_ptr((void*)mcontrol, "SUNAdaptController_ExpGus (mid)")) - return 1; + if (check_ptr((void*)mcontrol, "SUNAdaptController_ExpGus (mid)")) return 1; if (std::min(opts.k1s, opts.k2s) > -1) { retval = SUNAdaptController_SetParams_ExpGus(scontrol, opts.k1s, opts.k2s); @@ -762,8 +762,7 @@ int main(int argc, char* argv[]) if (check_ptr((void*)scontrol, "SUNAdaptController_ImpGus (slow)")) return 1; mcontrol = SUNAdaptController_ImpGus(sunctx); - if (check_ptr((void*)mcontrol, "SUNAdaptController_ImpGus (mid)")) - return 1; + if (check_ptr((void*)mcontrol, "SUNAdaptController_ImpGus (mid)")) return 1; if (std::min(opts.k1s, opts.k2s) > -1) { retval = SUNAdaptController_SetParams_ImpGus(scontrol, opts.k1s, opts.k2s); @@ -846,12 +845,13 @@ int main(int argc, char* argv[]) // Create intermediate stepper MRIStepInnerStepper intermediate_stepper = NULL; - retval = MRIStepCreateMRIStepInnerStepper(mid_arkode_mem, &intermediate_stepper); + retval = MRIStepCreateMRIStepInnerStepper(mid_arkode_mem, + &intermediate_stepper); if (check_flag(retval, "MRIStepCreateMRIStepInnerStepper")) return 1; // Create MRI (slow) integrator void* arkode_mem = NULL; // ARKode memory structure - arkode_mem = MRIStepCreate(f_se, f_si, T0, y, intermediate_stepper, sunctx); + arkode_mem = MRIStepCreate(f_se, f_si, T0, y, intermediate_stepper, sunctx); if (check_ptr((void*)arkode_mem, "MRIStepCreate")) return 1; MRIStepCoupling Cs = MRIStepCoupling_LoadTableByName((opts.mri_method).c_str()); if (check_ptr((void*)Cs, "MRIStepCoupling_LoadTableByName")) return 1; @@ -913,11 +913,16 @@ int main(int argc, char* argv[]) sunrealtype t2 = T0; sunrealtype dTout = (Tf - T0) / Nt; sunrealtype tout = T0 + dTout; - sunrealtype u, v, w, uerr, verr, werr, uerrtot, verrtot, werrtot, errtot, accuracy; + sunrealtype u, v, w, uerr, verr, werr, uerrtot, verrtot, werrtot, errtot, + accuracy; uerr = verr = werr = uerrtot = verrtot = werrtot = errtot = accuracy = ZERO; - printf(" t u v w uerr verr werr\n"); - printf(" ----------------------------------------------------------------------------\n"); - printf(" %10.6" FSYM " %10.6" FSYM " %10.6" FSYM " %10.6" FSYM " %.2" ESYM " %.2" ESYM " %.2" ESYM "\n", + printf(" t u v w uerr verr " + " werr\n"); + printf(" " + "---------------------------------------------------------------------" + "-------\n"); + printf(" %10.6" FSYM " %10.6" FSYM " %10.6" FSYM " %10.6" FSYM " %.2" ESYM + " %.2" ESYM " %.2" ESYM "\n", t, NV_Ith_S(y, 0), NV_Ith_S(y, 1), NV_Ith_S(y, 2), uerr, verr, werr); int Nout = 0; while (Tf - t > 1.0e-8) @@ -969,7 +974,8 @@ int main(int argc, char* argv[]) { tout += dTout; tout = (tout > Tf) ? Tf : tout; - printf(" %10.6" FSYM " %10.6" FSYM " %10.6" FSYM " %10.6" FSYM " %.2" ESYM " %.2" ESYM " %.2" ESYM "\n", + printf(" %10.6" FSYM " %10.6" FSYM " %10.6" FSYM " %10.6" FSYM + " %.2" ESYM " %.2" ESYM " %.2" ESYM "\n", t, u, v, w, uerr, verr, werr); } } @@ -977,7 +983,9 @@ int main(int argc, char* argv[]) verrtot = SUNRsqrt(verrtot / Nt); werrtot = SUNRsqrt(werrtot / Nt); errtot = SUNRsqrt(errtot / Nt / 3); - printf(" ----------------------------------------------------------------------------\n"); + printf(" " + "---------------------------------------------------------------------" + "-------\n"); // // Finalize @@ -1028,8 +1036,8 @@ int main(int argc, char* argv[]) << ", total error = " << errtot << std::endl; std::cout << " Relative accuracy = " << accuracy << std::endl; std::cout << " Total RHS evals: Fse = " << nfse << ", Fsi = " << nfsi - << ", Fme = " << nfme << ", Fmi = " << nfmi - << ", Ff = " << nff << std::endl; + << ", Fme = " << nfme << ", Fmi = " << nfmi << ", Ff = " << nff + << std::endl; // Get/print slow integrator implicit solver statistics if (slowimplicit) @@ -1072,12 +1080,12 @@ int main(int argc, char* argv[]) if (mcontrol_H) { SUNAdaptController_Destroy(mcontrol_H); } if (mcontrol_Tol) { SUNAdaptController_Destroy(mcontrol_Tol); } if (fcontrol) { SUNAdaptController_Destroy(fcontrol); } - ARKodeFree(&inner_arkode_mem); // Free fast integrator memory - ARKodeFree(&mid_arkode_mem) ; // Free intermediate integrator memory + ARKodeFree(&inner_arkode_mem); // Free fast integrator memory + ARKodeFree(&mid_arkode_mem); // Free intermediate integrator memory MRIStepInnerStepper_Free(&inner_stepper); // Free inner stepper structures MRIStepInnerStepper_Free(&intermediate_stepper); - ARKodeFree(&arkode_mem); // Free slow integrator memory - ARKodeFree(&arkode_ref); // Free reference solver memory + ARKodeFree(&arkode_mem); // Free slow integrator memory + ARKodeFree(&arkode_ref); // Free reference solver memory return 0; } @@ -1089,12 +1097,12 @@ int main(int argc, char* argv[]) // fn routine to compute the full ODE RHS. static int fn(sunrealtype t, N_Vector y, N_Vector ydot, void* user_data) { - Options* opts = (Options*)user_data; - const sunrealtype u = NV_Ith_S(y, 0); - const sunrealtype v = NV_Ith_S(y, 1); - const sunrealtype w = NV_Ith_S(y, 2); - const sunrealtype G = opts->G; - const sunrealtype e = opts->e; + Options* opts = (Options*)user_data; + const sunrealtype u = NV_Ith_S(y, 0); + const sunrealtype v = NV_Ith_S(y, 1); + const sunrealtype w = NV_Ith_S(y, 2); + const sunrealtype G = opts->G; + const sunrealtype e = opts->e; const sunrealtype al = opts->al; const sunrealtype be = opts->be; sunrealtype tmp1, tmp2, tmp3; @@ -1107,8 +1115,10 @@ static int fn(sunrealtype t, N_Vector y, N_Vector ydot, void* user_data) tmp2 = (-TWO + v * v - q(t, opts)) / (TWO * v); tmp3 = (-TWO + w * w - r(t, opts)) / (TWO * w); NV_Ith_S(ydot, 0) = G * tmp1 + e * tmp2 + e * tmp3 + pdot(t, opts) / (TWO * u); - NV_Ith_S(ydot, 1) = e * tmp1 + al * tmp2 + be * tmp3 + qdot(t, opts) / (TWO * v); - NV_Ith_S(ydot, 2) = e * tmp1 - be * tmp2 + al * tmp3 + rdot(t, opts) / (TWO * w); + NV_Ith_S(ydot, 1) = e * tmp1 + al * tmp2 + be * tmp3 + + qdot(t, opts) / (TWO * v); + NV_Ith_S(ydot, 2) = e * tmp1 - be * tmp2 + al * tmp3 + + rdot(t, opts) / (TWO * w); // Return with success return 0; @@ -1117,11 +1127,11 @@ static int fn(sunrealtype t, N_Vector y, N_Vector ydot, void* user_data) // ff routine to compute the fast portion of the ODE RHS. static int ff(sunrealtype t, N_Vector y, N_Vector ydot, void* user_data) { - Options* opts = (Options*)user_data; - const sunrealtype u = NV_Ith_S(y, 0); - const sunrealtype v = NV_Ith_S(y, 1); - const sunrealtype w = NV_Ith_S(y, 2); - const sunrealtype e = opts->e; + Options* opts = (Options*)user_data; + const sunrealtype u = NV_Ith_S(y, 0); + const sunrealtype v = NV_Ith_S(y, 1); + const sunrealtype w = NV_Ith_S(y, 2); + const sunrealtype e = opts->e; const sunrealtype al = opts->al; const sunrealtype be = opts->be; sunrealtype tmp1, tmp2, tmp3; @@ -1130,12 +1140,13 @@ static int ff(sunrealtype t, N_Vector y, N_Vector ydot, void* user_data) // [ 0 0 0 ] [(u^2-p-2)/(2u)] + [ 0 ] // [ 0 0 0 ] [(v^2-q-2)/(2v)] [ 0 ] // [ e -be al ] [(w^2-r-2)/(2w)] [ rdot(t)/(2w) ] - tmp1 = (-TWO + u * u - p(t, opts)) / (TWO * u); - tmp2 = (-TWO + v * v - q(t, opts)) / (TWO * v); - tmp3 = (-TWO + w * w - r(t, opts)) / (TWO * w); + tmp1 = (-TWO + u * u - p(t, opts)) / (TWO * u); + tmp2 = (-TWO + v * v - q(t, opts)) / (TWO * v); + tmp3 = (-TWO + w * w - r(t, opts)) / (TWO * w); NV_Ith_S(ydot, 0) = ZERO; NV_Ith_S(ydot, 1) = ZERO; - NV_Ith_S(ydot, 2) = e * tmp1 - be * tmp2 + al * tmp3 + rdot(t, opts) / (TWO * w); + NV_Ith_S(ydot, 2) = e * tmp1 - be * tmp2 + al * tmp3 + + rdot(t, opts) / (TWO * w); // Return with success return 0; @@ -1144,11 +1155,11 @@ static int ff(sunrealtype t, N_Vector y, N_Vector ydot, void* user_data) // fm routine to compute the intermediate portion of the ODE RHS. static int fm(sunrealtype t, N_Vector y, N_Vector ydot, void* user_data) { - Options* opts = (Options*)user_data; - const sunrealtype u = NV_Ith_S(y, 0); - const sunrealtype v = NV_Ith_S(y, 1); - const sunrealtype w = NV_Ith_S(y, 2); - const sunrealtype e = opts->e; + Options* opts = (Options*)user_data; + const sunrealtype u = NV_Ith_S(y, 0); + const sunrealtype v = NV_Ith_S(y, 1); + const sunrealtype w = NV_Ith_S(y, 2); + const sunrealtype e = opts->e; const sunrealtype al = opts->al; const sunrealtype be = opts->be; sunrealtype tmp1, tmp2, tmp3; @@ -1157,11 +1168,12 @@ static int fm(sunrealtype t, N_Vector y, N_Vector ydot, void* user_data) // [ 0 0 0 ] [(u^2-p-2)/(2u)] + [ 0 ] // [ e al be ] [(v^2-q-2)/(2v)] [ qdot(t)/(2v) ] // [ 0 0 0 ] [(w^2-r-2)/(2w)] [ 0 ] - tmp1 = (-TWO + u * u - p(t, opts)) / (TWO * u); - tmp2 = (-TWO + v * v - q(t, opts)) / (TWO * v); - tmp3 = (-TWO + w * w - r(t, opts)) / (TWO * w); + tmp1 = (-TWO + u * u - p(t, opts)) / (TWO * u); + tmp2 = (-TWO + v * v - q(t, opts)) / (TWO * v); + tmp3 = (-TWO + w * w - r(t, opts)) / (TWO * w); NV_Ith_S(ydot, 0) = ZERO; - NV_Ith_S(ydot, 1) = e * tmp1 + al * tmp2 + be * tmp3 + qdot(t, opts) / (TWO * v); + NV_Ith_S(ydot, 1) = e * tmp1 + al * tmp2 + be * tmp3 + + qdot(t, opts) / (TWO * v); NV_Ith_S(ydot, 2) = ZERO; return 0; @@ -1187,11 +1199,11 @@ static int fme(sunrealtype t, N_Vector y, N_Vector ydot, void* user_data) // fmi routine to compute the implicit intermediate portion of the ODE RHS. static int fmi(sunrealtype t, N_Vector y, N_Vector ydot, void* user_data) { - Options* opts = (Options*)user_data; - const sunrealtype u = NV_Ith_S(y, 0); - const sunrealtype v = NV_Ith_S(y, 1); - const sunrealtype w = NV_Ith_S(y, 2); - const sunrealtype e = opts->e; + Options* opts = (Options*)user_data; + const sunrealtype u = NV_Ith_S(y, 0); + const sunrealtype v = NV_Ith_S(y, 1); + const sunrealtype w = NV_Ith_S(y, 2); + const sunrealtype e = opts->e; const sunrealtype al = opts->al; const sunrealtype be = opts->be; sunrealtype tmp1, tmp2, tmp3; @@ -1200,9 +1212,9 @@ static int fmi(sunrealtype t, N_Vector y, N_Vector ydot, void* user_data) // [ 0 0 0 ] [(u^2-p-2)/(2u)] // [ e al be ] [(v^2-q-2)/(2v)] // [ 0 0 0 ] [(w^2-r-2)/(2w)] - tmp1 = (-TWO + u * u - p(t, opts)) / (TWO * u); - tmp2 = (-TWO + v * v - q(t, opts)) / (TWO * v); - tmp3 = (-TWO + w * w - r(t, opts)) / (TWO * w); + tmp1 = (-TWO + u * u - p(t, opts)) / (TWO * u); + tmp2 = (-TWO + v * v - q(t, opts)) / (TWO * v); + tmp3 = (-TWO + w * w - r(t, opts)) / (TWO * w); NV_Ith_S(ydot, 0) = ZERO; NV_Ith_S(ydot, 1) = e * tmp1 + al * tmp2 + be * tmp3; NV_Ith_S(ydot, 2) = ZERO; @@ -1268,9 +1280,9 @@ static int fsi(sunrealtype t, N_Vector y, N_Vector ydot, void* user_data) // [ G e e ] [(u^2-p-2)/(2u)] // [ 0 0 0 ] [(v^2-q-2)/(2v)] // [ 0 0 0 ] [(w^2-r-2)/(2w)] - tmp1 = (-TWO + u * u - p(t, opts)) / (TWO * u); - tmp2 = (-TWO + v * v - q(t, opts)) / (TWO * v); - tmp3 = (-TWO + w * w - r(t, opts)) / (TWO * w); + tmp1 = (-TWO + u * u - p(t, opts)) / (TWO * u); + tmp2 = (-TWO + v * v - q(t, opts)) / (TWO * v); + tmp3 = (-TWO + w * w - r(t, opts)) / (TWO * w); NV_Ith_S(ydot, 0) = G * tmp1 + e * tmp2 + e * tmp3; NV_Ith_S(ydot, 1) = ZERO; NV_Ith_S(ydot, 2) = ZERO; @@ -1299,9 +1311,9 @@ static int Jn(sunrealtype t, N_Vector y, N_Vector fy, SUNMatrix J, // [G e e]*[1-(u^2-p(t)-2)/(2*u^2), 0, 0] + [-p'(t)/(2*u^2), 0, 0] // [e al be] [0, 1-(v^2-q(t)-2)/(2*v^2), 0] [0, -q'(t)/(2*v^2), 0] // [e -be al] [0, 0, 1-(w^2-r(t)-2)/(2*w^2)] [0, 0, -r'(t)/(2*w^2)] - t11 = ONE - (u * u - p(t, opts) - TWO) / (TWO * u * u); - t22 = ONE - (v * v - q(t, opts) - TWO) / (TWO * v * v); - t33 = ONE - (w * w - r(t, opts) - TWO) / (TWO * w * w); + t11 = ONE - (u * u - p(t, opts) - TWO) / (TWO * u * u); + t22 = ONE - (v * v - q(t, opts) - TWO) / (TWO * v * v); + t33 = ONE - (w * w - r(t, opts) - TWO) / (TWO * w * w); SM_ELEMENT_D(J, 0, 0) = opts->G * t11 - pdot(t, opts) / (TWO * u * u); SM_ELEMENT_D(J, 0, 1) = opts->e * t22; SM_ELEMENT_D(J, 0, 2) = opts->e * t33; @@ -1330,9 +1342,9 @@ static int Jm(sunrealtype t, N_Vector y, N_Vector fy, SUNMatrix J, // [0 0 0]*[1-(u^2-p(t)-2)/(2*u^2), 0, 0] + [0, 0, 0] // [e al be] [0, 1-(v^2-q(t)-2)/(2*v^2), 0] [0, -q'(t)/(2*v^2), 0] // [0 0 0] [0, 0, 1-(w^2-r(t)-2)/(2*w^2)] [0, 0, 0] - t11 = ONE - (u * u - p(t, opts) - TWO) / (TWO * u * u); - t22 = ONE - (v * v - q(t, opts) - TWO) / (TWO * v * v); - t33 = ONE - (w * w - r(t, opts) - TWO) / (TWO * w * w); + t11 = ONE - (u * u - p(t, opts) - TWO) / (TWO * u * u); + t22 = ONE - (v * v - q(t, opts) - TWO) / (TWO * v * v); + t33 = ONE - (w * w - r(t, opts) - TWO) / (TWO * w * w); SM_ELEMENT_D(J, 0, 0) = ZERO; SM_ELEMENT_D(J, 0, 1) = ZERO; SM_ELEMENT_D(J, 0, 2) = ZERO; @@ -1361,9 +1373,9 @@ static int Jmi(sunrealtype t, N_Vector y, N_Vector fy, SUNMatrix J, // [0 0 0]*[1-(u^2-p(t)-2)/(2*u^2), 0, 0] // [e al be] [0, 1-(v^2-q(t)-2)/(2*v^2), 0] // [0 0 0] [0, 0, 1-(w^2-r(t)-2)/(2*w^2)] - t11 = ONE - (u * u - p(t, opts) - TWO) / (TWO * u * u); - t22 = ONE - (v * v - q(t, opts) - TWO) / (TWO * v * v); - t33 = ONE - (w * w - r(t, opts) - TWO) / (TWO * w * w); + t11 = ONE - (u * u - p(t, opts) - TWO) / (TWO * u * u); + t22 = ONE - (v * v - q(t, opts) - TWO) / (TWO * v * v); + t33 = ONE - (w * w - r(t, opts) - TWO) / (TWO * w * w); SM_ELEMENT_D(J, 0, 0) = ZERO; SM_ELEMENT_D(J, 0, 1) = ZERO; SM_ELEMENT_D(J, 0, 2) = ZERO; @@ -1378,7 +1390,6 @@ static int Jmi(sunrealtype t, N_Vector y, N_Vector fy, SUNMatrix J, return 0; } - // Jacobian of fs static int Js(sunrealtype t, N_Vector y, N_Vector fy, SUNMatrix J, void* user_data, N_Vector tmp1, N_Vector tmp2, N_Vector tmp3) @@ -1393,9 +1404,9 @@ static int Js(sunrealtype t, N_Vector y, N_Vector fy, SUNMatrix J, // [G e e]*[1-(u^2-p(t)-2)/(2*u^2), 0, 0] + [-p'(t)/(2*u^2), 0, 0] // [0 0 0] [0, 1-(v^2-q(t)-2)/(2*v^2), 0] [0, 0, 0] // [0 0 0] [0, 0, 1-(w^2-r(t)-2)/(2*w^2)] [0, 0, 0] - t11 = ONE - (u * u - p(t, opts) - TWO) / (TWO * u * u); - t22 = ONE - (v * v - q(t, opts) - TWO) / (TWO * v * v); - t33 = ONE - (w * w - r(t, opts) - TWO) / (TWO * w * w); + t11 = ONE - (u * u - p(t, opts) - TWO) / (TWO * u * u); + t22 = ONE - (v * v - q(t, opts) - TWO) / (TWO * v * v); + t33 = ONE - (w * w - r(t, opts) - TWO) / (TWO * w * w); SM_ELEMENT_D(J, 0, 0) = opts->G * t11 - pdot(t, opts) / (TWO * u * u); SM_ELEMENT_D(J, 0, 1) = opts->e * t22; SM_ELEMENT_D(J, 0, 2) = opts->e * t33; @@ -1424,9 +1435,9 @@ static int Jsi(sunrealtype t, N_Vector y, N_Vector fy, SUNMatrix J, // [G e e]*[1-(u^2-p(t)-2)/(2*u^2), 0, 0] // [0 0 0] [0, 1-(v^2-q(t)-2)/(2*v^2), 0] // [0 0 0] [0, 0, 1-(w^2-r(t)-2)/(2*w^2)] - t11 = ONE - (u * u - p(t, opts) - TWO) / (TWO * u * u); - t22 = ONE - (v * v - q(t, opts) - TWO) / (TWO * v * v); - t33 = ONE - (w * w - r(t, opts) - TWO) / (TWO * w * w); + t11 = ONE - (u * u - p(t, opts) - TWO) / (TWO * u * u); + t22 = ONE - (v * v - q(t, opts) - TWO) / (TWO * v * v); + t33 = ONE - (w * w - r(t, opts) - TWO) / (TWO * w * w); SM_ELEMENT_D(J, 0, 0) = opts->G * t11; SM_ELEMENT_D(J, 0, 1) = opts->e * t22; SM_ELEMENT_D(J, 0, 2) = opts->e * t33; @@ -1445,7 +1456,7 @@ static int Jsi(sunrealtype t, N_Vector y, N_Vector fy, SUNMatrix J, // Private helper functions // ----------------------------- -static sunrealtype p(sunrealtype t, Options* opts) { return HALF*cos(t); } +static sunrealtype p(sunrealtype t, Options* opts) { return HALF * cos(t); } static sunrealtype q(sunrealtype t, Options* opts) { @@ -1457,7 +1468,7 @@ static sunrealtype r(sunrealtype t, Options* opts) return (cos(opts->om * opts->om * t * (ONE + exp(-(t - THREE) * (t - THREE))))); } -static sunrealtype pdot(sunrealtype t, Options* opts) { return -HALF*sin(t); } +static sunrealtype pdot(sunrealtype t, Options* opts) { return -HALF * sin(t); } static sunrealtype qdot(sunrealtype t, Options* opts) { @@ -1469,8 +1480,8 @@ static sunrealtype qdot(sunrealtype t, Options* opts) static sunrealtype rdot(sunrealtype t, Options* opts) { - const sunrealtype tThree = t - THREE; - const sunrealtype eterm = exp(-tThree * tThree); + const sunrealtype tThree = t - THREE; + const sunrealtype eterm = exp(-tThree * tThree); return (-sin(opts->om * opts->om * t * (ONE + eterm)) * opts->om * opts->om * (ONE + eterm * (ONE - TWO * t * tThree))); } @@ -1523,17 +1534,22 @@ void InputHelp() std::cout << " --fast_rtol : relative solution tolerance for fast method\n"; std::cout << " --safety : slow time step safety factor\n"; - std::cout << " --mri_method : slow MRI method name (valid ARKODE_MRITableID)\n"; - std::cout << " --mid_method : intemediate MRI method name (valid ARKODE_MRITableID)\n"; + std::cout + << " --mri_method : slow MRI method name (valid ARKODE_MRITableID)\n"; + std::cout << " --mid_method : intemediate MRI method name (valid " + "ARKODE_MRITableID)\n"; std::cout << " --fast_order : fast RK method order\n"; - std::cout << " --scontrol : slow/intermeidate time step controllers, int in [0,12] " + std::cout << " --scontrol : slow/intermeidate time step controllers, " + "int in [0,12] " "(see source)\n"; std::cout << " --fcontrol : fast time step controller, int in [0,6] " "(see source)\n"; std::cout << " --faccum : fast error accumulation type {-1,0,1}\n"; - std::cout << " --slow_pq : use p (0) vs q (1) for slow/intermediate adaptivity\n"; + std::cout << " --slow_pq : use p (0) vs q (1) for slow/intermediate " + "adaptivity\n"; std::cout << " --fast_pq : use p (0) vs q (1) for fast adaptivity\n"; - std::cout << " --k1s, --k2s, -k3s : slow/intermediate controller parameters\n"; + std::cout + << " --k1s, --k2s, -k3s : slow/intermediate controller parameters\n"; std::cout << " --k1f, --k2f, -k3f : fast controller parameters\n"; std::cout << " --bias : slow and fast controller bias factors\n"; std::cout @@ -1677,7 +1693,8 @@ static void PrintSlowAdaptivity(Options opts) switch (opts.scontrol) { case (0): - std::cout << " fixed steps, hs = " << opts.hs << ", hm = " << opts.hm << std::endl; + std::cout << " fixed steps, hs = " << opts.hs << ", hm = " << opts.hm + << std::endl; std::cout << " rtol = " << opts.rtol << ", atol = " << opts.atol << "\n"; break; case (1): @@ -1688,7 +1705,8 @@ static void PrintSlowAdaptivity(Options opts) std::cout << " fast error accumulation strategy = " << opts.faccum << "\n"; if (opts.k1s > -1) { - std::cout << " slow/intermediate controller parameter: " << opts.k1s << "\n"; + std::cout << " slow/intermediate controller parameter: " << opts.k1s + << "\n"; } if (std::min(opts.htol_relch, std::min(opts.htol_minfac, opts.htol_maxfac)) > -1) @@ -1705,8 +1723,8 @@ static void PrintSlowAdaptivity(Options opts) std::cout << " fast error accumulation strategy = " << opts.faccum << "\n"; if (std::min(opts.k1s, opts.k2s) > -1) { - std::cout << " slow/intermediate controller parameters: " << opts.k1s << " " - << opts.k2s << "\n"; + std::cout << " slow/intermediate controller parameters: " << opts.k1s + << " " << opts.k2s << "\n"; } if (std::min(opts.htol_relch, std::min(opts.htol_minfac, opts.htol_maxfac)) > -1) @@ -1723,8 +1741,8 @@ static void PrintSlowAdaptivity(Options opts) std::cout << " fast error accumulation strategy = " << opts.faccum << "\n"; if (std::min(opts.k1s, std::min(opts.k2s, opts.k3s)) > -1) { - std::cout << " slow/intermediate controller parameters: " << opts.k1s << " " - << opts.k2s << " " << opts.k3s << "\n"; + std::cout << " slow/intermediate controller parameters: " << opts.k1s + << " " << opts.k2s << " " << opts.k3s << "\n"; } if (std::min(opts.htol_relch, std::min(opts.htol_minfac, opts.htol_maxfac)) > -1) @@ -1741,8 +1759,8 @@ static void PrintSlowAdaptivity(Options opts) std::cout << " fast error accumulation strategy = " << opts.faccum << "\n"; if (std::min(opts.k1s, opts.k2s) > -1) { - std::cout << " slow/intermediate controller parameters: " << opts.k1s << " " - << opts.k2s << "\n"; + std::cout << " slow/intermediate controller parameters: " << opts.k1s + << " " << opts.k2s << "\n"; } if (std::min(opts.htol_relch, std::min(opts.htol_minfac, opts.htol_maxfac)) > -1) @@ -1759,8 +1777,8 @@ static void PrintSlowAdaptivity(Options opts) std::cout << " fast error accumulation strategy = " << opts.faccum << "\n"; if (std::min(opts.k1s, opts.k2s) > -1) { - std::cout << " slow/intermediate controller parameters: " << opts.k1s << " " - << opts.k2s << "\n"; + std::cout << " slow/intermediate controller parameters: " << opts.k1s + << " " << opts.k2s << "\n"; } if (std::min(opts.htol_relch, std::min(opts.htol_minfac, opts.htol_maxfac)) > -1) @@ -1783,7 +1801,8 @@ static void PrintSlowAdaptivity(Options opts) std::cout << " rtol = " << opts.rtol << ", atol = " << opts.atol << "\n"; if (opts.k1s > -1) { - std::cout << " slow/intermediate controller parameter: " << opts.k1s << "\n"; + std::cout << " slow/intermediate controller parameter: " << opts.k1s + << "\n"; } break; case (8): @@ -1793,8 +1812,8 @@ static void PrintSlowAdaptivity(Options opts) std::cout << " rtol = " << opts.rtol << ", atol = " << opts.atol << "\n"; if (std::min(opts.k1s, opts.k2s) > -1) { - std::cout << " slow/intermediate controller parameters: " << opts.k1s << " " - << opts.k2s << "\n"; + std::cout << " slow/intermediate controller parameters: " << opts.k1s + << " " << opts.k2s << "\n"; } break; case (9): @@ -1804,8 +1823,8 @@ static void PrintSlowAdaptivity(Options opts) std::cout << " rtol = " << opts.rtol << ", atol = " << opts.atol << "\n"; if (std::min(opts.k1s, std::min(opts.k2s, opts.k3s)) > -1) { - std::cout << " slow/intermediate controller parameters: " << opts.k1s << " " - << opts.k2s << " " << opts.k3s << "\n"; + std::cout << " slow/intermediate controller parameters: " << opts.k1s + << " " << opts.k2s << " " << opts.k3s << "\n"; } break; case (10): @@ -1815,8 +1834,8 @@ static void PrintSlowAdaptivity(Options opts) std::cout << " rtol = " << opts.rtol << ", atol = " << opts.atol << "\n"; if (std::min(opts.k1s, opts.k2s) > -1) { - std::cout << " slow/intermediate controller parameters: " << opts.k1s << " " - << opts.k2s << "\n"; + std::cout << " slow/intermediate controller parameters: " << opts.k1s + << " " << opts.k2s << "\n"; } break; case (11): @@ -1826,8 +1845,8 @@ static void PrintSlowAdaptivity(Options opts) std::cout << " rtol = " << opts.rtol << ", atol = " << opts.atol << "\n"; if (std::min(opts.k1s, opts.k2s) > -1) { - std::cout << " slow/intermediate controller parameters: " << opts.k1s << " " - << opts.k2s << "\n"; + std::cout << " slow/intermediate controller parameters: " << opts.k1s + << " " << opts.k2s << "\n"; } break; case (12): diff --git a/src/arkode/arkode_mristep_impl.h b/src/arkode/arkode_mristep_impl.h index 393aa12cf6..b1149e619f 100644 --- a/src/arkode/arkode_mristep_impl.h +++ b/src/arkode/arkode_mristep_impl.h @@ -133,8 +133,8 @@ typedef struct ARKodeMRIStepMemRec MRIStepPostInnerFn post_inner_evolve; /* MRI adaptivity parameters */ - sunrealtype inner_control; /* prev control parameter */ - sunrealtype inner_dsm; /* prev inner stepper accumulated error */ + sunrealtype inner_control; /* prev control parameter */ + sunrealtype inner_dsm; /* prev inner stepper accumulated error */ sunrealtype inner_control_new; /* upcoming control parameter */ /* Counters */ diff --git a/src/sundials/sundials_adaptcontroller.c b/src/sundials/sundials_adaptcontroller.c index b44358289b..e841b08a60 100644 --- a/src/sundials/sundials_adaptcontroller.c +++ b/src/sundials/sundials_adaptcontroller.c @@ -46,17 +46,17 @@ SUNAdaptController SUNAdaptController_NewEmpty(SUNContext sunctx) SUNAssertNull(ops, SUN_ERR_MALLOC_FAIL); /* initialize operations to NULL */ - ops->gettype = NULL; - ops->destroy = NULL; - ops->reset = NULL; - ops->estimatestep = NULL; - ops->estimatesteptol = NULL; - ops->setdefaults = NULL; - ops->write = NULL; - ops->seterrorbias = NULL; - ops->updateh = NULL; - ops->updatemritol = NULL; - ops->space = NULL; + ops->gettype = NULL; + ops->destroy = NULL; + ops->reset = NULL; + ops->estimatestep = NULL; + ops->estimatesteptol = NULL; + ops->setdefaults = NULL; + ops->write = NULL; + ops->seterrorbias = NULL; + ops->updateh = NULL; + ops->updatemritol = NULL; + ops->space = NULL; /* attach ops and initialize content to NULL */ C->ops = ops; diff --git a/test/unit_tests/arkode/CXX_serial/ark_test_brusselator_mriadapt.cpp b/test/unit_tests/arkode/CXX_serial/ark_test_brusselator_mriadapt.cpp index 0b0c504f2b..a9963fed33 100644 --- a/test/unit_tests/arkode/CXX_serial/ark_test_brusselator_mriadapt.cpp +++ b/test/unit_tests/arkode/CXX_serial/ark_test_brusselator_mriadapt.cpp @@ -106,13 +106,13 @@ #include #include #include // serial N_Vector type, fcts., macros -#include #include #include +#include #include +#include #include // dense linear solver #include // dense matrix type, fcts., macros -#include #include // common utility functions #if defined(SUNDIALS_EXTENDED_PRECISION) @@ -191,8 +191,8 @@ static void PrintFastAdaptivity(Options opts); int main(int argc, char* argv[]) { // SUNDIALS context objects - sundials::Context sunctx; // main solver - sundials::Context refctx; // reference solver + sundials::Context sunctx; // main solver + sundials::Context refctx; // reference solver // Read input options Options opts; @@ -250,12 +250,12 @@ int main(int argc, char* argv[]) // If SUNLogger is enabled, manually disable it for the reference solver SUNLogger logger = NULL; - retval = SUNLogger_Create(SUN_COMM_NULL, 0, &logger); - retval = SUNContext_SetLogger(refctx, logger); - retval = SUNLogger_SetErrorFilename(logger, "/dev/null"); - retval = SUNLogger_SetWarningFilename(logger, "/dev/null"); - retval = SUNLogger_SetInfoFilename(logger, "/dev/null"); - retval = SUNLogger_SetDebugFilename(logger, "/dev/null"); + retval = SUNLogger_Create(SUN_COMM_NULL, 0, &logger); + retval = SUNContext_SetLogger(refctx, logger); + retval = SUNLogger_SetErrorFilename(logger, "/dev/null"); + retval = SUNLogger_SetWarningFilename(logger, "/dev/null"); + retval = SUNLogger_SetInfoFilename(logger, "/dev/null"); + retval = SUNLogger_SetDebugFilename(logger, "/dev/null"); // Create and initialize serial vectors for the solution and reference N_Vector y = N_VNew_Serial(NEQ, sunctx); diff --git a/test/unit_tests/arkode/CXX_serial/ark_test_kpr_mriadapt.cpp b/test/unit_tests/arkode/CXX_serial/ark_test_kpr_mriadapt.cpp index 088913ba0d..4e163cd9b1 100644 --- a/test/unit_tests/arkode/CXX_serial/ark_test_kpr_mriadapt.cpp +++ b/test/unit_tests/arkode/CXX_serial/ark_test_kpr_mriadapt.cpp @@ -104,13 +104,13 @@ #include #include #include // serial N_Vector type, fcts., macros -#include #include #include +#include #include +#include #include // dense linear solver #include // dense matrix type, fcts., macros -#include #include // common utility functions #if defined(SUNDIALS_EXTENDED_PRECISION) @@ -196,8 +196,8 @@ static int Ytrue(sunrealtype t, N_Vector y, Options* opts); int main(int argc, char* argv[]) { // SUNDIALS context objects - sundials::Context sunctx; // main solver - sundials::Context refctx; // reference solver + sundials::Context sunctx; // main solver + sundials::Context refctx; // reference solver // Read input options Options opts; @@ -258,12 +258,12 @@ int main(int argc, char* argv[]) // If SUNLogger is enabled, manually disable it for the reference solver SUNLogger logger = NULL; - retval = SUNLogger_Create(SUN_COMM_NULL, 0, &logger); - retval = SUNContext_SetLogger(refctx, logger); - retval = SUNLogger_SetErrorFilename(logger, "/dev/null"); - retval = SUNLogger_SetWarningFilename(logger, "/dev/null"); - retval = SUNLogger_SetInfoFilename(logger, "/dev/null"); - retval = SUNLogger_SetDebugFilename(logger, "/dev/null"); + retval = SUNLogger_Create(SUN_COMM_NULL, 0, &logger); + retval = SUNContext_SetLogger(refctx, logger); + retval = SUNLogger_SetErrorFilename(logger, "/dev/null"); + retval = SUNLogger_SetWarningFilename(logger, "/dev/null"); + retval = SUNLogger_SetInfoFilename(logger, "/dev/null"); + retval = SUNLogger_SetDebugFilename(logger, "/dev/null"); // Create and initialize serial vectors for the solution and reference N_Vector y = N_VNew_Serial(NEQ, sunctx); From 834ad2dd8b65857933cd034884911799aae4cff1 Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Thu, 5 Sep 2024 08:56:39 -0500 Subject: [PATCH 027/286] Ran spell checker --- doc/arkode/guide/source/Mathematics.rst | 2 +- doc/arkode/guide/source/Usage/MRIStep/User_callable.rst | 4 ++-- examples/arkode/CXX_serial/ark_kpr_nestedmri.cpp | 2 +- examples/arkode/C_serial/ark_kpr_mri.c | 4 ++-- test/test_driver.sh | 2 +- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/doc/arkode/guide/source/Mathematics.rst b/doc/arkode/guide/source/Mathematics.rst index 287114a381..75d1d53ed8 100644 --- a/doc/arkode/guide/source/Mathematics.rst +++ b/doc/arkode/guide/source/Mathematics.rst @@ -548,7 +548,7 @@ can be ignored). Optionally, a different algorithm leveraging compensated summation can be used that is more robust to roundoff error at the expense of 2 extra vector operations per stage and an additional 5 per time step. It also requires one extra vector to -be stored. However, it is signficantly more robust to roundoff error accumulation +be stored. However, it is significantly more robust to roundoff error accumulation :cite:p:`Sof:02`. When compensated summation is enabled, the following incremental form is used to compute a time step: diff --git a/doc/arkode/guide/source/Usage/MRIStep/User_callable.rst b/doc/arkode/guide/source/Usage/MRIStep/User_callable.rst index 0ca2251539..aa5c45c6e7 100644 --- a/doc/arkode/guide/source/Usage/MRIStep/User_callable.rst +++ b/doc/arkode/guide/source/Usage/MRIStep/User_callable.rst @@ -344,7 +344,7 @@ Rootfinding initialization function *nrtfn = 0*. Rootfinding is only supported for the slow (outer) integrator and should not - be actived for the fast (inner) integrator. + be activated for the fast (inner) integrator. .. deprecated:: 6.1.0 @@ -724,7 +724,7 @@ Optional inputs for MRIStep .. note:: - The stop time can be reenabled though a new call to + The stop time can be re-enabled though a new call to :c:func:`MRIStepSetStopTime`. .. versionadded:: 5.5.1 diff --git a/examples/arkode/CXX_serial/ark_kpr_nestedmri.cpp b/examples/arkode/CXX_serial/ark_kpr_nestedmri.cpp index 0214b3675a..eda932116b 100644 --- a/examples/arkode/CXX_serial/ark_kpr_nestedmri.cpp +++ b/examples/arkode/CXX_serial/ark_kpr_nestedmri.cpp @@ -1539,7 +1539,7 @@ void InputHelp() std::cout << " --mid_method : intemediate MRI method name (valid " "ARKODE_MRITableID)\n"; std::cout << " --fast_order : fast RK method order\n"; - std::cout << " --scontrol : slow/intermeidate time step controllers, " + std::cout << " --scontrol : slow/intermediate time step controllers, " "int in [0,12] " "(see source)\n"; std::cout << " --fcontrol : fast time step controller, int in [0,6] " diff --git a/examples/arkode/C_serial/ark_kpr_mri.c b/examples/arkode/C_serial/ark_kpr_mri.c index 3422f63a5b..0c69dd3da5 100644 --- a/examples/arkode/C_serial/ark_kpr_mri.c +++ b/examples/arkode/C_serial/ark_kpr_mri.c @@ -384,7 +384,7 @@ int main(int argc, char* argv[]) */ /* Initialize the fast integrator. Specify the fast right-hand side - function in y'=fs(t,y)+ff(t,y) = fse(t,y)+fsi(t,y)+ff(t,y), the inital time T0, + function in y'=fs(t,y)+ff(t,y) = fse(t,y)+fsi(t,y)+ff(t,y), the initial time T0, and the initial dependent variable vector y. If the fast scale is implicit, set up matrix, linear solver, and Jacobian function */ if (implicit_fast) @@ -524,7 +524,7 @@ int main(int argc, char* argv[]) */ /* Initialize the slow integrator. Specify the slow right-hand side - function in y'=fs(t,y)+ff(t,y) = fse(t,y)+fsi(t,y)+ff(t,y), the inital time + function in y'=fs(t,y)+ff(t,y) = fse(t,y)+fsi(t,y)+ff(t,y), the initial time T0, the initial dependent variable vector y, and the fast integrator. If the slow scale contains an implicit component, set up matrix, linear solver, and Jacobian function. */ diff --git a/test/test_driver.sh b/test/test_driver.sh index 3a1d25f4ec..4faee8b8ea 100755 --- a/test/test_driver.sh +++ b/test/test_driver.sh @@ -374,7 +374,7 @@ args_phase=() case "$testtype" in BRANCH) - # Don't creat tarballs + # Don't create tarballs tarball=NONE # Address sanitizer tests (TPLs OFF) From 4c8e887a51978776817bacd9ba61c09b06b9d7ec Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Thu, 5 Sep 2024 11:26:33 -0500 Subject: [PATCH 028/286] Removed some residual references to SUNADAPTCONTROLLER_MRI_H --- .../Usage/MRIStep/Custom_Inner_Stepper/Description.rst | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/doc/arkode/guide/source/Usage/MRIStep/Custom_Inner_Stepper/Description.rst b/doc/arkode/guide/source/Usage/MRIStep/Custom_Inner_Stepper/Description.rst index 96495dd8ae..579fe25bef 100644 --- a/doc/arkode/guide/source/Usage/MRIStep/Custom_Inner_Stepper/Description.rst +++ b/doc/arkode/guide/source/Usage/MRIStep/Custom_Inner_Stepper/Description.rst @@ -480,8 +480,7 @@ following member functions: **Notes:** This function is only called when multirate temporal adaptivity has been enabled, - using a :c:type:`SUNAdaptController` module having type ``SUNDIALS_CONTROL_MRI_H`` or - ``SUNDIALS_CONTROL_MRI_TOL``. + using a :c:type:`SUNAdaptController` module having type ``SUNDIALS_CONTROL_MRI_TOL``. If provided, the :c:type:`MRIStepInnerGetAccumulatedError` function will always be called *after* a preceding call to the :c:type:`MRIStepInnerResetAccumulatedError` @@ -506,8 +505,7 @@ following member functions: **Notes:** This function is only called when multirate temporal adaptivity has been enabled, - using a :c:type:`SUNAdaptController` module having type ``SUNDIALS_CONTROL_MRI_H`` or - ``SUNDIALS_CONTROL_MRI_TOL``. + using a :c:type:`SUNAdaptController` module having type ``SUNDIALS_CONTROL_MRI_TOL``. The :c:type:`MRIStepInnerResetAccumulatedError` function will always be called *before* any calls to the :c:type:`MRIStepInnerGetAccumulatedError` function. From e7d31e09f16f8e73c0df54794156a7bf717ce12e Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Thu, 5 Sep 2024 14:10:18 -0500 Subject: [PATCH 029/286] Fixed spelling --- .../Usage/MRIStep/Custom_Inner_Stepper/Description.rst | 2 +- examples/arkode/CXX_serial/ark_kpr_nestedmri.cpp | 2 +- src/arkode/arkode_mristep.c | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/doc/arkode/guide/source/Usage/MRIStep/Custom_Inner_Stepper/Description.rst b/doc/arkode/guide/source/Usage/MRIStep/Custom_Inner_Stepper/Description.rst index 579fe25bef..9dc117a91e 100644 --- a/doc/arkode/guide/source/Usage/MRIStep/Custom_Inner_Stepper/Description.rst +++ b/doc/arkode/guide/source/Usage/MRIStep/Custom_Inner_Stepper/Description.rst @@ -514,7 +514,7 @@ following member functions: :c:type:`MRIStepInnerResetAccumulatedError` functions should be provided, or not; if only one is provided then MRIStep will disable multirate temporal adaptivity and call neither. - This function peforms a different role within MRIStep than the + This function performs a different role within MRIStep than the :c:type:`MRIStepInnerResetFn`, and thus an implementation should make no assumptions about the frequency/ordering of calls to either. diff --git a/examples/arkode/CXX_serial/ark_kpr_nestedmri.cpp b/examples/arkode/CXX_serial/ark_kpr_nestedmri.cpp index eda932116b..3c69fed4a8 100644 --- a/examples/arkode/CXX_serial/ark_kpr_nestedmri.cpp +++ b/examples/arkode/CXX_serial/ark_kpr_nestedmri.cpp @@ -1536,7 +1536,7 @@ void InputHelp() std::cout << " --safety : slow time step safety factor\n"; std::cout << " --mri_method : slow MRI method name (valid ARKODE_MRITableID)\n"; - std::cout << " --mid_method : intemediate MRI method name (valid " + std::cout << " --mid_method : intermediate MRI method name (valid " "ARKODE_MRITableID)\n"; std::cout << " --fast_order : fast RK method order\n"; std::cout << " --scontrol : slow/intermediate time step controllers, " diff --git a/src/arkode/arkode_mristep.c b/src/arkode/arkode_mristep.c index 20b2d65f29..3b6b97cb22 100644 --- a/src/arkode/arkode_mristep.c +++ b/src/arkode/arkode_mristep.c @@ -1639,7 +1639,7 @@ int mriStep_FullRHS(ARKodeMem ark_mem, sunrealtype t, N_Vector y, N_Vector f, If timestep adaptivity is enabled, this routine also computes the error estimate y-ytilde, where ytilde is the embedded solution, and the norm weights come from ark_ewt. - This esimate is stored in ark_mem->tempv1, in case the calling + This estimate is stored in ark_mem->tempv1, in case the calling routine wishes to examine the error locations. The output variable dsmPtr should contain a scalar-valued @@ -2104,7 +2104,7 @@ int mriStep_TakeStepMRIGARK(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPt If timestep adaptivity is enabled, this routine also computes the error estimate y-ytilde, where ytilde is the embedded solution, and the norm weights come from ark_ewt. - This esimate is stored in ark_mem->tempv1, in case the calling + This estimate is stored in ark_mem->tempv1, in case the calling routine wishes to examine the error locations. The output variable dsmPtr should contain a scalar-valued @@ -2571,7 +2571,7 @@ int mriStep_TakeStepMRISR(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr) If timestep adaptivity is enabled, this routine also computes the error estimate y-ytilde, where ytilde is the embedded solution, and the norm weights come from ark_ewt. - This esimate is stored in ark_mem->tempv1, in case the calling + This estimate is stored in ark_mem->tempv1, in case the calling routine wishes to examine the error locations. The output variable dsmPtr should contain a scalar-valued From 009b971e3f6e02dc93b7288d08231c9211ad9d6a Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Thu, 5 Sep 2024 14:13:38 -0500 Subject: [PATCH 030/286] Fixed spelling --- .../arkode/CXX_serial/ark_test_slowerror_brusselator.cpp | 2 +- test/unit_tests/arkode/CXX_serial/ark_test_slowerror_kpr.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/test/unit_tests/arkode/CXX_serial/ark_test_slowerror_brusselator.cpp b/test/unit_tests/arkode/CXX_serial/ark_test_slowerror_brusselator.cpp index c412938fe6..659fb481eb 100644 --- a/test/unit_tests/arkode/CXX_serial/ark_test_slowerror_brusselator.cpp +++ b/test/unit_tests/arkode/CXX_serial/ark_test_slowerror_brusselator.cpp @@ -55,7 +55,7 @@ * hmax=(t_f-t_0)/20/Npart. * * We place the entire ODE in the "slow" RHS partition. For IMEX - * methods, thw third row is treated implicitly, and the first two + * methods, the third row is treated implicitly, and the first two * are treated explicitly. For the fast time scale, all tests use * ARKODE's default fifth-order ERK method, with relative and * absolute tolerances set to 1e-10 and 1e-12, respectively. diff --git a/test/unit_tests/arkode/CXX_serial/ark_test_slowerror_kpr.cpp b/test/unit_tests/arkode/CXX_serial/ark_test_slowerror_kpr.cpp index c31f6e5e80..164bb6ac4f 100644 --- a/test/unit_tests/arkode/CXX_serial/ark_test_slowerror_kpr.cpp +++ b/test/unit_tests/arkode/CXX_serial/ark_test_slowerror_kpr.cpp @@ -40,7 +40,7 @@ * hmax=(t_f-t_0)/20/Npart. * * We place the entire ODE in the "slow" RHS partition. For IMEX - * methods, thw first row is treated implicitly, and the second is + * methods, the first row is treated implicitly, and the second is * treated explicitly. For the fast time scale, all tests use * ARKODE's default fifth-order ERK method, with relative and * absolute tolerances set to 1e-10 and 1e-12, respectively. From 4d1f79da99d54b6a20ea8f5e4a6693ab7fe587b4 Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Thu, 5 Sep 2024 14:15:37 -0500 Subject: [PATCH 031/286] Added SUNDIALS_MAYBE_UNUSED --- src/sunadaptcontroller/mrihtol/sunadaptcontroller_mrihtol.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/sunadaptcontroller/mrihtol/sunadaptcontroller_mrihtol.c b/src/sunadaptcontroller/mrihtol/sunadaptcontroller_mrihtol.c index 64f975b76f..42460fa914 100644 --- a/src/sunadaptcontroller/mrihtol/sunadaptcontroller_mrihtol.c +++ b/src/sunadaptcontroller/mrihtol/sunadaptcontroller_mrihtol.c @@ -139,7 +139,8 @@ SUNAdaptController SUNAdaptController_GetFastController_MRIHTol(SUNAdaptControll * implementation of controller operations * ----------------------------------------------------------------- */ -SUNAdaptController_Type SUNAdaptController_GetType_MRIHTol(SUNAdaptController C) +SUNAdaptController_Type SUNAdaptController_GetType_MRIHTol( + SUNDIALS_MAYBE_UNUSED SUNAdaptController C) { return SUN_ADAPTCONTROLLER_MRI_TOL; } From 6d9d2b669f71c5d1534ccd3fdff78784241382fa Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Thu, 5 Sep 2024 14:20:23 -0500 Subject: [PATCH 032/286] Patched formatting --- .../mrihtol/fmod_int32/CMakeLists.txt | 13 +++++-------- .../mrihtol/fmod_int64/CMakeLists.txt | 13 +++++-------- test/unit_tests/arkode/CXX_serial/CMakeLists.txt | 4 ++-- 3 files changed, 12 insertions(+), 18 deletions(-) diff --git a/src/sunadaptcontroller/mrihtol/fmod_int32/CMakeLists.txt b/src/sunadaptcontroller/mrihtol/fmod_int32/CMakeLists.txt index 7f89cd14a6..8215ad7921 100644 --- a/src/sunadaptcontroller/mrihtol/fmod_int32/CMakeLists.txt +++ b/src/sunadaptcontroller/mrihtol/fmod_int32/CMakeLists.txt @@ -12,15 +12,12 @@ # SUNDIALS Copyright End # --------------------------------------------------------------- -sundials_add_f2003_library(sundials_fsunadaptcontrollermrihtol_mod - SOURCES - fsunadaptcontroller_mrihtol_mod.f90 fsunadaptcontroller_mrihtol_mod.c - LINK_LIBRARIES - PUBLIC sundials_fcore_mod +sundials_add_f2003_library( + sundials_fsunadaptcontrollermrihtol_mod + SOURCES fsunadaptcontroller_mrihtol_mod.f90 fsunadaptcontroller_mrihtol_mod.c + LINK_LIBRARIES PUBLIC sundials_fcore_mod OBJECT_LIBRARIES - OUTPUT_NAME - sundials_fsunadaptcontrollermrihtol_mod - OBJECT_LIB_ONLY + OUTPUT_NAME sundials_fsunadaptcontrollermrihtol_mod OBJECT_LIB_ONLY ) message(STATUS "Added SUNAdaptController_MRIHTol F2003 interface") diff --git a/src/sunadaptcontroller/mrihtol/fmod_int64/CMakeLists.txt b/src/sunadaptcontroller/mrihtol/fmod_int64/CMakeLists.txt index 7f89cd14a6..8215ad7921 100644 --- a/src/sunadaptcontroller/mrihtol/fmod_int64/CMakeLists.txt +++ b/src/sunadaptcontroller/mrihtol/fmod_int64/CMakeLists.txt @@ -12,15 +12,12 @@ # SUNDIALS Copyright End # --------------------------------------------------------------- -sundials_add_f2003_library(sundials_fsunadaptcontrollermrihtol_mod - SOURCES - fsunadaptcontroller_mrihtol_mod.f90 fsunadaptcontroller_mrihtol_mod.c - LINK_LIBRARIES - PUBLIC sundials_fcore_mod +sundials_add_f2003_library( + sundials_fsunadaptcontrollermrihtol_mod + SOURCES fsunadaptcontroller_mrihtol_mod.f90 fsunadaptcontroller_mrihtol_mod.c + LINK_LIBRARIES PUBLIC sundials_fcore_mod OBJECT_LIBRARIES - OUTPUT_NAME - sundials_fsunadaptcontrollermrihtol_mod - OBJECT_LIB_ONLY + OUTPUT_NAME sundials_fsunadaptcontrollermrihtol_mod OBJECT_LIB_ONLY ) message(STATUS "Added SUNAdaptController_MRIHTol F2003 interface") diff --git a/test/unit_tests/arkode/CXX_serial/CMakeLists.txt b/test/unit_tests/arkode/CXX_serial/CMakeLists.txt index 19b602a188..7dc10c3685 100644 --- a/test/unit_tests/arkode/CXX_serial/CMakeLists.txt +++ b/test/unit_tests/arkode/CXX_serial/CMakeLists.txt @@ -78,8 +78,8 @@ foreach(test_tuple ${unit_tests}) target_include_directories( ${test_target} PRIVATE $ - ${PROJECT_SOURCE_DIR}/test/unit_tests/utilities - ${CMAKE_SOURCE_DIR}/include ${CMAKE_SOURCE_DIR}/src) + ${PROJECT_SOURCE_DIR}/test/unit_tests/utilities + ${CMAKE_SOURCE_DIR}/include ${CMAKE_SOURCE_DIR}/src) # We explicitly choose which object libraries to link to and link in the # arkode objects so that we have access to private functions w/o changing From 1da0c02437bf5cf043019529939104465f917b33 Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Thu, 5 Sep 2024 14:23:14 -0500 Subject: [PATCH 033/286] Fixed SUNDIALS_MAYBE_UNUSED --- src/sunadaptcontroller/mrihtol/sunadaptcontroller_mrihtol.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/sunadaptcontroller/mrihtol/sunadaptcontroller_mrihtol.c b/src/sunadaptcontroller/mrihtol/sunadaptcontroller_mrihtol.c index 42460fa914..a1f0039b18 100644 --- a/src/sunadaptcontroller/mrihtol/sunadaptcontroller_mrihtol.c +++ b/src/sunadaptcontroller/mrihtol/sunadaptcontroller_mrihtol.c @@ -17,12 +17,14 @@ #include #include -#include -#include +#include #include "sundials/priv/sundials_errors_impl.h" +#include #include "sundials/sundials_errors.h" +#include "sundials_macros.h" + /* ------------------ * Default parameters * ------------------ */ From 22e1708ee01ed29d6d9bad77dfb66251078186c9 Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Thu, 5 Sep 2024 15:01:29 -0500 Subject: [PATCH 034/286] Added SUNDIALS_MAYBE_UNUSED --- src/arkode/arkode_erkstep.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/arkode/arkode_erkstep.c b/src/arkode/arkode_erkstep.c index c088472a4a..09cea4aeb0 100644 --- a/src/arkode/arkode_erkstep.c +++ b/src/arkode/arkode_erkstep.c @@ -1273,7 +1273,8 @@ int ERKStepCreateMRIStepInnerStepper(void* inner_arkode_mem, ODE IVP. ----------------------------------------------------------------------------*/ -int erkStep_MRIStepInnerEvolve(MRIStepInnerStepper stepper, sunrealtype t0, +int erkStep_MRIStepInnerEvolve(MRIStepInnerStepper stepper, + SUNDIALS_MAYBE_UNUSED sunrealtype t0, sunrealtype tout, N_Vector y) { void* arkode_mem; /* arkode memory */ From d976da180ed272415d4a75a1cfefa41c5c9a5b74 Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Thu, 5 Sep 2024 15:11:39 -0500 Subject: [PATCH 035/286] Formatting update --- src/sunadaptcontroller/mrihtol/fmod_int32/CMakeLists.txt | 3 +-- src/sunadaptcontroller/mrihtol/fmod_int64/CMakeLists.txt | 3 +-- src/sunadaptcontroller/mrihtol/sunadaptcontroller_mrihtol.c | 2 +- 3 files changed, 3 insertions(+), 5 deletions(-) diff --git a/src/sunadaptcontroller/mrihtol/fmod_int32/CMakeLists.txt b/src/sunadaptcontroller/mrihtol/fmod_int32/CMakeLists.txt index 8215ad7921..ecd215bc10 100644 --- a/src/sunadaptcontroller/mrihtol/fmod_int32/CMakeLists.txt +++ b/src/sunadaptcontroller/mrihtol/fmod_int32/CMakeLists.txt @@ -17,7 +17,6 @@ sundials_add_f2003_library( SOURCES fsunadaptcontroller_mrihtol_mod.f90 fsunadaptcontroller_mrihtol_mod.c LINK_LIBRARIES PUBLIC sundials_fcore_mod OBJECT_LIBRARIES - OUTPUT_NAME sundials_fsunadaptcontrollermrihtol_mod OBJECT_LIB_ONLY -) + OUTPUT_NAME sundials_fsunadaptcontrollermrihtol_mod OBJECT_LIB_ONLY) message(STATUS "Added SUNAdaptController_MRIHTol F2003 interface") diff --git a/src/sunadaptcontroller/mrihtol/fmod_int64/CMakeLists.txt b/src/sunadaptcontroller/mrihtol/fmod_int64/CMakeLists.txt index 8215ad7921..ecd215bc10 100644 --- a/src/sunadaptcontroller/mrihtol/fmod_int64/CMakeLists.txt +++ b/src/sunadaptcontroller/mrihtol/fmod_int64/CMakeLists.txt @@ -17,7 +17,6 @@ sundials_add_f2003_library( SOURCES fsunadaptcontroller_mrihtol_mod.f90 fsunadaptcontroller_mrihtol_mod.c LINK_LIBRARIES PUBLIC sundials_fcore_mod OBJECT_LIBRARIES - OUTPUT_NAME sundials_fsunadaptcontrollermrihtol_mod OBJECT_LIB_ONLY -) + OUTPUT_NAME sundials_fsunadaptcontrollermrihtol_mod OBJECT_LIB_ONLY) message(STATUS "Added SUNAdaptController_MRIHTol F2003 interface") diff --git a/src/sunadaptcontroller/mrihtol/sunadaptcontroller_mrihtol.c b/src/sunadaptcontroller/mrihtol/sunadaptcontroller_mrihtol.c index a1f0039b18..7b2fba0c17 100644 --- a/src/sunadaptcontroller/mrihtol/sunadaptcontroller_mrihtol.c +++ b/src/sunadaptcontroller/mrihtol/sunadaptcontroller_mrihtol.c @@ -19,8 +19,8 @@ #include #include -#include "sundials/priv/sundials_errors_impl.h" #include +#include "sundials/priv/sundials_errors_impl.h" #include "sundials/sundials_errors.h" #include "sundials_macros.h" From 800becf2cb8c9a21c78c5735b3bd1e34fb1296b5 Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Thu, 5 Sep 2024 15:36:45 -0500 Subject: [PATCH 036/286] Included --- test/unit_tests/utilities/test_utilities.hpp | 1 + 1 file changed, 1 insertion(+) diff --git a/test/unit_tests/utilities/test_utilities.hpp b/test/unit_tests/utilities/test_utilities.hpp index e624fefda2..cc603b046c 100644 --- a/test/unit_tests/utilities/test_utilities.hpp +++ b/test/unit_tests/utilities/test_utilities.hpp @@ -17,6 +17,7 @@ #include #include #include +#include // Check function return flag int check_flag(const int flag, const std::string funcname) From 958107f903b7f2c6cfd47ddce0061d4c559ff4f2 Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Thu, 5 Sep 2024 15:37:01 -0500 Subject: [PATCH 037/286] Fixed more unused variable warnings/errors --- src/arkode/arkode_mristep.c | 32 ++++++++++++-------------- src/arkode/arkode_mristep_controller.c | 3 +-- src/arkode/arkode_mristep_impl.h | 5 ++-- 3 files changed, 18 insertions(+), 22 deletions(-) diff --git a/src/arkode/arkode_mristep.c b/src/arkode/arkode_mristep.c index 3b6b97cb22..e6ebd8193d 100644 --- a/src/arkode/arkode_mristep.c +++ b/src/arkode/arkode_mristep.c @@ -1278,9 +1278,8 @@ int mriStep_Init(ARKodeMem ark_mem, int init_type) "error calling slow RHS function(s)"); return (ARK_RHSFUNC_FAIL); } - retval = mriStep_Hin(ark_mem, ark_mem->tcur, ark_mem->tout, ark_mem->yn, - ark_mem->tempv1, ark_mem->ycur, ark_mem->tempv2, - ark_mem->tempv3, mriStep_SlowRHS, &(ark_mem->hin)); + retval = mriStep_Hin(ark_mem, ark_mem->tcur, ark_mem->tout, + ark_mem->tempv1, &(ark_mem->hin)); if (retval != ARK_SUCCESS) { retval = arkHandleFailure(ark_mem, retval); @@ -1850,7 +1849,7 @@ int mriStep_TakeStepMRIGARK(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPt *nflagPtr = CONV_FAIL; break; } - retval = mriStep_StageERKFast(ark_mem, step_mem, is, t0, tf, ark_mem->ycur, + retval = mriStep_StageERKFast(ark_mem, step_mem, t0, tf, ark_mem->ycur, ark_mem->tempv2, SUNTRUE, need_inner_dsm); if (retval != ARK_SUCCESS) { *nflagPtr = CONV_FAIL; } break; @@ -2044,9 +2043,8 @@ int mriStep_TakeStepMRIGARK(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPt *nflagPtr = CONV_FAIL; break; } - retval = mriStep_StageERKFast(ark_mem, step_mem, step_mem->stages, t0, tf, - ark_mem->ycur, ark_mem->tempv2, SUNTRUE, - SUNFALSE); + retval = mriStep_StageERKFast(ark_mem, step_mem, t0, tf, ark_mem->ycur, + ark_mem->tempv2, SUNTRUE, SUNFALSE); if (retval != ARK_SUCCESS) { *nflagPtr = CONV_FAIL; } break; case (MRISTAGE_ERK_NOFAST): @@ -2332,7 +2330,7 @@ int mriStep_TakeStepMRISR(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr) /* Evolve fast IVP for this stage: force reset due to "stage-restart" structure potentially get inner dsm on all non-embedding stages */ - retval = mriStep_StageERKFast(ark_mem, step_mem, stage, ark_mem->tn, + retval = mriStep_StageERKFast(ark_mem, step_mem, ark_mem->tn, ark_mem->tn + cstage * ark_mem->h, ark_mem->ycur, ytemp, SUNTRUE, need_inner_dsm && !embedding); @@ -2774,7 +2772,7 @@ int mriStep_TakeStepMERK(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr) /* Evolve fast IVP for this stage: force reset on first stage in group potentially get inner dsm on all non-embedding stages */ - retval = mriStep_StageERKFast(ark_mem, step_mem, stage, t0, tf, + retval = mriStep_StageERKFast(ark_mem, step_mem, t0, tf, ark_mem->ycur, ytemp, is == 0, need_inner_dsm && !embedding); if (retval != ARK_SUCCESS) { *nflagPtr = CONV_FAIL; } @@ -3300,14 +3298,14 @@ int mriStep_CheckCoupling(ARKodeMem ark_mem) get_inner_dsm indicates whether this stage is one that should accumulate an inner temporal error estimate. ---------------------------------------------------------------*/ -int mriStep_StageERKFast(ARKodeMem ark_mem, ARKodeMRIStepMem step_mem, int is, +int mriStep_StageERKFast(ARKodeMem ark_mem, ARKodeMRIStepMem step_mem, sunrealtype t0, sunrealtype tf, N_Vector ycur, - N_Vector ytemp, sunbooleantype force_reset, + SUNDIALS_MAYBE_UNUSED N_Vector ytemp, + sunbooleantype force_reset, sunbooleantype get_inner_dsm) { int retval; /* reusable return flag */ SUNAdaptController_Type adapt_type; /* timestep adaptivity type */ - sunrealtype inner_error_factor; #ifdef SUNDIALS_DEBUG printf(" MRIStep ERK fast stage\n"); @@ -3957,7 +3955,7 @@ int mriStep_StageSetup(ARKodeMem ark_mem) ARK_FULLRHS_OTHER. ---------------------------------------------------------------*/ int mriStep_SlowRHS(ARKodeMem ark_mem, sunrealtype t, N_Vector y, N_Vector f, - int mode) + SUNDIALS_MAYBE_UNUSED int mode) { ARKodeMRIStepMem step_mem; int nvec, retval; @@ -4036,7 +4034,7 @@ int mriStep_SlowRHS(ARKodeMem ark_mem, sunrealtype t, N_Vector y, N_Vector f, adaptivity is enabled. ---------------------------------------------------------------*/ int mriStep_FastRHS(ARKodeMem ark_mem, sunrealtype t, N_Vector y, N_Vector f, - int mode) + SUNDIALS_MAYBE_UNUSED int mode) { ARKodeMRIStepMem step_mem; int retval; @@ -4069,8 +4067,7 @@ int mriStep_FastRHS(ARKodeMem ark_mem, sunrealtype t, N_Vector y, N_Vector f, initial condition. ---------------------------------------------------------------*/ int mriStep_Hin(ARKodeMem ark_mem, sunrealtype tcur, sunrealtype tout, - N_Vector ycur, N_Vector fcur, N_Vector ytmp, N_Vector temp1, - N_Vector temp2, ARKTimestepFullRHSFn rhs, sunrealtype* h) + N_Vector fcur, sunrealtype* h) { int sign; sunrealtype tdiff, tdist, tround, fnorm, h0_inv; @@ -4694,7 +4691,8 @@ int MRIStepCreateMRIStepInnerStepper(void* inner_arkode_mem, ODE IVP. ----------------------------------------------------------------------------*/ -int mriStep_MRIStepInnerEvolve(MRIStepInnerStepper stepper, sunrealtype t0, +int mriStep_MRIStepInnerEvolve(MRIStepInnerStepper stepper, + SUNDIALS_MAYBE_UNUSED sunrealtype t0, sunrealtype tout, N_Vector y) { void* arkode_mem; /* arkode memory */ diff --git a/src/arkode/arkode_mristep_controller.c b/src/arkode/arkode_mristep_controller.c index a1aaf4c88d..5deac961dd 100644 --- a/src/arkode/arkode_mristep_controller.c +++ b/src/arkode/arkode_mristep_controller.c @@ -99,8 +99,7 @@ int SUNAdaptController_EstimateStep_MRIStep(SUNAdaptController C, sunrealtype H, /* Estimate slow stepsize from MRI controller */ retval = SUNAdaptController_EstimateStepTol(MRICONTROL_C(C), H, step_mem->inner_control, - step_mem->p, DSM, - step_mem->inner_dsm, Hnew, + P, DSM, step_mem->inner_dsm, Hnew, &(step_mem->inner_control_new)); return retval; } diff --git a/src/arkode/arkode_mristep_impl.h b/src/arkode/arkode_mristep_impl.h index b1149e619f..ff193212df 100644 --- a/src/arkode/arkode_mristep_impl.h +++ b/src/arkode/arkode_mristep_impl.h @@ -268,7 +268,7 @@ int mriStep_AccessStepMem(ARKodeMem ark_mem, const char* fname, sunbooleantype mriStep_CheckNVector(N_Vector tmpl); int mriStep_SetCoupling(ARKodeMem ark_mem); int mriStep_CheckCoupling(ARKodeMem ark_mem); -int mriStep_StageERKFast(ARKodeMem ark_mem, ARKodeMRIStepMem step_mem, int is, +int mriStep_StageERKFast(ARKodeMem ark_mem, ARKodeMRIStepMem step_mem, sunrealtype t0, sunrealtype tf, N_Vector ycur, N_Vector ytemp, sunbooleantype force_reset, sunbooleantype get_inner_dsm); @@ -286,8 +286,7 @@ int mriStep_SlowRHS(ARKodeMem ark_mem, sunrealtype t, N_Vector y, N_Vector f, int mriStep_FastRHS(ARKodeMem ark_mem, sunrealtype t, N_Vector y, N_Vector f, int mode); int mriStep_Hin(ARKodeMem ark_mem, sunrealtype tcur, sunrealtype tout, - N_Vector ycur, N_Vector fcur, N_Vector ytmp, N_Vector temp1, - N_Vector temp2, ARKTimestepFullRHSFn rhs, sunrealtype* h); + N_Vector fcur, sunrealtype* h); void mriStep_ApplyForcing(ARKodeMRIStepMem step_mem, sunrealtype t, sunrealtype s, int* nvec); From ebdec7cda9757da0a9a113baa0022d99496aa264 Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Thu, 5 Sep 2024 15:56:16 -0500 Subject: [PATCH 038/286] Fixed conversion error/warning --- src/arkode/arkode_io.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/arkode/arkode_io.c b/src/arkode/arkode_io.c index 0daa2992fc..3931e4ad84 100644 --- a/src/arkode/arkode_io.c +++ b/src/arkode/arkode_io.c @@ -2476,7 +2476,7 @@ int ARKodeGetAccumulatedError(void* arkode_mem, sunrealtype* accum_error) } else if (ark_mem->AccumErrorType == 1) { - *accum_error = ark_mem->AccumError * ark_mem->reltol / steps; + *accum_error = ark_mem->AccumError * ark_mem->reltol / ((sunrealtype) steps); } else { From 7e19b47169f0c4cf001f9b0a820a99269b223bb8 Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Thu, 5 Sep 2024 16:01:51 -0500 Subject: [PATCH 039/286] Formatting updates --- src/arkode/arkode_mristep.c | 8 +++----- src/arkode/arkode_mristep_controller.c | 4 ++-- test/unit_tests/utilities/test_utilities.hpp | 2 +- 3 files changed, 6 insertions(+), 8 deletions(-) diff --git a/src/arkode/arkode_mristep.c b/src/arkode/arkode_mristep.c index e6ebd8193d..3e2b6ed9c9 100644 --- a/src/arkode/arkode_mristep.c +++ b/src/arkode/arkode_mristep.c @@ -2772,9 +2772,8 @@ int mriStep_TakeStepMERK(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr) /* Evolve fast IVP for this stage: force reset on first stage in group potentially get inner dsm on all non-embedding stages */ - retval = mriStep_StageERKFast(ark_mem, step_mem, t0, tf, - ark_mem->ycur, ytemp, is == 0, - need_inner_dsm && !embedding); + retval = mriStep_StageERKFast(ark_mem, step_mem, t0, tf, ark_mem->ycur, + ytemp, is == 0, need_inner_dsm && !embedding); if (retval != ARK_SUCCESS) { *nflagPtr = CONV_FAIL; } /* Update "initial time" for next stage in group */ @@ -3301,8 +3300,7 @@ int mriStep_CheckCoupling(ARKodeMem ark_mem) int mriStep_StageERKFast(ARKodeMem ark_mem, ARKodeMRIStepMem step_mem, sunrealtype t0, sunrealtype tf, N_Vector ycur, SUNDIALS_MAYBE_UNUSED N_Vector ytemp, - sunbooleantype force_reset, - sunbooleantype get_inner_dsm) + sunbooleantype force_reset, sunbooleantype get_inner_dsm) { int retval; /* reusable return flag */ SUNAdaptController_Type adapt_type; /* timestep adaptivity type */ diff --git a/src/arkode/arkode_mristep_controller.c b/src/arkode/arkode_mristep_controller.c index 5deac961dd..c701033e06 100644 --- a/src/arkode/arkode_mristep_controller.c +++ b/src/arkode/arkode_mristep_controller.c @@ -98,8 +98,8 @@ int SUNAdaptController_EstimateStep_MRIStep(SUNAdaptController C, sunrealtype H, /* Estimate slow stepsize from MRI controller */ retval = SUNAdaptController_EstimateStepTol(MRICONTROL_C(C), H, - step_mem->inner_control, - P, DSM, step_mem->inner_dsm, Hnew, + step_mem->inner_control, P, DSM, + step_mem->inner_dsm, Hnew, &(step_mem->inner_control_new)); return retval; } diff --git a/test/unit_tests/utilities/test_utilities.hpp b/test/unit_tests/utilities/test_utilities.hpp index cc603b046c..abc34f60bb 100644 --- a/test/unit_tests/utilities/test_utilities.hpp +++ b/test/unit_tests/utilities/test_utilities.hpp @@ -16,8 +16,8 @@ #include #include -#include #include +#include // Check function return flag int check_flag(const int flag, const std::string funcname) From 1bdd79ea0ffbe751e9d303df1f273d0c22bcddcc Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Fri, 6 Sep 2024 08:27:37 -0500 Subject: [PATCH 040/286] Propagated Steven's changes in default ERK methods from ARKStep to ERKStep --- include/arkode/arkode_erkstep.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/include/arkode/arkode_erkstep.h b/include/arkode/arkode_erkstep.h index 8257b2f6f2..1436ebbe89 100644 --- a/include/arkode/arkode_erkstep.h +++ b/include/arkode/arkode_erkstep.h @@ -33,13 +33,13 @@ extern "C" { /* Default Butcher tables for each order */ static const int ERKSTEP_DEFAULT_1 = ARKODE_FORWARD_EULER_1_1; -static const int ERKSTEP_DEFAULT_2 = ARKODE_HEUN_EULER_2_1_2; +static const int ERKSTEP_DEFAULT_2 = ARKODE_RALSTON_3_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_5 = ARKODE_CASH_KARP_6_4_5; -static const int ERKSTEP_DEFAULT_6 = ARKODE_VERNER_8_5_6; +static const int ERKSTEP_DEFAULT_4 = ARKODE_SOFRONIOU_SPALETTA_5_3_4; +static const int ERKSTEP_DEFAULT_5 = ARKODE_TSITOURAS_7_4_5; +static const int ERKSTEP_DEFAULT_6 = ARKODE_VERNER_9_5_6; static const int ERKSTEP_DEFAULT_7 = ARKODE_VERNER_10_6_7; -static const int ERKSTEP_DEFAULT_8 = ARKODE_FEHLBERG_13_7_8; +static const int ERKSTEP_DEFAULT_8 = ARKODE_VERNER_13_7_8; static const int ERKSTEP_DEFAULT_9 = ARKODE_VERNER_16_8_9; /* ------------------- From 6f59400cff744f83dd91a2a0efeaebdfe275ce93 Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Fri, 6 Sep 2024 09:15:24 -0500 Subject: [PATCH 041/286] Removed changesets from PR #547 --- include/arkode/arkode_arkstep.h | 27 ++++--- include/arkode/arkode_butcher_erk.h | 4 +- include/arkode/arkode_erkstep.h | 10 +-- src/arkode/arkode_butcher_erk.def | 77 ------------------- src/arkode/fmod_int32/farkode_arkstep_mod.f90 | 26 +++---- src/arkode/fmod_int32/farkode_mod.f90 | 7 +- src/arkode/fmod_int64/farkode_arkstep_mod.f90 | 26 +++---- src/arkode/fmod_int64/farkode_mod.f90 | 7 +- 8 files changed, 49 insertions(+), 135 deletions(-) diff --git a/include/arkode/arkode_arkstep.h b/include/arkode/arkode_arkstep.h index d13181f840..01c1e9bf17 100644 --- a/include/arkode/arkode_arkstep.h +++ b/include/arkode/arkode_arkstep.h @@ -36,32 +36,31 @@ extern "C" { /* explicit */ static const int ARKSTEP_DEFAULT_ERK_1 = ARKODE_FORWARD_EULER_1_1; -//TODO(SBR): Check if this is better than ARKODE_HEUN_EULER_2_1_2 -static const int ARKSTEP_DEFAULT_ERK_2 = ARKODE_RALSTON_3_1_2; +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_SOFRONIOU_SPALETTA_5_3_4; -static const int ARKSTEP_DEFAULT_ERK_5 = ARKODE_TSITOURAS_7_4_5; -static const int ARKSTEP_DEFAULT_ERK_6 = ARKODE_VERNER_9_5_6; +static const int ARKSTEP_DEFAULT_ERK_4 = ARKODE_ZONNEVELD_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_7 = ARKODE_VERNER_10_6_7; -static const int ARKSTEP_DEFAULT_ERK_8 = ARKODE_VERNER_13_7_8; +static const int ARKSTEP_DEFAULT_ERK_8 = ARKODE_FEHLBERG_13_7_8; static const int ARKSTEP_DEFAULT_ERK_9 = ARKODE_VERNER_16_8_9; /* implicit */ static const int ARKSTEP_DEFAULT_DIRK_1 = ARKODE_BACKWARD_EULER_1_1; -static const int ARKSTEP_DEFAULT_DIRK_2 = ARKODE_ARK2_DIRK_3_1_2; -static const int ARKSTEP_DEFAULT_DIRK_3 = ARKODE_ESDIRK325L2SA_5_2_3; -static const int ARKSTEP_DEFAULT_DIRK_4 = ARKODE_ESDIRK436L2SA_6_3_4; -static const int ARKSTEP_DEFAULT_DIRK_5 = ARKODE_ESDIRK547L2SA2_7_4_5; +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_5 = ARKODE_ARK548L2SA_DIRK_8_4_5; /* ImEx */ static const int ARKSTEP_DEFAULT_ARK_ETABLE_2 = ARKODE_ARK2_ERK_3_1_2; static const int ARKSTEP_DEFAULT_ARK_ETABLE_3 = ARKODE_ARK324L2SA_ERK_4_2_3; -static const int ARKSTEP_DEFAULT_ARK_ETABLE_4 = ARKODE_ARK437L2SA_ERK_7_3_4; -static const int ARKSTEP_DEFAULT_ARK_ETABLE_5 = ARKODE_ARK548L2SAb_ERK_8_4_5; +static const int ARKSTEP_DEFAULT_ARK_ETABLE_4 = ARKODE_ARK436L2SA_ERK_6_3_4; +static const int ARKSTEP_DEFAULT_ARK_ETABLE_5 = ARKODE_ARK548L2SA_ERK_8_4_5; static const int ARKSTEP_DEFAULT_ARK_ITABLE_2 = ARKODE_ARK2_DIRK_3_1_2; static const int ARKSTEP_DEFAULT_ARK_ITABLE_3 = ARKODE_ARK324L2SA_DIRK_4_2_3; -static const int ARKSTEP_DEFAULT_ARK_ITABLE_4 = ARKODE_ARK437L2SA_DIRK_7_3_4; -static const int ARKSTEP_DEFAULT_ARK_ITABLE_5 = ARKODE_ARK548L2SAb_DIRK_8_4_5; +static const int ARKSTEP_DEFAULT_ARK_ITABLE_4 = ARKODE_ARK436L2SA_DIRK_6_3_4; +static const int ARKSTEP_DEFAULT_ARK_ITABLE_5 = ARKODE_ARK548L2SA_DIRK_8_4_5; /* ------------------- * Exported Functions diff --git a/include/arkode/arkode_butcher_erk.h b/include/arkode/arkode_butcher_erk.h index 9e079c6a5a..c6c0373510 100644 --- a/include/arkode/arkode_butcher_erk.h +++ b/include/arkode/arkode_butcher_erk.h @@ -52,9 +52,7 @@ typedef enum ARKODE_FORWARD_EULER_1_1, ARKODE_RALSTON_EULER_2_1_2, ARKODE_EXPLICIT_MIDPOINT_EULER_2_1_2, - ARKODE_RALSTON_3_1_2, - ARKODE_TSITOURAS_7_4_5, - ARKODE_MAX_ERK_NUM = ARKODE_TSITOURAS_7_4_5 + ARKODE_MAX_ERK_NUM = ARKODE_EXPLICIT_MIDPOINT_EULER_2_1_2 } ARKODE_ERKTableID; /* Accessor routine to load built-in ERK table */ diff --git a/include/arkode/arkode_erkstep.h b/include/arkode/arkode_erkstep.h index 1436ebbe89..8257b2f6f2 100644 --- a/include/arkode/arkode_erkstep.h +++ b/include/arkode/arkode_erkstep.h @@ -33,13 +33,13 @@ extern "C" { /* Default Butcher tables for each order */ static const int ERKSTEP_DEFAULT_1 = ARKODE_FORWARD_EULER_1_1; -static const int ERKSTEP_DEFAULT_2 = ARKODE_RALSTON_3_1_2; +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_SOFRONIOU_SPALETTA_5_3_4; -static const int ERKSTEP_DEFAULT_5 = ARKODE_TSITOURAS_7_4_5; -static const int ERKSTEP_DEFAULT_6 = ARKODE_VERNER_9_5_6; +static const int ERKSTEP_DEFAULT_4 = ARKODE_ZONNEVELD_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_7 = ARKODE_VERNER_10_6_7; -static const int ERKSTEP_DEFAULT_8 = ARKODE_VERNER_13_7_8; +static const int ERKSTEP_DEFAULT_8 = ARKODE_FEHLBERG_13_7_8; static const int ERKSTEP_DEFAULT_9 = ARKODE_VERNER_16_8_9; /* ------------------- diff --git a/src/arkode/arkode_butcher_erk.def b/src/arkode/arkode_butcher_erk.def index b7daadd20a..4da35f9d07 100644 --- a/src/arkode/arkode_butcher_erk.def +++ b/src/arkode/arkode_butcher_erk.def @@ -39,7 +39,6 @@ imeth QP --------------------------------------- ARKODE_FORWARD_EULER_1_1 Y - ARKODE_RALSTON_3_1_2 Y ARKODE_HEUN_EULER_2_1_2 Y ARKODE_RALSTON_EULER_2_1_2 Y ARKODE_EXPLICIT_MIDPOINT_EULER_2_1_2 Y @@ -51,7 +50,6 @@ ARKODE_ARK436L2SA_ERK_6_3_4* N ARKODE_ARK437L2SA_ERK_7_3_4* N ARKODE_SAYFY_ABURUB_6_3_4 N - ARKODE_TSITOURAS_7_4_5 Y ARKODE_CASH_KARP_6_4_5 Y ARKODE_FEHLBERG_6_4_5 Y ARKODE_DORMAND_PRINCE_7_4_5 Y @@ -82,29 +80,6 @@ ARK_BUTCHER_TABLE(ARKODE_FORWARD_EULER_1_1, { /* Euler-ERK */ return B; }) -ARK_BUTCHER_TABLE(ARKODE_RALSTON_3_1_2, { /* Ralston-ERK */ - ARKodeButcherTable B = ARKodeButcherTable_Alloc(3, SUNTRUE); - B->q = 2; - B->p = 1; - - B->A[1][0] = SUN_RCONST(2.0)/SUN_RCONST(3.0); - B->A[2][0] = SUN_RCONST(1.0)/SUN_RCONST(4.0); - B->A[2][1] = SUN_RCONST(3.0)/SUN_RCONST(4.0); - - B->b[0] = SUN_RCONST(1.0)/SUN_RCONST(4.0); - B->b[1] = SUN_RCONST(3.0)/SUN_RCONST(4.0); - B->b[2] = SUN_RCONST(0.0); - - B->d[0] = SUN_RCONST(5.0)/SUN_RCONST(37.0); - B->d[1] = SUN_RCONST(2.0)/SUN_RCONST(3.0); - B->d[2] = SUN_RCONST(22.0)/SUN_RCONST(111.0); - - B->c[1] = SUN_RCONST(2.0)/SUN_RCONST(3.0); - B->c[2] = SUN_RCONST(1.0); - - return B; - }) - ARK_BUTCHER_TABLE(ARKODE_HEUN_EULER_2_1_2, { /* Heun-Euler-ERK */ ARKodeButcherTable B = ARKodeButcherTable_Alloc(2, SUNTRUE); B->q = 2; @@ -449,58 +424,6 @@ ARK_BUTCHER_TABLE(ARKODE_SAYFY_ABURUB_6_3_4, { /* Sayfy-Aburub-4-3-ERK */ return B; }) -ARK_BUTCHER_TABLE(ARKODE_TSITOURAS_7_4_5, { /* Tsitouras-ERK */ - ARKodeButcherTable B = ARKodeButcherTable_Alloc(7, SUNTRUE); - B->q = 5; - B->p = 4; - B->A[1][0] = SUN_RCONST(0.161); - B->A[2][0] = SUN_RCONST(-0.008480655492356988544426874250230774675121); - B->A[2][1] = SUN_RCONST(0.3354806554923569885444268742502307746751); - B->A[3][0] = SUN_RCONST(2.897153057105493432130432594192938764925); - B->A[3][1] = SUN_RCONST(-6.359448489975074843148159912383825625953); - B->A[3][2] = SUN_RCONST(4.362295432869581411017727318190886861028); - B->A[4][0] = SUN_RCONST(5.325864828439256604428877920840511317836); - B->A[4][1] = SUN_RCONST(-11.74888356406282787774717033978577296189); - B->A[4][2] = SUN_RCONST(7.495539342889836208304604784564358155659); - B->A[4][3] = SUN_RCONST(-0.0924950663617552492565020793320719161135); - B->A[5][0] = SUN_RCONST(5.861455442946420028659251486982647890394); - B->A[5][1] = SUN_RCONST(-12.92096931784710929170611868178335939542); - B->A[5][2] = SUN_RCONST(8.159367898576158643180400794539253485182); - B->A[5][3] = SUN_RCONST(-0.07158497328140099722453054252582973869127); - B->A[5][4] = SUN_RCONST(-0.02826905039406838290900305721271224146718); - B->A[6][0] = SUN_RCONST(0.09646076681806522951816731316512876333712); - B->A[6][1] = SUN_RCONST(0.01); - B->A[6][2] = SUN_RCONST(0.479889650414499574775249532290596519913); - B->A[6][3] = SUN_RCONST(1.379008574103741893192274821856872770756); - B->A[6][4] = SUN_RCONST(-3.290069515436080679901047585711363850116); - B->A[6][5] = SUN_RCONST(2.324710524099773982415355918398765796109); - - B->b[0] = SUN_RCONST(0.09646076681806522951816731316512876333712); - B->b[1] = SUN_RCONST(0.01); - B->b[2] = SUN_RCONST(0.479889650414499574775249532290596519913); - B->b[3] = SUN_RCONST(1.379008574103741893192274821856872770756); - B->b[4] = SUN_RCONST(-3.290069515436080679901047585711363850116); - B->b[5] = SUN_RCONST(2.324710524099773982415355918398765796109); - B->b[6] = SUN_RCONST(0.0); - - B->d[0] = SUN_RCONST(0.09352374858189270663659270466268853095681); - B->d[1] = SUN_RCONST(0.008652883141566367609681000495464767703693); - B->d[2] = SUN_RCONST(0.4928930991314318681922688329502649219068); - B->d[3] = SUN_RCONST(1.140235412267858095755952327702024828167); - B->d[4] = SUN_RCONST(-2.329180192439364558618150528135494254063); - B->d[5] = SUN_RCONST(1.568875049316615520423655662325051205328); - B->d[6] = SUN_RCONST(0.025); - - B->c[0] = SUN_RCONST(0.0); - B->c[1] = SUN_RCONST(0.161); - B->c[2] = SUN_RCONST(0.327); - B->c[3] = SUN_RCONST(0.9); - B->c[4] = SUN_RCONST(0.9800255409045096857298102862870245954942); - B->c[5] = SUN_RCONST(1.0); - B->c[6] = SUN_RCONST(1.0); - return B; - }) - ARK_BUTCHER_TABLE(ARKODE_CASH_KARP_6_4_5, { /* Cash-Karp-ERK */ ARKodeButcherTable B = ARKodeButcherTable_Alloc(6, SUNTRUE); B->q = 5; diff --git a/src/arkode/fmod_int32/farkode_arkstep_mod.f90 b/src/arkode/fmod_int32/farkode_arkstep_mod.f90 index 3708886004..cc0373f1eb 100644 --- a/src/arkode/fmod_int32/farkode_arkstep_mod.f90 +++ b/src/arkode/fmod_int32/farkode_arkstep_mod.f90 @@ -27,27 +27,27 @@ module farkode_arkstep_mod ! DECLARATION CONSTRUCTS integer(C_INT), parameter, public :: ARKSTEP_DEFAULT_ERK_1 = ARKODE_FORWARD_EULER_1_1 - integer(C_INT), parameter, public :: ARKSTEP_DEFAULT_ERK_2 = ARKODE_RALSTON_3_1_2 + integer(C_INT), parameter, public :: ARKSTEP_DEFAULT_ERK_2 = ARKODE_HEUN_EULER_2_1_2 integer(C_INT), parameter, public :: ARKSTEP_DEFAULT_ERK_3 = ARKODE_BOGACKI_SHAMPINE_4_2_3 - integer(C_INT), parameter, public :: ARKSTEP_DEFAULT_ERK_4 = ARKODE_SOFRONIOU_SPALETTA_5_3_4 - integer(C_INT), parameter, public :: ARKSTEP_DEFAULT_ERK_5 = ARKODE_TSITOURAS_7_4_5 - integer(C_INT), parameter, public :: ARKSTEP_DEFAULT_ERK_6 = ARKODE_VERNER_9_5_6 + integer(C_INT), parameter, public :: ARKSTEP_DEFAULT_ERK_4 = ARKODE_ZONNEVELD_5_3_4 + integer(C_INT), parameter, public :: ARKSTEP_DEFAULT_ERK_5 = ARKODE_CASH_KARP_6_4_5 + integer(C_INT), parameter, public :: ARKSTEP_DEFAULT_ERK_6 = ARKODE_VERNER_8_5_6 integer(C_INT), parameter, public :: ARKSTEP_DEFAULT_ERK_7 = ARKODE_VERNER_10_6_7 - integer(C_INT), parameter, public :: ARKSTEP_DEFAULT_ERK_8 = ARKODE_VERNER_13_7_8 + integer(C_INT), parameter, public :: ARKSTEP_DEFAULT_ERK_8 = ARKODE_FEHLBERG_13_7_8 integer(C_INT), parameter, public :: ARKSTEP_DEFAULT_ERK_9 = ARKODE_VERNER_16_8_9 integer(C_INT), parameter, public :: ARKSTEP_DEFAULT_DIRK_1 = ARKODE_BACKWARD_EULER_1_1 - integer(C_INT), parameter, public :: ARKSTEP_DEFAULT_DIRK_2 = ARKODE_ARK2_DIRK_3_1_2 - integer(C_INT), parameter, public :: ARKSTEP_DEFAULT_DIRK_3 = ARKODE_ESDIRK325L2SA_5_2_3 - integer(C_INT), parameter, public :: ARKSTEP_DEFAULT_DIRK_4 = ARKODE_ESDIRK436L2SA_6_3_4 - integer(C_INT), parameter, public :: ARKSTEP_DEFAULT_DIRK_5 = ARKODE_ESDIRK547L2SA2_7_4_5 + integer(C_INT), parameter, public :: ARKSTEP_DEFAULT_DIRK_2 = ARKODE_SDIRK_2_1_2 + integer(C_INT), parameter, public :: ARKSTEP_DEFAULT_DIRK_3 = ARKODE_ARK324L2SA_DIRK_4_2_3 + integer(C_INT), parameter, public :: ARKSTEP_DEFAULT_DIRK_4 = ARKODE_SDIRK_5_3_4 + integer(C_INT), parameter, public :: ARKSTEP_DEFAULT_DIRK_5 = ARKODE_ARK548L2SA_DIRK_8_4_5 integer(C_INT), parameter, public :: ARKSTEP_DEFAULT_ARK_ETABLE_2 = ARKODE_ARK2_ERK_3_1_2 integer(C_INT), parameter, public :: ARKSTEP_DEFAULT_ARK_ETABLE_3 = ARKODE_ARK324L2SA_ERK_4_2_3 - integer(C_INT), parameter, public :: ARKSTEP_DEFAULT_ARK_ETABLE_4 = ARKODE_ARK437L2SA_ERK_7_3_4 - integer(C_INT), parameter, public :: ARKSTEP_DEFAULT_ARK_ETABLE_5 = ARKODE_ARK548L2SAb_ERK_8_4_5 + integer(C_INT), parameter, public :: ARKSTEP_DEFAULT_ARK_ETABLE_4 = ARKODE_ARK436L2SA_ERK_6_3_4 + integer(C_INT), parameter, public :: ARKSTEP_DEFAULT_ARK_ETABLE_5 = ARKODE_ARK548L2SA_ERK_8_4_5 integer(C_INT), parameter, public :: ARKSTEP_DEFAULT_ARK_ITABLE_2 = ARKODE_ARK2_DIRK_3_1_2 integer(C_INT), parameter, public :: ARKSTEP_DEFAULT_ARK_ITABLE_3 = ARKODE_ARK324L2SA_DIRK_4_2_3 - integer(C_INT), parameter, public :: ARKSTEP_DEFAULT_ARK_ITABLE_4 = ARKODE_ARK437L2SA_DIRK_7_3_4 - integer(C_INT), parameter, public :: ARKSTEP_DEFAULT_ARK_ITABLE_5 = ARKODE_ARK548L2SAb_DIRK_8_4_5 + integer(C_INT), parameter, public :: ARKSTEP_DEFAULT_ARK_ITABLE_4 = ARKODE_ARK436L2SA_DIRK_6_3_4 + integer(C_INT), parameter, public :: ARKSTEP_DEFAULT_ARK_ITABLE_5 = ARKODE_ARK548L2SA_DIRK_8_4_5 public :: FARKStepCreate public :: FARKStepReInit public :: FARKStepSetExplicit diff --git a/src/arkode/fmod_int32/farkode_mod.f90 b/src/arkode/fmod_int32/farkode_mod.f90 index 37c99df220..8fa06ea70e 100644 --- a/src/arkode/fmod_int32/farkode_mod.f90 +++ b/src/arkode/fmod_int32/farkode_mod.f90 @@ -365,9 +365,7 @@ module farkode_mod enumerator :: ARKODE_FORWARD_EULER_1_1 enumerator :: ARKODE_RALSTON_EULER_2_1_2 enumerator :: ARKODE_EXPLICIT_MIDPOINT_EULER_2_1_2 - enumerator :: ARKODE_RALSTON_3_1_2 - enumerator :: ARKODE_TSITOURAS_7_4_5 - enumerator :: ARKODE_MAX_ERK_NUM = ARKODE_TSITOURAS_7_4_5 + enumerator :: ARKODE_MAX_ERK_NUM = ARKODE_EXPLICIT_MIDPOINT_EULER_2_1_2 end enum integer, parameter, public :: ARKODE_ERKTableID = kind(ARKODE_ERK_NONE) public :: ARKODE_ERK_NONE, ARKODE_MIN_ERK_NUM, ARKODE_HEUN_EULER_2_1_2, ARKODE_BOGACKI_SHAMPINE_4_2_3, & @@ -376,8 +374,7 @@ module farkode_mod ARKODE_VERNER_8_5_6, ARKODE_FEHLBERG_13_7_8, ARKODE_KNOTH_WOLKE_3_3, ARKODE_ARK437L2SA_ERK_7_3_4, & ARKODE_ARK548L2SAb_ERK_8_4_5, ARKODE_ARK2_ERK_3_1_2, ARKODE_SOFRONIOU_SPALETTA_5_3_4, ARKODE_SHU_OSHER_3_2_3, & ARKODE_VERNER_9_5_6, ARKODE_VERNER_10_6_7, ARKODE_VERNER_13_7_8, ARKODE_VERNER_16_8_9, ARKODE_FORWARD_EULER_1_1, & - ARKODE_RALSTON_EULER_2_1_2, ARKODE_EXPLICIT_MIDPOINT_EULER_2_1_2, ARKODE_RALSTON_3_1_2, ARKODE_TSITOURAS_7_4_5, & - ARKODE_MAX_ERK_NUM + ARKODE_RALSTON_EULER_2_1_2, ARKODE_EXPLICIT_MIDPOINT_EULER_2_1_2, ARKODE_MAX_ERK_NUM public :: FARKodeButcherTable_LoadERK public :: FARKodeButcherTable_LoadERKByName public :: FARKodeButcherTable_ERKIDToName diff --git a/src/arkode/fmod_int64/farkode_arkstep_mod.f90 b/src/arkode/fmod_int64/farkode_arkstep_mod.f90 index 3708886004..cc0373f1eb 100644 --- a/src/arkode/fmod_int64/farkode_arkstep_mod.f90 +++ b/src/arkode/fmod_int64/farkode_arkstep_mod.f90 @@ -27,27 +27,27 @@ module farkode_arkstep_mod ! DECLARATION CONSTRUCTS integer(C_INT), parameter, public :: ARKSTEP_DEFAULT_ERK_1 = ARKODE_FORWARD_EULER_1_1 - integer(C_INT), parameter, public :: ARKSTEP_DEFAULT_ERK_2 = ARKODE_RALSTON_3_1_2 + integer(C_INT), parameter, public :: ARKSTEP_DEFAULT_ERK_2 = ARKODE_HEUN_EULER_2_1_2 integer(C_INT), parameter, public :: ARKSTEP_DEFAULT_ERK_3 = ARKODE_BOGACKI_SHAMPINE_4_2_3 - integer(C_INT), parameter, public :: ARKSTEP_DEFAULT_ERK_4 = ARKODE_SOFRONIOU_SPALETTA_5_3_4 - integer(C_INT), parameter, public :: ARKSTEP_DEFAULT_ERK_5 = ARKODE_TSITOURAS_7_4_5 - integer(C_INT), parameter, public :: ARKSTEP_DEFAULT_ERK_6 = ARKODE_VERNER_9_5_6 + integer(C_INT), parameter, public :: ARKSTEP_DEFAULT_ERK_4 = ARKODE_ZONNEVELD_5_3_4 + integer(C_INT), parameter, public :: ARKSTEP_DEFAULT_ERK_5 = ARKODE_CASH_KARP_6_4_5 + integer(C_INT), parameter, public :: ARKSTEP_DEFAULT_ERK_6 = ARKODE_VERNER_8_5_6 integer(C_INT), parameter, public :: ARKSTEP_DEFAULT_ERK_7 = ARKODE_VERNER_10_6_7 - integer(C_INT), parameter, public :: ARKSTEP_DEFAULT_ERK_8 = ARKODE_VERNER_13_7_8 + integer(C_INT), parameter, public :: ARKSTEP_DEFAULT_ERK_8 = ARKODE_FEHLBERG_13_7_8 integer(C_INT), parameter, public :: ARKSTEP_DEFAULT_ERK_9 = ARKODE_VERNER_16_8_9 integer(C_INT), parameter, public :: ARKSTEP_DEFAULT_DIRK_1 = ARKODE_BACKWARD_EULER_1_1 - integer(C_INT), parameter, public :: ARKSTEP_DEFAULT_DIRK_2 = ARKODE_ARK2_DIRK_3_1_2 - integer(C_INT), parameter, public :: ARKSTEP_DEFAULT_DIRK_3 = ARKODE_ESDIRK325L2SA_5_2_3 - integer(C_INT), parameter, public :: ARKSTEP_DEFAULT_DIRK_4 = ARKODE_ESDIRK436L2SA_6_3_4 - integer(C_INT), parameter, public :: ARKSTEP_DEFAULT_DIRK_5 = ARKODE_ESDIRK547L2SA2_7_4_5 + integer(C_INT), parameter, public :: ARKSTEP_DEFAULT_DIRK_2 = ARKODE_SDIRK_2_1_2 + integer(C_INT), parameter, public :: ARKSTEP_DEFAULT_DIRK_3 = ARKODE_ARK324L2SA_DIRK_4_2_3 + integer(C_INT), parameter, public :: ARKSTEP_DEFAULT_DIRK_4 = ARKODE_SDIRK_5_3_4 + integer(C_INT), parameter, public :: ARKSTEP_DEFAULT_DIRK_5 = ARKODE_ARK548L2SA_DIRK_8_4_5 integer(C_INT), parameter, public :: ARKSTEP_DEFAULT_ARK_ETABLE_2 = ARKODE_ARK2_ERK_3_1_2 integer(C_INT), parameter, public :: ARKSTEP_DEFAULT_ARK_ETABLE_3 = ARKODE_ARK324L2SA_ERK_4_2_3 - integer(C_INT), parameter, public :: ARKSTEP_DEFAULT_ARK_ETABLE_4 = ARKODE_ARK437L2SA_ERK_7_3_4 - integer(C_INT), parameter, public :: ARKSTEP_DEFAULT_ARK_ETABLE_5 = ARKODE_ARK548L2SAb_ERK_8_4_5 + integer(C_INT), parameter, public :: ARKSTEP_DEFAULT_ARK_ETABLE_4 = ARKODE_ARK436L2SA_ERK_6_3_4 + integer(C_INT), parameter, public :: ARKSTEP_DEFAULT_ARK_ETABLE_5 = ARKODE_ARK548L2SA_ERK_8_4_5 integer(C_INT), parameter, public :: ARKSTEP_DEFAULT_ARK_ITABLE_2 = ARKODE_ARK2_DIRK_3_1_2 integer(C_INT), parameter, public :: ARKSTEP_DEFAULT_ARK_ITABLE_3 = ARKODE_ARK324L2SA_DIRK_4_2_3 - integer(C_INT), parameter, public :: ARKSTEP_DEFAULT_ARK_ITABLE_4 = ARKODE_ARK437L2SA_DIRK_7_3_4 - integer(C_INT), parameter, public :: ARKSTEP_DEFAULT_ARK_ITABLE_5 = ARKODE_ARK548L2SAb_DIRK_8_4_5 + integer(C_INT), parameter, public :: ARKSTEP_DEFAULT_ARK_ITABLE_4 = ARKODE_ARK436L2SA_DIRK_6_3_4 + integer(C_INT), parameter, public :: ARKSTEP_DEFAULT_ARK_ITABLE_5 = ARKODE_ARK548L2SA_DIRK_8_4_5 public :: FARKStepCreate public :: FARKStepReInit public :: FARKStepSetExplicit diff --git a/src/arkode/fmod_int64/farkode_mod.f90 b/src/arkode/fmod_int64/farkode_mod.f90 index 32aa57973e..2148977b2c 100644 --- a/src/arkode/fmod_int64/farkode_mod.f90 +++ b/src/arkode/fmod_int64/farkode_mod.f90 @@ -365,9 +365,7 @@ module farkode_mod enumerator :: ARKODE_FORWARD_EULER_1_1 enumerator :: ARKODE_RALSTON_EULER_2_1_2 enumerator :: ARKODE_EXPLICIT_MIDPOINT_EULER_2_1_2 - enumerator :: ARKODE_RALSTON_3_1_2 - enumerator :: ARKODE_TSITOURAS_7_4_5 - enumerator :: ARKODE_MAX_ERK_NUM = ARKODE_TSITOURAS_7_4_5 + enumerator :: ARKODE_MAX_ERK_NUM = ARKODE_EXPLICIT_MIDPOINT_EULER_2_1_2 end enum integer, parameter, public :: ARKODE_ERKTableID = kind(ARKODE_ERK_NONE) public :: ARKODE_ERK_NONE, ARKODE_MIN_ERK_NUM, ARKODE_HEUN_EULER_2_1_2, ARKODE_BOGACKI_SHAMPINE_4_2_3, & @@ -376,8 +374,7 @@ module farkode_mod ARKODE_VERNER_8_5_6, ARKODE_FEHLBERG_13_7_8, ARKODE_KNOTH_WOLKE_3_3, ARKODE_ARK437L2SA_ERK_7_3_4, & ARKODE_ARK548L2SAb_ERK_8_4_5, ARKODE_ARK2_ERK_3_1_2, ARKODE_SOFRONIOU_SPALETTA_5_3_4, ARKODE_SHU_OSHER_3_2_3, & ARKODE_VERNER_9_5_6, ARKODE_VERNER_10_6_7, ARKODE_VERNER_13_7_8, ARKODE_VERNER_16_8_9, ARKODE_FORWARD_EULER_1_1, & - ARKODE_RALSTON_EULER_2_1_2, ARKODE_EXPLICIT_MIDPOINT_EULER_2_1_2, ARKODE_RALSTON_3_1_2, ARKODE_TSITOURAS_7_4_5, & - ARKODE_MAX_ERK_NUM + ARKODE_RALSTON_EULER_2_1_2, ARKODE_EXPLICIT_MIDPOINT_EULER_2_1_2, ARKODE_MAX_ERK_NUM public :: FARKodeButcherTable_LoadERK public :: FARKodeButcherTable_LoadERKByName public :: FARKodeButcherTable_ERKIDToName From cd0d52d47421cd7adf254b17c432d89051cc2a6f Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Fri, 6 Sep 2024 09:21:47 -0500 Subject: [PATCH 042/286] Resolved some uninitialized and sign-compare warnings --- .../CXX_serial/ark_test_accumerror_brusselator.cpp | 10 +++++----- .../arkode/CXX_serial/ark_test_accumerror_kpr.cpp | 8 ++++---- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/test/unit_tests/arkode/CXX_serial/ark_test_accumerror_brusselator.cpp b/test/unit_tests/arkode/CXX_serial/ark_test_accumerror_brusselator.cpp index c1fd11cf25..26f97af15f 100644 --- a/test/unit_tests/arkode/CXX_serial/ark_test_accumerror_brusselator.cpp +++ b/test/unit_tests/arkode/CXX_serial/ark_test_accumerror_brusselator.cpp @@ -236,7 +236,7 @@ int main(int argc, char* argv[]) cout << " partition size = " << udata.Npart << endl; cout << " initial conditions: u0 = " << u0 << ", v0 = " << v0 << ", w0 = " << w0 << endl; - cout << " problem parameters: a = " << a << ", b = " << b + cout << " problem parameters: a = " << udata.a << ", b = " << udata.b << ", ep = " << udata.ep << endl; if (rk_type == 0) { cout << " DIRK solver, order = " << order << endl; } else if (rk_type == 1) @@ -412,10 +412,10 @@ static int adaptive_run(void* arkode_mem, N_Vector y, sunrealtype T0, // Loop over tolerances cout << "\nAdaptive-step runs:\n"; - for (int irtol = 0; irtol < rtols.size(); irtol++) + for (size_t irtol = 0; irtol < rtols.size(); irtol++) { // Loop over accumulation types - for (int iaccum = 0; iaccum < accum_types.size(); iaccum++) + for (size_t iaccum = 0; iaccum < accum_types.size(); iaccum++) { // Loop over partition for (int ipart = 0; ipart < udata.Npart; ipart++) @@ -499,10 +499,10 @@ static int fixed_run(void* arkode_mem, N_Vector y, sunrealtype T0, sunrealtype T // Loop over step sizes cout << "\nFixed-step runs:\n"; - for (int ih = 0; ih < hvals.size(); ih++) + for (size_t ih = 0; ih < hvals.size(); ih++) { // Loop over built-in accumulation types - for (int iaccum = 0; iaccum < accum_types.size(); iaccum++) + for (size_t iaccum = 0; iaccum < accum_types.size(); iaccum++) { // Loop over partition for (int ipart = 0; ipart < udata.Npart; ipart++) diff --git a/test/unit_tests/arkode/CXX_serial/ark_test_accumerror_kpr.cpp b/test/unit_tests/arkode/CXX_serial/ark_test_accumerror_kpr.cpp index fe7c9b4c0e..d402ef06c3 100644 --- a/test/unit_tests/arkode/CXX_serial/ark_test_accumerror_kpr.cpp +++ b/test/unit_tests/arkode/CXX_serial/ark_test_accumerror_kpr.cpp @@ -357,10 +357,10 @@ static int adaptive_run(void* arkode_mem, N_Vector y, sunrealtype T0, // Loop over tolerances cout << "\nAdaptive-step runs:\n"; - for (int irtol = 0; irtol < rtols.size(); irtol++) + for (size_t irtol = 0; irtol < rtols.size(); irtol++) { // Loop over accumulation types - for (int iaccum = 0; iaccum < accum_types.size(); iaccum++) + for (size_t iaccum = 0; iaccum < accum_types.size(); iaccum++) { // Loop over partition for (int ipart = 0; ipart < udata.Npart; ipart++) @@ -456,10 +456,10 @@ static int fixed_run(void* arkode_mem, N_Vector y, sunrealtype T0, // Loop over step sizes cout << "\nFixed-step runs:\n"; - for (int ih = 0; ih < hvals.size(); ih++) + for (size_t ih = 0; ih < hvals.size(); ih++) { // Loop over built-in accumulation types - for (int iaccum = 0; iaccum < accum_types.size(); iaccum++) + for (size_t iaccum = 0; iaccum < accum_types.size(); iaccum++) { // Loop over partition for (int ipart = 0; ipart < udata.Npart; ipart++) From 52a6a237507a8bb0c5f8e2bbd66a06b1bc4a6765 Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Fri, 6 Sep 2024 09:23:09 -0500 Subject: [PATCH 043/286] Resolved formatting 'error' --- src/arkode/arkode_io.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/arkode/arkode_io.c b/src/arkode/arkode_io.c index 3931e4ad84..8cea228240 100644 --- a/src/arkode/arkode_io.c +++ b/src/arkode/arkode_io.c @@ -2476,7 +2476,7 @@ int ARKodeGetAccumulatedError(void* arkode_mem, sunrealtype* accum_error) } else if (ark_mem->AccumErrorType == 1) { - *accum_error = ark_mem->AccumError * ark_mem->reltol / ((sunrealtype) steps); + *accum_error = ark_mem->AccumError * ark_mem->reltol / ((sunrealtype)steps); } else { From 1d16db98c4e45c1a4e13d78712d3c6a4730ae4cf Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Fri, 6 Sep 2024 09:51:01 -0500 Subject: [PATCH 044/286] Resolved unused-variable 'error' --- .../arkode/CXX_serial/ark_test_accumerror_brusselator.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/unit_tests/arkode/CXX_serial/ark_test_accumerror_brusselator.cpp b/test/unit_tests/arkode/CXX_serial/ark_test_accumerror_brusselator.cpp index 26f97af15f..46b1d88a32 100644 --- a/test/unit_tests/arkode/CXX_serial/ark_test_accumerror_brusselator.cpp +++ b/test/unit_tests/arkode/CXX_serial/ark_test_accumerror_brusselator.cpp @@ -144,7 +144,7 @@ int main(int argc, char* argv[]) int order = 4; // order of accuracy for RK method int test = 2; // test problem to run sunbooleantype adaptive = SUNTRUE; // adaptive run vs convergence order - sunrealtype a, b, u0, v0, w0; // parameters + sunrealtype u0, v0, w0; // parameters // general problem variables int retval; // reusable error-checking flag From a0216f84ac94bf04650f47adf2401164019c4030 Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Fri, 6 Sep 2024 10:56:45 -0500 Subject: [PATCH 045/286] Resolved conversion and sign comparision 'errors' --- .../ark_test_slowerror_brusselator.cpp | 29 ++++++++-------- .../CXX_serial/ark_test_slowerror_kpr.cpp | 29 ++++++++-------- .../ark_test_slowerror_polynomial.cpp | 34 +++++++++---------- 3 files changed, 47 insertions(+), 45 deletions(-) diff --git a/test/unit_tests/arkode/CXX_serial/ark_test_slowerror_brusselator.cpp b/test/unit_tests/arkode/CXX_serial/ark_test_slowerror_brusselator.cpp index 659fb481eb..93e05f19f6 100644 --- a/test/unit_tests/arkode/CXX_serial/ark_test_slowerror_brusselator.cpp +++ b/test/unit_tests/arkode/CXX_serial/ark_test_slowerror_brusselator.cpp @@ -133,7 +133,7 @@ static int computeErrorWeights(N_Vector ycur, N_Vector weight, sunrealtype rtol, static int check_retval(void* returnvalue, const char* funcname, int opt); static int run_test(void* mristep_mem, void* arkode_ref, N_Vector y, sunrealtype T0, sunrealtype Tf, N_Vector* yref, - vector Hvals, char* method, sunrealtype reltol, + vector Hvals, string method, sunrealtype reltol, sunrealtype abstol, UserData& udata); // Main Program @@ -143,7 +143,7 @@ int main(int argc, char* argv[]) sunrealtype T0 = SUN_RCONST(0.0); // initial time sunrealtype Tf = SUN_RCONST(10.0); // final time sunindextype NEQ = 3; // number of dependent vars. - char* method; // MRI method name + string method; // MRI method name int test = 2; // test problem to run sunrealtype a, b, u0, v0, w0; // parameters sunrealtype reltol = SUN_RCONST(1.e-10); // fast solver tolerances @@ -214,15 +214,15 @@ int main(int argc, char* argv[]) sunbooleantype implicit = SUNFALSE; sunbooleantype imex = SUNFALSE; - if ((strcmp(method, "ARKODE_MRI_GARK_IRK21a") == 0) || - (strcmp(method, "ARKODE_MRI_GARK_ESDIRK34a") == 0) || - (strcmp(method, "ARKODE_MRI_GARK_ESDIRK46a") == 0)) + if ((method == "ARKODE_MRI_GARK_IRK21a") || + (method == "ARKODE_MRI_GARK_ESDIRK34a") || + (method == "ARKODE_MRI_GARK_ESDIRK46a")) { implicit = SUNTRUE; } - if ((strcmp(method, "ARKODE_IMEX_MRI_SR21") == 0) || - (strcmp(method, "ARKODE_IMEX_MRI_SR32") == 0) || - (strcmp(method, "ARKODE_IMEX_MRI_SR43") == 0)) + if ((method == "ARKODE_IMEX_MRI_SR21") || + (method == "ARKODE_IMEX_MRI_SR32") || + (method == "ARKODE_IMEX_MRI_SR43")) { imex = SUNTRUE; implicit = SUNTRUE; @@ -307,7 +307,7 @@ int main(int argc, char* argv[]) } else { mristep_mem = MRIStepCreate(fn, NULL, T0, y, inner_stepper, ctx); } if (check_retval((void*)mristep_mem, "MRIStepCreate", 0)) return 1; - MRIStepCoupling C = MRIStepCoupling_LoadTableByName(method); + MRIStepCoupling C = MRIStepCoupling_LoadTableByName(method.c_str()); if (check_retval((void*)C, "MRIStepCoupling_LoadTableByName", 0)) return 1; retval = MRIStepSetCoupling(mristep_mem, C); if (check_retval(&retval, "MRIStepSetCoupling", 1)) return 1; @@ -340,8 +340,9 @@ int main(int argc, char* argv[]) // Run test for various H values sunrealtype hmax = (Tf - T0) / 20.0 / udata.Npart; - vector Hvals = {hmax, hmax / 4.0, hmax / 16.0, hmax / 64.0, - hmax / 256.0}; + vector Hvals(5); + for (size_t i = 0; i < Hvals.size(); i++) + { Hvals[i] = hmax / SUNRpowerI(SUN_RCONST(4.0), i); } retval = run_test(mristep_mem, arkode_ref, y, T0, Tf, yref, Hvals, method, reltol, abstol, udata); if (check_retval(&retval, "run_test", 1)) return 1; @@ -474,7 +475,7 @@ static int Ji(sunrealtype t, N_Vector y, N_Vector fy, SUNMatrix J, static int run_test(void* mristep_mem, void* arkode_ref, N_Vector y, sunrealtype T0, sunrealtype Tf, N_Vector* yref, - vector Hvals, char* method, sunrealtype reltol, + vector Hvals, string method, sunrealtype reltol, sunrealtype abstol, UserData& udata) { // Reused variables @@ -493,7 +494,7 @@ static int run_test(void* mristep_mem, void* arkode_ref, N_Vector y, vector(udata.Npart, ZERO)); // Loop over step sizes - for (int iH = 0; iH < Hvals.size(); iH++) + for (size_t iH = 0; iH < Hvals.size(); iH++) { // Loop over partition for (int ipart = 0; ipart < udata.Npart; ipart++) @@ -540,7 +541,7 @@ static int run_test(void* mristep_mem, void* arkode_ref, N_Vector y, } cout << endl << method << " summary:" << endl; - for (int iH = 0; iH < Hvals.size(); iH++) + for (size_t iH = 0; iH < Hvals.size(); iH++) { cout << " Stepsize " << Hvals[iH] << " \tmaxdsm " << *max_element(dsm[iH].begin(), dsm[iH].end()) << " \tmaxdsmest " diff --git a/test/unit_tests/arkode/CXX_serial/ark_test_slowerror_kpr.cpp b/test/unit_tests/arkode/CXX_serial/ark_test_slowerror_kpr.cpp index 164bb6ac4f..82b4818ef9 100644 --- a/test/unit_tests/arkode/CXX_serial/ark_test_slowerror_kpr.cpp +++ b/test/unit_tests/arkode/CXX_serial/ark_test_slowerror_kpr.cpp @@ -125,7 +125,7 @@ static int computeErrorWeights(N_Vector ycur, N_Vector weight, sunrealtype rtol, sunrealtype atol, N_Vector vtemp); static int check_retval(void* returnvalue, const char* funcname, int opt); static int run_test(void* mristep_mem, N_Vector y, sunrealtype T0, - sunrealtype Tf, vector Hvals, char* method, + sunrealtype Tf, vector Hvals, string method, sunrealtype reltol, sunrealtype abstol, UserData& udata); // Main Program @@ -135,7 +135,7 @@ int main(int argc, char* argv[]) sunrealtype T0 = SUN_RCONST(0.0); // initial time sunrealtype Tf = SUN_RCONST(5.0); // final time sunindextype NEQ = 2; // number of dependent vars. - char* method; // MRI method name + string method; // MRI method name sunrealtype reltol = SUN_RCONST(1.e-10); // fast solver tolerances sunrealtype abstol = SUN_RCONST(1.e-12); @@ -181,15 +181,15 @@ int main(int argc, char* argv[]) sunbooleantype implicit = SUNFALSE; sunbooleantype imex = SUNFALSE; - if ((strcmp(method, "ARKODE_MRI_GARK_IRK21a") == 0) || - (strcmp(method, "ARKODE_MRI_GARK_ESDIRK34a") == 0) || - (strcmp(method, "ARKODE_MRI_GARK_ESDIRK46a") == 0)) + if ((method == "ARKODE_MRI_GARK_IRK21a") || + (method == "ARKODE_MRI_GARK_ESDIRK34a") || + (method == "ARKODE_MRI_GARK_ESDIRK46a")) { implicit = SUNTRUE; } - if ((strcmp(method, "ARKODE_IMEX_MRI_SR21") == 0) || - (strcmp(method, "ARKODE_IMEX_MRI_SR32") == 0) || - (strcmp(method, "ARKODE_IMEX_MRI_SR43") == 0)) + if ((method == "ARKODE_IMEX_MRI_SR21") || + (method == "ARKODE_IMEX_MRI_SR32") || + (method == "ARKODE_IMEX_MRI_SR43")) { imex = SUNTRUE; implicit = SUNTRUE; @@ -244,7 +244,7 @@ int main(int argc, char* argv[]) } else { mristep_mem = MRIStepCreate(fn, NULL, T0, y, inner_stepper, ctx); } if (check_retval((void*)mristep_mem, "MRIStepCreate", 0)) return 1; - MRIStepCoupling C = MRIStepCoupling_LoadTableByName(method); + MRIStepCoupling C = MRIStepCoupling_LoadTableByName(method.c_str()); if (check_retval((void*)C, "MRIStepCoupling_LoadTableByName", 0)) return 1; retval = MRIStepSetCoupling(mristep_mem, C); if (check_retval(&retval, "MRIStepSetCoupling", 1)) return 1; @@ -277,8 +277,9 @@ int main(int argc, char* argv[]) // Run test for various H values sunrealtype hmax = (Tf - T0) / 20 / udata.Npart; - vector Hvals = {hmax, hmax / 4.0, hmax / 16.0, hmax / 64.0, - hmax / 256.0}; + vector Hvals(5); + for (size_t i = 0; i < Hvals.size(); i++) + { Hvals[i] = hmax / SUNRpowerI(SUN_RCONST(4.0), i); } retval = run_test(mristep_mem, y, T0, Tf, Hvals, method, reltol, abstol, udata); if (check_retval(&retval, "run_test", 1)) return 1; @@ -409,7 +410,7 @@ static int Ji(sunrealtype t, N_Vector y, N_Vector fy, SUNMatrix J, //------------------------------ static int run_test(void* mristep_mem, N_Vector y, sunrealtype T0, - sunrealtype Tf, vector Hvals, char* method, + sunrealtype Tf, vector Hvals, string method, sunrealtype reltol, sunrealtype abstol, UserData& udata) { // Reused variables @@ -427,7 +428,7 @@ static int run_test(void* mristep_mem, N_Vector y, sunrealtype T0, vector(udata.Npart, ZERO)); // Loop over step sizes - for (int iH = 0; iH < Hvals.size(); iH++) + for (size_t iH = 0; iH < Hvals.size(); iH++) { // Loop over partition for (int ipart = 0; ipart < udata.Npart; ipart++) @@ -465,7 +466,7 @@ static int run_test(void* mristep_mem, N_Vector y, sunrealtype T0, } cout << endl << method << " summary:" << endl; - for (int iH = 0; iH < Hvals.size(); iH++) + for (size_t iH = 0; iH < Hvals.size(); iH++) { cout << " Stepsize " << Hvals[iH] << " \tmaxdsm " << *max_element(dsm[iH].begin(), dsm[iH].end()) << " \tmaxdsmest " diff --git a/test/unit_tests/arkode/CXX_serial/ark_test_slowerror_polynomial.cpp b/test/unit_tests/arkode/CXX_serial/ark_test_slowerror_polynomial.cpp index e31739abdf..16b25bd9bc 100644 --- a/test/unit_tests/arkode/CXX_serial/ark_test_slowerror_polynomial.cpp +++ b/test/unit_tests/arkode/CXX_serial/ark_test_slowerror_polynomial.cpp @@ -91,7 +91,7 @@ static int computeErrorWeights(N_Vector ycur, N_Vector weight, sunrealtype rtol, sunrealtype atol, N_Vector vtemp); static int check_retval(void* returnvalue, const char* funcname, int opt); static int run_test(void* mristep_mem, N_Vector y, sunrealtype T0, - vector& Hvals, char* method, + vector& Hvals, string method, sunrealtype reltol, sunrealtype abstol, UserData& udata); // Main Program @@ -100,7 +100,7 @@ int main(int argc, char* argv[]) // general problem parameters sunrealtype T0 = ZERO; // initial time sunindextype NEQ = 1; // number of dependent vars. - char* method; // MRI method name + string method; // MRI method name sunrealtype reltol = SUN_RCONST(1.e-10); // fast solver tolerances sunrealtype abstol = SUN_RCONST(1.e-12); @@ -123,12 +123,12 @@ int main(int argc, char* argv[]) else { udata.c = ONE; } sunbooleantype implicit = SUNFALSE; - if ((strcmp(method, "ARKODE_MRI_GARK_IRK21a") == 0) || - (strcmp(method, "ARKODE_MRI_GARK_ESDIRK34a") == 0) || - (strcmp(method, "ARKODE_MRI_GARK_ESDIRK46a") == 0) || - (strcmp(method, "ARKODE_IMEX_MRI_SR21") == 0) || - (strcmp(method, "ARKODE_IMEX_MRI_SR32") == 0) || - (strcmp(method, "ARKODE_IMEX_MRI_SR43") == 0)) + if ((method == "ARKODE_MRI_GARK_IRK21a") || + (method == "ARKODE_MRI_GARK_ESDIRK34a") || + (method == "ARKODE_MRI_GARK_ESDIRK46a") || + (method == "ARKODE_IMEX_MRI_SR21") || + (method == "ARKODE_IMEX_MRI_SR32") || + (method == "ARKODE_IMEX_MRI_SR43")) { implicit = SUNTRUE; } @@ -177,7 +177,7 @@ int main(int argc, char* argv[]) } else { mristep_mem = MRIStepCreate(fn, NULL, T0, y, inner_stepper, ctx); } if (check_retval((void*)mristep_mem, "MRIStepCreate", 0)) return 1; - MRIStepCoupling C = MRIStepCoupling_LoadTableByName(method); + MRIStepCoupling C = MRIStepCoupling_LoadTableByName(method.c_str()); if (check_retval((void*)C, "MRIStepCoupling_LoadTableByName", 0)) return 1; retval = MRIStepSetCoupling(mristep_mem, C); if (check_retval(&retval, "MRIStepSetCoupling", 1)) return 1; @@ -208,9 +208,9 @@ int main(int argc, char* argv[]) if (check_retval(&retval, "ARKodeSetAccumulatedErrorType", 1)) return 1; // Run test for various H values - // vector Hvals = {ONE, ONE/2.0, ONE/4.0, ONE/8.0, ONE/16.0}; - vector Hvals = {ONE / 100.0, ONE / 200.0, ONE / 400.0, - ONE / 800.0, ONE / 1600.0}; + vector Hvals(5); + for (size_t i = 0; i < Hvals.size(); i++) + { Hvals[i] = SUN_RCONST(0.01) / SUNRpowerI(SUN_RCONST(2.0), i); } retval = run_test(mristep_mem, y, T0, Hvals, method, reltol, abstol, udata); if (check_retval(&retval, "run_test", 1)) return 1; @@ -257,7 +257,7 @@ static int Jn(sunrealtype t, N_Vector y, N_Vector fy, SUNMatrix J, //------------------------------ static int run_test(void* mristep_mem, N_Vector y, sunrealtype T0, - vector& Hvals, char* method, + vector& Hvals, string method, sunrealtype reltol, sunrealtype abstol, UserData& udata) { // Reused variables @@ -272,7 +272,7 @@ static int run_test(void* mristep_mem, N_Vector y, sunrealtype T0, vector dsm_est(Hvals.size(), ZERO); // Loop over step sizes - for (int iH = 0; iH < Hvals.size(); iH++) + for (size_t iH = 0; iH < Hvals.size(); iH++) { // Reset integrator for this run t = T0; @@ -299,7 +299,7 @@ static int run_test(void* mristep_mem, N_Vector y, sunrealtype T0, if (check_retval(&retval, "Ytrue", 1)) return 1; dsm[iH] = abs(NV_Ith_S(y, 0) - NV_Ith_S(vtemp, 0)) / (abstol + reltol * abs(NV_Ith_S(vtemp, 0))); - if (strcmp(method, "ARKODE_MRI_GARK_ERK22a") == 0) + if (method == "ARKODE_MRI_GARK_ERK22a") { printf(" H %.5f dsm %.2e dsm_est %.2e dsm_anal %.2e " " dsm_est_anal %.2e\n", @@ -310,7 +310,7 @@ static int run_test(void* mristep_mem, N_Vector y, sunrealtype T0, abs(udata.a * Hvals[iH] / 4.0 + udata.b / 2.0) / (abstol + reltol * abs(NV_Ith_S(vtemp, 0)))); } - else if (strcmp(method, "ARKODE_MRI_GARK_IRK21a") == 0) + else if (method == "ARKODE_MRI_GARK_IRK21a") { printf(" H %.5f dsm %.2e dsm_est %.2e dsm_anal %.2e " " dsm_est_anal %.2e\n", @@ -321,7 +321,7 @@ static int run_test(void* mristep_mem, N_Vector y, sunrealtype T0, abs(udata.a * Hvals[iH] / 2.0 + udata.b / 2.0) / (abstol + reltol * abs(NV_Ith_S(vtemp, 0)))); } - else if (strcmp(method, "ARKODE_IMEX_MRI_SR21") == 0) + else if (method == "ARKODE_IMEX_MRI_SR21") { printf(" H %.5f dsm %.2e dsm_est %.2e dsm_anal %.2e " " dsm_est_anal %.2e\n", From 7a38980eee7fc42b75293b84ef97784eb1dfd70e Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Fri, 6 Sep 2024 11:03:14 -0500 Subject: [PATCH 046/286] Formatting --- .../ark_test_slowerror_brusselator.cpp | 17 +++++++++-------- .../CXX_serial/ark_test_slowerror_kpr.cpp | 9 +++++---- .../ark_test_slowerror_polynomial.cpp | 7 ++++--- 3 files changed, 18 insertions(+), 15 deletions(-) diff --git a/test/unit_tests/arkode/CXX_serial/ark_test_slowerror_brusselator.cpp b/test/unit_tests/arkode/CXX_serial/ark_test_slowerror_brusselator.cpp index 93e05f19f6..ceb9f03282 100644 --- a/test/unit_tests/arkode/CXX_serial/ark_test_slowerror_brusselator.cpp +++ b/test/unit_tests/arkode/CXX_serial/ark_test_slowerror_brusselator.cpp @@ -133,8 +133,8 @@ static int computeErrorWeights(N_Vector ycur, N_Vector weight, sunrealtype rtol, static int check_retval(void* returnvalue, const char* funcname, int opt); static int run_test(void* mristep_mem, void* arkode_ref, N_Vector y, sunrealtype T0, sunrealtype Tf, N_Vector* yref, - vector Hvals, string method, sunrealtype reltol, - sunrealtype abstol, UserData& udata); + vector Hvals, string method, + sunrealtype reltol, sunrealtype abstol, UserData& udata); // Main Program int main(int argc, char* argv[]) @@ -221,8 +221,7 @@ int main(int argc, char* argv[]) implicit = SUNTRUE; } if ((method == "ARKODE_IMEX_MRI_SR21") || - (method == "ARKODE_IMEX_MRI_SR32") || - (method == "ARKODE_IMEX_MRI_SR43")) + (method == "ARKODE_IMEX_MRI_SR32") || (method == "ARKODE_IMEX_MRI_SR43")) { imex = SUNTRUE; implicit = SUNTRUE; @@ -339,10 +338,12 @@ int main(int argc, char* argv[]) if (check_retval(&retval, "ARKodeSetAccumulatedErrorType", 1)) return 1; // Run test for various H values - sunrealtype hmax = (Tf - T0) / 20.0 / udata.Npart; + sunrealtype hmax = (Tf - T0) / 20.0 / udata.Npart; vector Hvals(5); for (size_t i = 0; i < Hvals.size(); i++) - { Hvals[i] = hmax / SUNRpowerI(SUN_RCONST(4.0), i); } + { + Hvals[i] = hmax / SUNRpowerI(SUN_RCONST(4.0), i); + } retval = run_test(mristep_mem, arkode_ref, y, T0, Tf, yref, Hvals, method, reltol, abstol, udata); if (check_retval(&retval, "run_test", 1)) return 1; @@ -475,8 +476,8 @@ static int Ji(sunrealtype t, N_Vector y, N_Vector fy, SUNMatrix J, static int run_test(void* mristep_mem, void* arkode_ref, N_Vector y, sunrealtype T0, sunrealtype Tf, N_Vector* yref, - vector Hvals, string method, sunrealtype reltol, - sunrealtype abstol, UserData& udata) + vector Hvals, string method, + sunrealtype reltol, sunrealtype abstol, UserData& udata) { // Reused variables int retval; diff --git a/test/unit_tests/arkode/CXX_serial/ark_test_slowerror_kpr.cpp b/test/unit_tests/arkode/CXX_serial/ark_test_slowerror_kpr.cpp index 82b4818ef9..96ea4fc7db 100644 --- a/test/unit_tests/arkode/CXX_serial/ark_test_slowerror_kpr.cpp +++ b/test/unit_tests/arkode/CXX_serial/ark_test_slowerror_kpr.cpp @@ -188,8 +188,7 @@ int main(int argc, char* argv[]) implicit = SUNTRUE; } if ((method == "ARKODE_IMEX_MRI_SR21") || - (method == "ARKODE_IMEX_MRI_SR32") || - (method == "ARKODE_IMEX_MRI_SR43")) + (method == "ARKODE_IMEX_MRI_SR32") || (method == "ARKODE_IMEX_MRI_SR43")) { imex = SUNTRUE; implicit = SUNTRUE; @@ -276,10 +275,12 @@ int main(int argc, char* argv[]) if (check_retval(&retval, "ARKodeSetAccumulatedErrorType", 1)) return 1; // Run test for various H values - sunrealtype hmax = (Tf - T0) / 20 / udata.Npart; + sunrealtype hmax = (Tf - T0) / 20 / udata.Npart; vector Hvals(5); for (size_t i = 0; i < Hvals.size(); i++) - { Hvals[i] = hmax / SUNRpowerI(SUN_RCONST(4.0), i); } + { + Hvals[i] = hmax / SUNRpowerI(SUN_RCONST(4.0), i); + } retval = run_test(mristep_mem, y, T0, Tf, Hvals, method, reltol, abstol, udata); if (check_retval(&retval, "run_test", 1)) return 1; diff --git a/test/unit_tests/arkode/CXX_serial/ark_test_slowerror_polynomial.cpp b/test/unit_tests/arkode/CXX_serial/ark_test_slowerror_polynomial.cpp index 16b25bd9bc..ac870e53ea 100644 --- a/test/unit_tests/arkode/CXX_serial/ark_test_slowerror_polynomial.cpp +++ b/test/unit_tests/arkode/CXX_serial/ark_test_slowerror_polynomial.cpp @@ -127,8 +127,7 @@ int main(int argc, char* argv[]) (method == "ARKODE_MRI_GARK_ESDIRK34a") || (method == "ARKODE_MRI_GARK_ESDIRK46a") || (method == "ARKODE_IMEX_MRI_SR21") || - (method == "ARKODE_IMEX_MRI_SR32") || - (method == "ARKODE_IMEX_MRI_SR43")) + (method == "ARKODE_IMEX_MRI_SR32") || (method == "ARKODE_IMEX_MRI_SR43")) { implicit = SUNTRUE; } @@ -210,7 +209,9 @@ int main(int argc, char* argv[]) // Run test for various H values vector Hvals(5); for (size_t i = 0; i < Hvals.size(); i++) - { Hvals[i] = SUN_RCONST(0.01) / SUNRpowerI(SUN_RCONST(2.0), i); } + { + Hvals[i] = SUN_RCONST(0.01) / SUNRpowerI(SUN_RCONST(2.0), i); + } retval = run_test(mristep_mem, y, T0, Hvals, method, reltol, abstol, udata); if (check_retval(&retval, "run_test", 1)) return 1; From 816a24ffed346f1f5ce84534dd928f36d323bbe4 Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Fri, 6 Sep 2024 11:11:54 -0500 Subject: [PATCH 047/286] Resolved unused-variable 'errors' --- .../arkode/CXX_serial/ark_test_brusselator_mriadapt.cpp | 8 -------- .../arkode/CXX_serial/ark_test_slowerror_brusselator.cpp | 6 ++---- test/unit_tests/utilities/test_utilities.hpp | 7 ++++--- 3 files changed, 6 insertions(+), 15 deletions(-) diff --git a/test/unit_tests/arkode/CXX_serial/ark_test_brusselator_mriadapt.cpp b/test/unit_tests/arkode/CXX_serial/ark_test_brusselator_mriadapt.cpp index a9963fed33..49049dc4b0 100644 --- a/test/unit_tests/arkode/CXX_serial/ark_test_brusselator_mriadapt.cpp +++ b/test/unit_tests/arkode/CXX_serial/ark_test_brusselator_mriadapt.cpp @@ -809,8 +809,6 @@ int main(int argc, char* argv[]) static int ff(sunrealtype t, N_Vector y, N_Vector ydot, void* user_data) { Options* opts = (Options*)user_data; - const sunrealtype u = NV_Ith_S(y, 0); - const sunrealtype v = NV_Ith_S(y, 1); const sunrealtype w = NV_Ith_S(y, 2); // fill in the RHS function: @@ -845,7 +843,6 @@ static int fse(sunrealtype t, N_Vector y, N_Vector ydot, void* user_data) Options* opts = (Options*)user_data; const sunrealtype u = NV_Ith_S(y, 0); const sunrealtype v = NV_Ith_S(y, 1); - const sunrealtype w = NV_Ith_S(y, 2); // fill in the RHS function: NV_Ith_S(ydot, 0) = opts->a + v * u * u; @@ -859,9 +856,7 @@ static int fse(sunrealtype t, N_Vector y, N_Vector ydot, void* user_data) // fsi routine to compute the slow portion of the ODE RHS.(currently same as fse) static int fsi(sunrealtype t, N_Vector y, N_Vector ydot, void* user_data) { - Options* opts = (Options*)user_data; const sunrealtype u = NV_Ith_S(y, 0); - const sunrealtype v = NV_Ith_S(y, 1); const sunrealtype w = NV_Ith_S(y, 2); // fill in the RHS function: @@ -898,7 +893,6 @@ static int f0(sunrealtype t, N_Vector y, N_Vector ydot, void* user_data) static int Js(sunrealtype t, N_Vector y, N_Vector fy, SUNMatrix J, void* user_data, N_Vector tmp1, N_Vector tmp2, N_Vector tmp3) { - Options* opts = (Options*)user_data; const sunrealtype u = NV_Ith_S(y, 0); const sunrealtype v = NV_Ith_S(y, 1); const sunrealtype w = NV_Ith_S(y, 2); @@ -923,9 +917,7 @@ static int Js(sunrealtype t, N_Vector y, N_Vector fy, SUNMatrix J, static int Jsi(sunrealtype t, N_Vector y, N_Vector fy, SUNMatrix J, void* user_data, N_Vector tmp1, N_Vector tmp2, N_Vector tmp3) { - Options* opts = (Options*)user_data; const sunrealtype u = NV_Ith_S(y, 0); - const sunrealtype v = NV_Ith_S(y, 1); const sunrealtype w = NV_Ith_S(y, 2); // fill in the Jacobian: diff --git a/test/unit_tests/arkode/CXX_serial/ark_test_slowerror_brusselator.cpp b/test/unit_tests/arkode/CXX_serial/ark_test_slowerror_brusselator.cpp index ceb9f03282..94e3dcc5a3 100644 --- a/test/unit_tests/arkode/CXX_serial/ark_test_slowerror_brusselator.cpp +++ b/test/unit_tests/arkode/CXX_serial/ark_test_slowerror_brusselator.cpp @@ -145,7 +145,7 @@ int main(int argc, char* argv[]) sunindextype NEQ = 3; // number of dependent vars. string method; // MRI method name int test = 2; // test problem to run - sunrealtype a, b, u0, v0, w0; // parameters + sunrealtype u0, v0, w0; // parameters sunrealtype reltol = SUN_RCONST(1.e-10); // fast solver tolerances sunrealtype abstol = SUN_RCONST(1.e-12); @@ -233,7 +233,7 @@ int main(int argc, char* argv[]) cout << " partition size = " << udata.Npart << endl; cout << " initial conditions: u0 = " << u0 << ", v0 = " << v0 << ", w0 = " << w0 << endl; - cout << " problem parameters: a = " << a << ", b = " << b + cout << " problem parameters: a = " << udata.a << ", b = " << udata.b << ", ep = " << udata.ep << endl; cout << " MRI method: " << method; if (imex) { cout << " (ImEx)" << endl; } @@ -392,7 +392,6 @@ static int fi(sunrealtype t, N_Vector y, N_Vector ydot, void* user_data) { UserData* udata = (UserData*)user_data; sunrealtype u = NV_Ith_S(y, 0); // access solution values - sunrealtype v = NV_Ith_S(y, 1); sunrealtype w = NV_Ith_S(y, 2); // fill in the RHS function @@ -450,7 +449,6 @@ static int Ji(sunrealtype t, N_Vector y, N_Vector fy, SUNMatrix J, { UserData* udata = (UserData*)user_data; sunrealtype u = NV_Ith_S(y, 0); // access solution values - sunrealtype v = NV_Ith_S(y, 1); sunrealtype w = NV_Ith_S(y, 2); // fill in the Jacobian diff --git a/test/unit_tests/utilities/test_utilities.hpp b/test/unit_tests/utilities/test_utilities.hpp index abc34f60bb..6798740d63 100644 --- a/test/unit_tests/utilities/test_utilities.hpp +++ b/test/unit_tests/utilities/test_utilities.hpp @@ -1,5 +1,6 @@ /* ----------------------------------------------------------------------------- * Programmer(s): David J. Gardner @ LLNL + * Daniel R. Reynolds @ SMU * ----------------------------------------------------------------------------- * SUNDIALS Copyright Start * Copyright (c) 2002-2023, Lawrence Livermore National Security @@ -11,7 +12,7 @@ * SPDX-License-Identifier: BSD-3-Clause * SUNDIALS Copyright End * ----------------------------------------------------------------------------- - * Utility functions for C++ examples + * Utility functions for C++ unit tests. * ---------------------------------------------------------------------------*/ #include @@ -20,7 +21,7 @@ #include // Check function return flag -int check_flag(const int flag, const std::string funcname) +static int check_flag(const int flag, const std::string funcname) { if (!flag) return 0; if (flag < 0) std::cerr << "ERROR: "; @@ -29,7 +30,7 @@ int check_flag(const int flag, const std::string funcname) } // Check if a function returned a NULL pointer -int check_ptr(const void* ptr, const std::string funcname) +static int check_ptr(const void* ptr, const std::string funcname) { if (ptr) return 0; std::cerr << "ERROR: " << funcname << " returned NULL" << std::endl; From 5df89898c86f0d2dd697c493a5e287165482393b Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Fri, 6 Sep 2024 11:30:03 -0500 Subject: [PATCH 048/286] Resolved unused-function 'errors' --- .../arkode/CXX_serial/ark_kpr_nestedmri.cpp | 39 ------------------- 1 file changed, 39 deletions(-) diff --git a/examples/arkode/CXX_serial/ark_kpr_nestedmri.cpp b/examples/arkode/CXX_serial/ark_kpr_nestedmri.cpp index 3c69fed4a8..bf72f66ee0 100644 --- a/examples/arkode/CXX_serial/ark_kpr_nestedmri.cpp +++ b/examples/arkode/CXX_serial/ark_kpr_nestedmri.cpp @@ -214,8 +214,6 @@ static int Jm(sunrealtype t, N_Vector y, N_Vector fy, SUNMatrix J, void* user_data, N_Vector tmp1, N_Vector tmp2, N_Vector tmp3); static int Jmi(sunrealtype t, N_Vector y, N_Vector fy, SUNMatrix J, void* user_data, N_Vector tmp1, N_Vector tmp2, N_Vector tmp3); -static int Jn(sunrealtype t, N_Vector y, N_Vector fy, SUNMatrix J, - void* user_data, N_Vector tmp1, N_Vector tmp2, N_Vector tmp3); // Utility functions static void InputHelp(); @@ -1291,43 +1289,6 @@ static int fsi(sunrealtype t, N_Vector y, N_Vector ydot, void* user_data) return 0; } -static int f0(sunrealtype t, N_Vector y, N_Vector ydot, void* user_data) -{ - N_VConst(ZERO, ydot); - return (0); -} - -// Jacobian of fn -static int Jn(sunrealtype t, N_Vector y, N_Vector fy, SUNMatrix J, - void* user_data, N_Vector tmp1, N_Vector tmp2, N_Vector tmp3) -{ - Options* opts = (Options*)user_data; - const sunrealtype u = NV_Ith_S(y, 0); - const sunrealtype v = NV_Ith_S(y, 1); - const sunrealtype w = NV_Ith_S(y, 2); - sunrealtype t11, t22, t33; - - // fill in the Jacobian: - // [G e e]*[1-(u^2-p(t)-2)/(2*u^2), 0, 0] + [-p'(t)/(2*u^2), 0, 0] - // [e al be] [0, 1-(v^2-q(t)-2)/(2*v^2), 0] [0, -q'(t)/(2*v^2), 0] - // [e -be al] [0, 0, 1-(w^2-r(t)-2)/(2*w^2)] [0, 0, -r'(t)/(2*w^2)] - t11 = ONE - (u * u - p(t, opts) - TWO) / (TWO * u * u); - t22 = ONE - (v * v - q(t, opts) - TWO) / (TWO * v * v); - t33 = ONE - (w * w - r(t, opts) - TWO) / (TWO * w * w); - SM_ELEMENT_D(J, 0, 0) = opts->G * t11 - pdot(t, opts) / (TWO * u * u); - SM_ELEMENT_D(J, 0, 1) = opts->e * t22; - SM_ELEMENT_D(J, 0, 2) = opts->e * t33; - SM_ELEMENT_D(J, 1, 0) = opts->e * t11; - SM_ELEMENT_D(J, 1, 1) = opts->al * t22 - qdot(t, opts) / (TWO * v * v); - SM_ELEMENT_D(J, 1, 2) = opts->be * t33; - SM_ELEMENT_D(J, 2, 0) = opts->e * t11; - SM_ELEMENT_D(J, 2, 1) = -opts->be * t22; - SM_ELEMENT_D(J, 2, 2) = opts->al * t33 - rdot(t, opts) / (TWO * w * w); - - // Return with success - return 0; -} - // Jacobian of fm static int Jm(sunrealtype t, N_Vector y, N_Vector fy, SUNMatrix J, void* user_data, N_Vector tmp1, N_Vector tmp2, N_Vector tmp3) From f99701aa8fc4601e77890847d69c4b933e6381a4 Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Fri, 6 Sep 2024 12:07:53 -0500 Subject: [PATCH 049/286] Resolved unused-function 'error' --- examples/arkode/CXX_serial/ark_kpr_nestedmri.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/examples/arkode/CXX_serial/ark_kpr_nestedmri.cpp b/examples/arkode/CXX_serial/ark_kpr_nestedmri.cpp index bf72f66ee0..b8689506f6 100644 --- a/examples/arkode/CXX_serial/ark_kpr_nestedmri.cpp +++ b/examples/arkode/CXX_serial/ark_kpr_nestedmri.cpp @@ -205,7 +205,6 @@ static int fme(sunrealtype t, N_Vector y, N_Vector ydot, void* user_data); static int fm(sunrealtype t, N_Vector y, N_Vector ydot, void* user_data); static int ff(sunrealtype t, N_Vector y, N_Vector ydot, void* user_data); static int fn(sunrealtype t, N_Vector y, N_Vector ydot, void* user_data); -static int f0(sunrealtype t, N_Vector y, N_Vector ydot, void* user_data); static int Js(sunrealtype t, N_Vector y, N_Vector fy, SUNMatrix J, void* user_data, N_Vector tmp1, N_Vector tmp2, N_Vector tmp3); static int Jsi(sunrealtype t, N_Vector y, N_Vector fy, SUNMatrix J, From 8f19d2438de1cb0ab775f5a589b872f51238eaca Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Fri, 6 Sep 2024 13:09:40 -0500 Subject: [PATCH 050/286] Resolved conversion 'error' --- .../arkode/CXX_serial/ark_test_slowerror_brusselator.cpp | 2 +- test/unit_tests/arkode/CXX_serial/ark_test_slowerror_kpr.cpp | 2 +- .../arkode/CXX_serial/ark_test_slowerror_polynomial.cpp | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/test/unit_tests/arkode/CXX_serial/ark_test_slowerror_brusselator.cpp b/test/unit_tests/arkode/CXX_serial/ark_test_slowerror_brusselator.cpp index 94e3dcc5a3..34202b5cbc 100644 --- a/test/unit_tests/arkode/CXX_serial/ark_test_slowerror_brusselator.cpp +++ b/test/unit_tests/arkode/CXX_serial/ark_test_slowerror_brusselator.cpp @@ -342,7 +342,7 @@ int main(int argc, char* argv[]) vector Hvals(5); for (size_t i = 0; i < Hvals.size(); i++) { - Hvals[i] = hmax / SUNRpowerI(SUN_RCONST(4.0), i); + Hvals[i] = hmax / SUNRpowerI(SUN_RCONST(4.0), (int) i); } retval = run_test(mristep_mem, arkode_ref, y, T0, Tf, yref, Hvals, method, reltol, abstol, udata); diff --git a/test/unit_tests/arkode/CXX_serial/ark_test_slowerror_kpr.cpp b/test/unit_tests/arkode/CXX_serial/ark_test_slowerror_kpr.cpp index 96ea4fc7db..d91f7837cc 100644 --- a/test/unit_tests/arkode/CXX_serial/ark_test_slowerror_kpr.cpp +++ b/test/unit_tests/arkode/CXX_serial/ark_test_slowerror_kpr.cpp @@ -279,7 +279,7 @@ int main(int argc, char* argv[]) vector Hvals(5); for (size_t i = 0; i < Hvals.size(); i++) { - Hvals[i] = hmax / SUNRpowerI(SUN_RCONST(4.0), i); + Hvals[i] = hmax / SUNRpowerI(SUN_RCONST(4.0), (int) i); } retval = run_test(mristep_mem, y, T0, Tf, Hvals, method, reltol, abstol, udata); if (check_retval(&retval, "run_test", 1)) return 1; diff --git a/test/unit_tests/arkode/CXX_serial/ark_test_slowerror_polynomial.cpp b/test/unit_tests/arkode/CXX_serial/ark_test_slowerror_polynomial.cpp index ac870e53ea..6b7c7a4573 100644 --- a/test/unit_tests/arkode/CXX_serial/ark_test_slowerror_polynomial.cpp +++ b/test/unit_tests/arkode/CXX_serial/ark_test_slowerror_polynomial.cpp @@ -210,7 +210,7 @@ int main(int argc, char* argv[]) vector Hvals(5); for (size_t i = 0; i < Hvals.size(); i++) { - Hvals[i] = SUN_RCONST(0.01) / SUNRpowerI(SUN_RCONST(2.0), i); + Hvals[i] = SUN_RCONST(0.01) / SUNRpowerI(SUN_RCONST(2.0), (int) i); } retval = run_test(mristep_mem, y, T0, Hvals, method, reltol, abstol, udata); if (check_retval(&retval, "run_test", 1)) return 1; From 628cffc1d1691c834796126ed25fc653dc773748 Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Fri, 6 Sep 2024 13:15:20 -0500 Subject: [PATCH 051/286] Formatting --- .../arkode/CXX_serial/ark_test_slowerror_brusselator.cpp | 2 +- test/unit_tests/arkode/CXX_serial/ark_test_slowerror_kpr.cpp | 2 +- .../arkode/CXX_serial/ark_test_slowerror_polynomial.cpp | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/test/unit_tests/arkode/CXX_serial/ark_test_slowerror_brusselator.cpp b/test/unit_tests/arkode/CXX_serial/ark_test_slowerror_brusselator.cpp index 34202b5cbc..2d6f5f077b 100644 --- a/test/unit_tests/arkode/CXX_serial/ark_test_slowerror_brusselator.cpp +++ b/test/unit_tests/arkode/CXX_serial/ark_test_slowerror_brusselator.cpp @@ -342,7 +342,7 @@ int main(int argc, char* argv[]) vector Hvals(5); for (size_t i = 0; i < Hvals.size(); i++) { - Hvals[i] = hmax / SUNRpowerI(SUN_RCONST(4.0), (int) i); + Hvals[i] = hmax / SUNRpowerI(SUN_RCONST(4.0), (int)i); } retval = run_test(mristep_mem, arkode_ref, y, T0, Tf, yref, Hvals, method, reltol, abstol, udata); diff --git a/test/unit_tests/arkode/CXX_serial/ark_test_slowerror_kpr.cpp b/test/unit_tests/arkode/CXX_serial/ark_test_slowerror_kpr.cpp index d91f7837cc..9711f652da 100644 --- a/test/unit_tests/arkode/CXX_serial/ark_test_slowerror_kpr.cpp +++ b/test/unit_tests/arkode/CXX_serial/ark_test_slowerror_kpr.cpp @@ -279,7 +279,7 @@ int main(int argc, char* argv[]) vector Hvals(5); for (size_t i = 0; i < Hvals.size(); i++) { - Hvals[i] = hmax / SUNRpowerI(SUN_RCONST(4.0), (int) i); + Hvals[i] = hmax / SUNRpowerI(SUN_RCONST(4.0), (int)i); } retval = run_test(mristep_mem, y, T0, Tf, Hvals, method, reltol, abstol, udata); if (check_retval(&retval, "run_test", 1)) return 1; diff --git a/test/unit_tests/arkode/CXX_serial/ark_test_slowerror_polynomial.cpp b/test/unit_tests/arkode/CXX_serial/ark_test_slowerror_polynomial.cpp index 6b7c7a4573..53c1e0eb43 100644 --- a/test/unit_tests/arkode/CXX_serial/ark_test_slowerror_polynomial.cpp +++ b/test/unit_tests/arkode/CXX_serial/ark_test_slowerror_polynomial.cpp @@ -210,7 +210,7 @@ int main(int argc, char* argv[]) vector Hvals(5); for (size_t i = 0; i < Hvals.size(); i++) { - Hvals[i] = SUN_RCONST(0.01) / SUNRpowerI(SUN_RCONST(2.0), (int) i); + Hvals[i] = SUN_RCONST(0.01) / SUNRpowerI(SUN_RCONST(2.0), (int)i); } retval = run_test(mristep_mem, y, T0, Hvals, method, reltol, abstol, udata); if (check_retval(&retval, "run_test", 1)) return 1; From 6b9764cb817da9b92ce09f3dd95f353680431f79 Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Fri, 6 Sep 2024 14:02:48 -0500 Subject: [PATCH 052/286] Moved some new examples and unit tests to require double precision --- examples/arkode/CXX_serial/CMakeLists.txt | 4 +- examples/arkode/C_serial/CMakeLists.txt | 24 +++--- .../arkode/CXX_serial/CMakeLists.txt | 82 ++++++++++--------- 3 files changed, 56 insertions(+), 54 deletions(-) diff --git a/examples/arkode/CXX_serial/CMakeLists.txt b/examples/arkode/CXX_serial/CMakeLists.txt index 59bbcaec9f..be64e1d748 100644 --- a/examples/arkode/CXX_serial/CMakeLists.txt +++ b/examples/arkode/CXX_serial/CMakeLists.txt @@ -28,13 +28,13 @@ set(ARKODE_examples "ark_kpr_Mt.cpp\;0 4 1\;develop" "ark_kpr_Mt.cpp\;0 -4\;exclude-single" "ark_kpr_Mt.cpp\;1 -5\;exclude-single" - "ark_kpr_Mt.cpp\;2 -5 0 -10\;develop" + "ark_kpr_Mt.cpp\;2 -5 0 -10\;exclude-single" "ark_kpr_Mt.cpp\;1 -3 0 -10 0\;exclude-single" "ark_kpr_Mt.cpp\;0 3 0 -10 0\;develop" "ark_kpr_Mt.cpp\;2 4 0 -10 0\;develop" "ark_kpr_Mt.cpp\;0 4 0 -10 1 10 1\;develop" "ark_kpr_Mt.cpp\;0 4 0 -10 0 10 1\;develop" - "ark_kpr_nestedmri.cpp\;\;develop" + "ark_kpr_nestedmri.cpp\;\;exclude-single" "ark_pendulum.cpp\;\;develop") # Header files to install diff --git a/examples/arkode/C_serial/CMakeLists.txt b/examples/arkode/C_serial/CMakeLists.txt index 74e5665ea9..f5b236bf65 100644 --- a/examples/arkode/C_serial/CMakeLists.txt +++ b/examples/arkode/C_serial/CMakeLists.txt @@ -59,21 +59,21 @@ set(ARKODE_examples "ark_kepler\;--stepper SPRK --step-mode fixed --method ARKODE_SPRK_RUTH_3_3 --tf 50 --check-order --nout 1\;exclude-single" "ark_kepler\;--stepper SPRK --step-mode fixed --method ARKODE_SPRK_YOSHIDA_6_8 --tf 50 --check-order --nout 1\;exclude-single" "ark_kepler\;\;develop" - "ark_kpr_mri\;0 1 0.005\;develop" - "ark_kpr_mri\;1 0 0.01\;develop" - "ark_kpr_mri\;1 1 0.002\;develop" - "ark_kpr_mri\;2 4 0.002\;develop" - "ark_kpr_mri\;3 2 0.001\;develop" - "ark_kpr_mri\;4 3 0.001\;develop" - "ark_kpr_mri\;5 4 0.001\;develop" - "ark_kpr_mri\;6 5 0.001\;develop" - "ark_kpr_mri\;7 2 0.002\;develop" + "ark_kpr_mri\;0 1 0.005\;exclude-single" + "ark_kpr_mri\;1 0 0.01\;exclude-single" + "ark_kpr_mri\;1 1 0.002\;exclude-single" + "ark_kpr_mri\;2 4 0.002\;exclude-single" + "ark_kpr_mri\;3 2 0.001\;exclude-single" + "ark_kpr_mri\;4 3 0.001\;exclude-single" + "ark_kpr_mri\;5 4 0.001\;exclude-single" + "ark_kpr_mri\;6 5 0.001\;exclude-single" + "ark_kpr_mri\;7 2 0.002\;exclude-single" "ark_kpr_mri\;8 3 0.001 -100 100 0.5 1\;exclude-single" "ark_kpr_mri\;9 3 0.001 -100 100 0.5 1\;exclude-single" "ark_kpr_mri\;10 4 0.001 -100 100 0.5 1\;exclude-single" - "ark_kpr_mri\;11 2 0.001\;develop" - "ark_kpr_mri\;12 3 0.005\;develop" - "ark_kpr_mri\;13 4 0.01\;develop" + "ark_kpr_mri\;11 2 0.001\;exclude-single" + "ark_kpr_mri\;12 3 0.005\;exclude-single" + "ark_kpr_mri\;13 4 0.01\;exclude-single" "ark_KrylovDemo_prec\;\;exclude-single" "ark_KrylovDemo_prec\;1\;exclude-single" "ark_KrylovDemo_prec\;2\;exclude-single" diff --git a/test/unit_tests/arkode/CXX_serial/CMakeLists.txt b/test/unit_tests/arkode/CXX_serial/CMakeLists.txt index 7dc10c3685..fc324e5933 100644 --- a/test/unit_tests/arkode/CXX_serial/CMakeLists.txt +++ b/test/unit_tests/arkode/CXX_serial/CMakeLists.txt @@ -11,48 +11,49 @@ # SPDX-License-Identifier: BSD-3-Clause # SUNDIALS Copyright End # --------------------------------------------------------------- -# ARKode C++ serial unit_tests +# ARKODE C++ serial unit_tests # --------------------------------------------------------------- -# List of test tuples of the form "name\;args" +# List of test tuples of the form "name\;args\;type" where the +# type is 'develop' for tests excluded from 'make test' in releases set(unit_tests - "ark_test_accumerror_brusselator.cpp\;20 3 1" - "ark_test_accumerror_brusselator.cpp\;20 -4 0" - "ark_test_accumerror_brusselator.cpp\;20 5 0" - "ark_test_accumerror_kpr.cpp\;20 2 0" - "ark_test_accumerror_kpr.cpp\;20 3 1" - "ark_test_accumerror_kpr.cpp\;20 -4 1" - "ark_test_analytic_sys_mri.cpp\;0" - "ark_test_analytic_sys_mri.cpp\;1" - "ark_test_dahlquist_ark.cpp\;0 -1 0" - "ark_test_dahlquist_ark.cpp\;0 0 0" - "ark_test_dahlquist_ark.cpp\;0 0 1" - "ark_test_dahlquist_ark.cpp\;0 1 0" - "ark_test_dahlquist_ark.cpp\;0 1 1" - "ark_test_dahlquist_ark.cpp\;1 -1 0" - "ark_test_dahlquist_ark.cpp\;1 0 0" - "ark_test_dahlquist_ark.cpp\;1 0 1" - "ark_test_dahlquist_ark.cpp\;1 1 0" - "ark_test_dahlquist_ark.cpp\;1 1 1" - "ark_test_dahlquist_ark.cpp\;2 -1 0" - "ark_test_dahlquist_ark.cpp\;2 0 0" - "ark_test_dahlquist_ark.cpp\;2 0 1" - "ark_test_dahlquist_ark.cpp\;2 1 0" - "ark_test_dahlquist_ark.cpp\;2 1 1" - "ark_test_dahlquist_erk.cpp\;-1" - "ark_test_dahlquist_erk.cpp\;0" - "ark_test_dahlquist_erk.cpp\;1" - "ark_test_dahlquist_mri.cpp\;-1" - "ark_test_dahlquist_mri.cpp\;0" - "ark_test_dahlquist_mri.cpp\;1" - "ark_test_butcher.cpp\;" - "ark_test_getjac.cpp\;" - "ark_test_getjac_mri.cpp\;" - "ark_test_kpr_mriadapt.cpp\;--hs 0.002 --rtol 0.000004 --scontrol 0" - "ark_test_brusselator_mriadapt.cpp\;--rtol 0.000004 --scontrol 0" - "ark_test_slowerror_brusselator.cpp\;" - "ark_test_slowerror_kpr.cpp\;" - "ark_test_slowerror_polynomial.cpp\;") + "ark_test_accumerror_brusselator.cpp\;20 3 1\;exclude-single" + "ark_test_accumerror_brusselator.cpp\;20 -4 0\;exclude-single" + "ark_test_accumerror_brusselator.cpp\;20 5 0\;exclude-single" + "ark_test_accumerror_kpr.cpp\;20 2 0\;exclude-single" + "ark_test_accumerror_kpr.cpp\;20 3 1\;exclude-single" + "ark_test_accumerror_kpr.cpp\;20 -4 1\;exclude-single" + "ark_test_analytic_sys_mri.cpp\;0\;develop" + "ark_test_analytic_sys_mri.cpp\;1\;develop" + "ark_test_dahlquist_ark.cpp\;0 -1 0\;develop" + "ark_test_dahlquist_ark.cpp\;0 0 0\;develop" + "ark_test_dahlquist_ark.cpp\;0 0 1\;develop" + "ark_test_dahlquist_ark.cpp\;0 1 0\;develop" + "ark_test_dahlquist_ark.cpp\;0 1 1\;develop" + "ark_test_dahlquist_ark.cpp\;1 -1 0\;develop" + "ark_test_dahlquist_ark.cpp\;1 0 0\;develop" + "ark_test_dahlquist_ark.cpp\;1 0 1\;develop" + "ark_test_dahlquist_ark.cpp\;1 1 0\;develop" + "ark_test_dahlquist_ark.cpp\;1 1 1\;develop" + "ark_test_dahlquist_ark.cpp\;2 -1 0\;develop" + "ark_test_dahlquist_ark.cpp\;2 0 0\;develop" + "ark_test_dahlquist_ark.cpp\;2 0 1\;develop" + "ark_test_dahlquist_ark.cpp\;2 1 0\;develop" + "ark_test_dahlquist_ark.cpp\;2 1 1\;develop" + "ark_test_dahlquist_erk.cpp\;-1\;develop" + "ark_test_dahlquist_erk.cpp\;0\;develop" + "ark_test_dahlquist_erk.cpp\;1\;develop" + "ark_test_dahlquist_mri.cpp\;-1\;develop" + "ark_test_dahlquist_mri.cpp\;0\;develop" + "ark_test_dahlquist_mri.cpp\;1\;develop" + "ark_test_butcher.cpp\;\;develop" + "ark_test_getjac.cpp\;\;develop" + "ark_test_getjac_mri.cpp\;\;develop" + "ark_test_kpr_mriadapt.cpp\;--hs 0.002 --rtol 0.000004 --scontrol 0\;exclude-single" + "ark_test_brusselator_mriadapt.cpp\;--rtol 0.000004 --scontrol 0\;exclude-single" + "ark_test_slowerror_brusselator.cpp\;\;exclude-single" + "ark_test_slowerror_kpr.cpp\;\;exclude-single" + "ark_test_slowerror_polynomial.cpp\;\;exclude-single") # Add the build and install targets for each test foreach(test_tuple ${unit_tests}) @@ -60,6 +61,7 @@ foreach(test_tuple ${unit_tests}) # Parse the test tuple list(GET test_tuple 0 test) list(GET test_tuple 1 test_args) + list(GET test_tuple 2 test_type) # Extract the file name without extension get_filename_component(test_target ${test} NAME_WE) @@ -123,7 +125,7 @@ foreach(test_tuple ${unit_tests}) TEST_ARGS ${test_args} ANSWER_DIR ${CMAKE_CURRENT_SOURCE_DIR} ANSWER_FILE ${test_name}.out - EXAMPLE_TYPE "develop" ${diff_output}) + EXAMPLE_TYPE ${test_type} ${diff_output}) endforeach() From 395db4bc6f6c32e1d4e052c9c219582f3256a7e7 Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Fri, 6 Sep 2024 14:17:41 -0500 Subject: [PATCH 053/286] Formatting --- test/unit_tests/arkode/CXX_serial/CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/unit_tests/arkode/CXX_serial/CMakeLists.txt b/test/unit_tests/arkode/CXX_serial/CMakeLists.txt index fc324e5933..29de532878 100644 --- a/test/unit_tests/arkode/CXX_serial/CMakeLists.txt +++ b/test/unit_tests/arkode/CXX_serial/CMakeLists.txt @@ -14,8 +14,8 @@ # ARKODE C++ serial unit_tests # --------------------------------------------------------------- -# List of test tuples of the form "name\;args\;type" where the -# type is 'develop' for tests excluded from 'make test' in releases +# List of test tuples of the form "name\;args\;type" where the type is 'develop' +# for tests excluded from 'make test' in releases set(unit_tests "ark_test_accumerror_brusselator.cpp\;20 3 1\;exclude-single" "ark_test_accumerror_brusselator.cpp\;20 -4 0\;exclude-single" From 6fc56eeb84d1a745a11a645ef6485e3e24057750 Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Fri, 6 Sep 2024 14:21:46 -0500 Subject: [PATCH 054/286] Moved a few more examples to require double precision --- examples/arkode/C_serial/CMakeLists.txt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/examples/arkode/C_serial/CMakeLists.txt b/examples/arkode/C_serial/CMakeLists.txt index f5b236bf65..58e1421b92 100644 --- a/examples/arkode/C_serial/CMakeLists.txt +++ b/examples/arkode/C_serial/CMakeLists.txt @@ -25,7 +25,7 @@ set(ARKODE_examples # develop tests "ark_analytic_mels\;\;develop" "ark_analytic_nonlin\;\;develop" - "ark_brusselator_1D_mri\;\;develop" + "ark_brusselator_1D_mri\;\;exclude-single" "ark_brusselator_fp\;\;exclude-single" "ark_brusselator_mri\;\;develop" "ark_brusselator\;\;develop" @@ -77,12 +77,12 @@ set(ARKODE_examples "ark_KrylovDemo_prec\;\;exclude-single" "ark_KrylovDemo_prec\;1\;exclude-single" "ark_KrylovDemo_prec\;2\;exclude-single" - "ark_onewaycouple_mri\;\;develop" + "ark_onewaycouple_mri\;\;exclude-single" "ark_reaction_diffusion_mri\;\;develop" "ark_robertson_constraints\;\;exclude-single" "ark_robertson_root\;\;exclude-single" "ark_robertson\;\;exclude-single" - "ark_twowaycouple_mri\;\;develop") + "ark_twowaycouple_mri\;\;exclude-single") if(SUNDIALS_BUILD_WITH_MONITORING) list(APPEND ARKODE_examples "ark_brusselator_fp\;1\;exclude-single") From d289163c64451b4706a6e4bba7e467fec8037eeb Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Sat, 7 Sep 2024 20:25:00 -0500 Subject: [PATCH 055/286] Fixed bug wherein MRI-GARK methods mistakenly 'reset' the inner solver on every stage --- src/arkode/arkode_mristep.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/arkode/arkode_mristep.c b/src/arkode/arkode_mristep.c index 3e2b6ed9c9..334ef31d8a 100644 --- a/src/arkode/arkode_mristep.c +++ b/src/arkode/arkode_mristep.c @@ -1850,7 +1850,7 @@ int mriStep_TakeStepMRIGARK(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPt break; } retval = mriStep_StageERKFast(ark_mem, step_mem, t0, tf, ark_mem->ycur, - ark_mem->tempv2, SUNTRUE, need_inner_dsm); + ark_mem->tempv2, SUNFALSE, need_inner_dsm); if (retval != ARK_SUCCESS) { *nflagPtr = CONV_FAIL; } break; case (MRISTAGE_ERK_NOFAST): From 6f4cb697710255ed9424c3467fe3122eb67e5557 Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Mon, 9 Sep 2024 22:32:58 -0500 Subject: [PATCH 056/286] Updated changelog to include fix for loading default higher-order IMEX-MRI methods --- CHANGELOG.md | 5 +++++ doc/shared/RecentChanges.rst | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5ccaf65380..adbd7beca7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,7 @@ architecture for their system. Added support for multirate time step adaptivity controllers, based on the recently introduced `SUNAdaptController` base class, to ARKODE's MRIStep module. +Added new default MRI methods for temporally adaptive versus fixed-step runs. Added functionality to ARKODE to accumulate a temporal error estimate over multiple time steps. See the routines `ARKodeSetAccumulatedErrorType`, @@ -26,6 +27,10 @@ Fixed the loading of ARKStep's default first order explicit method. Fixed a CMake bug regarding usage of missing "print_warning" macro that was only triggered when the deprecated `CUDA_ARCH` option was used. +Fixed loading the default IMEX-MRI method if `ARKodeSetOrder` is used to specify +a third or fourth order method. Previously, the default second order method +was loaded in both cases. + ### Deprecation Notices ## Changes to SUNDIALS in release 7.1.1 diff --git a/doc/shared/RecentChanges.rst b/doc/shared/RecentChanges.rst index ecea556c52..e498dd10d7 100644 --- a/doc/shared/RecentChanges.rst +++ b/doc/shared/RecentChanges.rst @@ -10,6 +10,7 @@ override this value with the architecture for their system. Added support for multirate time step adaptivity controllers, based on the recently introduced `SUNAdaptController` base class, to ARKODE's MRIStep module. +Added new default MRI methods for temporally adaptive versus fixed-step runs. Added functionality to ARKODE to accumulate a temporal error estimate over multiple time steps. See the routines @@ -23,4 +24,8 @@ Fixed the loading of ARKStep's default first order explicit method. Fixed a CMake bug regarding usage of missing "print_warning" macro that was only triggered when the deprecated ``CUDA_ARCH`` option was used. +Fixed loading the default IMEX-MRI method if :c:func:`ARKodeSetOrder` is used to +specify a third or fourth order method. Previously, the default second order method +was loaded in both cases. + **Deprecation Notices** From 330fe7bb14f7445b73661fd81f2e3a462ea53075 Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Tue, 10 Sep 2024 15:23:03 -0500 Subject: [PATCH 057/286] Updated answer repository branch/commit --- test/answers | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/answers b/test/answers index 6426658117..9dcd9ce78e 160000 --- a/test/answers +++ b/test/answers @@ -1 +1 @@ -Subproject commit 64266581174b2a2c31283e82f5d28ea5683f6bce +Subproject commit 9dcd9ce78e70e3cc0877bfe4601090fa1aa3022b From 13ebccb9be20cfab7483eedfc7222dd22bee72d1 Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Wed, 11 Sep 2024 11:16:33 -0500 Subject: [PATCH 058/286] Fixed duplicate documentation label --- doc/arkode/guide/source/Usage/MRIStep/User_callable.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/arkode/guide/source/Usage/MRIStep/User_callable.rst b/doc/arkode/guide/source/Usage/MRIStep/User_callable.rst index 32a01861f7..5df668e962 100644 --- a/doc/arkode/guide/source/Usage/MRIStep/User_callable.rst +++ b/doc/arkode/guide/source/Usage/MRIStep/User_callable.rst @@ -2613,7 +2613,7 @@ MRIStep system resize function -.. _ARKStep_CInterface.MRIStepInterface: +.. _MRIStep_CInterface.MRIStepInterface: Nested multirate calculations ----------------------------- From d518dd1863c3500f005ef1b93fb5a559eb20282e Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Wed, 11 Sep 2024 11:17:37 -0500 Subject: [PATCH 059/286] Fixed missing line to set fn_is_current to SUNTRUE --- src/arkode/arkode.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/arkode/arkode.c b/src/arkode/arkode.c index d8f617997d..9c24f13bfd 100644 --- a/src/arkode/arkode.c +++ b/src/arkode/arkode.c @@ -1998,6 +1998,7 @@ int arkInitialSetup(ARKodeMem ark_mem, sunrealtype tout) retval = ark_mem->step_fullrhs(ark_mem, ark_mem->tcur, ark_mem->yn, ark_mem->fn, ARK_FULLRHS_START); if (retval != 0) return (ARK_RHSFUNC_FAIL); + ark_mem->fn_is_current = SUNTRUE; /* Estimate the first step size */ tout_hin = tout; From 55ad08fa0dee02a93e1f7a1e445f7ae2abff4654 Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Wed, 11 Sep 2024 11:18:07 -0500 Subject: [PATCH 060/286] Updated submodule commit --- test/answers | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/answers b/test/answers index 9dcd9ce78e..feac59ad47 160000 --- a/test/answers +++ b/test/answers @@ -1 +1 @@ -Subproject commit 9dcd9ce78e70e3cc0877bfe4601090fa1aa3022b +Subproject commit feac59ad47ae3f0a709bdcec4882a8f0afb08307 From f96bef8b4b4b06094a1a3db060294d00a570e1f0 Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Wed, 11 Sep 2024 11:55:04 -0500 Subject: [PATCH 061/286] Updated submodule commit --- test/answers | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/answers b/test/answers index feac59ad47..bbc9d290c1 160000 --- a/test/answers +++ b/test/answers @@ -1 +1 @@ -Subproject commit feac59ad47ae3f0a709bdcec4882a8f0afb08307 +Subproject commit bbc9d290c19c825c27b6a3d53951fd615b3af7e1 From e321e3215a3908bd04cf96c95c73bb3a453979af Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Wed, 11 Sep 2024 12:53:39 -0500 Subject: [PATCH 062/286] Updated handling for inclusion of test_utilities.hpp file --- test/unit_tests/arkode/CXX_serial/CMakeLists.txt | 1 - .../arkode/CXX_serial/ark_test_brusselator_mriadapt.cpp | 2 +- test/unit_tests/arkode/CXX_serial/ark_test_kpr_mriadapt.cpp | 2 +- 3 files changed, 2 insertions(+), 3 deletions(-) diff --git a/test/unit_tests/arkode/CXX_serial/CMakeLists.txt b/test/unit_tests/arkode/CXX_serial/CMakeLists.txt index 29de532878..c62580c508 100644 --- a/test/unit_tests/arkode/CXX_serial/CMakeLists.txt +++ b/test/unit_tests/arkode/CXX_serial/CMakeLists.txt @@ -80,7 +80,6 @@ foreach(test_tuple ${unit_tests}) target_include_directories( ${test_target} PRIVATE $ - ${PROJECT_SOURCE_DIR}/test/unit_tests/utilities ${CMAKE_SOURCE_DIR}/include ${CMAKE_SOURCE_DIR}/src) # We explicitly choose which object libraries to link to and link in the diff --git a/test/unit_tests/arkode/CXX_serial/ark_test_brusselator_mriadapt.cpp b/test/unit_tests/arkode/CXX_serial/ark_test_brusselator_mriadapt.cpp index 49049dc4b0..55566c482e 100644 --- a/test/unit_tests/arkode/CXX_serial/ark_test_brusselator_mriadapt.cpp +++ b/test/unit_tests/arkode/CXX_serial/ark_test_brusselator_mriadapt.cpp @@ -113,7 +113,7 @@ #include #include // dense linear solver #include // dense matrix type, fcts., macros -#include // common utility functions +#include "../../utilities/test_utilities.hpp" // common utility functions #if defined(SUNDIALS_EXTENDED_PRECISION) #define ESYM "Le" diff --git a/test/unit_tests/arkode/CXX_serial/ark_test_kpr_mriadapt.cpp b/test/unit_tests/arkode/CXX_serial/ark_test_kpr_mriadapt.cpp index 4e163cd9b1..3eac5f312c 100644 --- a/test/unit_tests/arkode/CXX_serial/ark_test_kpr_mriadapt.cpp +++ b/test/unit_tests/arkode/CXX_serial/ark_test_kpr_mriadapt.cpp @@ -111,7 +111,7 @@ #include #include // dense linear solver #include // dense matrix type, fcts., macros -#include // common utility functions +#include "../../utilities/test_utilities.hpp" // common utility functions #if defined(SUNDIALS_EXTENDED_PRECISION) #define ESYM "Le" From 47ae44d8d31fbcd35430e8af0c4ca10e6dfed0f9 Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Wed, 11 Sep 2024 13:45:39 -0500 Subject: [PATCH 063/286] Added test/unit_tests/utilities to scripts/shared --- scripts/shared | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/shared b/scripts/shared index fb6a1e0079..c6e5ae255c 100755 --- a/scripts/shared +++ b/scripts/shared @@ -101,6 +101,7 @@ $tar $tarfile $distrobase/test/unit_tests/CMakeLists.txt $tar $tarfile $distrobase/test/unit_tests/profiling $tar $tarfile $distrobase/test/unit_tests/sunmemory $tar $tarfile $distrobase/test/unit_tests/sundials +$tar $tarfile $distrobase/test/unit_tests/utilities echo " --- Add external files to $tarfile" $tar $tarfile $distrobase/external From 9607c8697967590990ab67ae4aac6a2987b70fee Mon Sep 17 00:00:00 2001 From: "David J. Gardner" Date: Thu, 12 Sep 2024 12:00:14 -0700 Subject: [PATCH 064/286] update output files --- ...sion_reaction_p_--np_2_2_--mri-arkstep.out | 60 ++-- ...reaction_p_--np_2_2_--mri-cvode-global.out | 52 ++-- ..._reaction_p_--np_2_2_--mri-cvode-local.out | 56 ++-- .../ark_heat2D_hypre_pfmg_mri_--np_2_2.out | 20 +- .../CXX_serial/ark_kpr_Mt_0_3_0_-10_0.out | 2 +- .../ark_kpr_Mt_0_4_0_-10_0_10_1.out | 2 +- .../ark_kpr_Mt_0_4_0_-10_1_10_1.out | 2 +- .../arkode/CXX_serial/ark_kpr_Mt_0_4_1.out | 2 +- examples/arkode/CXX_serial/ark_kpr_Mt_0_5.out | 2 +- examples/arkode/CXX_serial/ark_kpr_Mt_1_4.out | 2 +- .../CXX_serial/ark_kpr_Mt_2_4_0_-10_0.out | 2 +- .../CXX_serial/ark_kpr_Mt_2_8_0_-10.out | 2 +- .../arkode/CXX_serial/ark_kpr_nestedmri.out | 52 ++-- .../C_serial/ark_brusselator1D_FEM_slu.out | 2 +- .../ark_brusselator1D_imexmri_2_0.001.out | 2 +- .../ark_brusselator1D_imexmri_3_0.001.out | 2 +- .../ark_kpr_mri_10_4_0.001_-100_100_0.5_1.out | 10 +- .../arkode/C_serial/ark_kpr_mri_5_4_0.001.out | 80 ++--- .../arkode/C_serial/ark_kpr_mri_6_5_0.001.out | 80 ++--- .../ark_kpr_mri_8_3_0.001_-100_100_0.5_1.out | 102 +++---- .../CXX_parallel/ark_test_heat2D_mri_0.out | 6 +- .../CXX_parallel/ark_test_heat2D_mri_1.out | 6 +- ...rk_test_accumerror_brusselator_20_-4_0.out | 2 +- ...ark_test_accumerror_brusselator_20_3_1.out | 2 +- ...ark_test_accumerror_brusselator_20_5_0.out | 2 +- .../ark_test_accumerror_kpr_20_-4_1.out | 280 +++++++++--------- ..._mriadapt_--rtol_0.000004_--scontrol_0.out | 46 +-- .../CXX_serial/ark_test_dahlquist_mri_-1.out | 170 ++++++++++- .../CXX_serial/ark_test_dahlquist_mri_0.out | 170 ++++++++++- .../CXX_serial/ark_test_dahlquist_mri_1.out | 170 ++++++++++- ...-hs_0.002_--rtol_0.000004_--scontrol_0.out | 46 +-- .../ark_test_slowerror_brusselator.out | 192 ++++++------ .../CXX_serial/ark_test_slowerror_kpr.out | 74 ++--- 33 files changed, 1102 insertions(+), 598 deletions(-) diff --git a/examples/arkode/CXX_parallel/ark_diffusion_reaction_p_--np_2_2_--mri-arkstep.out b/examples/arkode/CXX_parallel/ark_diffusion_reaction_p_--np_2_2_--mri-arkstep.out index ae206aafd4..5f04385a88 100644 --- a/examples/arkode/CXX_parallel/ark_diffusion_reaction_p_--np_2_2_--mri-arkstep.out +++ b/examples/arkode/CXX_parallel/ark_diffusion_reaction_p_--np_2_2_--mri-arkstep.out @@ -51,49 +51,49 @@ t ||u||_rms ---------------------------------------------- 0.000000000000000e+00 3.172144385112383e+00 - 5.000000000000000e-01 3.136741760652088e+00 - 1.000000000000000e+00 3.125063175301122e+00 - 1.500000000000000e+00 3.152612863029649e+00 - 2.000000000000000e+00 3.252046438757223e+00 - 2.500000000000000e+00 3.404770336275880e+00 - 3.000000000000000e+00 3.570197843463192e+00 - 3.500000000000000e+00 3.699979298705992e+00 - 4.000000000000000e+00 3.694673743577147e+00 - 4.500000000000000e+00 3.628192807357139e+00 - 5.000000000000000e+00 3.475181871691853e+00 - 5.500000000000000e+00 3.343883541753708e+00 - 6.000000000000000e+00 3.234020189727759e+00 - 6.500000000000000e+00 3.082396969215168e+00 - 7.000000000000000e+00 2.890645348225157e+00 - 7.500000000000000e+00 2.837264086636537e+00 - 8.000000000000000e+00 2.898204389104409e+00 - 8.500000000000000e+00 3.140043837970826e+00 - 9.000000000000000e+00 3.442234882231944e+00 - 9.500000000000000e+00 3.740410418605710e+00 - 1.000000000000000e+01 4.014486526389547e+00 + 5.000000000000000e-01 3.136716116752151e+00 + 1.000000000000000e+00 3.125028912300580e+00 + 1.500000000000000e+00 3.152560626843121e+00 + 2.000000000000000e+00 3.251993026870305e+00 + 2.500000000000000e+00 3.404745650420647e+00 + 3.000000000000000e+00 3.570247335718721e+00 + 3.500000000000000e+00 3.700181440066816e+00 + 4.000000000000000e+00 3.695239773881522e+00 + 4.500000000000000e+00 3.628545878812146e+00 + 5.000000000000000e+00 3.475390052955260e+00 + 5.500000000000000e+00 3.343649932324244e+00 + 6.000000000000000e+00 3.233461171842096e+00 + 6.500000000000000e+00 3.081704256364488e+00 + 7.000000000000000e+00 2.889974509887209e+00 + 7.500000000000000e+00 2.836697779989570e+00 + 8.000000000000000e+00 2.897726300079596e+00 + 8.500000000000000e+00 3.139640427884362e+00 + 9.000000000000000e+00 3.441880223463777e+00 + 9.500000000000000e+00 3.740116847697612e+00 + 1.000000000000000e+01 4.014265455712714e+00 ---------------------------------------------- Final integrator statistics: Slow Integrator: Steps = 132 - RHS diffusion = 792 + RHS diffusion = 773 NLS iters = 396 NLS fails = 0 - LS iters = 2633 - LS fails = 1 + LS iters = 2639 + LS fails = 0 LS setups = 0 - LS RHS evals = 2633 - Jv products = 2633 + LS RHS evals = 2639 + Jv products = 2639 Avg NLS iters per step attempt = 3.000000 - Avg LS iters per NLS iter = 6.648990 + Avg LS iters per NLS iter = 6.664141 Preconditioner setups = 0 - Preconditioner solves = 2633 + Preconditioner solves = 2639 Fast Integrator: - Steps = 470 - Step attempts = 470 + Steps = 495 + Step attempts = 495 Error test fails = 0 - RHS reaction = 1827 + RHS reaction = 1902 diff --git a/examples/arkode/CXX_parallel/ark_diffusion_reaction_p_--np_2_2_--mri-cvode-global.out b/examples/arkode/CXX_parallel/ark_diffusion_reaction_p_--np_2_2_--mri-cvode-global.out index 9b913a3b91..1d47d636e7 100644 --- a/examples/arkode/CXX_parallel/ark_diffusion_reaction_p_--np_2_2_--mri-cvode-global.out +++ b/examples/arkode/CXX_parallel/ark_diffusion_reaction_p_--np_2_2_--mri-cvode-global.out @@ -51,46 +51,46 @@ t ||u||_rms ---------------------------------------------- 0.000000000000000e+00 3.172144385112383e+00 - 5.000000000000000e-01 3.136722629465066e+00 - 1.000000000000000e+00 3.125057552024107e+00 - 1.500000000000000e+00 3.152636979017849e+00 - 2.000000000000000e+00 3.252085784090209e+00 - 2.500000000000000e+00 3.404791619294692e+00 - 3.000000000000000e+00 3.570175845435155e+00 - 3.500000000000000e+00 3.699871659893790e+00 - 4.000000000000000e+00 3.694354186527817e+00 - 4.500000000000000e+00 3.627867393042675e+00 - 5.000000000000000e+00 3.474857085470333e+00 - 5.500000000000000e+00 3.343640002216235e+00 - 6.000000000000000e+00 3.233844046127573e+00 - 6.500000000000000e+00 3.082251062694890e+00 - 7.000000000000000e+00 2.890585369424727e+00 - 7.500000000000000e+00 2.837315452756403e+00 - 8.000000000000000e+00 2.898424893360023e+00 - 8.500000000000000e+00 3.140291028418674e+00 - 9.000000000000000e+00 3.442457327179101e+00 - 9.500000000000000e+00 3.740600281376645e+00 - 1.000000000000000e+01 4.014633156501281e+00 + 5.000000000000000e-01 3.136696996015633e+00 + 1.000000000000000e+00 3.125023309552764e+00 + 1.500000000000000e+00 3.152584771052598e+00 + 2.000000000000000e+00 3.252032392844841e+00 + 2.500000000000000e+00 3.404766961732514e+00 + 3.000000000000000e+00 3.570225378226986e+00 + 3.500000000000000e+00 3.700073897359325e+00 + 4.000000000000000e+00 3.694920292161422e+00 + 4.500000000000000e+00 3.628220467849570e+00 + 5.000000000000000e+00 3.475064822948501e+00 + 5.500000000000000e+00 3.343406087685922e+00 + 6.000000000000000e+00 3.233285038314854e+00 + 6.500000000000000e+00 3.081558692824315e+00 + 7.000000000000000e+00 2.889915001737479e+00 + 7.500000000000000e+00 2.836750836297845e+00 + 8.000000000000000e+00 2.897946724170101e+00 + 8.500000000000000e+00 3.139887229890297e+00 + 9.000000000000000e+00 3.442102260946054e+00 + 9.500000000000000e+00 3.740306358594533e+00 + 1.000000000000000e+01 4.014411828428858e+00 ---------------------------------------------- Final integrator statistics: Slow Integrator: Steps = 132 - RHS diffusion = 792 + RHS diffusion = 773 NLS iters = 396 NLS fails = 0 - LS iters = 2641 + LS iters = 2630 LS fails = 0 LS setups = 0 - LS RHS evals = 2641 - Jv products = 2641 + LS RHS evals = 2630 + Jv products = 2630 Avg NLS iters per step attempt = 3.000000 - Avg LS iters per NLS iter = 6.669192 + Avg LS iters per NLS iter = 6.641414 Preconditioner setups = 0 - Preconditioner solves = 2641 + Preconditioner solves = 2630 Fast Integrator: Steps = 2057 diff --git a/examples/arkode/CXX_parallel/ark_diffusion_reaction_p_--np_2_2_--mri-cvode-local.out b/examples/arkode/CXX_parallel/ark_diffusion_reaction_p_--np_2_2_--mri-cvode-local.out index 0dd0389711..395fce5774 100644 --- a/examples/arkode/CXX_parallel/ark_diffusion_reaction_p_--np_2_2_--mri-cvode-local.out +++ b/examples/arkode/CXX_parallel/ark_diffusion_reaction_p_--np_2_2_--mri-cvode-local.out @@ -51,50 +51,50 @@ t ||u||_rms ---------------------------------------------- 0.000000000000000e+00 3.172144385112383e+00 - 5.000000000000000e-01 3.136728141568442e+00 - 1.000000000000000e+00 3.125054078969537e+00 - 1.500000000000000e+00 3.152605475501787e+00 - 2.000000000000000e+00 3.252022913428429e+00 - 2.500000000000000e+00 3.404698680378851e+00 - 3.000000000000000e+00 3.570053730764652e+00 - 3.500000000000000e+00 3.699720763396807e+00 - 4.000000000000000e+00 3.694157931241854e+00 - 4.500000000000000e+00 3.627712125668464e+00 - 5.000000000000000e+00 3.474734466021550e+00 - 5.500000000000000e+00 3.343606933034505e+00 - 6.000000000000000e+00 3.233915506336244e+00 - 6.500000000000000e+00 3.082406527906665e+00 - 7.000000000000000e+00 2.890736516064349e+00 - 7.500000000000000e+00 2.837432528460562e+00 - 8.000000000000000e+00 2.898441248595020e+00 - 8.500000000000000e+00 3.140256919387674e+00 - 9.000000000000000e+00 3.442407086782958e+00 - 9.500000000000000e+00 3.740539247767240e+00 - 1.000000000000000e+01 4.014559182371761e+00 + 5.000000000000000e-01 3.136702506772491e+00 + 1.000000000000000e+00 3.125019831337103e+00 + 1.500000000000000e+00 3.152553269284723e+00 + 2.000000000000000e+00 3.251969494381176e+00 + 2.500000000000000e+00 3.404673933063467e+00 + 3.000000000000000e+00 3.570103152366130e+00 + 3.500000000000000e+00 3.699922896883436e+00 + 4.000000000000000e+00 3.694726101643302e+00 + 4.500000000000000e+00 3.628066610591935e+00 + 5.000000000000000e+00 3.474943316767684e+00 + 5.500000000000000e+00 3.343373209172369e+00 + 6.000000000000000e+00 3.233355958070737e+00 + 6.500000000000000e+00 3.081713311546319e+00 + 7.000000000000000e+00 2.890064956811404e+00 + 7.500000000000000e+00 2.836866861961995e+00 + 8.000000000000000e+00 2.897962217732046e+00 + 8.500000000000000e+00 3.139852442835502e+00 + 9.000000000000000e+00 3.442051478499238e+00 + 9.500000000000000e+00 3.740244912270594e+00 + 1.000000000000000e+01 4.014337597219764e+00 ---------------------------------------------- Final integrator statistics: Slow Integrator: Steps = 132 - RHS diffusion = 792 + RHS diffusion = 773 NLS iters = 396 NLS fails = 0 - LS iters = 2630 + LS iters = 2645 LS fails = 0 LS setups = 0 - LS RHS evals = 2630 - Jv products = 2630 + LS RHS evals = 2645 + Jv products = 2645 Avg NLS iters per step attempt = 3.000000 - Avg LS iters per NLS iter = 6.641414 + Avg LS iters per NLS iter = 6.679293 Preconditioner setups = 0 - Preconditioner solves = 2630 + Preconditioner solves = 2645 Fast Integrator: - Steps = 2002 - Error test fails = 397 + Steps = 2001 + Error test fails = 398 RHS reaction = 4898 NLS iters = 3710 NLS fails = 0 diff --git a/examples/arkode/CXX_parhyp/ark_heat2D_hypre_pfmg_mri_--np_2_2.out b/examples/arkode/CXX_parhyp/ark_heat2D_hypre_pfmg_mri_--np_2_2.out index 5c1a518ea8..f1e49737c7 100644 --- a/examples/arkode/CXX_parhyp/ark_heat2D_hypre_pfmg_mri_--np_2_2.out +++ b/examples/arkode/CXX_parhyp/ark_heat2D_hypre_pfmg_mri_--np_2_2.out @@ -42,16 +42,16 @@ t ||u||_rms ---------------------------------------------- 0.000000000000000e+00 3.691406249999997e-01 - 1.000000000000000e-01 5.162014241947240e-02 - 2.000000000000000e-01 7.426100187263422e-03 - 3.000000000000000e-01 1.067221316468460e-03 - 4.000000000000000e-01 1.533638016722887e-04 - 5.000000000000000e-01 2.203889954704845e-05 - 6.000000000000000e-01 3.167064268518253e-06 - 7.000000000000000e-01 4.551178805373316e-07 - 7.999999999999999e-01 6.540199603778498e-08 - 8.999999999999999e-01 9.398525782915539e-09 - 1.000000000000000e+00 1.350608880519736e-09 + 1.000000000000000e-01 5.162014241945451e-02 + 2.000000000000000e-01 7.426100187258647e-03 + 3.000000000000000e-01 1.067221316468833e-03 + 4.000000000000000e-01 1.533638016725418e-04 + 5.000000000000000e-01 2.203889954707766e-05 + 6.000000000000000e-01 3.167064268521805e-06 + 7.000000000000000e-01 4.551178805378924e-07 + 7.999999999999999e-01 6.540199603786467e-08 + 8.999999999999999e-01 9.398525782926989e-09 + 1.000000000000000e+00 1.350608880521382e-09 ---------------------------------------------- Final slow integrator statistics: diff --git a/examples/arkode/CXX_serial/ark_kpr_Mt_0_3_0_-10_0.out b/examples/arkode/CXX_serial/ark_kpr_Mt_0_3_0_-10_0.out index e3c31815e3..05da441507 100644 --- a/examples/arkode/CXX_serial/ark_kpr_Mt_0_3_0_-10_0.out +++ b/examples/arkode/CXX_serial/ark_kpr_Mt_0_3_0_-10_0.out @@ -120,7 +120,7 @@ Final Solver Statistics: Total RHS evals: Fe = 671, Fi = 1763 Total mass matrix setups = 504 Total mass matrix solves = 1340 - Total mass times evals = 1259 + Total mass times evals = 1258 Total number of Jacobian evaluations = 7 Total linear solver setups = 18 Total number of Nonlinear iterations = 1092 diff --git a/examples/arkode/CXX_serial/ark_kpr_Mt_0_4_0_-10_0_10_1.out b/examples/arkode/CXX_serial/ark_kpr_Mt_0_4_0_-10_0_10_1.out index 25d972ace0..c87c2ee2c6 100644 --- a/examples/arkode/CXX_serial/ark_kpr_Mt_0_4_0_-10_0_10_1.out +++ b/examples/arkode/CXX_serial/ark_kpr_Mt_0_4_0_-10_0_10_1.out @@ -120,7 +120,7 @@ Final Solver Statistics: Total RHS evals: Fe = 493, Fi = 1082 Total mass matrix setups = 413 Total mass matrix solves = 574 - Total mass times evals = 1079 + Total mass times evals = 1078 Total number of Jacobian evaluations = 12 Total linear solver setups = 21 Total number of Nonlinear iterations = 999 diff --git a/examples/arkode/CXX_serial/ark_kpr_Mt_0_4_0_-10_1_10_1.out b/examples/arkode/CXX_serial/ark_kpr_Mt_0_4_0_-10_1_10_1.out index e28c955d6b..19b9ac273b 100644 --- a/examples/arkode/CXX_serial/ark_kpr_Mt_0_4_0_-10_1_10_1.out +++ b/examples/arkode/CXX_serial/ark_kpr_Mt_0_4_0_-10_1_10_1.out @@ -120,7 +120,7 @@ Final Solver Statistics: Total RHS evals: Fe = 501, Fi = 1738 Total mass matrix setups = 418 Total mass matrix solves = 585 - Total mass times evals = 1735 + Total mass times evals = 1734 Total number of Jacobian evaluations = 145 Total linear solver setups = 150 Total number of Nonlinear iterations = 1652 diff --git a/examples/arkode/CXX_serial/ark_kpr_Mt_0_4_1.out b/examples/arkode/CXX_serial/ark_kpr_Mt_0_4_1.out index a662ca0306..8a5be5e7de 100644 --- a/examples/arkode/CXX_serial/ark_kpr_Mt_0_4_1.out +++ b/examples/arkode/CXX_serial/ark_kpr_Mt_0_4_1.out @@ -120,7 +120,7 @@ Final Solver Statistics: Total RHS evals: Fe = 13787, Fi = 50499 Total mass matrix setups = 12646 Total mass matrix solves = 64284 - Total mass times evals = 2271 + Total mass times evals = 2270 Total number of Jacobian evaluations = 0 Total linear solver setups = 0 Total number of Nonlinear iterations = 36712 diff --git a/examples/arkode/CXX_serial/ark_kpr_Mt_0_5.out b/examples/arkode/CXX_serial/ark_kpr_Mt_0_5.out index 7f9417757d..f9f3c99117 100644 --- a/examples/arkode/CXX_serial/ark_kpr_Mt_0_5.out +++ b/examples/arkode/CXX_serial/ark_kpr_Mt_0_5.out @@ -120,7 +120,7 @@ Final Solver Statistics: Total RHS evals: Fe = 1265, Fi = 4680 Total mass matrix setups = 1121 Total mass matrix solves = 2428 - Total mass times evals = 3559 + Total mass times evals = 3558 Total number of Jacobian evaluations = 204 Total linear solver setups = 214 Total number of Nonlinear iterations = 3415 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 c652708cf1..0a640a7723 100644 --- a/examples/arkode/CXX_serial/ark_kpr_Mt_1_4.out +++ b/examples/arkode/CXX_serial/ark_kpr_Mt_1_4.out @@ -120,7 +120,7 @@ Final Solver Statistics: Total RHS evals: Fe = 0, Fi = 5758 Total mass matrix setups = 1438 Total mass matrix solves = 1438 - Total mass times evals = 4604 + Total mass times evals = 4603 Total number of Jacobian evaluations = 152 Total linear solver setups = 166 Total number of Nonlinear iterations = 4320 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 54a56620ba..2549bfbc67 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 @@ -119,5 +119,5 @@ Final Solver Statistics: Total RHS evals: Fe = 840, Fi = 0 Total mass matrix setups = 672 Total mass matrix solves = 840 - Total mass times evals = 165 + Total mass times evals = 164 Errors: u = 3.7533e-06, v = 2.61601e-07, total = 2.66042e-06 diff --git a/examples/arkode/CXX_serial/ark_kpr_Mt_2_8_0_-10.out b/examples/arkode/CXX_serial/ark_kpr_Mt_2_8_0_-10.out index 09b1fd9f98..5b3c03aa20 100644 --- a/examples/arkode/CXX_serial/ark_kpr_Mt_2_8_0_-10.out +++ b/examples/arkode/CXX_serial/ark_kpr_Mt_2_8_0_-10.out @@ -119,5 +119,5 @@ Final Solver Statistics: Total RHS evals: Fe = 1742, Fi = 0 Total mass matrix setups = 1439 Total mass matrix solves = 1742 - Total mass times evals = 103 + Total mass times evals = 102 Errors: u = 1.83418e-08, v = 2.86413e-09, total = 1.31268e-08 diff --git a/examples/arkode/CXX_serial/ark_kpr_nestedmri.out b/examples/arkode/CXX_serial/ark_kpr_nestedmri.out index 95e0f7c44e..9b76d6015a 100644 --- a/examples/arkode/CXX_serial/ark_kpr_nestedmri.out +++ b/examples/arkode/CXX_serial/ark_kpr_nestedmri.out @@ -20,32 +20,32 @@ Adaptive nested multirate nonlinear Kvaerno-Prothero-Robinson test problem: t u v w uerr verr werr ---------------------------------------------------------------------------- 0.000000 1.581139 1.732051 1.732051 0.00e+00 0.00e+00 0.00e+00 - 0.250000 1.576211 1.693761 1.005220 9.29e-07 5.67e-05 6.93e-05 - 0.500000 1.561599 1.094201 1.236938 6.40e-06 7.10e-05 8.20e-05 - 0.750000 1.538091 1.480215 1.289928 3.15e-06 7.57e-05 4.66e-05 - 1.000000 1.506678 1.658588 1.566388 1.86e-06 8.12e-05 6.89e-06 - 1.250000 1.468874 1.117572 1.128939 4.86e-07 8.50e-05 3.56e-05 - 1.500000 1.426630 1.451349 1.383721 1.73e-07 6.82e-05 3.51e-05 - 1.750000 1.382317 1.731537 1.400664 5.24e-06 1.42e-04 8.50e-05 - 2.000000 1.338583 1.576792 1.004753 9.92e-07 7.73e-05 6.02e-05 - 2.250000 1.298343 1.357630 1.203255 3.15e-05 2.22e-04 3.28e-04 - 2.500000 1.265157 1.111803 1.080348 5.76e-08 2.91e-09 3.16e-07 - 2.750000 1.240078 1.181758 1.688613 3.74e-07 1.13e-07 1.82e-05 - 3.000000 1.226708 1.199800 1.243898 1.03e-07 2.74e-05 1.47e-04 - 3.250000 1.225891 1.336847 1.695845 3.83e-05 4.66e-05 6.62e-05 - 3.500000 1.237704 1.494163 1.577915 5.90e-07 3.39e-07 1.38e-05 - 3.750000 1.260835 1.441462 1.440583 3.72e-05 1.97e-05 1.14e-04 - 4.000000 1.293784 1.067928 1.718725 4.24e-07 1.12e-06 8.69e-06 - 4.250000 1.333018 1.724738 1.003916 2.75e-06 1.16e-05 6.63e-05 - 4.500000 1.376563 1.650128 1.499923 3.22e-07 2.16e-07 8.96e-07 - 4.750000 1.420823 1.555111 1.167594 1.04e-06 5.84e-06 5.16e-06 - 5.000000 1.463470 1.506592 1.644722 6.82e-06 4.07e-05 8.05e-05 + 0.250000 1.576185 1.693772 1.005263 2.68e-05 6.50e-06 7.40e-05 + 0.500000 1.561493 1.094294 1.236926 1.98e-06 4.53e-05 3.20e-05 + 0.750000 1.537292 1.480065 1.289834 8.10e-04 2.26e-04 1.94e-04 + 1.000000 1.506079 1.658256 1.566295 1.75e-07 2.30e-05 6.87e-06 + 1.250000 1.468771 1.117271 1.128804 4.06e-06 1.73e-04 2.48e-05 + 1.500000 1.426610 1.451084 1.383739 1.21e-06 1.17e-04 5.91e-05 + 1.750000 1.382269 1.731247 1.400679 3.60e-06 6.78e-05 9.82e-05 + 2.000000 1.338568 1.577290 1.004829 2.15e-06 5.96e-04 1.62e-04 + 2.250000 1.298417 1.357868 1.203073 6.37e-07 6.53e-07 5.92e-05 + 2.500000 1.264630 1.111890 1.079994 6.16e-06 4.54e-06 1.67e-04 + 2.750000 1.240048 1.181637 1.688472 2.78e-05 1.03e-04 2.38e-04 + 3.000000 1.226780 1.199832 1.243793 2.58e-06 2.08e-05 1.47e-04 + 3.250000 1.225866 1.336964 1.695773 2.72e-06 2.03e-05 3.74e-05 + 3.500000 1.237694 1.494251 1.577827 1.77e-06 5.51e-07 2.05e-05 + 3.750000 1.260876 1.441515 1.440466 2.99e-08 1.89e-06 8.19e-05 + 4.000000 1.294347 1.067920 1.718693 8.82e-04 8.63e-05 1.41e-04 + 4.250000 1.333409 1.724804 1.004034 4.31e-07 6.75e-07 4.49e-05 + 4.500000 1.376493 1.650147 1.499995 5.63e-05 1.87e-05 1.84e-05 + 4.750000 1.420959 1.555056 1.167670 1.39e-04 6.07e-05 2.39e-05 + 5.000000 1.463494 1.506542 1.644772 6.74e-06 1.24e-05 6.69e-05 ---------------------------------------------------------------------------- Final Solver Statistics: - Slow steps = 56 (attempts = 56, fails = 0) - Intermediate steps = 728 (attempts = 806, fails = 78) - Fast steps = 108912 (attempts = 122048, fails = 13136) - u error = 0.000170499, v error = 0.00011944, total error = 0.000173095 - Relative accuracy = 5.36137 - Total RHS evals: Fse = 281, Fsi = 0, Fme = 3953, Fmi = 0, Ff = 597107 + Slow steps = 42 (attempts = 44, fails = 2) + Intermediate steps = 684 (attempts = 837, fails = 153) + Fast steps = 142883 (attempts = 159706, fails = 16823) + u error = 0.000344385, v error = 0.000171906, total error = 0.000253474 + Relative accuracy = 6.8157 + Total RHS evals: Fse = 219, Fsi = 0, Fme = 4033, Fmi = 0, Ff = 781709 diff --git a/examples/arkode/C_serial/ark_brusselator1D_FEM_slu.out b/examples/arkode/C_serial/ark_brusselator1D_FEM_slu.out index 8cae2ef2fe..fae8230195 100644 --- a/examples/arkode/C_serial/ark_brusselator1D_FEM_slu.out +++ b/examples/arkode/C_serial/ark_brusselator1D_FEM_slu.out @@ -115,7 +115,7 @@ Final Solver Statistics: Total RHS evals: Fe = 0, Fi = 1111 Total mass matrix setups = 1 Total mass matrix solves = 193 - Total mass times evals = 1688 + Total mass times evals = 1687 Total linear solver setups = 31 Total number of Jacobian evaluations = 11 Total number of Newton iterations = 1118 diff --git a/examples/arkode/C_serial/ark_brusselator1D_imexmri_2_0.001.out b/examples/arkode/C_serial/ark_brusselator1D_imexmri_2_0.001.out index d8f1801e46..2f5cb90061 100644 --- a/examples/arkode/C_serial/ark_brusselator1D_imexmri_2_0.001.out +++ b/examples/arkode/C_serial/ark_brusselator1D_imexmri_2_0.001.out @@ -30,7 +30,7 @@ Final Solver Statistics: Slow Steps: nsts = 10001 Fast Steps: nstf = 120012 - Total RHS evals: Fs = 68887, Ff = 360046 + Total RHS evals: Fs = 68877, Ff = 360046 Slow Newton iters = 38883 Slow Newton conv fails = 0 Slow Jacobian evals = 501 diff --git a/examples/arkode/C_serial/ark_brusselator1D_imexmri_3_0.001.out b/examples/arkode/C_serial/ark_brusselator1D_imexmri_3_0.001.out index 0e3c13961a..30dba6ddc2 100644 --- a/examples/arkode/C_serial/ark_brusselator1D_imexmri_3_0.001.out +++ b/examples/arkode/C_serial/ark_brusselator1D_imexmri_3_0.001.out @@ -30,7 +30,7 @@ Final Solver Statistics: Slow Steps: nsts = 10001 Fast Steps: nstf = 120012 - Total RHS evals: Fs = 68887, Ff = 840121 + Total RHS evals: Fs = 68877, Ff = 840121 Slow Newton iters = 38883 Slow Newton conv fails = 0 Slow Jacobian evals = 501 diff --git a/examples/arkode/C_serial/ark_kpr_mri_10_4_0.001_-100_100_0.5_1.out b/examples/arkode/C_serial/ark_kpr_mri_10_4_0.001_-100_100_0.5_1.out index 0cec3055ec..4a6b542e90 100644 --- a/examples/arkode/C_serial/ark_kpr_mri_10_4_0.001_-100_100_0.5_1.out +++ b/examples/arkode/C_serial/ark_kpr_mri_10_4_0.001_-100_100_0.5_1.out @@ -26,10 +26,10 @@ Multirate nonlinear Kvaerno-Prothero-Robinson test problem: 1.200000 1.086821 1.677552 9.92e-12 2.03e-12 1.300000 1.064777 1.277775 7.66e-12 2.00e-12 1.400000 1.041625 1.342455 6.65e-12 2.48e-12 - 1.500000 1.017531 1.642940 6.42e-12 5.92e-12 + 1.500000 1.017531 1.642940 6.43e-12 5.92e-12 1.600000 0.992673 1.012112 4.49e-12 3.23e-12 1.700000 0.967253 1.714058 3.11e-12 2.87e-12 - 1.800000 0.941488 1.183867 5.85e-14 3.89e-12 + 1.800000 0.941488 1.183867 5.74e-14 3.89e-12 1.900000 0.915617 1.437465 1.88e-12 5.63e-12 2.000000 0.889903 1.577082 4.65e-12 9.04e-12 2.100000 0.864625 1.056467 6.53e-12 7.20e-12 @@ -39,11 +39,11 @@ Multirate nonlinear Kvaerno-Prothero-Robinson test problem: 2.500000 0.774227 1.496993 1.92e-11 1.10e-11 2.600000 0.756013 1.126857 2.04e-11 1.34e-11 2.700000 0.740246 1.727536 2.11e-11 7.02e-12 - 2.800000 0.727247 1.038393 2.44e-11 6.36e-13 + 2.800000 0.727247 1.038393 2.44e-11 6.35e-13 2.900000 0.717301 1.600759 2.66e-11 1.09e-11 3.000000 0.710636 1.406380 2.78e-11 1.16e-11 3.100000 0.707412 1.214353 2.84e-11 2.03e-11 - 3.200000 0.707709 1.704026 2.84e-11 9.85e-12 + 3.200000 0.707709 1.704026 2.84e-11 9.86e-12 3.300000 0.711520 1.004391 2.77e-11 7.02e-12 3.400000 0.718750 1.661225 2.61e-11 1.05e-11 3.500000 0.729227 1.310102 2.42e-11 1.14e-11 @@ -60,7 +60,7 @@ Multirate nonlinear Kvaerno-Prothero-Robinson test problem: 4.600000 0.971557 1.496974 3.73e-12 1.53e-11 4.700000 0.996898 1.525070 5.90e-12 8.98e-13 4.800000 1.021641 1.101030 7.16e-12 2.06e-12 - 4.900000 1.045589 1.730922 6.81e-12 8.94e-12 + 4.900000 1.045589 1.730922 6.80e-12 8.94e-12 5.000000 1.068565 1.056480 9.34e-12 3.23e-12 ------------------------------------------------------ diff --git a/examples/arkode/C_serial/ark_kpr_mri_5_4_0.001.out b/examples/arkode/C_serial/ark_kpr_mri_5_4_0.001.out index 292e3d4c0a..8e408cac91 100644 --- a/examples/arkode/C_serial/ark_kpr_mri_5_4_0.001.out +++ b/examples/arkode/C_serial/ark_kpr_mri_5_4_0.001.out @@ -21,49 +21,49 @@ Multirate nonlinear Kvaerno-Prothero-Robinson test problem: 0.800000 1.161186 1.374632 1.87e-11 5.82e-12 0.900000 1.144904 1.245763 1.77e-11 5.97e-12 1.000000 1.127010 1.691839 1.66e-11 6.30e-12 - 1.100000 1.107609 1.000489 1.54e-11 2.00e-12 - 1.200000 1.086821 1.677552 1.43e-11 6.20e-12 - 1.300000 1.064777 1.277775 1.29e-11 6.14e-12 - 1.400000 1.041625 1.342455 1.14e-11 1.56e-12 - 1.500000 1.017531 1.642940 9.78e-12 9.89e-12 - 1.600000 0.992673 1.012112 7.92e-12 4.47e-13 - 1.700000 0.967253 1.714058 5.88e-12 6.46e-12 - 1.800000 0.941488 1.183867 3.60e-12 7.16e-12 - 1.900000 0.915617 1.437465 1.07e-12 2.70e-12 - 2.000000 0.889903 1.577082 1.73e-12 1.16e-11 - 2.100000 0.864625 1.056467 4.78e-12 5.16e-12 - 2.200000 0.840089 1.730920 8.10e-12 6.35e-12 - 2.300000 0.816616 1.101047 1.17e-11 4.17e-12 - 2.400000 0.794546 1.525051 1.54e-11 8.29e-12 - 2.500000 0.774227 1.496993 1.93e-11 1.08e-11 - 2.600000 0.756013 1.126857 2.33e-11 1.42e-11 - 2.700000 0.740246 1.727536 2.71e-11 5.47e-12 - 2.800000 0.727247 1.038393 3.06e-11 3.03e-12 - 2.900000 0.717301 1.600759 3.37e-11 1.40e-11 - 3.000000 0.710636 1.406380 3.62e-11 7.68e-12 - 3.100000 0.707412 1.214353 3.78e-11 2.49e-11 - 3.200000 0.707709 1.704026 3.87e-11 4.61e-12 - 3.300000 0.711520 1.004391 3.87e-11 1.29e-11 - 3.400000 0.718750 1.661225 3.78e-11 1.68e-11 - 3.500000 0.729227 1.310102 3.62e-11 4.71e-12 - 3.600000 0.742712 1.310080 3.40e-11 3.30e-11 - 3.700000 0.758914 1.661237 3.14e-11 6.81e-12 - 3.800000 0.777506 1.004387 2.85e-11 2.15e-11 - 3.900000 0.798144 1.704019 2.55e-11 1.30e-11 - 4.000000 0.820474 1.214374 2.24e-11 4.33e-12 - 4.100000 0.844149 1.406358 1.83e-11 3.43e-11 - 4.200000 0.868832 1.600774 1.43e-11 5.29e-12 - 4.300000 0.894204 1.038382 1.03e-11 2.10e-11 - 4.400000 0.919964 1.727533 6.45e-12 8.06e-12 - 4.500000 0.945834 1.126875 2.75e-12 2.24e-12 - 4.600000 0.971557 1.496974 7.37e-13 1.69e-11 - 4.700000 0.996898 1.525070 4.02e-12 2.17e-13 - 4.800000 1.021641 1.101030 7.08e-12 1.01e-11 - 4.900000 1.045589 1.730922 9.91e-12 4.05e-12 + 1.100000 1.107609 1.000489 1.52e-11 2.00e-12 + 1.200000 1.086821 1.677552 1.38e-11 6.20e-12 + 1.300000 1.064777 1.277775 1.22e-11 6.14e-12 + 1.400000 1.041625 1.342455 1.04e-11 1.56e-12 + 1.500000 1.017531 1.642940 8.47e-12 9.89e-12 + 1.600000 0.992673 1.012112 6.30e-12 4.47e-13 + 1.700000 0.967253 1.714058 3.95e-12 6.46e-12 + 1.800000 0.941488 1.183867 1.35e-12 7.16e-12 + 1.900000 0.915617 1.437465 1.47e-12 2.70e-12 + 2.000000 0.889903 1.577082 4.53e-12 1.16e-11 + 2.100000 0.864625 1.056467 7.80e-12 5.16e-12 + 2.200000 0.840089 1.730920 1.13e-11 6.35e-12 + 2.300000 0.816616 1.101047 1.50e-11 4.17e-12 + 2.400000 0.794546 1.525051 1.88e-11 8.29e-12 + 2.500000 0.774227 1.496993 2.27e-11 1.08e-11 + 2.600000 0.756013 1.126857 2.64e-11 1.42e-11 + 2.700000 0.740246 1.727536 3.00e-11 5.47e-12 + 2.800000 0.727247 1.038393 3.32e-11 3.03e-12 + 2.900000 0.717301 1.600759 3.58e-11 1.40e-11 + 3.000000 0.710636 1.406380 3.76e-11 7.68e-12 + 3.100000 0.707412 1.214353 3.86e-11 2.49e-11 + 3.200000 0.707709 1.704026 3.86e-11 4.61e-12 + 3.300000 0.711520 1.004391 3.77e-11 1.29e-11 + 3.400000 0.718750 1.661225 3.59e-11 1.68e-11 + 3.500000 0.729227 1.310102 3.33e-11 4.71e-12 + 3.600000 0.742712 1.310080 3.02e-11 3.30e-11 + 3.700000 0.758914 1.661237 2.66e-11 6.81e-12 + 3.800000 0.777506 1.004387 2.28e-11 2.15e-11 + 3.900000 0.798144 1.704019 1.89e-11 1.30e-11 + 4.000000 0.820474 1.214374 1.51e-11 4.33e-12 + 4.100000 0.844149 1.406358 1.14e-11 3.43e-11 + 4.200000 0.868832 1.600774 7.85e-12 5.29e-12 + 4.300000 0.894204 1.038382 4.53e-12 2.10e-11 + 4.400000 0.919964 1.727533 1.45e-12 8.06e-12 + 4.500000 0.945834 1.126875 1.40e-12 2.24e-12 + 4.600000 0.971557 1.496974 4.01e-12 1.69e-11 + 4.700000 0.996898 1.525070 6.40e-12 2.17e-13 + 4.800000 1.021641 1.101030 8.58e-12 1.01e-11 + 4.900000 1.045589 1.730922 1.06e-11 4.05e-12 5.000000 1.068565 1.056480 1.23e-11 3.61e-12 ------------------------------------------------------ Final Solver Statistics: Steps: nsts = 5000, nstf = 1425000 - u error = 2.136e-11, v error = 1.132e-11, total error = 1.710e-11 + u error = 2.085e-11, v error = 1.132e-11, total error = 1.678e-11 Total RHS evals: Fs = 30001, Ff = 5700050 diff --git a/examples/arkode/C_serial/ark_kpr_mri_6_5_0.001.out b/examples/arkode/C_serial/ark_kpr_mri_6_5_0.001.out index 3ea2bad8da..a60e450a90 100644 --- a/examples/arkode/C_serial/ark_kpr_mri_6_5_0.001.out +++ b/examples/arkode/C_serial/ark_kpr_mri_6_5_0.001.out @@ -21,49 +21,49 @@ Multirate nonlinear Kvaerno-Prothero-Robinson test problem: 0.800000 1.161186 1.374632 3.73e-13 1.48e-13 0.900000 1.144904 1.245763 3.52e-13 3.93e-14 1.000000 1.127010 1.691839 3.32e-13 4.77e-14 - 1.100000 1.107609 1.000489 1.33e-13 4.42e-12 - 1.200000 1.086821 1.677552 1.51e-13 2.80e-13 - 1.300000 1.064777 1.277775 4.36e-13 3.47e-13 - 1.400000 1.041625 1.342455 7.76e-13 4.84e-12 - 1.500000 1.017531 1.642940 1.11e-12 3.64e-12 - 1.600000 0.992673 1.012112 1.47e-12 5.55e-12 - 1.700000 0.967253 1.714058 1.84e-12 7.75e-13 - 1.800000 0.941488 1.183867 2.19e-12 1.87e-12 - 1.900000 0.915617 1.437465 2.55e-12 7.48e-12 - 2.000000 0.889903 1.577082 2.86e-12 7.44e-12 - 2.100000 0.864625 1.056467 3.16e-12 8.63e-12 - 2.200000 0.840089 1.730920 3.42e-12 3.66e-12 - 2.300000 0.816616 1.101047 3.60e-12 2.38e-12 - 2.400000 0.794546 1.525051 3.74e-12 9.12e-12 - 2.500000 0.774227 1.496993 3.76e-12 1.11e-11 - 2.600000 0.756013 1.126857 3.70e-12 1.28e-11 - 2.700000 0.740246 1.727536 3.52e-12 8.05e-12 - 2.800000 0.727247 1.038393 3.21e-12 7.73e-13 - 2.900000 0.717301 1.600759 2.79e-12 8.96e-12 - 3.000000 0.710636 1.406380 2.21e-12 1.40e-11 - 3.100000 0.707412 1.214353 1.52e-12 1.74e-11 - 3.200000 0.707709 1.704026 7.13e-13 1.33e-11 - 3.300000 0.711520 1.004391 2.00e-13 3.30e-12 - 3.400000 0.718750 1.661225 1.16e-12 6.43e-12 - 3.500000 0.729227 1.310102 2.19e-12 1.58e-11 - 3.600000 0.742712 1.310080 3.21e-12 2.14e-11 - 3.700000 0.758914 1.661237 4.24e-12 1.86e-11 - 3.800000 0.777506 1.004387 5.23e-12 9.68e-12 - 3.900000 0.798144 1.704019 6.15e-12 1.34e-12 - 4.000000 0.820474 1.214374 7.00e-12 1.57e-11 - 4.100000 0.844149 1.406358 6.74e-12 2.33e-11 - 4.200000 0.868832 1.600774 6.28e-12 1.56e-11 - 4.300000 0.894204 1.038382 5.68e-12 1.13e-11 - 4.400000 0.919964 1.727533 4.97e-12 7.79e-13 - 4.500000 0.945834 1.126875 4.19e-12 5.77e-12 - 4.600000 0.971557 1.496974 3.36e-12 9.76e-12 - 4.700000 0.996898 1.525070 2.51e-12 6.00e-12 - 4.800000 1.021641 1.101030 1.67e-12 4.81e-12 - 4.900000 1.045589 1.730922 8.58e-13 2.44e-13 + 1.100000 1.107609 1.000489 3.33e-13 4.42e-12 + 1.200000 1.086821 1.677552 2.90e-13 2.80e-13 + 1.300000 1.064777 1.277775 2.74e-13 3.47e-13 + 1.400000 1.041625 1.342455 2.24e-13 4.84e-12 + 1.500000 1.017531 1.642940 1.92e-13 3.64e-12 + 1.600000 0.992673 1.012112 1.52e-13 5.55e-12 + 1.700000 0.967253 1.714058 9.33e-14 7.75e-13 + 1.800000 0.941488 1.183867 5.52e-14 1.87e-12 + 1.900000 0.915617 1.437465 1.53e-14 7.48e-12 + 2.000000 0.889903 1.577082 6.78e-14 7.44e-12 + 2.100000 0.864625 1.056467 1.36e-13 8.63e-12 + 2.200000 0.840089 1.730920 2.16e-13 3.66e-12 + 2.300000 0.816616 1.101047 2.76e-13 2.38e-12 + 2.400000 0.794546 1.525051 3.69e-13 9.12e-12 + 2.500000 0.774227 1.496993 4.38e-13 1.11e-11 + 2.600000 0.756013 1.126857 5.20e-13 1.28e-11 + 2.700000 0.740246 1.727536 5.97e-13 8.05e-12 + 2.800000 0.727247 1.038393 6.51e-13 7.73e-13 + 2.900000 0.717301 1.600759 7.23e-13 8.96e-12 + 3.000000 0.710636 1.406380 7.50e-13 1.40e-11 + 3.100000 0.707412 1.214353 7.81e-13 1.74e-11 + 3.200000 0.707709 1.704026 7.84e-13 1.33e-11 + 3.300000 0.711520 1.004391 7.58e-13 3.30e-12 + 3.400000 0.718750 1.661225 7.40e-13 6.43e-12 + 3.500000 0.729227 1.310102 6.75e-13 1.58e-11 + 3.600000 0.742712 1.310080 6.25e-13 2.14e-11 + 3.700000 0.758914 1.661237 5.52e-13 1.86e-11 + 3.800000 0.777506 1.004387 4.71e-13 9.68e-12 + 3.900000 0.798144 1.704019 4.06e-13 1.34e-12 + 4.000000 0.820474 1.214374 3.13e-13 1.57e-11 + 4.100000 0.844149 1.406358 2.24e-13 2.33e-11 + 4.200000 0.868832 1.600774 1.55e-13 1.56e-11 + 4.300000 0.894204 1.038382 8.57e-14 1.13e-11 + 4.400000 0.919964 1.727533 2.70e-14 7.79e-13 + 4.500000 0.945834 1.126875 3.24e-14 5.77e-12 + 4.600000 0.971557 1.496974 8.40e-14 9.76e-12 + 4.700000 0.996898 1.525070 1.31e-13 6.00e-12 + 4.800000 1.021641 1.101030 1.79e-13 4.81e-12 + 4.900000 1.045589 1.730922 2.13e-13 2.44e-13 5.000000 1.068565 1.056480 2.51e-13 2.92e-13 ------------------------------------------------------ Final Solver Statistics: Steps: nsts = 5000, nstf = 1615000 - u error = 3.075e-12, v error = 8.987e-12, total error = 6.716e-12 + u error = 4.211e-13, v error = 8.987e-12, total error = 6.362e-12 Total RHS evals: Fs = 50051, Ff = 9715100 diff --git a/examples/arkode/C_serial/ark_kpr_mri_8_3_0.001_-100_100_0.5_1.out b/examples/arkode/C_serial/ark_kpr_mri_8_3_0.001_-100_100_0.5_1.out index 18e6e54eaa..85bfb497b6 100644 --- a/examples/arkode/C_serial/ark_kpr_mri_8_3_0.001_-100_100_0.5_1.out +++ b/examples/arkode/C_serial/ark_kpr_mri_8_3_0.001_-100_100_0.5_1.out @@ -13,61 +13,61 @@ Multirate nonlinear Kvaerno-Prothero-Robinson test problem: ------------------------------------------------------ 0.000000 1.224745 1.732051 0.00e+00 0.00e+00 0.100000 1.223725 1.077464 4.02e-10 5.73e-11 - 0.200000 1.220669 1.551800 4.06e-10 1.12e-10 - 0.300000 1.215594 1.467737 3.95e-10 1.60e-10 - 0.400000 1.208524 1.154583 3.88e-10 2.03e-10 - 0.500000 1.199496 1.721908 3.80e-10 2.39e-10 - 0.600000 1.188557 1.023517 3.81e-10 2.70e-10 - 0.700000 1.175764 1.622751 3.29e-10 3.02e-10 - 0.800000 1.161186 1.374632 3.41e-10 3.23e-10 - 0.900000 1.144904 1.245763 3.23e-10 3.41e-10 - 1.000000 1.127010 1.691839 3.03e-10 3.56e-10 - 1.100000 1.107609 1.000489 2.71e-10 3.60e-10 - 1.200000 1.086821 1.677552 2.54e-10 3.60e-10 - 1.300000 1.064777 1.277775 2.27e-10 3.64e-10 - 1.400000 1.041625 1.342455 1.95e-10 3.59e-10 - 1.500000 1.017531 1.642940 1.58e-10 3.46e-10 - 1.600000 0.992673 1.012112 1.21e-10 3.37e-10 - 1.700000 0.967253 1.714058 7.81e-11 3.14e-10 - 1.800000 0.941488 1.183867 3.34e-11 2.95e-10 - 1.900000 0.915617 1.437465 1.78e-11 2.65e-10 - 2.000000 0.889903 1.577082 7.23e-11 2.30e-10 - 2.100000 0.864625 1.056467 1.32e-10 1.95e-10 - 2.200000 0.840089 1.730920 1.96e-10 1.46e-10 - 2.300000 0.816616 1.101047 2.61e-10 1.01e-10 - 2.400000 0.794546 1.525051 3.30e-10 4.30e-11 - 2.500000 0.774227 1.496993 4.23e-10 3.21e-11 - 2.600000 0.756013 1.126857 4.68e-10 9.29e-11 - 2.700000 0.740246 1.727536 5.36e-10 1.64e-10 - 2.800000 0.727247 1.038393 5.93e-10 2.29e-10 - 2.900000 0.717301 1.600759 5.07e-10 3.03e-10 - 3.000000 0.710636 1.406380 6.73e-10 3.71e-10 - 3.100000 0.707412 1.214353 6.94e-10 4.36e-10 - 3.200000 0.707709 1.704026 6.99e-10 5.01e-10 - 3.300000 0.711520 1.004391 6.73e-10 5.49e-10 - 3.400000 0.718750 1.661225 6.52e-10 5.98e-10 - 3.500000 0.729227 1.310102 6.01e-10 6.31e-10 - 3.600000 0.742712 1.310080 5.52e-10 6.56e-10 - 3.700000 0.758914 1.661237 4.89e-10 6.71e-10 - 3.800000 0.777506 1.004387 4.21e-10 6.69e-10 - 3.900000 0.798144 1.704019 3.62e-10 6.66e-10 - 4.000000 0.820474 1.214374 2.84e-10 6.45e-10 - 4.100000 0.844149 1.406358 3.43e-10 6.14e-10 - 4.200000 0.868832 1.600774 1.51e-10 5.74e-10 - 4.300000 0.894204 1.038382 9.08e-11 5.56e-10 - 4.400000 0.919964 1.727533 4.15e-11 5.08e-10 - 4.500000 0.945834 1.126875 1.62e-11 4.80e-10 - 4.600000 0.971557 1.496974 6.43e-11 4.14e-10 - 4.700000 0.996898 1.525070 1.06e-10 3.63e-10 - 4.800000 1.021641 1.101030 1.47e-10 3.24e-10 - 4.900000 1.045589 1.730922 1.85e-10 2.45e-10 - 5.000000 1.068565 1.056480 3.43e-10 2.17e-10 + 0.200000 1.220669 1.551800 4.06e-10 1.04e-10 + 0.300000 1.215594 1.467737 3.94e-10 1.46e-10 + 0.400000 1.208524 1.154583 3.88e-10 1.81e-10 + 0.500000 1.199496 1.721908 3.80e-10 2.13e-10 + 0.600000 1.188557 1.023517 3.81e-10 2.48e-10 + 0.700000 1.175764 1.622751 3.29e-10 2.78e-10 + 0.800000 1.161186 1.374632 3.41e-10 2.97e-10 + 0.900000 1.144904 1.245763 3.23e-10 3.04e-10 + 1.000000 1.127010 1.691839 3.02e-10 3.14e-10 + 1.100000 1.107609 1.000489 2.71e-10 3.23e-10 + 1.200000 1.086821 1.677552 2.54e-10 3.27e-10 + 1.300000 1.064777 1.277775 2.27e-10 3.33e-10 + 1.400000 1.041625 1.342455 1.95e-10 3.31e-10 + 1.500000 1.017531 1.642940 1.57e-10 3.21e-10 + 1.600000 0.992673 1.012112 1.21e-10 3.14e-10 + 1.700000 0.967253 1.714058 7.79e-11 2.93e-10 + 1.800000 0.941488 1.183867 3.33e-11 2.75e-10 + 1.900000 0.915617 1.437465 1.79e-11 2.47e-10 + 2.000000 0.889903 1.577082 7.24e-11 2.14e-10 + 2.100000 0.864625 1.056467 1.32e-10 1.79e-10 + 2.200000 0.840089 1.730920 1.96e-10 1.31e-10 + 2.300000 0.816616 1.101047 2.61e-10 8.71e-11 + 2.400000 0.794546 1.525051 3.30e-10 3.06e-11 + 2.500000 0.774227 1.496993 4.23e-10 4.32e-11 + 2.600000 0.756013 1.126857 4.68e-10 1.03e-10 + 2.700000 0.740246 1.727536 5.36e-10 1.73e-10 + 2.800000 0.727247 1.038393 5.93e-10 2.37e-10 + 2.900000 0.717301 1.600759 5.07e-10 3.10e-10 + 3.000000 0.710636 1.406380 6.73e-10 3.77e-10 + 3.100000 0.707412 1.214353 6.94e-10 4.43e-10 + 3.200000 0.707709 1.704026 6.99e-10 5.06e-10 + 3.300000 0.711520 1.004391 6.73e-10 5.54e-10 + 3.400000 0.718750 1.661225 6.52e-10 6.03e-10 + 3.500000 0.729227 1.310102 6.01e-10 6.37e-10 + 3.600000 0.742712 1.310080 5.52e-10 6.60e-10 + 3.700000 0.758914 1.661237 4.89e-10 6.76e-10 + 3.800000 0.777506 1.004387 4.21e-10 6.73e-10 + 3.900000 0.798144 1.704019 3.62e-10 6.70e-10 + 4.000000 0.820474 1.214374 2.84e-10 6.49e-10 + 4.100000 0.844149 1.406358 3.44e-10 6.18e-10 + 4.200000 0.868832 1.600774 1.51e-10 5.77e-10 + 4.300000 0.894204 1.038382 9.09e-11 5.60e-10 + 4.400000 0.919964 1.727533 4.16e-11 5.12e-10 + 4.500000 0.945834 1.126875 1.62e-11 4.84e-10 + 4.600000 0.971557 1.496974 6.43e-11 4.18e-10 + 4.700000 0.996898 1.525070 1.06e-10 3.66e-10 + 4.800000 1.021641 1.101030 1.47e-10 3.27e-10 + 4.900000 1.045589 1.730922 1.85e-10 2.48e-10 + 5.000000 1.068565 1.056480 3.43e-10 2.19e-10 ------------------------------------------------------ Final Solver Statistics: Steps: nsts = 5000, nstf = 510000 - u error = 3.764e-10, v error = 3.952e-10, total error = 3.859e-10 - Total RHS evals: Fs = 35313, Ff = 1530050 + u error = 3.763e-10, v error = 3.905e-10, total error = 3.835e-10 + Total RHS evals: Fs = 35263, Ff = 1530050 Slow Newton iters = 30312 Slow Newton conv fails = 0 Slow Jacobian evals = 250 diff --git a/test/unit_tests/arkode/CXX_parallel/ark_test_heat2D_mri_0.out b/test/unit_tests/arkode/CXX_parallel/ark_test_heat2D_mri_0.out index a78e16c9fd..9ca728ed54 100644 --- a/test/unit_tests/arkode/CXX_parallel/ark_test_heat2D_mri_0.out +++ b/test/unit_tests/arkode/CXX_parallel/ark_test_heat2D_mri_0.out @@ -28,10 +28,10 @@ MRIStep Solver Statistics: Internal solver steps = 1000 Total RHS evals: Fe = 2769 Total linear solver setups = 50 - Total linear iterations = 6250 - Total number of Jacobian-vector products = 6250 + Total linear iterations = 6234 + Total number of Jacobian-vector products = 6234 Total number of Preconditioner setups = 50 - Total number of Preconditioner solves = 6250 + Total number of Preconditioner solves = 6234 Total number of linear solver convergence failures = 0 Total number of Newton iterations = 1768 Total number of nonlinear solver convergence failures = 0 diff --git a/test/unit_tests/arkode/CXX_parallel/ark_test_heat2D_mri_1.out b/test/unit_tests/arkode/CXX_parallel/ark_test_heat2D_mri_1.out index bbf3267c89..d0a8f738c5 100644 --- a/test/unit_tests/arkode/CXX_parallel/ark_test_heat2D_mri_1.out +++ b/test/unit_tests/arkode/CXX_parallel/ark_test_heat2D_mri_1.out @@ -28,10 +28,10 @@ MRIStep Solver Statistics: Internal solver steps = 1000 Total RHS evals: Fe = 2001 Total linear solver setups = 1 - Total linear iterations = 4731 - Total number of Jacobian-vector products = 4731 + Total linear iterations = 4722 + Total number of Jacobian-vector products = 4722 Total number of Preconditioner setups = 1 - Total number of Preconditioner solves = 4731 + Total number of Preconditioner solves = 4722 Total number of linear solver convergence failures = 0 Total number of Newton iterations = 1000 Total number of nonlinear solver convergence failures = 0 diff --git a/test/unit_tests/arkode/CXX_serial/ark_test_accumerror_brusselator_20_-4_0.out b/test/unit_tests/arkode/CXX_serial/ark_test_accumerror_brusselator_20_-4_0.out index 2b1c57ba2c..6d03997f5a 100644 --- a/test/unit_tests/arkode/CXX_serial/ark_test_accumerror_brusselator_20_-4_0.out +++ b/test/unit_tests/arkode/CXX_serial/ark_test_accumerror_brusselator_20_-4_0.out @@ -3,7 +3,7 @@ Accumulated error estimation test (stiff Brusselator ODE problem): time domain: (0,10] partition size = 20 initial conditions: u0 = 1.2, v0 = 3.1, w0 = 3 - problem parameters: a = 0, b = 0, ep = 0.0004 + problem parameters: a = 1, b = 3.5, ep = 0.0004 DIRK solver, order = 4 Fixed-step runs: diff --git a/test/unit_tests/arkode/CXX_serial/ark_test_accumerror_brusselator_20_3_1.out b/test/unit_tests/arkode/CXX_serial/ark_test_accumerror_brusselator_20_3_1.out index 9ae57cd52a..3c3e7807b2 100644 --- a/test/unit_tests/arkode/CXX_serial/ark_test_accumerror_brusselator_20_3_1.out +++ b/test/unit_tests/arkode/CXX_serial/ark_test_accumerror_brusselator_20_3_1.out @@ -3,7 +3,7 @@ Accumulated error estimation test (stiff Brusselator ODE problem): time domain: (0,10] partition size = 20 initial conditions: u0 = 1.2, v0 = 3.1, w0 = 3 - problem parameters: a = 0, b = 0, ep = 0.0004 + problem parameters: a = 1, b = 3.5, ep = 0.0004 ERK solver, order = 3 Adaptive-step runs: diff --git a/test/unit_tests/arkode/CXX_serial/ark_test_accumerror_brusselator_20_5_0.out b/test/unit_tests/arkode/CXX_serial/ark_test_accumerror_brusselator_20_5_0.out index bca0f62a7b..f59cdceea8 100644 --- a/test/unit_tests/arkode/CXX_serial/ark_test_accumerror_brusselator_20_5_0.out +++ b/test/unit_tests/arkode/CXX_serial/ark_test_accumerror_brusselator_20_5_0.out @@ -3,7 +3,7 @@ Accumulated error estimation test (stiff Brusselator ODE problem): time domain: (0,10] partition size = 20 initial conditions: u0 = 1.2, v0 = 3.1, w0 = 3 - problem parameters: a = 0, b = 0, ep = 0.0004 + problem parameters: a = 1, b = 3.5, ep = 0.0004 DIRK solver, order = 5 Adaptive-step runs: diff --git a/test/unit_tests/arkode/CXX_serial/ark_test_accumerror_kpr_20_-4_1.out b/test/unit_tests/arkode/CXX_serial/ark_test_accumerror_kpr_20_-4_1.out index 05dbfd356a..dd27b7edcb 100644 --- a/test/unit_tests/arkode/CXX_serial/ark_test_accumerror_kpr_20_-4_1.out +++ b/test/unit_tests/arkode/CXX_serial/ark_test_accumerror_kpr_20_-4_1.out @@ -8,46 +8,46 @@ Accumulated error estimation test (Nonlinear Kvaerno-Prothero-Robinson problem): ERK solver, order = 4 Fixed-step runs: - h 0.005 rk_type 1 order 4 acc 0 t 0.25 dsm 5.99625e-11 dsm_est 7.9246e-10 nsteps 50 - h 0.005 rk_type 1 order 4 acc 0 t 0.5 dsm 1.42974e-10 dsm_est 3.12286e-09 nsteps 50 - h 0.005 rk_type 1 order 4 acc 0 t 0.75 dsm 2.42719e-10 dsm_est 9.28141e-09 nsteps 50 - h 0.005 rk_type 1 order 4 acc 0 t 1 dsm 6.83162e-10 dsm_est 1.26647e-09 nsteps 50 - h 0.005 rk_type 1 order 4 acc 0 t 1.25 dsm 3.14281e-09 dsm_est 2.69129e-08 nsteps 50 + h 0.005 rk_type 1 order 4 acc 0 t 0.25 dsm 5.99625e-11 dsm_est 2.97934e-09 nsteps 50 + h 0.005 rk_type 1 order 4 acc 0 t 0.5 dsm 1.42974e-10 dsm_est 1.09464e-08 nsteps 50 + h 0.005 rk_type 1 order 4 acc 0 t 0.75 dsm 2.42719e-10 dsm_est 4.48851e-08 nsteps 50 + h 0.005 rk_type 1 order 4 acc 0 t 1 dsm 6.83162e-10 dsm_est 2.52438e-08 nsteps 50 + h 0.005 rk_type 1 order 4 acc 0 t 1.25 dsm 3.14281e-09 dsm_est 6.51615e-07 nsteps 50 h 0.005 rk_type 1 order 4 acc 0 t 1.5 dsm 4.52762e-09 dsm_est 3.9027e-07 nsteps 50 - h 0.005 rk_type 1 order 4 acc 0 t 1.75 dsm 4.7305e-10 dsm_est 9.96347e-08 nsteps 50 + h 0.005 rk_type 1 order 4 acc 0 t 1.75 dsm 4.7305e-10 dsm_est 1.03348e-06 nsteps 50 h 0.005 rk_type 1 order 4 acc 0 t 2 dsm 1.22724e-09 dsm_est 2.15168e-07 nsteps 50 - h 0.005 rk_type 1 order 4 acc 0 t 2.25 dsm 2.1725e-10 dsm_est 3.71812e-09 nsteps 50 - h 0.005 rk_type 1 order 4 acc 0 t 2.5 dsm 1.44845e-10 dsm_est 1.77141e-09 nsteps 50 - h 0.005 rk_type 1 order 4 acc 0 t 2.75 dsm 1.45894e-10 dsm_est 7.14815e-09 nsteps 50 + h 0.005 rk_type 1 order 4 acc 0 t 2.25 dsm 2.1725e-10 dsm_est 4.54458e-08 nsteps 50 + h 0.005 rk_type 1 order 4 acc 0 t 2.5 dsm 1.44845e-10 dsm_est 1.64155e-08 nsteps 50 + h 0.005 rk_type 1 order 4 acc 0 t 2.75 dsm 1.45894e-10 dsm_est 1.12159e-08 nsteps 50 h 0.005 rk_type 1 order 4 acc 0 t 3 dsm 2.11123e-10 dsm_est 1.10902e-08 nsteps 50 - h 0.005 rk_type 1 order 4 acc 0 t 3.25 dsm 2.34671e-10 dsm_est 3.64116e-09 nsteps 50 - h 0.005 rk_type 1 order 4 acc 0 t 3.5 dsm 1.99557e-10 dsm_est 3.27436e-10 nsteps 50 + h 0.005 rk_type 1 order 4 acc 0 t 3.25 dsm 2.34671e-10 dsm_est 3.64366e-09 nsteps 50 + h 0.005 rk_type 1 order 4 acc 0 t 3.5 dsm 1.99557e-10 dsm_est 7.94986e-10 nsteps 50 h 0.005 rk_type 1 order 4 acc 0 t 3.75 dsm 1.51624e-10 dsm_est 7.64317e-10 nsteps 50 - h 0.005 rk_type 1 order 4 acc 0 t 4 dsm 9.7978e-11 dsm_est 1.91259e-10 nsteps 50 - h 0.005 rk_type 1 order 4 acc 0 t 4.25 dsm 3.36113e-11 dsm_est 1.88739e-09 nsteps 50 - h 0.005 rk_type 1 order 4 acc 0 t 4.5 dsm 7.15711e-11 dsm_est 1.40472e-10 nsteps 50 + h 0.005 rk_type 1 order 4 acc 0 t 4 dsm 9.7978e-11 dsm_est 1.84333e-09 nsteps 50 + h 0.005 rk_type 1 order 4 acc 0 t 4.25 dsm 3.36113e-11 dsm_est 3.03774e-09 nsteps 50 + h 0.005 rk_type 1 order 4 acc 0 t 4.5 dsm 7.15711e-11 dsm_est 1.1807e-08 nsteps 50 h 0.005 rk_type 1 order 4 acc 0 t 4.75 dsm 3.79788e-11 dsm_est 3.66885e-09 nsteps 50 h 0.005 rk_type 1 order 4 acc 0 t 5 dsm 4.13058e-11 dsm_est 1.68612e-09 nsteps 50 - h 0.005 rk_type 1 order 4 acc 1 t 0.25 dsm 5.99625e-11 dsm_est 1.58492e-11 nsteps 50 - h 0.005 rk_type 1 order 4 acc 1 t 0.5 dsm 1.42974e-10 dsm_est 6.24572e-11 nsteps 50 - h 0.005 rk_type 1 order 4 acc 1 t 0.75 dsm 2.42719e-10 dsm_est 1.85628e-10 nsteps 50 - h 0.005 rk_type 1 order 4 acc 1 t 1 dsm 6.83162e-10 dsm_est 2.53294e-11 nsteps 50 - h 0.005 rk_type 1 order 4 acc 1 t 1.25 dsm 3.14281e-09 dsm_est 5.38258e-10 nsteps 50 - h 0.005 rk_type 1 order 4 acc 1 t 1.5 dsm 4.52762e-09 dsm_est 7.8054e-09 nsteps 50 - h 0.005 rk_type 1 order 4 acc 1 t 1.75 dsm 4.7305e-10 dsm_est 1.99269e-09 nsteps 50 - h 0.005 rk_type 1 order 4 acc 1 t 2 dsm 1.22724e-09 dsm_est 4.30336e-09 nsteps 50 - h 0.005 rk_type 1 order 4 acc 1 t 2.25 dsm 2.1725e-10 dsm_est 7.43624e-11 nsteps 50 - h 0.005 rk_type 1 order 4 acc 1 t 2.5 dsm 1.44845e-10 dsm_est 3.54281e-11 nsteps 50 - h 0.005 rk_type 1 order 4 acc 1 t 2.75 dsm 1.45894e-10 dsm_est 1.42963e-10 nsteps 50 - h 0.005 rk_type 1 order 4 acc 1 t 3 dsm 2.11123e-10 dsm_est 2.21804e-10 nsteps 50 - h 0.005 rk_type 1 order 4 acc 1 t 3.25 dsm 2.34671e-10 dsm_est 7.28233e-11 nsteps 50 - h 0.005 rk_type 1 order 4 acc 1 t 3.5 dsm 1.99557e-10 dsm_est 6.54871e-12 nsteps 50 - h 0.005 rk_type 1 order 4 acc 1 t 3.75 dsm 1.51624e-10 dsm_est 1.52863e-11 nsteps 50 - h 0.005 rk_type 1 order 4 acc 1 t 4 dsm 9.7978e-11 dsm_est 3.82518e-12 nsteps 50 - h 0.005 rk_type 1 order 4 acc 1 t 4.25 dsm 3.36113e-11 dsm_est 3.77478e-11 nsteps 50 - h 0.005 rk_type 1 order 4 acc 1 t 4.5 dsm 7.15711e-11 dsm_est 2.80944e-12 nsteps 50 - h 0.005 rk_type 1 order 4 acc 1 t 4.75 dsm 3.79788e-11 dsm_est 7.33771e-11 nsteps 50 - h 0.005 rk_type 1 order 4 acc 1 t 5 dsm 4.13058e-11 dsm_est 3.37224e-11 nsteps 50 + h 0.005 rk_type 1 order 4 acc 1 t 0.25 dsm 5.99625e-11 dsm_est 1.385e-09 nsteps 50 + h 0.005 rk_type 1 order 4 acc 1 t 0.5 dsm 1.42974e-10 dsm_est 6.89431e-09 nsteps 50 + h 0.005 rk_type 1 order 4 acc 1 t 0.75 dsm 2.42719e-10 dsm_est 2.22335e-08 nsteps 50 + h 0.005 rk_type 1 order 4 acc 1 t 1 dsm 6.83162e-10 dsm_est 7.93747e-09 nsteps 50 + h 0.005 rk_type 1 order 4 acc 1 t 1.25 dsm 3.14281e-09 dsm_est 1.90356e-07 nsteps 50 + h 0.005 rk_type 1 order 4 acc 1 t 1.5 dsm 4.52762e-09 dsm_est 9.7768e-08 nsteps 50 + h 0.005 rk_type 1 order 4 acc 1 t 1.75 dsm 4.7305e-10 dsm_est 3.16168e-07 nsteps 50 + h 0.005 rk_type 1 order 4 acc 1 t 2 dsm 1.22724e-09 dsm_est 6.44894e-08 nsteps 50 + h 0.005 rk_type 1 order 4 acc 1 t 2.25 dsm 2.1725e-10 dsm_est 2.74317e-08 nsteps 50 + h 0.005 rk_type 1 order 4 acc 1 t 2.5 dsm 1.44845e-10 dsm_est 1.14324e-08 nsteps 50 + h 0.005 rk_type 1 order 4 acc 1 t 2.75 dsm 1.45894e-10 dsm_est 5.78824e-09 nsteps 50 + h 0.005 rk_type 1 order 4 acc 1 t 3 dsm 2.11123e-10 dsm_est 4.48643e-09 nsteps 50 + h 0.005 rk_type 1 order 4 acc 1 t 3.25 dsm 2.34671e-10 dsm_est 2.20404e-09 nsteps 50 + h 0.005 rk_type 1 order 4 acc 1 t 3.5 dsm 1.99557e-10 dsm_est 5.41306e-10 nsteps 50 + h 0.005 rk_type 1 order 4 acc 1 t 3.75 dsm 1.51624e-10 dsm_est 4.03452e-10 nsteps 50 + h 0.005 rk_type 1 order 4 acc 1 t 4 dsm 9.7978e-11 dsm_est 9.52633e-10 nsteps 50 + h 0.005 rk_type 1 order 4 acc 1 t 4.25 dsm 3.36113e-11 dsm_est 2.41808e-09 nsteps 50 + h 0.005 rk_type 1 order 4 acc 1 t 4.5 dsm 7.15711e-11 dsm_est 7.4142e-09 nsteps 50 + h 0.005 rk_type 1 order 4 acc 1 t 4.75 dsm 3.79788e-11 dsm_est 1.75558e-09 nsteps 50 + h 0.005 rk_type 1 order 4 acc 1 t 5 dsm 4.13058e-11 dsm_est 1.22629e-09 nsteps 50 h 0.005 rk_type 1 order 4 acc 2 t 0.25 dsm 5.99625e-11 dsm_est 9.19534e-10 nsteps 75 h 0.005 rk_type 1 order 4 acc 2 t 0.5 dsm 1.42974e-10 dsm_est 2.10629e-09 nsteps 75 h 0.005 rk_type 1 order 4 acc 2 t 0.75 dsm 2.42719e-10 dsm_est 3.82746e-09 nsteps 75 @@ -68,46 +68,46 @@ Fixed-step runs: h 0.005 rk_type 1 order 4 acc 2 t 4.5 dsm 7.15711e-11 dsm_est 1.10419e-09 nsteps 75 h 0.005 rk_type 1 order 4 acc 2 t 4.75 dsm 3.79788e-11 dsm_est 5.88316e-10 nsteps 75 h 0.005 rk_type 1 order 4 acc 2 t 5 dsm 4.13058e-11 dsm_est 6.25891e-10 nsteps 75 - h 0.00125 rk_type 1 order 4 acc 0 t 0.25 dsm 2.30499e-13 dsm_est 3.07508e-12 nsteps 200 - h 0.00125 rk_type 1 order 4 acc 0 t 0.5 dsm 5.68219e-13 dsm_est 1.20112e-11 nsteps 200 - h 0.00125 rk_type 1 order 4 acc 0 t 0.75 dsm 9.09327e-13 dsm_est 3.22789e-11 nsteps 200 - h 0.00125 rk_type 1 order 4 acc 0 t 1 dsm 2.66412e-12 dsm_est 4.42072e-12 nsteps 200 - h 0.00125 rk_type 1 order 4 acc 0 t 1.25 dsm 1.30178e-11 dsm_est 1.0259e-10 nsteps 200 + h 0.00125 rk_type 1 order 4 acc 0 t 0.25 dsm 2.30499e-13 dsm_est 1.18706e-11 nsteps 200 + h 0.00125 rk_type 1 order 4 acc 0 t 0.5 dsm 5.68219e-13 dsm_est 4.29143e-11 nsteps 200 + h 0.00125 rk_type 1 order 4 acc 0 t 0.75 dsm 9.09327e-13 dsm_est 1.75788e-10 nsteps 200 + h 0.00125 rk_type 1 order 4 acc 0 t 1 dsm 2.66412e-12 dsm_est 1.00941e-10 nsteps 200 + h 0.00125 rk_type 1 order 4 acc 0 t 1.25 dsm 1.30178e-11 dsm_est 2.55862e-09 nsteps 200 h 0.00125 rk_type 1 order 4 acc 0 t 1.5 dsm 1.73534e-11 dsm_est 1.64905e-09 nsteps 200 - h 0.00125 rk_type 1 order 4 acc 0 t 1.75 dsm 3.44384e-12 dsm_est 3.87489e-10 nsteps 200 + h 0.00125 rk_type 1 order 4 acc 0 t 1.75 dsm 3.44384e-12 dsm_est 4.05424e-09 nsteps 200 h 0.00125 rk_type 1 order 4 acc 0 t 2 dsm 4.73982e-12 dsm_est 8.44242e-10 nsteps 200 - h 0.00125 rk_type 1 order 4 acc 0 t 2.25 dsm 8.24836e-13 dsm_est 1.15395e-11 nsteps 200 - h 0.00125 rk_type 1 order 4 acc 0 t 2.5 dsm 5.58183e-13 dsm_est 1.08294e-11 nsteps 200 - h 0.00125 rk_type 1 order 4 acc 0 t 2.75 dsm 5.66294e-13 dsm_est 2.82685e-11 nsteps 200 + h 0.00125 rk_type 1 order 4 acc 0 t 2.25 dsm 8.24836e-13 dsm_est 1.78198e-10 nsteps 200 + h 0.00125 rk_type 1 order 4 acc 0 t 2.5 dsm 5.58183e-13 dsm_est 6.41367e-11 nsteps 200 + h 0.00125 rk_type 1 order 4 acc 0 t 2.75 dsm 5.66294e-13 dsm_est 4.38146e-11 nsteps 200 h 0.00125 rk_type 1 order 4 acc 0 t 3 dsm 8.06614e-13 dsm_est 4.34752e-11 nsteps 200 - h 0.00125 rk_type 1 order 4 acc 0 t 3.25 dsm 8.98387e-13 dsm_est 1.4135e-11 nsteps 200 - h 0.00125 rk_type 1 order 4 acc 0 t 3.5 dsm 7.63217e-13 dsm_est 1.35855e-12 nsteps 200 + h 0.00125 rk_type 1 order 4 acc 0 t 3.25 dsm 8.98387e-13 dsm_est 1.416e-11 nsteps 200 + h 0.00125 rk_type 1 order 4 acc 0 t 3.5 dsm 7.63217e-13 dsm_est 3.10184e-12 nsteps 200 h 0.00125 rk_type 1 order 4 acc 0 t 3.75 dsm 5.78309e-13 dsm_est 2.99367e-12 nsteps 200 - h 0.00125 rk_type 1 order 4 acc 0 t 4 dsm 3.75531e-13 dsm_est 6.93024e-13 nsteps 200 - h 0.00125 rk_type 1 order 4 acc 0 t 4.25 dsm 1.33194e-13 dsm_est 7.31752e-12 nsteps 200 - h 0.00125 rk_type 1 order 4 acc 0 t 4.5 dsm 2.44986e-13 dsm_est 1.08546e-12 nsteps 200 + h 0.00125 rk_type 1 order 4 acc 0 t 4 dsm 3.75531e-13 dsm_est 7.27428e-12 nsteps 200 + h 0.00125 rk_type 1 order 4 acc 0 t 4.25 dsm 1.33194e-13 dsm_est 1.19044e-11 nsteps 200 + h 0.00125 rk_type 1 order 4 acc 0 t 4.5 dsm 2.44986e-13 dsm_est 4.62152e-11 nsteps 200 h 0.00125 rk_type 1 order 4 acc 0 t 4.75 dsm 1.41286e-13 dsm_est 1.51237e-11 nsteps 200 h 0.00125 rk_type 1 order 4 acc 0 t 5 dsm 1.73009e-13 dsm_est 6.57848e-12 nsteps 200 - h 0.00125 rk_type 1 order 4 acc 1 t 0.25 dsm 2.30499e-13 dsm_est 1.53754e-14 nsteps 200 - h 0.00125 rk_type 1 order 4 acc 1 t 0.5 dsm 5.68219e-13 dsm_est 6.0056e-14 nsteps 200 - h 0.00125 rk_type 1 order 4 acc 1 t 0.75 dsm 9.09327e-13 dsm_est 1.61395e-13 nsteps 200 - h 0.00125 rk_type 1 order 4 acc 1 t 1 dsm 2.66412e-12 dsm_est 2.21036e-14 nsteps 200 - h 0.00125 rk_type 1 order 4 acc 1 t 1.25 dsm 1.30178e-11 dsm_est 5.12948e-13 nsteps 200 - h 0.00125 rk_type 1 order 4 acc 1 t 1.5 dsm 1.73534e-11 dsm_est 8.24527e-12 nsteps 200 - h 0.00125 rk_type 1 order 4 acc 1 t 1.75 dsm 3.44384e-12 dsm_est 1.93745e-12 nsteps 200 - h 0.00125 rk_type 1 order 4 acc 1 t 2 dsm 4.73982e-12 dsm_est 4.22121e-12 nsteps 200 - h 0.00125 rk_type 1 order 4 acc 1 t 2.25 dsm 8.24836e-13 dsm_est 5.76976e-14 nsteps 200 - h 0.00125 rk_type 1 order 4 acc 1 t 2.5 dsm 5.58183e-13 dsm_est 5.4147e-14 nsteps 200 - h 0.00125 rk_type 1 order 4 acc 1 t 2.75 dsm 5.66294e-13 dsm_est 1.41342e-13 nsteps 200 - h 0.00125 rk_type 1 order 4 acc 1 t 3 dsm 8.06614e-13 dsm_est 2.17376e-13 nsteps 200 - h 0.00125 rk_type 1 order 4 acc 1 t 3.25 dsm 8.98387e-13 dsm_est 7.06748e-14 nsteps 200 - h 0.00125 rk_type 1 order 4 acc 1 t 3.5 dsm 7.63217e-13 dsm_est 6.79273e-15 nsteps 200 - h 0.00125 rk_type 1 order 4 acc 1 t 3.75 dsm 5.78309e-13 dsm_est 1.49684e-14 nsteps 200 - h 0.00125 rk_type 1 order 4 acc 1 t 4 dsm 3.75531e-13 dsm_est 3.46512e-15 nsteps 200 - h 0.00125 rk_type 1 order 4 acc 1 t 4.25 dsm 1.33194e-13 dsm_est 3.65876e-14 nsteps 200 - h 0.00125 rk_type 1 order 4 acc 1 t 4.5 dsm 2.44986e-13 dsm_est 5.42731e-15 nsteps 200 - h 0.00125 rk_type 1 order 4 acc 1 t 4.75 dsm 1.41286e-13 dsm_est 7.56183e-14 nsteps 200 - h 0.00125 rk_type 1 order 4 acc 1 t 5 dsm 1.73009e-13 dsm_est 3.28924e-14 nsteps 200 + h 0.00125 rk_type 1 order 4 acc 1 t 0.25 dsm 2.30499e-13 dsm_est 5.41022e-12 nsteps 200 + h 0.00125 rk_type 1 order 4 acc 1 t 0.5 dsm 5.68219e-13 dsm_est 2.70444e-11 nsteps 200 + h 0.00125 rk_type 1 order 4 acc 1 t 0.75 dsm 9.09327e-13 dsm_est 8.70648e-11 nsteps 200 + h 0.00125 rk_type 1 order 4 acc 1 t 1 dsm 2.66412e-12 dsm_est 3.05099e-11 nsteps 200 + h 0.00125 rk_type 1 order 4 acc 1 t 1.25 dsm 1.30178e-11 dsm_est 7.46262e-10 nsteps 200 + h 0.00125 rk_type 1 order 4 acc 1 t 1.5 dsm 1.73534e-11 dsm_est 3.79955e-10 nsteps 200 + h 0.00125 rk_type 1 order 4 acc 1 t 1.75 dsm 3.44384e-12 dsm_est 1.23858e-09 nsteps 200 + h 0.00125 rk_type 1 order 4 acc 1 t 2 dsm 4.73982e-12 dsm_est 2.49903e-10 nsteps 200 + h 0.00125 rk_type 1 order 4 acc 1 t 2.25 dsm 8.24836e-13 dsm_est 1.07376e-10 nsteps 200 + h 0.00125 rk_type 1 order 4 acc 1 t 2.5 dsm 5.58183e-13 dsm_est 4.46515e-11 nsteps 200 + h 0.00125 rk_type 1 order 4 acc 1 t 2.75 dsm 5.66294e-13 dsm_est 2.26208e-11 nsteps 200 + h 0.00125 rk_type 1 order 4 acc 1 t 3 dsm 8.06614e-13 dsm_est 1.751e-11 nsteps 200 + h 0.00125 rk_type 1 order 4 acc 1 t 3.25 dsm 8.98387e-13 dsm_est 8.58119e-12 nsteps 200 + h 0.00125 rk_type 1 order 4 acc 1 t 3.5 dsm 7.63217e-13 dsm_est 2.09827e-12 nsteps 200 + h 0.00125 rk_type 1 order 4 acc 1 t 3.75 dsm 5.78309e-13 dsm_est 1.57035e-12 nsteps 200 + h 0.00125 rk_type 1 order 4 acc 1 t 4 dsm 3.75531e-13 dsm_est 3.71703e-12 nsteps 200 + h 0.00125 rk_type 1 order 4 acc 1 t 4.25 dsm 1.33194e-13 dsm_est 9.47327e-12 nsteps 200 + h 0.00125 rk_type 1 order 4 acc 1 t 4.5 dsm 2.44986e-13 dsm_est 2.90146e-11 nsteps 200 + h 0.00125 rk_type 1 order 4 acc 1 t 4.75 dsm 1.41286e-13 dsm_est 6.83008e-12 nsteps 200 + h 0.00125 rk_type 1 order 4 acc 1 t 5 dsm 1.73009e-13 dsm_est 4.75325e-12 nsteps 200 h 0.00125 rk_type 1 order 4 acc 2 t 0.25 dsm 2.30499e-13 dsm_est 3.47846e-12 nsteps 300 h 0.00125 rk_type 1 order 4 acc 2 t 0.5 dsm 5.68219e-13 dsm_est 8.44621e-12 nsteps 300 h 0.00125 rk_type 1 order 4 acc 2 t 0.75 dsm 9.09327e-13 dsm_est 1.38911e-11 nsteps 300 @@ -128,46 +128,46 @@ Fixed-step runs: h 0.00125 rk_type 1 order 4 acc 2 t 4.5 dsm 2.44986e-13 dsm_est 4.1717e-12 nsteps 300 h 0.00125 rk_type 1 order 4 acc 2 t 4.75 dsm 1.41286e-13 dsm_est 2.17896e-12 nsteps 300 h 0.00125 rk_type 1 order 4 acc 2 t 5 dsm 1.73009e-13 dsm_est 2.38734e-12 nsteps 300 - h 0.0003125 rk_type 1 order 4 acc 0 t 0.25 dsm 9.97977e-16 dsm_est 1.19921e-14 nsteps 800 - h 0.0003125 rk_type 1 order 4 acc 0 t 0.5 dsm 7.34738e-15 dsm_est 4.67384e-14 nsteps 800 - h 0.0003125 rk_type 1 order 4 acc 0 t 0.75 dsm 1.89479e-14 dsm_est 1.22245e-13 nsteps 800 - h 0.0003125 rk_type 1 order 4 acc 0 t 1 dsm 6.41345e-15 dsm_est 1.67508e-14 nsteps 800 - h 0.0003125 rk_type 1 order 4 acc 0 t 1.25 dsm 1.49538e-13 dsm_est 3.98278e-13 nsteps 801 + h 0.0003125 rk_type 1 order 4 acc 0 t 0.25 dsm 9.97977e-16 dsm_est 4.66004e-14 nsteps 800 + h 0.0003125 rk_type 1 order 4 acc 0 t 0.5 dsm 7.34738e-15 dsm_est 1.67783e-13 nsteps 800 + h 0.0003125 rk_type 1 order 4 acc 0 t 0.75 dsm 1.89479e-14 dsm_est 6.87079e-13 nsteps 800 + h 0.0003125 rk_type 1 order 4 acc 0 t 1 dsm 6.41345e-15 dsm_est 3.96662e-13 nsteps 800 + h 0.0003125 rk_type 1 order 4 acc 0 t 1.25 dsm 1.49538e-13 dsm_est 1.00006e-11 nsteps 801 h 0.0003125 rk_type 1 order 4 acc 0 t 1.5 dsm 1.0257e-13 dsm_est 6.56125e-12 nsteps 801 - h 0.0003125 rk_type 1 order 4 acc 0 t 1.75 dsm 4.74681e-14 dsm_est 1.51192e-12 nsteps 801 + h 0.0003125 rk_type 1 order 4 acc 0 t 1.75 dsm 4.74681e-14 dsm_est 1.58483e-11 nsteps 801 h 0.0003125 rk_type 1 order 4 acc 0 t 2 dsm 3.28771e-14 dsm_est 3.30065e-12 nsteps 801 - h 0.0003125 rk_type 1 order 4 acc 0 t 2.25 dsm 2.08777e-13 dsm_est 4.21238e-14 nsteps 800 - h 0.0003125 rk_type 1 order 4 acc 0 t 2.5 dsm 1.03256e-14 dsm_est 4.61805e-14 nsteps 800 - h 0.0003125 rk_type 1 order 4 acc 0 t 2.75 dsm 1.44079e-14 dsm_est 1.10761e-13 nsteps 800 + h 0.0003125 rk_type 1 order 4 acc 0 t 2.25 dsm 2.08777e-13 dsm_est 6.96642e-13 nsteps 800 + h 0.0003125 rk_type 1 order 4 acc 0 t 2.5 dsm 1.03256e-14 dsm_est 2.50524e-13 nsteps 800 + h 0.0003125 rk_type 1 order 4 acc 0 t 2.75 dsm 1.44079e-14 dsm_est 1.71146e-13 nsteps 800 h 0.0003125 rk_type 1 order 4 acc 0 t 3 dsm 6.86653e-14 dsm_est 1.69952e-13 nsteps 800 - h 0.0003125 rk_type 1 order 4 acc 0 t 3.25 dsm 4.56716e-14 dsm_est 5.51242e-14 nsteps 800 - h 0.0003125 rk_type 1 order 4 acc 0 t 3.5 dsm 1.14798e-14 dsm_est 5.39133e-15 nsteps 800 + h 0.0003125 rk_type 1 order 4 acc 0 t 3.25 dsm 4.56716e-14 dsm_est 5.52408e-14 nsteps 800 + h 0.0003125 rk_type 1 order 4 acc 0 t 3.5 dsm 1.14798e-14 dsm_est 1.21147e-14 nsteps 800 h 0.0003125 rk_type 1 order 4 acc 0 t 3.75 dsm 1.10427e-14 dsm_est 1.17036e-14 nsteps 800 - h 0.0003125 rk_type 1 order 4 acc 0 t 4 dsm 5.31806e-14 dsm_est 2.65473e-15 nsteps 800 - h 0.0003125 rk_type 1 order 4 acc 0 t 4.25 dsm 2.08119e-13 dsm_est 2.85291e-14 nsteps 801 - h 0.0003125 rk_type 1 order 4 acc 0 t 4.5 dsm 1.57233e-14 dsm_est 4.76197e-15 nsteps 801 + h 0.0003125 rk_type 1 order 4 acc 0 t 4 dsm 5.31806e-14 dsm_est 2.84886e-14 nsteps 800 + h 0.0003125 rk_type 1 order 4 acc 0 t 4.25 dsm 2.08119e-13 dsm_est 4.65384e-14 nsteps 801 + h 0.0003125 rk_type 1 order 4 acc 0 t 4.5 dsm 1.57233e-14 dsm_est 1.80608e-13 nsteps 801 h 0.0003125 rk_type 1 order 4 acc 0 t 4.75 dsm 1.39902e-13 dsm_est 5.98529e-14 nsteps 801 h 0.0003125 rk_type 1 order 4 acc 0 t 5 dsm 7.63042e-14 dsm_est 2.56897e-14 nsteps 801 - h 0.0003125 rk_type 1 order 4 acc 1 t 0.25 dsm 9.97977e-16 dsm_est 1.49901e-17 nsteps 800 - h 0.0003125 rk_type 1 order 4 acc 1 t 0.5 dsm 7.34738e-15 dsm_est 5.84231e-17 nsteps 800 - h 0.0003125 rk_type 1 order 4 acc 1 t 0.75 dsm 1.89479e-14 dsm_est 1.52806e-16 nsteps 800 - h 0.0003125 rk_type 1 order 4 acc 1 t 1 dsm 6.41345e-15 dsm_est 2.09385e-17 nsteps 800 - h 0.0003125 rk_type 1 order 4 acc 1 t 1.25 dsm 1.49538e-13 dsm_est 4.97226e-16 nsteps 801 - h 0.0003125 rk_type 1 order 4 acc 1 t 1.5 dsm 1.0257e-13 dsm_est 8.19133e-15 nsteps 801 - h 0.0003125 rk_type 1 order 4 acc 1 t 1.75 dsm 4.74681e-14 dsm_est 1.88754e-15 nsteps 801 - h 0.0003125 rk_type 1 order 4 acc 1 t 2 dsm 3.28771e-14 dsm_est 4.12066e-15 nsteps 801 - h 0.0003125 rk_type 1 order 4 acc 1 t 2.25 dsm 2.08777e-13 dsm_est 5.26547e-17 nsteps 800 - h 0.0003125 rk_type 1 order 4 acc 1 t 2.5 dsm 1.03256e-14 dsm_est 5.77257e-17 nsteps 800 - h 0.0003125 rk_type 1 order 4 acc 1 t 2.75 dsm 1.44079e-14 dsm_est 1.38452e-16 nsteps 800 - h 0.0003125 rk_type 1 order 4 acc 1 t 3 dsm 6.86653e-14 dsm_est 2.12439e-16 nsteps 800 - h 0.0003125 rk_type 1 order 4 acc 1 t 3.25 dsm 4.56716e-14 dsm_est 6.89052e-17 nsteps 800 - h 0.0003125 rk_type 1 order 4 acc 1 t 3.5 dsm 1.14798e-14 dsm_est 6.73916e-18 nsteps 800 - h 0.0003125 rk_type 1 order 4 acc 1 t 3.75 dsm 1.10427e-14 dsm_est 1.46294e-17 nsteps 800 - h 0.0003125 rk_type 1 order 4 acc 1 t 4 dsm 5.31806e-14 dsm_est 3.31841e-18 nsteps 800 - h 0.0003125 rk_type 1 order 4 acc 1 t 4.25 dsm 2.08119e-13 dsm_est 3.56169e-17 nsteps 801 - h 0.0003125 rk_type 1 order 4 acc 1 t 4.5 dsm 1.57233e-14 dsm_est 5.94504e-18 nsteps 801 - h 0.0003125 rk_type 1 order 4 acc 1 t 4.75 dsm 1.39902e-13 dsm_est 7.47228e-17 nsteps 801 - h 0.0003125 rk_type 1 order 4 acc 1 t 5 dsm 7.63042e-14 dsm_est 3.2072e-17 nsteps 801 + h 0.0003125 rk_type 1 order 4 acc 1 t 0.25 dsm 9.97977e-16 dsm_est 2.11337e-14 nsteps 800 + h 0.0003125 rk_type 1 order 4 acc 1 t 0.5 dsm 7.34738e-15 dsm_est 1.05726e-13 nsteps 800 + h 0.0003125 rk_type 1 order 4 acc 1 t 0.75 dsm 1.89479e-14 dsm_est 3.40303e-13 nsteps 800 + h 0.0003125 rk_type 1 order 4 acc 1 t 1 dsm 6.41345e-15 dsm_est 1.18696e-13 nsteps 800 + h 0.0003125 rk_type 1 order 4 acc 1 t 1.25 dsm 1.49538e-13 dsm_est 2.91382e-12 nsteps 801 + h 0.0003125 rk_type 1 order 4 acc 1 t 1.5 dsm 1.0257e-13 dsm_est 1.48008e-12 nsteps 801 + h 0.0003125 rk_type 1 order 4 acc 1 t 1.75 dsm 4.74681e-14 dsm_est 4.83572e-12 nsteps 801 + h 0.0003125 rk_type 1 order 4 acc 1 t 2 dsm 3.28771e-14 dsm_est 9.73028e-13 nsteps 801 + h 0.0003125 rk_type 1 order 4 acc 1 t 2.25 dsm 2.08777e-13 dsm_est 4.1965e-13 nsteps 800 + h 0.0003125 rk_type 1 order 4 acc 1 t 2.5 dsm 1.03256e-14 dsm_est 1.74409e-13 nsteps 800 + h 0.0003125 rk_type 1 order 4 acc 1 t 2.75 dsm 1.44079e-14 dsm_est 8.83656e-14 nsteps 800 + h 0.0003125 rk_type 1 order 4 acc 1 t 3 dsm 6.86653e-14 dsm_est 6.83819e-14 nsteps 800 + h 0.0003125 rk_type 1 order 4 acc 1 t 3.25 dsm 4.56716e-14 dsm_est 3.34939e-14 nsteps 800 + h 0.0003125 rk_type 1 order 4 acc 1 t 3.5 dsm 1.14798e-14 dsm_est 8.18506e-15 nsteps 800 + h 0.0003125 rk_type 1 order 4 acc 1 t 3.75 dsm 1.10427e-14 dsm_est 6.13312e-15 nsteps 800 + h 0.0003125 rk_type 1 order 4 acc 1 t 4 dsm 5.31806e-14 dsm_est 1.45159e-14 nsteps 800 + h 0.0003125 rk_type 1 order 4 acc 1 t 4.25 dsm 2.08119e-13 dsm_est 3.69873e-14 nsteps 801 + h 0.0003125 rk_type 1 order 4 acc 1 t 4.5 dsm 1.57233e-14 dsm_est 1.13245e-13 nsteps 801 + h 0.0003125 rk_type 1 order 4 acc 1 t 4.75 dsm 1.39902e-13 dsm_est 2.66213e-14 nsteps 801 + h 0.0003125 rk_type 1 order 4 acc 1 t 5 dsm 7.63042e-14 dsm_est 1.85072e-14 nsteps 801 h 0.0003125 rk_type 1 order 4 acc 2 t 0.25 dsm 9.97977e-16 dsm_est 1.35296e-14 nsteps 1200 h 0.0003125 rk_type 1 order 4 acc 2 t 0.5 dsm 7.34738e-15 dsm_est 3.14131e-14 nsteps 1200 h 0.0003125 rk_type 1 order 4 acc 2 t 0.75 dsm 1.89479e-14 dsm_est 6.96153e-14 nsteps 1200 @@ -188,46 +188,46 @@ Fixed-step runs: h 0.0003125 rk_type 1 order 4 acc 2 t 4.5 dsm 1.57233e-14 dsm_est 3.54399e-14 nsteps 1201 h 0.0003125 rk_type 1 order 4 acc 2 t 4.75 dsm 1.39902e-13 dsm_est 2.1045e-13 nsteps 1201 h 0.0003125 rk_type 1 order 4 acc 2 t 5 dsm 7.63042e-14 dsm_est 1.1047e-13 nsteps 1201 - h 7.8125e-05 rk_type 1 order 4 acc 0 t 0.25 dsm 1.20076e-14 dsm_est 4.68152e-17 nsteps 3200 - h 7.8125e-05 rk_type 1 order 4 acc 0 t 0.5 dsm 6.92895e-14 dsm_est 1.82422e-16 nsteps 3201 - h 7.8125e-05 rk_type 1 order 4 acc 0 t 0.75 dsm 7.1887e-14 dsm_est 4.7344e-16 nsteps 3200 - h 7.8125e-05 rk_type 1 order 4 acc 0 t 1 dsm 5.29714e-14 dsm_est 6.51084e-17 nsteps 3200 - h 7.8125e-05 rk_type 1 order 4 acc 0 t 1.25 dsm 4.54758e-13 dsm_est 1.55315e-15 nsteps 3201 + h 7.8125e-05 rk_type 1 order 4 acc 0 t 0.25 dsm 1.20076e-14 dsm_est 1.82253e-16 nsteps 3200 + h 7.8125e-05 rk_type 1 order 4 acc 0 t 0.5 dsm 6.92895e-14 dsm_est 6.55669e-16 nsteps 3201 + h 7.8125e-05 rk_type 1 order 4 acc 0 t 0.75 dsm 7.1887e-14 dsm_est 2.68471e-15 nsteps 3200 + h 7.8125e-05 rk_type 1 order 4 acc 0 t 1 dsm 5.29714e-14 dsm_est 1.55185e-15 nsteps 3200 + h 7.8125e-05 rk_type 1 order 4 acc 0 t 1.25 dsm 4.54758e-13 dsm_est 3.90711e-14 nsteps 3201 h 7.8125e-05 rk_type 1 order 4 acc 0 t 1.5 dsm 1.61784e-13 dsm_est 2.57413e-14 nsteps 3201 - h 7.8125e-05 rk_type 1 order 4 acc 0 t 1.75 dsm 1.4649e-13 dsm_est 5.90317e-15 nsteps 3201 + h 7.8125e-05 rk_type 1 order 4 acc 0 t 1.75 dsm 1.4649e-13 dsm_est 6.1914e-14 nsteps 3201 h 7.8125e-05 rk_type 1 order 4 acc 0 t 2 dsm 6.85301e-14 dsm_est 1.28969e-14 nsteps 3201 - h 7.8125e-05 rk_type 1 order 4 acc 0 t 2.25 dsm 3.74507e-13 dsm_est 1.62039e-16 nsteps 3201 - h 7.8125e-05 rk_type 1 order 4 acc 0 t 2.5 dsm 1.92671e-14 dsm_est 1.8265e-16 nsteps 3201 - h 7.8125e-05 rk_type 1 order 4 acc 0 t 2.75 dsm 1.93516e-14 dsm_est 4.32788e-16 nsteps 3201 - h 7.8125e-05 rk_type 1 order 4 acc 0 t 3 dsm 1.23711e-13 dsm_est 6.63893e-16 nsteps 3201 - h 7.8125e-05 rk_type 1 order 4 acc 0 t 3.25 dsm 8.16997e-14 dsm_est 2.14904e-16 nsteps 3201 - h 7.8125e-05 rk_type 1 order 4 acc 0 t 3.5 dsm 1.95956e-14 dsm_est 2.1102e-17 nsteps 3201 - h 7.8125e-05 rk_type 1 order 4 acc 0 t 3.75 dsm 2.16401e-14 dsm_est 4.57959e-17 nsteps 3201 - h 7.8125e-05 rk_type 1 order 4 acc 0 t 4 dsm 9.37664e-14 dsm_est 1.0225e-17 nsteps 3201 - h 7.8125e-05 rk_type 1 order 4 acc 0 t 4.25 dsm 2.10442e-13 dsm_est 1.11615e-16 nsteps 3201 - h 7.8125e-05 rk_type 1 order 4 acc 0 t 4.5 dsm 1.64627e-14 dsm_est 1.89457e-17 nsteps 3201 - h 7.8125e-05 rk_type 1 order 4 acc 0 t 4.75 dsm 1.39177e-13 dsm_est 2.3562e-16 nsteps 3201 - h 7.8125e-05 rk_type 1 order 4 acc 0 t 5 dsm 7.51104e-14 dsm_est 1.00279e-16 nsteps 3201 - h 7.8125e-05 rk_type 1 order 4 acc 1 t 0.25 dsm 1.20076e-14 dsm_est 1.46298e-20 nsteps 3200 - h 7.8125e-05 rk_type 1 order 4 acc 1 t 0.5 dsm 6.92895e-14 dsm_est 5.69892e-20 nsteps 3201 - h 7.8125e-05 rk_type 1 order 4 acc 1 t 0.75 dsm 7.1887e-14 dsm_est 1.4795e-19 nsteps 3200 - h 7.8125e-05 rk_type 1 order 4 acc 1 t 1 dsm 5.29714e-14 dsm_est 2.03464e-20 nsteps 3200 - h 7.8125e-05 rk_type 1 order 4 acc 1 t 1.25 dsm 4.54758e-13 dsm_est 4.85208e-19 nsteps 3201 - h 7.8125e-05 rk_type 1 order 4 acc 1 t 1.5 dsm 1.61784e-13 dsm_est 8.04164e-18 nsteps 3201 - h 7.8125e-05 rk_type 1 order 4 acc 1 t 1.75 dsm 1.4649e-13 dsm_est 1.84416e-18 nsteps 3201 - h 7.8125e-05 rk_type 1 order 4 acc 1 t 2 dsm 6.85301e-14 dsm_est 4.02902e-18 nsteps 3201 - h 7.8125e-05 rk_type 1 order 4 acc 1 t 2.25 dsm 3.74507e-13 dsm_est 5.06214e-20 nsteps 3201 - h 7.8125e-05 rk_type 1 order 4 acc 1 t 2.5 dsm 1.92671e-14 dsm_est 5.70603e-20 nsteps 3201 - h 7.8125e-05 rk_type 1 order 4 acc 1 t 2.75 dsm 1.93516e-14 dsm_est 1.35204e-19 nsteps 3201 - h 7.8125e-05 rk_type 1 order 4 acc 1 t 3 dsm 1.23711e-13 dsm_est 2.07402e-19 nsteps 3201 - h 7.8125e-05 rk_type 1 order 4 acc 1 t 3.25 dsm 8.16997e-14 dsm_est 6.71366e-20 nsteps 3201 - h 7.8125e-05 rk_type 1 order 4 acc 1 t 3.5 dsm 1.95956e-14 dsm_est 6.5923e-21 nsteps 3201 - h 7.8125e-05 rk_type 1 order 4 acc 1 t 3.75 dsm 2.16401e-14 dsm_est 1.43067e-20 nsteps 3201 - h 7.8125e-05 rk_type 1 order 4 acc 1 t 4 dsm 9.37664e-14 dsm_est 3.19433e-21 nsteps 3201 - h 7.8125e-05 rk_type 1 order 4 acc 1 t 4.25 dsm 2.10442e-13 dsm_est 3.48687e-20 nsteps 3201 - h 7.8125e-05 rk_type 1 order 4 acc 1 t 4.5 dsm 1.64627e-14 dsm_est 5.91869e-21 nsteps 3201 - h 7.8125e-05 rk_type 1 order 4 acc 1 t 4.75 dsm 1.39177e-13 dsm_est 7.36081e-20 nsteps 3201 - h 7.8125e-05 rk_type 1 order 4 acc 1 t 5 dsm 7.51104e-14 dsm_est 3.13274e-20 nsteps 3201 + h 7.8125e-05 rk_type 1 order 4 acc 0 t 2.25 dsm 3.74507e-13 dsm_est 2.72291e-15 nsteps 3201 + h 7.8125e-05 rk_type 1 order 4 acc 0 t 2.5 dsm 1.92671e-14 dsm_est 9.81217e-16 nsteps 3201 + h 7.8125e-05 rk_type 1 order 4 acc 0 t 2.75 dsm 1.93516e-14 dsm_est 6.71729e-16 nsteps 3201 + h 7.8125e-05 rk_type 1 order 4 acc 0 t 3 dsm 1.23711e-13 dsm_est 6.65622e-16 nsteps 3201 + h 7.8125e-05 rk_type 1 order 4 acc 0 t 3.25 dsm 8.16997e-14 dsm_est 2.16207e-16 nsteps 3201 + h 7.8125e-05 rk_type 1 order 4 acc 0 t 3.5 dsm 1.95956e-14 dsm_est 4.74185e-17 nsteps 3201 + h 7.8125e-05 rk_type 1 order 4 acc 0 t 3.75 dsm 2.16401e-14 dsm_est 4.58122e-17 nsteps 3201 + h 7.8125e-05 rk_type 1 order 4 acc 0 t 4 dsm 9.37664e-14 dsm_est 1.11469e-16 nsteps 3201 + h 7.8125e-05 rk_type 1 order 4 acc 0 t 4.25 dsm 2.10442e-13 dsm_est 1.82276e-16 nsteps 3201 + h 7.8125e-05 rk_type 1 order 4 acc 0 t 4.5 dsm 1.64627e-14 dsm_est 7.11037e-16 nsteps 3201 + h 7.8125e-05 rk_type 1 order 4 acc 0 t 4.75 dsm 1.39177e-13 dsm_est 2.35957e-16 nsteps 3201 + h 7.8125e-05 rk_type 1 order 4 acc 0 t 5 dsm 7.51104e-14 dsm_est 1.00425e-16 nsteps 3201 + h 7.8125e-05 rk_type 1 order 4 acc 1 t 0.25 dsm 1.20076e-14 dsm_est 8.25514e-17 nsteps 3200 + h 7.8125e-05 rk_type 1 order 4 acc 1 t 0.5 dsm 6.92895e-14 dsm_est 4.12935e-16 nsteps 3201 + h 7.8125e-05 rk_type 1 order 4 acc 1 t 0.75 dsm 7.1887e-14 dsm_est 1.32929e-15 nsteps 3200 + h 7.8125e-05 rk_type 1 order 4 acc 1 t 1 dsm 5.29714e-14 dsm_est 4.63079e-16 nsteps 3200 + h 7.8125e-05 rk_type 1 order 4 acc 1 t 1.25 dsm 4.54758e-13 dsm_est 1.13947e-14 nsteps 3201 + h 7.8125e-05 rk_type 1 order 4 acc 1 t 1.5 dsm 1.61784e-13 dsm_est 5.78442e-15 nsteps 3201 + h 7.8125e-05 rk_type 1 order 4 acc 1 t 1.75 dsm 1.4649e-13 dsm_est 1.89102e-14 nsteps 3201 + h 7.8125e-05 rk_type 1 order 4 acc 1 t 2 dsm 6.85301e-14 dsm_est 3.80224e-15 nsteps 3201 + h 7.8125e-05 rk_type 1 order 4 acc 1 t 2.25 dsm 3.74507e-13 dsm_est 1.6387e-15 nsteps 3201 + h 7.8125e-05 rk_type 1 order 4 acc 1 t 2.5 dsm 1.92671e-14 dsm_est 6.81275e-16 nsteps 3201 + h 7.8125e-05 rk_type 1 order 4 acc 1 t 2.75 dsm 1.93516e-14 dsm_est 3.45213e-16 nsteps 3201 + h 7.8125e-05 rk_type 1 order 4 acc 1 t 3 dsm 1.23711e-13 dsm_est 2.67136e-16 nsteps 3201 + h 7.8125e-05 rk_type 1 order 4 acc 1 t 3.25 dsm 8.16997e-14 dsm_est 1.30768e-16 nsteps 3201 + h 7.8125e-05 rk_type 1 order 4 acc 1 t 3.5 dsm 1.95956e-14 dsm_est 3.19583e-17 nsteps 3201 + h 7.8125e-05 rk_type 1 order 4 acc 1 t 3.75 dsm 2.16401e-14 dsm_est 2.39388e-17 nsteps 3201 + h 7.8125e-05 rk_type 1 order 4 acc 1 t 4 dsm 9.37664e-14 dsm_est 5.67508e-17 nsteps 3201 + h 7.8125e-05 rk_type 1 order 4 acc 1 t 4.25 dsm 2.10442e-13 dsm_est 1.44544e-16 nsteps 3201 + h 7.8125e-05 rk_type 1 order 4 acc 1 t 4.5 dsm 1.64627e-14 dsm_est 4.4406e-16 nsteps 3201 + h 7.8125e-05 rk_type 1 order 4 acc 1 t 4.75 dsm 1.39177e-13 dsm_est 1.03927e-16 nsteps 3201 + h 7.8125e-05 rk_type 1 order 4 acc 1 t 5 dsm 7.51104e-14 dsm_est 7.26595e-17 nsteps 3201 h 7.8125e-05 rk_type 1 order 4 acc 2 t 0.25 dsm 1.20076e-14 dsm_est 9.70841e-15 nsteps 4800 h 7.8125e-05 rk_type 1 order 4 acc 2 t 0.5 dsm 6.92895e-14 dsm_est 1.22494e-13 nsteps 4801 h 7.8125e-05 rk_type 1 order 4 acc 2 t 0.75 dsm 7.1887e-14 dsm_est 1.01008e-13 nsteps 4801 diff --git a/test/unit_tests/arkode/CXX_serial/ark_test_brusselator_mriadapt_--rtol_0.000004_--scontrol_0.out b/test/unit_tests/arkode/CXX_serial/ark_test_brusselator_mriadapt_--rtol_0.000004_--scontrol_0.out index f1a60d2ab7..4609777e89 100644 --- a/test/unit_tests/arkode/CXX_serial/ark_test_brusselator_mriadapt_--rtol_0.000004_--scontrol_0.out +++ b/test/unit_tests/arkode/CXX_serial/ark_test_brusselator_mriadapt_--rtol_0.000004_--scontrol_0.out @@ -13,31 +13,31 @@ Adaptive multirate stiff Brusselator test problem: t u v w uerr verr werr ------------------------------------------------------------------------- 0.000000 1.200000 3.100000 3.000000 0.0e+00 0.0e+00 0.0e+00 - 0.500000 1.200613 2.996066 3.498311 7.5e-05 8.8e-05 8.5e-06 - 1.000000 1.107158 3.008131 3.498438 9.3e-05 1.5e-04 1.3e-05 - 1.500000 0.917798 3.188082 3.498698 8.0e-05 1.8e-04 1.7e-05 - 2.000000 0.691486 3.512327 3.499015 4.5e-05 1.8e-04 1.6e-05 - 2.500000 0.510160 3.896431 3.499274 1.2e-05 1.6e-04 1.2e-05 - 3.000000 0.410222 4.269502 3.499416 6.6e-06 1.4e-04 9.6e-06 - 3.500000 0.372044 4.614020 3.499469 1.3e-05 1.3e-04 9.8e-06 - 4.000000 0.367587 4.934562 3.499472 1.6e-05 1.2e-04 1.3e-05 - 4.500000 0.382207 5.233152 3.499474 2.0e-05 1.1e-04 9.1e-06 - 5.000000 0.412957 5.504350 3.499431 2.3e-05 9.1e-05 8.5e-06 - 5.500000 0.467991 5.730484 3.499356 3.5e-05 6.6e-05 1.1e-05 - 6.000000 0.585319 5.854259 3.499196 7.8e-05 2.7e-06 1.5e-05 - 6.500000 1.060816 5.503421 3.498555 4.8e-04 5.0e-04 3.7e-05 - 7.000000 4.794985 0.734608 3.493240 6.9e-04 2.8e-05 5.7e-05 - 7.500000 3.037697 1.057906 3.495704 5.3e-04 1.3e-04 4.6e-05 - 8.000000 1.833967 1.562361 3.497406 3.6e-04 1.9e-04 2.7e-05 - 8.500000 1.008514 2.191339 3.498570 2.4e-04 2.1e-04 1.8e-05 - 9.000000 0.534095 2.794916 3.499237 1.1e-04 1.7e-04 1.5e-05 - 9.500000 0.352784 3.263323 3.499486 3.3e-05 1.3e-04 2.0e-05 - 10.000000 0.305955 3.648442 3.499562 6.1e-06 1.1e-04 9.8e-06 + 0.500000 1.200613 2.996066 3.498311 1.2e-07 1.2e-07 8.6e-06 + 1.000000 1.107158 3.008131 3.498438 1.2e-07 1.2e-07 1.3e-05 + 1.500000 0.917798 3.188082 3.498698 1.0e-07 1.0e-07 1.7e-05 + 2.000000 0.691486 3.512327 3.499015 7.6e-08 7.6e-08 1.7e-05 + 2.500000 0.510160 3.896431 3.499274 5.5e-08 5.5e-08 1.2e-05 + 3.000000 0.410222 4.269502 3.499416 4.6e-08 4.6e-08 9.6e-06 + 3.500000 0.372044 4.614020 3.499469 3.0e-08 3.0e-08 9.8e-06 + 4.000000 0.367587 4.934562 3.499472 3.2e-08 3.2e-08 1.3e-05 + 4.500000 0.382207 5.233152 3.499474 3.2e-08 3.2e-08 9.1e-06 + 5.000000 0.412957 5.504350 3.499431 4.1e-08 4.1e-08 8.5e-06 + 5.500000 0.467991 5.730484 3.499356 5.5e-08 5.5e-08 1.1e-05 + 6.000000 0.585319 5.854259 3.499196 6.5e-08 6.6e-08 1.5e-05 + 6.500000 1.060816 5.503421 3.498555 5.4e-07 5.5e-07 3.8e-05 + 7.000000 4.794985 0.734608 3.493240 3.6e-06 3.6e-06 5.8e-05 + 7.500000 3.037697 1.057906 3.495704 2.0e-06 2.0e-06 4.7e-05 + 8.000000 1.833967 1.562361 3.497406 7.7e-07 7.8e-07 2.7e-05 + 8.500000 1.008514 2.191339 3.498570 2.5e-07 2.5e-07 1.8e-05 + 9.000000 0.534095 2.794916 3.499237 6.6e-08 6.7e-08 1.5e-05 + 9.500000 0.352784 3.263323 3.499486 4.3e-08 4.3e-08 2.0e-05 + 10.000000 0.305955 3.648442 3.499562 2.5e-08 2.5e-08 9.8e-06 ------------------------------------------------------------------------- Final Solver Statistics: Slow steps = 1000 (attempts = 1000, fails = 0) Fast steps = 11775 (attempts = 16695, fails = 4920) - u error = 0.000246767, v error = 0.000173197, w error = 2.26939e-05, total error = 0.000174553 - Relative accuracy = 112.835 - Total RHS evals: Fse = 5000, Fsi = 0, Ff = 78558 + u error = 1.29633e-05, v error = 1.15346e-05, w error = 0.000392775, total error = 0.00022699 + Relative accuracy = 83.5081 + Total RHS evals: Fse = 5000, Fsi = 0, Ff = 78557 diff --git a/test/unit_tests/arkode/CXX_serial/ark_test_dahlquist_mri_-1.out b/test/unit_tests/arkode/CXX_serial/ark_test_dahlquist_mri_-1.out index aac0cac006..cc1343ca4c 100644 --- a/test/unit_tests/arkode/CXX_serial/ark_test_dahlquist_mri_-1.out +++ b/test/unit_tests/arkode/CXX_serial/ark_test_dahlquist_mri_-1.out @@ -144,7 +144,7 @@ Testing method ARKODE_MRI_GARK_ERK45a -0.5121234603937985 1.955496920787597 -1.243373460393798 0 0 0 -0.1068927211587161 -4.656693056981116 3.994968532757531 0.9686172453823019 0 0 0.911960843690752 -0.1837327083772207 -1.193926866090864 -2.611983006811319 3.277681737588653 0 - -1.952334369075205 2.468660908644056 -0.6939268660908644 -0.1119830068113194 0.4895833333333333 0 + -1.858584369075205 2.224667606006969 -0.5244469581796045 -0.09396291472257937 0.45232663597042 0 W[1] = 0 0 0 0 0 0 @@ -974,5 +974,173 @@ MRIStep Statistics: Comparing Solver Statistics: All checks passed +======================== +Test IMEX MRI SR methods +======================== + +Testing method ARKODE_IMEX_MRI_SR21 + type = MRISR + nmat = 1 + stages = 4 + method order (q) = 2 + embedding order (p) = 1 + c = 0 0.6 0.2666666666666667 1 + W[0] = + 0 0 0 0 + 0.6 0 0 0 + 0.08484848484848485 0.1818181818181818 0 0 + -0.2407407407407407 0.5074074074074074 0.7333333333333333 0 + -0.25 0.5 0.75 0 + + G[0] = + 0 0 0 0 + -0.4782608695652174 0.4782608695652174 0 0 + -0.1277806419583357 -0.3504802276068817 0.4782608695652174 0 + 0.1281737365715925 -0.9496349237862043 0.3432003176493945 0.4782608695652174 + -2.583333333333333 -0.1666666666666667 2.75 0 + + Stored stages = 4 + +MRIStep Statistics: + Time = 0.01 + y(t) = 0.970446 + y_n = 0.970445 + Error = 6.56922e-07 + Steps = 1 + Fe evals = 3 + Fi evals = 6 + NLS iters = 3 + NLS fails = 0 + LS setups = 1 + LS Fi evals = 0 + Ji evals = 1 + +Comparing Solver Statistics: +All checks passed + +Testing method ARKODE_IMEX_MRI_SR32 + type = MRISR + nmat = 2 + stages = 5 + method order (q) = 3 + embedding order (p) = 2 + c = 0 0.6764705882352942 0.8 1.133333333333333 1 + W[0] = + 0 0 0 0 0 + 0.6764705882352942 0 0 0 0 + 1.014285714285714 -0.2142857142857143 0 0 0 + 0.1073593073593074 0.5714285714285714 0.4545454545454545 0 0 + 0.8641357630008525 0.08623188405797101 0.34375 -0.2941176470588235 0 + 1.020324985968944 -1.483870967741935 1.970588235294118 -0.5070422535211268 0 + + W[1] = + 0 0 0 0 0 + 0 0 0 0 0 + -0.2264473168820995 0.2264473168820995 0 0 0 + -1.741503979463316 8.210746794478919 -6.469242815015602 0 0 + -1.295451217034184 2.560595940177763 -2.104988533033297 0.8398438098897179 0 + -1.638681583030989 6.083126027475434 -5.777777777777778 1.333333333333333 0 + + G[0] = + 0 0 0 0 0 + -0.5714285714285714 0.5714285714285714 0 0 0 + -0.8655695979919582 0.2941410265633868 0.5714285714285714 0 0 + 1.211752194844657 -2.237726220818683 0.4545454545454545 0.5714285714285714 0 + 0.02135581474837214 -0.07308298152405064 -0.2010145240388127 -0.3186868806140802 0.5714285714285714 + -0.04323671497584541 0.05514147688060732 0.07142857142857142 -0.08333333333333333 0 + + G[1] = + 0 0 0 0 0 + 0 0 0 0 0 + 0 0 0 0 0 + 0 0 0 0 0 + 0 0 0 0 0 + 0 0 0 0 0 + + Stored stages = 5 + +MRIStep Statistics: + Time = 0.01 + y(t) = 0.970446 + y_n = 0.970446 + Error = -3.76499e-09 + Steps = 1 + Fe evals = 4 + Fi evals = 8 + NLS iters = 4 + NLS fails = 0 + LS setups = 1 + LS Fi evals = 0 + Ji evals = 1 + +Comparing Solver Statistics: +All checks passed + +Testing method ARKODE_IMEX_MRI_SR43 + type = MRISR + nmat = 2 + stages = 7 + method order (q) = 4 + embedding order (p) = 3 + c = 0 0.25 0.75 0.55 0.5 1 1 + W[0] = + 0 0 0 0 0 0 0 + 0.25 0 0 0 0 0 0 + 1.125 -0.375 0 0 0 0 0 + 0.07991452991452991 0.7777777777777778 -0.3076923076923077 0 0 0 0 + 0.3878787878787879 0.1666666666666667 -0.6 0.5454545454545454 0 0 0 + 3.307624927156177 -0.2222222222222222 -0.3636363636363636 -0.1666666666666667 -1.555099674630925 0 0 + 0 0.6363636363636364 -8.344696969696969 13.66792929292929 -7.083333333333333 2.123737373737374 0 + 0.0025 4.083333333333333 7.166666666666667 -0.7 -7.083333333333333 -2.469166666666667 0 + + W[1] = + 0 0 0 0 0 0 0 + 0 0 0 0 0 0 0 + -2.75 2.75 0 0 0 0 0 + -0.4198290598290598 -0.4088888888888889 0.8287179487179487 0 0 0 0 + -0.9169340463458111 0.6549019607843137 1.463235294117647 -1.20120320855615 0 0 0 + -6.615249854312355 7.027777777777778 -0.5227272727272727 25.33333333333333 -25.22313398407148 0 0 + 0 0.8106060606060606 14.64772727272727 -11.71085858585859 0 -3.747474747474747 0 + -0.005 -5.708333333333333 -14.6875 15.4625 0 4.938333333333333 0 + + G[0] = + 0 0 0 0 0 0 0 + -0.25 0.25 0 0 0 0 0 + 0.25 -0.5 0.25 0 0 0 0 + 0.13 -0.2333333333333333 -0.1466666666666667 0.25 0 0 0 + 0.07058823529411765 -0.2213235294117647 -0.1819852941176471 0.08272058823529412 0.25 0 0 + 0 -2.25 -0.3958333333333333 -4.6875 7.083333333333333 0.25 0 + 0 0 0 0 0 0 0 + 0 0 0 0 0 0 0 + + G[1] = + 0 0 0 0 0 0 0 + 0 0 0 0 0 0 0 + 0 0 0 0 0 0 0 + 0 0 0 0 0 0 0 + 0 0 0 0 0 0 0 + 0 0 0 0 0 0 0 + 0 0 0 0 0 0 0 + 0 0 0 0 0 0 0 + + Stored stages = 7 + +MRIStep Statistics: + Time = 0.01 + y(t) = 0.970446 + y_n = 0.970446 + Error = -6.94172e-11 + Steps = 1 + Fe evals = 6 + Fi evals = 11 + NLS iters = 5 + NLS fails = 0 + LS setups = 1 + LS Fi evals = 0 + Ji evals = 1 + +Comparing Solver Statistics: +All checks passed + All tests passed! diff --git a/test/unit_tests/arkode/CXX_serial/ark_test_dahlquist_mri_0.out b/test/unit_tests/arkode/CXX_serial/ark_test_dahlquist_mri_0.out index b1147d78c1..36b5c0aaef 100644 --- a/test/unit_tests/arkode/CXX_serial/ark_test_dahlquist_mri_0.out +++ b/test/unit_tests/arkode/CXX_serial/ark_test_dahlquist_mri_0.out @@ -144,7 +144,7 @@ Testing method ARKODE_MRI_GARK_ERK45a -0.5121234603937985 1.955496920787597 -1.243373460393798 0 0 0 -0.1068927211587161 -4.656693056981116 3.994968532757531 0.9686172453823019 0 0 0.911960843690752 -0.1837327083772207 -1.193926866090864 -2.611983006811319 3.277681737588653 0 - -1.952334369075205 2.468660908644056 -0.6939268660908644 -0.1119830068113194 0.4895833333333333 0 + -1.858584369075205 2.224667606006969 -0.5244469581796045 -0.09396291472257937 0.45232663597042 0 W[1] = 0 0 0 0 0 0 @@ -974,5 +974,173 @@ MRIStep Statistics: Comparing Solver Statistics: All checks passed +======================== +Test IMEX MRI SR methods +======================== + +Testing method ARKODE_IMEX_MRI_SR21 + type = MRISR + nmat = 1 + stages = 4 + method order (q) = 2 + embedding order (p) = 1 + c = 0 0.6 0.2666666666666667 1 + W[0] = + 0 0 0 0 + 0.6 0 0 0 + 0.08484848484848485 0.1818181818181818 0 0 + -0.2407407407407407 0.5074074074074074 0.7333333333333333 0 + -0.25 0.5 0.75 0 + + G[0] = + 0 0 0 0 + -0.4782608695652174 0.4782608695652174 0 0 + -0.1277806419583357 -0.3504802276068817 0.4782608695652174 0 + 0.1281737365715925 -0.9496349237862043 0.3432003176493945 0.4782608695652174 + -2.583333333333333 -0.1666666666666667 2.75 0 + + Stored stages = 4 + +MRIStep Statistics: + Time = 0.01 + y(t) = 0.970446 + y_n = 0.970445 + Error = 6.56922e-07 + Steps = 1 + Fe evals = 3 + Fi evals = 6 + NLS iters = 3 + NLS fails = 0 + LS setups = 1 + LS Fi evals = 0 + Ji evals = 1 + +Comparing Solver Statistics: +All checks passed + +Testing method ARKODE_IMEX_MRI_SR32 + type = MRISR + nmat = 2 + stages = 5 + method order (q) = 3 + embedding order (p) = 2 + c = 0 0.6764705882352942 0.8 1.133333333333333 1 + W[0] = + 0 0 0 0 0 + 0.6764705882352942 0 0 0 0 + 1.014285714285714 -0.2142857142857143 0 0 0 + 0.1073593073593074 0.5714285714285714 0.4545454545454545 0 0 + 0.8641357630008525 0.08623188405797101 0.34375 -0.2941176470588235 0 + 1.020324985968944 -1.483870967741935 1.970588235294118 -0.5070422535211268 0 + + W[1] = + 0 0 0 0 0 + 0 0 0 0 0 + -0.2264473168820995 0.2264473168820995 0 0 0 + -1.741503979463316 8.210746794478919 -6.469242815015602 0 0 + -1.295451217034184 2.560595940177763 -2.104988533033297 0.8398438098897179 0 + -1.638681583030989 6.083126027475434 -5.777777777777778 1.333333333333333 0 + + G[0] = + 0 0 0 0 0 + -0.5714285714285714 0.5714285714285714 0 0 0 + -0.8655695979919582 0.2941410265633868 0.5714285714285714 0 0 + 1.211752194844657 -2.237726220818683 0.4545454545454545 0.5714285714285714 0 + 0.02135581474837214 -0.07308298152405064 -0.2010145240388127 -0.3186868806140802 0.5714285714285714 + -0.04323671497584541 0.05514147688060732 0.07142857142857142 -0.08333333333333333 0 + + G[1] = + 0 0 0 0 0 + 0 0 0 0 0 + 0 0 0 0 0 + 0 0 0 0 0 + 0 0 0 0 0 + 0 0 0 0 0 + + Stored stages = 5 + +MRIStep Statistics: + Time = 0.01 + y(t) = 0.970446 + y_n = 0.970446 + Error = -3.76499e-09 + Steps = 1 + Fe evals = 4 + Fi evals = 8 + NLS iters = 4 + NLS fails = 0 + LS setups = 1 + LS Fi evals = 0 + Ji evals = 1 + +Comparing Solver Statistics: +All checks passed + +Testing method ARKODE_IMEX_MRI_SR43 + type = MRISR + nmat = 2 + stages = 7 + method order (q) = 4 + embedding order (p) = 3 + c = 0 0.25 0.75 0.55 0.5 1 1 + W[0] = + 0 0 0 0 0 0 0 + 0.25 0 0 0 0 0 0 + 1.125 -0.375 0 0 0 0 0 + 0.07991452991452991 0.7777777777777778 -0.3076923076923077 0 0 0 0 + 0.3878787878787879 0.1666666666666667 -0.6 0.5454545454545454 0 0 0 + 3.307624927156177 -0.2222222222222222 -0.3636363636363636 -0.1666666666666667 -1.555099674630925 0 0 + 0 0.6363636363636364 -8.344696969696969 13.66792929292929 -7.083333333333333 2.123737373737374 0 + 0.0025 4.083333333333333 7.166666666666667 -0.7 -7.083333333333333 -2.469166666666667 0 + + W[1] = + 0 0 0 0 0 0 0 + 0 0 0 0 0 0 0 + -2.75 2.75 0 0 0 0 0 + -0.4198290598290598 -0.4088888888888889 0.8287179487179487 0 0 0 0 + -0.9169340463458111 0.6549019607843137 1.463235294117647 -1.20120320855615 0 0 0 + -6.615249854312355 7.027777777777778 -0.5227272727272727 25.33333333333333 -25.22313398407148 0 0 + 0 0.8106060606060606 14.64772727272727 -11.71085858585859 0 -3.747474747474747 0 + -0.005 -5.708333333333333 -14.6875 15.4625 0 4.938333333333333 0 + + G[0] = + 0 0 0 0 0 0 0 + -0.25 0.25 0 0 0 0 0 + 0.25 -0.5 0.25 0 0 0 0 + 0.13 -0.2333333333333333 -0.1466666666666667 0.25 0 0 0 + 0.07058823529411765 -0.2213235294117647 -0.1819852941176471 0.08272058823529412 0.25 0 0 + 0 -2.25 -0.3958333333333333 -4.6875 7.083333333333333 0.25 0 + 0 0 0 0 0 0 0 + 0 0 0 0 0 0 0 + + G[1] = + 0 0 0 0 0 0 0 + 0 0 0 0 0 0 0 + 0 0 0 0 0 0 0 + 0 0 0 0 0 0 0 + 0 0 0 0 0 0 0 + 0 0 0 0 0 0 0 + 0 0 0 0 0 0 0 + 0 0 0 0 0 0 0 + + Stored stages = 7 + +MRIStep Statistics: + Time = 0.01 + y(t) = 0.970446 + y_n = 0.970446 + Error = -6.94172e-11 + Steps = 1 + Fe evals = 6 + Fi evals = 11 + NLS iters = 5 + NLS fails = 0 + LS setups = 1 + LS Fi evals = 0 + Ji evals = 1 + +Comparing Solver Statistics: +All checks passed + All tests passed! diff --git a/test/unit_tests/arkode/CXX_serial/ark_test_dahlquist_mri_1.out b/test/unit_tests/arkode/CXX_serial/ark_test_dahlquist_mri_1.out index 3e5d63bd34..66c18208c1 100644 --- a/test/unit_tests/arkode/CXX_serial/ark_test_dahlquist_mri_1.out +++ b/test/unit_tests/arkode/CXX_serial/ark_test_dahlquist_mri_1.out @@ -144,7 +144,7 @@ Testing method ARKODE_MRI_GARK_ERK45a -0.5121234603937985 1.955496920787597 -1.243373460393798 0 0 0 -0.1068927211587161 -4.656693056981116 3.994968532757531 0.9686172453823019 0 0 0.911960843690752 -0.1837327083772207 -1.193926866090864 -2.611983006811319 3.277681737588653 0 - -1.952334369075205 2.468660908644056 -0.6939268660908644 -0.1119830068113194 0.4895833333333333 0 + -1.858584369075205 2.224667606006969 -0.5244469581796045 -0.09396291472257937 0.45232663597042 0 W[1] = 0 0 0 0 0 0 @@ -974,5 +974,173 @@ MRIStep Statistics: Comparing Solver Statistics: All checks passed +======================== +Test IMEX MRI SR methods +======================== + +Testing method ARKODE_IMEX_MRI_SR21 + type = MRISR + nmat = 1 + stages = 4 + method order (q) = 2 + embedding order (p) = 1 + c = 0 0.6 0.2666666666666667 1 + W[0] = + 0 0 0 0 + 0.6 0 0 0 + 0.08484848484848485 0.1818181818181818 0 0 + -0.2407407407407407 0.5074074074074074 0.7333333333333333 0 + -0.25 0.5 0.75 0 + + G[0] = + 0 0 0 0 + -0.4782608695652174 0.4782608695652174 0 0 + -0.1277806419583357 -0.3504802276068817 0.4782608695652174 0 + 0.1281737365715925 -0.9496349237862043 0.3432003176493945 0.4782608695652174 + -2.583333333333333 -0.1666666666666667 2.75 0 + + Stored stages = 4 + +MRIStep Statistics: + Time = 0.01 + y(t) = 0.970446 + y_n = 0.970445 + Error = 6.56922e-07 + Steps = 1 + Fe evals = 3 + Fi evals = 6 + NLS iters = 3 + NLS fails = 0 + LS setups = 1 + LS Fi evals = 0 + Ji evals = 1 + +Comparing Solver Statistics: +All checks passed + +Testing method ARKODE_IMEX_MRI_SR32 + type = MRISR + nmat = 2 + stages = 5 + method order (q) = 3 + embedding order (p) = 2 + c = 0 0.6764705882352942 0.8 1.133333333333333 1 + W[0] = + 0 0 0 0 0 + 0.6764705882352942 0 0 0 0 + 1.014285714285714 -0.2142857142857143 0 0 0 + 0.1073593073593074 0.5714285714285714 0.4545454545454545 0 0 + 0.8641357630008525 0.08623188405797101 0.34375 -0.2941176470588235 0 + 1.020324985968944 -1.483870967741935 1.970588235294118 -0.5070422535211268 0 + + W[1] = + 0 0 0 0 0 + 0 0 0 0 0 + -0.2264473168820995 0.2264473168820995 0 0 0 + -1.741503979463316 8.210746794478919 -6.469242815015602 0 0 + -1.295451217034184 2.560595940177763 -2.104988533033297 0.8398438098897179 0 + -1.638681583030989 6.083126027475434 -5.777777777777778 1.333333333333333 0 + + G[0] = + 0 0 0 0 0 + -0.5714285714285714 0.5714285714285714 0 0 0 + -0.8655695979919582 0.2941410265633868 0.5714285714285714 0 0 + 1.211752194844657 -2.237726220818683 0.4545454545454545 0.5714285714285714 0 + 0.02135581474837214 -0.07308298152405064 -0.2010145240388127 -0.3186868806140802 0.5714285714285714 + -0.04323671497584541 0.05514147688060732 0.07142857142857142 -0.08333333333333333 0 + + G[1] = + 0 0 0 0 0 + 0 0 0 0 0 + 0 0 0 0 0 + 0 0 0 0 0 + 0 0 0 0 0 + 0 0 0 0 0 + + Stored stages = 5 + +MRIStep Statistics: + Time = 0.01 + y(t) = 0.970446 + y_n = 0.970446 + Error = -3.76499e-09 + Steps = 1 + Fe evals = 4 + Fi evals = 8 + NLS iters = 4 + NLS fails = 0 + LS setups = 1 + LS Fi evals = 0 + Ji evals = 1 + +Comparing Solver Statistics: +All checks passed + +Testing method ARKODE_IMEX_MRI_SR43 + type = MRISR + nmat = 2 + stages = 7 + method order (q) = 4 + embedding order (p) = 3 + c = 0 0.25 0.75 0.55 0.5 1 1 + W[0] = + 0 0 0 0 0 0 0 + 0.25 0 0 0 0 0 0 + 1.125 -0.375 0 0 0 0 0 + 0.07991452991452991 0.7777777777777778 -0.3076923076923077 0 0 0 0 + 0.3878787878787879 0.1666666666666667 -0.6 0.5454545454545454 0 0 0 + 3.307624927156177 -0.2222222222222222 -0.3636363636363636 -0.1666666666666667 -1.555099674630925 0 0 + 0 0.6363636363636364 -8.344696969696969 13.66792929292929 -7.083333333333333 2.123737373737374 0 + 0.0025 4.083333333333333 7.166666666666667 -0.7 -7.083333333333333 -2.469166666666667 0 + + W[1] = + 0 0 0 0 0 0 0 + 0 0 0 0 0 0 0 + -2.75 2.75 0 0 0 0 0 + -0.4198290598290598 -0.4088888888888889 0.8287179487179487 0 0 0 0 + -0.9169340463458111 0.6549019607843137 1.463235294117647 -1.20120320855615 0 0 0 + -6.615249854312355 7.027777777777778 -0.5227272727272727 25.33333333333333 -25.22313398407148 0 0 + 0 0.8106060606060606 14.64772727272727 -11.71085858585859 0 -3.747474747474747 0 + -0.005 -5.708333333333333 -14.6875 15.4625 0 4.938333333333333 0 + + G[0] = + 0 0 0 0 0 0 0 + -0.25 0.25 0 0 0 0 0 + 0.25 -0.5 0.25 0 0 0 0 + 0.13 -0.2333333333333333 -0.1466666666666667 0.25 0 0 0 + 0.07058823529411765 -0.2213235294117647 -0.1819852941176471 0.08272058823529412 0.25 0 0 + 0 -2.25 -0.3958333333333333 -4.6875 7.083333333333333 0.25 0 + 0 0 0 0 0 0 0 + 0 0 0 0 0 0 0 + + G[1] = + 0 0 0 0 0 0 0 + 0 0 0 0 0 0 0 + 0 0 0 0 0 0 0 + 0 0 0 0 0 0 0 + 0 0 0 0 0 0 0 + 0 0 0 0 0 0 0 + 0 0 0 0 0 0 0 + 0 0 0 0 0 0 0 + + Stored stages = 7 + +MRIStep Statistics: + Time = 0.01 + y(t) = 0.970446 + y_n = 0.970446 + Error = -6.94172e-11 + Steps = 1 + Fe evals = 6 + Fi evals = 11 + NLS iters = 5 + NLS fails = 0 + LS setups = 1 + LS Fi evals = 0 + Ji evals = 1 + +Comparing Solver Statistics: +All checks passed + All tests passed! diff --git a/test/unit_tests/arkode/CXX_serial/ark_test_kpr_mriadapt_--hs_0.002_--rtol_0.000004_--scontrol_0.out b/test/unit_tests/arkode/CXX_serial/ark_test_kpr_mriadapt_--hs_0.002_--rtol_0.000004_--scontrol_0.out index 9416e34adc..a2776b60d6 100644 --- a/test/unit_tests/arkode/CXX_serial/ark_test_kpr_mriadapt_--hs_0.002_--rtol_0.000004_--scontrol_0.out +++ b/test/unit_tests/arkode/CXX_serial/ark_test_kpr_mriadapt_--hs_0.002_--rtol_0.000004_--scontrol_0.out @@ -15,31 +15,31 @@ Adaptive multirate nonlinear Kvaerno-Prothero-Robinson test problem: t u v uerr verr ------------------------------------------------------ 0.000000 1.732051 1.732051 0.00e+00 0.00e+00 - 0.250000 1.723053 1.584050 2.46e-10 4.03e-10 - 0.500000 1.696344 1.512598 2.34e-10 1.45e-09 - 0.750000 1.652782 1.036015 2.00e-10 1.13e-09 - 1.000000 1.593833 1.458873 1.33e-10 1.72e-08 - 1.250000 1.521618 1.458201 1.63e-10 6.16e-08 - 1.500000 1.439006 1.011474 7.31e-10 1.39e-07 - 1.750000 1.349724 1.730452 1.32e-09 2.50e-07 - 2.000000 1.258512 1.214374 1.58e-09 3.01e-07 - 2.250000 1.171250 1.024071 1.36e-09 2.86e-07 - 2.500000 1.094923 1.471085 1.02e-09 1.56e-07 - 2.750000 1.037158 1.313348 9.56e-10 1.36e-07 - 3.000000 1.004991 1.274175 1.04e-09 1.09e-07 - 3.250000 1.002931 1.043458 9.00e-10 1.04e-07 - 3.500000 1.031282 1.053648 7.83e-10 8.07e-08 - 3.750000 1.086021 1.006374 5.90e-10 6.59e-08 - 4.000000 1.160326 1.571824 3.69e-10 3.30e-08 - 4.250000 1.246560 1.705136 2.00e-10 2.42e-08 - 4.500000 1.337611 1.431830 1.20e-10 2.26e-08 - 4.750000 1.427446 1.162908 3.11e-11 2.19e-08 - 5.000000 1.511179 1.070831 4.69e-11 1.87e-08 + 0.250000 1.723053 1.584050 5.10e-11 1.74e-10 + 0.500000 1.696344 1.512598 4.32e-11 2.69e-10 + 0.750000 1.652782 1.036015 4.04e-11 3.14e-09 + 1.000000 1.593833 1.458873 3.27e-11 2.89e-09 + 1.250000 1.521618 1.458201 3.54e-11 1.27e-08 + 1.500000 1.439006 1.011474 4.37e-11 6.25e-08 + 1.750000 1.349724 1.730452 3.08e-12 3.71e-09 + 2.000000 1.258512 1.214374 1.24e-11 5.83e-09 + 2.250000 1.171250 1.024071 2.70e-11 1.63e-10 + 2.500000 1.094923 1.471085 4.59e-11 3.37e-13 + 2.750000 1.037158 1.313348 6.36e-11 2.73e-11 + 3.000000 1.004991 1.274175 7.66e-11 3.08e-11 + 3.250000 1.002931 1.043458 7.94e-11 6.65e-12 + 3.500000 1.031282 1.053648 6.81e-11 1.65e-13 + 3.750000 1.086021 1.006374 5.17e-11 2.69e-12 + 4.000000 1.160326 1.571824 3.06e-11 1.90e-11 + 4.250000 1.246560 1.705136 1.25e-11 2.07e-11 + 4.500000 1.337611 1.431830 3.29e-12 5.45e-11 + 4.750000 1.427446 1.162908 1.55e-11 1.82e-10 + 5.000000 1.511179 1.070831 2.51e-11 3.34e-10 ------------------------------------------------------ Final Solver Statistics: Slow steps = 2500 (attempts = 2500, fails = 0) Fast steps = 12502 (attempts = 12502, fails = 0) - u error = 7.68153e-10, v error = 1.29958e-07, total error = 9.1896e-08 - Relative accuracy = 0.0698426 - Total RHS evals: Fse = 12500, Fsi = 0, Ff = 62513 + u error = 4.83189e-10, v error = 1.06446e-07, total error = 7.52694e-08 + Relative accuracy = 0.0160088 + Total RHS evals: Fse = 12500, Fsi = 0, Ff = 62512 diff --git a/test/unit_tests/arkode/CXX_serial/ark_test_slowerror_brusselator.out b/test/unit_tests/arkode/CXX_serial/ark_test_slowerror_brusselator.out index 451e0ff65b..cfe44382f2 100644 --- a/test/unit_tests/arkode/CXX_serial/ark_test_slowerror_brusselator.out +++ b/test/unit_tests/arkode/CXX_serial/ark_test_slowerror_brusselator.out @@ -3,108 +3,108 @@ Slow error estimation test (stiff Brusselator ODE problem): time domain: (0,10] partition size = 20 initial conditions: u0 = 1.2, v0 = 3.1, w0 = 3 - problem parameters: a = 0, b = 0, ep = 0.0004 + problem parameters: a = 1, b = 3.5, ep = 0.0004 MRI method: ARKODE_MRI_GARK_ERK33a (explicit) H 0.025 method ARKODE_MRI_GARK_ERK33a t 0.025 dsm 3.18615e+13 dsm_est 2.87651e+09 - H 0.025 method ARKODE_MRI_GARK_ERK33a t 0.525 dsm 9710.21 dsm_est 2563.86 - H 0.025 method ARKODE_MRI_GARK_ERK33a t 1.025 dsm 3395.18 dsm_est 924.465 - H 0.025 method ARKODE_MRI_GARK_ERK33a t 1.525 dsm 664.284 dsm_est 1834.33 - H 0.025 method ARKODE_MRI_GARK_ERK33a t 2.025 dsm 45.486 dsm_est 1966.18 - H 0.025 method ARKODE_MRI_GARK_ERK33a t 2.525 dsm 194.704 dsm_est 800.323 - H 0.025 method ARKODE_MRI_GARK_ERK33a t 3.025 dsm 2450.84 dsm_est 2266.61 - H 0.025 method ARKODE_MRI_GARK_ERK33a t 3.525 dsm 1673.06 dsm_est 1473.74 - H 0.025 method ARKODE_MRI_GARK_ERK33a t 4.025 dsm 2037.27 dsm_est 761.723 - H 0.025 method ARKODE_MRI_GARK_ERK33a t 4.525 dsm 11645.3 dsm_est 2717.1 - H 0.025 method ARKODE_MRI_GARK_ERK33a t 5.025 dsm 396.447 dsm_est 385.357 - H 0.025 method ARKODE_MRI_GARK_ERK33a t 5.525 dsm 2677.65 dsm_est 2152.57 - H 0.025 method ARKODE_MRI_GARK_ERK33a t 6.025 dsm 23061.5 dsm_est 15279.7 - H 0.025 method ARKODE_MRI_GARK_ERK33a t 6.525 dsm 62044.8 dsm_est 330409 - H 0.025 method ARKODE_MRI_GARK_ERK33a t 7.025 dsm 742178 dsm_est 1.51629e+06 - H 0.025 method ARKODE_MRI_GARK_ERK33a t 7.525 dsm 8906.12 dsm_est 19929.1 - H 0.025 method ARKODE_MRI_GARK_ERK33a t 8.025 dsm 69031 dsm_est 17339.3 - H 0.025 method ARKODE_MRI_GARK_ERK33a t 8.525 dsm 1343.85 dsm_est 2289.77 - H 0.025 method ARKODE_MRI_GARK_ERK33a t 9.025 dsm 9763.15 dsm_est 11148.1 - H 0.025 method ARKODE_MRI_GARK_ERK33a t 9.525 dsm 5068.11 dsm_est 10742.2 + H 0.025 method ARKODE_MRI_GARK_ERK33a t 0.525 dsm 837.406 dsm_est 1222.98 + H 0.025 method ARKODE_MRI_GARK_ERK33a t 1.025 dsm 2348.79 dsm_est 726.699 + H 0.025 method ARKODE_MRI_GARK_ERK33a t 1.525 dsm 7973.51 dsm_est 2607.8 + H 0.025 method ARKODE_MRI_GARK_ERK33a t 2.025 dsm 9623.78 dsm_est 2984.3 + H 0.025 method ARKODE_MRI_GARK_ERK33a t 2.525 dsm 8578.19 dsm_est 2152.09 + H 0.025 method ARKODE_MRI_GARK_ERK33a t 3.025 dsm 1758.42 dsm_est 2231.61 + H 0.025 method ARKODE_MRI_GARK_ERK33a t 3.525 dsm 6231.49 dsm_est 2031.06 + H 0.025 method ARKODE_MRI_GARK_ERK33a t 4.025 dsm 581.953 dsm_est 611.637 + H 0.025 method ARKODE_MRI_GARK_ERK33a t 4.525 dsm 18745.1 dsm_est 4370.47 + H 0.025 method ARKODE_MRI_GARK_ERK33a t 5.025 dsm 1260.35 dsm_est 475.824 + H 0.025 method ARKODE_MRI_GARK_ERK33a t 5.525 dsm 883.239 dsm_est 2069.94 + H 0.025 method ARKODE_MRI_GARK_ERK33a t 6.025 dsm 1948.31 dsm_est 14304.8 + H 0.025 method ARKODE_MRI_GARK_ERK33a t 6.525 dsm 61433.5 dsm_est 330405 + H 0.025 method ARKODE_MRI_GARK_ERK33a t 7.025 dsm 742189 dsm_est 1.51629e+06 + H 0.025 method ARKODE_MRI_GARK_ERK33a t 7.525 dsm 9668.21 dsm_est 19961.4 + H 0.025 method ARKODE_MRI_GARK_ERK33a t 8.025 dsm 893.005 dsm_est 6498.9 + H 0.025 method ARKODE_MRI_GARK_ERK33a t 8.525 dsm 844.884 dsm_est 2277.18 + H 0.025 method ARKODE_MRI_GARK_ERK33a t 9.025 dsm 810.509 dsm_est 10912.2 + H 0.025 method ARKODE_MRI_GARK_ERK33a t 9.525 dsm 1454.42 dsm_est 10680.6 H 0.00625 method ARKODE_MRI_GARK_ERK33a t 0.00625 dsm 4.33933e+11 dsm_est 1.53179e+09 - H 0.00625 method ARKODE_MRI_GARK_ERK33a t 0.50625 dsm 132.32 dsm_est 40.1278 - H 0.00625 method ARKODE_MRI_GARK_ERK33a t 1.00625 dsm 46.7529 dsm_est 14.476 - H 0.00625 method ARKODE_MRI_GARK_ERK33a t 1.50625 dsm 9.95461 dsm_est 28.4157 - H 0.00625 method ARKODE_MRI_GARK_ERK33a t 2.00625 dsm 1.33577 dsm_est 30.7309 - H 0.00625 method ARKODE_MRI_GARK_ERK33a t 2.50625 dsm 3.44185 dsm_est 11.9088 - H 0.00625 method ARKODE_MRI_GARK_ERK33a t 3.00625 dsm 33.4688 dsm_est 35.0999 - H 0.00625 method ARKODE_MRI_GARK_ERK33a t 3.50625 dsm 22.8901 dsm_est 23.0456 - H 0.00625 method ARKODE_MRI_GARK_ERK33a t 4.00625 dsm 27.7324 dsm_est 11.9605 - H 0.00625 method ARKODE_MRI_GARK_ERK33a t 4.50625 dsm 159.5 dsm_est 42.4689 - H 0.00625 method ARKODE_MRI_GARK_ERK33a t 5.00625 dsm 5.51044 dsm_est 5.88584 - H 0.00625 method ARKODE_MRI_GARK_ERK33a t 5.50625 dsm 36.8279 dsm_est 33.2228 - H 0.00625 method ARKODE_MRI_GARK_ERK33a t 6.00625 dsm 315.007 dsm_est 236.943 - H 0.00625 method ARKODE_MRI_GARK_ERK33a t 6.50625 dsm 246.006 dsm_est 5222.77 - H 0.00625 method ARKODE_MRI_GARK_ERK33a t 7.00625 dsm 3236.65 dsm_est 24290.3 - H 0.00625 method ARKODE_MRI_GARK_ERK33a t 7.50625 dsm 99.9089 dsm_est 304.834 - H 0.00625 method ARKODE_MRI_GARK_ERK33a t 8.00625 dsm 938.001 dsm_est 270.44 - H 0.00625 method ARKODE_MRI_GARK_ERK33a t 8.50625 dsm 15.7881 dsm_est 36.4011 - H 0.00625 method ARKODE_MRI_GARK_ERK33a t 9.00625 dsm 132.241 dsm_est 168.298 - H 0.00625 method ARKODE_MRI_GARK_ERK33a t 9.50625 dsm 68.8352 dsm_est 165.971 + H 0.00625 method ARKODE_MRI_GARK_ERK33a t 0.50625 dsm 12.1853 dsm_est 19.2231 + H 0.00625 method ARKODE_MRI_GARK_ERK33a t 1.00625 dsm 32.4451 dsm_est 11.3701 + H 0.00625 method ARKODE_MRI_GARK_ERK33a t 1.50625 dsm 109.586 dsm_est 40.659 + H 0.00625 method ARKODE_MRI_GARK_ERK33a t 2.00625 dsm 131.993 dsm_est 46.7335 + H 0.00625 method ARKODE_MRI_GARK_ERK33a t 2.50625 dsm 117.719 dsm_est 33.46 + H 0.00625 method ARKODE_MRI_GARK_ERK33a t 3.00625 dsm 24.1579 dsm_est 34.5477 + H 0.00625 method ARKODE_MRI_GARK_ERK33a t 3.50625 dsm 85.0006 dsm_est 31.747 + H 0.00625 method ARKODE_MRI_GARK_ERK33a t 4.00625 dsm 7.95919 dsm_est 9.62849 + H 0.00625 method ARKODE_MRI_GARK_ERK33a t 4.50625 dsm 255.567 dsm_est 68.3015 + H 0.00625 method ARKODE_MRI_GARK_ERK33a t 5.00625 dsm 17.322 dsm_est 7.33608 + H 0.00625 method ARKODE_MRI_GARK_ERK33a t 5.50625 dsm 12.3537 dsm_est 31.9016 + H 0.00625 method ARKODE_MRI_GARK_ERK33a t 6.00625 dsm 25.1474 dsm_est 221.476 + H 0.00625 method ARKODE_MRI_GARK_ERK33a t 6.50625 dsm 230.645 dsm_est 5222.75 + H 0.00625 method ARKODE_MRI_GARK_ERK33a t 7.00625 dsm 3236.88 dsm_est 24290.4 + H 0.00625 method ARKODE_MRI_GARK_ERK33a t 7.50625 dsm 116.715 dsm_est 305.487 + H 0.00625 method ARKODE_MRI_GARK_ERK33a t 8.00625 dsm 11.908 dsm_est 101.68 + H 0.00625 method ARKODE_MRI_GARK_ERK33a t 8.50625 dsm 13.9795 dsm_est 36.3543 + H 0.00625 method ARKODE_MRI_GARK_ERK33a t 9.00625 dsm 10.4298 dsm_est 164.536 + H 0.00625 method ARKODE_MRI_GARK_ERK33a t 9.50625 dsm 18.0339 dsm_est 165.001 H 0.0015625 method ARKODE_MRI_GARK_ERK33a t 0.0015625 dsm 4.30937e+09 dsm_est 1.04109e+09 - H 0.0015625 method ARKODE_MRI_GARK_ERK33a t 0.501563 dsm 1.31042 dsm_est 0.627262 - H 0.0015625 method ARKODE_MRI_GARK_ERK33a t 1.00156 dsm 0.497356 dsm_est 0.226316 - H 0.0015625 method ARKODE_MRI_GARK_ERK33a t 1.50156 dsm 0.119634 dsm_est 0.443054 - H 0.0015625 method ARKODE_MRI_GARK_ERK33a t 2.00156 dsm 0.0107271 dsm_est 0.480195 - H 0.0015625 method ARKODE_MRI_GARK_ERK33a t 2.50156 dsm 0.0359355 dsm_est 0.183783 - H 0.0015625 method ARKODE_MRI_GARK_ERK33a t 3.00156 dsm 0.414754 dsm_est 0.547189 - H 0.0015625 method ARKODE_MRI_GARK_ERK33a t 3.50156 dsm 0.282576 dsm_est 0.36015 - H 0.0015625 method ARKODE_MRI_GARK_ERK33a t 4.00156 dsm 0.344442 dsm_est 0.187109 - H 0.0015625 method ARKODE_MRI_GARK_ERK33a t 4.50156 dsm 1.97083 dsm_est 0.663632 - H 0.0015625 method ARKODE_MRI_GARK_ERK33a t 5.00156 dsm 0.0684921 dsm_est 0.0914409 - H 0.0015625 method ARKODE_MRI_GARK_ERK33a t 5.50156 dsm 0.456656 dsm_est 0.517502 - H 0.0015625 method ARKODE_MRI_GARK_ERK33a t 6.00156 dsm 3.91728 dsm_est 3.69502 - H 0.0015625 method ARKODE_MRI_GARK_ERK33a t 6.50156 dsm 1.31633 dsm_est 81.802 - H 0.0015625 method ARKODE_MRI_GARK_ERK33a t 7.00156 dsm 12.9885 dsm_est 381.511 - H 0.0015625 method ARKODE_MRI_GARK_ERK33a t 7.50156 dsm 1.20582 dsm_est 4.73474 - H 0.0015625 method ARKODE_MRI_GARK_ERK33a t 8.00156 dsm 9.73269 dsm_est 4.22374 - H 0.0015625 method ARKODE_MRI_GARK_ERK33a t 8.50156 dsm 0.150084 dsm_est 0.571209 - H 0.0015625 method ARKODE_MRI_GARK_ERK33a t 9.00156 dsm 1.63694 dsm_est 2.60698 - H 0.0015625 method ARKODE_MRI_GARK_ERK33a t 9.50156 dsm 0.68322 dsm_est 2.58585 + H 0.0015625 method ARKODE_MRI_GARK_ERK33a t 0.501563 dsm 0.124019 dsm_est 0.300808 + H 0.0015625 method ARKODE_MRI_GARK_ERK33a t 1.00156 dsm 0.4016 dsm_est 0.177725 + H 0.0015625 method ARKODE_MRI_GARK_ERK33a t 1.50156 dsm 1.08417 dsm_est 0.634969 + H 0.0015625 method ARKODE_MRI_GARK_ERK33a t 2.00156 dsm 1.63593 dsm_est 0.730608 + H 0.0015625 method ARKODE_MRI_GARK_ERK33a t 2.50156 dsm 1.21684 dsm_est 0.522198 + H 0.0015625 method ARKODE_MRI_GARK_ERK33a t 3.00156 dsm 0.297567 dsm_est 0.53854 + H 0.0015625 method ARKODE_MRI_GARK_ERK33a t 3.50156 dsm 0.843901 dsm_est 0.496086 + H 0.0015625 method ARKODE_MRI_GARK_ERK33a t 4.00156 dsm 0.0984512 dsm_est 0.150722 + H 0.0015625 method ARKODE_MRI_GARK_ERK33a t 4.50156 dsm 3.172 dsm_est 1.06726 + H 0.0015625 method ARKODE_MRI_GARK_ERK33a t 5.00156 dsm 0.177228 dsm_est 0.114247 + H 0.0015625 method ARKODE_MRI_GARK_ERK33a t 5.50156 dsm 0.153004 dsm_est 0.496739 + H 0.0015625 method ARKODE_MRI_GARK_ERK33a t 6.00156 dsm 0.2503 dsm_est 3.45242 + H 0.0015625 method ARKODE_MRI_GARK_ERK33a t 6.50156 dsm 0.94962 dsm_est 81.8018 + H 0.0015625 method ARKODE_MRI_GARK_ERK33a t 7.00156 dsm 12.9921 dsm_est 381.512 + H 0.0015625 method ARKODE_MRI_GARK_ERK33a t 7.50156 dsm 1.43794 dsm_est 4.74552 + H 0.0015625 method ARKODE_MRI_GARK_ERK33a t 8.00156 dsm 0.120488 dsm_est 1.58917 + H 0.0015625 method ARKODE_MRI_GARK_ERK33a t 8.50156 dsm 0.179682 dsm_est 0.571046 + H 0.0015625 method ARKODE_MRI_GARK_ERK33a t 9.00156 dsm 0.118533 dsm_est 2.54788 + H 0.0015625 method ARKODE_MRI_GARK_ERK33a t 9.50156 dsm 0.220342 dsm_est 2.57065 H 0.000390625 method ARKODE_MRI_GARK_ERK33a t 0.000390625 dsm 2.73843e+07 dsm_est 2.97866e+07 - H 0.000390625 method ARKODE_MRI_GARK_ERK33a t 0.500391 dsm 0.00790675 dsm_est 0.00980231 - H 0.000390625 method ARKODE_MRI_GARK_ERK33a t 1.00039 dsm 0.00278359 dsm_est 0.00353684 - H 0.000390625 method ARKODE_MRI_GARK_ERK33a t 1.50039 dsm 0.000577287 dsm_est 0.00691933 - H 0.000390625 method ARKODE_MRI_GARK_ERK33a t 2.00039 dsm 6.43416e-05 dsm_est 0.0075032 - H 0.000390625 method ARKODE_MRI_GARK_ERK33a t 2.50039 dsm 0.000173927 dsm_est 0.00286286 - H 0.000390625 method ARKODE_MRI_GARK_ERK33a t 3.00039 dsm 0.00199524 dsm_est 0.00854497 - H 0.000390625 method ARKODE_MRI_GARK_ERK33a t 3.50039 dsm 0.00135961 dsm_est 0.00562669 - H 0.000390625 method ARKODE_MRI_GARK_ERK33a t 4.00039 dsm 0.00165695 dsm_est 0.00292461 - H 0.000390625 method ARKODE_MRI_GARK_ERK33a t 4.50039 dsm 0.00948223 dsm_est 0.0103697 - H 0.000390625 method ARKODE_MRI_GARK_ERK33a t 5.00039 dsm 0.000328768 dsm_est 0.00142679 - H 0.000390625 method ARKODE_MRI_GARK_ERK33a t 5.50039 dsm 0.00219767 dsm_est 0.00807905 - H 0.000390625 method ARKODE_MRI_GARK_ERK33a t 6.00039 dsm 0.0188505 dsm_est 0.0577057 - H 0.000390625 method ARKODE_MRI_GARK_ERK33a t 6.50039 dsm 0.00584 dsm_est 1.27889 - H 0.000390625 method ARKODE_MRI_GARK_ERK33a t 7.00039 dsm 0.0510766 dsm_est 5.96838 - H 0.000390625 method ARKODE_MRI_GARK_ERK33a t 7.50039 dsm 0.00578518 dsm_est 0.0738676 - H 0.000390625 method ARKODE_MRI_GARK_ERK33a t 8.00039 dsm 0.0560528 dsm_est 0.0659878 - H 0.000390625 method ARKODE_MRI_GARK_ERK33a t 8.50039 dsm 0.000893002 dsm_est 0.008934 - H 0.000390625 method ARKODE_MRI_GARK_ERK33a t 9.00039 dsm 0.00787258 dsm_est 0.0406446 - H 0.000390625 method ARKODE_MRI_GARK_ERK33a t 9.50039 dsm 0.00408635 dsm_est 0.0403739 + H 0.000390625 method ARKODE_MRI_GARK_ERK33a t 0.500391 dsm 0.00068624 dsm_est 0.0047023 + H 0.000390625 method ARKODE_MRI_GARK_ERK33a t 1.00039 dsm 0.00193295 dsm_est 0.00277776 + H 0.000390625 method ARKODE_MRI_GARK_ERK33a t 1.50039 dsm 0.00652841 dsm_est 0.00992033 + H 0.000390625 method ARKODE_MRI_GARK_ERK33a t 2.00039 dsm 0.007873 dsm_est 0.0114175 + H 0.000390625 method ARKODE_MRI_GARK_ERK33a t 2.50039 dsm 0.00699861 dsm_est 0.00815712 + H 0.000390625 method ARKODE_MRI_GARK_ERK33a t 3.00039 dsm 0.00143196 dsm_est 0.00840977 + H 0.000390625 method ARKODE_MRI_GARK_ERK33a t 3.50039 dsm 0.00507095 dsm_est 0.00775126 + H 0.000390625 method ARKODE_MRI_GARK_ERK33a t 4.00039 dsm 0.000473416 dsm_est 0.00235627 + H 0.000390625 method ARKODE_MRI_GARK_ERK33a t 4.50039 dsm 0.0152611 dsm_est 0.016676 + H 0.000390625 method ARKODE_MRI_GARK_ERK33a t 5.00039 dsm 0.00103306 dsm_est 0.00178339 + H 0.000390625 method ARKODE_MRI_GARK_ERK33a t 5.50039 dsm 0.000737183 dsm_est 0.00775511 + H 0.000390625 method ARKODE_MRI_GARK_ERK33a t 6.00039 dsm 0.00150366 dsm_est 0.0539128 + H 0.000390625 method ARKODE_MRI_GARK_ERK33a t 6.50039 dsm 0.00386116 dsm_est 1.27888 + H 0.000390625 method ARKODE_MRI_GARK_ERK33a t 7.00039 dsm 0.0511054 dsm_est 5.9684 + H 0.000390625 method ARKODE_MRI_GARK_ERK33a t 7.50039 dsm 0.00692145 dsm_est 0.074037 + H 0.000390625 method ARKODE_MRI_GARK_ERK33a t 8.00039 dsm 0.00073325 dsm_est 0.0248322 + H 0.000390625 method ARKODE_MRI_GARK_ERK33a t 8.50039 dsm 0.000872562 dsm_est 0.00893466 + H 0.000390625 method ARKODE_MRI_GARK_ERK33a t 9.00039 dsm 0.000621579 dsm_est 0.0397209 + H 0.000390625 method ARKODE_MRI_GARK_ERK33a t 9.50039 dsm 0.00106005 dsm_est 0.0401378 H 9.76563e-05 method ARKODE_MRI_GARK_ERK33a t 9.76563e-05 dsm 130431 dsm_est 498019 - H 9.76563e-05 method ARKODE_MRI_GARK_ERK33a t 0.500098 dsm 3.50953e-05 dsm_est 0.000152579 - H 9.76563e-05 method ARKODE_MRI_GARK_ERK33a t 1.0001 dsm 1.24764e-05 dsm_est 5.49428e-05 - H 9.76563e-05 method ARKODE_MRI_GARK_ERK33a t 1.5001 dsm 2.33422e-06 dsm_est 0.000108153 - H 9.76563e-05 method ARKODE_MRI_GARK_ERK33a t 2.0001 dsm 7.27936e-07 dsm_est 0.000117276 - H 9.76563e-05 method ARKODE_MRI_GARK_ERK33a t 2.5001 dsm 9.82143e-07 dsm_est 4.49931e-05 - H 9.76563e-05 method ARKODE_MRI_GARK_ERK33a t 3.0001 dsm 8.84859e-06 dsm_est 0.000133946 - H 9.76563e-05 method ARKODE_MRI_GARK_ERK33a t 3.5001 dsm 6.72064e-06 dsm_est 8.87346e-05 - H 9.76563e-05 method ARKODE_MRI_GARK_ERK33a t 4.0001 dsm 8.08105e-06 dsm_est 4.63154e-05 - H 9.76563e-05 method ARKODE_MRI_GARK_ERK33a t 4.5001 dsm 4.2385e-05 dsm_est 0.000162368 - H 9.76563e-05 method ARKODE_MRI_GARK_ERK33a t 5.0001 dsm 1.89051e-06 dsm_est 2.23151e-05 - H 9.76563e-05 method ARKODE_MRI_GARK_ERK33a t 5.5001 dsm 1.09591e-05 dsm_est 0.000126182 - H 9.76563e-05 method ARKODE_MRI_GARK_ERK33a t 6.0001 dsm 8.40237e-05 dsm_est 0.00090171 - H 9.76563e-05 method ARKODE_MRI_GARK_ERK33a t 6.5001 dsm 2.61573e-05 dsm_est 0.0199867 - H 9.76563e-05 method ARKODE_MRI_GARK_ERK33a t 7.0001 dsm 0.000200076 dsm_est 0.0932838 - H 9.76563e-05 method ARKODE_MRI_GARK_ERK33a t 7.5001 dsm 2.64767e-05 dsm_est 0.00115263 - H 9.76563e-05 method ARKODE_MRI_GARK_ERK33a t 8.0001 dsm 0.000250009 dsm_est 0.00103107 - H 9.76563e-05 method ARKODE_MRI_GARK_ERK33a t 8.5001 dsm 5.56659e-06 dsm_est 0.000140649 - H 9.76563e-05 method ARKODE_MRI_GARK_ERK33a t 9.0001 dsm 3.51966e-05 dsm_est 0.000633732 - H 9.76563e-05 method ARKODE_MRI_GARK_ERK33a t 9.5001 dsm 1.83527e-05 dsm_est 0.000631456 + H 9.76563e-05 method ARKODE_MRI_GARK_ERK33a t 0.500098 dsm 3.22403e-06 dsm_est 7.35991e-05 + H 9.76563e-05 method ARKODE_MRI_GARK_ERK33a t 1.0001 dsm 8.81057e-06 dsm_est 4.30975e-05 + H 9.76563e-05 method ARKODE_MRI_GARK_ERK33a t 1.5001 dsm 2.85071e-05 dsm_est 0.000154738 + H 9.76563e-05 method ARKODE_MRI_GARK_ERK33a t 2.0001 dsm 3.50798e-05 dsm_est 0.000177855 + H 9.76563e-05 method ARKODE_MRI_GARK_ERK33a t 2.5001 dsm 3.14166e-05 dsm_est 0.000127273 + H 9.76563e-05 method ARKODE_MRI_GARK_ERK33a t 3.0001 dsm 6.57531e-06 dsm_est 0.000131139 + H 9.76563e-05 method ARKODE_MRI_GARK_ERK33a t 3.5001 dsm 2.19174e-05 dsm_est 0.000120883 + H 9.76563e-05 method ARKODE_MRI_GARK_ERK33a t 4.0001 dsm 1.46115e-06 dsm_est 3.65453e-05 + H 9.76563e-05 method ARKODE_MRI_GARK_ERK33a t 4.5001 dsm 6.79441e-05 dsm_est 0.000260953 + H 9.76563e-05 method ARKODE_MRI_GARK_ERK33a t 5.0001 dsm 4.44856e-06 dsm_est 2.79151e-05 + H 9.76563e-05 method ARKODE_MRI_GARK_ERK33a t 5.5001 dsm 3.89141e-06 dsm_est 0.000121321 + H 9.76563e-05 method ARKODE_MRI_GARK_ERK33a t 6.0001 dsm 7.43691e-06 dsm_est 0.000842843 + H 9.76563e-05 method ARKODE_MRI_GARK_ERK33a t 6.5001 dsm 1.887e-05 dsm_est 0.0199854 + H 9.76563e-05 method ARKODE_MRI_GARK_ERK33a t 7.0001 dsm 0.00020015 dsm_est 0.0932838 + H 9.76563e-05 method ARKODE_MRI_GARK_ERK33a t 7.5001 dsm 3.10301e-05 dsm_est 0.00115562 + H 9.76563e-05 method ARKODE_MRI_GARK_ERK33a t 8.0001 dsm 4.87344e-06 dsm_est 0.00038836 + H 9.76563e-05 method ARKODE_MRI_GARK_ERK33a t 8.5001 dsm 3.86449e-06 dsm_est 0.000139579 + H 9.76563e-05 method ARKODE_MRI_GARK_ERK33a t 9.0001 dsm 4.17539e-06 dsm_est 0.000619455 + H 9.76563e-05 method ARKODE_MRI_GARK_ERK33a t 9.5001 dsm 4.45287e-06 dsm_est 0.000626933 ARKODE_MRI_GARK_ERK33a summary: Stepsize 0.025 maxdsm 3.18615e+13 maxdsmest 2.87651e+09 diff --git a/test/unit_tests/arkode/CXX_serial/ark_test_slowerror_kpr.out b/test/unit_tests/arkode/CXX_serial/ark_test_slowerror_kpr.out index 390ca5a056..21eb6c79f2 100644 --- a/test/unit_tests/arkode/CXX_serial/ark_test_slowerror_kpr.out +++ b/test/unit_tests/arkode/CXX_serial/ark_test_slowerror_kpr.out @@ -32,21 +32,21 @@ Slow error estimation test (Nonlinear Kvaerno-Prothero-Robinson problem): H 0.003125 method ARKODE_MRI_GARK_ERK33a t 1.25313 dsm 37.2232 dsm_est 3954.15 H 0.003125 method ARKODE_MRI_GARK_ERK33a t 1.50313 dsm 17.7805 dsm_est 786.062 H 0.003125 method ARKODE_MRI_GARK_ERK33a t 1.75313 dsm 58.1561 dsm_est 2999.34 - H 0.003125 method ARKODE_MRI_GARK_ERK33a t 2.00312 dsm 0.615846 dsm_est 764.348 + H 0.003125 method ARKODE_MRI_GARK_ERK33a t 2.00312 dsm 0.615847 dsm_est 764.348 H 0.003125 method ARKODE_MRI_GARK_ERK33a t 2.25312 dsm 0.208735 dsm_est 542.352 H 0.003125 method ARKODE_MRI_GARK_ERK33a t 2.50312 dsm 1.15342 dsm_est 106.225 H 0.003125 method ARKODE_MRI_GARK_ERK33a t 2.75312 dsm 1.54621 dsm_est 59.6688 H 0.003125 method ARKODE_MRI_GARK_ERK33a t 3.00312 dsm 1.18391 dsm_est 80.2941 H 0.003125 method ARKODE_MRI_GARK_ERK33a t 3.25312 dsm 1.00984 dsm_est 46.1362 - H 0.003125 method ARKODE_MRI_GARK_ERK33a t 3.50312 dsm 0.853891 dsm_est 19.4476 - H 0.003125 method ARKODE_MRI_GARK_ERK33a t 3.75312 dsm 0.637603 dsm_est 20.4096 + H 0.003125 method ARKODE_MRI_GARK_ERK33a t 3.50312 dsm 0.853892 dsm_est 19.4476 + H 0.003125 method ARKODE_MRI_GARK_ERK33a t 3.75312 dsm 0.637605 dsm_est 20.4096 H 0.003125 method ARKODE_MRI_GARK_ERK33a t 4.00312 dsm 0.50676 dsm_est 35.5067 H 0.003125 method ARKODE_MRI_GARK_ERK33a t 4.25312 dsm 0.0997811 dsm_est 197.159 - H 0.003125 method ARKODE_MRI_GARK_ERK33a t 4.50312 dsm 0.602658 dsm_est 244.1 + H 0.003125 method ARKODE_MRI_GARK_ERK33a t 4.50312 dsm 0.60266 dsm_est 244.1 H 0.003125 method ARKODE_MRI_GARK_ERK33a t 4.75312 dsm 0.3657 dsm_est 59.8484 - H 0.00078125 method ARKODE_MRI_GARK_ERK33a t 0.00078125 dsm 0.000906789 dsm_est 0.1702 + H 0.00078125 method ARKODE_MRI_GARK_ERK33a t 0.00078125 dsm 0.000907653 dsm_est 0.1702 H 0.00078125 method ARKODE_MRI_GARK_ERK33a t 0.250781 dsm 0.00229725 dsm_est 1.09748 - H 0.00078125 method ARKODE_MRI_GARK_ERK33a t 0.500781 dsm 0.00528907 dsm_est 8.25834 + H 0.00078125 method ARKODE_MRI_GARK_ERK33a t 0.500781 dsm 0.0052905 dsm_est 8.25834 H 0.00078125 method ARKODE_MRI_GARK_ERK33a t 0.750781 dsm 0.0112664 dsm_est 8.18019 H 0.00078125 method ARKODE_MRI_GARK_ERK33a t 1.00078 dsm 0.0172485 dsm_est 0.149038 H 0.00078125 method ARKODE_MRI_GARK_ERK33a t 1.25078 dsm 0.162364 dsm_est 60.7616 @@ -55,59 +55,59 @@ Slow error estimation test (Nonlinear Kvaerno-Prothero-Robinson problem): H 0.00078125 method ARKODE_MRI_GARK_ERK33a t 2.00078 dsm 0.00251159 dsm_est 11.9018 H 0.00078125 method ARKODE_MRI_GARK_ERK33a t 2.25078 dsm 0.000388484 dsm_est 8.4539 H 0.00078125 method ARKODE_MRI_GARK_ERK33a t 2.50078 dsm 0.00453393 dsm_est 1.64038 - H 0.00078125 method ARKODE_MRI_GARK_ERK33a t 2.75078 dsm 0.00608412 dsm_est 0.901588 + H 0.00078125 method ARKODE_MRI_GARK_ERK33a t 2.75078 dsm 0.00608272 dsm_est 0.90159 H 0.00078125 method ARKODE_MRI_GARK_ERK33a t 3.00078 dsm 0.00463348 dsm_est 1.26635 - H 0.00078125 method ARKODE_MRI_GARK_ERK33a t 3.25078 dsm 0.00394414 dsm_est 0.719303 - H 0.00078125 method ARKODE_MRI_GARK_ERK33a t 3.50078 dsm 0.00333765 dsm_est 0.302408 + H 0.00078125 method ARKODE_MRI_GARK_ERK33a t 3.25078 dsm 0.00394421 dsm_est 0.719304 + H 0.00078125 method ARKODE_MRI_GARK_ERK33a t 3.50078 dsm 0.00333748 dsm_est 0.302407 H 0.00078125 method ARKODE_MRI_GARK_ERK33a t 3.75078 dsm 0.00249229 dsm_est 0.318005 H 0.00078125 method ARKODE_MRI_GARK_ERK33a t 4.00078 dsm 0.00197527 dsm_est 0.548996 H 0.00078125 method ARKODE_MRI_GARK_ERK33a t 4.25078 dsm 0.000423031 dsm_est 3.07331 H 0.00078125 method ARKODE_MRI_GARK_ERK33a t 4.50078 dsm 0.00226465 dsm_est 3.80981 - H 0.00078125 method ARKODE_MRI_GARK_ERK33a t 4.75078 dsm 0.00143499 dsm_est 0.942031 - H 0.000195313 method ARKODE_MRI_GARK_ERK33a t 0.000195313 dsm 2.85013e-06 dsm_est 0.00265424 - H 0.000195313 method ARKODE_MRI_GARK_ERK33a t 0.250195 dsm 9.05953e-06 dsm_est 0.0171084 + H 0.00078125 method ARKODE_MRI_GARK_ERK33a t 4.75078 dsm 0.00143601 dsm_est 0.942032 + H 0.000195313 method ARKODE_MRI_GARK_ERK33a t 0.000195313 dsm 3.24965e-06 dsm_est 0.00265343 + H 0.000195313 method ARKODE_MRI_GARK_ERK33a t 0.250195 dsm 9.45845e-06 dsm_est 0.0171085 H 0.000195313 method ARKODE_MRI_GARK_ERK33a t 0.500195 dsm 2.05759e-05 dsm_est 0.129079 - H 0.000195313 method ARKODE_MRI_GARK_ERK33a t 0.750195 dsm 4.6605e-05 dsm_est 0.127987 - H 0.000195313 method ARKODE_MRI_GARK_ERK33a t 1.0002 dsm 6.66547e-05 dsm_est 0.00213263 + H 0.000195313 method ARKODE_MRI_GARK_ERK33a t 0.750195 dsm 4.54636e-05 dsm_est 0.127986 + H 0.000195313 method ARKODE_MRI_GARK_ERK33a t 1.0002 dsm 6.66187e-05 dsm_est 0.00213239 H 0.000195313 method ARKODE_MRI_GARK_ERK33a t 1.2502 dsm 0.000653038 dsm_est 0.945246 H 0.000195313 method ARKODE_MRI_GARK_ERK33a t 1.5002 dsm 0.000267427 dsm_est 0.186783 - H 0.000195313 method ARKODE_MRI_GARK_ERK33a t 1.7502 dsm 0.000909834 dsm_est 0.751614 - H 0.000195313 method ARKODE_MRI_GARK_ERK33a t 2.0002 dsm 1.02331e-05 dsm_est 0.185807 - H 0.000195313 method ARKODE_MRI_GARK_ERK33a t 2.2502 dsm 1.54333e-06 dsm_est 0.132009 - H 0.000195313 method ARKODE_MRI_GARK_ERK33a t 2.5002 dsm 1.7004e-05 dsm_est 0.0255566 + H 0.000195313 method ARKODE_MRI_GARK_ERK33a t 1.7502 dsm 0.000909843 dsm_est 0.751614 + H 0.000195313 method ARKODE_MRI_GARK_ERK33a t 2.0002 dsm 1.01505e-05 dsm_est 0.185806 + H 0.000195313 method ARKODE_MRI_GARK_ERK33a t 2.2502 dsm 2.03685e-06 dsm_est 0.132009 + H 0.000195313 method ARKODE_MRI_GARK_ERK33a t 2.5002 dsm 1.75355e-05 dsm_est 0.025555 H 0.000195313 method ARKODE_MRI_GARK_ERK33a t 2.7502 dsm 2.75731e-05 dsm_est 0.0139673 - H 0.000195313 method ARKODE_MRI_GARK_ERK33a t 3.0002 dsm 1.60122e-05 dsm_est 0.0198318 - H 0.000195313 method ARKODE_MRI_GARK_ERK33a t 3.2502 dsm 1.59604e-05 dsm_est 0.0112328 + H 0.000195313 method ARKODE_MRI_GARK_ERK33a t 3.0002 dsm 1.65995e-05 dsm_est 0.0198329 + H 0.000195313 method ARKODE_MRI_GARK_ERK33a t 3.2502 dsm 1.74696e-05 dsm_est 0.0112335 H 0.000195313 method ARKODE_MRI_GARK_ERK33a t 3.5002 dsm 1.2611e-05 dsm_est 0.00471821 - H 0.000195313 method ARKODE_MRI_GARK_ERK33a t 3.7502 dsm 1.0072e-05 dsm_est 0.00496521 - H 0.000195313 method ARKODE_MRI_GARK_ERK33a t 4.0002 dsm 7.64165e-06 dsm_est 0.00855534 + H 0.000195313 method ARKODE_MRI_GARK_ERK33a t 3.7502 dsm 1.02048e-05 dsm_est 0.00496587 + H 0.000195313 method ARKODE_MRI_GARK_ERK33a t 4.0002 dsm 6.90932e-06 dsm_est 0.00855639 H 0.000195313 method ARKODE_MRI_GARK_ERK33a t 4.2502 dsm 3.12732e-06 dsm_est 0.0479914 - H 0.000195313 method ARKODE_MRI_GARK_ERK33a t 4.5002 dsm 6.25467e-06 dsm_est 0.0595107 - H 0.000195313 method ARKODE_MRI_GARK_ERK33a t 4.7502 dsm 1.05712e-05 dsm_est 0.0147462 + H 0.000195313 method ARKODE_MRI_GARK_ERK33a t 4.5002 dsm 6.7755e-06 dsm_est 0.0595108 + H 0.000195313 method ARKODE_MRI_GARK_ERK33a t 4.7502 dsm 1.07392e-05 dsm_est 0.0147462 H 4.88281e-05 method ARKODE_MRI_GARK_ERK33a t 4.88281e-05 dsm 2.01535e-06 dsm_est 4.1115e-05 H 4.88281e-05 method ARKODE_MRI_GARK_ERK33a t 0.250049 dsm 0 dsm_est 0.000267507 - H 4.88281e-05 method ARKODE_MRI_GARK_ERK33a t 0.500049 dsm 1.50297e-06 dsm_est 0.00201586 - H 4.88281e-05 method ARKODE_MRI_GARK_ERK33a t 0.750049 dsm 1.49086e-06 dsm_est 0.00200068 + H 4.88281e-05 method ARKODE_MRI_GARK_ERK33a t 0.500049 dsm 0 dsm_est 0.00201736 + H 4.88281e-05 method ARKODE_MRI_GARK_ERK33a t 0.750049 dsm 1.15371e-06 dsm_est 0.00200067 H 4.88281e-05 method ARKODE_MRI_GARK_ERK33a t 1.00005 dsm 9.78971e-07 dsm_est 3.2652e-05 - H 4.88281e-05 method ARKODE_MRI_GARK_ERK33a t 1.25005 dsm 3.17142e-06 dsm_est 0.0147541 - H 4.88281e-05 method ARKODE_MRI_GARK_ERK33a t 1.50005 dsm 2.18254e-06 dsm_est 0.0029151 + H 4.88281e-05 method ARKODE_MRI_GARK_ERK33a t 1.25005 dsm 4.617e-06 dsm_est 0.0147526 + H 4.88281e-05 method ARKODE_MRI_GARK_ERK33a t 1.50005 dsm 1.89456e-06 dsm_est 0.00291509 H 4.88281e-05 method ARKODE_MRI_GARK_ERK33a t 1.75005 dsm 2.39243e-06 dsm_est 0.0117588 H 4.88281e-05 method ARKODE_MRI_GARK_ERK33a t 2.00005 dsm 1.0054e-06 dsm_est 0.00290265 - H 4.88281e-05 method ARKODE_MRI_GARK_ERK33a t 2.25005 dsm 2.03676e-06 dsm_est 0.00206178 - H 4.88281e-05 method ARKODE_MRI_GARK_ERK33a t 2.50005 dsm 3.37798e-06 dsm_est 0.000398446 - H 4.88281e-05 method ARKODE_MRI_GARK_ERK33a t 2.75005 dsm 4.72989e-06 dsm_est 0.000217912 - H 4.88281e-05 method ARKODE_MRI_GARK_ERK33a t 3.00005 dsm 6.95491e-06 dsm_est 0.000310377 + H 4.88281e-05 method ARKODE_MRI_GARK_ERK33a t 2.25005 dsm 3.36053e-06 dsm_est 0.00206332 + H 4.88281e-05 method ARKODE_MRI_GARK_ERK33a t 2.50005 dsm 4.81145e-06 dsm_est 0.000399972 + H 4.88281e-05 method ARKODE_MRI_GARK_ERK33a t 2.75005 dsm 3.34545e-06 dsm_est 0.000216445 + H 4.88281e-05 method ARKODE_MRI_GARK_ERK33a t 3.00005 dsm 5.65058e-06 dsm_est 0.000309645 H 4.88281e-05 method ARKODE_MRI_GARK_ERK33a t 3.25005 dsm 1.55004e-06 dsm_est 0.000175458 H 4.88281e-05 method ARKODE_MRI_GARK_ERK33a t 3.50005 dsm 9.19766e-07 dsm_est 7.37004e-05 H 4.88281e-05 method ARKODE_MRI_GARK_ERK33a t 3.75005 dsm 0 dsm_est 7.66833e-05 - H 4.88281e-05 method ARKODE_MRI_GARK_ERK33a t 4.00005 dsm 1.08798e-06 dsm_est 0.000134086 - H 4.88281e-05 method ARKODE_MRI_GARK_ERK33a t 4.25005 dsm 3.12694e-06 dsm_est 0.000748179 - H 4.88281e-05 method ARKODE_MRI_GARK_ERK33a t 4.50005 dsm 1.16508e-06 dsm_est 0.000930348 + H 4.88281e-05 method ARKODE_MRI_GARK_ERK33a t 4.00005 dsm 2.55629e-06 dsm_est 0.000133394 + H 4.88281e-05 method ARKODE_MRI_GARK_ERK33a t 4.25005 dsm 4.47754e-06 dsm_est 0.000749612 + H 4.88281e-05 method ARKODE_MRI_GARK_ERK33a t 4.50005 dsm 0 dsm_est 0.000930338 H 4.88281e-05 method ARKODE_MRI_GARK_ERK33a t 4.75005 dsm 6.40365e-06 dsm_est 0.000231401 ARKODE_MRI_GARK_ERK33a summary: Stepsize 0.0125 maxdsm 13680.4 maxdsmest 267128 Stepsize 0.003125 maxdsm 58.1561 maxdsmest 3954.15 Stepsize 0.00078125 maxdsm 0.231817 maxdsmest 60.7616 - Stepsize 0.000195313 maxdsm 0.000909834 maxdsmest 0.945246 - Stepsize 4.88281e-05 maxdsm 6.95491e-06 maxdsmest 0.0147541 + Stepsize 0.000195313 maxdsm 0.000909843 maxdsmest 0.945246 + Stepsize 4.88281e-05 maxdsm 6.40365e-06 maxdsmest 0.0147526 From f30ebc8a3856da646465c803f7952cb3d1cdaeaf Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Thu, 12 Sep 2024 16:41:56 -0500 Subject: [PATCH 065/286] Moved check for controller type to only occur for adaptive runs --- src/arkode/arkode_mristep.c | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/src/arkode/arkode_mristep.c b/src/arkode/arkode_mristep.c index 334ef31d8a..b9e386c21f 100644 --- a/src/arkode/arkode_mristep.c +++ b/src/arkode/arkode_mristep.c @@ -1233,17 +1233,6 @@ int mriStep_Init(ARKodeMem ark_mem, int init_type) } } - /* get timestep adaptivity type, and return an error if an - incompatible type is detected */ - adapt_type = SUNAdaptController_GetType(ark_mem->hadapt_mem->hcontroller); - if ((adapt_type != SUN_ADAPTCONTROLLER_MRI_TOL) && - (adapt_type != SUN_ADAPTCONTROLLER_H)) - { - arkProcessError(ark_mem, ARK_ILL_INPUT, __LINE__, __func__, __FILE__, - "SUNAdaptController type is unsupported by MRIStep"); - return (ARK_ILL_INPUT); - } - /*** Perform timestep adaptivity checks and initial setup ***/ if (ark_mem->fixedstep) @@ -1259,6 +1248,18 @@ int mriStep_Init(ARKodeMem ark_mem, int init_type) } else { + + /* get timestep adaptivity type, and return an error if an + incompatible type is detected */ + adapt_type = SUNAdaptController_GetType(ark_mem->hadapt_mem->hcontroller); + if ((adapt_type != SUN_ADAPTCONTROLLER_MRI_TOL) && + (adapt_type != SUN_ADAPTCONTROLLER_H)) + { + arkProcessError(ark_mem, ARK_ILL_INPUT, __LINE__, __func__, __FILE__, + "SUNAdaptController type is unsupported by MRIStep"); + return (ARK_ILL_INPUT); + } + /* Controller provides adaptivity (at least at the slow time scale): - verify that the MRI method includes an embedding, and - estimate initial slow step size (store in ark_mem->hin) */ From 4269e128e023c324c337489d178d6e793e2941d3 Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Thu, 12 Sep 2024 16:47:20 -0500 Subject: [PATCH 066/286] minor fix --- src/arkode/arkode_mristep.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/arkode/arkode_mristep.c b/src/arkode/arkode_mristep.c index b9e386c21f..8d059f4081 100644 --- a/src/arkode/arkode_mristep.c +++ b/src/arkode/arkode_mristep.c @@ -1235,6 +1235,9 @@ int mriStep_Init(ARKodeMem ark_mem, int init_type) /*** Perform timestep adaptivity checks and initial setup ***/ + /* get timestep adaptivity type */ + adapt_type = SUNAdaptController_GetType(ark_mem->hadapt_mem->hcontroller); + if (ark_mem->fixedstep) { /* Non-adaptive controller: user must have supplied initial step @@ -1249,9 +1252,7 @@ int mriStep_Init(ARKodeMem ark_mem, int init_type) else { - /* get timestep adaptivity type, and return an error if an - incompatible type is detected */ - adapt_type = SUNAdaptController_GetType(ark_mem->hadapt_mem->hcontroller); + /* ensure that a compatible adaptivity controller is provided */ if ((adapt_type != SUN_ADAPTCONTROLLER_MRI_TOL) && (adapt_type != SUN_ADAPTCONTROLLER_H)) { From 8d6dc7c2d95a0146a0309b19ca78e86abe11184d Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Thu, 12 Sep 2024 16:54:47 -0500 Subject: [PATCH 067/286] formatting --- src/arkode/arkode_mristep.c | 1 - 1 file changed, 1 deletion(-) diff --git a/src/arkode/arkode_mristep.c b/src/arkode/arkode_mristep.c index 8d059f4081..9bf2fc6a15 100644 --- a/src/arkode/arkode_mristep.c +++ b/src/arkode/arkode_mristep.c @@ -1251,7 +1251,6 @@ int mriStep_Init(ARKodeMem ark_mem, int init_type) } else { - /* ensure that a compatible adaptivity controller is provided */ if ((adapt_type != SUN_ADAPTCONTROLLER_MRI_TOL) && (adapt_type != SUN_ADAPTCONTROLLER_H)) From 8729ed25dbaf26d279d96422834ede6caf1be82e Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Thu, 19 Sep 2024 17:14:58 -0500 Subject: [PATCH 068/286] Fixed error in ark_brusselator1D_FEM_sludist (needed to initialize the stepper before calling rfun) --- src/arkode/arkode.c | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/src/arkode/arkode.c b/src/arkode/arkode.c index 93811720e7..b39b36085f 100644 --- a/src/arkode/arkode.c +++ b/src/arkode/arkode.c @@ -1819,6 +1819,21 @@ int arkInitialSetup(ARKodeMem ark_mem, sunrealtype tout) return (ARK_ILL_INPUT); } + /* Set up the time stepper module */ + if (ark_mem->step_init == NULL) + { + arkProcessError(ark_mem, ARK_ILL_INPUT, __LINE__, __func__, __FILE__, + "Time stepper module is missing"); + return (ARK_ILL_INPUT); + } + retval = ark_mem->step_init(ark_mem, ark_mem->init_type); + if (retval != ARK_SUCCESS) + { + arkProcessError(ark_mem, retval, __LINE__, __func__, __FILE__, + "Error in initialization of time stepper module"); + return (retval); + } + /* Load initial residual weights */ if (ark_mem->rwt_is_ewt) { /* update pointer to ewt */ @@ -1843,21 +1858,6 @@ int arkInitialSetup(ARKodeMem ark_mem, sunrealtype tout) } } - /* Set up the time stepper module */ - if (ark_mem->step_init == NULL) - { - arkProcessError(ark_mem, ARK_ILL_INPUT, __LINE__, __func__, __FILE__, - "Time stepper module is missing"); - return (ARK_ILL_INPUT); - } - retval = ark_mem->step_init(ark_mem, ark_mem->init_type); - if (retval != ARK_SUCCESS) - { - arkProcessError(ark_mem, retval, __LINE__, __func__, __FILE__, - "Error in initialization of time stepper module"); - return (retval); - } - /* Check that user has supplied an initial step size if fixedstep mode is on */ if ((ark_mem->fixedstep) && (ark_mem->hin == ZERO)) { From 2f75492da9636f148427da08cc6f0032dfe66594 Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Fri, 20 Sep 2024 08:11:47 -0500 Subject: [PATCH 069/286] Updated answers repository commit --- test/answers | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/answers b/test/answers index bbc9d290c1..21c9406c82 160000 --- a/test/answers +++ b/test/answers @@ -1 +1 @@ -Subproject commit bbc9d290c19c825c27b6a3d53951fd615b3af7e1 +Subproject commit 21c9406c82f2388c974678b68197dca42799266a From ab5f57c4acbe42193104007e20febb3d1db6e369 Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Fri, 20 Sep 2024 08:28:52 -0500 Subject: [PATCH 070/286] Added guard against one extraneous fullrhs call --- src/arkode/arkode.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/arkode/arkode.c b/src/arkode/arkode.c index b39b36085f..165b5f5abe 100644 --- a/src/arkode/arkode.c +++ b/src/arkode/arkode.c @@ -1981,11 +1981,14 @@ int arkInitialSetup(ARKodeMem ark_mem, sunrealtype tout) ark_mem->h = SUNRabs(tout - ark_mem->tcur); if (ark_mem->h == ZERO) ark_mem->h = ONE; - /* Call fullrhs */ - retval = ark_mem->step_fullrhs(ark_mem, ark_mem->tcur, ark_mem->yn, - ark_mem->fn, ARK_FULLRHS_START); - if (retval != 0) return (ARK_RHSFUNC_FAIL); - ark_mem->fn_is_current = SUNTRUE; + /* Call fullrhs if needed */ + if (!(ark_mem->fn_is_current)) + { + retval = ark_mem->step_fullrhs(ark_mem, ark_mem->tcur, ark_mem->yn, + ark_mem->fn, ARK_FULLRHS_START); + if (retval != 0) { return (ARK_RHSFUNC_FAIL); } + ark_mem->fn_is_current = SUNTRUE; + } /* Estimate the first step size */ tout_hin = tout; From 61f4ee4cc61eece452fe7dcb7b3cfda61d999f27 Mon Sep 17 00:00:00 2001 From: "David J. Gardner" Date: Fri, 20 Sep 2024 07:19:37 -0700 Subject: [PATCH 071/286] update output files --- examples/arkode/CXX_serial/ark_kpr_Mt_0_3_0_-10_0.out | 2 +- examples/arkode/CXX_serial/ark_kpr_Mt_0_4_0_-10_0_10_1.out | 2 +- examples/arkode/CXX_serial/ark_kpr_Mt_0_4_0_-10_1_10_1.out | 2 +- examples/arkode/CXX_serial/ark_kpr_Mt_0_4_1.out | 2 +- examples/arkode/CXX_serial/ark_kpr_Mt_0_5.out | 2 +- examples/arkode/CXX_serial/ark_kpr_Mt_1_4.out | 2 +- examples/arkode/CXX_serial/ark_kpr_Mt_2_4_0_-10_0.out | 2 +- examples/arkode/CXX_serial/ark_kpr_Mt_2_8_0_-10.out | 2 +- examples/arkode/C_serial/ark_brusselator1D_FEM_slu.out | 2 +- 9 files changed, 9 insertions(+), 9 deletions(-) diff --git a/examples/arkode/CXX_serial/ark_kpr_Mt_0_3_0_-10_0.out b/examples/arkode/CXX_serial/ark_kpr_Mt_0_3_0_-10_0.out index 05da441507..e3c31815e3 100644 --- a/examples/arkode/CXX_serial/ark_kpr_Mt_0_3_0_-10_0.out +++ b/examples/arkode/CXX_serial/ark_kpr_Mt_0_3_0_-10_0.out @@ -120,7 +120,7 @@ Final Solver Statistics: Total RHS evals: Fe = 671, Fi = 1763 Total mass matrix setups = 504 Total mass matrix solves = 1340 - Total mass times evals = 1258 + Total mass times evals = 1259 Total number of Jacobian evaluations = 7 Total linear solver setups = 18 Total number of Nonlinear iterations = 1092 diff --git a/examples/arkode/CXX_serial/ark_kpr_Mt_0_4_0_-10_0_10_1.out b/examples/arkode/CXX_serial/ark_kpr_Mt_0_4_0_-10_0_10_1.out index c87c2ee2c6..25d972ace0 100644 --- a/examples/arkode/CXX_serial/ark_kpr_Mt_0_4_0_-10_0_10_1.out +++ b/examples/arkode/CXX_serial/ark_kpr_Mt_0_4_0_-10_0_10_1.out @@ -120,7 +120,7 @@ Final Solver Statistics: Total RHS evals: Fe = 493, Fi = 1082 Total mass matrix setups = 413 Total mass matrix solves = 574 - Total mass times evals = 1078 + Total mass times evals = 1079 Total number of Jacobian evaluations = 12 Total linear solver setups = 21 Total number of Nonlinear iterations = 999 diff --git a/examples/arkode/CXX_serial/ark_kpr_Mt_0_4_0_-10_1_10_1.out b/examples/arkode/CXX_serial/ark_kpr_Mt_0_4_0_-10_1_10_1.out index 19b9ac273b..e28c955d6b 100644 --- a/examples/arkode/CXX_serial/ark_kpr_Mt_0_4_0_-10_1_10_1.out +++ b/examples/arkode/CXX_serial/ark_kpr_Mt_0_4_0_-10_1_10_1.out @@ -120,7 +120,7 @@ Final Solver Statistics: Total RHS evals: Fe = 501, Fi = 1738 Total mass matrix setups = 418 Total mass matrix solves = 585 - Total mass times evals = 1734 + Total mass times evals = 1735 Total number of Jacobian evaluations = 145 Total linear solver setups = 150 Total number of Nonlinear iterations = 1652 diff --git a/examples/arkode/CXX_serial/ark_kpr_Mt_0_4_1.out b/examples/arkode/CXX_serial/ark_kpr_Mt_0_4_1.out index 8a5be5e7de..a662ca0306 100644 --- a/examples/arkode/CXX_serial/ark_kpr_Mt_0_4_1.out +++ b/examples/arkode/CXX_serial/ark_kpr_Mt_0_4_1.out @@ -120,7 +120,7 @@ Final Solver Statistics: Total RHS evals: Fe = 13787, Fi = 50499 Total mass matrix setups = 12646 Total mass matrix solves = 64284 - Total mass times evals = 2270 + Total mass times evals = 2271 Total number of Jacobian evaluations = 0 Total linear solver setups = 0 Total number of Nonlinear iterations = 36712 diff --git a/examples/arkode/CXX_serial/ark_kpr_Mt_0_5.out b/examples/arkode/CXX_serial/ark_kpr_Mt_0_5.out index f9f3c99117..7f9417757d 100644 --- a/examples/arkode/CXX_serial/ark_kpr_Mt_0_5.out +++ b/examples/arkode/CXX_serial/ark_kpr_Mt_0_5.out @@ -120,7 +120,7 @@ Final Solver Statistics: Total RHS evals: Fe = 1265, Fi = 4680 Total mass matrix setups = 1121 Total mass matrix solves = 2428 - Total mass times evals = 3558 + Total mass times evals = 3559 Total number of Jacobian evaluations = 204 Total linear solver setups = 214 Total number of Nonlinear iterations = 3415 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 0a640a7723..c652708cf1 100644 --- a/examples/arkode/CXX_serial/ark_kpr_Mt_1_4.out +++ b/examples/arkode/CXX_serial/ark_kpr_Mt_1_4.out @@ -120,7 +120,7 @@ Final Solver Statistics: Total RHS evals: Fe = 0, Fi = 5758 Total mass matrix setups = 1438 Total mass matrix solves = 1438 - Total mass times evals = 4603 + Total mass times evals = 4604 Total number of Jacobian evaluations = 152 Total linear solver setups = 166 Total number of Nonlinear iterations = 4320 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 2549bfbc67..54a56620ba 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 @@ -119,5 +119,5 @@ Final Solver Statistics: Total RHS evals: Fe = 840, Fi = 0 Total mass matrix setups = 672 Total mass matrix solves = 840 - Total mass times evals = 164 + Total mass times evals = 165 Errors: u = 3.7533e-06, v = 2.61601e-07, total = 2.66042e-06 diff --git a/examples/arkode/CXX_serial/ark_kpr_Mt_2_8_0_-10.out b/examples/arkode/CXX_serial/ark_kpr_Mt_2_8_0_-10.out index 5b3c03aa20..09b1fd9f98 100644 --- a/examples/arkode/CXX_serial/ark_kpr_Mt_2_8_0_-10.out +++ b/examples/arkode/CXX_serial/ark_kpr_Mt_2_8_0_-10.out @@ -119,5 +119,5 @@ Final Solver Statistics: Total RHS evals: Fe = 1742, Fi = 0 Total mass matrix setups = 1439 Total mass matrix solves = 1742 - Total mass times evals = 102 + Total mass times evals = 103 Errors: u = 1.83418e-08, v = 2.86413e-09, total = 1.31268e-08 diff --git a/examples/arkode/C_serial/ark_brusselator1D_FEM_slu.out b/examples/arkode/C_serial/ark_brusselator1D_FEM_slu.out index fae8230195..8cae2ef2fe 100644 --- a/examples/arkode/C_serial/ark_brusselator1D_FEM_slu.out +++ b/examples/arkode/C_serial/ark_brusselator1D_FEM_slu.out @@ -115,7 +115,7 @@ Final Solver Statistics: Total RHS evals: Fe = 0, Fi = 1111 Total mass matrix setups = 1 Total mass matrix solves = 193 - Total mass times evals = 1687 + Total mass times evals = 1688 Total linear solver setups = 31 Total number of Jacobian evaluations = 11 Total number of Newton iterations = 1118 From 54617b5e1733d92fbc17f0951d2574ad8de4c615 Mon Sep 17 00:00:00 2001 From: "David J. Gardner" Date: Fri, 20 Sep 2024 08:30:19 -0700 Subject: [PATCH 072/286] update f2003 outputs --- .../ark_kpr_mri_f2003_4_0.002.out | 88 +++++++++---------- .../ark_kpr_mri_f2003_7_0.001.out | 72 +++++++-------- 2 files changed, 80 insertions(+), 80 deletions(-) diff --git a/examples/arkode/F2003_serial/ark_kpr_mri_f2003_4_0.002.out b/examples/arkode/F2003_serial/ark_kpr_mri_f2003_4_0.002.out index 22fca6299a..9aa6c31a91 100644 --- a/examples/arkode/F2003_serial/ark_kpr_mri_f2003_4_0.002.out +++ b/examples/arkode/F2003_serial/ark_kpr_mri_f2003_4_0.002.out @@ -18,53 +18,53 @@ 0.600000 1.188564 1.025537 0.74E-05 0.20E-02 0.700000 1.175763 1.622485 0.12E-05 0.27E-03 0.800000 1.161186 1.374900 0.25E-06 0.27E-03 - 0.900000 1.144904 1.246450 0.11E-06 0.69E-03 - 1.000000 1.127010 1.691322 0.54E-06 0.52E-03 - 1.100000 1.107615 1.002500 0.54E-05 0.20E-02 - 1.200000 1.086818 1.677003 0.21E-05 0.55E-03 - 1.300000 1.064782 1.278198 0.55E-05 0.42E-03 - 1.400000 1.041624 1.342655 0.14E-05 0.20E-03 - 1.500000 1.017531 1.642375 0.74E-06 0.56E-03 - 1.600000 0.992677 1.013911 0.34E-05 0.18E-02 - 1.700000 0.967249 1.713353 0.35E-05 0.71E-03 - 1.800000 0.941493 1.184579 0.54E-05 0.71E-03 - 1.900000 0.915615 1.437305 0.24E-05 0.16E-03 - 2.000000 0.889904 1.576564 0.13E-05 0.52E-03 - 2.100000 0.864627 1.057868 0.15E-05 0.14E-02 - 2.200000 0.840087 1.730117 0.24E-05 0.80E-03 - 2.300000 0.816622 1.102136 0.58E-05 0.11E-02 - 2.400000 0.794543 1.524625 0.31E-05 0.43E-03 - 2.500000 0.774230 1.496597 0.22E-05 0.40E-03 - 2.600000 0.756013 1.127800 0.77E-07 0.94E-03 - 2.700000 0.740244 1.726696 0.18E-05 0.84E-03 - 2.800000 0.727253 1.039861 0.53E-05 0.15E-02 - 2.900000 0.717298 1.600138 0.32E-05 0.62E-03 - 3.000000 0.710633 1.406200 0.30E-05 0.18E-03 - 3.100000 0.707411 1.214845 0.12E-05 0.49E-03 - 3.200000 0.707708 1.703196 0.12E-05 0.83E-03 - 3.300000 0.711524 1.006102 0.44E-05 0.17E-02 - 3.400000 0.718746 1.660466 0.34E-05 0.76E-03 - 3.500000 0.729231 1.310194 0.41E-05 0.93E-04 - 3.600000 0.742710 1.310190 0.22E-05 0.11E-03 - 3.700000 0.758913 1.660462 0.47E-06 0.77E-03 - 3.800000 0.777509 1.006087 0.31E-05 0.17E-02 - 3.900000 0.798140 1.703188 0.39E-05 0.83E-03 - 4.000000 0.820479 1.214819 0.46E-05 0.45E-03 - 4.100000 0.844147 1.406163 0.28E-05 0.20E-03 - 4.200000 0.868833 1.600102 0.42E-06 0.67E-03 - 4.300000 0.894205 1.039813 0.15E-05 0.14E-02 - 4.400000 0.919961 1.726651 0.28E-05 0.88E-03 - 4.500000 0.945839 1.127737 0.53E-05 0.86E-03 - 4.600000 0.971554 1.496541 0.33E-05 0.43E-03 - 4.700000 0.996899 1.524547 0.14E-05 0.52E-03 - 4.800000 1.021641 1.102066 0.86E-07 0.10E-02 - 4.900000 1.045587 1.730025 0.20E-05 0.90E-03 - 5.000000 1.068570 1.057773 0.53E-05 0.13E-02 + 0.900000 1.144904 1.246518 0.45E-06 0.75E-03 + 1.000000 1.127011 1.691383 0.85E-06 0.46E-03 + 1.100000 1.107615 1.002555 0.57E-05 0.21E-02 + 1.200000 1.086819 1.677049 0.18E-05 0.50E-03 + 1.300000 1.064782 1.278212 0.56E-05 0.44E-03 + 1.400000 1.041624 1.342668 0.13E-05 0.21E-03 + 1.500000 1.017531 1.642387 0.80E-06 0.55E-03 + 1.600000 0.992677 1.013922 0.34E-05 0.18E-02 + 1.700000 0.967249 1.713363 0.34E-05 0.70E-03 + 1.800000 0.941493 1.184574 0.53E-05 0.71E-03 + 1.900000 0.915615 1.437301 0.24E-05 0.16E-03 + 2.000000 0.889904 1.576560 0.13E-05 0.52E-03 + 2.100000 0.864627 1.057865 0.15E-05 0.14E-02 + 2.200000 0.840086 1.730082 0.26E-05 0.84E-03 + 2.300000 0.816622 1.102105 0.56E-05 0.11E-02 + 2.400000 0.794543 1.524597 0.33E-05 0.45E-03 + 2.500000 0.774230 1.496572 0.20E-05 0.42E-03 + 2.600000 0.756013 1.127777 0.20E-06 0.92E-03 + 2.700000 0.740244 1.726675 0.20E-05 0.86E-03 + 2.800000 0.727253 1.039846 0.53E-05 0.15E-02 + 2.900000 0.717298 1.600124 0.33E-05 0.63E-03 + 3.000000 0.710633 1.406188 0.31E-05 0.19E-03 + 3.100000 0.707411 1.214834 0.13E-05 0.48E-03 + 3.200000 0.707708 1.703186 0.13E-05 0.84E-03 + 3.300000 0.711524 1.006093 0.43E-05 0.17E-02 + 3.400000 0.718746 1.660457 0.34E-05 0.77E-03 + 3.500000 0.729231 1.310187 0.40E-05 0.85E-04 + 3.600000 0.742710 1.310183 0.22E-05 0.10E-03 + 3.700000 0.758913 1.660456 0.50E-06 0.78E-03 + 3.800000 0.777509 1.006081 0.30E-05 0.17E-02 + 3.900000 0.798140 1.703183 0.39E-05 0.84E-03 + 4.000000 0.820479 1.214815 0.46E-05 0.44E-03 + 4.100000 0.844146 1.406159 0.28E-05 0.20E-03 + 4.200000 0.868833 1.600098 0.40E-06 0.68E-03 + 4.300000 0.894205 1.039810 0.15E-05 0.14E-02 + 4.400000 0.919961 1.726622 0.29E-05 0.91E-03 + 4.500000 0.945839 1.127712 0.52E-05 0.84E-03 + 4.600000 0.971554 1.496517 0.34E-05 0.46E-03 + 4.700000 0.996899 1.524526 0.13E-05 0.54E-03 + 4.800000 1.021641 1.102047 0.10E-07 0.10E-02 + 4.900000 1.045587 1.730008 0.21E-05 0.91E-03 + 5.000000 1.068570 1.057757 0.52E-05 0.13E-02 ------------------------------------------------------ Final Solver Statistics: Steps: nsts = 2501, nstf = 250100 - u error = 0.348E-05, v error = 0.953E-03, total error = 0.674E-03 - Total RHS evals: Fs = 7143, Ff = 750350 + u error = 0.349E-05, v error = 0.956E-03, total error = 0.676E-03 + Total RHS evals: Fs = 7093, Ff = 750350 Slow Newton iters = 4641 Slow Newton conv fails = 0 Slow Jacobian evals = 126 diff --git a/examples/arkode/F2003_serial/ark_kpr_mri_f2003_7_0.001.out b/examples/arkode/F2003_serial/ark_kpr_mri_f2003_7_0.001.out index 925d9c3474..ff922403a8 100644 --- a/examples/arkode/F2003_serial/ark_kpr_mri_f2003_7_0.001.out +++ b/examples/arkode/F2003_serial/ark_kpr_mri_f2003_7_0.001.out @@ -11,60 +11,60 @@ ------------------------------------------------------ 0.000000 1.224745 1.732051 0.00E+00 0.00E+00 0.100000 1.223725 1.077464 0.40E-09 0.57E-10 - 0.200000 1.220669 1.551800 0.41E-09 0.11E-09 - 0.300000 1.215594 1.467737 0.39E-09 0.16E-09 - 0.400000 1.208524 1.154583 0.39E-09 0.20E-09 - 0.500000 1.199496 1.721908 0.38E-09 0.24E-09 - 0.600000 1.188557 1.023517 0.38E-09 0.27E-09 - 0.700000 1.175764 1.622751 0.35E-09 0.30E-09 - 0.800000 1.161186 1.374632 0.34E-09 0.32E-09 - 0.900000 1.144904 1.245763 0.32E-09 0.34E-09 - 1.000000 1.127010 1.691839 0.30E-09 0.36E-09 - 1.100000 1.107609 1.000489 0.28E-09 0.37E-09 - 1.200000 1.086821 1.677552 0.25E-09 0.37E-09 - 1.300000 1.064777 1.277775 0.23E-09 0.37E-09 - 1.400000 1.041625 1.342455 0.20E-09 0.36E-09 - 1.500000 1.017531 1.642940 0.16E-09 0.35E-09 - 1.600000 0.992673 1.012112 0.12E-09 0.34E-09 - 1.700000 0.967253 1.714058 0.78E-10 0.32E-09 - 1.800000 0.941488 1.183867 0.35E-10 0.30E-09 - 1.900000 0.915617 1.437465 0.17E-10 0.27E-09 - 2.000000 0.889903 1.577082 0.70E-10 0.23E-09 - 2.100000 0.864625 1.056467 0.13E-09 0.20E-09 - 2.200000 0.840089 1.730920 0.20E-09 0.15E-09 - 2.300000 0.816616 1.101047 0.26E-09 0.10E-09 - 2.400000 0.794546 1.525051 0.33E-09 0.45E-10 - 2.500000 0.774227 1.496993 0.40E-09 0.20E-10 - 2.600000 0.756013 1.126857 0.47E-09 0.82E-10 - 2.700000 0.740246 1.727536 0.54E-09 0.15E-09 - 2.800000 0.727247 1.038393 0.59E-09 0.22E-09 + 0.200000 1.220669 1.551800 0.41E-09 0.10E-09 + 0.300000 1.215594 1.467737 0.39E-09 0.15E-09 + 0.400000 1.208524 1.154583 0.39E-09 0.18E-09 + 0.500000 1.199496 1.721908 0.38E-09 0.21E-09 + 0.600000 1.188557 1.023517 0.38E-09 0.25E-09 + 0.700000 1.175764 1.622751 0.35E-09 0.28E-09 + 0.800000 1.161186 1.374632 0.34E-09 0.30E-09 + 0.900000 1.144904 1.245763 0.32E-09 0.30E-09 + 1.000000 1.127010 1.691839 0.30E-09 0.31E-09 + 1.100000 1.107609 1.000489 0.28E-09 0.33E-09 + 1.200000 1.086821 1.677552 0.25E-09 0.33E-09 + 1.300000 1.064777 1.277775 0.23E-09 0.34E-09 + 1.400000 1.041625 1.342455 0.20E-09 0.34E-09 + 1.500000 1.017531 1.642940 0.16E-09 0.33E-09 + 1.600000 0.992673 1.012112 0.12E-09 0.32E-09 + 1.700000 0.967253 1.714058 0.78E-10 0.30E-09 + 1.800000 0.941488 1.183867 0.35E-10 0.28E-09 + 1.900000 0.915617 1.437465 0.17E-10 0.25E-09 + 2.000000 0.889903 1.577082 0.70E-10 0.22E-09 + 2.100000 0.864625 1.056467 0.13E-09 0.18E-09 + 2.200000 0.840089 1.730920 0.20E-09 0.13E-09 + 2.300000 0.816616 1.101047 0.26E-09 0.90E-10 + 2.400000 0.794546 1.525051 0.33E-09 0.33E-10 + 2.500000 0.774227 1.496993 0.40E-09 0.31E-10 + 2.600000 0.756013 1.126857 0.47E-09 0.92E-10 + 2.700000 0.740246 1.727536 0.54E-09 0.16E-09 + 2.800000 0.727247 1.038393 0.59E-09 0.23E-09 2.900000 0.717301 1.600759 0.75E-09 0.30E-09 3.000000 0.710636 1.406380 0.67E-09 0.37E-09 - 3.100000 0.707412 1.214353 0.69E-09 0.43E-09 + 3.100000 0.707412 1.214353 0.69E-09 0.44E-09 3.200000 0.707709 1.704026 0.70E-09 0.50E-09 3.300000 0.711520 1.004391 0.68E-09 0.55E-09 3.400000 0.718750 1.661225 0.65E-09 0.60E-09 3.500000 0.729227 1.310102 0.60E-09 0.63E-09 - 3.600000 0.742712 1.310080 0.55E-09 0.65E-09 + 3.600000 0.742712 1.310080 0.55E-09 0.66E-09 3.700000 0.758914 1.661237 0.50E-09 0.68E-09 - 3.800000 0.777506 1.004387 0.42E-09 0.67E-09 + 3.800000 0.777506 1.004387 0.42E-09 0.68E-09 3.900000 0.798144 1.704019 0.35E-09 0.67E-09 4.000000 0.820474 1.214374 0.29E-09 0.65E-09 4.100000 0.844149 1.406358 0.26E-09 0.62E-09 4.200000 0.868832 1.600774 0.15E-09 0.58E-09 4.300000 0.894204 1.038382 0.92E-10 0.56E-09 - 4.400000 0.919964 1.727533 0.36E-10 0.49E-09 + 4.400000 0.919964 1.727533 0.36E-10 0.50E-09 4.500000 0.945834 1.126875 0.14E-10 0.47E-09 - 4.600000 0.971557 1.496974 0.63E-10 0.40E-09 + 4.600000 0.971557 1.496974 0.63E-10 0.41E-09 4.700000 0.996898 1.525070 0.10E-09 0.35E-09 - 4.800000 1.021641 1.101030 0.15E-09 0.31E-09 - 4.900000 1.045589 1.730922 0.19E-09 0.23E-09 + 4.800000 1.021641 1.101030 0.15E-09 0.32E-09 + 4.900000 1.045589 1.730922 0.19E-09 0.24E-09 5.000000 1.068565 1.056480 0.39E-10 0.21E-09 ------------------------------------------------------ Final Solver Statistics: Steps: nsts = 5000, nstf = 510000 - u error = 0.380E-09, v error = 0.394E-09, total error = 0.387E-09 - Total RHS evals: Fs = 45313, Ff = 1530050 + u error = 0.380E-09, v error = 0.389E-09, total error = 0.385E-09 + Total RHS evals: Fs = 45263, Ff = 1530050 Slow Newton iters = 30312 Slow Newton conv fails = 0 Slow Jacobian evals = 250 From 502b9bf619ec47e4eeb6228c2b14bc4fab36e9c9 Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Thu, 26 Sep 2024 12:03:24 -0500 Subject: [PATCH 073/286] Added MERK and IMEX-MRI-SR methods to recent changes files --- CHANGELOG.md | 4 +++- doc/shared/RecentChanges.rst | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b1aaa511b6..24daa00566 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -25,7 +25,9 @@ specific linker flags e.g., MKL. Added support for multirate time step adaptivity controllers, based on the recently introduced `SUNAdaptController` base class, to ARKODE's MRIStep module. -Added new default MRI methods for temporally adaptive versus fixed-step runs. +As a part of this, we added embeddings for existing MRI-GARK methods, as well as +support for embedded MERK and IMEX-MRI-SR methods. Added new default MRI methods +for temporally adaptive versus fixed-step runs. Added functionality to ARKODE to accumulate a temporal error estimate over multiple time steps. See the routines `ARKodeSetAccumulatedErrorType`, diff --git a/doc/shared/RecentChanges.rst b/doc/shared/RecentChanges.rst index d7101d2ab5..6e59c34e89 100644 --- a/doc/shared/RecentChanges.rst +++ b/doc/shared/RecentChanges.rst @@ -21,7 +21,9 @@ specific linker flags e.g., MKL. Added support for multirate time step adaptivity controllers, based on the recently introduced `SUNAdaptController` base class, to ARKODE's MRIStep module. -Added new default MRI methods for temporally adaptive versus fixed-step runs. +As a part of this, we added embeddings for existing MRI-GARK methods, as well as +support for embedded MERK and IMEX-MRI-SR methods. Added new default MRI methods +for temporally adaptive versus fixed-step runs. Added functionality to ARKODE to accumulate a temporal error estimate over multiple time steps. See the routines From cfda92a3ffdd65c16acf11647e43f344392a330a Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Thu, 26 Sep 2024 12:11:06 -0500 Subject: [PATCH 074/286] Applied changes suggested in code review --- doc/arkode/guide/source/Mathematics.rst | 32 ++++++++++++------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/doc/arkode/guide/source/Mathematics.rst b/doc/arkode/guide/source/Mathematics.rst index 75d1d53ed8..5126b6f118 100644 --- a/doc/arkode/guide/source/Mathematics.rst +++ b/doc/arkode/guide/source/Mathematics.rst @@ -682,9 +682,9 @@ single step: The specific aspects of the fast IVP forcing function (:math:`r_i(t)` or :math:`\tilde{r}(t)`) -and Runge--Kutta stage coefficient and data (:math:`\gamma_{i,i}`, :math:`\tilde{\gamma}`, +and Runge--Kutta stage coefficients and data (:math:`\gamma_{i,i}`, :math:`\tilde{\gamma}`, :math:`a_i` and :math:`\tilde{a}`), are determined by the method family (MRI-GARK, MERK, etc.). -Generally, however, the forcing functions and RK stage update data, :math:`r_i(t)`, +Generally, however, the forcing functions and Runge--Kutta stage update data, :math:`r_i(t)`, :math:`\tilde{r}(t)`, :math:`a_i` and :math:`\tilde{a}`, are constructed using evaluations of the slow RHS functions :math:`f^E` and :math:`f^I` at preceding stages, :math:`z_j`. For specific details, please see the references for each method family listed above. @@ -701,7 +701,7 @@ For problems with only a slow-nonstiff term (:math:`f^I \equiv 0`), MRIStep provides first through fourth order explicit MRI-GARK methods, as well as explicit MERK methods of orders two through five. In cases with only a slow-stiff term (:math:`f^E \equiv 0`), MRIStep supplies first through fourth order implicit MRI-GARK methods. For applications -with both stiff and nonstiff slow terms, MRIStep implements third and fourth +with both stiff and nonstiff slow terms, MRIStep implements first through fourth order IMEX-MRI-GARK methods, as well as IMEX-MRI-SR methods of orders two through four. We note that ImEx methods may also be applied to problems with simpler structure through specification of either :math:`f^I=0` or :math:`f^E=0`. For a complete list of the methods available in @@ -937,21 +937,21 @@ methods should work well for multirate problems where the time scales are somewh decoupled, and that errors introduced at one scale do not "pollute" the other. The second category of controllers that we provide are :math:`h^S-Tol` multirate -controllers. The basic idea is that at any given time scale, an integrator will +controllers. The basic idea is that an adaptive time integration method will attempt to adapt step sizes to control the *local error* within each step to -achieve a requested tolerance. However, MRI methods must ask another adaptive -fast-scale solver to produce the stage solutions :math:`v_i(t_{F,i})` and -:math:`\tilde{v}(\tilde{t}_{F})`, that result from sub-stepping over fast intervals +achieve a requested tolerance. However, MRI methods must ask an adaptive "inner" +solver to produce the stage solutions :math:`v_i(t_{F,i})` and +:math:`\tilde{v}(\tilde{t}_{F})`, that result from sub-stepping over intervals :math:`[t_{0,i},t_{F,i}]` or :math:`[\tilde{t}_{0},\tilde{t}_{F}]`, respectively. -Local errors within the fast integrator may accumulate, resulting in an overall -fast-solver error :math:`\varepsilon^f_n` that exceeds the requested tolerance. -If that next-fastest solver can produce *both* :math:`v_i(t_{F,i})` and +Local errors within the inner integrator may accumulate, resulting in an overall +inner solver error :math:`\varepsilon^f_n` that exceeds the requested tolerance. +If that inner solver can produce *both* :math:`v_i(t_{F,i})` and an estimation of the accumulated error, :math:`\varepsilon^f_{n,approx}`, then the -tolerances provided to that next-fastest solver can be adjusted accordingly to -ensure stage solutions that are within the overall tolerances requested of the MRI -method. +tolerances provided to that inner solver can be adjusted accordingly to +ensure stage solutions that are within the overall tolerances requested of the outer +MRI method. -To this end, we assume that the next-fastest solver will provide accumulated errors +To this end, we assume that the inner solver will provide accumulated errors over each fast interval having the form .. math:: @@ -963,11 +963,11 @@ Single-scale adaptive controllers assume that the local error at a step :math:`n size :math:`h^S` has order :math:`p`, i.e., .. math:: - LTE_n = c(t_n) (h^S)^p, + LTE_n = c(t_n) (h^S)^{p+1}, to predict candidate values :math:`h^S_{n+1}`. We may therefore repurpose an existing single-scale controller to predict candidate values :math:`\text{reltol}^f_{n+1}` by -supplying an "order" :math:`p=1` and a "control parameter" +supplying an "order" :math:`p=0` and a "control parameter" :math:`h^S_n=\left(\text{reltol}_n^f\right) \left(t_{F,i}-t_{0,i}\right)`, and scaling the output by the subinterval width. From b26c39f129aca2e0576b9732c89082fe2d631ce9 Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Thu, 26 Sep 2024 12:55:48 -0500 Subject: [PATCH 075/286] Applied changes suggested in code review --- .../source/Usage/ERKStep/User_callable.rst | 6 +-- .../Custom_Inner_Stepper/Description.rst | 25 ------------- .../source/Usage/MRIStep/MRIStepCoupling.rst | 36 +++++++++--------- .../source/Usage/MRIStep/User_callable.rst | 2 +- .../SUNAdaptController_Description.rst | 37 +------------------ .../SUNAdaptController_MRIHTol.rst | 17 ++------- 6 files changed, 26 insertions(+), 97 deletions(-) diff --git a/doc/arkode/guide/source/Usage/ERKStep/User_callable.rst b/doc/arkode/guide/source/Usage/ERKStep/User_callable.rst index 6b6107781c..8ac01ce4b6 100644 --- a/doc/arkode/guide/source/Usage/ERKStep/User_callable.rst +++ b/doc/arkode/guide/source/Usage/ERKStep/User_callable.rst @@ -650,7 +650,7 @@ Optional inputs for ERKStep **Return value:** * *ARK_SUCCESS* if successful - * *ARK_MEM_NULL* if the ARKStep memory is ``NULL`` + * *ARK_MEM_NULL* if the ERKStep memory is ``NULL`` .. versionadded:: 5.6.0 @@ -1874,7 +1874,7 @@ Main solver optional output functions **Return value:** * *ARK_SUCCESS* if successful - * *ARK_MEM_NULL* if the ARKStep memory was ``NULL`` + * *ARK_MEM_NULL* if the ERKStep memory was ``NULL`` .. versionadded:: 5.3.0 @@ -2199,7 +2199,7 @@ wrap an ERKStep memory block as an :c:type:`MRIStepInnerStepper`. /* setup ERKStep */ . . . - /* create MRIStepInnerStepper wrapper for the ARKStep memory block */ + /* create MRIStepInnerStepper wrapper for the ERKStep memory block */ flag = ERKStepCreateMRIStepInnerStepper(inner_arkode_mem, &stepper); /* create an MRIStep object, setting the slow (outer) right-hand side diff --git a/doc/arkode/guide/source/Usage/MRIStep/Custom_Inner_Stepper/Description.rst b/doc/arkode/guide/source/Usage/MRIStep/Custom_Inner_Stepper/Description.rst index 9dc117a91e..c9eb478cd6 100644 --- a/doc/arkode/guide/source/Usage/MRIStep/Custom_Inner_Stepper/Description.rst +++ b/doc/arkode/guide/source/Usage/MRIStep/Custom_Inner_Stepper/Description.rst @@ -239,12 +239,6 @@ Setting Member Functions :retval ARK_SUCCESS: if successful :retval ARK_ILL_INPUT: if the stepper is ``NULL`` - **Example usage:** - - .. code-block:: C - - /* set the inner stepper accumulated error 'get' function */ - flag = MRIStepInnerStepper_SetAccumulatedErrorGetFn(inner_stepper, MyAccumErr); .. c:function:: int MRIStepInnerStepper_SetAccumulatedErrorResetFn(MRIStepInnerStepper stepper, MRIStepInnerResetAccumulatedError fn) @@ -257,12 +251,6 @@ Setting Member Functions :retval ARK_SUCCESS: if successful :retval ARK_ILL_INPUT: if the stepper is ``NULL`` - **Example usage:** - - .. code-block:: C - - /* set the inner stepper accumulated error 'reset' function */ - flag = MRIStepInnerStepper_SetAccumulatedErrorResetFn(inner_stepper, MyResetAccumErr); .. c:function:: int MRIStepInnerStepper_SetRTolFn(MRIStepInnerStepper stepper, MRIStepInnerSetRTol fn) @@ -275,12 +263,6 @@ Setting Member Functions :retval ARK_SUCCESS: if successful :retval ARK_ILL_INPUT: if the stepper is ``NULL`` - **Example usage:** - - .. code-block:: C - - /* set the inner stepper relative tolerance function */ - flag = MRIStepInnerStepper_SetRTolFn(inner_stepper, MySetRTol); .. _ARKODE.Usage.MRIStep.CustomInnerStepper.Description.BaseMethods.Forcing: @@ -309,13 +291,6 @@ data necessary to construct the inner (fast) forcing polynomial. :retval ARK_SUCCESS: if successful :retval ARK_ILL_INPUT: if the stepper is ``NULL`` - **Example usage:** - - .. code-block:: C - - /* compute the forcing term and add it the fast RHS vector */ - flag = MRIStepInnerStepper_AddForcing(inner_stepper, t, f_fast); - **Example codes:** * ``examples/arkode/CXX_parallel/ark_diffusion_reaction_p.cpp`` diff --git a/doc/arkode/guide/source/Usage/MRIStep/MRIStepCoupling.rst b/doc/arkode/guide/source/Usage/MRIStep/MRIStepCoupling.rst index da7479dfcc..72222704bb 100644 --- a/doc/arkode/guide/source/Usage/MRIStep/MRIStepCoupling.rst +++ b/doc/arkode/guide/source/Usage/MRIStep/MRIStepCoupling.rst @@ -26,22 +26,22 @@ constructing a coupling table and attaching it with the MRI methods supported by MRIStep. The family of MRI method encoded by the table is determined by an enumerated type, :c:type:`ARKODE_MRIType`: -.. c:type:: ARKODE_MRIType +.. c:enum:: ARKODE_MRIType This may take any of the following constants: - * :index:`MRISTEP_EXPLICIT` -- indicates an MRI-GARK method that + * :enumerator:`MRISTEP_EXPLICIT` -- indicates an MRI-GARK method that does not support a slow implicit operator, :math:`f^I`. - * :index:`MRISTEP_IMPLICIT` -- indicates an MRI-GARK method that + * :enumerator:`MRISTEP_IMPLICIT` -- indicates an MRI-GARK method that does not support a slow explicit operator, :math:`f^E`. - * :index:`MRISTEP_IMEX` -- indicates an IMEX-MRK-GARK method. + * :enumerator:`MRISTEP_IMEX` -- indicates an IMEX-MRK-GARK method. - * :index:`MRISTEP_MERK` -- indicates a MERK method, that by definition + * :enumerator:`MRISTEP_MERK` -- indicates a MERK method, that by definition does not support a slow implicit operator, :math:`f^I`. - * :index:`MRISTEP_MRISR` -- indicates an IMEX-MRI-SR method. + * :enumerator:`MRISTEP_MRISR` -- indicates an IMEX-MRI-SR method. The MRI coupling tables themselves are stored in an :c:func:`MRIStepCoupling` object which is a pointer to a @@ -383,14 +383,14 @@ with values specified for each method below (e.g., ``ARKODE_MIS_KW3``). ====================================== ================== =============== ============== ===================== Table name Method Order Embedding Order Slow RHS Calls Reference ====================================== ================== =============== ============== ===================== - :index:`ARKODE_MRI_GARK_FORWARD_EULER` :math:`1^*` 0 1 + :index:`ARKODE_MRI_GARK_FORWARD_EULER` :math:`1^*` -- 1 :index:`ARKODE_MRI_GARK_ERK22a` :math:`2^{\circ}` 1 2 :cite:p:`Sandu:19` :index:`ARKODE_MRI_GARK_ERK22b` :math:`2^*` 1 2 :cite:p:`Sandu:19` - :index:`ARKODE_MRI_GARK_RALSTON2` 2 0 2 :cite:p:`Roberts:22` + :index:`ARKODE_MRI_GARK_RALSTON2` 2 1 2 :cite:p:`Roberts:22` :index:`ARKODE_MERK21` 2 1 2 :cite:p:`Luan:20` - :index:`ARKODE_MIS_KW3` :math:`3^*` 0 3 :cite:p:`Schlegel:09` + :index:`ARKODE_MIS_KW3` :math:`3^*` -- 3 :cite:p:`Schlegel:09` :index:`ARKODE_MRI_GARK_ERK33a` :math:`3^{\circ}` 2 3 :cite:p:`Sandu:19` - :index:`ARKODE_MRI_GARK_RALSTON3` 3 0 3 :cite:p:`Roberts:22` + :index:`ARKODE_MRI_GARK_RALSTON3` 3 -- 3 :cite:p:`Roberts:22` :index:`ARKODE_MERK32` 3 2 3 :cite:p:`Luan:20` :index:`ARKODE_MRI_GARK_ERK45a` :math:`4^{*\circ}` 3 5 :cite:p:`Sandu:19` :index:`ARKODE_MERK43` 4 3 6 :cite:p:`Luan:20` @@ -408,9 +408,9 @@ with values specified for each method below (e.g., ``ARKODE_MIS_KW3``). ========================================== ================== =============== =============== ================== Table name Method Order Embedding Order Implicit Solves Reference ========================================== ================== =============== =============== ================== - :index:`ARKODE_MRI_GARK_BACKWARD_EULER` :math:`1^{*\circ}` 0 1 + :index:`ARKODE_MRI_GARK_BACKWARD_EULER` :math:`1^{*\circ}` -- 1 :index:`ARKODE_MRI_GARK_IRK21a` :math:`2^{*\circ}` 1 1 :cite:p:`Sandu:19` - :index:`ARKODE_MRI_GARK_IMPLICIT_MIDPOINT` 2 0 2 + :index:`ARKODE_MRI_GARK_IMPLICIT_MIDPOINT` 2 -- 2 :index:`ARKODE_MRI_GARK_ESDIRK34a` :math:`3^{*\circ}` 2 3 :cite:p:`Sandu:19` :index:`ARKODE_MRI_GARK_ESDIRK46a` :math:`4^{*\circ}` 3 5 :cite:p:`Sandu:19` ========================================== ================== =============== =============== ================== @@ -426,13 +426,13 @@ with values specified for each method below (e.g., ``ARKODE_MIS_KW3``). ========================================= ================= =============== =============== =================== Table name Method Order Embedding Order Implicit Solves Reference ========================================= ================= =============== =============== =================== - :index:`ARKODE_IMEX_MRI_GARK_EULER` :math:`1^*` 0 1 - :index:`ARKODE_IMEX_MRI_GARK_TRAPEZOIDAL` :math:`2^*` 0 1 - :index:`ARKODE_IMEX_MRI_GARK_MIDPOINT` 2 0 2 + :index:`ARKODE_IMEX_MRI_GARK_EULER` :math:`1^*` -- 1 + :index:`ARKODE_IMEX_MRI_GARK_TRAPEZOIDAL` :math:`2^*` -- 1 + :index:`ARKODE_IMEX_MRI_GARK_MIDPOINT` 2 -- 2 :index:`ARKODE_IMEX_MRI_SR21` :math:`2^{\circ}` 1 3 :cite:p:`Fish:24` - :index:`ARKODE_IMEX_MRI_GARK3a` :math:`3^*` 0 2 :cite:p:`ChiRen:21` - :index:`ARKODE_IMEX_MRI_GARK3b` 3 0 2 :cite:p:`ChiRen:21` + :index:`ARKODE_IMEX_MRI_GARK3a` :math:`3^*` -- 2 :cite:p:`ChiRen:21` + :index:`ARKODE_IMEX_MRI_GARK3b` 3 -- 2 :cite:p:`ChiRen:21` :index:`ARKODE_IMEX_MRI_SR32` :math:`3^{\circ}` 2 4 :cite:p:`Fish:24` - :index:`ARKODE_IMEX_MRI_GARK4` :math:`4^*` 0 5 :cite:p:`ChiRen:21` + :index:`ARKODE_IMEX_MRI_GARK4` :math:`4^*` -- 5 :cite:p:`ChiRen:21` :index:`ARKODE_IMEX_MRI_SR43` :math:`4^{\circ}` 3 5 :cite:p:`Fish:24` ========================================= ================= =============== =============== =================== diff --git a/doc/arkode/guide/source/Usage/MRIStep/User_callable.rst b/doc/arkode/guide/source/Usage/MRIStep/User_callable.rst index 5df668e962..cbfdb19e4f 100644 --- a/doc/arkode/guide/source/Usage/MRIStep/User_callable.rst +++ b/doc/arkode/guide/source/Usage/MRIStep/User_callable.rst @@ -815,7 +815,7 @@ Optional inputs for IVP method selection Select the default MRI method of a given order. - The default order is 3. An order less than 1 or greater than 4 will result in + The default order is 3. An order less than 1 will result in using the default. :param arkode_mem: pointer to the MRIStep memory block. diff --git a/doc/shared/sunadaptcontroller/SUNAdaptController_Description.rst b/doc/shared/sunadaptcontroller/SUNAdaptController_Description.rst index 3ac3add4e6..8d1158a778 100644 --- a/doc/shared/sunadaptcontroller/SUNAdaptController_Description.rst +++ b/doc/shared/sunadaptcontroller/SUNAdaptController_Description.rst @@ -260,7 +260,7 @@ note these requirements below. Additionally, we note the behavior of the base SU .. note:: - If the current [slow] time scale has relative tolerance :math:`rtol`, then the + If the current time scale has relative tolerance :math:`rtol`, then the next-faster time scale will be called with relative tolerance :math:`tolfac * rtol`. Usage: @@ -277,11 +277,6 @@ note these requirements below. Additionally, we note the behavior of the base SU :param C: the :c:type:`SUNAdaptController` object. :return: :c:type:`SUNErrCode` indicating success or failure. - Usage: - - .. code-block:: c - - retval = SUNAdaptController_Reset(C); .. c:function:: SUNErrCode SUNAdaptController_SetDefaults(SUNAdaptController C) @@ -290,11 +285,6 @@ note these requirements below. Additionally, we note the behavior of the base SU :param C: the :c:type:`SUNAdaptController` object. :return: :c:type:`SUNErrCode` indicating success or failure. - Usage: - - .. code-block:: c - - retval = SUNAdaptController_SetDefaults(C); .. c:function:: SUNErrCode SUNAdaptController_Write(SUNAdaptController C, FILE* fptr) @@ -304,11 +294,6 @@ note these requirements below. Additionally, we note the behavior of the base SU :param fptr: the output stream to write the parameters to. :return: :c:type:`SUNErrCode` indicating success or failure. - Usage: - - .. code-block:: c - - retval = SUNAdaptController_Write(C, stdout); .. c:function:: SUNErrCode SUNAdaptController_SetErrorBias(SUNAdaptController C, sunrealtype bias) @@ -321,11 +306,6 @@ note these requirements below. Additionally, we note the behavior of the base SU the default value for the controller. :return: :c:type:`SUNErrCode` indicating success or failure. - Usage: - - .. code-block:: c - - retval = SUNAdaptController_SetErrorBias(C, 1.2); .. c:function:: SUNErrCode SUNAdaptController_UpdateH(SUNAdaptController C, sunrealtype h, sunrealtype dsm) @@ -340,11 +320,6 @@ note these requirements below. Additionally, we note the behavior of the base SU :param dsm: the successful temporal error estimate. :return: :c:type:`SUNErrCode` indicating success or failure. - Usage: - - .. code-block:: c - - retval = SUNAdaptController_UpdateH(C, h, dsm); .. c:function:: SUNErrCode SUNAdaptController_UpdateMRITol(SUNAdaptController C, sunrealtype H, sunrealtype tolfac, sunrealtype DSM, sunrealtype dsm) @@ -361,11 +336,6 @@ note these requirements below. Additionally, we note the behavior of the base SU :param dsm: the successful fast temporal error estimate. :return: :c:type:`SUNErrCode` indicating success or failure. - Usage: - - .. code-block:: c - - retval = SUNAdaptController_UpdateMRITol(C, H, tolfac, DSM, dsm); .. c:function:: SUNErrCode SUNAdaptController_Space(SUNAdaptController C, long int *lenrw, long int *leniw) @@ -380,11 +350,6 @@ note these requirements below. Additionally, we note the behavior of the base SU `long int` words. :return: :c:type:`SUNErrCode` indicating success or failure. - Usage: - - .. code-block:: c - - retval = SUNAdaptController_Space(C, &lenrw, &leniw); diff --git a/doc/shared/sunadaptcontroller/SUNAdaptController_MRIHTol.rst b/doc/shared/sunadaptcontroller/SUNAdaptController_MRIHTol.rst index 56678205bb..de17e2d3ab 100644 --- a/doc/shared/sunadaptcontroller/SUNAdaptController_MRIHTol.rst +++ b/doc/shared/sunadaptcontroller/SUNAdaptController_MRIHTol.rst @@ -32,7 +32,7 @@ results from two types of error: #. "Slow" temporal errors introduced at the current time scale, .. math:: - \varepsilon^s_{n} = C(t_n) \left(h_n^s\right)^P, + \varepsilon^s_{n} = C(t_n) \left(h_n^s\right)^{P+1}, :label: slow_error_assumption where :math:`C(t)` is independent of the current time scale step size :math:`h^s` @@ -60,7 +60,7 @@ results from two types of error: :math:`\kappa(t_n) = c(t_n) \text{reltol}^s \left(t_{F,i}-t_{0,i}\right)` is independent of the relative tolerance factor, :math:`\text{tolfac}_n^f`. -Single-rate controllers are constructed to adapt a single order parameter, e.g., +Single-rate controllers are constructed to adapt a single parameter, e.g., :math:`\delta`, under an assumption that solution error :math:`\varepsilon` depends asymptotically on this parameter via the form @@ -69,7 +69,7 @@ asymptotically on this parameter via the form Both :eq:`slow_error_assumption` and :eq:`inner_solver_assumption` fit this form, with control parameters :math:`h^s` and :math:`\text{tolfac}^f_n`, and "orders" -:math:`P` and :math:`1`, respectively. Thus an MRIHTol controller employs +:math:`P` and :math:`0`, respectively. Thus an MRIHTol controller employs *HControl* to adapt :math:`h_n^s` to control the current time scale error :math:`\varepsilon^s_n`, and it employs *TolControl* to adapt :math:`\text{tolfac}_n^f` to control the accumulated inner solver error @@ -140,11 +140,6 @@ also provides the following additional user-callable routines: :return: if successful, a usable :c:type:`SUNAdaptController` object; otherwise it will return ``NULL``. - Usage: - - .. code-block:: c - - SUNAdaptController C = SUNAdaptController_MRIHTol(sunctx, HControl, TolControl); .. c:function:: SUNErrCode SUNAdaptController_SetParams_MRIHTol(SUNAdaptController C, sunrealtype inner_max_relch, sunrealtype inner_min_tolfac, sunrealtype inner_max_tolfac) @@ -157,9 +152,3 @@ also provides the following additional user-callable routines: :param inner_min_tolfac: the parameter :math:`\text{tolfac}_{min}`. :param inner_max_tolfac: the parameter :math:`\text{tolfac}_{max}`. :return: :c:type:`SUNErrCode` indicating success or failure. - - Usage: - - .. code-block:: c - - retval = SUNAdaptController_SetParams_MRIHTol(C, 20.0, 1e-5, 1.0); From d46fb9ae5a9e2bae3fc85213cbd12a588569f80a Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Thu, 26 Sep 2024 13:00:19 -0500 Subject: [PATCH 076/286] Applied changes suggested in code review --- doc/shared/sunadaptcontroller/SUNAdaptController_MRIHTol.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/shared/sunadaptcontroller/SUNAdaptController_MRIHTol.rst b/doc/shared/sunadaptcontroller/SUNAdaptController_MRIHTol.rst index de17e2d3ab..16595267ae 100644 --- a/doc/shared/sunadaptcontroller/SUNAdaptController_MRIHTol.rst +++ b/doc/shared/sunadaptcontroller/SUNAdaptController_MRIHTol.rst @@ -65,7 +65,7 @@ Single-rate controllers are constructed to adapt a single parameter, e.g., asymptotically on this parameter via the form .. math:: - \varepsilon = \mathcal{O}(\delta^q). + \varepsilon = \mathcal{O}(\delta^{q+1}). Both :eq:`slow_error_assumption` and :eq:`inner_solver_assumption` fit this form, with control parameters :math:`h^s` and :math:`\text{tolfac}^f_n`, and "orders" From 1b8df49a7ac464bae75327e38b543536cee87ad9 Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Thu, 26 Sep 2024 13:45:41 -0500 Subject: [PATCH 077/286] Applied suggestions from code review --- examples/arkode/C_serial/ark_kpr_mri.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/examples/arkode/C_serial/ark_kpr_mri.c b/examples/arkode/C_serial/ark_kpr_mri.c index 0c69dd3da5..1ad01b5d06 100644 --- a/examples/arkode/C_serial/ark_kpr_mri.c +++ b/examples/arkode/C_serial/ark_kpr_mri.c @@ -61,14 +61,14 @@ * 5 - ARKODE_DORMAND_PRINCE_7_4_5 * * The program should be run with arguments in the following order: - * $ a.out slow_type fast_type h G w e deduce + * $ ark_kpr_mri slow_type fast_type h G w e deduce_rhs * Not all arguments are required, but these must be omitted from * end-to-beginning, i.e. any one of - * $ a.out slow_type fast_type h G w e - * $ a.out slow_type fast_type h G w - * $ a.out slow_type fast_type h G - * $ a.out slow_type fast_type h - * $ a.out slow_type fast_type + * $ ark_kpr_mri slow_type fast_type h G w e + * $ ark_kpr_mri slow_type fast_type h G w + * $ ark_kpr_mri slow_type fast_type h G + * $ ark_kpr_mri slow_type fast_type h + * $ ark_kpr_mri slow_type fast_type * are acceptable. We require: * * 0 <= solve_type <= 9 * * 0 < h < 1/|G| @@ -169,7 +169,7 @@ int main(int argc, char* argv[]) sunbooleantype implicit_fast = SUNFALSE; sunbooleantype explicit_fast = SUNFALSE; sunbooleantype no_fast = SUNFALSE; - sunbooleantype deduce = SUNFALSE; + sunbooleantype deduce_rhs = SUNFALSE; FILE* UFID; sunrealtype hf, gamma, beta, t, tout, rpar[3]; sunrealtype uerr, verr, uerrtot, verrtot, errtot; @@ -180,13 +180,13 @@ int main(int argc, char* argv[]) * Initialization */ - /* Retrieve the command-line options: slow_type fast_type h G w e deduce */ + /* Retrieve the command-line options: slow_type fast_type h G w e deduce_rhs */ if (argc < 3) { printf("ERROR: executable requires at least two arguments [slow_type " "fast_type]\n"); printf("Usage:\n"); - printf(" a.out slow_type fast_type h G w e deduce"); + printf(" ark_kpr_mri slow_type fast_type h G w e deduce_rhs"); return (-1); } slow_type = (sunindextype)atol(argv[1]); @@ -195,7 +195,7 @@ int main(int argc, char* argv[]) if (argc > 4) { G = SUNStrToReal(argv[4]); } if (argc > 5) { w = SUNStrToReal(argv[5]); } if (argc > 6) { e = SUNStrToReal(argv[6]); } - if (argc > 7) { deduce = (sunbooleantype)atoi(argv[7]); } + if (argc > 7) { deduce_rhs = (sunbooleantype)atoi(argv[7]); } /* Check arguments for validity */ /* 0 <= slow_type <= 13 */ @@ -658,7 +658,7 @@ int main(int argc, char* argv[]) retval = ARKodeSetUserData(arkode_mem, (void*)rpar); if (check_retval(&retval, "ARKodeSetUserData", 1)) { return 1; } - retval = ARKodeSetDeduceImplicitRhs(arkode_mem, deduce); + retval = ARKodeSetDeduceImplicitRhs(arkode_mem, deduce_rhs); if (check_retval(&retval, "ARKodeSetDeduceImplicitRhs", 1)) { return 1; } /* Set the slow step size */ From c465dbb6c57da47f982a4ab22cb34f1c3116c248 Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Thu, 26 Sep 2024 14:20:18 -0500 Subject: [PATCH 078/286] Minor documentation fix --- doc/arkode/guide/source/Usage/MRIStep/MRIStepCoupling.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/arkode/guide/source/Usage/MRIStep/MRIStepCoupling.rst b/doc/arkode/guide/source/Usage/MRIStep/MRIStepCoupling.rst index 72222704bb..a1709c3a9a 100644 --- a/doc/arkode/guide/source/Usage/MRIStep/MRIStepCoupling.rst +++ b/doc/arkode/guide/source/Usage/MRIStep/MRIStepCoupling.rst @@ -24,7 +24,7 @@ supply a custom set of slow-to-fast time scale coupling coefficients by constructing a coupling table and attaching it with :c:func:`MRIStepSetCoupling`. A given MRI coupling table can encode any of the MRI methods supported by MRIStep. The family of MRI method encoded -by the table is determined by an enumerated type, :c:type:`ARKODE_MRIType`: +by the table is determined by an enumerated type, :c:enum:`ARKODE_MRIType`: .. c:enum:: ARKODE_MRIType From 309f08bf66de3f29010e347276019374ed7b166f Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Thu, 26 Sep 2024 14:25:51 -0500 Subject: [PATCH 079/286] Added embedding for Ralston 3 method --- doc/arkode/guide/source/Usage/MRIStep/MRIStepCoupling.rst | 2 +- src/arkode/arkode_mri_tables.def | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/doc/arkode/guide/source/Usage/MRIStep/MRIStepCoupling.rst b/doc/arkode/guide/source/Usage/MRIStep/MRIStepCoupling.rst index a1709c3a9a..2d5c77d368 100644 --- a/doc/arkode/guide/source/Usage/MRIStep/MRIStepCoupling.rst +++ b/doc/arkode/guide/source/Usage/MRIStep/MRIStepCoupling.rst @@ -390,7 +390,7 @@ with values specified for each method below (e.g., ``ARKODE_MIS_KW3``). :index:`ARKODE_MERK21` 2 1 2 :cite:p:`Luan:20` :index:`ARKODE_MIS_KW3` :math:`3^*` -- 3 :cite:p:`Schlegel:09` :index:`ARKODE_MRI_GARK_ERK33a` :math:`3^{\circ}` 2 3 :cite:p:`Sandu:19` - :index:`ARKODE_MRI_GARK_RALSTON3` 3 -- 3 :cite:p:`Roberts:22` + :index:`ARKODE_MRI_GARK_RALSTON3` 3 2 3 :cite:p:`Roberts:22` :index:`ARKODE_MERK32` 3 2 3 :cite:p:`Luan:20` :index:`ARKODE_MRI_GARK_ERK45a` :math:`4^{*\circ}` 3 5 :cite:p:`Sandu:19` :index:`ARKODE_MERK43` 4 3 6 :cite:p:`Luan:20` diff --git a/src/arkode/arkode_mri_tables.def b/src/arkode/arkode_mri_tables.def index 13d2e8b5da..b6f9f6cc2f 100644 --- a/src/arkode/arkode_mri_tables.def +++ b/src/arkode/arkode_mri_tables.def @@ -41,7 +41,7 @@ ARKODE_MRI_GARK_RALSTON2 2 1 E Y ARKODE_MIS_KW3 3 0 E Y ARKODE_MRI_GARK_ERK33a 3 2 E Y - ARKODE_MRI_GARK_RALSTON3 3 0 E Y + ARKODE_MRI_GARK_RALSTON3 3 2 E Y ARKODE_MRI_GARK_ERK45a 4 3 E Y ARKODE_MERK21 2 1 ES Y ARKODE_MERK32 3 2 ES Y @@ -132,7 +132,7 @@ ARK_MRI_TABLE(ARKODE_MRI_GARK_RALSTON3, { /* Roberts et al., SISC 44:A1405 - A14 MRIStepCoupling C = MRIStepCoupling_Alloc(2, 4, MRISTEP_EXPLICIT); C->q = 3; - C->p = 0; + C->p = 2; C->c[1] = ONE/TWO; C->c[2] = SUN_RCONST(3.0)/SUN_RCONST(4.0); @@ -144,6 +144,9 @@ ARK_MRI_TABLE(ARKODE_MRI_GARK_RALSTON3, { /* Roberts et al., SISC 44:A1405 - A14 C->W[0][3][0] = SUN_RCONST(47.0)/SUN_RCONST(36.0); C->W[0][3][1] = -ONE/SUN_RCONST(6.0); C->W[0][3][2] = -SUN_RCONST(8.0)/SUN_RCONST(9.0); + C->W[0][4][0] = ONE/SUN_RCONST(40.0); + C->W[0][4][1] = SUN_RCONST(7.0)/SUN_RCONST(40.0); + C->W[0][4][2] = ONE/SUN_RCONST(20.0); C->W[1][2][0] = SUN_RCONST(9.0)/TWO; C->W[1][2][1] = -SUN_RCONST(9.0)/TWO; From 8128a45127e6cfd345b44657bde7be1ce7c13781 Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Fri, 27 Sep 2024 09:05:27 -0500 Subject: [PATCH 080/286] Updated examples according to PR recommendations --- .../arkode/CXX_serial/ark_kpr_nestedmri.cpp | 471 ++++++++++-------- examples/utilities/example_utilities.hpp | 18 +- 2 files changed, 274 insertions(+), 215 deletions(-) diff --git a/examples/arkode/CXX_serial/ark_kpr_nestedmri.cpp b/examples/arkode/CXX_serial/ark_kpr_nestedmri.cpp index b8689506f6..55d9f5d47c 100644 --- a/examples/arkode/CXX_serial/ark_kpr_nestedmri.cpp +++ b/examples/arkode/CXX_serial/ark_kpr_nestedmri.cpp @@ -183,17 +183,17 @@ struct Options int fast_pq = 0; // controller parameters - sunrealtype k1s = SUN_RCONST(-1.0); - sunrealtype k2s = SUN_RCONST(-1.0); - sunrealtype k3s = SUN_RCONST(-1.0); - sunrealtype k1f = SUN_RCONST(-1.0); - sunrealtype k2f = SUN_RCONST(-1.0); - sunrealtype k3f = SUN_RCONST(-1.0); - sunrealtype bias = SUN_RCONST(-1.0); - sunrealtype htol_relch = SUN_RCONST(-1.0); - sunrealtype htol_minfac = SUN_RCONST(-1.0); - sunrealtype htol_maxfac = SUN_RCONST(-1.0); - sunrealtype slow_safety = SUN_RCONST(-1.0); + sunrealtype k1s = NAN; + sunrealtype k2s = NAN; + sunrealtype k3s = NAN; + sunrealtype k1f = NAN; + sunrealtype k2f = NAN; + sunrealtype k3f = NAN; + sunrealtype bias = NAN; + sunrealtype htol_relch = NAN; + sunrealtype htol_minfac = NAN; + sunrealtype htol_maxfac = NAN; + sunrealtype slow_safety = NAN; }; // User-supplied functions called by the solver @@ -220,16 +220,16 @@ static int ReadInputs(std::vector& args, Options& opts, SUNContext ctx); static void PrintSlowAdaptivity(Options opts); static void PrintFastAdaptivity(Options opts); -static sunrealtype p(sunrealtype t, Options* opts); -static sunrealtype q(sunrealtype t, Options* opts); -static sunrealtype r(sunrealtype t, Options* opts); -static sunrealtype pdot(sunrealtype t, Options* opts); -static sunrealtype qdot(sunrealtype t, Options* opts); -static sunrealtype rdot(sunrealtype t, Options* opts); -static sunrealtype utrue(sunrealtype t, Options* opts); -static sunrealtype vtrue(sunrealtype t, Options* opts); -static sunrealtype wtrue(sunrealtype t, Options* opts); -static int Ytrue(sunrealtype t, N_Vector y, Options* opts); +static sunrealtype p(sunrealtype t, const Options& opts); +static sunrealtype q(sunrealtype t, const Options& opts); +static sunrealtype r(sunrealtype t, const Options& opts); +static sunrealtype pdot(sunrealtype t, const Options& opts); +static sunrealtype qdot(sunrealtype t, const Options& opts); +static sunrealtype rdot(sunrealtype t, const Options& opts); +static sunrealtype utrue(sunrealtype t, const Options& opts); +static sunrealtype vtrue(sunrealtype t, const Options& opts); +static sunrealtype wtrue(sunrealtype t, const Options& opts); +static int Ytrue(sunrealtype t, N_Vector y, const Options& opts); // Main Program int main(int argc, char* argv[]) @@ -256,19 +256,19 @@ int main(int argc, char* argv[]) int retval; sunbooleantype slowimplicit, slowimex, midimplicit, midimex; slowimplicit = slowimex = midimplicit = midimex = SUNFALSE; - f_mi = NULL; + f_mi = nullptr; f_me = fm; - f_si = NULL; + f_si = nullptr; f_se = fs; - J_m = NULL; - J_s = NULL; + J_m = nullptr; + J_s = nullptr; f_f = ff; if ((opts.mri_method == "ARKODE_MRI_GARK_IRK21a") || (opts.mri_method == "ARKODE_MRI_GARK_ESDIRK34a") || (opts.mri_method == "ARKODE_MRI_GARK_ESDIRK46a")) { slowimplicit = SUNTRUE; - f_se = NULL; + f_se = nullptr; f_si = fs; J_s = Js; } @@ -287,7 +287,7 @@ int main(int argc, char* argv[]) (opts.mid_method == "ARKODE_MRI_GARK_ESDIRK46a")) { midimplicit = SUNTRUE; - f_me = NULL; + f_me = nullptr; f_mi = fm; J_m = Jm; } @@ -329,7 +329,7 @@ int main(int argc, char* argv[]) if (check_ptr((void*)yref, "N_VClone")) return 1; // Set initial conditions - retval = Ytrue(T0, y, &opts); + retval = Ytrue(T0, y, opts); if (check_flag(retval, "Ytrue")) return 1; N_VScale(ONE, y, yref); @@ -346,13 +346,13 @@ int main(int argc, char* argv[]) if (check_flag(retval, "ARKodeSetMaxNumSteps")) return (1); // Create and configure fast controller object - SUNAdaptController fcontrol = NULL; + SUNAdaptController fcontrol = nullptr; switch (opts.fcontrol) { case (1): fcontrol = SUNAdaptController_I(sunctx); if (check_ptr((void*)fcontrol, "SUNAdaptController_I")) return 1; - if (opts.k1f > -1) + if (!std::isnan(opts.k1f)) { retval = SUNAdaptController_SetParams_I(fcontrol, opts.k1f); if (check_flag(retval, "SUNAdaptController_SetParams_I")) return 1; @@ -361,7 +361,7 @@ int main(int argc, char* argv[]) case (2): fcontrol = SUNAdaptController_PI(sunctx); if (check_ptr((void*)fcontrol, "SUNAdaptController_PI")) return 1; - if (std::min(opts.k1f, opts.k2f) > -1) + if (!(std::isnan(opts.k1f) || std::isnan(opts.k2f))) { retval = SUNAdaptController_SetParams_PI(fcontrol, opts.k1f, opts.k2f); if (check_flag(retval, "SUNAdaptController_SetParams_PI")) return 1; @@ -370,7 +370,7 @@ int main(int argc, char* argv[]) case (3): fcontrol = SUNAdaptController_PID(sunctx); if (check_ptr((void*)fcontrol, "SUNAdaptController_PID")) return 1; - if (std::min(opts.k1f, std::min(opts.k2f, opts.k3f)) > -1) + if (!(std::isnan(opts.k1f) || std::isnan(opts.k2f) || std::isnan(opts.k3f))) { retval = SUNAdaptController_SetParams_PID(fcontrol, opts.k1f, opts.k2f, opts.k3f); @@ -380,7 +380,7 @@ int main(int argc, char* argv[]) case (4): fcontrol = SUNAdaptController_ExpGus(sunctx); if (check_ptr((void*)fcontrol, "SUNAdaptController_ExpGus")) return 1; - if (std::min(opts.k1f, opts.k2f) > -1) + if (!(std::isnan(opts.k1f) || std::isnan(opts.k2f))) { retval = SUNAdaptController_SetParams_ExpGus(fcontrol, opts.k1f, opts.k2f); if (check_flag(retval, "SUNAdaptController_SetParams_ExpGus")) return 1; @@ -389,7 +389,7 @@ int main(int argc, char* argv[]) case (5): fcontrol = SUNAdaptController_ImpGus(sunctx); if (check_ptr((void*)fcontrol, "SUNAdaptController_ImpGus")) return 1; - if (std::min(opts.k1f, opts.k2f) > -1) + if (!(std::isnan(opts.k1f) || std::isnan(opts.k2f))) { retval = SUNAdaptController_SetParams_ImpGus(fcontrol, opts.k1f, opts.k2f); if (check_flag(retval, "SUNAdaptController_SetParams_ImpGus")) return 1; @@ -400,15 +400,14 @@ int main(int argc, char* argv[]) if (check_ptr((void*)fcontrol, "SUNAdaptController_ImExGus")) return 1; break; } - if ((opts.bias > -1) && (opts.fcontrol > 0)) + if (!std::isnan(opts.bias) && (opts.fcontrol > 0)) { retval = SUNAdaptController_SetErrorBias(fcontrol, opts.bias); if (check_flag(retval, "SUNAdaptController_SetErrorBias")) return 1; } // Create ERKStep (fast) integrator - void* inner_arkode_mem = NULL; // ARKode memory structure - inner_arkode_mem = ERKStepCreate(f_f, T0, y, sunctx); + void* inner_arkode_mem = ERKStepCreate(f_f, T0, y, sunctx); if (check_ptr((void*)inner_arkode_mem, "ERKStepCreate")) return 1; retval = ARKodeSetOrder(inner_arkode_mem, opts.fast_order); if (check_flag(retval, "ARKodeSetOrder")) return 1; @@ -442,20 +441,21 @@ int main(int argc, char* argv[]) if (check_flag(retval, "ARKodeSetUserData")) return 1; // Create inner stepper - MRIStepInnerStepper inner_stepper = NULL; + MRIStepInnerStepper inner_stepper = nullptr; retval = ERKStepCreateMRIStepInnerStepper(inner_arkode_mem, &inner_stepper); if (check_flag(retval, "ERKStepCreateMRIStepInnerStepper")) return 1; // Create intermediate and slow controller objects, and select orders of accuracy as relevant - SUNAdaptController scontrol = NULL; - SUNAdaptController scontrol_H = NULL; - SUNAdaptController scontrol_Tol = NULL; - SUNAdaptController mcontrol = NULL; - SUNAdaptController mcontrol_H = NULL; - SUNAdaptController mcontrol_Tol = NULL; + SUNAdaptController scontrol = nullptr; + SUNAdaptController scontrol_H = nullptr; + SUNAdaptController scontrol_Tol = nullptr; + SUNAdaptController mcontrol = nullptr; + SUNAdaptController mcontrol_H = nullptr; + SUNAdaptController mcontrol_Tol = nullptr; switch (opts.scontrol) { case (1): + { scontrol_H = SUNAdaptController_I(sunctx); if (check_ptr((void*)scontrol_H, "SUNAdaptController_I (slow H)")) return 1; scontrol_Tol = SUNAdaptController_I(sunctx); @@ -466,7 +466,7 @@ int main(int argc, char* argv[]) mcontrol_Tol = SUNAdaptController_I(sunctx); if (check_ptr((void*)mcontrol_Tol, "SUNAdaptController_I (mid Tol)")) return 1; - if (opts.k1s > -1) + if (!std::isnan(opts.k1s)) { retval = SUNAdaptController_SetParams_I(scontrol_H, opts.k1s); if (check_flag(retval, "SUNAdaptController_SetParams_I")) return 1; @@ -481,8 +481,8 @@ int main(int argc, char* argv[]) if (check_ptr((void*)scontrol, "SUNAdaptController_MRIHTol")) return 1; mcontrol = SUNAdaptController_MRIHTol(sunctx, mcontrol_H, mcontrol_Tol); if (check_ptr((void*)mcontrol, "SUNAdaptController_MRIHTol")) return 1; - if (std::min(opts.htol_relch, std::min(opts.htol_minfac, opts.htol_maxfac)) > - -1) + if (!(std::isnan(opts.htol_relch) || std::isnan(opts.htol_minfac) || + std::isnan(opts.htol_maxfac))) { retval = SUNAdaptController_SetParams_MRIHTol(scontrol, opts.htol_relch, opts.htol_minfac, @@ -494,7 +494,9 @@ int main(int argc, char* argv[]) if (check_flag(retval, "SUNAdaptController_SetParams_MRIHTol")) return 1; } break; + } case (2): + { scontrol_H = SUNAdaptController_PI(sunctx); if (check_ptr((void*)scontrol_H, "SUNAdaptController_PI (slow H)")) return 1; @@ -506,7 +508,7 @@ int main(int argc, char* argv[]) mcontrol_Tol = SUNAdaptController_PI(sunctx); if (check_ptr((void*)mcontrol_Tol, "SUNAdaptController_PI (mid Tol)")) return 1; - if (std::min(opts.k1s, opts.k2s) > -1) + if (!(std::isnan(opts.k1s) || std::isnan(opts.k2s))) { retval = SUNAdaptController_SetParams_PI(scontrol_H, opts.k1s, opts.k2s); if (check_flag(retval, "SUNAdaptController_SetParams_PI")) return 1; @@ -521,8 +523,8 @@ int main(int argc, char* argv[]) if (check_ptr((void*)scontrol, "SUNAdaptController_MRIHTol")) return 1; mcontrol = SUNAdaptController_MRIHTol(sunctx, mcontrol_H, mcontrol_Tol); if (check_ptr((void*)mcontrol, "SUNAdaptController_MRIHTol")) return 1; - if (std::min(opts.htol_relch, std::min(opts.htol_minfac, opts.htol_maxfac)) > - -1) + if (!(std::isnan(opts.htol_relch) || std::isnan(opts.htol_minfac) || + std::isnan(opts.htol_maxfac))) { retval = SUNAdaptController_SetParams_MRIHTol(scontrol, opts.htol_relch, opts.htol_minfac, @@ -534,7 +536,9 @@ int main(int argc, char* argv[]) if (check_flag(retval, "SUNAdaptController_SetParams_MRIHTol")) return 1; } break; + } case (3): + { scontrol_H = SUNAdaptController_PID(sunctx); if (check_ptr((void*)scontrol_H, "SUNAdaptController_PID (slow H)")) return 1; @@ -547,7 +551,7 @@ int main(int argc, char* argv[]) mcontrol_Tol = SUNAdaptController_PID(sunctx); if (check_ptr((void*)mcontrol_Tol, "SUNAdaptController_PID (mid Tol)")) return 1; - if (std::min(opts.k1s, std::min(opts.k2s, opts.k3s)) > -1) + if (!(std::isnan(opts.k1s) || std::isnan(opts.k2s) || std::isnan(opts.k3s))) { retval = SUNAdaptController_SetParams_PID(scontrol_H, opts.k1s, opts.k2s, opts.k3s); @@ -566,8 +570,7 @@ int main(int argc, char* argv[]) if (check_ptr((void*)scontrol, "SUNAdaptController_MRIHTol")) return 1; mcontrol = SUNAdaptController_MRIHTol(sunctx, mcontrol_H, mcontrol_Tol); if (check_ptr((void*)mcontrol, "SUNAdaptController_MRIHTol")) return 1; - if (std::min(opts.htol_relch, std::min(opts.htol_minfac, opts.htol_maxfac)) > - -1) + if (!(std::isnan(opts.htol_relch) || std::isnan(opts.htol_minfac) || std::isnan(opts.htol_maxfac))) { retval = SUNAdaptController_SetParams_MRIHTol(scontrol, opts.htol_relch, opts.htol_minfac, @@ -579,7 +582,9 @@ int main(int argc, char* argv[]) if (check_flag(retval, "SUNAdaptController_SetParams_MRIHTol")) return 1; } break; + } case (4): + { scontrol_H = SUNAdaptController_ExpGus(sunctx); if (check_ptr((void*)scontrol_H, "SUNAdaptController_ExpGus (slow H)")) return 1; @@ -592,7 +597,7 @@ int main(int argc, char* argv[]) mcontrol_Tol = SUNAdaptController_ExpGus(sunctx); if (check_ptr((void*)mcontrol_Tol, "SUNAdaptController_ExpGus (mid Tol)")) return 1; - if (std::min(opts.k1s, opts.k2s) > -1) + if (!(std::isnan(opts.k1s) || std::isnan(opts.k2s))) { retval = SUNAdaptController_SetParams_ExpGus(scontrol_H, opts.k1s, opts.k2s); @@ -611,8 +616,8 @@ int main(int argc, char* argv[]) if (check_ptr((void*)scontrol, "SUNAdaptController_MRIHTol")) return 1; mcontrol = SUNAdaptController_MRIHTol(sunctx, mcontrol_H, mcontrol_Tol); if (check_ptr((void*)mcontrol, "SUNAdaptController_MRIHTol")) return 1; - if (std::min(opts.htol_relch, std::min(opts.htol_minfac, opts.htol_maxfac)) > - -1) + if (!(std::isnan(opts.htol_relch) || std::isnan(opts.htol_minfac) || + std::isnan(opts.htol_maxfac))) { retval = SUNAdaptController_SetParams_MRIHTol(scontrol, opts.htol_relch, opts.htol_minfac, @@ -624,7 +629,9 @@ int main(int argc, char* argv[]) if (check_flag(retval, "SUNAdaptController_SetParams_MRIHTol")) return 1; } break; + } case (5): + { scontrol_H = SUNAdaptController_ImpGus(sunctx); if (check_ptr((void*)scontrol_H, "SUNAdaptController_ImpGus (slow H)")) return 1; @@ -637,7 +644,7 @@ int main(int argc, char* argv[]) mcontrol_Tol = SUNAdaptController_ImpGus(sunctx); if (check_ptr((void*)mcontrol_Tol, "SUNAdaptController_ImpGus (mid Tol)")) return 1; - if (std::min(opts.k1s, opts.k2s) > -1) + if (!(std::isnan(opts.k1s) || std::isnan(opts.k2s))) { retval = SUNAdaptController_SetParams_ImpGus(scontrol_H, opts.k1s, opts.k2s); @@ -656,8 +663,8 @@ int main(int argc, char* argv[]) if (check_ptr((void*)scontrol, "SUNAdaptController_MRIHTol")) return 1; mcontrol = SUNAdaptController_MRIHTol(sunctx, mcontrol_H, mcontrol_Tol); if (check_ptr((void*)mcontrol, "SUNAdaptController_MRIHTol")) return 1; - if (std::min(opts.htol_relch, std::min(opts.htol_minfac, opts.htol_maxfac)) > - -1) + if (!(std::isnan(opts.htol_relch) || std::isnan(opts.htol_minfac) || + std::isnan(opts.htol_maxfac))) { retval = SUNAdaptController_SetParams_MRIHTol(scontrol, opts.htol_relch, opts.htol_minfac, @@ -669,7 +676,9 @@ int main(int argc, char* argv[]) if (check_flag(retval, "SUNAdaptController_SetParams_MRIHTol")) return 1; } break; + } case (6): + { scontrol_H = SUNAdaptController_ImExGus(sunctx); if (check_ptr((void*)scontrol_H, "SUNAdaptController_ImExGus (slow H)")) return 1; @@ -686,8 +695,8 @@ int main(int argc, char* argv[]) if (check_ptr((void*)scontrol, "SUNAdaptController_MRIHTol")) return 1; mcontrol = SUNAdaptController_MRIHTol(sunctx, scontrol_H, scontrol_Tol); if (check_ptr((void*)mcontrol, "SUNAdaptController_MRIHTol")) return 1; - if (std::min(opts.htol_relch, std::min(opts.htol_minfac, opts.htol_maxfac)) > - -1) + if (!(std::isnan(opts.htol_relch) || std::isnan(opts.htol_minfac) || + std::isnan(opts.htol_maxfac))) { retval = SUNAdaptController_SetParams_MRIHTol(scontrol, opts.htol_relch, opts.htol_minfac, @@ -699,12 +708,14 @@ int main(int argc, char* argv[]) if (check_flag(retval, "SUNAdaptController_SetParams_MRIHTol")) return 1; } break; + } case (7): + { scontrol = SUNAdaptController_I(sunctx); if (check_ptr((void*)scontrol, "SUNAdaptControllerI (slow)")) return 1; mcontrol = SUNAdaptController_I(sunctx); if (check_ptr((void*)mcontrol, "SUNAdaptControllerI (mid)")) return 1; - if (opts.k1s > -1) + if (!std::isnan(opts.k1s)) { retval = SUNAdaptController_SetParams_I(scontrol, opts.k1s); if (check_flag(retval, "SUNAdaptController_SetParams_I")) return 1; @@ -712,12 +723,14 @@ int main(int argc, char* argv[]) if (check_flag(retval, "SUNAdaptController_SetParams_I")) return 1; } break; + } case (8): + { scontrol = SUNAdaptController_PI(sunctx); if (check_ptr((void*)scontrol, "SUNAdaptController_PI (slow)")) return 1; mcontrol = SUNAdaptController_PI(sunctx); if (check_ptr((void*)mcontrol, "SUNAdaptController_PI (mid)")) return 1; - if (std::min(opts.k1s, opts.k2s) > -1) + if (!(std::isnan(opts.k1s) || std::isnan(opts.k2s))) { retval = SUNAdaptController_SetParams_PI(scontrol, opts.k1s, opts.k2s); if (check_flag(retval, "SUNAdaptController_SetParams_PI")) return 1; @@ -725,12 +738,14 @@ int main(int argc, char* argv[]) if (check_flag(retval, "SUNAdaptController_SetParams_PI")) return 1; } break; + } case (9): + { scontrol = SUNAdaptController_PID(sunctx); if (check_ptr((void*)scontrol, "SUNAdaptController_PID (slow)")) return 1; mcontrol = SUNAdaptController_PID(sunctx); if (check_ptr((void*)mcontrol, "SUNAdaptController_PID (mid)")) return 1; - if (std::min(opts.k1s, std::min(opts.k2s, opts.k3s)) > -1) + if (!(std::isnan(opts.k1s) || std::isnan(opts.k2s) || std::isnan(opts.k3s))) { retval = SUNAdaptController_SetParams_PID(scontrol, opts.k1s, opts.k2s, opts.k3s); @@ -740,13 +755,15 @@ int main(int argc, char* argv[]) if (check_flag(retval, "SUNAdaptController_SetParams_PID")) return 1; } break; + } case (10): + { scontrol = SUNAdaptController_ExpGus(sunctx); if (check_ptr((void*)scontrol, "SUNAdaptController_ExpGus (slow)")) return 1; mcontrol = SUNAdaptController_ExpGus(sunctx); if (check_ptr((void*)mcontrol, "SUNAdaptController_ExpGus (mid)")) return 1; - if (std::min(opts.k1s, opts.k2s) > -1) + if (!(std::isnan(opts.k1s) || std::isnan(opts.k2s))) { retval = SUNAdaptController_SetParams_ExpGus(scontrol, opts.k1s, opts.k2s); if (check_flag(retval, "SUNAdaptController_SetParams_ExpGus")) return 1; @@ -754,13 +771,15 @@ int main(int argc, char* argv[]) if (check_flag(retval, "SUNAdaptController_SetParams_ExpGus")) return 1; } break; + } case (11): + { scontrol = SUNAdaptController_ImpGus(sunctx); if (check_ptr((void*)scontrol, "SUNAdaptController_ImpGus (slow)")) return 1; mcontrol = SUNAdaptController_ImpGus(sunctx); if (check_ptr((void*)mcontrol, "SUNAdaptController_ImpGus (mid)")) return 1; - if (std::min(opts.k1s, opts.k2s) > -1) + if (!(std::isnan(opts.k1s) || std::isnan(opts.k2s))) { retval = SUNAdaptController_SetParams_ImpGus(scontrol, opts.k1s, opts.k2s); if (check_flag(retval, "SUNAdaptController_SetParams_ImpGus")) return 1; @@ -768,7 +787,9 @@ int main(int argc, char* argv[]) if (check_flag(retval, "SUNAdaptController_SetParams_ImpGus")) return 1; } break; - case (16): + } + case (12): + { scontrol = SUNAdaptController_ImExGus(sunctx); if (check_ptr((void*)scontrol, "SUNAdaptController_ImExGus (slow)")) return 1; @@ -777,7 +798,8 @@ int main(int argc, char* argv[]) return 1; break; } - if ((opts.bias > -1) && (opts.scontrol > 0)) + } + if (!std::isnan(opts.bias) && (opts.scontrol > 0)) { retval = SUNAdaptController_SetErrorBias(scontrol, opts.bias); if (check_flag(retval, "SUNAdaptController_SetErrorBias")) return 1; @@ -786,15 +808,14 @@ int main(int argc, char* argv[]) } // Create MRI (intermediate) integrator - void* mid_arkode_mem = NULL; // ARKode memory structure - mid_arkode_mem = MRIStepCreate(f_me, f_mi, T0, y, inner_stepper, sunctx); + void* mid_arkode_mem = MRIStepCreate(f_me, f_mi, T0, y, inner_stepper, sunctx); if (check_ptr((void*)mid_arkode_mem, "MRIStepCreate")) return 1; MRIStepCoupling Cm = MRIStepCoupling_LoadTableByName((opts.mid_method).c_str()); if (check_ptr((void*)Cm, "MRIStepCoupling_LoadTableByName")) return 1; retval = MRIStepSetCoupling(mid_arkode_mem, Cm); if (check_flag(retval, "MRIStepSetCoupling")) return 1; - SUNMatrix Am = NULL; // matrix for intermediate solver - SUNLinearSolver LSm = NULL; // intermediate linear solver object + SUNMatrix Am = nullptr; // matrix for intermediate solver + SUNLinearSolver LSm = nullptr; // intermediate linear solver object if (midimplicit) { Am = SUNDenseMatrix(NEQ, NEQ, sunctx); @@ -828,7 +849,7 @@ int main(int argc, char* argv[]) retval = ARKodeSetAdaptivityAdjustment(mid_arkode_mem, 0); if (check_flag(retval, "ARKodeSetAdaptivityAdjustment")) return 1; } - if (opts.slow_safety > -1) + if (!std::isnan(opts.slow_safety)) { retval = ARKodeSetSafetyFactor(mid_arkode_mem, opts.slow_safety); if (check_flag(retval, "ARKodeSetSafetyFactor")) return 1; @@ -841,21 +862,19 @@ int main(int argc, char* argv[]) } // Create intermediate stepper - MRIStepInnerStepper intermediate_stepper = NULL; - retval = MRIStepCreateMRIStepInnerStepper(mid_arkode_mem, - &intermediate_stepper); + MRIStepInnerStepper intermediate_stepper = nullptr; + retval = MRIStepCreateMRIStepInnerStepper(mid_arkode_mem, &intermediate_stepper); if (check_flag(retval, "MRIStepCreateMRIStepInnerStepper")) return 1; // Create MRI (slow) integrator - void* arkode_mem = NULL; // ARKode memory structure - arkode_mem = MRIStepCreate(f_se, f_si, T0, y, intermediate_stepper, sunctx); + void* arkode_mem = MRIStepCreate(f_se, f_si, T0, y, intermediate_stepper, sunctx); if (check_ptr((void*)arkode_mem, "MRIStepCreate")) return 1; MRIStepCoupling Cs = MRIStepCoupling_LoadTableByName((opts.mri_method).c_str()); if (check_ptr((void*)Cs, "MRIStepCoupling_LoadTableByName")) return 1; retval = MRIStepSetCoupling(arkode_mem, Cs); if (check_flag(retval, "MRIStepSetCoupling")) return 1; - SUNMatrix As = NULL; // matrix for slow solver - SUNLinearSolver LSs = NULL; // slow linear solver object + SUNMatrix As = nullptr; // matrix for slow solver + SUNLinearSolver LSs = nullptr; // slow linear solver object if (slowimplicit) { As = SUNDenseMatrix(NEQ, NEQ, sunctx); @@ -887,7 +906,7 @@ int main(int argc, char* argv[]) retval = ARKodeSetAdaptivityAdjustment(arkode_mem, 0); if (check_flag(retval, "ARKodeSetAdaptivityAdjustment")) return 1; } - if (opts.slow_safety > -1) + if (!std::isnan(opts.slow_safety)) { retval = ARKodeSetSafetyFactor(arkode_mem, opts.slow_safety); if (check_flag(retval, "ARKodeSetSafetyFactor")) return 1; @@ -951,19 +970,19 @@ int main(int argc, char* argv[]) u = NV_Ith_S(y, 0); v = NV_Ith_S(y, 1); w = NV_Ith_S(y, 2); - uerr = SUNRabs(NV_Ith_S(yref, 0) - u); - verr = SUNRabs(NV_Ith_S(yref, 1) - v); - werr = SUNRabs(NV_Ith_S(yref, 2) - w); + uerr = std::abs(NV_Ith_S(yref, 0) - u); + verr = std::abs(NV_Ith_S(yref, 1) - v); + werr = std::abs(NV_Ith_S(yref, 2) - w); uerrtot += uerr * uerr; verrtot += verr * verr; werrtot += werr * werr; errtot += uerr * uerr + verr * verr + werr * werr; - accuracy = std::max(accuracy, uerr / SUNRabs(opts.atol + - opts.rtol * NV_Ith_S(yref, 0))); - accuracy = std::max(accuracy, verr / SUNRabs(opts.atol + - opts.rtol * NV_Ith_S(yref, 1))); - accuracy = std::max(accuracy, werr / SUNRabs(opts.atol + - opts.rtol * NV_Ith_S(yref, 2))); + accuracy = std::max(accuracy, uerr / std::abs(opts.atol + + opts.rtol * NV_Ith_S(yref, 0))); + accuracy = std::max(accuracy, verr / std::abs(opts.atol + + opts.rtol * NV_Ith_S(yref, 1))); + accuracy = std::max(accuracy, werr / std::abs(opts.atol + + opts.rtol * NV_Ith_S(yref, 2))); Nout++; // Periodically output current results to screen @@ -976,10 +995,10 @@ int main(int argc, char* argv[]) t, u, v, w, uerr, verr, werr); } } - uerrtot = SUNRsqrt(uerrtot / Nt); - verrtot = SUNRsqrt(verrtot / Nt); - werrtot = SUNRsqrt(werrtot / Nt); - errtot = SUNRsqrt(errtot / Nt / 3); + uerrtot = std::sqrt(uerrtot / Nt); + verrtot = std::sqrt(verrtot / Nt); + werrtot = std::sqrt(werrtot / Nt); + errtot = std::sqrt(errtot / Nt / 3); printf(" " "---------------------------------------------------------------------" "-------\n"); @@ -1066,17 +1085,17 @@ int main(int argc, char* argv[]) N_VDestroy(y); MRIStepCoupling_Free(Cs); MRIStepCoupling_Free(Cm); - if (As) { SUNMatDestroy(As); } - if (LSs) { SUNLinSolFree(LSs); } - if (Am) { SUNMatDestroy(Am); } - if (LSm) { SUNLinSolFree(LSm); } - if (scontrol) { SUNAdaptController_Destroy(scontrol); } - if (scontrol_H) { SUNAdaptController_Destroy(scontrol_H); } - if (scontrol_Tol) { SUNAdaptController_Destroy(scontrol_Tol); } - if (mcontrol) { SUNAdaptController_Destroy(mcontrol); } - if (mcontrol_H) { SUNAdaptController_Destroy(mcontrol_H); } - if (mcontrol_Tol) { SUNAdaptController_Destroy(mcontrol_Tol); } - if (fcontrol) { SUNAdaptController_Destroy(fcontrol); } + SUNMatDestroy(As); + SUNLinSolFree(LSs); + SUNMatDestroy(Am); + SUNLinSolFree(LSm); + SUNAdaptController_Destroy(scontrol); + SUNAdaptController_Destroy(scontrol_H); + SUNAdaptController_Destroy(scontrol_Tol); + SUNAdaptController_Destroy(mcontrol); + SUNAdaptController_Destroy(mcontrol_H); + SUNAdaptController_Destroy(mcontrol_Tol); + SUNAdaptController_Destroy(fcontrol); ARKodeFree(&inner_arkode_mem); // Free fast integrator memory ARKodeFree(&mid_arkode_mem); // Free intermediate integrator memory MRIStepInnerStepper_Free(&inner_stepper); // Free inner stepper structures @@ -1094,7 +1113,7 @@ int main(int argc, char* argv[]) // fn routine to compute the full ODE RHS. static int fn(sunrealtype t, N_Vector y, N_Vector ydot, void* user_data) { - Options* opts = (Options*)user_data; + Options* opts = static_cast(user_data); const sunrealtype u = NV_Ith_S(y, 0); const sunrealtype v = NV_Ith_S(y, 1); const sunrealtype w = NV_Ith_S(y, 2); @@ -1108,14 +1127,14 @@ static int fn(sunrealtype t, N_Vector y, N_Vector ydot, void* user_data) // [ G e e ] [(u^2-p-2)/(2u)] + [ pdot(t)/(2u) ] // [ e al be ] [(v^2-q-2)/(2v)] [ qdot(t)/(2v) ] // [ e -be al ] [(w^2-r-2)/(2w)] [ rdot(t)/(2w) ] - tmp1 = (-TWO + u * u - p(t, opts)) / (TWO * u); - tmp2 = (-TWO + v * v - q(t, opts)) / (TWO * v); - tmp3 = (-TWO + w * w - r(t, opts)) / (TWO * w); - NV_Ith_S(ydot, 0) = G * tmp1 + e * tmp2 + e * tmp3 + pdot(t, opts) / (TWO * u); + tmp1 = (-TWO + u * u - p(t, *opts)) / (TWO * u); + tmp2 = (-TWO + v * v - q(t, *opts)) / (TWO * v); + tmp3 = (-TWO + w * w - r(t, *opts)) / (TWO * w); + NV_Ith_S(ydot, 0) = G * tmp1 + e * tmp2 + e * tmp3 + pdot(t, *opts) / (TWO * u); NV_Ith_S(ydot, 1) = e * tmp1 + al * tmp2 + be * tmp3 + - qdot(t, opts) / (TWO * v); + qdot(t, *opts) / (TWO * v); NV_Ith_S(ydot, 2) = e * tmp1 - be * tmp2 + al * tmp3 + - rdot(t, opts) / (TWO * w); + rdot(t, *opts) / (TWO * w); // Return with success return 0; @@ -1124,7 +1143,7 @@ static int fn(sunrealtype t, N_Vector y, N_Vector ydot, void* user_data) // ff routine to compute the fast portion of the ODE RHS. static int ff(sunrealtype t, N_Vector y, N_Vector ydot, void* user_data) { - Options* opts = (Options*)user_data; + Options* opts = static_cast(user_data); const sunrealtype u = NV_Ith_S(y, 0); const sunrealtype v = NV_Ith_S(y, 1); const sunrealtype w = NV_Ith_S(y, 2); @@ -1137,13 +1156,13 @@ static int ff(sunrealtype t, N_Vector y, N_Vector ydot, void* user_data) // [ 0 0 0 ] [(u^2-p-2)/(2u)] + [ 0 ] // [ 0 0 0 ] [(v^2-q-2)/(2v)] [ 0 ] // [ e -be al ] [(w^2-r-2)/(2w)] [ rdot(t)/(2w) ] - tmp1 = (-TWO + u * u - p(t, opts)) / (TWO * u); - tmp2 = (-TWO + v * v - q(t, opts)) / (TWO * v); - tmp3 = (-TWO + w * w - r(t, opts)) / (TWO * w); + tmp1 = (-TWO + u * u - p(t, *opts)) / (TWO * u); + tmp2 = (-TWO + v * v - q(t, *opts)) / (TWO * v); + tmp3 = (-TWO + w * w - r(t, *opts)) / (TWO * w); NV_Ith_S(ydot, 0) = ZERO; NV_Ith_S(ydot, 1) = ZERO; NV_Ith_S(ydot, 2) = e * tmp1 - be * tmp2 + al * tmp3 + - rdot(t, opts) / (TWO * w); + rdot(t, *opts) / (TWO * w); // Return with success return 0; @@ -1152,7 +1171,7 @@ static int ff(sunrealtype t, N_Vector y, N_Vector ydot, void* user_data) // fm routine to compute the intermediate portion of the ODE RHS. static int fm(sunrealtype t, N_Vector y, N_Vector ydot, void* user_data) { - Options* opts = (Options*)user_data; + Options* opts = static_cast(user_data); const sunrealtype u = NV_Ith_S(y, 0); const sunrealtype v = NV_Ith_S(y, 1); const sunrealtype w = NV_Ith_S(y, 2); @@ -1165,12 +1184,12 @@ static int fm(sunrealtype t, N_Vector y, N_Vector ydot, void* user_data) // [ 0 0 0 ] [(u^2-p-2)/(2u)] + [ 0 ] // [ e al be ] [(v^2-q-2)/(2v)] [ qdot(t)/(2v) ] // [ 0 0 0 ] [(w^2-r-2)/(2w)] [ 0 ] - tmp1 = (-TWO + u * u - p(t, opts)) / (TWO * u); - tmp2 = (-TWO + v * v - q(t, opts)) / (TWO * v); - tmp3 = (-TWO + w * w - r(t, opts)) / (TWO * w); + tmp1 = (-TWO + u * u - p(t, *opts)) / (TWO * u); + tmp2 = (-TWO + v * v - q(t, *opts)) / (TWO * v); + tmp3 = (-TWO + w * w - r(t, *opts)) / (TWO * w); NV_Ith_S(ydot, 0) = ZERO; NV_Ith_S(ydot, 1) = e * tmp1 + al * tmp2 + be * tmp3 + - qdot(t, opts) / (TWO * v); + qdot(t, *opts) / (TWO * v); NV_Ith_S(ydot, 2) = ZERO; return 0; @@ -1179,7 +1198,7 @@ static int fm(sunrealtype t, N_Vector y, N_Vector ydot, void* user_data) // fme routine to compute the explicit intermediate portion of the ODE RHS. static int fme(sunrealtype t, N_Vector y, N_Vector ydot, void* user_data) { - Options* opts = (Options*)user_data; + Options* opts = static_cast(user_data); const sunrealtype v = NV_Ith_S(y, 1); // fill in the RHS function: @@ -1187,7 +1206,7 @@ static int fme(sunrealtype t, N_Vector y, N_Vector ydot, void* user_data) // [ qdot(t)/(2v) ] // [ 0 ] NV_Ith_S(ydot, 0) = ZERO; - NV_Ith_S(ydot, 1) = qdot(t, opts) / (TWO * v); + NV_Ith_S(ydot, 1) = qdot(t, *opts) / (TWO * v); NV_Ith_S(ydot, 2) = ZERO; return 0; @@ -1196,7 +1215,7 @@ static int fme(sunrealtype t, N_Vector y, N_Vector ydot, void* user_data) // fmi routine to compute the implicit intermediate portion of the ODE RHS. static int fmi(sunrealtype t, N_Vector y, N_Vector ydot, void* user_data) { - Options* opts = (Options*)user_data; + Options* opts = static_cast(user_data); const sunrealtype u = NV_Ith_S(y, 0); const sunrealtype v = NV_Ith_S(y, 1); const sunrealtype w = NV_Ith_S(y, 2); @@ -1209,9 +1228,9 @@ static int fmi(sunrealtype t, N_Vector y, N_Vector ydot, void* user_data) // [ 0 0 0 ] [(u^2-p-2)/(2u)] // [ e al be ] [(v^2-q-2)/(2v)] // [ 0 0 0 ] [(w^2-r-2)/(2w)] - tmp1 = (-TWO + u * u - p(t, opts)) / (TWO * u); - tmp2 = (-TWO + v * v - q(t, opts)) / (TWO * v); - tmp3 = (-TWO + w * w - r(t, opts)) / (TWO * w); + tmp1 = (-TWO + u * u - p(t, *opts)) / (TWO * u); + tmp2 = (-TWO + v * v - q(t, *opts)) / (TWO * v); + tmp3 = (-TWO + w * w - r(t, *opts)) / (TWO * w); NV_Ith_S(ydot, 0) = ZERO; NV_Ith_S(ydot, 1) = e * tmp1 + al * tmp2 + be * tmp3; NV_Ith_S(ydot, 2) = ZERO; @@ -1223,7 +1242,7 @@ static int fmi(sunrealtype t, N_Vector y, N_Vector ydot, void* user_data) // fs routine to compute the slow portion of the ODE RHS. static int fs(sunrealtype t, N_Vector y, N_Vector ydot, void* user_data) { - Options* opts = (Options*)user_data; + Options* opts = static_cast(user_data); const sunrealtype u = NV_Ith_S(y, 0); const sunrealtype v = NV_Ith_S(y, 1); const sunrealtype w = NV_Ith_S(y, 2); @@ -1235,10 +1254,10 @@ static int fs(sunrealtype t, N_Vector y, N_Vector ydot, void* user_data) // [ G e e ] [(u^2-p-2)/(2u)] + [ pdot(t)/(2u) ] // [ 0 0 0 ] [(v^2-q-2)/(2v)] [ 0 ] // [ 0 0 0 ] [(w^2-r-2)/(2w)] [ 0 ] - tmp1 = (-TWO + u * u - p(t, opts)) / (TWO * u); - tmp2 = (-TWO + v * v - q(t, opts)) / (TWO * v); - tmp3 = (-TWO + w * w - r(t, opts)) / (TWO * w); - NV_Ith_S(ydot, 0) = G * tmp1 + e * tmp2 + e * tmp3 + pdot(t, opts) / (TWO * u); + tmp1 = (-TWO + u * u - p(t, *opts)) / (TWO * u); + tmp2 = (-TWO + v * v - q(t, *opts)) / (TWO * v); + tmp3 = (-TWO + w * w - r(t, *opts)) / (TWO * w); + NV_Ith_S(ydot, 0) = G * tmp1 + e * tmp2 + e * tmp3 + pdot(t, *opts) / (TWO * u); NV_Ith_S(ydot, 1) = ZERO; NV_Ith_S(ydot, 2) = ZERO; @@ -1248,14 +1267,14 @@ static int fs(sunrealtype t, N_Vector y, N_Vector ydot, void* user_data) // fse routine to compute the explicit slow portion of the ODE RHS. static int fse(sunrealtype t, N_Vector y, N_Vector ydot, void* user_data) { - Options* opts = (Options*)user_data; + Options* opts = static_cast(user_data); const sunrealtype u = NV_Ith_S(y, 0); // fill in the RHS function: // [ pdot(t)/(2u) ] // [ 0 ] // [ 0 ] - NV_Ith_S(ydot, 0) = pdot(t, opts) / (TWO * u); + NV_Ith_S(ydot, 0) = pdot(t, *opts) / (TWO * u); NV_Ith_S(ydot, 1) = ZERO; NV_Ith_S(ydot, 2) = ZERO; @@ -1265,7 +1284,7 @@ static int fse(sunrealtype t, N_Vector y, N_Vector ydot, void* user_data) // fsi routine to compute the implicit slow portion of the ODE RHS. static int fsi(sunrealtype t, N_Vector y, N_Vector ydot, void* user_data) { - Options* opts = (Options*)user_data; + Options* opts = static_cast(user_data); const sunrealtype u = NV_Ith_S(y, 0); const sunrealtype v = NV_Ith_S(y, 1); const sunrealtype w = NV_Ith_S(y, 2); @@ -1277,9 +1296,9 @@ static int fsi(sunrealtype t, N_Vector y, N_Vector ydot, void* user_data) // [ G e e ] [(u^2-p-2)/(2u)] // [ 0 0 0 ] [(v^2-q-2)/(2v)] // [ 0 0 0 ] [(w^2-r-2)/(2w)] - tmp1 = (-TWO + u * u - p(t, opts)) / (TWO * u); - tmp2 = (-TWO + v * v - q(t, opts)) / (TWO * v); - tmp3 = (-TWO + w * w - r(t, opts)) / (TWO * w); + tmp1 = (-TWO + u * u - p(t, *opts)) / (TWO * u); + tmp2 = (-TWO + v * v - q(t, *opts)) / (TWO * v); + tmp3 = (-TWO + w * w - r(t, *opts)) / (TWO * w); NV_Ith_S(ydot, 0) = G * tmp1 + e * tmp2 + e * tmp3; NV_Ith_S(ydot, 1) = ZERO; NV_Ith_S(ydot, 2) = ZERO; @@ -1292,7 +1311,7 @@ static int fsi(sunrealtype t, N_Vector y, N_Vector ydot, void* user_data) static int Jm(sunrealtype t, N_Vector y, N_Vector fy, SUNMatrix J, void* user_data, N_Vector tmp1, N_Vector tmp2, N_Vector tmp3) { - Options* opts = (Options*)user_data; + Options* opts = static_cast(user_data); const sunrealtype u = NV_Ith_S(y, 0); const sunrealtype v = NV_Ith_S(y, 1); const sunrealtype w = NV_Ith_S(y, 2); @@ -1302,14 +1321,14 @@ static int Jm(sunrealtype t, N_Vector y, N_Vector fy, SUNMatrix J, // [0 0 0]*[1-(u^2-p(t)-2)/(2*u^2), 0, 0] + [0, 0, 0] // [e al be] [0, 1-(v^2-q(t)-2)/(2*v^2), 0] [0, -q'(t)/(2*v^2), 0] // [0 0 0] [0, 0, 1-(w^2-r(t)-2)/(2*w^2)] [0, 0, 0] - t11 = ONE - (u * u - p(t, opts) - TWO) / (TWO * u * u); - t22 = ONE - (v * v - q(t, opts) - TWO) / (TWO * v * v); - t33 = ONE - (w * w - r(t, opts) - TWO) / (TWO * w * w); + t11 = ONE - (u * u - p(t, *opts) - TWO) / (TWO * u * u); + t22 = ONE - (v * v - q(t, *opts) - TWO) / (TWO * v * v); + t33 = ONE - (w * w - r(t, *opts) - TWO) / (TWO * w * w); SM_ELEMENT_D(J, 0, 0) = ZERO; SM_ELEMENT_D(J, 0, 1) = ZERO; SM_ELEMENT_D(J, 0, 2) = ZERO; SM_ELEMENT_D(J, 1, 0) = opts->e * t11; - SM_ELEMENT_D(J, 1, 1) = opts->al * t22 - qdot(t, opts) / (TWO * v * v); + SM_ELEMENT_D(J, 1, 1) = opts->al * t22 - qdot(t, *opts) / (TWO * v * v); SM_ELEMENT_D(J, 1, 2) = opts->be * t33; SM_ELEMENT_D(J, 2, 0) = ZERO; SM_ELEMENT_D(J, 2, 1) = ZERO; @@ -1323,7 +1342,7 @@ static int Jm(sunrealtype t, N_Vector y, N_Vector fy, SUNMatrix J, static int Jmi(sunrealtype t, N_Vector y, N_Vector fy, SUNMatrix J, void* user_data, N_Vector tmp1, N_Vector tmp2, N_Vector tmp3) { - Options* opts = (Options*)user_data; + Options* opts = static_cast(user_data); const sunrealtype u = NV_Ith_S(y, 0); const sunrealtype v = NV_Ith_S(y, 1); const sunrealtype w = NV_Ith_S(y, 2); @@ -1333,9 +1352,9 @@ static int Jmi(sunrealtype t, N_Vector y, N_Vector fy, SUNMatrix J, // [0 0 0]*[1-(u^2-p(t)-2)/(2*u^2), 0, 0] // [e al be] [0, 1-(v^2-q(t)-2)/(2*v^2), 0] // [0 0 0] [0, 0, 1-(w^2-r(t)-2)/(2*w^2)] - t11 = ONE - (u * u - p(t, opts) - TWO) / (TWO * u * u); - t22 = ONE - (v * v - q(t, opts) - TWO) / (TWO * v * v); - t33 = ONE - (w * w - r(t, opts) - TWO) / (TWO * w * w); + t11 = ONE - (u * u - p(t, *opts) - TWO) / (TWO * u * u); + t22 = ONE - (v * v - q(t, *opts) - TWO) / (TWO * v * v); + t33 = ONE - (w * w - r(t, *opts) - TWO) / (TWO * w * w); SM_ELEMENT_D(J, 0, 0) = ZERO; SM_ELEMENT_D(J, 0, 1) = ZERO; SM_ELEMENT_D(J, 0, 2) = ZERO; @@ -1354,7 +1373,7 @@ static int Jmi(sunrealtype t, N_Vector y, N_Vector fy, SUNMatrix J, static int Js(sunrealtype t, N_Vector y, N_Vector fy, SUNMatrix J, void* user_data, N_Vector tmp1, N_Vector tmp2, N_Vector tmp3) { - Options* opts = (Options*)user_data; + Options* opts = static_cast(user_data); const sunrealtype u = NV_Ith_S(y, 0); const sunrealtype v = NV_Ith_S(y, 1); const sunrealtype w = NV_Ith_S(y, 2); @@ -1364,10 +1383,10 @@ static int Js(sunrealtype t, N_Vector y, N_Vector fy, SUNMatrix J, // [G e e]*[1-(u^2-p(t)-2)/(2*u^2), 0, 0] + [-p'(t)/(2*u^2), 0, 0] // [0 0 0] [0, 1-(v^2-q(t)-2)/(2*v^2), 0] [0, 0, 0] // [0 0 0] [0, 0, 1-(w^2-r(t)-2)/(2*w^2)] [0, 0, 0] - t11 = ONE - (u * u - p(t, opts) - TWO) / (TWO * u * u); - t22 = ONE - (v * v - q(t, opts) - TWO) / (TWO * v * v); - t33 = ONE - (w * w - r(t, opts) - TWO) / (TWO * w * w); - SM_ELEMENT_D(J, 0, 0) = opts->G * t11 - pdot(t, opts) / (TWO * u * u); + t11 = ONE - (u * u - p(t, *opts) - TWO) / (TWO * u * u); + t22 = ONE - (v * v - q(t, *opts) - TWO) / (TWO * v * v); + t33 = ONE - (w * w - r(t, *opts) - TWO) / (TWO * w * w); + SM_ELEMENT_D(J, 0, 0) = opts->G * t11 - pdot(t, *opts) / (TWO * u * u); SM_ELEMENT_D(J, 0, 1) = opts->e * t22; SM_ELEMENT_D(J, 0, 2) = opts->e * t33; SM_ELEMENT_D(J, 1, 0) = ZERO; @@ -1385,7 +1404,7 @@ static int Js(sunrealtype t, N_Vector y, N_Vector fy, SUNMatrix J, static int Jsi(sunrealtype t, N_Vector y, N_Vector fy, SUNMatrix J, void* user_data, N_Vector tmp1, N_Vector tmp2, N_Vector tmp3) { - Options* opts = (Options*)user_data; + Options* opts = static_cast(user_data); const sunrealtype u = NV_Ith_S(y, 0); const sunrealtype v = NV_Ith_S(y, 1); const sunrealtype w = NV_Ith_S(y, 2); @@ -1395,9 +1414,9 @@ static int Jsi(sunrealtype t, N_Vector y, N_Vector fy, SUNMatrix J, // [G e e]*[1-(u^2-p(t)-2)/(2*u^2), 0, 0] // [0 0 0] [0, 1-(v^2-q(t)-2)/(2*v^2), 0] // [0 0 0] [0, 0, 1-(w^2-r(t)-2)/(2*w^2)] - t11 = ONE - (u * u - p(t, opts) - TWO) / (TWO * u * u); - t22 = ONE - (v * v - q(t, opts) - TWO) / (TWO * v * v); - t33 = ONE - (w * w - r(t, opts) - TWO) / (TWO * w * w); + t11 = ONE - (u * u - p(t, *opts) - TWO) / (TWO * u * u); + t22 = ONE - (v * v - q(t, *opts) - TWO) / (TWO * v * v); + t33 = ONE - (w * w - r(t, *opts) - TWO) / (TWO * w * w); SM_ELEMENT_D(J, 0, 0) = opts->G * t11; SM_ELEMENT_D(J, 0, 1) = opts->e * t22; SM_ELEMENT_D(J, 0, 2) = opts->e * t33; @@ -1416,52 +1435,52 @@ static int Jsi(sunrealtype t, N_Vector y, N_Vector fy, SUNMatrix J, // Private helper functions // ----------------------------- -static sunrealtype p(sunrealtype t, Options* opts) { return HALF * cos(t); } +static sunrealtype p(sunrealtype t, const Options& opts) { return HALF * cos(t); } -static sunrealtype q(sunrealtype t, Options* opts) +static sunrealtype q(sunrealtype t, const Options& opts) { - return (cos(opts->om * t * (ONE + exp(-(t - TWO) * (t - TWO))))); + return (cos(opts.om * t * (ONE + exp(-(t - TWO) * (t - TWO))))); } -static sunrealtype r(sunrealtype t, Options* opts) +static sunrealtype r(sunrealtype t, const Options& opts) { - return (cos(opts->om * opts->om * t * (ONE + exp(-(t - THREE) * (t - THREE))))); + return (cos(opts.om * opts.om * t * (ONE + exp(-(t - THREE) * (t - THREE))))); } -static sunrealtype pdot(sunrealtype t, Options* opts) { return -HALF * sin(t); } +static sunrealtype pdot(sunrealtype t, const Options& opts) { return -HALF * sin(t); } -static sunrealtype qdot(sunrealtype t, Options* opts) +static sunrealtype qdot(sunrealtype t, const Options& opts) { const sunrealtype tTwo = t - TWO; const sunrealtype eterm = exp(-tTwo * tTwo); - return (-sin(opts->om * t * (ONE + eterm)) * opts->om * + return (-sin(opts.om * t * (ONE + eterm)) * opts.om * (ONE + eterm * (ONE - TWO * t * tTwo))); } -static sunrealtype rdot(sunrealtype t, Options* opts) +static sunrealtype rdot(sunrealtype t, const Options& opts) { const sunrealtype tThree = t - THREE; const sunrealtype eterm = exp(-tThree * tThree); - return (-sin(opts->om * opts->om * t * (ONE + eterm)) * opts->om * opts->om * + return (-sin(opts.om * opts.om * t * (ONE + eterm)) * opts.om * opts.om * (ONE + eterm * (ONE - TWO * t * tThree))); } -static sunrealtype utrue(sunrealtype t, Options* opts) +static sunrealtype utrue(sunrealtype t, const Options& opts) { - return (SUNRsqrt(TWO + p(t, opts))); + return (std::sqrt(TWO + p(t, opts))); } -static sunrealtype vtrue(sunrealtype t, Options* opts) +static sunrealtype vtrue(sunrealtype t, const Options& opts) { - return (SUNRsqrt(TWO + q(t, opts))); + return (std::sqrt(TWO + q(t, opts))); } -static sunrealtype wtrue(sunrealtype t, Options* opts) +static sunrealtype wtrue(sunrealtype t, const Options& opts) { - return (SUNRsqrt(TWO + r(t, opts))); + return (std::sqrt(TWO + r(t, opts))); } -static int Ytrue(sunrealtype t, N_Vector y, Options* opts) +static int Ytrue(sunrealtype t, N_Vector y, const Options& opts) { NV_Ith_S(y, 0) = utrue(t, opts); NV_Ith_S(y, 1) = vtrue(t, opts); @@ -1564,19 +1583,19 @@ int ReadInputs(std::vector& args, Options& opts, SUNContext ctx) // Check inputs for validity // 0 < rtol < 1 - if ((opts.rtol < ZERO) || (opts.rtol > ONE)) + if ((opts.rtol <= ZERO) || (opts.rtol >= ONE)) { std::cerr << "ERROR: rtol must be in (0,1), (" << opts.rtol << " input)\n"; return -1; } // 0 < atol < 1 - if ((opts.atol < ZERO) || (opts.atol > ONE)) + if ((opts.atol <= ZERO) || (opts.atol >= ONE)) { std::cerr << "ERROR: atol must be in (0,1), (" << opts.atol << " input)\n"; return -1; } // 0 < fast_rtol < 1 - if ((opts.fast_rtol < ZERO) || (opts.fast_rtol > ONE)) + if ((opts.fast_rtol <= ZERO) || (opts.fast_rtol >= ONE)) { std::cerr << "ERROR: fast_rtol must be in (0,1), (" << opts.fast_rtol << " input)\n"; @@ -1603,10 +1622,10 @@ int ReadInputs(std::vector& args, Options& opts, SUNContext ctx) << " input)\n"; return -1; } - // scontrol in [0,16] + // scontrol in [0,12] if ((opts.scontrol < 0) || (opts.scontrol > 12)) { - std::cerr << "ERROR: scontrol must be in [0,16], (" << opts.scontrol + std::cerr << "ERROR: scontrol must be in [0,12], (" << opts.scontrol << " input)\n"; return -1; } @@ -1653,174 +1672,200 @@ static void PrintSlowAdaptivity(Options opts) switch (opts.scontrol) { case (0): + { std::cout << " fixed steps, hs = " << opts.hs << ", hm = " << opts.hm << std::endl; std::cout << " rtol = " << opts.rtol << ", atol = " << opts.atol << "\n"; break; + } case (1): + { std::cout << " MRI-HTOL controller (using I for H) based on order of MRI " << ((opts.slow_pq == 1) ? "method\n" : "embedding\n"); std::cout << " rtol = " << opts.rtol << ", atol = " << opts.atol << "\n"; std::cout << " fast error accumulation strategy = " << opts.faccum << "\n"; - if (opts.k1s > -1) + if (!std::isnan(opts.k1s)) { std::cout << " slow/intermediate controller parameter: " << opts.k1s << "\n"; } - if (std::min(opts.htol_relch, std::min(opts.htol_minfac, opts.htol_maxfac)) > - -1) + if (!(std::isnan(opts.htol_relch) || std::isnan(opts.htol_minfac) || + std::isnan(opts.htol_maxfac))) { std::cout << " HTol controller parameters: " << opts.htol_relch << " " << opts.htol_minfac << " " << opts.htol_maxfac << "\n"; } break; + } case (2): + { std::cout << " MRI-HTOL controller (using PI for H) based on order of MRI " << ((opts.slow_pq == 1) ? "method\n" : "embedding\n"); std::cout << " rtol = " << opts.rtol << ", atol = " << opts.atol << "\n"; std::cout << " fast error accumulation strategy = " << opts.faccum << "\n"; - if (std::min(opts.k1s, opts.k2s) > -1) + if (!(std::isnan(opts.k1s) || std::isnan(opts.k2s))) { std::cout << " slow/intermediate controller parameters: " << opts.k1s << " " << opts.k2s << "\n"; } - if (std::min(opts.htol_relch, std::min(opts.htol_minfac, opts.htol_maxfac)) > - -1) + if (!(std::isnan(opts.htol_relch) || std::isnan(opts.htol_minfac) || + std::isnan(opts.htol_maxfac))) { std::cout << " HTol controller parameters: " << opts.htol_relch << " " << opts.htol_minfac << " " << opts.htol_maxfac << "\n"; } break; + } case (3): + { std::cout << " MRI-HTOL controller (using PID for H) based on order of MRI " << ((opts.slow_pq == 1) ? "method\n" : "embedding\n"); std::cout << " rtol = " << opts.rtol << ", atol = " << opts.atol << "\n"; std::cout << " fast error accumulation strategy = " << opts.faccum << "\n"; - if (std::min(opts.k1s, std::min(opts.k2s, opts.k3s)) > -1) + if (!(std::isnan(opts.k1s) || std::isnan(opts.k2s) || std::isnan(opts.k3s))) { std::cout << " slow/intermediate controller parameters: " << opts.k1s << " " << opts.k2s << " " << opts.k3s << "\n"; } - if (std::min(opts.htol_relch, std::min(opts.htol_minfac, opts.htol_maxfac)) > - -1) + if (!(std::isnan(opts.htol_relch) || std::isnan(opts.htol_minfac) || + std::isnan(opts.htol_maxfac))) { std::cout << " HTol controller parameters: " << opts.htol_relch << " " << opts.htol_minfac << " " << opts.htol_maxfac << "\n"; } break; + } case (4): + { std::cout << " MRI-HTOL controller (using ExpGus for H) based on order of MRI " << ((opts.slow_pq == 1) ? "method\n" : "embedding\n"); std::cout << " rtol = " << opts.rtol << ", atol = " << opts.atol << "\n"; std::cout << " fast error accumulation strategy = " << opts.faccum << "\n"; - if (std::min(opts.k1s, opts.k2s) > -1) + if (!(std::isnan(opts.k1s) || std::isnan(opts.k2s))) { std::cout << " slow/intermediate controller parameters: " << opts.k1s << " " << opts.k2s << "\n"; } - if (std::min(opts.htol_relch, std::min(opts.htol_minfac, opts.htol_maxfac)) > - -1) + if (!(std::isnan(opts.htol_relch) || std::isnan(opts.htol_minfac) || + std::isnan(opts.htol_maxfac))) { std::cout << " HTol controller parameters: " << opts.htol_relch << " " << opts.htol_minfac << " " << opts.htol_maxfac << "\n"; } break; + } case (5): + { std::cout << " MRI-HTOL controller (using ImpGus for H) based on order of MRI " << ((opts.slow_pq == 1) ? "method\n" : "embedding\n"); std::cout << " rtol = " << opts.rtol << ", atol = " << opts.atol << "\n"; std::cout << " fast error accumulation strategy = " << opts.faccum << "\n"; - if (std::min(opts.k1s, opts.k2s) > -1) + if (!(std::isnan(opts.k1s) || std::isnan(opts.k2s))) { std::cout << " slow/intermediate controller parameters: " << opts.k1s << " " << opts.k2s << "\n"; } - if (std::min(opts.htol_relch, std::min(opts.htol_minfac, opts.htol_maxfac)) > - -1) + if (!(std::isnan(opts.htol_relch) || std::isnan(opts.htol_minfac) || + std::isnan(opts.htol_maxfac))) { std::cout << " HTol controller parameters: " << opts.htol_relch << " " << opts.htol_minfac << " " << opts.htol_maxfac << "\n"; } break; + } case (6): + { std::cout << " MRI-HTOL controller (using ImExGus for H) based on order of MRI " << ((opts.slow_pq == 1) ? "method\n" : "embedding\n"); std::cout << " rtol = " << opts.rtol << ", atol = " << opts.atol << "\n"; std::cout << " fast error accumulation strategy = " << opts.faccum << "\n"; break; + } case (7): + { std::cout << " Decoupled I controller for slow time scale, based on " "order of MRI " << ((opts.slow_pq == 1) ? "method\n" : "embedding\n"); std::cout << " rtol = " << opts.rtol << ", atol = " << opts.atol << "\n"; - if (opts.k1s > -1) + if (!std::isnan(opts.k1s)) { std::cout << " slow/intermediate controller parameter: " << opts.k1s << "\n"; } break; + } case (8): + { std::cout << " Decoupled PI controller for slow time scale, based on " "order of MRI " << ((opts.slow_pq == 1) ? "method\n" : "embedding\n"); std::cout << " rtol = " << opts.rtol << ", atol = " << opts.atol << "\n"; - if (std::min(opts.k1s, opts.k2s) > -1) + if (!(std::isnan(opts.k1s) || std::isnan(opts.k2s))) { std::cout << " slow/intermediate controller parameters: " << opts.k1s << " " << opts.k2s << "\n"; } break; + } case (9): + { std::cout << " Decoupled PID controller for slow time scale, based on " "order of MRI " << ((opts.slow_pq == 1) ? "method\n" : "embedding\n"); std::cout << " rtol = " << opts.rtol << ", atol = " << opts.atol << "\n"; - if (std::min(opts.k1s, std::min(opts.k2s, opts.k3s)) > -1) + if (!(std::isnan(opts.k1s) || std::isnan(opts.k2s) || std::isnan(opts.k3s))) { std::cout << " slow/intermediate controller parameters: " << opts.k1s << " " << opts.k2s << " " << opts.k3s << "\n"; } break; + } case (10): + { std::cout << " Decoupled ExpGus controller for slow time scale, based " "on order of MRI " << ((opts.slow_pq == 1) ? "method\n" : "embedding\n"); std::cout << " rtol = " << opts.rtol << ", atol = " << opts.atol << "\n"; - if (std::min(opts.k1s, opts.k2s) > -1) + if (!(std::isnan(opts.k1s) || std::isnan(opts.k2s))) { std::cout << " slow/intermediate controller parameters: " << opts.k1s << " " << opts.k2s << "\n"; } break; + } case (11): + { std::cout << " Decoupled ImpGus controller for slow time scale, based " "on order of MRI " << ((opts.slow_pq == 1) ? "method\n" : "embedding\n"); std::cout << " rtol = " << opts.rtol << ", atol = " << opts.atol << "\n"; - if (std::min(opts.k1s, opts.k2s) > -1) + if (!(std::isnan(opts.k1s) || std::isnan(opts.k2s))) { std::cout << " slow/intermediate controller parameters: " << opts.k1s << " " << opts.k2s << "\n"; } break; + } case (12): + { std::cout << " Decoupled ImExGus controller for slow time scale, based " "on order of MRI " << ((opts.slow_pq == 1) ? "method\n" : "embedding\n"); std::cout << " rtol = " << opts.rtol << ", atol = " << opts.atol << "\n"; break; } - if (opts.bias > -1) + } + if (!std::isnan(opts.bias)) { std::cout << " controller bias factor: " << opts.bias << "\n"; } - if (opts.slow_safety > -1) + if (!std::isnan(opts.slow_safety)) { std::cout << " slow step safety factor: " << opts.slow_safety << "\n"; } @@ -1831,67 +1876,80 @@ static void PrintFastAdaptivity(Options opts) switch (opts.fcontrol) { case (0): + { std::cout << " fixed steps, hf = " << opts.hf << std::endl; std::cout << " fast_rtol = " << opts.fast_rtol << ", atol = " << opts.atol << "\n"; break; + } case (1): + { std::cout << " I controller for fast time scale, based on order of RK " << ((opts.fast_pq == 1) ? "method\n" : "embedding\n"); std::cout << " fast_rtol = " << opts.fast_rtol << ", atol = " << opts.atol << "\n"; - if (opts.k1f > -1) + if (!std::isnan(opts.k1f)) { std::cout << " fast controller parameter: " << opts.k1f << "\n"; } break; + } case (2): + { std::cout << " PI controller for fast time scale, based on order of RK " << ((opts.fast_pq == 1) ? "method\n" : "embedding\n"); std::cout << " fast_rtol = " << opts.fast_rtol << ", atol = " << opts.atol << "\n"; - if (std::min(opts.k1f, opts.k2f) > -1) + if (!(std::isnan(opts.k1f) || std::isnan(opts.k2f))) { std::cout << " fast controller parameters: " << opts.k1f << " " << opts.k2f << "\n"; } break; + } case (3): + { std::cout << " PID controller for fast time scale, based on order of RK " << ((opts.fast_pq == 1) ? "method\n" : "embedding\n"); std::cout << " fast_rtol = " << opts.fast_rtol << ", atol = " << opts.atol << "\n"; - if (std::min(opts.k1f, std::min(opts.k2f, opts.k3f)) > -1) + if (!(std::isnan(opts.k1f) || std::isnan(opts.k2f) || std::isnan(opts.k3f))) { std::cout << " fast controller parameters: " << opts.k1f << " " << opts.k2f << " " << opts.k3f << "\n"; } break; + } case (4): + { std::cout << " ExpGus controller for fast time scale, based on order of RK " << ((opts.fast_pq == 1) ? "method\n" : "embedding\n"); std::cout << " fast_rtol = " << opts.fast_rtol << ", atol = " << opts.atol << "\n"; - if (std::min(opts.k1f, opts.k2f) > -1) + if (!(std::isnan(opts.k1f) || std::isnan(opts.k2f))) { std::cout << " fast controller parameters: " << opts.k1f << " " << opts.k2f << "\n"; } break; + } case (5): + { std::cout << " ImpGus controller for fast time scale, based on order of RK " << ((opts.fast_pq == 1) ? "method\n" : "embedding\n"); std::cout << " fast_rtol = " << opts.fast_rtol << ", atol = " << opts.atol << "\n"; - if (std::min(opts.k1f, opts.k2f) > -1) + if (!(std::isnan(opts.k1f) || std::isnan(opts.k2f))) { std::cout << " fast controller parameters: " << opts.k1f << " " << opts.k2f << "\n"; } break; + } case (6): + { std::cout << " ImExGus controller for fast time scale, based on order of RK " << ((opts.fast_pq == 1) ? "method\n" : "embedding\n"); @@ -1899,6 +1957,7 @@ static void PrintFastAdaptivity(Options opts) << ", atol = " << opts.atol << "\n"; break; } + } } //---- end of file ----// diff --git a/examples/utilities/example_utilities.hpp b/examples/utilities/example_utilities.hpp index 1dd30c037c..448ac8e268 100644 --- a/examples/utilities/example_utilities.hpp +++ b/examples/utilities/example_utilities.hpp @@ -43,7 +43,7 @@ static int check_ptr(const void* ptr, const std::string funcname) inline void find_arg(std::vector& args, const std::string key, float& dest) { - auto it = std::find(args.begin(), args.end(), key); + auto it = std::find(args.cbegin(), args.cend(), key); if (it != args.end()) { dest = stof(*(it + 1)); @@ -54,7 +54,7 @@ inline void find_arg(std::vector& args, const std::string key, inline void find_arg(std::vector& args, const std::string key, double& dest) { - auto it = std::find(args.begin(), args.end(), key); + auto it = std::find(args.cbegin(), args.cend(), key); if (it != args.end()) { dest = stod(*(it + 1)); @@ -65,7 +65,7 @@ inline void find_arg(std::vector& args, const std::string key, inline void find_arg(std::vector& args, const std::string key, long double& dest) { - auto it = std::find(args.begin(), args.end(), key); + auto it = std::find(args.cbegin(), args.cend(), key); if (it != args.end()) { dest = stold(*(it + 1)); @@ -76,7 +76,7 @@ inline void find_arg(std::vector& args, const std::string key, inline void find_arg(std::vector& args, const std::string key, long long& dest) { - auto it = std::find(args.begin(), args.end(), key); + auto it = std::find(args.cbegin(), args.cend(), key); if (it != args.end()) { dest = stoll(*(it + 1)); @@ -87,7 +87,7 @@ inline void find_arg(std::vector& args, const std::string key, inline void find_arg(std::vector& args, const std::string key, long int& dest) { - auto it = std::find(args.begin(), args.end(), key); + auto it = std::find(args.cbegin(), args.cend(), key); if (it != args.end()) { dest = stol(*(it + 1)); @@ -98,7 +98,7 @@ inline void find_arg(std::vector& args, const std::string key, inline void find_arg(std::vector& args, const std::string key, int& dest) { - auto it = std::find(args.begin(), args.end(), key); + auto it = std::find(args.cbegin(), args.cend(), key); if (it != args.end()) { dest = stoi(*(it + 1)); @@ -109,7 +109,7 @@ inline void find_arg(std::vector& args, const std::string key, inline void find_arg(std::vector& args, const std::string key, bool& dest, bool store = true) { - auto it = std::find(args.begin(), args.end(), key); + auto it = std::find(args.cbegin(), args.cend(), key); if (it != args.end()) { dest = store; @@ -120,10 +120,10 @@ inline void find_arg(std::vector& args, const std::string key, inline void find_arg(std::vector& args, const std::string key, std::string& dest) { - auto it = std::find(args.begin(), args.end(), key); + auto it = std::find(args.cbegin(), args.cend(), key); if (it != args.end()) { - dest = *(it + 1); + dest = std::move(*(it + 1)); args.erase(it, it + 2); } } From d745a8fc3381612c9a2f606f0753d65e6ccbc2fb Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Fri, 27 Sep 2024 09:14:40 -0500 Subject: [PATCH 081/286] Formatting --- .../arkode/CXX_serial/ark_kpr_nestedmri.cpp | 34 +++++++++++++------ 1 file changed, 23 insertions(+), 11 deletions(-) diff --git a/examples/arkode/CXX_serial/ark_kpr_nestedmri.cpp b/examples/arkode/CXX_serial/ark_kpr_nestedmri.cpp index 55d9f5d47c..a7fc30bcea 100644 --- a/examples/arkode/CXX_serial/ark_kpr_nestedmri.cpp +++ b/examples/arkode/CXX_serial/ark_kpr_nestedmri.cpp @@ -570,7 +570,8 @@ int main(int argc, char* argv[]) if (check_ptr((void*)scontrol, "SUNAdaptController_MRIHTol")) return 1; mcontrol = SUNAdaptController_MRIHTol(sunctx, mcontrol_H, mcontrol_Tol); if (check_ptr((void*)mcontrol, "SUNAdaptController_MRIHTol")) return 1; - if (!(std::isnan(opts.htol_relch) || std::isnan(opts.htol_minfac) || std::isnan(opts.htol_maxfac))) + if (!(std::isnan(opts.htol_relch) || std::isnan(opts.htol_minfac) || + std::isnan(opts.htol_maxfac))) { retval = SUNAdaptController_SetParams_MRIHTol(scontrol, opts.htol_relch, opts.htol_minfac, @@ -863,11 +864,13 @@ int main(int argc, char* argv[]) // Create intermediate stepper MRIStepInnerStepper intermediate_stepper = nullptr; - retval = MRIStepCreateMRIStepInnerStepper(mid_arkode_mem, &intermediate_stepper); + retval = MRIStepCreateMRIStepInnerStepper(mid_arkode_mem, + &intermediate_stepper); if (check_flag(retval, "MRIStepCreateMRIStepInnerStepper")) return 1; // Create MRI (slow) integrator - void* arkode_mem = MRIStepCreate(f_se, f_si, T0, y, intermediate_stepper, sunctx); + void* arkode_mem = MRIStepCreate(f_se, f_si, T0, y, intermediate_stepper, + sunctx); if (check_ptr((void*)arkode_mem, "MRIStepCreate")) return 1; MRIStepCoupling Cs = MRIStepCoupling_LoadTableByName((opts.mri_method).c_str()); if (check_ptr((void*)Cs, "MRIStepCoupling_LoadTableByName")) return 1; @@ -977,12 +980,15 @@ int main(int argc, char* argv[]) verrtot += verr * verr; werrtot += werr * werr; errtot += uerr * uerr + verr * verr + werr * werr; - accuracy = std::max(accuracy, uerr / std::abs(opts.atol + - opts.rtol * NV_Ith_S(yref, 0))); - accuracy = std::max(accuracy, verr / std::abs(opts.atol + - opts.rtol * NV_Ith_S(yref, 1))); - accuracy = std::max(accuracy, werr / std::abs(opts.atol + - opts.rtol * NV_Ith_S(yref, 2))); + accuracy = + std::max(accuracy, + uerr / std::abs(opts.atol + opts.rtol * NV_Ith_S(yref, 0))); + accuracy = + std::max(accuracy, + verr / std::abs(opts.atol + opts.rtol * NV_Ith_S(yref, 1))); + accuracy = + std::max(accuracy, + werr / std::abs(opts.atol + opts.rtol * NV_Ith_S(yref, 2))); Nout++; // Periodically output current results to screen @@ -1435,7 +1441,10 @@ static int Jsi(sunrealtype t, N_Vector y, N_Vector fy, SUNMatrix J, // Private helper functions // ----------------------------- -static sunrealtype p(sunrealtype t, const Options& opts) { return HALF * cos(t); } +static sunrealtype p(sunrealtype t, const Options& opts) +{ + return HALF * cos(t); +} static sunrealtype q(sunrealtype t, const Options& opts) { @@ -1447,7 +1456,10 @@ static sunrealtype r(sunrealtype t, const Options& opts) return (cos(opts.om * opts.om * t * (ONE + exp(-(t - THREE) * (t - THREE))))); } -static sunrealtype pdot(sunrealtype t, const Options& opts) { return -HALF * sin(t); } +static sunrealtype pdot(sunrealtype t, const Options& opts) +{ + return -HALF * sin(t); +} static sunrealtype qdot(sunrealtype t, const Options& opts) { From 4a037169ff9511e318533e8dc83febf2914fb092 Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Fri, 27 Sep 2024 09:19:33 -0500 Subject: [PATCH 082/286] Updated answers submodule --- test/answers | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/answers b/test/answers index 21c9406c82..78be537875 160000 --- a/test/answers +++ b/test/answers @@ -1 +1 @@ -Subproject commit 21c9406c82f2388c974678b68197dca42799266a +Subproject commit 78be537875aa4ac9e228ebcb0f4d2d2720d9e7ab From cc4073c6efd5e0d39136c880d82f6d8fa9e504be Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Fri, 27 Sep 2024 09:53:51 -0500 Subject: [PATCH 083/286] Updated answers submodule --- test/answers | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/answers b/test/answers index 78be537875..6d4a36a008 160000 --- a/test/answers +++ b/test/answers @@ -1 +1 @@ -Subproject commit 78be537875aa4ac9e228ebcb0f4d2d2720d9e7ab +Subproject commit 6d4a36a008df0593c48b2a3facb574ace1a43855 From 7646b29ff9879a3659d9c17cee59ed04173e28e6 Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Fri, 27 Sep 2024 10:23:34 -0500 Subject: [PATCH 084/286] Converted accumulated error options to an enumerated type --- .../guide/source/Usage/User_callable.rst | 63 ++++++++++++------- .../arkode/CXX_serial/ark_kpr_nestedmri.cpp | 11 +++- include/arkode/arkode.h | 14 ++++- src/arkode/arkode.c | 11 ++-- src/arkode/arkode_impl.h | 3 +- src/arkode/arkode_io.c | 18 +++--- src/arkode/fmod_int32/farkode_mod.c | 4 +- src/arkode/fmod_int32/farkode_mod.f90 | 11 +++- src/arkode/fmod_int64/farkode_mod.c | 4 +- src/arkode/fmod_int64/farkode_mod.f90 | 11 +++- .../ark_test_accumerror_brusselator.cpp | 6 +- .../CXX_serial/ark_test_accumerror_kpr.cpp | 8 +-- .../ark_test_brusselator_mriadapt.cpp | 9 ++- .../CXX_serial/ark_test_kpr_mriadapt.cpp | 9 ++- .../ark_test_slowerror_brusselator.cpp | 2 +- .../CXX_serial/ark_test_slowerror_kpr.cpp | 2 +- .../ark_test_slowerror_polynomial.cpp | 2 +- 17 files changed, 124 insertions(+), 64 deletions(-) diff --git a/doc/arkode/guide/source/Usage/User_callable.rst b/doc/arkode/guide/source/Usage/User_callable.rst index cc335a58c4..f77e61f75b 100644 --- a/doc/arkode/guide/source/Usage/User_callable.rst +++ b/doc/arkode/guide/source/Usage/User_callable.rst @@ -1751,18 +1751,46 @@ Reset accumulated error :c:func:`ARKodeReset .. versionadded:: 6.1.0 -.. c:function:: int ARKodeSetAccumulatedErrorType(void* arkode_mem, int accum_type) +The two following routines are used to control algorithms that ARKODE can use to estimate +the accumulated temporal error over multiple time steps. For time-stepping modules that +compute both a solution and embedding, :math:`y_n` and :math:`\tilde{y}_n`, these may be +combined to create a vector-valued local temporal error estimate for the current internal +step, :math:`y_n - \tilde{y}_n`. These local errors may be accumulated by ARKODE in a +variety of ways, as determined by the enumerated type :c:enum:`ARK_ACCUMERROR`. In each +of the cases below, the accumulation is taken over all steps :math:`n\in N` since the most +recent call to either :c:func:`ARKodeSetAccumulatedErrorType` or +:c:func:`ARKodeResetAccumulatedError`. The norm is taken using the tolerance-informed +error-weight vector (see :c:func:`ARKodeGetErrWeights`), and ``reltol`` is the +user-specified relative solution tolerance. + +.. c:enum:: ARKAccumError + + The type of error accumulation that ARKODE should use. + +.. c:enumerator:: ARK_ACCUMERROR_NONE + + No accumulation should be performed + +.. c:enumerator:: ARK_ACCUMERROR_MAX + + Computes :math:`\text{reltol} \max_{n\in N} \|y_n - \tilde{y}_n\|_{WRMS}` + +.. c:enumerator:: ARK_ACCUMERROR_SUM + + Computes :math:`\text{reltol} \sum_{n\in N} \|y_n - \tilde{y}_n\|_{WRMS}` + +.. c:enumerator:: ARK_ACCUMERROR_AVG + + Computes :math:`\frac{\text{reltol}}{N} \sum_{n\in N} \|y_n - \tilde{y}_n\|_{WRMS}`. + + +.. c:function:: int ARKodeSetAccumulatedErrorType(void* arkode_mem, ARKAccumError accum_type) Sets the strategy to use for accumulating a temporal error estimate over multiple time steps. :param arkode_mem: pointer to the ARKODE memory block. - :param accum_type: accumulation strategy: - - * ``-1`` -- no accumulation (default). - * ``0`` -- maximum accumulation. - * ``1`` -- additive accumulation. - + :param accum_type: accumulation strategy. :retval ARK_SUCCESS: the function exited successfully. :retval ARK_MEM_NULL: ``arkode_mem`` was ``NULL`` :retval ARK_STEPPER_UNSUPPORTED: temporal error estimation is not supported @@ -1770,24 +1798,11 @@ Reset accumulated error :c:func:`ARKodeReset .. note:: - Multiple of ARKODE's time-stepping modules compute both a solution and embedding, - :math:`y_n` and :math:`\tilde{y}_n`, that may be combined to create a vector-valued - local temporal error estimate, :math:`y_n - \tilde{y}_n`. By default, ARKODE will - not accumulate these local error estimates, but accumulation can be triggered by - calling this function with one of two options: - - * ``0`` computes :math:`\text{reltol} \max_{n\in N} \|y_n - \tilde{y}_n\|_{WRMS}` - - * ``1`` computes :math:`\frac{\text{reltol}}{N} \sum_{n\in N} \|y_n - \tilde{y}_n\|_{WRMS}`, - - In both cases, the sum or maximum is taken over all steps :math:`n\in N` since the most - recent call to either :c:func:`ARKodeSetAccumulatedErrorType` or - :c:func:`ARKodeResetAccumulatedError`. The norm is taken using the tolerance-informed - error-weight vector (see :c:func:`ARKodeGetErrWeights`), and ``reltol`` is the - user-specified relative solution tolerance. + By default, ARKODE will not accumulate any local error estimates (i.e., + the default *accum_type` is ``ARK_ACCUMERROR_NONE``). - Error accumulation can be disabled by calling :c:func:`ARKodeSetAccumulatedErrorType` - with the argument ``-1``. + A non-default error accumulation strategy can be disabled by calling + :c:func:`ARKodeSetAccumulatedErrorType` with the argument ``ARK_ACCUMERROR_NONE``. .. versionadded:: x.y.z diff --git a/examples/arkode/CXX_serial/ark_kpr_nestedmri.cpp b/examples/arkode/CXX_serial/ark_kpr_nestedmri.cpp index a7fc30bcea..7e520eb497 100644 --- a/examples/arkode/CXX_serial/ark_kpr_nestedmri.cpp +++ b/examples/arkode/CXX_serial/ark_kpr_nestedmri.cpp @@ -110,6 +110,7 @@ * -1: no accumulation * 0: maximum accumulation * 1: additive accumulation + * 2: average accumulation * - controller parameters: (k1s, k2s, k3s, k1f, k2f, k3f, * bias, htol_relch, htol_minfac, htol_maxfac) * slow and intermediate single-rate controllers: use k1s through k3s, @@ -433,7 +434,11 @@ int main(int argc, char* argv[]) retval = ARKodeSetFixedStep(inner_arkode_mem, opts.hf); if (check_flag(retval, "ARKodeSetFixedStep")) return 1; } - retval = ARKodeSetAccumulatedErrorType(inner_arkode_mem, opts.faccum); + ARKAccumError acc_type = ARK_ACCUMERROR_NONE; + if (opts.faccum == 0) { acc_type = ARK_ACCUMERROR_MAX; } + if (opts.faccum == 1) { acc_type = ARK_ACCUMERROR_SUM; } + if (opts.faccum == 2) { acc_type = ARK_ACCUMERROR_AVG; } + retval = ARKodeSetAccumulatedErrorType(inner_arkode_mem, acc_type); if (check_flag(retval, "ARKodeSetAccumulatedErrorType")) return 1; retval = ARKodeSetMaxNumSteps(inner_arkode_mem, 1000000); if (check_flag(retval, "ARKodeSetMaxNumSteps")) return 1; @@ -832,7 +837,7 @@ int main(int argc, char* argv[]) if (check_flag(retval, "ARKodeSStolerances")) return 1; retval = ARKodeSetMaxNumSteps(mid_arkode_mem, 100000); if (check_flag(retval, "ARKodeSetMaxNumSteps")) return 1; - retval = ARKodeSetAccumulatedErrorType(mid_arkode_mem, opts.faccum); + retval = ARKodeSetAccumulatedErrorType(mid_arkode_mem, acc_type); if (check_flag(retval, "ARKodeSetAccumulatedErrorType")) return 1; retval = ARKodeSetUserData(mid_arkode_mem, (void*)&opts); if (check_flag(retval, "ARKodeSetUserData")) return 1; @@ -1535,7 +1540,7 @@ void InputHelp() "(see source)\n"; std::cout << " --fcontrol : fast time step controller, int in [0,6] " "(see source)\n"; - std::cout << " --faccum : fast error accumulation type {-1,0,1}\n"; + std::cout << " --faccum : fast error accumulation type {-1,0,1,2}\n"; std::cout << " --slow_pq : use p (0) vs q (1) for slow/intermediate " "adaptivity\n"; std::cout << " --fast_pq : use p (0) vs q (1) for fast adaptivity\n"; diff --git a/include/arkode/arkode.h b/include/arkode/arkode.h index 5a7fb8485b..c9a154a8ed 100644 --- a/include/arkode/arkode.h +++ b/include/arkode/arkode.h @@ -190,6 +190,18 @@ typedef enum ARK_RELAX_NEWTON } ARKRelaxSolver; +/* -------------------------- + * Error Accumulation Options + * -------------------------- */ + +typedef enum +{ + ARK_ACCUMERROR_NONE, + ARK_ACCUMERROR_MAX, + ARK_ACCUMERROR_SUM, + ARK_ACCUMERROR_AVG +} ARKAccumError; + /* -------------------------- * Shared API routines * -------------------------- */ @@ -281,7 +293,7 @@ SUNDIALS_EXPORT int ARKodeSetMinStep(void* arkode_mem, sunrealtype hmin); SUNDIALS_EXPORT int ARKodeSetMaxStep(void* arkode_mem, sunrealtype hmax); SUNDIALS_EXPORT int ARKodeSetMaxNumConstrFails(void* arkode_mem, int maxfails); SUNDIALS_EXPORT int ARKodeSetAccumulatedErrorType(void* arkode_mem, - int accum_type); + ARKAccumError accum_type); SUNDIALS_EXPORT int ARKodeResetAccumulatedError(void* arkode_mem); /* Integrate the ODE over an interval in t */ diff --git a/src/arkode/arkode.c b/src/arkode/arkode.c index 165b5f5abe..52e92d5f2d 100644 --- a/src/arkode/arkode.c +++ b/src/arkode/arkode.c @@ -1511,7 +1511,7 @@ ARKodeMem arkCreate(SUNContext sunctx) ark_mem->h0u = ZERO; /* Accumulated error estimation strategy */ - ark_mem->AccumErrorType = -1; + ark_mem->AccumErrorType = ARK_ACCUMERROR_NONE; ark_mem->AccumError = ZERO; /* Set default values for integrator and stepper optional inputs */ @@ -2523,11 +2523,14 @@ int arkCompleteStep(ARKodeMem ark_mem, sunrealtype dsm) #endif /* store this step's contribution to accumulated temporal error */ - if (ark_mem->AccumErrorType == 0) + if (ark_mem->AccumErrorType != ARK_ACCUMERROR_NONE) { - ark_mem->AccumError = SUNMAX(dsm, ark_mem->AccumError); + if (ark_mem->AccumErrorType == ARK_ACCUMERROR_MAX) + { + ark_mem->AccumError = SUNMAX(dsm, ark_mem->AccumError); + } + else { ark_mem->AccumError += dsm; } } - else if (ark_mem->AccumErrorType == 1) { ark_mem->AccumError += dsm; } /* apply user-supplied step postprocessing function (if supplied) */ if (ark_mem->ProcessStep != NULL) diff --git a/src/arkode/arkode_impl.h b/src/arkode/arkode_impl.h index 8a440dc2b0..3674a9d428 100644 --- a/src/arkode/arkode_impl.h +++ b/src/arkode/arkode_impl.h @@ -525,8 +525,7 @@ struct ARKodeMemRec sunrealtype terr; /* error in tn for compensated sums */ sunrealtype hold; /* last successful h value used */ sunrealtype tolsf; /* tolerance scale factor (suggestion to user) */ - int AccumErrorType; /* accumulated error estimation type: - none (-1), scalar-max (0), scalar-sum (1) */ + ARKAccumError AccumErrorType; /* accumulated error estimation type */ long int AccumErrorStep; /* time step of last accumulated error reset */ sunrealtype AccumError; /* accumulated error estimate */ sunbooleantype VabstolMallocDone; diff --git a/src/arkode/arkode_io.c b/src/arkode/arkode_io.c index 929d485c3c..5554096bdf 100644 --- a/src/arkode/arkode_io.c +++ b/src/arkode/arkode_io.c @@ -1999,12 +1999,9 @@ int ARKodeSetMaxConvFails(void* arkode_mem, int maxncf) ARKodeSetAccumulatedErrorType: This routine sets the accumulated temporal error estimation - strategy: - 0 => scalar 'max' accumulation - 1 => scalar 'mean' accumulation - -1 => no accumulation + strategy. ---------------------------------------------------------------*/ -int ARKodeSetAccumulatedErrorType(void* arkode_mem, int accum_type) +int ARKodeSetAccumulatedErrorType(void* arkode_mem, ARKAccumError accum_type) { ARKodeMem ark_mem; if (arkode_mem == NULL) @@ -2023,9 +2020,6 @@ int ARKodeSetAccumulatedErrorType(void* arkode_mem, int accum_type) return (ARK_STEPPER_UNSUPPORTED); } - /* Check for valid accumulation type (set to none on illegal input) */ - if ((accum_type < 0) || (accum_type > 1)) { accum_type = -1; } - /* Store type, reset accumulated error value and counter, and return */ ark_mem->AccumErrorType = accum_type; ark_mem->AccumErrorStep = ark_mem->nst; @@ -2484,11 +2478,15 @@ int ARKodeGetAccumulatedError(void* arkode_mem, sunrealtype* accum_error) long int steps = SUNMAX(1, ark_mem->nst - ark_mem->AccumErrorStep); /* Fill output based on error accumulation type */ - if (ark_mem->AccumErrorType == 0) + if (ark_mem->AccumErrorType == ARK_ACCUMERROR_MAX) + { + *accum_error = ark_mem->AccumError * ark_mem->reltol; + } + else if (ark_mem->AccumErrorType == ARK_ACCUMERROR_SUM) { *accum_error = ark_mem->AccumError * ark_mem->reltol; } - else if (ark_mem->AccumErrorType == 1) + else if (ark_mem->AccumErrorType == ARK_ACCUMERROR_AVG) { *accum_error = ark_mem->AccumError * ark_mem->reltol / ((sunrealtype)steps); } diff --git a/src/arkode/fmod_int32/farkode_mod.c b/src/arkode/fmod_int32/farkode_mod.c index e4c0129c22..911e666192 100644 --- a/src/arkode/fmod_int32/farkode_mod.c +++ b/src/arkode/fmod_int32/farkode_mod.c @@ -1142,11 +1142,11 @@ SWIGEXPORT int _wrap_FARKodeSetMaxNumConstrFails(void *farg1, int const *farg2) SWIGEXPORT int _wrap_FARKodeSetAccumulatedErrorType(void *farg1, int const *farg2) { int fresult ; void *arg1 = (void *) 0 ; - int arg2 ; + ARKAccumError arg2 ; int result; arg1 = (void *)(farg1); - arg2 = (int)(*farg2); + arg2 = (ARKAccumError)(*farg2); result = (int)ARKodeSetAccumulatedErrorType(arg1,arg2); fresult = (int)(result); return fresult; diff --git a/src/arkode/fmod_int32/farkode_mod.f90 b/src/arkode/fmod_int32/farkode_mod.f90 index 8fa06ea70e..e2645bed83 100644 --- a/src/arkode/fmod_int32/farkode_mod.f90 +++ b/src/arkode/fmod_int32/farkode_mod.f90 @@ -102,6 +102,15 @@ module farkode_mod end enum integer, parameter, public :: ARKRelaxSolver = kind(ARK_RELAX_BRENT) public :: ARK_RELAX_BRENT, ARK_RELAX_NEWTON + ! typedef enum ARKAccumError + enum, bind(c) + enumerator :: ARK_ACCUMERROR_NONE + enumerator :: ARK_ACCUMERROR_MAX + enumerator :: ARK_ACCUMERROR_SUM + enumerator :: ARK_ACCUMERROR_AVG + end enum + integer, parameter, public :: ARKAccumError = kind(ARK_ACCUMERROR_NONE) + public :: ARK_ACCUMERROR_NONE, ARK_ACCUMERROR_MAX, ARK_ACCUMERROR_SUM, ARK_ACCUMERROR_AVG public :: FARKodeResize public :: FARKodeReset public :: FARKodeSStolerances @@ -3349,7 +3358,7 @@ function FARKodeSetAccumulatedErrorType(arkode_mem, accum_type) & use, intrinsic :: ISO_C_BINDING integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem -integer(C_INT), intent(in) :: accum_type +integer(ARKAccumError), intent(in) :: accum_type integer(C_INT) :: fresult type(C_PTR) :: farg1 integer(C_INT) :: farg2 diff --git a/src/arkode/fmod_int64/farkode_mod.c b/src/arkode/fmod_int64/farkode_mod.c index 49be036eb3..f993cbe05a 100644 --- a/src/arkode/fmod_int64/farkode_mod.c +++ b/src/arkode/fmod_int64/farkode_mod.c @@ -1142,11 +1142,11 @@ SWIGEXPORT int _wrap_FARKodeSetMaxNumConstrFails(void *farg1, int const *farg2) SWIGEXPORT int _wrap_FARKodeSetAccumulatedErrorType(void *farg1, int const *farg2) { int fresult ; void *arg1 = (void *) 0 ; - int arg2 ; + ARKAccumError arg2 ; int result; arg1 = (void *)(farg1); - arg2 = (int)(*farg2); + arg2 = (ARKAccumError)(*farg2); result = (int)ARKodeSetAccumulatedErrorType(arg1,arg2); fresult = (int)(result); return fresult; diff --git a/src/arkode/fmod_int64/farkode_mod.f90 b/src/arkode/fmod_int64/farkode_mod.f90 index 2148977b2c..92ca85969d 100644 --- a/src/arkode/fmod_int64/farkode_mod.f90 +++ b/src/arkode/fmod_int64/farkode_mod.f90 @@ -102,6 +102,15 @@ module farkode_mod end enum integer, parameter, public :: ARKRelaxSolver = kind(ARK_RELAX_BRENT) public :: ARK_RELAX_BRENT, ARK_RELAX_NEWTON + ! typedef enum ARKAccumError + enum, bind(c) + enumerator :: ARK_ACCUMERROR_NONE + enumerator :: ARK_ACCUMERROR_MAX + enumerator :: ARK_ACCUMERROR_SUM + enumerator :: ARK_ACCUMERROR_AVG + end enum + integer, parameter, public :: ARKAccumError = kind(ARK_ACCUMERROR_NONE) + public :: ARK_ACCUMERROR_NONE, ARK_ACCUMERROR_MAX, ARK_ACCUMERROR_SUM, ARK_ACCUMERROR_AVG public :: FARKodeResize public :: FARKodeReset public :: FARKodeSStolerances @@ -3349,7 +3358,7 @@ function FARKodeSetAccumulatedErrorType(arkode_mem, accum_type) & use, intrinsic :: ISO_C_BINDING integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem -integer(C_INT), intent(in) :: accum_type +integer(ARKAccumError), intent(in) :: accum_type integer(C_INT) :: fresult type(C_PTR) :: farg1 integer(C_INT) :: farg2 diff --git a/test/unit_tests/arkode/CXX_serial/ark_test_accumerror_brusselator.cpp b/test/unit_tests/arkode/CXX_serial/ark_test_accumerror_brusselator.cpp index 46b1d88a32..cb955d44e9 100644 --- a/test/unit_tests/arkode/CXX_serial/ark_test_accumerror_brusselator.cpp +++ b/test/unit_tests/arkode/CXX_serial/ark_test_accumerror_brusselator.cpp @@ -405,7 +405,7 @@ static int adaptive_run(void* arkode_mem, N_Vector y, sunrealtype T0, sunrealtype abstol = SUN_RCONST(1.e-12); vector rtols = {SUN_RCONST(1.e-2), SUN_RCONST(1.e-4), SUN_RCONST(1.e-6)}; - vector accum_types = {0, 1}; + vector accum_types = {ARK_ACCUMERROR_MAX, ARK_ACCUMERROR_AVG}; vector dsm(udata.Npart); vector dsm_est(udata.Npart); vector Nsteps(udata.Npart); @@ -492,7 +492,7 @@ static int fixed_run(void* arkode_mem, N_Vector y, sunrealtype T0, sunrealtype T sunrealtype hmax = (Tf - T0) / 400; if (rk_type == 1) hmax = min(hmax, udata.ep); vector hvals = {hmax, hmax / 4, hmax / 16, hmax / 64}; - vector accum_types = {0, 1}; + vector accum_types = {ARK_ACCUMERROR_MAX, ARK_ACCUMERROR_AVG}; vector dsm(udata.Npart); vector dsm_est(udata.Npart); vector Nsteps(udata.Npart); @@ -581,7 +581,7 @@ static int fixed_run(void* arkode_mem, N_Vector y, sunrealtype T0, sunrealtype T retval = ARKStepReInit(arkode_mem, fn, NULL, t, y); } if (check_retval(&retval, "ARKStepReInit", 1)) return 1; - retval = ARKodeSetAccumulatedErrorType(arkode_mem, -1); + retval = ARKodeSetAccumulatedErrorType(arkode_mem, ARK_ACCUMERROR_NONE); if (check_retval(&retval, "ARKodeSetAccumulatedErrorType", 1)) return 1; retval = ARKodeSetFixedStep(arkode_mem, hvals[ih]); if (check_retval(&retval, "ARKodeSetFixedStep", 1)) return 1; diff --git a/test/unit_tests/arkode/CXX_serial/ark_test_accumerror_kpr.cpp b/test/unit_tests/arkode/CXX_serial/ark_test_accumerror_kpr.cpp index d402ef06c3..6bf85e004f 100644 --- a/test/unit_tests/arkode/CXX_serial/ark_test_accumerror_kpr.cpp +++ b/test/unit_tests/arkode/CXX_serial/ark_test_accumerror_kpr.cpp @@ -350,7 +350,7 @@ static int adaptive_run(void* arkode_mem, N_Vector y, sunrealtype T0, sunrealtype abstol = SUN_RCONST(1.e-12); vector rtols = {SUN_RCONST(1.e-2), SUN_RCONST(1.e-4), SUN_RCONST(1.e-6)}; - vector accum_types = {0, 1}; + vector accum_types = {ARK_ACCUMERROR_MAX, ARK_ACCUMERROR_AVG}; vector dsm(udata.Npart); vector dsm_est(udata.Npart); vector Nsteps(udata.Npart); @@ -449,7 +449,7 @@ static int fixed_run(void* arkode_mem, N_Vector y, sunrealtype T0, sunrealtype hmax = (Tf - T0) / 1000; if (rk_type == 1) hmax = min(hmax, ONE / abs(udata.G)); vector hvals = {hmax, hmax / 4, hmax / 16, hmax / 64}; - vector accum_types = {0, 1}; + vector accum_types = {ARK_ACCUMERROR_MAX, ARK_ACCUMERROR_AVG}; vector dsm(udata.Npart); vector dsm_est(udata.Npart); vector Nsteps(udata.Npart); @@ -551,7 +551,7 @@ static int fixed_run(void* arkode_mem, N_Vector y, sunrealtype T0, { // DIRK retval = ARKStepReInit(arkode_mem, NULL, fn, t, y); if (check_retval(&retval, "ARKStepReInit", 1)) return 1; - retval = ARKodeSetAccumulatedErrorType(arkode_mem, -1); + retval = ARKodeSetAccumulatedErrorType(arkode_mem, ARK_ACCUMERROR_NONE); if (check_retval(&retval, "ARKodeSetAccumulatedErrorType", 1)) return 1; retval = ARKodeSetFixedStep(arkode_mem, hvals[ih]); if (check_retval(&retval, "ARKodeSetFixedStep", 1)) return 1; @@ -587,7 +587,7 @@ static int fixed_run(void* arkode_mem, N_Vector y, sunrealtype T0, { // ERK retval = ERKStepReInit(arkode_mem, fn, t, y); if (check_retval(&retval, "ERKStepReInit", 1)) return 1; - retval = ARKodeSetAccumulatedErrorType(arkode_mem, -1); + retval = ARKodeSetAccumulatedErrorType(arkode_mem, ARK_ACCUMERROR_NONE); if (check_retval(&retval, "ARKodeSetAccumulatedErrorType", 1)) return 1; retval = ARKodeSetFixedStep(arkode_mem, hvals[ih]); if (check_retval(&retval, "ARKodeSetFixedStep", 1)) return 1; diff --git a/test/unit_tests/arkode/CXX_serial/ark_test_brusselator_mriadapt.cpp b/test/unit_tests/arkode/CXX_serial/ark_test_brusselator_mriadapt.cpp index 55566c482e..1343e3320e 100644 --- a/test/unit_tests/arkode/CXX_serial/ark_test_brusselator_mriadapt.cpp +++ b/test/unit_tests/arkode/CXX_serial/ark_test_brusselator_mriadapt.cpp @@ -85,6 +85,7 @@ * -1: no accumulation * 0: maximum accumulation * 1: additive accumulation + * 2: average accumulation * - controller parameters: (k1s, k2s, k3s, k1f, k2f, k3f, * bias, htol_relch, htol_minfac, htol_maxfac) * slow single-rate controllers: use k1s through k3s, as appropriate. @@ -367,7 +368,11 @@ int main(int argc, char* argv[]) retval = ARKodeSetFixedStep(inner_arkode_mem, opts.hf); if (check_flag(retval, "ARKodeSetFixedStep")) return 1; } - retval = ARKodeSetAccumulatedErrorType(inner_arkode_mem, opts.faccum); + ARKAccumError acc_type = ARK_ACCUMERROR_NONE; + if (opts.faccum == 0) { acc_type = ARK_ACCUMERROR_MAX; } + if (opts.faccum == 1) { acc_type = ARK_ACCUMERROR_SUM; } + if (opts.faccum == 2) { acc_type = ARK_ACCUMERROR_AVG; } + retval = ARKodeSetAccumulatedErrorType(inner_arkode_mem, acc_type); if (check_flag(retval, "ARKodeSetAccumulatedErrorType")) return 1; retval = ARKodeSetMaxNumSteps(inner_arkode_mem, 1000000); if (check_flag(retval, "ARKodeSetMaxNumSteps")) return 1; @@ -991,7 +996,7 @@ void InputHelp() "(see source)\n"; std::cout << " --fcontrol : fast time step controller, int in [0,6] " "(see source)\n"; - std::cout << " --faccum : fast error accumulation type {-1,0,1}\n"; + std::cout << " --faccum : fast error accumulation type {-1,0,1,2}\n"; std::cout << " --slow_pq : use p (0) vs q (1) for slow adaptivity\n"; std::cout << " --fast_pq : use p (0) vs q (1) for fast adaptivity\n"; std::cout << " --k1s, --k2s, ..., -k6s : slow controller parameters\n"; diff --git a/test/unit_tests/arkode/CXX_serial/ark_test_kpr_mriadapt.cpp b/test/unit_tests/arkode/CXX_serial/ark_test_kpr_mriadapt.cpp index 3eac5f312c..2cf3d3783a 100644 --- a/test/unit_tests/arkode/CXX_serial/ark_test_kpr_mriadapt.cpp +++ b/test/unit_tests/arkode/CXX_serial/ark_test_kpr_mriadapt.cpp @@ -83,6 +83,7 @@ * -1: no accumulation * 0: maximum accumulation * 1: additive accumulation + * 2: average accumulation * - controller parameters: (k1s, k2s, k3s, k1f, k2f, k3f, * bias, htol_relch, htol_minfac, htol_maxfac) * slow single-rate controllers: use k1s through k3s, as appropriate. @@ -377,7 +378,11 @@ int main(int argc, char* argv[]) retval = ARKodeSetFixedStep(inner_arkode_mem, opts.hf); if (check_flag(retval, "ARKodeSetFixedStep")) return 1; } - retval = ARKodeSetAccumulatedErrorType(inner_arkode_mem, opts.faccum); + ARKAccumError acc_type = ARK_ACCUMERROR_NONE; + if (opts.faccum == 0) { acc_type = ARK_ACCUMERROR_MAX; } + if (opts.faccum == 1) { acc_type = ARK_ACCUMERROR_SUM; } + if (opts.faccum == 2) { acc_type = ARK_ACCUMERROR_AVG; } + retval = ARKodeSetAccumulatedErrorType(inner_arkode_mem, acc_type); if (check_flag(retval, "ARKodeSetAccumulatedErrorType")) return 1; retval = ARKodeSetMaxNumSteps(inner_arkode_mem, 1000000); if (check_flag(retval, "ARKodeSetMaxNumSteps")) return 1; @@ -1034,7 +1039,7 @@ void InputHelp() "(see source)\n"; std::cout << " --fcontrol : fast time step controller, int in [0,6] " "(see source)\n"; - std::cout << " --faccum : fast error accumulation type {-1,0,1}\n"; + std::cout << " --faccum : fast error accumulation type {-1,0,1,2}\n"; std::cout << " --slow_pq : use p (0) vs q (1) for slow adaptivity\n"; std::cout << " --fast_pq : use p (0) vs q (1) for fast adaptivity\n"; std::cout << " --k1s, --k2s, ..., -k6s : slow controller parameters\n"; diff --git a/test/unit_tests/arkode/CXX_serial/ark_test_slowerror_brusselator.cpp b/test/unit_tests/arkode/CXX_serial/ark_test_slowerror_brusselator.cpp index 2d6f5f077b..e926be3d80 100644 --- a/test/unit_tests/arkode/CXX_serial/ark_test_slowerror_brusselator.cpp +++ b/test/unit_tests/arkode/CXX_serial/ark_test_slowerror_brusselator.cpp @@ -334,7 +334,7 @@ int main(int argc, char* argv[]) if (check_retval(&retval, "ARKodeSStolerances", 1)) return 1; retval = ARKodeSetUserData(mristep_mem, (void*)&udata); if (check_retval(&retval, "ARKodeSetUserData", 1)) return 1; - retval = ARKodeSetAccumulatedErrorType(mristep_mem, 0); + retval = ARKodeSetAccumulatedErrorType(mristep_mem, ARK_ACCUMERROR_MAX); if (check_retval(&retval, "ARKodeSetAccumulatedErrorType", 1)) return 1; // Run test for various H values diff --git a/test/unit_tests/arkode/CXX_serial/ark_test_slowerror_kpr.cpp b/test/unit_tests/arkode/CXX_serial/ark_test_slowerror_kpr.cpp index 9711f652da..820e299be1 100644 --- a/test/unit_tests/arkode/CXX_serial/ark_test_slowerror_kpr.cpp +++ b/test/unit_tests/arkode/CXX_serial/ark_test_slowerror_kpr.cpp @@ -271,7 +271,7 @@ int main(int argc, char* argv[]) if (check_retval(&retval, "ARKodeSStolerances", 1)) return 1; retval = ARKodeSetUserData(mristep_mem, (void*)&udata); if (check_retval(&retval, "ARKodeSetUserData", 1)) return 1; - retval = ARKodeSetAccumulatedErrorType(mristep_mem, 0); + retval = ARKodeSetAccumulatedErrorType(mristep_mem, ARK_ACCUMERROR_MAX); if (check_retval(&retval, "ARKodeSetAccumulatedErrorType", 1)) return 1; // Run test for various H values diff --git a/test/unit_tests/arkode/CXX_serial/ark_test_slowerror_polynomial.cpp b/test/unit_tests/arkode/CXX_serial/ark_test_slowerror_polynomial.cpp index 53c1e0eb43..29adfd5093 100644 --- a/test/unit_tests/arkode/CXX_serial/ark_test_slowerror_polynomial.cpp +++ b/test/unit_tests/arkode/CXX_serial/ark_test_slowerror_polynomial.cpp @@ -203,7 +203,7 @@ int main(int argc, char* argv[]) if (check_retval(&retval, "ARKodeSStolerances", 1)) return 1; retval = ARKodeSetUserData(mristep_mem, (void*)&udata); if (check_retval(&retval, "ARKodeSetUserData", 1)) return 1; - retval = ARKodeSetAccumulatedErrorType(mristep_mem, 0); + retval = ARKodeSetAccumulatedErrorType(mristep_mem, ARK_ACCUMERROR_MAX); if (check_retval(&retval, "ARKodeSetAccumulatedErrorType", 1)) return 1; // Run test for various H values From a036591673dc485ab369247f2e0be1119933494b Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Fri, 27 Sep 2024 10:26:02 -0500 Subject: [PATCH 085/286] Reverted some examples back to run on single-precision CI jobs --- examples/arkode/C_serial/CMakeLists.txt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/examples/arkode/C_serial/CMakeLists.txt b/examples/arkode/C_serial/CMakeLists.txt index 58e1421b92..f5b236bf65 100644 --- a/examples/arkode/C_serial/CMakeLists.txt +++ b/examples/arkode/C_serial/CMakeLists.txt @@ -25,7 +25,7 @@ set(ARKODE_examples # develop tests "ark_analytic_mels\;\;develop" "ark_analytic_nonlin\;\;develop" - "ark_brusselator_1D_mri\;\;exclude-single" + "ark_brusselator_1D_mri\;\;develop" "ark_brusselator_fp\;\;exclude-single" "ark_brusselator_mri\;\;develop" "ark_brusselator\;\;develop" @@ -77,12 +77,12 @@ set(ARKODE_examples "ark_KrylovDemo_prec\;\;exclude-single" "ark_KrylovDemo_prec\;1\;exclude-single" "ark_KrylovDemo_prec\;2\;exclude-single" - "ark_onewaycouple_mri\;\;exclude-single" + "ark_onewaycouple_mri\;\;develop" "ark_reaction_diffusion_mri\;\;develop" "ark_robertson_constraints\;\;exclude-single" "ark_robertson_root\;\;exclude-single" "ark_robertson\;\;exclude-single" - "ark_twowaycouple_mri\;\;exclude-single") + "ark_twowaycouple_mri\;\;develop") if(SUNDIALS_BUILD_WITH_MONITORING) list(APPEND ARKODE_examples "ark_brusselator_fp\;1\;exclude-single") From a70c4ee364cc893dca6741aabf39538388e2431d Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Fri, 27 Sep 2024 10:28:08 -0500 Subject: [PATCH 086/286] formatting --- src/arkode/arkode_impl.h | 10 +++++----- .../CXX_serial/ark_test_accumerror_brusselator.cpp | 10 +++++----- .../arkode/CXX_serial/ark_test_accumerror_kpr.cpp | 10 +++++----- 3 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/arkode/arkode_impl.h b/src/arkode/arkode_impl.h index 3674a9d428..37b4981243 100644 --- a/src/arkode/arkode_impl.h +++ b/src/arkode/arkode_impl.h @@ -520,11 +520,11 @@ struct ARKodeMemRec long int liw; /* no. of integer words in ARKODE work vectors */ /* Saved Values */ - sunrealtype h0u; /* actual initial stepsize */ - sunrealtype tn; /* time of last successful step */ - sunrealtype terr; /* error in tn for compensated sums */ - sunrealtype hold; /* last successful h value used */ - sunrealtype tolsf; /* tolerance scale factor (suggestion to user) */ + sunrealtype h0u; /* actual initial stepsize */ + sunrealtype tn; /* time of last successful step */ + sunrealtype terr; /* error in tn for compensated sums */ + sunrealtype hold; /* last successful h value used */ + sunrealtype tolsf; /* tolerance scale factor (suggestion to user) */ ARKAccumError AccumErrorType; /* accumulated error estimation type */ long int AccumErrorStep; /* time step of last accumulated error reset */ sunrealtype AccumError; /* accumulated error estimate */ diff --git a/test/unit_tests/arkode/CXX_serial/ark_test_accumerror_brusselator.cpp b/test/unit_tests/arkode/CXX_serial/ark_test_accumerror_brusselator.cpp index cb955d44e9..4e46546c86 100644 --- a/test/unit_tests/arkode/CXX_serial/ark_test_accumerror_brusselator.cpp +++ b/test/unit_tests/arkode/CXX_serial/ark_test_accumerror_brusselator.cpp @@ -401,10 +401,10 @@ static int adaptive_run(void* arkode_mem, N_Vector y, sunrealtype T0, // Reused variables int retval; sunrealtype t; - sunrealtype hpart = (Tf - T0) / udata.Npart; - sunrealtype abstol = SUN_RCONST(1.e-12); - vector rtols = {SUN_RCONST(1.e-2), SUN_RCONST(1.e-4), - SUN_RCONST(1.e-6)}; + sunrealtype hpart = (Tf - T0) / udata.Npart; + sunrealtype abstol = SUN_RCONST(1.e-12); + vector rtols = {SUN_RCONST(1.e-2), SUN_RCONST(1.e-4), + SUN_RCONST(1.e-6)}; vector accum_types = {ARK_ACCUMERROR_MAX, ARK_ACCUMERROR_AVG}; vector dsm(udata.Npart); vector dsm_est(udata.Npart); @@ -491,7 +491,7 @@ static int fixed_run(void* arkode_mem, N_Vector y, sunrealtype T0, sunrealtype T // Set array of fixed step sizes to use, storage for corresponding errors/orders sunrealtype hmax = (Tf - T0) / 400; if (rk_type == 1) hmax = min(hmax, udata.ep); - vector hvals = {hmax, hmax / 4, hmax / 16, hmax / 64}; + vector hvals = {hmax, hmax / 4, hmax / 16, hmax / 64}; vector accum_types = {ARK_ACCUMERROR_MAX, ARK_ACCUMERROR_AVG}; vector dsm(udata.Npart); vector dsm_est(udata.Npart); diff --git a/test/unit_tests/arkode/CXX_serial/ark_test_accumerror_kpr.cpp b/test/unit_tests/arkode/CXX_serial/ark_test_accumerror_kpr.cpp index 6bf85e004f..8af02c6ce8 100644 --- a/test/unit_tests/arkode/CXX_serial/ark_test_accumerror_kpr.cpp +++ b/test/unit_tests/arkode/CXX_serial/ark_test_accumerror_kpr.cpp @@ -346,10 +346,10 @@ static int adaptive_run(void* arkode_mem, N_Vector y, sunrealtype T0, // Reused variables int retval; sunrealtype t; - sunrealtype hpart = (Tf - T0) / udata.Npart; - sunrealtype abstol = SUN_RCONST(1.e-12); - vector rtols = {SUN_RCONST(1.e-2), SUN_RCONST(1.e-4), - SUN_RCONST(1.e-6)}; + sunrealtype hpart = (Tf - T0) / udata.Npart; + sunrealtype abstol = SUN_RCONST(1.e-12); + vector rtols = {SUN_RCONST(1.e-2), SUN_RCONST(1.e-4), + SUN_RCONST(1.e-6)}; vector accum_types = {ARK_ACCUMERROR_MAX, ARK_ACCUMERROR_AVG}; vector dsm(udata.Npart); vector dsm_est(udata.Npart); @@ -448,7 +448,7 @@ static int fixed_run(void* arkode_mem, N_Vector y, sunrealtype T0, // Set array of fixed step sizes to use, storage for corresponding errors/orders sunrealtype hmax = (Tf - T0) / 1000; if (rk_type == 1) hmax = min(hmax, ONE / abs(udata.G)); - vector hvals = {hmax, hmax / 4, hmax / 16, hmax / 64}; + vector hvals = {hmax, hmax / 4, hmax / 16, hmax / 64}; vector accum_types = {ARK_ACCUMERROR_MAX, ARK_ACCUMERROR_AVG}; vector dsm(udata.Npart); vector dsm_est(udata.Npart); From 45da294efdf61542853b604579b78ee132c629ec Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Fri, 27 Sep 2024 10:38:17 -0500 Subject: [PATCH 087/286] Bugfix from conversion of AccumErrorType to enum --- src/arkode/arkode_mristep.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/arkode/arkode_mristep.c b/src/arkode/arkode_mristep.c index 9bf2fc6a15..6e1668ca11 100644 --- a/src/arkode/arkode_mristep.c +++ b/src/arkode/arkode_mristep.c @@ -911,7 +911,7 @@ int mriStep_Init(ARKodeMem ark_mem, int init_type) if (step_mem->implicit_rhs) { reset_efun = SUNFALSE; } if (!ark_mem->fixedstep) { reset_efun = SUNFALSE; } if (ark_mem->user_efun) { reset_efun = SUNFALSE; } - if (ark_mem->AccumErrorType >= 0) { reset_efun = SUNFALSE; } + if (ark_mem->AccumErrorType != ARK_ACCUMERROR_NONE) { reset_efun = SUNFALSE; } if (reset_efun) { ark_mem->user_efun = SUNFALSE; @@ -954,7 +954,7 @@ int mriStep_Init(ARKodeMem ark_mem, int init_type) /* Ensure that if adaptivity or error accumulation is enabled, then method includes embedding coefficients */ - if ((!ark_mem->fixedstep || (ark_mem->AccumErrorType >= 0)) && + if ((!ark_mem->fixedstep || (ark_mem->AccumErrorType != ARK_ACCUMERROR_NONE)) && (step_mem->p == 0)) { arkProcessError(ark_mem, ARK_ILL_INPUT, __LINE__, __func__, @@ -1691,7 +1691,7 @@ int mriStep_TakeStepMRIGARK(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPt t0 = ark_mem->tn; /* determine whether embedding stage is needed */ - do_embedding = !ark_mem->fixedstep || (ark_mem->AccumErrorType >= 0); + do_embedding = !ark_mem->fixedstep || (ark_mem->AccumErrorType != ARK_ACCUMERROR_NONE); /* if MRI adaptivity is enabled: reset fast accumulated error, and send appropriate control parameter to the fast integrator */ @@ -2300,7 +2300,7 @@ int mriStep_TakeStepMRISR(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr) /* Skip the embedding if we're using fixed time-stepping and temporal error estimation is disabled */ - if (ark_mem->fixedstep && embedding && (ark_mem->AccumErrorType < 0)) + if (ark_mem->fixedstep && embedding && (ark_mem->AccumErrorType == ARK_ACCUMERROR_NONE)) { break; } @@ -2540,7 +2540,7 @@ int mriStep_TakeStepMRISR(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr) /* if temporal error estimation is enabled: compute estimate via difference between step solution and embedding, store in ark_mem->tempv1, store norm in dsmPtr, and copy solution back to ycur */ - if (!ark_mem->fixedstep || (ark_mem->AccumErrorType >= 0)) + if (!ark_mem->fixedstep || (ark_mem->AccumErrorType != ARK_ACCUMERROR_NONE)) { N_VLinearSum(ONE, ytilde, -ONE, ark_mem->ycur, ark_mem->tempv1); *dsmPtr = N_VWrmsNorm(ark_mem->tempv1, ark_mem->ewt); @@ -2759,7 +2759,7 @@ int mriStep_TakeStepMERK(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr) /* Skip the embedding if we're using fixed time-stepping and temporal error estimation is disabled */ - if (ark_mem->fixedstep && embedding && (ark_mem->AccumErrorType < 0)) + if (ark_mem->fixedstep && embedding && (ark_mem->AccumErrorType == ARK_ACCUMERROR_NONE)) { break; } @@ -2852,7 +2852,7 @@ int mriStep_TakeStepMERK(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr) /* if temporal error estimation is enabled: compute estimate via difference between step solution and embedding, store in ark_mem->tempv1, and store norm in dsmPtr */ - if (!ark_mem->fixedstep || (ark_mem->AccumErrorType >= 0)) + if (!ark_mem->fixedstep || (ark_mem->AccumErrorType != ARK_ACCUMERROR_NONE)) { N_VLinearSum(ONE, ytilde, -ONE, ark_mem->ycur, ark_mem->tempv1); *dsmPtr = N_VWrmsNorm(ark_mem->tempv1, ark_mem->ewt); From 9af8d3b8755627c81cf7c3614a2cc5b0193fc026 Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Fri, 27 Sep 2024 10:44:51 -0500 Subject: [PATCH 088/286] Formatting --- src/arkode/arkode_mristep.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/arkode/arkode_mristep.c b/src/arkode/arkode_mristep.c index 6e1668ca11..b1a9f9420e 100644 --- a/src/arkode/arkode_mristep.c +++ b/src/arkode/arkode_mristep.c @@ -911,7 +911,10 @@ int mriStep_Init(ARKodeMem ark_mem, int init_type) if (step_mem->implicit_rhs) { reset_efun = SUNFALSE; } if (!ark_mem->fixedstep) { reset_efun = SUNFALSE; } if (ark_mem->user_efun) { reset_efun = SUNFALSE; } - if (ark_mem->AccumErrorType != ARK_ACCUMERROR_NONE) { reset_efun = SUNFALSE; } + if (ark_mem->AccumErrorType != ARK_ACCUMERROR_NONE) + { + reset_efun = SUNFALSE; + } if (reset_efun) { ark_mem->user_efun = SUNFALSE; @@ -1691,7 +1694,8 @@ int mriStep_TakeStepMRIGARK(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPt t0 = ark_mem->tn; /* determine whether embedding stage is needed */ - do_embedding = !ark_mem->fixedstep || (ark_mem->AccumErrorType != ARK_ACCUMERROR_NONE); + do_embedding = !ark_mem->fixedstep || + (ark_mem->AccumErrorType != ARK_ACCUMERROR_NONE); /* if MRI adaptivity is enabled: reset fast accumulated error, and send appropriate control parameter to the fast integrator */ @@ -2300,7 +2304,8 @@ int mriStep_TakeStepMRISR(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr) /* Skip the embedding if we're using fixed time-stepping and temporal error estimation is disabled */ - if (ark_mem->fixedstep && embedding && (ark_mem->AccumErrorType == ARK_ACCUMERROR_NONE)) + if (ark_mem->fixedstep && embedding && + (ark_mem->AccumErrorType == ARK_ACCUMERROR_NONE)) { break; } @@ -2759,7 +2764,8 @@ int mriStep_TakeStepMERK(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr) /* Skip the embedding if we're using fixed time-stepping and temporal error estimation is disabled */ - if (ark_mem->fixedstep && embedding && (ark_mem->AccumErrorType == ARK_ACCUMERROR_NONE)) + if (ark_mem->fixedstep && embedding && + (ark_mem->AccumErrorType == ARK_ACCUMERROR_NONE)) { break; } From acf992bf0af7d04bec8f559dd9af4621a6ba2cdc Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Fri, 27 Sep 2024 12:37:55 -0500 Subject: [PATCH 089/286] Documentation fixes --- .../source/Usage/MRIStep/MRIStepCoupling.rst | 36 ++++++++++++++----- .../guide/source/Usage/User_callable.rst | 4 +-- 2 files changed, 30 insertions(+), 10 deletions(-) diff --git a/doc/arkode/guide/source/Usage/MRIStep/MRIStepCoupling.rst b/doc/arkode/guide/source/Usage/MRIStep/MRIStepCoupling.rst index 2d5c77d368..eaa0a1b9eb 100644 --- a/doc/arkode/guide/source/Usage/MRIStep/MRIStepCoupling.rst +++ b/doc/arkode/guide/source/Usage/MRIStep/MRIStepCoupling.rst @@ -30,18 +30,26 @@ by the table is determined by an enumerated type, :c:enum:`ARKODE_MRIType`: This may take any of the following constants: - * :enumerator:`MRISTEP_EXPLICIT` -- indicates an MRI-GARK method that - does not support a slow implicit operator, :math:`f^I`. +.. c:enumerator:: MRISTEP_EXPLICIT - * :enumerator:`MRISTEP_IMPLICIT` -- indicates an MRI-GARK method that - does not support a slow explicit operator, :math:`f^E`. + An explicit MRI-GARK method (does not support a slow implicit operator, :math:`f^I`). - * :enumerator:`MRISTEP_IMEX` -- indicates an IMEX-MRK-GARK method. +.. c:enumerator:: MRISTEP_IMPLICIT - * :enumerator:`MRISTEP_MERK` -- indicates a MERK method, that by definition - does not support a slow implicit operator, :math:`f^I`. + An implicit MRI-GARK method (does not support a slow explicit operator, :math:`f^E`). + +.. c:enumerator:: MRISTEP_IMEX + + An IMEX-MRK-GARK method. + +.. c:enumerator:: MRISTEP_MERK + + A explicit MERK method (does not support a slow implicit operator, :math:`f^I`). + +.. c:enumerator:: MRISTEP_MRISR + + An IMEX-MRI-SR method. - * :enumerator:`MRISTEP_MRISR` -- indicates an IMEX-MRI-SR method. The MRI coupling tables themselves are stored in an :c:func:`MRIStepCoupling` object which is a pointer to a @@ -199,6 +207,18 @@ are defined ``arkode/arkode_mristep.h``. For MRISTEP_MRISR tables, the *group* array is not allocated. + When allocated, each of :math:`\Omega^{\{k\}}` and :math:`\Gamma^{\{k\}}` + are initialized to all zeros, so only nonzero coefficients need to be provided. + + When allocated, all entries in *group* are initialized to ``-1``, indicating an unused group and/or the end of a stage group. Users who supply a custom MRISTEP_MERK table should over-write all active stages in each group. For example the ``ARKODE_MERK32`` method has 4 stages that are evolved in 3 groups -- the first group consists of stage 1, the second group consists of stages 2 and 4, while the third group consists of stage 3. Thus *ngroup* should equal 3, and *group* should have non-default entries + + .. code-block:: C + + C->group[0][0] = 1; + C->group[1][0] = 2; + C->group[1][1] = 4; + C->group[2][0] = 3; + .. versionchanged:: x.y.z In previous releases, this function did not include the *type* argument. diff --git a/doc/arkode/guide/source/Usage/User_callable.rst b/doc/arkode/guide/source/Usage/User_callable.rst index f77e61f75b..41c37fa175 100644 --- a/doc/arkode/guide/source/Usage/User_callable.rst +++ b/doc/arkode/guide/source/Usage/User_callable.rst @@ -1756,7 +1756,7 @@ the accumulated temporal error over multiple time steps. For time-stepping modu compute both a solution and embedding, :math:`y_n` and :math:`\tilde{y}_n`, these may be combined to create a vector-valued local temporal error estimate for the current internal step, :math:`y_n - \tilde{y}_n`. These local errors may be accumulated by ARKODE in a -variety of ways, as determined by the enumerated type :c:enum:`ARK_ACCUMERROR`. In each +variety of ways, as determined by the enumerated type :c:enum:`ARKODE_MRIType`. In each of the cases below, the accumulation is taken over all steps :math:`n\in N` since the most recent call to either :c:func:`ARKodeSetAccumulatedErrorType` or :c:func:`ARKodeResetAccumulatedError`. The norm is taken using the tolerance-informed @@ -1799,7 +1799,7 @@ user-specified relative solution tolerance. .. note:: By default, ARKODE will not accumulate any local error estimates (i.e., - the default *accum_type` is ``ARK_ACCUMERROR_NONE``). + the default *accum_type* is ``ARK_ACCUMERROR_NONE``). A non-default error accumulation strategy can be disabled by calling :c:func:`ARKodeSetAccumulatedErrorType` with the argument ``ARK_ACCUMERROR_NONE``. From 6c72290eae59c2be368e2725a401bef0d835c5b5 Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Fri, 27 Sep 2024 14:41:36 -0500 Subject: [PATCH 090/286] Fixed one more bug in changing accumulated error type to enum; created ARKODE-level utility routine to create MRIStepInnerStepper --- CHANGELOG.md | 6 + .../source/Usage/ARKStep/User_callable.rst | 4 + .../source/Usage/ERKStep/User_callable.rst | 48 ---- .../guide/source/Usage/MRIStep/Skeleton.rst | 16 +- .../source/Usage/MRIStep/User_callable.rst | 83 +----- .../guide/source/Usage/User_callable.rst | 55 ++++ doc/shared/RecentChanges.rst | 6 + .../CXX_parallel/ark_diffusion_reaction_p.cpp | 4 +- .../CXX_parhyp/ark_heat2D_hypre_pfmg_mri.cpp | 4 +- .../ark_advection_diffusion_reaction.cpp | 4 +- .../arkode/CXX_serial/ark_kpr_nestedmri.cpp | 10 +- .../C_serial/ark_brusselator1D_imexmri.c | 4 +- .../arkode/C_serial/ark_brusselator_1D_mri.c | 4 +- .../arkode/C_serial/ark_brusselator_mri.c | 4 +- examples/arkode/C_serial/ark_kpr_mri.c | 4 +- .../arkode/C_serial/ark_onewaycouple_mri.c | 4 +- .../C_serial/ark_reaction_diffusion_mri.c | 4 +- .../arkode/C_serial/ark_twowaycouple_mri.c | 4 +- .../arkode/F2003_serial/ark_kpr_mri_f2003.f90 | 4 +- include/arkode/arkode.h | 4 + include/arkode/arkode_arkstep.h | 6 +- include/arkode/arkode_erkstep.h | 3 - include/arkode/arkode_mristep.h | 3 - src/arkode/arkode.c | 239 ++++++++++++++++++ src/arkode/arkode_arkstep.c | 218 +--------------- src/arkode/arkode_arkstep_impl.h | 15 +- src/arkode/arkode_arkstep_io.c | 7 +- src/arkode/arkode_erkstep.c | 219 +--------------- src/arkode/arkode_erkstep_impl.h | 19 +- src/arkode/arkode_erkstep_io.c | 2 +- src/arkode/arkode_impl.h | 22 ++ src/arkode/arkode_mristep.c | 213 +--------------- src/arkode/arkode_mristep_impl.h | 15 +- src/arkode/arkode_mristep_io.c | 2 +- src/arkode/fmod_int32/farkode_arkstep_mod.c | 14 - src/arkode/fmod_int32/farkode_arkstep_mod.f90 | 26 -- src/arkode/fmod_int32/farkode_erkstep_mod.c | 14 - src/arkode/fmod_int32/farkode_erkstep_mod.f90 | 26 -- src/arkode/fmod_int32/farkode_mod.c | 14 + src/arkode/fmod_int32/farkode_mod.f90 | 26 ++ src/arkode/fmod_int32/farkode_mristep_mod.c | 14 - src/arkode/fmod_int32/farkode_mristep_mod.f90 | 26 -- src/arkode/fmod_int64/farkode_arkstep_mod.c | 14 - src/arkode/fmod_int64/farkode_arkstep_mod.f90 | 26 -- src/arkode/fmod_int64/farkode_erkstep_mod.c | 14 - src/arkode/fmod_int64/farkode_erkstep_mod.f90 | 26 -- src/arkode/fmod_int64/farkode_mod.c | 14 + src/arkode/fmod_int64/farkode_mod.f90 | 26 ++ src/arkode/fmod_int64/farkode_mristep_mod.c | 14 - src/arkode/fmod_int64/farkode_mristep_mod.f90 | 26 -- .../CXX_parallel/ark_test_heat2D_mri.cpp | 4 +- .../CXX_serial/ark_test_analytic_sys_mri.cpp | 4 +- .../ark_test_brusselator_mriadapt.cpp | 4 +- .../CXX_serial/ark_test_dahlquist_mri.cpp | 4 +- .../arkode/CXX_serial/ark_test_getjac_mri.cpp | 4 +- .../CXX_serial/ark_test_kpr_mriadapt.cpp | 4 +- .../ark_test_slowerror_brusselator.cpp | 4 +- .../CXX_serial/ark_test_slowerror_kpr.cpp | 4 +- .../ark_test_slowerror_polynomial.cpp | 4 +- .../arkode/C_serial/ark_test_getuserdata.c | 4 +- .../arkode/C_serial/ark_test_reset.c | 4 +- 61 files changed, 512 insertions(+), 1111 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 24daa00566..b0d4a2df92 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -33,6 +33,9 @@ Added functionality to ARKODE to accumulate a temporal error estimate over multiple time steps. See the routines `ARKodeSetAccumulatedErrorType`, `ARKodeResetAccumulatedError`, and `ARKodeGetAccumulatedError` for details. +Added utility routine to wrap any valid ARKODE integrator for use as an MRIStep +inner stepper object, `ARKodeCreateMRIStepInnerStepper`. + ### Bug Fixes Fixed `ARKodeResize` not using the default `hscale` when an argument of `0` was @@ -56,6 +59,9 @@ was loaded in both cases. ### Deprecation Notices +Deprecated ARKStep-specific utility routine for wrapping as an MRIStep +inner stepper object, `ARKStepCreateMRIStepInnerStepper`. + ## Changes to SUNDIALS in release 7.1.1 ### Bug Fixes diff --git a/doc/arkode/guide/source/Usage/ARKStep/User_callable.rst b/doc/arkode/guide/source/Usage/ARKStep/User_callable.rst index a5589a9cdc..f8fe7b5dc7 100644 --- a/doc/arkode/guide/source/Usage/ARKStep/User_callable.rst +++ b/doc/arkode/guide/source/Usage/ARKStep/User_callable.rst @@ -4400,3 +4400,7 @@ wrap an ARKStep memory block as an :c:type:`MRIStepInnerStepper`. **Example codes:** * ``examples/arkode/CXX_parallel/ark_diffusion_reaction_p.cpp`` + + .. deprecated:: x.y.z + + Use :c:func:`ARKodeCreateMRIStepInnerStepper` instead. diff --git a/doc/arkode/guide/source/Usage/ERKStep/User_callable.rst b/doc/arkode/guide/source/Usage/ERKStep/User_callable.rst index 8ac01ce4b6..7ab94fe6c0 100644 --- a/doc/arkode/guide/source/Usage/ERKStep/User_callable.rst +++ b/doc/arkode/guide/source/Usage/ERKStep/User_callable.rst @@ -2157,51 +2157,3 @@ ERKStep system resize function .. deprecated:: 6.1.0 Use :c:func:`ARKodeResize` instead. - - -.. _ERKStep_CInterface.MRIStepInterface: - -Interfacing with MRIStep ------------------------- - -When using ERKStep as the inner (fast) integrator with MRIStep, the -utility function :c:func:`ERKStepCreateMRIStepInnerStepper` should be used to -wrap an ERKStep memory block as an :c:type:`MRIStepInnerStepper`. - -.. c:function:: int ERKStepCreateMRIStepInnerStepper(void *inner_arkode_mem, MRIStepInnerStepper *stepper) - - Wraps an ERKStep memory block as an :c:type:`MRIStepInnerStepper` for use - with MRIStep. - - **Arguments:** - * *arkode_mem* -- pointer to the ERKStep memory block. - * *stepper* -- the :c:type:`MRIStepInnerStepper` object. - - **Return value:** - * *ARK_SUCCESS* if successful - * *ARK_MEM_FAIL* if a memory allocation failed - * *ARK_ILL_INPUT* if an argument has an illegal value. - - **Example usage:** - .. code-block:: C - - /* fast (inner) and slow (outer) ARKODE objects */ - void *inner_arkode_mem = NULL; - void *outer_arkode_mem = NULL; - - /* MRIStepInnerStepper to wrap the inner (fast) ERKStep object */ - MRIStepInnerStepper stepper = NULL; - - /* create an ERKStep object, setting fast (inner) right-hand side - functions and the initial condition */ - inner_arkode_mem = ERKStepCreate(ff, t0, y0, sunctx); - - /* setup ERKStep */ - . . . - - /* create MRIStepInnerStepper wrapper for the ERKStep memory block */ - flag = ERKStepCreateMRIStepInnerStepper(inner_arkode_mem, &stepper); - - /* create an MRIStep object, setting the slow (outer) right-hand side - functions and the initial condition */ - outer_arkode_mem = MRIStepCreate(fse, fsi, t0, y0, stepper, sunctx) diff --git a/doc/arkode/guide/source/Usage/MRIStep/Skeleton.rst b/doc/arkode/guide/source/Usage/MRIStep/Skeleton.rst index f1275b0ae3..6ead901fda 100644 --- a/doc/arkode/guide/source/Usage/MRIStep/Skeleton.rst +++ b/doc/arkode/guide/source/Usage/MRIStep/Skeleton.rst @@ -39,15 +39,17 @@ unchanged from the skeleton program presented in #. Create an inner stepper object to solve the fast (inner) IVP - * If using ARKStep as the fast (inner) integrator, create the ARKStep object - with :c:func:`ARKStepCreate` and configure the integrator as desired for + * If using ERKStep, ARKStep, or MRIStep as the fast (inner) integrator, create + the solver object with :c:func:`ERKStepCreate`, :c:func:`ARKStepCreate`, or + :c:func:`MRIStepCreate`, and configure the integrator as desired for evolving the fast time scale. See sections :numref:`ARKODE.Usage.Skeleton`, - :numref:`ARKODE.Usage.OptionalInputs`, and - :numref:`ARKODE.Usage.ARKStep.OptionalInputs` for details on configuring - ARKStep. + :numref:`ARKODE.Usage.OptionalInputs`, :numref:`ARKODE.Usage.ERKStep.OptionalInputs`, + :numref:`ARKODE.Usage.ARKStep.OptionalInputs`, and + :numref:`ARKODE.Usage.MRIStep.OptionalInputs` for details on configuring + these integrators. - Once the ARKStep object is setup, create an ``MRIStepInnerStepper`` object - with :c:func:`ARKStepCreateMRIStepInnerStepper`. + Once the ARKODE stepper object is setup, create an ``MRIStepInnerStepper`` object + with :c:func:`ARKodeCreateMRIStepInnerStepper`. * If supplying a user-defined fast (inner) integrator, create the ``MRIStepInnerStepper`` object as described in section diff --git a/doc/arkode/guide/source/Usage/MRIStep/User_callable.rst b/doc/arkode/guide/source/Usage/MRIStep/User_callable.rst index cbfdb19e4f..cbeaac8322 100644 --- a/doc/arkode/guide/source/Usage/MRIStep/User_callable.rst +++ b/doc/arkode/guide/source/Usage/MRIStep/User_callable.rst @@ -72,18 +72,18 @@ MRIStep initialization and deallocation functions void *inner_arkode_mem = NULL; void *outer_arkode_mem = NULL; - /* MRIStepInnerStepper to wrap the inner (fast) ARKStep object */ + /* MRIStepInnerStepper to wrap the inner (fast) ERKStep object */ MRIStepInnerStepper stepper = NULL; - /* create an ARKStep object, setting fast (inner) right-hand side + /* create an ERKStep/ARKStep/MRIStep object, setting fast (inner) right-hand side functions and the initial condition */ - inner_arkode_mem = ARKStepCreate(ffe, ffi, t0, y0, sunctx); + inner_arkode_mem = *StepCreate(...); - /* setup ARKStep */ - . . . + /* configure the inner integrator */ + retval = ARKodeSet*(inner_arkode_mem, ...); - /* create MRIStepInnerStepper wrapper for the ARKStep memory block */ - flag = ARKStepCreateMRIStepInnerStepper(inner_arkode_mem, &stepper); + /* create MRIStepInnerStepper wrapper for the ARKODE integrator */ + flag = ARKodeCreateMRIStepInnerStepper(inner_arkode_mem, &stepper); /* create an MRIStep object, setting the slow (outer) right-hand side functions and the initial condition */ @@ -97,6 +97,8 @@ MRIStep initialization and deallocation functions * ``examples/arkode/C_serial/ark_reaction_diffusion_mri.c`` * ``examples/arkode/C_serial/ark_kpr_mri.c`` * ``examples/arkode/CXX_parallel/ark_diffusion_reaction_p.cpp`` + * ``examples/arkode/CXX_serial/ark_test_kpr_nestedmri.cpp`` + (uses MRIStep within itself) .. c:function:: void MRIStepFree(void** arkode_mem) @@ -2609,70 +2611,3 @@ MRIStep system resize function .. deprecated:: 6.1.0 Use :c:func:`ARKodeResize` instead. - - - - -.. _MRIStep_CInterface.MRIStepInterface: - -Nested multirate calculations ------------------------------ - -It is possible to use MRIStep as an inner integrator within a slower time scale -MRIStep integration, thereby allowing for nested multirate calculations with more than -two time scales. Here, the inner MRIStep integrator can be wrapped as an -:c:type:`MRIStepInnerStepper` by calling the utility function -:c:func:`MRIStepCreateMRIStepInnerStepper`. - -.. c:function:: int MRIStepCreateMRIStepInnerStepper(void *inner_arkode_mem, MRIStepInnerStepper *stepper) - - Wraps an MRIStep memory block as an :c:type:`MRIStepInnerStepper` for use - with an outer MRIStep instance. - - **Arguments:** - * *arkode_mem* -- pointer to the inner MRIStep memory block. - * *stepper* -- the :c:type:`MRIStepInnerStepper` object. - - **Return value:** - * *ARK_SUCCESS* if successful - * *ARK_MEM_FAIL* if a memory allocation failed - * *ARK_ILL_INPUT* if an argument has an illegal value. - - **Example usage:** - .. code-block:: C - - /* fast, intermediate, and slow ARKODE objects */ - void *fast_arkode_mem = NULL; - void *mid_arkode_mem = NULL; - void *outer_arkode_mem = NULL; - - /* MRIStepInnerSteppers to wrap the fast ARKStep and intermediate MRIStep objects */ - MRIStepInnerStepper faststepper = NULL; - MRIStepInnerStepper midstepper = NULL; - - /* create an ARKStep object, setting fast (inner) right-hand side - functions and the initial condition */ - fast_arkode_mem = ARKStepCreate(ffe, ffi, t0, y0, sunctx); - - /* setup ARKStep */ - . . . - - /* create MRIStepInnerStepper wrapper for the ARKStep memory block */ - flag = ARKStepCreateMRIStepInnerStepper(fast_arkode_mem, &faststepper); - - /* create an MRIStep object, setting the intermediate right-hand side - functions and the initial condition */ - mid_arkode_mem = MRIStepCreate(fme, fmi, t0, y0, faststepper, sunctx); - - /* setup MRIStep */ - . . . - - /* create MRIStepInnerStepper wrapper for the MRIStep memory block */ - flag = MRIStepCreateMRIStepInnerStepper(mid_arkode_mem, &midstepper); - - /* create an MRIStep object, setting the slow (outer) right-hand side - functions and the initial condition */ - outer_arkode_mem = MRIStepCreate(fse, fsi, t0, y0, midstepper, sunctx); - - **Example codes:** - * ``examples/arkode/CXX_serial/ark_test_kpr_nestedmri.cpp`` diff --git a/doc/arkode/guide/source/Usage/User_callable.rst b/doc/arkode/guide/source/Usage/User_callable.rst index 41c37fa175..0162a3b1f3 100644 --- a/doc/arkode/guide/source/Usage/User_callable.rst +++ b/doc/arkode/guide/source/Usage/User_callable.rst @@ -4776,3 +4776,58 @@ rescale the upcoming time step by the specified factor. If a value * ``examples/arkode/C_serial/ark_heat1D_adapt.c`` .. versionadded:: 6.1.0 + + + +.. _ERKStep_CInterface.MRIStepInterface: + +Using an ARKODE solver as an MRIStep "inner" solver +--------------------------------------------------- + +When using an integrator from ARKODE as the inner (fast) integrator with MRIStep, the +utility function :c:func:`ARKodeCreateMRIStepInnerStepper` should be used to +wrap the ARKODE memory block as an :c:type:`MRIStepInnerStepper`. + +.. c:function:: int ARKodeCreateMRIStepInnerStepper(void *inner_arkode_mem, MRIStepInnerStepper *stepper) + + Wraps an ARKODE integrator as an :c:type:`MRIStepInnerStepper` for use + with MRIStep. + + :param arkode_mem: pointer to the ARKODE memory block. + :param stepper: the :c:type:`MRIStepInnerStepper` object to create. + + :retval ARK_SUCCESS: the function exited successfully. + :retval ARK_MEM_FAIL: a memory allocation failed. + :retval ARK_STEPPER_UNSUPPORTED: the time-stepping module does not currently support use as an inner stepper. + + .. note:: + + Currently, ARKODE integrators based on ARKStep, ERKStep, and MRIStep + support use as an MRIStep inner stepper. + + **Example usage:** + + .. code-block:: C + + /* fast (inner) and slow (outer) ARKODE objects */ + void *inner_arkode_mem = NULL; + void *outer_arkode_mem = NULL; + + /* MRIStepInnerStepper to wrap the inner (fast) ERKStep object */ + MRIStepInnerStepper stepper = NULL; + + /* create an ERKStep/ARKStep/MRIStep object, setting fast (inner) right-hand side + functions and the initial condition */ + inner_arkode_mem = *StepCreate(...); + + /* configure the inner integrator */ + retval = ARKodeSet*(inner_arkode_mem, ...); + + /* create MRIStepInnerStepper wrapper for the ARKODE integrator */ + flag = ARKodeCreateMRIStepInnerStepper(inner_arkode_mem, &stepper); + + /* create an MRIStep object, setting the slow (outer) right-hand side + functions and the initial condition */ + outer_arkode_mem = MRIStepCreate(fse, fsi, t0, y0, stepper, sunctx) + + .. versionadded:: 6.1.0 diff --git a/doc/shared/RecentChanges.rst b/doc/shared/RecentChanges.rst index 6e59c34e89..e6bab18cdf 100644 --- a/doc/shared/RecentChanges.rst +++ b/doc/shared/RecentChanges.rst @@ -30,6 +30,9 @@ estimate over multiple time steps. See the routines :c:func:`ARKodeSetAccumulatedErrorType`, :c:func:`ARKodeResetAccumulatedError`, and :c:func:`ARKodeGetAccumulatedError` for details. +Added utility routine to wrap any valid ARKODE integrator for use as an MRIStep +inner stepper object, :c:func:`ARKodeCreateMRIStepInnerStepper`. + **Bug Fixes** Fixed c:func:`ARKodeResize` not using the default ``hscale`` when an argument of @@ -52,3 +55,6 @@ was loaded in both cases. **Deprecation Notices** + +Deprecated ARKStep-specific utility routine for wrapping as an MRIStep +inner stepper object, :c:func:`ARKStepCreateMRIStepInnerStepper`. diff --git a/examples/arkode/CXX_parallel/ark_diffusion_reaction_p.cpp b/examples/arkode/CXX_parallel/ark_diffusion_reaction_p.cpp index 5643211620..3185ac802f 100644 --- a/examples/arkode/CXX_parallel/ark_diffusion_reaction_p.cpp +++ b/examples/arkode/CXX_parallel/ark_diffusion_reaction_p.cpp @@ -1044,8 +1044,8 @@ static int SetupMRI(SUNContext ctx, UserData* udata, N_Vector y, if (check_flag(&flag, "ARKodeSetMaxNumSteps", 1)) { return 1; } // Wrap ARKODE as an MRIStepInnerStepper - flag = ARKStepCreateMRIStepInnerStepper(inner_arkode_mem, stepper); - if (check_flag(&flag, "ARKStepCreateMRIStepInnerStepper", 1)) { return 1; } + flag = ARKodeCreateMRIStepInnerStepper(inner_arkode_mem, stepper); + if (check_flag(&flag, "ARKodeCreateMRIStepInnerStepper", 1)) { return 1; } // ------------------------- // Setup the slow integrator 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 aa75c8b61c..426a0ad572 100644 --- a/examples/arkode/CXX_parhyp/ark_heat2D_hypre_pfmg_mri.cpp +++ b/examples/arkode/CXX_parhyp/ark_heat2D_hypre_pfmg_mri.cpp @@ -466,8 +466,8 @@ int main(int argc, char* argv[]) if (check_flag(&flag, "ARKodeSetMaxNumSteps", 1)) { return 1; } // Create inner stepper - flag = ARKStepCreateMRIStepInnerStepper(inner_arkode_mem, &inner_stepper); - if (check_flag(&flag, "ARKStepCreateMRIStepInnerStepper", 1)) { return 1; } + flag = ARKodeCreateMRIStepInnerStepper(inner_arkode_mem, &inner_stepper); + if (check_flag(&flag, "ARKodeCreateMRIStepInnerStepper", 1)) { return 1; } // ----------------------------------------------- // Set up MRIStep slow integrator and set options diff --git a/examples/arkode/CXX_serial/ark_advection_diffusion_reaction.cpp b/examples/arkode/CXX_serial/ark_advection_diffusion_reaction.cpp index 4ee2587c82..3423bc5c56 100644 --- a/examples/arkode/CXX_serial/ark_advection_diffusion_reaction.cpp +++ b/examples/arkode/CXX_serial/ark_advection_diffusion_reaction.cpp @@ -783,8 +783,8 @@ int SetupMRIARK(SUNContext ctx, UserData& udata, UserOptions& uopts, N_Vector y, if (check_flag(flag, "ARKodeSetMaxNumSteps")) { return 1; } // Wrap ARKODE as an MRIStepInnerStepper - flag = ARKStepCreateMRIStepInnerStepper(fast_arkode_mem, fast_mem); - if (check_flag(flag, "ARKStepCreateMRIStepInnerStepper")) { return 1; } + flag = ARKodeCreateMRIStepInnerStepper(fast_arkode_mem, fast_mem); + if (check_flag(flag, "ARKodeCreateMRIStepInnerStepper")) { return 1; } // ------------------------- // Setup the slow integrator diff --git a/examples/arkode/CXX_serial/ark_kpr_nestedmri.cpp b/examples/arkode/CXX_serial/ark_kpr_nestedmri.cpp index 7e520eb497..dc4bd06114 100644 --- a/examples/arkode/CXX_serial/ark_kpr_nestedmri.cpp +++ b/examples/arkode/CXX_serial/ark_kpr_nestedmri.cpp @@ -447,8 +447,8 @@ int main(int argc, char* argv[]) // Create inner stepper MRIStepInnerStepper inner_stepper = nullptr; - retval = ERKStepCreateMRIStepInnerStepper(inner_arkode_mem, &inner_stepper); - if (check_flag(retval, "ERKStepCreateMRIStepInnerStepper")) return 1; + retval = ARKodeCreateMRIStepInnerStepper(inner_arkode_mem, &inner_stepper); + if (check_flag(retval, "ARKodeCreateMRIStepInnerStepper")) return 1; // Create intermediate and slow controller objects, and select orders of accuracy as relevant SUNAdaptController scontrol = nullptr; @@ -869,9 +869,9 @@ int main(int argc, char* argv[]) // Create intermediate stepper MRIStepInnerStepper intermediate_stepper = nullptr; - retval = MRIStepCreateMRIStepInnerStepper(mid_arkode_mem, - &intermediate_stepper); - if (check_flag(retval, "MRIStepCreateMRIStepInnerStepper")) return 1; + retval = ARKodeCreateMRIStepInnerStepper(mid_arkode_mem, + &intermediate_stepper); + if (check_flag(retval, "ARKodeCreateMRIStepInnerStepper")) return 1; // Create MRI (slow) integrator void* arkode_mem = MRIStepCreate(f_se, f_si, T0, y, intermediate_stepper, diff --git a/examples/arkode/C_serial/ark_brusselator1D_imexmri.c b/examples/arkode/C_serial/ark_brusselator1D_imexmri.c index 1d52164719..2deca42f2d 100644 --- a/examples/arkode/C_serial/ark_brusselator1D_imexmri.c +++ b/examples/arkode/C_serial/ark_brusselator1D_imexmri.c @@ -523,8 +523,8 @@ int main(int argc, char* argv[]) if (check_retval(&retval, "ARKodeSetFixedStep", 1)) { return 1; } /* Create inner stepper */ - retval = ARKStepCreateMRIStepInnerStepper(inner_arkode_mem, &inner_stepper); - if (check_retval(&retval, "ARKStepCreateMRIStepInnerStepper", 1)) + retval = ARKodeCreateMRIStepInnerStepper(inner_arkode_mem, &inner_stepper); + if (check_retval(&retval, "ARKodeCreateMRIStepInnerStepper", 1)) { return 1; } diff --git a/examples/arkode/C_serial/ark_brusselator_1D_mri.c b/examples/arkode/C_serial/ark_brusselator_1D_mri.c index 54398dcf71..d9a9ce21d8 100644 --- a/examples/arkode/C_serial/ark_brusselator_1D_mri.c +++ b/examples/arkode/C_serial/ark_brusselator_1D_mri.c @@ -248,8 +248,8 @@ int main(int argc, char* argv[]) if (check_retval(&retval, "ARKodeSetJacFn", 1)) { return 1; } /* Create inner stepper */ - retval = ARKStepCreateMRIStepInnerStepper(inner_arkode_mem, &inner_stepper); - if (check_retval(&retval, "ARKStepCreateMRIStepInnerStepper", 1)) + retval = ARKodeCreateMRIStepInnerStepper(inner_arkode_mem, &inner_stepper); + if (check_retval(&retval, "ARKodeCreateMRIStepInnerStepper", 1)) { return 1; } diff --git a/examples/arkode/C_serial/ark_brusselator_mri.c b/examples/arkode/C_serial/ark_brusselator_mri.c index 1ea84c3ee5..1586ca51f6 100644 --- a/examples/arkode/C_serial/ark_brusselator_mri.c +++ b/examples/arkode/C_serial/ark_brusselator_mri.c @@ -147,8 +147,8 @@ int main(void) if (check_retval(&retval, "ARKodeSetFixedStep", 1)) { return 1; } /* Create inner stepper */ - retval = ARKStepCreateMRIStepInnerStepper(inner_arkode_mem, &inner_stepper); - if (check_retval(&retval, "ARKStepCreateMRIStepInnerStepper", 1)) + retval = ARKodeCreateMRIStepInnerStepper(inner_arkode_mem, &inner_stepper); + if (check_retval(&retval, "ARKodeCreateMRIStepInnerStepper", 1)) { return 1; } diff --git a/examples/arkode/C_serial/ark_kpr_mri.c b/examples/arkode/C_serial/ark_kpr_mri.c index 1ad01b5d06..cd8ee4e2e9 100644 --- a/examples/arkode/C_serial/ark_kpr_mri.c +++ b/examples/arkode/C_serial/ark_kpr_mri.c @@ -513,8 +513,8 @@ int main(int argc, char* argv[]) if (check_retval(&retval, "ARKodeSetFixedStep", 1)) { return 1; } /* Create inner stepper */ - retval = ARKStepCreateMRIStepInnerStepper(inner_arkode_mem, &inner_stepper); - if (check_retval(&retval, "ARKStepCreateMRIStepInnerStepper", 1)) + retval = ARKodeCreateMRIStepInnerStepper(inner_arkode_mem, &inner_stepper); + if (check_retval(&retval, "ARKodeCreateMRIStepInnerStepper", 1)) { return 1; } diff --git a/examples/arkode/C_serial/ark_onewaycouple_mri.c b/examples/arkode/C_serial/ark_onewaycouple_mri.c index ad6776e7bb..fdb9ce1f9b 100644 --- a/examples/arkode/C_serial/ark_onewaycouple_mri.c +++ b/examples/arkode/C_serial/ark_onewaycouple_mri.c @@ -148,8 +148,8 @@ int main(void) if (check_retval(&retval, "ARKodeSetFixedStep", 1)) { return 1; } /* Create inner stepper */ - retval = ARKStepCreateMRIStepInnerStepper(inner_arkode_mem, &inner_stepper); - if (check_retval(&retval, "ARKStepCreateMRIStepInnerStepper", 1)) + retval = ARKodeCreateMRIStepInnerStepper(inner_arkode_mem, &inner_stepper); + if (check_retval(&retval, "ARKodeCreateMRIStepInnerStepper", 1)) { return 1; } diff --git a/examples/arkode/C_serial/ark_reaction_diffusion_mri.c b/examples/arkode/C_serial/ark_reaction_diffusion_mri.c index e6a5b6d138..38d156ce65 100644 --- a/examples/arkode/C_serial/ark_reaction_diffusion_mri.c +++ b/examples/arkode/C_serial/ark_reaction_diffusion_mri.c @@ -157,8 +157,8 @@ int main(void) if (check_retval(&retval, "ARKodeSetFixedStep", 1)) { return 1; } /* Create inner stepper */ - retval = ARKStepCreateMRIStepInnerStepper(inner_arkode_mem, &inner_stepper); - if (check_retval(&retval, "ARKStepCreateMRIStepInnerStepper", 1)) + retval = ARKodeCreateMRIStepInnerStepper(inner_arkode_mem, &inner_stepper); + if (check_retval(&retval, "ARKodeCreateMRIStepInnerStepper", 1)) { return 1; } diff --git a/examples/arkode/C_serial/ark_twowaycouple_mri.c b/examples/arkode/C_serial/ark_twowaycouple_mri.c index 4a099d99a4..03a159f35d 100644 --- a/examples/arkode/C_serial/ark_twowaycouple_mri.c +++ b/examples/arkode/C_serial/ark_twowaycouple_mri.c @@ -127,8 +127,8 @@ int main(void) if (check_retval(&retval, "ARKodeSetFixedStep", 1)) { return 1; } /* Create inner stepper */ - retval = ARKStepCreateMRIStepInnerStepper(inner_arkode_mem, &inner_stepper); - if (check_retval(&retval, "ARKStepCreateMRIStepInnerStepper", 1)) + retval = ARKodeCreateMRIStepInnerStepper(inner_arkode_mem, &inner_stepper); + if (check_retval(&retval, "ARKodeCreateMRIStepInnerStepper", 1)) { return 1; } diff --git a/examples/arkode/F2003_serial/ark_kpr_mri_f2003.f90 b/examples/arkode/F2003_serial/ark_kpr_mri_f2003.f90 index 330e54f6b7..9a572d82f1 100644 --- a/examples/arkode/F2003_serial/ark_kpr_mri_f2003.f90 +++ b/examples/arkode/F2003_serial/ark_kpr_mri_f2003.f90 @@ -886,9 +886,9 @@ program main end if ! Create inner stepper */ - retval = FARKStepCreateMRIStepInnerStepper(inner_arkode_mem, inner_stepper) + retval = FARKodeCreateMRIStepInnerStepper(inner_arkode_mem, inner_stepper) if (retval /= 0) then - print *, 'ERROR: FARKStepCreateMRIStepInnerStepper failed' + print *, 'ERROR: FARKodeCreateMRIStepInnerStepper failed' stop 1 end if diff --git a/include/arkode/arkode.h b/include/arkode/arkode.h index c9a154a8ed..a693916f88 100644 --- a/include/arkode/arkode.h +++ b/include/arkode/arkode.h @@ -212,6 +212,10 @@ SUNDIALS_EXPORT int ARKodeResize(void* arkode_mem, N_Vector ynew, ARKVecResizeFn resize, void* resize_data); SUNDIALS_EXPORT int ARKodeReset(void* arkode_mem, sunrealtype tR, N_Vector yR); +/* Utility to wrap ARKODE as an MRIStepInnerStepper */ +SUNDIALS_EXPORT int ARKodeCreateMRIStepInnerStepper(void* arkode_mem, + MRIStepInnerStepper* stepper); + /* Tolerance input functions */ SUNDIALS_EXPORT int ARKodeSStolerances(void* arkode_mem, sunrealtype reltol, sunrealtype abstol); diff --git a/include/arkode/arkode_arkstep.h b/include/arkode/arkode_arkstep.h index 01c1e9bf17..0ad922f1eb 100644 --- a/include/arkode/arkode_arkstep.h +++ b/include/arkode/arkode_arkstep.h @@ -96,14 +96,14 @@ SUNDIALS_EXPORT int ARKStepGetTimestepperStats( long int* step_attempts, long int* nfe_evals, long int* nfi_evals, long int* nlinsetups, long int* netfails); -/* Utility to wrap ARKStep as an MRIStepInnerStepper */ -SUNDIALS_EXPORT int ARKStepCreateMRIStepInnerStepper(void* arkode_mem, - MRIStepInnerStepper* stepper); /* -------------------------------------------------------------------------- * Deprecated Functions -- all are superseded by shared ARKODE-level routines * -------------------------------------------------------------------------- */ +SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeCreateMRIStepInnerStepper instead") +int ARKStepCreateMRIStepInnerStepper(void* arkode_mem, + MRIStepInnerStepper* stepper); SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeResize instead") int ARKStepResize(void* arkode_mem, N_Vector ynew, sunrealtype hscale, sunrealtype t0, ARKVecResizeFn resize, void* resize_data); diff --git a/include/arkode/arkode_erkstep.h b/include/arkode/arkode_erkstep.h index 8257b2f6f2..f8fd4f359f 100644 --- a/include/arkode/arkode_erkstep.h +++ b/include/arkode/arkode_erkstep.h @@ -68,9 +68,6 @@ SUNDIALS_EXPORT int ERKStepGetTimestepperStats( void* arkode_mem, long int* expsteps, long int* accsteps, long int* step_attempts, long int* nfevals, long int* netfails); -/* Utility to wrap ERKStep as an MRIStepInnerStepper */ -SUNDIALS_EXPORT int ERKStepCreateMRIStepInnerStepper(void* arkode_mem, - MRIStepInnerStepper* stepper); /* -------------------------------------------------------------------------- * Deprecated Functions -- all are superseded by shared ARKODE-level routines diff --git a/include/arkode/arkode_mristep.h b/include/arkode/arkode_mristep.h index 5f67b4f0b2..8feb45b5cc 100644 --- a/include/arkode/arkode_mristep.h +++ b/include/arkode/arkode_mristep.h @@ -226,9 +226,6 @@ SUNDIALS_EXPORT int MRIStepInnerStepper_GetForcingData( MRIStepInnerStepper stepper, sunrealtype* tshift, sunrealtype* tscale, N_Vector** forcing, int* nforcing); -/* Utility to wrap ERKStep as an MRIStepInnerStepper */ -SUNDIALS_EXPORT int MRIStepCreateMRIStepInnerStepper(void* arkode_mem, - MRIStepInnerStepper* stepper); /* -------------------------------------------------------------------------- * Deprecated Functions -- all are superseded by shared ARKODE-level routines diff --git a/src/arkode/arkode.c b/src/arkode/arkode.c index 52e92d5f2d..58c69be732 100644 --- a/src/arkode/arkode.c +++ b/src/arkode/arkode.c @@ -1351,6 +1351,68 @@ void ARKodePrintMem(void* arkode_mem, FILE* outfile) if (ark_mem->step_printmem) { ark_mem->step_printmem(ark_mem, outfile); } } +/*------------------------------------------------------------------------------ + ARKodeCreateMRIStepInnerStepper + + Wraps an ARKODE integrator as an MRIStep inner stepper. + ----------------------------------------------------------------------------*/ + +int ARKodeCreateMRIStepInnerStepper(void* inner_arkode_mem, + MRIStepInnerStepper* stepper) +{ + ARKodeMem ark_mem; + int retval; + + /* Check if ark_mem exists */ + if (inner_arkode_mem == NULL) + { + arkProcessError(NULL, ARK_MEM_NULL, __LINE__, __func__, __FILE__, + MSG_ARK_NO_MEM); + return (ARK_MEM_NULL); + } + ark_mem = (ARKodeMem)inner_arkode_mem; + + /* return with an error if the ARKODE solver does not support forcing */ + if (!ark_mem->step_supports_forcing) + { + arkProcessError(ark_mem, ARK_STEPPER_UNSUPPORTED, __LINE__, __func__, + __FILE__, "time-stepping module does not support forcing"); + return (ARK_STEPPER_UNSUPPORTED); + } + + retval = MRIStepInnerStepper_Create(ark_mem->sunctx, stepper); + if (retval != ARK_SUCCESS) { return (retval); } + + retval = MRIStepInnerStepper_SetContent(*stepper, inner_arkode_mem); + if (retval != ARK_SUCCESS) { return (retval); } + + retval = MRIStepInnerStepper_SetEvolveFn(*stepper, ark_MRIStepInnerEvolve); + if (retval != ARK_SUCCESS) { return (retval); } + + retval = MRIStepInnerStepper_SetFullRhsFn(*stepper, + ark_MRIStepInnerFullRhs); + if (retval != ARK_SUCCESS) { return (retval); } + + retval = MRIStepInnerStepper_SetResetFn(*stepper, ark_MRIStepInnerReset); + if (retval != ARK_SUCCESS) { return (retval); } + + retval = + MRIStepInnerStepper_SetAccumulatedErrorGetFn(*stepper, + ark_MRIStepInnerGetAccumulatedError); + if (retval != ARK_SUCCESS) { return (retval); } + + retval = + MRIStepInnerStepper_SetAccumulatedErrorResetFn(*stepper, + ark_MRIStepInnerResetAccumulatedError); + if (retval != ARK_SUCCESS) { return (retval); } + + retval = MRIStepInnerStepper_SetRTolFn(*stepper, ark_MRIStepInnerSetRTol); + if (retval != ARK_SUCCESS) { return (retval); } + + return (ARK_SUCCESS); +} + + /*=============================================================== Private internal functions ===============================================================*/ @@ -3592,6 +3654,183 @@ void arkProcessError(ARKodeMem ark_mem, int error_code, int line, return; } +/*--------------------------------------------------------------- + Utility routines for ARKODE to serve as an MRIStepInnerStepper + ---------------------------------------------------------------*/ + +/*------------------------------------------------------------------------------ + ark_MRIStepInnerEvolve + + Implementation of MRIStepInnerStepperEvolveFn to advance the inner (fast) + ODE IVP. + ----------------------------------------------------------------------------*/ + +int ark_MRIStepInnerEvolve(MRIStepInnerStepper stepper, + SUNDIALS_MAYBE_UNUSED sunrealtype t0, + sunrealtype tout, N_Vector y) +{ + void* arkode_mem; /* arkode memory */ + ARKodeMem ark_mem; + sunrealtype tret; /* return time */ + sunrealtype tshift, tscale; /* time normalization values */ + N_Vector* forcing; /* forcing vectors */ + int nforcing; /* number of forcing vectors */ + int retval; /* return value */ + + /* extract the ARKODE memory struct */ + retval = MRIStepInnerStepper_GetContent(stepper, &arkode_mem); + if (retval != ARK_SUCCESS) { return (retval); } + if (arkode_mem == NULL) + { + arkProcessError(NULL, ARK_MEM_NULL, __LINE__, __func__, __FILE__, + MSG_ARK_NO_MEM); + return ARK_MEM_NULL; + } + ark_mem = (ARKodeMem)arkode_mem; + + /* get the forcing data */ + retval = MRIStepInnerStepper_GetForcingData(stepper, &tshift, &tscale, + &forcing, &nforcing); + if (retval != ARK_SUCCESS) { return (retval); } + + /* set the inner forcing data */ + retval = ark_mem->step_setforcing(arkode_mem, tshift, tscale, forcing, nforcing); + if (retval != ARK_SUCCESS) { return (retval); } + + /* set the stop time */ + retval = ARKodeSetStopTime(arkode_mem, tout); + if (retval != ARK_SUCCESS) { return (retval); } + + /* evolve inner ODE */ + retval = ARKodeEvolve(arkode_mem, tout, y, &tret, ARK_NORMAL); + if (retval < 0) { return (retval); } + + /* disable inner forcing */ + retval = ark_mem->step_setforcing(arkode_mem, ZERO, ONE, NULL, 0); + if (retval != ARK_SUCCESS) { return (retval); } + + return (ARK_SUCCESS); +} + +/*------------------------------------------------------------------------------ + ark_MRIStepInnerFullRhs + + Implementation of MRIStepInnerStepperFullRhsFn to compute the full inner + (fast) ODE IVP RHS. + ----------------------------------------------------------------------------*/ + +int ark_MRIStepInnerFullRhs(MRIStepInnerStepper stepper, sunrealtype t, + N_Vector y, N_Vector f, int mode) +{ + void* arkode_mem; /* arkode memory */ + ARKodeMem ark_mem; + int retval; /* return value */ + + /* extract the ARKODE memory struct */ + retval = MRIStepInnerStepper_GetContent(stepper, &arkode_mem); + if (retval != ARK_SUCCESS) { return (retval); } + if (arkode_mem == NULL) + { + arkProcessError(NULL, ARK_MEM_NULL, __LINE__, __func__, __FILE__, + MSG_ARK_NO_MEM); + return ARK_MEM_NULL; + } + ark_mem = (ARKodeMem)arkode_mem; + + return (ark_mem->step_fullrhs(arkode_mem, t, y, f, mode)); +} + +/*------------------------------------------------------------------------------ + ark_MRIStepInnerReset + + Implementation of MRIStepInnerStepperResetFn to reset the inner (fast) stepper + state. + ----------------------------------------------------------------------------*/ + +int ark_MRIStepInnerReset(MRIStepInnerStepper stepper, sunrealtype tR, + N_Vector yR) +{ + void* arkode_mem; + int retval; + + /* extract the ARKODE memory struct */ + retval = MRIStepInnerStepper_GetContent(stepper, &arkode_mem); + if (retval != ARK_SUCCESS) { return (retval); } + + return (ARKodeReset(arkode_mem, tR, yR)); +} + +/*------------------------------------------------------------------------------ + ark_MRIStepInnerGetAccumulatedError + + Implementation of MRIStepInnerGetAccumulatedError to retrieve the accumulated + temporal error estimate from the inner (fast) stepper. + ----------------------------------------------------------------------------*/ + +int ark_MRIStepInnerGetAccumulatedError(MRIStepInnerStepper stepper, + sunrealtype* accum_error) +{ + void* arkode_mem; + int retval; + + /* extract the ARKODE memory struct */ + retval = MRIStepInnerStepper_GetContent(stepper, &arkode_mem); + if (retval != ARK_SUCCESS) { return (retval); } + + return (ARKodeGetAccumulatedError(arkode_mem, accum_error)); +} + +/*------------------------------------------------------------------------------ + ark_MRIStepInnerResetAccumulatedError + + Implementation of MRIStepInnerResetAccumulatedError to reset the accumulated + temporal error estimator in the inner (fast) stepper. + ----------------------------------------------------------------------------*/ + +int ark_MRIStepInnerResetAccumulatedError(MRIStepInnerStepper stepper) +{ + void* arkode_mem; + int retval; + + /* extract the ARKODE memory struct */ + retval = MRIStepInnerStepper_GetContent(stepper, &arkode_mem); + if (retval != ARK_SUCCESS) { return (retval); } + + return (ARKodeResetAccumulatedError(arkode_mem)); +} + +/*------------------------------------------------------------------------------ + ark_MRIStepInnerSetRTol + + Implementation of MRIStepInnerSetRTol to set a relative tolerance for the + upcoming evolution using the inner (fast) stepper. + ----------------------------------------------------------------------------*/ + +int ark_MRIStepInnerSetRTol(MRIStepInnerStepper stepper, sunrealtype rtol) +{ + void* arkode_mem; + ARKodeMem ark_mem; + int retval; + + /* extract the ARKODE memory struct */ + retval = MRIStepInnerStepper_GetContent(stepper, &arkode_mem); + if (retval != ARK_SUCCESS) { return (retval); } + if (arkode_mem == NULL) + { + arkProcessError(NULL, ARK_MEM_NULL, __LINE__, __func__, __FILE__, + MSG_ARK_NO_MEM); + return ARK_MEM_NULL; + } + ark_mem = (ARKodeMem)arkode_mem; + + if (rtol > ZERO) + { + ark_mem->reltol = rtol; + return (ARK_SUCCESS); + } + else { return (ARK_ILL_INPUT); } +} + /*=============================================================== EOF ===============================================================*/ diff --git a/src/arkode/arkode_arkstep.c b/src/arkode/arkode_arkstep.c index 1118a748d4..131309ed00 100644 --- a/src/arkode/arkode_arkstep.c +++ b/src/arkode/arkode_arkstep.c @@ -138,8 +138,10 @@ void* ARKStepCreate(ARKRhsFn fe, ARKRhsFn fi, sunrealtype t0, N_Vector y0, ark_mem->step_getnumnonlinsolviters = arkStep_GetNumNonlinSolvIters; ark_mem->step_getnumnonlinsolvconvfails = arkStep_GetNumNonlinSolvConvFails; ark_mem->step_getnonlinsolvstats = arkStep_GetNonlinSolvStats; + ark_mem->step_setforcing = arkStep_SetInnerForcing; ark_mem->step_supports_adaptive = SUNTRUE; ark_mem->step_supports_implicit = SUNTRUE; + ark_mem->step_supports_forcing = SUNTRUE; ark_mem->step_supports_massmatrix = SUNTRUE; ark_mem->step_supports_relaxation = SUNTRUE; ark_mem->step_mem = (void*)step_mem; @@ -341,59 +343,6 @@ int ARKStepReInit(void* arkode_mem, ARKRhsFn fe, ARKRhsFn fi, sunrealtype t0, return (ARK_SUCCESS); } -/*------------------------------------------------------------------------------ - ARKStepCreateMRIStepInnerStepper - - Wraps an ARKStep memory structure as an MRIStep inner stepper. - ----------------------------------------------------------------------------*/ -int ARKStepCreateMRIStepInnerStepper(void* inner_arkode_mem, - MRIStepInnerStepper* stepper) -{ - int retval; - ARKodeMem ark_mem; - ARKodeARKStepMem step_mem; - - retval = arkStep_AccessARKODEStepMem(inner_arkode_mem, - "ARKStepCreateMRIStepInnerStepper", - &ark_mem, &step_mem); - if (retval) - { - arkProcessError(NULL, ARK_ILL_INPUT, __LINE__, __func__, __FILE__, - "The ARKStep memory pointer is NULL"); - return ARK_ILL_INPUT; - } - - retval = MRIStepInnerStepper_Create(ark_mem->sunctx, stepper); - if (retval != ARK_SUCCESS) { return (retval); } - - retval = MRIStepInnerStepper_SetContent(*stepper, inner_arkode_mem); - if (retval != ARK_SUCCESS) { return (retval); } - - retval = MRIStepInnerStepper_SetEvolveFn(*stepper, arkStep_MRIStepInnerEvolve); - if (retval != ARK_SUCCESS) { return (retval); } - - retval = MRIStepInnerStepper_SetFullRhsFn(*stepper, - arkStep_MRIStepInnerFullRhs); - if (retval != ARK_SUCCESS) { return (retval); } - - retval = MRIStepInnerStepper_SetResetFn(*stepper, arkStep_MRIStepInnerReset); - if (retval != ARK_SUCCESS) { return (retval); } - - retval = - MRIStepInnerStepper_SetAccumulatedErrorGetFn(*stepper, - arkStep_MRIStepInnerGetAccumulatedError); - if (retval != ARK_SUCCESS) { return (retval); } - - retval = - MRIStepInnerStepper_SetAccumulatedErrorResetFn(*stepper, - arkStep_MRIStepInnerResetAccumulatedError); - if (retval != ARK_SUCCESS) { return (retval); } - - retval = MRIStepInnerStepper_SetRTolFn(*stepper, arkStep_MRIStepInnerSetRTol); - if (retval != ARK_SUCCESS) { return (retval); } - - return (ARK_SUCCESS); -} /*=============================================================== Interface routines supplied to ARKODE @@ -1015,7 +964,7 @@ int arkStep_Init(ARKodeMem ark_mem, int init_type) if (step_mem->implicit) { reset_efun = SUNFALSE; } if (!ark_mem->fixedstep) { reset_efun = SUNFALSE; } if (ark_mem->user_efun) { reset_efun = SUNFALSE; } - if (ark_mem->AccumErrorType >= 0) { reset_efun = SUNFALSE; } + if (ark_mem->AccumErrorType != ARK_ACCUMERROR_NONE) { reset_efun = SUNFALSE; } if (ark_mem->rwt_is_ewt && (step_mem->msolve_type == SUNLINEARSOLVER_ITERATIVE)) { @@ -1065,7 +1014,7 @@ int arkStep_Init(ARKodeMem ark_mem, int init_type) /* Ensure that if adaptivity or error accumulation is enabled, then method includes embedding coefficients */ - if ((!ark_mem->fixedstep || (ark_mem->AccumErrorType >= 0)) && + if ((!ark_mem->fixedstep || (ark_mem->AccumErrorType != ARK_ACCUMERROR_NONE)) && (step_mem->p == 0)) { arkProcessError(ark_mem, ARK_ILL_INPUT, __LINE__, __func__, @@ -2974,7 +2923,7 @@ int arkStep_ComputeSolutions(ARKodeMem ark_mem, sunrealtype* dsmPtr) } /* Compute yerr (if temporal error estimation is enabled). */ - if (!ark_mem->fixedstep || (ark_mem->AccumErrorType >= 0)) + if (!ark_mem->fixedstep || (ark_mem->AccumErrorType != ARK_ACCUMERROR_NONE)) { /* set arrays for fused vector operation */ nvec = 0; @@ -3178,163 +3127,6 @@ int arkStep_ComputeSolutions_MassFixed(ARKodeMem ark_mem, sunrealtype* dsmPtr) Internal utility routines for interacting with MRIStep ===============================================================*/ -/*------------------------------------------------------------------------------ - arkStep_MRIStepInnerEvolve - - Implementation of MRIStepInnerStepperEvolveFn to advance the inner (fast) - ODE IVP. - ----------------------------------------------------------------------------*/ - -int arkStep_MRIStepInnerEvolve(MRIStepInnerStepper stepper, - SUNDIALS_MAYBE_UNUSED sunrealtype t0, - sunrealtype tout, N_Vector y) -{ - void* arkode_mem; /* arkode memory */ - sunrealtype tret; /* return time */ - sunrealtype tshift, tscale; /* time normalization values */ - N_Vector* forcing; /* forcing vectors */ - int nforcing; /* number of forcing vectors */ - int retval; /* return value */ - - /* extract the ARKODE memory struct */ - retval = MRIStepInnerStepper_GetContent(stepper, &arkode_mem); - if (retval != ARK_SUCCESS) { return (retval); } - - /* get the forcing data */ - retval = MRIStepInnerStepper_GetForcingData(stepper, &tshift, &tscale, - &forcing, &nforcing); - if (retval != ARK_SUCCESS) { return (retval); } - - /* set the inner forcing data */ - retval = arkStep_SetInnerForcing(arkode_mem, tshift, tscale, forcing, nforcing); - if (retval != ARK_SUCCESS) { return (retval); } - - /* set the stop time */ - retval = ARKodeSetStopTime(arkode_mem, tout); - if (retval != ARK_SUCCESS) { return (retval); } - - /* evolve inner ODE */ - retval = ARKodeEvolve(arkode_mem, tout, y, &tret, ARK_NORMAL); - if (retval < 0) { return (retval); } - - /* disable inner forcing */ - retval = arkStep_SetInnerForcing(arkode_mem, ZERO, ONE, NULL, 0); - if (retval != ARK_SUCCESS) { return (retval); } - - return (ARK_SUCCESS); -} - -/*------------------------------------------------------------------------------ - arkStep_MRIStepInnerFullRhs - - Implementation of MRIStepInnerStepperFullRhsFn to compute the full inner - (fast) ODE IVP RHS. - ----------------------------------------------------------------------------*/ - -int arkStep_MRIStepInnerFullRhs(MRIStepInnerStepper stepper, sunrealtype t, - N_Vector y, N_Vector f, int mode) -{ - void* arkode_mem; - int retval; - - /* extract the ARKODE memory struct */ - retval = MRIStepInnerStepper_GetContent(stepper, &arkode_mem); - if (retval != ARK_SUCCESS) { return (retval); } - - return (arkStep_FullRHS(arkode_mem, t, y, f, mode)); -} - -/*------------------------------------------------------------------------------ - arkStep_MRIStepInnerReset - - Implementation of MRIStepInnerStepperResetFn to reset the inner (fast) stepper - state. - ----------------------------------------------------------------------------*/ - -int arkStep_MRIStepInnerReset(MRIStepInnerStepper stepper, sunrealtype tR, - N_Vector yR) -{ - void* arkode_mem; - int retval; - - /* extract the ARKODE memory struct */ - retval = MRIStepInnerStepper_GetContent(stepper, &arkode_mem); - if (retval != ARK_SUCCESS) { return (retval); } - - return (ARKodeReset(arkode_mem, tR, yR)); -} - -/*------------------------------------------------------------------------------ - arkStep_MRIStepInnerGetAccumulatedError - - Implementation of MRIStepInnerGetAccumulatedError to retrieve the accumulated - temporal error estimate from the inner (fast) stepper. - ----------------------------------------------------------------------------*/ - -int arkStep_MRIStepInnerGetAccumulatedError(MRIStepInnerStepper stepper, - sunrealtype* accum_error) -{ - void* arkode_mem; - int retval; - - /* extract the ARKODE memory struct */ - retval = MRIStepInnerStepper_GetContent(stepper, &arkode_mem); - if (retval != ARK_SUCCESS) { return (retval); } - - return (ARKodeGetAccumulatedError(arkode_mem, accum_error)); -} - -/*------------------------------------------------------------------------------ - arkStep_MRIStepInnerResetAccumulatedError - - Implementation of MRIStepInnerResetAccumulatedError to reset the accumulated - temporal error estimator in the inner (fast) stepper. - ----------------------------------------------------------------------------*/ - -int arkStep_MRIStepInnerResetAccumulatedError(MRIStepInnerStepper stepper) -{ - void* arkode_mem; - int retval; - - /* extract the ARKODE memory struct */ - retval = MRIStepInnerStepper_GetContent(stepper, &arkode_mem); - if (retval != ARK_SUCCESS) { return (retval); } - - return (ARKodeResetAccumulatedError(arkode_mem)); -} - -/*------------------------------------------------------------------------------ - arkStep_MRIStepInnerSetRTol - - Implementation of MRIStepInnerSetRTol to set a relative tolerance for the - upcoming evolution using the inner (fast) stepper. - ----------------------------------------------------------------------------*/ - -int arkStep_MRIStepInnerSetRTol(MRIStepInnerStepper stepper, sunrealtype rtol) -{ - void* arkode_mem; - ARKodeMem ark_mem; - int retval; - - /* extract the ARKODE memory struct */ - retval = MRIStepInnerStepper_GetContent(stepper, &arkode_mem); - if (retval != ARK_SUCCESS) return (retval); - if (arkode_mem == NULL) - { - arkProcessError(NULL, ARK_ILL_INPUT, __LINE__, __func__, __FILE__, - MSG_ARK_NO_MEM); - return (ARK_MEM_NULL); - } - ark_mem = (ARKodeMem)arkode_mem; - - if (rtol > ZERO) - { - ark_mem->reltol = rtol; - return (ARK_SUCCESS); - } - else { return (ARK_ILL_INPUT); } -} - /*------------------------------------------------------------------------------ arkStep_ApplyForcing diff --git a/src/arkode/arkode_arkstep_impl.h b/src/arkode/arkode_arkstep_impl.h index e53f244824..075905bb20 100644 --- a/src/arkode/arkode_arkstep_impl.h +++ b/src/arkode/arkode_arkstep_impl.h @@ -226,6 +226,8 @@ int arkStep_Resize(ARKodeMem ark_mem, N_Vector y0, sunrealtype hscale, int arkStep_ComputeState(ARKodeMem ark_mem, N_Vector zcor, N_Vector z); void arkStep_Free(ARKodeMem ark_mem); void arkStep_PrintMem(ARKodeMem ark_mem, FILE* outfile); +int arkStep_SetInnerForcing(void* arkode_mem, sunrealtype tshift, + sunrealtype tscale, N_Vector* f, int nvecs); /* Internal utility routines */ int arkStep_AccessARKODEStepMem(void* arkode_mem, const char* fname, @@ -268,19 +270,6 @@ int arkStep_NlsLSolve(N_Vector delta, void* arkode_mem); int arkStep_NlsConvTest(SUNNonlinearSolver NLS, N_Vector y, N_Vector del, sunrealtype tol, N_Vector ewt, void* arkode_mem); -/* private functions for interfacing with MRIStep */ -int arkStep_SetInnerForcing(void* arkode_mem, sunrealtype tshift, - sunrealtype tscale, N_Vector* f, int nvecs); -int arkStep_MRIStepInnerEvolve(MRIStepInnerStepper stepper, sunrealtype t0, - sunrealtype tout, N_Vector y); -int arkStep_MRIStepInnerFullRhs(MRIStepInnerStepper stepper, sunrealtype t, - N_Vector y, N_Vector f, int mode); -int arkStep_MRIStepInnerReset(MRIStepInnerStepper stepper, sunrealtype tR, - N_Vector yR); -int arkStep_MRIStepInnerGetAccumulatedError(MRIStepInnerStepper stepper, - sunrealtype* accum_error); -int arkStep_MRIStepInnerResetAccumulatedError(MRIStepInnerStepper stepper); -int arkStep_MRIStepInnerSetRTol(MRIStepInnerStepper stepper, sunrealtype rtol); /* private functions for relaxation */ int arkStep_SetRelaxFn(ARKodeMem ark_mem, ARKRelaxFn rfn, ARKRelaxJacFn rjac); diff --git a/src/arkode/arkode_arkstep_io.c b/src/arkode/arkode_arkstep_io.c index b02f904f6b..78da2108ac 100644 --- a/src/arkode/arkode_arkstep_io.c +++ b/src/arkode/arkode_arkstep_io.c @@ -1154,7 +1154,7 @@ int arkStep_GetEstLocalErrors(ARKodeMem ark_mem, N_Vector ele) if (retval != ARK_SUCCESS) { return (retval); } /* return an error if local truncation error is not computed */ - if (ark_mem->fixedstep && (ark_mem->AccumErrorType < 0)) + if (ark_mem->fixedstep && (ark_mem->AccumErrorType == ARK_ACCUMERROR_NONE)) { return (ARK_STEPPER_UNSUPPORTED); } @@ -1446,6 +1446,11 @@ int arkStep_WriteParameters(ARKodeMem ark_mem, FILE* fp) Exported-but-deprecated user-callable functions. ===============================================================*/ +int ARKStepCreateMRIStepInnerStepper(void* inner_arkode_mem, + MRIStepInnerStepper* stepper) +{ + return (ARKodeCreateMRIStepInnerStepper(inner_arkode_mem, stepper)); +} int ARKStepResize(void* arkode_mem, N_Vector y0, sunrealtype hscale, sunrealtype t0, ARKVecResizeFn resize, void* resize_data) { diff --git a/src/arkode/arkode_erkstep.c b/src/arkode/arkode_erkstep.c index cd850f6413..78d0d1e536 100644 --- a/src/arkode/arkode_erkstep.c +++ b/src/arkode/arkode_erkstep.c @@ -103,8 +103,10 @@ void* ERKStepCreate(ARKRhsFn f, sunrealtype t0, N_Vector y0, SUNContext sunctx) ark_mem->step_setrelaxfn = erkStep_SetRelaxFn; ark_mem->step_setorder = erkStep_SetOrder; ark_mem->step_getestlocalerrors = erkStep_GetEstLocalErrors; + ark_mem->step_setforcing = erkStep_SetInnerForcing; ark_mem->step_supports_adaptive = SUNTRUE; ark_mem->step_supports_relaxation = SUNTRUE; + ark_mem->step_supports_forcing = SUNTRUE; ark_mem->step_mem = (void*)step_mem; /* Set default values for optional inputs */ @@ -399,7 +401,7 @@ int erkStep_Init(ARKodeMem ark_mem, int init_type) reset_efun = SUNTRUE; if (!ark_mem->fixedstep) { reset_efun = SUNFALSE; } if (ark_mem->user_efun) { reset_efun = SUNFALSE; } - if (ark_mem->AccumErrorType >= 0) { reset_efun = SUNFALSE; } + if (ark_mem->AccumErrorType != ARK_ACCUMERROR_NONE) { reset_efun = SUNFALSE; } if (reset_efun) { ark_mem->user_efun = SUNFALSE; @@ -431,7 +433,7 @@ int erkStep_Init(ARKodeMem ark_mem, int init_type) /* Ensure that if adaptivity or error accumulation is enabled, then method includes embedding coefficients */ - if ((!ark_mem->fixedstep || (ark_mem->AccumErrorType >= 0)) && + if ((!ark_mem->fixedstep || (ark_mem->AccumErrorType != ARK_ACCUMERROR_NONE)) && (step_mem->p == 0)) { arkProcessError(ark_mem, ARK_ILL_INPUT, __LINE__, __func__, @@ -1091,7 +1093,7 @@ int erkStep_ComputeSolutions(ARKodeMem ark_mem, sunrealtype* dsmPtr) if (retval != 0) { return (ARK_VECTOROP_ERR); } /* Compute yerr (if step adaptivity or error accumulation enabled) */ - if (!ark_mem->fixedstep || (ark_mem->AccumErrorType >= 0)) + if (!ark_mem->fixedstep || (ark_mem->AccumErrorType != ARK_ACCUMERROR_NONE)) { /* set arrays for fused vector operation */ nvec = 0; @@ -1212,217 +1214,6 @@ int erkStep_GetOrder(ARKodeMem ark_mem) Utility routines for ERKStep to serve as an MRIStepInnerStepper ---------------------------------------------------------------*/ -/*------------------------------------------------------------------------------ - ERKStepCreateMRIStepInnerStepper - - Wraps an ERKStep memory structure as an MRIStep inner stepper. - ----------------------------------------------------------------------------*/ - -int ERKStepCreateMRIStepInnerStepper(void* inner_arkode_mem, - MRIStepInnerStepper* stepper) -{ - int retval; - ARKodeMem ark_mem; - ARKodeERKStepMem step_mem; - - retval = erkStep_AccessARKODEStepMem(inner_arkode_mem, __func__, &ark_mem, - &step_mem); - if (retval) - { - arkProcessError(NULL, ARK_ILL_INPUT, __LINE__, __func__, __FILE__, - "The ERKStep memory pointer is NULL"); - return ARK_ILL_INPUT; - } - - retval = MRIStepInnerStepper_Create(ark_mem->sunctx, stepper); - if (retval != ARK_SUCCESS) { return (retval); } - - retval = MRIStepInnerStepper_SetContent(*stepper, inner_arkode_mem); - if (retval != ARK_SUCCESS) { return (retval); } - - retval = MRIStepInnerStepper_SetEvolveFn(*stepper, erkStep_MRIStepInnerEvolve); - if (retval != ARK_SUCCESS) { return (retval); } - - retval = MRIStepInnerStepper_SetFullRhsFn(*stepper, - erkStep_MRIStepInnerFullRhs); - if (retval != ARK_SUCCESS) { return (retval); } - - retval = MRIStepInnerStepper_SetResetFn(*stepper, erkStep_MRIStepInnerReset); - if (retval != ARK_SUCCESS) { return (retval); } - - retval = - MRIStepInnerStepper_SetAccumulatedErrorGetFn(*stepper, - erkStep_MRIStepInnerGetAccumulatedError); - if (retval != ARK_SUCCESS) { return (retval); } - - retval = - MRIStepInnerStepper_SetAccumulatedErrorResetFn(*stepper, - erkStep_MRIStepInnerResetAccumulatedError); - if (retval != ARK_SUCCESS) { return (retval); } - - retval = MRIStepInnerStepper_SetRTolFn(*stepper, erkStep_MRIStepInnerSetRTol); - if (retval != ARK_SUCCESS) { return (retval); } - - return (ARK_SUCCESS); -} - -/*------------------------------------------------------------------------------ - erkStep_MRIStepInnerEvolve - - Implementation of MRIStepInnerStepperEvolveFn to advance the inner (fast) - ODE IVP. - ----------------------------------------------------------------------------*/ - -int erkStep_MRIStepInnerEvolve(MRIStepInnerStepper stepper, - SUNDIALS_MAYBE_UNUSED sunrealtype t0, - sunrealtype tout, N_Vector y) -{ - void* arkode_mem; /* arkode memory */ - sunrealtype tret; /* return time */ - sunrealtype tshift, tscale; /* time normalization values */ - N_Vector* forcing; /* forcing vectors */ - int nforcing; /* number of forcing vectors */ - int retval; /* return value */ - - /* extract the ARKODE memory struct */ - retval = MRIStepInnerStepper_GetContent(stepper, &arkode_mem); - if (retval != ARK_SUCCESS) { return (retval); } - - /* get the forcing data */ - retval = MRIStepInnerStepper_GetForcingData(stepper, &tshift, &tscale, - &forcing, &nforcing); - if (retval != ARK_SUCCESS) { return (retval); } - - /* set the inner forcing data */ - retval = erkStep_SetInnerForcing(arkode_mem, tshift, tscale, forcing, nforcing); - if (retval != ARK_SUCCESS) { return (retval); } - - /* set the stop time */ - retval = ARKodeSetStopTime(arkode_mem, tout); - if (retval != ARK_SUCCESS) { return (retval); } - - /* evolve inner ODE */ - retval = ARKodeEvolve(arkode_mem, tout, y, &tret, ARK_NORMAL); - if (retval < 0) { return (retval); } - - /* disable inner forcing */ - retval = erkStep_SetInnerForcing(arkode_mem, ZERO, ONE, NULL, 0); - if (retval != ARK_SUCCESS) { return (retval); } - - return (ARK_SUCCESS); -} - -/*------------------------------------------------------------------------------ - erkStep_MRIStepInnerFullRhs - - Implementation of MRIStepInnerStepperFullRhsFn to compute the full inner - (fast) ODE IVP RHS. - ----------------------------------------------------------------------------*/ - -int erkStep_MRIStepInnerFullRhs(MRIStepInnerStepper stepper, sunrealtype t, - N_Vector y, N_Vector f, int mode) -{ - void* arkode_mem; - int retval; - - /* extract the ARKODE memory struct */ - retval = MRIStepInnerStepper_GetContent(stepper, &arkode_mem); - if (retval != ARK_SUCCESS) { return (retval); } - - return (erkStep_FullRHS(arkode_mem, t, y, f, mode)); -} - -/*------------------------------------------------------------------------------ - erkStep_MRIStepInnerReset - - Implementation of MRIStepInnerStepperResetFn to reset the inner (fast) stepper - state. - ----------------------------------------------------------------------------*/ - -int erkStep_MRIStepInnerReset(MRIStepInnerStepper stepper, sunrealtype tR, - N_Vector yR) -{ - void* arkode_mem; - int retval; - - /* extract the ARKODE memory struct */ - retval = MRIStepInnerStepper_GetContent(stepper, &arkode_mem); - if (retval != ARK_SUCCESS) { return (retval); } - - return (ARKodeReset(arkode_mem, tR, yR)); -} - -/*------------------------------------------------------------------------------ - erkStep_MRIStepInnerGetAccumulatedError - - Implementation of MRIStepInnerGetAccumulatedError to retrieve the accumulated - temporal error estimate from the inner (fast) stepper. - ----------------------------------------------------------------------------*/ - -int erkStep_MRIStepInnerGetAccumulatedError(MRIStepInnerStepper stepper, - sunrealtype* accum_error) -{ - void* arkode_mem; - int retval; - - /* extract the ARKODE memory struct */ - retval = MRIStepInnerStepper_GetContent(stepper, &arkode_mem); - if (retval != ARK_SUCCESS) { return (retval); } - - return (ARKodeGetAccumulatedError(arkode_mem, accum_error)); -} - -/*------------------------------------------------------------------------------ - erkStep_MRIStepInnerResetAccumulatedError - - Implementation of MRIStepInnerResetAccumulatedError to reset the accumulated - temporal error estimator in the inner (fast) stepper. - ----------------------------------------------------------------------------*/ - -int erkStep_MRIStepInnerResetAccumulatedError(MRIStepInnerStepper stepper) -{ - void* arkode_mem; - int retval; - - /* extract the ARKODE memory struct */ - retval = MRIStepInnerStepper_GetContent(stepper, &arkode_mem); - if (retval != ARK_SUCCESS) { return (retval); } - - return (ARKodeResetAccumulatedError(arkode_mem)); -} - -/*------------------------------------------------------------------------------ - erkStep_MRIStepInnerSetRTol - - Implementation of MRIStepInnerSetRTol to set a relative tolerance for the - upcoming evolution using the inner (fast) stepper. - ----------------------------------------------------------------------------*/ - -int erkStep_MRIStepInnerSetRTol(MRIStepInnerStepper stepper, sunrealtype rtol) -{ - void* arkode_mem; - ARKodeMem ark_mem; - int retval; - - /* extract the ARKODE memory struct */ - retval = MRIStepInnerStepper_GetContent(stepper, &arkode_mem); - if (retval != ARK_SUCCESS) { return (retval); } - if (arkode_mem == NULL) - { - arkProcessError(NULL, ARK_MEM_NULL, __LINE__, __func__, __FILE__, - MSG_ERKSTEP_NO_MEM); - return ARK_MEM_NULL; - } - ark_mem = (ARKodeMem)arkode_mem; - - if (rtol > ZERO) - { - ark_mem->reltol = rtol; - return (ARK_SUCCESS); - } - else { return (ARK_ILL_INPUT); } -} - /*------------------------------------------------------------------------------ erkStep_ApplyForcing diff --git a/src/arkode/arkode_erkstep_impl.h b/src/arkode/arkode_erkstep_impl.h index bdcbe66a85..4457aaa9a4 100644 --- a/src/arkode/arkode_erkstep_impl.h +++ b/src/arkode/arkode_erkstep_impl.h @@ -22,9 +22,6 @@ #include "arkode_impl.h" -/* access to MRIStepInnerStepper_Create */ -#include "arkode/arkode_mristep.h" - #ifdef __cplusplus /* wrapper to enable C++ usage */ extern "C" { #endif @@ -93,6 +90,8 @@ int erkStep_Resize(ARKodeMem ark_mem, N_Vector y0, sunrealtype hscale, void erkStep_Free(ARKodeMem ark_mem); void erkStep_PrintMem(ARKodeMem ark_mem, FILE* outfile); int erkStep_GetEstLocalErrors(ARKodeMem ark_mem, N_Vector ele); +int erkStep_SetInnerForcing(void* arkode_mem, sunrealtype tshift, + sunrealtype tscale, N_Vector* f, int nvecs); /* Internal utility routines */ int erkStep_AccessARKODEStepMem(void* arkode_mem, const char* fname, @@ -106,20 +105,6 @@ int erkStep_ComputeSolutions(ARKodeMem ark_mem, sunrealtype* dsm); void erkStep_ApplyForcing(ARKodeERKStepMem step_mem, sunrealtype t, sunrealtype s, int* nvec); -/* private functions for interfacing with MRIStep */ -int erkStep_SetInnerForcing(void* arkode_mem, sunrealtype tshift, - sunrealtype tscale, N_Vector* f, int nvecs); -int erkStep_MRIStepInnerEvolve(MRIStepInnerStepper stepper, sunrealtype t0, - sunrealtype tout, N_Vector y); -int erkStep_MRIStepInnerFullRhs(MRIStepInnerStepper stepper, sunrealtype t, - N_Vector y, N_Vector f, int mode); -int erkStep_MRIStepInnerReset(MRIStepInnerStepper stepper, sunrealtype tR, - N_Vector yR); -int erkStep_MRIStepInnerGetAccumulatedError(MRIStepInnerStepper stepper, - sunrealtype* accum_error); -int erkStep_MRIStepInnerResetAccumulatedError(MRIStepInnerStepper stepper); -int erkStep_MRIStepInnerSetRTol(MRIStepInnerStepper stepper, sunrealtype rtol); - /* private functions for relaxation */ int erkStep_SetRelaxFn(ARKodeMem ark_mem, ARKRelaxFn rfn, ARKRelaxJacFn rjac); int erkStep_RelaxDeltaE(ARKodeMem ark_mem, ARKRelaxJacFn relax_jac_fn, diff --git a/src/arkode/arkode_erkstep_io.c b/src/arkode/arkode_erkstep_io.c index 0aaa26bfa9..35d14a5940 100644 --- a/src/arkode/arkode_erkstep_io.c +++ b/src/arkode/arkode_erkstep_io.c @@ -374,7 +374,7 @@ int erkStep_GetEstLocalErrors(ARKodeMem ark_mem, N_Vector ele) if (retval != ARK_SUCCESS) { return (retval); } /* return an error if local truncation error is not computed */ - if (ark_mem->fixedstep && (ark_mem->AccumErrorType < 0)) + if (ark_mem->fixedstep && (ark_mem->AccumErrorType == ARK_ACCUMERROR_NONE)) { return (ARK_STEPPER_UNSUPPORTED); } diff --git a/src/arkode/arkode_impl.h b/src/arkode/arkode_impl.h index 37b4981243..415f7e6e21 100644 --- a/src/arkode/arkode_impl.h +++ b/src/arkode/arkode_impl.h @@ -23,6 +23,7 @@ #include #include #include +#include #include #include #include @@ -287,6 +288,11 @@ typedef int (*ARKTimestepAttachMasssolFn)( typedef void (*ARKTimestepDisableMSetup)(ARKodeMem ark_mem); typedef void* (*ARKTimestepGetMassMemFn)(ARKodeMem ark_mem); +/* time stepper interface functions -- forcing */ +typedef int (*ARKTimestepSetForcingFn)(void* arkode_mem, sunrealtype tshift, + sunrealtype tscale, N_Vector* f, int nvecs); + + /*=============================================================== ARKODE interpolation module definition ===============================================================*/ @@ -451,6 +457,10 @@ struct ARKodeMemRec ARKTimestepGetMassMemFn step_getmassmem; ARKMassMultFn step_mmult; + /* Time stepper module -- forcing */ + sunbooleantype step_supports_forcing; + ARKTimestepSetForcingFn step_setforcing; + /* N_Vector storage */ N_Vector ewt; /* error weight vector */ N_Vector rwt; /* residual weight vector */ @@ -652,6 +662,18 @@ int arkSetAdaptivityFn(void* arkode_mem, ARKAdaptFn hfun, void* h_data); ARKODE_DIRKTableID arkButcherTableDIRKNameToID(const char* imethod); ARKODE_ERKTableID arkButcherTableERKNameToID(const char* emethod); +/* utility functions for wrapping ARKODE as an MRIStep inner stepper */ +int ark_MRIStepInnerEvolve(MRIStepInnerStepper stepper, sunrealtype t0, + sunrealtype tout, N_Vector y); +int ark_MRIStepInnerFullRhs(MRIStepInnerStepper stepper, sunrealtype t, + N_Vector y, N_Vector f, int mode); +int ark_MRIStepInnerReset(MRIStepInnerStepper stepper, sunrealtype tR, + N_Vector yR); +int ark_MRIStepInnerGetAccumulatedError(MRIStepInnerStepper stepper, + sunrealtype* accum_error); +int ark_MRIStepInnerResetAccumulatedError(MRIStepInnerStepper stepper); +int ark_MRIStepInnerSetRTol(MRIStepInnerStepper stepper, sunrealtype rtol); + /* XBraid interface functions */ int arkSetForcePass(void* arkode_mem, sunbooleantype force_pass); int arkGetLastKFlag(void* arkode_mem, int* last_kflag); diff --git a/src/arkode/arkode_mristep.c b/src/arkode/arkode_mristep.c index b1a9f9420e..bb1d3493b4 100644 --- a/src/arkode/arkode_mristep.c +++ b/src/arkode/arkode_mristep.c @@ -138,8 +138,10 @@ void* MRIStepCreate(ARKRhsFn fse, ARKRhsFn fsi, sunrealtype t0, N_Vector y0, ark_mem->step_getnumnonlinsolviters = mriStep_GetNumNonlinSolvIters; ark_mem->step_getnumnonlinsolvconvfails = mriStep_GetNumNonlinSolvConvFails; ark_mem->step_getnonlinsolvstats = mriStep_GetNonlinSolvStats; + ark_mem->step_setforcing = mriStep_SetInnerForcing; ark_mem->step_supports_adaptive = SUNTRUE; ark_mem->step_supports_implicit = SUNTRUE; + ark_mem->step_supports_forcing = SUNTRUE; ark_mem->step_mem = (void*)step_mem; /* Set default values for optional inputs */ @@ -4635,217 +4637,6 @@ void mriStepInnerStepper_PrintMem(MRIStepInnerStepper stepper, FILE* outfile) Utility routines for MRIStep to serve as an MRIStepInnerStepper ---------------------------------------------------------------*/ -/*------------------------------------------------------------------------------ - MRiStepCreateMRIStepInnerStepper - - Wraps an MRIStep memory structure as an MRIStep inner stepper. - ----------------------------------------------------------------------------*/ - -int MRIStepCreateMRIStepInnerStepper(void* inner_arkode_mem, - MRIStepInnerStepper* stepper) -{ - int retval; - ARKodeMem ark_mem; - ARKodeMRIStepMem step_mem; - - retval = mriStep_AccessARKODEStepMem(inner_arkode_mem, __func__, &ark_mem, - &step_mem); - if (retval) - { - arkProcessError(NULL, ARK_ILL_INPUT, __LINE__, __func__, __FILE__, - "The MRIStep memory pointer is NULL"); - return ARK_ILL_INPUT; - } - - retval = MRIStepInnerStepper_Create(ark_mem->sunctx, stepper); - if (retval != ARK_SUCCESS) { return (retval); } - - retval = MRIStepInnerStepper_SetContent(*stepper, inner_arkode_mem); - if (retval != ARK_SUCCESS) { return (retval); } - - retval = MRIStepInnerStepper_SetEvolveFn(*stepper, mriStep_MRIStepInnerEvolve); - if (retval != ARK_SUCCESS) { return (retval); } - - retval = MRIStepInnerStepper_SetFullRhsFn(*stepper, - mriStep_MRIStepInnerFullRhs); - if (retval != ARK_SUCCESS) { return (retval); } - - retval = MRIStepInnerStepper_SetResetFn(*stepper, mriStep_MRIStepInnerReset); - if (retval != ARK_SUCCESS) { return (retval); } - - retval = - MRIStepInnerStepper_SetAccumulatedErrorGetFn(*stepper, - mriStep_MRIStepInnerGetAccumulatedError); - if (retval != ARK_SUCCESS) { return (retval); } - - retval = - MRIStepInnerStepper_SetAccumulatedErrorResetFn(*stepper, - mriStep_MRIStepInnerResetAccumulatedError); - if (retval != ARK_SUCCESS) { return (retval); } - - retval = MRIStepInnerStepper_SetRTolFn(*stepper, mriStep_MRIStepInnerSetRTol); - if (retval != ARK_SUCCESS) { return (retval); } - - return (ARK_SUCCESS); -} - -/*------------------------------------------------------------------------------ - mriStep_MRIStepInnerEvolve - - Implementation of MRIStepInnerStepperEvolveFn to advance the inner (fast) - ODE IVP. - ----------------------------------------------------------------------------*/ - -int mriStep_MRIStepInnerEvolve(MRIStepInnerStepper stepper, - SUNDIALS_MAYBE_UNUSED sunrealtype t0, - sunrealtype tout, N_Vector y) -{ - void* arkode_mem; /* arkode memory */ - sunrealtype tret; /* return time */ - sunrealtype tshift, tscale; /* time normalization values */ - N_Vector* forcing; /* forcing vectors */ - int nforcing; /* number of forcing vectors */ - int retval; /* return value */ - - /* extract the ARKODE memory struct */ - retval = MRIStepInnerStepper_GetContent(stepper, &arkode_mem); - if (retval != ARK_SUCCESS) { return (retval); } - - /* get the forcing data */ - retval = MRIStepInnerStepper_GetForcingData(stepper, &tshift, &tscale, - &forcing, &nforcing); - if (retval != ARK_SUCCESS) { return (retval); } - - /* set the inner forcing data */ - retval = mriStep_SetInnerForcing(arkode_mem, tshift, tscale, forcing, nforcing); - if (retval != ARK_SUCCESS) { return (retval); } - - /* set the stop time */ - retval = ARKodeSetStopTime(arkode_mem, tout); - if (retval != ARK_SUCCESS) { return (retval); } - - /* evolve inner ODE */ - retval = ARKodeEvolve(arkode_mem, tout, y, &tret, ARK_NORMAL); - if (retval < 0) { return (retval); } - - /* disable inner forcing */ - retval = mriStep_SetInnerForcing(arkode_mem, ZERO, ONE, NULL, 0); - if (retval != ARK_SUCCESS) { return (retval); } - - return (ARK_SUCCESS); -} - -/*------------------------------------------------------------------------------ - mriStep_MRIStepInnerFullRhs - - Implementation of MRIStepInnerStepperFullRhsFn to compute the full inner - (fast) ODE IVP RHS. - ----------------------------------------------------------------------------*/ - -int mriStep_MRIStepInnerFullRhs(MRIStepInnerStepper stepper, sunrealtype t, - N_Vector y, N_Vector f, int mode) -{ - void* arkode_mem; - int retval; - - /* extract the ARKODE memory struct */ - retval = MRIStepInnerStepper_GetContent(stepper, &arkode_mem); - if (retval != ARK_SUCCESS) { return (retval); } - - return (mriStep_FullRHS(arkode_mem, t, y, f, mode)); -} - -/*------------------------------------------------------------------------------ - mriStep_MRIStepInnerReset - - Implementation of MRIStepInnerStepperResetFn to reset the inner (fast) stepper - state. - ----------------------------------------------------------------------------*/ - -int mriStep_MRIStepInnerReset(MRIStepInnerStepper stepper, sunrealtype tR, - N_Vector yR) -{ - void* arkode_mem; - int retval; - - /* extract the ARKODE memory struct */ - retval = MRIStepInnerStepper_GetContent(stepper, &arkode_mem); - if (retval != ARK_SUCCESS) { return (retval); } - - return (ARKodeReset(arkode_mem, tR, yR)); -} - -/*------------------------------------------------------------------------------ - mriStep_MRIStepInnerGetAccumulatedError - - Implementation of MRIStepInnerGetAccumulatedError to retrieve the accumulated - temporal error estimate from the inner (fast) stepper. - ----------------------------------------------------------------------------*/ - -int mriStep_MRIStepInnerGetAccumulatedError(MRIStepInnerStepper stepper, - sunrealtype* accum_error) -{ - void* arkode_mem; - int retval; - - /* extract the ARKODE memory struct */ - retval = MRIStepInnerStepper_GetContent(stepper, &arkode_mem); - if (retval != ARK_SUCCESS) { return (retval); } - - return (ARKodeGetAccumulatedError(arkode_mem, accum_error)); -} - -/*------------------------------------------------------------------------------ - mriStep_MRIStepInnerResetAccumulatedError - - Implementation of MRIStepInnerResetAccumulatedError to reset the accumulated - temporal error estimator in the inner (fast) stepper. - ----------------------------------------------------------------------------*/ - -int mriStep_MRIStepInnerResetAccumulatedError(MRIStepInnerStepper stepper) -{ - void* arkode_mem; - int retval; - - /* extract the ARKODE memory struct */ - retval = MRIStepInnerStepper_GetContent(stepper, &arkode_mem); - if (retval != ARK_SUCCESS) { return (retval); } - - return (ARKodeResetAccumulatedError(arkode_mem)); -} - -/*------------------------------------------------------------------------------ - mriStep_MRIStepInnerSetRTol - - Implementation of MRIStepInnerSetRTol to set a relative tolerance for the - upcoming evolution using the inner (fast) stepper. - ----------------------------------------------------------------------------*/ - -int mriStep_MRIStepInnerSetRTol(MRIStepInnerStepper stepper, sunrealtype rtol) -{ - void* arkode_mem; - ARKodeMem ark_mem; - int retval; - - /* extract the ARKODE memory struct */ - retval = MRIStepInnerStepper_GetContent(stepper, &arkode_mem); - if (retval != ARK_SUCCESS) { return (retval); } - if (arkode_mem == NULL) - { - arkProcessError(NULL, ARK_MEM_NULL, __LINE__, __func__, __FILE__, - MSG_MRISTEP_NO_MEM); - return ARK_MEM_NULL; - } - ark_mem = (ARKodeMem)arkode_mem; - - if (rtol > ZERO) - { - ark_mem->reltol = rtol; - return (ARK_SUCCESS); - } - else { return (ARK_ILL_INPUT); } -} - /*------------------------------------------------------------------------------ mriStep_ApplyForcing diff --git a/src/arkode/arkode_mristep_impl.h b/src/arkode/arkode_mristep_impl.h index ff193212df..656a387d55 100644 --- a/src/arkode/arkode_mristep_impl.h +++ b/src/arkode/arkode_mristep_impl.h @@ -259,6 +259,8 @@ int mriStep_Resize(ARKodeMem ark_mem, N_Vector y0, sunrealtype hscale, int mriStep_ComputeState(ARKodeMem ark_mem, N_Vector zcor, N_Vector z); void mriStep_Free(ARKodeMem ark_mem); void mriStep_PrintMem(ARKodeMem ark_mem, FILE* outfile); +int mriStep_SetInnerForcing(void* arkode_mem, sunrealtype tshift, + sunrealtype tscale, N_Vector* f, int nvecs); /* Internal utility routines */ int mriStep_AccessARKODEStepMem(void* arkode_mem, const char* fname, @@ -329,19 +331,6 @@ int mriStep_ComputeInnerForcing(ARKodeMem ark_mem, ARKodeMRIStepMem step_mem, int mriStep_RKCoeffs(MRIStepCoupling MRIC, int is, int* stage_map, sunrealtype* Ae_row, sunrealtype* Ai_row); -/* private functions for serving as an MRIStepInnerStepper */ -int mriStep_SetInnerForcing(void* arkode_mem, sunrealtype tshift, - sunrealtype tscale, N_Vector* f, int nvecs); -int mriStep_MRIStepInnerEvolve(MRIStepInnerStepper stepper, sunrealtype t0, - sunrealtype tout, N_Vector y); -int mriStep_MRIStepInnerFullRhs(MRIStepInnerStepper stepper, sunrealtype t, - N_Vector y, N_Vector f, int mode); -int mriStep_MRIStepInnerReset(MRIStepInnerStepper stepper, sunrealtype tR, - N_Vector yR); -int mriStep_MRIStepInnerGetAccumulatedError(MRIStepInnerStepper stepper, - sunrealtype* accum_error); -int mriStep_MRIStepInnerResetAccumulatedError(MRIStepInnerStepper stepper); -int mriStep_MRIStepInnerSetRTol(MRIStepInnerStepper stepper, sunrealtype rtol); /*=============================================================== MRIStep SUNAdaptController wrapper module -- this is used to diff --git a/src/arkode/arkode_mristep_io.c b/src/arkode/arkode_mristep_io.c index 49f0a9c1fd..e7b4b50f20 100644 --- a/src/arkode/arkode_mristep_io.c +++ b/src/arkode/arkode_mristep_io.c @@ -633,7 +633,7 @@ int mriStep_GetEstLocalErrors(ARKodeMem ark_mem, N_Vector ele) if (retval != ARK_SUCCESS) { return (retval); } /* return an error if local truncation error is not computed */ - if (ark_mem->fixedstep && (ark_mem->AccumErrorType < 0)) + if (ark_mem->fixedstep && (ark_mem->AccumErrorType == ARK_ACCUMERROR_NONE)) { return (ARK_STEPPER_UNSUPPORTED); } diff --git a/src/arkode/fmod_int32/farkode_arkstep_mod.c b/src/arkode/fmod_int32/farkode_arkstep_mod.c index 4791bedcdc..38e7da3c29 100644 --- a/src/arkode/fmod_int32/farkode_arkstep_mod.c +++ b/src/arkode/fmod_int32/farkode_arkstep_mod.c @@ -419,20 +419,6 @@ SWIGEXPORT int _wrap_FARKStepGetTimestepperStats(void *farg1, long *farg2, long } -SWIGEXPORT int _wrap_FARKStepCreateMRIStepInnerStepper(void *farg1, void *farg2) { - int fresult ; - void *arg1 = (void *) 0 ; - MRIStepInnerStepper *arg2 = (MRIStepInnerStepper *) 0 ; - int result; - - arg1 = (void *)(farg1); - arg2 = (MRIStepInnerStepper *)(farg2); - result = (int)ARKStepCreateMRIStepInnerStepper(arg1,arg2); - fresult = (int)(result); - return fresult; -} - - SWIGEXPORT int _wrap_FARKStepResize(void *farg1, N_Vector farg2, double const *farg3, double const *farg4, ARKVecResizeFn farg5, void *farg6) { int fresult ; void *arg1 = (void *) 0 ; diff --git a/src/arkode/fmod_int32/farkode_arkstep_mod.f90 b/src/arkode/fmod_int32/farkode_arkstep_mod.f90 index cc0373f1eb..fe9a9d28f0 100644 --- a/src/arkode/fmod_int32/farkode_arkstep_mod.f90 +++ b/src/arkode/fmod_int32/farkode_arkstep_mod.f90 @@ -63,7 +63,6 @@ module farkode_arkstep_mod public :: FARKStepGetNumRhsEvals public :: FARKStepGetCurrentButcherTables public :: FARKStepGetTimestepperStats - public :: FARKStepCreateMRIStepInnerStepper public :: FARKStepResize public :: FARKStepReset public :: FARKStepSStolerances @@ -337,15 +336,6 @@ function swigc_FARKStepGetTimestepperStats(farg1, farg2, farg3, farg4, farg5, fa integer(C_INT) :: fresult end function -function swigc_FARKStepCreateMRIStepInnerStepper(farg1, farg2) & -bind(C, name="_wrap_FARKStepCreateMRIStepInnerStepper") & -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_FARKStepResize(farg1, farg2, farg3, farg4, farg5, farg6) & bind(C, name="_wrap_FARKStepResize") & result(fresult) @@ -2022,22 +2012,6 @@ function FARKStepGetTimestepperStats(arkode_mem, expsteps, accsteps, step_attemp swig_result = fresult end function -function FARKStepCreateMRIStepInnerStepper(arkode_mem, stepper) & -result(swig_result) -use, intrinsic :: ISO_C_BINDING -integer(C_INT) :: swig_result -type(C_PTR) :: arkode_mem -type(C_PTR), target, intent(inout) :: stepper -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 - -farg1 = arkode_mem -farg2 = c_loc(stepper) -fresult = swigc_FARKStepCreateMRIStepInnerStepper(farg1, farg2) -swig_result = fresult -end function - function FARKStepResize(arkode_mem, ynew, hscale, t0, resize, resize_data) & result(swig_result) use, intrinsic :: ISO_C_BINDING diff --git a/src/arkode/fmod_int32/farkode_erkstep_mod.c b/src/arkode/fmod_int32/farkode_erkstep_mod.c index d475e25e44..5def57befc 100644 --- a/src/arkode/fmod_int32/farkode_erkstep_mod.c +++ b/src/arkode/fmod_int32/farkode_erkstep_mod.c @@ -361,20 +361,6 @@ SWIGEXPORT int _wrap_FERKStepGetTimestepperStats(void *farg1, long *farg2, long } -SWIGEXPORT int _wrap_FERKStepCreateMRIStepInnerStepper(void *farg1, void *farg2) { - int fresult ; - void *arg1 = (void *) 0 ; - MRIStepInnerStepper *arg2 = (MRIStepInnerStepper *) 0 ; - int result; - - arg1 = (void *)(farg1); - arg2 = (MRIStepInnerStepper *)(farg2); - result = (int)ERKStepCreateMRIStepInnerStepper(arg1,arg2); - fresult = (int)(result); - return fresult; -} - - SWIGEXPORT int _wrap_FERKStepResize(void *farg1, N_Vector farg2, double const *farg3, double const *farg4, ARKVecResizeFn farg5, void *farg6) { int fresult ; void *arg1 = (void *) 0 ; diff --git a/src/arkode/fmod_int32/farkode_erkstep_mod.f90 b/src/arkode/fmod_int32/farkode_erkstep_mod.f90 index 147a7692ac..291dc643d5 100644 --- a/src/arkode/fmod_int32/farkode_erkstep_mod.f90 +++ b/src/arkode/fmod_int32/farkode_erkstep_mod.f90 @@ -47,7 +47,6 @@ module farkode_erkstep_mod public :: FERKStepGetNumRhsEvals public :: FERKStepGetCurrentButcherTable public :: FERKStepGetTimestepperStats - public :: FERKStepCreateMRIStepInnerStepper public :: FERKStepResize public :: FERKStepReset public :: FERKStepSStolerances @@ -215,15 +214,6 @@ function swigc_FERKStepGetTimestepperStats(farg1, farg2, farg3, farg4, farg5, fa integer(C_INT) :: fresult end function -function swigc_FERKStepCreateMRIStepInnerStepper(farg1, farg2) & -bind(C, name="_wrap_FERKStepCreateMRIStepInnerStepper") & -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_FERKStepResize(farg1, farg2, farg3, farg4, farg5, farg6) & bind(C, name="_wrap_FERKStepResize") & result(fresult) @@ -1171,22 +1161,6 @@ function FERKStepGetTimestepperStats(arkode_mem, expsteps, accsteps, step_attemp swig_result = fresult end function -function FERKStepCreateMRIStepInnerStepper(arkode_mem, stepper) & -result(swig_result) -use, intrinsic :: ISO_C_BINDING -integer(C_INT) :: swig_result -type(C_PTR) :: arkode_mem -type(C_PTR), target, intent(inout) :: stepper -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 - -farg1 = arkode_mem -farg2 = c_loc(stepper) -fresult = swigc_FERKStepCreateMRIStepInnerStepper(farg1, farg2) -swig_result = fresult -end function - function FERKStepResize(arkode_mem, ynew, hscale, t0, resize, resize_data) & result(swig_result) use, intrinsic :: ISO_C_BINDING diff --git a/src/arkode/fmod_int32/farkode_mod.c b/src/arkode/fmod_int32/farkode_mod.c index 911e666192..a53be5b81c 100644 --- a/src/arkode/fmod_int32/farkode_mod.c +++ b/src/arkode/fmod_int32/farkode_mod.c @@ -353,6 +353,20 @@ SWIGEXPORT int _wrap_FARKodeReset(void *farg1, double const *farg2, N_Vector far } +SWIGEXPORT int _wrap_FARKodeCreateMRIStepInnerStepper(void *farg1, void *farg2) { + int fresult ; + void *arg1 = (void *) 0 ; + MRIStepInnerStepper *arg2 = (MRIStepInnerStepper *) 0 ; + int result; + + arg1 = (void *)(farg1); + arg2 = (MRIStepInnerStepper *)(farg2); + result = (int)ARKodeCreateMRIStepInnerStepper(arg1,arg2); + fresult = (int)(result); + return fresult; +} + + SWIGEXPORT int _wrap_FARKodeSStolerances(void *farg1, double const *farg2, double const *farg3) { int fresult ; void *arg1 = (void *) 0 ; diff --git a/src/arkode/fmod_int32/farkode_mod.f90 b/src/arkode/fmod_int32/farkode_mod.f90 index e2645bed83..1f6c51639d 100644 --- a/src/arkode/fmod_int32/farkode_mod.f90 +++ b/src/arkode/fmod_int32/farkode_mod.f90 @@ -113,6 +113,7 @@ module farkode_mod public :: ARK_ACCUMERROR_NONE, ARK_ACCUMERROR_MAX, ARK_ACCUMERROR_SUM, ARK_ACCUMERROR_AVG public :: FARKodeResize public :: FARKodeReset + public :: FARKodeCreateMRIStepInnerStepper public :: FARKodeSStolerances public :: FARKodeSVtolerances public :: FARKodeWFtolerances @@ -493,6 +494,15 @@ function swigc_FARKodeReset(farg1, farg2, farg3) & integer(C_INT) :: fresult end function +function swigc_FARKodeCreateMRIStepInnerStepper(farg1, farg2) & +bind(C, name="_wrap_FARKodeCreateMRIStepInnerStepper") & +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_FARKodeSStolerances(farg1, farg2, farg3) & bind(C, name="_wrap_FARKodeSStolerances") & result(fresult) @@ -2454,6 +2464,22 @@ function FARKodeReset(arkode_mem, tr, yr) & swig_result = fresult end function +function FARKodeCreateMRIStepInnerStepper(arkode_mem, stepper) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(C_PTR) :: arkode_mem +type(C_PTR), target, intent(inout) :: stepper +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 + +farg1 = arkode_mem +farg2 = c_loc(stepper) +fresult = swigc_FARKodeCreateMRIStepInnerStepper(farg1, farg2) +swig_result = fresult +end function + function FARKodeSStolerances(arkode_mem, reltol, abstol) & result(swig_result) use, intrinsic :: ISO_C_BINDING diff --git a/src/arkode/fmod_int32/farkode_mristep_mod.c b/src/arkode/fmod_int32/farkode_mristep_mod.c index 947c6d14b1..067677e3a5 100644 --- a/src/arkode/fmod_int32/farkode_mristep_mod.c +++ b/src/arkode/fmod_int32/farkode_mristep_mod.c @@ -1017,20 +1017,6 @@ SWIGEXPORT int _wrap_FMRIStepInnerStepper_GetForcingData(void *farg1, double *fa } -SWIGEXPORT int _wrap_FMRIStepCreateMRIStepInnerStepper(void *farg1, void *farg2) { - int fresult ; - void *arg1 = (void *) 0 ; - MRIStepInnerStepper *arg2 = (MRIStepInnerStepper *) 0 ; - int result; - - arg1 = (void *)(farg1); - arg2 = (MRIStepInnerStepper *)(farg2); - result = (int)MRIStepCreateMRIStepInnerStepper(arg1,arg2); - fresult = (int)(result); - return fresult; -} - - SWIGEXPORT int _wrap_FMRIStepResize(void *farg1, N_Vector farg2, double const *farg3, ARKVecResizeFn farg4, void *farg5) { int fresult ; void *arg1 = (void *) 0 ; diff --git a/src/arkode/fmod_int32/farkode_mristep_mod.f90 b/src/arkode/fmod_int32/farkode_mristep_mod.f90 index 34961cddba..a155838ff7 100644 --- a/src/arkode/fmod_int32/farkode_mristep_mod.f90 +++ b/src/arkode/fmod_int32/farkode_mristep_mod.f90 @@ -168,7 +168,6 @@ module farkode_mristep_mod public :: FMRIStepInnerStepper_SetRTolFn public :: FMRIStepInnerStepper_AddForcing public :: FMRIStepInnerStepper_GetForcingData - public :: FMRIStepCreateMRIStepInnerStepper public :: FMRIStepResize public :: FMRIStepReset public :: FMRIStepSStolerances @@ -730,15 +729,6 @@ function swigc_FMRIStepInnerStepper_GetForcingData(farg1, farg2, farg3, farg4, f integer(C_INT) :: fresult end function -function swigc_FMRIStepCreateMRIStepInnerStepper(farg1, farg2) & -bind(C, name="_wrap_FMRIStepCreateMRIStepInnerStepper") & -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_FMRIStepResize(farg1, farg2, farg3, farg4, farg5) & bind(C, name="_wrap_FMRIStepResize") & result(fresult) @@ -2350,22 +2340,6 @@ function FMRIStepInnerStepper_GetForcingData(stepper, tshift, tscale, forcing, n swig_result = fresult end function -function FMRIStepCreateMRIStepInnerStepper(arkode_mem, stepper) & -result(swig_result) -use, intrinsic :: ISO_C_BINDING -integer(C_INT) :: swig_result -type(C_PTR) :: arkode_mem -type(C_PTR), target, intent(inout) :: stepper -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 - -farg1 = arkode_mem -farg2 = c_loc(stepper) -fresult = swigc_FMRIStepCreateMRIStepInnerStepper(farg1, farg2) -swig_result = fresult -end function - function FMRIStepResize(arkode_mem, ynew, t0, resize, resize_data) & result(swig_result) use, intrinsic :: ISO_C_BINDING diff --git a/src/arkode/fmod_int64/farkode_arkstep_mod.c b/src/arkode/fmod_int64/farkode_arkstep_mod.c index 4791bedcdc..38e7da3c29 100644 --- a/src/arkode/fmod_int64/farkode_arkstep_mod.c +++ b/src/arkode/fmod_int64/farkode_arkstep_mod.c @@ -419,20 +419,6 @@ SWIGEXPORT int _wrap_FARKStepGetTimestepperStats(void *farg1, long *farg2, long } -SWIGEXPORT int _wrap_FARKStepCreateMRIStepInnerStepper(void *farg1, void *farg2) { - int fresult ; - void *arg1 = (void *) 0 ; - MRIStepInnerStepper *arg2 = (MRIStepInnerStepper *) 0 ; - int result; - - arg1 = (void *)(farg1); - arg2 = (MRIStepInnerStepper *)(farg2); - result = (int)ARKStepCreateMRIStepInnerStepper(arg1,arg2); - fresult = (int)(result); - return fresult; -} - - SWIGEXPORT int _wrap_FARKStepResize(void *farg1, N_Vector farg2, double const *farg3, double const *farg4, ARKVecResizeFn farg5, void *farg6) { int fresult ; void *arg1 = (void *) 0 ; diff --git a/src/arkode/fmod_int64/farkode_arkstep_mod.f90 b/src/arkode/fmod_int64/farkode_arkstep_mod.f90 index cc0373f1eb..fe9a9d28f0 100644 --- a/src/arkode/fmod_int64/farkode_arkstep_mod.f90 +++ b/src/arkode/fmod_int64/farkode_arkstep_mod.f90 @@ -63,7 +63,6 @@ module farkode_arkstep_mod public :: FARKStepGetNumRhsEvals public :: FARKStepGetCurrentButcherTables public :: FARKStepGetTimestepperStats - public :: FARKStepCreateMRIStepInnerStepper public :: FARKStepResize public :: FARKStepReset public :: FARKStepSStolerances @@ -337,15 +336,6 @@ function swigc_FARKStepGetTimestepperStats(farg1, farg2, farg3, farg4, farg5, fa integer(C_INT) :: fresult end function -function swigc_FARKStepCreateMRIStepInnerStepper(farg1, farg2) & -bind(C, name="_wrap_FARKStepCreateMRIStepInnerStepper") & -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_FARKStepResize(farg1, farg2, farg3, farg4, farg5, farg6) & bind(C, name="_wrap_FARKStepResize") & result(fresult) @@ -2022,22 +2012,6 @@ function FARKStepGetTimestepperStats(arkode_mem, expsteps, accsteps, step_attemp swig_result = fresult end function -function FARKStepCreateMRIStepInnerStepper(arkode_mem, stepper) & -result(swig_result) -use, intrinsic :: ISO_C_BINDING -integer(C_INT) :: swig_result -type(C_PTR) :: arkode_mem -type(C_PTR), target, intent(inout) :: stepper -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 - -farg1 = arkode_mem -farg2 = c_loc(stepper) -fresult = swigc_FARKStepCreateMRIStepInnerStepper(farg1, farg2) -swig_result = fresult -end function - function FARKStepResize(arkode_mem, ynew, hscale, t0, resize, resize_data) & result(swig_result) use, intrinsic :: ISO_C_BINDING diff --git a/src/arkode/fmod_int64/farkode_erkstep_mod.c b/src/arkode/fmod_int64/farkode_erkstep_mod.c index d475e25e44..5def57befc 100644 --- a/src/arkode/fmod_int64/farkode_erkstep_mod.c +++ b/src/arkode/fmod_int64/farkode_erkstep_mod.c @@ -361,20 +361,6 @@ SWIGEXPORT int _wrap_FERKStepGetTimestepperStats(void *farg1, long *farg2, long } -SWIGEXPORT int _wrap_FERKStepCreateMRIStepInnerStepper(void *farg1, void *farg2) { - int fresult ; - void *arg1 = (void *) 0 ; - MRIStepInnerStepper *arg2 = (MRIStepInnerStepper *) 0 ; - int result; - - arg1 = (void *)(farg1); - arg2 = (MRIStepInnerStepper *)(farg2); - result = (int)ERKStepCreateMRIStepInnerStepper(arg1,arg2); - fresult = (int)(result); - return fresult; -} - - SWIGEXPORT int _wrap_FERKStepResize(void *farg1, N_Vector farg2, double const *farg3, double const *farg4, ARKVecResizeFn farg5, void *farg6) { int fresult ; void *arg1 = (void *) 0 ; diff --git a/src/arkode/fmod_int64/farkode_erkstep_mod.f90 b/src/arkode/fmod_int64/farkode_erkstep_mod.f90 index 147a7692ac..291dc643d5 100644 --- a/src/arkode/fmod_int64/farkode_erkstep_mod.f90 +++ b/src/arkode/fmod_int64/farkode_erkstep_mod.f90 @@ -47,7 +47,6 @@ module farkode_erkstep_mod public :: FERKStepGetNumRhsEvals public :: FERKStepGetCurrentButcherTable public :: FERKStepGetTimestepperStats - public :: FERKStepCreateMRIStepInnerStepper public :: FERKStepResize public :: FERKStepReset public :: FERKStepSStolerances @@ -215,15 +214,6 @@ function swigc_FERKStepGetTimestepperStats(farg1, farg2, farg3, farg4, farg5, fa integer(C_INT) :: fresult end function -function swigc_FERKStepCreateMRIStepInnerStepper(farg1, farg2) & -bind(C, name="_wrap_FERKStepCreateMRIStepInnerStepper") & -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_FERKStepResize(farg1, farg2, farg3, farg4, farg5, farg6) & bind(C, name="_wrap_FERKStepResize") & result(fresult) @@ -1171,22 +1161,6 @@ function FERKStepGetTimestepperStats(arkode_mem, expsteps, accsteps, step_attemp swig_result = fresult end function -function FERKStepCreateMRIStepInnerStepper(arkode_mem, stepper) & -result(swig_result) -use, intrinsic :: ISO_C_BINDING -integer(C_INT) :: swig_result -type(C_PTR) :: arkode_mem -type(C_PTR), target, intent(inout) :: stepper -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 - -farg1 = arkode_mem -farg2 = c_loc(stepper) -fresult = swigc_FERKStepCreateMRIStepInnerStepper(farg1, farg2) -swig_result = fresult -end function - function FERKStepResize(arkode_mem, ynew, hscale, t0, resize, resize_data) & result(swig_result) use, intrinsic :: ISO_C_BINDING diff --git a/src/arkode/fmod_int64/farkode_mod.c b/src/arkode/fmod_int64/farkode_mod.c index f993cbe05a..e86a453a22 100644 --- a/src/arkode/fmod_int64/farkode_mod.c +++ b/src/arkode/fmod_int64/farkode_mod.c @@ -353,6 +353,20 @@ SWIGEXPORT int _wrap_FARKodeReset(void *farg1, double const *farg2, N_Vector far } +SWIGEXPORT int _wrap_FARKodeCreateMRIStepInnerStepper(void *farg1, void *farg2) { + int fresult ; + void *arg1 = (void *) 0 ; + MRIStepInnerStepper *arg2 = (MRIStepInnerStepper *) 0 ; + int result; + + arg1 = (void *)(farg1); + arg2 = (MRIStepInnerStepper *)(farg2); + result = (int)ARKodeCreateMRIStepInnerStepper(arg1,arg2); + fresult = (int)(result); + return fresult; +} + + SWIGEXPORT int _wrap_FARKodeSStolerances(void *farg1, double const *farg2, double const *farg3) { int fresult ; void *arg1 = (void *) 0 ; diff --git a/src/arkode/fmod_int64/farkode_mod.f90 b/src/arkode/fmod_int64/farkode_mod.f90 index 92ca85969d..f634c8c2c4 100644 --- a/src/arkode/fmod_int64/farkode_mod.f90 +++ b/src/arkode/fmod_int64/farkode_mod.f90 @@ -113,6 +113,7 @@ module farkode_mod public :: ARK_ACCUMERROR_NONE, ARK_ACCUMERROR_MAX, ARK_ACCUMERROR_SUM, ARK_ACCUMERROR_AVG public :: FARKodeResize public :: FARKodeReset + public :: FARKodeCreateMRIStepInnerStepper public :: FARKodeSStolerances public :: FARKodeSVtolerances public :: FARKodeWFtolerances @@ -493,6 +494,15 @@ function swigc_FARKodeReset(farg1, farg2, farg3) & integer(C_INT) :: fresult end function +function swigc_FARKodeCreateMRIStepInnerStepper(farg1, farg2) & +bind(C, name="_wrap_FARKodeCreateMRIStepInnerStepper") & +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_FARKodeSStolerances(farg1, farg2, farg3) & bind(C, name="_wrap_FARKodeSStolerances") & result(fresult) @@ -2454,6 +2464,22 @@ function FARKodeReset(arkode_mem, tr, yr) & swig_result = fresult end function +function FARKodeCreateMRIStepInnerStepper(arkode_mem, stepper) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(C_PTR) :: arkode_mem +type(C_PTR), target, intent(inout) :: stepper +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 + +farg1 = arkode_mem +farg2 = c_loc(stepper) +fresult = swigc_FARKodeCreateMRIStepInnerStepper(farg1, farg2) +swig_result = fresult +end function + function FARKodeSStolerances(arkode_mem, reltol, abstol) & result(swig_result) use, intrinsic :: ISO_C_BINDING diff --git a/src/arkode/fmod_int64/farkode_mristep_mod.c b/src/arkode/fmod_int64/farkode_mristep_mod.c index 0e4d347155..09eb4bbfcd 100644 --- a/src/arkode/fmod_int64/farkode_mristep_mod.c +++ b/src/arkode/fmod_int64/farkode_mristep_mod.c @@ -1017,20 +1017,6 @@ SWIGEXPORT int _wrap_FMRIStepInnerStepper_GetForcingData(void *farg1, double *fa } -SWIGEXPORT int _wrap_FMRIStepCreateMRIStepInnerStepper(void *farg1, void *farg2) { - int fresult ; - void *arg1 = (void *) 0 ; - MRIStepInnerStepper *arg2 = (MRIStepInnerStepper *) 0 ; - int result; - - arg1 = (void *)(farg1); - arg2 = (MRIStepInnerStepper *)(farg2); - result = (int)MRIStepCreateMRIStepInnerStepper(arg1,arg2); - fresult = (int)(result); - return fresult; -} - - SWIGEXPORT int _wrap_FMRIStepResize(void *farg1, N_Vector farg2, double const *farg3, ARKVecResizeFn farg4, void *farg5) { int fresult ; void *arg1 = (void *) 0 ; diff --git a/src/arkode/fmod_int64/farkode_mristep_mod.f90 b/src/arkode/fmod_int64/farkode_mristep_mod.f90 index ea97add0e3..3feb69ca82 100644 --- a/src/arkode/fmod_int64/farkode_mristep_mod.f90 +++ b/src/arkode/fmod_int64/farkode_mristep_mod.f90 @@ -168,7 +168,6 @@ module farkode_mristep_mod public :: FMRIStepInnerStepper_SetRTolFn public :: FMRIStepInnerStepper_AddForcing public :: FMRIStepInnerStepper_GetForcingData - public :: FMRIStepCreateMRIStepInnerStepper public :: FMRIStepResize public :: FMRIStepReset public :: FMRIStepSStolerances @@ -730,15 +729,6 @@ function swigc_FMRIStepInnerStepper_GetForcingData(farg1, farg2, farg3, farg4, f integer(C_INT) :: fresult end function -function swigc_FMRIStepCreateMRIStepInnerStepper(farg1, farg2) & -bind(C, name="_wrap_FMRIStepCreateMRIStepInnerStepper") & -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_FMRIStepResize(farg1, farg2, farg3, farg4, farg5) & bind(C, name="_wrap_FMRIStepResize") & result(fresult) @@ -2350,22 +2340,6 @@ function FMRIStepInnerStepper_GetForcingData(stepper, tshift, tscale, forcing, n swig_result = fresult end function -function FMRIStepCreateMRIStepInnerStepper(arkode_mem, stepper) & -result(swig_result) -use, intrinsic :: ISO_C_BINDING -integer(C_INT) :: swig_result -type(C_PTR) :: arkode_mem -type(C_PTR), target, intent(inout) :: stepper -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 - -farg1 = arkode_mem -farg2 = c_loc(stepper) -fresult = swigc_FMRIStepCreateMRIStepInnerStepper(farg1, farg2) -swig_result = fresult -end function - function FMRIStepResize(arkode_mem, ynew, t0, resize, resize_data) & result(swig_result) use, intrinsic :: ISO_C_BINDING diff --git a/test/unit_tests/arkode/CXX_parallel/ark_test_heat2D_mri.cpp b/test/unit_tests/arkode/CXX_parallel/ark_test_heat2D_mri.cpp index 00008a1f11..d282332727 100644 --- a/test/unit_tests/arkode/CXX_parallel/ark_test_heat2D_mri.cpp +++ b/test/unit_tests/arkode/CXX_parallel/ark_test_heat2D_mri.cpp @@ -225,8 +225,8 @@ int main(int argc, char* argv[]) if (check_flag((void*)inner_mem, "ARKStepCreate", 0)) { return 1; } MRIStepInnerStepper inner_stepper = NULL; - flag = ARKStepCreateMRIStepInnerStepper(inner_mem, &inner_stepper); - if (check_flag(&flag, "ARKStepCreateMRIStepInnerStepper", 1)) { return 1; } + flag = ARKodeCreateMRIStepInnerStepper(inner_mem, &inner_stepper); + if (check_flag(&flag, "ARKodeCreateMRIStepInnerStepper", 1)) { return 1; } mristep_mem = MRIStepCreate(NULL, f, T0, y, inner_stepper, ctx); if (check_flag((void*)mristep_mem, "MRIStepCreate", 0)) { return 1; } diff --git a/test/unit_tests/arkode/CXX_serial/ark_test_analytic_sys_mri.cpp b/test/unit_tests/arkode/CXX_serial/ark_test_analytic_sys_mri.cpp index a31e3d81e0..824488bd04 100644 --- a/test/unit_tests/arkode/CXX_serial/ark_test_analytic_sys_mri.cpp +++ b/test/unit_tests/arkode/CXX_serial/ark_test_analytic_sys_mri.cpp @@ -129,8 +129,8 @@ int main(int argc, char* argv[]) if (check_flag((void*)inner_mem, "ARKStepCreate", 0)) { return 1; } MRIStepInnerStepper inner_stepper = NULL; - flag = ARKStepCreateMRIStepInnerStepper(inner_mem, &inner_stepper); - if (check_flag(&flag, "ARKStepCreateMRIStepInnerStepper", 1)) { return 1; } + flag = ARKodeCreateMRIStepInnerStepper(inner_mem, &inner_stepper); + if (check_flag(&flag, "ARKodeCreateMRIStepInnerStepper", 1)) { return 1; } mristep_mem = MRIStepCreate(NULL, f, T0, y, inner_stepper, sunctx); if (check_flag((void*)mristep_mem, "MRIStepCreate", 0)) { return 1; } diff --git a/test/unit_tests/arkode/CXX_serial/ark_test_brusselator_mriadapt.cpp b/test/unit_tests/arkode/CXX_serial/ark_test_brusselator_mriadapt.cpp index 1343e3320e..3426e8b486 100644 --- a/test/unit_tests/arkode/CXX_serial/ark_test_brusselator_mriadapt.cpp +++ b/test/unit_tests/arkode/CXX_serial/ark_test_brusselator_mriadapt.cpp @@ -381,8 +381,8 @@ int main(int argc, char* argv[]) // Create inner stepper MRIStepInnerStepper inner_stepper = NULL; // inner stepper - retval = ERKStepCreateMRIStepInnerStepper(inner_arkode_mem, &inner_stepper); - if (check_flag(retval, "ERKStepCreateMRIStepInnerStepper")) return 1; + retval = ARKodeCreateMRIStepInnerStepper(inner_arkode_mem, &inner_stepper); + if (check_flag(retval, "ARKodeCreateMRIStepInnerStepper")) return 1; // Create slow controller object, and select orders of accuracy as relevant SUNAdaptController scontrol = NULL; diff --git a/test/unit_tests/arkode/CXX_serial/ark_test_dahlquist_mri.cpp b/test/unit_tests/arkode/CXX_serial/ark_test_dahlquist_mri.cpp index e831dcb2e7..0f895c9645 100644 --- a/test/unit_tests/arkode/CXX_serial/ark_test_dahlquist_mri.cpp +++ b/test/unit_tests/arkode/CXX_serial/ark_test_dahlquist_mri.cpp @@ -233,8 +233,8 @@ int run_tests(ARKODE_MRIType type, ProblemOptions& prob_opts, // Wrap ARKStep integrator as fast integrator object MRIStepInnerStepper inner_stepper = nullptr; - flag = ARKStepCreateMRIStepInnerStepper(arkstep_mem, &inner_stepper); - if (check_flag(&flag, "ARKStepCreateMRIStepInnerStepper", 1)) { return 1; } + flag = ARKodeCreateMRIStepInnerStepper(arkstep_mem, &inner_stepper); + if (check_flag(&flag, "ARKodeCreateMRIStepInnerStepper", 1)) { return 1; } // ---------------------- // Create slow integrator diff --git a/test/unit_tests/arkode/CXX_serial/ark_test_getjac_mri.cpp b/test/unit_tests/arkode/CXX_serial/ark_test_getjac_mri.cpp index 4737434ff6..3f3da4398a 100644 --- a/test/unit_tests/arkode/CXX_serial/ark_test_getjac_mri.cpp +++ b/test/unit_tests/arkode/CXX_serial/ark_test_getjac_mri.cpp @@ -226,8 +226,8 @@ int main(int argc, char* argv[]) // Create inner stepper MRIStepInnerStepper inner_stepper; - flag = ARKStepCreateMRIStepInnerStepper(inner_arkode_mem, &inner_stepper); - if (check_flag(flag, "ARKStepCreateMRIStepInnerStepper")) { return 1; } + flag = ARKodeCreateMRIStepInnerStepper(inner_arkode_mem, &inner_stepper); + if (check_flag(flag, "ARKodeCreateMRIStepInnerStepper")) { return 1; } // Create MRIStep memory structure void* arkode_mem = MRIStepCreate(nullptr, f, ZERO, y, inner_stepper, sunctx); diff --git a/test/unit_tests/arkode/CXX_serial/ark_test_kpr_mriadapt.cpp b/test/unit_tests/arkode/CXX_serial/ark_test_kpr_mriadapt.cpp index 2cf3d3783a..5fce159a49 100644 --- a/test/unit_tests/arkode/CXX_serial/ark_test_kpr_mriadapt.cpp +++ b/test/unit_tests/arkode/CXX_serial/ark_test_kpr_mriadapt.cpp @@ -391,8 +391,8 @@ int main(int argc, char* argv[]) // Create inner stepper MRIStepInnerStepper inner_stepper = NULL; // inner stepper - retval = ERKStepCreateMRIStepInnerStepper(inner_arkode_mem, &inner_stepper); - if (check_flag(retval, "ERKStepCreateMRIStepInnerStepper")) return 1; + retval = ARKodeCreateMRIStepInnerStepper(inner_arkode_mem, &inner_stepper); + if (check_flag(retval, "ARKodeCreateMRIStepInnerStepper")) return 1; // Create slow controller object, and select orders of accuracy as relevant SUNAdaptController scontrol = NULL; diff --git a/test/unit_tests/arkode/CXX_serial/ark_test_slowerror_brusselator.cpp b/test/unit_tests/arkode/CXX_serial/ark_test_slowerror_brusselator.cpp index e926be3d80..cc0b1b5a11 100644 --- a/test/unit_tests/arkode/CXX_serial/ark_test_slowerror_brusselator.cpp +++ b/test/unit_tests/arkode/CXX_serial/ark_test_slowerror_brusselator.cpp @@ -294,8 +294,8 @@ int main(int argc, char* argv[]) // Create inner stepper wrapper MRIStepInnerStepper inner_stepper = NULL; // inner stepper - retval = ERKStepCreateMRIStepInnerStepper(inner_arkode_mem, &inner_stepper); - if (check_retval(&retval, "ERKStepCreateMRIStepInnerStepper", 1)) return 1; + retval = ARKodeCreateMRIStepInnerStepper(inner_arkode_mem, &inner_stepper); + if (check_retval(&retval, "ARKodeCreateMRIStepInnerStepper", 1)) return 1; // Set up slow MRIStep integrator void* mristep_mem = NULL; diff --git a/test/unit_tests/arkode/CXX_serial/ark_test_slowerror_kpr.cpp b/test/unit_tests/arkode/CXX_serial/ark_test_slowerror_kpr.cpp index 820e299be1..ef9c5e97e6 100644 --- a/test/unit_tests/arkode/CXX_serial/ark_test_slowerror_kpr.cpp +++ b/test/unit_tests/arkode/CXX_serial/ark_test_slowerror_kpr.cpp @@ -231,8 +231,8 @@ int main(int argc, char* argv[]) // Create inner stepper wrapper MRIStepInnerStepper inner_stepper = NULL; // inner stepper - retval = ERKStepCreateMRIStepInnerStepper(inner_arkode_mem, &inner_stepper); - if (check_retval(&retval, "ERKStepCreateMRIStepInnerStepper", 1)) return 1; + retval = ARKodeCreateMRIStepInnerStepper(inner_arkode_mem, &inner_stepper); + if (check_retval(&retval, "ARKodeCreateMRIStepInnerStepper", 1)) return 1; // Set up slow MRIStep integrator void* mristep_mem = NULL; diff --git a/test/unit_tests/arkode/CXX_serial/ark_test_slowerror_polynomial.cpp b/test/unit_tests/arkode/CXX_serial/ark_test_slowerror_polynomial.cpp index 29adfd5093..1f236da7d6 100644 --- a/test/unit_tests/arkode/CXX_serial/ark_test_slowerror_polynomial.cpp +++ b/test/unit_tests/arkode/CXX_serial/ark_test_slowerror_polynomial.cpp @@ -165,8 +165,8 @@ int main(int argc, char* argv[]) // Create inner stepper wrapper MRIStepInnerStepper inner_stepper = NULL; // inner stepper - retval = ARKStepCreateMRIStepInnerStepper(inner_arkode_mem, &inner_stepper); - if (check_retval(&retval, "ARKStepCreateMRIStepInnerStepper", 1)) return 1; + retval = ARKodeCreateMRIStepInnerStepper(inner_arkode_mem, &inner_stepper); + if (check_retval(&retval, "ARKodeCreateMRIStepInnerStepper", 1)) return 1; // Set up slow MRIStep integrator void* mristep_mem = NULL; diff --git a/test/unit_tests/arkode/C_serial/ark_test_getuserdata.c b/test/unit_tests/arkode/C_serial/ark_test_getuserdata.c index 25c5de6982..24be91856d 100644 --- a/test/unit_tests/arkode/C_serial/ark_test_getuserdata.c +++ b/test/unit_tests/arkode/C_serial/ark_test_getuserdata.c @@ -165,10 +165,10 @@ int main(int argc, char* argv[]) } /* Create inner stepper */ - retval = ARKStepCreateMRIStepInnerStepper(arkode_inner_mem, &inner_stepper); + retval = ARKodeCreateMRIStepInnerStepper(arkode_inner_mem, &inner_stepper); if (retval) { - fprintf(stderr, "ARKStepCreateMRIStepInnerStepper returned %i", retval); + fprintf(stderr, "ARKodeCreateMRIStepInnerStepper returned %i", retval); return 1; } diff --git a/test/unit_tests/arkode/C_serial/ark_test_reset.c b/test/unit_tests/arkode/C_serial/ark_test_reset.c index ca68de5975..56b38c14e5 100644 --- a/test/unit_tests/arkode/C_serial/ark_test_reset.c +++ b/test/unit_tests/arkode/C_serial/ark_test_reset.c @@ -299,8 +299,8 @@ int main(void) if (check_retval(&retval, "ARKodeSStolerances", 1)) { return 1; } retval = ARKodeSetMaxNumSteps(arkode_mem, 100); check_retval(&retval, "ARKodeSetMaxNumSteps", 1); - retval = ARKStepCreateMRIStepInnerStepper(arkode_mem, &inner_stepper); - if (check_retval(&retval, "ARKStepCreateMRIStepInnerStepper", 1)) + retval = ARKodeCreateMRIStepInnerStepper(arkode_mem, &inner_stepper); + if (check_retval(&retval, "ARKodeCreateMRIStepInnerStepper", 1)) { return 1; } From c8082785b2d65677aba866e0f97a06580f10226c Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Fri, 27 Sep 2024 14:42:37 -0500 Subject: [PATCH 091/286] Updated some .out files --- ...rk_test_accumerror_brusselator_20_-4_0.out | 320 +++++++++--------- ...ark_test_accumerror_brusselator_20_3_1.out | 240 ++++++------- ...ark_test_accumerror_brusselator_20_5_0.out | 240 ++++++------- .../ark_test_accumerror_kpr_20_-4_1.out | 320 +++++++++--------- .../ark_test_accumerror_kpr_20_2_0.out | 240 ++++++------- .../ark_test_accumerror_kpr_20_3_1.out | 240 ++++++------- .../CXX_serial/ark_test_dahlquist_mri_-1.out | 4 +- .../CXX_serial/ark_test_dahlquist_mri_0.out | 4 +- .../CXX_serial/ark_test_dahlquist_mri_1.out | 4 +- 9 files changed, 806 insertions(+), 806 deletions(-) diff --git a/test/unit_tests/arkode/CXX_serial/ark_test_accumerror_brusselator_20_-4_0.out b/test/unit_tests/arkode/CXX_serial/ark_test_accumerror_brusselator_20_-4_0.out index 6d03997f5a..83a2d7ecf7 100644 --- a/test/unit_tests/arkode/CXX_serial/ark_test_accumerror_brusselator_20_-4_0.out +++ b/test/unit_tests/arkode/CXX_serial/ark_test_accumerror_brusselator_20_-4_0.out @@ -7,46 +7,46 @@ Accumulated error estimation test (stiff Brusselator ODE problem): DIRK solver, order = 4 Fixed-step runs: - h 0.025 rk_type 0 order 4 acc 0 t 0.5 dsm 2.02741e-07 dsm_est 0.244873 nsteps 20 - h 0.025 rk_type 0 order 4 acc 0 t 1 dsm 4.36512e-10 dsm_est 9.15797e-10 nsteps 20 - h 0.025 rk_type 0 order 4 acc 0 t 1.5 dsm 1.47944e-09 dsm_est 1.03904e-09 nsteps 20 - h 0.025 rk_type 0 order 4 acc 0 t 2 dsm 3.07014e-09 dsm_est 7.16968e-10 nsteps 20 - h 0.025 rk_type 0 order 4 acc 0 t 2.5 dsm 2.41009e-09 dsm_est 9.26427e-10 nsteps 20 - h 0.025 rk_type 0 order 4 acc 0 t 3 dsm 2.2919e-10 dsm_est 1.68058e-09 nsteps 20 - h 0.025 rk_type 0 order 4 acc 0 t 3.5 dsm 2.10843e-11 dsm_est 1.6358e-09 nsteps 20 - h 0.025 rk_type 0 order 4 acc 0 t 4 dsm 4.85414e-11 dsm_est 8.11006e-10 nsteps 20 - h 0.025 rk_type 0 order 4 acc 0 t 4.5 dsm 1.96723e-10 dsm_est 1.90108e-10 nsteps 20 - h 0.025 rk_type 0 order 4 acc 0 t 5 dsm 8.22132e-10 dsm_est 5.32797e-10 nsteps 20 - h 0.025 rk_type 0 order 4 acc 0 t 5.5 dsm 1.54757e-09 dsm_est 9.55312e-10 nsteps 20 - h 0.025 rk_type 0 order 4 acc 0 t 6 dsm 1.4066e-09 dsm_est 5.43427e-09 nsteps 20 - h 0.025 rk_type 0 order 4 acc 0 t 6.5 dsm 1.53642e-07 dsm_est 8.50911e-07 nsteps 20 - h 0.025 rk_type 0 order 4 acc 0 t 7 dsm 4.94724e-06 dsm_est 0.000100467 nsteps 20 - h 0.025 rk_type 0 order 4 acc 0 t 7.5 dsm 4.18294e-08 dsm_est 1.0711e-05 nsteps 20 - h 0.025 rk_type 0 order 4 acc 0 t 8 dsm 1.04878e-08 dsm_est 1.1263e-07 nsteps 20 - h 0.025 rk_type 0 order 4 acc 0 t 8.5 dsm 2.79702e-09 dsm_est 2.16903e-08 nsteps 20 - h 0.025 rk_type 0 order 4 acc 0 t 9 dsm 1.60168e-09 dsm_est 1.38178e-08 nsteps 20 - h 0.025 rk_type 0 order 4 acc 0 t 9.5 dsm 1.4347e-09 dsm_est 1.88007e-08 nsteps 20 - h 0.025 rk_type 0 order 4 acc 0 t 10 dsm 5.54538e-10 dsm_est 1.51522e-08 nsteps 20 - h 0.025 rk_type 0 order 4 acc 1 t 0.5 dsm 2.02741e-07 dsm_est 0.0135207 nsteps 20 - h 0.025 rk_type 0 order 4 acc 1 t 1 dsm 4.36512e-10 dsm_est 5.08381e-10 nsteps 20 - h 0.025 rk_type 0 order 4 acc 1 t 1.5 dsm 1.47944e-09 dsm_est 9.58723e-10 nsteps 20 - h 0.025 rk_type 0 order 4 acc 1 t 2 dsm 3.07014e-09 dsm_est 3.90744e-10 nsteps 20 - h 0.025 rk_type 0 order 4 acc 1 t 2.5 dsm 2.41009e-09 dsm_est 3.67901e-10 nsteps 20 - h 0.025 rk_type 0 order 4 acc 1 t 3 dsm 2.2919e-10 dsm_est 1.47844e-09 nsteps 20 - h 0.025 rk_type 0 order 4 acc 1 t 3.5 dsm 2.10843e-11 dsm_est 1.28099e-09 nsteps 20 - h 0.025 rk_type 0 order 4 acc 1 t 4 dsm 4.85414e-11 dsm_est 4.55485e-10 nsteps 20 - h 0.025 rk_type 0 order 4 acc 1 t 4.5 dsm 1.96723e-10 dsm_est 9.4415e-11 nsteps 20 - h 0.025 rk_type 0 order 4 acc 1 t 5 dsm 8.22132e-10 dsm_est 3.5967e-10 nsteps 20 - h 0.025 rk_type 0 order 4 acc 1 t 5.5 dsm 1.54757e-09 dsm_est 7.71393e-10 nsteps 20 - h 0.025 rk_type 0 order 4 acc 1 t 6 dsm 1.4066e-09 dsm_est 1.38966e-09 nsteps 20 - h 0.025 rk_type 0 order 4 acc 1 t 6.5 dsm 1.53642e-07 dsm_est 1.71964e-07 nsteps 20 - h 0.025 rk_type 0 order 4 acc 1 t 7 dsm 4.94724e-06 dsm_est 2.68263e-05 nsteps 20 - h 0.025 rk_type 0 order 4 acc 1 t 7.5 dsm 4.18294e-08 dsm_est 1.40652e-06 nsteps 20 - h 0.025 rk_type 0 order 4 acc 1 t 8 dsm 1.04878e-08 dsm_est 5.45367e-08 nsteps 20 - h 0.025 rk_type 0 order 4 acc 1 t 8.5 dsm 2.79702e-09 dsm_est 1.40952e-08 nsteps 20 - h 0.025 rk_type 0 order 4 acc 1 t 9 dsm 1.60168e-09 dsm_est 6.13761e-09 nsteps 20 - h 0.025 rk_type 0 order 4 acc 1 t 9.5 dsm 1.4347e-09 dsm_est 1.74499e-08 nsteps 20 - h 0.025 rk_type 0 order 4 acc 1 t 10 dsm 5.54538e-10 dsm_est 9.89407e-09 nsteps 20 + h 0.025 rk_type 0 order 4 acc 1 t 0.5 dsm 2.02741e-07 dsm_est 0.244873 nsteps 20 + h 0.025 rk_type 0 order 4 acc 1 t 1 dsm 4.36512e-10 dsm_est 9.15797e-10 nsteps 20 + h 0.025 rk_type 0 order 4 acc 1 t 1.5 dsm 1.47944e-09 dsm_est 1.03904e-09 nsteps 20 + h 0.025 rk_type 0 order 4 acc 1 t 2 dsm 3.07014e-09 dsm_est 7.16968e-10 nsteps 20 + h 0.025 rk_type 0 order 4 acc 1 t 2.5 dsm 2.41009e-09 dsm_est 9.26427e-10 nsteps 20 + h 0.025 rk_type 0 order 4 acc 1 t 3 dsm 2.2919e-10 dsm_est 1.68058e-09 nsteps 20 + h 0.025 rk_type 0 order 4 acc 1 t 3.5 dsm 2.10843e-11 dsm_est 1.6358e-09 nsteps 20 + h 0.025 rk_type 0 order 4 acc 1 t 4 dsm 4.85414e-11 dsm_est 8.11006e-10 nsteps 20 + h 0.025 rk_type 0 order 4 acc 1 t 4.5 dsm 1.96723e-10 dsm_est 1.90108e-10 nsteps 20 + h 0.025 rk_type 0 order 4 acc 1 t 5 dsm 8.22132e-10 dsm_est 5.32797e-10 nsteps 20 + h 0.025 rk_type 0 order 4 acc 1 t 5.5 dsm 1.54757e-09 dsm_est 9.55312e-10 nsteps 20 + h 0.025 rk_type 0 order 4 acc 1 t 6 dsm 1.4066e-09 dsm_est 5.43427e-09 nsteps 20 + h 0.025 rk_type 0 order 4 acc 1 t 6.5 dsm 1.53642e-07 dsm_est 8.50911e-07 nsteps 20 + h 0.025 rk_type 0 order 4 acc 1 t 7 dsm 4.94724e-06 dsm_est 0.000100467 nsteps 20 + h 0.025 rk_type 0 order 4 acc 1 t 7.5 dsm 4.18294e-08 dsm_est 1.0711e-05 nsteps 20 + h 0.025 rk_type 0 order 4 acc 1 t 8 dsm 1.04878e-08 dsm_est 1.1263e-07 nsteps 20 + h 0.025 rk_type 0 order 4 acc 1 t 8.5 dsm 2.79702e-09 dsm_est 2.16903e-08 nsteps 20 + h 0.025 rk_type 0 order 4 acc 1 t 9 dsm 1.60168e-09 dsm_est 1.38178e-08 nsteps 20 + h 0.025 rk_type 0 order 4 acc 1 t 9.5 dsm 1.4347e-09 dsm_est 1.88007e-08 nsteps 20 + h 0.025 rk_type 0 order 4 acc 1 t 10 dsm 5.54538e-10 dsm_est 1.51522e-08 nsteps 20 + h 0.025 rk_type 0 order 4 acc 3 t 0.5 dsm 2.02741e-07 dsm_est 0.0135207 nsteps 20 + h 0.025 rk_type 0 order 4 acc 3 t 1 dsm 4.36512e-10 dsm_est 5.08381e-10 nsteps 20 + h 0.025 rk_type 0 order 4 acc 3 t 1.5 dsm 1.47944e-09 dsm_est 9.58723e-10 nsteps 20 + h 0.025 rk_type 0 order 4 acc 3 t 2 dsm 3.07014e-09 dsm_est 3.90744e-10 nsteps 20 + h 0.025 rk_type 0 order 4 acc 3 t 2.5 dsm 2.41009e-09 dsm_est 3.67901e-10 nsteps 20 + h 0.025 rk_type 0 order 4 acc 3 t 3 dsm 2.2919e-10 dsm_est 1.47844e-09 nsteps 20 + h 0.025 rk_type 0 order 4 acc 3 t 3.5 dsm 2.10843e-11 dsm_est 1.28099e-09 nsteps 20 + h 0.025 rk_type 0 order 4 acc 3 t 4 dsm 4.85414e-11 dsm_est 4.55485e-10 nsteps 20 + h 0.025 rk_type 0 order 4 acc 3 t 4.5 dsm 1.96723e-10 dsm_est 9.4415e-11 nsteps 20 + h 0.025 rk_type 0 order 4 acc 3 t 5 dsm 8.22132e-10 dsm_est 3.5967e-10 nsteps 20 + h 0.025 rk_type 0 order 4 acc 3 t 5.5 dsm 1.54757e-09 dsm_est 7.71393e-10 nsteps 20 + h 0.025 rk_type 0 order 4 acc 3 t 6 dsm 1.4066e-09 dsm_est 1.38966e-09 nsteps 20 + h 0.025 rk_type 0 order 4 acc 3 t 6.5 dsm 1.53642e-07 dsm_est 1.71964e-07 nsteps 20 + h 0.025 rk_type 0 order 4 acc 3 t 7 dsm 4.94724e-06 dsm_est 2.68263e-05 nsteps 20 + h 0.025 rk_type 0 order 4 acc 3 t 7.5 dsm 4.18294e-08 dsm_est 1.40652e-06 nsteps 20 + h 0.025 rk_type 0 order 4 acc 3 t 8 dsm 1.04878e-08 dsm_est 5.45367e-08 nsteps 20 + h 0.025 rk_type 0 order 4 acc 3 t 8.5 dsm 2.79702e-09 dsm_est 1.40952e-08 nsteps 20 + h 0.025 rk_type 0 order 4 acc 3 t 9 dsm 1.60168e-09 dsm_est 6.13761e-09 nsteps 20 + h 0.025 rk_type 0 order 4 acc 3 t 9.5 dsm 1.4347e-09 dsm_est 1.74499e-08 nsteps 20 + h 0.025 rk_type 0 order 4 acc 3 t 10 dsm 5.54538e-10 dsm_est 9.89407e-09 nsteps 20 h 0.025 rk_type 0 order 4 acc 2 t 0.5 dsm 2.02741e-07 dsm_est 2.04151e-07 nsteps 30 h 0.025 rk_type 0 order 4 acc 2 t 1 dsm 4.36512e-10 dsm_est 1.51075e-09 nsteps 30 h 0.025 rk_type 0 order 4 acc 2 t 1.5 dsm 1.47944e-09 dsm_est 1.30553e-09 nsteps 30 @@ -67,46 +67,46 @@ Fixed-step runs: h 0.025 rk_type 0 order 4 acc 2 t 9 dsm 1.60168e-09 dsm_est 3.77187e-08 nsteps 30 h 0.025 rk_type 0 order 4 acc 2 t 9.5 dsm 1.4347e-09 dsm_est 2.25916e-09 nsteps 30 h 0.025 rk_type 0 order 4 acc 2 t 10 dsm 5.54538e-10 dsm_est 8.39636e-09 nsteps 30 - h 0.00625 rk_type 0 order 4 acc 0 t 0.5 dsm 2.01526e-08 dsm_est 0.12061 nsteps 80 - h 0.00625 rk_type 0 order 4 acc 0 t 1 dsm 9.02564e-12 dsm_est 3.15224e-11 nsteps 80 - h 0.00625 rk_type 0 order 4 acc 0 t 1.5 dsm 6.18719e-12 dsm_est 1.15612e-11 nsteps 80 - h 0.00625 rk_type 0 order 4 acc 0 t 2 dsm 1.21264e-11 dsm_est 3.56333e-12 nsteps 80 - h 0.00625 rk_type 0 order 4 acc 0 t 2.5 dsm 9.39437e-12 dsm_est 3.71652e-12 nsteps 80 - h 0.00625 rk_type 0 order 4 acc 0 t 3 dsm 6.39567e-12 dsm_est 6.60675e-12 nsteps 80 - h 0.00625 rk_type 0 order 4 acc 0 t 3.5 dsm 4.31321e-12 dsm_est 1.02486e-11 nsteps 80 - h 0.00625 rk_type 0 order 4 acc 0 t 4 dsm 5.26346e-12 dsm_est 6.34128e-12 nsteps 80 - h 0.00625 rk_type 0 order 4 acc 0 t 4.5 dsm 3.00982e-11 dsm_est 6.6337e-12 nsteps 80 - h 0.00625 rk_type 0 order 4 acc 0 t 5 dsm 3.35644e-12 dsm_est 3.78322e-11 nsteps 80 - h 0.00625 rk_type 0 order 4 acc 0 t 5.5 dsm 1.37915e-11 dsm_est 3.71144e-12 nsteps 80 - h 0.00625 rk_type 0 order 4 acc 0 t 6 dsm 9.91766e-11 dsm_est 2.23847e-11 nsteps 80 - h 0.00625 rk_type 0 order 4 acc 0 t 6.5 dsm 3.01672e-09 dsm_est 3.42521e-09 nsteps 80 - h 0.00625 rk_type 0 order 4 acc 0 t 7 dsm 1.77811e-08 dsm_est 4.60341e-07 nsteps 80 - h 0.00625 rk_type 0 order 4 acc 0 t 7.5 dsm 7.42418e-10 dsm_est 6.0223e-08 nsteps 80 - h 0.00625 rk_type 0 order 4 acc 0 t 8 dsm 3.89202e-10 dsm_est 4.90508e-10 nsteps 80 - h 0.00625 rk_type 0 order 4 acc 0 t 8.5 dsm 3.7018e-11 dsm_est 2.41013e-10 nsteps 80 - h 0.00625 rk_type 0 order 4 acc 0 t 9 dsm 2.94415e-11 dsm_est 5.60347e-11 nsteps 80 - h 0.00625 rk_type 0 order 4 acc 0 t 9.5 dsm 1.42778e-11 dsm_est 7.48066e-11 nsteps 80 - h 0.00625 rk_type 0 order 4 acc 0 t 10 dsm 4.93463e-12 dsm_est 6.33468e-11 nsteps 80 - h 0.00625 rk_type 0 order 4 acc 1 t 0.5 dsm 2.01526e-08 dsm_est 0.00177442 nsteps 80 - h 0.00625 rk_type 0 order 4 acc 1 t 1 dsm 9.02564e-12 dsm_est 2.40701e-12 nsteps 80 - h 0.00625 rk_type 0 order 4 acc 1 t 1.5 dsm 6.18719e-12 dsm_est 3.87284e-12 nsteps 80 - h 0.00625 rk_type 0 order 4 acc 1 t 2 dsm 1.21264e-11 dsm_est 1.58498e-12 nsteps 80 - h 0.00625 rk_type 0 order 4 acc 1 t 2.5 dsm 9.39437e-12 dsm_est 1.44929e-12 nsteps 80 - h 0.00625 rk_type 0 order 4 acc 1 t 3 dsm 6.39567e-12 dsm_est 5.79442e-12 nsteps 80 - h 0.00625 rk_type 0 order 4 acc 1 t 3.5 dsm 4.31321e-12 dsm_est 5.09937e-12 nsteps 80 - h 0.00625 rk_type 0 order 4 acc 1 t 4 dsm 5.26346e-12 dsm_est 1.84452e-12 nsteps 80 - h 0.00625 rk_type 0 order 4 acc 1 t 4.5 dsm 3.00982e-11 dsm_est 4.51445e-13 nsteps 80 - h 0.00625 rk_type 0 order 4 acc 1 t 5 dsm 3.35644e-12 dsm_est 1.92957e-12 nsteps 80 - h 0.00625 rk_type 0 order 4 acc 1 t 5.5 dsm 1.37915e-11 dsm_est 2.9942e-12 nsteps 80 - h 0.00625 rk_type 0 order 4 acc 1 t 6 dsm 9.91766e-11 dsm_est 5.36083e-12 nsteps 80 - h 0.00625 rk_type 0 order 4 acc 1 t 6.5 dsm 3.01672e-09 dsm_est 6.26439e-10 nsteps 80 - h 0.00625 rk_type 0 order 4 acc 1 t 7 dsm 1.77811e-08 dsm_est 1.16445e-07 nsteps 80 - h 0.00625 rk_type 0 order 4 acc 1 t 7.5 dsm 7.42418e-10 dsm_est 6.32584e-09 nsteps 80 - h 0.00625 rk_type 0 order 4 acc 1 t 8 dsm 3.89202e-10 dsm_est 2.24093e-10 nsteps 80 - h 0.00625 rk_type 0 order 4 acc 1 t 8.5 dsm 3.7018e-11 dsm_est 5.81897e-11 nsteps 80 - h 0.00625 rk_type 0 order 4 acc 1 t 9 dsm 2.94415e-11 dsm_est 2.43467e-11 nsteps 80 - h 0.00625 rk_type 0 order 4 acc 1 t 9.5 dsm 1.42778e-11 dsm_est 6.94659e-11 nsteps 80 - h 0.00625 rk_type 0 order 4 acc 1 t 10 dsm 4.93463e-12 dsm_est 3.94313e-11 nsteps 80 + h 0.00625 rk_type 0 order 4 acc 1 t 0.5 dsm 2.01526e-08 dsm_est 0.12061 nsteps 80 + h 0.00625 rk_type 0 order 4 acc 1 t 1 dsm 9.02564e-12 dsm_est 3.15224e-11 nsteps 80 + h 0.00625 rk_type 0 order 4 acc 1 t 1.5 dsm 6.18719e-12 dsm_est 1.15612e-11 nsteps 80 + h 0.00625 rk_type 0 order 4 acc 1 t 2 dsm 1.21264e-11 dsm_est 3.56333e-12 nsteps 80 + h 0.00625 rk_type 0 order 4 acc 1 t 2.5 dsm 9.39437e-12 dsm_est 3.71652e-12 nsteps 80 + h 0.00625 rk_type 0 order 4 acc 1 t 3 dsm 6.39567e-12 dsm_est 6.60675e-12 nsteps 80 + h 0.00625 rk_type 0 order 4 acc 1 t 3.5 dsm 4.31321e-12 dsm_est 1.02486e-11 nsteps 80 + h 0.00625 rk_type 0 order 4 acc 1 t 4 dsm 5.26346e-12 dsm_est 6.34128e-12 nsteps 80 + h 0.00625 rk_type 0 order 4 acc 1 t 4.5 dsm 3.00982e-11 dsm_est 6.6337e-12 nsteps 80 + h 0.00625 rk_type 0 order 4 acc 1 t 5 dsm 3.35644e-12 dsm_est 3.78322e-11 nsteps 80 + h 0.00625 rk_type 0 order 4 acc 1 t 5.5 dsm 1.37915e-11 dsm_est 3.71144e-12 nsteps 80 + h 0.00625 rk_type 0 order 4 acc 1 t 6 dsm 9.91766e-11 dsm_est 2.23847e-11 nsteps 80 + h 0.00625 rk_type 0 order 4 acc 1 t 6.5 dsm 3.01672e-09 dsm_est 3.42521e-09 nsteps 80 + h 0.00625 rk_type 0 order 4 acc 1 t 7 dsm 1.77811e-08 dsm_est 4.60341e-07 nsteps 80 + h 0.00625 rk_type 0 order 4 acc 1 t 7.5 dsm 7.42418e-10 dsm_est 6.0223e-08 nsteps 80 + h 0.00625 rk_type 0 order 4 acc 1 t 8 dsm 3.89202e-10 dsm_est 4.90508e-10 nsteps 80 + h 0.00625 rk_type 0 order 4 acc 1 t 8.5 dsm 3.7018e-11 dsm_est 2.41013e-10 nsteps 80 + h 0.00625 rk_type 0 order 4 acc 1 t 9 dsm 2.94415e-11 dsm_est 5.60347e-11 nsteps 80 + h 0.00625 rk_type 0 order 4 acc 1 t 9.5 dsm 1.42778e-11 dsm_est 7.48066e-11 nsteps 80 + h 0.00625 rk_type 0 order 4 acc 1 t 10 dsm 4.93463e-12 dsm_est 6.33468e-11 nsteps 80 + h 0.00625 rk_type 0 order 4 acc 3 t 0.5 dsm 2.01526e-08 dsm_est 0.00177442 nsteps 80 + h 0.00625 rk_type 0 order 4 acc 3 t 1 dsm 9.02564e-12 dsm_est 2.40701e-12 nsteps 80 + h 0.00625 rk_type 0 order 4 acc 3 t 1.5 dsm 6.18719e-12 dsm_est 3.87284e-12 nsteps 80 + h 0.00625 rk_type 0 order 4 acc 3 t 2 dsm 1.21264e-11 dsm_est 1.58498e-12 nsteps 80 + h 0.00625 rk_type 0 order 4 acc 3 t 2.5 dsm 9.39437e-12 dsm_est 1.44929e-12 nsteps 80 + h 0.00625 rk_type 0 order 4 acc 3 t 3 dsm 6.39567e-12 dsm_est 5.79442e-12 nsteps 80 + h 0.00625 rk_type 0 order 4 acc 3 t 3.5 dsm 4.31321e-12 dsm_est 5.09937e-12 nsteps 80 + h 0.00625 rk_type 0 order 4 acc 3 t 4 dsm 5.26346e-12 dsm_est 1.84452e-12 nsteps 80 + h 0.00625 rk_type 0 order 4 acc 3 t 4.5 dsm 3.00982e-11 dsm_est 4.51445e-13 nsteps 80 + h 0.00625 rk_type 0 order 4 acc 3 t 5 dsm 3.35644e-12 dsm_est 1.92957e-12 nsteps 80 + h 0.00625 rk_type 0 order 4 acc 3 t 5.5 dsm 1.37915e-11 dsm_est 2.9942e-12 nsteps 80 + h 0.00625 rk_type 0 order 4 acc 3 t 6 dsm 9.91766e-11 dsm_est 5.36083e-12 nsteps 80 + h 0.00625 rk_type 0 order 4 acc 3 t 6.5 dsm 3.01672e-09 dsm_est 6.26439e-10 nsteps 80 + h 0.00625 rk_type 0 order 4 acc 3 t 7 dsm 1.77811e-08 dsm_est 1.16445e-07 nsteps 80 + h 0.00625 rk_type 0 order 4 acc 3 t 7.5 dsm 7.42418e-10 dsm_est 6.32584e-09 nsteps 80 + h 0.00625 rk_type 0 order 4 acc 3 t 8 dsm 3.89202e-10 dsm_est 2.24093e-10 nsteps 80 + h 0.00625 rk_type 0 order 4 acc 3 t 8.5 dsm 3.7018e-11 dsm_est 5.81897e-11 nsteps 80 + h 0.00625 rk_type 0 order 4 acc 3 t 9 dsm 2.94415e-11 dsm_est 2.43467e-11 nsteps 80 + h 0.00625 rk_type 0 order 4 acc 3 t 9.5 dsm 1.42778e-11 dsm_est 6.94659e-11 nsteps 80 + h 0.00625 rk_type 0 order 4 acc 3 t 10 dsm 4.93463e-12 dsm_est 3.94313e-11 nsteps 80 h 0.00625 rk_type 0 order 4 acc 2 t 0.5 dsm 2.01526e-08 dsm_est 5.96471e-08 nsteps 120 h 0.00625 rk_type 0 order 4 acc 2 t 1 dsm 9.02564e-12 dsm_est 2.62428e-11 nsteps 120 h 0.00625 rk_type 0 order 4 acc 2 t 1.5 dsm 6.18719e-12 dsm_est 8.82608e-11 nsteps 120 @@ -127,46 +127,46 @@ Fixed-step runs: h 0.00625 rk_type 0 order 4 acc 2 t 9 dsm 2.94415e-11 dsm_est 2.41758e-10 nsteps 120 h 0.00625 rk_type 0 order 4 acc 2 t 9.5 dsm 1.42778e-11 dsm_est 9.06696e-11 nsteps 120 h 0.00625 rk_type 0 order 4 acc 2 t 10 dsm 4.93463e-12 dsm_est 3.23538e-11 nsteps 120 - h 0.0015625 rk_type 0 order 4 acc 0 t 0.5 dsm 1.12995e-09 dsm_est 0.0161685 nsteps 320 - h 0.0015625 rk_type 0 order 4 acc 0 t 1 dsm 8.83314e-12 dsm_est 4.22807e-12 nsteps 320 - h 0.0015625 rk_type 0 order 4 acc 0 t 1.5 dsm 1.84069e-12 dsm_est 1.48779e-12 nsteps 320 - h 0.0015625 rk_type 0 order 4 acc 0 t 2 dsm 2.23198e-13 dsm_est 3.06e-13 nsteps 320 - h 0.0015625 rk_type 0 order 4 acc 0 t 2.5 dsm 5.57615e-13 dsm_est 3.16293e-14 nsteps 320 - h 0.0015625 rk_type 0 order 4 acc 0 t 3 dsm 6.33215e-12 dsm_est 9.28211e-14 nsteps 320 - h 0.0015625 rk_type 0 order 4 acc 0 t 3.5 dsm 4.31345e-12 dsm_est 1.06725e-12 nsteps 320 - h 0.0015625 rk_type 0 order 4 acc 0 t 4 dsm 5.25911e-12 dsm_est 7.27486e-13 nsteps 320 - h 0.0015625 rk_type 0 order 4 acc 0 t 4.5 dsm 3.00873e-11 dsm_est 8.86785e-13 nsteps 320 - h 0.0015625 rk_type 0 order 4 acc 0 t 5 dsm 1.04948e-12 dsm_est 5.07072e-12 nsteps 320 - h 0.0015625 rk_type 0 order 4 acc 0 t 5.5 dsm 6.97828e-12 dsm_est 1.75823e-13 nsteps 320 - h 0.0015625 rk_type 0 order 4 acc 0 t 6 dsm 5.98205e-11 dsm_est 1.17286e-12 nsteps 320 - h 0.0015625 rk_type 0 order 4 acc 0 t 6.5 dsm 1.87435e-11 dsm_est 1.34855e-11 nsteps 320 - h 0.0015625 rk_type 0 order 4 acc 0 t 7 dsm 6.39659e-10 dsm_est 1.86951e-09 nsteps 320 - h 0.0015625 rk_type 0 order 4 acc 0 t 7.5 dsm 1.83962e-11 dsm_est 2.58837e-10 nsteps 320 - h 0.0015625 rk_type 0 order 4 acc 0 t 8 dsm 1.77418e-10 dsm_est 3.6664e-12 nsteps 320 - h 0.0015625 rk_type 0 order 4 acc 0 t 8.5 dsm 2.78724e-12 dsm_est 2.99588e-11 nsteps 320 - h 0.0015625 rk_type 0 order 4 acc 0 t 9 dsm 2.4955e-11 dsm_est 5.0593e-13 nsteps 320 - h 0.0015625 rk_type 0 order 4 acc 0 t 9.5 dsm 1.29649e-11 dsm_est 4.22112e-12 nsteps 320 - h 0.0015625 rk_type 0 order 4 acc 0 t 10 dsm 4.44459e-12 dsm_est 2.19913e-12 nsteps 320 - h 0.0015625 rk_type 0 order 4 acc 1 t 0.5 dsm 1.12995e-09 dsm_est 5.29229e-05 nsteps 320 - h 0.0015625 rk_type 0 order 4 acc 1 t 1 dsm 8.83314e-12 dsm_est 2.17158e-14 nsteps 320 - h 0.0015625 rk_type 0 order 4 acc 1 t 1.5 dsm 1.84069e-12 dsm_est 1.99723e-14 nsteps 320 - h 0.0015625 rk_type 0 order 4 acc 1 t 2 dsm 2.23198e-13 dsm_est 8.79682e-15 nsteps 320 - h 0.0015625 rk_type 0 order 4 acc 1 t 2.5 dsm 5.57615e-13 dsm_est 7.03822e-15 nsteps 320 - h 0.0015625 rk_type 0 order 4 acc 1 t 3 dsm 6.33215e-12 dsm_est 2.29246e-14 nsteps 320 - h 0.0015625 rk_type 0 order 4 acc 1 t 3.5 dsm 4.31345e-12 dsm_est 2.31473e-14 nsteps 320 - h 0.0015625 rk_type 0 order 4 acc 1 t 4 dsm 5.25911e-12 dsm_est 9.40731e-15 nsteps 320 - h 0.0015625 rk_type 0 order 4 acc 1 t 4.5 dsm 3.00873e-11 dsm_est 4.42611e-15 nsteps 320 - h 0.0015625 rk_type 0 order 4 acc 1 t 5 dsm 1.04948e-12 dsm_est 2.21481e-14 nsteps 320 - h 0.0015625 rk_type 0 order 4 acc 1 t 5.5 dsm 6.97828e-12 dsm_est 1.2278e-14 nsteps 320 - h 0.0015625 rk_type 0 order 4 acc 1 t 6 dsm 5.98205e-11 dsm_est 2.51123e-14 nsteps 320 - h 0.0015625 rk_type 0 order 4 acc 1 t 6.5 dsm 1.87435e-11 dsm_est 2.43406e-12 nsteps 320 - h 0.0015625 rk_type 0 order 4 acc 1 t 7 dsm 6.39659e-10 dsm_est 4.6675e-10 nsteps 320 - h 0.0015625 rk_type 0 order 4 acc 1 t 7.5 dsm 1.83962e-11 dsm_est 2.56334e-11 nsteps 320 - h 0.0015625 rk_type 0 order 4 acc 1 t 8 dsm 1.77418e-10 dsm_est 8.92764e-13 nsteps 320 - h 0.0015625 rk_type 0 order 4 acc 1 t 8.5 dsm 2.78724e-12 dsm_est 3.18282e-13 nsteps 320 - h 0.0015625 rk_type 0 order 4 acc 1 t 9 dsm 2.4955e-11 dsm_est 9.93014e-14 nsteps 320 - h 0.0015625 rk_type 0 order 4 acc 1 t 9.5 dsm 1.29649e-11 dsm_est 2.84939e-13 nsteps 320 - h 0.0015625 rk_type 0 order 4 acc 1 t 10 dsm 4.44459e-12 dsm_est 1.6087e-13 nsteps 320 + h 0.0015625 rk_type 0 order 4 acc 1 t 0.5 dsm 1.12995e-09 dsm_est 0.0161685 nsteps 320 + h 0.0015625 rk_type 0 order 4 acc 1 t 1 dsm 8.83314e-12 dsm_est 4.22807e-12 nsteps 320 + h 0.0015625 rk_type 0 order 4 acc 1 t 1.5 dsm 1.84069e-12 dsm_est 1.48779e-12 nsteps 320 + h 0.0015625 rk_type 0 order 4 acc 1 t 2 dsm 2.23198e-13 dsm_est 3.06e-13 nsteps 320 + h 0.0015625 rk_type 0 order 4 acc 1 t 2.5 dsm 5.57615e-13 dsm_est 3.16293e-14 nsteps 320 + h 0.0015625 rk_type 0 order 4 acc 1 t 3 dsm 6.33215e-12 dsm_est 9.28211e-14 nsteps 320 + h 0.0015625 rk_type 0 order 4 acc 1 t 3.5 dsm 4.31345e-12 dsm_est 1.06725e-12 nsteps 320 + h 0.0015625 rk_type 0 order 4 acc 1 t 4 dsm 5.25911e-12 dsm_est 7.27486e-13 nsteps 320 + h 0.0015625 rk_type 0 order 4 acc 1 t 4.5 dsm 3.00873e-11 dsm_est 8.86785e-13 nsteps 320 + h 0.0015625 rk_type 0 order 4 acc 1 t 5 dsm 1.04948e-12 dsm_est 5.07072e-12 nsteps 320 + h 0.0015625 rk_type 0 order 4 acc 1 t 5.5 dsm 6.97828e-12 dsm_est 1.75823e-13 nsteps 320 + h 0.0015625 rk_type 0 order 4 acc 1 t 6 dsm 5.98205e-11 dsm_est 1.17286e-12 nsteps 320 + h 0.0015625 rk_type 0 order 4 acc 1 t 6.5 dsm 1.87435e-11 dsm_est 1.34855e-11 nsteps 320 + h 0.0015625 rk_type 0 order 4 acc 1 t 7 dsm 6.39659e-10 dsm_est 1.86951e-09 nsteps 320 + h 0.0015625 rk_type 0 order 4 acc 1 t 7.5 dsm 1.83962e-11 dsm_est 2.58837e-10 nsteps 320 + h 0.0015625 rk_type 0 order 4 acc 1 t 8 dsm 1.77418e-10 dsm_est 3.6664e-12 nsteps 320 + h 0.0015625 rk_type 0 order 4 acc 1 t 8.5 dsm 2.78724e-12 dsm_est 2.99588e-11 nsteps 320 + h 0.0015625 rk_type 0 order 4 acc 1 t 9 dsm 2.4955e-11 dsm_est 5.0593e-13 nsteps 320 + h 0.0015625 rk_type 0 order 4 acc 1 t 9.5 dsm 1.29649e-11 dsm_est 4.22112e-12 nsteps 320 + h 0.0015625 rk_type 0 order 4 acc 1 t 10 dsm 4.44459e-12 dsm_est 2.19913e-12 nsteps 320 + h 0.0015625 rk_type 0 order 4 acc 3 t 0.5 dsm 1.12995e-09 dsm_est 5.29229e-05 nsteps 320 + h 0.0015625 rk_type 0 order 4 acc 3 t 1 dsm 8.83314e-12 dsm_est 2.17158e-14 nsteps 320 + h 0.0015625 rk_type 0 order 4 acc 3 t 1.5 dsm 1.84069e-12 dsm_est 1.99723e-14 nsteps 320 + h 0.0015625 rk_type 0 order 4 acc 3 t 2 dsm 2.23198e-13 dsm_est 8.79682e-15 nsteps 320 + h 0.0015625 rk_type 0 order 4 acc 3 t 2.5 dsm 5.57615e-13 dsm_est 7.03822e-15 nsteps 320 + h 0.0015625 rk_type 0 order 4 acc 3 t 3 dsm 6.33215e-12 dsm_est 2.29246e-14 nsteps 320 + h 0.0015625 rk_type 0 order 4 acc 3 t 3.5 dsm 4.31345e-12 dsm_est 2.31473e-14 nsteps 320 + h 0.0015625 rk_type 0 order 4 acc 3 t 4 dsm 5.25911e-12 dsm_est 9.40731e-15 nsteps 320 + h 0.0015625 rk_type 0 order 4 acc 3 t 4.5 dsm 3.00873e-11 dsm_est 4.42611e-15 nsteps 320 + h 0.0015625 rk_type 0 order 4 acc 3 t 5 dsm 1.04948e-12 dsm_est 2.21481e-14 nsteps 320 + h 0.0015625 rk_type 0 order 4 acc 3 t 5.5 dsm 6.97828e-12 dsm_est 1.2278e-14 nsteps 320 + h 0.0015625 rk_type 0 order 4 acc 3 t 6 dsm 5.98205e-11 dsm_est 2.51123e-14 nsteps 320 + h 0.0015625 rk_type 0 order 4 acc 3 t 6.5 dsm 1.87435e-11 dsm_est 2.43406e-12 nsteps 320 + h 0.0015625 rk_type 0 order 4 acc 3 t 7 dsm 6.39659e-10 dsm_est 4.6675e-10 nsteps 320 + h 0.0015625 rk_type 0 order 4 acc 3 t 7.5 dsm 1.83962e-11 dsm_est 2.56334e-11 nsteps 320 + h 0.0015625 rk_type 0 order 4 acc 3 t 8 dsm 1.77418e-10 dsm_est 8.92764e-13 nsteps 320 + h 0.0015625 rk_type 0 order 4 acc 3 t 8.5 dsm 2.78724e-12 dsm_est 3.18282e-13 nsteps 320 + h 0.0015625 rk_type 0 order 4 acc 3 t 9 dsm 2.4955e-11 dsm_est 9.93014e-14 nsteps 320 + h 0.0015625 rk_type 0 order 4 acc 3 t 9.5 dsm 1.29649e-11 dsm_est 2.84939e-13 nsteps 320 + h 0.0015625 rk_type 0 order 4 acc 3 t 10 dsm 4.44459e-12 dsm_est 1.6087e-13 nsteps 320 h 0.0015625 rk_type 0 order 4 acc 2 t 0.5 dsm 1.12995e-09 dsm_est 2.29243e-09 nsteps 480 h 0.0015625 rk_type 0 order 4 acc 2 t 1 dsm 8.83314e-12 dsm_est 1.01708e-13 nsteps 480 h 0.0015625 rk_type 0 order 4 acc 2 t 1.5 dsm 1.84069e-12 dsm_est 3.46845e-13 nsteps 480 @@ -187,46 +187,46 @@ Fixed-step runs: h 0.0015625 rk_type 0 order 4 acc 2 t 9 dsm 2.4955e-11 dsm_est 9.29203e-13 nsteps 480 h 0.0015625 rk_type 0 order 4 acc 2 t 9.5 dsm 1.29649e-11 dsm_est 3.52852e-13 nsteps 480 h 0.0015625 rk_type 0 order 4 acc 2 t 10 dsm 4.44459e-12 dsm_est 1.2586e-13 nsteps 480 - h 0.000390625 rk_type 0 order 4 acc 0 t 0.5 dsm 4.75504e-11 dsm_est 0.000360159 nsteps 1281 - h 0.000390625 rk_type 0 order 4 acc 0 t 1 dsm 8.83253e-12 dsm_est 9.41667e-14 nsteps 1281 - h 0.000390625 rk_type 0 order 4 acc 0 t 1.5 dsm 1.8399e-12 dsm_est 3.31853e-14 nsteps 1280 - h 0.000390625 rk_type 0 order 4 acc 0 t 2 dsm 2.21232e-13 dsm_est 6.92196e-15 nsteps 1280 - h 0.000390625 rk_type 0 order 4 acc 0 t 2.5 dsm 5.57029e-13 dsm_est 7.49969e-16 nsteps 1280 - h 0.000390625 rk_type 0 order 4 acc 0 t 3 dsm 6.33194e-12 dsm_est 2.00962e-15 nsteps 1280 - h 0.000390625 rk_type 0 order 4 acc 0 t 3.5 dsm 4.31407e-12 dsm_est 2.37702e-14 nsteps 1280 - h 0.000390625 rk_type 0 order 4 acc 0 t 4 dsm 5.25853e-12 dsm_est 1.62111e-14 nsteps 1280 - h 0.000390625 rk_type 0 order 4 acc 0 t 4.5 dsm 3.00881e-11 dsm_est 1.97207e-14 nsteps 1281 - h 0.000390625 rk_type 0 order 4 acc 0 t 5 dsm 1.04964e-12 dsm_est 1.12957e-13 nsteps 1281 - h 0.000390625 rk_type 0 order 4 acc 0 t 5.5 dsm 6.97849e-12 dsm_est 3.92461e-15 nsteps 1281 - h 0.000390625 rk_type 0 order 4 acc 0 t 6 dsm 5.9817e-11 dsm_est 2.61272e-14 nsteps 1281 - h 0.000390625 rk_type 0 order 4 acc 0 t 6.5 dsm 1.43381e-11 dsm_est 2.24496e-13 nsteps 1281 - h 0.000390625 rk_type 0 order 4 acc 0 t 7 dsm 2.94602e-12 dsm_est 7.37178e-12 nsteps 1281 - h 0.000390625 rk_type 0 order 4 acc 0 t 7.5 dsm 1.82124e-11 dsm_est 1.0358e-12 nsteps 1281 - h 0.000390625 rk_type 0 order 4 acc 0 t 8 dsm 1.77421e-10 dsm_est 6.91895e-14 nsteps 1281 - h 0.000390625 rk_type 0 order 4 acc 0 t 8.5 dsm 2.81466e-12 dsm_est 6.67292e-13 nsteps 1281 - h 0.000390625 rk_type 0 order 4 acc 0 t 9 dsm 2.496e-11 dsm_est 1.06333e-14 nsteps 1281 - h 0.000390625 rk_type 0 order 4 acc 0 t 9.5 dsm 1.2967e-11 dsm_est 9.36985e-14 nsteps 1281 - h 0.000390625 rk_type 0 order 4 acc 0 t 10 dsm 4.44606e-12 dsm_est 4.86957e-14 nsteps 1281 - h 0.000390625 rk_type 0 order 4 acc 1 t 0.5 dsm 4.75504e-11 dsm_est 4.32867e-07 nsteps 1281 - h 0.000390625 rk_type 0 order 4 acc 1 t 1 dsm 8.83253e-12 dsm_est 1.65206e-16 nsteps 1281 - h 0.000390625 rk_type 0 order 4 acc 1 t 1.5 dsm 1.8399e-12 dsm_est 1.14767e-16 nsteps 1280 - h 0.000390625 rk_type 0 order 4 acc 1 t 2 dsm 2.21232e-13 dsm_est 6.3138e-17 nsteps 1280 - h 0.000390625 rk_type 0 order 4 acc 1 t 2.5 dsm 5.57029e-13 dsm_est 4.78256e-17 nsteps 1280 - h 0.000390625 rk_type 0 order 4 acc 1 t 3 dsm 6.33194e-12 dsm_est 9.84357e-17 nsteps 1280 - h 0.000390625 rk_type 0 order 4 acc 1 t 3.5 dsm 4.31407e-12 dsm_est 1.14709e-16 nsteps 1280 - h 0.000390625 rk_type 0 order 4 acc 1 t 4 dsm 5.25853e-12 dsm_est 6.48108e-17 nsteps 1280 - h 0.000390625 rk_type 0 order 4 acc 1 t 4.5 dsm 3.00881e-11 dsm_est 5.75437e-17 nsteps 1281 - h 0.000390625 rk_type 0 order 4 acc 1 t 5 dsm 1.04964e-12 dsm_est 1.8087e-16 nsteps 1281 - h 0.000390625 rk_type 0 order 4 acc 1 t 5.5 dsm 6.97849e-12 dsm_est 6.30545e-17 nsteps 1281 - h 0.000390625 rk_type 0 order 4 acc 1 t 6 dsm 5.9817e-11 dsm_est 1.32311e-16 nsteps 1281 - h 0.000390625 rk_type 0 order 4 acc 1 t 6.5 dsm 1.43381e-11 dsm_est 9.62831e-15 nsteps 1281 - h 0.000390625 rk_type 0 order 4 acc 1 t 7 dsm 2.94602e-12 dsm_est 1.83666e-12 nsteps 1281 - h 0.000390625 rk_type 0 order 4 acc 1 t 7.5 dsm 1.82124e-11 dsm_est 1.00979e-13 nsteps 1281 - h 0.000390625 rk_type 0 order 4 acc 1 t 8 dsm 1.77421e-10 dsm_est 3.54707e-15 nsteps 1281 - h 0.000390625 rk_type 0 order 4 acc 1 t 8.5 dsm 2.81466e-12 dsm_est 1.71467e-15 nsteps 1281 - h 0.000390625 rk_type 0 order 4 acc 1 t 9 dsm 2.496e-11 dsm_est 4.28593e-16 nsteps 1281 - h 0.000390625 rk_type 0 order 4 acc 1 t 9.5 dsm 1.2967e-11 dsm_est 1.17821e-15 nsteps 1281 - h 0.000390625 rk_type 0 order 4 acc 1 t 10 dsm 4.44606e-12 dsm_est 6.63078e-16 nsteps 1281 + h 0.000390625 rk_type 0 order 4 acc 1 t 0.5 dsm 4.75504e-11 dsm_est 0.000360159 nsteps 1281 + h 0.000390625 rk_type 0 order 4 acc 1 t 1 dsm 8.83253e-12 dsm_est 9.41667e-14 nsteps 1281 + h 0.000390625 rk_type 0 order 4 acc 1 t 1.5 dsm 1.8399e-12 dsm_est 3.31853e-14 nsteps 1280 + h 0.000390625 rk_type 0 order 4 acc 1 t 2 dsm 2.21232e-13 dsm_est 6.92196e-15 nsteps 1280 + h 0.000390625 rk_type 0 order 4 acc 1 t 2.5 dsm 5.57029e-13 dsm_est 7.49969e-16 nsteps 1280 + h 0.000390625 rk_type 0 order 4 acc 1 t 3 dsm 6.33194e-12 dsm_est 2.00962e-15 nsteps 1280 + h 0.000390625 rk_type 0 order 4 acc 1 t 3.5 dsm 4.31407e-12 dsm_est 2.37702e-14 nsteps 1280 + h 0.000390625 rk_type 0 order 4 acc 1 t 4 dsm 5.25853e-12 dsm_est 1.62111e-14 nsteps 1280 + h 0.000390625 rk_type 0 order 4 acc 1 t 4.5 dsm 3.00881e-11 dsm_est 1.97207e-14 nsteps 1281 + h 0.000390625 rk_type 0 order 4 acc 1 t 5 dsm 1.04964e-12 dsm_est 1.12957e-13 nsteps 1281 + h 0.000390625 rk_type 0 order 4 acc 1 t 5.5 dsm 6.97849e-12 dsm_est 3.92461e-15 nsteps 1281 + h 0.000390625 rk_type 0 order 4 acc 1 t 6 dsm 5.9817e-11 dsm_est 2.61272e-14 nsteps 1281 + h 0.000390625 rk_type 0 order 4 acc 1 t 6.5 dsm 1.43381e-11 dsm_est 2.24496e-13 nsteps 1281 + h 0.000390625 rk_type 0 order 4 acc 1 t 7 dsm 2.94602e-12 dsm_est 7.37178e-12 nsteps 1281 + h 0.000390625 rk_type 0 order 4 acc 1 t 7.5 dsm 1.82124e-11 dsm_est 1.0358e-12 nsteps 1281 + h 0.000390625 rk_type 0 order 4 acc 1 t 8 dsm 1.77421e-10 dsm_est 6.91895e-14 nsteps 1281 + h 0.000390625 rk_type 0 order 4 acc 1 t 8.5 dsm 2.81466e-12 dsm_est 6.67292e-13 nsteps 1281 + h 0.000390625 rk_type 0 order 4 acc 1 t 9 dsm 2.496e-11 dsm_est 1.06333e-14 nsteps 1281 + h 0.000390625 rk_type 0 order 4 acc 1 t 9.5 dsm 1.2967e-11 dsm_est 9.36985e-14 nsteps 1281 + h 0.000390625 rk_type 0 order 4 acc 1 t 10 dsm 4.44606e-12 dsm_est 4.86957e-14 nsteps 1281 + h 0.000390625 rk_type 0 order 4 acc 3 t 0.5 dsm 4.75504e-11 dsm_est 4.32867e-07 nsteps 1281 + h 0.000390625 rk_type 0 order 4 acc 3 t 1 dsm 8.83253e-12 dsm_est 1.65206e-16 nsteps 1281 + h 0.000390625 rk_type 0 order 4 acc 3 t 1.5 dsm 1.8399e-12 dsm_est 1.14767e-16 nsteps 1280 + h 0.000390625 rk_type 0 order 4 acc 3 t 2 dsm 2.21232e-13 dsm_est 6.3138e-17 nsteps 1280 + h 0.000390625 rk_type 0 order 4 acc 3 t 2.5 dsm 5.57029e-13 dsm_est 4.78256e-17 nsteps 1280 + h 0.000390625 rk_type 0 order 4 acc 3 t 3 dsm 6.33194e-12 dsm_est 9.84357e-17 nsteps 1280 + h 0.000390625 rk_type 0 order 4 acc 3 t 3.5 dsm 4.31407e-12 dsm_est 1.14709e-16 nsteps 1280 + h 0.000390625 rk_type 0 order 4 acc 3 t 4 dsm 5.25853e-12 dsm_est 6.48108e-17 nsteps 1280 + h 0.000390625 rk_type 0 order 4 acc 3 t 4.5 dsm 3.00881e-11 dsm_est 5.75437e-17 nsteps 1281 + h 0.000390625 rk_type 0 order 4 acc 3 t 5 dsm 1.04964e-12 dsm_est 1.8087e-16 nsteps 1281 + h 0.000390625 rk_type 0 order 4 acc 3 t 5.5 dsm 6.97849e-12 dsm_est 6.30545e-17 nsteps 1281 + h 0.000390625 rk_type 0 order 4 acc 3 t 6 dsm 5.9817e-11 dsm_est 1.32311e-16 nsteps 1281 + h 0.000390625 rk_type 0 order 4 acc 3 t 6.5 dsm 1.43381e-11 dsm_est 9.62831e-15 nsteps 1281 + h 0.000390625 rk_type 0 order 4 acc 3 t 7 dsm 2.94602e-12 dsm_est 1.83666e-12 nsteps 1281 + h 0.000390625 rk_type 0 order 4 acc 3 t 7.5 dsm 1.82124e-11 dsm_est 1.00979e-13 nsteps 1281 + h 0.000390625 rk_type 0 order 4 acc 3 t 8 dsm 1.77421e-10 dsm_est 3.54707e-15 nsteps 1281 + h 0.000390625 rk_type 0 order 4 acc 3 t 8.5 dsm 2.81466e-12 dsm_est 1.71467e-15 nsteps 1281 + h 0.000390625 rk_type 0 order 4 acc 3 t 9 dsm 2.496e-11 dsm_est 4.28593e-16 nsteps 1281 + h 0.000390625 rk_type 0 order 4 acc 3 t 9.5 dsm 1.2967e-11 dsm_est 1.17821e-15 nsteps 1281 + h 0.000390625 rk_type 0 order 4 acc 3 t 10 dsm 4.44606e-12 dsm_est 6.63078e-16 nsteps 1281 h 0.000390625 rk_type 0 order 4 acc 2 t 0.5 dsm 4.75504e-11 dsm_est 2.63435e-10 nsteps 1921 h 0.000390625 rk_type 0 order 4 acc 2 t 1 dsm 8.83253e-12 dsm_est 2.03794e-15 nsteps 1922 h 0.000390625 rk_type 0 order 4 acc 2 t 1.5 dsm 1.8399e-12 dsm_est 3.00814e-14 nsteps 1920 diff --git a/test/unit_tests/arkode/CXX_serial/ark_test_accumerror_brusselator_20_3_1.out b/test/unit_tests/arkode/CXX_serial/ark_test_accumerror_brusselator_20_3_1.out index 3c3e7807b2..e3774e291e 100644 --- a/test/unit_tests/arkode/CXX_serial/ark_test_accumerror_brusselator_20_3_1.out +++ b/test/unit_tests/arkode/CXX_serial/ark_test_accumerror_brusselator_20_3_1.out @@ -7,123 +7,123 @@ Accumulated error estimation test (stiff Brusselator ODE problem): ERK solver, order = 3 Adaptive-step runs: - rtol 0.01 rk_type 1 order 3 acc 0 t 0.5 dsm 0.00199866 dsm_est 0.00993779 nsteps 492 - rtol 0.01 rk_type 1 order 3 acc 0 t 1 dsm 0.00148824 dsm_est 0.00998004 nsteps 473 - rtol 0.01 rk_type 1 order 3 acc 0 t 1.5 dsm 0.00330184 dsm_est 0.00995476 nsteps 459 - rtol 0.01 rk_type 1 order 3 acc 0 t 2 dsm 0.000346469 dsm_est 0.00994631 nsteps 450 - rtol 0.01 rk_type 1 order 3 acc 0 t 2.5 dsm 0.0103541 dsm_est 0.00997759 nsteps 430 - rtol 0.01 rk_type 1 order 3 acc 0 t 3 dsm 0.0108871 dsm_est 0.00988341 nsteps 447 - rtol 0.01 rk_type 1 order 3 acc 0 t 3.5 dsm 0.00245302 dsm_est 0.00996656 nsteps 465 - rtol 0.01 rk_type 1 order 3 acc 0 t 4 dsm 0.00613073 dsm_est 0.00995474 nsteps 464 - rtol 0.01 rk_type 1 order 3 acc 0 t 4.5 dsm 0.00368671 dsm_est 0.00994184 nsteps 464 - rtol 0.01 rk_type 1 order 3 acc 0 t 5 dsm 0.000382639 dsm_est 0.0099621 nsteps 466 - rtol 0.01 rk_type 1 order 3 acc 0 t 5.5 dsm 0.00138001 dsm_est 0.00996202 nsteps 443 - rtol 0.01 rk_type 1 order 3 acc 0 t 6 dsm 0.00204504 dsm_est 0.00995126 nsteps 463 - rtol 0.01 rk_type 1 order 3 acc 0 t 6.5 dsm 0.00544154 dsm_est 0.00991159 nsteps 465 - rtol 0.01 rk_type 1 order 3 acc 0 t 7 dsm 0.00167909 dsm_est 0.00996267 nsteps 459 - rtol 0.01 rk_type 1 order 3 acc 0 t 7.5 dsm 0.00762228 dsm_est 0.0099702 nsteps 464 - rtol 0.01 rk_type 1 order 3 acc 0 t 8 dsm 0.00815849 dsm_est 0.00996685 nsteps 463 - rtol 0.01 rk_type 1 order 3 acc 0 t 8.5 dsm 0.00479833 dsm_est 0.00996162 nsteps 463 - rtol 0.01 rk_type 1 order 3 acc 0 t 9 dsm 0.00530688 dsm_est 0.00991151 nsteps 460 - rtol 0.01 rk_type 1 order 3 acc 0 t 9.5 dsm 0.00453492 dsm_est 0.00996905 nsteps 461 - rtol 0.01 rk_type 1 order 3 acc 0 t 10 dsm 0.000530102 dsm_est 0.00998737 nsteps 461 - rtol 0.01 rk_type 1 order 3 acc 1 t 0.5 dsm 0.00199866 dsm_est 0.00426439 nsteps 492 - rtol 0.01 rk_type 1 order 3 acc 1 t 1 dsm 0.00148824 dsm_est 0.00401684 nsteps 473 - rtol 0.01 rk_type 1 order 3 acc 1 t 1.5 dsm 0.00330184 dsm_est 0.00429906 nsteps 459 - rtol 0.01 rk_type 1 order 3 acc 1 t 2 dsm 0.000346469 dsm_est 0.00422221 nsteps 450 - rtol 0.01 rk_type 1 order 3 acc 1 t 2.5 dsm 0.0103541 dsm_est 0.0039254 nsteps 430 - rtol 0.01 rk_type 1 order 3 acc 1 t 3 dsm 0.0108871 dsm_est 0.00418766 nsteps 447 - rtol 0.01 rk_type 1 order 3 acc 1 t 3.5 dsm 0.00245302 dsm_est 0.00418645 nsteps 465 - rtol 0.01 rk_type 1 order 3 acc 1 t 4 dsm 0.00613073 dsm_est 0.00418211 nsteps 464 - rtol 0.01 rk_type 1 order 3 acc 1 t 4.5 dsm 0.00368671 dsm_est 0.00418783 nsteps 464 - rtol 0.01 rk_type 1 order 3 acc 1 t 5 dsm 0.000382639 dsm_est 0.00393723 nsteps 466 - rtol 0.01 rk_type 1 order 3 acc 1 t 5.5 dsm 0.00138001 dsm_est 0.00421341 nsteps 443 - rtol 0.01 rk_type 1 order 3 acc 1 t 6 dsm 0.00204504 dsm_est 0.00419418 nsteps 463 - rtol 0.01 rk_type 1 order 3 acc 1 t 6.5 dsm 0.00544154 dsm_est 0.00421996 nsteps 465 - rtol 0.01 rk_type 1 order 3 acc 1 t 7 dsm 0.00167909 dsm_est 0.00415345 nsteps 459 - rtol 0.01 rk_type 1 order 3 acc 1 t 7.5 dsm 0.00762228 dsm_est 0.00386309 nsteps 464 - rtol 0.01 rk_type 1 order 3 acc 1 t 8 dsm 0.00815849 dsm_est 0.0039821 nsteps 463 - rtol 0.01 rk_type 1 order 3 acc 1 t 8.5 dsm 0.00479833 dsm_est 0.00427435 nsteps 463 - rtol 0.01 rk_type 1 order 3 acc 1 t 9 dsm 0.00530688 dsm_est 0.004236 nsteps 460 - rtol 0.01 rk_type 1 order 3 acc 1 t 9.5 dsm 0.00453492 dsm_est 0.00415846 nsteps 461 - rtol 0.01 rk_type 1 order 3 acc 1 t 10 dsm 0.000530102 dsm_est 0.00414409 nsteps 461 - rtol 0.0001 rk_type 1 order 3 acc 0 t 0.5 dsm 4.52215e-05 dsm_est 9.69104e-05 nsteps 501 - rtol 0.0001 rk_type 1 order 3 acc 0 t 1 dsm 1.81631e-05 dsm_est 9.49781e-05 nsteps 474 - rtol 0.0001 rk_type 1 order 3 acc 0 t 1.5 dsm 2.77186e-05 dsm_est 9.49662e-05 nsteps 474 - rtol 0.0001 rk_type 1 order 3 acc 0 t 2 dsm 1.52803e-05 dsm_est 9.4909e-05 nsteps 470 - rtol 0.0001 rk_type 1 order 3 acc 0 t 2.5 dsm 4.78098e-05 dsm_est 9.49489e-05 nsteps 464 - rtol 0.0001 rk_type 1 order 3 acc 0 t 3 dsm 2.25476e-05 dsm_est 9.47509e-05 nsteps 465 - rtol 0.0001 rk_type 1 order 3 acc 0 t 3.5 dsm 5.07755e-05 dsm_est 9.47129e-05 nsteps 474 - rtol 0.0001 rk_type 1 order 3 acc 0 t 4 dsm 2.29469e-05 dsm_est 9.49709e-05 nsteps 474 - rtol 0.0001 rk_type 1 order 3 acc 0 t 4.5 dsm 3.88359e-05 dsm_est 9.46293e-05 nsteps 470 - rtol 0.0001 rk_type 1 order 3 acc 0 t 5 dsm 1.51443e-05 dsm_est 9.49444e-05 nsteps 469 - rtol 0.0001 rk_type 1 order 3 acc 0 t 5.5 dsm 1.12906e-05 dsm_est 9.45516e-05 nsteps 470 - rtol 0.0001 rk_type 1 order 3 acc 0 t 6 dsm 2.05734e-05 dsm_est 9.49206e-05 nsteps 474 - rtol 0.0001 rk_type 1 order 3 acc 0 t 6.5 dsm 2.51686e-05 dsm_est 9.49703e-05 nsteps 481 - rtol 0.0001 rk_type 1 order 3 acc 0 t 7 dsm 6.45125e-05 dsm_est 9.93155e-05 nsteps 481 - rtol 0.0001 rk_type 1 order 3 acc 0 t 7.5 dsm 6.30239e-05 dsm_est 9.4983e-05 nsteps 475 - rtol 0.0001 rk_type 1 order 3 acc 0 t 8 dsm 2.85855e-05 dsm_est 9.44898e-05 nsteps 478 - rtol 0.0001 rk_type 1 order 3 acc 0 t 8.5 dsm 4.15619e-05 dsm_est 9.47874e-05 nsteps 480 - rtol 0.0001 rk_type 1 order 3 acc 0 t 9 dsm 9.3894e-06 dsm_est 9.91602e-05 nsteps 475 - rtol 0.0001 rk_type 1 order 3 acc 0 t 9.5 dsm 1.95141e-05 dsm_est 9.49246e-05 nsteps 482 - rtol 0.0001 rk_type 1 order 3 acc 0 t 10 dsm 2.83938e-05 dsm_est 9.5044e-05 nsteps 479 - rtol 0.0001 rk_type 1 order 3 acc 1 t 0.5 dsm 4.52215e-05 dsm_est 4.08107e-05 nsteps 501 - rtol 0.0001 rk_type 1 order 3 acc 1 t 1 dsm 1.81631e-05 dsm_est 4.12007e-05 nsteps 474 - rtol 0.0001 rk_type 1 order 3 acc 1 t 1.5 dsm 2.77186e-05 dsm_est 3.92848e-05 nsteps 474 - rtol 0.0001 rk_type 1 order 3 acc 1 t 2 dsm 1.52803e-05 dsm_est 4.11758e-05 nsteps 470 - rtol 0.0001 rk_type 1 order 3 acc 1 t 2.5 dsm 4.78098e-05 dsm_est 4.06774e-05 nsteps 464 - rtol 0.0001 rk_type 1 order 3 acc 1 t 3 dsm 2.25476e-05 dsm_est 4.05186e-05 nsteps 465 - rtol 0.0001 rk_type 1 order 3 acc 1 t 3.5 dsm 5.07755e-05 dsm_est 3.94363e-05 nsteps 474 - rtol 0.0001 rk_type 1 order 3 acc 1 t 4 dsm 2.29469e-05 dsm_est 4.0612e-05 nsteps 474 - rtol 0.0001 rk_type 1 order 3 acc 1 t 4.5 dsm 3.88359e-05 dsm_est 4.04377e-05 nsteps 470 - rtol 0.0001 rk_type 1 order 3 acc 1 t 5 dsm 1.51443e-05 dsm_est 4.10883e-05 nsteps 469 - rtol 0.0001 rk_type 1 order 3 acc 1 t 5.5 dsm 1.12906e-05 dsm_est 4.03674e-05 nsteps 470 - rtol 0.0001 rk_type 1 order 3 acc 1 t 6 dsm 2.05734e-05 dsm_est 3.92226e-05 nsteps 474 - rtol 0.0001 rk_type 1 order 3 acc 1 t 6.5 dsm 2.51686e-05 dsm_est 4.05458e-05 nsteps 481 - rtol 0.0001 rk_type 1 order 3 acc 1 t 7 dsm 6.45125e-05 dsm_est 4.1002e-05 nsteps 481 - rtol 0.0001 rk_type 1 order 3 acc 1 t 7.5 dsm 6.30239e-05 dsm_est 3.79447e-05 nsteps 475 - rtol 0.0001 rk_type 1 order 3 acc 1 t 8 dsm 2.85855e-05 dsm_est 4.09141e-05 nsteps 478 - rtol 0.0001 rk_type 1 order 3 acc 1 t 8.5 dsm 4.15619e-05 dsm_est 4.07839e-05 nsteps 480 - rtol 0.0001 rk_type 1 order 3 acc 1 t 9 dsm 9.3894e-06 dsm_est 4.10757e-05 nsteps 475 - rtol 0.0001 rk_type 1 order 3 acc 1 t 9.5 dsm 1.95141e-05 dsm_est 3.99021e-05 nsteps 482 - rtol 0.0001 rk_type 1 order 3 acc 1 t 10 dsm 2.83938e-05 dsm_est 4.08542e-05 nsteps 479 - rtol 1e-06 rk_type 1 order 3 acc 0 t 0.5 dsm 6.49367e-08 dsm_est 9.89086e-07 nsteps 550 - rtol 1e-06 rk_type 1 order 3 acc 0 t 1 dsm 5.83524e-07 dsm_est 9.4678e-07 nsteps 488 - rtol 1e-06 rk_type 1 order 3 acc 0 t 1.5 dsm 2.01442e-08 dsm_est 9.47358e-07 nsteps 491 - rtol 1e-06 rk_type 1 order 3 acc 0 t 2 dsm 6.89174e-08 dsm_est 9.48104e-07 nsteps 485 - rtol 1e-06 rk_type 1 order 3 acc 0 t 2.5 dsm 3.25214e-07 dsm_est 9.49113e-07 nsteps 463 - rtol 1e-06 rk_type 1 order 3 acc 0 t 3 dsm 3.48745e-07 dsm_est 9.48334e-07 nsteps 481 - rtol 1e-06 rk_type 1 order 3 acc 0 t 3.5 dsm 1.27971e-06 dsm_est 9.46641e-07 nsteps 484 - rtol 1e-06 rk_type 1 order 3 acc 0 t 4 dsm 5.22124e-07 dsm_est 9.49243e-07 nsteps 485 - rtol 1e-06 rk_type 1 order 3 acc 0 t 4.5 dsm 6.25795e-07 dsm_est 9.48421e-07 nsteps 486 - rtol 1e-06 rk_type 1 order 3 acc 0 t 5 dsm 5.82624e-07 dsm_est 9.48091e-07 nsteps 487 - rtol 1e-06 rk_type 1 order 3 acc 0 t 5.5 dsm 5.29296e-07 dsm_est 9.82269e-07 nsteps 483 - rtol 1e-06 rk_type 1 order 3 acc 0 t 6 dsm 3.47222e-07 dsm_est 9.87002e-07 nsteps 484 - rtol 1e-06 rk_type 1 order 3 acc 0 t 6.5 dsm 8.05504e-07 dsm_est 9.48638e-07 nsteps 477 - rtol 1e-06 rk_type 1 order 3 acc 0 t 7 dsm 4.05624e-08 dsm_est 9.61095e-07 nsteps 487 - rtol 1e-06 rk_type 1 order 3 acc 0 t 7.5 dsm 7.28832e-08 dsm_est 9.4602e-07 nsteps 487 - rtol 1e-06 rk_type 1 order 3 acc 0 t 8 dsm 9.01356e-07 dsm_est 9.48084e-07 nsteps 485 - rtol 1e-06 rk_type 1 order 3 acc 0 t 8.5 dsm 9.82212e-07 dsm_est 9.4573e-07 nsteps 489 - rtol 1e-06 rk_type 1 order 3 acc 0 t 9 dsm 2.03978e-07 dsm_est 9.47478e-07 nsteps 468 - rtol 1e-06 rk_type 1 order 3 acc 0 t 9.5 dsm 2.77163e-07 dsm_est 9.49943e-07 nsteps 475 - rtol 1e-06 rk_type 1 order 3 acc 0 t 10 dsm 4.2482e-07 dsm_est 9.47165e-07 nsteps 476 - rtol 1e-06 rk_type 1 order 3 acc 1 t 0.5 dsm 6.49367e-08 dsm_est 3.45481e-07 nsteps 550 - rtol 1e-06 rk_type 1 order 3 acc 1 t 1 dsm 5.83524e-07 dsm_est 3.92843e-07 nsteps 488 - rtol 1e-06 rk_type 1 order 3 acc 1 t 1.5 dsm 2.01442e-08 dsm_est 3.15167e-07 nsteps 491 - rtol 1e-06 rk_type 1 order 3 acc 1 t 2 dsm 6.89174e-08 dsm_est 3.94168e-07 nsteps 485 - rtol 1e-06 rk_type 1 order 3 acc 1 t 2.5 dsm 3.25214e-07 dsm_est 4.0852e-07 nsteps 463 - rtol 1e-06 rk_type 1 order 3 acc 1 t 3 dsm 3.48745e-07 dsm_est 4.02669e-07 nsteps 481 - rtol 1e-06 rk_type 1 order 3 acc 1 t 3.5 dsm 1.27971e-06 dsm_est 4.10995e-07 nsteps 484 - rtol 1e-06 rk_type 1 order 3 acc 1 t 4 dsm 5.22124e-07 dsm_est 4.06335e-07 nsteps 485 - rtol 1e-06 rk_type 1 order 3 acc 1 t 4.5 dsm 6.25795e-07 dsm_est 3.93901e-07 nsteps 486 - rtol 1e-06 rk_type 1 order 3 acc 1 t 5 dsm 5.82624e-07 dsm_est 4.02844e-07 nsteps 487 - rtol 1e-06 rk_type 1 order 3 acc 1 t 5.5 dsm 5.29296e-07 dsm_est 4.12265e-07 nsteps 483 - rtol 1e-06 rk_type 1 order 3 acc 1 t 6 dsm 3.47222e-07 dsm_est 4.13091e-07 nsteps 484 - rtol 1e-06 rk_type 1 order 3 acc 1 t 6.5 dsm 8.05504e-07 dsm_est 4.05024e-07 nsteps 477 - rtol 1e-06 rk_type 1 order 3 acc 1 t 7 dsm 4.05624e-08 dsm_est 4.06655e-07 nsteps 487 - rtol 1e-06 rk_type 1 order 3 acc 1 t 7.5 dsm 7.28832e-08 dsm_est 4.09645e-07 nsteps 487 - rtol 1e-06 rk_type 1 order 3 acc 1 t 8 dsm 9.01356e-07 dsm_est 4.07695e-07 nsteps 485 - rtol 1e-06 rk_type 1 order 3 acc 1 t 8.5 dsm 9.82212e-07 dsm_est 3.86761e-07 nsteps 489 - rtol 1e-06 rk_type 1 order 3 acc 1 t 9 dsm 2.03978e-07 dsm_est 4.05711e-07 nsteps 468 - rtol 1e-06 rk_type 1 order 3 acc 1 t 9.5 dsm 2.77163e-07 dsm_est 4.05851e-07 nsteps 475 - rtol 1e-06 rk_type 1 order 3 acc 1 t 10 dsm 4.2482e-07 dsm_est 3.92237e-07 nsteps 476 + rtol 0.01 rk_type 1 order 3 acc 1 t 0.5 dsm 0.00199866 dsm_est 0.00993779 nsteps 492 + rtol 0.01 rk_type 1 order 3 acc 1 t 1 dsm 0.00148824 dsm_est 0.00998004 nsteps 473 + rtol 0.01 rk_type 1 order 3 acc 1 t 1.5 dsm 0.00330184 dsm_est 0.00995476 nsteps 459 + rtol 0.01 rk_type 1 order 3 acc 1 t 2 dsm 0.000346469 dsm_est 0.00994631 nsteps 450 + rtol 0.01 rk_type 1 order 3 acc 1 t 2.5 dsm 0.0103541 dsm_est 0.00997759 nsteps 430 + rtol 0.01 rk_type 1 order 3 acc 1 t 3 dsm 0.0108871 dsm_est 0.00988341 nsteps 447 + rtol 0.01 rk_type 1 order 3 acc 1 t 3.5 dsm 0.00245302 dsm_est 0.00996656 nsteps 465 + rtol 0.01 rk_type 1 order 3 acc 1 t 4 dsm 0.00613073 dsm_est 0.00995474 nsteps 464 + rtol 0.01 rk_type 1 order 3 acc 1 t 4.5 dsm 0.00368671 dsm_est 0.00994184 nsteps 464 + rtol 0.01 rk_type 1 order 3 acc 1 t 5 dsm 0.000382639 dsm_est 0.0099621 nsteps 466 + rtol 0.01 rk_type 1 order 3 acc 1 t 5.5 dsm 0.00138001 dsm_est 0.00996202 nsteps 443 + rtol 0.01 rk_type 1 order 3 acc 1 t 6 dsm 0.00204504 dsm_est 0.00995126 nsteps 463 + rtol 0.01 rk_type 1 order 3 acc 1 t 6.5 dsm 0.00544154 dsm_est 0.00991159 nsteps 465 + rtol 0.01 rk_type 1 order 3 acc 1 t 7 dsm 0.00167909 dsm_est 0.00996267 nsteps 459 + rtol 0.01 rk_type 1 order 3 acc 1 t 7.5 dsm 0.00762228 dsm_est 0.0099702 nsteps 464 + rtol 0.01 rk_type 1 order 3 acc 1 t 8 dsm 0.00815849 dsm_est 0.00996685 nsteps 463 + rtol 0.01 rk_type 1 order 3 acc 1 t 8.5 dsm 0.00479833 dsm_est 0.00996162 nsteps 463 + rtol 0.01 rk_type 1 order 3 acc 1 t 9 dsm 0.00530688 dsm_est 0.00991151 nsteps 460 + rtol 0.01 rk_type 1 order 3 acc 1 t 9.5 dsm 0.00453492 dsm_est 0.00996905 nsteps 461 + rtol 0.01 rk_type 1 order 3 acc 1 t 10 dsm 0.000530102 dsm_est 0.00998737 nsteps 461 + rtol 0.01 rk_type 1 order 3 acc 3 t 0.5 dsm 0.00199866 dsm_est 0.00426439 nsteps 492 + rtol 0.01 rk_type 1 order 3 acc 3 t 1 dsm 0.00148824 dsm_est 0.00401684 nsteps 473 + rtol 0.01 rk_type 1 order 3 acc 3 t 1.5 dsm 0.00330184 dsm_est 0.00429906 nsteps 459 + rtol 0.01 rk_type 1 order 3 acc 3 t 2 dsm 0.000346469 dsm_est 0.00422221 nsteps 450 + rtol 0.01 rk_type 1 order 3 acc 3 t 2.5 dsm 0.0103541 dsm_est 0.0039254 nsteps 430 + rtol 0.01 rk_type 1 order 3 acc 3 t 3 dsm 0.0108871 dsm_est 0.00418766 nsteps 447 + rtol 0.01 rk_type 1 order 3 acc 3 t 3.5 dsm 0.00245302 dsm_est 0.00418645 nsteps 465 + rtol 0.01 rk_type 1 order 3 acc 3 t 4 dsm 0.00613073 dsm_est 0.00418211 nsteps 464 + rtol 0.01 rk_type 1 order 3 acc 3 t 4.5 dsm 0.00368671 dsm_est 0.00418783 nsteps 464 + rtol 0.01 rk_type 1 order 3 acc 3 t 5 dsm 0.000382639 dsm_est 0.00393723 nsteps 466 + rtol 0.01 rk_type 1 order 3 acc 3 t 5.5 dsm 0.00138001 dsm_est 0.00421341 nsteps 443 + rtol 0.01 rk_type 1 order 3 acc 3 t 6 dsm 0.00204504 dsm_est 0.00419418 nsteps 463 + rtol 0.01 rk_type 1 order 3 acc 3 t 6.5 dsm 0.00544154 dsm_est 0.00421996 nsteps 465 + rtol 0.01 rk_type 1 order 3 acc 3 t 7 dsm 0.00167909 dsm_est 0.00415345 nsteps 459 + rtol 0.01 rk_type 1 order 3 acc 3 t 7.5 dsm 0.00762228 dsm_est 0.00386309 nsteps 464 + rtol 0.01 rk_type 1 order 3 acc 3 t 8 dsm 0.00815849 dsm_est 0.0039821 nsteps 463 + rtol 0.01 rk_type 1 order 3 acc 3 t 8.5 dsm 0.00479833 dsm_est 0.00427435 nsteps 463 + rtol 0.01 rk_type 1 order 3 acc 3 t 9 dsm 0.00530688 dsm_est 0.004236 nsteps 460 + rtol 0.01 rk_type 1 order 3 acc 3 t 9.5 dsm 0.00453492 dsm_est 0.00415846 nsteps 461 + rtol 0.01 rk_type 1 order 3 acc 3 t 10 dsm 0.000530102 dsm_est 0.00414409 nsteps 461 + rtol 0.0001 rk_type 1 order 3 acc 1 t 0.5 dsm 4.52215e-05 dsm_est 9.69104e-05 nsteps 501 + rtol 0.0001 rk_type 1 order 3 acc 1 t 1 dsm 1.81631e-05 dsm_est 9.49781e-05 nsteps 474 + rtol 0.0001 rk_type 1 order 3 acc 1 t 1.5 dsm 2.77186e-05 dsm_est 9.49662e-05 nsteps 474 + rtol 0.0001 rk_type 1 order 3 acc 1 t 2 dsm 1.52803e-05 dsm_est 9.4909e-05 nsteps 470 + rtol 0.0001 rk_type 1 order 3 acc 1 t 2.5 dsm 4.78098e-05 dsm_est 9.49489e-05 nsteps 464 + rtol 0.0001 rk_type 1 order 3 acc 1 t 3 dsm 2.25476e-05 dsm_est 9.47509e-05 nsteps 465 + rtol 0.0001 rk_type 1 order 3 acc 1 t 3.5 dsm 5.07755e-05 dsm_est 9.47129e-05 nsteps 474 + rtol 0.0001 rk_type 1 order 3 acc 1 t 4 dsm 2.29469e-05 dsm_est 9.49709e-05 nsteps 474 + rtol 0.0001 rk_type 1 order 3 acc 1 t 4.5 dsm 3.88359e-05 dsm_est 9.46293e-05 nsteps 470 + rtol 0.0001 rk_type 1 order 3 acc 1 t 5 dsm 1.51443e-05 dsm_est 9.49444e-05 nsteps 469 + rtol 0.0001 rk_type 1 order 3 acc 1 t 5.5 dsm 1.12906e-05 dsm_est 9.45516e-05 nsteps 470 + rtol 0.0001 rk_type 1 order 3 acc 1 t 6 dsm 2.05734e-05 dsm_est 9.49206e-05 nsteps 474 + rtol 0.0001 rk_type 1 order 3 acc 1 t 6.5 dsm 2.51686e-05 dsm_est 9.49703e-05 nsteps 481 + rtol 0.0001 rk_type 1 order 3 acc 1 t 7 dsm 6.45125e-05 dsm_est 9.93155e-05 nsteps 481 + rtol 0.0001 rk_type 1 order 3 acc 1 t 7.5 dsm 6.30239e-05 dsm_est 9.4983e-05 nsteps 475 + rtol 0.0001 rk_type 1 order 3 acc 1 t 8 dsm 2.85855e-05 dsm_est 9.44898e-05 nsteps 478 + rtol 0.0001 rk_type 1 order 3 acc 1 t 8.5 dsm 4.15619e-05 dsm_est 9.47874e-05 nsteps 480 + rtol 0.0001 rk_type 1 order 3 acc 1 t 9 dsm 9.3894e-06 dsm_est 9.91602e-05 nsteps 475 + rtol 0.0001 rk_type 1 order 3 acc 1 t 9.5 dsm 1.95141e-05 dsm_est 9.49246e-05 nsteps 482 + rtol 0.0001 rk_type 1 order 3 acc 1 t 10 dsm 2.83938e-05 dsm_est 9.5044e-05 nsteps 479 + rtol 0.0001 rk_type 1 order 3 acc 3 t 0.5 dsm 4.52215e-05 dsm_est 4.08107e-05 nsteps 501 + rtol 0.0001 rk_type 1 order 3 acc 3 t 1 dsm 1.81631e-05 dsm_est 4.12007e-05 nsteps 474 + rtol 0.0001 rk_type 1 order 3 acc 3 t 1.5 dsm 2.77186e-05 dsm_est 3.92848e-05 nsteps 474 + rtol 0.0001 rk_type 1 order 3 acc 3 t 2 dsm 1.52803e-05 dsm_est 4.11758e-05 nsteps 470 + rtol 0.0001 rk_type 1 order 3 acc 3 t 2.5 dsm 4.78098e-05 dsm_est 4.06774e-05 nsteps 464 + rtol 0.0001 rk_type 1 order 3 acc 3 t 3 dsm 2.25476e-05 dsm_est 4.05186e-05 nsteps 465 + rtol 0.0001 rk_type 1 order 3 acc 3 t 3.5 dsm 5.07755e-05 dsm_est 3.94363e-05 nsteps 474 + rtol 0.0001 rk_type 1 order 3 acc 3 t 4 dsm 2.29469e-05 dsm_est 4.0612e-05 nsteps 474 + rtol 0.0001 rk_type 1 order 3 acc 3 t 4.5 dsm 3.88359e-05 dsm_est 4.04377e-05 nsteps 470 + rtol 0.0001 rk_type 1 order 3 acc 3 t 5 dsm 1.51443e-05 dsm_est 4.10883e-05 nsteps 469 + rtol 0.0001 rk_type 1 order 3 acc 3 t 5.5 dsm 1.12906e-05 dsm_est 4.03674e-05 nsteps 470 + rtol 0.0001 rk_type 1 order 3 acc 3 t 6 dsm 2.05734e-05 dsm_est 3.92226e-05 nsteps 474 + rtol 0.0001 rk_type 1 order 3 acc 3 t 6.5 dsm 2.51686e-05 dsm_est 4.05458e-05 nsteps 481 + rtol 0.0001 rk_type 1 order 3 acc 3 t 7 dsm 6.45125e-05 dsm_est 4.1002e-05 nsteps 481 + rtol 0.0001 rk_type 1 order 3 acc 3 t 7.5 dsm 6.30239e-05 dsm_est 3.79447e-05 nsteps 475 + rtol 0.0001 rk_type 1 order 3 acc 3 t 8 dsm 2.85855e-05 dsm_est 4.09141e-05 nsteps 478 + rtol 0.0001 rk_type 1 order 3 acc 3 t 8.5 dsm 4.15619e-05 dsm_est 4.07839e-05 nsteps 480 + rtol 0.0001 rk_type 1 order 3 acc 3 t 9 dsm 9.3894e-06 dsm_est 4.10757e-05 nsteps 475 + rtol 0.0001 rk_type 1 order 3 acc 3 t 9.5 dsm 1.95141e-05 dsm_est 3.99021e-05 nsteps 482 + rtol 0.0001 rk_type 1 order 3 acc 3 t 10 dsm 2.83938e-05 dsm_est 4.08542e-05 nsteps 479 + rtol 1e-06 rk_type 1 order 3 acc 1 t 0.5 dsm 6.49367e-08 dsm_est 9.89086e-07 nsteps 550 + rtol 1e-06 rk_type 1 order 3 acc 1 t 1 dsm 5.83524e-07 dsm_est 9.4678e-07 nsteps 488 + rtol 1e-06 rk_type 1 order 3 acc 1 t 1.5 dsm 2.01442e-08 dsm_est 9.47358e-07 nsteps 491 + rtol 1e-06 rk_type 1 order 3 acc 1 t 2 dsm 6.89174e-08 dsm_est 9.48104e-07 nsteps 485 + rtol 1e-06 rk_type 1 order 3 acc 1 t 2.5 dsm 3.25214e-07 dsm_est 9.49113e-07 nsteps 463 + rtol 1e-06 rk_type 1 order 3 acc 1 t 3 dsm 3.48745e-07 dsm_est 9.48334e-07 nsteps 481 + rtol 1e-06 rk_type 1 order 3 acc 1 t 3.5 dsm 1.27971e-06 dsm_est 9.46641e-07 nsteps 484 + rtol 1e-06 rk_type 1 order 3 acc 1 t 4 dsm 5.22124e-07 dsm_est 9.49243e-07 nsteps 485 + rtol 1e-06 rk_type 1 order 3 acc 1 t 4.5 dsm 6.25795e-07 dsm_est 9.48421e-07 nsteps 486 + rtol 1e-06 rk_type 1 order 3 acc 1 t 5 dsm 5.82624e-07 dsm_est 9.48091e-07 nsteps 487 + rtol 1e-06 rk_type 1 order 3 acc 1 t 5.5 dsm 5.29296e-07 dsm_est 9.82269e-07 nsteps 483 + rtol 1e-06 rk_type 1 order 3 acc 1 t 6 dsm 3.47222e-07 dsm_est 9.87002e-07 nsteps 484 + rtol 1e-06 rk_type 1 order 3 acc 1 t 6.5 dsm 8.05504e-07 dsm_est 9.48638e-07 nsteps 477 + rtol 1e-06 rk_type 1 order 3 acc 1 t 7 dsm 4.05624e-08 dsm_est 9.61095e-07 nsteps 487 + rtol 1e-06 rk_type 1 order 3 acc 1 t 7.5 dsm 7.28832e-08 dsm_est 9.4602e-07 nsteps 487 + rtol 1e-06 rk_type 1 order 3 acc 1 t 8 dsm 9.01356e-07 dsm_est 9.48084e-07 nsteps 485 + rtol 1e-06 rk_type 1 order 3 acc 1 t 8.5 dsm 9.82212e-07 dsm_est 9.4573e-07 nsteps 489 + rtol 1e-06 rk_type 1 order 3 acc 1 t 9 dsm 2.03978e-07 dsm_est 9.47478e-07 nsteps 468 + rtol 1e-06 rk_type 1 order 3 acc 1 t 9.5 dsm 2.77163e-07 dsm_est 9.49943e-07 nsteps 475 + rtol 1e-06 rk_type 1 order 3 acc 1 t 10 dsm 4.2482e-07 dsm_est 9.47165e-07 nsteps 476 + rtol 1e-06 rk_type 1 order 3 acc 3 t 0.5 dsm 6.49367e-08 dsm_est 3.45481e-07 nsteps 550 + rtol 1e-06 rk_type 1 order 3 acc 3 t 1 dsm 5.83524e-07 dsm_est 3.92843e-07 nsteps 488 + rtol 1e-06 rk_type 1 order 3 acc 3 t 1.5 dsm 2.01442e-08 dsm_est 3.15167e-07 nsteps 491 + rtol 1e-06 rk_type 1 order 3 acc 3 t 2 dsm 6.89174e-08 dsm_est 3.94168e-07 nsteps 485 + rtol 1e-06 rk_type 1 order 3 acc 3 t 2.5 dsm 3.25214e-07 dsm_est 4.0852e-07 nsteps 463 + rtol 1e-06 rk_type 1 order 3 acc 3 t 3 dsm 3.48745e-07 dsm_est 4.02669e-07 nsteps 481 + rtol 1e-06 rk_type 1 order 3 acc 3 t 3.5 dsm 1.27971e-06 dsm_est 4.10995e-07 nsteps 484 + rtol 1e-06 rk_type 1 order 3 acc 3 t 4 dsm 5.22124e-07 dsm_est 4.06335e-07 nsteps 485 + rtol 1e-06 rk_type 1 order 3 acc 3 t 4.5 dsm 6.25795e-07 dsm_est 3.93901e-07 nsteps 486 + rtol 1e-06 rk_type 1 order 3 acc 3 t 5 dsm 5.82624e-07 dsm_est 4.02844e-07 nsteps 487 + rtol 1e-06 rk_type 1 order 3 acc 3 t 5.5 dsm 5.29296e-07 dsm_est 4.12265e-07 nsteps 483 + rtol 1e-06 rk_type 1 order 3 acc 3 t 6 dsm 3.47222e-07 dsm_est 4.13091e-07 nsteps 484 + rtol 1e-06 rk_type 1 order 3 acc 3 t 6.5 dsm 8.05504e-07 dsm_est 4.05024e-07 nsteps 477 + rtol 1e-06 rk_type 1 order 3 acc 3 t 7 dsm 4.05624e-08 dsm_est 4.06655e-07 nsteps 487 + rtol 1e-06 rk_type 1 order 3 acc 3 t 7.5 dsm 7.28832e-08 dsm_est 4.09645e-07 nsteps 487 + rtol 1e-06 rk_type 1 order 3 acc 3 t 8 dsm 9.01356e-07 dsm_est 4.07695e-07 nsteps 485 + rtol 1e-06 rk_type 1 order 3 acc 3 t 8.5 dsm 9.82212e-07 dsm_est 3.86761e-07 nsteps 489 + rtol 1e-06 rk_type 1 order 3 acc 3 t 9 dsm 2.03978e-07 dsm_est 4.05711e-07 nsteps 468 + rtol 1e-06 rk_type 1 order 3 acc 3 t 9.5 dsm 2.77163e-07 dsm_est 4.05851e-07 nsteps 475 + rtol 1e-06 rk_type 1 order 3 acc 3 t 10 dsm 4.2482e-07 dsm_est 3.92237e-07 nsteps 476 diff --git a/test/unit_tests/arkode/CXX_serial/ark_test_accumerror_brusselator_20_5_0.out b/test/unit_tests/arkode/CXX_serial/ark_test_accumerror_brusselator_20_5_0.out index f59cdceea8..d010eeef4b 100644 --- a/test/unit_tests/arkode/CXX_serial/ark_test_accumerror_brusselator_20_5_0.out +++ b/test/unit_tests/arkode/CXX_serial/ark_test_accumerror_brusselator_20_5_0.out @@ -7,123 +7,123 @@ Accumulated error estimation test (stiff Brusselator ODE problem): DIRK solver, order = 5 Adaptive-step runs: - rtol 0.01 rk_type 0 order 5 acc 0 t 0.5 dsm 7.48644e-05 dsm_est 3.4373e-05 nsteps 9 - rtol 0.01 rk_type 0 order 5 acc 0 t 1 dsm 0.000110257 dsm_est 2.23308e-06 nsteps 5 - rtol 0.01 rk_type 0 order 5 acc 0 t 1.5 dsm 0.00132404 dsm_est 2.08137e-06 nsteps 6 - rtol 0.01 rk_type 0 order 5 acc 0 t 2 dsm 0.00110273 dsm_est 6.3665e-07 nsteps 6 - rtol 0.01 rk_type 0 order 5 acc 0 t 2.5 dsm 6.10485e-05 dsm_est 1.85399e-07 nsteps 6 - rtol 0.01 rk_type 0 order 5 acc 0 t 3 dsm 0.000275174 dsm_est 6.46876e-07 nsteps 6 - rtol 0.01 rk_type 0 order 5 acc 0 t 3.5 dsm 0.00032811 dsm_est 1.68426e-06 nsteps 6 - rtol 0.01 rk_type 0 order 5 acc 0 t 4 dsm 7.35974e-05 dsm_est 4.88814e-07 nsteps 6 - rtol 0.01 rk_type 0 order 5 acc 0 t 4.5 dsm 0.000394423 dsm_est 1.74045e-06 nsteps 6 - rtol 0.01 rk_type 0 order 5 acc 0 t 5 dsm 4.44693e-05 dsm_est 4.77027e-07 nsteps 6 - rtol 0.01 rk_type 0 order 5 acc 0 t 5.5 dsm 0.000153383 dsm_est 6.89334e-07 nsteps 5 - rtol 0.01 rk_type 0 order 5 acc 0 t 6 dsm 0.00039377 dsm_est 3.77896e-06 nsteps 6 - rtol 0.01 rk_type 0 order 5 acc 0 t 6.5 dsm 0.000506258 dsm_est 1.01998e-06 nsteps 6 - rtol 0.01 rk_type 0 order 5 acc 0 t 7 dsm 0.00148699 dsm_est 4.63864e-05 nsteps 12 - rtol 0.01 rk_type 0 order 5 acc 0 t 7.5 dsm 0.000435975 dsm_est 0.000225656 nsteps 4 - rtol 0.01 rk_type 0 order 5 acc 0 t 8 dsm 0.000824606 dsm_est 1.36787e-05 nsteps 7 - rtol 0.01 rk_type 0 order 5 acc 0 t 8.5 dsm 0.00100819 dsm_est 1.09309e-05 nsteps 6 - rtol 0.01 rk_type 0 order 5 acc 0 t 9 dsm 0.00058073 dsm_est 4.52926e-06 nsteps 6 - rtol 0.01 rk_type 0 order 5 acc 0 t 9.5 dsm 6.70214e-05 dsm_est 2.50118e-06 nsteps 6 - rtol 0.01 rk_type 0 order 5 acc 0 t 10 dsm 0.000490488 dsm_est 4.64334e-06 nsteps 6 - rtol 0.01 rk_type 0 order 5 acc 1 t 0.5 dsm 7.48644e-05 dsm_est 6.06577e-06 nsteps 9 - rtol 0.01 rk_type 0 order 5 acc 1 t 1 dsm 0.000110257 dsm_est 4.46624e-07 nsteps 5 - rtol 0.01 rk_type 0 order 5 acc 1 t 1.5 dsm 0.00132404 dsm_est 3.96295e-07 nsteps 6 - rtol 0.01 rk_type 0 order 5 acc 1 t 2 dsm 0.00110273 dsm_est 1.36233e-07 nsteps 6 - rtol 0.01 rk_type 0 order 5 acc 1 t 2.5 dsm 6.10485e-05 dsm_est 5.46756e-08 nsteps 6 - rtol 0.01 rk_type 0 order 5 acc 1 t 3 dsm 0.000275174 dsm_est 1.12723e-07 nsteps 6 - rtol 0.01 rk_type 0 order 5 acc 1 t 3.5 dsm 0.00032811 dsm_est 2.82543e-07 nsteps 6 - rtol 0.01 rk_type 0 order 5 acc 1 t 4 dsm 7.35974e-05 dsm_est 8.23161e-08 nsteps 6 - rtol 0.01 rk_type 0 order 5 acc 1 t 4.5 dsm 0.000394423 dsm_est 2.90774e-07 nsteps 6 - rtol 0.01 rk_type 0 order 5 acc 1 t 5 dsm 4.44693e-05 dsm_est 8.19327e-08 nsteps 6 - rtol 0.01 rk_type 0 order 5 acc 1 t 5.5 dsm 0.000153383 dsm_est 1.38044e-07 nsteps 5 - rtol 0.01 rk_type 0 order 5 acc 1 t 6 dsm 0.00039377 dsm_est 7.71683e-07 nsteps 6 - rtol 0.01 rk_type 0 order 5 acc 1 t 6.5 dsm 0.000506258 dsm_est 2.97917e-07 nsteps 6 - rtol 0.01 rk_type 0 order 5 acc 1 t 7 dsm 0.00148699 dsm_est 6.06974e-06 nsteps 12 - rtol 0.01 rk_type 0 order 5 acc 1 t 7.5 dsm 0.000435975 dsm_est 5.85078e-05 nsteps 4 - rtol 0.01 rk_type 0 order 5 acc 1 t 8 dsm 0.000824606 dsm_est 3.65766e-06 nsteps 7 - rtol 0.01 rk_type 0 order 5 acc 1 t 8.5 dsm 0.00100819 dsm_est 1.8302e-06 nsteps 6 - rtol 0.01 rk_type 0 order 5 acc 1 t 9 dsm 0.00058073 dsm_est 8.22737e-07 nsteps 6 - rtol 0.01 rk_type 0 order 5 acc 1 t 9.5 dsm 6.70214e-05 dsm_est 4.25553e-07 nsteps 6 - rtol 0.01 rk_type 0 order 5 acc 1 t 10 dsm 0.000490488 dsm_est 7.76906e-07 nsteps 6 - rtol 0.0001 rk_type 0 order 5 acc 0 t 0.5 dsm 1.9124e-05 dsm_est 4.10549e-06 nsteps 13 - rtol 0.0001 rk_type 0 order 5 acc 0 t 1 dsm 1.46639e-06 dsm_est 2.99051e-08 nsteps 3 - rtol 0.0001 rk_type 0 order 5 acc 0 t 1.5 dsm 1.49779e-06 dsm_est 2.8794e-08 nsteps 3 - rtol 0.0001 rk_type 0 order 5 acc 0 t 2 dsm 2.48711e-06 dsm_est 5.23997e-08 nsteps 3 - rtol 0.0001 rk_type 0 order 5 acc 0 t 2.5 dsm 8.68487e-07 dsm_est 8.11031e-09 nsteps 3 - rtol 0.0001 rk_type 0 order 5 acc 0 t 3 dsm 4.6854e-06 dsm_est 3.54429e-08 nsteps 4 - rtol 0.0001 rk_type 0 order 5 acc 0 t 3.5 dsm 4.86491e-06 dsm_est 1.27286e-08 nsteps 4 - rtol 0.0001 rk_type 0 order 5 acc 0 t 4 dsm 9.38226e-06 dsm_est 6.18062e-10 nsteps 3 - rtol 0.0001 rk_type 0 order 5 acc 0 t 4.5 dsm 3.64804e-06 dsm_est 5.92484e-10 nsteps 3 - rtol 0.0001 rk_type 0 order 5 acc 0 t 5 dsm 1.20837e-06 dsm_est 1.11283e-08 nsteps 3 - rtol 0.0001 rk_type 0 order 5 acc 0 t 5.5 dsm 1.96373e-05 dsm_est 1.16786e-08 nsteps 3 - rtol 0.0001 rk_type 0 order 5 acc 0 t 6 dsm 6.78601e-06 dsm_est 5.56249e-08 nsteps 4 - rtol 0.0001 rk_type 0 order 5 acc 0 t 6.5 dsm 3.28653e-05 dsm_est 5.49255e-08 nsteps 8 - rtol 0.0001 rk_type 0 order 5 acc 0 t 7 dsm 1.0851e-05 dsm_est 2.95421e-06 nsteps 17 - rtol 0.0001 rk_type 0 order 5 acc 0 t 7.5 dsm 8.11463e-06 dsm_est 7.59043e-08 nsteps 13 - rtol 0.0001 rk_type 0 order 5 acc 0 t 8 dsm 1.12113e-05 dsm_est 6.59216e-08 nsteps 7 - rtol 0.0001 rk_type 0 order 5 acc 0 t 8.5 dsm 7.59151e-06 dsm_est 8.65901e-08 nsteps 5 - rtol 0.0001 rk_type 0 order 5 acc 0 t 9 dsm 1.10466e-05 dsm_est 2.02617e-08 nsteps 4 - rtol 0.0001 rk_type 0 order 5 acc 0 t 9.5 dsm 1.12334e-05 dsm_est 1.10517e-07 nsteps 4 - rtol 0.0001 rk_type 0 order 5 acc 0 t 10 dsm 9.05222e-07 dsm_est 1.64841e-08 nsteps 4 - rtol 0.0001 rk_type 0 order 5 acc 1 t 0.5 dsm 1.9124e-05 dsm_est 4.39976e-07 nsteps 13 - rtol 0.0001 rk_type 0 order 5 acc 1 t 1 dsm 1.46639e-06 dsm_est 9.99964e-09 nsteps 3 - rtol 0.0001 rk_type 0 order 5 acc 1 t 1.5 dsm 1.49779e-06 dsm_est 9.65784e-09 nsteps 3 - rtol 0.0001 rk_type 0 order 5 acc 1 t 2 dsm 2.48711e-06 dsm_est 1.78583e-08 nsteps 3 - rtol 0.0001 rk_type 0 order 5 acc 1 t 2.5 dsm 8.68487e-07 dsm_est 3.53288e-09 nsteps 3 - rtol 0.0001 rk_type 0 order 5 acc 1 t 3 dsm 4.6854e-06 dsm_est 8.97419e-09 nsteps 4 - rtol 0.0001 rk_type 0 order 5 acc 1 t 3.5 dsm 4.86491e-06 dsm_est 3.82982e-09 nsteps 4 - rtol 0.0001 rk_type 0 order 5 acc 1 t 4 dsm 9.38226e-06 dsm_est 3.82569e-10 nsteps 3 - rtol 0.0001 rk_type 0 order 5 acc 1 t 4.5 dsm 3.64804e-06 dsm_est 2.71444e-10 nsteps 3 - rtol 0.0001 rk_type 0 order 5 acc 1 t 5 dsm 1.20837e-06 dsm_est 3.93773e-09 nsteps 3 - rtol 0.0001 rk_type 0 order 5 acc 1 t 5.5 dsm 1.96373e-05 dsm_est 5.04674e-09 nsteps 3 - rtol 0.0001 rk_type 0 order 5 acc 1 t 6 dsm 6.78601e-06 dsm_est 2.03601e-08 nsteps 4 - rtol 0.0001 rk_type 0 order 5 acc 1 t 6.5 dsm 3.28653e-05 dsm_est 1.42284e-08 nsteps 8 - rtol 0.0001 rk_type 0 order 5 acc 1 t 7 dsm 1.0851e-05 dsm_est 2.55057e-07 nsteps 17 - rtol 0.0001 rk_type 0 order 5 acc 1 t 7.5 dsm 8.11463e-06 dsm_est 1.57107e-08 nsteps 13 - rtol 0.0001 rk_type 0 order 5 acc 1 t 8 dsm 1.12113e-05 dsm_est 9.4603e-09 nsteps 7 - rtol 0.0001 rk_type 0 order 5 acc 1 t 8.5 dsm 7.59151e-06 dsm_est 1.73402e-08 nsteps 5 - rtol 0.0001 rk_type 0 order 5 acc 1 t 9 dsm 1.10466e-05 dsm_est 7.67057e-09 nsteps 4 - rtol 0.0001 rk_type 0 order 5 acc 1 t 9.5 dsm 1.12334e-05 dsm_est 3.41962e-08 nsteps 4 - rtol 0.0001 rk_type 0 order 5 acc 1 t 10 dsm 9.05222e-07 dsm_est 8.2015e-09 nsteps 4 - rtol 1e-06 rk_type 0 order 5 acc 0 t 0.5 dsm 1.88136e-07 dsm_est 1.26411e-07 nsteps 20 - rtol 1e-06 rk_type 0 order 5 acc 0 t 1 dsm 3.6815e-08 dsm_est 2.79712e-09 nsteps 5 - rtol 1e-06 rk_type 0 order 5 acc 0 t 1.5 dsm 3.46973e-08 dsm_est 3.51635e-09 nsteps 7 - rtol 1e-06 rk_type 0 order 5 acc 0 t 2 dsm 2.15722e-07 dsm_est 6.11647e-09 nsteps 7 - rtol 1e-06 rk_type 0 order 5 acc 0 t 2.5 dsm 9.55646e-08 dsm_est 1.88588e-09 nsteps 7 - rtol 1e-06 rk_type 0 order 5 acc 0 t 3 dsm 1.61192e-07 dsm_est 1.2608e-08 nsteps 5 - rtol 1e-06 rk_type 0 order 5 acc 0 t 3.5 dsm 4.89781e-08 dsm_est 3.86937e-09 nsteps 5 - rtol 1e-06 rk_type 0 order 5 acc 0 t 4 dsm 2.89671e-09 dsm_est 1.89611e-10 nsteps 5 - rtol 1e-06 rk_type 0 order 5 acc 0 t 4.5 dsm 1.33856e-07 dsm_est 1.34787e-10 nsteps 4 - rtol 1e-06 rk_type 0 order 5 acc 0 t 5 dsm 1.14768e-07 dsm_est 3.89832e-09 nsteps 5 - rtol 1e-06 rk_type 0 order 5 acc 0 t 5.5 dsm 3.35877e-07 dsm_est 5.30354e-09 nsteps 7 - rtol 1e-06 rk_type 0 order 5 acc 0 t 6 dsm 3.66079e-07 dsm_est 3.68188e-09 nsteps 9 - rtol 1e-06 rk_type 0 order 5 acc 0 t 6.5 dsm 1.18284e-06 dsm_est 5.36543e-09 nsteps 13 - rtol 1e-06 rk_type 0 order 5 acc 0 t 7 dsm 6.15151e-07 dsm_est 1.3137e-07 nsteps 32 - rtol 1e-06 rk_type 0 order 5 acc 0 t 7.5 dsm 7.6586e-08 dsm_est 5.37386e-09 nsteps 17 - rtol 1e-06 rk_type 0 order 5 acc 0 t 8 dsm 4.14322e-07 dsm_est 7.83969e-10 nsteps 13 - rtol 1e-06 rk_type 0 order 5 acc 0 t 8.5 dsm 2.50606e-07 dsm_est 1.87037e-08 nsteps 9 - rtol 1e-06 rk_type 0 order 5 acc 0 t 9 dsm 1.33343e-07 dsm_est 8.70204e-09 nsteps 7 - rtol 1e-06 rk_type 0 order 5 acc 0 t 9.5 dsm 1.44237e-07 dsm_est 1.59014e-08 nsteps 6 - rtol 1e-06 rk_type 0 order 5 acc 0 t 10 dsm 1.34853e-07 dsm_est 2.74315e-08 nsteps 6 - rtol 1e-06 rk_type 0 order 5 acc 1 t 0.5 dsm 1.88136e-07 dsm_est 1.55378e-08 nsteps 20 - rtol 1e-06 rk_type 0 order 5 acc 1 t 1 dsm 3.6815e-08 dsm_est 5.70344e-10 nsteps 5 - rtol 1e-06 rk_type 0 order 5 acc 1 t 1.5 dsm 3.46973e-08 dsm_est 5.04993e-10 nsteps 7 - rtol 1e-06 rk_type 0 order 5 acc 1 t 2 dsm 2.15722e-07 dsm_est 8.8739e-10 nsteps 7 - rtol 1e-06 rk_type 0 order 5 acc 1 t 2.5 dsm 9.55646e-08 dsm_est 2.79785e-10 nsteps 7 - rtol 1e-06 rk_type 0 order 5 acc 1 t 3 dsm 1.61192e-07 dsm_est 2.84751e-09 nsteps 5 - rtol 1e-06 rk_type 0 order 5 acc 1 t 3.5 dsm 4.89781e-08 dsm_est 1.08999e-09 nsteps 5 - rtol 1e-06 rk_type 0 order 5 acc 1 t 4 dsm 2.89671e-09 dsm_est 4.1169e-11 nsteps 5 - rtol 1e-06 rk_type 0 order 5 acc 1 t 4.5 dsm 1.33856e-07 dsm_est 3.63099e-11 nsteps 4 - rtol 1e-06 rk_type 0 order 5 acc 1 t 5 dsm 1.14768e-07 dsm_est 7.94799e-10 nsteps 5 - rtol 1e-06 rk_type 0 order 5 acc 1 t 5.5 dsm 3.35877e-07 dsm_est 7.7014e-10 nsteps 7 - rtol 1e-06 rk_type 0 order 5 acc 1 t 6 dsm 3.66079e-07 dsm_est 5.04916e-10 nsteps 9 - rtol 1e-06 rk_type 0 order 5 acc 1 t 6.5 dsm 1.18284e-06 dsm_est 1.10349e-09 nsteps 13 - rtol 1e-06 rk_type 0 order 5 acc 1 t 7 dsm 6.15151e-07 dsm_est 1.15991e-08 nsteps 32 - rtol 1e-06 rk_type 0 order 5 acc 1 t 7.5 dsm 7.6586e-08 dsm_est 6.18109e-10 nsteps 17 - rtol 1e-06 rk_type 0 order 5 acc 1 t 8 dsm 4.14322e-07 dsm_est 1.39091e-10 nsteps 13 - rtol 1e-06 rk_type 0 order 5 acc 1 t 8.5 dsm 2.50606e-07 dsm_est 2.08704e-09 nsteps 9 - rtol 1e-06 rk_type 0 order 5 acc 1 t 9 dsm 1.33343e-07 dsm_est 1.74354e-09 nsteps 7 - rtol 1e-06 rk_type 0 order 5 acc 1 t 9.5 dsm 1.44237e-07 dsm_est 5.67526e-09 nsteps 6 - rtol 1e-06 rk_type 0 order 5 acc 1 t 10 dsm 1.34853e-07 dsm_est 5.58746e-09 nsteps 6 + rtol 0.01 rk_type 0 order 5 acc 1 t 0.5 dsm 7.48644e-05 dsm_est 3.4373e-05 nsteps 9 + rtol 0.01 rk_type 0 order 5 acc 1 t 1 dsm 0.000110257 dsm_est 2.23308e-06 nsteps 5 + rtol 0.01 rk_type 0 order 5 acc 1 t 1.5 dsm 0.00132404 dsm_est 2.08137e-06 nsteps 6 + rtol 0.01 rk_type 0 order 5 acc 1 t 2 dsm 0.00110273 dsm_est 6.3665e-07 nsteps 6 + rtol 0.01 rk_type 0 order 5 acc 1 t 2.5 dsm 6.10485e-05 dsm_est 1.85399e-07 nsteps 6 + rtol 0.01 rk_type 0 order 5 acc 1 t 3 dsm 0.000275174 dsm_est 6.46876e-07 nsteps 6 + rtol 0.01 rk_type 0 order 5 acc 1 t 3.5 dsm 0.00032811 dsm_est 1.68426e-06 nsteps 6 + rtol 0.01 rk_type 0 order 5 acc 1 t 4 dsm 7.35974e-05 dsm_est 4.88814e-07 nsteps 6 + rtol 0.01 rk_type 0 order 5 acc 1 t 4.5 dsm 0.000394423 dsm_est 1.74045e-06 nsteps 6 + rtol 0.01 rk_type 0 order 5 acc 1 t 5 dsm 4.44693e-05 dsm_est 4.77027e-07 nsteps 6 + rtol 0.01 rk_type 0 order 5 acc 1 t 5.5 dsm 0.000153383 dsm_est 6.89334e-07 nsteps 5 + rtol 0.01 rk_type 0 order 5 acc 1 t 6 dsm 0.00039377 dsm_est 3.77896e-06 nsteps 6 + rtol 0.01 rk_type 0 order 5 acc 1 t 6.5 dsm 0.000506258 dsm_est 1.01998e-06 nsteps 6 + rtol 0.01 rk_type 0 order 5 acc 1 t 7 dsm 0.00148699 dsm_est 4.63864e-05 nsteps 12 + rtol 0.01 rk_type 0 order 5 acc 1 t 7.5 dsm 0.000435975 dsm_est 0.000225656 nsteps 4 + rtol 0.01 rk_type 0 order 5 acc 1 t 8 dsm 0.000824606 dsm_est 1.36787e-05 nsteps 7 + rtol 0.01 rk_type 0 order 5 acc 1 t 8.5 dsm 0.00100819 dsm_est 1.09309e-05 nsteps 6 + rtol 0.01 rk_type 0 order 5 acc 1 t 9 dsm 0.00058073 dsm_est 4.52926e-06 nsteps 6 + rtol 0.01 rk_type 0 order 5 acc 1 t 9.5 dsm 6.70214e-05 dsm_est 2.50118e-06 nsteps 6 + rtol 0.01 rk_type 0 order 5 acc 1 t 10 dsm 0.000490488 dsm_est 4.64334e-06 nsteps 6 + rtol 0.01 rk_type 0 order 5 acc 3 t 0.5 dsm 7.48644e-05 dsm_est 6.06577e-06 nsteps 9 + rtol 0.01 rk_type 0 order 5 acc 3 t 1 dsm 0.000110257 dsm_est 4.46624e-07 nsteps 5 + rtol 0.01 rk_type 0 order 5 acc 3 t 1.5 dsm 0.00132404 dsm_est 3.96295e-07 nsteps 6 + rtol 0.01 rk_type 0 order 5 acc 3 t 2 dsm 0.00110273 dsm_est 1.36233e-07 nsteps 6 + rtol 0.01 rk_type 0 order 5 acc 3 t 2.5 dsm 6.10485e-05 dsm_est 5.46756e-08 nsteps 6 + rtol 0.01 rk_type 0 order 5 acc 3 t 3 dsm 0.000275174 dsm_est 1.12723e-07 nsteps 6 + rtol 0.01 rk_type 0 order 5 acc 3 t 3.5 dsm 0.00032811 dsm_est 2.82543e-07 nsteps 6 + rtol 0.01 rk_type 0 order 5 acc 3 t 4 dsm 7.35974e-05 dsm_est 8.23161e-08 nsteps 6 + rtol 0.01 rk_type 0 order 5 acc 3 t 4.5 dsm 0.000394423 dsm_est 2.90774e-07 nsteps 6 + rtol 0.01 rk_type 0 order 5 acc 3 t 5 dsm 4.44693e-05 dsm_est 8.19327e-08 nsteps 6 + rtol 0.01 rk_type 0 order 5 acc 3 t 5.5 dsm 0.000153383 dsm_est 1.38044e-07 nsteps 5 + rtol 0.01 rk_type 0 order 5 acc 3 t 6 dsm 0.00039377 dsm_est 7.71683e-07 nsteps 6 + rtol 0.01 rk_type 0 order 5 acc 3 t 6.5 dsm 0.000506258 dsm_est 2.97917e-07 nsteps 6 + rtol 0.01 rk_type 0 order 5 acc 3 t 7 dsm 0.00148699 dsm_est 6.06974e-06 nsteps 12 + rtol 0.01 rk_type 0 order 5 acc 3 t 7.5 dsm 0.000435975 dsm_est 5.85078e-05 nsteps 4 + rtol 0.01 rk_type 0 order 5 acc 3 t 8 dsm 0.000824606 dsm_est 3.65766e-06 nsteps 7 + rtol 0.01 rk_type 0 order 5 acc 3 t 8.5 dsm 0.00100819 dsm_est 1.8302e-06 nsteps 6 + rtol 0.01 rk_type 0 order 5 acc 3 t 9 dsm 0.00058073 dsm_est 8.22737e-07 nsteps 6 + rtol 0.01 rk_type 0 order 5 acc 3 t 9.5 dsm 6.70214e-05 dsm_est 4.25553e-07 nsteps 6 + rtol 0.01 rk_type 0 order 5 acc 3 t 10 dsm 0.000490488 dsm_est 7.76906e-07 nsteps 6 + rtol 0.0001 rk_type 0 order 5 acc 1 t 0.5 dsm 1.9124e-05 dsm_est 4.10549e-06 nsteps 13 + rtol 0.0001 rk_type 0 order 5 acc 1 t 1 dsm 1.46639e-06 dsm_est 2.99051e-08 nsteps 3 + rtol 0.0001 rk_type 0 order 5 acc 1 t 1.5 dsm 1.49779e-06 dsm_est 2.8794e-08 nsteps 3 + rtol 0.0001 rk_type 0 order 5 acc 1 t 2 dsm 2.48711e-06 dsm_est 5.23997e-08 nsteps 3 + rtol 0.0001 rk_type 0 order 5 acc 1 t 2.5 dsm 8.68487e-07 dsm_est 8.11031e-09 nsteps 3 + rtol 0.0001 rk_type 0 order 5 acc 1 t 3 dsm 4.6854e-06 dsm_est 3.54429e-08 nsteps 4 + rtol 0.0001 rk_type 0 order 5 acc 1 t 3.5 dsm 4.86491e-06 dsm_est 1.27286e-08 nsteps 4 + rtol 0.0001 rk_type 0 order 5 acc 1 t 4 dsm 9.38226e-06 dsm_est 6.18062e-10 nsteps 3 + rtol 0.0001 rk_type 0 order 5 acc 1 t 4.5 dsm 3.64804e-06 dsm_est 5.92484e-10 nsteps 3 + rtol 0.0001 rk_type 0 order 5 acc 1 t 5 dsm 1.20837e-06 dsm_est 1.11283e-08 nsteps 3 + rtol 0.0001 rk_type 0 order 5 acc 1 t 5.5 dsm 1.96373e-05 dsm_est 1.16786e-08 nsteps 3 + rtol 0.0001 rk_type 0 order 5 acc 1 t 6 dsm 6.78601e-06 dsm_est 5.56249e-08 nsteps 4 + rtol 0.0001 rk_type 0 order 5 acc 1 t 6.5 dsm 3.28653e-05 dsm_est 5.49255e-08 nsteps 8 + rtol 0.0001 rk_type 0 order 5 acc 1 t 7 dsm 1.0851e-05 dsm_est 2.95421e-06 nsteps 17 + rtol 0.0001 rk_type 0 order 5 acc 1 t 7.5 dsm 8.11463e-06 dsm_est 7.59043e-08 nsteps 13 + rtol 0.0001 rk_type 0 order 5 acc 1 t 8 dsm 1.12113e-05 dsm_est 6.59216e-08 nsteps 7 + rtol 0.0001 rk_type 0 order 5 acc 1 t 8.5 dsm 7.59151e-06 dsm_est 8.65901e-08 nsteps 5 + rtol 0.0001 rk_type 0 order 5 acc 1 t 9 dsm 1.10466e-05 dsm_est 2.02617e-08 nsteps 4 + rtol 0.0001 rk_type 0 order 5 acc 1 t 9.5 dsm 1.12334e-05 dsm_est 1.10517e-07 nsteps 4 + rtol 0.0001 rk_type 0 order 5 acc 1 t 10 dsm 9.05222e-07 dsm_est 1.64841e-08 nsteps 4 + rtol 0.0001 rk_type 0 order 5 acc 3 t 0.5 dsm 1.9124e-05 dsm_est 4.39976e-07 nsteps 13 + rtol 0.0001 rk_type 0 order 5 acc 3 t 1 dsm 1.46639e-06 dsm_est 9.99964e-09 nsteps 3 + rtol 0.0001 rk_type 0 order 5 acc 3 t 1.5 dsm 1.49779e-06 dsm_est 9.65784e-09 nsteps 3 + rtol 0.0001 rk_type 0 order 5 acc 3 t 2 dsm 2.48711e-06 dsm_est 1.78583e-08 nsteps 3 + rtol 0.0001 rk_type 0 order 5 acc 3 t 2.5 dsm 8.68487e-07 dsm_est 3.53288e-09 nsteps 3 + rtol 0.0001 rk_type 0 order 5 acc 3 t 3 dsm 4.6854e-06 dsm_est 8.97419e-09 nsteps 4 + rtol 0.0001 rk_type 0 order 5 acc 3 t 3.5 dsm 4.86491e-06 dsm_est 3.82982e-09 nsteps 4 + rtol 0.0001 rk_type 0 order 5 acc 3 t 4 dsm 9.38226e-06 dsm_est 3.82569e-10 nsteps 3 + rtol 0.0001 rk_type 0 order 5 acc 3 t 4.5 dsm 3.64804e-06 dsm_est 2.71444e-10 nsteps 3 + rtol 0.0001 rk_type 0 order 5 acc 3 t 5 dsm 1.20837e-06 dsm_est 3.93773e-09 nsteps 3 + rtol 0.0001 rk_type 0 order 5 acc 3 t 5.5 dsm 1.96373e-05 dsm_est 5.04674e-09 nsteps 3 + rtol 0.0001 rk_type 0 order 5 acc 3 t 6 dsm 6.78601e-06 dsm_est 2.03601e-08 nsteps 4 + rtol 0.0001 rk_type 0 order 5 acc 3 t 6.5 dsm 3.28653e-05 dsm_est 1.42284e-08 nsteps 8 + rtol 0.0001 rk_type 0 order 5 acc 3 t 7 dsm 1.0851e-05 dsm_est 2.55057e-07 nsteps 17 + rtol 0.0001 rk_type 0 order 5 acc 3 t 7.5 dsm 8.11463e-06 dsm_est 1.57107e-08 nsteps 13 + rtol 0.0001 rk_type 0 order 5 acc 3 t 8 dsm 1.12113e-05 dsm_est 9.4603e-09 nsteps 7 + rtol 0.0001 rk_type 0 order 5 acc 3 t 8.5 dsm 7.59151e-06 dsm_est 1.73402e-08 nsteps 5 + rtol 0.0001 rk_type 0 order 5 acc 3 t 9 dsm 1.10466e-05 dsm_est 7.67057e-09 nsteps 4 + rtol 0.0001 rk_type 0 order 5 acc 3 t 9.5 dsm 1.12334e-05 dsm_est 3.41962e-08 nsteps 4 + rtol 0.0001 rk_type 0 order 5 acc 3 t 10 dsm 9.05222e-07 dsm_est 8.2015e-09 nsteps 4 + rtol 1e-06 rk_type 0 order 5 acc 1 t 0.5 dsm 1.88136e-07 dsm_est 1.26411e-07 nsteps 20 + rtol 1e-06 rk_type 0 order 5 acc 1 t 1 dsm 3.6815e-08 dsm_est 2.79712e-09 nsteps 5 + rtol 1e-06 rk_type 0 order 5 acc 1 t 1.5 dsm 3.46973e-08 dsm_est 3.51635e-09 nsteps 7 + rtol 1e-06 rk_type 0 order 5 acc 1 t 2 dsm 2.15722e-07 dsm_est 6.11647e-09 nsteps 7 + rtol 1e-06 rk_type 0 order 5 acc 1 t 2.5 dsm 9.55646e-08 dsm_est 1.88588e-09 nsteps 7 + rtol 1e-06 rk_type 0 order 5 acc 1 t 3 dsm 1.61192e-07 dsm_est 1.2608e-08 nsteps 5 + rtol 1e-06 rk_type 0 order 5 acc 1 t 3.5 dsm 4.89781e-08 dsm_est 3.86937e-09 nsteps 5 + rtol 1e-06 rk_type 0 order 5 acc 1 t 4 dsm 2.89671e-09 dsm_est 1.89611e-10 nsteps 5 + rtol 1e-06 rk_type 0 order 5 acc 1 t 4.5 dsm 1.33856e-07 dsm_est 1.34787e-10 nsteps 4 + rtol 1e-06 rk_type 0 order 5 acc 1 t 5 dsm 1.14768e-07 dsm_est 3.89832e-09 nsteps 5 + rtol 1e-06 rk_type 0 order 5 acc 1 t 5.5 dsm 3.35877e-07 dsm_est 5.30354e-09 nsteps 7 + rtol 1e-06 rk_type 0 order 5 acc 1 t 6 dsm 3.66079e-07 dsm_est 3.68188e-09 nsteps 9 + rtol 1e-06 rk_type 0 order 5 acc 1 t 6.5 dsm 1.18284e-06 dsm_est 5.36543e-09 nsteps 13 + rtol 1e-06 rk_type 0 order 5 acc 1 t 7 dsm 6.15151e-07 dsm_est 1.3137e-07 nsteps 32 + rtol 1e-06 rk_type 0 order 5 acc 1 t 7.5 dsm 7.6586e-08 dsm_est 5.37386e-09 nsteps 17 + rtol 1e-06 rk_type 0 order 5 acc 1 t 8 dsm 4.14322e-07 dsm_est 7.83969e-10 nsteps 13 + rtol 1e-06 rk_type 0 order 5 acc 1 t 8.5 dsm 2.50606e-07 dsm_est 1.87037e-08 nsteps 9 + rtol 1e-06 rk_type 0 order 5 acc 1 t 9 dsm 1.33343e-07 dsm_est 8.70204e-09 nsteps 7 + rtol 1e-06 rk_type 0 order 5 acc 1 t 9.5 dsm 1.44237e-07 dsm_est 1.59014e-08 nsteps 6 + rtol 1e-06 rk_type 0 order 5 acc 1 t 10 dsm 1.34853e-07 dsm_est 2.74315e-08 nsteps 6 + rtol 1e-06 rk_type 0 order 5 acc 3 t 0.5 dsm 1.88136e-07 dsm_est 1.55378e-08 nsteps 20 + rtol 1e-06 rk_type 0 order 5 acc 3 t 1 dsm 3.6815e-08 dsm_est 5.70344e-10 nsteps 5 + rtol 1e-06 rk_type 0 order 5 acc 3 t 1.5 dsm 3.46973e-08 dsm_est 5.04993e-10 nsteps 7 + rtol 1e-06 rk_type 0 order 5 acc 3 t 2 dsm 2.15722e-07 dsm_est 8.8739e-10 nsteps 7 + rtol 1e-06 rk_type 0 order 5 acc 3 t 2.5 dsm 9.55646e-08 dsm_est 2.79785e-10 nsteps 7 + rtol 1e-06 rk_type 0 order 5 acc 3 t 3 dsm 1.61192e-07 dsm_est 2.84751e-09 nsteps 5 + rtol 1e-06 rk_type 0 order 5 acc 3 t 3.5 dsm 4.89781e-08 dsm_est 1.08999e-09 nsteps 5 + rtol 1e-06 rk_type 0 order 5 acc 3 t 4 dsm 2.89671e-09 dsm_est 4.1169e-11 nsteps 5 + rtol 1e-06 rk_type 0 order 5 acc 3 t 4.5 dsm 1.33856e-07 dsm_est 3.63099e-11 nsteps 4 + rtol 1e-06 rk_type 0 order 5 acc 3 t 5 dsm 1.14768e-07 dsm_est 7.94799e-10 nsteps 5 + rtol 1e-06 rk_type 0 order 5 acc 3 t 5.5 dsm 3.35877e-07 dsm_est 7.7014e-10 nsteps 7 + rtol 1e-06 rk_type 0 order 5 acc 3 t 6 dsm 3.66079e-07 dsm_est 5.04916e-10 nsteps 9 + rtol 1e-06 rk_type 0 order 5 acc 3 t 6.5 dsm 1.18284e-06 dsm_est 1.10349e-09 nsteps 13 + rtol 1e-06 rk_type 0 order 5 acc 3 t 7 dsm 6.15151e-07 dsm_est 1.15991e-08 nsteps 32 + rtol 1e-06 rk_type 0 order 5 acc 3 t 7.5 dsm 7.6586e-08 dsm_est 6.18109e-10 nsteps 17 + rtol 1e-06 rk_type 0 order 5 acc 3 t 8 dsm 4.14322e-07 dsm_est 1.39091e-10 nsteps 13 + rtol 1e-06 rk_type 0 order 5 acc 3 t 8.5 dsm 2.50606e-07 dsm_est 2.08704e-09 nsteps 9 + rtol 1e-06 rk_type 0 order 5 acc 3 t 9 dsm 1.33343e-07 dsm_est 1.74354e-09 nsteps 7 + rtol 1e-06 rk_type 0 order 5 acc 3 t 9.5 dsm 1.44237e-07 dsm_est 5.67526e-09 nsteps 6 + rtol 1e-06 rk_type 0 order 5 acc 3 t 10 dsm 1.34853e-07 dsm_est 5.58746e-09 nsteps 6 diff --git a/test/unit_tests/arkode/CXX_serial/ark_test_accumerror_kpr_20_-4_1.out b/test/unit_tests/arkode/CXX_serial/ark_test_accumerror_kpr_20_-4_1.out index dd27b7edcb..0375dbd972 100644 --- a/test/unit_tests/arkode/CXX_serial/ark_test_accumerror_kpr_20_-4_1.out +++ b/test/unit_tests/arkode/CXX_serial/ark_test_accumerror_kpr_20_-4_1.out @@ -8,46 +8,46 @@ Accumulated error estimation test (Nonlinear Kvaerno-Prothero-Robinson problem): ERK solver, order = 4 Fixed-step runs: - h 0.005 rk_type 1 order 4 acc 0 t 0.25 dsm 5.99625e-11 dsm_est 2.97934e-09 nsteps 50 - h 0.005 rk_type 1 order 4 acc 0 t 0.5 dsm 1.42974e-10 dsm_est 1.09464e-08 nsteps 50 - h 0.005 rk_type 1 order 4 acc 0 t 0.75 dsm 2.42719e-10 dsm_est 4.48851e-08 nsteps 50 - h 0.005 rk_type 1 order 4 acc 0 t 1 dsm 6.83162e-10 dsm_est 2.52438e-08 nsteps 50 - h 0.005 rk_type 1 order 4 acc 0 t 1.25 dsm 3.14281e-09 dsm_est 6.51615e-07 nsteps 50 - h 0.005 rk_type 1 order 4 acc 0 t 1.5 dsm 4.52762e-09 dsm_est 3.9027e-07 nsteps 50 - h 0.005 rk_type 1 order 4 acc 0 t 1.75 dsm 4.7305e-10 dsm_est 1.03348e-06 nsteps 50 - h 0.005 rk_type 1 order 4 acc 0 t 2 dsm 1.22724e-09 dsm_est 2.15168e-07 nsteps 50 - h 0.005 rk_type 1 order 4 acc 0 t 2.25 dsm 2.1725e-10 dsm_est 4.54458e-08 nsteps 50 - h 0.005 rk_type 1 order 4 acc 0 t 2.5 dsm 1.44845e-10 dsm_est 1.64155e-08 nsteps 50 - h 0.005 rk_type 1 order 4 acc 0 t 2.75 dsm 1.45894e-10 dsm_est 1.12159e-08 nsteps 50 - h 0.005 rk_type 1 order 4 acc 0 t 3 dsm 2.11123e-10 dsm_est 1.10902e-08 nsteps 50 - h 0.005 rk_type 1 order 4 acc 0 t 3.25 dsm 2.34671e-10 dsm_est 3.64366e-09 nsteps 50 - h 0.005 rk_type 1 order 4 acc 0 t 3.5 dsm 1.99557e-10 dsm_est 7.94986e-10 nsteps 50 - h 0.005 rk_type 1 order 4 acc 0 t 3.75 dsm 1.51624e-10 dsm_est 7.64317e-10 nsteps 50 - h 0.005 rk_type 1 order 4 acc 0 t 4 dsm 9.7978e-11 dsm_est 1.84333e-09 nsteps 50 - h 0.005 rk_type 1 order 4 acc 0 t 4.25 dsm 3.36113e-11 dsm_est 3.03774e-09 nsteps 50 - h 0.005 rk_type 1 order 4 acc 0 t 4.5 dsm 7.15711e-11 dsm_est 1.1807e-08 nsteps 50 - h 0.005 rk_type 1 order 4 acc 0 t 4.75 dsm 3.79788e-11 dsm_est 3.66885e-09 nsteps 50 - h 0.005 rk_type 1 order 4 acc 0 t 5 dsm 4.13058e-11 dsm_est 1.68612e-09 nsteps 50 - h 0.005 rk_type 1 order 4 acc 1 t 0.25 dsm 5.99625e-11 dsm_est 1.385e-09 nsteps 50 - h 0.005 rk_type 1 order 4 acc 1 t 0.5 dsm 1.42974e-10 dsm_est 6.89431e-09 nsteps 50 - h 0.005 rk_type 1 order 4 acc 1 t 0.75 dsm 2.42719e-10 dsm_est 2.22335e-08 nsteps 50 - h 0.005 rk_type 1 order 4 acc 1 t 1 dsm 6.83162e-10 dsm_est 7.93747e-09 nsteps 50 - h 0.005 rk_type 1 order 4 acc 1 t 1.25 dsm 3.14281e-09 dsm_est 1.90356e-07 nsteps 50 - h 0.005 rk_type 1 order 4 acc 1 t 1.5 dsm 4.52762e-09 dsm_est 9.7768e-08 nsteps 50 - h 0.005 rk_type 1 order 4 acc 1 t 1.75 dsm 4.7305e-10 dsm_est 3.16168e-07 nsteps 50 - h 0.005 rk_type 1 order 4 acc 1 t 2 dsm 1.22724e-09 dsm_est 6.44894e-08 nsteps 50 - h 0.005 rk_type 1 order 4 acc 1 t 2.25 dsm 2.1725e-10 dsm_est 2.74317e-08 nsteps 50 - h 0.005 rk_type 1 order 4 acc 1 t 2.5 dsm 1.44845e-10 dsm_est 1.14324e-08 nsteps 50 - h 0.005 rk_type 1 order 4 acc 1 t 2.75 dsm 1.45894e-10 dsm_est 5.78824e-09 nsteps 50 - h 0.005 rk_type 1 order 4 acc 1 t 3 dsm 2.11123e-10 dsm_est 4.48643e-09 nsteps 50 - h 0.005 rk_type 1 order 4 acc 1 t 3.25 dsm 2.34671e-10 dsm_est 2.20404e-09 nsteps 50 - h 0.005 rk_type 1 order 4 acc 1 t 3.5 dsm 1.99557e-10 dsm_est 5.41306e-10 nsteps 50 - h 0.005 rk_type 1 order 4 acc 1 t 3.75 dsm 1.51624e-10 dsm_est 4.03452e-10 nsteps 50 - h 0.005 rk_type 1 order 4 acc 1 t 4 dsm 9.7978e-11 dsm_est 9.52633e-10 nsteps 50 - h 0.005 rk_type 1 order 4 acc 1 t 4.25 dsm 3.36113e-11 dsm_est 2.41808e-09 nsteps 50 - h 0.005 rk_type 1 order 4 acc 1 t 4.5 dsm 7.15711e-11 dsm_est 7.4142e-09 nsteps 50 - h 0.005 rk_type 1 order 4 acc 1 t 4.75 dsm 3.79788e-11 dsm_est 1.75558e-09 nsteps 50 - h 0.005 rk_type 1 order 4 acc 1 t 5 dsm 4.13058e-11 dsm_est 1.22629e-09 nsteps 50 + h 0.005 rk_type 1 order 4 acc 1 t 0.25 dsm 5.99625e-11 dsm_est 2.97934e-09 nsteps 50 + h 0.005 rk_type 1 order 4 acc 1 t 0.5 dsm 1.42974e-10 dsm_est 1.09464e-08 nsteps 50 + h 0.005 rk_type 1 order 4 acc 1 t 0.75 dsm 2.42719e-10 dsm_est 4.48851e-08 nsteps 50 + h 0.005 rk_type 1 order 4 acc 1 t 1 dsm 6.83162e-10 dsm_est 2.52438e-08 nsteps 50 + h 0.005 rk_type 1 order 4 acc 1 t 1.25 dsm 3.14281e-09 dsm_est 6.51615e-07 nsteps 50 + h 0.005 rk_type 1 order 4 acc 1 t 1.5 dsm 4.52762e-09 dsm_est 3.9027e-07 nsteps 50 + h 0.005 rk_type 1 order 4 acc 1 t 1.75 dsm 4.7305e-10 dsm_est 1.03348e-06 nsteps 50 + h 0.005 rk_type 1 order 4 acc 1 t 2 dsm 1.22724e-09 dsm_est 2.15168e-07 nsteps 50 + h 0.005 rk_type 1 order 4 acc 1 t 2.25 dsm 2.1725e-10 dsm_est 4.54458e-08 nsteps 50 + h 0.005 rk_type 1 order 4 acc 1 t 2.5 dsm 1.44845e-10 dsm_est 1.64155e-08 nsteps 50 + h 0.005 rk_type 1 order 4 acc 1 t 2.75 dsm 1.45894e-10 dsm_est 1.12159e-08 nsteps 50 + h 0.005 rk_type 1 order 4 acc 1 t 3 dsm 2.11123e-10 dsm_est 1.10902e-08 nsteps 50 + h 0.005 rk_type 1 order 4 acc 1 t 3.25 dsm 2.34671e-10 dsm_est 3.64366e-09 nsteps 50 + h 0.005 rk_type 1 order 4 acc 1 t 3.5 dsm 1.99557e-10 dsm_est 7.94986e-10 nsteps 50 + h 0.005 rk_type 1 order 4 acc 1 t 3.75 dsm 1.51624e-10 dsm_est 7.64317e-10 nsteps 50 + h 0.005 rk_type 1 order 4 acc 1 t 4 dsm 9.7978e-11 dsm_est 1.84333e-09 nsteps 50 + h 0.005 rk_type 1 order 4 acc 1 t 4.25 dsm 3.36113e-11 dsm_est 3.03774e-09 nsteps 50 + h 0.005 rk_type 1 order 4 acc 1 t 4.5 dsm 7.15711e-11 dsm_est 1.1807e-08 nsteps 50 + h 0.005 rk_type 1 order 4 acc 1 t 4.75 dsm 3.79788e-11 dsm_est 3.66885e-09 nsteps 50 + h 0.005 rk_type 1 order 4 acc 1 t 5 dsm 4.13058e-11 dsm_est 1.68612e-09 nsteps 50 + h 0.005 rk_type 1 order 4 acc 3 t 0.25 dsm 5.99625e-11 dsm_est 1.385e-09 nsteps 50 + h 0.005 rk_type 1 order 4 acc 3 t 0.5 dsm 1.42974e-10 dsm_est 6.89431e-09 nsteps 50 + h 0.005 rk_type 1 order 4 acc 3 t 0.75 dsm 2.42719e-10 dsm_est 2.22335e-08 nsteps 50 + h 0.005 rk_type 1 order 4 acc 3 t 1 dsm 6.83162e-10 dsm_est 7.93747e-09 nsteps 50 + h 0.005 rk_type 1 order 4 acc 3 t 1.25 dsm 3.14281e-09 dsm_est 1.90356e-07 nsteps 50 + h 0.005 rk_type 1 order 4 acc 3 t 1.5 dsm 4.52762e-09 dsm_est 9.7768e-08 nsteps 50 + h 0.005 rk_type 1 order 4 acc 3 t 1.75 dsm 4.7305e-10 dsm_est 3.16168e-07 nsteps 50 + h 0.005 rk_type 1 order 4 acc 3 t 2 dsm 1.22724e-09 dsm_est 6.44894e-08 nsteps 50 + h 0.005 rk_type 1 order 4 acc 3 t 2.25 dsm 2.1725e-10 dsm_est 2.74317e-08 nsteps 50 + h 0.005 rk_type 1 order 4 acc 3 t 2.5 dsm 1.44845e-10 dsm_est 1.14324e-08 nsteps 50 + h 0.005 rk_type 1 order 4 acc 3 t 2.75 dsm 1.45894e-10 dsm_est 5.78824e-09 nsteps 50 + h 0.005 rk_type 1 order 4 acc 3 t 3 dsm 2.11123e-10 dsm_est 4.48643e-09 nsteps 50 + h 0.005 rk_type 1 order 4 acc 3 t 3.25 dsm 2.34671e-10 dsm_est 2.20404e-09 nsteps 50 + h 0.005 rk_type 1 order 4 acc 3 t 3.5 dsm 1.99557e-10 dsm_est 5.41306e-10 nsteps 50 + h 0.005 rk_type 1 order 4 acc 3 t 3.75 dsm 1.51624e-10 dsm_est 4.03452e-10 nsteps 50 + h 0.005 rk_type 1 order 4 acc 3 t 4 dsm 9.7978e-11 dsm_est 9.52633e-10 nsteps 50 + h 0.005 rk_type 1 order 4 acc 3 t 4.25 dsm 3.36113e-11 dsm_est 2.41808e-09 nsteps 50 + h 0.005 rk_type 1 order 4 acc 3 t 4.5 dsm 7.15711e-11 dsm_est 7.4142e-09 nsteps 50 + h 0.005 rk_type 1 order 4 acc 3 t 4.75 dsm 3.79788e-11 dsm_est 1.75558e-09 nsteps 50 + h 0.005 rk_type 1 order 4 acc 3 t 5 dsm 4.13058e-11 dsm_est 1.22629e-09 nsteps 50 h 0.005 rk_type 1 order 4 acc 2 t 0.25 dsm 5.99625e-11 dsm_est 9.19534e-10 nsteps 75 h 0.005 rk_type 1 order 4 acc 2 t 0.5 dsm 1.42974e-10 dsm_est 2.10629e-09 nsteps 75 h 0.005 rk_type 1 order 4 acc 2 t 0.75 dsm 2.42719e-10 dsm_est 3.82746e-09 nsteps 75 @@ -68,46 +68,46 @@ Fixed-step runs: h 0.005 rk_type 1 order 4 acc 2 t 4.5 dsm 7.15711e-11 dsm_est 1.10419e-09 nsteps 75 h 0.005 rk_type 1 order 4 acc 2 t 4.75 dsm 3.79788e-11 dsm_est 5.88316e-10 nsteps 75 h 0.005 rk_type 1 order 4 acc 2 t 5 dsm 4.13058e-11 dsm_est 6.25891e-10 nsteps 75 - h 0.00125 rk_type 1 order 4 acc 0 t 0.25 dsm 2.30499e-13 dsm_est 1.18706e-11 nsteps 200 - h 0.00125 rk_type 1 order 4 acc 0 t 0.5 dsm 5.68219e-13 dsm_est 4.29143e-11 nsteps 200 - h 0.00125 rk_type 1 order 4 acc 0 t 0.75 dsm 9.09327e-13 dsm_est 1.75788e-10 nsteps 200 - h 0.00125 rk_type 1 order 4 acc 0 t 1 dsm 2.66412e-12 dsm_est 1.00941e-10 nsteps 200 - h 0.00125 rk_type 1 order 4 acc 0 t 1.25 dsm 1.30178e-11 dsm_est 2.55862e-09 nsteps 200 - h 0.00125 rk_type 1 order 4 acc 0 t 1.5 dsm 1.73534e-11 dsm_est 1.64905e-09 nsteps 200 - h 0.00125 rk_type 1 order 4 acc 0 t 1.75 dsm 3.44384e-12 dsm_est 4.05424e-09 nsteps 200 - h 0.00125 rk_type 1 order 4 acc 0 t 2 dsm 4.73982e-12 dsm_est 8.44242e-10 nsteps 200 - h 0.00125 rk_type 1 order 4 acc 0 t 2.25 dsm 8.24836e-13 dsm_est 1.78198e-10 nsteps 200 - h 0.00125 rk_type 1 order 4 acc 0 t 2.5 dsm 5.58183e-13 dsm_est 6.41367e-11 nsteps 200 - h 0.00125 rk_type 1 order 4 acc 0 t 2.75 dsm 5.66294e-13 dsm_est 4.38146e-11 nsteps 200 - h 0.00125 rk_type 1 order 4 acc 0 t 3 dsm 8.06614e-13 dsm_est 4.34752e-11 nsteps 200 - h 0.00125 rk_type 1 order 4 acc 0 t 3.25 dsm 8.98387e-13 dsm_est 1.416e-11 nsteps 200 - h 0.00125 rk_type 1 order 4 acc 0 t 3.5 dsm 7.63217e-13 dsm_est 3.10184e-12 nsteps 200 - h 0.00125 rk_type 1 order 4 acc 0 t 3.75 dsm 5.78309e-13 dsm_est 2.99367e-12 nsteps 200 - h 0.00125 rk_type 1 order 4 acc 0 t 4 dsm 3.75531e-13 dsm_est 7.27428e-12 nsteps 200 - h 0.00125 rk_type 1 order 4 acc 0 t 4.25 dsm 1.33194e-13 dsm_est 1.19044e-11 nsteps 200 - h 0.00125 rk_type 1 order 4 acc 0 t 4.5 dsm 2.44986e-13 dsm_est 4.62152e-11 nsteps 200 - h 0.00125 rk_type 1 order 4 acc 0 t 4.75 dsm 1.41286e-13 dsm_est 1.51237e-11 nsteps 200 - h 0.00125 rk_type 1 order 4 acc 0 t 5 dsm 1.73009e-13 dsm_est 6.57848e-12 nsteps 200 - h 0.00125 rk_type 1 order 4 acc 1 t 0.25 dsm 2.30499e-13 dsm_est 5.41022e-12 nsteps 200 - h 0.00125 rk_type 1 order 4 acc 1 t 0.5 dsm 5.68219e-13 dsm_est 2.70444e-11 nsteps 200 - h 0.00125 rk_type 1 order 4 acc 1 t 0.75 dsm 9.09327e-13 dsm_est 8.70648e-11 nsteps 200 - h 0.00125 rk_type 1 order 4 acc 1 t 1 dsm 2.66412e-12 dsm_est 3.05099e-11 nsteps 200 - h 0.00125 rk_type 1 order 4 acc 1 t 1.25 dsm 1.30178e-11 dsm_est 7.46262e-10 nsteps 200 - h 0.00125 rk_type 1 order 4 acc 1 t 1.5 dsm 1.73534e-11 dsm_est 3.79955e-10 nsteps 200 - h 0.00125 rk_type 1 order 4 acc 1 t 1.75 dsm 3.44384e-12 dsm_est 1.23858e-09 nsteps 200 - h 0.00125 rk_type 1 order 4 acc 1 t 2 dsm 4.73982e-12 dsm_est 2.49903e-10 nsteps 200 - h 0.00125 rk_type 1 order 4 acc 1 t 2.25 dsm 8.24836e-13 dsm_est 1.07376e-10 nsteps 200 - h 0.00125 rk_type 1 order 4 acc 1 t 2.5 dsm 5.58183e-13 dsm_est 4.46515e-11 nsteps 200 - h 0.00125 rk_type 1 order 4 acc 1 t 2.75 dsm 5.66294e-13 dsm_est 2.26208e-11 nsteps 200 - h 0.00125 rk_type 1 order 4 acc 1 t 3 dsm 8.06614e-13 dsm_est 1.751e-11 nsteps 200 - h 0.00125 rk_type 1 order 4 acc 1 t 3.25 dsm 8.98387e-13 dsm_est 8.58119e-12 nsteps 200 - h 0.00125 rk_type 1 order 4 acc 1 t 3.5 dsm 7.63217e-13 dsm_est 2.09827e-12 nsteps 200 - h 0.00125 rk_type 1 order 4 acc 1 t 3.75 dsm 5.78309e-13 dsm_est 1.57035e-12 nsteps 200 - h 0.00125 rk_type 1 order 4 acc 1 t 4 dsm 3.75531e-13 dsm_est 3.71703e-12 nsteps 200 - h 0.00125 rk_type 1 order 4 acc 1 t 4.25 dsm 1.33194e-13 dsm_est 9.47327e-12 nsteps 200 - h 0.00125 rk_type 1 order 4 acc 1 t 4.5 dsm 2.44986e-13 dsm_est 2.90146e-11 nsteps 200 - h 0.00125 rk_type 1 order 4 acc 1 t 4.75 dsm 1.41286e-13 dsm_est 6.83008e-12 nsteps 200 - h 0.00125 rk_type 1 order 4 acc 1 t 5 dsm 1.73009e-13 dsm_est 4.75325e-12 nsteps 200 + h 0.00125 rk_type 1 order 4 acc 1 t 0.25 dsm 2.30499e-13 dsm_est 1.18706e-11 nsteps 200 + h 0.00125 rk_type 1 order 4 acc 1 t 0.5 dsm 5.68219e-13 dsm_est 4.29143e-11 nsteps 200 + h 0.00125 rk_type 1 order 4 acc 1 t 0.75 dsm 9.09327e-13 dsm_est 1.75788e-10 nsteps 200 + h 0.00125 rk_type 1 order 4 acc 1 t 1 dsm 2.66412e-12 dsm_est 1.00941e-10 nsteps 200 + h 0.00125 rk_type 1 order 4 acc 1 t 1.25 dsm 1.30178e-11 dsm_est 2.55862e-09 nsteps 200 + h 0.00125 rk_type 1 order 4 acc 1 t 1.5 dsm 1.73534e-11 dsm_est 1.64905e-09 nsteps 200 + h 0.00125 rk_type 1 order 4 acc 1 t 1.75 dsm 3.44384e-12 dsm_est 4.05424e-09 nsteps 200 + h 0.00125 rk_type 1 order 4 acc 1 t 2 dsm 4.73982e-12 dsm_est 8.44242e-10 nsteps 200 + h 0.00125 rk_type 1 order 4 acc 1 t 2.25 dsm 8.24836e-13 dsm_est 1.78198e-10 nsteps 200 + h 0.00125 rk_type 1 order 4 acc 1 t 2.5 dsm 5.58183e-13 dsm_est 6.41367e-11 nsteps 200 + h 0.00125 rk_type 1 order 4 acc 1 t 2.75 dsm 5.66294e-13 dsm_est 4.38146e-11 nsteps 200 + h 0.00125 rk_type 1 order 4 acc 1 t 3 dsm 8.06614e-13 dsm_est 4.34752e-11 nsteps 200 + h 0.00125 rk_type 1 order 4 acc 1 t 3.25 dsm 8.98387e-13 dsm_est 1.416e-11 nsteps 200 + h 0.00125 rk_type 1 order 4 acc 1 t 3.5 dsm 7.63217e-13 dsm_est 3.10184e-12 nsteps 200 + h 0.00125 rk_type 1 order 4 acc 1 t 3.75 dsm 5.78309e-13 dsm_est 2.99367e-12 nsteps 200 + h 0.00125 rk_type 1 order 4 acc 1 t 4 dsm 3.75531e-13 dsm_est 7.27428e-12 nsteps 200 + h 0.00125 rk_type 1 order 4 acc 1 t 4.25 dsm 1.33194e-13 dsm_est 1.19044e-11 nsteps 200 + h 0.00125 rk_type 1 order 4 acc 1 t 4.5 dsm 2.44986e-13 dsm_est 4.62152e-11 nsteps 200 + h 0.00125 rk_type 1 order 4 acc 1 t 4.75 dsm 1.41286e-13 dsm_est 1.51237e-11 nsteps 200 + h 0.00125 rk_type 1 order 4 acc 1 t 5 dsm 1.73009e-13 dsm_est 6.57848e-12 nsteps 200 + h 0.00125 rk_type 1 order 4 acc 3 t 0.25 dsm 2.30499e-13 dsm_est 5.41022e-12 nsteps 200 + h 0.00125 rk_type 1 order 4 acc 3 t 0.5 dsm 5.68219e-13 dsm_est 2.70444e-11 nsteps 200 + h 0.00125 rk_type 1 order 4 acc 3 t 0.75 dsm 9.09327e-13 dsm_est 8.70648e-11 nsteps 200 + h 0.00125 rk_type 1 order 4 acc 3 t 1 dsm 2.66412e-12 dsm_est 3.05099e-11 nsteps 200 + h 0.00125 rk_type 1 order 4 acc 3 t 1.25 dsm 1.30178e-11 dsm_est 7.46262e-10 nsteps 200 + h 0.00125 rk_type 1 order 4 acc 3 t 1.5 dsm 1.73534e-11 dsm_est 3.79955e-10 nsteps 200 + h 0.00125 rk_type 1 order 4 acc 3 t 1.75 dsm 3.44384e-12 dsm_est 1.23858e-09 nsteps 200 + h 0.00125 rk_type 1 order 4 acc 3 t 2 dsm 4.73982e-12 dsm_est 2.49903e-10 nsteps 200 + h 0.00125 rk_type 1 order 4 acc 3 t 2.25 dsm 8.24836e-13 dsm_est 1.07376e-10 nsteps 200 + h 0.00125 rk_type 1 order 4 acc 3 t 2.5 dsm 5.58183e-13 dsm_est 4.46515e-11 nsteps 200 + h 0.00125 rk_type 1 order 4 acc 3 t 2.75 dsm 5.66294e-13 dsm_est 2.26208e-11 nsteps 200 + h 0.00125 rk_type 1 order 4 acc 3 t 3 dsm 8.06614e-13 dsm_est 1.751e-11 nsteps 200 + h 0.00125 rk_type 1 order 4 acc 3 t 3.25 dsm 8.98387e-13 dsm_est 8.58119e-12 nsteps 200 + h 0.00125 rk_type 1 order 4 acc 3 t 3.5 dsm 7.63217e-13 dsm_est 2.09827e-12 nsteps 200 + h 0.00125 rk_type 1 order 4 acc 3 t 3.75 dsm 5.78309e-13 dsm_est 1.57035e-12 nsteps 200 + h 0.00125 rk_type 1 order 4 acc 3 t 4 dsm 3.75531e-13 dsm_est 3.71703e-12 nsteps 200 + h 0.00125 rk_type 1 order 4 acc 3 t 4.25 dsm 1.33194e-13 dsm_est 9.47327e-12 nsteps 200 + h 0.00125 rk_type 1 order 4 acc 3 t 4.5 dsm 2.44986e-13 dsm_est 2.90146e-11 nsteps 200 + h 0.00125 rk_type 1 order 4 acc 3 t 4.75 dsm 1.41286e-13 dsm_est 6.83008e-12 nsteps 200 + h 0.00125 rk_type 1 order 4 acc 3 t 5 dsm 1.73009e-13 dsm_est 4.75325e-12 nsteps 200 h 0.00125 rk_type 1 order 4 acc 2 t 0.25 dsm 2.30499e-13 dsm_est 3.47846e-12 nsteps 300 h 0.00125 rk_type 1 order 4 acc 2 t 0.5 dsm 5.68219e-13 dsm_est 8.44621e-12 nsteps 300 h 0.00125 rk_type 1 order 4 acc 2 t 0.75 dsm 9.09327e-13 dsm_est 1.38911e-11 nsteps 300 @@ -128,46 +128,46 @@ Fixed-step runs: h 0.00125 rk_type 1 order 4 acc 2 t 4.5 dsm 2.44986e-13 dsm_est 4.1717e-12 nsteps 300 h 0.00125 rk_type 1 order 4 acc 2 t 4.75 dsm 1.41286e-13 dsm_est 2.17896e-12 nsteps 300 h 0.00125 rk_type 1 order 4 acc 2 t 5 dsm 1.73009e-13 dsm_est 2.38734e-12 nsteps 300 - h 0.0003125 rk_type 1 order 4 acc 0 t 0.25 dsm 9.97977e-16 dsm_est 4.66004e-14 nsteps 800 - h 0.0003125 rk_type 1 order 4 acc 0 t 0.5 dsm 7.34738e-15 dsm_est 1.67783e-13 nsteps 800 - h 0.0003125 rk_type 1 order 4 acc 0 t 0.75 dsm 1.89479e-14 dsm_est 6.87079e-13 nsteps 800 - h 0.0003125 rk_type 1 order 4 acc 0 t 1 dsm 6.41345e-15 dsm_est 3.96662e-13 nsteps 800 - h 0.0003125 rk_type 1 order 4 acc 0 t 1.25 dsm 1.49538e-13 dsm_est 1.00006e-11 nsteps 801 - h 0.0003125 rk_type 1 order 4 acc 0 t 1.5 dsm 1.0257e-13 dsm_est 6.56125e-12 nsteps 801 - h 0.0003125 rk_type 1 order 4 acc 0 t 1.75 dsm 4.74681e-14 dsm_est 1.58483e-11 nsteps 801 - h 0.0003125 rk_type 1 order 4 acc 0 t 2 dsm 3.28771e-14 dsm_est 3.30065e-12 nsteps 801 - h 0.0003125 rk_type 1 order 4 acc 0 t 2.25 dsm 2.08777e-13 dsm_est 6.96642e-13 nsteps 800 - h 0.0003125 rk_type 1 order 4 acc 0 t 2.5 dsm 1.03256e-14 dsm_est 2.50524e-13 nsteps 800 - h 0.0003125 rk_type 1 order 4 acc 0 t 2.75 dsm 1.44079e-14 dsm_est 1.71146e-13 nsteps 800 - h 0.0003125 rk_type 1 order 4 acc 0 t 3 dsm 6.86653e-14 dsm_est 1.69952e-13 nsteps 800 - h 0.0003125 rk_type 1 order 4 acc 0 t 3.25 dsm 4.56716e-14 dsm_est 5.52408e-14 nsteps 800 - h 0.0003125 rk_type 1 order 4 acc 0 t 3.5 dsm 1.14798e-14 dsm_est 1.21147e-14 nsteps 800 - h 0.0003125 rk_type 1 order 4 acc 0 t 3.75 dsm 1.10427e-14 dsm_est 1.17036e-14 nsteps 800 - h 0.0003125 rk_type 1 order 4 acc 0 t 4 dsm 5.31806e-14 dsm_est 2.84886e-14 nsteps 800 - h 0.0003125 rk_type 1 order 4 acc 0 t 4.25 dsm 2.08119e-13 dsm_est 4.65384e-14 nsteps 801 - h 0.0003125 rk_type 1 order 4 acc 0 t 4.5 dsm 1.57233e-14 dsm_est 1.80608e-13 nsteps 801 - h 0.0003125 rk_type 1 order 4 acc 0 t 4.75 dsm 1.39902e-13 dsm_est 5.98529e-14 nsteps 801 - h 0.0003125 rk_type 1 order 4 acc 0 t 5 dsm 7.63042e-14 dsm_est 2.56897e-14 nsteps 801 - h 0.0003125 rk_type 1 order 4 acc 1 t 0.25 dsm 9.97977e-16 dsm_est 2.11337e-14 nsteps 800 - h 0.0003125 rk_type 1 order 4 acc 1 t 0.5 dsm 7.34738e-15 dsm_est 1.05726e-13 nsteps 800 - h 0.0003125 rk_type 1 order 4 acc 1 t 0.75 dsm 1.89479e-14 dsm_est 3.40303e-13 nsteps 800 - h 0.0003125 rk_type 1 order 4 acc 1 t 1 dsm 6.41345e-15 dsm_est 1.18696e-13 nsteps 800 - h 0.0003125 rk_type 1 order 4 acc 1 t 1.25 dsm 1.49538e-13 dsm_est 2.91382e-12 nsteps 801 - h 0.0003125 rk_type 1 order 4 acc 1 t 1.5 dsm 1.0257e-13 dsm_est 1.48008e-12 nsteps 801 - h 0.0003125 rk_type 1 order 4 acc 1 t 1.75 dsm 4.74681e-14 dsm_est 4.83572e-12 nsteps 801 - h 0.0003125 rk_type 1 order 4 acc 1 t 2 dsm 3.28771e-14 dsm_est 9.73028e-13 nsteps 801 - h 0.0003125 rk_type 1 order 4 acc 1 t 2.25 dsm 2.08777e-13 dsm_est 4.1965e-13 nsteps 800 - h 0.0003125 rk_type 1 order 4 acc 1 t 2.5 dsm 1.03256e-14 dsm_est 1.74409e-13 nsteps 800 - h 0.0003125 rk_type 1 order 4 acc 1 t 2.75 dsm 1.44079e-14 dsm_est 8.83656e-14 nsteps 800 - h 0.0003125 rk_type 1 order 4 acc 1 t 3 dsm 6.86653e-14 dsm_est 6.83819e-14 nsteps 800 - h 0.0003125 rk_type 1 order 4 acc 1 t 3.25 dsm 4.56716e-14 dsm_est 3.34939e-14 nsteps 800 - h 0.0003125 rk_type 1 order 4 acc 1 t 3.5 dsm 1.14798e-14 dsm_est 8.18506e-15 nsteps 800 - h 0.0003125 rk_type 1 order 4 acc 1 t 3.75 dsm 1.10427e-14 dsm_est 6.13312e-15 nsteps 800 - h 0.0003125 rk_type 1 order 4 acc 1 t 4 dsm 5.31806e-14 dsm_est 1.45159e-14 nsteps 800 - h 0.0003125 rk_type 1 order 4 acc 1 t 4.25 dsm 2.08119e-13 dsm_est 3.69873e-14 nsteps 801 - h 0.0003125 rk_type 1 order 4 acc 1 t 4.5 dsm 1.57233e-14 dsm_est 1.13245e-13 nsteps 801 - h 0.0003125 rk_type 1 order 4 acc 1 t 4.75 dsm 1.39902e-13 dsm_est 2.66213e-14 nsteps 801 - h 0.0003125 rk_type 1 order 4 acc 1 t 5 dsm 7.63042e-14 dsm_est 1.85072e-14 nsteps 801 + h 0.0003125 rk_type 1 order 4 acc 1 t 0.25 dsm 9.97977e-16 dsm_est 4.66004e-14 nsteps 800 + h 0.0003125 rk_type 1 order 4 acc 1 t 0.5 dsm 7.34738e-15 dsm_est 1.67783e-13 nsteps 800 + h 0.0003125 rk_type 1 order 4 acc 1 t 0.75 dsm 1.89479e-14 dsm_est 6.87079e-13 nsteps 800 + h 0.0003125 rk_type 1 order 4 acc 1 t 1 dsm 6.41345e-15 dsm_est 3.96662e-13 nsteps 800 + h 0.0003125 rk_type 1 order 4 acc 1 t 1.25 dsm 1.49538e-13 dsm_est 1.00006e-11 nsteps 801 + h 0.0003125 rk_type 1 order 4 acc 1 t 1.5 dsm 1.0257e-13 dsm_est 6.56125e-12 nsteps 801 + h 0.0003125 rk_type 1 order 4 acc 1 t 1.75 dsm 4.74681e-14 dsm_est 1.58483e-11 nsteps 801 + h 0.0003125 rk_type 1 order 4 acc 1 t 2 dsm 3.28771e-14 dsm_est 3.30065e-12 nsteps 801 + h 0.0003125 rk_type 1 order 4 acc 1 t 2.25 dsm 2.08777e-13 dsm_est 6.96642e-13 nsteps 800 + h 0.0003125 rk_type 1 order 4 acc 1 t 2.5 dsm 1.03256e-14 dsm_est 2.50524e-13 nsteps 800 + h 0.0003125 rk_type 1 order 4 acc 1 t 2.75 dsm 1.44079e-14 dsm_est 1.71146e-13 nsteps 800 + h 0.0003125 rk_type 1 order 4 acc 1 t 3 dsm 6.86653e-14 dsm_est 1.69952e-13 nsteps 800 + h 0.0003125 rk_type 1 order 4 acc 1 t 3.25 dsm 4.56716e-14 dsm_est 5.52408e-14 nsteps 800 + h 0.0003125 rk_type 1 order 4 acc 1 t 3.5 dsm 1.14798e-14 dsm_est 1.21147e-14 nsteps 800 + h 0.0003125 rk_type 1 order 4 acc 1 t 3.75 dsm 1.10427e-14 dsm_est 1.17036e-14 nsteps 800 + h 0.0003125 rk_type 1 order 4 acc 1 t 4 dsm 5.31806e-14 dsm_est 2.84886e-14 nsteps 800 + h 0.0003125 rk_type 1 order 4 acc 1 t 4.25 dsm 2.08119e-13 dsm_est 4.65384e-14 nsteps 801 + h 0.0003125 rk_type 1 order 4 acc 1 t 4.5 dsm 1.57233e-14 dsm_est 1.80608e-13 nsteps 801 + h 0.0003125 rk_type 1 order 4 acc 1 t 4.75 dsm 1.39902e-13 dsm_est 5.98529e-14 nsteps 801 + h 0.0003125 rk_type 1 order 4 acc 1 t 5 dsm 7.63042e-14 dsm_est 2.56897e-14 nsteps 801 + h 0.0003125 rk_type 1 order 4 acc 3 t 0.25 dsm 9.97977e-16 dsm_est 2.11337e-14 nsteps 800 + h 0.0003125 rk_type 1 order 4 acc 3 t 0.5 dsm 7.34738e-15 dsm_est 1.05726e-13 nsteps 800 + h 0.0003125 rk_type 1 order 4 acc 3 t 0.75 dsm 1.89479e-14 dsm_est 3.40303e-13 nsteps 800 + h 0.0003125 rk_type 1 order 4 acc 3 t 1 dsm 6.41345e-15 dsm_est 1.18696e-13 nsteps 800 + h 0.0003125 rk_type 1 order 4 acc 3 t 1.25 dsm 1.49538e-13 dsm_est 2.91382e-12 nsteps 801 + h 0.0003125 rk_type 1 order 4 acc 3 t 1.5 dsm 1.0257e-13 dsm_est 1.48008e-12 nsteps 801 + h 0.0003125 rk_type 1 order 4 acc 3 t 1.75 dsm 4.74681e-14 dsm_est 4.83572e-12 nsteps 801 + h 0.0003125 rk_type 1 order 4 acc 3 t 2 dsm 3.28771e-14 dsm_est 9.73028e-13 nsteps 801 + h 0.0003125 rk_type 1 order 4 acc 3 t 2.25 dsm 2.08777e-13 dsm_est 4.1965e-13 nsteps 800 + h 0.0003125 rk_type 1 order 4 acc 3 t 2.5 dsm 1.03256e-14 dsm_est 1.74409e-13 nsteps 800 + h 0.0003125 rk_type 1 order 4 acc 3 t 2.75 dsm 1.44079e-14 dsm_est 8.83656e-14 nsteps 800 + h 0.0003125 rk_type 1 order 4 acc 3 t 3 dsm 6.86653e-14 dsm_est 6.83819e-14 nsteps 800 + h 0.0003125 rk_type 1 order 4 acc 3 t 3.25 dsm 4.56716e-14 dsm_est 3.34939e-14 nsteps 800 + h 0.0003125 rk_type 1 order 4 acc 3 t 3.5 dsm 1.14798e-14 dsm_est 8.18506e-15 nsteps 800 + h 0.0003125 rk_type 1 order 4 acc 3 t 3.75 dsm 1.10427e-14 dsm_est 6.13312e-15 nsteps 800 + h 0.0003125 rk_type 1 order 4 acc 3 t 4 dsm 5.31806e-14 dsm_est 1.45159e-14 nsteps 800 + h 0.0003125 rk_type 1 order 4 acc 3 t 4.25 dsm 2.08119e-13 dsm_est 3.69873e-14 nsteps 801 + h 0.0003125 rk_type 1 order 4 acc 3 t 4.5 dsm 1.57233e-14 dsm_est 1.13245e-13 nsteps 801 + h 0.0003125 rk_type 1 order 4 acc 3 t 4.75 dsm 1.39902e-13 dsm_est 2.66213e-14 nsteps 801 + h 0.0003125 rk_type 1 order 4 acc 3 t 5 dsm 7.63042e-14 dsm_est 1.85072e-14 nsteps 801 h 0.0003125 rk_type 1 order 4 acc 2 t 0.25 dsm 9.97977e-16 dsm_est 1.35296e-14 nsteps 1200 h 0.0003125 rk_type 1 order 4 acc 2 t 0.5 dsm 7.34738e-15 dsm_est 3.14131e-14 nsteps 1200 h 0.0003125 rk_type 1 order 4 acc 2 t 0.75 dsm 1.89479e-14 dsm_est 6.96153e-14 nsteps 1200 @@ -188,46 +188,46 @@ Fixed-step runs: h 0.0003125 rk_type 1 order 4 acc 2 t 4.5 dsm 1.57233e-14 dsm_est 3.54399e-14 nsteps 1201 h 0.0003125 rk_type 1 order 4 acc 2 t 4.75 dsm 1.39902e-13 dsm_est 2.1045e-13 nsteps 1201 h 0.0003125 rk_type 1 order 4 acc 2 t 5 dsm 7.63042e-14 dsm_est 1.1047e-13 nsteps 1201 - h 7.8125e-05 rk_type 1 order 4 acc 0 t 0.25 dsm 1.20076e-14 dsm_est 1.82253e-16 nsteps 3200 - h 7.8125e-05 rk_type 1 order 4 acc 0 t 0.5 dsm 6.92895e-14 dsm_est 6.55669e-16 nsteps 3201 - h 7.8125e-05 rk_type 1 order 4 acc 0 t 0.75 dsm 7.1887e-14 dsm_est 2.68471e-15 nsteps 3200 - h 7.8125e-05 rk_type 1 order 4 acc 0 t 1 dsm 5.29714e-14 dsm_est 1.55185e-15 nsteps 3200 - h 7.8125e-05 rk_type 1 order 4 acc 0 t 1.25 dsm 4.54758e-13 dsm_est 3.90711e-14 nsteps 3201 - h 7.8125e-05 rk_type 1 order 4 acc 0 t 1.5 dsm 1.61784e-13 dsm_est 2.57413e-14 nsteps 3201 - h 7.8125e-05 rk_type 1 order 4 acc 0 t 1.75 dsm 1.4649e-13 dsm_est 6.1914e-14 nsteps 3201 - h 7.8125e-05 rk_type 1 order 4 acc 0 t 2 dsm 6.85301e-14 dsm_est 1.28969e-14 nsteps 3201 - h 7.8125e-05 rk_type 1 order 4 acc 0 t 2.25 dsm 3.74507e-13 dsm_est 2.72291e-15 nsteps 3201 - h 7.8125e-05 rk_type 1 order 4 acc 0 t 2.5 dsm 1.92671e-14 dsm_est 9.81217e-16 nsteps 3201 - h 7.8125e-05 rk_type 1 order 4 acc 0 t 2.75 dsm 1.93516e-14 dsm_est 6.71729e-16 nsteps 3201 - h 7.8125e-05 rk_type 1 order 4 acc 0 t 3 dsm 1.23711e-13 dsm_est 6.65622e-16 nsteps 3201 - h 7.8125e-05 rk_type 1 order 4 acc 0 t 3.25 dsm 8.16997e-14 dsm_est 2.16207e-16 nsteps 3201 - h 7.8125e-05 rk_type 1 order 4 acc 0 t 3.5 dsm 1.95956e-14 dsm_est 4.74185e-17 nsteps 3201 - h 7.8125e-05 rk_type 1 order 4 acc 0 t 3.75 dsm 2.16401e-14 dsm_est 4.58122e-17 nsteps 3201 - h 7.8125e-05 rk_type 1 order 4 acc 0 t 4 dsm 9.37664e-14 dsm_est 1.11469e-16 nsteps 3201 - h 7.8125e-05 rk_type 1 order 4 acc 0 t 4.25 dsm 2.10442e-13 dsm_est 1.82276e-16 nsteps 3201 - h 7.8125e-05 rk_type 1 order 4 acc 0 t 4.5 dsm 1.64627e-14 dsm_est 7.11037e-16 nsteps 3201 - h 7.8125e-05 rk_type 1 order 4 acc 0 t 4.75 dsm 1.39177e-13 dsm_est 2.35957e-16 nsteps 3201 - h 7.8125e-05 rk_type 1 order 4 acc 0 t 5 dsm 7.51104e-14 dsm_est 1.00425e-16 nsteps 3201 - h 7.8125e-05 rk_type 1 order 4 acc 1 t 0.25 dsm 1.20076e-14 dsm_est 8.25514e-17 nsteps 3200 - h 7.8125e-05 rk_type 1 order 4 acc 1 t 0.5 dsm 6.92895e-14 dsm_est 4.12935e-16 nsteps 3201 - h 7.8125e-05 rk_type 1 order 4 acc 1 t 0.75 dsm 7.1887e-14 dsm_est 1.32929e-15 nsteps 3200 - h 7.8125e-05 rk_type 1 order 4 acc 1 t 1 dsm 5.29714e-14 dsm_est 4.63079e-16 nsteps 3200 - h 7.8125e-05 rk_type 1 order 4 acc 1 t 1.25 dsm 4.54758e-13 dsm_est 1.13947e-14 nsteps 3201 - h 7.8125e-05 rk_type 1 order 4 acc 1 t 1.5 dsm 1.61784e-13 dsm_est 5.78442e-15 nsteps 3201 - h 7.8125e-05 rk_type 1 order 4 acc 1 t 1.75 dsm 1.4649e-13 dsm_est 1.89102e-14 nsteps 3201 - h 7.8125e-05 rk_type 1 order 4 acc 1 t 2 dsm 6.85301e-14 dsm_est 3.80224e-15 nsteps 3201 - h 7.8125e-05 rk_type 1 order 4 acc 1 t 2.25 dsm 3.74507e-13 dsm_est 1.6387e-15 nsteps 3201 - h 7.8125e-05 rk_type 1 order 4 acc 1 t 2.5 dsm 1.92671e-14 dsm_est 6.81275e-16 nsteps 3201 - h 7.8125e-05 rk_type 1 order 4 acc 1 t 2.75 dsm 1.93516e-14 dsm_est 3.45213e-16 nsteps 3201 - h 7.8125e-05 rk_type 1 order 4 acc 1 t 3 dsm 1.23711e-13 dsm_est 2.67136e-16 nsteps 3201 - h 7.8125e-05 rk_type 1 order 4 acc 1 t 3.25 dsm 8.16997e-14 dsm_est 1.30768e-16 nsteps 3201 - h 7.8125e-05 rk_type 1 order 4 acc 1 t 3.5 dsm 1.95956e-14 dsm_est 3.19583e-17 nsteps 3201 - h 7.8125e-05 rk_type 1 order 4 acc 1 t 3.75 dsm 2.16401e-14 dsm_est 2.39388e-17 nsteps 3201 - h 7.8125e-05 rk_type 1 order 4 acc 1 t 4 dsm 9.37664e-14 dsm_est 5.67508e-17 nsteps 3201 - h 7.8125e-05 rk_type 1 order 4 acc 1 t 4.25 dsm 2.10442e-13 dsm_est 1.44544e-16 nsteps 3201 - h 7.8125e-05 rk_type 1 order 4 acc 1 t 4.5 dsm 1.64627e-14 dsm_est 4.4406e-16 nsteps 3201 - h 7.8125e-05 rk_type 1 order 4 acc 1 t 4.75 dsm 1.39177e-13 dsm_est 1.03927e-16 nsteps 3201 - h 7.8125e-05 rk_type 1 order 4 acc 1 t 5 dsm 7.51104e-14 dsm_est 7.26595e-17 nsteps 3201 + h 7.8125e-05 rk_type 1 order 4 acc 1 t 0.25 dsm 1.20076e-14 dsm_est 1.82253e-16 nsteps 3200 + h 7.8125e-05 rk_type 1 order 4 acc 1 t 0.5 dsm 6.92895e-14 dsm_est 6.55669e-16 nsteps 3201 + h 7.8125e-05 rk_type 1 order 4 acc 1 t 0.75 dsm 7.1887e-14 dsm_est 2.68471e-15 nsteps 3200 + h 7.8125e-05 rk_type 1 order 4 acc 1 t 1 dsm 5.29714e-14 dsm_est 1.55185e-15 nsteps 3200 + h 7.8125e-05 rk_type 1 order 4 acc 1 t 1.25 dsm 4.54758e-13 dsm_est 3.90711e-14 nsteps 3201 + h 7.8125e-05 rk_type 1 order 4 acc 1 t 1.5 dsm 1.61784e-13 dsm_est 2.57413e-14 nsteps 3201 + h 7.8125e-05 rk_type 1 order 4 acc 1 t 1.75 dsm 1.4649e-13 dsm_est 6.1914e-14 nsteps 3201 + h 7.8125e-05 rk_type 1 order 4 acc 1 t 2 dsm 6.85301e-14 dsm_est 1.28969e-14 nsteps 3201 + h 7.8125e-05 rk_type 1 order 4 acc 1 t 2.25 dsm 3.74507e-13 dsm_est 2.72291e-15 nsteps 3201 + h 7.8125e-05 rk_type 1 order 4 acc 1 t 2.5 dsm 1.92671e-14 dsm_est 9.81217e-16 nsteps 3201 + h 7.8125e-05 rk_type 1 order 4 acc 1 t 2.75 dsm 1.93516e-14 dsm_est 6.71729e-16 nsteps 3201 + h 7.8125e-05 rk_type 1 order 4 acc 1 t 3 dsm 1.23711e-13 dsm_est 6.65622e-16 nsteps 3201 + h 7.8125e-05 rk_type 1 order 4 acc 1 t 3.25 dsm 8.16997e-14 dsm_est 2.16207e-16 nsteps 3201 + h 7.8125e-05 rk_type 1 order 4 acc 1 t 3.5 dsm 1.95956e-14 dsm_est 4.74185e-17 nsteps 3201 + h 7.8125e-05 rk_type 1 order 4 acc 1 t 3.75 dsm 2.16401e-14 dsm_est 4.58122e-17 nsteps 3201 + h 7.8125e-05 rk_type 1 order 4 acc 1 t 4 dsm 9.37664e-14 dsm_est 1.11469e-16 nsteps 3201 + h 7.8125e-05 rk_type 1 order 4 acc 1 t 4.25 dsm 2.10442e-13 dsm_est 1.82276e-16 nsteps 3201 + h 7.8125e-05 rk_type 1 order 4 acc 1 t 4.5 dsm 1.64627e-14 dsm_est 7.11037e-16 nsteps 3201 + h 7.8125e-05 rk_type 1 order 4 acc 1 t 4.75 dsm 1.39177e-13 dsm_est 2.35957e-16 nsteps 3201 + h 7.8125e-05 rk_type 1 order 4 acc 1 t 5 dsm 7.51104e-14 dsm_est 1.00425e-16 nsteps 3201 + h 7.8125e-05 rk_type 1 order 4 acc 3 t 0.25 dsm 1.20076e-14 dsm_est 8.25514e-17 nsteps 3200 + h 7.8125e-05 rk_type 1 order 4 acc 3 t 0.5 dsm 6.92895e-14 dsm_est 4.12935e-16 nsteps 3201 + h 7.8125e-05 rk_type 1 order 4 acc 3 t 0.75 dsm 7.1887e-14 dsm_est 1.32929e-15 nsteps 3200 + h 7.8125e-05 rk_type 1 order 4 acc 3 t 1 dsm 5.29714e-14 dsm_est 4.63079e-16 nsteps 3200 + h 7.8125e-05 rk_type 1 order 4 acc 3 t 1.25 dsm 4.54758e-13 dsm_est 1.13947e-14 nsteps 3201 + h 7.8125e-05 rk_type 1 order 4 acc 3 t 1.5 dsm 1.61784e-13 dsm_est 5.78442e-15 nsteps 3201 + h 7.8125e-05 rk_type 1 order 4 acc 3 t 1.75 dsm 1.4649e-13 dsm_est 1.89102e-14 nsteps 3201 + h 7.8125e-05 rk_type 1 order 4 acc 3 t 2 dsm 6.85301e-14 dsm_est 3.80224e-15 nsteps 3201 + h 7.8125e-05 rk_type 1 order 4 acc 3 t 2.25 dsm 3.74507e-13 dsm_est 1.6387e-15 nsteps 3201 + h 7.8125e-05 rk_type 1 order 4 acc 3 t 2.5 dsm 1.92671e-14 dsm_est 6.81275e-16 nsteps 3201 + h 7.8125e-05 rk_type 1 order 4 acc 3 t 2.75 dsm 1.93516e-14 dsm_est 3.45213e-16 nsteps 3201 + h 7.8125e-05 rk_type 1 order 4 acc 3 t 3 dsm 1.23711e-13 dsm_est 2.67136e-16 nsteps 3201 + h 7.8125e-05 rk_type 1 order 4 acc 3 t 3.25 dsm 8.16997e-14 dsm_est 1.30768e-16 nsteps 3201 + h 7.8125e-05 rk_type 1 order 4 acc 3 t 3.5 dsm 1.95956e-14 dsm_est 3.19583e-17 nsteps 3201 + h 7.8125e-05 rk_type 1 order 4 acc 3 t 3.75 dsm 2.16401e-14 dsm_est 2.39388e-17 nsteps 3201 + h 7.8125e-05 rk_type 1 order 4 acc 3 t 4 dsm 9.37664e-14 dsm_est 5.67508e-17 nsteps 3201 + h 7.8125e-05 rk_type 1 order 4 acc 3 t 4.25 dsm 2.10442e-13 dsm_est 1.44544e-16 nsteps 3201 + h 7.8125e-05 rk_type 1 order 4 acc 3 t 4.5 dsm 1.64627e-14 dsm_est 4.4406e-16 nsteps 3201 + h 7.8125e-05 rk_type 1 order 4 acc 3 t 4.75 dsm 1.39177e-13 dsm_est 1.03927e-16 nsteps 3201 + h 7.8125e-05 rk_type 1 order 4 acc 3 t 5 dsm 7.51104e-14 dsm_est 7.26595e-17 nsteps 3201 h 7.8125e-05 rk_type 1 order 4 acc 2 t 0.25 dsm 1.20076e-14 dsm_est 9.70841e-15 nsteps 4800 h 7.8125e-05 rk_type 1 order 4 acc 2 t 0.5 dsm 6.92895e-14 dsm_est 1.22494e-13 nsteps 4801 h 7.8125e-05 rk_type 1 order 4 acc 2 t 0.75 dsm 7.1887e-14 dsm_est 1.01008e-13 nsteps 4801 diff --git a/test/unit_tests/arkode/CXX_serial/ark_test_accumerror_kpr_20_2_0.out b/test/unit_tests/arkode/CXX_serial/ark_test_accumerror_kpr_20_2_0.out index d6a9b75054..fc1ead1041 100644 --- a/test/unit_tests/arkode/CXX_serial/ark_test_accumerror_kpr_20_2_0.out +++ b/test/unit_tests/arkode/CXX_serial/ark_test_accumerror_kpr_20_2_0.out @@ -8,123 +8,123 @@ Accumulated error estimation test (Nonlinear Kvaerno-Prothero-Robinson problem): DIRK solver, order = 2 Adaptive-step runs: - rtol 0.01 rk_type 0 order 2 acc 0 t 0.25 dsm 5.77245e-05 dsm_est 0.00686971 nsteps 9 - rtol 0.01 rk_type 0 order 2 acc 0 t 0.5 dsm 0.00372257 dsm_est 0.00877859 nsteps 8 - rtol 0.01 rk_type 0 order 2 acc 0 t 0.75 dsm 0.000232425 dsm_est 0.0066976 nsteps 13 - rtol 0.01 rk_type 0 order 2 acc 0 t 1 dsm 0.00327055 dsm_est 0.00759421 nsteps 9 - rtol 0.01 rk_type 0 order 2 acc 0 t 1.25 dsm 0.00363058 dsm_est 0.00633487 nsteps 16 - rtol 0.01 rk_type 0 order 2 acc 0 t 1.5 dsm 0.00267076 dsm_est 0.00679482 nsteps 12 - rtol 0.01 rk_type 0 order 2 acc 0 t 1.75 dsm 0.00971976 dsm_est 0.00698823 nsteps 16 - rtol 0.01 rk_type 0 order 2 acc 0 t 2 dsm 0.000918207 dsm_est 0.00684032 nsteps 14 - rtol 0.01 rk_type 0 order 2 acc 0 t 2.25 dsm 0.0016944 dsm_est 0.00722321 nsteps 10 - rtol 0.01 rk_type 0 order 2 acc 0 t 2.5 dsm 0.0056199 dsm_est 0.00390805 nsteps 7 - rtol 0.01 rk_type 0 order 2 acc 0 t 2.75 dsm 0.00855479 dsm_est 0.00899318 nsteps 6 - rtol 0.01 rk_type 0 order 2 acc 0 t 3 dsm 0.0023308 dsm_est 0.00881185 nsteps 7 - rtol 0.01 rk_type 0 order 2 acc 0 t 3.25 dsm 0.000539467 dsm_est 0.00351937 nsteps 8 - rtol 0.01 rk_type 0 order 2 acc 0 t 3.5 dsm 0.000312605 dsm_est 0.00446438 nsteps 6 - rtol 0.01 rk_type 0 order 2 acc 0 t 3.75 dsm 0.00144605 dsm_est 0.00759178 nsteps 4 - rtol 0.01 rk_type 0 order 2 acc 0 t 4 dsm 0.00023147 dsm_est 0.0031488 nsteps 7 - rtol 0.01 rk_type 0 order 2 acc 0 t 4.25 dsm 0.00806953 dsm_est 0.00741572 nsteps 4 - rtol 0.01 rk_type 0 order 2 acc 0 t 4.5 dsm 0.000322019 dsm_est 0.00679423 nsteps 11 - rtol 0.01 rk_type 0 order 2 acc 0 t 4.75 dsm 0.00405487 dsm_est 0.00313156 nsteps 7 - rtol 0.01 rk_type 0 order 2 acc 0 t 5 dsm 0.000699178 dsm_est 0.0036148 nsteps 8 - rtol 0.01 rk_type 0 order 2 acc 1 t 0.25 dsm 5.77245e-05 dsm_est 0.00183312 nsteps 9 - rtol 0.01 rk_type 0 order 2 acc 1 t 0.5 dsm 0.00372257 dsm_est 0.0026276 nsteps 8 - rtol 0.01 rk_type 0 order 2 acc 1 t 0.75 dsm 0.000232425 dsm_est 0.00237463 nsteps 13 - rtol 0.01 rk_type 0 order 2 acc 1 t 1 dsm 0.00327055 dsm_est 0.00377797 nsteps 9 - rtol 0.01 rk_type 0 order 2 acc 1 t 1.25 dsm 0.00363058 dsm_est 0.00286963 nsteps 16 - rtol 0.01 rk_type 0 order 2 acc 1 t 1.5 dsm 0.00267076 dsm_est 0.00422946 nsteps 12 - rtol 0.01 rk_type 0 order 2 acc 1 t 1.75 dsm 0.00971976 dsm_est 0.00351813 nsteps 16 - rtol 0.01 rk_type 0 order 2 acc 1 t 2 dsm 0.000918207 dsm_est 0.00268129 nsteps 14 - rtol 0.01 rk_type 0 order 2 acc 1 t 2.25 dsm 0.0016944 dsm_est 0.0031166 nsteps 10 - rtol 0.01 rk_type 0 order 2 acc 1 t 2.5 dsm 0.0056199 dsm_est 0.00138151 nsteps 7 - rtol 0.01 rk_type 0 order 2 acc 1 t 2.75 dsm 0.00855479 dsm_est 0.00234303 nsteps 6 - rtol 0.01 rk_type 0 order 2 acc 1 t 3 dsm 0.0023308 dsm_est 0.00207814 nsteps 7 - rtol 0.01 rk_type 0 order 2 acc 1 t 3.25 dsm 0.000539467 dsm_est 0.00139745 nsteps 8 - rtol 0.01 rk_type 0 order 2 acc 1 t 3.5 dsm 0.000312605 dsm_est 0.00128426 nsteps 6 - rtol 0.01 rk_type 0 order 2 acc 1 t 3.75 dsm 0.00144605 dsm_est 0.00243161 nsteps 4 - rtol 0.01 rk_type 0 order 2 acc 1 t 4 dsm 0.00023147 dsm_est 0.00140273 nsteps 7 - rtol 0.01 rk_type 0 order 2 acc 1 t 4.25 dsm 0.00806953 dsm_est 0.00295759 nsteps 4 - rtol 0.01 rk_type 0 order 2 acc 1 t 4.5 dsm 0.000322019 dsm_est 0.00239066 nsteps 11 - rtol 0.01 rk_type 0 order 2 acc 1 t 4.75 dsm 0.00405487 dsm_est 0.00089527 nsteps 7 - rtol 0.01 rk_type 0 order 2 acc 1 t 5 dsm 0.000699178 dsm_est 0.00160895 nsteps 8 - rtol 0.0001 rk_type 0 order 2 acc 0 t 0.25 dsm 7.46709e-07 dsm_est 7.18663e-05 nsteps 49 - rtol 0.0001 rk_type 0 order 2 acc 0 t 0.5 dsm 6.50352e-05 dsm_est 7.49302e-05 nsteps 42 - rtol 0.0001 rk_type 0 order 2 acc 0 t 0.75 dsm 4.48379e-06 dsm_est 7.39118e-05 nsteps 84 - rtol 0.0001 rk_type 0 order 2 acc 0 t 1 dsm 3.76158e-05 dsm_est 7.93376e-05 nsteps 61 - rtol 0.0001 rk_type 0 order 2 acc 0 t 1.25 dsm 6.82164e-05 dsm_est 9.03489e-05 nsteps 110 - rtol 0.0001 rk_type 0 order 2 acc 0 t 1.5 dsm 3.68171e-05 dsm_est 8.51313e-05 nsteps 109 - rtol 0.0001 rk_type 0 order 2 acc 0 t 1.75 dsm 2.35133e-05 dsm_est 8.17961e-05 nsteps 136 - rtol 0.0001 rk_type 0 order 2 acc 0 t 2 dsm 1.61655e-05 dsm_est 6.74799e-05 nsteps 91 - rtol 0.0001 rk_type 0 order 2 acc 0 t 2.25 dsm 6.22229e-05 dsm_est 8.55795e-05 nsteps 65 - rtol 0.0001 rk_type 0 order 2 acc 0 t 2.5 dsm 4.95459e-05 dsm_est 9.95948e-05 nsteps 38 - rtol 0.0001 rk_type 0 order 2 acc 0 t 2.75 dsm 4.09894e-05 dsm_est 7.97659e-05 nsteps 35 - rtol 0.0001 rk_type 0 order 2 acc 0 t 3 dsm 3.51226e-05 dsm_est 9.83341e-05 nsteps 41 - rtol 0.0001 rk_type 0 order 2 acc 0 t 3.25 dsm 9.918e-06 dsm_est 7.80442e-05 nsteps 34 - rtol 0.0001 rk_type 0 order 2 acc 0 t 3.5 dsm 6.68205e-06 dsm_est 6.93297e-05 nsteps 29 - rtol 0.0001 rk_type 0 order 2 acc 0 t 3.75 dsm 1.12533e-05 dsm_est 7.07769e-05 nsteps 22 - rtol 0.0001 rk_type 0 order 2 acc 0 t 4 dsm 4.18856e-06 dsm_est 7.35665e-05 nsteps 31 - rtol 0.0001 rk_type 0 order 2 acc 0 t 4.25 dsm 5.65033e-05 dsm_est 9.50758e-05 nsteps 27 - rtol 0.0001 rk_type 0 order 2 acc 0 t 4.5 dsm 8.06381e-06 dsm_est 7.57142e-05 nsteps 60 - rtol 0.0001 rk_type 0 order 2 acc 0 t 4.75 dsm 3.08146e-05 dsm_est 7.53944e-05 nsteps 36 - rtol 0.0001 rk_type 0 order 2 acc 0 t 5 dsm 1.43844e-05 dsm_est 7.56604e-05 nsteps 37 - rtol 0.0001 rk_type 0 order 2 acc 1 t 0.25 dsm 7.46709e-07 dsm_est 3.89514e-05 nsteps 49 - rtol 0.0001 rk_type 0 order 2 acc 1 t 0.5 dsm 6.50352e-05 dsm_est 4.87422e-05 nsteps 42 - rtol 0.0001 rk_type 0 order 2 acc 1 t 0.75 dsm 4.48379e-06 dsm_est 4.52376e-05 nsteps 84 - rtol 0.0001 rk_type 0 order 2 acc 1 t 1 dsm 3.76158e-05 dsm_est 5.97057e-05 nsteps 61 - rtol 0.0001 rk_type 0 order 2 acc 1 t 1.25 dsm 6.82164e-05 dsm_est 5.09587e-05 nsteps 110 - rtol 0.0001 rk_type 0 order 2 acc 1 t 1.5 dsm 3.68171e-05 dsm_est 5.14096e-05 nsteps 109 - rtol 0.0001 rk_type 0 order 2 acc 1 t 1.75 dsm 2.35133e-05 dsm_est 4.76173e-05 nsteps 136 - rtol 0.0001 rk_type 0 order 2 acc 1 t 2 dsm 1.61655e-05 dsm_est 5.09324e-05 nsteps 91 - rtol 0.0001 rk_type 0 order 2 acc 1 t 2.25 dsm 6.22229e-05 dsm_est 5.36928e-05 nsteps 65 - rtol 0.0001 rk_type 0 order 2 acc 1 t 2.5 dsm 4.95459e-05 dsm_est 4.4449e-05 nsteps 38 - rtol 0.0001 rk_type 0 order 2 acc 1 t 2.75 dsm 4.09894e-05 dsm_est 5.85403e-05 nsteps 35 - rtol 0.0001 rk_type 0 order 2 acc 1 t 3 dsm 3.51226e-05 dsm_est 3.83191e-05 nsteps 41 - rtol 0.0001 rk_type 0 order 2 acc 1 t 3.25 dsm 9.918e-06 dsm_est 4.95986e-05 nsteps 34 - rtol 0.0001 rk_type 0 order 2 acc 1 t 3.5 dsm 6.68205e-06 dsm_est 3.60708e-05 nsteps 29 - rtol 0.0001 rk_type 0 order 2 acc 1 t 3.75 dsm 1.12533e-05 dsm_est 5.1455e-05 nsteps 22 - rtol 0.0001 rk_type 0 order 2 acc 1 t 4 dsm 4.18856e-06 dsm_est 4.77684e-05 nsteps 31 - rtol 0.0001 rk_type 0 order 2 acc 1 t 4.25 dsm 5.65033e-05 dsm_est 4.91962e-05 nsteps 27 - rtol 0.0001 rk_type 0 order 2 acc 1 t 4.5 dsm 8.06381e-06 dsm_est 5.56661e-05 nsteps 60 - rtol 0.0001 rk_type 0 order 2 acc 1 t 4.75 dsm 3.08146e-05 dsm_est 3.80468e-05 nsteps 36 - rtol 0.0001 rk_type 0 order 2 acc 1 t 5 dsm 1.43844e-05 dsm_est 5.58721e-05 nsteps 37 - rtol 1e-06 rk_type 0 order 2 acc 0 t 0.25 dsm 5.66725e-09 dsm_est 7.18787e-07 nsteps 488 - rtol 1e-06 rk_type 0 order 2 acc 0 t 0.5 dsm 9.92276e-07 dsm_est 8.1602e-07 nsteps 403 - rtol 1e-06 rk_type 0 order 2 acc 0 t 0.75 dsm 8.0717e-08 dsm_est 7.2088e-07 nsteps 823 - rtol 1e-06 rk_type 0 order 2 acc 0 t 1 dsm 5.67858e-07 dsm_est 9.90249e-07 nsteps 596 - rtol 1e-06 rk_type 0 order 2 acc 0 t 1.25 dsm 1.03484e-06 dsm_est 7.69939e-07 nsteps 1091 - rtol 1e-06 rk_type 0 order 2 acc 0 t 1.5 dsm 5.45182e-07 dsm_est 9.21351e-07 nsteps 1080 - rtol 1e-06 rk_type 0 order 2 acc 0 t 1.75 dsm 3.61096e-07 dsm_est 8.11495e-07 nsteps 1337 - rtol 1e-06 rk_type 0 order 2 acc 0 t 2 dsm 2.2003e-07 dsm_est 6.89881e-07 nsteps 898 - rtol 1e-06 rk_type 0 order 2 acc 0 t 2.25 dsm 9.38782e-07 dsm_est 7.22168e-07 nsteps 635 - rtol 1e-06 rk_type 0 order 2 acc 0 t 2.5 dsm 5.20042e-07 dsm_est 7.8752e-07 nsteps 372 - rtol 1e-06 rk_type 0 order 2 acc 0 t 2.75 dsm 4.66825e-07 dsm_est 7.09276e-07 nsteps 354 - rtol 1e-06 rk_type 0 order 2 acc 0 t 3 dsm 3.30086e-07 dsm_est 7.18289e-07 nsteps 409 - rtol 1e-06 rk_type 0 order 2 acc 0 t 3.25 dsm 1.19548e-07 dsm_est 7.25689e-07 nsteps 320 - rtol 1e-06 rk_type 0 order 2 acc 0 t 3.5 dsm 4.13474e-08 dsm_est 7.16259e-07 nsteps 288 - rtol 1e-06 rk_type 0 order 2 acc 0 t 3.75 dsm 1.02293e-07 dsm_est 7.17021e-07 nsteps 225 - rtol 1e-06 rk_type 0 order 2 acc 0 t 4 dsm 3.98477e-08 dsm_est 7.20467e-07 nsteps 304 - rtol 1e-06 rk_type 0 order 2 acc 0 t 4.25 dsm 7.93335e-07 dsm_est 7.48243e-07 nsteps 268 - rtol 1e-06 rk_type 0 order 2 acc 0 t 4.5 dsm 7.4366e-08 dsm_est 7.22713e-07 nsteps 597 - rtol 1e-06 rk_type 0 order 2 acc 0 t 4.75 dsm 5.08713e-07 dsm_est 8.6505e-07 nsteps 347 - rtol 1e-06 rk_type 0 order 2 acc 0 t 5 dsm 1.42752e-07 dsm_est 7.22893e-07 nsteps 366 - rtol 1e-06 rk_type 0 order 2 acc 1 t 0.25 dsm 5.66725e-09 dsm_est 3.91786e-07 nsteps 488 - rtol 1e-06 rk_type 0 order 2 acc 1 t 0.5 dsm 9.92276e-07 dsm_est 5.14717e-07 nsteps 403 - rtol 1e-06 rk_type 0 order 2 acc 1 t 0.75 dsm 8.0717e-08 dsm_est 4.71859e-07 nsteps 823 - rtol 1e-06 rk_type 0 order 2 acc 1 t 1 dsm 5.67858e-07 dsm_est 6.13342e-07 nsteps 596 - rtol 1e-06 rk_type 0 order 2 acc 1 t 1.25 dsm 1.03484e-06 dsm_est 5.1167e-07 nsteps 1091 - rtol 1e-06 rk_type 0 order 2 acc 1 t 1.5 dsm 5.45182e-07 dsm_est 5.19559e-07 nsteps 1080 - rtol 1e-06 rk_type 0 order 2 acc 1 t 1.75 dsm 3.61096e-07 dsm_est 4.83426e-07 nsteps 1337 - rtol 1e-06 rk_type 0 order 2 acc 1 t 2 dsm 2.2003e-07 dsm_est 5.21923e-07 nsteps 898 - rtol 1e-06 rk_type 0 order 2 acc 1 t 2.25 dsm 9.38782e-07 dsm_est 5.48693e-07 nsteps 635 - rtol 1e-06 rk_type 0 order 2 acc 1 t 2.5 dsm 5.20042e-07 dsm_est 4.49869e-07 nsteps 372 - rtol 1e-06 rk_type 0 order 2 acc 1 t 2.75 dsm 4.66825e-07 dsm_est 5.75673e-07 nsteps 354 - rtol 1e-06 rk_type 0 order 2 acc 1 t 3 dsm 3.30086e-07 dsm_est 3.88553e-07 nsteps 409 - rtol 1e-06 rk_type 0 order 2 acc 1 t 3.25 dsm 1.19548e-07 dsm_est 5.56086e-07 nsteps 320 - rtol 1e-06 rk_type 0 order 2 acc 1 t 3.5 dsm 4.13474e-08 dsm_est 3.61457e-07 nsteps 288 - rtol 1e-06 rk_type 0 order 2 acc 1 t 3.75 dsm 1.02293e-07 dsm_est 5.03828e-07 nsteps 225 - rtol 1e-06 rk_type 0 order 2 acc 1 t 4 dsm 3.98477e-08 dsm_est 4.97667e-07 nsteps 304 - rtol 1e-06 rk_type 0 order 2 acc 1 t 4.25 dsm 7.93335e-07 dsm_est 4.85132e-07 nsteps 268 - rtol 1e-06 rk_type 0 order 2 acc 1 t 4.5 dsm 7.4366e-08 dsm_est 5.62809e-07 nsteps 597 - rtol 1e-06 rk_type 0 order 2 acc 1 t 4.75 dsm 5.08713e-07 dsm_est 4.12187e-07 nsteps 347 - rtol 1e-06 rk_type 0 order 2 acc 1 t 5 dsm 1.42752e-07 dsm_est 5.76073e-07 nsteps 366 + rtol 0.01 rk_type 0 order 2 acc 1 t 0.25 dsm 5.77245e-05 dsm_est 0.00686971 nsteps 9 + rtol 0.01 rk_type 0 order 2 acc 1 t 0.5 dsm 0.00372257 dsm_est 0.00877859 nsteps 8 + rtol 0.01 rk_type 0 order 2 acc 1 t 0.75 dsm 0.000232425 dsm_est 0.0066976 nsteps 13 + rtol 0.01 rk_type 0 order 2 acc 1 t 1 dsm 0.00327055 dsm_est 0.00759421 nsteps 9 + rtol 0.01 rk_type 0 order 2 acc 1 t 1.25 dsm 0.00363058 dsm_est 0.00633487 nsteps 16 + rtol 0.01 rk_type 0 order 2 acc 1 t 1.5 dsm 0.00267076 dsm_est 0.00679482 nsteps 12 + rtol 0.01 rk_type 0 order 2 acc 1 t 1.75 dsm 0.00971976 dsm_est 0.00698823 nsteps 16 + rtol 0.01 rk_type 0 order 2 acc 1 t 2 dsm 0.000918207 dsm_est 0.00684032 nsteps 14 + rtol 0.01 rk_type 0 order 2 acc 1 t 2.25 dsm 0.0016944 dsm_est 0.00722321 nsteps 10 + rtol 0.01 rk_type 0 order 2 acc 1 t 2.5 dsm 0.0056199 dsm_est 0.00390805 nsteps 7 + rtol 0.01 rk_type 0 order 2 acc 1 t 2.75 dsm 0.00855479 dsm_est 0.00899318 nsteps 6 + rtol 0.01 rk_type 0 order 2 acc 1 t 3 dsm 0.0023308 dsm_est 0.00881185 nsteps 7 + rtol 0.01 rk_type 0 order 2 acc 1 t 3.25 dsm 0.000539467 dsm_est 0.00351937 nsteps 8 + rtol 0.01 rk_type 0 order 2 acc 1 t 3.5 dsm 0.000312605 dsm_est 0.00446438 nsteps 6 + rtol 0.01 rk_type 0 order 2 acc 1 t 3.75 dsm 0.00144605 dsm_est 0.00759178 nsteps 4 + rtol 0.01 rk_type 0 order 2 acc 1 t 4 dsm 0.00023147 dsm_est 0.0031488 nsteps 7 + rtol 0.01 rk_type 0 order 2 acc 1 t 4.25 dsm 0.00806953 dsm_est 0.00741572 nsteps 4 + rtol 0.01 rk_type 0 order 2 acc 1 t 4.5 dsm 0.000322019 dsm_est 0.00679423 nsteps 11 + rtol 0.01 rk_type 0 order 2 acc 1 t 4.75 dsm 0.00405487 dsm_est 0.00313156 nsteps 7 + rtol 0.01 rk_type 0 order 2 acc 1 t 5 dsm 0.000699178 dsm_est 0.0036148 nsteps 8 + rtol 0.01 rk_type 0 order 2 acc 3 t 0.25 dsm 5.77245e-05 dsm_est 0.00183312 nsteps 9 + rtol 0.01 rk_type 0 order 2 acc 3 t 0.5 dsm 0.00372257 dsm_est 0.0026276 nsteps 8 + rtol 0.01 rk_type 0 order 2 acc 3 t 0.75 dsm 0.000232425 dsm_est 0.00237463 nsteps 13 + rtol 0.01 rk_type 0 order 2 acc 3 t 1 dsm 0.00327055 dsm_est 0.00377797 nsteps 9 + rtol 0.01 rk_type 0 order 2 acc 3 t 1.25 dsm 0.00363058 dsm_est 0.00286963 nsteps 16 + rtol 0.01 rk_type 0 order 2 acc 3 t 1.5 dsm 0.00267076 dsm_est 0.00422946 nsteps 12 + rtol 0.01 rk_type 0 order 2 acc 3 t 1.75 dsm 0.00971976 dsm_est 0.00351813 nsteps 16 + rtol 0.01 rk_type 0 order 2 acc 3 t 2 dsm 0.000918207 dsm_est 0.00268129 nsteps 14 + rtol 0.01 rk_type 0 order 2 acc 3 t 2.25 dsm 0.0016944 dsm_est 0.0031166 nsteps 10 + rtol 0.01 rk_type 0 order 2 acc 3 t 2.5 dsm 0.0056199 dsm_est 0.00138151 nsteps 7 + rtol 0.01 rk_type 0 order 2 acc 3 t 2.75 dsm 0.00855479 dsm_est 0.00234303 nsteps 6 + rtol 0.01 rk_type 0 order 2 acc 3 t 3 dsm 0.0023308 dsm_est 0.00207814 nsteps 7 + rtol 0.01 rk_type 0 order 2 acc 3 t 3.25 dsm 0.000539467 dsm_est 0.00139745 nsteps 8 + rtol 0.01 rk_type 0 order 2 acc 3 t 3.5 dsm 0.000312605 dsm_est 0.00128426 nsteps 6 + rtol 0.01 rk_type 0 order 2 acc 3 t 3.75 dsm 0.00144605 dsm_est 0.00243161 nsteps 4 + rtol 0.01 rk_type 0 order 2 acc 3 t 4 dsm 0.00023147 dsm_est 0.00140273 nsteps 7 + rtol 0.01 rk_type 0 order 2 acc 3 t 4.25 dsm 0.00806953 dsm_est 0.00295759 nsteps 4 + rtol 0.01 rk_type 0 order 2 acc 3 t 4.5 dsm 0.000322019 dsm_est 0.00239066 nsteps 11 + rtol 0.01 rk_type 0 order 2 acc 3 t 4.75 dsm 0.00405487 dsm_est 0.00089527 nsteps 7 + rtol 0.01 rk_type 0 order 2 acc 3 t 5 dsm 0.000699178 dsm_est 0.00160895 nsteps 8 + rtol 0.0001 rk_type 0 order 2 acc 1 t 0.25 dsm 7.46709e-07 dsm_est 7.18663e-05 nsteps 49 + rtol 0.0001 rk_type 0 order 2 acc 1 t 0.5 dsm 6.50352e-05 dsm_est 7.49302e-05 nsteps 42 + rtol 0.0001 rk_type 0 order 2 acc 1 t 0.75 dsm 4.48379e-06 dsm_est 7.39118e-05 nsteps 84 + rtol 0.0001 rk_type 0 order 2 acc 1 t 1 dsm 3.76158e-05 dsm_est 7.93376e-05 nsteps 61 + rtol 0.0001 rk_type 0 order 2 acc 1 t 1.25 dsm 6.82164e-05 dsm_est 9.03489e-05 nsteps 110 + rtol 0.0001 rk_type 0 order 2 acc 1 t 1.5 dsm 3.68171e-05 dsm_est 8.51313e-05 nsteps 109 + rtol 0.0001 rk_type 0 order 2 acc 1 t 1.75 dsm 2.35133e-05 dsm_est 8.17961e-05 nsteps 136 + rtol 0.0001 rk_type 0 order 2 acc 1 t 2 dsm 1.61655e-05 dsm_est 6.74799e-05 nsteps 91 + rtol 0.0001 rk_type 0 order 2 acc 1 t 2.25 dsm 6.22229e-05 dsm_est 8.55795e-05 nsteps 65 + rtol 0.0001 rk_type 0 order 2 acc 1 t 2.5 dsm 4.95459e-05 dsm_est 9.95948e-05 nsteps 38 + rtol 0.0001 rk_type 0 order 2 acc 1 t 2.75 dsm 4.09894e-05 dsm_est 7.97659e-05 nsteps 35 + rtol 0.0001 rk_type 0 order 2 acc 1 t 3 dsm 3.51226e-05 dsm_est 9.83341e-05 nsteps 41 + rtol 0.0001 rk_type 0 order 2 acc 1 t 3.25 dsm 9.918e-06 dsm_est 7.80442e-05 nsteps 34 + rtol 0.0001 rk_type 0 order 2 acc 1 t 3.5 dsm 6.68205e-06 dsm_est 6.93297e-05 nsteps 29 + rtol 0.0001 rk_type 0 order 2 acc 1 t 3.75 dsm 1.12533e-05 dsm_est 7.07769e-05 nsteps 22 + rtol 0.0001 rk_type 0 order 2 acc 1 t 4 dsm 4.18856e-06 dsm_est 7.35665e-05 nsteps 31 + rtol 0.0001 rk_type 0 order 2 acc 1 t 4.25 dsm 5.65033e-05 dsm_est 9.50758e-05 nsteps 27 + rtol 0.0001 rk_type 0 order 2 acc 1 t 4.5 dsm 8.06381e-06 dsm_est 7.57142e-05 nsteps 60 + rtol 0.0001 rk_type 0 order 2 acc 1 t 4.75 dsm 3.08146e-05 dsm_est 7.53944e-05 nsteps 36 + rtol 0.0001 rk_type 0 order 2 acc 1 t 5 dsm 1.43844e-05 dsm_est 7.56604e-05 nsteps 37 + rtol 0.0001 rk_type 0 order 2 acc 3 t 0.25 dsm 7.46709e-07 dsm_est 3.89514e-05 nsteps 49 + rtol 0.0001 rk_type 0 order 2 acc 3 t 0.5 dsm 6.50352e-05 dsm_est 4.87422e-05 nsteps 42 + rtol 0.0001 rk_type 0 order 2 acc 3 t 0.75 dsm 4.48379e-06 dsm_est 4.52376e-05 nsteps 84 + rtol 0.0001 rk_type 0 order 2 acc 3 t 1 dsm 3.76158e-05 dsm_est 5.97057e-05 nsteps 61 + rtol 0.0001 rk_type 0 order 2 acc 3 t 1.25 dsm 6.82164e-05 dsm_est 5.09587e-05 nsteps 110 + rtol 0.0001 rk_type 0 order 2 acc 3 t 1.5 dsm 3.68171e-05 dsm_est 5.14096e-05 nsteps 109 + rtol 0.0001 rk_type 0 order 2 acc 3 t 1.75 dsm 2.35133e-05 dsm_est 4.76173e-05 nsteps 136 + rtol 0.0001 rk_type 0 order 2 acc 3 t 2 dsm 1.61655e-05 dsm_est 5.09324e-05 nsteps 91 + rtol 0.0001 rk_type 0 order 2 acc 3 t 2.25 dsm 6.22229e-05 dsm_est 5.36928e-05 nsteps 65 + rtol 0.0001 rk_type 0 order 2 acc 3 t 2.5 dsm 4.95459e-05 dsm_est 4.4449e-05 nsteps 38 + rtol 0.0001 rk_type 0 order 2 acc 3 t 2.75 dsm 4.09894e-05 dsm_est 5.85403e-05 nsteps 35 + rtol 0.0001 rk_type 0 order 2 acc 3 t 3 dsm 3.51226e-05 dsm_est 3.83191e-05 nsteps 41 + rtol 0.0001 rk_type 0 order 2 acc 3 t 3.25 dsm 9.918e-06 dsm_est 4.95986e-05 nsteps 34 + rtol 0.0001 rk_type 0 order 2 acc 3 t 3.5 dsm 6.68205e-06 dsm_est 3.60708e-05 nsteps 29 + rtol 0.0001 rk_type 0 order 2 acc 3 t 3.75 dsm 1.12533e-05 dsm_est 5.1455e-05 nsteps 22 + rtol 0.0001 rk_type 0 order 2 acc 3 t 4 dsm 4.18856e-06 dsm_est 4.77684e-05 nsteps 31 + rtol 0.0001 rk_type 0 order 2 acc 3 t 4.25 dsm 5.65033e-05 dsm_est 4.91962e-05 nsteps 27 + rtol 0.0001 rk_type 0 order 2 acc 3 t 4.5 dsm 8.06381e-06 dsm_est 5.56661e-05 nsteps 60 + rtol 0.0001 rk_type 0 order 2 acc 3 t 4.75 dsm 3.08146e-05 dsm_est 3.80468e-05 nsteps 36 + rtol 0.0001 rk_type 0 order 2 acc 3 t 5 dsm 1.43844e-05 dsm_est 5.58721e-05 nsteps 37 + rtol 1e-06 rk_type 0 order 2 acc 1 t 0.25 dsm 5.66725e-09 dsm_est 7.18787e-07 nsteps 488 + rtol 1e-06 rk_type 0 order 2 acc 1 t 0.5 dsm 9.92276e-07 dsm_est 8.1602e-07 nsteps 403 + rtol 1e-06 rk_type 0 order 2 acc 1 t 0.75 dsm 8.0717e-08 dsm_est 7.2088e-07 nsteps 823 + rtol 1e-06 rk_type 0 order 2 acc 1 t 1 dsm 5.67858e-07 dsm_est 9.90249e-07 nsteps 596 + rtol 1e-06 rk_type 0 order 2 acc 1 t 1.25 dsm 1.03484e-06 dsm_est 7.69939e-07 nsteps 1091 + rtol 1e-06 rk_type 0 order 2 acc 1 t 1.5 dsm 5.45182e-07 dsm_est 9.21351e-07 nsteps 1080 + rtol 1e-06 rk_type 0 order 2 acc 1 t 1.75 dsm 3.61096e-07 dsm_est 8.11495e-07 nsteps 1337 + rtol 1e-06 rk_type 0 order 2 acc 1 t 2 dsm 2.2003e-07 dsm_est 6.89881e-07 nsteps 898 + rtol 1e-06 rk_type 0 order 2 acc 1 t 2.25 dsm 9.38782e-07 dsm_est 7.22168e-07 nsteps 635 + rtol 1e-06 rk_type 0 order 2 acc 1 t 2.5 dsm 5.20042e-07 dsm_est 7.8752e-07 nsteps 372 + rtol 1e-06 rk_type 0 order 2 acc 1 t 2.75 dsm 4.66825e-07 dsm_est 7.09276e-07 nsteps 354 + rtol 1e-06 rk_type 0 order 2 acc 1 t 3 dsm 3.30086e-07 dsm_est 7.18289e-07 nsteps 409 + rtol 1e-06 rk_type 0 order 2 acc 1 t 3.25 dsm 1.19548e-07 dsm_est 7.25689e-07 nsteps 320 + rtol 1e-06 rk_type 0 order 2 acc 1 t 3.5 dsm 4.13474e-08 dsm_est 7.16259e-07 nsteps 288 + rtol 1e-06 rk_type 0 order 2 acc 1 t 3.75 dsm 1.02293e-07 dsm_est 7.17021e-07 nsteps 225 + rtol 1e-06 rk_type 0 order 2 acc 1 t 4 dsm 3.98477e-08 dsm_est 7.20467e-07 nsteps 304 + rtol 1e-06 rk_type 0 order 2 acc 1 t 4.25 dsm 7.93335e-07 dsm_est 7.48243e-07 nsteps 268 + rtol 1e-06 rk_type 0 order 2 acc 1 t 4.5 dsm 7.4366e-08 dsm_est 7.22713e-07 nsteps 597 + rtol 1e-06 rk_type 0 order 2 acc 1 t 4.75 dsm 5.08713e-07 dsm_est 8.6505e-07 nsteps 347 + rtol 1e-06 rk_type 0 order 2 acc 1 t 5 dsm 1.42752e-07 dsm_est 7.22893e-07 nsteps 366 + rtol 1e-06 rk_type 0 order 2 acc 3 t 0.25 dsm 5.66725e-09 dsm_est 3.91786e-07 nsteps 488 + rtol 1e-06 rk_type 0 order 2 acc 3 t 0.5 dsm 9.92276e-07 dsm_est 5.14717e-07 nsteps 403 + rtol 1e-06 rk_type 0 order 2 acc 3 t 0.75 dsm 8.0717e-08 dsm_est 4.71859e-07 nsteps 823 + rtol 1e-06 rk_type 0 order 2 acc 3 t 1 dsm 5.67858e-07 dsm_est 6.13342e-07 nsteps 596 + rtol 1e-06 rk_type 0 order 2 acc 3 t 1.25 dsm 1.03484e-06 dsm_est 5.1167e-07 nsteps 1091 + rtol 1e-06 rk_type 0 order 2 acc 3 t 1.5 dsm 5.45182e-07 dsm_est 5.19559e-07 nsteps 1080 + rtol 1e-06 rk_type 0 order 2 acc 3 t 1.75 dsm 3.61096e-07 dsm_est 4.83426e-07 nsteps 1337 + rtol 1e-06 rk_type 0 order 2 acc 3 t 2 dsm 2.2003e-07 dsm_est 5.21923e-07 nsteps 898 + rtol 1e-06 rk_type 0 order 2 acc 3 t 2.25 dsm 9.38782e-07 dsm_est 5.48693e-07 nsteps 635 + rtol 1e-06 rk_type 0 order 2 acc 3 t 2.5 dsm 5.20042e-07 dsm_est 4.49869e-07 nsteps 372 + rtol 1e-06 rk_type 0 order 2 acc 3 t 2.75 dsm 4.66825e-07 dsm_est 5.75673e-07 nsteps 354 + rtol 1e-06 rk_type 0 order 2 acc 3 t 3 dsm 3.30086e-07 dsm_est 3.88553e-07 nsteps 409 + rtol 1e-06 rk_type 0 order 2 acc 3 t 3.25 dsm 1.19548e-07 dsm_est 5.56086e-07 nsteps 320 + rtol 1e-06 rk_type 0 order 2 acc 3 t 3.5 dsm 4.13474e-08 dsm_est 3.61457e-07 nsteps 288 + rtol 1e-06 rk_type 0 order 2 acc 3 t 3.75 dsm 1.02293e-07 dsm_est 5.03828e-07 nsteps 225 + rtol 1e-06 rk_type 0 order 2 acc 3 t 4 dsm 3.98477e-08 dsm_est 4.97667e-07 nsteps 304 + rtol 1e-06 rk_type 0 order 2 acc 3 t 4.25 dsm 7.93335e-07 dsm_est 4.85132e-07 nsteps 268 + rtol 1e-06 rk_type 0 order 2 acc 3 t 4.5 dsm 7.4366e-08 dsm_est 5.62809e-07 nsteps 597 + rtol 1e-06 rk_type 0 order 2 acc 3 t 4.75 dsm 5.08713e-07 dsm_est 4.12187e-07 nsteps 347 + rtol 1e-06 rk_type 0 order 2 acc 3 t 5 dsm 1.42752e-07 dsm_est 5.76073e-07 nsteps 366 diff --git a/test/unit_tests/arkode/CXX_serial/ark_test_accumerror_kpr_20_3_1.out b/test/unit_tests/arkode/CXX_serial/ark_test_accumerror_kpr_20_3_1.out index bc52bf93d6..f956e1f6e0 100644 --- a/test/unit_tests/arkode/CXX_serial/ark_test_accumerror_kpr_20_3_1.out +++ b/test/unit_tests/arkode/CXX_serial/ark_test_accumerror_kpr_20_3_1.out @@ -8,123 +8,123 @@ Accumulated error estimation test (Nonlinear Kvaerno-Prothero-Robinson problem): ERK solver, order = 3 Adaptive-step runs: - rtol 0.01 rk_type 1 order 3 acc 0 t 0.25 dsm 6.04149e-05 dsm_est 0.000128901 nsteps 5 - rtol 0.01 rk_type 1 order 3 acc 0 t 0.5 dsm 0.000268262 dsm_est 0.00122853 nsteps 5 - rtol 0.01 rk_type 1 order 3 acc 0 t 0.75 dsm 0.000162426 dsm_est 0.00195582 nsteps 5 - rtol 0.01 rk_type 1 order 3 acc 0 t 1 dsm 0.00010345 dsm_est 0.0018572 nsteps 5 - rtol 0.01 rk_type 1 order 3 acc 0 t 1.25 dsm 0.00145293 dsm_est 0.00223784 nsteps 7 - rtol 0.01 rk_type 1 order 3 acc 0 t 1.5 dsm 0.000475504 dsm_est 0.00220612 nsteps 6 - rtol 0.01 rk_type 1 order 3 acc 0 t 1.75 dsm 0.000953909 dsm_est 0.00848961 nsteps 5 - rtol 0.01 rk_type 1 order 3 acc 0 t 2 dsm 0.00190469 dsm_est 0.00438086 nsteps 6 - rtol 0.01 rk_type 1 order 3 acc 0 t 2.25 dsm 0.00091692 dsm_est 0.00242184 nsteps 5 - rtol 0.01 rk_type 1 order 3 acc 0 t 2.5 dsm 0.000303064 dsm_est 0.00155453 nsteps 5 - rtol 0.01 rk_type 1 order 3 acc 0 t 2.75 dsm 8.75302e-05 dsm_est 0.000628795 nsteps 5 - rtol 0.01 rk_type 1 order 3 acc 0 t 3 dsm 0.000106108 dsm_est 0.000628042 nsteps 5 - rtol 0.01 rk_type 1 order 3 acc 0 t 3.25 dsm 0.000146676 dsm_est 0.000206402 nsteps 5 - rtol 0.01 rk_type 1 order 3 acc 0 t 3.5 dsm 0.000132279 dsm_est 0.000121892 nsteps 5 - rtol 0.01 rk_type 1 order 3 acc 0 t 3.75 dsm 0.000106549 dsm_est 7.66243e-05 nsteps 5 - rtol 0.01 rk_type 1 order 3 acc 0 t 4 dsm 7.68783e-05 dsm_est 6.29323e-05 nsteps 5 - rtol 0.01 rk_type 1 order 3 acc 0 t 4.25 dsm 9.2941e-05 dsm_est 0.000487848 nsteps 5 - rtol 0.01 rk_type 1 order 3 acc 0 t 4.5 dsm 1.84821e-05 dsm_est 0.000635863 nsteps 5 - rtol 0.01 rk_type 1 order 3 acc 0 t 4.75 dsm 6.25225e-05 dsm_est 0.000713957 nsteps 5 - rtol 0.01 rk_type 1 order 3 acc 0 t 5 dsm 1.27772e-05 dsm_est 0.000232819 nsteps 5 - rtol 0.01 rk_type 1 order 3 acc 1 t 0.25 dsm 6.04149e-05 dsm_est 2.84962e-05 nsteps 5 - rtol 0.01 rk_type 1 order 3 acc 1 t 0.5 dsm 0.000268262 dsm_est 0.00035888 nsteps 5 - rtol 0.01 rk_type 1 order 3 acc 1 t 0.75 dsm 0.000162426 dsm_est 0.000612632 nsteps 5 - rtol 0.01 rk_type 1 order 3 acc 1 t 1 dsm 0.00010345 dsm_est 0.000591054 nsteps 5 - rtol 0.01 rk_type 1 order 3 acc 1 t 1.25 dsm 0.00145293 dsm_est 0.000651262 nsteps 7 - rtol 0.01 rk_type 1 order 3 acc 1 t 1.5 dsm 0.000475504 dsm_est 0.000619088 nsteps 6 - rtol 0.01 rk_type 1 order 3 acc 1 t 1.75 dsm 0.000953909 dsm_est 0.00225203 nsteps 5 - rtol 0.01 rk_type 1 order 3 acc 1 t 2 dsm 0.00190469 dsm_est 0.00106139 nsteps 6 - rtol 0.01 rk_type 1 order 3 acc 1 t 2.25 dsm 0.00091692 dsm_est 0.000519458 nsteps 5 - rtol 0.01 rk_type 1 order 3 acc 1 t 2.5 dsm 0.000303064 dsm_est 0.000373224 nsteps 5 - rtol 0.01 rk_type 1 order 3 acc 1 t 2.75 dsm 8.75302e-05 dsm_est 0.000251533 nsteps 5 - rtol 0.01 rk_type 1 order 3 acc 1 t 3 dsm 0.000106108 dsm_est 0.000216057 nsteps 5 - rtol 0.01 rk_type 1 order 3 acc 1 t 3.25 dsm 0.000146676 dsm_est 5.74422e-05 nsteps 5 - rtol 0.01 rk_type 1 order 3 acc 1 t 3.5 dsm 0.000132279 dsm_est 3.97606e-05 nsteps 5 - rtol 0.01 rk_type 1 order 3 acc 1 t 3.75 dsm 0.000106549 dsm_est 2.55114e-05 nsteps 5 - rtol 0.01 rk_type 1 order 3 acc 1 t 4 dsm 7.68783e-05 dsm_est 1.97574e-05 nsteps 5 - rtol 0.01 rk_type 1 order 3 acc 1 t 4.25 dsm 9.2941e-05 dsm_est 0.000147815 nsteps 5 - rtol 0.01 rk_type 1 order 3 acc 1 t 4.5 dsm 1.84821e-05 dsm_est 0.000156419 nsteps 5 - rtol 0.01 rk_type 1 order 3 acc 1 t 4.75 dsm 6.25225e-05 dsm_est 0.000247722 nsteps 5 - rtol 0.01 rk_type 1 order 3 acc 1 t 5 dsm 1.27772e-05 dsm_est 6.70899e-05 nsteps 5 - rtol 0.0001 rk_type 1 order 3 acc 0 t 0.25 dsm 2.72131e-05 dsm_est 1.82775e-05 nsteps 6 - rtol 0.0001 rk_type 1 order 3 acc 0 t 0.5 dsm 1.24325e-05 dsm_est 7.57337e-05 nsteps 10 - rtol 0.0001 rk_type 1 order 3 acc 0 t 0.75 dsm 3.04294e-06 dsm_est 5.32249e-05 nsteps 11 - rtol 0.0001 rk_type 1 order 3 acc 0 t 1 dsm 5.56473e-06 dsm_est 4.83864e-05 nsteps 10 - rtol 0.0001 rk_type 1 order 3 acc 0 t 1.25 dsm 2.64925e-05 dsm_est 9.09824e-05 nsteps 14 - rtol 0.0001 rk_type 1 order 3 acc 0 t 1.5 dsm 3.99013e-05 dsm_est 6.618e-05 nsteps 17 - rtol 0.0001 rk_type 1 order 3 acc 0 t 1.75 dsm 6.46566e-06 dsm_est 9.0814e-05 nsteps 20 - rtol 0.0001 rk_type 1 order 3 acc 0 t 2 dsm 2.27591e-05 dsm_est 4.33739e-05 nsteps 14 - rtol 0.0001 rk_type 1 order 3 acc 0 t 2.25 dsm 2.35987e-05 dsm_est 6.01739e-05 nsteps 12 - rtol 0.0001 rk_type 1 order 3 acc 0 t 2.5 dsm 1.9839e-05 dsm_est 5.21299e-05 nsteps 10 - rtol 0.0001 rk_type 1 order 3 acc 0 t 2.75 dsm 4.82543e-06 dsm_est 7.16519e-05 nsteps 9 - rtol 0.0001 rk_type 1 order 3 acc 0 t 3 dsm 1.42111e-05 dsm_est 8.44199e-05 nsteps 9 - rtol 0.0001 rk_type 1 order 3 acc 0 t 3.25 dsm 8.99237e-05 dsm_est 5.93926e-05 nsteps 6 - rtol 0.0001 rk_type 1 order 3 acc 0 t 3.5 dsm 7.05943e-05 dsm_est 2.57508e-05 nsteps 6 - rtol 0.0001 rk_type 1 order 3 acc 0 t 3.75 dsm 0.00011745 dsm_est 7.78236e-05 nsteps 5 - rtol 0.0001 rk_type 1 order 3 acc 0 t 4 dsm 8.6392e-05 dsm_est 6.06003e-05 nsteps 5 - rtol 0.0001 rk_type 1 order 3 acc 0 t 4.25 dsm 1.06282e-05 dsm_est 9.64146e-05 nsteps 8 - rtol 0.0001 rk_type 1 order 3 acc 0 t 4.5 dsm 3.00465e-06 dsm_est 6.91731e-05 nsteps 9 - rtol 0.0001 rk_type 1 order 3 acc 0 t 4.75 dsm 2.24177e-06 dsm_est 6.08731e-05 nsteps 9 - rtol 0.0001 rk_type 1 order 3 acc 0 t 5 dsm 4.61559e-06 dsm_est 3.8972e-05 nsteps 7 - rtol 0.0001 rk_type 1 order 3 acc 1 t 0.25 dsm 2.72131e-05 dsm_est 8.20667e-06 nsteps 6 - rtol 0.0001 rk_type 1 order 3 acc 1 t 0.5 dsm 1.24325e-05 dsm_est 2.77893e-05 nsteps 10 - rtol 0.0001 rk_type 1 order 3 acc 1 t 0.75 dsm 3.04294e-06 dsm_est 2.4191e-05 nsteps 11 - rtol 0.0001 rk_type 1 order 3 acc 1 t 1 dsm 5.56473e-06 dsm_est 2.1078e-05 nsteps 10 - rtol 0.0001 rk_type 1 order 3 acc 1 t 1.25 dsm 2.64925e-05 dsm_est 4.37622e-05 nsteps 14 - rtol 0.0001 rk_type 1 order 3 acc 1 t 1.5 dsm 3.99013e-05 dsm_est 2.21272e-05 nsteps 17 - rtol 0.0001 rk_type 1 order 3 acc 1 t 1.75 dsm 6.46566e-06 dsm_est 3.32327e-05 nsteps 20 - rtol 0.0001 rk_type 1 order 3 acc 1 t 2 dsm 2.27591e-05 dsm_est 1.88101e-05 nsteps 14 - rtol 0.0001 rk_type 1 order 3 acc 1 t 2.25 dsm 2.35987e-05 dsm_est 1.82395e-05 nsteps 12 - rtol 0.0001 rk_type 1 order 3 acc 1 t 2.5 dsm 1.9839e-05 dsm_est 1.44657e-05 nsteps 10 - rtol 0.0001 rk_type 1 order 3 acc 1 t 2.75 dsm 4.82543e-06 dsm_est 2.04852e-05 nsteps 9 - rtol 0.0001 rk_type 1 order 3 acc 1 t 3 dsm 1.42111e-05 dsm_est 2.59031e-05 nsteps 9 - rtol 0.0001 rk_type 1 order 3 acc 1 t 3.25 dsm 8.99237e-05 dsm_est 1.52677e-05 nsteps 6 - rtol 0.0001 rk_type 1 order 3 acc 1 t 3.5 dsm 7.05943e-05 dsm_est 1.07712e-05 nsteps 6 - rtol 0.0001 rk_type 1 order 3 acc 1 t 3.75 dsm 0.00011745 dsm_est 2.59539e-05 nsteps 5 - rtol 0.0001 rk_type 1 order 3 acc 1 t 4 dsm 8.6392e-05 dsm_est 2.17376e-05 nsteps 5 - rtol 0.0001 rk_type 1 order 3 acc 1 t 4.25 dsm 1.06282e-05 dsm_est 2.59085e-05 nsteps 8 - rtol 0.0001 rk_type 1 order 3 acc 1 t 4.5 dsm 3.00465e-06 dsm_est 1.89589e-05 nsteps 9 - rtol 0.0001 rk_type 1 order 3 acc 1 t 4.75 dsm 2.24177e-06 dsm_est 1.96451e-05 nsteps 9 - rtol 0.0001 rk_type 1 order 3 acc 1 t 5 dsm 4.61559e-06 dsm_est 1.20081e-05 nsteps 7 - rtol 1e-06 rk_type 1 order 3 acc 0 t 0.25 dsm 4.12033e-07 dsm_est 8.83529e-07 nsteps 17 - rtol 1e-06 rk_type 1 order 3 acc 0 t 0.5 dsm 2.46326e-07 dsm_est 8.87311e-07 nsteps 31 - rtol 1e-06 rk_type 1 order 3 acc 0 t 0.75 dsm 3.64026e-08 dsm_est 8.31388e-07 nsteps 39 - rtol 1e-06 rk_type 1 order 3 acc 0 t 1 dsm 2.25687e-07 dsm_est 5.06051e-07 nsteps 45 - rtol 1e-06 rk_type 1 order 3 acc 0 t 1.25 dsm 5.93423e-07 dsm_est 9.4211e-07 nsteps 53 - rtol 1e-06 rk_type 1 order 3 acc 0 t 1.5 dsm 6.11123e-07 dsm_est 7.4438e-07 nsteps 68 - rtol 1e-06 rk_type 1 order 3 acc 0 t 1.75 dsm 1.11041e-07 dsm_est 8.66272e-07 nsteps 76 - rtol 1e-06 rk_type 1 order 3 acc 0 t 2 dsm 4.68945e-07 dsm_est 8.0627e-07 nsteps 49 - rtol 1e-06 rk_type 1 order 3 acc 0 t 2.25 dsm 2.82077e-07 dsm_est 7.6683e-07 nsteps 46 - rtol 1e-06 rk_type 1 order 3 acc 0 t 2.5 dsm 3.42754e-07 dsm_est 6.52319e-07 nsteps 37 - rtol 1e-06 rk_type 1 order 3 acc 0 t 2.75 dsm 8.76441e-08 dsm_est 7.34826e-07 nsteps 30 - rtol 1e-06 rk_type 1 order 3 acc 0 t 3 dsm 9.61476e-08 dsm_est 8.15376e-07 nsteps 29 - rtol 1e-06 rk_type 1 order 3 acc 0 t 3.25 dsm 1.10578e-06 dsm_est 8.36809e-07 nsteps 19 - rtol 1e-06 rk_type 1 order 3 acc 0 t 3.5 dsm 8.13041e-07 dsm_est 6.57651e-07 nsteps 19 - rtol 1e-06 rk_type 1 order 3 acc 0 t 3.75 dsm 8.63105e-07 dsm_est 6.37719e-07 nsteps 15 - rtol 1e-06 rk_type 1 order 3 acc 0 t 4 dsm 6.24598e-07 dsm_est 6.02239e-07 nsteps 17 - rtol 1e-06 rk_type 1 order 3 acc 0 t 4.25 dsm 1.79535e-07 dsm_est 8.62348e-07 nsteps 24 - rtol 1e-06 rk_type 1 order 3 acc 0 t 4.5 dsm 4.23449e-08 dsm_est 8.85746e-07 nsteps 29 - rtol 1e-06 rk_type 1 order 3 acc 0 t 4.75 dsm 1.70945e-08 dsm_est 6.68877e-07 nsteps 35 - rtol 1e-06 rk_type 1 order 3 acc 0 t 5 dsm 4.21376e-08 dsm_est 6.1895e-07 nsteps 23 - rtol 1e-06 rk_type 1 order 3 acc 1 t 0.25 dsm 4.12033e-07 dsm_est 3.17288e-07 nsteps 17 - rtol 1e-06 rk_type 1 order 3 acc 1 t 0.5 dsm 2.46326e-07 dsm_est 6.20547e-07 nsteps 31 - rtol 1e-06 rk_type 1 order 3 acc 1 t 0.75 dsm 3.64026e-08 dsm_est 4.69255e-07 nsteps 39 - rtol 1e-06 rk_type 1 order 3 acc 1 t 1 dsm 2.25687e-07 dsm_est 2.13052e-07 nsteps 45 - rtol 1e-06 rk_type 1 order 3 acc 1 t 1.25 dsm 5.93423e-07 dsm_est 6.03951e-07 nsteps 53 - rtol 1e-06 rk_type 1 order 3 acc 1 t 1.5 dsm 6.11123e-07 dsm_est 2.8192e-07 nsteps 68 - rtol 1e-06 rk_type 1 order 3 acc 1 t 1.75 dsm 1.11041e-07 dsm_est 4.94913e-07 nsteps 76 - rtol 1e-06 rk_type 1 order 3 acc 1 t 2 dsm 4.68945e-07 dsm_est 3.61283e-07 nsteps 49 - rtol 1e-06 rk_type 1 order 3 acc 1 t 2.25 dsm 2.82077e-07 dsm_est 3.07636e-07 nsteps 46 - rtol 1e-06 rk_type 1 order 3 acc 1 t 2.5 dsm 3.42754e-07 dsm_est 2.3822e-07 nsteps 37 - rtol 1e-06 rk_type 1 order 3 acc 1 t 2.75 dsm 8.76441e-08 dsm_est 3.52094e-07 nsteps 30 - rtol 1e-06 rk_type 1 order 3 acc 1 t 3 dsm 9.61476e-08 dsm_est 3.53089e-07 nsteps 29 - rtol 1e-06 rk_type 1 order 3 acc 1 t 3.25 dsm 1.10578e-06 dsm_est 3.08489e-07 nsteps 19 - rtol 1e-06 rk_type 1 order 3 acc 1 t 3.5 dsm 8.13041e-07 dsm_est 2.17804e-07 nsteps 19 - rtol 1e-06 rk_type 1 order 3 acc 1 t 3.75 dsm 8.63105e-07 dsm_est 3.30737e-07 nsteps 15 - rtol 1e-06 rk_type 1 order 3 acc 1 t 4 dsm 6.24598e-07 dsm_est 2.01343e-07 nsteps 17 - rtol 1e-06 rk_type 1 order 3 acc 1 t 4.25 dsm 1.79535e-07 dsm_est 5.65678e-07 nsteps 24 - rtol 1e-06 rk_type 1 order 3 acc 1 t 4.5 dsm 4.23449e-08 dsm_est 3.44003e-07 nsteps 29 - rtol 1e-06 rk_type 1 order 3 acc 1 t 4.75 dsm 1.70945e-08 dsm_est 2.39733e-07 nsteps 35 - rtol 1e-06 rk_type 1 order 3 acc 1 t 5 dsm 4.21376e-08 dsm_est 2.14337e-07 nsteps 23 + rtol 0.01 rk_type 1 order 3 acc 1 t 0.25 dsm 6.04149e-05 dsm_est 0.000128901 nsteps 5 + rtol 0.01 rk_type 1 order 3 acc 1 t 0.5 dsm 0.000268262 dsm_est 0.00122853 nsteps 5 + rtol 0.01 rk_type 1 order 3 acc 1 t 0.75 dsm 0.000162426 dsm_est 0.00195582 nsteps 5 + rtol 0.01 rk_type 1 order 3 acc 1 t 1 dsm 0.00010345 dsm_est 0.0018572 nsteps 5 + rtol 0.01 rk_type 1 order 3 acc 1 t 1.25 dsm 0.00145293 dsm_est 0.00223784 nsteps 7 + rtol 0.01 rk_type 1 order 3 acc 1 t 1.5 dsm 0.000475504 dsm_est 0.00220612 nsteps 6 + rtol 0.01 rk_type 1 order 3 acc 1 t 1.75 dsm 0.000953909 dsm_est 0.00848961 nsteps 5 + rtol 0.01 rk_type 1 order 3 acc 1 t 2 dsm 0.00190469 dsm_est 0.00438086 nsteps 6 + rtol 0.01 rk_type 1 order 3 acc 1 t 2.25 dsm 0.00091692 dsm_est 0.00242184 nsteps 5 + rtol 0.01 rk_type 1 order 3 acc 1 t 2.5 dsm 0.000303064 dsm_est 0.00155453 nsteps 5 + rtol 0.01 rk_type 1 order 3 acc 1 t 2.75 dsm 8.75302e-05 dsm_est 0.000628795 nsteps 5 + rtol 0.01 rk_type 1 order 3 acc 1 t 3 dsm 0.000106108 dsm_est 0.000628042 nsteps 5 + rtol 0.01 rk_type 1 order 3 acc 1 t 3.25 dsm 0.000146676 dsm_est 0.000206402 nsteps 5 + rtol 0.01 rk_type 1 order 3 acc 1 t 3.5 dsm 0.000132279 dsm_est 0.000121892 nsteps 5 + rtol 0.01 rk_type 1 order 3 acc 1 t 3.75 dsm 0.000106549 dsm_est 7.66243e-05 nsteps 5 + rtol 0.01 rk_type 1 order 3 acc 1 t 4 dsm 7.68783e-05 dsm_est 6.29323e-05 nsteps 5 + rtol 0.01 rk_type 1 order 3 acc 1 t 4.25 dsm 9.2941e-05 dsm_est 0.000487848 nsteps 5 + rtol 0.01 rk_type 1 order 3 acc 1 t 4.5 dsm 1.84821e-05 dsm_est 0.000635863 nsteps 5 + rtol 0.01 rk_type 1 order 3 acc 1 t 4.75 dsm 6.25225e-05 dsm_est 0.000713957 nsteps 5 + rtol 0.01 rk_type 1 order 3 acc 1 t 5 dsm 1.27772e-05 dsm_est 0.000232819 nsteps 5 + rtol 0.01 rk_type 1 order 3 acc 3 t 0.25 dsm 6.04149e-05 dsm_est 2.84962e-05 nsteps 5 + rtol 0.01 rk_type 1 order 3 acc 3 t 0.5 dsm 0.000268262 dsm_est 0.00035888 nsteps 5 + rtol 0.01 rk_type 1 order 3 acc 3 t 0.75 dsm 0.000162426 dsm_est 0.000612632 nsteps 5 + rtol 0.01 rk_type 1 order 3 acc 3 t 1 dsm 0.00010345 dsm_est 0.000591054 nsteps 5 + rtol 0.01 rk_type 1 order 3 acc 3 t 1.25 dsm 0.00145293 dsm_est 0.000651262 nsteps 7 + rtol 0.01 rk_type 1 order 3 acc 3 t 1.5 dsm 0.000475504 dsm_est 0.000619088 nsteps 6 + rtol 0.01 rk_type 1 order 3 acc 3 t 1.75 dsm 0.000953909 dsm_est 0.00225203 nsteps 5 + rtol 0.01 rk_type 1 order 3 acc 3 t 2 dsm 0.00190469 dsm_est 0.00106139 nsteps 6 + rtol 0.01 rk_type 1 order 3 acc 3 t 2.25 dsm 0.00091692 dsm_est 0.000519458 nsteps 5 + rtol 0.01 rk_type 1 order 3 acc 3 t 2.5 dsm 0.000303064 dsm_est 0.000373224 nsteps 5 + rtol 0.01 rk_type 1 order 3 acc 3 t 2.75 dsm 8.75302e-05 dsm_est 0.000251533 nsteps 5 + rtol 0.01 rk_type 1 order 3 acc 3 t 3 dsm 0.000106108 dsm_est 0.000216057 nsteps 5 + rtol 0.01 rk_type 1 order 3 acc 3 t 3.25 dsm 0.000146676 dsm_est 5.74422e-05 nsteps 5 + rtol 0.01 rk_type 1 order 3 acc 3 t 3.5 dsm 0.000132279 dsm_est 3.97606e-05 nsteps 5 + rtol 0.01 rk_type 1 order 3 acc 3 t 3.75 dsm 0.000106549 dsm_est 2.55114e-05 nsteps 5 + rtol 0.01 rk_type 1 order 3 acc 3 t 4 dsm 7.68783e-05 dsm_est 1.97574e-05 nsteps 5 + rtol 0.01 rk_type 1 order 3 acc 3 t 4.25 dsm 9.2941e-05 dsm_est 0.000147815 nsteps 5 + rtol 0.01 rk_type 1 order 3 acc 3 t 4.5 dsm 1.84821e-05 dsm_est 0.000156419 nsteps 5 + rtol 0.01 rk_type 1 order 3 acc 3 t 4.75 dsm 6.25225e-05 dsm_est 0.000247722 nsteps 5 + rtol 0.01 rk_type 1 order 3 acc 3 t 5 dsm 1.27772e-05 dsm_est 6.70899e-05 nsteps 5 + rtol 0.0001 rk_type 1 order 3 acc 1 t 0.25 dsm 2.72131e-05 dsm_est 1.82775e-05 nsteps 6 + rtol 0.0001 rk_type 1 order 3 acc 1 t 0.5 dsm 1.24325e-05 dsm_est 7.57337e-05 nsteps 10 + rtol 0.0001 rk_type 1 order 3 acc 1 t 0.75 dsm 3.04294e-06 dsm_est 5.32249e-05 nsteps 11 + rtol 0.0001 rk_type 1 order 3 acc 1 t 1 dsm 5.56473e-06 dsm_est 4.83864e-05 nsteps 10 + rtol 0.0001 rk_type 1 order 3 acc 1 t 1.25 dsm 2.64925e-05 dsm_est 9.09824e-05 nsteps 14 + rtol 0.0001 rk_type 1 order 3 acc 1 t 1.5 dsm 3.99013e-05 dsm_est 6.618e-05 nsteps 17 + rtol 0.0001 rk_type 1 order 3 acc 1 t 1.75 dsm 6.46566e-06 dsm_est 9.0814e-05 nsteps 20 + rtol 0.0001 rk_type 1 order 3 acc 1 t 2 dsm 2.27591e-05 dsm_est 4.33739e-05 nsteps 14 + rtol 0.0001 rk_type 1 order 3 acc 1 t 2.25 dsm 2.35987e-05 dsm_est 6.01739e-05 nsteps 12 + rtol 0.0001 rk_type 1 order 3 acc 1 t 2.5 dsm 1.9839e-05 dsm_est 5.21299e-05 nsteps 10 + rtol 0.0001 rk_type 1 order 3 acc 1 t 2.75 dsm 4.82543e-06 dsm_est 7.16519e-05 nsteps 9 + rtol 0.0001 rk_type 1 order 3 acc 1 t 3 dsm 1.42111e-05 dsm_est 8.44199e-05 nsteps 9 + rtol 0.0001 rk_type 1 order 3 acc 1 t 3.25 dsm 8.99237e-05 dsm_est 5.93926e-05 nsteps 6 + rtol 0.0001 rk_type 1 order 3 acc 1 t 3.5 dsm 7.05943e-05 dsm_est 2.57508e-05 nsteps 6 + rtol 0.0001 rk_type 1 order 3 acc 1 t 3.75 dsm 0.00011745 dsm_est 7.78236e-05 nsteps 5 + rtol 0.0001 rk_type 1 order 3 acc 1 t 4 dsm 8.6392e-05 dsm_est 6.06003e-05 nsteps 5 + rtol 0.0001 rk_type 1 order 3 acc 1 t 4.25 dsm 1.06282e-05 dsm_est 9.64146e-05 nsteps 8 + rtol 0.0001 rk_type 1 order 3 acc 1 t 4.5 dsm 3.00465e-06 dsm_est 6.91731e-05 nsteps 9 + rtol 0.0001 rk_type 1 order 3 acc 1 t 4.75 dsm 2.24177e-06 dsm_est 6.08731e-05 nsteps 9 + rtol 0.0001 rk_type 1 order 3 acc 1 t 5 dsm 4.61559e-06 dsm_est 3.8972e-05 nsteps 7 + rtol 0.0001 rk_type 1 order 3 acc 3 t 0.25 dsm 2.72131e-05 dsm_est 8.20667e-06 nsteps 6 + rtol 0.0001 rk_type 1 order 3 acc 3 t 0.5 dsm 1.24325e-05 dsm_est 2.77893e-05 nsteps 10 + rtol 0.0001 rk_type 1 order 3 acc 3 t 0.75 dsm 3.04294e-06 dsm_est 2.4191e-05 nsteps 11 + rtol 0.0001 rk_type 1 order 3 acc 3 t 1 dsm 5.56473e-06 dsm_est 2.1078e-05 nsteps 10 + rtol 0.0001 rk_type 1 order 3 acc 3 t 1.25 dsm 2.64925e-05 dsm_est 4.37622e-05 nsteps 14 + rtol 0.0001 rk_type 1 order 3 acc 3 t 1.5 dsm 3.99013e-05 dsm_est 2.21272e-05 nsteps 17 + rtol 0.0001 rk_type 1 order 3 acc 3 t 1.75 dsm 6.46566e-06 dsm_est 3.32327e-05 nsteps 20 + rtol 0.0001 rk_type 1 order 3 acc 3 t 2 dsm 2.27591e-05 dsm_est 1.88101e-05 nsteps 14 + rtol 0.0001 rk_type 1 order 3 acc 3 t 2.25 dsm 2.35987e-05 dsm_est 1.82395e-05 nsteps 12 + rtol 0.0001 rk_type 1 order 3 acc 3 t 2.5 dsm 1.9839e-05 dsm_est 1.44657e-05 nsteps 10 + rtol 0.0001 rk_type 1 order 3 acc 3 t 2.75 dsm 4.82543e-06 dsm_est 2.04852e-05 nsteps 9 + rtol 0.0001 rk_type 1 order 3 acc 3 t 3 dsm 1.42111e-05 dsm_est 2.59031e-05 nsteps 9 + rtol 0.0001 rk_type 1 order 3 acc 3 t 3.25 dsm 8.99237e-05 dsm_est 1.52677e-05 nsteps 6 + rtol 0.0001 rk_type 1 order 3 acc 3 t 3.5 dsm 7.05943e-05 dsm_est 1.07712e-05 nsteps 6 + rtol 0.0001 rk_type 1 order 3 acc 3 t 3.75 dsm 0.00011745 dsm_est 2.59539e-05 nsteps 5 + rtol 0.0001 rk_type 1 order 3 acc 3 t 4 dsm 8.6392e-05 dsm_est 2.17376e-05 nsteps 5 + rtol 0.0001 rk_type 1 order 3 acc 3 t 4.25 dsm 1.06282e-05 dsm_est 2.59085e-05 nsteps 8 + rtol 0.0001 rk_type 1 order 3 acc 3 t 4.5 dsm 3.00465e-06 dsm_est 1.89589e-05 nsteps 9 + rtol 0.0001 rk_type 1 order 3 acc 3 t 4.75 dsm 2.24177e-06 dsm_est 1.96451e-05 nsteps 9 + rtol 0.0001 rk_type 1 order 3 acc 3 t 5 dsm 4.61559e-06 dsm_est 1.20081e-05 nsteps 7 + rtol 1e-06 rk_type 1 order 3 acc 1 t 0.25 dsm 4.12033e-07 dsm_est 8.83529e-07 nsteps 17 + rtol 1e-06 rk_type 1 order 3 acc 1 t 0.5 dsm 2.46326e-07 dsm_est 8.87311e-07 nsteps 31 + rtol 1e-06 rk_type 1 order 3 acc 1 t 0.75 dsm 3.64026e-08 dsm_est 8.31388e-07 nsteps 39 + rtol 1e-06 rk_type 1 order 3 acc 1 t 1 dsm 2.25687e-07 dsm_est 5.06051e-07 nsteps 45 + rtol 1e-06 rk_type 1 order 3 acc 1 t 1.25 dsm 5.93423e-07 dsm_est 9.4211e-07 nsteps 53 + rtol 1e-06 rk_type 1 order 3 acc 1 t 1.5 dsm 6.11123e-07 dsm_est 7.4438e-07 nsteps 68 + rtol 1e-06 rk_type 1 order 3 acc 1 t 1.75 dsm 1.11041e-07 dsm_est 8.66272e-07 nsteps 76 + rtol 1e-06 rk_type 1 order 3 acc 1 t 2 dsm 4.68945e-07 dsm_est 8.0627e-07 nsteps 49 + rtol 1e-06 rk_type 1 order 3 acc 1 t 2.25 dsm 2.82077e-07 dsm_est 7.6683e-07 nsteps 46 + rtol 1e-06 rk_type 1 order 3 acc 1 t 2.5 dsm 3.42754e-07 dsm_est 6.52319e-07 nsteps 37 + rtol 1e-06 rk_type 1 order 3 acc 1 t 2.75 dsm 8.76441e-08 dsm_est 7.34826e-07 nsteps 30 + rtol 1e-06 rk_type 1 order 3 acc 1 t 3 dsm 9.61476e-08 dsm_est 8.15376e-07 nsteps 29 + rtol 1e-06 rk_type 1 order 3 acc 1 t 3.25 dsm 1.10578e-06 dsm_est 8.36809e-07 nsteps 19 + rtol 1e-06 rk_type 1 order 3 acc 1 t 3.5 dsm 8.13041e-07 dsm_est 6.57651e-07 nsteps 19 + rtol 1e-06 rk_type 1 order 3 acc 1 t 3.75 dsm 8.63105e-07 dsm_est 6.37719e-07 nsteps 15 + rtol 1e-06 rk_type 1 order 3 acc 1 t 4 dsm 6.24598e-07 dsm_est 6.02239e-07 nsteps 17 + rtol 1e-06 rk_type 1 order 3 acc 1 t 4.25 dsm 1.79535e-07 dsm_est 8.62348e-07 nsteps 24 + rtol 1e-06 rk_type 1 order 3 acc 1 t 4.5 dsm 4.23449e-08 dsm_est 8.85746e-07 nsteps 29 + rtol 1e-06 rk_type 1 order 3 acc 1 t 4.75 dsm 1.70945e-08 dsm_est 6.68877e-07 nsteps 35 + rtol 1e-06 rk_type 1 order 3 acc 1 t 5 dsm 4.21376e-08 dsm_est 6.1895e-07 nsteps 23 + rtol 1e-06 rk_type 1 order 3 acc 3 t 0.25 dsm 4.12033e-07 dsm_est 3.17288e-07 nsteps 17 + rtol 1e-06 rk_type 1 order 3 acc 3 t 0.5 dsm 2.46326e-07 dsm_est 6.20547e-07 nsteps 31 + rtol 1e-06 rk_type 1 order 3 acc 3 t 0.75 dsm 3.64026e-08 dsm_est 4.69255e-07 nsteps 39 + rtol 1e-06 rk_type 1 order 3 acc 3 t 1 dsm 2.25687e-07 dsm_est 2.13052e-07 nsteps 45 + rtol 1e-06 rk_type 1 order 3 acc 3 t 1.25 dsm 5.93423e-07 dsm_est 6.03951e-07 nsteps 53 + rtol 1e-06 rk_type 1 order 3 acc 3 t 1.5 dsm 6.11123e-07 dsm_est 2.8192e-07 nsteps 68 + rtol 1e-06 rk_type 1 order 3 acc 3 t 1.75 dsm 1.11041e-07 dsm_est 4.94913e-07 nsteps 76 + rtol 1e-06 rk_type 1 order 3 acc 3 t 2 dsm 4.68945e-07 dsm_est 3.61283e-07 nsteps 49 + rtol 1e-06 rk_type 1 order 3 acc 3 t 2.25 dsm 2.82077e-07 dsm_est 3.07636e-07 nsteps 46 + rtol 1e-06 rk_type 1 order 3 acc 3 t 2.5 dsm 3.42754e-07 dsm_est 2.3822e-07 nsteps 37 + rtol 1e-06 rk_type 1 order 3 acc 3 t 2.75 dsm 8.76441e-08 dsm_est 3.52094e-07 nsteps 30 + rtol 1e-06 rk_type 1 order 3 acc 3 t 3 dsm 9.61476e-08 dsm_est 3.53089e-07 nsteps 29 + rtol 1e-06 rk_type 1 order 3 acc 3 t 3.25 dsm 1.10578e-06 dsm_est 3.08489e-07 nsteps 19 + rtol 1e-06 rk_type 1 order 3 acc 3 t 3.5 dsm 8.13041e-07 dsm_est 2.17804e-07 nsteps 19 + rtol 1e-06 rk_type 1 order 3 acc 3 t 3.75 dsm 8.63105e-07 dsm_est 3.30737e-07 nsteps 15 + rtol 1e-06 rk_type 1 order 3 acc 3 t 4 dsm 6.24598e-07 dsm_est 2.01343e-07 nsteps 17 + rtol 1e-06 rk_type 1 order 3 acc 3 t 4.25 dsm 1.79535e-07 dsm_est 5.65678e-07 nsteps 24 + rtol 1e-06 rk_type 1 order 3 acc 3 t 4.5 dsm 4.23449e-08 dsm_est 3.44003e-07 nsteps 29 + rtol 1e-06 rk_type 1 order 3 acc 3 t 4.75 dsm 1.70945e-08 dsm_est 2.39733e-07 nsteps 35 + rtol 1e-06 rk_type 1 order 3 acc 3 t 5 dsm 4.21376e-08 dsm_est 2.14337e-07 nsteps 23 diff --git a/test/unit_tests/arkode/CXX_serial/ark_test_dahlquist_mri_-1.out b/test/unit_tests/arkode/CXX_serial/ark_test_dahlquist_mri_-1.out index cc1343ca4c..dedbba4239 100644 --- a/test/unit_tests/arkode/CXX_serial/ark_test_dahlquist_mri_-1.out +++ b/test/unit_tests/arkode/CXX_serial/ark_test_dahlquist_mri_-1.out @@ -227,14 +227,14 @@ Testing method ARKODE_MRI_GARK_RALSTON3 nmat = 2 stages = 4 method order (q) = 3 - embedding order (p) = 0 + embedding order (p) = 2 c = 0 0.5 0.75 1 W[0] = 0 0 0 0 0.5 0 0 0 -2.75 3 0 0 1.305555555555556 -0.1666666666666667 -0.8888888888888888 0 - 0 0 0 0 + 0.025 0.175 0.05 0 W[1] = 0 0 0 0 diff --git a/test/unit_tests/arkode/CXX_serial/ark_test_dahlquist_mri_0.out b/test/unit_tests/arkode/CXX_serial/ark_test_dahlquist_mri_0.out index 36b5c0aaef..b4d2dc4117 100644 --- a/test/unit_tests/arkode/CXX_serial/ark_test_dahlquist_mri_0.out +++ b/test/unit_tests/arkode/CXX_serial/ark_test_dahlquist_mri_0.out @@ -227,14 +227,14 @@ Testing method ARKODE_MRI_GARK_RALSTON3 nmat = 2 stages = 4 method order (q) = 3 - embedding order (p) = 0 + embedding order (p) = 2 c = 0 0.5 0.75 1 W[0] = 0 0 0 0 0.5 0 0 0 -2.75 3 0 0 1.305555555555556 -0.1666666666666667 -0.8888888888888888 0 - 0 0 0 0 + 0.025 0.175 0.05 0 W[1] = 0 0 0 0 diff --git a/test/unit_tests/arkode/CXX_serial/ark_test_dahlquist_mri_1.out b/test/unit_tests/arkode/CXX_serial/ark_test_dahlquist_mri_1.out index 66c18208c1..9f48d829f2 100644 --- a/test/unit_tests/arkode/CXX_serial/ark_test_dahlquist_mri_1.out +++ b/test/unit_tests/arkode/CXX_serial/ark_test_dahlquist_mri_1.out @@ -227,14 +227,14 @@ Testing method ARKODE_MRI_GARK_RALSTON3 nmat = 2 stages = 4 method order (q) = 3 - embedding order (p) = 0 + embedding order (p) = 2 c = 0 0.5 0.75 1 W[0] = 0 0 0 0 0.5 0 0 0 -2.75 3 0 0 1.305555555555556 -0.1666666666666667 -0.8888888888888888 0 - 0 0 0 0 + 0.025 0.175 0.05 0 W[1] = 0 0 0 0 From a58e21f04898c9084f3e3ea41edbe7f2376655c9 Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Fri, 27 Sep 2024 14:46:06 -0500 Subject: [PATCH 092/286] Formatting; swig --- .../arkode/CXX_serial/ark_kpr_nestedmri.cpp | 3 +-- .../C_serial/ark_brusselator1D_imexmri.c | 5 +--- .../arkode/C_serial/ark_brusselator_1D_mri.c | 5 +--- .../arkode/C_serial/ark_brusselator_mri.c | 5 +--- examples/arkode/C_serial/ark_kpr_mri.c | 5 +--- .../arkode/C_serial/ark_onewaycouple_mri.c | 5 +--- .../C_serial/ark_reaction_diffusion_mri.c | 5 +--- .../arkode/C_serial/ark_twowaycouple_mri.c | 5 +--- include/arkode/arkode_arkstep.h | 1 - include/arkode/arkode_erkstep.h | 1 - include/arkode/arkode_mristep.h | 1 - src/arkode/arkode.c | 16 +++++------- src/arkode/arkode_arkstep.c | 6 +++-- src/arkode/arkode_arkstep_impl.h | 1 - src/arkode/arkode_arkstep_io.c | 1 + src/arkode/arkode_impl.h | 6 ++--- src/arkode/arkode_mristep_impl.h | 1 - src/arkode/fmod_int32/farkode_arkstep_mod.c | 14 ++++++++++ src/arkode/fmod_int32/farkode_arkstep_mod.f90 | 26 +++++++++++++++++++ .../arkode/C_serial/ark_test_reset.c | 5 +--- 20 files changed, 64 insertions(+), 53 deletions(-) diff --git a/examples/arkode/CXX_serial/ark_kpr_nestedmri.cpp b/examples/arkode/CXX_serial/ark_kpr_nestedmri.cpp index dc4bd06114..e981b6255d 100644 --- a/examples/arkode/CXX_serial/ark_kpr_nestedmri.cpp +++ b/examples/arkode/CXX_serial/ark_kpr_nestedmri.cpp @@ -869,8 +869,7 @@ int main(int argc, char* argv[]) // Create intermediate stepper MRIStepInnerStepper intermediate_stepper = nullptr; - retval = ARKodeCreateMRIStepInnerStepper(mid_arkode_mem, - &intermediate_stepper); + retval = ARKodeCreateMRIStepInnerStepper(mid_arkode_mem, &intermediate_stepper); if (check_flag(retval, "ARKodeCreateMRIStepInnerStepper")) return 1; // Create MRI (slow) integrator diff --git a/examples/arkode/C_serial/ark_brusselator1D_imexmri.c b/examples/arkode/C_serial/ark_brusselator1D_imexmri.c index 2deca42f2d..d189f920ef 100644 --- a/examples/arkode/C_serial/ark_brusselator1D_imexmri.c +++ b/examples/arkode/C_serial/ark_brusselator1D_imexmri.c @@ -524,10 +524,7 @@ int main(int argc, char* argv[]) /* Create inner stepper */ retval = ARKodeCreateMRIStepInnerStepper(inner_arkode_mem, &inner_stepper); - if (check_retval(&retval, "ARKodeCreateMRIStepInnerStepper", 1)) - { - return 1; - } + if (check_retval(&retval, "ARKodeCreateMRIStepInnerStepper", 1)) { return 1; } /* * Create the slow integrator and set options diff --git a/examples/arkode/C_serial/ark_brusselator_1D_mri.c b/examples/arkode/C_serial/ark_brusselator_1D_mri.c index d9a9ce21d8..5a6b325f3e 100644 --- a/examples/arkode/C_serial/ark_brusselator_1D_mri.c +++ b/examples/arkode/C_serial/ark_brusselator_1D_mri.c @@ -249,10 +249,7 @@ int main(int argc, char* argv[]) /* Create inner stepper */ retval = ARKodeCreateMRIStepInnerStepper(inner_arkode_mem, &inner_stepper); - if (check_retval(&retval, "ARKodeCreateMRIStepInnerStepper", 1)) - { - return 1; - } + if (check_retval(&retval, "ARKodeCreateMRIStepInnerStepper", 1)) { return 1; } /* * Create the slow integrator and set options diff --git a/examples/arkode/C_serial/ark_brusselator_mri.c b/examples/arkode/C_serial/ark_brusselator_mri.c index 1586ca51f6..51e79f3cf5 100644 --- a/examples/arkode/C_serial/ark_brusselator_mri.c +++ b/examples/arkode/C_serial/ark_brusselator_mri.c @@ -148,10 +148,7 @@ int main(void) /* Create inner stepper */ retval = ARKodeCreateMRIStepInnerStepper(inner_arkode_mem, &inner_stepper); - if (check_retval(&retval, "ARKodeCreateMRIStepInnerStepper", 1)) - { - return 1; - } + if (check_retval(&retval, "ARKodeCreateMRIStepInnerStepper", 1)) { return 1; } /* * Create the slow integrator and set options diff --git a/examples/arkode/C_serial/ark_kpr_mri.c b/examples/arkode/C_serial/ark_kpr_mri.c index cd8ee4e2e9..c7eb467bfb 100644 --- a/examples/arkode/C_serial/ark_kpr_mri.c +++ b/examples/arkode/C_serial/ark_kpr_mri.c @@ -514,10 +514,7 @@ int main(int argc, char* argv[]) /* Create inner stepper */ retval = ARKodeCreateMRIStepInnerStepper(inner_arkode_mem, &inner_stepper); - if (check_retval(&retval, "ARKodeCreateMRIStepInnerStepper", 1)) - { - return 1; - } + if (check_retval(&retval, "ARKodeCreateMRIStepInnerStepper", 1)) { return 1; } /* * Create the slow integrator and set options diff --git a/examples/arkode/C_serial/ark_onewaycouple_mri.c b/examples/arkode/C_serial/ark_onewaycouple_mri.c index fdb9ce1f9b..4e8c2e2ff1 100644 --- a/examples/arkode/C_serial/ark_onewaycouple_mri.c +++ b/examples/arkode/C_serial/ark_onewaycouple_mri.c @@ -149,10 +149,7 @@ int main(void) /* Create inner stepper */ retval = ARKodeCreateMRIStepInnerStepper(inner_arkode_mem, &inner_stepper); - if (check_retval(&retval, "ARKodeCreateMRIStepInnerStepper", 1)) - { - return 1; - } + if (check_retval(&retval, "ARKodeCreateMRIStepInnerStepper", 1)) { return 1; } /* * Create the slow integrator and set options diff --git a/examples/arkode/C_serial/ark_reaction_diffusion_mri.c b/examples/arkode/C_serial/ark_reaction_diffusion_mri.c index 38d156ce65..2bb420efc2 100644 --- a/examples/arkode/C_serial/ark_reaction_diffusion_mri.c +++ b/examples/arkode/C_serial/ark_reaction_diffusion_mri.c @@ -158,10 +158,7 @@ int main(void) /* Create inner stepper */ retval = ARKodeCreateMRIStepInnerStepper(inner_arkode_mem, &inner_stepper); - if (check_retval(&retval, "ARKodeCreateMRIStepInnerStepper", 1)) - { - return 1; - } + if (check_retval(&retval, "ARKodeCreateMRIStepInnerStepper", 1)) { return 1; } /* * Create the slow integrator and set options diff --git a/examples/arkode/C_serial/ark_twowaycouple_mri.c b/examples/arkode/C_serial/ark_twowaycouple_mri.c index 03a159f35d..4383749d4d 100644 --- a/examples/arkode/C_serial/ark_twowaycouple_mri.c +++ b/examples/arkode/C_serial/ark_twowaycouple_mri.c @@ -128,10 +128,7 @@ int main(void) /* Create inner stepper */ retval = ARKodeCreateMRIStepInnerStepper(inner_arkode_mem, &inner_stepper); - if (check_retval(&retval, "ARKodeCreateMRIStepInnerStepper", 1)) - { - return 1; - } + if (check_retval(&retval, "ARKodeCreateMRIStepInnerStepper", 1)) { return 1; } /* * Create the slow integrator and set options diff --git a/include/arkode/arkode_arkstep.h b/include/arkode/arkode_arkstep.h index 0ad922f1eb..a8d13d735b 100644 --- a/include/arkode/arkode_arkstep.h +++ b/include/arkode/arkode_arkstep.h @@ -96,7 +96,6 @@ SUNDIALS_EXPORT int ARKStepGetTimestepperStats( long int* step_attempts, long int* nfe_evals, long int* nfi_evals, long int* nlinsetups, long int* netfails); - /* -------------------------------------------------------------------------- * Deprecated Functions -- all are superseded by shared ARKODE-level routines * -------------------------------------------------------------------------- */ diff --git a/include/arkode/arkode_erkstep.h b/include/arkode/arkode_erkstep.h index f8fd4f359f..ed93a240b9 100644 --- a/include/arkode/arkode_erkstep.h +++ b/include/arkode/arkode_erkstep.h @@ -68,7 +68,6 @@ SUNDIALS_EXPORT int ERKStepGetTimestepperStats( void* arkode_mem, long int* expsteps, long int* accsteps, long int* step_attempts, long int* nfevals, long int* netfails); - /* -------------------------------------------------------------------------- * Deprecated Functions -- all are superseded by shared ARKODE-level routines * -------------------------------------------------------------------------- */ diff --git a/include/arkode/arkode_mristep.h b/include/arkode/arkode_mristep.h index 8feb45b5cc..87d992db72 100644 --- a/include/arkode/arkode_mristep.h +++ b/include/arkode/arkode_mristep.h @@ -226,7 +226,6 @@ SUNDIALS_EXPORT int MRIStepInnerStepper_GetForcingData( MRIStepInnerStepper stepper, sunrealtype* tshift, sunrealtype* tscale, N_Vector** forcing, int* nforcing); - /* -------------------------------------------------------------------------- * Deprecated Functions -- all are superseded by shared ARKODE-level routines * -------------------------------------------------------------------------- */ diff --git a/src/arkode/arkode.c b/src/arkode/arkode.c index 58c69be732..374f67070f 100644 --- a/src/arkode/arkode.c +++ b/src/arkode/arkode.c @@ -1389,8 +1389,7 @@ int ARKodeCreateMRIStepInnerStepper(void* inner_arkode_mem, retval = MRIStepInnerStepper_SetEvolveFn(*stepper, ark_MRIStepInnerEvolve); if (retval != ARK_SUCCESS) { return (retval); } - retval = MRIStepInnerStepper_SetFullRhsFn(*stepper, - ark_MRIStepInnerFullRhs); + retval = MRIStepInnerStepper_SetFullRhsFn(*stepper, ark_MRIStepInnerFullRhs); if (retval != ARK_SUCCESS) { return (retval); } retval = MRIStepInnerStepper_SetResetFn(*stepper, ark_MRIStepInnerReset); @@ -1412,7 +1411,6 @@ int ARKodeCreateMRIStepInnerStepper(void* inner_arkode_mem, return (ARK_SUCCESS); } - /*=============================================================== Private internal functions ===============================================================*/ @@ -3669,7 +3667,7 @@ int ark_MRIStepInnerEvolve(MRIStepInnerStepper stepper, SUNDIALS_MAYBE_UNUSED sunrealtype t0, sunrealtype tout, N_Vector y) { - void* arkode_mem; /* arkode memory */ + void* arkode_mem; /* arkode memory */ ARKodeMem ark_mem; sunrealtype tret; /* return time */ sunrealtype tshift, tscale; /* time normalization values */ @@ -3694,7 +3692,8 @@ int ark_MRIStepInnerEvolve(MRIStepInnerStepper stepper, if (retval != ARK_SUCCESS) { return (retval); } /* set the inner forcing data */ - retval = ark_mem->step_setforcing(arkode_mem, tshift, tscale, forcing, nforcing); + retval = ark_mem->step_setforcing(arkode_mem, tshift, tscale, forcing, + nforcing); if (retval != ARK_SUCCESS) { return (retval); } /* set the stop time */ @@ -3722,9 +3721,9 @@ int ark_MRIStepInnerEvolve(MRIStepInnerStepper stepper, int ark_MRIStepInnerFullRhs(MRIStepInnerStepper stepper, sunrealtype t, N_Vector y, N_Vector f, int mode) { - void* arkode_mem; /* arkode memory */ + void* arkode_mem; /* arkode memory */ ARKodeMem ark_mem; - int retval; /* return value */ + int retval; /* return value */ /* extract the ARKODE memory struct */ retval = MRIStepInnerStepper_GetContent(stepper, &arkode_mem); @@ -3747,8 +3746,7 @@ int ark_MRIStepInnerFullRhs(MRIStepInnerStepper stepper, sunrealtype t, state. ----------------------------------------------------------------------------*/ -int ark_MRIStepInnerReset(MRIStepInnerStepper stepper, sunrealtype tR, - N_Vector yR) +int ark_MRIStepInnerReset(MRIStepInnerStepper stepper, sunrealtype tR, N_Vector yR) { void* arkode_mem; int retval; diff --git a/src/arkode/arkode_arkstep.c b/src/arkode/arkode_arkstep.c index 131309ed00..679c8a28ca 100644 --- a/src/arkode/arkode_arkstep.c +++ b/src/arkode/arkode_arkstep.c @@ -343,7 +343,6 @@ int ARKStepReInit(void* arkode_mem, ARKRhsFn fe, ARKRhsFn fi, sunrealtype t0, return (ARK_SUCCESS); } - /*=============================================================== Interface routines supplied to ARKODE ===============================================================*/ @@ -964,7 +963,10 @@ int arkStep_Init(ARKodeMem ark_mem, int init_type) if (step_mem->implicit) { reset_efun = SUNFALSE; } if (!ark_mem->fixedstep) { reset_efun = SUNFALSE; } if (ark_mem->user_efun) { reset_efun = SUNFALSE; } - if (ark_mem->AccumErrorType != ARK_ACCUMERROR_NONE) { reset_efun = SUNFALSE; } + if (ark_mem->AccumErrorType != ARK_ACCUMERROR_NONE) + { + reset_efun = SUNFALSE; + } if (ark_mem->rwt_is_ewt && (step_mem->msolve_type == SUNLINEARSOLVER_ITERATIVE)) { diff --git a/src/arkode/arkode_arkstep_impl.h b/src/arkode/arkode_arkstep_impl.h index 075905bb20..d77701404d 100644 --- a/src/arkode/arkode_arkstep_impl.h +++ b/src/arkode/arkode_arkstep_impl.h @@ -270,7 +270,6 @@ int arkStep_NlsLSolve(N_Vector delta, void* arkode_mem); int arkStep_NlsConvTest(SUNNonlinearSolver NLS, N_Vector y, N_Vector del, sunrealtype tol, N_Vector ewt, void* arkode_mem); - /* private functions for relaxation */ int arkStep_SetRelaxFn(ARKodeMem ark_mem, ARKRelaxFn rfn, ARKRelaxJacFn rjac); int arkStep_RelaxDeltaE(ARKodeMem ark_mem, ARKRelaxJacFn relax_jac_fn, diff --git a/src/arkode/arkode_arkstep_io.c b/src/arkode/arkode_arkstep_io.c index 78da2108ac..7283810b1d 100644 --- a/src/arkode/arkode_arkstep_io.c +++ b/src/arkode/arkode_arkstep_io.c @@ -1451,6 +1451,7 @@ int ARKStepCreateMRIStepInnerStepper(void* inner_arkode_mem, { return (ARKodeCreateMRIStepInnerStepper(inner_arkode_mem, stepper)); } + int ARKStepResize(void* arkode_mem, N_Vector y0, sunrealtype hscale, sunrealtype t0, ARKVecResizeFn resize, void* resize_data) { diff --git a/src/arkode/arkode_impl.h b/src/arkode/arkode_impl.h index 415f7e6e21..be7fa4a0a9 100644 --- a/src/arkode/arkode_impl.h +++ b/src/arkode/arkode_impl.h @@ -290,8 +290,8 @@ typedef void* (*ARKTimestepGetMassMemFn)(ARKodeMem ark_mem); /* time stepper interface functions -- forcing */ typedef int (*ARKTimestepSetForcingFn)(void* arkode_mem, sunrealtype tshift, - sunrealtype tscale, N_Vector* f, int nvecs); - + sunrealtype tscale, N_Vector* f, + int nvecs); /*=============================================================== ARKODE interpolation module definition @@ -670,7 +670,7 @@ int ark_MRIStepInnerFullRhs(MRIStepInnerStepper stepper, sunrealtype t, int ark_MRIStepInnerReset(MRIStepInnerStepper stepper, sunrealtype tR, N_Vector yR); int ark_MRIStepInnerGetAccumulatedError(MRIStepInnerStepper stepper, - sunrealtype* accum_error); + sunrealtype* accum_error); int ark_MRIStepInnerResetAccumulatedError(MRIStepInnerStepper stepper); int ark_MRIStepInnerSetRTol(MRIStepInnerStepper stepper, sunrealtype rtol); diff --git a/src/arkode/arkode_mristep_impl.h b/src/arkode/arkode_mristep_impl.h index 656a387d55..d5fbde81e1 100644 --- a/src/arkode/arkode_mristep_impl.h +++ b/src/arkode/arkode_mristep_impl.h @@ -331,7 +331,6 @@ int mriStep_ComputeInnerForcing(ARKodeMem ark_mem, ARKodeMRIStepMem step_mem, int mriStep_RKCoeffs(MRIStepCoupling MRIC, int is, int* stage_map, sunrealtype* Ae_row, sunrealtype* Ai_row); - /*=============================================================== MRIStep SUNAdaptController wrapper module -- this is used to insert MRIStep in-between ARKODE at the "slow" time scale, and diff --git a/src/arkode/fmod_int32/farkode_arkstep_mod.c b/src/arkode/fmod_int32/farkode_arkstep_mod.c index 38e7da3c29..4791bedcdc 100644 --- a/src/arkode/fmod_int32/farkode_arkstep_mod.c +++ b/src/arkode/fmod_int32/farkode_arkstep_mod.c @@ -419,6 +419,20 @@ SWIGEXPORT int _wrap_FARKStepGetTimestepperStats(void *farg1, long *farg2, long } +SWIGEXPORT int _wrap_FARKStepCreateMRIStepInnerStepper(void *farg1, void *farg2) { + int fresult ; + void *arg1 = (void *) 0 ; + MRIStepInnerStepper *arg2 = (MRIStepInnerStepper *) 0 ; + int result; + + arg1 = (void *)(farg1); + arg2 = (MRIStepInnerStepper *)(farg2); + result = (int)ARKStepCreateMRIStepInnerStepper(arg1,arg2); + fresult = (int)(result); + return fresult; +} + + SWIGEXPORT int _wrap_FARKStepResize(void *farg1, N_Vector farg2, double const *farg3, double const *farg4, ARKVecResizeFn farg5, void *farg6) { int fresult ; void *arg1 = (void *) 0 ; diff --git a/src/arkode/fmod_int32/farkode_arkstep_mod.f90 b/src/arkode/fmod_int32/farkode_arkstep_mod.f90 index fe9a9d28f0..cc0373f1eb 100644 --- a/src/arkode/fmod_int32/farkode_arkstep_mod.f90 +++ b/src/arkode/fmod_int32/farkode_arkstep_mod.f90 @@ -63,6 +63,7 @@ module farkode_arkstep_mod public :: FARKStepGetNumRhsEvals public :: FARKStepGetCurrentButcherTables public :: FARKStepGetTimestepperStats + public :: FARKStepCreateMRIStepInnerStepper public :: FARKStepResize public :: FARKStepReset public :: FARKStepSStolerances @@ -336,6 +337,15 @@ function swigc_FARKStepGetTimestepperStats(farg1, farg2, farg3, farg4, farg5, fa integer(C_INT) :: fresult end function +function swigc_FARKStepCreateMRIStepInnerStepper(farg1, farg2) & +bind(C, name="_wrap_FARKStepCreateMRIStepInnerStepper") & +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_FARKStepResize(farg1, farg2, farg3, farg4, farg5, farg6) & bind(C, name="_wrap_FARKStepResize") & result(fresult) @@ -2012,6 +2022,22 @@ function FARKStepGetTimestepperStats(arkode_mem, expsteps, accsteps, step_attemp swig_result = fresult end function +function FARKStepCreateMRIStepInnerStepper(arkode_mem, stepper) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(C_PTR) :: arkode_mem +type(C_PTR), target, intent(inout) :: stepper +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 + +farg1 = arkode_mem +farg2 = c_loc(stepper) +fresult = swigc_FARKStepCreateMRIStepInnerStepper(farg1, farg2) +swig_result = fresult +end function + function FARKStepResize(arkode_mem, ynew, hscale, t0, resize, resize_data) & result(swig_result) use, intrinsic :: ISO_C_BINDING diff --git a/test/unit_tests/arkode/C_serial/ark_test_reset.c b/test/unit_tests/arkode/C_serial/ark_test_reset.c index 56b38c14e5..8574dd31a4 100644 --- a/test/unit_tests/arkode/C_serial/ark_test_reset.c +++ b/test/unit_tests/arkode/C_serial/ark_test_reset.c @@ -300,10 +300,7 @@ int main(void) retval = ARKodeSetMaxNumSteps(arkode_mem, 100); check_retval(&retval, "ARKodeSetMaxNumSteps", 1); retval = ARKodeCreateMRIStepInnerStepper(arkode_mem, &inner_stepper); - if (check_retval(&retval, "ARKodeCreateMRIStepInnerStepper", 1)) - { - return 1; - } + if (check_retval(&retval, "ARKodeCreateMRIStepInnerStepper", 1)) { return 1; } mristep_mem = MRIStepCreate(NULL, f, t, y, inner_stepper, ctx); if (check_retval((void*)mristep_mem, "MRIStepCreate", 0)) { return 1; } retval = ARKodeSetUserData(mristep_mem, (void*)&lambda); From 69cb926c4bed8629ba1285a45212f7235af8ccdd Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Fri, 27 Sep 2024 14:52:28 -0500 Subject: [PATCH 093/286] Apparently I have to run swig twice? --- src/arkode/fmod_int64/farkode_arkstep_mod.c | 14 ++++++++++ src/arkode/fmod_int64/farkode_arkstep_mod.f90 | 26 +++++++++++++++++++ 2 files changed, 40 insertions(+) diff --git a/src/arkode/fmod_int64/farkode_arkstep_mod.c b/src/arkode/fmod_int64/farkode_arkstep_mod.c index 38e7da3c29..4791bedcdc 100644 --- a/src/arkode/fmod_int64/farkode_arkstep_mod.c +++ b/src/arkode/fmod_int64/farkode_arkstep_mod.c @@ -419,6 +419,20 @@ SWIGEXPORT int _wrap_FARKStepGetTimestepperStats(void *farg1, long *farg2, long } +SWIGEXPORT int _wrap_FARKStepCreateMRIStepInnerStepper(void *farg1, void *farg2) { + int fresult ; + void *arg1 = (void *) 0 ; + MRIStepInnerStepper *arg2 = (MRIStepInnerStepper *) 0 ; + int result; + + arg1 = (void *)(farg1); + arg2 = (MRIStepInnerStepper *)(farg2); + result = (int)ARKStepCreateMRIStepInnerStepper(arg1,arg2); + fresult = (int)(result); + return fresult; +} + + SWIGEXPORT int _wrap_FARKStepResize(void *farg1, N_Vector farg2, double const *farg3, double const *farg4, ARKVecResizeFn farg5, void *farg6) { int fresult ; void *arg1 = (void *) 0 ; diff --git a/src/arkode/fmod_int64/farkode_arkstep_mod.f90 b/src/arkode/fmod_int64/farkode_arkstep_mod.f90 index fe9a9d28f0..cc0373f1eb 100644 --- a/src/arkode/fmod_int64/farkode_arkstep_mod.f90 +++ b/src/arkode/fmod_int64/farkode_arkstep_mod.f90 @@ -63,6 +63,7 @@ module farkode_arkstep_mod public :: FARKStepGetNumRhsEvals public :: FARKStepGetCurrentButcherTables public :: FARKStepGetTimestepperStats + public :: FARKStepCreateMRIStepInnerStepper public :: FARKStepResize public :: FARKStepReset public :: FARKStepSStolerances @@ -336,6 +337,15 @@ function swigc_FARKStepGetTimestepperStats(farg1, farg2, farg3, farg4, farg5, fa integer(C_INT) :: fresult end function +function swigc_FARKStepCreateMRIStepInnerStepper(farg1, farg2) & +bind(C, name="_wrap_FARKStepCreateMRIStepInnerStepper") & +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_FARKStepResize(farg1, farg2, farg3, farg4, farg5, farg6) & bind(C, name="_wrap_FARKStepResize") & result(fresult) @@ -2012,6 +2022,22 @@ function FARKStepGetTimestepperStats(arkode_mem, expsteps, accsteps, step_attemp swig_result = fresult end function +function FARKStepCreateMRIStepInnerStepper(arkode_mem, stepper) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(C_PTR) :: arkode_mem +type(C_PTR), target, intent(inout) :: stepper +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 + +farg1 = arkode_mem +farg2 = c_loc(stepper) +fresult = swigc_FARKStepCreateMRIStepInnerStepper(farg1, farg2) +swig_result = fresult +end function + function FARKStepResize(arkode_mem, ynew, hscale, t0, resize, resize_data) & result(swig_result) use, intrinsic :: ISO_C_BINDING From 4d112cd5f933d21fbde63106fb19ef7c189cea60 Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Fri, 27 Sep 2024 15:13:47 -0500 Subject: [PATCH 094/286] Updated answers submodule --- test/answers | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/answers b/test/answers index 6d4a36a008..952f5e7f17 160000 --- a/test/answers +++ b/test/answers @@ -1 +1 @@ -Subproject commit 6d4a36a008df0593c48b2a3facb574ace1a43855 +Subproject commit 952f5e7f1784d9a235bb3049229e312dbe6c7ab4 From d31ead7deca5d77224ef6c848b72218308f0f13a Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Fri, 27 Sep 2024 15:48:47 -0500 Subject: [PATCH 095/286] Updated answers submodule --- test/answers | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/answers b/test/answers index 952f5e7f17..bafeb3bac8 160000 --- a/test/answers +++ b/test/answers @@ -1 +1 @@ -Subproject commit 952f5e7f1784d9a235bb3049229e312dbe6c7ab4 +Subproject commit bafeb3bac8c15d3e3aff44491cc81c0981d007d8 From 6affbc0438f6bca2ae3e6f5af4b5ddfa62eaca71 Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Fri, 27 Sep 2024 16:40:52 -0500 Subject: [PATCH 096/286] Reverted one more test to be included in the single-precision CI tests --- examples/arkode/CXX_serial/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/arkode/CXX_serial/CMakeLists.txt b/examples/arkode/CXX_serial/CMakeLists.txt index be64e1d748..51d5582a97 100644 --- a/examples/arkode/CXX_serial/CMakeLists.txt +++ b/examples/arkode/CXX_serial/CMakeLists.txt @@ -28,7 +28,7 @@ set(ARKODE_examples "ark_kpr_Mt.cpp\;0 4 1\;develop" "ark_kpr_Mt.cpp\;0 -4\;exclude-single" "ark_kpr_Mt.cpp\;1 -5\;exclude-single" - "ark_kpr_Mt.cpp\;2 -5 0 -10\;exclude-single" + "ark_kpr_Mt.cpp\;2 -5 0 -10\;develop" "ark_kpr_Mt.cpp\;1 -3 0 -10 0\;exclude-single" "ark_kpr_Mt.cpp\;0 3 0 -10 0\;develop" "ark_kpr_Mt.cpp\;2 4 0 -10 0\;develop" From 1d840daca315c1879ac8792320040c1c8ddf75b6 Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Fri, 27 Sep 2024 16:59:06 -0500 Subject: [PATCH 097/286] Removed that single-precision CI test since it fails due to insufficient accuracy in the fast solver due to single-precision arithmetic --- examples/arkode/CXX_serial/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/arkode/CXX_serial/CMakeLists.txt b/examples/arkode/CXX_serial/CMakeLists.txt index 51d5582a97..be64e1d748 100644 --- a/examples/arkode/CXX_serial/CMakeLists.txt +++ b/examples/arkode/CXX_serial/CMakeLists.txt @@ -28,7 +28,7 @@ set(ARKODE_examples "ark_kpr_Mt.cpp\;0 4 1\;develop" "ark_kpr_Mt.cpp\;0 -4\;exclude-single" "ark_kpr_Mt.cpp\;1 -5\;exclude-single" - "ark_kpr_Mt.cpp\;2 -5 0 -10\;develop" + "ark_kpr_Mt.cpp\;2 -5 0 -10\;exclude-single" "ark_kpr_Mt.cpp\;1 -3 0 -10 0\;exclude-single" "ark_kpr_Mt.cpp\;0 3 0 -10 0\;develop" "ark_kpr_Mt.cpp\;2 4 0 -10 0\;develop" From 5cb6f3e9031d24729c117b6785f2d1a5f8e6a134 Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Sat, 28 Sep 2024 17:20:06 -0500 Subject: [PATCH 098/286] Converted first argument of ARKTimestepSetForcingFn to ARKodeMem type instead of void* --- src/arkode/arkode.c | 4 ++-- src/arkode/arkode_arkstep.c | 9 ++++----- src/arkode/arkode_arkstep_impl.h | 2 +- src/arkode/arkode_erkstep.c | 5 ++--- src/arkode/arkode_erkstep_impl.h | 2 +- src/arkode/arkode_impl.h | 2 +- src/arkode/arkode_mristep.c | 5 ++--- src/arkode/arkode_mristep_impl.h | 2 +- 8 files changed, 14 insertions(+), 17 deletions(-) diff --git a/src/arkode/arkode.c b/src/arkode/arkode.c index 374f67070f..32884c7f91 100644 --- a/src/arkode/arkode.c +++ b/src/arkode/arkode.c @@ -3692,7 +3692,7 @@ int ark_MRIStepInnerEvolve(MRIStepInnerStepper stepper, if (retval != ARK_SUCCESS) { return (retval); } /* set the inner forcing data */ - retval = ark_mem->step_setforcing(arkode_mem, tshift, tscale, forcing, + retval = ark_mem->step_setforcing(ark_mem, tshift, tscale, forcing, nforcing); if (retval != ARK_SUCCESS) { return (retval); } @@ -3705,7 +3705,7 @@ int ark_MRIStepInnerEvolve(MRIStepInnerStepper stepper, if (retval < 0) { return (retval); } /* disable inner forcing */ - retval = ark_mem->step_setforcing(arkode_mem, ZERO, ONE, NULL, 0); + retval = ark_mem->step_setforcing(ark_mem, ZERO, ONE, NULL, 0); if (retval != ARK_SUCCESS) { return (retval); } return (ARK_SUCCESS); diff --git a/src/arkode/arkode_arkstep.c b/src/arkode/arkode_arkstep.c index 679c8a28ca..ca023e407c 100644 --- a/src/arkode/arkode_arkstep.c +++ b/src/arkode/arkode_arkstep.c @@ -3205,16 +3205,15 @@ void arkStep_ApplyForcing(ARKodeARKStepMem step_mem, sunrealtype* stage_times, methods). ----------------------------------------------------------------------------*/ -int arkStep_SetInnerForcing(void* arkode_mem, sunrealtype tshift, +int arkStep_SetInnerForcing(ARKodeMem ark_mem, sunrealtype tshift, sunrealtype tscale, N_Vector* forcing, int nvecs) { - ARKodeMem ark_mem; ARKodeARKStepMem step_mem; int retval; - /* access ARKodeMem and ARKodeARKStepMem structures */ - retval = arkStep_AccessARKODEStepMem(arkode_mem, __func__, &ark_mem, &step_mem); - if (retval != ARK_SUCCESS) { return (retval); } + /* access ARKodeARKStepMem structure */ + retval = arkStep_AccessStepMem(ark_mem, __func__, &step_mem); + if (retval != ARK_SUCCESS) { return; } if (nvecs > 0) { diff --git a/src/arkode/arkode_arkstep_impl.h b/src/arkode/arkode_arkstep_impl.h index d77701404d..33a9d5abd7 100644 --- a/src/arkode/arkode_arkstep_impl.h +++ b/src/arkode/arkode_arkstep_impl.h @@ -226,7 +226,7 @@ int arkStep_Resize(ARKodeMem ark_mem, N_Vector y0, sunrealtype hscale, int arkStep_ComputeState(ARKodeMem ark_mem, N_Vector zcor, N_Vector z); void arkStep_Free(ARKodeMem ark_mem); void arkStep_PrintMem(ARKodeMem ark_mem, FILE* outfile); -int arkStep_SetInnerForcing(void* arkode_mem, sunrealtype tshift, +int arkStep_SetInnerForcing(ARKodeMem ark_mem, sunrealtype tshift, sunrealtype tscale, N_Vector* f, int nvecs); /* Internal utility routines */ diff --git a/src/arkode/arkode_erkstep.c b/src/arkode/arkode_erkstep.c index 78d0d1e536..00f478f87b 100644 --- a/src/arkode/arkode_erkstep.c +++ b/src/arkode/arkode_erkstep.c @@ -1263,15 +1263,14 @@ void erkStep_ApplyForcing(ARKodeERKStepMem step_mem, sunrealtype t, methods). ----------------------------------------------------------------------------*/ -int erkStep_SetInnerForcing(void* arkode_mem, sunrealtype tshift, +int erkStep_SetInnerForcing(ARKodeMem ark_mem, sunrealtype tshift, sunrealtype tscale, N_Vector* forcing, int nvecs) { - ARKodeMem ark_mem; ARKodeERKStepMem step_mem; int retval; /* access ARKodeERKStepMem structure */ - retval = erkStep_AccessARKODEStepMem(arkode_mem, __func__, &ark_mem, &step_mem); + retval = erkStep_AccessStepMem(ark_mem, __func__, &step_mem); if (retval != ARK_SUCCESS) { return (retval); } if (nvecs > 0) diff --git a/src/arkode/arkode_erkstep_impl.h b/src/arkode/arkode_erkstep_impl.h index 4457aaa9a4..c56ccad2b5 100644 --- a/src/arkode/arkode_erkstep_impl.h +++ b/src/arkode/arkode_erkstep_impl.h @@ -90,7 +90,7 @@ int erkStep_Resize(ARKodeMem ark_mem, N_Vector y0, sunrealtype hscale, void erkStep_Free(ARKodeMem ark_mem); void erkStep_PrintMem(ARKodeMem ark_mem, FILE* outfile); int erkStep_GetEstLocalErrors(ARKodeMem ark_mem, N_Vector ele); -int erkStep_SetInnerForcing(void* arkode_mem, sunrealtype tshift, +int erkStep_SetInnerForcing(ARKodeMem ark_mem, sunrealtype tshift, sunrealtype tscale, N_Vector* f, int nvecs); /* Internal utility routines */ diff --git a/src/arkode/arkode_impl.h b/src/arkode/arkode_impl.h index be7fa4a0a9..179d2540f0 100644 --- a/src/arkode/arkode_impl.h +++ b/src/arkode/arkode_impl.h @@ -289,7 +289,7 @@ typedef void (*ARKTimestepDisableMSetup)(ARKodeMem ark_mem); typedef void* (*ARKTimestepGetMassMemFn)(ARKodeMem ark_mem); /* time stepper interface functions -- forcing */ -typedef int (*ARKTimestepSetForcingFn)(void* arkode_mem, sunrealtype tshift, +typedef int (*ARKTimestepSetForcingFn)(ARKodeMem ark_mem, sunrealtype tshift, sunrealtype tscale, N_Vector* f, int nvecs); diff --git a/src/arkode/arkode_mristep.c b/src/arkode/arkode_mristep.c index bb1d3493b4..33e67bb396 100644 --- a/src/arkode/arkode_mristep.c +++ b/src/arkode/arkode_mristep.c @@ -4686,15 +4686,14 @@ void mriStep_ApplyForcing(ARKodeMRIStepMem step_mem, sunrealtype t, methods). ----------------------------------------------------------------------------*/ -int mriStep_SetInnerForcing(void* arkode_mem, sunrealtype tshift, +int mriStep_SetInnerForcing(ARKodeMem ark_mem, sunrealtype tshift, sunrealtype tscale, N_Vector* forcing, int nvecs) { - ARKodeMem ark_mem; ARKodeMRIStepMem step_mem; int retval; /* access ARKodeMRIStepMem structure */ - retval = mriStep_AccessARKODEStepMem(arkode_mem, __func__, &ark_mem, &step_mem); + retval = mriStep_AccessStepMem(ark_mem, __func__, &step_mem); if (retval != ARK_SUCCESS) { return (retval); } if (nvecs > 0) diff --git a/src/arkode/arkode_mristep_impl.h b/src/arkode/arkode_mristep_impl.h index d5fbde81e1..7fff1c05e1 100644 --- a/src/arkode/arkode_mristep_impl.h +++ b/src/arkode/arkode_mristep_impl.h @@ -259,7 +259,7 @@ int mriStep_Resize(ARKodeMem ark_mem, N_Vector y0, sunrealtype hscale, int mriStep_ComputeState(ARKodeMem ark_mem, N_Vector zcor, N_Vector z); void mriStep_Free(ARKodeMem ark_mem); void mriStep_PrintMem(ARKodeMem ark_mem, FILE* outfile); -int mriStep_SetInnerForcing(void* arkode_mem, sunrealtype tshift, +int mriStep_SetInnerForcing(ARKodeMem ark_mem, sunrealtype tshift, sunrealtype tscale, N_Vector* f, int nvecs); /* Internal utility routines */ From ccb8b63e5e66b1c947bda49bd539190211e88aa1 Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Sat, 28 Sep 2024 17:39:28 -0500 Subject: [PATCH 099/286] Updated documentation formatting for custom MRI inner stepper function --- .../Custom_Inner_Stepper/Description.rst | 97 ++++++++----------- 1 file changed, 43 insertions(+), 54 deletions(-) diff --git a/doc/arkode/guide/source/Usage/MRIStep/Custom_Inner_Stepper/Description.rst b/doc/arkode/guide/source/Usage/MRIStep/Custom_Inner_Stepper/Description.rst index c9eb478cd6..e6fa2dc0a0 100644 --- a/doc/arkode/guide/source/Usage/MRIStep/Custom_Inner_Stepper/Description.rst +++ b/doc/arkode/guide/source/Usage/MRIStep/Custom_Inner_Stepper/Description.rst @@ -364,20 +364,18 @@ member functions: This function advances the state vector *v* for the inner (fast) ODE system from time *t0* to time *tout*. - **Arguments:** - * *stepper* -- the inner stepper object. - * *t0* -- the initial time for the inner (fast) integration. - * *tout* -- the final time for the inner (fast) integration. - * *v* -- on input the state at time *t0* and, on output, the state at time - *tout*. - - **Return value:** - An :c:type:`MRIStepInnerEvolveFn` should return 0 if successful, a positive - value if a recoverable error occurred, or a negative value if it failed - unrecoverably. + :param stepper: the inner stepper object. + :param t0: the initial time for the inner (fast) integration. + :param tout: the final time for the inner (fast) integration. + :param v: on input the state at time *t0* and, on output, the state at time *tout*. - **Example codes:** - * ``examples/arkode/CXX_parallel/ark_diffusion_reaction_p.cpp`` + :return: An :c:type:`MRIStepInnerEvolveFn` should return 0 if successful, a positive + value if a recoverable error occurred, or a negative value if it failed + unrecoverably. + + .. note:: + + An example of this is in ``examples/arkode/CXX_parallel/ark_diffusion_reaction_p.cpp``. Optional Member Functions """"""""""""""""""""""""" @@ -391,26 +389,25 @@ following member functions: ODE, :math:`f^F(t,v)` in :eq:`ARKODE_MRI_IVP` for a given value of the independent variable *t* and state vector *y*. - **Arguments:** - * *stepper* -- the inner stepper object. - * *t* -- the current value of the independent variable. - * *y* -- the current value of the dependent variable vector. - * *f* -- the output vector that forms a portion the ODE right-hand side, + :param stepper: the inner stepper object. + :param t: the current value of the independent variable. + :param y: the current value of the dependent variable vector. + :param f: the output vector that forms a portion the ODE right-hand side, :math:`f^F(t,y)` in :eq:`ARKODE_IVP_two_rate`. - * *mode* -- a flag indicating the purpose for which the right-hand side + :param mode: a flag indicating the purpose for which the right-hand side function evaluation is called. * ``ARK_FULLRHS_START`` -- called at the beginning of the simulation * ``ARK_FULLRHS_END`` -- called at the end of a successful step * ``ARK_FULLRHS_OTHER`` -- called elsewhere e.g., for dense output - **Return value:** - An :c:type:`MRIStepInnerFullRhsFn` should return 0 if successful, a positive + :return: An :c:type:`MRIStepInnerFullRhsFn` should return 0 if successful, a positive value if a recoverable error occurred, or a negative value if it failed unrecoverably. - **Example codes:** - * ``examples/arkode/CXX_parallel/ark_diffusion_reaction_p.cpp`` + .. note:: + + An example of this is in ``examples/arkode/CXX_parallel/ark_diffusion_reaction_p.cpp``. .. versionchanged:: v5.7.0 @@ -421,39 +418,34 @@ following member functions: This function resets the inner (fast) stepper state to the provided independent variable value and dependent variable vector. - **Arguments:** - * *stepper* -- the inner stepper object. - * *tR* -- the value of the independent variable :math:`t_R`. - * *vR* -- the value of the dependent variable vector :math:`v(t_R)`. + :param stepper: the inner stepper object. + :param tR: the value of the independent variable :math:`t_R`. + :param vR: the value of the dependent variable vector :math:`v(t_R)`. - **Return value:** - An :c:type:`MRIStepInnerResetFn` should return 0 if successful, a positive + :return: An :c:type:`MRIStepInnerResetFn` should return 0 if successful, a positive value if a recoverable error occurred, or a negative value if it failed unrecoverably. - **Notes:** + .. note:: + If provided, the :c:type:`MRIStepInnerResetFn` function will always be called *before* the function :c:type:`MRIStepInnerEvolveFn` is first called. - - **Example codes:** - * ``examples/arkode/CXX_parallel/ark_diffusion_reaction_p.cpp`` + An example of this is in ``examples/arkode/CXX_parallel/ark_diffusion_reaction_p.cpp``. .. c:type:: int (*MRIStepInnerGetAccumulatedError)(MRIStepInnerStepper stepper, sunrealtype* accum_error) This function returns an estimate of the accumulated solution error arising from the inner stepper. - **Arguments:** - * *stepper* -- the inner stepper object. - * *accum_error* -- estimation of the accumulated solution error. + :param stepper: the inner stepper object. + :param accum_error: estimation of the accumulated solution error. - **Return value:** - An :c:type:`MRIStepInnerGetAccumulatedError` should return 0 if successful, a positive - value if a recoverable error occurred, or a negative value if it failed - unrecoverably. + :return: An :c:type:`MRIStepInnerGetAccumulatedError` should return 0 if successful, a positive + value if a recoverable error occurred, or a negative value if it failed unrecoverably. + + .. note:: - **Notes:** This function is only called when multirate temporal adaptivity has been enabled, using a :c:type:`SUNAdaptController` module having type ``SUNDIALS_CONTROL_MRI_TOL``. @@ -470,15 +462,13 @@ following member functions: This function resets the inner stepper's accumulated solution error to zero. - **Arguments:** - * *stepper* -- the inner stepper object. + :param stepper: the inner stepper object. - **Return value:** - An :c:type:`MRIStepInnerResetAccumulatedError` should return 0 if successful, a positive - value if a recoverable error occurred, or a negative value if it failed - unrecoverably. + :return: An :c:type:`MRIStepInnerResetAccumulatedError` should return 0 if successful, a positive` + value if a recoverable error occurred, or a negative value if it failed unrecoverably. + + .. note:: - **Notes:** This function is only called when multirate temporal adaptivity has been enabled, using a :c:type:`SUNAdaptController` module having type ``SUNDIALS_CONTROL_MRI_TOL``. @@ -498,16 +488,15 @@ following member functions: This function accepts a relative tolerance for the inner stepper to use in its upcoming adaptive solve. - **Arguments:** - * *stepper* -- the inner stepper object. - * *rtol* -- relative tolerance to use on the upcoming solve. + :param stepper: the inner stepper object. + :param rtol: relative tolerance to use on the upcoming solve. - **Return value:** - An :c:type:`MRIStepInnerSetRTol` should return 0 if successful, a positive + :return: An :c:type:`MRIStepInnerSetRTol` should return 0 if successful, a positive value if a recoverable error occurred, or a negative value if it failed unrecoverably. - **Notes:** + .. note:: + This function is only called when multirate temporal adaptivity has been enabled using a :c:type:`SUNAdaptController` module having type ``SUNDIALS_CONTROL_MRI_TOL``. From 7abffc4a846d23b630b272e88ee5200de1cad8ce Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Sat, 28 Sep 2024 17:47:36 -0500 Subject: [PATCH 100/286] Fixed copy/paste error for version where ARKodeCreateMRIStepInnerStepper was added --- doc/arkode/guide/source/Usage/User_callable.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/arkode/guide/source/Usage/User_callable.rst b/doc/arkode/guide/source/Usage/User_callable.rst index 0162a3b1f3..ea8009d0e7 100644 --- a/doc/arkode/guide/source/Usage/User_callable.rst +++ b/doc/arkode/guide/source/Usage/User_callable.rst @@ -4830,4 +4830,4 @@ wrap the ARKODE memory block as an :c:type:`MRIStepInnerStepper`. functions and the initial condition */ outer_arkode_mem = MRIStepCreate(fse, fsi, t0, y0, stepper, sunctx) - .. versionadded:: 6.1.0 + .. versionadded:: x.y.z From b1ddb1ddfda09392e869bd10d957883e89175bea Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Sat, 28 Sep 2024 17:57:49 -0500 Subject: [PATCH 101/286] Fixed erroneous return --- src/arkode/arkode_arkstep.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/arkode/arkode_arkstep.c b/src/arkode/arkode_arkstep.c index ca023e407c..c2e04ca196 100644 --- a/src/arkode/arkode_arkstep.c +++ b/src/arkode/arkode_arkstep.c @@ -3213,7 +3213,7 @@ int arkStep_SetInnerForcing(ARKodeMem ark_mem, sunrealtype tshift, /* access ARKodeARKStepMem structure */ retval = arkStep_AccessStepMem(ark_mem, __func__, &step_mem); - if (retval != ARK_SUCCESS) { return; } + if (retval != ARK_SUCCESS) { return(retval); } if (nvecs > 0) { From 96926e70c2fe83e687e4a755e191ff44ec17f1f2 Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Sat, 28 Sep 2024 17:58:42 -0500 Subject: [PATCH 102/286] formatting --- src/arkode/arkode.c | 3 +-- src/arkode/arkode_arkstep.c | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/arkode/arkode.c b/src/arkode/arkode.c index 32884c7f91..e17232c102 100644 --- a/src/arkode/arkode.c +++ b/src/arkode/arkode.c @@ -3692,8 +3692,7 @@ int ark_MRIStepInnerEvolve(MRIStepInnerStepper stepper, if (retval != ARK_SUCCESS) { return (retval); } /* set the inner forcing data */ - retval = ark_mem->step_setforcing(ark_mem, tshift, tscale, forcing, - nforcing); + retval = ark_mem->step_setforcing(ark_mem, tshift, tscale, forcing, nforcing); if (retval != ARK_SUCCESS) { return (retval); } /* set the stop time */ diff --git a/src/arkode/arkode_arkstep.c b/src/arkode/arkode_arkstep.c index c2e04ca196..ef5bf0b1e2 100644 --- a/src/arkode/arkode_arkstep.c +++ b/src/arkode/arkode_arkstep.c @@ -3213,7 +3213,7 @@ int arkStep_SetInnerForcing(ARKodeMem ark_mem, sunrealtype tshift, /* access ARKodeARKStepMem structure */ retval = arkStep_AccessStepMem(ark_mem, __func__, &step_mem); - if (retval != ARK_SUCCESS) { return(retval); } + if (retval != ARK_SUCCESS) { return (retval); } if (nvecs > 0) { From a35f336b7688f83701f98a60f424141c74f13f9c Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Tue, 1 Oct 2024 12:18:06 -0500 Subject: [PATCH 103/286] Updated SUNAdaptController_MRIHTol structure to remove leading underscore --- .../SUNAdaptController_MRIHTol.rst | 2 +- .../sunadaptcontroller_mrihtol.h | 4 +- .../fsunadaptcontroller_mrihtol_mod.c | 240 ++++++++++++++ .../fsunadaptcontroller_mrihtol_mod.f90 | 299 ++++++++++++++++++ .../fsunadaptcontroller_mrihtol_mod.c | 240 ++++++++++++++ .../fsunadaptcontroller_mrihtol_mod.f90 | 299 ++++++++++++++++++ 6 files changed, 1081 insertions(+), 3 deletions(-) diff --git a/doc/shared/sunadaptcontroller/SUNAdaptController_MRIHTol.rst b/doc/shared/sunadaptcontroller/SUNAdaptController_MRIHTol.rst index 16595267ae..1131290142 100644 --- a/doc/shared/sunadaptcontroller/SUNAdaptController_MRIHTol.rst +++ b/doc/shared/sunadaptcontroller/SUNAdaptController_MRIHTol.rst @@ -97,7 +97,7 @@ SUNAdaptController class, and defines its *content* field as: .. code-block:: c - struct _SUNAdaptControllerContent_MRIHTol + struct SUNAdaptControllerContent_MRIHTol { SUNAdaptController HControl; SUNAdaptController TolControl; diff --git a/include/sunadaptcontroller/sunadaptcontroller_mrihtol.h b/include/sunadaptcontroller/sunadaptcontroller_mrihtol.h index e15692e53b..0e58f6d7ee 100644 --- a/include/sunadaptcontroller/sunadaptcontroller_mrihtol.h +++ b/include/sunadaptcontroller/sunadaptcontroller_mrihtol.h @@ -28,7 +28,7 @@ extern "C" { * MRI H+tolerance implementation of SUNAdaptController * -------------------------------------------- */ -struct _SUNAdaptControllerContent_MRIHTol +struct SUNAdaptControllerContent_MRIHTol_ { SUNAdaptController HControl; SUNAdaptController TolControl; @@ -37,7 +37,7 @@ struct _SUNAdaptControllerContent_MRIHTol sunrealtype inner_max_tolfac; }; -typedef struct _SUNAdaptControllerContent_MRIHTol* SUNAdaptControllerContent_MRIHTol; +typedef struct SUNAdaptControllerContent_MRIHTol_* SUNAdaptControllerContent_MRIHTol; /* ------------------ * Exported Functions diff --git a/src/sunadaptcontroller/mrihtol/fmod_int32/fsunadaptcontroller_mrihtol_mod.c b/src/sunadaptcontroller/mrihtol/fmod_int32/fsunadaptcontroller_mrihtol_mod.c index 4f01ed2426..bcc7a8c8d3 100644 --- a/src/sunadaptcontroller/mrihtol/fmod_int32/fsunadaptcontroller_mrihtol_mod.c +++ b/src/sunadaptcontroller/mrihtol/fmod_int32/fsunadaptcontroller_mrihtol_mod.c @@ -178,6 +178,35 @@ { printf("In " DECL ": " MSG); assert(0); RETURNNULL; } +enum { + SWIG_MEM_OWN = 0x01, + SWIG_MEM_RVALUE = 0x02, + SWIG_MEM_CONST = 0x04 +}; + + +#define SWIG_check_mutable(SWIG_CLASS_WRAPPER, TYPENAME, FNAME, FUNCNAME, RETURNNULL) \ + if ((SWIG_CLASS_WRAPPER).cmemflags & SWIG_MEM_CONST) { \ + SWIG_exception_impl(FUNCNAME, SWIG_TypeError, \ + "Cannot pass const " TYPENAME " (class " FNAME ") " \ + "as a mutable reference", \ + RETURNNULL); \ + } + + +#define SWIG_check_nonnull(SWIG_CLASS_WRAPPER, TYPENAME, FNAME, FUNCNAME, RETURNNULL) \ + if (!(SWIG_CLASS_WRAPPER).cptr) { \ + SWIG_exception_impl(FUNCNAME, SWIG_TypeError, \ + "Cannot pass null " TYPENAME " (class " FNAME ") " \ + "as a reference", RETURNNULL); \ + } + + +#define SWIG_check_mutable_nonnull(SWIG_CLASS_WRAPPER, TYPENAME, FNAME, FUNCNAME, RETURNNULL) \ + SWIG_check_nonnull(SWIG_CLASS_WRAPPER, TYPENAME, FNAME, FUNCNAME, RETURNNULL); \ + SWIG_check_mutable(SWIG_CLASS_WRAPPER, TYPENAME, FNAME, FUNCNAME, RETURNNULL); + + #include #if defined(_MSC_VER) || defined(__BORLANDC__) || defined(_WATCOM) # ifndef snprintf @@ -208,6 +237,217 @@ #include "sunadaptcontroller/sunadaptcontroller_mrihtol.h" + +typedef struct { + void* cptr; + int cmemflags; +} SwigClassWrapper; + + +SWIGINTERN SwigClassWrapper SwigClassWrapper_uninitialized() { + SwigClassWrapper result; + result.cptr = NULL; + result.cmemflags = 0; + return result; +} + + +#include +#ifdef _MSC_VER +# ifndef strtoull +# define strtoull _strtoui64 +# endif +# ifndef strtoll +# define strtoll _strtoi64 +# endif +#endif + + +#include + + +SWIGINTERN void SWIG_assign(SwigClassWrapper* self, SwigClassWrapper other) { + if (self->cptr == NULL) { + /* LHS is unassigned */ + if (other.cmemflags & SWIG_MEM_RVALUE) { + /* Capture pointer from RHS, clear 'moving' flag */ + self->cptr = other.cptr; + self->cmemflags = other.cmemflags & (~SWIG_MEM_RVALUE); + } else { + /* Become a reference to the other object */ + self->cptr = other.cptr; + self->cmemflags = other.cmemflags & (~SWIG_MEM_OWN); + } + } else if (other.cptr == NULL) { + /* Replace LHS with a null pointer */ + free(self->cptr); + *self = SwigClassWrapper_uninitialized(); + } else { + if (self->cmemflags & SWIG_MEM_OWN) { + free(self->cptr); + } + self->cptr = other.cptr; + if (other.cmemflags & SWIG_MEM_RVALUE) { + /* Capture RHS */ + self->cmemflags = other.cmemflags & ~SWIG_MEM_RVALUE; + } else { + /* Point to RHS */ + self->cmemflags = other.cmemflags & ~SWIG_MEM_OWN; + } + } +} + +SWIGEXPORT void _wrap_SUNAdaptControllerContent_MRIHTol__HControl_set(SwigClassWrapper const *farg1, SUNAdaptController farg2) { + struct SUNAdaptControllerContent_MRIHTol_ *arg1 = (struct SUNAdaptControllerContent_MRIHTol_ *) 0 ; + SUNAdaptController arg2 = (SUNAdaptController) 0 ; + + SWIG_check_mutable_nonnull(*farg1, "struct SUNAdaptControllerContent_MRIHTol_ *", "SUNAdaptControllerContent_MRIHTol_", "SUNAdaptControllerContent_MRIHTol_::HControl", return ); + arg1 = (struct SUNAdaptControllerContent_MRIHTol_ *)(farg1->cptr); + arg2 = (SUNAdaptController)(farg2); + if (arg1) (arg1)->HControl = arg2; +} + + +SWIGEXPORT SUNAdaptController _wrap_SUNAdaptControllerContent_MRIHTol__HControl_get(SwigClassWrapper const *farg1) { + SUNAdaptController fresult ; + struct SUNAdaptControllerContent_MRIHTol_ *arg1 = (struct SUNAdaptControllerContent_MRIHTol_ *) 0 ; + SUNAdaptController result; + + SWIG_check_mutable_nonnull(*farg1, "struct SUNAdaptControllerContent_MRIHTol_ *", "SUNAdaptControllerContent_MRIHTol_", "SUNAdaptControllerContent_MRIHTol_::HControl", return 0); + arg1 = (struct SUNAdaptControllerContent_MRIHTol_ *)(farg1->cptr); + result = (SUNAdaptController) ((arg1)->HControl); + fresult = result; + return fresult; +} + + +SWIGEXPORT void _wrap_SUNAdaptControllerContent_MRIHTol__TolControl_set(SwigClassWrapper const *farg1, SUNAdaptController farg2) { + struct SUNAdaptControllerContent_MRIHTol_ *arg1 = (struct SUNAdaptControllerContent_MRIHTol_ *) 0 ; + SUNAdaptController arg2 = (SUNAdaptController) 0 ; + + SWIG_check_mutable_nonnull(*farg1, "struct SUNAdaptControllerContent_MRIHTol_ *", "SUNAdaptControllerContent_MRIHTol_", "SUNAdaptControllerContent_MRIHTol_::TolControl", return ); + arg1 = (struct SUNAdaptControllerContent_MRIHTol_ *)(farg1->cptr); + arg2 = (SUNAdaptController)(farg2); + if (arg1) (arg1)->TolControl = arg2; +} + + +SWIGEXPORT SUNAdaptController _wrap_SUNAdaptControllerContent_MRIHTol__TolControl_get(SwigClassWrapper const *farg1) { + SUNAdaptController fresult ; + struct SUNAdaptControllerContent_MRIHTol_ *arg1 = (struct SUNAdaptControllerContent_MRIHTol_ *) 0 ; + SUNAdaptController result; + + SWIG_check_mutable_nonnull(*farg1, "struct SUNAdaptControllerContent_MRIHTol_ *", "SUNAdaptControllerContent_MRIHTol_", "SUNAdaptControllerContent_MRIHTol_::TolControl", return 0); + arg1 = (struct SUNAdaptControllerContent_MRIHTol_ *)(farg1->cptr); + result = (SUNAdaptController) ((arg1)->TolControl); + fresult = result; + return fresult; +} + + +SWIGEXPORT void _wrap_SUNAdaptControllerContent_MRIHTol__inner_max_relch_set(SwigClassWrapper const *farg1, double const *farg2) { + struct SUNAdaptControllerContent_MRIHTol_ *arg1 = (struct SUNAdaptControllerContent_MRIHTol_ *) 0 ; + sunrealtype arg2 ; + + SWIG_check_mutable_nonnull(*farg1, "struct SUNAdaptControllerContent_MRIHTol_ *", "SUNAdaptControllerContent_MRIHTol_", "SUNAdaptControllerContent_MRIHTol_::inner_max_relch", return ); + arg1 = (struct SUNAdaptControllerContent_MRIHTol_ *)(farg1->cptr); + arg2 = (sunrealtype)(*farg2); + if (arg1) (arg1)->inner_max_relch = arg2; +} + + +SWIGEXPORT double _wrap_SUNAdaptControllerContent_MRIHTol__inner_max_relch_get(SwigClassWrapper const *farg1) { + double fresult ; + struct SUNAdaptControllerContent_MRIHTol_ *arg1 = (struct SUNAdaptControllerContent_MRIHTol_ *) 0 ; + sunrealtype result; + + SWIG_check_mutable_nonnull(*farg1, "struct SUNAdaptControllerContent_MRIHTol_ *", "SUNAdaptControllerContent_MRIHTol_", "SUNAdaptControllerContent_MRIHTol_::inner_max_relch", return 0); + arg1 = (struct SUNAdaptControllerContent_MRIHTol_ *)(farg1->cptr); + result = (sunrealtype) ((arg1)->inner_max_relch); + fresult = (sunrealtype)(result); + return fresult; +} + + +SWIGEXPORT void _wrap_SUNAdaptControllerContent_MRIHTol__inner_min_tolfac_set(SwigClassWrapper const *farg1, double const *farg2) { + struct SUNAdaptControllerContent_MRIHTol_ *arg1 = (struct SUNAdaptControllerContent_MRIHTol_ *) 0 ; + sunrealtype arg2 ; + + SWIG_check_mutable_nonnull(*farg1, "struct SUNAdaptControllerContent_MRIHTol_ *", "SUNAdaptControllerContent_MRIHTol_", "SUNAdaptControllerContent_MRIHTol_::inner_min_tolfac", return ); + arg1 = (struct SUNAdaptControllerContent_MRIHTol_ *)(farg1->cptr); + arg2 = (sunrealtype)(*farg2); + if (arg1) (arg1)->inner_min_tolfac = arg2; +} + + +SWIGEXPORT double _wrap_SUNAdaptControllerContent_MRIHTol__inner_min_tolfac_get(SwigClassWrapper const *farg1) { + double fresult ; + struct SUNAdaptControllerContent_MRIHTol_ *arg1 = (struct SUNAdaptControllerContent_MRIHTol_ *) 0 ; + sunrealtype result; + + SWIG_check_mutable_nonnull(*farg1, "struct SUNAdaptControllerContent_MRIHTol_ *", "SUNAdaptControllerContent_MRIHTol_", "SUNAdaptControllerContent_MRIHTol_::inner_min_tolfac", return 0); + arg1 = (struct SUNAdaptControllerContent_MRIHTol_ *)(farg1->cptr); + result = (sunrealtype) ((arg1)->inner_min_tolfac); + fresult = (sunrealtype)(result); + return fresult; +} + + +SWIGEXPORT void _wrap_SUNAdaptControllerContent_MRIHTol__inner_max_tolfac_set(SwigClassWrapper const *farg1, double const *farg2) { + struct SUNAdaptControllerContent_MRIHTol_ *arg1 = (struct SUNAdaptControllerContent_MRIHTol_ *) 0 ; + sunrealtype arg2 ; + + SWIG_check_mutable_nonnull(*farg1, "struct SUNAdaptControllerContent_MRIHTol_ *", "SUNAdaptControllerContent_MRIHTol_", "SUNAdaptControllerContent_MRIHTol_::inner_max_tolfac", return ); + arg1 = (struct SUNAdaptControllerContent_MRIHTol_ *)(farg1->cptr); + arg2 = (sunrealtype)(*farg2); + if (arg1) (arg1)->inner_max_tolfac = arg2; +} + + +SWIGEXPORT double _wrap_SUNAdaptControllerContent_MRIHTol__inner_max_tolfac_get(SwigClassWrapper const *farg1) { + double fresult ; + struct SUNAdaptControllerContent_MRIHTol_ *arg1 = (struct SUNAdaptControllerContent_MRIHTol_ *) 0 ; + sunrealtype result; + + SWIG_check_mutable_nonnull(*farg1, "struct SUNAdaptControllerContent_MRIHTol_ *", "SUNAdaptControllerContent_MRIHTol_", "SUNAdaptControllerContent_MRIHTol_::inner_max_tolfac", return 0); + arg1 = (struct SUNAdaptControllerContent_MRIHTol_ *)(farg1->cptr); + result = (sunrealtype) ((arg1)->inner_max_tolfac); + fresult = (sunrealtype)(result); + return fresult; +} + + +SWIGEXPORT SwigClassWrapper _wrap_new_SUNAdaptControllerContent_MRIHTol_() { + SwigClassWrapper fresult ; + struct SUNAdaptControllerContent_MRIHTol_ *result = 0 ; + + result = (struct SUNAdaptControllerContent_MRIHTol_ *)calloc(1, sizeof(struct SUNAdaptControllerContent_MRIHTol_)); + fresult.cptr = result; + fresult.cmemflags = SWIG_MEM_RVALUE | (1 ? SWIG_MEM_OWN : 0); + return fresult; +} + + +SWIGEXPORT void _wrap_delete_SUNAdaptControllerContent_MRIHTol_(SwigClassWrapper *farg1) { + struct SUNAdaptControllerContent_MRIHTol_ *arg1 = (struct SUNAdaptControllerContent_MRIHTol_ *) 0 ; + + SWIG_check_mutable(*farg1, "struct SUNAdaptControllerContent_MRIHTol_ *", "SUNAdaptControllerContent_MRIHTol_", "SUNAdaptControllerContent_MRIHTol_::~SUNAdaptControllerContent_MRIHTol_()", return ); + arg1 = (struct SUNAdaptControllerContent_MRIHTol_ *)(farg1->cptr); + free((char *) arg1); +} + + +SWIGEXPORT void _wrap_SUNAdaptControllerContent_MRIHTol__op_assign__(SwigClassWrapper *farg1, SwigClassWrapper const *farg2) { + struct SUNAdaptControllerContent_MRIHTol_ *arg1 = (struct SUNAdaptControllerContent_MRIHTol_ *) 0 ; + struct SUNAdaptControllerContent_MRIHTol_ *arg2 = 0 ; + + (void)sizeof(arg1); + (void)sizeof(arg2); + SWIG_assign(farg1, *farg2); + +} + + SWIGEXPORT SUNAdaptController _wrap_FSUNAdaptController_MRIHTol(void *farg1, SUNAdaptController farg2, SUNAdaptController farg3) { SUNAdaptController fresult ; SUNContext arg1 = (SUNContext) 0 ; diff --git a/src/sunadaptcontroller/mrihtol/fmod_int32/fsunadaptcontroller_mrihtol_mod.f90 b/src/sunadaptcontroller/mrihtol/fmod_int32/fsunadaptcontroller_mrihtol_mod.f90 index 19ce2d9d6f..0cf5b8a79c 100644 --- a/src/sunadaptcontroller/mrihtol/fmod_int32/fsunadaptcontroller_mrihtol_mod.f90 +++ b/src/sunadaptcontroller/mrihtol/fmod_int32/fsunadaptcontroller_mrihtol_mod.f90 @@ -25,6 +25,35 @@ module fsunadaptcontroller_mrihtol_mod private ! DECLARATION CONSTRUCTS + + integer, parameter :: swig_cmem_own_bit = 0 + integer, parameter :: swig_cmem_rvalue_bit = 1 + integer, parameter :: swig_cmem_const_bit = 2 + type, bind(C) :: SwigClassWrapper + type(C_PTR), public :: cptr = C_NULL_PTR + integer(C_INT), public :: cmemflags = 0 + end type + ! struct struct SUNAdaptControllerContent_MRIHTol_ + type, public :: SUNAdaptControllerContent_MRIHTol_ + type(SwigClassWrapper), public :: swigdata + contains + procedure :: set_HControl => swigf_SUNAdaptControllerContent_MRIHTol__HControl_set + procedure :: get_HControl => swigf_SUNAdaptControllerContent_MRIHTol__HControl_get + procedure :: set_TolControl => swigf_SUNAdaptControllerContent_MRIHTol__TolControl_set + procedure :: get_TolControl => swigf_SUNAdaptControllerContent_MRIHTol__TolControl_get + procedure :: set_inner_max_relch => swigf_SUNAdaptControllerContent_MRIHTol__inner_max_relch_set + procedure :: get_inner_max_relch => swigf_SUNAdaptControllerContent_MRIHTol__inner_max_relch_get + procedure :: set_inner_min_tolfac => swigf_SUNAdaptControllerContent_MRIHTol__inner_min_tolfac_set + procedure :: get_inner_min_tolfac => swigf_SUNAdaptControllerContent_MRIHTol__inner_min_tolfac_get + procedure :: set_inner_max_tolfac => swigf_SUNAdaptControllerContent_MRIHTol__inner_max_tolfac_set + procedure :: get_inner_max_tolfac => swigf_SUNAdaptControllerContent_MRIHTol__inner_max_tolfac_get + procedure :: release => swigf_release_SUNAdaptControllerContent_MRIHTol_ + procedure, private :: swigf_SUNAdaptControllerContent_MRIHTol__op_assign__ + generic :: assignment(=) => swigf_SUNAdaptControllerContent_MRIHTol__op_assign__ + end type SUNAdaptControllerContent_MRIHTol_ + interface SUNAdaptControllerContent_MRIHTol_ + module procedure swigf_create_SUNAdaptControllerContent_MRIHTol_ + end interface public :: FSUNAdaptController_MRIHTol public :: FSUNAdaptController_SetParams_MRIHTol public :: FSUNAdaptController_GetSlowController_MRIHTol @@ -40,6 +69,114 @@ module fsunadaptcontroller_mrihtol_mod ! WRAPPER DECLARATIONS interface +subroutine swigc_SUNAdaptControllerContent_MRIHTol__HControl_set(farg1, farg2) & +bind(C, name="_wrap_SUNAdaptControllerContent_MRIHTol__HControl_set") +use, intrinsic :: ISO_C_BINDING +import :: swigclasswrapper +type(SwigClassWrapper) :: farg1 +type(C_PTR), value :: farg2 +end subroutine + +function swigc_SUNAdaptControllerContent_MRIHTol__HControl_get(farg1) & +bind(C, name="_wrap_SUNAdaptControllerContent_MRIHTol__HControl_get") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +import :: swigclasswrapper +type(SwigClassWrapper) :: farg1 +type(C_PTR) :: fresult +end function + +subroutine swigc_SUNAdaptControllerContent_MRIHTol__TolControl_set(farg1, farg2) & +bind(C, name="_wrap_SUNAdaptControllerContent_MRIHTol__TolControl_set") +use, intrinsic :: ISO_C_BINDING +import :: swigclasswrapper +type(SwigClassWrapper) :: farg1 +type(C_PTR), value :: farg2 +end subroutine + +function swigc_SUNAdaptControllerContent_MRIHTol__TolControl_get(farg1) & +bind(C, name="_wrap_SUNAdaptControllerContent_MRIHTol__TolControl_get") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +import :: swigclasswrapper +type(SwigClassWrapper) :: farg1 +type(C_PTR) :: fresult +end function + +subroutine swigc_SUNAdaptControllerContent_MRIHTol__inner_max_relch_set(farg1, farg2) & +bind(C, name="_wrap_SUNAdaptControllerContent_MRIHTol__inner_max_relch_set") +use, intrinsic :: ISO_C_BINDING +import :: swigclasswrapper +type(SwigClassWrapper) :: farg1 +real(C_DOUBLE), intent(in) :: farg2 +end subroutine + +function swigc_SUNAdaptControllerContent_MRIHTol__inner_max_relch_get(farg1) & +bind(C, name="_wrap_SUNAdaptControllerContent_MRIHTol__inner_max_relch_get") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +import :: swigclasswrapper +type(SwigClassWrapper) :: farg1 +real(C_DOUBLE) :: fresult +end function + +subroutine swigc_SUNAdaptControllerContent_MRIHTol__inner_min_tolfac_set(farg1, farg2) & +bind(C, name="_wrap_SUNAdaptControllerContent_MRIHTol__inner_min_tolfac_set") +use, intrinsic :: ISO_C_BINDING +import :: swigclasswrapper +type(SwigClassWrapper) :: farg1 +real(C_DOUBLE), intent(in) :: farg2 +end subroutine + +function swigc_SUNAdaptControllerContent_MRIHTol__inner_min_tolfac_get(farg1) & +bind(C, name="_wrap_SUNAdaptControllerContent_MRIHTol__inner_min_tolfac_get") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +import :: swigclasswrapper +type(SwigClassWrapper) :: farg1 +real(C_DOUBLE) :: fresult +end function + +subroutine swigc_SUNAdaptControllerContent_MRIHTol__inner_max_tolfac_set(farg1, farg2) & +bind(C, name="_wrap_SUNAdaptControllerContent_MRIHTol__inner_max_tolfac_set") +use, intrinsic :: ISO_C_BINDING +import :: swigclasswrapper +type(SwigClassWrapper) :: farg1 +real(C_DOUBLE), intent(in) :: farg2 +end subroutine + +function swigc_SUNAdaptControllerContent_MRIHTol__inner_max_tolfac_get(farg1) & +bind(C, name="_wrap_SUNAdaptControllerContent_MRIHTol__inner_max_tolfac_get") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +import :: swigclasswrapper +type(SwigClassWrapper) :: farg1 +real(C_DOUBLE) :: fresult +end function + +function swigc_new_SUNAdaptControllerContent_MRIHTol_() & +bind(C, name="_wrap_new_SUNAdaptControllerContent_MRIHTol_") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +import :: swigclasswrapper +type(SwigClassWrapper) :: fresult +end function + +subroutine swigc_delete_SUNAdaptControllerContent_MRIHTol_(farg1) & +bind(C, name="_wrap_delete_SUNAdaptControllerContent_MRIHTol_") +use, intrinsic :: ISO_C_BINDING +import :: swigclasswrapper +type(SwigClassWrapper), intent(inout) :: farg1 +end subroutine + +subroutine swigc_SUNAdaptControllerContent_MRIHTol__op_assign__(farg1, farg2) & +bind(C, name="_wrap_SUNAdaptControllerContent_MRIHTol__op_assign__") +use, intrinsic :: ISO_C_BINDING +import :: swigclasswrapper +type(SwigClassWrapper), intent(inout) :: farg1 +type(SwigClassWrapper) :: farg2 +end subroutine + function swigc_FSUNAdaptController_MRIHTol(farg1, farg2, farg3) & bind(C, name="_wrap_FSUNAdaptController_MRIHTol") & result(fresult) @@ -161,6 +298,168 @@ function swigc_FSUNAdaptController_Space_MRIHTol(farg1, farg2, farg3) & contains ! MODULE SUBPROGRAMS +subroutine swigf_SUNAdaptControllerContent_MRIHTol__HControl_set(self, hcontrol) +use, intrinsic :: ISO_C_BINDING +class(SUNAdaptControllerContent_MRIHTol_), intent(in) :: self +type(SUNAdaptController), target, intent(inout) :: hcontrol +type(SwigClassWrapper) :: farg1 +type(C_PTR) :: farg2 + +farg1 = self%swigdata +farg2 = c_loc(hcontrol) +call swigc_SUNAdaptControllerContent_MRIHTol__HControl_set(farg1, farg2) +end subroutine + +function swigf_SUNAdaptControllerContent_MRIHTol__HControl_get(self) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +type(SUNAdaptController), pointer :: swig_result +class(SUNAdaptControllerContent_MRIHTol_), intent(in) :: self +type(C_PTR) :: fresult +type(SwigClassWrapper) :: farg1 + +farg1 = self%swigdata +fresult = swigc_SUNAdaptControllerContent_MRIHTol__HControl_get(farg1) +call c_f_pointer(fresult, swig_result) +end function + +subroutine swigf_SUNAdaptControllerContent_MRIHTol__TolControl_set(self, tolcontrol) +use, intrinsic :: ISO_C_BINDING +class(SUNAdaptControllerContent_MRIHTol_), intent(in) :: self +type(SUNAdaptController), target, intent(inout) :: tolcontrol +type(SwigClassWrapper) :: farg1 +type(C_PTR) :: farg2 + +farg1 = self%swigdata +farg2 = c_loc(tolcontrol) +call swigc_SUNAdaptControllerContent_MRIHTol__TolControl_set(farg1, farg2) +end subroutine + +function swigf_SUNAdaptControllerContent_MRIHTol__TolControl_get(self) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +type(SUNAdaptController), pointer :: swig_result +class(SUNAdaptControllerContent_MRIHTol_), intent(in) :: self +type(C_PTR) :: fresult +type(SwigClassWrapper) :: farg1 + +farg1 = self%swigdata +fresult = swigc_SUNAdaptControllerContent_MRIHTol__TolControl_get(farg1) +call c_f_pointer(fresult, swig_result) +end function + +subroutine swigf_SUNAdaptControllerContent_MRIHTol__inner_max_relch_set(self, inner_max_relch) +use, intrinsic :: ISO_C_BINDING +class(SUNAdaptControllerContent_MRIHTol_), intent(in) :: self +real(C_DOUBLE), intent(in) :: inner_max_relch +type(SwigClassWrapper) :: farg1 +real(C_DOUBLE) :: farg2 + +farg1 = self%swigdata +farg2 = inner_max_relch +call swigc_SUNAdaptControllerContent_MRIHTol__inner_max_relch_set(farg1, farg2) +end subroutine + +function swigf_SUNAdaptControllerContent_MRIHTol__inner_max_relch_get(self) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +real(C_DOUBLE) :: swig_result +class(SUNAdaptControllerContent_MRIHTol_), intent(in) :: self +real(C_DOUBLE) :: fresult +type(SwigClassWrapper) :: farg1 + +farg1 = self%swigdata +fresult = swigc_SUNAdaptControllerContent_MRIHTol__inner_max_relch_get(farg1) +swig_result = fresult +end function + +subroutine swigf_SUNAdaptControllerContent_MRIHTol__inner_min_tolfac_set(self, inner_min_tolfac) +use, intrinsic :: ISO_C_BINDING +class(SUNAdaptControllerContent_MRIHTol_), intent(in) :: self +real(C_DOUBLE), intent(in) :: inner_min_tolfac +type(SwigClassWrapper) :: farg1 +real(C_DOUBLE) :: farg2 + +farg1 = self%swigdata +farg2 = inner_min_tolfac +call swigc_SUNAdaptControllerContent_MRIHTol__inner_min_tolfac_set(farg1, farg2) +end subroutine + +function swigf_SUNAdaptControllerContent_MRIHTol__inner_min_tolfac_get(self) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +real(C_DOUBLE) :: swig_result +class(SUNAdaptControllerContent_MRIHTol_), intent(in) :: self +real(C_DOUBLE) :: fresult +type(SwigClassWrapper) :: farg1 + +farg1 = self%swigdata +fresult = swigc_SUNAdaptControllerContent_MRIHTol__inner_min_tolfac_get(farg1) +swig_result = fresult +end function + +subroutine swigf_SUNAdaptControllerContent_MRIHTol__inner_max_tolfac_set(self, inner_max_tolfac) +use, intrinsic :: ISO_C_BINDING +class(SUNAdaptControllerContent_MRIHTol_), intent(in) :: self +real(C_DOUBLE), intent(in) :: inner_max_tolfac +type(SwigClassWrapper) :: farg1 +real(C_DOUBLE) :: farg2 + +farg1 = self%swigdata +farg2 = inner_max_tolfac +call swigc_SUNAdaptControllerContent_MRIHTol__inner_max_tolfac_set(farg1, farg2) +end subroutine + +function swigf_SUNAdaptControllerContent_MRIHTol__inner_max_tolfac_get(self) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +real(C_DOUBLE) :: swig_result +class(SUNAdaptControllerContent_MRIHTol_), intent(in) :: self +real(C_DOUBLE) :: fresult +type(SwigClassWrapper) :: farg1 + +farg1 = self%swigdata +fresult = swigc_SUNAdaptControllerContent_MRIHTol__inner_max_tolfac_get(farg1) +swig_result = fresult +end function + +function swigf_create_SUNAdaptControllerContent_MRIHTol_() & +result(self) +use, intrinsic :: ISO_C_BINDING +type(SUNAdaptControllerContent_MRIHTol_) :: self +type(SwigClassWrapper) :: fresult + +fresult = swigc_new_SUNAdaptControllerContent_MRIHTol_() +self%swigdata = fresult +end function + +subroutine swigf_release_SUNAdaptControllerContent_MRIHTol_(self) +use, intrinsic :: ISO_C_BINDING +class(SUNAdaptControllerContent_MRIHTol_), intent(inout) :: self +type(SwigClassWrapper) :: farg1 + +farg1 = self%swigdata +if (btest(farg1%cmemflags, swig_cmem_own_bit)) then +call swigc_delete_SUNAdaptControllerContent_MRIHTol_(farg1) +endif +farg1%cptr = C_NULL_PTR +farg1%cmemflags = 0 +self%swigdata = farg1 +end subroutine + +subroutine swigf_SUNAdaptControllerContent_MRIHTol__op_assign__(self, other) +use, intrinsic :: ISO_C_BINDING +class(SUNAdaptControllerContent_MRIHTol_), intent(inout) :: self +type(SUNAdaptControllerContent_MRIHTol_), intent(in) :: other +type(SwigClassWrapper) :: farg1 +type(SwigClassWrapper) :: farg2 + +farg1 = self%swigdata +farg2 = other%swigdata +call swigc_SUNAdaptControllerContent_MRIHTol__op_assign__(farg1, farg2) +self%swigdata = farg1 +end subroutine + function FSUNAdaptController_MRIHTol(sunctx, hcontrol, tolcontrol) & result(swig_result) use, intrinsic :: ISO_C_BINDING diff --git a/src/sunadaptcontroller/mrihtol/fmod_int64/fsunadaptcontroller_mrihtol_mod.c b/src/sunadaptcontroller/mrihtol/fmod_int64/fsunadaptcontroller_mrihtol_mod.c index 4f01ed2426..bcc7a8c8d3 100644 --- a/src/sunadaptcontroller/mrihtol/fmod_int64/fsunadaptcontroller_mrihtol_mod.c +++ b/src/sunadaptcontroller/mrihtol/fmod_int64/fsunadaptcontroller_mrihtol_mod.c @@ -178,6 +178,35 @@ { printf("In " DECL ": " MSG); assert(0); RETURNNULL; } +enum { + SWIG_MEM_OWN = 0x01, + SWIG_MEM_RVALUE = 0x02, + SWIG_MEM_CONST = 0x04 +}; + + +#define SWIG_check_mutable(SWIG_CLASS_WRAPPER, TYPENAME, FNAME, FUNCNAME, RETURNNULL) \ + if ((SWIG_CLASS_WRAPPER).cmemflags & SWIG_MEM_CONST) { \ + SWIG_exception_impl(FUNCNAME, SWIG_TypeError, \ + "Cannot pass const " TYPENAME " (class " FNAME ") " \ + "as a mutable reference", \ + RETURNNULL); \ + } + + +#define SWIG_check_nonnull(SWIG_CLASS_WRAPPER, TYPENAME, FNAME, FUNCNAME, RETURNNULL) \ + if (!(SWIG_CLASS_WRAPPER).cptr) { \ + SWIG_exception_impl(FUNCNAME, SWIG_TypeError, \ + "Cannot pass null " TYPENAME " (class " FNAME ") " \ + "as a reference", RETURNNULL); \ + } + + +#define SWIG_check_mutable_nonnull(SWIG_CLASS_WRAPPER, TYPENAME, FNAME, FUNCNAME, RETURNNULL) \ + SWIG_check_nonnull(SWIG_CLASS_WRAPPER, TYPENAME, FNAME, FUNCNAME, RETURNNULL); \ + SWIG_check_mutable(SWIG_CLASS_WRAPPER, TYPENAME, FNAME, FUNCNAME, RETURNNULL); + + #include #if defined(_MSC_VER) || defined(__BORLANDC__) || defined(_WATCOM) # ifndef snprintf @@ -208,6 +237,217 @@ #include "sunadaptcontroller/sunadaptcontroller_mrihtol.h" + +typedef struct { + void* cptr; + int cmemflags; +} SwigClassWrapper; + + +SWIGINTERN SwigClassWrapper SwigClassWrapper_uninitialized() { + SwigClassWrapper result; + result.cptr = NULL; + result.cmemflags = 0; + return result; +} + + +#include +#ifdef _MSC_VER +# ifndef strtoull +# define strtoull _strtoui64 +# endif +# ifndef strtoll +# define strtoll _strtoi64 +# endif +#endif + + +#include + + +SWIGINTERN void SWIG_assign(SwigClassWrapper* self, SwigClassWrapper other) { + if (self->cptr == NULL) { + /* LHS is unassigned */ + if (other.cmemflags & SWIG_MEM_RVALUE) { + /* Capture pointer from RHS, clear 'moving' flag */ + self->cptr = other.cptr; + self->cmemflags = other.cmemflags & (~SWIG_MEM_RVALUE); + } else { + /* Become a reference to the other object */ + self->cptr = other.cptr; + self->cmemflags = other.cmemflags & (~SWIG_MEM_OWN); + } + } else if (other.cptr == NULL) { + /* Replace LHS with a null pointer */ + free(self->cptr); + *self = SwigClassWrapper_uninitialized(); + } else { + if (self->cmemflags & SWIG_MEM_OWN) { + free(self->cptr); + } + self->cptr = other.cptr; + if (other.cmemflags & SWIG_MEM_RVALUE) { + /* Capture RHS */ + self->cmemflags = other.cmemflags & ~SWIG_MEM_RVALUE; + } else { + /* Point to RHS */ + self->cmemflags = other.cmemflags & ~SWIG_MEM_OWN; + } + } +} + +SWIGEXPORT void _wrap_SUNAdaptControllerContent_MRIHTol__HControl_set(SwigClassWrapper const *farg1, SUNAdaptController farg2) { + struct SUNAdaptControllerContent_MRIHTol_ *arg1 = (struct SUNAdaptControllerContent_MRIHTol_ *) 0 ; + SUNAdaptController arg2 = (SUNAdaptController) 0 ; + + SWIG_check_mutable_nonnull(*farg1, "struct SUNAdaptControllerContent_MRIHTol_ *", "SUNAdaptControllerContent_MRIHTol_", "SUNAdaptControllerContent_MRIHTol_::HControl", return ); + arg1 = (struct SUNAdaptControllerContent_MRIHTol_ *)(farg1->cptr); + arg2 = (SUNAdaptController)(farg2); + if (arg1) (arg1)->HControl = arg2; +} + + +SWIGEXPORT SUNAdaptController _wrap_SUNAdaptControllerContent_MRIHTol__HControl_get(SwigClassWrapper const *farg1) { + SUNAdaptController fresult ; + struct SUNAdaptControllerContent_MRIHTol_ *arg1 = (struct SUNAdaptControllerContent_MRIHTol_ *) 0 ; + SUNAdaptController result; + + SWIG_check_mutable_nonnull(*farg1, "struct SUNAdaptControllerContent_MRIHTol_ *", "SUNAdaptControllerContent_MRIHTol_", "SUNAdaptControllerContent_MRIHTol_::HControl", return 0); + arg1 = (struct SUNAdaptControllerContent_MRIHTol_ *)(farg1->cptr); + result = (SUNAdaptController) ((arg1)->HControl); + fresult = result; + return fresult; +} + + +SWIGEXPORT void _wrap_SUNAdaptControllerContent_MRIHTol__TolControl_set(SwigClassWrapper const *farg1, SUNAdaptController farg2) { + struct SUNAdaptControllerContent_MRIHTol_ *arg1 = (struct SUNAdaptControllerContent_MRIHTol_ *) 0 ; + SUNAdaptController arg2 = (SUNAdaptController) 0 ; + + SWIG_check_mutable_nonnull(*farg1, "struct SUNAdaptControllerContent_MRIHTol_ *", "SUNAdaptControllerContent_MRIHTol_", "SUNAdaptControllerContent_MRIHTol_::TolControl", return ); + arg1 = (struct SUNAdaptControllerContent_MRIHTol_ *)(farg1->cptr); + arg2 = (SUNAdaptController)(farg2); + if (arg1) (arg1)->TolControl = arg2; +} + + +SWIGEXPORT SUNAdaptController _wrap_SUNAdaptControllerContent_MRIHTol__TolControl_get(SwigClassWrapper const *farg1) { + SUNAdaptController fresult ; + struct SUNAdaptControllerContent_MRIHTol_ *arg1 = (struct SUNAdaptControllerContent_MRIHTol_ *) 0 ; + SUNAdaptController result; + + SWIG_check_mutable_nonnull(*farg1, "struct SUNAdaptControllerContent_MRIHTol_ *", "SUNAdaptControllerContent_MRIHTol_", "SUNAdaptControllerContent_MRIHTol_::TolControl", return 0); + arg1 = (struct SUNAdaptControllerContent_MRIHTol_ *)(farg1->cptr); + result = (SUNAdaptController) ((arg1)->TolControl); + fresult = result; + return fresult; +} + + +SWIGEXPORT void _wrap_SUNAdaptControllerContent_MRIHTol__inner_max_relch_set(SwigClassWrapper const *farg1, double const *farg2) { + struct SUNAdaptControllerContent_MRIHTol_ *arg1 = (struct SUNAdaptControllerContent_MRIHTol_ *) 0 ; + sunrealtype arg2 ; + + SWIG_check_mutable_nonnull(*farg1, "struct SUNAdaptControllerContent_MRIHTol_ *", "SUNAdaptControllerContent_MRIHTol_", "SUNAdaptControllerContent_MRIHTol_::inner_max_relch", return ); + arg1 = (struct SUNAdaptControllerContent_MRIHTol_ *)(farg1->cptr); + arg2 = (sunrealtype)(*farg2); + if (arg1) (arg1)->inner_max_relch = arg2; +} + + +SWIGEXPORT double _wrap_SUNAdaptControllerContent_MRIHTol__inner_max_relch_get(SwigClassWrapper const *farg1) { + double fresult ; + struct SUNAdaptControllerContent_MRIHTol_ *arg1 = (struct SUNAdaptControllerContent_MRIHTol_ *) 0 ; + sunrealtype result; + + SWIG_check_mutable_nonnull(*farg1, "struct SUNAdaptControllerContent_MRIHTol_ *", "SUNAdaptControllerContent_MRIHTol_", "SUNAdaptControllerContent_MRIHTol_::inner_max_relch", return 0); + arg1 = (struct SUNAdaptControllerContent_MRIHTol_ *)(farg1->cptr); + result = (sunrealtype) ((arg1)->inner_max_relch); + fresult = (sunrealtype)(result); + return fresult; +} + + +SWIGEXPORT void _wrap_SUNAdaptControllerContent_MRIHTol__inner_min_tolfac_set(SwigClassWrapper const *farg1, double const *farg2) { + struct SUNAdaptControllerContent_MRIHTol_ *arg1 = (struct SUNAdaptControllerContent_MRIHTol_ *) 0 ; + sunrealtype arg2 ; + + SWIG_check_mutable_nonnull(*farg1, "struct SUNAdaptControllerContent_MRIHTol_ *", "SUNAdaptControllerContent_MRIHTol_", "SUNAdaptControllerContent_MRIHTol_::inner_min_tolfac", return ); + arg1 = (struct SUNAdaptControllerContent_MRIHTol_ *)(farg1->cptr); + arg2 = (sunrealtype)(*farg2); + if (arg1) (arg1)->inner_min_tolfac = arg2; +} + + +SWIGEXPORT double _wrap_SUNAdaptControllerContent_MRIHTol__inner_min_tolfac_get(SwigClassWrapper const *farg1) { + double fresult ; + struct SUNAdaptControllerContent_MRIHTol_ *arg1 = (struct SUNAdaptControllerContent_MRIHTol_ *) 0 ; + sunrealtype result; + + SWIG_check_mutable_nonnull(*farg1, "struct SUNAdaptControllerContent_MRIHTol_ *", "SUNAdaptControllerContent_MRIHTol_", "SUNAdaptControllerContent_MRIHTol_::inner_min_tolfac", return 0); + arg1 = (struct SUNAdaptControllerContent_MRIHTol_ *)(farg1->cptr); + result = (sunrealtype) ((arg1)->inner_min_tolfac); + fresult = (sunrealtype)(result); + return fresult; +} + + +SWIGEXPORT void _wrap_SUNAdaptControllerContent_MRIHTol__inner_max_tolfac_set(SwigClassWrapper const *farg1, double const *farg2) { + struct SUNAdaptControllerContent_MRIHTol_ *arg1 = (struct SUNAdaptControllerContent_MRIHTol_ *) 0 ; + sunrealtype arg2 ; + + SWIG_check_mutable_nonnull(*farg1, "struct SUNAdaptControllerContent_MRIHTol_ *", "SUNAdaptControllerContent_MRIHTol_", "SUNAdaptControllerContent_MRIHTol_::inner_max_tolfac", return ); + arg1 = (struct SUNAdaptControllerContent_MRIHTol_ *)(farg1->cptr); + arg2 = (sunrealtype)(*farg2); + if (arg1) (arg1)->inner_max_tolfac = arg2; +} + + +SWIGEXPORT double _wrap_SUNAdaptControllerContent_MRIHTol__inner_max_tolfac_get(SwigClassWrapper const *farg1) { + double fresult ; + struct SUNAdaptControllerContent_MRIHTol_ *arg1 = (struct SUNAdaptControllerContent_MRIHTol_ *) 0 ; + sunrealtype result; + + SWIG_check_mutable_nonnull(*farg1, "struct SUNAdaptControllerContent_MRIHTol_ *", "SUNAdaptControllerContent_MRIHTol_", "SUNAdaptControllerContent_MRIHTol_::inner_max_tolfac", return 0); + arg1 = (struct SUNAdaptControllerContent_MRIHTol_ *)(farg1->cptr); + result = (sunrealtype) ((arg1)->inner_max_tolfac); + fresult = (sunrealtype)(result); + return fresult; +} + + +SWIGEXPORT SwigClassWrapper _wrap_new_SUNAdaptControllerContent_MRIHTol_() { + SwigClassWrapper fresult ; + struct SUNAdaptControllerContent_MRIHTol_ *result = 0 ; + + result = (struct SUNAdaptControllerContent_MRIHTol_ *)calloc(1, sizeof(struct SUNAdaptControllerContent_MRIHTol_)); + fresult.cptr = result; + fresult.cmemflags = SWIG_MEM_RVALUE | (1 ? SWIG_MEM_OWN : 0); + return fresult; +} + + +SWIGEXPORT void _wrap_delete_SUNAdaptControllerContent_MRIHTol_(SwigClassWrapper *farg1) { + struct SUNAdaptControllerContent_MRIHTol_ *arg1 = (struct SUNAdaptControllerContent_MRIHTol_ *) 0 ; + + SWIG_check_mutable(*farg1, "struct SUNAdaptControllerContent_MRIHTol_ *", "SUNAdaptControllerContent_MRIHTol_", "SUNAdaptControllerContent_MRIHTol_::~SUNAdaptControllerContent_MRIHTol_()", return ); + arg1 = (struct SUNAdaptControllerContent_MRIHTol_ *)(farg1->cptr); + free((char *) arg1); +} + + +SWIGEXPORT void _wrap_SUNAdaptControllerContent_MRIHTol__op_assign__(SwigClassWrapper *farg1, SwigClassWrapper const *farg2) { + struct SUNAdaptControllerContent_MRIHTol_ *arg1 = (struct SUNAdaptControllerContent_MRIHTol_ *) 0 ; + struct SUNAdaptControllerContent_MRIHTol_ *arg2 = 0 ; + + (void)sizeof(arg1); + (void)sizeof(arg2); + SWIG_assign(farg1, *farg2); + +} + + SWIGEXPORT SUNAdaptController _wrap_FSUNAdaptController_MRIHTol(void *farg1, SUNAdaptController farg2, SUNAdaptController farg3) { SUNAdaptController fresult ; SUNContext arg1 = (SUNContext) 0 ; diff --git a/src/sunadaptcontroller/mrihtol/fmod_int64/fsunadaptcontroller_mrihtol_mod.f90 b/src/sunadaptcontroller/mrihtol/fmod_int64/fsunadaptcontroller_mrihtol_mod.f90 index 19ce2d9d6f..0cf5b8a79c 100644 --- a/src/sunadaptcontroller/mrihtol/fmod_int64/fsunadaptcontroller_mrihtol_mod.f90 +++ b/src/sunadaptcontroller/mrihtol/fmod_int64/fsunadaptcontroller_mrihtol_mod.f90 @@ -25,6 +25,35 @@ module fsunadaptcontroller_mrihtol_mod private ! DECLARATION CONSTRUCTS + + integer, parameter :: swig_cmem_own_bit = 0 + integer, parameter :: swig_cmem_rvalue_bit = 1 + integer, parameter :: swig_cmem_const_bit = 2 + type, bind(C) :: SwigClassWrapper + type(C_PTR), public :: cptr = C_NULL_PTR + integer(C_INT), public :: cmemflags = 0 + end type + ! struct struct SUNAdaptControllerContent_MRIHTol_ + type, public :: SUNAdaptControllerContent_MRIHTol_ + type(SwigClassWrapper), public :: swigdata + contains + procedure :: set_HControl => swigf_SUNAdaptControllerContent_MRIHTol__HControl_set + procedure :: get_HControl => swigf_SUNAdaptControllerContent_MRIHTol__HControl_get + procedure :: set_TolControl => swigf_SUNAdaptControllerContent_MRIHTol__TolControl_set + procedure :: get_TolControl => swigf_SUNAdaptControllerContent_MRIHTol__TolControl_get + procedure :: set_inner_max_relch => swigf_SUNAdaptControllerContent_MRIHTol__inner_max_relch_set + procedure :: get_inner_max_relch => swigf_SUNAdaptControllerContent_MRIHTol__inner_max_relch_get + procedure :: set_inner_min_tolfac => swigf_SUNAdaptControllerContent_MRIHTol__inner_min_tolfac_set + procedure :: get_inner_min_tolfac => swigf_SUNAdaptControllerContent_MRIHTol__inner_min_tolfac_get + procedure :: set_inner_max_tolfac => swigf_SUNAdaptControllerContent_MRIHTol__inner_max_tolfac_set + procedure :: get_inner_max_tolfac => swigf_SUNAdaptControllerContent_MRIHTol__inner_max_tolfac_get + procedure :: release => swigf_release_SUNAdaptControllerContent_MRIHTol_ + procedure, private :: swigf_SUNAdaptControllerContent_MRIHTol__op_assign__ + generic :: assignment(=) => swigf_SUNAdaptControllerContent_MRIHTol__op_assign__ + end type SUNAdaptControllerContent_MRIHTol_ + interface SUNAdaptControllerContent_MRIHTol_ + module procedure swigf_create_SUNAdaptControllerContent_MRIHTol_ + end interface public :: FSUNAdaptController_MRIHTol public :: FSUNAdaptController_SetParams_MRIHTol public :: FSUNAdaptController_GetSlowController_MRIHTol @@ -40,6 +69,114 @@ module fsunadaptcontroller_mrihtol_mod ! WRAPPER DECLARATIONS interface +subroutine swigc_SUNAdaptControllerContent_MRIHTol__HControl_set(farg1, farg2) & +bind(C, name="_wrap_SUNAdaptControllerContent_MRIHTol__HControl_set") +use, intrinsic :: ISO_C_BINDING +import :: swigclasswrapper +type(SwigClassWrapper) :: farg1 +type(C_PTR), value :: farg2 +end subroutine + +function swigc_SUNAdaptControllerContent_MRIHTol__HControl_get(farg1) & +bind(C, name="_wrap_SUNAdaptControllerContent_MRIHTol__HControl_get") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +import :: swigclasswrapper +type(SwigClassWrapper) :: farg1 +type(C_PTR) :: fresult +end function + +subroutine swigc_SUNAdaptControllerContent_MRIHTol__TolControl_set(farg1, farg2) & +bind(C, name="_wrap_SUNAdaptControllerContent_MRIHTol__TolControl_set") +use, intrinsic :: ISO_C_BINDING +import :: swigclasswrapper +type(SwigClassWrapper) :: farg1 +type(C_PTR), value :: farg2 +end subroutine + +function swigc_SUNAdaptControllerContent_MRIHTol__TolControl_get(farg1) & +bind(C, name="_wrap_SUNAdaptControllerContent_MRIHTol__TolControl_get") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +import :: swigclasswrapper +type(SwigClassWrapper) :: farg1 +type(C_PTR) :: fresult +end function + +subroutine swigc_SUNAdaptControllerContent_MRIHTol__inner_max_relch_set(farg1, farg2) & +bind(C, name="_wrap_SUNAdaptControllerContent_MRIHTol__inner_max_relch_set") +use, intrinsic :: ISO_C_BINDING +import :: swigclasswrapper +type(SwigClassWrapper) :: farg1 +real(C_DOUBLE), intent(in) :: farg2 +end subroutine + +function swigc_SUNAdaptControllerContent_MRIHTol__inner_max_relch_get(farg1) & +bind(C, name="_wrap_SUNAdaptControllerContent_MRIHTol__inner_max_relch_get") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +import :: swigclasswrapper +type(SwigClassWrapper) :: farg1 +real(C_DOUBLE) :: fresult +end function + +subroutine swigc_SUNAdaptControllerContent_MRIHTol__inner_min_tolfac_set(farg1, farg2) & +bind(C, name="_wrap_SUNAdaptControllerContent_MRIHTol__inner_min_tolfac_set") +use, intrinsic :: ISO_C_BINDING +import :: swigclasswrapper +type(SwigClassWrapper) :: farg1 +real(C_DOUBLE), intent(in) :: farg2 +end subroutine + +function swigc_SUNAdaptControllerContent_MRIHTol__inner_min_tolfac_get(farg1) & +bind(C, name="_wrap_SUNAdaptControllerContent_MRIHTol__inner_min_tolfac_get") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +import :: swigclasswrapper +type(SwigClassWrapper) :: farg1 +real(C_DOUBLE) :: fresult +end function + +subroutine swigc_SUNAdaptControllerContent_MRIHTol__inner_max_tolfac_set(farg1, farg2) & +bind(C, name="_wrap_SUNAdaptControllerContent_MRIHTol__inner_max_tolfac_set") +use, intrinsic :: ISO_C_BINDING +import :: swigclasswrapper +type(SwigClassWrapper) :: farg1 +real(C_DOUBLE), intent(in) :: farg2 +end subroutine + +function swigc_SUNAdaptControllerContent_MRIHTol__inner_max_tolfac_get(farg1) & +bind(C, name="_wrap_SUNAdaptControllerContent_MRIHTol__inner_max_tolfac_get") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +import :: swigclasswrapper +type(SwigClassWrapper) :: farg1 +real(C_DOUBLE) :: fresult +end function + +function swigc_new_SUNAdaptControllerContent_MRIHTol_() & +bind(C, name="_wrap_new_SUNAdaptControllerContent_MRIHTol_") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +import :: swigclasswrapper +type(SwigClassWrapper) :: fresult +end function + +subroutine swigc_delete_SUNAdaptControllerContent_MRIHTol_(farg1) & +bind(C, name="_wrap_delete_SUNAdaptControllerContent_MRIHTol_") +use, intrinsic :: ISO_C_BINDING +import :: swigclasswrapper +type(SwigClassWrapper), intent(inout) :: farg1 +end subroutine + +subroutine swigc_SUNAdaptControllerContent_MRIHTol__op_assign__(farg1, farg2) & +bind(C, name="_wrap_SUNAdaptControllerContent_MRIHTol__op_assign__") +use, intrinsic :: ISO_C_BINDING +import :: swigclasswrapper +type(SwigClassWrapper), intent(inout) :: farg1 +type(SwigClassWrapper) :: farg2 +end subroutine + function swigc_FSUNAdaptController_MRIHTol(farg1, farg2, farg3) & bind(C, name="_wrap_FSUNAdaptController_MRIHTol") & result(fresult) @@ -161,6 +298,168 @@ function swigc_FSUNAdaptController_Space_MRIHTol(farg1, farg2, farg3) & contains ! MODULE SUBPROGRAMS +subroutine swigf_SUNAdaptControllerContent_MRIHTol__HControl_set(self, hcontrol) +use, intrinsic :: ISO_C_BINDING +class(SUNAdaptControllerContent_MRIHTol_), intent(in) :: self +type(SUNAdaptController), target, intent(inout) :: hcontrol +type(SwigClassWrapper) :: farg1 +type(C_PTR) :: farg2 + +farg1 = self%swigdata +farg2 = c_loc(hcontrol) +call swigc_SUNAdaptControllerContent_MRIHTol__HControl_set(farg1, farg2) +end subroutine + +function swigf_SUNAdaptControllerContent_MRIHTol__HControl_get(self) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +type(SUNAdaptController), pointer :: swig_result +class(SUNAdaptControllerContent_MRIHTol_), intent(in) :: self +type(C_PTR) :: fresult +type(SwigClassWrapper) :: farg1 + +farg1 = self%swigdata +fresult = swigc_SUNAdaptControllerContent_MRIHTol__HControl_get(farg1) +call c_f_pointer(fresult, swig_result) +end function + +subroutine swigf_SUNAdaptControllerContent_MRIHTol__TolControl_set(self, tolcontrol) +use, intrinsic :: ISO_C_BINDING +class(SUNAdaptControllerContent_MRIHTol_), intent(in) :: self +type(SUNAdaptController), target, intent(inout) :: tolcontrol +type(SwigClassWrapper) :: farg1 +type(C_PTR) :: farg2 + +farg1 = self%swigdata +farg2 = c_loc(tolcontrol) +call swigc_SUNAdaptControllerContent_MRIHTol__TolControl_set(farg1, farg2) +end subroutine + +function swigf_SUNAdaptControllerContent_MRIHTol__TolControl_get(self) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +type(SUNAdaptController), pointer :: swig_result +class(SUNAdaptControllerContent_MRIHTol_), intent(in) :: self +type(C_PTR) :: fresult +type(SwigClassWrapper) :: farg1 + +farg1 = self%swigdata +fresult = swigc_SUNAdaptControllerContent_MRIHTol__TolControl_get(farg1) +call c_f_pointer(fresult, swig_result) +end function + +subroutine swigf_SUNAdaptControllerContent_MRIHTol__inner_max_relch_set(self, inner_max_relch) +use, intrinsic :: ISO_C_BINDING +class(SUNAdaptControllerContent_MRIHTol_), intent(in) :: self +real(C_DOUBLE), intent(in) :: inner_max_relch +type(SwigClassWrapper) :: farg1 +real(C_DOUBLE) :: farg2 + +farg1 = self%swigdata +farg2 = inner_max_relch +call swigc_SUNAdaptControllerContent_MRIHTol__inner_max_relch_set(farg1, farg2) +end subroutine + +function swigf_SUNAdaptControllerContent_MRIHTol__inner_max_relch_get(self) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +real(C_DOUBLE) :: swig_result +class(SUNAdaptControllerContent_MRIHTol_), intent(in) :: self +real(C_DOUBLE) :: fresult +type(SwigClassWrapper) :: farg1 + +farg1 = self%swigdata +fresult = swigc_SUNAdaptControllerContent_MRIHTol__inner_max_relch_get(farg1) +swig_result = fresult +end function + +subroutine swigf_SUNAdaptControllerContent_MRIHTol__inner_min_tolfac_set(self, inner_min_tolfac) +use, intrinsic :: ISO_C_BINDING +class(SUNAdaptControllerContent_MRIHTol_), intent(in) :: self +real(C_DOUBLE), intent(in) :: inner_min_tolfac +type(SwigClassWrapper) :: farg1 +real(C_DOUBLE) :: farg2 + +farg1 = self%swigdata +farg2 = inner_min_tolfac +call swigc_SUNAdaptControllerContent_MRIHTol__inner_min_tolfac_set(farg1, farg2) +end subroutine + +function swigf_SUNAdaptControllerContent_MRIHTol__inner_min_tolfac_get(self) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +real(C_DOUBLE) :: swig_result +class(SUNAdaptControllerContent_MRIHTol_), intent(in) :: self +real(C_DOUBLE) :: fresult +type(SwigClassWrapper) :: farg1 + +farg1 = self%swigdata +fresult = swigc_SUNAdaptControllerContent_MRIHTol__inner_min_tolfac_get(farg1) +swig_result = fresult +end function + +subroutine swigf_SUNAdaptControllerContent_MRIHTol__inner_max_tolfac_set(self, inner_max_tolfac) +use, intrinsic :: ISO_C_BINDING +class(SUNAdaptControllerContent_MRIHTol_), intent(in) :: self +real(C_DOUBLE), intent(in) :: inner_max_tolfac +type(SwigClassWrapper) :: farg1 +real(C_DOUBLE) :: farg2 + +farg1 = self%swigdata +farg2 = inner_max_tolfac +call swigc_SUNAdaptControllerContent_MRIHTol__inner_max_tolfac_set(farg1, farg2) +end subroutine + +function swigf_SUNAdaptControllerContent_MRIHTol__inner_max_tolfac_get(self) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +real(C_DOUBLE) :: swig_result +class(SUNAdaptControllerContent_MRIHTol_), intent(in) :: self +real(C_DOUBLE) :: fresult +type(SwigClassWrapper) :: farg1 + +farg1 = self%swigdata +fresult = swigc_SUNAdaptControllerContent_MRIHTol__inner_max_tolfac_get(farg1) +swig_result = fresult +end function + +function swigf_create_SUNAdaptControllerContent_MRIHTol_() & +result(self) +use, intrinsic :: ISO_C_BINDING +type(SUNAdaptControllerContent_MRIHTol_) :: self +type(SwigClassWrapper) :: fresult + +fresult = swigc_new_SUNAdaptControllerContent_MRIHTol_() +self%swigdata = fresult +end function + +subroutine swigf_release_SUNAdaptControllerContent_MRIHTol_(self) +use, intrinsic :: ISO_C_BINDING +class(SUNAdaptControllerContent_MRIHTol_), intent(inout) :: self +type(SwigClassWrapper) :: farg1 + +farg1 = self%swigdata +if (btest(farg1%cmemflags, swig_cmem_own_bit)) then +call swigc_delete_SUNAdaptControllerContent_MRIHTol_(farg1) +endif +farg1%cptr = C_NULL_PTR +farg1%cmemflags = 0 +self%swigdata = farg1 +end subroutine + +subroutine swigf_SUNAdaptControllerContent_MRIHTol__op_assign__(self, other) +use, intrinsic :: ISO_C_BINDING +class(SUNAdaptControllerContent_MRIHTol_), intent(inout) :: self +type(SUNAdaptControllerContent_MRIHTol_), intent(in) :: other +type(SwigClassWrapper) :: farg1 +type(SwigClassWrapper) :: farg2 + +farg1 = self%swigdata +farg2 = other%swigdata +call swigc_SUNAdaptControllerContent_MRIHTol__op_assign__(farg1, farg2) +self%swigdata = farg1 +end subroutine + function FSUNAdaptController_MRIHTol(sunctx, hcontrol, tolcontrol) & result(swig_result) use, intrinsic :: ISO_C_BINDING From 49fc004e3da29df6124398525ee089ea51b9de1d Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Tue, 1 Oct 2024 13:24:49 -0500 Subject: [PATCH 104/286] Removed MRIStepSetAdaptController (converted to internal arkode stepper-provided function) --- .../source/Usage/MRIStep/User_callable.rst | 48 ------- .../guide/source/Usage/User_callable.rst | 5 + .../arkode/CXX_serial/ark_kpr_nestedmri.cpp | 8 +- include/arkode/arkode_mristep.h | 2 - src/arkode/arkode.c | 1 + src/arkode/arkode_impl.h | 3 + src/arkode/arkode_io.c | 119 +++++++++++------- src/arkode/arkode_mristep.c | 1 + src/arkode/arkode_mristep_controller.c | 5 +- src/arkode/arkode_mristep_impl.h | 3 +- src/arkode/arkode_mristep_io.c | 52 ++++---- src/arkode/fmod_int32/farkode_mristep_mod.c | 14 --- src/arkode/fmod_int32/farkode_mristep_mod.f90 | 26 ---- src/arkode/fmod_int64/farkode_mristep_mod.c | 14 --- src/arkode/fmod_int64/farkode_mristep_mod.f90 | 26 ---- .../ark_test_brusselator_mriadapt.cpp | 4 +- .../CXX_serial/ark_test_kpr_mriadapt.cpp | 4 +- 17 files changed, 123 insertions(+), 212 deletions(-) diff --git a/doc/arkode/guide/source/Usage/MRIStep/User_callable.rst b/doc/arkode/guide/source/Usage/MRIStep/User_callable.rst index cbeaac8322..0d7633e27e 100644 --- a/doc/arkode/guide/source/Usage/MRIStep/User_callable.rst +++ b/doc/arkode/guide/source/Usage/MRIStep/User_callable.rst @@ -181,54 +181,6 @@ MRIStep tolerance specification functions -.. _ARKODE.Usage.MRIStep.StepAdaptivity: - -Multirate temporal adaptivity specification functions ------------------------------------------------------- - -As described in Section :numref:`ARKODE.Mathematics.MultirateAdaptivity`, MRIStep -supports additional forms of temporal adaptivity due to its evolution of multiple -time scales. - -For the simplest form of multirate temporal adaptivity, corresponding to -"decoupled" multirate control, users should merely specify a single-rate -controller to MRIStep using the :c:func:`ARKodeSetAdaptController` function. -The time step controller for the inner integrator may be specified independently. - -However, specification of the :math:`h^S-Tol` type of multirate controller requires -an additional step. First, a SUNAdaptController with :c:type:`SUNAdaptController_Type` type -``SUN_ADAPTCONTROLLER_MRI_TOL`` should be constructed, following the documentation in -Section :numref:`SUNAdaptController.MRIHTol`. This controller should then be passed as an -input to the MRIStep function :c:func:`MRIStepSetAdaptController`, as follows. - - -.. c:function:: int MRIStepSetAdaptController(void* arkode_mem, SUNAdaptController C) - - Sets a user-supplied multirate time-step controller object. - - :param arkode_mem: pointer to the MRIStep memory block. - :param C: user-supplied time adaptivity controller. If ``NULL`` then this routine - will just call :c:func:`ARKodeSetAdaptController` to specify that the - default ARKODE controller should be created. - - :retval ARK_SUCCESS: the function exited successfully. - :retval ARK_MEM_NULL: ``arkode_mem`` was ``NULL``. - :retval ARK_MEM_FAIL: *C* was ``NULL`` and a default controller could not be allocated. - - .. note:: - - If the input *C* has :c:type:`SUNAdaptController_Type` type ``SUN_ADAPTCONTROLLER_MRI_TOL`` - then this creates an MRIStep-specific adaptivity controller that couples the slow and fast - time scales, and that leverages *C* to perform multirate temporal adaptivity. - - If *C* has :c:type:`SUNAdaptController_Type` type ``SUN_ADAPTCONTROLLER_H`` - or ``SUN_ADAPTCONTROLLER_NONE`` then this routine merely passes *C* to the ARKODE-level - routine :c:func:`ARKodeSetAdaptController`. - - .. versionadded:: x.y.z - - - .. _ARKODE.Usage.MRIStep.LinearSolvers: diff --git a/doc/arkode/guide/source/Usage/User_callable.rst b/doc/arkode/guide/source/Usage/User_callable.rst index ea8009d0e7..2d500b65b3 100644 --- a/doc/arkode/guide/source/Usage/User_callable.rst +++ b/doc/arkode/guide/source/Usage/User_callable.rst @@ -1448,6 +1448,11 @@ Reset accumulated error :c:func:`ARKodeReset This is only compatible with time-stepping modules that support temporal adaptivity. + Not all time-stepping modules are compatible with all types of :c:type:`SUNAdaptController` + objects. While all steppers that support temporal adaptivity support controllers with + :c:type:`SUNAdaptController_Type` type ``SUN_ADAPTCONTROLLER_H``, only MRIStep supports + inputs with type ``SUN_ADAPTCONTROLLER_MRI_TOL``. + .. versionadded:: 6.1.0 diff --git a/examples/arkode/CXX_serial/ark_kpr_nestedmri.cpp b/examples/arkode/CXX_serial/ark_kpr_nestedmri.cpp index e981b6255d..28bdfbe312 100644 --- a/examples/arkode/CXX_serial/ark_kpr_nestedmri.cpp +++ b/examples/arkode/CXX_serial/ark_kpr_nestedmri.cpp @@ -843,8 +843,8 @@ int main(int argc, char* argv[]) if (check_flag(retval, "ARKodeSetUserData")) return 1; if (opts.scontrol != 0) { - retval = MRIStepSetAdaptController(mid_arkode_mem, mcontrol); - if (check_flag(retval, "MRIStepSetAdaptController")) return 1; + retval = ARKodeSetAdaptController(mid_arkode_mem, mcontrol); + if (check_flag(retval, "ARKodeSetAdaptController")) return 1; if (opts.set_h0 != 0) { retval = ARKodeSetInitStep(mid_arkode_mem, opts.hm); @@ -901,8 +901,8 @@ int main(int argc, char* argv[]) if (check_flag(retval, "ARKodeSetUserData")) return 1; if (opts.scontrol != 0) { - retval = MRIStepSetAdaptController(arkode_mem, scontrol); - if (check_flag(retval, "MRIStepSetAdaptController")) return 1; + retval = ARKodeSetAdaptController(arkode_mem, scontrol); + if (check_flag(retval, "ARKodeSetAdaptController")) return 1; if (opts.set_h0 != 0) { retval = ARKodeSetInitStep(arkode_mem, opts.hs); diff --git a/include/arkode/arkode_mristep.h b/include/arkode/arkode_mristep.h index 87d992db72..2851682972 100644 --- a/include/arkode/arkode_mristep.h +++ b/include/arkode/arkode_mristep.h @@ -190,8 +190,6 @@ SUNDIALS_EXPORT int MRIStepSetPreInnerFn(void* arkode_mem, MRIStepPreInnerFn prefn); SUNDIALS_EXPORT int MRIStepSetPostInnerFn(void* arkode_mem, MRIStepPostInnerFn postfn); -SUNDIALS_EXPORT int MRIStepSetAdaptController(void* arkode_mem, - SUNAdaptController C); /* Optional output functions */ SUNDIALS_EXPORT int MRIStepGetNumRhsEvals(void* arkode_mem, long int* nfse_evals, diff --git a/src/arkode/arkode.c b/src/arkode/arkode.c index e17232c102..37e9d54778 100644 --- a/src/arkode/arkode.c +++ b/src/arkode/arkode.c @@ -1493,6 +1493,7 @@ ARKodeMem arkCreate(SUNContext sunctx) ark_mem->step_setnonlinconvcoef = NULL; ark_mem->step_setstagepredictfn = NULL; ark_mem->step_getnumlinsolvsetups = NULL; + ark_mem->step_setadaptcontroller = NULL; ark_mem->step_getestlocalerrors = NULL; ark_mem->step_getcurrentgamma = NULL; ark_mem->step_getnonlinearsystemdata = NULL; diff --git a/src/arkode/arkode_impl.h b/src/arkode/arkode_impl.h index 179d2540f0..df7e6e6f57 100644 --- a/src/arkode/arkode_impl.h +++ b/src/arkode/arkode_impl.h @@ -228,6 +228,7 @@ typedef int (*ARKTimestepSetOrder)(ARKodeMem ark_mem, int maxord); /* time stepper interface functions -- temporal adaptivity */ typedef int (*ARKTimestepGetEstLocalErrors)(ARKodeMem ark_mem, N_Vector ele); +typedef int (*ARKSetAdaptControllerFn)(ARKodeMem ark_mem, SUNAdaptController C); /* time stepper interface functions -- relaxation */ typedef int (*ARKTimestepSetRelaxFn)(ARKodeMem ark_mem, ARKRelaxFn rfn, @@ -415,6 +416,7 @@ struct ARKodeMemRec /* Time stepper module -- temporal adaptivity */ sunbooleantype step_supports_adaptive; + ARKSetAdaptControllerFn step_setadaptcontroller; ARKTimestepGetEstLocalErrors step_getestlocalerrors; /* Time stepper module -- relaxation */ @@ -655,6 +657,7 @@ int arkCheckTemporalError(ARKodeMem ark_mem, int* nflagPtr, int* nefPtr, int arkAccessHAdaptMem(void* arkode_mem, const char* fname, ARKodeMem* ark_mem, ARKodeHAdaptMem* hadapt_mem); +int arkReplaceAdaptController(ARKodeMem ark_mem, SUNAdaptController C); int arkSetAdaptivityMethod(void* arkode_mem, int imethod, int idefault, int pq, sunrealtype adapt_params[3]); int arkSetAdaptivityFn(void* arkode_mem, ARKAdaptFn hfun, void* h_data); diff --git a/src/arkode/arkode_io.c b/src/arkode/arkode_io.c index 5554096bdf..b9001ab5f0 100644 --- a/src/arkode/arkode_io.c +++ b/src/arkode/arkode_io.c @@ -909,54 +909,15 @@ int ARKodeSetAdaptController(void* arkode_mem, SUNAdaptController C) return (ARK_STEPPER_UNSUPPORTED); } - /* Remove current SUNAdaptController object - (delete if owned, and then nullify pointer) */ - if (ark_mem->hadapt_mem->owncontroller && - (ark_mem->hadapt_mem->hcontroller != NULL)) + /* If the stepper has provided a custom function, then call it and return */ + if (ark_mem->step_setadaptcontroller) { - retval = SUNAdaptController_Space(ark_mem->hadapt_mem->hcontroller, &lenrw, - &leniw); - if (retval == SUN_SUCCESS) - { - ark_mem->liw -= leniw; - ark_mem->lrw -= lenrw; - } - - retval = SUNAdaptController_Destroy(ark_mem->hadapt_mem->hcontroller); - ark_mem->hadapt_mem->owncontroller = SUNFALSE; - if (retval != SUN_SUCCESS) - { - arkProcessError(ark_mem, ARK_MEM_FAIL, __LINE__, __func__, __FILE__, - "SUNAdaptController_Destroy failure"); - return (ARK_MEM_FAIL); - } + return (ark_mem->step_setadaptcontroller(ark_mem, C)); } - ark_mem->hadapt_mem->hcontroller = NULL; - /* On NULL-valued input, create default SUNAdaptController object */ - if (C == NULL) - { - C = SUNAdaptController_PID(ark_mem->sunctx); - if (C == NULL) - { - arkProcessError(ark_mem, ARK_MEM_FAIL, __LINE__, __func__, __FILE__, - "SUNAdaptControllerPID allocation failure"); - return (ARK_MEM_FAIL); - } - ark_mem->hadapt_mem->owncontroller = SUNTRUE; - } - else { ark_mem->hadapt_mem->owncontroller = SUNFALSE; } + /* Otherwise, call a utility routine to replace the current controller object */ + return (arkReplaceAdaptController(ark_mem, C)); - /* Attach new SUNAdaptController object */ - retval = SUNAdaptController_Space(C, &lenrw, &leniw); - if (retval == SUN_SUCCESS) - { - ark_mem->liw += leniw; - ark_mem->lrw += lenrw; - } - ark_mem->hadapt_mem->hcontroller = C; - - return (ARK_SUCCESS); } /*--------------------------------------------------------------- @@ -3084,6 +3045,76 @@ int ARKodeWriteParameters(void* arkode_mem, FILE* fp) return (ARK_SUCCESS); } + +/*=============================================================== + ARKODE-IO internal utility functions + ===============================================================*/ + +/*--------------------------------------------------------------- + arkReplaceAdaptController + + Replaces the current SUNAdaptController time step controller + object. If a NULL-valued SUNAdaptController is input, the + default will be re-enabled. + ---------------------------------------------------------------*/ +int arkReplaceAdaptController(ARKodeMem ark_mem, SUNAdaptController C) +{ + int retval; + long int lenrw, leniw; + SUNAdaptController_Type Ctype; + + /* Remove current SUNAdaptController object + (delete if owned, and then nullify pointer) */ + if (ark_mem->hadapt_mem->owncontroller && + (ark_mem->hadapt_mem->hcontroller != NULL)) + { + retval = SUNAdaptController_Space(ark_mem->hadapt_mem->hcontroller, &lenrw, + &leniw); + if (retval == SUN_SUCCESS) + { + ark_mem->liw -= leniw; + ark_mem->lrw -= lenrw; + } + + retval = SUNAdaptController_Destroy(ark_mem->hadapt_mem->hcontroller); + ark_mem->hadapt_mem->owncontroller = SUNFALSE; + if (retval != SUN_SUCCESS) + { + arkProcessError(ark_mem, ARK_MEM_FAIL, __LINE__, __func__, __FILE__, + "SUNAdaptController_Destroy failure"); + return (ARK_MEM_FAIL); + } + } + ark_mem->hadapt_mem->hcontroller = NULL; + + /* On NULL-valued input, create default SUNAdaptController object */ + if (C == NULL) + { + C = SUNAdaptController_PID(ark_mem->sunctx); + if (C == NULL) + { + arkProcessError(ark_mem, ARK_MEM_FAIL, __LINE__, __func__, __FILE__, + "SUNAdaptControllerPID allocation failure"); + return (ARK_MEM_FAIL); + } + ark_mem->hadapt_mem->owncontroller = SUNTRUE; + } + else { ark_mem->hadapt_mem->owncontroller = SUNFALSE; } + + /* Attach new SUNAdaptController object */ + retval = SUNAdaptController_Space(C, &lenrw, &leniw); + if (retval == SUN_SUCCESS) + { + ark_mem->liw += leniw; + ark_mem->lrw += lenrw; + } + ark_mem->hadapt_mem->hcontroller = C; + + return (ARK_SUCCESS); +} + + + /*=============================================================== ARKODE + XBraid interface utility functions ===============================================================*/ diff --git a/src/arkode/arkode_mristep.c b/src/arkode/arkode_mristep.c index 33e67bb396..235e868dcc 100644 --- a/src/arkode/arkode_mristep.c +++ b/src/arkode/arkode_mristep.c @@ -133,6 +133,7 @@ void* MRIStepCreate(ARKRhsFn fse, ARKRhsFn fsi, sunrealtype t0, N_Vector y0, ark_mem->step_setstagepredictfn = mriStep_SetStagePredictFn; ark_mem->step_getnumlinsolvsetups = mriStep_GetNumLinSolvSetups; ark_mem->step_getcurrentgamma = mriStep_GetCurrentGamma; + ark_mem->step_setadaptcontroller = mriStep_SetAdaptController; ark_mem->step_getestlocalerrors = mriStep_GetEstLocalErrors; ark_mem->step_getnonlinearsystemdata = mriStep_GetNonlinearSystemData; ark_mem->step_getnumnonlinsolviters = mriStep_GetNumNonlinSolvIters; diff --git a/src/arkode/arkode_mristep_controller.c b/src/arkode/arkode_mristep_controller.c index c701033e06..b992e30bb1 100644 --- a/src/arkode/arkode_mristep_controller.c +++ b/src/arkode/arkode_mristep_controller.c @@ -30,12 +30,11 @@ MRIStep SUNAdaptController wrapper functions --------------------------------------------*/ -SUNAdaptController SUNAdaptController_MRIStep(void* arkode_mem, +SUNAdaptController SUNAdaptController_MRIStep(ARKodeMem ark_mem, SUNAdaptController CMRI) { SUNAdaptController C; mriStepControlContent content; - ARKodeMem ark_mem; ARKodeMRIStepMem step_mem; int retval; @@ -48,7 +47,7 @@ SUNAdaptController SUNAdaptController_MRIStep(void* arkode_mem, } /* Return with failure if stepper is inaccessible */ - retval = mriStep_AccessARKODEStepMem(arkode_mem, __func__, &ark_mem, &step_mem); + retval = mriStep_AccessStepMem(ark_mem, __func__, &step_mem); if (retval != ARK_SUCCESS) return (NULL); /* Create an empty controller object */ diff --git a/src/arkode/arkode_mristep_impl.h b/src/arkode/arkode_mristep_impl.h index 7fff1c05e1..7a73fdb103 100644 --- a/src/arkode/arkode_mristep_impl.h +++ b/src/arkode/arkode_mristep_impl.h @@ -224,6 +224,7 @@ int mriStep_TakeStepMRIGARK(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr); int mriStep_TakeStepMRISR(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr); int mriStep_TakeStepMERK(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr); +int mriStep_SetAdaptController(ARKodeMem ark_mem, SUNAdaptController C); int mriStep_SetUserData(ARKodeMem ark_mem, void* user_data); int mriStep_SetDefaults(ARKodeMem ark_mem); int mriStep_SetOrder(ARKodeMem ark_mem, int ord); @@ -356,7 +357,7 @@ typedef struct _mriStepControlContent #define MRICONTROL_A(C) (((mriStepControlContent)(C->content))->ark_mem) #define MRICONTROL_S(C) (((mriStepControlContent)(C->content))->step_mem) -SUNAdaptController SUNAdaptController_MRIStep(void* arkode_mem, +SUNAdaptController SUNAdaptController_MRIStep(ARKodeMem ark_mem, SUNAdaptController C); SUNAdaptController_Type SUNAdaptController_GetType_MRIStep(SUNAdaptController C); SUNErrCode SUNAdaptController_EstimateStep_MRIStep(SUNAdaptController C, diff --git a/src/arkode/arkode_mristep_io.c b/src/arkode/arkode_mristep_io.c index e7b4b50f20..9d1115edfa 100644 --- a/src/arkode/arkode_mristep_io.c +++ b/src/arkode/arkode_mristep_io.c @@ -124,32 +124,6 @@ int MRIStepSetPostInnerFn(void* arkode_mem, MRIStepPostInnerFn postfn) return (ARK_SUCCESS); } -/*--------------------------------------------------------------- - MRIStepSetAdaptController: - - Specifies a temporal adaptivity controller for MRIStep to use. - If a non-MRI controller is provided, this just passes that - through to arkSetAdaptController. However, if an MRI - controller is provided, then this wraps that inside a - "SUNAdaptController_MRIStep" wrapper, which will properly - interact with the fast integration module. - ---------------------------------------------------------------*/ -int MRIStepSetAdaptController(void* arkode_mem, SUNAdaptController C) -{ - /* Retrieve the controller type */ - SUNAdaptController_Type ctype = SUNAdaptController_GetType(C); - - /* If this does not have MRI type, then just pass to ARKODE */ - if (ctype != SUN_ADAPTCONTROLLER_MRI_TOL) - { - return (ARKodeSetAdaptController(arkode_mem, C)); - } - - /* Create the mriStepControl wrapper, and pass that to ARKODE */ - SUNAdaptController Cwrapper = SUNAdaptController_MRIStep(arkode_mem, C); - return (ARKodeSetAdaptController(arkode_mem, Cwrapper)); -} - /*=============================================================== Exported optional output functions. ===============================================================*/ @@ -223,6 +197,32 @@ int MRIStepGetLastInnerStepFlag(void* arkode_mem, int* flag) Private functions attached to ARKODE ===============================================================*/ +/*--------------------------------------------------------------- + mriStep_SetAdaptController: + + Specifies a temporal adaptivity controller for MRIStep to use. + If a non-MRI controller is provided, this just passes that + through to arkReplaceAdaptController. However, if an MRI + controller is provided, then this wraps that inside a + "SUNAdaptController_MRIStep" wrapper, which will properly + interact with the fast integration module. + ---------------------------------------------------------------*/ +int mriStep_SetAdaptController(ARKodeMem ark_mem, SUNAdaptController C) +{ + /* Retrieve the controller type */ + SUNAdaptController_Type ctype = SUNAdaptController_GetType(C); + + /* If this does not have MRI type, then just pass to ARKODE */ + if (ctype != SUN_ADAPTCONTROLLER_MRI_TOL) + { + return (arkReplaceAdaptController(ark_mem, C)); + } + + /* Create the mriStepControl wrapper, and pass that to ARKODE */ + SUNAdaptController Cwrapper = SUNAdaptController_MRIStep(ark_mem, C); + return (arkReplaceAdaptController(ark_mem, Cwrapper)); +} + /*--------------------------------------------------------------- mriStep_SetUserData: diff --git a/src/arkode/fmod_int32/farkode_mristep_mod.c b/src/arkode/fmod_int32/farkode_mristep_mod.c index 067677e3a5..45300c3cfb 100644 --- a/src/arkode/fmod_int32/farkode_mristep_mod.c +++ b/src/arkode/fmod_int32/farkode_mristep_mod.c @@ -785,20 +785,6 @@ SWIGEXPORT int _wrap_FMRIStepSetPostInnerFn(void *farg1, MRIStepPostInnerFn farg } -SWIGEXPORT int _wrap_FMRIStepSetAdaptController(void *farg1, SUNAdaptController farg2) { - int fresult ; - void *arg1 = (void *) 0 ; - SUNAdaptController arg2 = (SUNAdaptController) 0 ; - int result; - - arg1 = (void *)(farg1); - arg2 = (SUNAdaptController)(farg2); - result = (int)MRIStepSetAdaptController(arg1,arg2); - fresult = (int)(result); - return fresult; -} - - SWIGEXPORT int _wrap_FMRIStepGetNumRhsEvals(void *farg1, long *farg2, long *farg3) { int fresult ; void *arg1 = (void *) 0 ; diff --git a/src/arkode/fmod_int32/farkode_mristep_mod.f90 b/src/arkode/fmod_int32/farkode_mristep_mod.f90 index a155838ff7..d4ab82a69f 100644 --- a/src/arkode/fmod_int32/farkode_mristep_mod.f90 +++ b/src/arkode/fmod_int32/farkode_mristep_mod.f90 @@ -152,7 +152,6 @@ module farkode_mristep_mod public :: FMRIStepSetCoupling public :: FMRIStepSetPreInnerFn public :: FMRIStepSetPostInnerFn - public :: FMRIStepSetAdaptController public :: FMRIStepGetNumRhsEvals public :: FMRIStepGetCurrentCoupling public :: FMRIStepGetLastInnerStepFlag @@ -581,15 +580,6 @@ function swigc_FMRIStepSetPostInnerFn(farg1, farg2) & integer(C_INT) :: fresult end function -function swigc_FMRIStepSetAdaptController(farg1, farg2) & -bind(C, name="_wrap_FMRIStepSetAdaptController") & -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_FMRIStepGetNumRhsEvals(farg1, farg2, farg3) & bind(C, name="_wrap_FMRIStepGetNumRhsEvals") & result(fresult) @@ -2072,22 +2062,6 @@ function FMRIStepSetPostInnerFn(arkode_mem, postfn) & swig_result = fresult end function -function FMRIStepSetAdaptController(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_FMRIStepSetAdaptController(farg1, farg2) -swig_result = fresult -end function - function FMRIStepGetNumRhsEvals(arkode_mem, nfse_evals, nfsi_evals) & result(swig_result) use, intrinsic :: ISO_C_BINDING diff --git a/src/arkode/fmod_int64/farkode_mristep_mod.c b/src/arkode/fmod_int64/farkode_mristep_mod.c index 09eb4bbfcd..44e98d145b 100644 --- a/src/arkode/fmod_int64/farkode_mristep_mod.c +++ b/src/arkode/fmod_int64/farkode_mristep_mod.c @@ -785,20 +785,6 @@ SWIGEXPORT int _wrap_FMRIStepSetPostInnerFn(void *farg1, MRIStepPostInnerFn farg } -SWIGEXPORT int _wrap_FMRIStepSetAdaptController(void *farg1, SUNAdaptController farg2) { - int fresult ; - void *arg1 = (void *) 0 ; - SUNAdaptController arg2 = (SUNAdaptController) 0 ; - int result; - - arg1 = (void *)(farg1); - arg2 = (SUNAdaptController)(farg2); - result = (int)MRIStepSetAdaptController(arg1,arg2); - fresult = (int)(result); - return fresult; -} - - SWIGEXPORT int _wrap_FMRIStepGetNumRhsEvals(void *farg1, long *farg2, long *farg3) { int fresult ; void *arg1 = (void *) 0 ; diff --git a/src/arkode/fmod_int64/farkode_mristep_mod.f90 b/src/arkode/fmod_int64/farkode_mristep_mod.f90 index 3feb69ca82..c4fa555d2d 100644 --- a/src/arkode/fmod_int64/farkode_mristep_mod.f90 +++ b/src/arkode/fmod_int64/farkode_mristep_mod.f90 @@ -152,7 +152,6 @@ module farkode_mristep_mod public :: FMRIStepSetCoupling public :: FMRIStepSetPreInnerFn public :: FMRIStepSetPostInnerFn - public :: FMRIStepSetAdaptController public :: FMRIStepGetNumRhsEvals public :: FMRIStepGetCurrentCoupling public :: FMRIStepGetLastInnerStepFlag @@ -581,15 +580,6 @@ function swigc_FMRIStepSetPostInnerFn(farg1, farg2) & integer(C_INT) :: fresult end function -function swigc_FMRIStepSetAdaptController(farg1, farg2) & -bind(C, name="_wrap_FMRIStepSetAdaptController") & -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_FMRIStepGetNumRhsEvals(farg1, farg2, farg3) & bind(C, name="_wrap_FMRIStepGetNumRhsEvals") & result(fresult) @@ -2072,22 +2062,6 @@ function FMRIStepSetPostInnerFn(arkode_mem, postfn) & swig_result = fresult end function -function FMRIStepSetAdaptController(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_FMRIStepSetAdaptController(farg1, farg2) -swig_result = fresult -end function - function FMRIStepGetNumRhsEvals(arkode_mem, nfse_evals, nfsi_evals) & result(swig_result) use, intrinsic :: ISO_C_BINDING diff --git a/test/unit_tests/arkode/CXX_serial/ark_test_brusselator_mriadapt.cpp b/test/unit_tests/arkode/CXX_serial/ark_test_brusselator_mriadapt.cpp index 3426e8b486..d801784816 100644 --- a/test/unit_tests/arkode/CXX_serial/ark_test_brusselator_mriadapt.cpp +++ b/test/unit_tests/arkode/CXX_serial/ark_test_brusselator_mriadapt.cpp @@ -627,8 +627,8 @@ int main(int argc, char* argv[]) if (check_flag(retval, "ARKodeSetUserData")) return 1; if (opts.scontrol != 0) { - retval = MRIStepSetAdaptController(arkode_mem, scontrol); - if (check_flag(retval, "MRIStepSetAdaptController")) return 1; + retval = ARKodeSetAdaptController(arkode_mem, scontrol); + if (check_flag(retval, "ARKodeSetAdaptController")) return 1; if (opts.set_h0 != 0) { retval = ARKodeSetInitStep(arkode_mem, opts.hs); diff --git a/test/unit_tests/arkode/CXX_serial/ark_test_kpr_mriadapt.cpp b/test/unit_tests/arkode/CXX_serial/ark_test_kpr_mriadapt.cpp index 5fce159a49..ae24a2f0dc 100644 --- a/test/unit_tests/arkode/CXX_serial/ark_test_kpr_mriadapt.cpp +++ b/test/unit_tests/arkode/CXX_serial/ark_test_kpr_mriadapt.cpp @@ -637,8 +637,8 @@ int main(int argc, char* argv[]) if (check_flag(retval, "ARKodeSetUserData")) return 1; if (opts.scontrol != 0) { - retval = MRIStepSetAdaptController(arkode_mem, scontrol); - if (check_flag(retval, "MRIStepSetAdaptController")) return 1; + retval = ARKodeSetAdaptController(arkode_mem, scontrol); + if (check_flag(retval, "ARKodeSetAdaptController")) return 1; if (opts.set_h0 != 0) { retval = ARKodeSetInitStep(arkode_mem, opts.hs); From ddaa953c7ee84dd5719236fa6d31ef6484f76031 Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Tue, 1 Oct 2024 13:29:00 -0500 Subject: [PATCH 105/286] Minor documentation fixes --- doc/arkode/guide/source/Usage/User_callable.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/arkode/guide/source/Usage/User_callable.rst b/doc/arkode/guide/source/Usage/User_callable.rst index 2d500b65b3..1cfdcb6c79 100644 --- a/doc/arkode/guide/source/Usage/User_callable.rst +++ b/doc/arkode/guide/source/Usage/User_callable.rst @@ -1412,7 +1412,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 -Adjust the method order used in the controller :c:func:`ERKStepSetAdaptivityAdjustment` -1 +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 Bounds determining no change in step size :c:func:`ARKodeSetFixedStepBounds` 1.0 1.5 @@ -4784,7 +4784,7 @@ rescale the upcoming time step by the specified factor. If a value -.. _ERKStep_CInterface.MRIStepInterface: +.. _ARKODE.Usage.MRIStepInterface: Using an ARKODE solver as an MRIStep "inner" solver --------------------------------------------------- From f0c53cba25f389afe6b56dc75933dee67930297f Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Tue, 1 Oct 2024 13:30:43 -0500 Subject: [PATCH 106/286] Minor documentation fix --- doc/shared/sunadaptcontroller/SUNAdaptController_MRIHTol.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/shared/sunadaptcontroller/SUNAdaptController_MRIHTol.rst b/doc/shared/sunadaptcontroller/SUNAdaptController_MRIHTol.rst index 1131290142..bc2303210c 100644 --- a/doc/shared/sunadaptcontroller/SUNAdaptController_MRIHTol.rst +++ b/doc/shared/sunadaptcontroller/SUNAdaptController_MRIHTol.rst @@ -97,7 +97,7 @@ SUNAdaptController class, and defines its *content* field as: .. code-block:: c - struct SUNAdaptControllerContent_MRIHTol + struct SUNAdaptControllerContent_MRIHTol_ { SUNAdaptController HControl; SUNAdaptController TolControl; From 3ac78129d21457729da5ecdf9523f578715ba4db Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Tue, 1 Oct 2024 13:34:01 -0500 Subject: [PATCH 107/286] formatting --- src/arkode/arkode_io.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/arkode/arkode_io.c b/src/arkode/arkode_io.c index b9001ab5f0..e0cc4395dc 100644 --- a/src/arkode/arkode_io.c +++ b/src/arkode/arkode_io.c @@ -917,7 +917,6 @@ int ARKodeSetAdaptController(void* arkode_mem, SUNAdaptController C) /* Otherwise, call a utility routine to replace the current controller object */ return (arkReplaceAdaptController(ark_mem, C)); - } /*--------------------------------------------------------------- @@ -3045,7 +3044,6 @@ int ARKodeWriteParameters(void* arkode_mem, FILE* fp) return (ARK_SUCCESS); } - /*=============================================================== ARKODE-IO internal utility functions ===============================================================*/ @@ -3113,8 +3111,6 @@ int arkReplaceAdaptController(ARKodeMem ark_mem, SUNAdaptController C) return (ARK_SUCCESS); } - - /*=============================================================== ARKODE + XBraid interface utility functions ===============================================================*/ From 2ecafeb26aa825d8a110b30b1af1bf537a946ba3 Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Tue, 1 Oct 2024 13:36:03 -0500 Subject: [PATCH 108/286] Removed unused variables --- src/arkode/arkode_io.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/arkode/arkode_io.c b/src/arkode/arkode_io.c index e0cc4395dc..61f96c14b8 100644 --- a/src/arkode/arkode_io.c +++ b/src/arkode/arkode_io.c @@ -890,8 +890,6 @@ int ARKodeSetUserData(void* arkode_mem, void* user_data) ---------------------------------------------------------------*/ int ARKodeSetAdaptController(void* arkode_mem, SUNAdaptController C) { - int retval; - long int lenrw, leniw; ARKodeMem ark_mem; if (arkode_mem == NULL) { From fbc48bdb19ee00a32447e60e1d9085b6277c8e59 Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Tue, 1 Oct 2024 13:37:53 -0500 Subject: [PATCH 109/286] Removed unused variables --- src/arkode/arkode_io.c | 1 - 1 file changed, 1 deletion(-) diff --git a/src/arkode/arkode_io.c b/src/arkode/arkode_io.c index 61f96c14b8..a27e0238c1 100644 --- a/src/arkode/arkode_io.c +++ b/src/arkode/arkode_io.c @@ -3057,7 +3057,6 @@ int arkReplaceAdaptController(ARKodeMem ark_mem, SUNAdaptController C) { int retval; long int lenrw, leniw; - SUNAdaptController_Type Ctype; /* Remove current SUNAdaptController object (delete if owned, and then nullify pointer) */ From ed75b3eba54e2941c7122c851c9a3469070bfe13 Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Tue, 1 Oct 2024 13:47:20 -0500 Subject: [PATCH 110/286] Table formatting fix --- doc/arkode/guide/source/Usage/User_callable.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/arkode/guide/source/Usage/User_callable.rst b/doc/arkode/guide/source/Usage/User_callable.rst index 1cfdcb6c79..dd287cb9d9 100644 --- a/doc/arkode/guide/source/Usage/User_callable.rst +++ b/doc/arkode/guide/source/Usage/User_callable.rst @@ -1412,7 +1412,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 -Adjust the method order used in the controller :c:func:`ARKodeSetAdaptivityAdjustment` -1 +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 Bounds determining no change in step size :c:func:`ARKodeSetFixedStepBounds` 1.0 1.5 From f9886a2a5b46614f064caa26c6afc0b0d2de6440 Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Tue, 1 Oct 2024 13:54:58 -0500 Subject: [PATCH 111/286] Minor formatting fixes --- doc/arkode/guide/source/Usage/User_callable.rst | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/doc/arkode/guide/source/Usage/User_callable.rst b/doc/arkode/guide/source/Usage/User_callable.rst index dd287cb9d9..c644a9b036 100644 --- a/doc/arkode/guide/source/Usage/User_callable.rst +++ b/doc/arkode/guide/source/Usage/User_callable.rst @@ -1435,8 +1435,7 @@ Reset accumulated error :c:func:`ARKodeReset Sets a user-supplied time-step controller object. :param arkode_mem: pointer to the ARKODE memory block. - :param C: user-supplied time adaptivity controller. If ``NULL`` then the PID controller - will be created (see :numref:`SUNAdaptController.Soderlind`). + :param C: user-supplied time adaptivity controller. :retval ARK_SUCCESS: the function exited successfully. :retval ARK_MEM_NULL: ``arkode_mem`` was ``NULL``. @@ -1446,6 +1445,8 @@ Reset accumulated error :c:func:`ARKodeReset .. note:: + If *C* is ``NULL`` then the PID controller will be created (see :numref:`SUNAdaptController.Soderlind`). + This is only compatible with time-stepping modules that support temporal adaptivity. Not all time-stepping modules are compatible with all types of :c:type:`SUNAdaptController` @@ -1453,7 +1454,7 @@ Reset accumulated error :c:func:`ARKodeReset :c:type:`SUNAdaptController_Type` type ``SUN_ADAPTCONTROLLER_H``, only MRIStep supports inputs with type ``SUN_ADAPTCONTROLLER_MRI_TOL``. - .. versionadded:: 6.1.0 + .. versionadded:: 6.1.0 .. c:function:: int ARKodeSetAdaptivityAdjustment(void* arkode_mem, int adjust) From ffbe8054878a61598cf29e8240260643c2827fc2 Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Fri, 4 Oct 2024 09:55:30 -0500 Subject: [PATCH 112/286] Applied suggestions from code review --- .../Custom_Inner_Stepper/Description.rst | 38 ++++----- .../source/Usage/MRIStep/MRIStepCoupling.rst | 16 ++-- .../source/Usage/MRIStep/User_callable.rst | 10 +-- src/arkode/arkode.c | 3 + src/arkode/arkode_arkstep.c | 2 +- src/arkode/arkode_arkstep_io.c | 3 +- src/arkode/arkode_erkstep_io.c | 3 +- src/arkode/arkode_mri_tables.c | 68 ++++++---------- src/arkode/arkode_mristep.c | 10 +-- src/arkode/arkode_mristep_controller.c | 28 +++---- src/arkode/arkode_mristep_io.c | 3 +- .../ark_test_accumerror_brusselator.cpp | 6 +- ...rk_test_accumerror_brusselator_20_-4_0.out | 80 +++++++++++++++++++ ...ark_test_accumerror_brusselator_20_3_1.out | 60 ++++++++++++++ ...ark_test_accumerror_brusselator_20_5_0.out | 60 ++++++++++++++ .../CXX_serial/ark_test_accumerror_kpr.cpp | 6 +- .../ark_test_accumerror_kpr_20_-4_1.out | 80 +++++++++++++++++++ .../ark_test_accumerror_kpr_20_2_0.out | 60 ++++++++++++++ .../ark_test_accumerror_kpr_20_3_1.out | 60 ++++++++++++++ .../C_serial/ark_test_erkstepsetforcing.c | 26 +++--- 20 files changed, 500 insertions(+), 122 deletions(-) diff --git a/doc/arkode/guide/source/Usage/MRIStep/Custom_Inner_Stepper/Description.rst b/doc/arkode/guide/source/Usage/MRIStep/Custom_Inner_Stepper/Description.rst index e6fa2dc0a0..80a9577158 100644 --- a/doc/arkode/guide/source/Usage/MRIStep/Custom_Inner_Stepper/Description.rst +++ b/doc/arkode/guide/source/Usage/MRIStep/Custom_Inner_Stepper/Description.rst @@ -369,11 +369,11 @@ member functions: :param tout: the final time for the inner (fast) integration. :param v: on input the state at time *t0* and, on output, the state at time *tout*. - :return: An :c:type:`MRIStepInnerEvolveFn` should return 0 if successful, a positive - value if a recoverable error occurred, or a negative value if it failed - unrecoverably. + :return value: An :c:type:`MRIStepInnerEvolveFn` should return 0 if successful, a positive + value if a recoverable error occurred, or a negative value if it failed + unrecoverably. - .. note:: + .. note:: An example of this is in ``examples/arkode/CXX_parallel/ark_diffusion_reaction_p.cpp``. @@ -401,11 +401,11 @@ following member functions: * ``ARK_FULLRHS_END`` -- called at the end of a successful step * ``ARK_FULLRHS_OTHER`` -- called elsewhere e.g., for dense output - :return: An :c:type:`MRIStepInnerFullRhsFn` should return 0 if successful, a positive - value if a recoverable error occurred, or a negative value if it failed - unrecoverably. + :return value: An :c:type:`MRIStepInnerFullRhsFn` should return 0 if successful, a positive + value if a recoverable error occurred, or a negative value if it failed + unrecoverably. - .. note:: + .. note:: An example of this is in ``examples/arkode/CXX_parallel/ark_diffusion_reaction_p.cpp``. @@ -422,9 +422,9 @@ following member functions: :param tR: the value of the independent variable :math:`t_R`. :param vR: the value of the dependent variable vector :math:`v(t_R)`. - :return: An :c:type:`MRIStepInnerResetFn` should return 0 if successful, a positive - value if a recoverable error occurred, or a negative value if it failed - unrecoverably. + :return value: An :c:type:`MRIStepInnerResetFn` should return 0 if successful, a positive + value if a recoverable error occurred, or a negative value if it failed + unrecoverably. .. note:: @@ -441,8 +441,8 @@ following member functions: :param stepper: the inner stepper object. :param accum_error: estimation of the accumulated solution error. - :return: An :c:type:`MRIStepInnerGetAccumulatedError` should return 0 if successful, a positive - value if a recoverable error occurred, or a negative value if it failed unrecoverably. + :return value: An :c:type:`MRIStepInnerGetAccumulatedError` should return 0 if successful, a positive + value if a recoverable error occurred, or a negative value if it failed unrecoverably. .. note:: @@ -464,8 +464,8 @@ following member functions: :param stepper: the inner stepper object. - :return: An :c:type:`MRIStepInnerResetAccumulatedError` should return 0 if successful, a positive` - value if a recoverable error occurred, or a negative value if it failed unrecoverably. + :return value: An :c:type:`MRIStepInnerResetAccumulatedError` should return 0 if successful, a positive` + value if a recoverable error occurred, or a negative value if it failed unrecoverably. .. note:: @@ -491,12 +491,12 @@ following member functions: :param stepper: the inner stepper object. :param rtol: relative tolerance to use on the upcoming solve. - :return: An :c:type:`MRIStepInnerSetRTol` should return 0 if successful, a positive - value if a recoverable error occurred, or a negative value if it failed - unrecoverably. + :return value: An :c:type:`MRIStepInnerSetRTol` should return 0 if successful, a positive + value if a recoverable error occurred, or a negative value if it failed + unrecoverably. .. note:: - + This function is only called when multirate temporal adaptivity has been enabled using a :c:type:`SUNAdaptController` module having type ``SUNDIALS_CONTROL_MRI_TOL``. diff --git a/doc/arkode/guide/source/Usage/MRIStep/MRIStepCoupling.rst b/doc/arkode/guide/source/Usage/MRIStep/MRIStepCoupling.rst index eaa0a1b9eb..0e3b1ca570 100644 --- a/doc/arkode/guide/source/Usage/MRIStep/MRIStepCoupling.rst +++ b/doc/arkode/guide/source/Usage/MRIStep/MRIStepCoupling.rst @@ -70,42 +70,42 @@ The MRI coupling tables themselves are stored in an .. c:member:: ARKODE_MRIType type - Flag indicating the type of MRI method encoded by this table, + Flag indicating the type of MRI method encoded by this table. .. c:member:: int nmat The number of coupling matrices :math:`\Omega^{\{k\}}` for the slow-nonstiff terms and/or :math:`\Gamma^{\{k\}}` for the slow-stiff terms - in :eq:`ARKODE_IVP_two_rate`, + in :eq:`ARKODE_IVP_two_rate`. .. c:member:: int stages - The number of abscissae i.e., :math:`s+1` above + The number of abscissae i.e., :math:`s+1` above. .. c:member:: int q - The method order of accuracy + The method order of accuracy. .. c:member:: int p - The embedding order of accuracy + The embedding order of accuracy. .. c:member:: sunrealtype* c An array of length ``[stages]`` containing the slow abscissae :math:`c^S` - for the method + for the method. .. c:member:: sunrealtype*** W A three-dimensional array with dimensions ``[nmat][stages+1][stages]`` containing the method's :math:`\Omega^{\{k\}}` coupling matrices for the - slow-nonstiff (explicit) terms in :eq:`ARKODE_IVP_two_rate` + slow-nonstiff (explicit) terms in :eq:`ARKODE_IVP_two_rate`. .. c:member:: sunrealtype*** G A three-dimensional array with dimensions ``[nmat][stages+1][stages]`` containing the method's :math:`\Gamma^{\{k\}}` coupling matrices for the - slow-stiff (implicit) terms in :eq:`ARKODE_IVP_two_rate` + slow-stiff (implicit) terms in :eq:`ARKODE_IVP_two_rate`. .. c:member:: int ngroup diff --git a/doc/arkode/guide/source/Usage/MRIStep/User_callable.rst b/doc/arkode/guide/source/Usage/MRIStep/User_callable.rst index 0d7633e27e..720ff7056e 100644 --- a/doc/arkode/guide/source/Usage/MRIStep/User_callable.rst +++ b/doc/arkode/guide/source/Usage/MRIStep/User_callable.rst @@ -651,13 +651,11 @@ Optional inputs for MRIStep :math:`t` equals the specified ``tstop`` (instead of merely copying the internal solution :math:`y_n`). - **Arguments:** - * *arkode_mem* -- pointer to the MRIStep memory block. - * *interp* -- flag indicating to use interpolation (1) or copy (0). + :param arkode_mem: pointer to the MRIStep memory block. + :param interp: flag indicating to use interpolation (1) or copy (0). - **Return value:** - * *ARK_SUCCESS* if successful - * *ARK_MEM_NULL* if the ARKStep memory is ``NULL`` + :retval ARK_SUCCESS: if successful + :retval ARK_MEM_NULL: if the MRIStep memory is ``NULL`` .. versionadded:: 5.6.0 diff --git a/src/arkode/arkode.c b/src/arkode/arkode.c index 37e9d54778..3ef8a4a70a 100644 --- a/src/arkode/arkode.c +++ b/src/arkode/arkode.c @@ -1773,6 +1773,9 @@ int arkInit(ARKodeMem ark_mem, sunrealtype t0, N_Vector y0, int init_type) ark_mem->hadapt_mem->nst_acc = 0; ark_mem->hadapt_mem->nst_exp = 0; + /* Accumulated error estimate */ + ark_mem->AccumError = ZERO; + /* Indicate that calling the full RHS function is not required, this flag is updated to SUNTRUE by the interpolation module initialization function and/or the stepper initialization function in arkInitialSetup */ diff --git a/src/arkode/arkode_arkstep.c b/src/arkode/arkode_arkstep.c index ef5bf0b1e2..c9cef7892f 100644 --- a/src/arkode/arkode_arkstep.c +++ b/src/arkode/arkode_arkstep.c @@ -1017,7 +1017,7 @@ int arkStep_Init(ARKodeMem ark_mem, int init_type) /* Ensure that if adaptivity or error accumulation is enabled, then method includes embedding coefficients */ if ((!ark_mem->fixedstep || (ark_mem->AccumErrorType != ARK_ACCUMERROR_NONE)) && - (step_mem->p == 0)) + (step_mem->p <= 0)) { arkProcessError(ark_mem, ARK_ILL_INPUT, __LINE__, __func__, __FILE__, "Temporal error estimation cannot be performed without embedding coefficients"); diff --git a/src/arkode/arkode_arkstep_io.c b/src/arkode/arkode_arkstep_io.c index 7283810b1d..a269996f92 100644 --- a/src/arkode/arkode_arkstep_io.c +++ b/src/arkode/arkode_arkstep_io.c @@ -1154,7 +1154,8 @@ int arkStep_GetEstLocalErrors(ARKodeMem ark_mem, N_Vector ele) if (retval != ARK_SUCCESS) { return (retval); } /* return an error if local truncation error is not computed */ - if (ark_mem->fixedstep && (ark_mem->AccumErrorType == ARK_ACCUMERROR_NONE)) + if ((ark_mem->fixedstep && (ark_mem->AccumErrorType == ARK_ACCUMERROR_NONE)) || + (step_mem->p <= 0)) { return (ARK_STEPPER_UNSUPPORTED); } diff --git a/src/arkode/arkode_erkstep_io.c b/src/arkode/arkode_erkstep_io.c index 35d14a5940..7cc750a8f8 100644 --- a/src/arkode/arkode_erkstep_io.c +++ b/src/arkode/arkode_erkstep_io.c @@ -374,7 +374,8 @@ int erkStep_GetEstLocalErrors(ARKodeMem ark_mem, N_Vector ele) if (retval != ARK_SUCCESS) { return (retval); } /* return an error if local truncation error is not computed */ - if (ark_mem->fixedstep && (ark_mem->AccumErrorType == ARK_ACCUMERROR_NONE)) + if ((ark_mem->fixedstep && (ark_mem->AccumErrorType == ARK_ACCUMERROR_NONE)) || + (step_mem->p <= 0)) { return (ARK_STEPPER_UNSUPPORTED); } diff --git a/src/arkode/arkode_mri_tables.c b/src/arkode/arkode_mri_tables.c index a1b7bcc35d..d89b577749 100644 --- a/src/arkode/arkode_mri_tables.c +++ b/src/arkode/arkode_mri_tables.c @@ -268,26 +268,17 @@ MRIStepCoupling MRIStepCoupling_Create(int nmat, int stages, int q, int p, /* non-embedded method: coupling coefficient 1D arrays have length nmat * stages * stages, with each stages * stages matrix stored in C (row-major) order */ - if (type == MRISTEP_EXPLICIT || type == MRISTEP_IMEX) + for (k = 0; k < nmat; k++) { - for (k = 0; k < nmat; k++) + for (i = 0; i < stages; i++) { - for (i = 0; i < stages; i++) + for (j = 0; j < stages; j++) { - for (j = 0; j < stages; j++) + if (type == MRISTEP_EXPLICIT || type == MRISTEP_IMEX) { MRIC->W[k][i][j] = W[stages * (stages * k + i) + j]; } - } - } - } - if (type == MRISTEP_IMPLICIT || type == MRISTEP_IMEX) - { - for (k = 0; k < nmat; k++) - { - for (i = 0; i < stages; i++) - { - for (j = 0; j < stages; j++) + if (type == MRISTEP_IMPLICIT || type == MRISTEP_IMEX) { MRIC->G[k][i][j] = G[stages * (stages * k + i) + j]; } @@ -300,26 +291,17 @@ MRIStepCoupling MRIStepCoupling_Create(int nmat, int stages, int q, int p, /* embedded method: coupling coefficient 1D arrays have length nmat * (stages+1) * stages, with each (stages+1) * stages matrix stored in C (row-major) order */ - if (type == MRISTEP_EXPLICIT || type == MRISTEP_IMEX) + for (k = 0; k < nmat; k++) { - for (k = 0; k < nmat; k++) + for (i = 0; i <= stages; i++) { - for (i = 0; i <= stages; i++) + for (j = 0; j < stages; j++) { - for (j = 0; j < stages; j++) + if (type == MRISTEP_EXPLICIT || type == MRISTEP_IMEX) { MRIC->W[k][i][j] = W[(stages + 1) * (stages * k + i) + j]; } - } - } - } - if (type == MRISTEP_IMPLICIT || type == MRISTEP_IMEX) - { - for (k = 0; k < nmat; k++) - { - for (i = 0; i <= stages; i++) - { - for (j = 0; j < stages; j++) + if (type == MRISTEP_IMPLICIT || type == MRISTEP_IMEX) { MRIC->G[k][i][j] = G[(stages + 1) * (stages * k + i) + j]; } @@ -788,7 +770,7 @@ void MRIStepCoupling_Write(MRIStepCoupling MRIC, FILE* outfile) int mriStepCoupling_GetStageType(MRIStepCoupling MRIC, int is) { int i, j; - sunrealtype Gabs, cdiff, Gabsrow, Wabsrow; + sunbooleantype Gdiag, Grow, Wrow, cdiff; const sunrealtype tol = SUN_RCONST(100.0) * SUN_UNIT_ROUNDOFF; if ((is < 1) || (is > MRIC->stages)) { return ARK_INVALID_TABLE; } @@ -802,16 +784,15 @@ int mriStepCoupling_GetStageType(MRIStepCoupling MRIC, int is) /* separately handle an embedding "stage" from normal stages */ if (is < MRIC->stages) { /* normal */ - /* sum of stage diagonal entries across implicit tables */ - Gabs = Gabsrow = Wabsrow = ZERO; + Gdiag = Grow = Wrow = cdiff = SUNFALSE; if (MRIC->G) { for (i = 0; i < MRIC->nmat; i++) { - Gabs += SUNRabs(MRIC->G[i][is][is]); + Gdiag = Gdiag || (SUNRabs(MRIC->G[i][is][is]) > tol); for (j = 0; j < MRIC->stages; j++) { - Gabsrow += SUNRabs(MRIC->G[i][is][j]); + Grow = Grow || (SUNRabs(MRIC->G[i][is][j]) > tol); } } } @@ -821,25 +802,24 @@ int mriStepCoupling_GetStageType(MRIStepCoupling MRIC, int is) { for (j = 0; j < MRIC->stages; j++) { - Wabsrow += SUNRabs(MRIC->W[i][is][j]); + Wrow = Wrow || (SUNRabs(MRIC->W[i][is][j]) > tol); } } } /* abscissae difference */ - cdiff = MRIC->c[is] - MRIC->c[is - 1]; + cdiff = (SUNRabs(MRIC->c[is] - MRIC->c[is - 1]) > tol); } else { /* embedding */ - Gabs = Gabsrow = Wabsrow = ZERO; if (MRIC->G) { for (i = 0; i < MRIC->nmat; i++) { - Gabs += SUNRabs(MRIC->G[i][is][is - 1]); + Gdiag = Gdiag || (SUNRabs(MRIC->G[i][is][is - 1]) > tol); for (j = 0; j < MRIC->stages; j++) { - Gabsrow += SUNRabs(MRIC->G[i][is][j]); + Grow = Grow || (SUNRabs(MRIC->G[i][is][j]) > tol); } } } @@ -849,21 +829,21 @@ int mriStepCoupling_GetStageType(MRIStepCoupling MRIC, int is) { for (j = 0; j < MRIC->stages; j++) { - Wabsrow += SUNRabs(MRIC->W[i][is][j]); + Wrow = Wrow || (SUNRabs(MRIC->W[i][is][j]) > tol); } } } - cdiff = MRIC->c[is - 1] - MRIC->c[is - 2]; + cdiff = (SUNRabs(MRIC->c[is - 1] - MRIC->c[is - 2]) > tol); } /* make determination */ - if ((Gabs <= tol) && (Gabsrow <= tol) && (Wabsrow <= tol) && (cdiff <= tol)) + if (!(Gdiag || Grow || Wrow || cdiff)) { /* stiffly-accurate stage */ return (MRISTAGE_STIFF_ACC); } - if (Gabs > tol) + if (Gdiag) { /* DIRK */ - if (cdiff > tol) + if (cdiff) { /* Fast */ return (MRISTAGE_DIRK_FAST); } @@ -871,7 +851,7 @@ int mriStepCoupling_GetStageType(MRIStepCoupling MRIC, int is) } else { /* ERK */ - if (cdiff > tol) + if (cdiff) { /* Fast */ return (MRISTAGE_ERK_FAST); } diff --git a/src/arkode/arkode_mristep.c b/src/arkode/arkode_mristep.c index 235e868dcc..6a01659d27 100644 --- a/src/arkode/arkode_mristep.c +++ b/src/arkode/arkode_mristep.c @@ -1310,9 +1310,6 @@ int mriStep_Init(ARKodeMem ark_mem, int init_type) step_mem->inner_control = ONE; } - /* /\* Signal to shared arkode module that fullrhs is required after each step *\/ */ - /* /\* TO-DO: verify whether this is actually required *\/ */ - /* ark_mem->call_fullrhs = SUNTRUE; */ return (ARK_SUCCESS); } @@ -4460,12 +4457,7 @@ int mriStepInnerStepper_GetError(MRIStepInnerStepper stepper, stepper->last_flag = stepper->ops->geterror(stepper, accum_error); return stepper->last_flag; } - else - { - /* assume stepper provides exact solution */ - *accum_error = SUN_RCONST(0.0); - return ARK_SUCCESS; - } + else { return ARK_INNERSTEP_FAIL; } } /* Resets the inner (fast) stepper accumulated error */ diff --git a/src/arkode/arkode_mristep_controller.c b/src/arkode/arkode_mristep_controller.c index b992e30bb1..bef6c5a711 100644 --- a/src/arkode/arkode_mristep_controller.c +++ b/src/arkode/arkode_mristep_controller.c @@ -82,12 +82,12 @@ SUNAdaptController SUNAdaptController_MRIStep(ARKodeMem ark_mem, return (C); } -int SUNAdaptController_EstimateStep_MRIStep(SUNAdaptController C, sunrealtype H, - int P, sunrealtype DSM, - sunrealtype* Hnew) +SUNErrCode SUNAdaptController_EstimateStep_MRIStep(SUNAdaptController C, + sunrealtype H, int P, + sunrealtype DSM, + sunrealtype* Hnew) { /* Shortcuts to ARKODE and MRIStep memory */ - int retval; ARKodeMem ark_mem = MRICONTROL_A(C); ARKodeMRIStepMem step_mem = MRICONTROL_S(C); if ((ark_mem == NULL) || (step_mem == NULL)) { return SUN_ERR_MEM_FAIL; } @@ -96,15 +96,14 @@ int SUNAdaptController_EstimateStep_MRIStep(SUNAdaptController C, sunrealtype H, step_mem->inner_dsm = SUNMAX(step_mem->inner_dsm, INNER_MIN_DSM); /* Estimate slow stepsize from MRI controller */ - retval = SUNAdaptController_EstimateStepTol(MRICONTROL_C(C), H, - step_mem->inner_control, P, DSM, - step_mem->inner_dsm, Hnew, - &(step_mem->inner_control_new)); - return retval; + return SUNAdaptController_EstimateStepTol(MRICONTROL_C(C), H, + step_mem->inner_control, P, DSM, + step_mem->inner_dsm, Hnew, + &(step_mem->inner_control_new)); } -int SUNAdaptController_UpdateH_MRIStep(SUNAdaptController C, sunrealtype H, - sunrealtype DSM) +SUNErrCode SUNAdaptController_UpdateH_MRIStep(SUNAdaptController C, + sunrealtype H, sunrealtype DSM) { /* Shortcuts to ARKODE and MRIStep memory */ ARKodeMem ark_mem = MRICONTROL_A(C); @@ -112,10 +111,9 @@ int SUNAdaptController_UpdateH_MRIStep(SUNAdaptController C, sunrealtype H, if ((ark_mem == NULL) || (step_mem == NULL)) { return SUN_ERR_MEM_FAIL; } /* Update MRI controller */ - int retval; - retval = SUNAdaptController_UpdateMRITol(MRICONTROL_C(C), H, - step_mem->inner_control, DSM, - step_mem->inner_dsm); + SUNErrCode retval = SUNAdaptController_UpdateMRITol(MRICONTROL_C(C), H, + step_mem->inner_control, + DSM, step_mem->inner_dsm); if (retval != SUN_SUCCESS) { return (retval); } /* Update inner controller parameter to most-recent prediction */ diff --git a/src/arkode/arkode_mristep_io.c b/src/arkode/arkode_mristep_io.c index 9d1115edfa..dd331741a4 100644 --- a/src/arkode/arkode_mristep_io.c +++ b/src/arkode/arkode_mristep_io.c @@ -633,7 +633,8 @@ int mriStep_GetEstLocalErrors(ARKodeMem ark_mem, N_Vector ele) if (retval != ARK_SUCCESS) { return (retval); } /* return an error if local truncation error is not computed */ - if (ark_mem->fixedstep && (ark_mem->AccumErrorType == ARK_ACCUMERROR_NONE)) + if ((ark_mem->fixedstep && (ark_mem->AccumErrorType == ARK_ACCUMERROR_NONE)) || + (step_mem->p <= 0)) { return (ARK_STEPPER_UNSUPPORTED); } diff --git a/test/unit_tests/arkode/CXX_serial/ark_test_accumerror_brusselator.cpp b/test/unit_tests/arkode/CXX_serial/ark_test_accumerror_brusselator.cpp index 4e46546c86..7869048a90 100644 --- a/test/unit_tests/arkode/CXX_serial/ark_test_accumerror_brusselator.cpp +++ b/test/unit_tests/arkode/CXX_serial/ark_test_accumerror_brusselator.cpp @@ -405,7 +405,8 @@ static int adaptive_run(void* arkode_mem, N_Vector y, sunrealtype T0, sunrealtype abstol = SUN_RCONST(1.e-12); vector rtols = {SUN_RCONST(1.e-2), SUN_RCONST(1.e-4), SUN_RCONST(1.e-6)}; - vector accum_types = {ARK_ACCUMERROR_MAX, ARK_ACCUMERROR_AVG}; + vector accum_types = {ARK_ACCUMERROR_MAX, ARK_ACCUMERROR_SUM, + ARK_ACCUMERROR_AVG}; vector dsm(udata.Npart); vector dsm_est(udata.Npart); vector Nsteps(udata.Npart); @@ -492,7 +493,8 @@ static int fixed_run(void* arkode_mem, N_Vector y, sunrealtype T0, sunrealtype T sunrealtype hmax = (Tf - T0) / 400; if (rk_type == 1) hmax = min(hmax, udata.ep); vector hvals = {hmax, hmax / 4, hmax / 16, hmax / 64}; - vector accum_types = {ARK_ACCUMERROR_MAX, ARK_ACCUMERROR_AVG}; + vector accum_types = {ARK_ACCUMERROR_MAX, ARK_ACCUMERROR_SUM, + ARK_ACCUMERROR_AVG}; vector dsm(udata.Npart); vector dsm_est(udata.Npart); vector Nsteps(udata.Npart); diff --git a/test/unit_tests/arkode/CXX_serial/ark_test_accumerror_brusselator_20_-4_0.out b/test/unit_tests/arkode/CXX_serial/ark_test_accumerror_brusselator_20_-4_0.out index 83a2d7ecf7..029ea6d134 100644 --- a/test/unit_tests/arkode/CXX_serial/ark_test_accumerror_brusselator_20_-4_0.out +++ b/test/unit_tests/arkode/CXX_serial/ark_test_accumerror_brusselator_20_-4_0.out @@ -27,6 +27,26 @@ Fixed-step runs: h 0.025 rk_type 0 order 4 acc 1 t 9 dsm 1.60168e-09 dsm_est 1.38178e-08 nsteps 20 h 0.025 rk_type 0 order 4 acc 1 t 9.5 dsm 1.4347e-09 dsm_est 1.88007e-08 nsteps 20 h 0.025 rk_type 0 order 4 acc 1 t 10 dsm 5.54538e-10 dsm_est 1.51522e-08 nsteps 20 + h 0.025 rk_type 0 order 4 acc 2 t 0.5 dsm 2.02741e-07 dsm_est 0.270414 nsteps 20 + h 0.025 rk_type 0 order 4 acc 2 t 1 dsm 4.36512e-10 dsm_est 1.01676e-08 nsteps 20 + h 0.025 rk_type 0 order 4 acc 2 t 1.5 dsm 1.47944e-09 dsm_est 1.91745e-08 nsteps 20 + h 0.025 rk_type 0 order 4 acc 2 t 2 dsm 3.07014e-09 dsm_est 7.81488e-09 nsteps 20 + h 0.025 rk_type 0 order 4 acc 2 t 2.5 dsm 2.41009e-09 dsm_est 7.35801e-09 nsteps 20 + h 0.025 rk_type 0 order 4 acc 2 t 3 dsm 2.2919e-10 dsm_est 2.95688e-08 nsteps 20 + h 0.025 rk_type 0 order 4 acc 2 t 3.5 dsm 2.10843e-11 dsm_est 2.56198e-08 nsteps 20 + h 0.025 rk_type 0 order 4 acc 2 t 4 dsm 4.85414e-11 dsm_est 9.1097e-09 nsteps 20 + h 0.025 rk_type 0 order 4 acc 2 t 4.5 dsm 1.96723e-10 dsm_est 1.8883e-09 nsteps 20 + h 0.025 rk_type 0 order 4 acc 2 t 5 dsm 8.22132e-10 dsm_est 7.19339e-09 nsteps 20 + h 0.025 rk_type 0 order 4 acc 2 t 5.5 dsm 1.54757e-09 dsm_est 1.54279e-08 nsteps 20 + h 0.025 rk_type 0 order 4 acc 2 t 6 dsm 1.4066e-09 dsm_est 2.77932e-08 nsteps 20 + h 0.025 rk_type 0 order 4 acc 2 t 6.5 dsm 1.53642e-07 dsm_est 3.43927e-06 nsteps 20 + h 0.025 rk_type 0 order 4 acc 2 t 7 dsm 4.94724e-06 dsm_est 0.000536526 nsteps 20 + h 0.025 rk_type 0 order 4 acc 2 t 7.5 dsm 4.18294e-08 dsm_est 2.81303e-05 nsteps 20 + h 0.025 rk_type 0 order 4 acc 2 t 8 dsm 1.04878e-08 dsm_est 1.09073e-06 nsteps 20 + h 0.025 rk_type 0 order 4 acc 2 t 8.5 dsm 2.79702e-09 dsm_est 2.81903e-07 nsteps 20 + h 0.025 rk_type 0 order 4 acc 2 t 9 dsm 1.60168e-09 dsm_est 1.22752e-07 nsteps 20 + h 0.025 rk_type 0 order 4 acc 2 t 9.5 dsm 1.4347e-09 dsm_est 3.48997e-07 nsteps 20 + h 0.025 rk_type 0 order 4 acc 2 t 10 dsm 5.54538e-10 dsm_est 1.97881e-07 nsteps 20 h 0.025 rk_type 0 order 4 acc 3 t 0.5 dsm 2.02741e-07 dsm_est 0.0135207 nsteps 20 h 0.025 rk_type 0 order 4 acc 3 t 1 dsm 4.36512e-10 dsm_est 5.08381e-10 nsteps 20 h 0.025 rk_type 0 order 4 acc 3 t 1.5 dsm 1.47944e-09 dsm_est 9.58723e-10 nsteps 20 @@ -87,6 +107,26 @@ Fixed-step runs: h 0.00625 rk_type 0 order 4 acc 1 t 9 dsm 2.94415e-11 dsm_est 5.60347e-11 nsteps 80 h 0.00625 rk_type 0 order 4 acc 1 t 9.5 dsm 1.42778e-11 dsm_est 7.48066e-11 nsteps 80 h 0.00625 rk_type 0 order 4 acc 1 t 10 dsm 4.93463e-12 dsm_est 6.33468e-11 nsteps 80 + h 0.00625 rk_type 0 order 4 acc 2 t 0.5 dsm 2.01526e-08 dsm_est 0.141954 nsteps 80 + h 0.00625 rk_type 0 order 4 acc 2 t 1 dsm 9.02564e-12 dsm_est 1.9256e-10 nsteps 80 + h 0.00625 rk_type 0 order 4 acc 2 t 1.5 dsm 6.18719e-12 dsm_est 3.09827e-10 nsteps 80 + h 0.00625 rk_type 0 order 4 acc 2 t 2 dsm 1.21264e-11 dsm_est 1.26799e-10 nsteps 80 + h 0.00625 rk_type 0 order 4 acc 2 t 2.5 dsm 9.39437e-12 dsm_est 1.15943e-10 nsteps 80 + h 0.00625 rk_type 0 order 4 acc 2 t 3 dsm 6.39567e-12 dsm_est 4.63554e-10 nsteps 80 + h 0.00625 rk_type 0 order 4 acc 2 t 3.5 dsm 4.31321e-12 dsm_est 4.07949e-10 nsteps 80 + h 0.00625 rk_type 0 order 4 acc 2 t 4 dsm 5.26346e-12 dsm_est 1.47561e-10 nsteps 80 + h 0.00625 rk_type 0 order 4 acc 2 t 4.5 dsm 3.00982e-11 dsm_est 3.61156e-11 nsteps 80 + h 0.00625 rk_type 0 order 4 acc 2 t 5 dsm 3.35644e-12 dsm_est 1.54366e-10 nsteps 80 + h 0.00625 rk_type 0 order 4 acc 2 t 5.5 dsm 1.37915e-11 dsm_est 2.39536e-10 nsteps 80 + h 0.00625 rk_type 0 order 4 acc 2 t 6 dsm 9.91766e-11 dsm_est 4.28866e-10 nsteps 80 + h 0.00625 rk_type 0 order 4 acc 2 t 6.5 dsm 3.01672e-09 dsm_est 5.01151e-08 nsteps 80 + h 0.00625 rk_type 0 order 4 acc 2 t 7 dsm 1.77811e-08 dsm_est 9.3156e-06 nsteps 80 + h 0.00625 rk_type 0 order 4 acc 2 t 7.5 dsm 7.42418e-10 dsm_est 5.06067e-07 nsteps 80 + h 0.00625 rk_type 0 order 4 acc 2 t 8 dsm 3.89202e-10 dsm_est 1.79275e-08 nsteps 80 + h 0.00625 rk_type 0 order 4 acc 2 t 8.5 dsm 3.7018e-11 dsm_est 4.65518e-09 nsteps 80 + h 0.00625 rk_type 0 order 4 acc 2 t 9 dsm 2.94415e-11 dsm_est 1.94773e-09 nsteps 80 + h 0.00625 rk_type 0 order 4 acc 2 t 9.5 dsm 1.42778e-11 dsm_est 5.55728e-09 nsteps 80 + h 0.00625 rk_type 0 order 4 acc 2 t 10 dsm 4.93463e-12 dsm_est 3.15451e-09 nsteps 80 h 0.00625 rk_type 0 order 4 acc 3 t 0.5 dsm 2.01526e-08 dsm_est 0.00177442 nsteps 80 h 0.00625 rk_type 0 order 4 acc 3 t 1 dsm 9.02564e-12 dsm_est 2.40701e-12 nsteps 80 h 0.00625 rk_type 0 order 4 acc 3 t 1.5 dsm 6.18719e-12 dsm_est 3.87284e-12 nsteps 80 @@ -147,6 +187,26 @@ Fixed-step runs: h 0.0015625 rk_type 0 order 4 acc 1 t 9 dsm 2.4955e-11 dsm_est 5.0593e-13 nsteps 320 h 0.0015625 rk_type 0 order 4 acc 1 t 9.5 dsm 1.29649e-11 dsm_est 4.22112e-12 nsteps 320 h 0.0015625 rk_type 0 order 4 acc 1 t 10 dsm 4.44459e-12 dsm_est 2.19913e-12 nsteps 320 + h 0.0015625 rk_type 0 order 4 acc 2 t 0.5 dsm 1.12995e-09 dsm_est 0.0169353 nsteps 320 + h 0.0015625 rk_type 0 order 4 acc 2 t 1 dsm 8.83314e-12 dsm_est 6.94907e-12 nsteps 320 + h 0.0015625 rk_type 0 order 4 acc 2 t 1.5 dsm 1.84069e-12 dsm_est 6.39115e-12 nsteps 320 + h 0.0015625 rk_type 0 order 4 acc 2 t 2 dsm 2.23198e-13 dsm_est 2.81498e-12 nsteps 320 + h 0.0015625 rk_type 0 order 4 acc 2 t 2.5 dsm 5.57615e-13 dsm_est 2.25223e-12 nsteps 320 + h 0.0015625 rk_type 0 order 4 acc 2 t 3 dsm 6.33215e-12 dsm_est 7.33588e-12 nsteps 320 + h 0.0015625 rk_type 0 order 4 acc 2 t 3.5 dsm 4.31345e-12 dsm_est 7.40715e-12 nsteps 320 + h 0.0015625 rk_type 0 order 4 acc 2 t 4 dsm 5.25911e-12 dsm_est 3.01034e-12 nsteps 320 + h 0.0015625 rk_type 0 order 4 acc 2 t 4.5 dsm 3.00873e-11 dsm_est 1.41635e-12 nsteps 320 + h 0.0015625 rk_type 0 order 4 acc 2 t 5 dsm 1.04948e-12 dsm_est 7.0874e-12 nsteps 320 + h 0.0015625 rk_type 0 order 4 acc 2 t 5.5 dsm 6.97828e-12 dsm_est 3.92895e-12 nsteps 320 + h 0.0015625 rk_type 0 order 4 acc 2 t 6 dsm 5.98205e-11 dsm_est 8.03594e-12 nsteps 320 + h 0.0015625 rk_type 0 order 4 acc 2 t 6.5 dsm 1.87435e-11 dsm_est 7.78898e-10 nsteps 320 + h 0.0015625 rk_type 0 order 4 acc 2 t 7 dsm 6.39659e-10 dsm_est 1.4936e-07 nsteps 320 + h 0.0015625 rk_type 0 order 4 acc 2 t 7.5 dsm 1.83962e-11 dsm_est 8.20268e-09 nsteps 320 + h 0.0015625 rk_type 0 order 4 acc 2 t 8 dsm 1.77418e-10 dsm_est 2.85684e-10 nsteps 320 + h 0.0015625 rk_type 0 order 4 acc 2 t 8.5 dsm 2.78724e-12 dsm_est 1.0185e-10 nsteps 320 + h 0.0015625 rk_type 0 order 4 acc 2 t 9 dsm 2.4955e-11 dsm_est 3.17765e-11 nsteps 320 + h 0.0015625 rk_type 0 order 4 acc 2 t 9.5 dsm 1.29649e-11 dsm_est 9.11804e-11 nsteps 320 + h 0.0015625 rk_type 0 order 4 acc 2 t 10 dsm 4.44459e-12 dsm_est 5.14784e-11 nsteps 320 h 0.0015625 rk_type 0 order 4 acc 3 t 0.5 dsm 1.12995e-09 dsm_est 5.29229e-05 nsteps 320 h 0.0015625 rk_type 0 order 4 acc 3 t 1 dsm 8.83314e-12 dsm_est 2.17158e-14 nsteps 320 h 0.0015625 rk_type 0 order 4 acc 3 t 1.5 dsm 1.84069e-12 dsm_est 1.99723e-14 nsteps 320 @@ -207,6 +267,26 @@ Fixed-step runs: h 0.000390625 rk_type 0 order 4 acc 1 t 9 dsm 2.496e-11 dsm_est 1.06333e-14 nsteps 1281 h 0.000390625 rk_type 0 order 4 acc 1 t 9.5 dsm 1.2967e-11 dsm_est 9.36985e-14 nsteps 1281 h 0.000390625 rk_type 0 order 4 acc 1 t 10 dsm 4.44606e-12 dsm_est 4.86957e-14 nsteps 1281 + h 0.000390625 rk_type 0 order 4 acc 2 t 0.5 dsm 4.75504e-11 dsm_est 0.000554502 nsteps 1281 + h 0.000390625 rk_type 0 order 4 acc 2 t 1 dsm 8.83253e-12 dsm_est 2.11629e-13 nsteps 1281 + h 0.000390625 rk_type 0 order 4 acc 2 t 1.5 dsm 1.8399e-12 dsm_est 1.46902e-13 nsteps 1280 + h 0.000390625 rk_type 0 order 4 acc 2 t 2 dsm 2.21232e-13 dsm_est 8.08167e-14 nsteps 1280 + h 0.000390625 rk_type 0 order 4 acc 2 t 2.5 dsm 5.57029e-13 dsm_est 6.12168e-14 nsteps 1280 + h 0.000390625 rk_type 0 order 4 acc 2 t 3 dsm 6.33194e-12 dsm_est 1.25998e-13 nsteps 1280 + h 0.000390625 rk_type 0 order 4 acc 2 t 3.5 dsm 4.31407e-12 dsm_est 1.46827e-13 nsteps 1280 + h 0.000390625 rk_type 0 order 4 acc 2 t 4 dsm 5.25853e-12 dsm_est 8.29578e-14 nsteps 1280 + h 0.000390625 rk_type 0 order 4 acc 2 t 4.5 dsm 3.00881e-11 dsm_est 7.37135e-14 nsteps 1281 + h 0.000390625 rk_type 0 order 4 acc 2 t 5 dsm 1.04964e-12 dsm_est 2.31694e-13 nsteps 1281 + h 0.000390625 rk_type 0 order 4 acc 2 t 5.5 dsm 6.97849e-12 dsm_est 8.07729e-14 nsteps 1281 + h 0.000390625 rk_type 0 order 4 acc 2 t 6 dsm 5.9817e-11 dsm_est 1.6949e-13 nsteps 1281 + h 0.000390625 rk_type 0 order 4 acc 2 t 6.5 dsm 1.43381e-11 dsm_est 1.23339e-11 nsteps 1281 + h 0.000390625 rk_type 0 order 4 acc 2 t 7 dsm 2.94602e-12 dsm_est 2.35276e-09 nsteps 1281 + h 0.000390625 rk_type 0 order 4 acc 2 t 7.5 dsm 1.82124e-11 dsm_est 1.29354e-10 nsteps 1281 + h 0.000390625 rk_type 0 order 4 acc 2 t 8 dsm 1.77421e-10 dsm_est 4.5438e-12 nsteps 1281 + h 0.000390625 rk_type 0 order 4 acc 2 t 8.5 dsm 2.81466e-12 dsm_est 2.19649e-12 nsteps 1281 + h 0.000390625 rk_type 0 order 4 acc 2 t 9 dsm 2.496e-11 dsm_est 5.49027e-13 nsteps 1281 + h 0.000390625 rk_type 0 order 4 acc 2 t 9.5 dsm 1.2967e-11 dsm_est 1.50929e-12 nsteps 1281 + h 0.000390625 rk_type 0 order 4 acc 2 t 10 dsm 4.44606e-12 dsm_est 8.49403e-13 nsteps 1281 h 0.000390625 rk_type 0 order 4 acc 3 t 0.5 dsm 4.75504e-11 dsm_est 4.32867e-07 nsteps 1281 h 0.000390625 rk_type 0 order 4 acc 3 t 1 dsm 8.83253e-12 dsm_est 1.65206e-16 nsteps 1281 h 0.000390625 rk_type 0 order 4 acc 3 t 1.5 dsm 1.8399e-12 dsm_est 1.14767e-16 nsteps 1280 diff --git a/test/unit_tests/arkode/CXX_serial/ark_test_accumerror_brusselator_20_3_1.out b/test/unit_tests/arkode/CXX_serial/ark_test_accumerror_brusselator_20_3_1.out index e3774e291e..ab7079a647 100644 --- a/test/unit_tests/arkode/CXX_serial/ark_test_accumerror_brusselator_20_3_1.out +++ b/test/unit_tests/arkode/CXX_serial/ark_test_accumerror_brusselator_20_3_1.out @@ -27,6 +27,26 @@ Adaptive-step runs: rtol 0.01 rk_type 1 order 3 acc 1 t 9 dsm 0.00530688 dsm_est 0.00991151 nsteps 460 rtol 0.01 rk_type 1 order 3 acc 1 t 9.5 dsm 0.00453492 dsm_est 0.00996905 nsteps 461 rtol 0.01 rk_type 1 order 3 acc 1 t 10 dsm 0.000530102 dsm_est 0.00998737 nsteps 461 + rtol 0.01 rk_type 1 order 3 acc 2 t 0.5 dsm 0.00199866 dsm_est 2.09808 nsteps 492 + rtol 0.01 rk_type 1 order 3 acc 2 t 1 dsm 0.00148824 dsm_est 1.89996 nsteps 473 + rtol 0.01 rk_type 1 order 3 acc 2 t 1.5 dsm 0.00330184 dsm_est 1.97327 nsteps 459 + rtol 0.01 rk_type 1 order 3 acc 2 t 2 dsm 0.000346469 dsm_est 1.9 nsteps 450 + rtol 0.01 rk_type 1 order 3 acc 2 t 2.5 dsm 0.0103541 dsm_est 1.68792 nsteps 430 + rtol 0.01 rk_type 1 order 3 acc 2 t 3 dsm 0.0108871 dsm_est 1.87188 nsteps 447 + rtol 0.01 rk_type 1 order 3 acc 2 t 3.5 dsm 0.00245302 dsm_est 1.9467 nsteps 465 + rtol 0.01 rk_type 1 order 3 acc 2 t 4 dsm 0.00613073 dsm_est 1.9405 nsteps 464 + rtol 0.01 rk_type 1 order 3 acc 2 t 4.5 dsm 0.00368671 dsm_est 1.94315 nsteps 464 + rtol 0.01 rk_type 1 order 3 acc 2 t 5 dsm 0.000382639 dsm_est 1.83475 nsteps 466 + rtol 0.01 rk_type 1 order 3 acc 2 t 5.5 dsm 0.00138001 dsm_est 1.86654 nsteps 443 + rtol 0.01 rk_type 1 order 3 acc 2 t 6 dsm 0.00204504 dsm_est 1.9419 nsteps 463 + rtol 0.01 rk_type 1 order 3 acc 2 t 6.5 dsm 0.00544154 dsm_est 1.96228 nsteps 465 + rtol 0.01 rk_type 1 order 3 acc 2 t 7 dsm 0.00167909 dsm_est 1.90643 nsteps 459 + rtol 0.01 rk_type 1 order 3 acc 2 t 7.5 dsm 0.00762228 dsm_est 1.79247 nsteps 464 + rtol 0.01 rk_type 1 order 3 acc 2 t 8 dsm 0.00815849 dsm_est 1.84371 nsteps 463 + rtol 0.01 rk_type 1 order 3 acc 2 t 8.5 dsm 0.00479833 dsm_est 1.97902 nsteps 463 + rtol 0.01 rk_type 1 order 3 acc 2 t 9 dsm 0.00530688 dsm_est 1.94856 nsteps 460 + rtol 0.01 rk_type 1 order 3 acc 2 t 9.5 dsm 0.00453492 dsm_est 1.91705 nsteps 461 + rtol 0.01 rk_type 1 order 3 acc 2 t 10 dsm 0.000530102 dsm_est 1.91042 nsteps 461 rtol 0.01 rk_type 1 order 3 acc 3 t 0.5 dsm 0.00199866 dsm_est 0.00426439 nsteps 492 rtol 0.01 rk_type 1 order 3 acc 3 t 1 dsm 0.00148824 dsm_est 0.00401684 nsteps 473 rtol 0.01 rk_type 1 order 3 acc 3 t 1.5 dsm 0.00330184 dsm_est 0.00429906 nsteps 459 @@ -67,6 +87,26 @@ Adaptive-step runs: rtol 0.0001 rk_type 1 order 3 acc 1 t 9 dsm 9.3894e-06 dsm_est 9.91602e-05 nsteps 475 rtol 0.0001 rk_type 1 order 3 acc 1 t 9.5 dsm 1.95141e-05 dsm_est 9.49246e-05 nsteps 482 rtol 0.0001 rk_type 1 order 3 acc 1 t 10 dsm 2.83938e-05 dsm_est 9.5044e-05 nsteps 479 + rtol 0.0001 rk_type 1 order 3 acc 2 t 0.5 dsm 4.52215e-05 dsm_est 0.0204462 nsteps 501 + rtol 0.0001 rk_type 1 order 3 acc 2 t 1 dsm 1.81631e-05 dsm_est 0.0195291 nsteps 474 + rtol 0.0001 rk_type 1 order 3 acc 2 t 1.5 dsm 2.77186e-05 dsm_est 0.018621 nsteps 474 + rtol 0.0001 rk_type 1 order 3 acc 2 t 2 dsm 1.52803e-05 dsm_est 0.0193526 nsteps 470 + rtol 0.0001 rk_type 1 order 3 acc 2 t 2.5 dsm 4.78098e-05 dsm_est 0.0188743 nsteps 464 + rtol 0.0001 rk_type 1 order 3 acc 2 t 3 dsm 2.25476e-05 dsm_est 0.0188411 nsteps 465 + rtol 0.0001 rk_type 1 order 3 acc 2 t 3.5 dsm 5.07755e-05 dsm_est 0.0186928 nsteps 474 + rtol 0.0001 rk_type 1 order 3 acc 2 t 4 dsm 2.29469e-05 dsm_est 0.0192501 nsteps 474 + rtol 0.0001 rk_type 1 order 3 acc 2 t 4.5 dsm 3.88359e-05 dsm_est 0.0190057 nsteps 470 + rtol 0.0001 rk_type 1 order 3 acc 2 t 5 dsm 1.51443e-05 dsm_est 0.0192704 nsteps 469 + rtol 0.0001 rk_type 1 order 3 acc 2 t 5.5 dsm 1.12906e-05 dsm_est 0.0189727 nsteps 470 + rtol 0.0001 rk_type 1 order 3 acc 2 t 6 dsm 2.05734e-05 dsm_est 0.0185915 nsteps 474 + rtol 0.0001 rk_type 1 order 3 acc 2 t 6.5 dsm 2.51686e-05 dsm_est 0.0195025 nsteps 481 + rtol 0.0001 rk_type 1 order 3 acc 2 t 7 dsm 6.45125e-05 dsm_est 0.019722 nsteps 481 + rtol 0.0001 rk_type 1 order 3 acc 2 t 7.5 dsm 6.30239e-05 dsm_est 0.0180237 nsteps 475 + rtol 0.0001 rk_type 1 order 3 acc 2 t 8 dsm 2.85855e-05 dsm_est 0.019557 nsteps 478 + rtol 0.0001 rk_type 1 order 3 acc 2 t 8.5 dsm 4.15619e-05 dsm_est 0.0195763 nsteps 480 + rtol 0.0001 rk_type 1 order 3 acc 2 t 9 dsm 9.3894e-06 dsm_est 0.0195109 nsteps 475 + rtol 0.0001 rk_type 1 order 3 acc 2 t 9.5 dsm 1.95141e-05 dsm_est 0.0192328 nsteps 482 + rtol 0.0001 rk_type 1 order 3 acc 2 t 10 dsm 2.83938e-05 dsm_est 0.0195692 nsteps 479 rtol 0.0001 rk_type 1 order 3 acc 3 t 0.5 dsm 4.52215e-05 dsm_est 4.08107e-05 nsteps 501 rtol 0.0001 rk_type 1 order 3 acc 3 t 1 dsm 1.81631e-05 dsm_est 4.12007e-05 nsteps 474 rtol 0.0001 rk_type 1 order 3 acc 3 t 1.5 dsm 2.77186e-05 dsm_est 3.92848e-05 nsteps 474 @@ -107,6 +147,26 @@ Adaptive-step runs: rtol 1e-06 rk_type 1 order 3 acc 1 t 9 dsm 2.03978e-07 dsm_est 9.47478e-07 nsteps 468 rtol 1e-06 rk_type 1 order 3 acc 1 t 9.5 dsm 2.77163e-07 dsm_est 9.49943e-07 nsteps 475 rtol 1e-06 rk_type 1 order 3 acc 1 t 10 dsm 4.2482e-07 dsm_est 9.47165e-07 nsteps 476 + rtol 1e-06 rk_type 1 order 3 acc 2 t 0.5 dsm 6.49367e-08 dsm_est 0.000190015 nsteps 550 + rtol 1e-06 rk_type 1 order 3 acc 2 t 1 dsm 5.83524e-07 dsm_est 0.000191707 nsteps 488 + rtol 1e-06 rk_type 1 order 3 acc 2 t 1.5 dsm 2.01442e-08 dsm_est 0.000154747 nsteps 491 + rtol 1e-06 rk_type 1 order 3 acc 2 t 2 dsm 6.89174e-08 dsm_est 0.000191171 nsteps 485 + rtol 1e-06 rk_type 1 order 3 acc 2 t 2.5 dsm 3.25214e-07 dsm_est 0.000189145 nsteps 463 + rtol 1e-06 rk_type 1 order 3 acc 2 t 3 dsm 3.48745e-07 dsm_est 0.000193684 nsteps 481 + rtol 1e-06 rk_type 1 order 3 acc 2 t 3.5 dsm 1.27971e-06 dsm_est 0.000198922 nsteps 484 + rtol 1e-06 rk_type 1 order 3 acc 2 t 4 dsm 5.22124e-07 dsm_est 0.000197072 nsteps 485 + rtol 1e-06 rk_type 1 order 3 acc 2 t 4.5 dsm 6.25795e-07 dsm_est 0.000191436 nsteps 486 + rtol 1e-06 rk_type 1 order 3 acc 2 t 5 dsm 5.82624e-07 dsm_est 0.000196185 nsteps 487 + rtol 1e-06 rk_type 1 order 3 acc 2 t 5.5 dsm 5.29296e-07 dsm_est 0.000199124 nsteps 483 + rtol 1e-06 rk_type 1 order 3 acc 2 t 6 dsm 3.47222e-07 dsm_est 0.000199936 nsteps 484 + rtol 1e-06 rk_type 1 order 3 acc 2 t 6.5 dsm 8.05504e-07 dsm_est 0.000193196 nsteps 477 + rtol 1e-06 rk_type 1 order 3 acc 2 t 7 dsm 4.05624e-08 dsm_est 0.000198041 nsteps 487 + rtol 1e-06 rk_type 1 order 3 acc 2 t 7.5 dsm 7.28832e-08 dsm_est 0.000199497 nsteps 487 + rtol 1e-06 rk_type 1 order 3 acc 2 t 8 dsm 9.01356e-07 dsm_est 0.000197732 nsteps 485 + rtol 1e-06 rk_type 1 order 3 acc 2 t 8.5 dsm 9.82212e-07 dsm_est 0.000189126 nsteps 489 + rtol 1e-06 rk_type 1 order 3 acc 2 t 9 dsm 2.03978e-07 dsm_est 0.000189873 nsteps 468 + rtol 1e-06 rk_type 1 order 3 acc 2 t 9.5 dsm 2.77163e-07 dsm_est 0.000192779 nsteps 475 + rtol 1e-06 rk_type 1 order 3 acc 2 t 10 dsm 4.2482e-07 dsm_est 0.000186705 nsteps 476 rtol 1e-06 rk_type 1 order 3 acc 3 t 0.5 dsm 6.49367e-08 dsm_est 3.45481e-07 nsteps 550 rtol 1e-06 rk_type 1 order 3 acc 3 t 1 dsm 5.83524e-07 dsm_est 3.92843e-07 nsteps 488 rtol 1e-06 rk_type 1 order 3 acc 3 t 1.5 dsm 2.01442e-08 dsm_est 3.15167e-07 nsteps 491 diff --git a/test/unit_tests/arkode/CXX_serial/ark_test_accumerror_brusselator_20_5_0.out b/test/unit_tests/arkode/CXX_serial/ark_test_accumerror_brusselator_20_5_0.out index d010eeef4b..4fb78b4cf9 100644 --- a/test/unit_tests/arkode/CXX_serial/ark_test_accumerror_brusselator_20_5_0.out +++ b/test/unit_tests/arkode/CXX_serial/ark_test_accumerror_brusselator_20_5_0.out @@ -27,6 +27,26 @@ Adaptive-step runs: rtol 0.01 rk_type 0 order 5 acc 1 t 9 dsm 0.00058073 dsm_est 4.52926e-06 nsteps 6 rtol 0.01 rk_type 0 order 5 acc 1 t 9.5 dsm 6.70214e-05 dsm_est 2.50118e-06 nsteps 6 rtol 0.01 rk_type 0 order 5 acc 1 t 10 dsm 0.000490488 dsm_est 4.64334e-06 nsteps 6 + rtol 0.01 rk_type 0 order 5 acc 2 t 0.5 dsm 7.48644e-05 dsm_est 5.4592e-05 nsteps 9 + rtol 0.01 rk_type 0 order 5 acc 2 t 1 dsm 0.000110257 dsm_est 2.23312e-06 nsteps 5 + rtol 0.01 rk_type 0 order 5 acc 2 t 1.5 dsm 0.00132404 dsm_est 2.37777e-06 nsteps 6 + rtol 0.01 rk_type 0 order 5 acc 2 t 2 dsm 0.00110273 dsm_est 8.17396e-07 nsteps 6 + rtol 0.01 rk_type 0 order 5 acc 2 t 2.5 dsm 6.10485e-05 dsm_est 3.28054e-07 nsteps 6 + rtol 0.01 rk_type 0 order 5 acc 2 t 3 dsm 0.000275174 dsm_est 6.76339e-07 nsteps 6 + rtol 0.01 rk_type 0 order 5 acc 2 t 3.5 dsm 0.00032811 dsm_est 1.69526e-06 nsteps 6 + rtol 0.01 rk_type 0 order 5 acc 2 t 4 dsm 7.35974e-05 dsm_est 4.93897e-07 nsteps 6 + rtol 0.01 rk_type 0 order 5 acc 2 t 4.5 dsm 0.000394423 dsm_est 1.74465e-06 nsteps 6 + rtol 0.01 rk_type 0 order 5 acc 2 t 5 dsm 4.44693e-05 dsm_est 4.91596e-07 nsteps 6 + rtol 0.01 rk_type 0 order 5 acc 2 t 5.5 dsm 0.000153383 dsm_est 6.90221e-07 nsteps 5 + rtol 0.01 rk_type 0 order 5 acc 2 t 6 dsm 0.00039377 dsm_est 4.6301e-06 nsteps 6 + rtol 0.01 rk_type 0 order 5 acc 2 t 6.5 dsm 0.000506258 dsm_est 1.7875e-06 nsteps 6 + rtol 0.01 rk_type 0 order 5 acc 2 t 7 dsm 0.00148699 dsm_est 7.28369e-05 nsteps 12 + rtol 0.01 rk_type 0 order 5 acc 2 t 7.5 dsm 0.000435975 dsm_est 0.000234031 nsteps 4 + rtol 0.01 rk_type 0 order 5 acc 2 t 8 dsm 0.000824606 dsm_est 2.56036e-05 nsteps 7 + rtol 0.01 rk_type 0 order 5 acc 2 t 8.5 dsm 0.00100819 dsm_est 1.09812e-05 nsteps 6 + rtol 0.01 rk_type 0 order 5 acc 2 t 9 dsm 0.00058073 dsm_est 4.93642e-06 nsteps 6 + rtol 0.01 rk_type 0 order 5 acc 2 t 9.5 dsm 6.70214e-05 dsm_est 2.55332e-06 nsteps 6 + rtol 0.01 rk_type 0 order 5 acc 2 t 10 dsm 0.000490488 dsm_est 4.66143e-06 nsteps 6 rtol 0.01 rk_type 0 order 5 acc 3 t 0.5 dsm 7.48644e-05 dsm_est 6.06577e-06 nsteps 9 rtol 0.01 rk_type 0 order 5 acc 3 t 1 dsm 0.000110257 dsm_est 4.46624e-07 nsteps 5 rtol 0.01 rk_type 0 order 5 acc 3 t 1.5 dsm 0.00132404 dsm_est 3.96295e-07 nsteps 6 @@ -67,6 +87,26 @@ Adaptive-step runs: rtol 0.0001 rk_type 0 order 5 acc 1 t 9 dsm 1.10466e-05 dsm_est 2.02617e-08 nsteps 4 rtol 0.0001 rk_type 0 order 5 acc 1 t 9.5 dsm 1.12334e-05 dsm_est 1.10517e-07 nsteps 4 rtol 0.0001 rk_type 0 order 5 acc 1 t 10 dsm 9.05222e-07 dsm_est 1.64841e-08 nsteps 4 + rtol 0.0001 rk_type 0 order 5 acc 2 t 0.5 dsm 1.9124e-05 dsm_est 5.71969e-06 nsteps 13 + rtol 0.0001 rk_type 0 order 5 acc 2 t 1 dsm 1.46639e-06 dsm_est 2.99989e-08 nsteps 3 + rtol 0.0001 rk_type 0 order 5 acc 2 t 1.5 dsm 1.49779e-06 dsm_est 2.89735e-08 nsteps 3 + rtol 0.0001 rk_type 0 order 5 acc 2 t 2 dsm 2.48711e-06 dsm_est 5.35748e-08 nsteps 3 + rtol 0.0001 rk_type 0 order 5 acc 2 t 2.5 dsm 8.68487e-07 dsm_est 1.05987e-08 nsteps 3 + rtol 0.0001 rk_type 0 order 5 acc 2 t 3 dsm 4.6854e-06 dsm_est 3.58967e-08 nsteps 4 + rtol 0.0001 rk_type 0 order 5 acc 2 t 3.5 dsm 4.86491e-06 dsm_est 1.53193e-08 nsteps 4 + rtol 0.0001 rk_type 0 order 5 acc 2 t 4 dsm 9.38226e-06 dsm_est 1.14771e-09 nsteps 3 + rtol 0.0001 rk_type 0 order 5 acc 2 t 4.5 dsm 3.64804e-06 dsm_est 8.14332e-10 nsteps 3 + rtol 0.0001 rk_type 0 order 5 acc 2 t 5 dsm 1.20837e-06 dsm_est 1.18132e-08 nsteps 3 + rtol 0.0001 rk_type 0 order 5 acc 2 t 5.5 dsm 1.96373e-05 dsm_est 1.51402e-08 nsteps 3 + rtol 0.0001 rk_type 0 order 5 acc 2 t 6 dsm 6.78601e-06 dsm_est 8.14402e-08 nsteps 4 + rtol 0.0001 rk_type 0 order 5 acc 2 t 6.5 dsm 3.28653e-05 dsm_est 1.13828e-07 nsteps 8 + rtol 0.0001 rk_type 0 order 5 acc 2 t 7 dsm 1.0851e-05 dsm_est 4.33597e-06 nsteps 17 + rtol 0.0001 rk_type 0 order 5 acc 2 t 7.5 dsm 8.11463e-06 dsm_est 2.04239e-07 nsteps 13 + rtol 0.0001 rk_type 0 order 5 acc 2 t 8 dsm 1.12113e-05 dsm_est 6.62221e-08 nsteps 7 + rtol 0.0001 rk_type 0 order 5 acc 2 t 8.5 dsm 7.59151e-06 dsm_est 8.67008e-08 nsteps 5 + rtol 0.0001 rk_type 0 order 5 acc 2 t 9 dsm 1.10466e-05 dsm_est 3.06823e-08 nsteps 4 + rtol 0.0001 rk_type 0 order 5 acc 2 t 9.5 dsm 1.12334e-05 dsm_est 1.36785e-07 nsteps 4 + rtol 0.0001 rk_type 0 order 5 acc 2 t 10 dsm 9.05222e-07 dsm_est 3.2806e-08 nsteps 4 rtol 0.0001 rk_type 0 order 5 acc 3 t 0.5 dsm 1.9124e-05 dsm_est 4.39976e-07 nsteps 13 rtol 0.0001 rk_type 0 order 5 acc 3 t 1 dsm 1.46639e-06 dsm_est 9.99964e-09 nsteps 3 rtol 0.0001 rk_type 0 order 5 acc 3 t 1.5 dsm 1.49779e-06 dsm_est 9.65784e-09 nsteps 3 @@ -107,6 +147,26 @@ Adaptive-step runs: rtol 1e-06 rk_type 0 order 5 acc 1 t 9 dsm 1.33343e-07 dsm_est 8.70204e-09 nsteps 7 rtol 1e-06 rk_type 0 order 5 acc 1 t 9.5 dsm 1.44237e-07 dsm_est 1.59014e-08 nsteps 6 rtol 1e-06 rk_type 0 order 5 acc 1 t 10 dsm 1.34853e-07 dsm_est 2.74315e-08 nsteps 6 + rtol 1e-06 rk_type 0 order 5 acc 2 t 0.5 dsm 1.88136e-07 dsm_est 3.10757e-07 nsteps 20 + rtol 1e-06 rk_type 0 order 5 acc 2 t 1 dsm 3.6815e-08 dsm_est 2.85172e-09 nsteps 5 + rtol 1e-06 rk_type 0 order 5 acc 2 t 1.5 dsm 3.46973e-08 dsm_est 3.53495e-09 nsteps 7 + rtol 1e-06 rk_type 0 order 5 acc 2 t 2 dsm 2.15722e-07 dsm_est 6.21173e-09 nsteps 7 + rtol 1e-06 rk_type 0 order 5 acc 2 t 2.5 dsm 9.55646e-08 dsm_est 1.95849e-09 nsteps 7 + rtol 1e-06 rk_type 0 order 5 acc 2 t 3 dsm 1.61192e-07 dsm_est 1.42375e-08 nsteps 5 + rtol 1e-06 rk_type 0 order 5 acc 2 t 3.5 dsm 4.89781e-08 dsm_est 5.44995e-09 nsteps 5 + rtol 1e-06 rk_type 0 order 5 acc 2 t 4 dsm 2.89671e-09 dsm_est 2.05845e-10 nsteps 5 + rtol 1e-06 rk_type 0 order 5 acc 2 t 4.5 dsm 1.33856e-07 dsm_est 1.4524e-10 nsteps 4 + rtol 1e-06 rk_type 0 order 5 acc 2 t 5 dsm 1.14768e-07 dsm_est 3.97399e-09 nsteps 5 + rtol 1e-06 rk_type 0 order 5 acc 2 t 5.5 dsm 3.35877e-07 dsm_est 5.39098e-09 nsteps 7 + rtol 1e-06 rk_type 0 order 5 acc 2 t 6 dsm 3.66079e-07 dsm_est 4.54425e-09 nsteps 9 + rtol 1e-06 rk_type 0 order 5 acc 2 t 6.5 dsm 1.18284e-06 dsm_est 1.43453e-08 nsteps 13 + rtol 1e-06 rk_type 0 order 5 acc 2 t 7 dsm 6.15151e-07 dsm_est 3.71172e-07 nsteps 32 + rtol 1e-06 rk_type 0 order 5 acc 2 t 7.5 dsm 7.6586e-08 dsm_est 1.05078e-08 nsteps 17 + rtol 1e-06 rk_type 0 order 5 acc 2 t 8 dsm 4.14322e-07 dsm_est 1.80819e-09 nsteps 13 + rtol 1e-06 rk_type 0 order 5 acc 2 t 8.5 dsm 2.50606e-07 dsm_est 1.87833e-08 nsteps 9 + rtol 1e-06 rk_type 0 order 5 acc 2 t 9 dsm 1.33343e-07 dsm_est 1.22048e-08 nsteps 7 + rtol 1e-06 rk_type 0 order 5 acc 2 t 9.5 dsm 1.44237e-07 dsm_est 3.40516e-08 nsteps 6 + rtol 1e-06 rk_type 0 order 5 acc 2 t 10 dsm 1.34853e-07 dsm_est 3.35247e-08 nsteps 6 rtol 1e-06 rk_type 0 order 5 acc 3 t 0.5 dsm 1.88136e-07 dsm_est 1.55378e-08 nsteps 20 rtol 1e-06 rk_type 0 order 5 acc 3 t 1 dsm 3.6815e-08 dsm_est 5.70344e-10 nsteps 5 rtol 1e-06 rk_type 0 order 5 acc 3 t 1.5 dsm 3.46973e-08 dsm_est 5.04993e-10 nsteps 7 diff --git a/test/unit_tests/arkode/CXX_serial/ark_test_accumerror_kpr.cpp b/test/unit_tests/arkode/CXX_serial/ark_test_accumerror_kpr.cpp index 8af02c6ce8..b5bf8f48ae 100644 --- a/test/unit_tests/arkode/CXX_serial/ark_test_accumerror_kpr.cpp +++ b/test/unit_tests/arkode/CXX_serial/ark_test_accumerror_kpr.cpp @@ -350,7 +350,8 @@ static int adaptive_run(void* arkode_mem, N_Vector y, sunrealtype T0, sunrealtype abstol = SUN_RCONST(1.e-12); vector rtols = {SUN_RCONST(1.e-2), SUN_RCONST(1.e-4), SUN_RCONST(1.e-6)}; - vector accum_types = {ARK_ACCUMERROR_MAX, ARK_ACCUMERROR_AVG}; + vector accum_types = {ARK_ACCUMERROR_MAX, ARK_ACCUMERROR_SUM, + ARK_ACCUMERROR_AVG}; vector dsm(udata.Npart); vector dsm_est(udata.Npart); vector Nsteps(udata.Npart); @@ -449,7 +450,8 @@ static int fixed_run(void* arkode_mem, N_Vector y, sunrealtype T0, sunrealtype hmax = (Tf - T0) / 1000; if (rk_type == 1) hmax = min(hmax, ONE / abs(udata.G)); vector hvals = {hmax, hmax / 4, hmax / 16, hmax / 64}; - vector accum_types = {ARK_ACCUMERROR_MAX, ARK_ACCUMERROR_AVG}; + vector accum_types = {ARK_ACCUMERROR_MAX, ARK_ACCUMERROR_SUM, + ARK_ACCUMERROR_AVG}; vector dsm(udata.Npart); vector dsm_est(udata.Npart); vector Nsteps(udata.Npart); diff --git a/test/unit_tests/arkode/CXX_serial/ark_test_accumerror_kpr_20_-4_1.out b/test/unit_tests/arkode/CXX_serial/ark_test_accumerror_kpr_20_-4_1.out index 0375dbd972..f45276a7a9 100644 --- a/test/unit_tests/arkode/CXX_serial/ark_test_accumerror_kpr_20_-4_1.out +++ b/test/unit_tests/arkode/CXX_serial/ark_test_accumerror_kpr_20_-4_1.out @@ -28,6 +28,26 @@ Fixed-step runs: h 0.005 rk_type 1 order 4 acc 1 t 4.5 dsm 7.15711e-11 dsm_est 1.1807e-08 nsteps 50 h 0.005 rk_type 1 order 4 acc 1 t 4.75 dsm 3.79788e-11 dsm_est 3.66885e-09 nsteps 50 h 0.005 rk_type 1 order 4 acc 1 t 5 dsm 4.13058e-11 dsm_est 1.68612e-09 nsteps 50 + h 0.005 rk_type 1 order 4 acc 2 t 0.25 dsm 5.99625e-11 dsm_est 6.92498e-08 nsteps 50 + h 0.005 rk_type 1 order 4 acc 2 t 0.5 dsm 1.42974e-10 dsm_est 3.44716e-07 nsteps 50 + h 0.005 rk_type 1 order 4 acc 2 t 0.75 dsm 2.42719e-10 dsm_est 1.11167e-06 nsteps 50 + h 0.005 rk_type 1 order 4 acc 2 t 1 dsm 6.83162e-10 dsm_est 3.96873e-07 nsteps 50 + h 0.005 rk_type 1 order 4 acc 2 t 1.25 dsm 3.14281e-09 dsm_est 9.51778e-06 nsteps 50 + h 0.005 rk_type 1 order 4 acc 2 t 1.5 dsm 4.52762e-09 dsm_est 4.8884e-06 nsteps 50 + h 0.005 rk_type 1 order 4 acc 2 t 1.75 dsm 4.7305e-10 dsm_est 1.58084e-05 nsteps 50 + h 0.005 rk_type 1 order 4 acc 2 t 2 dsm 1.22724e-09 dsm_est 3.22447e-06 nsteps 50 + h 0.005 rk_type 1 order 4 acc 2 t 2.25 dsm 2.1725e-10 dsm_est 1.37158e-06 nsteps 50 + h 0.005 rk_type 1 order 4 acc 2 t 2.5 dsm 1.44845e-10 dsm_est 5.71622e-07 nsteps 50 + h 0.005 rk_type 1 order 4 acc 2 t 2.75 dsm 1.45894e-10 dsm_est 2.89412e-07 nsteps 50 + h 0.005 rk_type 1 order 4 acc 2 t 3 dsm 2.11123e-10 dsm_est 2.24322e-07 nsteps 50 + h 0.005 rk_type 1 order 4 acc 2 t 3.25 dsm 2.34671e-10 dsm_est 1.10202e-07 nsteps 50 + h 0.005 rk_type 1 order 4 acc 2 t 3.5 dsm 1.99557e-10 dsm_est 2.70653e-08 nsteps 50 + h 0.005 rk_type 1 order 4 acc 2 t 3.75 dsm 1.51624e-10 dsm_est 2.01726e-08 nsteps 50 + h 0.005 rk_type 1 order 4 acc 2 t 4 dsm 9.7978e-11 dsm_est 4.76316e-08 nsteps 50 + h 0.005 rk_type 1 order 4 acc 2 t 4.25 dsm 3.36113e-11 dsm_est 1.20904e-07 nsteps 50 + h 0.005 rk_type 1 order 4 acc 2 t 4.5 dsm 7.15711e-11 dsm_est 3.7071e-07 nsteps 50 + h 0.005 rk_type 1 order 4 acc 2 t 4.75 dsm 3.79788e-11 dsm_est 8.7779e-08 nsteps 50 + h 0.005 rk_type 1 order 4 acc 2 t 5 dsm 4.13058e-11 dsm_est 6.13145e-08 nsteps 50 h 0.005 rk_type 1 order 4 acc 3 t 0.25 dsm 5.99625e-11 dsm_est 1.385e-09 nsteps 50 h 0.005 rk_type 1 order 4 acc 3 t 0.5 dsm 1.42974e-10 dsm_est 6.89431e-09 nsteps 50 h 0.005 rk_type 1 order 4 acc 3 t 0.75 dsm 2.42719e-10 dsm_est 2.22335e-08 nsteps 50 @@ -88,6 +108,26 @@ Fixed-step runs: h 0.00125 rk_type 1 order 4 acc 1 t 4.5 dsm 2.44986e-13 dsm_est 4.62152e-11 nsteps 200 h 0.00125 rk_type 1 order 4 acc 1 t 4.75 dsm 1.41286e-13 dsm_est 1.51237e-11 nsteps 200 h 0.00125 rk_type 1 order 4 acc 1 t 5 dsm 1.73009e-13 dsm_est 6.57848e-12 nsteps 200 + h 0.00125 rk_type 1 order 4 acc 2 t 0.25 dsm 2.30499e-13 dsm_est 1.08204e-09 nsteps 200 + h 0.00125 rk_type 1 order 4 acc 2 t 0.5 dsm 5.68219e-13 dsm_est 5.40888e-09 nsteps 200 + h 0.00125 rk_type 1 order 4 acc 2 t 0.75 dsm 9.09327e-13 dsm_est 1.7413e-08 nsteps 200 + h 0.00125 rk_type 1 order 4 acc 2 t 1 dsm 2.66412e-12 dsm_est 6.10198e-09 nsteps 200 + h 0.00125 rk_type 1 order 4 acc 2 t 1.25 dsm 1.30178e-11 dsm_est 1.49252e-07 nsteps 200 + h 0.00125 rk_type 1 order 4 acc 2 t 1.5 dsm 1.73534e-11 dsm_est 7.5991e-08 nsteps 200 + h 0.00125 rk_type 1 order 4 acc 2 t 1.75 dsm 3.44384e-12 dsm_est 2.47716e-07 nsteps 200 + h 0.00125 rk_type 1 order 4 acc 2 t 2 dsm 4.73982e-12 dsm_est 4.99807e-08 nsteps 200 + h 0.00125 rk_type 1 order 4 acc 2 t 2.25 dsm 8.24836e-13 dsm_est 2.14752e-08 nsteps 200 + h 0.00125 rk_type 1 order 4 acc 2 t 2.5 dsm 5.58183e-13 dsm_est 8.93029e-09 nsteps 200 + h 0.00125 rk_type 1 order 4 acc 2 t 2.75 dsm 5.66294e-13 dsm_est 4.52416e-09 nsteps 200 + h 0.00125 rk_type 1 order 4 acc 2 t 3 dsm 8.06614e-13 dsm_est 3.502e-09 nsteps 200 + h 0.00125 rk_type 1 order 4 acc 2 t 3.25 dsm 8.98387e-13 dsm_est 1.71624e-09 nsteps 200 + h 0.00125 rk_type 1 order 4 acc 2 t 3.5 dsm 7.63217e-13 dsm_est 4.19654e-10 nsteps 200 + h 0.00125 rk_type 1 order 4 acc 2 t 3.75 dsm 5.78309e-13 dsm_est 3.14069e-10 nsteps 200 + h 0.00125 rk_type 1 order 4 acc 2 t 4 dsm 3.75531e-13 dsm_est 7.43405e-10 nsteps 200 + h 0.00125 rk_type 1 order 4 acc 2 t 4.25 dsm 1.33194e-13 dsm_est 1.89465e-09 nsteps 200 + h 0.00125 rk_type 1 order 4 acc 2 t 4.5 dsm 2.44986e-13 dsm_est 5.80293e-09 nsteps 200 + h 0.00125 rk_type 1 order 4 acc 2 t 4.75 dsm 1.41286e-13 dsm_est 1.36602e-09 nsteps 200 + h 0.00125 rk_type 1 order 4 acc 2 t 5 dsm 1.73009e-13 dsm_est 9.5065e-10 nsteps 200 h 0.00125 rk_type 1 order 4 acc 3 t 0.25 dsm 2.30499e-13 dsm_est 5.41022e-12 nsteps 200 h 0.00125 rk_type 1 order 4 acc 3 t 0.5 dsm 5.68219e-13 dsm_est 2.70444e-11 nsteps 200 h 0.00125 rk_type 1 order 4 acc 3 t 0.75 dsm 9.09327e-13 dsm_est 8.70648e-11 nsteps 200 @@ -148,6 +188,26 @@ Fixed-step runs: h 0.0003125 rk_type 1 order 4 acc 1 t 4.5 dsm 1.57233e-14 dsm_est 1.80608e-13 nsteps 801 h 0.0003125 rk_type 1 order 4 acc 1 t 4.75 dsm 1.39902e-13 dsm_est 5.98529e-14 nsteps 801 h 0.0003125 rk_type 1 order 4 acc 1 t 5 dsm 7.63042e-14 dsm_est 2.56897e-14 nsteps 801 + h 0.0003125 rk_type 1 order 4 acc 2 t 0.25 dsm 9.97977e-16 dsm_est 1.6907e-11 nsteps 800 + h 0.0003125 rk_type 1 order 4 acc 2 t 0.5 dsm 7.34738e-15 dsm_est 8.45809e-11 nsteps 800 + h 0.0003125 rk_type 1 order 4 acc 2 t 0.75 dsm 1.89479e-14 dsm_est 2.72242e-10 nsteps 800 + h 0.0003125 rk_type 1 order 4 acc 2 t 1 dsm 6.41345e-15 dsm_est 9.49565e-11 nsteps 800 + h 0.0003125 rk_type 1 order 4 acc 2 t 1.25 dsm 1.49538e-13 dsm_est 2.33397e-09 nsteps 801 + h 0.0003125 rk_type 1 order 4 acc 2 t 1.5 dsm 1.0257e-13 dsm_est 1.18555e-09 nsteps 801 + h 0.0003125 rk_type 1 order 4 acc 2 t 1.75 dsm 4.74681e-14 dsm_est 3.87341e-09 nsteps 801 + h 0.0003125 rk_type 1 order 4 acc 2 t 2 dsm 3.28771e-14 dsm_est 7.79395e-10 nsteps 801 + h 0.0003125 rk_type 1 order 4 acc 2 t 2.25 dsm 2.08777e-13 dsm_est 3.3572e-10 nsteps 800 + h 0.0003125 rk_type 1 order 4 acc 2 t 2.5 dsm 1.03256e-14 dsm_est 1.39527e-10 nsteps 800 + h 0.0003125 rk_type 1 order 4 acc 2 t 2.75 dsm 1.44079e-14 dsm_est 7.06925e-11 nsteps 800 + h 0.0003125 rk_type 1 order 4 acc 2 t 3 dsm 6.86653e-14 dsm_est 5.47055e-11 nsteps 800 + h 0.0003125 rk_type 1 order 4 acc 2 t 3.25 dsm 4.56716e-14 dsm_est 2.67951e-11 nsteps 800 + h 0.0003125 rk_type 1 order 4 acc 2 t 3.5 dsm 1.14798e-14 dsm_est 6.54805e-12 nsteps 800 + h 0.0003125 rk_type 1 order 4 acc 2 t 3.75 dsm 1.10427e-14 dsm_est 4.9065e-12 nsteps 800 + h 0.0003125 rk_type 1 order 4 acc 2 t 4 dsm 5.31806e-14 dsm_est 1.16127e-11 nsteps 800 + h 0.0003125 rk_type 1 order 4 acc 2 t 4.25 dsm 2.08119e-13 dsm_est 2.96268e-11 nsteps 801 + h 0.0003125 rk_type 1 order 4 acc 2 t 4.5 dsm 1.57233e-14 dsm_est 9.07089e-11 nsteps 801 + h 0.0003125 rk_type 1 order 4 acc 2 t 4.75 dsm 1.39902e-13 dsm_est 2.13237e-11 nsteps 801 + h 0.0003125 rk_type 1 order 4 acc 2 t 5 dsm 7.63042e-14 dsm_est 1.48242e-11 nsteps 801 h 0.0003125 rk_type 1 order 4 acc 3 t 0.25 dsm 9.97977e-16 dsm_est 2.11337e-14 nsteps 800 h 0.0003125 rk_type 1 order 4 acc 3 t 0.5 dsm 7.34738e-15 dsm_est 1.05726e-13 nsteps 800 h 0.0003125 rk_type 1 order 4 acc 3 t 0.75 dsm 1.89479e-14 dsm_est 3.40303e-13 nsteps 800 @@ -208,6 +268,26 @@ Fixed-step runs: h 7.8125e-05 rk_type 1 order 4 acc 1 t 4.5 dsm 1.64627e-14 dsm_est 7.11037e-16 nsteps 3201 h 7.8125e-05 rk_type 1 order 4 acc 1 t 4.75 dsm 1.39177e-13 dsm_est 2.35957e-16 nsteps 3201 h 7.8125e-05 rk_type 1 order 4 acc 1 t 5 dsm 7.51104e-14 dsm_est 1.00425e-16 nsteps 3201 + h 7.8125e-05 rk_type 1 order 4 acc 2 t 0.25 dsm 1.20076e-14 dsm_est 2.64165e-13 nsteps 3200 + h 7.8125e-05 rk_type 1 order 4 acc 2 t 0.5 dsm 6.92895e-14 dsm_est 1.32181e-12 nsteps 3201 + h 7.8125e-05 rk_type 1 order 4 acc 2 t 0.75 dsm 7.1887e-14 dsm_est 4.25372e-12 nsteps 3200 + h 7.8125e-05 rk_type 1 order 4 acc 2 t 1 dsm 5.29714e-14 dsm_est 1.48185e-12 nsteps 3200 + h 7.8125e-05 rk_type 1 order 4 acc 2 t 1.25 dsm 4.54758e-13 dsm_est 3.64743e-11 nsteps 3201 + h 7.8125e-05 rk_type 1 order 4 acc 2 t 1.5 dsm 1.61784e-13 dsm_est 1.85159e-11 nsteps 3201 + h 7.8125e-05 rk_type 1 order 4 acc 2 t 1.75 dsm 1.4649e-13 dsm_est 6.05314e-11 nsteps 3201 + h 7.8125e-05 rk_type 1 order 4 acc 2 t 2 dsm 6.85301e-14 dsm_est 1.2171e-11 nsteps 3201 + h 7.8125e-05 rk_type 1 order 4 acc 2 t 2.25 dsm 3.74507e-13 dsm_est 5.24549e-12 nsteps 3201 + h 7.8125e-05 rk_type 1 order 4 acc 2 t 2.5 dsm 1.92671e-14 dsm_est 2.18076e-12 nsteps 3201 + h 7.8125e-05 rk_type 1 order 4 acc 2 t 2.75 dsm 1.93516e-14 dsm_est 1.10503e-12 nsteps 3201 + h 7.8125e-05 rk_type 1 order 4 acc 2 t 3 dsm 1.23711e-13 dsm_est 8.55102e-13 nsteps 3201 + h 7.8125e-05 rk_type 1 order 4 acc 2 t 3.25 dsm 8.16997e-14 dsm_est 4.18589e-13 nsteps 3201 + h 7.8125e-05 rk_type 1 order 4 acc 2 t 3.5 dsm 1.95956e-14 dsm_est 1.02298e-13 nsteps 3201 + h 7.8125e-05 rk_type 1 order 4 acc 2 t 3.75 dsm 2.16401e-14 dsm_est 7.6628e-14 nsteps 3201 + h 7.8125e-05 rk_type 1 order 4 acc 2 t 4 dsm 9.37664e-14 dsm_est 1.81659e-13 nsteps 3201 + h 7.8125e-05 rk_type 1 order 4 acc 2 t 4.25 dsm 2.10442e-13 dsm_est 4.62687e-13 nsteps 3201 + h 7.8125e-05 rk_type 1 order 4 acc 2 t 4.5 dsm 1.64627e-14 dsm_est 1.42144e-12 nsteps 3201 + h 7.8125e-05 rk_type 1 order 4 acc 2 t 4.75 dsm 1.39177e-13 dsm_est 3.32669e-13 nsteps 3201 + h 7.8125e-05 rk_type 1 order 4 acc 2 t 5 dsm 7.51104e-14 dsm_est 2.32583e-13 nsteps 3201 h 7.8125e-05 rk_type 1 order 4 acc 3 t 0.25 dsm 1.20076e-14 dsm_est 8.25514e-17 nsteps 3200 h 7.8125e-05 rk_type 1 order 4 acc 3 t 0.5 dsm 6.92895e-14 dsm_est 4.12935e-16 nsteps 3201 h 7.8125e-05 rk_type 1 order 4 acc 3 t 0.75 dsm 7.1887e-14 dsm_est 1.32929e-15 nsteps 3200 diff --git a/test/unit_tests/arkode/CXX_serial/ark_test_accumerror_kpr_20_2_0.out b/test/unit_tests/arkode/CXX_serial/ark_test_accumerror_kpr_20_2_0.out index fc1ead1041..766322cfac 100644 --- a/test/unit_tests/arkode/CXX_serial/ark_test_accumerror_kpr_20_2_0.out +++ b/test/unit_tests/arkode/CXX_serial/ark_test_accumerror_kpr_20_2_0.out @@ -28,6 +28,26 @@ Adaptive-step runs: rtol 0.01 rk_type 0 order 2 acc 1 t 4.5 dsm 0.000322019 dsm_est 0.00679423 nsteps 11 rtol 0.01 rk_type 0 order 2 acc 1 t 4.75 dsm 0.00405487 dsm_est 0.00313156 nsteps 7 rtol 0.01 rk_type 0 order 2 acc 1 t 5 dsm 0.000699178 dsm_est 0.0036148 nsteps 8 + rtol 0.01 rk_type 0 order 2 acc 2 t 0.25 dsm 5.77245e-05 dsm_est 0.0164981 nsteps 9 + rtol 0.01 rk_type 0 order 2 acc 2 t 0.5 dsm 0.00372257 dsm_est 0.0210208 nsteps 8 + rtol 0.01 rk_type 0 order 2 acc 2 t 0.75 dsm 0.000232425 dsm_est 0.0308702 nsteps 13 + rtol 0.01 rk_type 0 order 2 acc 2 t 1 dsm 0.00327055 dsm_est 0.0340018 nsteps 9 + rtol 0.01 rk_type 0 order 2 acc 2 t 1.25 dsm 0.00363058 dsm_est 0.045914 nsteps 16 + rtol 0.01 rk_type 0 order 2 acc 2 t 1.5 dsm 0.00267076 dsm_est 0.0507535 nsteps 12 + rtol 0.01 rk_type 0 order 2 acc 2 t 1.75 dsm 0.00971976 dsm_est 0.05629 nsteps 16 + rtol 0.01 rk_type 0 order 2 acc 2 t 2 dsm 0.000918207 dsm_est 0.0375381 nsteps 14 + rtol 0.01 rk_type 0 order 2 acc 2 t 2.25 dsm 0.0016944 dsm_est 0.031166 nsteps 10 + rtol 0.01 rk_type 0 order 2 acc 2 t 2.5 dsm 0.0056199 dsm_est 0.00967058 nsteps 7 + rtol 0.01 rk_type 0 order 2 acc 2 t 2.75 dsm 0.00855479 dsm_est 0.0140582 nsteps 6 + rtol 0.01 rk_type 0 order 2 acc 2 t 3 dsm 0.0023308 dsm_est 0.014547 nsteps 7 + rtol 0.01 rk_type 0 order 2 acc 2 t 3.25 dsm 0.000539467 dsm_est 0.0111796 nsteps 8 + rtol 0.01 rk_type 0 order 2 acc 2 t 3.5 dsm 0.000312605 dsm_est 0.00770553 nsteps 6 + rtol 0.01 rk_type 0 order 2 acc 2 t 3.75 dsm 0.00144605 dsm_est 0.00972643 nsteps 4 + rtol 0.01 rk_type 0 order 2 acc 2 t 4 dsm 0.00023147 dsm_est 0.00981914 nsteps 7 + rtol 0.01 rk_type 0 order 2 acc 2 t 4.25 dsm 0.00806953 dsm_est 0.0118304 nsteps 4 + rtol 0.01 rk_type 0 order 2 acc 2 t 4.5 dsm 0.000322019 dsm_est 0.0262973 nsteps 11 + rtol 0.01 rk_type 0 order 2 acc 2 t 4.75 dsm 0.00405487 dsm_est 0.00626689 nsteps 7 + rtol 0.01 rk_type 0 order 2 acc 2 t 5 dsm 0.000699178 dsm_est 0.0128716 nsteps 8 rtol 0.01 rk_type 0 order 2 acc 3 t 0.25 dsm 5.77245e-05 dsm_est 0.00183312 nsteps 9 rtol 0.01 rk_type 0 order 2 acc 3 t 0.5 dsm 0.00372257 dsm_est 0.0026276 nsteps 8 rtol 0.01 rk_type 0 order 2 acc 3 t 0.75 dsm 0.000232425 dsm_est 0.00237463 nsteps 13 @@ -68,6 +88,26 @@ Adaptive-step runs: rtol 0.0001 rk_type 0 order 2 acc 1 t 4.5 dsm 8.06381e-06 dsm_est 7.57142e-05 nsteps 60 rtol 0.0001 rk_type 0 order 2 acc 1 t 4.75 dsm 3.08146e-05 dsm_est 7.53944e-05 nsteps 36 rtol 0.0001 rk_type 0 order 2 acc 1 t 5 dsm 1.43844e-05 dsm_est 7.56604e-05 nsteps 37 + rtol 0.0001 rk_type 0 order 2 acc 2 t 0.25 dsm 7.46709e-07 dsm_est 0.00190862 nsteps 49 + rtol 0.0001 rk_type 0 order 2 acc 2 t 0.5 dsm 6.50352e-05 dsm_est 0.00204717 nsteps 42 + rtol 0.0001 rk_type 0 order 2 acc 2 t 0.75 dsm 4.48379e-06 dsm_est 0.00379996 nsteps 84 + rtol 0.0001 rk_type 0 order 2 acc 2 t 1 dsm 3.76158e-05 dsm_est 0.00364205 nsteps 61 + rtol 0.0001 rk_type 0 order 2 acc 2 t 1.25 dsm 6.82164e-05 dsm_est 0.00560546 nsteps 110 + rtol 0.0001 rk_type 0 order 2 acc 2 t 1.5 dsm 3.68171e-05 dsm_est 0.00560365 nsteps 109 + rtol 0.0001 rk_type 0 order 2 acc 2 t 1.75 dsm 2.35133e-05 dsm_est 0.00647595 nsteps 136 + rtol 0.0001 rk_type 0 order 2 acc 2 t 2 dsm 1.61655e-05 dsm_est 0.00463485 nsteps 91 + rtol 0.0001 rk_type 0 order 2 acc 2 t 2.25 dsm 6.22229e-05 dsm_est 0.00349003 nsteps 65 + rtol 0.0001 rk_type 0 order 2 acc 2 t 2.5 dsm 4.95459e-05 dsm_est 0.00168906 nsteps 38 + rtol 0.0001 rk_type 0 order 2 acc 2 t 2.75 dsm 4.09894e-05 dsm_est 0.00204891 nsteps 35 + rtol 0.0001 rk_type 0 order 2 acc 2 t 3 dsm 3.51226e-05 dsm_est 0.00157108 nsteps 41 + rtol 0.0001 rk_type 0 order 2 acc 2 t 3.25 dsm 9.918e-06 dsm_est 0.00168635 nsteps 34 + rtol 0.0001 rk_type 0 order 2 acc 2 t 3.5 dsm 6.68205e-06 dsm_est 0.00104605 nsteps 29 + rtol 0.0001 rk_type 0 order 2 acc 2 t 3.75 dsm 1.12533e-05 dsm_est 0.00113201 nsteps 22 + rtol 0.0001 rk_type 0 order 2 acc 2 t 4 dsm 4.18856e-06 dsm_est 0.00148082 nsteps 31 + rtol 0.0001 rk_type 0 order 2 acc 2 t 4.25 dsm 5.65033e-05 dsm_est 0.0013283 nsteps 27 + rtol 0.0001 rk_type 0 order 2 acc 2 t 4.5 dsm 8.06381e-06 dsm_est 0.00333997 nsteps 60 + rtol 0.0001 rk_type 0 order 2 acc 2 t 4.75 dsm 3.08146e-05 dsm_est 0.00136969 nsteps 36 + rtol 0.0001 rk_type 0 order 2 acc 2 t 5 dsm 1.43844e-05 dsm_est 0.00206727 nsteps 37 rtol 0.0001 rk_type 0 order 2 acc 3 t 0.25 dsm 7.46709e-07 dsm_est 3.89514e-05 nsteps 49 rtol 0.0001 rk_type 0 order 2 acc 3 t 0.5 dsm 6.50352e-05 dsm_est 4.87422e-05 nsteps 42 rtol 0.0001 rk_type 0 order 2 acc 3 t 0.75 dsm 4.48379e-06 dsm_est 4.52376e-05 nsteps 84 @@ -108,6 +148,26 @@ Adaptive-step runs: rtol 1e-06 rk_type 0 order 2 acc 1 t 4.5 dsm 7.4366e-08 dsm_est 7.22713e-07 nsteps 597 rtol 1e-06 rk_type 0 order 2 acc 1 t 4.75 dsm 5.08713e-07 dsm_est 8.6505e-07 nsteps 347 rtol 1e-06 rk_type 0 order 2 acc 1 t 5 dsm 1.42752e-07 dsm_est 7.22893e-07 nsteps 366 + rtol 1e-06 rk_type 0 order 2 acc 2 t 0.25 dsm 5.66725e-09 dsm_est 0.000191192 nsteps 488 + rtol 1e-06 rk_type 0 order 2 acc 2 t 0.5 dsm 9.92276e-07 dsm_est 0.000207431 nsteps 403 + rtol 1e-06 rk_type 0 order 2 acc 2 t 0.75 dsm 8.0717e-08 dsm_est 0.00038834 nsteps 823 + rtol 1e-06 rk_type 0 order 2 acc 2 t 1 dsm 5.67858e-07 dsm_est 0.000365552 nsteps 596 + rtol 1e-06 rk_type 0 order 2 acc 2 t 1.25 dsm 1.03484e-06 dsm_est 0.000558232 nsteps 1091 + rtol 1e-06 rk_type 0 order 2 acc 2 t 1.5 dsm 5.45182e-07 dsm_est 0.000561123 nsteps 1080 + rtol 1e-06 rk_type 0 order 2 acc 2 t 1.75 dsm 3.61096e-07 dsm_est 0.000646341 nsteps 1337 + rtol 1e-06 rk_type 0 order 2 acc 2 t 2 dsm 2.2003e-07 dsm_est 0.000468686 nsteps 898 + rtol 1e-06 rk_type 0 order 2 acc 2 t 2.25 dsm 9.38782e-07 dsm_est 0.00034842 nsteps 635 + rtol 1e-06 rk_type 0 order 2 acc 2 t 2.5 dsm 5.20042e-07 dsm_est 0.000167351 nsteps 372 + rtol 1e-06 rk_type 0 order 2 acc 2 t 2.75 dsm 4.66825e-07 dsm_est 0.000203788 nsteps 354 + rtol 1e-06 rk_type 0 order 2 acc 2 t 3 dsm 3.30086e-07 dsm_est 0.000158918 nsteps 409 + rtol 1e-06 rk_type 0 order 2 acc 2 t 3.25 dsm 1.19548e-07 dsm_est 0.000177948 nsteps 320 + rtol 1e-06 rk_type 0 order 2 acc 2 t 3.5 dsm 4.13474e-08 dsm_est 0.0001041 nsteps 288 + rtol 1e-06 rk_type 0 order 2 acc 2 t 3.75 dsm 1.02293e-07 dsm_est 0.000113361 nsteps 225 + rtol 1e-06 rk_type 0 order 2 acc 2 t 4 dsm 3.98477e-08 dsm_est 0.000151291 nsteps 304 + rtol 1e-06 rk_type 0 order 2 acc 2 t 4.25 dsm 7.93335e-07 dsm_est 0.000130015 nsteps 268 + rtol 1e-06 rk_type 0 order 2 acc 2 t 4.5 dsm 7.4366e-08 dsm_est 0.000335997 nsteps 597 + rtol 1e-06 rk_type 0 order 2 acc 2 t 4.75 dsm 5.08713e-07 dsm_est 0.000143029 nsteps 347 + rtol 1e-06 rk_type 0 order 2 acc 2 t 5 dsm 1.42752e-07 dsm_est 0.000210843 nsteps 366 rtol 1e-06 rk_type 0 order 2 acc 3 t 0.25 dsm 5.66725e-09 dsm_est 3.91786e-07 nsteps 488 rtol 1e-06 rk_type 0 order 2 acc 3 t 0.5 dsm 9.92276e-07 dsm_est 5.14717e-07 nsteps 403 rtol 1e-06 rk_type 0 order 2 acc 3 t 0.75 dsm 8.0717e-08 dsm_est 4.71859e-07 nsteps 823 diff --git a/test/unit_tests/arkode/CXX_serial/ark_test_accumerror_kpr_20_3_1.out b/test/unit_tests/arkode/CXX_serial/ark_test_accumerror_kpr_20_3_1.out index f956e1f6e0..5e13fabf2e 100644 --- a/test/unit_tests/arkode/CXX_serial/ark_test_accumerror_kpr_20_3_1.out +++ b/test/unit_tests/arkode/CXX_serial/ark_test_accumerror_kpr_20_3_1.out @@ -28,6 +28,26 @@ Adaptive-step runs: rtol 0.01 rk_type 1 order 3 acc 1 t 4.5 dsm 1.84821e-05 dsm_est 0.000635863 nsteps 5 rtol 0.01 rk_type 1 order 3 acc 1 t 4.75 dsm 6.25225e-05 dsm_est 0.000713957 nsteps 5 rtol 0.01 rk_type 1 order 3 acc 1 t 5 dsm 1.27772e-05 dsm_est 0.000232819 nsteps 5 + rtol 0.01 rk_type 1 order 3 acc 2 t 0.25 dsm 6.04149e-05 dsm_est 0.000142481 nsteps 5 + rtol 0.01 rk_type 1 order 3 acc 2 t 0.5 dsm 0.000268262 dsm_est 0.0017944 nsteps 5 + rtol 0.01 rk_type 1 order 3 acc 2 t 0.75 dsm 0.000162426 dsm_est 0.00306316 nsteps 5 + rtol 0.01 rk_type 1 order 3 acc 2 t 1 dsm 0.00010345 dsm_est 0.00295527 nsteps 5 + rtol 0.01 rk_type 1 order 3 acc 2 t 1.25 dsm 0.00145293 dsm_est 0.00455884 nsteps 7 + rtol 0.01 rk_type 1 order 3 acc 2 t 1.5 dsm 0.000475504 dsm_est 0.00371453 nsteps 6 + rtol 0.01 rk_type 1 order 3 acc 2 t 1.75 dsm 0.000953909 dsm_est 0.0112601 nsteps 5 + rtol 0.01 rk_type 1 order 3 acc 2 t 2 dsm 0.00190469 dsm_est 0.00636832 nsteps 6 + rtol 0.01 rk_type 1 order 3 acc 2 t 2.25 dsm 0.00091692 dsm_est 0.00259729 nsteps 5 + rtol 0.01 rk_type 1 order 3 acc 2 t 2.5 dsm 0.000303064 dsm_est 0.00186612 nsteps 5 + rtol 0.01 rk_type 1 order 3 acc 2 t 2.75 dsm 8.75302e-05 dsm_est 0.00125767 nsteps 5 + rtol 0.01 rk_type 1 order 3 acc 2 t 3 dsm 0.000106108 dsm_est 0.00108028 nsteps 5 + rtol 0.01 rk_type 1 order 3 acc 2 t 3.25 dsm 0.000146676 dsm_est 0.000287211 nsteps 5 + rtol 0.01 rk_type 1 order 3 acc 2 t 3.5 dsm 0.000132279 dsm_est 0.000198803 nsteps 5 + rtol 0.01 rk_type 1 order 3 acc 2 t 3.75 dsm 0.000106549 dsm_est 0.000127557 nsteps 5 + rtol 0.01 rk_type 1 order 3 acc 2 t 4 dsm 7.68783e-05 dsm_est 9.87869e-05 nsteps 5 + rtol 0.01 rk_type 1 order 3 acc 2 t 4.25 dsm 9.2941e-05 dsm_est 0.000739077 nsteps 5 + rtol 0.01 rk_type 1 order 3 acc 2 t 4.5 dsm 1.84821e-05 dsm_est 0.000782096 nsteps 5 + rtol 0.01 rk_type 1 order 3 acc 2 t 4.75 dsm 6.25225e-05 dsm_est 0.00123861 nsteps 5 + rtol 0.01 rk_type 1 order 3 acc 2 t 5 dsm 1.27772e-05 dsm_est 0.000335449 nsteps 5 rtol 0.01 rk_type 1 order 3 acc 3 t 0.25 dsm 6.04149e-05 dsm_est 2.84962e-05 nsteps 5 rtol 0.01 rk_type 1 order 3 acc 3 t 0.5 dsm 0.000268262 dsm_est 0.00035888 nsteps 5 rtol 0.01 rk_type 1 order 3 acc 3 t 0.75 dsm 0.000162426 dsm_est 0.000612632 nsteps 5 @@ -68,6 +88,26 @@ Adaptive-step runs: rtol 0.0001 rk_type 1 order 3 acc 1 t 4.5 dsm 3.00465e-06 dsm_est 6.91731e-05 nsteps 9 rtol 0.0001 rk_type 1 order 3 acc 1 t 4.75 dsm 2.24177e-06 dsm_est 6.08731e-05 nsteps 9 rtol 0.0001 rk_type 1 order 3 acc 1 t 5 dsm 4.61559e-06 dsm_est 3.8972e-05 nsteps 7 + rtol 0.0001 rk_type 1 order 3 acc 2 t 0.25 dsm 2.72131e-05 dsm_est 4.924e-05 nsteps 6 + rtol 0.0001 rk_type 1 order 3 acc 2 t 0.5 dsm 1.24325e-05 dsm_est 0.000277893 nsteps 10 + rtol 0.0001 rk_type 1 order 3 acc 2 t 0.75 dsm 3.04294e-06 dsm_est 0.000266101 nsteps 11 + rtol 0.0001 rk_type 1 order 3 acc 2 t 1 dsm 5.56473e-06 dsm_est 0.00021078 nsteps 10 + rtol 0.0001 rk_type 1 order 3 acc 2 t 1.25 dsm 2.64925e-05 dsm_est 0.000612671 nsteps 14 + rtol 0.0001 rk_type 1 order 3 acc 2 t 1.5 dsm 3.99013e-05 dsm_est 0.000376163 nsteps 17 + rtol 0.0001 rk_type 1 order 3 acc 2 t 1.75 dsm 6.46566e-06 dsm_est 0.000664655 nsteps 20 + rtol 0.0001 rk_type 1 order 3 acc 2 t 2 dsm 2.27591e-05 dsm_est 0.000263341 nsteps 14 + rtol 0.0001 rk_type 1 order 3 acc 2 t 2.25 dsm 2.35987e-05 dsm_est 0.000218874 nsteps 12 + rtol 0.0001 rk_type 1 order 3 acc 2 t 2.5 dsm 1.9839e-05 dsm_est 0.000144657 nsteps 10 + rtol 0.0001 rk_type 1 order 3 acc 2 t 2.75 dsm 4.82543e-06 dsm_est 0.000184366 nsteps 9 + rtol 0.0001 rk_type 1 order 3 acc 2 t 3 dsm 1.42111e-05 dsm_est 0.000233128 nsteps 9 + rtol 0.0001 rk_type 1 order 3 acc 2 t 3.25 dsm 8.99237e-05 dsm_est 9.1606e-05 nsteps 6 + rtol 0.0001 rk_type 1 order 3 acc 2 t 3.5 dsm 7.05943e-05 dsm_est 6.46269e-05 nsteps 6 + rtol 0.0001 rk_type 1 order 3 acc 2 t 3.75 dsm 0.00011745 dsm_est 0.000129769 nsteps 5 + rtol 0.0001 rk_type 1 order 3 acc 2 t 4 dsm 8.6392e-05 dsm_est 0.000108688 nsteps 5 + rtol 0.0001 rk_type 1 order 3 acc 2 t 4.25 dsm 1.06282e-05 dsm_est 0.000207268 nsteps 8 + rtol 0.0001 rk_type 1 order 3 acc 2 t 4.5 dsm 3.00465e-06 dsm_est 0.00017063 nsteps 9 + rtol 0.0001 rk_type 1 order 3 acc 2 t 4.75 dsm 2.24177e-06 dsm_est 0.000176806 nsteps 9 + rtol 0.0001 rk_type 1 order 3 acc 2 t 5 dsm 4.61559e-06 dsm_est 8.40566e-05 nsteps 7 rtol 0.0001 rk_type 1 order 3 acc 3 t 0.25 dsm 2.72131e-05 dsm_est 8.20667e-06 nsteps 6 rtol 0.0001 rk_type 1 order 3 acc 3 t 0.5 dsm 1.24325e-05 dsm_est 2.77893e-05 nsteps 10 rtol 0.0001 rk_type 1 order 3 acc 3 t 0.75 dsm 3.04294e-06 dsm_est 2.4191e-05 nsteps 11 @@ -108,6 +148,26 @@ Adaptive-step runs: rtol 1e-06 rk_type 1 order 3 acc 1 t 4.5 dsm 4.23449e-08 dsm_est 8.85746e-07 nsteps 29 rtol 1e-06 rk_type 1 order 3 acc 1 t 4.75 dsm 1.70945e-08 dsm_est 6.68877e-07 nsteps 35 rtol 1e-06 rk_type 1 order 3 acc 1 t 5 dsm 4.21376e-08 dsm_est 6.1895e-07 nsteps 23 + rtol 1e-06 rk_type 1 order 3 acc 2 t 0.25 dsm 4.12033e-07 dsm_est 5.39389e-06 nsteps 17 + rtol 1e-06 rk_type 1 order 3 acc 2 t 0.5 dsm 2.46326e-07 dsm_est 1.9237e-05 nsteps 31 + rtol 1e-06 rk_type 1 order 3 acc 2 t 0.75 dsm 3.64026e-08 dsm_est 1.83009e-05 nsteps 39 + rtol 1e-06 rk_type 1 order 3 acc 2 t 1 dsm 2.25687e-07 dsm_est 9.58735e-06 nsteps 45 + rtol 1e-06 rk_type 1 order 3 acc 2 t 1.25 dsm 5.93423e-07 dsm_est 3.20094e-05 nsteps 53 + rtol 1e-06 rk_type 1 order 3 acc 2 t 1.5 dsm 6.11123e-07 dsm_est 1.91705e-05 nsteps 68 + rtol 1e-06 rk_type 1 order 3 acc 2 t 1.75 dsm 1.11041e-07 dsm_est 3.76134e-05 nsteps 76 + rtol 1e-06 rk_type 1 order 3 acc 2 t 2 dsm 4.68945e-07 dsm_est 1.77029e-05 nsteps 49 + rtol 1e-06 rk_type 1 order 3 acc 2 t 2.25 dsm 2.82077e-07 dsm_est 1.41512e-05 nsteps 46 + rtol 1e-06 rk_type 1 order 3 acc 2 t 2.5 dsm 3.42754e-07 dsm_est 8.81414e-06 nsteps 37 + rtol 1e-06 rk_type 1 order 3 acc 2 t 2.75 dsm 8.76441e-08 dsm_est 1.05628e-05 nsteps 30 + rtol 1e-06 rk_type 1 order 3 acc 2 t 3 dsm 9.61476e-08 dsm_est 1.02396e-05 nsteps 29 + rtol 1e-06 rk_type 1 order 3 acc 2 t 3.25 dsm 1.10578e-06 dsm_est 5.86128e-06 nsteps 19 + rtol 1e-06 rk_type 1 order 3 acc 2 t 3.5 dsm 8.13041e-07 dsm_est 4.13828e-06 nsteps 19 + rtol 1e-06 rk_type 1 order 3 acc 2 t 3.75 dsm 8.63105e-07 dsm_est 4.96105e-06 nsteps 15 + rtol 1e-06 rk_type 1 order 3 acc 2 t 4 dsm 6.24598e-07 dsm_est 3.42283e-06 nsteps 17 + rtol 1e-06 rk_type 1 order 3 acc 2 t 4.25 dsm 1.79535e-07 dsm_est 1.35763e-05 nsteps 24 + rtol 1e-06 rk_type 1 order 3 acc 2 t 4.5 dsm 4.23449e-08 dsm_est 9.97609e-06 nsteps 29 + rtol 1e-06 rk_type 1 order 3 acc 2 t 4.75 dsm 1.70945e-08 dsm_est 8.39064e-06 nsteps 35 + rtol 1e-06 rk_type 1 order 3 acc 2 t 5 dsm 4.21376e-08 dsm_est 4.92976e-06 nsteps 23 rtol 1e-06 rk_type 1 order 3 acc 3 t 0.25 dsm 4.12033e-07 dsm_est 3.17288e-07 nsteps 17 rtol 1e-06 rk_type 1 order 3 acc 3 t 0.5 dsm 2.46326e-07 dsm_est 6.20547e-07 nsteps 31 rtol 1e-06 rk_type 1 order 3 acc 3 t 0.75 dsm 3.64026e-08 dsm_est 4.69255e-07 nsteps 39 diff --git a/test/unit_tests/arkode/C_serial/ark_test_erkstepsetforcing.c b/test/unit_tests/arkode/C_serial/ark_test_erkstepsetforcing.c index b80198444e..1a40f17082 100644 --- a/test/unit_tests/arkode/C_serial/ark_test_erkstepsetforcing.c +++ b/test/unit_tests/arkode/C_serial/ark_test_erkstepsetforcing.c @@ -198,43 +198,43 @@ int main(int argc, char* argv[]) if (check_flag((void*)arkode_mem, "ERKStepCreate", 0)) return 1; /* Specify tolerances */ - flag = ERKStepSStolerances(arkode_mem, reltol, abstol); - if (check_flag(&flag, "ERKStepSStolerances", 1)) return 1; + flag = ARKodeSStolerances(arkode_mem, reltol, abstol); + if (check_flag(&flag, "ARKodeSStolerances", 1)) return 1; /* Set stop time */ - flag = ERKStepSetStopTime(arkode_mem, Tf); - if (check_flag(&flag, "ERKStepSetStopTime", 1)) return 1; + flag = ARKodeSetStopTime(arkode_mem, Tf); + if (check_flag(&flag, "ARKodeSetStopTime", 1)) return 1; /* Set max steps before output */ - flag = ERKStepSetMaxNumSteps(arkode_mem, mxsteps); - if (check_flag(&flag, "ERKStepSetMaxNumSteps", 1)) return 1; + flag = ARKodeSetMaxNumSteps(arkode_mem, mxsteps); + if (check_flag(&flag, "ARKodeSetMaxNumSteps", 1)) return 1; /* Set forcing */ flag = erkStep_SetInnerForcing(arkode_mem, tshift, tscale, forcing, order + 1); if (check_flag(&flag, "erkStep_SetInnerForcing", 1)) return 1; /* Integrate the problem */ - flag = ERKStepEvolve(arkode_mem, Tf, y, &tret, ARK_NORMAL); + flag = ARKodeEvolve(arkode_mem, Tf, y, &tret, ARK_NORMAL); /* check for errors */ if (flag < 0) { - fprintf(stderr, "ERKStep failure, flag = %d\n", flag); + fprintf(stderr, "ARKodeEvolve failure, flag = %d\n", flag); return 1; } /* get some integrator stats */ - flag = ERKStepGetNumSteps(arkode_mem, &nst); - check_flag(&flag, "ERKStepGetNumSteps", 1); + flag = ARKodeGetNumSteps(arkode_mem, &nst); + check_flag(&flag, "ARKodeGetNumSteps", 1); - flag = ERKStepGetNumStepAttempts(arkode_mem, &nst_a); - check_flag(&flag, "ERKStepGetNumStepAttempts", 1); + flag = ARKodeGetNumStepAttempts(arkode_mem, &nst_a); + check_flag(&flag, "ARKodeGetNumStepAttempts", 1); printf("Stats:\n"); printf("Steps = %li (attempted = %li)\n\n", nst, nst_a); /* Free integrator memory */ - ERKStepFree(&arkode_mem); + ARKodeFree(&arkode_mem); arkode_mem = NULL; /* print solution */ From c445608421ab39e590b256144c7a9db0b3d9b741 Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Fri, 4 Oct 2024 10:16:01 -0500 Subject: [PATCH 113/286] Apply suggestion from code review Co-authored-by: Steven Roberts --- src/arkode/arkode_io.c | 24 +++--------------------- 1 file changed, 3 insertions(+), 21 deletions(-) diff --git a/src/arkode/arkode_io.c b/src/arkode/arkode_io.c index a27e0238c1..2bf7d7b401 100644 --- a/src/arkode/arkode_io.c +++ b/src/arkode/arkode_io.c @@ -1961,27 +1961,9 @@ int ARKodeSetMaxConvFails(void* arkode_mem, int maxncf) ---------------------------------------------------------------*/ int ARKodeSetAccumulatedErrorType(void* arkode_mem, ARKAccumError accum_type) { - ARKodeMem ark_mem; - if (arkode_mem == NULL) - { - arkProcessError(NULL, ARK_MEM_NULL, __LINE__, __func__, __FILE__, - MSG_ARK_NO_MEM); - return (ARK_MEM_NULL); - } - ark_mem = (ARKodeMem)arkode_mem; - - /* Guard against use for non-adaptive time stepper modules */ - if (!ark_mem->step_supports_adaptive) - { - arkProcessError(ark_mem, ARK_STEPPER_UNSUPPORTED, __LINE__, __func__, - __FILE__, "time-stepping module does not support temporal adaptivity"); - return (ARK_STEPPER_UNSUPPORTED); - } - - /* Store type, reset accumulated error value and counter, and return */ - ark_mem->AccumErrorType = accum_type; - ark_mem->AccumErrorStep = ark_mem->nst; - ark_mem->AccumError = ZERO; + int retval = ARKodeResetAccumulatedError(arkode_mem); + if (retval != ARK_SUCCESS) { return retval; } + ((ARKodeMem) arkode_mem)->AccumErrorType = accum_type; return (ARK_SUCCESS); } From a017c07ec083706ee0e7c56b8610b1f5f413dcf6 Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Fri, 4 Oct 2024 10:25:46 -0500 Subject: [PATCH 114/286] Fix formatting introduced in PR suggestion --- src/arkode/arkode_io.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/arkode/arkode_io.c b/src/arkode/arkode_io.c index 2bf7d7b401..8b6696dd95 100644 --- a/src/arkode/arkode_io.c +++ b/src/arkode/arkode_io.c @@ -1963,7 +1963,7 @@ int ARKodeSetAccumulatedErrorType(void* arkode_mem, ARKAccumError accum_type) { int retval = ARKodeResetAccumulatedError(arkode_mem); if (retval != ARK_SUCCESS) { return retval; } - ((ARKodeMem) arkode_mem)->AccumErrorType = accum_type; + ((ARKodeMem)arkode_mem)->AccumErrorType = accum_type; return (ARK_SUCCESS); } From e5c28011a5e7d5bc50a42f608ba5321f68b593aa Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Fri, 4 Oct 2024 10:47:08 -0500 Subject: [PATCH 115/286] Updated answers repository commit --- test/answers | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/answers b/test/answers index bafeb3bac8..3bd1f2fa65 160000 --- a/test/answers +++ b/test/answers @@ -1 +1 @@ -Subproject commit bafeb3bac8c15d3e3aff44491cc81c0981d007d8 +Subproject commit 3bd1f2fa65278ded085f3cf21b701ed8fd0bed02 From 884b78dc2915fd703f8ef83ae9b996ba35847986 Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Fri, 4 Oct 2024 11:06:01 -0500 Subject: [PATCH 116/286] Added comment regarding order of MERK54 method --- .../guide/source/Usage/MRIStep/MRIStepCoupling.rst | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/doc/arkode/guide/source/Usage/MRIStep/MRIStepCoupling.rst b/doc/arkode/guide/source/Usage/MRIStep/MRIStepCoupling.rst index 0e3b1ca570..885e7c8ca1 100644 --- a/doc/arkode/guide/source/Usage/MRIStep/MRIStepCoupling.rst +++ b/doc/arkode/guide/source/Usage/MRIStep/MRIStepCoupling.rst @@ -399,6 +399,15 @@ with values specified for each method below (e.g., ``ARKODE_MIS_KW3``). for each order when using adaptive time stepping is marked with a circle (:math:`^\circ`). The "Slow RHS Calls" column corresponds to the number of calls to the slow right-hand side function, :math:`f^E`, per time step. + Note :math:`^\vee`: although all MERK methods were derived in :cite:p:`Luan:20` + under an assumption that the fast time scale is linear in the solution, in + :cite:p:`Fish:24` it was proven that they also satisfy all nonlinear order + conditions up through their linear order. The lone exception is MERK54, where + it was only proven to satisfy all nonlinear conditions up to order 4, since + :cite:p:`Fish:24` did not establish the formulas for the order 5 conditions. + All our numerical tests to date have shown MERK54 to achieve fifth order for + nonlinear problems, and so we conjecture that it also satisfies the nonlinear + fifth order conditions. ====================================== ================== =============== ============== ===================== Table name Method Order Embedding Order Slow RHS Calls Reference @@ -414,7 +423,7 @@ with values specified for each method below (e.g., ``ARKODE_MIS_KW3``). :index:`ARKODE_MERK32` 3 2 3 :cite:p:`Luan:20` :index:`ARKODE_MRI_GARK_ERK45a` :math:`4^{*\circ}` 3 5 :cite:p:`Sandu:19` :index:`ARKODE_MERK43` 4 3 6 :cite:p:`Luan:20` - :index:`ARKODE_MERK54` 5 4 10 :cite:p:`Luan:20` + :index:`ARKODE_MERK54` :math:`5^{\vee}` 4 10 :cite:p:`Luan:20` ====================================== ================== =============== ============== ===================== From bb0dc398125d84ac9c83ca5dd5cb9f549510bf4d Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Fri, 4 Oct 2024 11:19:29 -0500 Subject: [PATCH 117/286] Changed default embedded second-order MRI-GARK method to ARKODE_MRI_GARK_ERK22b (to match fixed-step default) --- doc/arkode/guide/source/Usage/MRIStep/MRIStepCoupling.rst | 4 ++-- include/arkode/arkode_mristep.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/doc/arkode/guide/source/Usage/MRIStep/MRIStepCoupling.rst b/doc/arkode/guide/source/Usage/MRIStep/MRIStepCoupling.rst index 885e7c8ca1..c1b31fa576 100644 --- a/doc/arkode/guide/source/Usage/MRIStep/MRIStepCoupling.rst +++ b/doc/arkode/guide/source/Usage/MRIStep/MRIStepCoupling.rst @@ -413,8 +413,8 @@ with values specified for each method below (e.g., ``ARKODE_MIS_KW3``). Table name Method Order Embedding Order Slow RHS Calls Reference ====================================== ================== =============== ============== ===================== :index:`ARKODE_MRI_GARK_FORWARD_EULER` :math:`1^*` -- 1 - :index:`ARKODE_MRI_GARK_ERK22a` :math:`2^{\circ}` 1 2 :cite:p:`Sandu:19` - :index:`ARKODE_MRI_GARK_ERK22b` :math:`2^*` 1 2 :cite:p:`Sandu:19` + :index:`ARKODE_MRI_GARK_ERK22a` 2 1 2 :cite:p:`Sandu:19` + :index:`ARKODE_MRI_GARK_ERK22b` :math:`2^{*\circ}` 1 2 :cite:p:`Sandu:19` :index:`ARKODE_MRI_GARK_RALSTON2` 2 1 2 :cite:p:`Roberts:22` :index:`ARKODE_MERK21` 2 1 2 :cite:p:`Luan:20` :index:`ARKODE_MIS_KW3` :math:`3^*` -- 3 :cite:p:`Schlegel:09` diff --git a/include/arkode/arkode_mristep.h b/include/arkode/arkode_mristep.h index 2851682972..bde45c1fab 100644 --- a/include/arkode/arkode_mristep.h +++ b/include/arkode/arkode_mristep.h @@ -80,7 +80,7 @@ static const int MRISTEP_DEFAULT_EXPL_2 = ARKODE_MRI_GARK_ERK22b; static const int MRISTEP_DEFAULT_EXPL_3 = ARKODE_MIS_KW3; static const int MRISTEP_DEFAULT_EXPL_4 = ARKODE_MRI_GARK_ERK45a; -static const int MRISTEP_DEFAULT_EXPL_2_AD = ARKODE_MRI_GARK_ERK22a; +static const int MRISTEP_DEFAULT_EXPL_2_AD = ARKODE_MRI_GARK_ERK22b; static const int MRISTEP_DEFAULT_EXPL_3_AD = ARKODE_MRI_GARK_ERK33a; static const int MRISTEP_DEFAULT_EXPL_4_AD = ARKODE_MRI_GARK_ERK45a; static const int MRISTEP_DEFAULT_EXPL_5_AD = ARKODE_MERK54; From cc2f2a2a111484fa8ee319798ce8cec1e03b7921 Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Fri, 4 Oct 2024 11:27:25 -0500 Subject: [PATCH 118/286] Swig --- src/arkode/fmod_int32/farkode_mristep_mod.f90 | 2 +- src/arkode/fmod_int64/farkode_mristep_mod.f90 | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/arkode/fmod_int32/farkode_mristep_mod.f90 b/src/arkode/fmod_int32/farkode_mristep_mod.f90 index d4ab82a69f..40ceba1779 100644 --- a/src/arkode/fmod_int32/farkode_mristep_mod.f90 +++ b/src/arkode/fmod_int32/farkode_mristep_mod.f90 @@ -80,7 +80,7 @@ module farkode_mristep_mod integer(C_INT), parameter, public :: MRISTEP_DEFAULT_EXPL_2 = ARKODE_MRI_GARK_ERK22b integer(C_INT), parameter, public :: MRISTEP_DEFAULT_EXPL_3 = ARKODE_MIS_KW3 integer(C_INT), parameter, public :: MRISTEP_DEFAULT_EXPL_4 = ARKODE_MRI_GARK_ERK45a - integer(C_INT), parameter, public :: MRISTEP_DEFAULT_EXPL_2_AD = ARKODE_MRI_GARK_ERK22a + integer(C_INT), parameter, public :: MRISTEP_DEFAULT_EXPL_2_AD = ARKODE_MRI_GARK_ERK22b integer(C_INT), parameter, public :: MRISTEP_DEFAULT_EXPL_3_AD = ARKODE_MRI_GARK_ERK33a integer(C_INT), parameter, public :: MRISTEP_DEFAULT_EXPL_4_AD = ARKODE_MRI_GARK_ERK45a integer(C_INT), parameter, public :: MRISTEP_DEFAULT_EXPL_5_AD = ARKODE_MERK54 diff --git a/src/arkode/fmod_int64/farkode_mristep_mod.f90 b/src/arkode/fmod_int64/farkode_mristep_mod.f90 index c4fa555d2d..327e44da65 100644 --- a/src/arkode/fmod_int64/farkode_mristep_mod.f90 +++ b/src/arkode/fmod_int64/farkode_mristep_mod.f90 @@ -80,7 +80,7 @@ module farkode_mristep_mod integer(C_INT), parameter, public :: MRISTEP_DEFAULT_EXPL_2 = ARKODE_MRI_GARK_ERK22b integer(C_INT), parameter, public :: MRISTEP_DEFAULT_EXPL_3 = ARKODE_MIS_KW3 integer(C_INT), parameter, public :: MRISTEP_DEFAULT_EXPL_4 = ARKODE_MRI_GARK_ERK45a - integer(C_INT), parameter, public :: MRISTEP_DEFAULT_EXPL_2_AD = ARKODE_MRI_GARK_ERK22a + integer(C_INT), parameter, public :: MRISTEP_DEFAULT_EXPL_2_AD = ARKODE_MRI_GARK_ERK22b integer(C_INT), parameter, public :: MRISTEP_DEFAULT_EXPL_3_AD = ARKODE_MRI_GARK_ERK33a integer(C_INT), parameter, public :: MRISTEP_DEFAULT_EXPL_4_AD = ARKODE_MRI_GARK_ERK45a integer(C_INT), parameter, public :: MRISTEP_DEFAULT_EXPL_5_AD = ARKODE_MERK54 From c4d0b27c0da9e3fffeee2a1dd2285a4c862ca1f3 Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Fri, 4 Oct 2024 14:20:48 -0500 Subject: [PATCH 119/286] Fixed docs build error (apparently, you cannot :cite: inside a table caption?) --- doc/arkode/guide/source/Usage/MRIStep/MRIStepCoupling.rst | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/doc/arkode/guide/source/Usage/MRIStep/MRIStepCoupling.rst b/doc/arkode/guide/source/Usage/MRIStep/MRIStepCoupling.rst index c1b31fa576..c9ee71835e 100644 --- a/doc/arkode/guide/source/Usage/MRIStep/MRIStepCoupling.rst +++ b/doc/arkode/guide/source/Usage/MRIStep/MRIStepCoupling.rst @@ -399,12 +399,12 @@ with values specified for each method below (e.g., ``ARKODE_MIS_KW3``). for each order when using adaptive time stepping is marked with a circle (:math:`^\circ`). The "Slow RHS Calls" column corresponds to the number of calls to the slow right-hand side function, :math:`f^E`, per time step. - Note :math:`^\vee`: although all MERK methods were derived in :cite:p:`Luan:20` + Note A: although all MERK methods were derived in Luan et al. (2020) under an assumption that the fast time scale is linear in the solution, in - :cite:p:`Fish:24` it was proven that they also satisfy all nonlinear order + Fish et al. (2024) it was proven that they also satisfy all nonlinear order conditions up through their linear order. The lone exception is MERK54, where it was only proven to satisfy all nonlinear conditions up to order 4, since - :cite:p:`Fish:24` did not establish the formulas for the order 5 conditions. + Fish et al. (2024) did not establish the formulas for the order 5 conditions. All our numerical tests to date have shown MERK54 to achieve fifth order for nonlinear problems, and so we conjecture that it also satisfies the nonlinear fifth order conditions. @@ -423,7 +423,7 @@ with values specified for each method below (e.g., ``ARKODE_MIS_KW3``). :index:`ARKODE_MERK32` 3 2 3 :cite:p:`Luan:20` :index:`ARKODE_MRI_GARK_ERK45a` :math:`4^{*\circ}` 3 5 :cite:p:`Sandu:19` :index:`ARKODE_MERK43` 4 3 6 :cite:p:`Luan:20` - :index:`ARKODE_MERK54` :math:`5^{\vee}` 4 10 :cite:p:`Luan:20` + :index:`ARKODE_MERK54` :math:`5^{A}` 4 10 :cite:p:`Luan:20` ====================================== ================== =============== ============== ===================== From af9205e622f65932627e2137166646a154f1bba6 Mon Sep 17 00:00:00 2001 From: "David J. Gardner" Date: Fri, 4 Oct 2024 14:01:42 -0700 Subject: [PATCH 120/286] revise MRIStep mathmatics section --- doc/arkode/guide/source/Mathematics.rst | 223 +++++++++++++++--------- 1 file changed, 140 insertions(+), 83 deletions(-) diff --git a/doc/arkode/guide/source/Mathematics.rst b/doc/arkode/guide/source/Mathematics.rst index 5126b6f118..4e62c500c8 100644 --- a/doc/arkode/guide/source/Mathematics.rst +++ b/doc/arkode/guide/source/Mathematics.rst @@ -604,111 +604,168 @@ an identity mass matrix, :math:`M(t)=I`. The slow time scale may consist of only nonstiff terms (:math:`f^I \equiv 0`), only stiff terms (:math:`f^E \equiv 0`), or both nonstiff and stiff terms. -For cases with only a single slow right-hand side function (i.e., -:math:`f^E \equiv 0` or :math:`f^I \equiv 0`), MRIStep provides multirate -infinitesimal step (MIS) :cite:p:`Schlegel:09, Schlegel:12a, Schlegel:12b`, -multirate infinitesimal GARK (MRI-GARK) :cite:p:`Sandu:19`, and -multirate exponential Runge--Kutta (MERK) :cite:p:`Luan:20` methods. For -problems with an additively split slow right-hand side, MRIStep -provides implicit-explicit MRI-GARK (IMEX-MRI-GARK) -:cite:p:`ChiRen:21` and implicit-explicit multirate infinitesimal stage-restart -(IMEX-MRI-SR) :cite:p:`Fish:24` methods. Generally, the slow (outer) method for each -family derives from an :math:`s` stage single-rate method: MIS and MRI-GARK methods -derive from explicit or diagonally-implicit Runge--Kutta methods, MERK methods derive -from exponential Runge--Kutta methods, while IMEX-MRI-GARK and IMEX-MRI-SR methods -derive from additive Runge--Kutta methods. In each case, the "infinitesimal" nature -of the multirate methods derives from the fact that slow stages are computed by solving -a set of auxiliary ODEs with a fast (inner) time integration method. Generally speaking, -an :math:`s`-stage method from of each family adheres to the following algorithm for a -single step: +For cases with only a single slow right-hand side function (i.e., :math:`f^E +\equiv 0` or :math:`f^I \equiv 0`), MRIStep provides multirate infinitesimal +step (MIS) :cite:p:`Schlegel:09, Schlegel:12a, Schlegel:12b`, first through +fourth order multirate infinitesimal GARK (MRI-GARK) :cite:p:`Sandu:19`, and +second through fifth order multirate exponential Runge--Kutta (MERK) +:cite:p:`Luan:20` methods. For problems with an additively split slow right-hand +side, MRIStep provides first through fourth order implicit-explicit MRI-GARK +(IMEX-MRI-GARK) :cite:p:`ChiRen:21` and second through fourth order +implicit-explicit multirate infinitesimal stage-restart (IMEX-MRI-SR) +:cite:p:`Fish:24` methods. For a complete list of the methods available in +MRIStep see :numref:`ARKODE.Usage.MRIStep.MRIStepCoupling.Tables`. Additionally, +users may supply their own method by defining and attaching a coupling table, +see :numref:`ARKODE.Usage.MRIStep.MRIStepCoupling` for more information. + +Generally, the slow (outer) method for each family derives from an :math:`s` +stage single-rate method: MIS and MRI-GARK methods derive from explicit or +diagonally-implicit Runge--Kutta methods, MERK methods derive from exponential +Runge--Kutta methods, while IMEX-MRI-GARK and IMEX-MRI-SR methods derive from +additive Runge--Kutta methods. In each case, the "infinitesimal" nature of the +multirate methods derives from the fact that slow stages are computed by solving +a set of auxiliary ODEs with a fast (inner) time integration method. Generally +speaking, an :math:`s`-stage method from of each family adheres to the following +algorithm for a single step: #. Set :math:`z_1 = y_{n-1}`. -#. For :math:`i = 2,\ldots,s` do: +#. For :math:`i = 2,\ldots,s`, compute the stage solutions, :math:`z_i`, by + evolving the fast IVP - #. Either + .. math:: + {v}_i'(t) = f^F(t, v_i) + r_i(t) \quad\text{for}\quad t \in [t_{0,i},t_{F,i}] \quad\text{with}\quad v_i(t_{0,i}) = v_{0,i} + :label: MRI_fast_IVP - #. evolve a fast IVP + and setting :math:`z_i = v(t_{F,i})`, and/or performing a standard explicit, + diagonally-implicit, or additive Runge--Kutta stage update, - .. math:: - {v}_i'(t) = f^F(t, v_i) + r_i(t) \quad\text{for}\quad t \in [t_{0,i},t_{F,i}] \quad\text{with}\quad v_i(t_{0,i}) = v_{0,i} - :label: MRI_fast_IVP - - and let :math:`z_i = v(t_{F,i})`, or - - #. perform a standard explicit, diagonally-implicit, or additive Runge--Kutta stage update, - - .. math:: - z_i - \gamma_{i,i} h^S f^I(t_{n-1}+c_i^S h^s, z_i) = a_i. - :label: MRI_implicit_solve + .. math:: + z_i - \theta_{i,i} h^S f^I(t_{n-1}+c_i^S h^S, z_i) = a_i. + :label: MRI_implicit_solve #. Set :math:`y_{n} = z_{s}`. -#. (Optional embedded solution) either - - #. evolve a fast IVP - - .. math:: - \tilde{v}'(t) = f^F(t, \tilde{v}) + \tilde{r}(t) \quad\text{for}\quad t \in [\tilde{t}_{0},\tilde{t}_{F}] \quad\text{with}\quad \tilde{v}(\tilde{t}_{0}) = \tilde{v}_{0} - :label: MRI_embedding_fast_IVP +#. If the method has an embedding, compute the embedded solution, + :math:`\tilde{y}`, by evolving the fast IVP + + .. math:: + \tilde{v}'(t) = f^F(t, \tilde{v}) + \tilde{r}(t) \quad\text{for}\quad t \in [\tilde{t}_{0},\tilde{t}_{F}] \quad\text{with}\quad \tilde{v}(\tilde{t}_{0}) = \tilde{v}_{0} + :label: MRI_embedding_fast_IVP + + and setting :math:`\tilde{y}_{n} = \tilde{v}(\tilde{t}_{F})`, and/or + performing a standard explicit, diagonally-implicit, or additive Runge--Kutta + stage update, + + .. math:: + \tilde{y}_n - \tilde{\theta} h^S f^I(t_n, \tilde{y}_n) = \tilde{a}. + :label: MRI_embedding_implicit_solve + +Whether a fast IVP evolution or a stage update (or both) is needed depends on +the method family (MRI-GARK, MERK, etc.). The specific aspects of the fast IVP +forcing function (:math:`r_i(t)` or :math:`\tilde{r}(t)`), the interval over +which the IVP must be evolved (:math:`[t_{0,i},t_{F,i}])`, the Runge--Kutta +coefficients (:math:`\theta_{i,i}` and :math:`\tilde{\theta}`), and the +Runge--Kutta data (:math:`a_i` and :math:`\tilde{a}`), are also determined by +the method family. Generally, the forcing functions and data, are constructed +using evaluations of the slow RHS functions, :math:`f^E` and :math:`f^I`, at +preceding stages, :math:`z_j`. The fast IVP solves can be carried out using any +valid ARKODE integrator or a user-defined integration method (see section +:numref:`ARKODE.Usage.MRIStep.CustomInnerStepper`). - and let :math:`\tilde{y}_{n} = \tilde{v}(\tilde{t}_{F})`, or +Below we summarize the details for each method family. For additional +information, please see the references listed above. - #. perform a standard explicit, diagonally-implicit, or additive Runge--Kutta stage update, - .. math:: - \tilde{y}_n - \tilde{\gamma} h^S f^I(t_n, \tilde{y}_n) = \tilde{a}. - :label: MRI_embedding_implicit_solve +MIS, MRI-GARK, and IMEX-MRI-GARK Methods +---------------------------------------- -.. note:: +The methods in IMEX-MRI-GARK family, which includes MIS and MRI-GARK methods, +are defined by a vector of slow stage time abscissae, :math:`c^S \in +\mathbb{R}^{s+1}`, and a set of coupling tensors, +:math:`\Omega\in\mathbb{R}^{(s+1)\times(s+1)\times k}` and +:math:`\Gamma\in\mathbb{R}^{(s+1)\times(s+1)\times k}`, that specify the +slow-to-fast coupling for the explicit and implicit components, respectively. - **MIS**, **MRI-GARK** and **IMEX-MRI-GARK** methods follow the above pattern, with non-overlapping - fast IVP time intervals :math:`[t_{0,i},t_{F,i}] = [t_{n-1}+c_{i-1}h^S, t_{n-1}+c_ih^S]` and - :math:`[\tilde{t}_{0},\tilde{t}_{F}] = [t_{n-1}+c_{s-1}h^S, t_{n}]`, and initial conditions - :math:`v_{0,i}=z_{i-1}` and :math:`\tilde{v}_0=z_{s-1}`. +The fast stage IVPs, :eq:`MRI_fast_IVP`, are evolved over non-overlapping +intervals :math:`[t_{0,i},t_{F,i}] = [t_{n-1}+c_{i-1}h^S, t_{n-1}+c_ih^S]` with +the initial condition :math:`v_{0,i}=z_{i-1}`. The fast IVP forcing function is +given by - **MERK** and **IMEX-MRI-SR** methods evolve the fast IVPs :eq:`MRI_fast_IVP` and :eq:`MRI_embedding_fast_IVP` - on overlapping time intervals :math:`[t_{0,i},t_{F,i}] = [t_{n-1}, t_{n-1}+c_i h^S]` and - :math:`[\tilde{t}_{0},\tilde{t}_{F}] = [t_{n-1}, t_{n}]`, using initial conditions - :math:`v_{0,i}=y_{n-1}` and :math:`\tilde{v}_0=y_{n-1}`. +.. math:: + r_i(t) = \frac{1}{\Delta c_i^S} \sum\limits_{j=1}^{i-1} \omega_{i,j}(\tau) f^E(t_{n,j}^I, z_j) + + \frac{1}{\Delta c_i^S} \sum\limits_{j=1}^i \gamma_{i,j}(\tau) f^I(t_{n,j}^I, z_j) - **MERK** methods never include the stage updates :eq:`MRI_implicit_solve` or - :eq:`MRI_embedding_implicit_solve`. +where :math:`\Delta c_i^S=\left(c^S_i - c^S_{i-1}\right)`, :math:`\tau = (t - +t_{n,i-1}^S)/(h^S \Delta c_i^S)` is the normalized time, the coefficients +:math:`\omega_{i,j}` and :math:`\gamma_{i,j}` are polynomials in time of degree +:math:`k` given by - **IMEX-MRI-SR** methods perform *both* the fast IVP evolution (:eq:`MRI_fast_IVP` or - :eq:`MRI_embedding_fast_IVP`) *and* stage update (:eq:`MRI_implicit_solve` - or :eq:`MRI_embedding_implicit_solve`) in every stage (but typically have far fewer - stages than implicit MRI-GARK or IMEX-MRI-GARK methods). +.. math:: + \omega_{i,j}(\tau) = \sum_{k\geq 1} \Omega_{i,j,k} \, \tau^{k-1} + \quad\text{and}\quad + \gamma_{i,j}(\tau) = \sum_{k\geq 1} \Gamma_{i,j,k} \, \tau^{k-1}. + :label: ARKODE_MRI_coupling +When the slow abscissa are repeated, i.e. :math:`\Delta c_i^S = 0`, the fast IVP +can be rescaled and integrated analytically leading to the Runge--Kutta update +:eq:`MRI_implicit_solve` instead of the fast IVP evolution. In this case the +stage is computed as -The specific aspects of the fast IVP forcing function (:math:`r_i(t)` or :math:`\tilde{r}(t)`) -and Runge--Kutta stage coefficients and data (:math:`\gamma_{i,i}`, :math:`\tilde{\gamma}`, -:math:`a_i` and :math:`\tilde{a}`), are determined by the method family (MRI-GARK, MERK, etc.). -Generally, however, the forcing functions and Runge--Kutta stage update data, :math:`r_i(t)`, -:math:`\tilde{r}(t)`, :math:`a_i` and :math:`\tilde{a}`, are constructed using evaluations of -the slow RHS functions :math:`f^E` and :math:`f^I` at preceding stages, :math:`z_j`. -For specific details, please see the references for each method family listed above. +.. math:: + z_i = z_{i-1} + + h^S \sum_{j=1}^{i-1} \left(\sum_{k\geq 1} + \frac{\Omega_{i,j,k}}{k}\right) f^E(t_{n,j}^S, z_j) + + h^S \sum_{j=1}^i \left(\sum_{k\geq 1} + \frac{\Gamma_{i,j,k}}{k}\right) f^I(t_{n,j}^S, z_j). + :label: ARKODE_MRI_delta_c_zero -The fast (inner) IVP solves can be carried out using either the ARKStep module -(allowing for explicit, implicit, or ImEx treatments of the fast time scale with -fixed or adaptive steps), or a user-defined integration method (see section -:numref:`ARKODE.Usage.MRIStep.CustomInnerStepper`). +Similarly, the embedded solution IVP, :eq:`MRI_embedding_fast_IVP`, is evolved +over the interval :math:`[\tilde{t}_{0},\tilde{t}_{F}] = [t_{n-1}+c_{s-1}h^S, t_{n}]` +with the initial condition :math:`\tilde{v}_0=z_{s-1}`. As with standard ARK and DIRK methods, implicitness at the slow time scale is -characterized by nonzero coefficient values :math:`\gamma_{i,i}` or :math:`\tilde{\gamma}`. - -For problems with only a slow-nonstiff term (:math:`f^I \equiv 0`), MRIStep -provides first through fourth order explicit MRI-GARK methods, as well as explicit MERK methods -of orders two through five. In cases with only a slow-stiff term (:math:`f^E \equiv 0`), MRIStep -supplies first through fourth order implicit MRI-GARK methods. For applications -with both stiff and nonstiff slow terms, MRIStep implements first through fourth -order IMEX-MRI-GARK methods, as well as IMEX-MRI-SR methods of orders two through four. We note -that ImEx methods may also be applied to problems with simpler structure through specification of -either :math:`f^I=0` or :math:`f^E=0`. For a complete list of the methods available in -MRIStep see :numref:`ARKODE.Usage.MRIStep.MRIStepCoupling.Tables`. Additionally, users -may supply their own method by defining and attaching a coupling table, see -:numref:`ARKODE.Usage.MRIStep.MRIStepCoupling` for more information. - +characterized by nonzero values on or above the diagonal of the :math:`k` +matrices in :math:`\Gamma`. Typically, MRI-GARK and IMEX-MRI-GARK methods are at +most diagonally-implicit (i.e., :math:`\Gamma_{i,j,k}=0` for all :math:`k` and +:math:`j>i`). Furthermore, diagonally-implicit stages are characterized as being +"solve-decoupled" if :math:`\Delta c_i^S = 0` when :math:`\Gamma_{i,i,k} \ne 0`, +in which case the stage is computed as standard ARK or DIRK update. Alternately, +a diagonally-implicit stage :math:`i` is considered "solve-coupled" if +:math:`\Delta c^S_i \, \Gamma_{i,j,k} \ne 0`, in which +case the stage solution :math:`z_i` is *both* an input to :math:`r_i(t)` and the +result of time-evolution of the fast IVP, necessitating an implicit solve that +is coupled to the fast evolution. At present, only "solve-decoupled" +diagonally-implicit MRI-GARK and IMEX-MRI-GARK methods are supported. + + +IMEX-MRI-SR Methods +------------------- + +The IMEX-MRI-SR family of methods perform *both* the fast IVP evolution, +:eq:`MRI_fast_IVP` or :eq:`MRI_embedding_fast_IVP`, *and* stage update, +:eq:`MRI_implicit_solve` or :eq:`MRI_embedding_implicit_solve`, in every stage +(but these methods typically have far fewer stages than implicit MRI-GARK or +IMEX-MRI-GARK methods). + +These methods evolve the fast IVPs, :eq:`MRI_fast_IVP` and +:eq:`MRI_embedding_fast_IVP`, on overlapping time intervals +:math:`[t_{0,i},t_{F,i}] = [t_{n-1}, t_{n-1}+c_i h^S]` and +:math:`[\tilde{t}_{0},\tilde{t}_{F}] = [t_{n-1}, t_{n}]`, using initial +conditions :math:`v_{0,i}=y_{n-1}` and :math:`\tilde{v}_0=y_{n-1}`. + + +MERK Methods +------------ + +MERK family of methods never include the stage updates, :eq:`MRI_implicit_solve` +or :eq:`MRI_embedding_implicit_solve`. + +These methods evolve the fast IVPs, :eq:`MRI_fast_IVP` and +:eq:`MRI_embedding_fast_IVP`, on overlapping time intervals +:math:`[t_{0,i},t_{F,i}] = [t_{n-1}, t_{n-1}+c_i h^S]` and +:math:`[\tilde{t}_{0},\tilde{t}_{F}] = [t_{n-1}, t_{n}]`, using initial +conditions :math:`v_{0,i}=y_{n-1}` and :math:`\tilde{v}_0=y_{n-1}`. .. _ARKODE.Mathematics.Error.Norm: From 0419c3ad2bfe0419cc20e138b38d445d91960271 Mon Sep 17 00:00:00 2001 From: "David J. Gardner" Date: Fri, 4 Oct 2024 15:49:06 -0700 Subject: [PATCH 121/286] notational consistency --- doc/arkode/guide/source/Mathematics.rst | 20 ++++----- .../Custom_Inner_Stepper/Description.rst | 4 +- .../MRIStep/Custom_Inner_Stepper/index.rst | 12 ++--- .../source/Usage/MRIStep/MRIStepCoupling.rst | 45 ++++++++++--------- 4 files changed, 40 insertions(+), 41 deletions(-) diff --git a/doc/arkode/guide/source/Mathematics.rst b/doc/arkode/guide/source/Mathematics.rst index 4e62c500c8..6ae2185ab0 100644 --- a/doc/arkode/guide/source/Mathematics.rst +++ b/doc/arkode/guide/source/Mathematics.rst @@ -1371,30 +1371,26 @@ based on the type of mass-matrix supplied by the user. have the residual .. math:: - G(z_i) \equiv z_i - h^S \left(\sum_{k\geq 0} \frac{\gamma_{i,i}^{\{k\}}}{k+1}\right) + G(z_i) \equiv z_i - h^S \left(\sum_{k\geq 1} \frac{\Gamma_{i,i,k}}{k}\right) f^I(t_{n,i}^S, z_i) - a_i = 0 :label: ARKODE_IMEX-MRI-GARK_Residual where .. math:: - a_i \equiv z_{i-1} + h^S \sum_{j=1}^{i-1} \left(\sum_{k\geq 0} - \frac{\gamma_{i,j}^{\{k\}}}{k+1}\right)f^I(t_{n,j}^S, z_j), + a_i \equiv z_{i-1} + h^S \sum_{j=1}^{i-1} \left(\sum_{k\geq 1} + \frac{\Gamma_{i,j,k}}{k}\right)f^I(t_{n,j}^S, z_j). - and the tables :math:`\Omega^{\{k\}}` and :math:`\Gamma^{\{k\}}` store the slow-to-fast coupling - coefficients for the explicit and implicit components, respectively. Similarly, IMEX-MRI-SR - methods have the residual + IMEX-MRI-SR methods have the residual .. math:: - G(z_i) \equiv z_i - h^S \gamma_{i,i} f^I(t_{n,i}^S, z_i) - a_i = 0 + G(z_i) \equiv z_i - h^S \Gamma_{i,i} f^I(t_{n,i}^S, z_i) - a_i = 0 :label: ARKODE_IMEX-MRI-SR_Residual where .. math:: - a_i \equiv z_{i-1} + h^S \sum_{j=1}^{i-1} \gamma_{i,j} f^I(t_{n,j}^S, z_j), - - and where the table :math:`\Gamma` stores the slow implicit stage coefficients. + a_i \equiv z_{i-1} + h^S \sum_{j=1}^{i-1} \Gamma_{i,j} f^I(t_{n,j}^S, z_j). Upon solving for :math:`z_i`, method stages must store @@ -1453,7 +1449,7 @@ within ARKStep, or .. math:: {\mathcal A}(t,z) \approx I - \gamma J(t,z), \quad J(t,z) = \frac{\partial f^I(t,z)}{\partial z}, \quad\text{and}\quad - \gamma = h^S \sum_{k\geq 0} \frac{\gamma_{i,i}^{\{k\}}}{k+1} + \gamma = h^S \sum_{k\geq 1} \frac{\Gamma_{i,i,k}}{k} :label: ARKODE_NewtonMatrix_MRIStep within MRIStep. @@ -1548,7 +1544,7 @@ or .. math:: \tilde{\mathcal A}(\tilde{t},\tilde{z}) \approx I - \tilde{\gamma} J(\tilde{t},\tilde{z}), \quad\text{and}\quad - \tilde{\gamma} = \tilde{h} \sum_{k\geq 0} \frac{\gamma_{i,i}^{\{k\}}}{k+1}\quad\text{(MRIStep)}. + \tilde{\gamma} = \tilde{h} \sum_{k\geq 1} \frac{\Gamma_{i,i,k}}{k}\quad\text{(MRIStep)}. :label: ARKODE_modified_NewtonMatrix_MRI Here, the solution :math:`\tilde{z}`, time :math:`\tilde{t}`, and step diff --git a/doc/arkode/guide/source/Usage/MRIStep/Custom_Inner_Stepper/Description.rst b/doc/arkode/guide/source/Usage/MRIStep/Custom_Inner_Stepper/Description.rst index 80a9577158..1c5804de59 100644 --- a/doc/arkode/guide/source/Usage/MRIStep/Custom_Inner_Stepper/Description.rst +++ b/doc/arkode/guide/source/Usage/MRIStep/Custom_Inner_Stepper/Description.rst @@ -300,7 +300,7 @@ data necessary to construct the inner (fast) forcing polynomial. This function provides access to data necessary to compute the forcing term :eq:`ARKODE_MRI_forcing_poly`. This includes the shift and scaling factors for the normalized time :math:`\tau = (t - t_{n,i-1}^S)/(h^S \Delta c_i^S)` and the - array of polynomial coefficient vectors :math:`\hat{\gamma}^{\{k\}}_i`. + array of polynomial coefficient vectors :math:`\hat{\gamma}^{i,k}`. :param stepper: an inner stepper object. :param tshift: the time shift to apply to the current time when computing the @@ -308,7 +308,7 @@ data necessary to construct the inner (fast) forcing polynomial. :param tscale: the time scaling to apply to the current time when computing the forcing, :math:`h^S \Delta c_i^S`. :param forcing: a pointer to an array of forcing vectors, - :math:`\hat{\gamma}^{\{k\}}_i`. + :math:`\hat{\gamma}_{i,k}`. :param nforcing: the number of forcing vectors. :retval ARK_SUCCESS: if successful diff --git a/doc/arkode/guide/source/Usage/MRIStep/Custom_Inner_Stepper/index.rst b/doc/arkode/guide/source/Usage/MRIStep/Custom_Inner_Stepper/index.rst index f1ffa424d3..a1f5272aae 100644 --- a/doc/arkode/guide/source/Usage/MRIStep/Custom_Inner_Stepper/index.rst +++ b/doc/arkode/guide/source/Usage/MRIStep/Custom_Inner_Stepper/index.rst @@ -29,9 +29,9 @@ presented in :numref:`ARKODE.Mathematics.MRIStep` can be equivalently written as .. math:: r_i(t) = - \sum\limits_{k \geq 0} \hat{\omega}^{\{k\}}_i \tau^k + \sum\limits_{k \geq 1} \hat{\omega}_{i,k} \tau^{k-1} + - \sum\limits_{k \geq 0} \hat{\gamma}^{\{k\}}_i \tau^k + \sum\limits_{k \geq 1} \hat{\gamma}_{i,k} \tau^{k-1} :label: ARKODE_MRI_forcing_poly where :math:`\tau = (t - t_{n,i-1}^S)/(h^S \Delta c_i^S)` is the normalized time @@ -40,11 +40,11 @@ with :math:`\Delta c_i^S=\left(c^S_i - c^S_{i-1}\right)`, the slow stage times a vectors are .. math:: - \hat{\omega}^{\{k\}}_i = \frac{1}{\Delta c_i^S} \sum\limits_{j=1}^{i-1} - \omega^{\{k\}}_{i,j} f^E(t_{n,j}^S, z_j) + \hat{\omega}_{i,k} = \frac{1}{\Delta c_i^S} \sum\limits_{j=1}^{i-1} + \Omega_{i,j,k} f^E(t_{n,j}^S, z_j) \quad\text{and}\quad - \hat{\gamma}^{\{k\}}_i = \frac{1}{\Delta c_i^S} \sum\limits_{j=1}^i - \gamma^{\{k\}}_{i,j} f^I(t_{n,j}^S, z_j). + \hat{\gamma}_{i,k} = \frac{1}{\Delta c_i^S} \sum\limits_{j=1}^i + \Gamma_{i,j,k} f^I(t_{n,j}^S, z_j). :label: ARKODE_MRI_forcing_coefficients The MERK and IMEX-MRI-SR methods included in MRIStep compute the forcing polynomial diff --git a/doc/arkode/guide/source/Usage/MRIStep/MRIStepCoupling.rst b/doc/arkode/guide/source/Usage/MRIStep/MRIStepCoupling.rst index c9ee71835e..4f1e8a2d0b 100644 --- a/doc/arkode/guide/source/Usage/MRIStep/MRIStepCoupling.rst +++ b/doc/arkode/guide/source/Usage/MRIStep/MRIStepCoupling.rst @@ -65,8 +65,8 @@ The MRI coupling tables themselves are stored in an As described in :numref:`ARKODE.Mathematics.MRIStep`, the coupling from the slow time scale to the fast time scale is encoded by a vector of slow stage time abscissae, :math:`c^S \in \mathbb{R}^{s+1}` and a set of coupling - matrices :math:`\Gamma^{\{k\}}\in\mathbb{R}^{(s+1)\times(s+1)}` and - :math:`\Omega^{\{k\}}\in\mathbb{R}^{(s+1)\times(s+1)}`. + tensors :math:`\Gamma\in\mathbb{R}^{(s+1)\times(s+1)\times k}` and + :math:`\Omega\in\mathbb{R}^{(s+1)\times(s+1)\times k}`. .. c:member:: ARKODE_MRIType type @@ -74,9 +74,9 @@ The MRI coupling tables themselves are stored in an .. c:member:: int nmat - The number of coupling matrices :math:`\Omega^{\{k\}}` for the - slow-nonstiff terms and/or :math:`\Gamma^{\{k\}}` for the slow-stiff terms - in :eq:`ARKODE_IVP_two_rate`. + The value of :math:`k` above i.e., number of coupling matrices in + :math:`\Omega` for the slow-nonstiff terms and/or in :math:`\Gamma` for + the slow-stiff terms in :eq:`ARKODE_IVP_two_rate`. .. c:member:: int stages @@ -98,13 +98,13 @@ The MRI coupling tables themselves are stored in an .. c:member:: sunrealtype*** W A three-dimensional array with dimensions ``[nmat][stages+1][stages]`` - containing the method's :math:`\Omega^{\{k\}}` coupling matrices for the + containing the method's :math:`\Omega` coupling coefficients for the slow-nonstiff (explicit) terms in :eq:`ARKODE_IVP_two_rate`. .. c:member:: sunrealtype*** G A three-dimensional array with dimensions ``[nmat][stages+1][stages]`` - containing the method's :math:`\Gamma^{\{k\}}` coupling matrices for the + containing the method's :math:`\Gamma` coupling coefficients for the slow-stiff (implicit) terms in :eq:`ARKODE_IVP_two_rate`. .. c:member:: int ngroup @@ -186,8 +186,9 @@ are defined ``arkode/arkode_mristep.h``. Allocates an empty MRIStepCoupling table. - :param nmat: number of :math:`\Omega^{\{k\}}` and/or :math:`\Gamma^{\{k\}}` - matrices in the coupling table. + :param nmat: the value of :math:`k` i.e., number of number of coupling + matrices in :math:`\Omega` for the slow-nonstiff terms and/or in + :math:`\Gamma` for the slow-stiff terms in :eq:`ARKODE_IVP_two_rate`. :param stages: number of stages in the coupling table. :param type: the type of MRI method the table will encode. @@ -229,15 +230,16 @@ are defined ``arkode/arkode_mristep.h``. Allocates a coupling table and fills it with the given values. - :param nmat: number of :math:`\Omega^{\{k\}}` and/or :math:`\Gamma^{\{k\}}` - matrices in the coupling table. + :param nmat: the value of :math:`k` i.e., number of number of coupling + matrices in :math:`\Omega` for the slow-nonstiff terms and/or in + :math:`\Gamma` for the slow-stiff terms in :eq:`ARKODE_IVP_two_rate`. :param stages: number of stages in the method. :param q: global order of accuracy for the method. :param p: global order of accuracy for the embedded method. - :param W: array of coefficients defining the explicit coupling matrices - :math:`\Omega^{\{k\}}`. If the slow method is implicit pass ``NULL``. - :param G: array of coefficients defining the implicit coupling matrices - :math:`\Gamma^{\{k\}}`. If the slow method is explicit pass ``NULL``. + :param W: array of values defining the explicit coupling coefficients + :math:`\Omega`. If the slow method is implicit pass ``NULL``. + :param G: array of values defining the implicit coupling coefficients + :math:`\Gamma`. If the slow method is explicit pass ``NULL``. :param c: array of slow abscissae for the MRI method. The entries should be stored as a 1D array of length ``stages``. @@ -289,7 +291,8 @@ are defined ``arkode/arkode_mristep.h``. .. math:: - \omega_{i,j}^{\{0\}} \;\text{or}\; \gamma_{i,j}^{\{0\}} = \begin{cases} + \Omega_{i,j,1} \;\text{or}\; \Gamma_{i,j,1} = + \begin{cases} 0, & \text{if}\; i=1,\\ A_{i,j}-A_{i-1,j}, & \text{if}\; 2\le i\le s,\\ b_{j}-A_{s,j}, & \text{if}\; i= s+1. @@ -299,13 +302,13 @@ are defined ``arkode/arkode_mristep.h``. .. math:: - \tilde{\omega}_{i,j}^{\{0\}} \;\text{or}\; \tilde{\gamma}_{i,j}^{\{0\}} = \tilde{b}_{j}-A_{s,j}. + \tilde{\Omega}_{i,j,1} \;\text{or}\; \tilde{\Gamma}_{i,j,1} = \tilde{b}_{j}-A_{s,j}. - We note that only one of :math:`\Omega^{\{0\}}` or :math:`\Gamma^{\{0\}}` will - be filled in. If *B* corresponded to an explicit method, then this routine - fills :math:`\Omega^{\{0\}}`; if *B* is diagonally-implicit, then this routine + We note that only one of :math:`\Omega` or :math:`\Gamma` will + be filled in. If *B* corresponded to an explicit method, then this routine + fills :math:`\Omega`; if *B* is diagonally-implicit, then this routine inserts redundant "padding" stages to ensure a solve-decoupled structure and - then uses the above formula to fill :math:`\Gamma^{\{0\}}`. + then uses the above formula to fill :math:`\Gamma`. For general slow tables with at least second-order accuracy, the MIS method will be second order. However, if the slow table is at least third order and From 3e09545044aac2aabeaa7a071a96a40f33853cfa Mon Sep 17 00:00:00 2001 From: "David J. Gardner" Date: Fri, 4 Oct 2024 15:49:21 -0700 Subject: [PATCH 122/286] wrap long line --- .../guide/source/Usage/MRIStep/MRIStepCoupling.rst | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/doc/arkode/guide/source/Usage/MRIStep/MRIStepCoupling.rst b/doc/arkode/guide/source/Usage/MRIStep/MRIStepCoupling.rst index 4f1e8a2d0b..625d3bb89e 100644 --- a/doc/arkode/guide/source/Usage/MRIStep/MRIStepCoupling.rst +++ b/doc/arkode/guide/source/Usage/MRIStep/MRIStepCoupling.rst @@ -208,10 +208,17 @@ are defined ``arkode/arkode_mristep.h``. For MRISTEP_MRISR tables, the *group* array is not allocated. - When allocated, each of :math:`\Omega^{\{k\}}` and :math:`\Gamma^{\{k\}}` + When allocated, both :math:`\Omega` and :math:`\Gamma` are initialized to all zeros, so only nonzero coefficients need to be provided. - When allocated, all entries in *group* are initialized to ``-1``, indicating an unused group and/or the end of a stage group. Users who supply a custom MRISTEP_MERK table should over-write all active stages in each group. For example the ``ARKODE_MERK32`` method has 4 stages that are evolved in 3 groups -- the first group consists of stage 1, the second group consists of stages 2 and 4, while the third group consists of stage 3. Thus *ngroup* should equal 3, and *group* should have non-default entries + When allocated, all entries in *group* are initialized to ``-1``, + indicating an unused group and/or the end of a stage group. Users who + supply a custom MRISTEP_MERK table should over-write all active stages in + each group. For example the ``ARKODE_MERK32`` method has 4 stages that + are evolved in 3 groups -- the first group consists of stage 1, the second + group consists of stages 2 and 4, while the third group consists of + stage 3. Thus *ngroup* should equal 3, and *group* should have + non-default entries .. code-block:: C From 963ddf8a42663cc6c53c1027c3bf286ffbcfc3b0 Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Sun, 20 Oct 2024 13:13:52 -0500 Subject: [PATCH 123/286] bugfix (to resolve change added in PR revisions) --- src/arkode/arkode_mri_tables.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/arkode/arkode_mri_tables.c b/src/arkode/arkode_mri_tables.c index d89b577749..021d03c638 100644 --- a/src/arkode/arkode_mri_tables.c +++ b/src/arkode/arkode_mri_tables.c @@ -812,6 +812,7 @@ int mriStepCoupling_GetStageType(MRIStepCoupling MRIC, int is) } else { /* embedding */ + Gdiag = Grow = Wrow = cdiff = SUNFALSE; if (MRIC->G) { for (i = 0; i < MRIC->nmat; i++) From 2af1f57fd2c69a6b30bb1a1787e4a3e52e1962da Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Sun, 20 Oct 2024 14:03:32 -0500 Subject: [PATCH 124/286] Minor parameter update --- src/sunadaptcontroller/mrihtol/sunadaptcontroller_mrihtol.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sunadaptcontroller/mrihtol/sunadaptcontroller_mrihtol.c b/src/sunadaptcontroller/mrihtol/sunadaptcontroller_mrihtol.c index 7b2fba0c17..0e454c562e 100644 --- a/src/sunadaptcontroller/mrihtol/sunadaptcontroller_mrihtol.c +++ b/src/sunadaptcontroller/mrihtol/sunadaptcontroller_mrihtol.c @@ -162,7 +162,7 @@ SUNErrCode SUNAdaptController_EstimateStepTol_MRIHTol( /* Call fast time scale sub-controller with order=1: no matter the integrator order, we expect its error to be proportional to the tolerance factor */ - SUNCheckCall(SUNAdaptController_EstimateStep(MRIHTOL_CFAST(C), tolfac, 1, dsm, + SUNCheckCall(SUNAdaptController_EstimateStep(MRIHTOL_CFAST(C), tolfac, 0, dsm, &tolfacest)); /* Enforce bounds on estimated tolerance factor */ From 664ac54a3a0ba2bda1c761cf9ad93f1d127cc831 Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Mon, 21 Oct 2024 21:54:45 -0500 Subject: [PATCH 125/286] Added alias --- include/arkode/arkode_mristep.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/include/arkode/arkode_mristep.h b/include/arkode/arkode_mristep.h index d3a9abb9ad..3812b04d07 100644 --- a/include/arkode/arkode_mristep.h +++ b/include/arkode/arkode_mristep.h @@ -41,6 +41,11 @@ typedef enum MRISTEP_MRISR } ARKODE_MRIType; +/* Alias to account for the changed enum name above */ +typedef ARKODE_MRIType MRISTEP_METHOD_TYPE; + +/* MRI coupling table IDs */ + typedef enum { ARKODE_MRI_NONE = -1, /* ensure enum is signed int */ From 67f02c03976ff73fafff2420f9be9593f30d5a5e Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Mon, 21 Oct 2024 21:55:06 -0500 Subject: [PATCH 126/286] Manual fixes from code review --- doc/arkode/guide/source/Mathematics.rst | 34 +++++++++---------- .../source/Usage/MRIStep/MRIStepCoupling.rst | 3 +- .../source/Usage/MRIStep/User_callable.rst | 4 +-- .../SUNAdaptController_MRIHTol.rst | 12 +++---- 4 files changed, 26 insertions(+), 27 deletions(-) diff --git a/doc/arkode/guide/source/Mathematics.rst b/doc/arkode/guide/source/Mathematics.rst index 6ae2185ab0..7ce4019ecb 100644 --- a/doc/arkode/guide/source/Mathematics.rst +++ b/doc/arkode/guide/source/Mathematics.rst @@ -1012,21 +1012,20 @@ To this end, we assume that the inner solver will provide accumulated errors over each fast interval having the form .. math:: - \varepsilon^f_{n} = c(t_n) \left(\text{reltol}_n^f\right) \left(t_{F,i}-t_{0,i}\right), + \varepsilon^f_{n} = c(t_n) h^S_n \left(\text{RTOL}_n^f\right), :label: fast_error_accumulation_assumption -where :math:`c(t)` is independent of the tolerance or subinterval width, but may vary in time. +where :math:`c(t)` is independent of the tolerance or step size, but may vary in time. Single-scale adaptive controllers assume that the local error at a step :math:`n` with step -size :math:`h^S` has order :math:`p`, i.e., +size :math:`h_n` has order :math:`p`, i.e., .. math:: - LTE_n = c(t_n) (h^S)^{p+1}, + LTE_n = c(t_n) (h_n)^{p+1}, -to predict candidate values :math:`h^S_{n+1}`. We may therefore repurpose an existing -single-scale controller to predict candidate values :math:`\text{reltol}^f_{n+1}` by +to predict candidate values :math:`h_{n+1}`. We may therefore repurpose an existing +single-scale controller to predict candidate values :math:`\text{RTOL}^f_{n+1}` by supplying an "order" :math:`p=0` and a "control parameter" -:math:`h^S_n=\left(\text{reltol}_n^f\right) \left(t_{F,i}-t_{0,i}\right)`, and scaling -the output by the subinterval width. +:math:`h_n=\left(\text{RTOL}_n^f\right)`. Thus to construct an :math:`h^S-Tol` controller, we require three separate single-rate adaptivity controllers: @@ -1034,11 +1033,11 @@ adaptivity controllers: * scontrol-H -- this is a single-rate controller that adapts :math:`h^S_n` within the slow integrator to achieve user-requested solution tolerances. -* scontrol-Tol -- this is a single-rate controller that adapts :math:`\text{reltol}^f_n` +* scontrol-Tol -- this is a single-rate controller that adapts :math:`\text{RTOL}^f_n` using the strategy described above. * fcontrol -- this adapts time steps :math:`h^F` within the fast integrator to achieve - the current tolerance, :math:`\text{reltol}^f_n`. + the current tolerance, :math:`\text{RTOL}^f_n`. We note that both the decoupled and :math:`h^S-Tol` controller families may be used in multirate calculations with an arbitrary number of time scales, since these focus on only @@ -1161,17 +1160,17 @@ method computes an estimate of the local temporal error, :math:`\varepsilon^f_{n the fast integrator itself is temporally adaptive. In this case, we assume that the fast integrator was run with the same absolute tolerances as the slow integrator, but that it may have used a potentially different relative solution tolerance, -:math:`\text{reltol}^f`. The fast integrator then accumulates these local error +:math:`\text{RTOL}^f`. The fast integrator then accumulates these local error estimates using either a "maximum accumulation: strategy, .. math:: - \varepsilon^f_{max} = \text{reltol}^f \max_{m\in M} \|\varepsilon^f_{n,m}\|_{WRMS}, + \varepsilon^f_{max} = \text{RTOL}^f \max_{m\in M} \|\varepsilon^f_{n,m}\|_{WRMS}, :label: maximum_accumulation or using an "averaged accumulation" strategy, .. math:: - \varepsilon^f_{avg} = \frac{\text{reltol}^f}{|M|} \sum_{m\in M} \|\varepsilon^f_{n,m}\|_{WRMS}, + \varepsilon^f_{avg} = \frac{\text{RTOL}^f}{|M|} \sum_{m\in M} \|\varepsilon^f_{n,m}\|_{WRMS}, :label: average_accumulation where the norm is taken using the tolerance-informed error-weight vector. In @@ -1300,18 +1299,17 @@ Nonlinear solver methods ------------------------------------ -For the DIRK and ARK methods corresponding to :eq:`ARKODE_IMEX_IVP` and +Methods with an implicit partition require solving implicit systems of the form :eq:`ARKODE_IVP_implicit` in ARKStep, and the implicit slow stages :eq:`MRI_implicit_solve` or :eq:`MRI_embedding_implicit_solve` in MRIStep, an implicit system .. math:: - G(z_i) = 0 + G(z_i) = 0. :label: ARKODE_Residual -must be solved for each implicit stage :math:`z_i`. In order to -maximize solver efficiency, we define this root-finding problem differently -based on the type of mass-matrix supplied by the user. +In order to maximize solver efficiency, we define this root-finding problem +differently based on the type of mass-matrix supplied by the user. * In the case that :math:`M=I` within ARKStep, we define the residual as diff --git a/doc/arkode/guide/source/Usage/MRIStep/MRIStepCoupling.rst b/doc/arkode/guide/source/Usage/MRIStep/MRIStepCoupling.rst index 625d3bb89e..078134e1d0 100644 --- a/doc/arkode/guide/source/Usage/MRIStep/MRIStepCoupling.rst +++ b/doc/arkode/guide/source/Usage/MRIStep/MRIStepCoupling.rst @@ -229,7 +229,8 @@ are defined ``arkode/arkode_mristep.h``. .. versionchanged:: x.y.z - In previous releases, this function did not include the *type* argument. + In previous releases, this final argument had type ``MRISTEP_METHOD_TYPE``. That has now + been aliased to ``ARKODE_MRIType`` for backwards compatibility. diff --git a/doc/arkode/guide/source/Usage/MRIStep/User_callable.rst b/doc/arkode/guide/source/Usage/MRIStep/User_callable.rst index f37a36e356..8ad5195a27 100644 --- a/doc/arkode/guide/source/Usage/MRIStep/User_callable.rst +++ b/doc/arkode/guide/source/Usage/MRIStep/User_callable.rst @@ -1704,8 +1704,8 @@ Main solver optional output functions of key and value pairs e.g., ``key1,value1,key2,value2,...`` :retval ARK_SUCCESS: -- if the output was successfully. - :retval CV_MEM_NULL: -- if the MRIStep memory was ``NULL``. - :retval CV_ILL_INPUT: -- if an invalid formatting option was provided. + :retval ARK_MEM_NULL: -- if the MRIStep memory was ``NULL``. + :retval ARK_ILL_INPUT: -- if an invalid formatting option was provided. .. note:: diff --git a/doc/shared/sunadaptcontroller/SUNAdaptController_MRIHTol.rst b/doc/shared/sunadaptcontroller/SUNAdaptController_MRIHTol.rst index bc2303210c..0a385a3fa2 100644 --- a/doc/shared/sunadaptcontroller/SUNAdaptController_MRIHTol.rst +++ b/doc/shared/sunadaptcontroller/SUNAdaptController_MRIHTol.rst @@ -41,11 +41,11 @@ results from two types of error: #. "Fast" errors introduced through calls to the next-fastest ("inner") solver, :math:`\varepsilon^f_{n}`. If this inner solver is called to evolve IVPs over time intervals :math:`[t_{0,i}, t_{F,i}]` with a relative tolerance - :math:`\text{reltol}_n^f`, then it will result in accumulated errors over these + :math:`\text{RTOL}_n^f`, then it will result in accumulated errors over these intervals of the form .. math:: - \varepsilon^f_{n} = c(t_n) \left(\text{reltol}_n^f\right) \left(t_{F,i}-t_{0,i}\right), + \varepsilon^f_{n} = c(t_n) \left(\text{RTOL}_n^f\right) \left(t_{F,i}-t_{0,i}\right), where :math:`c(t)` is independent of the tolerance or subinterval width but may vary in time, or equivalently, @@ -54,10 +54,10 @@ results from two types of error: \varepsilon^f_{n} = \kappa(t_n) \left(\text{tolfac}_n^f\right), :label: inner_solver_assumption - where :math:`\text{reltol}_n^f = \text{reltol}^s \text{tolfac}_n^f`, - :math:`\text{reltol}^s` is the relative tolerance that was supplied to the + where :math:`\text{RTOL}_n^f = \text{RTOL}^s \text{tolfac}_n^f`, + :math:`\text{RTOL}^s` is the relative tolerance that was supplied to the current time scale solver, and where - :math:`\kappa(t_n) = c(t_n) \text{reltol}^s \left(t_{F,i}-t_{0,i}\right)` is + :math:`\kappa(t_n) = c(t_n) \text{RTOL}^s \left(t_{F,i}-t_{0,i}\right)` is independent of the relative tolerance factor, :math:`\text{tolfac}_n^f`. Single-rate controllers are constructed to adapt a single parameter, e.g., @@ -112,7 +112,7 @@ These entries of the *content* field contain the following information: the current step size, :math:`h^s_n`. * ``TolControl`` - single time-scale SUNAdaptController object to adapt - the inner solver relative tolerance factor, :math:`\text{reltol}^f_n`. + the inner solver relative tolerance factor, :math:`\text{RTOL}^f_n`. * ``inner_max_relch`` - the parameter :math:`\text{max}_{relch}` above. From a2e416a7ab23d61b8ad8fe4f67acd6215859a170 Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Mon, 21 Oct 2024 22:22:09 -0500 Subject: [PATCH 127/286] Apply documentation suggestions from code review Co-authored-by: David Gardner --- CHANGELOG.md | 7 ++++--- doc/shared/RecentChanges.rst | 9 +++++---- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 48756bd544..94734867e2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -41,7 +41,7 @@ Added functionality to ARKODE to accumulate a temporal error estimate over multiple time steps. See the routines `ARKodeSetAccumulatedErrorType`, `ARKodeResetAccumulatedError`, and `ARKodeGetAccumulatedError` for details. -Added utility routine to wrap any valid ARKODE integrator for use as an MRIStep +Added a utility routine to wrap any valid ARKODE integrator for use as an MRIStep inner stepper object, `ARKodeCreateMRIStepInnerStepper`. ### Bug Fixes @@ -73,8 +73,9 @@ using `ENABLE_KLU=ON` in combination with a static-only build of SuiteSparse. ### Deprecation Notices -Deprecated ARKStep-specific utility routine for wrapping as an MRIStep -inner stepper object, `ARKStepCreateMRIStepInnerStepper`. +Deprecated the ARKStep-specific utility routine for wrapping an ARKStep instance +as an MRIStep inner stepper object, `ARKStepCreateMRIStepInnerStepper`. Use +`ARKodeCreateMRIStepInnerStepper` instead. The ARKODE stepper specific functions to retrieve the number of right-hand side function evaluations have been deprecated. Use `ARKodeGetNumRhsEvals` instead. diff --git a/doc/shared/RecentChanges.rst b/doc/shared/RecentChanges.rst index 5e0bc0b8bd..51638cb9d9 100644 --- a/doc/shared/RecentChanges.rst +++ b/doc/shared/RecentChanges.rst @@ -34,7 +34,7 @@ which should ease building SUNDIALS with LAPACK libraries that require setting specific linker flags e.g., MKL. Added support for multirate time step adaptivity controllers, based on the -recently introduced `SUNAdaptController` base class, to ARKODE's MRIStep module. +recently introduced :c:type:`SUNAdaptController` base class, to ARKODE's MRIStep module. As a part of this, we added embeddings for existing MRI-GARK methods, as well as support for embedded MERK and IMEX-MRI-SR methods. Added new default MRI methods for temporally adaptive versus fixed-step runs. @@ -44,7 +44,7 @@ estimate over multiple time steps. See the routines :c:func:`ARKodeSetAccumulatedErrorType`, :c:func:`ARKodeResetAccumulatedError`, and :c:func:`ARKodeGetAccumulatedError` for details. -Added utility routine to wrap any valid ARKODE integrator for use as an MRIStep +Added a utility routine to wrap any valid ARKODE integrator for use as an MRIStep inner stepper object, :c:func:`ARKodeCreateMRIStepInnerStepper`. **Bug Fixes** @@ -76,8 +76,9 @@ using ``ENABLE_KLU=ON`` in combination with a static-only build of SuiteSparse. **Deprecation Notices** -Deprecated ARKStep-specific utility routine for wrapping as an MRIStep -inner stepper object, :c:func:`ARKStepCreateMRIStepInnerStepper`. +Deprecated the ARKStep-specific utility routine for wrapping an ARKStep instance +as an MRIStep inner stepper object, :c:func:`ARKStepCreateMRIStepInnerStepper`. Use +:c:func:`ARKodeCreateMRIStepInnerStepper` instead. The ARKODE stepper specific functions to retrieve the number of right-hand side function evaluations have been deprecated. Use :c:func:`ARKodeGetNumRhsEvals` From 3ac13b48c70d0d3586117f5a84bf35992ced549b Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Mon, 21 Oct 2024 22:41:29 -0500 Subject: [PATCH 128/286] Apply documentation suggestions from code review (next batch) (I'm having to batch these because GitHub keeps erroring out, saying that I cannot accept recommendations that edit the same line twice). Co-authored-by: David Gardner --- .../Custom_Inner_Stepper/Description.rst | 117 ++++++++++-------- .../source/Usage/MRIStep/MRIStepCoupling.rst | 100 +++++++-------- .../source/Usage/MRIStep/User_callable.rst | 34 +++-- .../guide/source/Usage/User_callable.rst | 65 +++++----- 4 files changed, 168 insertions(+), 148 deletions(-) diff --git a/doc/arkode/guide/source/Usage/MRIStep/Custom_Inner_Stepper/Description.rst b/doc/arkode/guide/source/Usage/MRIStep/Custom_Inner_Stepper/Description.rst index 1c5804de59..a2daa41e4b 100644 --- a/doc/arkode/guide/source/Usage/MRIStep/Custom_Inner_Stepper/Description.rst +++ b/doc/arkode/guide/source/Usage/MRIStep/Custom_Inner_Stepper/Description.rst @@ -19,15 +19,14 @@ The MRIStepInnerStepper Class As with other SUNDIALS classes, the :c:type:`MRIStepInnerStepper` abstract base class is implemented using a C structure containing a ``content`` pointer to the -derived class member data and a structure of function pointers wherein the -derived class implements the base class virtual methods. -The :c:type:`MRIStepInnerStepper` type is defined in ``include/arkode/arkode.h`` as +derived class member data and a structure of function pointers (vtable) to the +derived class implementations of the base class virtual methods. .. c:type:: MRIStepInnerStepper An object for solving the fast (inner) ODE in an MRI method. -The actual definitions of the ``_MRIStepInnerStepper`` structure and the +The actual definitions of the structure and the corresponding operations structure are kept private to allow for the object internals to change without impacting user code. The following sections describe the base (:numref:`ARKODE.Usage.MRIStep.CustomInnerStepper.Description.BaseMethods`) @@ -238,6 +237,8 @@ Setting Member Functions :retval ARK_SUCCESS: if successful :retval ARK_ILL_INPUT: if the stepper is ``NULL`` + + .. versionadded: x.y.z .. c:function:: int MRIStepInnerStepper_SetAccumulatedErrorResetFn(MRIStepInnerStepper stepper, MRIStepInnerResetAccumulatedError fn) @@ -250,6 +251,8 @@ Setting Member Functions :retval ARK_SUCCESS: if successful :retval ARK_ILL_INPUT: if the stepper is ``NULL`` + + .. versionadded: x.y.z .. c:function:: int MRIStepInnerStepper_SetRTolFn(MRIStepInnerStepper stepper, MRIStepInnerSetRTol fn) @@ -262,6 +265,8 @@ Setting Member Functions :retval ARK_SUCCESS: if successful :retval ARK_ILL_INPUT: if the stepper is ``NULL`` + + .. versionadded: x.y.z @@ -364,18 +369,20 @@ member functions: This function advances the state vector *v* for the inner (fast) ODE system from time *t0* to time *tout*. - :param stepper: the inner stepper object. - :param t0: the initial time for the inner (fast) integration. - :param tout: the final time for the inner (fast) integration. - :param v: on input the state at time *t0* and, on output, the state at time *tout*. + **Arguments:** + * *stepper* -- the inner stepper object. + * *t0* -- the initial time for the inner (fast) integration. + * *tout* -- the final time for the inner (fast) integration. + * *v* -- on input the state at time *t0* and, on output, the state at time + *tout*. - :return value: An :c:type:`MRIStepInnerEvolveFn` should return 0 if successful, a positive - value if a recoverable error occurred, or a negative value if it failed - unrecoverably. + **Return value:** + An :c:type:`MRIStepInnerEvolveFn` should return 0 if successful, a positive + value if a recoverable error occurred, or a negative value if it failed + unrecoverably. - .. note:: - - An example of this is in ``examples/arkode/CXX_parallel/ark_diffusion_reaction_p.cpp``. + **Example codes:** + * ``examples/arkode/CXX_parallel/ark_diffusion_reaction_p.cpp`` Optional Member Functions """"""""""""""""""""""""" @@ -389,26 +396,26 @@ following member functions: ODE, :math:`f^F(t,v)` in :eq:`ARKODE_MRI_IVP` for a given value of the independent variable *t* and state vector *y*. - :param stepper: the inner stepper object. - :param t: the current value of the independent variable. - :param y: the current value of the dependent variable vector. - :param f: the output vector that forms a portion the ODE right-hand side, + **Arguments:** + * *stepper* -- the inner stepper object. + * *t* -- the current value of the independent variable. + * *y* -- the current value of the dependent variable vector. + * *f* -- the output vector that forms a portion the ODE right-hand side, :math:`f^F(t,y)` in :eq:`ARKODE_IVP_two_rate`. - :param mode: a flag indicating the purpose for which the right-hand side + * *mode* -- a flag indicating the purpose for which the right-hand side function evaluation is called. * ``ARK_FULLRHS_START`` -- called at the beginning of the simulation * ``ARK_FULLRHS_END`` -- called at the end of a successful step * ``ARK_FULLRHS_OTHER`` -- called elsewhere e.g., for dense output - :return value: An :c:type:`MRIStepInnerFullRhsFn` should return 0 if successful, a positive - value if a recoverable error occurred, or a negative value if it failed - unrecoverably. - - .. note:: - - An example of this is in ``examples/arkode/CXX_parallel/ark_diffusion_reaction_p.cpp``. + **Return value:** + An :c:type:`MRIStepInnerFullRhsFn` should return 0 if successful, a positive + value if a recoverable error occurred, or a negative value if it failed + unrecoverably. + **Example codes:** + * ``examples/arkode/CXX_parallel/ark_diffusion_reaction_p.cpp`` .. versionchanged:: v5.7.0 Supplying a full right-hand side function was made optional. @@ -417,37 +424,44 @@ following member functions: This function resets the inner (fast) stepper state to the provided independent variable value and dependent variable vector. + + If provided, the :c:type:`MRIStepInnerResetFn` function will be called + *before* a call to :c:type:`MRIStepInnerEvolveFn` when the state was + updated at the slow timescale. - :param stepper: the inner stepper object. - :param tR: the value of the independent variable :math:`t_R`. - :param vR: the value of the dependent variable vector :math:`v(t_R)`. + **Arguments:** + * *stepper* -- the inner stepper object. + * *tR* -- the value of the independent variable :math:`t_R`. + * *vR* -- the value of the dependent variable vector :math:`v(t_R)`. - :return value: An :c:type:`MRIStepInnerResetFn` should return 0 if successful, a positive - value if a recoverable error occurred, or a negative value if it failed - unrecoverably. + **Return value:** + An :c:type:`MRIStepInnerResetFn` should return 0 if successful, a positive + value if a recoverable error occurred, or a negative value if it failed + unrecoverably. .. note:: - If provided, the :c:type:`MRIStepInnerResetFn` function will always be called - *before* the function :c:type:`MRIStepInnerEvolveFn` is first called. - An example of this is in ``examples/arkode/CXX_parallel/ark_diffusion_reaction_p.cpp``. + **Example codes:** + * ``examples/arkode/CXX_parallel/ark_diffusion_reaction_p.cpp`` .. c:type:: int (*MRIStepInnerGetAccumulatedError)(MRIStepInnerStepper stepper, sunrealtype* accum_error) This function returns an estimate of the accumulated solution error arising from the inner stepper. - :param stepper: the inner stepper object. - :param accum_error: estimation of the accumulated solution error. + **Arguments:** + * *stepper* -- the inner stepper object. + * *accum_error* -- estimation of the accumulated solution error. - :return value: An :c:type:`MRIStepInnerGetAccumulatedError` should return 0 if successful, a positive - value if a recoverable error occurred, or a negative value if it failed unrecoverably. + **Return value:** + An :c:type:`MRIStepInnerGetAccumulatedError` should return 0 if successful, a positive + value if a recoverable error occurred, or a negative value if it failed unrecoverably. .. note:: This function is only called when multirate temporal adaptivity has been enabled, - using a :c:type:`SUNAdaptController` module having type ``SUNDIALS_CONTROL_MRI_TOL``. + using a :c:type:`SUNAdaptController` module having type :c:enumerator:`SUN_ADAPTCONTROLLER_MRI_TOL`. If provided, the :c:type:`MRIStepInnerGetAccumulatedError` function will always be called *after* a preceding call to the :c:type:`MRIStepInnerResetAccumulatedError` @@ -462,15 +476,17 @@ following member functions: This function resets the inner stepper's accumulated solution error to zero. - :param stepper: the inner stepper object. + **Arguments:** + * *stepper* -- the inner stepper object. - :return value: An :c:type:`MRIStepInnerResetAccumulatedError` should return 0 if successful, a positive` - value if a recoverable error occurred, or a negative value if it failed unrecoverably. + **Return value:** + An :c:type:`MRIStepInnerResetAccumulatedError` should return 0 if successful, a positive` + value if a recoverable error occurred, or a negative value if it failed unrecoverably. .. note:: This function is only called when multirate temporal adaptivity has been enabled, - using a :c:type:`SUNAdaptController` module having type ``SUNDIALS_CONTROL_MRI_TOL``. + using a :c:type:`SUNAdaptController` module having type :c:enumerator:`SUN_ADAPTCONTROLLER_MRI_TOL`. The :c:type:`MRIStepInnerResetAccumulatedError` function will always be called *before* any calls to the :c:type:`MRIStepInnerGetAccumulatedError` function. @@ -488,17 +504,18 @@ following member functions: This function accepts a relative tolerance for the inner stepper to use in its upcoming adaptive solve. - :param stepper: the inner stepper object. - :param rtol: relative tolerance to use on the upcoming solve. + **Arguments:** + * *stepper* -- the inner stepper object. + * *rtol* -- relative tolerance to use on the upcoming solve. - :return value: An :c:type:`MRIStepInnerSetRTol` should return 0 if successful, a positive - value if a recoverable error occurred, or a negative value if it failed - unrecoverably. + **Return value:** + An :c:type:`MRIStepInnerSetRTol` should return 0 if successful, a positive` + value if a recoverable error occurred, or a negative value if it failed unrecoverably. .. note:: This function is only called when multirate temporal adaptivity has been enabled - using a :c:type:`SUNAdaptController` module having type ``SUNDIALS_CONTROL_MRI_TOL``. + using a :c:type:`SUNAdaptController` module having type :c:enumerator:`SUN_ADAPTCONTROLLER_MRI_TOL`. It is assumed that if the inner stepper supports absolute tolerances as well, then these have been set up directly by the user to indicate the "noise" level for diff --git a/doc/arkode/guide/source/Usage/MRIStep/MRIStepCoupling.rst b/doc/arkode/guide/source/Usage/MRIStep/MRIStepCoupling.rst index 625d3bb89e..adc0342616 100644 --- a/doc/arkode/guide/source/Usage/MRIStep/MRIStepCoupling.rst +++ b/doc/arkode/guide/source/Usage/MRIStep/MRIStepCoupling.rst @@ -28,27 +28,27 @@ by the table is determined by an enumerated type, :c:enum:`ARKODE_MRIType`: .. c:enum:: ARKODE_MRIType - This may take any of the following constants: + The MRI method family encoded by a :c:type:`MRIStepCoupling` table -.. c:enumerator:: MRISTEP_EXPLICIT + .. c:enumerator:: MRISTEP_EXPLICIT - An explicit MRI-GARK method (does not support a slow implicit operator, :math:`f^I`). + An explicit MRI-GARK method (does not support a slow implicit operator, :math:`f^I`). -.. c:enumerator:: MRISTEP_IMPLICIT + .. c:enumerator:: MRISTEP_IMPLICIT - An implicit MRI-GARK method (does not support a slow explicit operator, :math:`f^E`). + An implicit MRI-GARK method (does not support a slow explicit operator, :math:`f^E`). -.. c:enumerator:: MRISTEP_IMEX + .. c:enumerator:: MRISTEP_IMEX - An IMEX-MRK-GARK method. + An IMEX-MRK-GARK method. -.. c:enumerator:: MRISTEP_MERK + .. c:enumerator:: MRISTEP_MERK - A explicit MERK method (does not support a slow implicit operator, :math:`f^I`). + A explicit MERK method (does not support a slow implicit operator, :math:`f^I`). -.. c:enumerator:: MRISTEP_MRISR + .. c:enumerator:: MRISTEP_MRISR - An IMEX-MRI-SR method. + An IMEX-MRI-SR method. The MRI coupling tables themselves are stored in an @@ -141,7 +141,7 @@ are defined ``arkode/arkode_mristep.h``. +-------------------------------------------+--------------------------------------------------------------------+ | :c:func:`MRIStepCoupling_Create` | Create a new MRIStepCoupling table from coefficients | +-------------------------------------------+--------------------------------------------------------------------+ - | :c:func:`MRIStepCoupling_MIStoMRI` | Create a new MRIStepCoupling table from a slow Butcher table | + | :c:func:`MRIStepCoupling_MIStoMRI` | Create a new MRIStepCoupling table from a Butcher table | +-------------------------------------------+--------------------------------------------------------------------+ | :c:func:`MRIStepCoupling_Copy` | Create a copy of a MRIStepCoupling table | +-------------------------------------------+--------------------------------------------------------------------+ @@ -161,7 +161,7 @@ are defined ``arkode/arkode_mristep.h``. :param method: the coupling table identifier. - :return value: An :c:type:`MRIStepCoupling` structure if successful. A ``NULL`` + :returns: An :c:type:`MRIStepCoupling` structure if successful. A ``NULL`` pointer if *method* was invalid or an allocation error occurred. @@ -173,9 +173,9 @@ are defined ``arkode/arkode_mristep.h``. :param method: the coupling table name. - :return value: An :c:type:`MRIStepCoupling` structure if successful. - A ``NULL`` pointer if *method* was invalid, *method* was - ``"ARKODE_MRI_NONE"``, or an allocation error occurred. + :returns: An :c:type:`MRIStepCoupling` structure if successful. + A ``NULL`` pointer if *method* was invalid, *method* was + ``"ARKODE_MRI_NONE"``, or an allocation error occurred. .. note:: @@ -192,21 +192,21 @@ are defined ``arkode/arkode_mristep.h``. :param stages: number of stages in the coupling table. :param type: the type of MRI method the table will encode. - :return value: An :c:type:`MRIStepCoupling` structure if successful. - A ``NULL`` pointer if *stages* or *type* was invalid or an allocation error - occurred. + :returns: An :c:type:`MRIStepCoupling` structure if successful. + A ``NULL`` pointer if *stages* or *type* was invalid or an allocation error + occurred. .. note:: - For MRISTEP_EXPLICIT tables, the *G* and *group* arrays are not allocated. + For :c:enumerator:`MRISTEP_EXPLICIT` tables, the *G* and *group* arrays are not allocated. - For MRISTEP_IMPLICIT tables, the *W* and *group* arrays are not allocated. + For :c:enumerator:`MRISTEP_IMPLICIT` tables, the *W* and *group* arrays are not allocated. - For MRISTEP_IMEX tables, the *group* array is not allocated. + For :c:enumerator:`MRISTEP_IMEX` tables, the *group* array is not allocated. - For MRISTEP_MERK tables, the *G* array is not allocated. + For :c:enumerator:`MRISTEP_MERK` tables, the *G* array is not allocated. - For MRISTEP_MRISR tables, the *group* array is not allocated. + For :c:enumerator:`MRISTEP_MRISR` tables, the *group* array is not allocated. When allocated, both :math:`\Omega` and :math:`\Gamma` are initialized to all zeros, so only nonzero coefficients need to be provided. @@ -236,6 +236,25 @@ are defined ``arkode/arkode_mristep.h``. .. c:function:: MRIStepCoupling MRIStepCoupling_Create(int nmat, int stages, int q, int p, sunrealtype *W, sunrealtype *G, sunrealtype *c) Allocates a coupling table and fills it with the given values. + + This routine can only be used to create coupling tables with type + ``MRISTEP_EXPLICIT``, ``MRISTEP_IMPLICIT``, or ``MRISTEP_IMEX``. The + routine determines the relevant type based on whether either of the + arguments *W* and *G* are ``NULL``. Users who wish to create MRI + methods of type ``MRISTEP_MERK`` or ``MRISTEP_MRISR`` must currently + do so manually. + + The assumed size of the input arrays *W* and *G* depends on the + input value for the embedding order of accuracy, *p*. + + * Non-embedded methods should be indicated by an input *p=0*, in which + case *W* and/or *G* should have entries stored as a 1D array of size + ``nmat * stages * stages``, in row-major order. + + * Embedded methods should be indicated by an input *p>0*, in which + case *W* and/or *G* should have entries stored as a 1D array of size + ``nmat * (stages+1) * stages``, in row-major order. The additional + "row" is assumed to hold the embedding coefficients. :param nmat: the value of :math:`k` i.e., number of number of coupling matrices in :math:`\Omega` for the slow-nonstiff terms and/or in @@ -250,31 +269,12 @@ are defined ``arkode/arkode_mristep.h``. :param c: array of slow abscissae for the MRI method. The entries should be stored as a 1D array of length ``stages``. - :return value: An :c:type:`MRIStepCoupling` structure if successful. - A ``NULL`` pointer if ``stages`` was invalid, an allocation error occurred, - or the input data arrays are inconsistent with the method type. + :returns: An :c:type:`MRIStepCoupling` structure if successful. + A ``NULL`` pointer if ``stages`` was invalid, an allocation error occurred, + or the input data arrays are inconsistent with the method type. .. note:: - This routine can only be used to create coupling tables with type - ``MRISTEP_EXPLICIT``, ``MRISTEP_IMPLICIT``, or ``MRISTEP_IMEX``. The - routine determines the relevant type based on whether either of the - arguments *W* and *G* are ``NULL``. Users who wish to create MRI - methods of type ``MRISTEP_MERK`` or ``MRISTEP_MRISR`` must currently - do so manually. - - The assumed size of the input arrays *W* and *G* depends on the - input value for the embedding order of accuracy, *p*. - - * Non-embedded methods should be indicated by an input *p=0*, in which - case *W* and/or *G* should have entries stored as a 1D array of size - ``nmat * stages * stages``, in row-major order. - - * Embedded methods should be indicated by an input *p>0*, in which - case *W* and/or *G* should have entries stored as a 1D array of size - ``nmat * (stages+1) * stages``, in row-major order. The additional - "row" is assumed to hold the embedding coefficients. - .. c:function:: MRIStepCoupling MRIStepCoupling_MIStoMRI(ARKodeButcherTable B, int q, int p) @@ -285,8 +285,8 @@ are defined ``arkode/arkode_mristep.h``. :param q: the overall order of the MIS/MRI method. :param p: the overall order of the MIS/MRI embedding. - :return value: An :c:type:`MRIStepCoupling` structure if successful. - A ``NULL`` pointer if an allocation error occurred. + :returns: An :c:type:`MRIStepCoupling` structure if successful. + A ``NULL`` pointer if an allocation error occurred. .. note:: @@ -341,8 +341,8 @@ are defined ``arkode/arkode_mristep.h``. :param C: the coupling table to copy. - :return value: An :c:type:`MRIStepCoupling` structure if successful. - A ``NULL`` pointer if an allocation error occurred. + :returns: An :c:type:`MRIStepCoupling` structure if successful. + A ``NULL`` pointer if an allocation error occurred. .. c:function:: void MRIStepCoupling_Space(MRIStepCoupling C, sunindextype *liw, sunindextype *lrw) diff --git a/doc/arkode/guide/source/Usage/MRIStep/User_callable.rst b/doc/arkode/guide/source/Usage/MRIStep/User_callable.rst index f37a36e356..f4d2de879e 100644 --- a/doc/arkode/guide/source/Usage/MRIStep/User_callable.rst +++ b/doc/arkode/guide/source/Usage/MRIStep/User_callable.rst @@ -59,10 +59,10 @@ MRIStep initialization and deallocation functions time scale. :param sunctx: the :c:type:`SUNContext` object (see :numref:`SUNDIALS.SUNContext`) - :return value: If successful, a pointer to initialized problem memory of type ``void*``, to - be passed to all user-facing MRIStep routines listed below. If unsuccessful, - a ``NULL`` pointer will be returned, and an error message will be printed to - ``stderr``. + :returns: If successful, a pointer to initialized problem memory of type ``void*``, to + be passed to all user-facing MRIStep routines listed below. If unsuccessful, + a ``NULL`` pointer will be returned, and an error message will be printed to + ``stderr``. **Example usage:** @@ -72,10 +72,10 @@ MRIStep initialization and deallocation functions void *inner_arkode_mem = NULL; void *outer_arkode_mem = NULL; - /* MRIStepInnerStepper to wrap the inner (fast) ERKStep object */ + /* MRIStepInnerStepper to wrap the inner (fast) object */ MRIStepInnerStepper stepper = NULL; - /* create an ERKStep/ARKStep/MRIStep object, setting fast (inner) right-hand side + /* create an ARKODE object, setting fast (inner) right-hand side functions and the initial condition */ inner_arkode_mem = *StepCreate(...); @@ -108,7 +108,6 @@ MRIStep initialization and deallocation functions :param arkode_mem: pointer to the MRIStep memory block. - :return value: None .. deprecated:: 6.1.0 @@ -873,7 +872,7 @@ Optional inputs for implicit stage solves Specifies the method to use for predicting implicit solutions. :param arkode_mem: pointer to the MRIStep memory block. - :param method: + :param method: the predictor method * 0 is the trivial predictor, @@ -1703,9 +1702,9 @@ Main solver optional output functions * :c:enumerator:`SUN_OUTPUTFORMAT_CSV` -- prints a comma-separated list of key and value pairs e.g., ``key1,value1,key2,value2,...`` - :retval ARK_SUCCESS: -- if the output was successfully. - :retval CV_MEM_NULL: -- if the MRIStep memory was ``NULL``. - :retval CV_ILL_INPUT: -- if an invalid formatting option was provided. + :retval ARK_SUCCESS: if the output was successfully. + :retval CV_MEM_NULL: if the MRIStep memory was ``NULL``. + :retval CV_ILL_INPUT: if an invalid formatting option was provided. .. note:: @@ -1727,8 +1726,7 @@ Main solver optional output functions :param flag: a return flag from an MRIStep function. - :return value: The return value is a string containing the name of - the corresponding constant. + :returns: A string containing the name of the corresponding constant. .. deprecated:: 6.1.0 @@ -2312,11 +2310,11 @@ Linear solver interface optional output functions :param lsflag: a return flag from an ARKLS function. - :return value: The return value is a string containing the name of - the corresponding constant. If using the ``SUNLINSOL_DENSE`` - or ``SUNLINSOL_BAND`` modules, then if 1 :math:`\le` `lsflag` - :math:`\le n` (LU factorization failed), this routine returns - "NONE". + :returns: The return value is a string containing the name of + the corresponding constant. If using the ``SUNLINSOL_DENSE`` + or ``SUNLINSOL_BAND`` modules, then if 1 :math:`\le` `lsflag` + :math:`\le n` (LU factorization failed), this routine returns + "NONE". .. deprecated:: 6.1.0 diff --git a/doc/arkode/guide/source/Usage/User_callable.rst b/doc/arkode/guide/source/Usage/User_callable.rst index 49aa15e1ec..5c394b0de1 100644 --- a/doc/arkode/guide/source/Usage/User_callable.rst +++ b/doc/arkode/guide/source/Usage/User_callable.rst @@ -1757,37 +1757,41 @@ Reset accumulated error :c:func:`ARKodeReset .. versionadded:: 6.1.0 -The two following routines are used to control algorithms that ARKODE can use to estimate +The following routines are used to control algorithms that ARKODE can use to estimate the accumulated temporal error over multiple time steps. For time-stepping modules that compute both a solution and embedding, :math:`y_n` and :math:`\tilde{y}_n`, these may be combined to create a vector-valued local temporal error estimate for the current internal step, :math:`y_n - \tilde{y}_n`. These local errors may be accumulated by ARKODE in a -variety of ways, as determined by the enumerated type :c:enum:`ARKODE_MRIType`. In each -of the cases below, the accumulation is taken over all steps :math:`n\in N` since the most -recent call to either :c:func:`ARKodeSetAccumulatedErrorType` or -:c:func:`ARKodeResetAccumulatedError`. The norm is taken using the tolerance-informed +variety of ways, as determined by the enumerated type :c:enum:`ARKAccumError`. In each +of the cases below, the accumulation is taken over all steps since the most recent +call to either :c:func:`ARKodeSetAccumulatedErrorType` or +:c:func:`ARKodeResetAccumulatedError`. Below the set :math:`\mathcal{S}` contains +the indices of the steps since the last call to either of the aforementioned functions. +The norm is taken using the tolerance-informed error-weight vector (see :c:func:`ARKodeGetErrWeights`), and ``reltol`` is the user-specified relative solution tolerance. .. c:enum:: ARKAccumError The type of error accumulation that ARKODE should use. + + .. versionadded:: x.y.z -.. c:enumerator:: ARK_ACCUMERROR_NONE + .. c:enumerator:: ARK_ACCUMERROR_NONE - No accumulation should be performed + No accumulation should be performed -.. c:enumerator:: ARK_ACCUMERROR_MAX + .. c:enumerator:: ARK_ACCUMERROR_MAX - Computes :math:`\text{reltol} \max_{n\in N} \|y_n - \tilde{y}_n\|_{WRMS}` + Computes :math:`\text{reltol} \max_{i \in \mathcal{S}} \|y_i - \tilde{y}_i\|_{WRMS}` -.. c:enumerator:: ARK_ACCUMERROR_SUM + .. c:enumerator:: ARK_ACCUMERROR_SUM - Computes :math:`\text{reltol} \sum_{n\in N} \|y_n - \tilde{y}_n\|_{WRMS}` + Computes :math:`\text{reltol} \sum_{i \in \mathcal{S}} \|y_i - \tilde{y}_i\|_{WRMS}` -.. c:enumerator:: ARK_ACCUMERROR_AVG + .. c:enumerator:: ARK_ACCUMERROR_AVG - Computes :math:`\frac{\text{reltol}}{N} \sum_{n\in N} \|y_n - \tilde{y}_n\|_{WRMS}`. + Computes :math:`\frac{\text{reltol}}{|\mathcal{S}|} \sum_{i \in \mathcal{S}} \|y_i - \tilde{y}_i\|_{WRMS}`. .. c:function:: int ARKodeSetAccumulatedErrorType(void* arkode_mem, ARKAccumError accum_type) @@ -1797,6 +1801,7 @@ user-specified relative solution tolerance. :param arkode_mem: pointer to the ARKODE memory block. :param accum_type: accumulation strategy. + :retval ARK_SUCCESS: the function exited successfully. :retval ARK_MEM_NULL: ``arkode_mem`` was ``NULL`` :retval ARK_STEPPER_UNSUPPORTED: temporal error estimation is not supported @@ -4845,29 +4850,29 @@ wrap the ARKODE memory block as an :c:type:`MRIStepInnerStepper`. Currently, ARKODE integrators based on ARKStep, ERKStep, and MRIStep support use as an MRIStep inner stepper. - **Example usage:** + **Example usage:** - .. code-block:: C + .. code-block:: C - /* fast (inner) and slow (outer) ARKODE objects */ - void *inner_arkode_mem = NULL; - void *outer_arkode_mem = NULL; + /* fast (inner) and slow (outer) ARKODE objects */ + void *inner_arkode_mem = NULL; + void *outer_arkode_mem = NULL; - /* MRIStepInnerStepper to wrap the inner (fast) ERKStep object */ - MRIStepInnerStepper stepper = NULL; + /* MRIStepInnerStepper to wrap the inner (fast) object */ + MRIStepInnerStepper stepper = NULL; - /* create an ERKStep/ARKStep/MRIStep object, setting fast (inner) right-hand side - functions and the initial condition */ - inner_arkode_mem = *StepCreate(...); + /* create an ARKODE object, setting fast (inner) right-hand side + functions and the initial condition */ + inner_arkode_mem = *StepCreate(...); - /* configure the inner integrator */ - retval = ARKodeSet*(inner_arkode_mem, ...); + /* configure the inner integrator */ + retval = ARKodeSet*(inner_arkode_mem, ...); - /* create MRIStepInnerStepper wrapper for the ARKODE integrator */ - flag = ARKodeCreateMRIStepInnerStepper(inner_arkode_mem, &stepper); + /* create MRIStepInnerStepper wrapper for the ARKODE integrator */ + flag = ARKodeCreateMRIStepInnerStepper(inner_arkode_mem, &stepper); - /* create an MRIStep object, setting the slow (outer) right-hand side - functions and the initial condition */ - outer_arkode_mem = MRIStepCreate(fse, fsi, t0, y0, stepper, sunctx) + /* create an MRIStep object, setting the slow (outer) right-hand side + functions and the initial condition */ + outer_arkode_mem = MRIStepCreate(fse, fsi, t0, y0, stepper, sunctx) .. versionadded:: x.y.z From 4ff54b389ba9aebb6f4cbb13d388c0ab70b7d18d Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Mon, 21 Oct 2024 23:14:45 -0500 Subject: [PATCH 129/286] Manually applied suggestions from code review --- doc/arkode/guide/source/Mathematics.rst | 183 +++++++++++++----------- 1 file changed, 96 insertions(+), 87 deletions(-) diff --git a/doc/arkode/guide/source/Mathematics.rst b/doc/arkode/guide/source/Mathematics.rst index 7ce4019ecb..d2e5ac0b06 100644 --- a/doc/arkode/guide/source/Mathematics.rst +++ b/doc/arkode/guide/source/Mathematics.rst @@ -618,8 +618,8 @@ MRIStep see :numref:`ARKODE.Usage.MRIStep.MRIStepCoupling.Tables`. Additionally, users may supply their own method by defining and attaching a coupling table, see :numref:`ARKODE.Usage.MRIStep.MRIStepCoupling` for more information. -Generally, the slow (outer) method for each family derives from an :math:`s` -stage single-rate method: MIS and MRI-GARK methods derive from explicit or +Generally, the slow (outer) method for each family derives from a single-rate +method: MIS and MRI-GARK methods derive from explicit or diagonally-implicit Runge--Kutta methods, MERK methods derive from exponential Runge--Kutta methods, while IMEX-MRI-GARK and IMEX-MRI-SR methods derive from additive Runge--Kutta methods. In each case, the "infinitesimal" nature of the @@ -829,8 +829,7 @@ time-steppers) is their adaptive control of local truncation error (LTE). At every step, we estimate the local error, and ensure that it satisfies tolerance conditions. If this local error test fails, then the step is recomputed with a reduced step size. To this end, the -majority of Runge--Kutta methods packaged within both the ARKStep and -ERKStep modules, as well as many of the MRI methods packaged within MRIStep, +majority of the Runge--Kutta methods and many of the MRI methods in ARKODE admit an embedded solution :math:`\tilde{y}_n`, as shown in equations :eq:`ARKODE_ARK`, :eq:`ARKODE_ERK`, and :eq:`MRI_embedding_fast_IVP`-:eq:`MRI_embedding_implicit_solve`. Generally, @@ -993,7 +992,7 @@ step size, :math:`h^S`, and the other that adapts the fast time scale step size, methods should work well for multirate problems where the time scales are somewhat decoupled, and that errors introduced at one scale do not "pollute" the other. -The second category of controllers that we provide are :math:`h^S-Tol` multirate +The second category of controllers that we provide are :math:`h^S`-:math:`Tol` multirate controllers. The basic idea is that an adaptive time integration method will attempt to adapt step sizes to control the *local error* within each step to achieve a requested tolerance. However, MRI methods must ask an adaptive "inner" @@ -1001,9 +1000,9 @@ solver to produce the stage solutions :math:`v_i(t_{F,i})` and :math:`\tilde{v}(\tilde{t}_{F})`, that result from sub-stepping over intervals :math:`[t_{0,i},t_{F,i}]` or :math:`[\tilde{t}_{0},\tilde{t}_{F}]`, respectively. Local errors within the inner integrator may accumulate, resulting in an overall -inner solver error :math:`\varepsilon^f_n` that exceeds the requested tolerance. +inner solver error :math:`\varepsilon^F_n` that exceeds the requested tolerance. If that inner solver can produce *both* :math:`v_i(t_{F,i})` and -an estimation of the accumulated error, :math:`\varepsilon^f_{n,approx}`, then the +an estimation of the accumulated error, :math:`\varepsilon^F_{n,approx}`, then the tolerances provided to that inner solver can be adjusted accordingly to ensure stage solutions that are within the overall tolerances requested of the outer MRI method. @@ -1012,7 +1011,7 @@ To this end, we assume that the inner solver will provide accumulated errors over each fast interval having the form .. math:: - \varepsilon^f_{n} = c(t_n) h^S_n \left(\text{RTOL}_n^f\right), + \varepsilon^F_{n} = c(t_n) h^S_n \left(\text{RTOL}_n^F\right), :label: fast_error_accumulation_assumption where :math:`c(t)` is independent of the tolerance or step size, but may vary in time. @@ -1023,46 +1022,77 @@ size :math:`h_n` has order :math:`p`, i.e., LTE_n = c(t_n) (h_n)^{p+1}, to predict candidate values :math:`h_{n+1}`. We may therefore repurpose an existing -single-scale controller to predict candidate values :math:`\text{RTOL}^f_{n+1}` by +single-scale controller to predict candidate values :math:`\text{RTOL}^F_{n+1}` by supplying an "order" :math:`p=0` and a "control parameter" -:math:`h_n=\left(\text{RTOL}_n^f\right)`. +:math:`h_n=\left(\text{RTOL}_n^F\right)`. -Thus to construct an :math:`h^S-Tol` controller, we require three separate single-rate +Thus to construct an :math:`h^S`-:math:`Tol` controller, we require three separate single-rate adaptivity controllers: * scontrol-H -- this is a single-rate controller that adapts :math:`h^S_n` within the slow integrator to achieve user-requested solution tolerances. -* scontrol-Tol -- this is a single-rate controller that adapts :math:`\text{RTOL}^f_n` +* scontrol-Tol -- this is a single-rate controller that adapts :math:`\text{RTOL}^F_n` using the strategy described above. * fcontrol -- this adapts time steps :math:`h^F` within the fast integrator to achieve - the current tolerance, :math:`\text{RTOL}^f_n`. + the current tolerance, :math:`\text{RTOL}^F_n`. -We note that both the decoupled and :math:`h^S-Tol` controller families may be used in +We note that both the decoupled and :math:`h^S`-:math:`Tol` controller families may be used in multirate calculations with an arbitrary number of time scales, since these focus on only one scale at a time, or on how a given time scale relates to the next-faster scale. -.. _ARKODE.Mathematics.MultirateInitialSteps: +.. _ARKODE.Mathematics.MultirateFastError: -Initial multirate step size estimation -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +Fast temporal error estimation +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +MRI temporal adaptivity requires estimation of the temporal errors that +arise at *both* the slow and fast time scales, which we denote here as +:math:`\varepsilon^S` and :math:`\varepsilon^F`, respectively. While the +slow error may be estimated as :math:`\varepsilon^S = \|y_n - \tilde{y}_n\|`, +non-intrusive approaches for estimating :math:`\varepsilon^F` are more +challenging. ARKODE provides two strategies to help provide this estimate, both +of which assume the fast integrator is temporally adaptive and, at each of its +:math:`m` steps to reach :math:`t_n`, computes an estimate of the local +temporal error, :math:`\varepsilon^F_{n,m}`. In this case, we assume that the +fast integrator was run with the same absolute tolerances as the slow integrator, but +that it may have used a potentially different relative solution tolerance, +:math:`\text{RTOL}^F`. The fast integrator then accumulates these local error +estimates using either a "maximum accumulation" strategy, + +.. math:: + \varepsilon^F_{max} = \text{RTOL}^F \max_{m\in M} \|\varepsilon^F_{n,m}\|_{WRMS}, + :label: maximum_accumulation -Before time step adaptivity can be accomplished, an initial step must be taken. As is -typical with adaptive methods, the first step should be chosen conservatively to ensure +or using an "averaged accumulation" strategy, + +.. math:: + \varepsilon^F_{avg} = \frac{\text{RTOL}^F}{|M|} \sum_{m\in M} \|\varepsilon^F_{n,m}\|_{WRMS}, + :label: average_accumulation + +where the norm is taken using the tolerance-informed error-weight vector. In +both cases, the sum or the maximum is taken over the set of all steps :math:`M` +since the fast error accumulator has been reset. + + + +.. _ARKODE.Mathematics.InitialStep: + +Initial step size estimation +============================== + +Before time step adaptivity can be accomplished, an initial step must be taken. These +values may always be provided by the user; however, if these are not provided then +ARKODE will estimate a suitable choice. Typically +with adaptive methods, the first step should be chosen conservatively to ensure that it succeeds both in its internal solver algorithms, and its eventual temporal error test. However, if this initial step is too conservative then its computational cost will essentially be wasted. We thus strive to construct a conservative step that will succeed while also progressing toward the eventual solution. -In MRI methods, initial time step selection is complicated by the fact that not only must -an initial slow step size, :math:`h_0^S`, be chosen, but a smaller initial step, -:math:`h_0^F`, must also be selected. Additionally, it is typically assumed that within -MRI methods, evaluation of :math:`f^S` is significantly more costly than evaluation of -:math:`f^f`, and thus we wish to construct these initial steps accordingly. - -Before examining MRI initial time step estimation, we first summarize two common +Before commenting on the specifics of ARKODE, we first summarize two common approaches to initial step size selection. To this end, consider a simple single-time-scale ODE, @@ -1070,38 +1100,38 @@ single-time-scale ODE, y'(t) = f(t,y), \quad y(t_0) = y_0 :label: IVP_single -For this, we may consider two Taylor series expansions of :math:`y(t_0+h^S)` around the +For this, we may consider two Taylor series expansions of :math:`y(t_0+h)` around the initial time, .. math:: - y(t_0+h^S) = y_0 + h^S f(t_0,y_0) + \frac{(h^S)^2}{2} \frac{\mathrm d}{\mathrm dt} f(t_0+\tau,y_0+\eta),\\ + y(t_0+h) = y_0 + h f(t_0,y_0) + \frac{h^2}{2} \frac{\mathrm d}{\mathrm dt} f(t_0+\tau,y_0+\eta),\\ :label: TSExp1 and .. math:: - y(t_0+h^S) = y_0 + h^S f(t_0+\tau,y_0+\eta), + y(t_0+h) = y_0 + h f(t_0+\tau,y_0+\eta), :label: TSExp0 -where :math:`t_0+\tau` is between :math:`t_0` and :math:`t_0+h^S`, and :math:`y_0+\eta` -is on the line segment connecting :math:`y_0` and :math:`y(t_0+h^S)`. +where :math:`t_0+\tau` is between :math:`t_0` and :math:`t_0+h`, and :math:`y_0+\eta` +is on the line segment connecting :math:`y_0` and :math:`y(t_0+h)`. Initial step size estimation based on the first-order Taylor expansion :eq:`TSExp1` typically attempts to determine a step size such that an explicit Euler method for :eq:`IVP_single` would be sufficiently accurate, i.e., .. math:: - \|y(t_0+h^S_0) - \left(y_0 + h^S_0 f(t_0,y_0)\right)\| \approx \left\|\frac{(h^S)^2}{2} \frac{\mathrm d}{\mathrm dt} f(t_0,y_0)\right\| < 1, + \|y(t_0+h_0) - \left(y_0 + h_0 f(t_0,y_0)\right)\| \approx \left\|\frac{h^2}{2} \frac{\mathrm d}{\mathrm dt} f(t_0,y_0)\right\| < 1, where we have assumed that :math:`y(t)` is sufficiently differentiable, and that the norms include user-specified tolerances such that an error with norm less than one is deemed "acceptable." Satisfying this inequality with a value of :math:`\frac12` and -solving for :math:`h^S_0`, we have +solving for :math:`h_0`, we have .. math:: - |h^S_0| = \frac{1}{\left\|\frac{\mathrm d}{\mathrm dt} f(t_0,y_0)\right\|^{1/2}}. + |h_0| = \frac{1}{\left\|\frac{\mathrm d}{\mathrm dt} f(t_0,y_0)\right\|^{1/2}}. -Finally, by estimating the time derivative via use of finite-differences, +Finally, by estimating the time derivative with finite-differences, .. math:: \frac{\mathrm d}{\mathrm dt} f(t_0,y_0) \approx \frac{1}{\delta t} \left(f(t_0+\delta t,y_0+\delta t f(t_0,y_0)) - f(t_0,y_0)\right), @@ -1109,7 +1139,7 @@ Finally, by estimating the time derivative via use of finite-differences, we obtain .. math:: - |h^S_0| = \frac{(\delta t)^{1/2}}{\|f(t_0+\delta t,y_0+\delta t f(t_0,y_0)) - f(t_0,y_0)\|^{1/2}}. + |h_0| = \frac{{\delta t}^{1/2}}{\|f(t_0+\delta t,y_0+\delta t f(t_0,y_0)) - f(t_0,y_0)\|^{1/2}}. :label: H0_TSExp1 Initial step size estimation based on the simpler Taylor expansion :eq:`TSExp0` @@ -1117,67 +1147,50 @@ instead assumes that the first calculated time step should be "close" to the initial state, .. math:: - &\|y(t_0+h^S_0) - y_0 \| \approx \left\|h^S_0 f(t_0,y_0)\right\| < 1,\\ - \Rightarrow\quad&\\ - &|h^S_0| = \frac{1}{2\left\| f(t_0,y_0)\right\|}, + \|y(t_0+h_0) - y_0 \| \approx \left\|h_0 f(t_0,y_0)\right\| < 1, + +where we again satisfy the inequality with a value of :math:`\frac12` to obtain + +.. math:: + |h_0| = \frac{1}{2\left\| f(t_0,y_0)\right\|}, :label: H0_TSExp0 -where we again satisfy the inequality with a value of :math:`\frac12`. + Comparing the two estimates :eq:`H0_TSExp0` and :eq:`H0_TSExp1`, we see that the former has double the number of :math:`f` evaluations, but that it has a less -conservative estimate of :math:`h^S_0`, particularly since we expect any valid -time integration method to have at least :math:`\mathcal{O}(h^S)` accuracy. +conservative estimate of :math:`h_0`, particularly since we expect any valid +time integration method to have at least :math:`\mathcal{O}(h)` accuracy. + +Of these two approaches, for calculations at a single time scale (e.g., using ARKStep), +formula :eq:`H0_TSExp1` is used, due to its more aggressive estimate for :math:`h_0`. + + +.. _ARKODE.Mathematics.MultirateInitialSteps: + +Initial multirate step sizes +------------------------------ + +In MRI methods, initial time step selection is complicated by the fact that not only must +an initial slow step size, :math:`h_0^S`, be chosen, but a smaller initial step, +:math:`h_0^F`, must also be selected. Additionally, it is typically assumed that within +MRI methods, evaluation of :math:`f^S` is significantly more costly than evaluation of +:math:`f^F`, and thus we wish to construct these initial steps accordingly. Under an assumption that conservative steps will be selected for both time scales, the error arising from temporal coupling between the slow and fast methods may be negligible. Thus, we estimate initial values of :math:`h^S_0` and :math:`h^F_0` -independently. Due to our assumed higher cost of :math:`f^s`, then for the slow +independently. Due to our assumed higher cost of :math:`f^S`, then for the slow time scale we employ the initial estimate :eq:`H0_TSExp0` for :math:`h^S_0` using -:math:`f = f^s`. Since the function :math:`f^f` is assumed to be cheaper, we -instead apply the estimate :eq:`H0_TSExp1` for :math:`h^F_0` using :math:`f=f^f`, +:math:`f = f^S`. Since the function :math:`f^F` is assumed to be cheaper, we +instead apply the estimate :eq:`H0_TSExp1` for :math:`h^F_0` using :math:`f=f^F`, and enforce an upper bound :math:`|h^F_0| \le \frac{|h^S_0|}{10}`. .. note:: - If the fast integrator does not supply its "full RHS function" :math:`f^f` + If the fast integrator does not supply its "full RHS function" :math:`f^F` for the MRI method to call, then we simply initialize :math:`h^F_0 = \frac{h^S_0}{100}`. -.. _ARKODE.Mathematics.MultirateFastError: - -Fast temporal error estimation -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -MRI temporal adaptivity requires estimation of the temporal errors that -arise at *both* the slow and fast time scales, which we denote here as -:math:`\varepsilon^s` and :math:`\varepsilon^f`, respectively. While the -slow error may be estimated as :math:`\varepsilon^s = \|y_n - \tilde{y}_n\|`, -non-intrusive approaches for estimating :math:`\varepsilon^f` are more -challenging. ARKODE provides two strategies to help provide this estimate, both -of which assume that at each sub-step of the fast integrator :math:`t_{n,m}`, the -method computes an estimate of the local temporal error, :math:`\varepsilon^f_{n,m}` -(this typically results from its own time step solution and embedding), and that -the fast integrator itself is temporally adaptive. In this case, we assume that the -fast integrator was run with the same absolute tolerances as the slow integrator, but -that it may have used a potentially different relative solution tolerance, -:math:`\text{RTOL}^f`. The fast integrator then accumulates these local error -estimates using either a "maximum accumulation: strategy, - -.. math:: - \varepsilon^f_{max} = \text{RTOL}^f \max_{m\in M} \|\varepsilon^f_{n,m}\|_{WRMS}, - :label: maximum_accumulation - -or using an "averaged accumulation" strategy, - -.. math:: - \varepsilon^f_{avg} = \frac{\text{RTOL}^f}{|M|} \sum_{m\in M} \|\varepsilon^f_{n,m}\|_{WRMS}, - :label: average_accumulation - -where the norm is taken using the tolerance-informed error-weight vector. In -both cases, the sum or the maximum is taken over the set of all steps :math:`M` -since the fast error accumulator has been reset. - - .. _ARKODE.Mathematics.Stability: @@ -1242,7 +1255,7 @@ Here the explicit stability step factor :math:`c>0` (often called the Fixed time stepping =================== -While the ARKStep, ERKStep and MRIStep time-stepping modules are +While most of the time-stepping modules are designed for tolerance-based time step adaptivity, they additionally support a "fixed-step" mode. This mode is typically used for debugging purposes, for verification against hand-coded methods, or for @@ -1262,8 +1275,7 @@ information. In this mode, all internal time step adaptivity is disabled: size by default. .. note:: - Any methods that do not provide embedding coefficients (ERK, DIRK, ARK, - or MRI) are required to be run in fixed-step mode. + Any methods that do not provide an embedding are required to be run in fixed-step mode. Additional information on this mode is provided in the section @@ -1300,9 +1312,6 @@ Nonlinear solver methods Methods with an implicit partition require solving implicit systems of the form -:eq:`ARKODE_IVP_implicit` in ARKStep, and the implicit slow stages -:eq:`MRI_implicit_solve` or :eq:`MRI_embedding_implicit_solve` in MRIStep, -an implicit system .. math:: G(z_i) = 0. From 8953eb616ee70a116428e359082fe40611d4fdac Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Mon, 21 Oct 2024 23:25:00 -0500 Subject: [PATCH 130/286] Manually applied suggestions from code review --- .../source/Usage/MRIStep/MRIStepCoupling.rst | 109 +++++++++--------- 1 file changed, 56 insertions(+), 53 deletions(-) diff --git a/doc/arkode/guide/source/Usage/MRIStep/MRIStepCoupling.rst b/doc/arkode/guide/source/Usage/MRIStep/MRIStepCoupling.rst index f66969a9b6..eb0b5d09d2 100644 --- a/doc/arkode/guide/source/Usage/MRIStep/MRIStepCoupling.rst +++ b/doc/arkode/guide/source/Usage/MRIStep/MRIStepCoupling.rst @@ -213,7 +213,7 @@ are defined ``arkode/arkode_mristep.h``. When allocated, all entries in *group* are initialized to ``-1``, indicating an unused group and/or the end of a stage group. Users who - supply a custom MRISTEP_MERK table should over-write all active stages in + supply a custom MRISTEP_MERK table should overwrite all active stages in each group. For example the ``ARKODE_MERK32`` method has 4 stages that are evolved in 3 groups -- the first group consists of stage 1, the second group consists of stages 2 and 4, while the third group consists of @@ -237,7 +237,7 @@ are defined ``arkode/arkode_mristep.h``. .. c:function:: MRIStepCoupling MRIStepCoupling_Create(int nmat, int stages, int q, int p, sunrealtype *W, sunrealtype *G, sunrealtype *c) Allocates a coupling table and fills it with the given values. - + This routine can only be used to create coupling tables with type ``MRISTEP_EXPLICIT``, ``MRISTEP_IMPLICIT``, or ``MRISTEP_IMEX``. The routine determines the relevant type based on whether either of the @@ -282,58 +282,57 @@ are defined ``arkode/arkode_mristep.h``. Creates an MRI coupling table for a traditional MIS method based on the slow Butcher table *B*. - :param B: the :c:type:`ARKodeButcherTable` for the "slow" MIS method. - :param q: the overall order of the MIS/MRI method. - :param p: the overall order of the MIS/MRI embedding. + The :math:`s`-stage slow Butcher table must have an explicit first stage + (i.e., :math:`c_1=0` and :math:`A_{1,j}=0` for :math:`1\le j\le s`), + sorted abscissae (i.e., :math:`c_{i} \ge c_{i-1}` for :math:`2\le i\le s`), + and a final abscissa value :math:`c_s \le 1`. In this case, the + :math:`(s+1)`-stage coupling table is computed as - :returns: An :c:type:`MRIStepCoupling` structure if successful. - A ``NULL`` pointer if an allocation error occurred. + .. math:: - .. note:: + \Omega_{i,j,1} \;\text{or}\; \Gamma_{i,j,1} = + \begin{cases} + 0, & \text{if}\; i=1,\\ + A_{i,j}-A_{i-1,j}, & \text{if}\; 2\le i\le s,\\ + b_{j}-A_{s,j}, & \text{if}\; i= s+1. + \end{cases} - The :math:`s`-stage slow Butcher table must have an explicit first stage - (i.e., :math:`c_1=0` and :math:`A_{1,j}=0` for :math:`1\le j\le s`), - sorted abscissae (i.e., :math:`c_{i} \ge c_{i-1}` for :math:`2\le i\le s`), - and a final abscissa value :math:`c_s \le 1`. In this case, the - :math:`(s+1)`-stage coupling table is computed as + and the embedding coefficients (if applicable) are computed as - .. math:: + .. math:: - \Omega_{i,j,1} \;\text{or}\; \Gamma_{i,j,1} = - \begin{cases} - 0, & \text{if}\; i=1,\\ - A_{i,j}-A_{i-1,j}, & \text{if}\; 2\le i\le s,\\ - b_{j}-A_{s,j}, & \text{if}\; i= s+1. - \end{cases} + \tilde{\Omega}_{i,j,1} \;\text{or}\; \tilde{\Gamma}_{i,j,1} = \tilde{b}_{j}-A_{s,j}. - and the embedding coefficients (if applicable) are computed as + We note that only one of :math:`\Omega` or :math:`\Gamma` will + be filled in. If *B* corresponded to an explicit method, then this routine + fills :math:`\Omega`; if *B* is diagonally-implicit, then this routine + inserts redundant "padding" stages to ensure a solve-decoupled structure and + then uses the above formula to fill :math:`\Gamma`. - .. math:: + For general slow tables with at least second-order accuracy, the MIS method will + be second order. However, if the slow table is at least third order and + additionally satisfies - \tilde{\Omega}_{i,j,1} \;\text{or}\; \tilde{\Gamma}_{i,j,1} = \tilde{b}_{j}-A_{s,j}. + .. math:: - We note that only one of :math:`\Omega` or :math:`\Gamma` will - be filled in. If *B* corresponded to an explicit method, then this routine - fills :math:`\Omega`; if *B* is diagonally-implicit, then this routine - inserts redundant "padding" stages to ensure a solve-decoupled structure and - then uses the above formula to fill :math:`\Gamma`. + \sum_{i=2}^s (c_i-c_{i-1})(\mathbf{e}_i+\mathbf{e}_{i-1})^T A c + (1-c_s) \left(\frac12 + \mathbf{e}_s^T A c\right) = \frac13, - For general slow tables with at least second-order accuracy, the MIS method will - be second order. However, if the slow table is at least third order and - additionally satisfies + where :math:`\mathbf{e}_j` corresponds to the :math:`j`-th column from the + :math:`s \times s` identity matrix, then the overall MIS method will be third order. - .. math:: + As a result, the values of *q* and *p* may differ from the method and + embedding orders of accuracy for the Runge--Kutta method encoded in *B*, + which is why these arguments should be supplied separately. - \sum_{i=2}^s (c_i-c_{i-1})(\mathbf{e}_i+\mathbf{e}_{i-1})^T A c + (1-c_s) \left(\frac12 + \mathbf{e}_s^T A c\right) = \frac13, + If *p>0* is input, then the table *B* must include embedding coefficients. - where :math:`\mathbf{e}_j` corresponds to the :math:`j`-th column from the - :math:`s \times s` identity matrix, then the overall MIS method will be third order. - As a result, the values of *q* and *p* may differ from the method and - embedding orders of accuracy for the Runge--Kutta method encoded in *B*, - which is why these arguments should be supplied separately. + :param B: the :c:type:`ARKodeButcherTable` for the "slow" MIS method. + :param q: the overall order of the MIS/MRI method. + :param p: the overall order of the MIS/MRI embedding. - If *p>0* is input, then the table *B* must include embedding coefficients. + :returns: An :c:type:`MRIStepCoupling` structure if successful. + A ``NULL`` pointer if an allocation error occurred. .. c:function:: MRIStepCoupling MRIStepCoupling_Copy(MRIStepCoupling C) @@ -405,20 +404,7 @@ with values specified for each method below (e.g., ``ARKODE_MIS_KW3``). -.. table:: Explicit MRIStep coupling tables. The default method for each order when using - fixed step sizes is marked with an asterisk (:math:`^*`); the default method - for each order when using adaptive time stepping is marked with a circle - (:math:`^\circ`). The "Slow RHS Calls" column corresponds to the number of - calls to the slow right-hand side function, :math:`f^E`, per time step. - Note A: although all MERK methods were derived in Luan et al. (2020) - under an assumption that the fast time scale is linear in the solution, in - Fish et al. (2024) it was proven that they also satisfy all nonlinear order - conditions up through their linear order. The lone exception is MERK54, where - it was only proven to satisfy all nonlinear conditions up to order 4, since - Fish et al. (2024) did not establish the formulas for the order 5 conditions. - All our numerical tests to date have shown MERK54 to achieve fifth order for - nonlinear problems, and so we conjecture that it also satisfies the nonlinear - fifth order conditions. +.. table:: Explicit MRIStep coupling tables. ====================================== ================== =============== ============== ===================== Table name Method Order Embedding Order Slow RHS Calls Reference @@ -438,6 +424,23 @@ with values specified for each method below (e.g., ``ARKODE_MIS_KW3``). ====================================== ================== =============== ============== ===================== +Notes regarding the above table: + +#. The default method for each order when using fixed step sizes is marked with an asterisk (:math:`^*`). + +#. The default method for each order when using adaptive time stepping is marked with a circle (:math:`^\circ`). + +#. The "Slow RHS Calls" column corresponds to the number of calls to the slow right-hand side function, + :math:`f^E`, per time step. + +#. Note A: although all MERK methods were derived in :cite:p:`Luan:20` under an assumption that the fast time + scale is linear in the solution, in :cite:p:`Fish:24` it was proven that they also satisfy all nonlinear + order conditions up through their linear order. The lone exception is MERK54, where it was only proven to + satisfy all nonlinear conditions up to order 4, since :cite:p:`Fish:24` did not establish the formulas for + the order 5 conditions. All our numerical tests to date have shown MERK54 to achieve fifth order for + nonlinear problems, and so we conjecture that it also satisfies the nonlinear fifth order conditions. + + .. table:: Diagonally-implicit, solve-decoupled MRI-GARK coupling tables. The default method for each order when using fixed step sizes is marked with an asterisk (:math:`^*`); the default method for each order when using adaptive time From d9869d7b518526c62feee67e41774f92c0d70115 Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Mon, 21 Oct 2024 23:28:05 -0500 Subject: [PATCH 131/286] Manually applied suggestions from code review --- doc/arkode/guide/source/Usage/MRIStep/Skeleton.rst | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/doc/arkode/guide/source/Usage/MRIStep/Skeleton.rst b/doc/arkode/guide/source/Usage/MRIStep/Skeleton.rst index 6ead901fda..1a7bf46c42 100644 --- a/doc/arkode/guide/source/Usage/MRIStep/Skeleton.rst +++ b/doc/arkode/guide/source/Usage/MRIStep/Skeleton.rst @@ -39,14 +39,9 @@ unchanged from the skeleton program presented in #. Create an inner stepper object to solve the fast (inner) IVP - * If using ERKStep, ARKStep, or MRIStep as the fast (inner) integrator, create - the solver object with :c:func:`ERKStepCreate`, :c:func:`ARKStepCreate`, or - :c:func:`MRIStepCreate`, and configure the integrator as desired for - evolving the fast time scale. See sections :numref:`ARKODE.Usage.Skeleton`, - :numref:`ARKODE.Usage.OptionalInputs`, :numref:`ARKODE.Usage.ERKStep.OptionalInputs`, - :numref:`ARKODE.Usage.ARKStep.OptionalInputs`, and - :numref:`ARKODE.Usage.MRIStep.OptionalInputs` for details on configuring - these integrators. + * If using an ARKODE stepper module for the fast integrator, create and configure + the stepper as normal following the steps detailed in the section for the desired + stepper. Once the ARKODE stepper object is setup, create an ``MRIStepInnerStepper`` object with :c:func:`ARKodeCreateMRIStepInnerStepper`. From b40476370f409aa1f9abb1603a73ad30d2f55d44 Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Mon, 21 Oct 2024 23:36:45 -0500 Subject: [PATCH 132/286] Manually applied suggestions from code review --- .../SUNAdaptController_MRIHTol.rst | 54 +++++++++---------- 1 file changed, 27 insertions(+), 27 deletions(-) diff --git a/doc/shared/sunadaptcontroller/SUNAdaptController_MRIHTol.rst b/doc/shared/sunadaptcontroller/SUNAdaptController_MRIHTol.rst index 0a385a3fa2..d6de1cbd2a 100644 --- a/doc/shared/sunadaptcontroller/SUNAdaptController_MRIHTol.rst +++ b/doc/shared/sunadaptcontroller/SUNAdaptController_MRIHTol.rst @@ -15,7 +15,7 @@ .. _SUNAdaptController.MRIHTol: The SUNAdaptController_MRIHTol Module -======================================= +====================================== .. versionadded:: x.y.z @@ -32,33 +32,33 @@ results from two types of error: #. "Slow" temporal errors introduced at the current time scale, .. math:: - \varepsilon^s_{n} = C(t_n) \left(h_n^s\right)^{P+1}, + \varepsilon^S_{n} = C(t_n) \left(h_n^S\right)^{P+1}, :label: slow_error_assumption - where :math:`C(t)` is independent of the current time scale step size :math:`h^s` + where :math:`C(t)` is independent of the current time scale step size :math:`h_n^S` but may vary in time. #. "Fast" errors introduced through calls to the next-fastest ("inner") solver, - :math:`\varepsilon^f_{n}`. If this inner solver is called to evolve IVPs over + :math:`\varepsilon^F_{n}`. If this inner solver is called to evolve IVPs over time intervals :math:`[t_{0,i}, t_{F,i}]` with a relative tolerance - :math:`\text{RTOL}_n^f`, then it will result in accumulated errors over these + :math:`\text{RTOL}_n^F`, then it will result in accumulated errors over these intervals of the form .. math:: - \varepsilon^f_{n} = c(t_n) \left(\text{RTOL}_n^f\right) \left(t_{F,i}-t_{0,i}\right), + \varepsilon^F_{n} = c(t_n) h_n^S \left(\text{RTOL}_n^F\right), where :math:`c(t)` is independent of the tolerance or subinterval width but may vary in time, or equivalently, .. math:: - \varepsilon^f_{n} = \kappa(t_n) \left(\text{tolfac}_n^f\right), + \varepsilon^F_{n} = \kappa(t_n) \left(\text{tolfac}_n^F\right), :label: inner_solver_assumption - where :math:`\text{RTOL}_n^f = \text{RTOL}^s \text{tolfac}_n^f`, - :math:`\text{RTOL}^s` is the relative tolerance that was supplied to the + where :math:`\text{RTOL}_n^F = \text{RTOL}^S \text{tolfac}_n^F`, + :math:`\text{RTOL}^S` is the relative tolerance that was supplied to the current time scale solver, and where - :math:`\kappa(t_n) = c(t_n) \text{RTOL}^s \left(t_{F,i}-t_{0,i}\right)` is - independent of the relative tolerance factor, :math:`\text{tolfac}_n^f`. + :math:`\kappa(t_n) = c(t_n) h_n^S \text{RTOL}^S` is + independent of the relative tolerance factor, :math:`\text{tolfac}_n^F`. Single-rate controllers are constructed to adapt a single parameter, e.g., :math:`\delta`, under an assumption that solution error :math:`\varepsilon` depends @@ -68,12 +68,12 @@ asymptotically on this parameter via the form \varepsilon = \mathcal{O}(\delta^{q+1}). Both :eq:`slow_error_assumption` and :eq:`inner_solver_assumption` fit this form, -with control parameters :math:`h^s` and :math:`\text{tolfac}^f_n`, and "orders" +with control parameters :math:`h_n^S` and :math:`\text{tolfac}^F_n`, and "orders" :math:`P` and :math:`0`, respectively. Thus an MRIHTol controller employs -*HControl* to adapt :math:`h_n^s` to control the current time scale error -:math:`\varepsilon^s_n`, and it employs *TolControl* to adapt -:math:`\text{tolfac}_n^f` to control the accumulated inner solver error -:math:`\varepsilon^f_n`. +*HControl* to adapt :math:`h_n^S` to control the current time scale error +:math:`\varepsilon^S_n`, and it employs *TolControl* to adapt +:math:`\text{tolfac}_n^F` to control the accumulated inner solver error +:math:`\varepsilon^F_n`. To avoid overly large changes in calls to the inner solver, we apply bounds on the results from *TolControl*. If *TolControl* predicts a control parameter @@ -81,11 +81,11 @@ results from *TolControl*. If *TolControl* predicts a control parameter enforcing the following bounds: .. math:: - \frac{\text{tolfac}_{n}^f}{\text{tolfac}'} &\le \text{max}_{relch},\\ - \frac{\text{tolfac}'}{\text{tolfac}_{n}^f} &\le \text{max}_{relch},\\ + \frac{\text{tolfac}_{n}^F}{\text{tolfac}'} &\ge relch_{\text{max}},\\ + \frac{\text{tolfac}'}{\text{tolfac}_{n}^F} &\le relch_{\text{max}},\\ \text{tolfac}_{min} &\le \text{tolfac}' \le \text{tolfac}_{max}. -The default values for these bounds are :math:`\text{max}_{relch} = 20`, +The default values for these bounds are :math:`relch_{\text{max}} = 20`, :math:`\text{tolfac}_{min} = 10^{-5}`, and :math:`\text{tolfac}_{max} = 1`. @@ -109,12 +109,12 @@ SUNAdaptController class, and defines its *content* field as: These entries of the *content* field contain the following information: * ``HControl`` - single time-scale SUNAdaptController object to adapt - the current step size, :math:`h^s_n`. + the current step size, :math:`h^S_n`. * ``TolControl`` - single time-scale SUNAdaptController object to adapt - the inner solver relative tolerance factor, :math:`\text{RTOL}^f_n`. + the inner solver relative tolerance factor, :math:`\text{RTOL}^F_n`. -* ``inner_max_relch`` - the parameter :math:`\text{max}_{relch}` above. +* ``inner_max_relch`` - the parameter :math:`relch_{\text{max}}` above. * ``inner_min_tolfac`` - the parameter :math:`\text{tolfac}_{min}` above. @@ -124,7 +124,7 @@ The header file to be included when using this module is ``sunadaptcontroller/sunadaptcontroller_mrihtol.h``. The SUNAdaptController_MRIHTol class provides implementations of all operations -relevant to a ``SUN_ADAPTCONTROLLER_MRI_TOL`` controller listed in +relevant to a :c:enumerator:`SUN_ADAPTCONTROLLER_MRI_TOL` controller listed in :numref:`SUNAdaptController.Description.operations`. This class also provides the following additional user-callable routines: @@ -137,8 +137,8 @@ also provides the following additional user-callable routines: :param sunctx: the current :c:type:`SUNContext` object. :param HControl: the slow time step adaptivity controller object. :param TolControl: the inner solver tolerance factor adaptivity controller object. - :return: if successful, a usable :c:type:`SUNAdaptController` object; - otherwise it will return ``NULL``. + :returns: if successful, a usable :c:type:`SUNAdaptController` object; + otherwise it will return ``NULL``. .. c:function:: SUNErrCode SUNAdaptController_SetParams_MRIHTol(SUNAdaptController C, sunrealtype inner_max_relch, sunrealtype inner_min_tolfac, sunrealtype inner_max_tolfac) @@ -148,7 +148,7 @@ also provides the following additional user-callable routines: the problem. :param C: the SUNAdaptController_MRIHTol object. - :param inner_max_relch: the parameter :math:`\text{max}_{relch}`. + :param inner_max_relch: the parameter :math:`relch_{\text{max}}`. :param inner_min_tolfac: the parameter :math:`\text{tolfac}_{min}`. :param inner_max_tolfac: the parameter :math:`\text{tolfac}_{max}`. - :return: :c:type:`SUNErrCode` indicating success or failure. + :returns: :c:type:`SUNErrCode` indicating success or failure. From e72ec14e3493c2f8f2422482c96d4a29eae45e03 Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Mon, 21 Oct 2024 23:39:27 -0500 Subject: [PATCH 133/286] Apply suggestions from code review Co-authored-by: David Gardner --- .../SUNAdaptController_Description.rst | 35 +++++++++++++------ 1 file changed, 24 insertions(+), 11 deletions(-) diff --git a/doc/shared/sunadaptcontroller/SUNAdaptController_Description.rst b/doc/shared/sunadaptcontroller/SUNAdaptController_Description.rst index 8d1158a778..fa7e048017 100644 --- a/doc/shared/sunadaptcontroller/SUNAdaptController_Description.rst +++ b/doc/shared/sunadaptcontroller/SUNAdaptController_Description.rst @@ -20,6 +20,8 @@ The SUNAdaptController API .. versionchanged:: x.y.z + Added support multirate time step adaptivity controllers + 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 @@ -84,6 +86,8 @@ The virtual table structure is defined as .. c:member:: SUNErrCode (*estimatesteptol)(SUNAdaptController C, sunrealtype H, sunrealtype tolfac, int P, sunrealtype DSM, sunrealtype dsm, sunrealtype* Hnew, sunrealtype* tolfacnew) The function implementing :c:func:`SUNAdaptController_EstimateStepTol` + + .. versionadded:: x.y.z .. c:member:: SUNErrCode (*reset)(SUNAdaptController C) @@ -109,6 +113,8 @@ The virtual table structure is defined as The function implementing :c:func:`SUNAdaptController_UpdateMRITol` + .. versionadded:: x.y.z + .. c:member:: SUNErrCode (*space)(SUNAdaptController C, long int *lenrw, long int *leniw) The function implementing :c:func:`SUNAdaptController_Space` @@ -142,6 +148,8 @@ following set of SUNAdaptController types: Controls both a slow time step and a tolerance factor to apply on the next-faster time scale within a multirate simulation that has an arbitrary number of time scales. + + .. versionadded:: x.y.z @@ -243,8 +251,11 @@ note these requirements below. Additionally, we note the behavior of the base SU .. c:function:: SUNErrCode SUNAdaptController_EstimateStepTol(SUNAdaptController C, sunrealtype H, sunrealtype tolfac, int P, sunrealtype DSM, sunrealtype dsm, sunrealtype* Hnew, sunrealtype* tolfacnew) Estimates a slow step size and a fast tolerance multiplication factor - for two adjacent time scales within a multirate application. This - routine is required for controllers of type ``SUN_ADAPTCONTROLLER_MRI_TOL``. + for two adjacent time scales within a multirate application. + + This routine is required for controllers of type :c:enumerator`SUN_ADAPTCONTROLLER_MRI_TOL`. + If the current time scale has relative tolerance ``rtol``, then the + next-faster time scale will be called with relative tolerance ``tolfac * rtol``. If this is not provided by the implementation, the base class method will set ``*Hnew = H`` and ``*tolfacnew = tolfac`` and return. @@ -258,11 +269,7 @@ note these requirements below. Additionally, we note the behavior of the base SU :param tolfacnew: (output) the estimated relative tolerance factor. :return: :c:type:`SUNErrCode` indicating success or failure. - .. note:: - - If the current time scale has relative tolerance :math:`rtol`, then the - next-faster time scale will be called with relative tolerance :math:`tolfac * rtol`. - + .. versionadded:: x.y.z Usage: .. code-block:: c @@ -272,10 +279,12 @@ note these requirements below. Additionally, we note the behavior of the base SU .. c:function:: SUNErrCode 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. + of previous ``dsm`` or ``h`` values. :param C: the :c:type:`SUNAdaptController` object. :return: :c:type:`SUNErrCode` indicating success or failure. + + .. versionadded:: x.y.z .. c:function:: SUNErrCode SUNAdaptController_SetDefaults(SUNAdaptController C) @@ -284,6 +293,8 @@ note these requirements below. Additionally, we note the behavior of the base SU :param C: the :c:type:`SUNAdaptController` object. :return: :c:type:`SUNErrCode` indicating success or failure. + + .. versionadded:: x.y.z .. c:function:: SUNErrCode SUNAdaptController_Write(SUNAdaptController C, FILE* fptr) @@ -323,9 +334,9 @@ note these requirements below. Additionally, we note the behavior of the base SU .. c:function:: SUNErrCode SUNAdaptController_UpdateMRITol(SUNAdaptController C, sunrealtype H, sunrealtype tolfac, sunrealtype DSM, sunrealtype dsm) - Notifies a controller of type ``SUN_ADAPTCONTROLLER_MRI_TOL`` that a successful time step - was taken with slow stepsize *H* and fast relative tolerance factor *tolfac*, and that the - step had slow and fast local error factors *DSM* and *dsm*, indicating that these can be + Notifies a controller of type :c:enumerator:`SUN_ADAPTCONTROLLER_MRI_TOL` that a successful time step + was taken with slow stepsize ``H`` and fast relative tolerance factor ``tolfac``, and that the + step had slow and fast local error factors ``DSM`` and ``dsm``, indicating that these can be saved for subsequent controller functions. This is typically relevant for controllers that store a history of either step sizes or error estimates for performing the estimation process. @@ -335,6 +346,8 @@ note these requirements below. Additionally, we note the behavior of the base SU :param DSM: the successful slow temporal error estimate. :param dsm: the successful fast temporal error estimate. :return: :c:type:`SUNErrCode` indicating success or failure. + + .. versionadded:: x.y.z .. c:function:: SUNErrCode SUNAdaptController_Space(SUNAdaptController C, long int *lenrw, long int *leniw) From 4e1d9fc26591b659462e71fd7b0822c8ad863cbf Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Tue, 22 Oct 2024 15:06:57 +0000 Subject: [PATCH 134/286] Initial work on addressing PR comments in code --- .../SUNAdaptController_MRIHTol.rst | 4 +- examples/arkode/CXX_serial/CMakeLists.txt | 2 +- .../arkode/CXX_serial/ark_kpr_nestedmri.cpp | 303 ++++++++++-------- examples/arkode/C_serial/CMakeLists.txt | 24 +- examples/arkode/C_serial/ark_kpr_mri.c | 68 ++-- include/arkode/arkode_mristep.h | 2 - .../sunadaptcontroller_mrihtol.h | 10 +- include/sundials/sundials_adaptcontroller.h | 2 +- .../mrihtol/sunadaptcontroller_mrihtol.c | 6 +- .../ark_test_brusselator_mriadapt.cpp | 12 +- .../CXX_serial/ark_test_kpr_mriadapt.cpp | 12 +- 11 files changed, 235 insertions(+), 210 deletions(-) diff --git a/doc/shared/sunadaptcontroller/SUNAdaptController_MRIHTol.rst b/doc/shared/sunadaptcontroller/SUNAdaptController_MRIHTol.rst index d6de1cbd2a..db8136668b 100644 --- a/doc/shared/sunadaptcontroller/SUNAdaptController_MRIHTol.rst +++ b/doc/shared/sunadaptcontroller/SUNAdaptController_MRIHTol.rst @@ -129,14 +129,14 @@ relevant to a :c:enumerator:`SUN_ADAPTCONTROLLER_MRI_TOL` controller listed in also provides the following additional user-callable routines: -.. c:function:: SUNAdaptController SUNAdaptController_MRIHTol(SUNContext sunctx, SUNAdaptController HControl, SUNAdaptController TolControl) +.. c:function:: SUNAdaptController SUNAdaptController_MRIHTol(SUNAdaptController HControl, SUNAdaptController TolControl, SUNContext sunctx) This constructor creates and allocates memory for a SUNAdaptController_MRIHTol object, and inserts its default parameters. - :param sunctx: the current :c:type:`SUNContext` object. :param HControl: the slow time step adaptivity controller object. :param TolControl: the inner solver tolerance factor adaptivity controller object. + :param sunctx: the current :c:type:`SUNContext` object. :returns: if successful, a usable :c:type:`SUNAdaptController` object; otherwise it will return ``NULL``. diff --git a/examples/arkode/CXX_serial/CMakeLists.txt b/examples/arkode/CXX_serial/CMakeLists.txt index be64e1d748..51d5582a97 100644 --- a/examples/arkode/CXX_serial/CMakeLists.txt +++ b/examples/arkode/CXX_serial/CMakeLists.txt @@ -28,7 +28,7 @@ set(ARKODE_examples "ark_kpr_Mt.cpp\;0 4 1\;develop" "ark_kpr_Mt.cpp\;0 -4\;exclude-single" "ark_kpr_Mt.cpp\;1 -5\;exclude-single" - "ark_kpr_Mt.cpp\;2 -5 0 -10\;exclude-single" + "ark_kpr_Mt.cpp\;2 -5 0 -10\;develop" "ark_kpr_Mt.cpp\;1 -3 0 -10 0\;exclude-single" "ark_kpr_Mt.cpp\;0 3 0 -10 0\;develop" "ark_kpr_Mt.cpp\;2 4 0 -10 0\;develop" diff --git a/examples/arkode/CXX_serial/ark_kpr_nestedmri.cpp b/examples/arkode/CXX_serial/ark_kpr_nestedmri.cpp index 28bdfbe312..42568dba60 100644 --- a/examples/arkode/CXX_serial/ark_kpr_nestedmri.cpp +++ b/examples/arkode/CXX_serial/ark_kpr_nestedmri.cpp @@ -21,8 +21,8 @@ * where p(t) = 0.5*cos(t), q(t) = cos(om*t*(1+exp(-(t-2)^2))), * and r(t) = cos(om*om*t*(1+exp(-(t-3)^2))). * - * When the slow time scale is implicit or explicit, the entire first row - * is placed appropriately; however, when it is ImEx we set + * The first row corresponds to the slowest time scale; when an ImEx method is applied + * to this time scale, we set * * fsi = [ G e e ] [(u^2-p-2)/(2u)] * [ 0 0 0 ] [(v^2-q-2)/(2v)] @@ -32,8 +32,8 @@ * [ 0 ] * [ 0 ] * - * When the intermediate time scale is implicit or explicit, the entire - * second row is placed appropriately; however, when it is ImEx we set + * The second row corresponds to the intermediate time scale; when an ImEx method + * is applied to this time scale, we set * * fmi = [ 0 0 0 ] [(u^2-p-2)/(2u)] * [ e al be ] [(v^2-q-2)/(2v)] @@ -91,11 +91,11 @@ * 3: PID controller (as part of MRI-HTOL) * 4: ExpGus controller (as part of MRI-HTOL) * 5: ImpGus controller (as part of MRI-HTOL) - * 6: ImExGus controller (as part of MRI-HTOL) + * 6: ImExGus controller (as part of MRI-HTOL) * 7: I controller (alone) * 8: PI controller (alone) * 9: PID controller (alone) - * 10: ExpGus controller (alone) + * 10: ExpGus controller (alone) * 11: ImpGus controller (alone) * 12: ImExGus controller (alone) * - "fast" ERKStep temporal adaptivity controller: fcontrol [default = 1] @@ -257,13 +257,15 @@ int main(int argc, char* argv[]) int retval; sunbooleantype slowimplicit, slowimex, midimplicit, midimex; slowimplicit = slowimex = midimplicit = midimex = SUNFALSE; - f_mi = nullptr; - f_me = fm; - f_si = nullptr; - f_se = fs; - J_m = nullptr; - J_s = nullptr; - f_f = ff; + + f_mi = nullptr; + f_me = fm; + f_si = nullptr; + f_se = fs; + J_m = nullptr; + J_s = nullptr; + f_f = ff; + if ((opts.mri_method == "ARKODE_MRI_GARK_IRK21a") || (opts.mri_method == "ARKODE_MRI_GARK_ESDIRK34a") || (opts.mri_method == "ARKODE_MRI_GARK_ESDIRK46a")) @@ -482,9 +484,9 @@ int main(int argc, char* argv[]) retval = SUNAdaptController_SetParams_I(mcontrol_Tol, opts.k1s); if (check_flag(retval, "SUNAdaptController_SetParams_I")) return 1; } - scontrol = SUNAdaptController_MRIHTol(sunctx, scontrol_H, scontrol_Tol); + scontrol = SUNAdaptController_MRIHTol(scontrol_H, scontrol_Tol, sunctx); if (check_ptr((void*)scontrol, "SUNAdaptController_MRIHTol")) return 1; - mcontrol = SUNAdaptController_MRIHTol(sunctx, mcontrol_H, mcontrol_Tol); + mcontrol = SUNAdaptController_MRIHTol(mcontrol_H, mcontrol_Tol, sunctx); if (check_ptr((void*)mcontrol, "SUNAdaptController_MRIHTol")) return 1; if (!(std::isnan(opts.htol_relch) || std::isnan(opts.htol_minfac) || std::isnan(opts.htol_maxfac))) @@ -524,9 +526,9 @@ int main(int argc, char* argv[]) retval = SUNAdaptController_SetParams_PI(mcontrol_Tol, opts.k1s, opts.k2s); if (check_flag(retval, "SUNAdaptController_SetParams_PI")) return 1; } - scontrol = SUNAdaptController_MRIHTol(sunctx, scontrol_H, scontrol_Tol); + scontrol = SUNAdaptController_MRIHTol(scontrol_H, scontrol_Tol, sunctx); if (check_ptr((void*)scontrol, "SUNAdaptController_MRIHTol")) return 1; - mcontrol = SUNAdaptController_MRIHTol(sunctx, mcontrol_H, mcontrol_Tol); + mcontrol = SUNAdaptController_MRIHTol(mcontrol_H, mcontrol_Tol, sunctx); if (check_ptr((void*)mcontrol, "SUNAdaptController_MRIHTol")) return 1; if (!(std::isnan(opts.htol_relch) || std::isnan(opts.htol_minfac) || std::isnan(opts.htol_maxfac))) @@ -571,9 +573,9 @@ int main(int argc, char* argv[]) opts.k2s, opts.k3s); if (check_flag(retval, "SUNAdaptController_SetParams_PID")) return 1; } - scontrol = SUNAdaptController_MRIHTol(sunctx, scontrol_H, scontrol_Tol); + scontrol = SUNAdaptController_MRIHTol(scontrol_H, scontrol_Tol, sunctx); if (check_ptr((void*)scontrol, "SUNAdaptController_MRIHTol")) return 1; - mcontrol = SUNAdaptController_MRIHTol(sunctx, mcontrol_H, mcontrol_Tol); + mcontrol = SUNAdaptController_MRIHTol(mcontrol_H, mcontrol_Tol, sunctx); if (check_ptr((void*)mcontrol, "SUNAdaptController_MRIHTol")) return 1; if (!(std::isnan(opts.htol_relch) || std::isnan(opts.htol_minfac) || std::isnan(opts.htol_maxfac))) @@ -618,9 +620,9 @@ int main(int argc, char* argv[]) opts.k2s); if (check_flag(retval, "SUNAdaptController_SetParams_ExpGus")) return 1; } - scontrol = SUNAdaptController_MRIHTol(sunctx, scontrol_H, scontrol_Tol); + scontrol = SUNAdaptController_MRIHTol(scontrol_H, scontrol_Tol, sunctx); if (check_ptr((void*)scontrol, "SUNAdaptController_MRIHTol")) return 1; - mcontrol = SUNAdaptController_MRIHTol(sunctx, mcontrol_H, mcontrol_Tol); + mcontrol = SUNAdaptController_MRIHTol(mcontrol_H, mcontrol_Tol, sunctx); if (check_ptr((void*)mcontrol, "SUNAdaptController_MRIHTol")) return 1; if (!(std::isnan(opts.htol_relch) || std::isnan(opts.htol_minfac) || std::isnan(opts.htol_maxfac))) @@ -665,9 +667,9 @@ int main(int argc, char* argv[]) opts.k2s); if (check_flag(retval, "SUNAdaptController_SetParams_ImpGus")) return 1; } - scontrol = SUNAdaptController_MRIHTol(sunctx, scontrol_H, scontrol_Tol); + scontrol = SUNAdaptController_MRIHTol(scontrol_H, scontrol_Tol, sunctx); if (check_ptr((void*)scontrol, "SUNAdaptController_MRIHTol")) return 1; - mcontrol = SUNAdaptController_MRIHTol(sunctx, mcontrol_H, mcontrol_Tol); + mcontrol = SUNAdaptController_MRIHTol(mcontrol_H, mcontrol_Tol, sunctx); if (check_ptr((void*)mcontrol, "SUNAdaptController_MRIHTol")) return 1; if (!(std::isnan(opts.htol_relch) || std::isnan(opts.htol_minfac) || std::isnan(opts.htol_maxfac))) @@ -697,9 +699,9 @@ int main(int argc, char* argv[]) mcontrol_Tol = SUNAdaptController_ImExGus(sunctx); if (check_ptr((void*)mcontrol_Tol, "SUNAdaptController_ImExGus (mid Tol)")) return 1; - scontrol = SUNAdaptController_MRIHTol(sunctx, scontrol_H, scontrol_Tol); + scontrol = SUNAdaptController_MRIHTol(scontrol_H, scontrol_Tol, sunctx); if (check_ptr((void*)scontrol, "SUNAdaptController_MRIHTol")) return 1; - mcontrol = SUNAdaptController_MRIHTol(sunctx, scontrol_H, scontrol_Tol); + mcontrol = SUNAdaptController_MRIHTol(scontrol_H, scontrol_Tol, sunctx); if (check_ptr((void*)mcontrol, "SUNAdaptController_MRIHTol")) return 1; if (!(std::isnan(opts.htol_relch) || std::isnan(opts.htol_minfac) || std::isnan(opts.htol_maxfac))) @@ -936,6 +938,8 @@ int main(int argc, char* argv[]) sunrealtype t2 = T0; sunrealtype dTout = (Tf - T0) / Nt; sunrealtype tout = T0 + dTout; + sunrealtype* ydata = N_VGetArrayPointer(y); + sunrealtype* yrefdata = N_VGetArrayPointer(yref); sunrealtype u, v, w, uerr, verr, werr, uerrtot, verrtot, werrtot, errtot, accuracy; uerr = verr = werr = uerrtot = verrtot = werrtot = errtot = accuracy = ZERO; @@ -945,18 +949,15 @@ int main(int argc, char* argv[]) "---------------------------------------------------------------------" "-------\n"); printf(" %10.6" FSYM " %10.6" FSYM " %10.6" FSYM " %10.6" FSYM " %.2" ESYM - " %.2" ESYM " %.2" ESYM "\n", - t, NV_Ith_S(y, 0), NV_Ith_S(y, 1), NV_Ith_S(y, 2), uerr, verr, werr); - int Nout = 0; - while (Tf - t > 1.0e-8) + while (Tf - t > SUN_RCONST(1.0e-8)) + t, ydata[0], ydata[1], ydata[2], uerr, verr, werr); + while (Tf - t > SUN_RCONST(1.0e-8)) { // reset reference solver so that it begins with identical state retval = ARKodeReset(arkode_ref, t, y); // evolve solution in one-step mode - retval = ARKodeSetStopTime(arkode_mem, tout); - if (check_flag(retval, "ARKodeSetStopTime")) return 1; - retval = ARKodeEvolve(arkode_mem, tout, y, &t, ARK_ONE_STEP); + retval = ARKodeEvolve(arkode_mem, Tf, y, &t, ARK_ONE_STEP); if (retval < 0) { printf("ARKodeEvolve error (%i)\n", retval); @@ -966,7 +967,7 @@ int main(int argc, char* argv[]) // evolve reference solver to same time in "normal" mode retval = ARKodeSetStopTime(arkode_ref, t); if (check_flag(retval, "ARKodeSetStopTime")) return 1; - retval = ARKodeEvolve(arkode_ref, t, yref, &t2, ARK_NORMAL); + retval = ARKodeEvolve(arkode_ref, Tf, yref, &t2, ARK_NORMAL); if (retval < 0) { printf("ARKodeEvolve reference solution error (%i)\n", retval); @@ -974,12 +975,12 @@ int main(int argc, char* argv[]) } // access/print solution and error - u = NV_Ith_S(y, 0); - v = NV_Ith_S(y, 1); - w = NV_Ith_S(y, 2); - uerr = std::abs(NV_Ith_S(yref, 0) - u); - verr = std::abs(NV_Ith_S(yref, 1) - v); - werr = std::abs(NV_Ith_S(yref, 2) - w); + u = ydata[0]; + v = ydata[1]; + w = ydata[2]; + uerr = std::abs(yrefdata[0] - u); + verr = std::abs(yrefdata[1] - v); + werr = std::abs(yrefdata[2] - w); uerrtot += uerr * uerr; verrtot += verr * verr; werrtot += werr * werr; @@ -993,7 +994,6 @@ int main(int argc, char* argv[]) accuracy = std::max(accuracy, werr / std::abs(opts.atol + opts.rtol * NV_Ith_S(yref, 2))); - Nout++; // Periodically output current results to screen if (t >= tout) @@ -1005,10 +1005,6 @@ int main(int argc, char* argv[]) t, u, v, w, uerr, verr, werr); } } - uerrtot = std::sqrt(uerrtot / Nt); - verrtot = std::sqrt(verrtot / Nt); - werrtot = std::sqrt(werrtot / Nt); - errtot = std::sqrt(errtot / Nt / 3); printf(" " "---------------------------------------------------------------------" "-------\n"); @@ -1051,6 +1047,10 @@ int main(int argc, char* argv[]) check_flag(retval, "ERKStepGetNumRhsEvals"); // Print some final statistics + uerrtot = std::sqrt(uerrtot / nsts); + verrtot = std::sqrt(verrtot / nsts); + werrtot = std::sqrt(werrtot / nsts); + errtot = std::sqrt(errtot / nsts / 3); std::cout << "\nFinal Solver Statistics:\n"; std::cout << " Slow steps = " << nsts << " (attempts = " << natts << ", fails = " << netfs << ")\n"; @@ -1074,8 +1074,10 @@ int main(int argc, char* argv[]) retval = ARKodeGetNumJacEvals(arkode_mem, &njes); check_flag(retval, "ARKodeGetNumJacEvals"); std::cout << " Slow Newton iters = " << nnis << std::endl; + std::cout << " Slow Newton iters/attempt = " << nnis/natts << std::endl; std::cout << " Slow Newton conv fails = " << nncs << std::endl; std::cout << " Slow Jacobian evals = " << njes << std::endl; + std::cout << " Slow Jacobian evals/Newton = " << njes/nnis << std::endl; } // Get/print intermediate integrator implicit solver statistics @@ -1087,12 +1089,15 @@ int main(int argc, char* argv[]) retval = ARKodeGetNumJacEvals(mid_arkode_mem, &njem); check_flag(retval, "ARKodeGetNumJacEvals"); std::cout << " Intermediate Newton iters = " << nnim << std::endl; + std::cout << " Intermediate Newton iters/attempt = " << nnim/nattm << std::endl; std::cout << " Intermediate Newton conv fails = " << nncm << std::endl; std::cout << " Intermediate Jacobian evals = " << njem << std::endl; + std::cout << " Intermediate Jacobian evals/Newton = " << njem/nnim << std::endl; } // Clean up and return N_VDestroy(y); + N_VDestroy(yref); MRIStepCoupling_Free(Cs); MRIStepCoupling_Free(Cm); SUNMatDestroy(As); @@ -1123,14 +1128,16 @@ int main(int argc, char* argv[]) // fn routine to compute the full ODE RHS. static int fn(sunrealtype t, N_Vector y, N_Vector ydot, void* user_data) { - Options* opts = static_cast(user_data); - const sunrealtype u = NV_Ith_S(y, 0); - const sunrealtype v = NV_Ith_S(y, 1); - const sunrealtype w = NV_Ith_S(y, 2); - const sunrealtype G = opts->G; - const sunrealtype e = opts->e; - const sunrealtype al = opts->al; - const sunrealtype be = opts->be; + Options* opts = static_cast(user_data); + sunrealtype* ydata = N_VGetArrayPointer(y); + sunrealtype* ydotdata = N_VGetArrayPointer(ydot); + const sunrealtype u = ydata[0]; + const sunrealtype v = ydata[1]; + const sunrealtype w = ydata[2]; + const sunrealtype G = opts->G; + const sunrealtype e = opts->e; + const sunrealtype al = opts->al; + const sunrealtype be = opts->be; sunrealtype tmp1, tmp2, tmp3; // fill in the RHS function: @@ -1140,11 +1147,11 @@ static int fn(sunrealtype t, N_Vector y, N_Vector ydot, void* user_data) tmp1 = (-TWO + u * u - p(t, *opts)) / (TWO * u); tmp2 = (-TWO + v * v - q(t, *opts)) / (TWO * v); tmp3 = (-TWO + w * w - r(t, *opts)) / (TWO * w); - NV_Ith_S(ydot, 0) = G * tmp1 + e * tmp2 + e * tmp3 + pdot(t, *opts) / (TWO * u); - NV_Ith_S(ydot, 1) = e * tmp1 + al * tmp2 + be * tmp3 + - qdot(t, *opts) / (TWO * v); - NV_Ith_S(ydot, 2) = e * tmp1 - be * tmp2 + al * tmp3 + - rdot(t, *opts) / (TWO * w); + ydotdata[0] = G * tmp1 + e * tmp2 + e * tmp3 + pdot(t, *opts) / (TWO * u); + ydotdata[1] = e * tmp1 + al * tmp2 + be * tmp3 + + qdot(t, *opts) / (TWO * v); + ydotdata[2] = e * tmp1 - be * tmp2 + al * tmp3 + + rdot(t, *opts) / (TWO * w); // Return with success return 0; @@ -1153,13 +1160,15 @@ static int fn(sunrealtype t, N_Vector y, N_Vector ydot, void* user_data) // ff routine to compute the fast portion of the ODE RHS. static int ff(sunrealtype t, N_Vector y, N_Vector ydot, void* user_data) { - Options* opts = static_cast(user_data); - const sunrealtype u = NV_Ith_S(y, 0); - const sunrealtype v = NV_Ith_S(y, 1); - const sunrealtype w = NV_Ith_S(y, 2); - const sunrealtype e = opts->e; - const sunrealtype al = opts->al; - const sunrealtype be = opts->be; + Options* opts = static_cast(user_data); + sunrealtype* ydata = N_VGetArrayPointer(y); + sunrealtype* ydotdata = N_VGetArrayPointer(ydot); + const sunrealtype u = ydata[0]; + const sunrealtype v = ydata[1]; + const sunrealtype w = ydata[2]; + const sunrealtype e = opts->e; + const sunrealtype al = opts->al; + const sunrealtype be = opts->be; sunrealtype tmp1, tmp2, tmp3; // fill in the RHS function: @@ -1169,10 +1178,10 @@ static int ff(sunrealtype t, N_Vector y, N_Vector ydot, void* user_data) tmp1 = (-TWO + u * u - p(t, *opts)) / (TWO * u); tmp2 = (-TWO + v * v - q(t, *opts)) / (TWO * v); tmp3 = (-TWO + w * w - r(t, *opts)) / (TWO * w); - NV_Ith_S(ydot, 0) = ZERO; - NV_Ith_S(ydot, 1) = ZERO; - NV_Ith_S(ydot, 2) = e * tmp1 - be * tmp2 + al * tmp3 + - rdot(t, *opts) / (TWO * w); + ydotdata[0] = ZERO; + ydotdata[1] = ZERO; + ydotdata[2] = e * tmp1 - be * tmp2 + al * tmp3 + + rdot(t, *opts) / (TWO * w); // Return with success return 0; @@ -1181,13 +1190,15 @@ static int ff(sunrealtype t, N_Vector y, N_Vector ydot, void* user_data) // fm routine to compute the intermediate portion of the ODE RHS. static int fm(sunrealtype t, N_Vector y, N_Vector ydot, void* user_data) { - Options* opts = static_cast(user_data); - const sunrealtype u = NV_Ith_S(y, 0); - const sunrealtype v = NV_Ith_S(y, 1); - const sunrealtype w = NV_Ith_S(y, 2); - const sunrealtype e = opts->e; - const sunrealtype al = opts->al; - const sunrealtype be = opts->be; + Options* opts = static_cast(user_data); + sunrealtype* ydata = N_VGetArrayPointer(y); + sunrealtype* ydotdata = N_VGetArrayPointer(ydot); + const sunrealtype u = ydata[0]; + const sunrealtype v = ydata[1]; + const sunrealtype w = ydata[2]; + const sunrealtype e = opts->e; + const sunrealtype al = opts->al; + const sunrealtype be = opts->be; sunrealtype tmp1, tmp2, tmp3; // fill in the RHS function: @@ -1197,10 +1208,10 @@ static int fm(sunrealtype t, N_Vector y, N_Vector ydot, void* user_data) tmp1 = (-TWO + u * u - p(t, *opts)) / (TWO * u); tmp2 = (-TWO + v * v - q(t, *opts)) / (TWO * v); tmp3 = (-TWO + w * w - r(t, *opts)) / (TWO * w); - NV_Ith_S(ydot, 0) = ZERO; - NV_Ith_S(ydot, 1) = e * tmp1 + al * tmp2 + be * tmp3 + - qdot(t, *opts) / (TWO * v); - NV_Ith_S(ydot, 2) = ZERO; + ydotdata[0] = ZERO; + ydotdata[1] = e * tmp1 + al * tmp2 + be * tmp3 + + qdot(t, *opts) / (TWO * v); + ydotdata[2] = ZERO; return 0; } @@ -1208,16 +1219,18 @@ static int fm(sunrealtype t, N_Vector y, N_Vector ydot, void* user_data) // fme routine to compute the explicit intermediate portion of the ODE RHS. static int fme(sunrealtype t, N_Vector y, N_Vector ydot, void* user_data) { - Options* opts = static_cast(user_data); - const sunrealtype v = NV_Ith_S(y, 1); + Options* opts = static_cast(user_data); + sunrealtype* ydata = N_VGetArrayPointer(y); + sunrealtype* ydotdata = N_VGetArrayPointer(ydot); + const sunrealtype v = ydata[1]; // fill in the RHS function: // [ 0 ] // [ qdot(t)/(2v) ] // [ 0 ] - NV_Ith_S(ydot, 0) = ZERO; - NV_Ith_S(ydot, 1) = qdot(t, *opts) / (TWO * v); - NV_Ith_S(ydot, 2) = ZERO; + ydotdata[0] = ZERO; + ydotdata[1] = qdot(t, *opts) / (TWO * v); + ydotdata[2] = ZERO; return 0; } @@ -1225,25 +1238,27 @@ static int fme(sunrealtype t, N_Vector y, N_Vector ydot, void* user_data) // fmi routine to compute the implicit intermediate portion of the ODE RHS. static int fmi(sunrealtype t, N_Vector y, N_Vector ydot, void* user_data) { - Options* opts = static_cast(user_data); - const sunrealtype u = NV_Ith_S(y, 0); - const sunrealtype v = NV_Ith_S(y, 1); - const sunrealtype w = NV_Ith_S(y, 2); - const sunrealtype e = opts->e; - const sunrealtype al = opts->al; - const sunrealtype be = opts->be; + Options* opts = static_cast(user_data); + sunrealtype* ydata = N_VGetArrayPointer(y); + sunrealtype* ydotdata = N_VGetArrayPointer(ydot); + const sunrealtype u = ydata[0]; + const sunrealtype v = ydata[1]; + const sunrealtype w = ydata[2]; + const sunrealtype e = opts->e; + const sunrealtype al = opts->al; + const sunrealtype be = opts->be; sunrealtype tmp1, tmp2, tmp3; // fill in the RHS function: // [ 0 0 0 ] [(u^2-p-2)/(2u)] // [ e al be ] [(v^2-q-2)/(2v)] // [ 0 0 0 ] [(w^2-r-2)/(2w)] - tmp1 = (-TWO + u * u - p(t, *opts)) / (TWO * u); - tmp2 = (-TWO + v * v - q(t, *opts)) / (TWO * v); - tmp3 = (-TWO + w * w - r(t, *opts)) / (TWO * w); - NV_Ith_S(ydot, 0) = ZERO; - NV_Ith_S(ydot, 1) = e * tmp1 + al * tmp2 + be * tmp3; - NV_Ith_S(ydot, 2) = ZERO; + tmp1 = (-TWO + u * u - p(t, *opts)) / (TWO * u); + tmp2 = (-TWO + v * v - q(t, *opts)) / (TWO * v); + tmp3 = (-TWO + w * w - r(t, *opts)) / (TWO * w); + ydotdata[0] = ZERO; + ydotdata[1] = e * tmp1 + al * tmp2 + be * tmp3; + ydotdata[2] = ZERO; // Return with success return 0; @@ -1252,12 +1267,14 @@ static int fmi(sunrealtype t, N_Vector y, N_Vector ydot, void* user_data) // fs routine to compute the slow portion of the ODE RHS. static int fs(sunrealtype t, N_Vector y, N_Vector ydot, void* user_data) { - Options* opts = static_cast(user_data); - const sunrealtype u = NV_Ith_S(y, 0); - const sunrealtype v = NV_Ith_S(y, 1); - const sunrealtype w = NV_Ith_S(y, 2); - const sunrealtype G = opts->G; - const sunrealtype e = opts->e; + Options* opts = static_cast(user_data); + sunrealtype* ydata = N_VGetArrayPointer(y); + sunrealtype* ydotdata = N_VGetArrayPointer(ydot); + const sunrealtype u = ydata[0]; + const sunrealtype v = ydata[1]; + const sunrealtype w = ydata[2]; + const sunrealtype G = opts->G; + const sunrealtype e = opts->e; sunrealtype tmp1, tmp2, tmp3; // fill in the RHS function: @@ -1267,9 +1284,9 @@ static int fs(sunrealtype t, N_Vector y, N_Vector ydot, void* user_data) tmp1 = (-TWO + u * u - p(t, *opts)) / (TWO * u); tmp2 = (-TWO + v * v - q(t, *opts)) / (TWO * v); tmp3 = (-TWO + w * w - r(t, *opts)) / (TWO * w); - NV_Ith_S(ydot, 0) = G * tmp1 + e * tmp2 + e * tmp3 + pdot(t, *opts) / (TWO * u); - NV_Ith_S(ydot, 1) = ZERO; - NV_Ith_S(ydot, 2) = ZERO; + ydotdata[0] = G * tmp1 + e * tmp2 + e * tmp3 + pdot(t, *opts) / (TWO * u); + ydotdata[1] = ZERO; + ydotdata[2] = ZERO; return 0; } @@ -1277,16 +1294,18 @@ static int fs(sunrealtype t, N_Vector y, N_Vector ydot, void* user_data) // fse routine to compute the explicit slow portion of the ODE RHS. static int fse(sunrealtype t, N_Vector y, N_Vector ydot, void* user_data) { - Options* opts = static_cast(user_data); - const sunrealtype u = NV_Ith_S(y, 0); + Options* opts. = static_cast(user_data); + sunrealtype* ydata = N_VGetArrayPointer(y); + sunrealtype* ydotdata = N_VGetArrayPointer(ydot); + const sunrealtype u = ydata[0]; // fill in the RHS function: // [ pdot(t)/(2u) ] // [ 0 ] // [ 0 ] - NV_Ith_S(ydot, 0) = pdot(t, *opts) / (TWO * u); - NV_Ith_S(ydot, 1) = ZERO; - NV_Ith_S(ydot, 2) = ZERO; + ydotdata[0] = pdot(t, *opts) / (TWO * u); + ydotdata[1] = ZERO; + ydotdata[2] = ZERO; return 0; } @@ -1294,24 +1313,26 @@ static int fse(sunrealtype t, N_Vector y, N_Vector ydot, void* user_data) // fsi routine to compute the implicit slow portion of the ODE RHS. static int fsi(sunrealtype t, N_Vector y, N_Vector ydot, void* user_data) { - Options* opts = static_cast(user_data); - const sunrealtype u = NV_Ith_S(y, 0); - const sunrealtype v = NV_Ith_S(y, 1); - const sunrealtype w = NV_Ith_S(y, 2); - const sunrealtype G = opts->G; - const sunrealtype e = opts->e; + Options* opts = static_cast(user_data); + sunrealtype* ydata = N_VGetArrayPointer(y); + sunrealtype* ydotdata = N_VGetArrayPointer(ydot); + const sunrealtype u = ydata[0]; + const sunrealtype v = ydata[1]; + const sunrealtype w = ydata[2]; + const sunrealtype G = opts->G; + const sunrealtype e = opts->e; sunrealtype tmp1, tmp2, tmp3; // fill in the RHS function: // [ G e e ] [(u^2-p-2)/(2u)] // [ 0 0 0 ] [(v^2-q-2)/(2v)] // [ 0 0 0 ] [(w^2-r-2)/(2w)] - tmp1 = (-TWO + u * u - p(t, *opts)) / (TWO * u); - tmp2 = (-TWO + v * v - q(t, *opts)) / (TWO * v); - tmp3 = (-TWO + w * w - r(t, *opts)) / (TWO * w); - NV_Ith_S(ydot, 0) = G * tmp1 + e * tmp2 + e * tmp3; - NV_Ith_S(ydot, 1) = ZERO; - NV_Ith_S(ydot, 2) = ZERO; + tmp1 = (-TWO + u * u - p(t, *opts)) / (TWO * u); + tmp2 = (-TWO + v * v - q(t, *opts)) / (TWO * v); + tmp3 = (-TWO + w * w - r(t, *opts)) / (TWO * w); + ydotdata[0] = G * tmp1 + e * tmp2 + e * tmp3; + ydotdata[1] = ZERO; + ydotdata[2] = ZERO; // Return with success return 0; @@ -1321,10 +1342,11 @@ static int fsi(sunrealtype t, N_Vector y, N_Vector ydot, void* user_data) static int Jm(sunrealtype t, N_Vector y, N_Vector fy, SUNMatrix J, void* user_data, N_Vector tmp1, N_Vector tmp2, N_Vector tmp3) { - Options* opts = static_cast(user_data); - const sunrealtype u = NV_Ith_S(y, 0); - const sunrealtype v = NV_Ith_S(y, 1); - const sunrealtype w = NV_Ith_S(y, 2); + Options* opts = static_cast(user_data); + sunrealtype* ydata = N_VGetArrayPointer(y); + const sunrealtype u = ydata[0]; + const sunrealtype v = ydata[1]; + const sunrealtype w = ydata[2]; sunrealtype t11, t22, t33; // fill in the Jacobian: @@ -1352,10 +1374,11 @@ static int Jm(sunrealtype t, N_Vector y, N_Vector fy, SUNMatrix J, static int Jmi(sunrealtype t, N_Vector y, N_Vector fy, SUNMatrix J, void* user_data, N_Vector tmp1, N_Vector tmp2, N_Vector tmp3) { - Options* opts = static_cast(user_data); - const sunrealtype u = NV_Ith_S(y, 0); - const sunrealtype v = NV_Ith_S(y, 1); - const sunrealtype w = NV_Ith_S(y, 2); + Options* opts = static_cast(user_data); + sunrealtype* ydata = N_VGetArrayPointer(y); + const sunrealtype u = ydata[0]; + const sunrealtype v = ydata[1]; + const sunrealtype w = ydata[2]; sunrealtype t11, t22, t33; // fill in the Jacobian: @@ -1383,10 +1406,11 @@ static int Jmi(sunrealtype t, N_Vector y, N_Vector fy, SUNMatrix J, static int Js(sunrealtype t, N_Vector y, N_Vector fy, SUNMatrix J, void* user_data, N_Vector tmp1, N_Vector tmp2, N_Vector tmp3) { - Options* opts = static_cast(user_data); - const sunrealtype u = NV_Ith_S(y, 0); - const sunrealtype v = NV_Ith_S(y, 1); - const sunrealtype w = NV_Ith_S(y, 2); + Options* opts = static_cast(user_data); + sunrealtype* ydata = N_VGetArrayPointer(y); + const sunrealtype u = ydata[0]; + const sunrealtype v = ydata[1]; + const sunrealtype w = ydata[2]; sunrealtype t11, t22, t33; // fill in the Jacobian: @@ -1414,10 +1438,11 @@ static int Js(sunrealtype t, N_Vector y, N_Vector fy, SUNMatrix J, static int Jsi(sunrealtype t, N_Vector y, N_Vector fy, SUNMatrix J, void* user_data, N_Vector tmp1, N_Vector tmp2, N_Vector tmp3) { - Options* opts = static_cast(user_data); - const sunrealtype u = NV_Ith_S(y, 0); - const sunrealtype v = NV_Ith_S(y, 1); - const sunrealtype w = NV_Ith_S(y, 2); + Options* opts = static_cast(user_data); + sunrealtype* ydata = N_VGetArrayPointer(y); + const sunrealtype u = ydata[0]; + const sunrealtype v = ydata[1]; + const sunrealtype w = ydata[2]; sunrealtype t11, t22, t33; // fill in the Jacobian: diff --git a/examples/arkode/C_serial/CMakeLists.txt b/examples/arkode/C_serial/CMakeLists.txt index f5b236bf65..74e5665ea9 100644 --- a/examples/arkode/C_serial/CMakeLists.txt +++ b/examples/arkode/C_serial/CMakeLists.txt @@ -59,21 +59,21 @@ set(ARKODE_examples "ark_kepler\;--stepper SPRK --step-mode fixed --method ARKODE_SPRK_RUTH_3_3 --tf 50 --check-order --nout 1\;exclude-single" "ark_kepler\;--stepper SPRK --step-mode fixed --method ARKODE_SPRK_YOSHIDA_6_8 --tf 50 --check-order --nout 1\;exclude-single" "ark_kepler\;\;develop" - "ark_kpr_mri\;0 1 0.005\;exclude-single" - "ark_kpr_mri\;1 0 0.01\;exclude-single" - "ark_kpr_mri\;1 1 0.002\;exclude-single" - "ark_kpr_mri\;2 4 0.002\;exclude-single" - "ark_kpr_mri\;3 2 0.001\;exclude-single" - "ark_kpr_mri\;4 3 0.001\;exclude-single" - "ark_kpr_mri\;5 4 0.001\;exclude-single" - "ark_kpr_mri\;6 5 0.001\;exclude-single" - "ark_kpr_mri\;7 2 0.002\;exclude-single" + "ark_kpr_mri\;0 1 0.005\;develop" + "ark_kpr_mri\;1 0 0.01\;develop" + "ark_kpr_mri\;1 1 0.002\;develop" + "ark_kpr_mri\;2 4 0.002\;develop" + "ark_kpr_mri\;3 2 0.001\;develop" + "ark_kpr_mri\;4 3 0.001\;develop" + "ark_kpr_mri\;5 4 0.001\;develop" + "ark_kpr_mri\;6 5 0.001\;develop" + "ark_kpr_mri\;7 2 0.002\;develop" "ark_kpr_mri\;8 3 0.001 -100 100 0.5 1\;exclude-single" "ark_kpr_mri\;9 3 0.001 -100 100 0.5 1\;exclude-single" "ark_kpr_mri\;10 4 0.001 -100 100 0.5 1\;exclude-single" - "ark_kpr_mri\;11 2 0.001\;exclude-single" - "ark_kpr_mri\;12 3 0.005\;exclude-single" - "ark_kpr_mri\;13 4 0.01\;exclude-single" + "ark_kpr_mri\;11 2 0.001\;develop" + "ark_kpr_mri\;12 3 0.005\;develop" + "ark_kpr_mri\;13 4 0.01\;develop" "ark_KrylovDemo_prec\;\;exclude-single" "ark_KrylovDemo_prec\;1\;exclude-single" "ark_KrylovDemo_prec\;2\;exclude-single" diff --git a/examples/arkode/C_serial/ark_kpr_mri.c b/examples/arkode/C_serial/ark_kpr_mri.c index f59fc480ed..d9e96e6a1f 100644 --- a/examples/arkode/C_serial/ark_kpr_mri.c +++ b/examples/arkode/C_serial/ark_kpr_mri.c @@ -64,6 +64,7 @@ * $ ark_kpr_mri slow_type fast_type h G w e deduce_rhs * Not all arguments are required, but these must be omitted from * end-to-beginning, i.e. any one of + * $ ark_kpr_mri slow_type fast_type h G w e deduce_rhs * $ ark_kpr_mri slow_type fast_type h G w e * $ ark_kpr_mri slow_type fast_type h G w * $ ark_kpr_mri slow_type fast_type h G @@ -189,8 +190,8 @@ int main(int argc, char* argv[]) printf(" ark_kpr_mri slow_type fast_type h G w e deduce_rhs"); return (-1); } - slow_type = (sunindextype)atol(argv[1]); - fast_type = (sunindextype)atol(argv[2]); + slow_type = atoi(argv[1]); + fast_type = atoi(argv[2]); if (argc > 3) { hs = SUNStrToReal(argv[3]); } if (argc > 4) { G = SUNStrToReal(argv[4]); } if (argc > 5) { w = SUNStrToReal(argv[5]); } @@ -211,7 +212,7 @@ int main(int argc, char* argv[]) } if ((fast_type < 0) || (fast_type > 5)) { - printf("ERROR: fast_type be an integer in [0,3] \n"); + printf("ERROR: fast_type be an integer in [0,5] \n"); return (-1); } if ((slow_type == 0) && (fast_type == 0)) @@ -344,10 +345,6 @@ int main(int argc, char* argv[]) printf(" fast solver: none\n"); no_fast = SUNTRUE; break; - case (3): - printf(" fast solver: erk-3-3\n"); - explicit_fast = SUNTRUE; - break; case (1): printf(" fast solver: esdirk-3-3\n"); implicit_fast = SUNTRUE; @@ -355,14 +352,18 @@ int main(int argc, char* argv[]) abstol = 1e-11; printf(" reltol = %.2" ESYM ", abstol = %.2" ESYM "\n", reltol, abstol); break; - case (4): - printf(" fast solver: erk-4-4\n"); - explicit_fast = SUNTRUE; - break; case (2): printf(" fast solver: ARKODE_HEUN_EULER_2_1_2\n"); explicit_fast = SUNTRUE; break; + case (3): + printf(" fast solver: erk-3-3\n"); + explicit_fast = SUNTRUE; + break; + case (4): + printf(" fast solver: erk-4-4\n"); + explicit_fast = SUNTRUE; + break; case (5): printf(" fast solver: ARKODE_DORMAND_PRINCE_7_4_5\n"); explicit_fast = SUNTRUE; @@ -432,22 +433,6 @@ int main(int argc, char* argv[]) switch (fast_type) { case (0): - case (3): - B = ARKodeButcherTable_Alloc(3, SUNTRUE); - if (check_retval((void*)B, "ARKodeButcherTable_Alloc", 0)) { return 1; } - B->A[1][0] = SUN_RCONST(0.5); - B->A[2][0] = -ONE; - B->A[2][1] = TWO; - B->b[0] = ONE / SUN_RCONST(6.0); - B->b[1] = TWO / SUN_RCONST(3.0); - B->b[2] = ONE / SUN_RCONST(6.0); - B->d[1] = ONE; - B->c[1] = SUN_RCONST(0.5); - B->c[2] = ONE; - B->q = 3; - B->p = 2; - retval = ARKStepSetTables(inner_arkode_mem, 3, 2, NULL, B); - if (check_retval(&retval, "ARKStepSetTables", 1)) { return 1; } break; case (1): B = ARKodeButcherTable_Alloc(3, SUNFALSE); @@ -468,6 +453,29 @@ int main(int argc, char* argv[]) retval = ARKStepSetTables(inner_arkode_mem, 3, 0, B, NULL); if (check_retval(&retval, "ARKStepSetTables", 1)) { return 1; } break; + case (2): + B = ARKodeButcherTable_LoadERK(ARKODE_HEUN_EULER_2_1_2); + if (check_retval((void*)B, "ARKodeButcherTable_LoadERK", 0)) { return 1; } + retval = ARKStepSetTables(inner_arkode_mem, 2, 1, NULL, B); + if (check_retval(&retval, "ARKStepSetTables", 1)) { return 1; } + break; + case (3): + B = ARKodeButcherTable_Alloc(3, SUNTRUE); + if (check_retval((void*)B, "ARKodeButcherTable_Alloc", 0)) { return 1; } + B->A[1][0] = SUN_RCONST(0.5); + B->A[2][0] = -ONE; + B->A[2][1] = TWO; + B->b[0] = ONE / SUN_RCONST(6.0); + B->b[1] = TWO / SUN_RCONST(3.0); + B->b[2] = ONE / SUN_RCONST(6.0); + B->d[1] = ONE; + B->c[1] = SUN_RCONST(0.5); + B->c[2] = ONE; + B->q = 3; + B->p = 2; + retval = ARKStepSetTables(inner_arkode_mem, 3, 2, NULL, B); + if (check_retval(&retval, "ARKStepSetTables", 1)) { return 1; } + break; case (4): B = ARKodeButcherTable_Alloc(4, SUNFALSE); if (check_retval((void*)B, "ARKodeButcherTable_Alloc", 0)) { return 1; } @@ -485,12 +493,6 @@ int main(int argc, char* argv[]) retval = ARKStepSetTables(inner_arkode_mem, 4, 0, NULL, B); if (check_retval(&retval, "ARKStepSetTables", 1)) { return 1; } break; - case (2): - B = ARKodeButcherTable_LoadERK(ARKODE_HEUN_EULER_2_1_2); - if (check_retval((void*)B, "ARKodeButcherTable_LoadERK", 0)) { return 1; } - retval = ARKStepSetTables(inner_arkode_mem, 2, 1, NULL, B); - if (check_retval(&retval, "ARKStepSetTables", 1)) { return 1; } - break; case (5): B = ARKodeButcherTable_LoadERK(ARKODE_DORMAND_PRINCE_7_4_5); if (check_retval((void*)B, "ARKodeButcherTable_LoadERK", 0)) { return 1; } diff --git a/include/arkode/arkode_mristep.h b/include/arkode/arkode_mristep.h index 3812b04d07..23c43a2309 100644 --- a/include/arkode/arkode_mristep.h +++ b/include/arkode/arkode_mristep.h @@ -122,8 +122,6 @@ typedef int (*MRIStepInnerGetAccumulatedError)(MRIStepInnerStepper stepper, typedef int (*MRIStepInnerResetAccumulatedError)(MRIStepInnerStepper stepper); -typedef int (*MRIStepInnerSetFixedStep)(MRIStepInnerStepper stepper, - sunrealtype h); typedef int (*MRIStepInnerSetRTol)(MRIStepInnerStepper stepper, sunrealtype rtol); diff --git a/include/sunadaptcontroller/sunadaptcontroller_mrihtol.h b/include/sunadaptcontroller/sunadaptcontroller_mrihtol.h index 0e58f6d7ee..e53f17327f 100644 --- a/include/sunadaptcontroller/sunadaptcontroller_mrihtol.h +++ b/include/sunadaptcontroller/sunadaptcontroller_mrihtol.h @@ -24,9 +24,9 @@ extern "C" { #endif -/* -------------------------------------------- +/* ---------------------------------------------------- * MRI H+tolerance implementation of SUNAdaptController - * -------------------------------------------- */ + * ---------------------------------------------------- */ struct SUNAdaptControllerContent_MRIHTol_ { @@ -44,9 +44,9 @@ typedef struct SUNAdaptControllerContent_MRIHTol_* SUNAdaptControllerContent_MRI * ------------------ */ SUNDIALS_EXPORT -SUNAdaptController SUNAdaptController_MRIHTol(SUNContext sunctx, - SUNAdaptController HControl, - SUNAdaptController TolControl); +SUNAdaptController SUNAdaptController_MRIHTol(SUNAdaptController HControl, + SUNAdaptController TolControl, + SUNContext sunctx); SUNDIALS_EXPORT SUNErrCode SUNAdaptController_SetParams_MRIHTol(SUNAdaptController C, sunrealtype inner_max_relch, diff --git a/include/sundials/sundials_adaptcontroller.h b/include/sundials/sundials_adaptcontroller.h index dc3572e12b..4809ea64eb 100644 --- a/include/sundials/sundials_adaptcontroller.h +++ b/include/sundials/sundials_adaptcontroller.h @@ -34,7 +34,7 @@ extern "C" { * SUNAdaptController types: * NONE - empty controller (does nothing) * H - controls a single-rate step size - * MRI_TOL - controls slow and fast relative tolerances + * MRI_H_TOL - controls slow step and fast relative tolerances * ----------------------------------------------------------------- */ typedef enum diff --git a/src/sunadaptcontroller/mrihtol/sunadaptcontroller_mrihtol.c b/src/sunadaptcontroller/mrihtol/sunadaptcontroller_mrihtol.c index 0e454c562e..ae8716258a 100644 --- a/src/sunadaptcontroller/mrihtol/sunadaptcontroller_mrihtol.c +++ b/src/sunadaptcontroller/mrihtol/sunadaptcontroller_mrihtol.c @@ -55,9 +55,9 @@ * Function to create a new MRIHTol controller */ -SUNAdaptController SUNAdaptController_MRIHTol(SUNContext sunctx, - SUNAdaptController HControl, - SUNAdaptController TolControl) +SUNAdaptController SUNAdaptController_MRIHTol(SUNAdaptController HControl, + SUNAdaptController TolControl, + SUNContext sunctx) { SUNFunctionBegin(sunctx); diff --git a/test/unit_tests/arkode/CXX_serial/ark_test_brusselator_mriadapt.cpp b/test/unit_tests/arkode/CXX_serial/ark_test_brusselator_mriadapt.cpp index d801784816..57714351d6 100644 --- a/test/unit_tests/arkode/CXX_serial/ark_test_brusselator_mriadapt.cpp +++ b/test/unit_tests/arkode/CXX_serial/ark_test_brusselator_mriadapt.cpp @@ -403,7 +403,7 @@ int main(int argc, char* argv[]) retval = SUNAdaptController_SetParams_I(scontrol_Tol, opts.k1s); if (check_flag(retval, "SUNAdaptController_SetParams_I")) return 1; } - scontrol = SUNAdaptController_MRIHTol(sunctx, scontrol_H, scontrol_Tol); + scontrol = SUNAdaptController_MRIHTol(scontrol_H, scontrol_Tol, sunctx); if (check_ptr((void*)scontrol, "SUNAdaptController_MRIHTol")) return 1; if (std::min(opts.htol_relch, std::min(opts.htol_minfac, opts.htol_maxfac)) > -1) @@ -437,7 +437,7 @@ int main(int argc, char* argv[]) retval = SUNAdaptController_SetParams_PI(scontrol_Tol, opts.k1s, opts.k2s); if (check_flag(retval, "SUNAdaptController_SetParams_PI")) return 1; } - scontrol = SUNAdaptController_MRIHTol(sunctx, scontrol_H, scontrol_Tol); + scontrol = SUNAdaptController_MRIHTol(scontrol_H, scontrol_Tol, sunctx); if (check_ptr((void*)scontrol, "SUNAdaptController_MRIHTol")) return 1; if (std::min(opts.htol_relch, std::min(opts.htol_minfac, opts.htol_maxfac)) > -1) @@ -473,7 +473,7 @@ int main(int argc, char* argv[]) opts.k2s, opts.k3s); if (check_flag(retval, "SUNAdaptController_SetParams_PID")) return 1; } - scontrol = SUNAdaptController_MRIHTol(sunctx, scontrol_H, scontrol_Tol); + scontrol = SUNAdaptController_MRIHTol(scontrol_H, scontrol_Tol, sunctx); if (check_ptr((void*)scontrol, "SUNAdaptController_MRIHTol")) return 1; if (std::min(opts.htol_relch, std::min(opts.htol_minfac, opts.htol_maxfac)) > -1) @@ -510,7 +510,7 @@ int main(int argc, char* argv[]) opts.k2s); if (check_flag(retval, "SUNAdaptController_SetParams_ExpGus")) return 1; } - scontrol = SUNAdaptController_MRIHTol(sunctx, scontrol_H, scontrol_Tol); + scontrol = SUNAdaptController_MRIHTol(scontrol_H, scontrol_Tol, sunctx); if (check_ptr((void*)scontrol, "SUNAdaptController_MRIHTol")) return 1; if (std::min(opts.htol_relch, std::min(opts.htol_minfac, opts.htol_maxfac)) > -1) @@ -547,7 +547,7 @@ int main(int argc, char* argv[]) opts.k2s); if (check_flag(retval, "SUNAdaptController_SetParams_ImpGus")) return 1; } - scontrol = SUNAdaptController_MRIHTol(sunctx, scontrol_H, scontrol_Tol); + scontrol = SUNAdaptController_MRIHTol(scontrol_H, scontrol_Tol, sunctx); if (check_ptr((void*)scontrol, "SUNAdaptController_MRIHTol")) return 1; if (std::min(opts.htol_relch, std::min(opts.htol_minfac, opts.htol_maxfac)) > -1) @@ -575,7 +575,7 @@ int main(int argc, char* argv[]) scontrol_Tol = SUNAdaptController_ImExGus(sunctx); if (check_ptr((void*)scontrol_Tol, "SUNAdaptController_ImExGus (slow Tol)")) return 1; - scontrol = SUNAdaptController_MRIHTol(sunctx, scontrol_H, scontrol_Tol); + scontrol = SUNAdaptController_MRIHTol(scontrol_H, scontrol_Tolsunctx); if (check_ptr((void*)scontrol, "SUNAdaptController_MRIHTol")) return 1; if (std::min(opts.htol_relch, std::min(opts.htol_minfac, opts.htol_maxfac)) > -1) diff --git a/test/unit_tests/arkode/CXX_serial/ark_test_kpr_mriadapt.cpp b/test/unit_tests/arkode/CXX_serial/ark_test_kpr_mriadapt.cpp index ae24a2f0dc..5611780f19 100644 --- a/test/unit_tests/arkode/CXX_serial/ark_test_kpr_mriadapt.cpp +++ b/test/unit_tests/arkode/CXX_serial/ark_test_kpr_mriadapt.cpp @@ -413,7 +413,7 @@ int main(int argc, char* argv[]) retval = SUNAdaptController_SetParams_I(scontrol_Tol, opts.k1s); if (check_flag(retval, "SUNAdaptController_SetParams_I")) return 1; } - scontrol = SUNAdaptController_MRIHTol(sunctx, scontrol_H, scontrol_Tol); + scontrol = SUNAdaptController_MRIHTol(scontrol_H, scontrol_Tol, sunctx); if (check_ptr((void*)scontrol, "SUNAdaptController_MRIHTol")) return 1; if (std::min(opts.htol_relch, std::min(opts.htol_minfac, opts.htol_maxfac)) > -1) @@ -447,7 +447,7 @@ int main(int argc, char* argv[]) retval = SUNAdaptController_SetParams_PI(scontrol_Tol, opts.k1s, opts.k2s); if (check_flag(retval, "SUNAdaptController_SetParams_PI")) return 1; } - scontrol = SUNAdaptController_MRIHTol(sunctx, scontrol_H, scontrol_Tol); + scontrol = SUNAdaptController_MRIHTol(scontrol_H, scontrol_Tol, sunctx); if (check_ptr((void*)scontrol, "SUNAdaptController_MRIHTol")) return 1; if (std::min(opts.htol_relch, std::min(opts.htol_minfac, opts.htol_maxfac)) > -1) @@ -483,7 +483,7 @@ int main(int argc, char* argv[]) opts.k2s, opts.k3s); if (check_flag(retval, "SUNAdaptController_SetParams_PID")) return 1; } - scontrol = SUNAdaptController_MRIHTol(sunctx, scontrol_H, scontrol_Tol); + scontrol = SUNAdaptController_MRIHTol(scontrol_H, scontrol_Tol, sunctx); if (check_ptr((void*)scontrol, "SUNAdaptController_MRIHTol")) return 1; if (std::min(opts.htol_relch, std::min(opts.htol_minfac, opts.htol_maxfac)) > -1) @@ -520,7 +520,7 @@ int main(int argc, char* argv[]) opts.k2s); if (check_flag(retval, "SUNAdaptController_SetParams_ExpGus")) return 1; } - scontrol = SUNAdaptController_MRIHTol(sunctx, scontrol_H, scontrol_Tol); + scontrol = SUNAdaptController_MRIHTol(scontrol_H, scontrol_Tol, sunctx); if (check_ptr((void*)scontrol, "SUNAdaptController_MRIHTol")) return 1; if (std::min(opts.htol_relch, std::min(opts.htol_minfac, opts.htol_maxfac)) > -1) @@ -557,7 +557,7 @@ int main(int argc, char* argv[]) opts.k2s); if (check_flag(retval, "SUNAdaptController_SetParams_ImpGus")) return 1; } - scontrol = SUNAdaptController_MRIHTol(sunctx, scontrol_H, scontrol_Tol); + scontrol = SUNAdaptController_MRIHTol(scontrol_H, scontrol_Tol, sunctx); if (check_ptr((void*)scontrol, "SUNAdaptController_MRIHTol")) return 1; if (std::min(opts.htol_relch, std::min(opts.htol_minfac, opts.htol_maxfac)) > -1) @@ -585,7 +585,7 @@ int main(int argc, char* argv[]) scontrol_Tol = SUNAdaptController_ImExGus(sunctx); if (check_ptr((void*)scontrol_Tol, "SUNAdaptController_ImExGus (slow Tol)")) return 1; - scontrol = SUNAdaptController_MRIHTol(sunctx, scontrol_H, scontrol_Tol); + scontrol = SUNAdaptController_MRIHTol(scontrol_H, scontrol_Tol, sunctx); if (check_ptr((void*)scontrol, "SUNAdaptController_MRIHTol")) return 1; if (std::min(opts.htol_relch, std::min(opts.htol_minfac, opts.htol_maxfac)) > -1) From d7f961b344f42151c48afb24c02a6719b6e48764 Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Tue, 22 Oct 2024 13:00:14 -0500 Subject: [PATCH 135/286] Updated Swig interfaces --- src/arkode/fmod_int32/farkode_mristep_mod.c | 12 ++++++------ src/arkode/fmod_int32/farkode_mristep_mod.f90 | 10 +++++----- src/arkode/fmod_int64/farkode_mristep_mod.c | 12 ++++++------ src/arkode/fmod_int64/farkode_mristep_mod.f90 | 10 +++++----- 4 files changed, 22 insertions(+), 22 deletions(-) diff --git a/src/arkode/fmod_int32/farkode_mristep_mod.c b/src/arkode/fmod_int32/farkode_mristep_mod.c index b6470ebeb1..8f665dde6e 100644 --- a/src/arkode/fmod_int32/farkode_mristep_mod.c +++ b/src/arkode/fmod_int32/farkode_mristep_mod.c @@ -310,11 +310,11 @@ SWIGINTERN SwigArrayWrapper SwigArrayWrapper_uninitialized() { SWIGEXPORT void _wrap_MRIStepCouplingMem_type_set(SwigClassWrapper const *farg1, int const *farg2) { struct MRIStepCouplingMem *arg1 = (struct MRIStepCouplingMem *) 0 ; - ARKODE_MRIType arg2 ; + MRISTEP_METHOD_TYPE arg2 ; SWIG_check_mutable_nonnull(*farg1, "struct MRIStepCouplingMem *", "MRIStepCouplingMem", "MRIStepCouplingMem::type", return ); arg1 = (struct MRIStepCouplingMem *)(farg1->cptr); - arg2 = (ARKODE_MRIType)(*farg2); + arg2 = (MRISTEP_METHOD_TYPE)(*farg2); if (arg1) (arg1)->type = arg2; } @@ -322,11 +322,11 @@ SWIGEXPORT void _wrap_MRIStepCouplingMem_type_set(SwigClassWrapper const *farg1, SWIGEXPORT int _wrap_MRIStepCouplingMem_type_get(SwigClassWrapper const *farg1) { int fresult ; struct MRIStepCouplingMem *arg1 = (struct MRIStepCouplingMem *) 0 ; - ARKODE_MRIType result; + MRISTEP_METHOD_TYPE result; SWIG_check_mutable_nonnull(*farg1, "struct MRIStepCouplingMem *", "MRIStepCouplingMem", "MRIStepCouplingMem::type", return 0); arg1 = (struct MRIStepCouplingMem *)(farg1->cptr); - result = (ARKODE_MRIType) ((arg1)->type); + result = (MRISTEP_METHOD_TYPE) ((arg1)->type); fresult = (int)(result); return fresult; } @@ -607,12 +607,12 @@ SWIGEXPORT void * _wrap_FMRIStepCoupling_Alloc(int const *farg1, int const *farg void * fresult ; int arg1 ; int arg2 ; - ARKODE_MRIType arg3 ; + MRISTEP_METHOD_TYPE arg3 ; MRIStepCoupling result; arg1 = (int)(*farg1); arg2 = (int)(*farg2); - arg3 = (ARKODE_MRIType)(*farg3); + arg3 = (MRISTEP_METHOD_TYPE)(*farg3); result = (MRIStepCoupling)MRIStepCoupling_Alloc(arg1,arg2,arg3); fresult = result; return fresult; diff --git a/src/arkode/fmod_int32/farkode_mristep_mod.f90 b/src/arkode/fmod_int32/farkode_mristep_mod.f90 index 707804576b..879eb8d9ed 100644 --- a/src/arkode/fmod_int32/farkode_mristep_mod.f90 +++ b/src/arkode/fmod_int32/farkode_mristep_mod.f90 @@ -26,7 +26,7 @@ module farkode_mristep_mod private ! DECLARATION CONSTRUCTS - ! typedef enum ARKODE_MRIType + ! typedef enum MRISTEP_METHOD_TYPE enum, bind(c) enumerator :: MRISTEP_EXPLICIT enumerator :: MRISTEP_IMPLICIT @@ -34,7 +34,7 @@ module farkode_mristep_mod enumerator :: MRISTEP_MERK enumerator :: MRISTEP_MRISR end enum - integer, parameter, public :: ARKODE_MRIType = kind(MRISTEP_EXPLICIT) + integer, parameter, public :: MRISTEP_METHOD_TYPE = kind(MRISTEP_EXPLICIT) public :: MRISTEP_EXPLICIT, MRISTEP_IMPLICIT, MRISTEP_IMEX, MRISTEP_MERK, MRISTEP_MRISR ! typedef enum ARKODE_MRITableID enum, bind(c) @@ -1514,7 +1514,7 @@ function swigc_FMRIStepGetNumRhsEvals(farg1, farg2, farg3) & subroutine swigf_MRIStepCouplingMem_type_set(self, type) use, intrinsic :: ISO_C_BINDING class(MRIStepCouplingMem), intent(in) :: self -integer(ARKODE_MRIType), intent(in) :: type +integer(MRISTEP_METHOD_TYPE), intent(in) :: type type(SwigClassWrapper) :: farg1 integer(C_INT) :: farg2 @@ -1526,7 +1526,7 @@ subroutine swigf_MRIStepCouplingMem_type_set(self, type) function swigf_MRIStepCouplingMem_type_get(self) & result(swig_result) use, intrinsic :: ISO_C_BINDING -integer(ARKODE_MRIType) :: swig_result +integer(MRISTEP_METHOD_TYPE) :: swig_result class(MRIStepCouplingMem), intent(in) :: self integer(C_INT) :: fresult type(SwigClassWrapper) :: farg1 @@ -1849,7 +1849,7 @@ function FMRIStepCoupling_Alloc(nmat, stages, type) & type(C_PTR) :: swig_result integer(C_INT), intent(in) :: nmat integer(C_INT), intent(in) :: stages -integer(ARKODE_MRIType), intent(in) :: type +integer(MRISTEP_METHOD_TYPE), intent(in) :: type type(C_PTR) :: fresult integer(C_INT) :: farg1 integer(C_INT) :: farg2 diff --git a/src/arkode/fmod_int64/farkode_mristep_mod.c b/src/arkode/fmod_int64/farkode_mristep_mod.c index 2328dceb33..1eec16bb13 100644 --- a/src/arkode/fmod_int64/farkode_mristep_mod.c +++ b/src/arkode/fmod_int64/farkode_mristep_mod.c @@ -310,11 +310,11 @@ SWIGINTERN SwigArrayWrapper SwigArrayWrapper_uninitialized() { SWIGEXPORT void _wrap_MRIStepCouplingMem_type_set(SwigClassWrapper const *farg1, int const *farg2) { struct MRIStepCouplingMem *arg1 = (struct MRIStepCouplingMem *) 0 ; - ARKODE_MRIType arg2 ; + MRISTEP_METHOD_TYPE arg2 ; SWIG_check_mutable_nonnull(*farg1, "struct MRIStepCouplingMem *", "MRIStepCouplingMem", "MRIStepCouplingMem::type", return ); arg1 = (struct MRIStepCouplingMem *)(farg1->cptr); - arg2 = (ARKODE_MRIType)(*farg2); + arg2 = (MRISTEP_METHOD_TYPE)(*farg2); if (arg1) (arg1)->type = arg2; } @@ -322,11 +322,11 @@ SWIGEXPORT void _wrap_MRIStepCouplingMem_type_set(SwigClassWrapper const *farg1, SWIGEXPORT int _wrap_MRIStepCouplingMem_type_get(SwigClassWrapper const *farg1) { int fresult ; struct MRIStepCouplingMem *arg1 = (struct MRIStepCouplingMem *) 0 ; - ARKODE_MRIType result; + MRISTEP_METHOD_TYPE result; SWIG_check_mutable_nonnull(*farg1, "struct MRIStepCouplingMem *", "MRIStepCouplingMem", "MRIStepCouplingMem::type", return 0); arg1 = (struct MRIStepCouplingMem *)(farg1->cptr); - result = (ARKODE_MRIType) ((arg1)->type); + result = (MRISTEP_METHOD_TYPE) ((arg1)->type); fresult = (int)(result); return fresult; } @@ -607,12 +607,12 @@ SWIGEXPORT void * _wrap_FMRIStepCoupling_Alloc(int const *farg1, int const *farg void * fresult ; int arg1 ; int arg2 ; - ARKODE_MRIType arg3 ; + MRISTEP_METHOD_TYPE arg3 ; MRIStepCoupling result; arg1 = (int)(*farg1); arg2 = (int)(*farg2); - arg3 = (ARKODE_MRIType)(*farg3); + arg3 = (MRISTEP_METHOD_TYPE)(*farg3); result = (MRIStepCoupling)MRIStepCoupling_Alloc(arg1,arg2,arg3); fresult = result; return fresult; diff --git a/src/arkode/fmod_int64/farkode_mristep_mod.f90 b/src/arkode/fmod_int64/farkode_mristep_mod.f90 index fbfc0d5bee..395babfce3 100644 --- a/src/arkode/fmod_int64/farkode_mristep_mod.f90 +++ b/src/arkode/fmod_int64/farkode_mristep_mod.f90 @@ -26,7 +26,7 @@ module farkode_mristep_mod private ! DECLARATION CONSTRUCTS - ! typedef enum ARKODE_MRIType + ! typedef enum MRISTEP_METHOD_TYPE enum, bind(c) enumerator :: MRISTEP_EXPLICIT enumerator :: MRISTEP_IMPLICIT @@ -34,7 +34,7 @@ module farkode_mristep_mod enumerator :: MRISTEP_MERK enumerator :: MRISTEP_MRISR end enum - integer, parameter, public :: ARKODE_MRIType = kind(MRISTEP_EXPLICIT) + integer, parameter, public :: MRISTEP_METHOD_TYPE = kind(MRISTEP_EXPLICIT) public :: MRISTEP_EXPLICIT, MRISTEP_IMPLICIT, MRISTEP_IMEX, MRISTEP_MERK, MRISTEP_MRISR ! typedef enum ARKODE_MRITableID enum, bind(c) @@ -1514,7 +1514,7 @@ function swigc_FMRIStepGetNumRhsEvals(farg1, farg2, farg3) & subroutine swigf_MRIStepCouplingMem_type_set(self, type) use, intrinsic :: ISO_C_BINDING class(MRIStepCouplingMem), intent(in) :: self -integer(ARKODE_MRIType), intent(in) :: type +integer(MRISTEP_METHOD_TYPE), intent(in) :: type type(SwigClassWrapper) :: farg1 integer(C_INT) :: farg2 @@ -1526,7 +1526,7 @@ subroutine swigf_MRIStepCouplingMem_type_set(self, type) function swigf_MRIStepCouplingMem_type_get(self) & result(swig_result) use, intrinsic :: ISO_C_BINDING -integer(ARKODE_MRIType) :: swig_result +integer(MRISTEP_METHOD_TYPE) :: swig_result class(MRIStepCouplingMem), intent(in) :: self integer(C_INT) :: fresult type(SwigClassWrapper) :: farg1 @@ -1849,7 +1849,7 @@ function FMRIStepCoupling_Alloc(nmat, stages, type) & type(C_PTR) :: swig_result integer(C_INT), intent(in) :: nmat integer(C_INT), intent(in) :: stages -integer(ARKODE_MRIType), intent(in) :: type +integer(MRISTEP_METHOD_TYPE), intent(in) :: type type(C_PTR) :: fresult integer(C_INT) :: farg1 integer(C_INT) :: farg2 From 479e505ec4aec9c1c3c0332c09c2fcf5b01d799d Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Tue, 22 Oct 2024 13:00:37 -0500 Subject: [PATCH 136/286] Updated Swig interfaces --- .../fmod_int32/fsunadaptcontroller_mrihtol_mod.c | 10 +++++----- .../fmod_int32/fsunadaptcontroller_mrihtol_mod.f90 | 10 +++++----- .../fmod_int64/fsunadaptcontroller_mrihtol_mod.c | 10 +++++----- .../fmod_int64/fsunadaptcontroller_mrihtol_mod.f90 | 10 +++++----- 4 files changed, 20 insertions(+), 20 deletions(-) diff --git a/src/sunadaptcontroller/mrihtol/fmod_int32/fsunadaptcontroller_mrihtol_mod.c b/src/sunadaptcontroller/mrihtol/fmod_int32/fsunadaptcontroller_mrihtol_mod.c index bcc7a8c8d3..dcb3ecddda 100644 --- a/src/sunadaptcontroller/mrihtol/fmod_int32/fsunadaptcontroller_mrihtol_mod.c +++ b/src/sunadaptcontroller/mrihtol/fmod_int32/fsunadaptcontroller_mrihtol_mod.c @@ -448,16 +448,16 @@ SWIGEXPORT void _wrap_SUNAdaptControllerContent_MRIHTol__op_assign__(SwigClassWr } -SWIGEXPORT SUNAdaptController _wrap_FSUNAdaptController_MRIHTol(void *farg1, SUNAdaptController farg2, SUNAdaptController farg3) { +SWIGEXPORT SUNAdaptController _wrap_FSUNAdaptController_MRIHTol(SUNAdaptController farg1, SUNAdaptController farg2, void *farg3) { SUNAdaptController fresult ; - SUNContext arg1 = (SUNContext) 0 ; + SUNAdaptController arg1 = (SUNAdaptController) 0 ; SUNAdaptController arg2 = (SUNAdaptController) 0 ; - SUNAdaptController arg3 = (SUNAdaptController) 0 ; + SUNContext arg3 = (SUNContext) 0 ; SUNAdaptController result; - arg1 = (SUNContext)(farg1); + arg1 = (SUNAdaptController)(farg1); arg2 = (SUNAdaptController)(farg2); - arg3 = (SUNAdaptController)(farg3); + arg3 = (SUNContext)(farg3); result = (SUNAdaptController)SUNAdaptController_MRIHTol(arg1,arg2,arg3); fresult = result; return fresult; diff --git a/src/sunadaptcontroller/mrihtol/fmod_int32/fsunadaptcontroller_mrihtol_mod.f90 b/src/sunadaptcontroller/mrihtol/fmod_int32/fsunadaptcontroller_mrihtol_mod.f90 index 0cf5b8a79c..c08850f180 100644 --- a/src/sunadaptcontroller/mrihtol/fmod_int32/fsunadaptcontroller_mrihtol_mod.f90 +++ b/src/sunadaptcontroller/mrihtol/fmod_int32/fsunadaptcontroller_mrihtol_mod.f90 @@ -460,21 +460,21 @@ subroutine swigf_SUNAdaptControllerContent_MRIHTol__op_assign__(self, other) self%swigdata = farg1 end subroutine -function FSUNAdaptController_MRIHTol(sunctx, hcontrol, tolcontrol) & +function FSUNAdaptController_MRIHTol(hcontrol, tolcontrol, sunctx) & result(swig_result) use, intrinsic :: ISO_C_BINDING type(SUNAdaptController), pointer :: swig_result -type(C_PTR) :: sunctx type(SUNAdaptController), target, intent(inout) :: hcontrol type(SUNAdaptController), target, intent(inout) :: tolcontrol +type(C_PTR) :: sunctx type(C_PTR) :: fresult type(C_PTR) :: farg1 type(C_PTR) :: farg2 type(C_PTR) :: farg3 -farg1 = sunctx -farg2 = c_loc(hcontrol) -farg3 = c_loc(tolcontrol) +farg1 = c_loc(hcontrol) +farg2 = c_loc(tolcontrol) +farg3 = sunctx fresult = swigc_FSUNAdaptController_MRIHTol(farg1, farg2, farg3) call c_f_pointer(fresult, swig_result) end function diff --git a/src/sunadaptcontroller/mrihtol/fmod_int64/fsunadaptcontroller_mrihtol_mod.c b/src/sunadaptcontroller/mrihtol/fmod_int64/fsunadaptcontroller_mrihtol_mod.c index bcc7a8c8d3..dcb3ecddda 100644 --- a/src/sunadaptcontroller/mrihtol/fmod_int64/fsunadaptcontroller_mrihtol_mod.c +++ b/src/sunadaptcontroller/mrihtol/fmod_int64/fsunadaptcontroller_mrihtol_mod.c @@ -448,16 +448,16 @@ SWIGEXPORT void _wrap_SUNAdaptControllerContent_MRIHTol__op_assign__(SwigClassWr } -SWIGEXPORT SUNAdaptController _wrap_FSUNAdaptController_MRIHTol(void *farg1, SUNAdaptController farg2, SUNAdaptController farg3) { +SWIGEXPORT SUNAdaptController _wrap_FSUNAdaptController_MRIHTol(SUNAdaptController farg1, SUNAdaptController farg2, void *farg3) { SUNAdaptController fresult ; - SUNContext arg1 = (SUNContext) 0 ; + SUNAdaptController arg1 = (SUNAdaptController) 0 ; SUNAdaptController arg2 = (SUNAdaptController) 0 ; - SUNAdaptController arg3 = (SUNAdaptController) 0 ; + SUNContext arg3 = (SUNContext) 0 ; SUNAdaptController result; - arg1 = (SUNContext)(farg1); + arg1 = (SUNAdaptController)(farg1); arg2 = (SUNAdaptController)(farg2); - arg3 = (SUNAdaptController)(farg3); + arg3 = (SUNContext)(farg3); result = (SUNAdaptController)SUNAdaptController_MRIHTol(arg1,arg2,arg3); fresult = result; return fresult; diff --git a/src/sunadaptcontroller/mrihtol/fmod_int64/fsunadaptcontroller_mrihtol_mod.f90 b/src/sunadaptcontroller/mrihtol/fmod_int64/fsunadaptcontroller_mrihtol_mod.f90 index 0cf5b8a79c..c08850f180 100644 --- a/src/sunadaptcontroller/mrihtol/fmod_int64/fsunadaptcontroller_mrihtol_mod.f90 +++ b/src/sunadaptcontroller/mrihtol/fmod_int64/fsunadaptcontroller_mrihtol_mod.f90 @@ -460,21 +460,21 @@ subroutine swigf_SUNAdaptControllerContent_MRIHTol__op_assign__(self, other) self%swigdata = farg1 end subroutine -function FSUNAdaptController_MRIHTol(sunctx, hcontrol, tolcontrol) & +function FSUNAdaptController_MRIHTol(hcontrol, tolcontrol, sunctx) & result(swig_result) use, intrinsic :: ISO_C_BINDING type(SUNAdaptController), pointer :: swig_result -type(C_PTR) :: sunctx type(SUNAdaptController), target, intent(inout) :: hcontrol type(SUNAdaptController), target, intent(inout) :: tolcontrol +type(C_PTR) :: sunctx type(C_PTR) :: fresult type(C_PTR) :: farg1 type(C_PTR) :: farg2 type(C_PTR) :: farg3 -farg1 = sunctx -farg2 = c_loc(hcontrol) -farg3 = c_loc(tolcontrol) +farg1 = c_loc(hcontrol) +farg2 = c_loc(tolcontrol) +farg3 = sunctx fresult = swigc_FSUNAdaptController_MRIHTol(farg1, farg2, farg3) call c_f_pointer(fresult, swig_result) end function From 3ce6435c89d2474fc777cdfead84e5896dacc859 Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Tue, 22 Oct 2024 13:01:22 -0500 Subject: [PATCH 137/286] Reverted ARKODE_MRIType back to MRISTEP_METHOD_TYPE --- .../source/Usage/MRIStep/MRIStepCoupling.rst | 11 ++++----- include/arkode/arkode_mristep.h | 24 ++++++++----------- src/arkode/arkode_mri_tables.c | 8 +++---- .../CXX_serial/ark_test_dahlquist_mri.cpp | 4 ++-- 4 files changed, 21 insertions(+), 26 deletions(-) diff --git a/doc/arkode/guide/source/Usage/MRIStep/MRIStepCoupling.rst b/doc/arkode/guide/source/Usage/MRIStep/MRIStepCoupling.rst index eb0b5d09d2..bda7590bfc 100644 --- a/doc/arkode/guide/source/Usage/MRIStep/MRIStepCoupling.rst +++ b/doc/arkode/guide/source/Usage/MRIStep/MRIStepCoupling.rst @@ -24,9 +24,9 @@ supply a custom set of slow-to-fast time scale coupling coefficients by constructing a coupling table and attaching it with :c:func:`MRIStepSetCoupling`. A given MRI coupling table can encode any of the MRI methods supported by MRIStep. The family of MRI method encoded -by the table is determined by an enumerated type, :c:enum:`ARKODE_MRIType`: +by the table is determined by an enumerated type, :c:enum:`MRISTEP_METHOD_TYPE`: -.. c:enum:: ARKODE_MRIType +.. c:enum:: MRISTEP_METHOD_TYPE The MRI method family encoded by a :c:type:`MRIStepCoupling` table @@ -68,7 +68,7 @@ The MRI coupling tables themselves are stored in an tensors :math:`\Gamma\in\mathbb{R}^{(s+1)\times(s+1)\times k}` and :math:`\Omega\in\mathbb{R}^{(s+1)\times(s+1)\times k}`. - .. c:member:: ARKODE_MRIType type + .. c:member:: MRISTEP_METHOD_TYPE type Flag indicating the type of MRI method encoded by this table. @@ -182,7 +182,7 @@ are defined ``arkode/arkode_mristep.h``. This function is case sensitive. -.. c:function:: MRIStepCoupling MRIStepCoupling_Alloc(int nmat, int stages, ARKODE_MRIType type) +.. c:function:: MRIStepCoupling MRIStepCoupling_Alloc(int nmat, int stages, MRISTEP_METHOD_TYPE type) Allocates an empty MRIStepCoupling table. @@ -229,8 +229,7 @@ are defined ``arkode/arkode_mristep.h``. .. versionchanged:: x.y.z - In previous releases, this final argument had type ``MRISTEP_METHOD_TYPE``. That has now - been aliased to ``ARKODE_MRIType`` for backwards compatibility. + This function now supports a broader range of MRI method types. diff --git a/include/arkode/arkode_mristep.h b/include/arkode/arkode_mristep.h index 23c43a2309..cd972e94ff 100644 --- a/include/arkode/arkode_mristep.h +++ b/include/arkode/arkode_mristep.h @@ -39,13 +39,9 @@ typedef enum MRISTEP_IMEX, MRISTEP_MERK, MRISTEP_MRISR -} ARKODE_MRIType; - -/* Alias to account for the changed enum name above */ -typedef ARKODE_MRIType MRISTEP_METHOD_TYPE; +} MRISTEP_METHOD_TYPE; /* MRI coupling table IDs */ - typedef enum { ARKODE_MRI_NONE = -1, /* ensure enum is signed int */ @@ -130,14 +126,14 @@ typedef int (*MRIStepInnerSetRTol)(MRIStepInnerStepper stepper, sunrealtype rtol ---------------------------------------------------------------*/ struct MRIStepCouplingMem { - ARKODE_MRIType type; /* flag to encode the MRI method type */ - int nmat; /* number of MRI coupling matrices */ - int stages; /* size of coupling matrices ((stages+1) * stages) */ - int q; /* method order of accuracy */ - int p; /* embedding order of accuracy */ - sunrealtype* c; /* stage abscissae */ - sunrealtype*** W; /* explicit coupling matrices [nmat][stages+1][stages] */ - sunrealtype*** G; /* implicit coupling matrices [nmat][stages+1][stages] */ + MRISTEP_METHOD_TYPE type; /* flag to encode the MRI method type */ + int nmat; /* number of MRI coupling matrices */ + int stages; /* size of coupling matrices ((stages+1) * stages) */ + int q; /* method order of accuracy */ + int p; /* embedding order of accuracy */ + sunrealtype* c; /* stage abscissae */ + sunrealtype*** W; /* explicit coupling matrices [nmat][stages+1][stages] */ + sunrealtype*** G; /* implicit coupling matrices [nmat][stages+1][stages] */ int ngroup; /* number of stage groups (MERK-specific) */ int** group; /* stages to integrate together (MERK-specific) */ @@ -153,7 +149,7 @@ SUNDIALS_EXPORT MRIStepCoupling MRIStepCoupling_LoadTableByName(const char* meth /* Utility routines to allocate/free/output coupling table structures */ SUNDIALS_EXPORT MRIStepCoupling MRIStepCoupling_Alloc(int nmat, int stages, - ARKODE_MRIType type); + MRISTEP_METHOD_TYPE type); SUNDIALS_EXPORT MRIStepCoupling MRIStepCoupling_Create(int nmat, int stages, int q, int p, sunrealtype* W, diff --git a/src/arkode/arkode_mri_tables.c b/src/arkode/arkode_mri_tables.c index 021d03c638..11d8e14b17 100644 --- a/src/arkode/arkode_mri_tables.c +++ b/src/arkode/arkode_mri_tables.c @@ -69,7 +69,7 @@ MRIStepCoupling MRIStepCoupling_LoadTableByName(const char* method) /*--------------------------------------------------------------- Routine to allocate an empty MRIStepCoupling structure ---------------------------------------------------------------*/ -MRIStepCoupling MRIStepCoupling_Alloc(int nmat, int stages, ARKODE_MRIType type) +MRIStepCoupling MRIStepCoupling_Alloc(int nmat, int stages, MRISTEP_METHOD_TYPE type) { int i, j; sunbooleantype hasOmegas, hasGammas; @@ -234,7 +234,7 @@ MRIStepCoupling MRIStepCoupling_Create(int nmat, int stages, int q, int p, sunrealtype* c) { int i, j, k; - ARKODE_MRIType type; + MRISTEP_METHOD_TYPE type; MRIStepCoupling MRIC = NULL; /* Check for legal inputs */ @@ -322,7 +322,7 @@ MRIStepCoupling MRIStepCoupling_MIStoMRI(ARKodeButcherTable B, int q, int p) sunbooleantype padding; sunrealtype Asum; sunrealtype*** C; - ARKODE_MRIType type; + MRISTEP_METHOD_TYPE type; MRIStepCoupling MRIC; const sunrealtype tol = SUN_RCONST(100.0) * SUN_UNIT_ROUNDOFF; @@ -459,7 +459,7 @@ MRIStepCoupling MRIStepCoupling_MIStoMRI(ARKodeButcherTable B, int q, int p) MRIStepCoupling MRIStepCoupling_Copy(MRIStepCoupling MRIC) { int i, j, k, nmat, stages; - ARKODE_MRIType type; + MRISTEP_METHOD_TYPE type; MRIStepCoupling MRICcopy; /* Check for legal input */ diff --git a/test/unit_tests/arkode/CXX_serial/ark_test_dahlquist_mri.cpp b/test/unit_tests/arkode/CXX_serial/ark_test_dahlquist_mri.cpp index aa8d798993..4db8264121 100644 --- a/test/unit_tests/arkode/CXX_serial/ark_test_dahlquist_mri.cpp +++ b/test/unit_tests/arkode/CXX_serial/ark_test_dahlquist_mri.cpp @@ -93,7 +93,7 @@ static int Ji(sunrealtype t, N_Vector y, N_Vector fy, SUNMatrix J, static int check_flag(void* flagvalue, const std::string funcname, int opt); // Test drivers -static int run_tests(ARKODE_MRIType type, ProblemOptions& prob_opts, +static int run_tests(MRISTEP_METHOD_TYPE type, ProblemOptions& prob_opts, ProblemData& prob_data, SUNContext ctx); // ----------------------------------------------------------------------------- @@ -170,7 +170,7 @@ int main(int argc, char* argv[]) // Test drivers // ----------------------------------------------------------------------------- -int run_tests(ARKODE_MRIType type, ProblemOptions& prob_opts, +int run_tests(MRISTEP_METHOD_TYPE type, ProblemOptions& prob_opts, ProblemData& prob_data, SUNContext sunctx) { // Reusable error-checking flag From 3c94fba851e3c88fed4c0d4e95ad6f0e17c2d705 Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Tue, 22 Oct 2024 13:18:14 -0500 Subject: [PATCH 138/286] Removed step_supports_forcing flag from ARKODE memory structure --- src/arkode/arkode.c | 2 +- src/arkode/arkode_arkstep.c | 1 - src/arkode/arkode_erkstep.c | 1 - src/arkode/arkode_impl.h | 1 - src/arkode/arkode_mristep.c | 1 - 5 files changed, 1 insertion(+), 5 deletions(-) diff --git a/src/arkode/arkode.c b/src/arkode/arkode.c index fcdaca944e..222a83a9e1 100644 --- a/src/arkode/arkode.c +++ b/src/arkode/arkode.c @@ -1373,7 +1373,7 @@ int ARKodeCreateMRIStepInnerStepper(void* inner_arkode_mem, ark_mem = (ARKodeMem)inner_arkode_mem; /* return with an error if the ARKODE solver does not support forcing */ - if (!ark_mem->step_supports_forcing) + if (ark_mem->step_setforcing == NULL) { arkProcessError(ark_mem, ARK_STEPPER_UNSUPPORTED, __LINE__, __func__, __FILE__, "time-stepping module does not support forcing"); diff --git a/src/arkode/arkode_arkstep.c b/src/arkode/arkode_arkstep.c index a2d25adebe..b2a3f042aa 100644 --- a/src/arkode/arkode_arkstep.c +++ b/src/arkode/arkode_arkstep.c @@ -142,7 +142,6 @@ void* ARKStepCreate(ARKRhsFn fe, ARKRhsFn fi, sunrealtype t0, N_Vector y0, ark_mem->step_setforcing = arkStep_SetInnerForcing; ark_mem->step_supports_adaptive = SUNTRUE; ark_mem->step_supports_implicit = SUNTRUE; - ark_mem->step_supports_forcing = SUNTRUE; ark_mem->step_supports_massmatrix = SUNTRUE; ark_mem->step_supports_relaxation = SUNTRUE; ark_mem->step_mem = (void*)step_mem; diff --git a/src/arkode/arkode_erkstep.c b/src/arkode/arkode_erkstep.c index 873af9b888..e8717f45db 100644 --- a/src/arkode/arkode_erkstep.c +++ b/src/arkode/arkode_erkstep.c @@ -107,7 +107,6 @@ void* ERKStepCreate(ARKRhsFn f, sunrealtype t0, N_Vector y0, SUNContext sunctx) ark_mem->step_setforcing = erkStep_SetInnerForcing; ark_mem->step_supports_adaptive = SUNTRUE; ark_mem->step_supports_relaxation = SUNTRUE; - ark_mem->step_supports_forcing = SUNTRUE; ark_mem->step_mem = (void*)step_mem; /* Set default values for optional inputs */ diff --git a/src/arkode/arkode_impl.h b/src/arkode/arkode_impl.h index 1568ccb56f..669dd9b1e8 100644 --- a/src/arkode/arkode_impl.h +++ b/src/arkode/arkode_impl.h @@ -463,7 +463,6 @@ struct ARKodeMemRec ARKMassMultFn step_mmult; /* Time stepper module -- forcing */ - sunbooleantype step_supports_forcing; ARKTimestepSetForcingFn step_setforcing; /* N_Vector storage */ diff --git a/src/arkode/arkode_mristep.c b/src/arkode/arkode_mristep.c index f4f9760c58..89d45597f0 100644 --- a/src/arkode/arkode_mristep.c +++ b/src/arkode/arkode_mristep.c @@ -143,7 +143,6 @@ void* MRIStepCreate(ARKRhsFn fse, ARKRhsFn fsi, sunrealtype t0, N_Vector y0, ark_mem->step_setforcing = mriStep_SetInnerForcing; ark_mem->step_supports_adaptive = SUNTRUE; ark_mem->step_supports_implicit = SUNTRUE; - ark_mem->step_supports_forcing = SUNTRUE; ark_mem->step_mem = (void*)step_mem; /* Set default values for optional inputs */ From b64f62f7ff8f05023a985e93baf3e7515acc9db3 Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Tue, 22 Oct 2024 13:23:28 -0500 Subject: [PATCH 139/286] Fixed 'apply suggestion' errors --- examples/arkode/CXX_serial/ark_kpr_nestedmri.cpp | 10 +++++----- .../CXX_serial/ark_test_brusselator_mriadapt.cpp | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/examples/arkode/CXX_serial/ark_kpr_nestedmri.cpp b/examples/arkode/CXX_serial/ark_kpr_nestedmri.cpp index 42568dba60..dcee0eb147 100644 --- a/examples/arkode/CXX_serial/ark_kpr_nestedmri.cpp +++ b/examples/arkode/CXX_serial/ark_kpr_nestedmri.cpp @@ -948,10 +948,10 @@ int main(int argc, char* argv[]) printf(" " "---------------------------------------------------------------------" "-------\n"); - printf(" %10.6" FSYM " %10.6" FSYM " %10.6" FSYM " %10.6" FSYM " %.2" ESYM - while (Tf - t > SUN_RCONST(1.0e-8)) + printf(" %10.6" FSYM " %10.6" FSYM " %10.6" FSYM " %10.6" FSYM + " %.2" ESYM " %.2" ESYM " %.2" ESYM "\n", t, ydata[0], ydata[1], ydata[2], uerr, verr, werr); - while (Tf - t > SUN_RCONST(1.0e-8)) + while (Tf - t > SUN_RCONST(1.0e-8)) { // reset reference solver so that it begins with identical state retval = ARKodeReset(arkode_ref, t, y); @@ -1050,7 +1050,7 @@ int main(int argc, char* argv[]) uerrtot = std::sqrt(uerrtot / nsts); verrtot = std::sqrt(verrtot / nsts); werrtot = std::sqrt(werrtot / nsts); - errtot = std::sqrt(errtot / nsts / 3); + errtot = std::sqrt(errtot / nsts / 3); std::cout << "\nFinal Solver Statistics:\n"; std::cout << " Slow steps = " << nsts << " (attempts = " << natts << ", fails = " << netfs << ")\n"; @@ -1294,7 +1294,7 @@ static int fs(sunrealtype t, N_Vector y, N_Vector ydot, void* user_data) // fse routine to compute the explicit slow portion of the ODE RHS. static int fse(sunrealtype t, N_Vector y, N_Vector ydot, void* user_data) { - Options* opts. = static_cast(user_data); + Options* opts = static_cast(user_data); sunrealtype* ydata = N_VGetArrayPointer(y); sunrealtype* ydotdata = N_VGetArrayPointer(ydot); const sunrealtype u = ydata[0]; diff --git a/test/unit_tests/arkode/CXX_serial/ark_test_brusselator_mriadapt.cpp b/test/unit_tests/arkode/CXX_serial/ark_test_brusselator_mriadapt.cpp index 57714351d6..16e9287f4d 100644 --- a/test/unit_tests/arkode/CXX_serial/ark_test_brusselator_mriadapt.cpp +++ b/test/unit_tests/arkode/CXX_serial/ark_test_brusselator_mriadapt.cpp @@ -575,7 +575,7 @@ int main(int argc, char* argv[]) scontrol_Tol = SUNAdaptController_ImExGus(sunctx); if (check_ptr((void*)scontrol_Tol, "SUNAdaptController_ImExGus (slow Tol)")) return 1; - scontrol = SUNAdaptController_MRIHTol(scontrol_H, scontrol_Tolsunctx); + scontrol = SUNAdaptController_MRIHTol(scontrol_H, scontrol_Tol,sunctx); if (check_ptr((void*)scontrol, "SUNAdaptController_MRIHTol")) return 1; if (std::min(opts.htol_relch, std::min(opts.htol_minfac, opts.htol_maxfac)) > -1) From 422db6b575f9695ee23b111b5e902c0f63e8a4bd Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Tue, 22 Oct 2024 14:46:28 -0500 Subject: [PATCH 140/286] Fixed conversion 'error' --- .../arkode/CXX_serial/ark_kpr_nestedmri.cpp | 20 +++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/examples/arkode/CXX_serial/ark_kpr_nestedmri.cpp b/examples/arkode/CXX_serial/ark_kpr_nestedmri.cpp index dcee0eb147..e82176cafe 100644 --- a/examples/arkode/CXX_serial/ark_kpr_nestedmri.cpp +++ b/examples/arkode/CXX_serial/ark_kpr_nestedmri.cpp @@ -1047,10 +1047,10 @@ int main(int argc, char* argv[]) check_flag(retval, "ERKStepGetNumRhsEvals"); // Print some final statistics - uerrtot = std::sqrt(uerrtot / nsts); - verrtot = std::sqrt(verrtot / nsts); - werrtot = std::sqrt(werrtot / nsts); - errtot = std::sqrt(errtot / nsts / 3); + uerrtot = std::sqrt(uerrtot / (sunrealtype) nsts); + verrtot = std::sqrt(verrtot / (sunrealtype) nsts); + werrtot = std::sqrt(werrtot / (sunrealtype) nsts); + errtot = std::sqrt(errtot / SUN_RCONST(3.0) / (sunrealtype) nsts); std::cout << "\nFinal Solver Statistics:\n"; std::cout << " Slow steps = " << nsts << " (attempts = " << natts << ", fails = " << netfs << ")\n"; @@ -1074,10 +1074,12 @@ int main(int argc, char* argv[]) retval = ARKodeGetNumJacEvals(arkode_mem, &njes); check_flag(retval, "ARKodeGetNumJacEvals"); std::cout << " Slow Newton iters = " << nnis << std::endl; - std::cout << " Slow Newton iters/attempt = " << nnis/natts << std::endl; + std::cout << " Slow Newton iters/attempt = " + << (sunrealtype) nnis/natts << std::endl; std::cout << " Slow Newton conv fails = " << nncs << std::endl; std::cout << " Slow Jacobian evals = " << njes << std::endl; - std::cout << " Slow Jacobian evals/Newton = " << njes/nnis << std::endl; + std::cout << " Slow Jacobian evals/Newton = " + << (sunrealtype) njes/nnis << std::endl; } // Get/print intermediate integrator implicit solver statistics @@ -1089,10 +1091,12 @@ int main(int argc, char* argv[]) retval = ARKodeGetNumJacEvals(mid_arkode_mem, &njem); check_flag(retval, "ARKodeGetNumJacEvals"); std::cout << " Intermediate Newton iters = " << nnim << std::endl; - std::cout << " Intermediate Newton iters/attempt = " << nnim/nattm << std::endl; + std::cout << " Intermediate Newton iters/attempt = " + << (sunrealtype) nnim/nattm << std::endl; std::cout << " Intermediate Newton conv fails = " << nncm << std::endl; std::cout << " Intermediate Jacobian evals = " << njem << std::endl; - std::cout << " Intermediate Jacobian evals/Newton = " << njem/nnim << std::endl; + std::cout << " Intermediate Jacobian evals/Newton = " + << (sunrealtype) njem/nnim << std::endl; } // Clean up and return From 07bea45b2fa442699c28b23376189a7f7d5c70b1 Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Tue, 22 Oct 2024 18:11:55 -0500 Subject: [PATCH 141/286] Updated exposition on IMEX-MRI-SR and MERK methods (as per PR request) --- doc/arkode/guide/source/Mathematics.rst | 105 ++++++++++++++---- .../Custom_Inner_Stepper/Description.rst | 12 +- .../source/Usage/MRIStep/MRIStepCoupling.rst | 26 +++-- .../SUNAdaptController_Description.rst | 38 ++----- 4 files changed, 110 insertions(+), 71 deletions(-) diff --git a/doc/arkode/guide/source/Mathematics.rst b/doc/arkode/guide/source/Mathematics.rst index d2e5ac0b06..3ccb4b2246 100644 --- a/doc/arkode/guide/source/Mathematics.rst +++ b/doc/arkode/guide/source/Mathematics.rst @@ -641,9 +641,11 @@ algorithm for a single step: diagonally-implicit, or additive Runge--Kutta stage update, .. math:: - z_i - \theta_{i,i} h^S f^I(t_{n-1}+c_i^S h^S, z_i) = a_i. + z_i - \theta_{i,i} h^S f^I(t_{n,i}^S, z_i) = a_i. :label: MRI_implicit_solve + where :math:`t_{n,j}^S = t_{n-1}*h^S c^S_j`. + #. Set :math:`y_{n} = z_{s}`. #. If the method has an embedding, compute the embedded solution, @@ -682,19 +684,19 @@ MIS, MRI-GARK, and IMEX-MRI-GARK Methods The methods in IMEX-MRI-GARK family, which includes MIS and MRI-GARK methods, are defined by a vector of slow stage time abscissae, :math:`c^S \in -\mathbb{R}^{s+1}`, and a set of coupling tensors, -:math:`\Omega\in\mathbb{R}^{(s+1)\times(s+1)\times k}` and -:math:`\Gamma\in\mathbb{R}^{(s+1)\times(s+1)\times k}`, that specify the +\mathbb{R}^{s}`, and a set of coupling tensors, +:math:`\Omega\in\mathbb{R}^{(s+1)\times s \times k}` and +:math:`\Gamma\in\mathbb{R}^{(s+1)\times s \times k}`, that specify the slow-to-fast coupling for the explicit and implicit components, respectively. The fast stage IVPs, :eq:`MRI_fast_IVP`, are evolved over non-overlapping -intervals :math:`[t_{0,i},t_{F,i}] = [t_{n-1}+c_{i-1}h^S, t_{n-1}+c_ih^S]` with +intervals :math:`[t_{0,i},t_{F,i}] = [t_{n,i-1}^S, t_{n,i}^S]` with the initial condition :math:`v_{0,i}=z_{i-1}`. The fast IVP forcing function is given by .. math:: - r_i(t) = \frac{1}{\Delta c_i^S} \sum\limits_{j=1}^{i-1} \omega_{i,j}(\tau) f^E(t_{n,j}^I, z_j) - + \frac{1}{\Delta c_i^S} \sum\limits_{j=1}^i \gamma_{i,j}(\tau) f^I(t_{n,j}^I, z_j) + r_i(t) = \frac{1}{\Delta c_i^S} \sum\limits_{j=1}^{i-1} \omega_{i,j}(\tau) f^E(t_{n,j}^S, z_j) + + \frac{1}{\Delta c_i^S} \sum\limits_{j=1}^i \gamma_{i,j}(\tau) f^I(t_{n,j}^S, z_j) where :math:`\Delta c_i^S=\left(c^S_i - c^S_{i-1}\right)`, :math:`\tau = (t - t_{n,i-1}^S)/(h^S \Delta c_i^S)` is the normalized time, the coefficients @@ -721,7 +723,7 @@ stage is computed as :label: ARKODE_MRI_delta_c_zero Similarly, the embedded solution IVP, :eq:`MRI_embedding_fast_IVP`, is evolved -over the interval :math:`[\tilde{t}_{0},\tilde{t}_{F}] = [t_{n-1}+c_{s-1}h^S, t_{n}]` +over the interval :math:`[\tilde{t}_{0},\tilde{t}_{F}] = [t_{n,s-1}^S, t_{n}]` with the initial condition :math:`\tilde{v}_0=z_{s-1}`. As with standard ARK and DIRK methods, implicitness at the slow time scale is @@ -746,26 +748,87 @@ The IMEX-MRI-SR family of methods perform *both* the fast IVP evolution, :eq:`MRI_fast_IVP` or :eq:`MRI_embedding_fast_IVP`, *and* stage update, :eq:`MRI_implicit_solve` or :eq:`MRI_embedding_implicit_solve`, in every stage (but these methods typically have far fewer stages than implicit MRI-GARK or -IMEX-MRI-GARK methods). +IMEX-MRI-GARK methods). These methods are defined by a vector of slow stage +time abscissae :math:`c^S \in \mathbb{R}^{s}`, a set of coupling tensors +:math:`\Omega\in\mathbb{R}^{(s+1)\times s\times k}`, and a Butcher table of +slow-implicit coefficients, :math:`\Gamma\in\mathbb{R}^{(s+1) \times s}`. + +The fast stage IVPs, :eq:`MRI_fast_IVP`, are evolved on overlapping +intervals :math:`[t_{0,i},t_{F,i}] = [t_{n-1}, t_{n,i}^S]` with +the initial condition :math:`v_{0,i}=y_{n-1}`. The fast IVP forcing function is +given by + +.. math:: + 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), + :label: IMEXMRISR_forcing + +where :math:`\tau = (t - t_n)/(h^S c_i^S)` is the normalized time, and the coefficients +:math:`\omega_{i,j}` are polynomials in time of degree :math:`k` that are also given by +:eq:`ARKODE_MRI_coupling`. The solution of these fast IVPs defines an intermediate stage +solution, :math:`\tilde{z}_i`. + +The implicit solve that follows each fast IVP must solve the algebraic equation for :math:`z_i` + +.. math:: + z_i = \tilde{z}_i + h^S \sum_{j=1}^{i} \gamma_{i,j} f^I(t_{n,j}^S, z_j). + :label: ARKODE_MRISR_implicit + +We note that IMEX-MRI-SR methods are solve-decoupled by construction, and thus the structure +of a given stage never needs to be deduced based on :math:`\Delta c_i^S`. However, ARKODE +still checks the value of :math:`\gamma_{i,i}`, since if it zero then the stage update +equation :eq:`ARKODE_MRISR_implicit` simplifes to a simple explicit Runge--Kutta-like stage +update. + +The overall time step solution is given by the final internal stage solution, +i.e., :math:`y_{n} = z_{s}`. The embedded solution is computing using the above +algorithm for stage index :math:`s+1`, under the definition that :math:`c_{s+1}^S=1` +(and thus the fast IVP portion is evolved over the full time step, +:math:`[t_{0,i},t_{F,i}] = [t_{n-1}, t_{n}]`). -These methods evolve the fast IVPs, :eq:`MRI_fast_IVP` and -:eq:`MRI_embedding_fast_IVP`, on overlapping time intervals -:math:`[t_{0,i},t_{F,i}] = [t_{n-1}, t_{n-1}+c_i h^S]` and -:math:`[\tilde{t}_{0},\tilde{t}_{F}] = [t_{n-1}, t_{n}]`, using initial -conditions :math:`v_{0,i}=y_{n-1}` and :math:`\tilde{v}_0=y_{n-1}`. MERK Methods ------------ -MERK family of methods never include the stage updates, :eq:`MRI_implicit_solve` -or :eq:`MRI_embedding_implicit_solve`. +The MERK family of methods are only defined for multirate applications that +are explicit at the slow time scale, i.e., :math:`f^I=0`, but otherwise they are +nearly identical to IMEX-MRI-SR methods. Specifically, like IMEX-MRI-SR methods, +these evolve the fast IVPs +:eq:`MRI_fast_IVP` and :eq:`MRI_embedding_fast_IVP` over the intervals +:math:`[t_{0,i},t_{F,i}] = [t_{n-1}, t_{n,i}^S]` and +:math:`[t_{0,i},t_{F,i}] = [t_{n-1}, t_{n}]`, respectively, and begin +with the initial condition :math:`v_{0,i}=y_{n-1}`. Furthermore, the fast IVP +forcing functions are given by :eq:`IMEXMRISR_forcing` with :math:`f^I=0`. +As MERK-based applications lack the implicit slow operator, they do not require +the solution of implicit algebraic equations. + +However, unlike other MRI families, MERK methods were designed to admit a useful +efficiency improvement. Since each fast IVP begins with the same initial condition, +:math:`v_{0,i}=y_{n-1}`, if multiple stages share the same forcing function +:math:`r_i(t)`, then they may be "grouped" together. This is achieved by sorting the +final IVP solution time for each stage, :math:`t_{n,i}^S`, and then evolving the inner +solver to each of these stage times in order, storing the corresponding inner solver +solutions at these times as the stages :math:`z_i`. For example, the +:index:`ARKODE_MERK54` method involves 11 stages, that may be combined into 5 distinct +groups. The fourth group contains stages 7, 8, 9, and the embedding, corresponding to +the :math:`c_i^S` values :math:`7/10`, :math:`1/2`, :math:`2/3`, and :math:`1`. +Sorting these, a single fast IVP for this group must be evolved over the interval +:math:`[t_{0,i},t_{F,i}] = [t_{n-1}, t_{n}]`, first pausing at :math:`t_{n-1}+\frac12 h^S` +to store :math:`z_8`, then pausing at :math:`t_{n-1}+\frac{2}{3} h^S` to store +:math:`z_9`, then pausing at :math:`t_{n-1}+\frac{7}{10} h^S` to store :math:`z_7`, +and finally finishing the IVP solve to :math:`t_{n-1}+h^S` to obtain :math:`\tilde{y}_n`. + +.. note:: + + Although all MERK methods were derived in :cite:p:`Luan:20` under an assumption that + the fast function :math:`f^F(t,y)` is linear in :math:`y`, in :cite:p:`Fish:24` it + was proven that MERK methods also satisfy all nonlinear order conditions up through + their linear order. The lone exception is :index:`ARKODE_MERK54`, where it was only + proven to satisfy all nonlinear conditions up to order 4 (since :cite:p:`Fish:24` did + not establish the formulas for the order 5 conditions). All our numerical tests to + date have shown :index:`ARKODE_MERK54` to achieve fifth order for nonlinear problems, + and so we conjecture that it also satisfies the nonlinear fifth order conditions. -These methods evolve the fast IVPs, :eq:`MRI_fast_IVP` and -:eq:`MRI_embedding_fast_IVP`, on overlapping time intervals -:math:`[t_{0,i},t_{F,i}] = [t_{n-1}, t_{n-1}+c_i h^S]` and -:math:`[\tilde{t}_{0},\tilde{t}_{F}] = [t_{n-1}, t_{n}]`, using initial -conditions :math:`v_{0,i}=y_{n-1}` and :math:`\tilde{v}_0=y_{n-1}`. .. _ARKODE.Mathematics.Error.Norm: diff --git a/doc/arkode/guide/source/Usage/MRIStep/Custom_Inner_Stepper/Description.rst b/doc/arkode/guide/source/Usage/MRIStep/Custom_Inner_Stepper/Description.rst index a2daa41e4b..b4348e0d83 100644 --- a/doc/arkode/guide/source/Usage/MRIStep/Custom_Inner_Stepper/Description.rst +++ b/doc/arkode/guide/source/Usage/MRIStep/Custom_Inner_Stepper/Description.rst @@ -237,7 +237,7 @@ Setting Member Functions :retval ARK_SUCCESS: if successful :retval ARK_ILL_INPUT: if the stepper is ``NULL`` - + .. versionadded: x.y.z @@ -251,7 +251,7 @@ Setting Member Functions :retval ARK_SUCCESS: if successful :retval ARK_ILL_INPUT: if the stepper is ``NULL`` - + .. versionadded: x.y.z @@ -265,7 +265,7 @@ Setting Member Functions :retval ARK_SUCCESS: if successful :retval ARK_ILL_INPUT: if the stepper is ``NULL`` - + .. versionadded: x.y.z @@ -416,6 +416,7 @@ following member functions: **Example codes:** * ``examples/arkode/CXX_parallel/ark_diffusion_reaction_p.cpp`` + .. versionchanged:: v5.7.0 Supplying a full right-hand side function was made optional. @@ -424,7 +425,7 @@ following member functions: This function resets the inner (fast) stepper state to the provided independent variable value and dependent variable vector. - + If provided, the :c:type:`MRIStepInnerResetFn` function will be called *before* a call to :c:type:`MRIStepInnerEvolveFn` when the state was updated at the slow timescale. @@ -439,9 +440,6 @@ following member functions: value if a recoverable error occurred, or a negative value if it failed unrecoverably. - .. note:: - - **Example codes:** * ``examples/arkode/CXX_parallel/ark_diffusion_reaction_p.cpp`` diff --git a/doc/arkode/guide/source/Usage/MRIStep/MRIStepCoupling.rst b/doc/arkode/guide/source/Usage/MRIStep/MRIStepCoupling.rst index bda7590bfc..46590c75a7 100644 --- a/doc/arkode/guide/source/Usage/MRIStep/MRIStepCoupling.rst +++ b/doc/arkode/guide/source/Usage/MRIStep/MRIStepCoupling.rst @@ -273,8 +273,6 @@ are defined ``arkode/arkode_mristep.h``. A ``NULL`` pointer if ``stages`` was invalid, an allocation error occurred, or the input data arrays are inconsistent with the method type. - .. note:: - .. c:function:: MRIStepCoupling MRIStepCoupling_MIStoMRI(ARKodeButcherTable B, int q, int p) @@ -425,19 +423,23 @@ with values specified for each method below (e.g., ``ARKODE_MIS_KW3``). Notes regarding the above table: -#. The default method for each order when using fixed step sizes is marked with an asterisk (:math:`^*`). +#. The default method for each order when using fixed step sizes is marked with an + asterisk (:math:`^*`). -#. The default method for each order when using adaptive time stepping is marked with a circle (:math:`^\circ`). +#. The default method for each order when using adaptive time stepping is marked + with a circle (:math:`^\circ`). -#. The "Slow RHS Calls" column corresponds to the number of calls to the slow right-hand side function, - :math:`f^E`, per time step. +#. The "Slow RHS Calls" column corresponds to the number of calls to the slow + right-hand side function, :math:`f^E`, per time step. -#. Note A: although all MERK methods were derived in :cite:p:`Luan:20` under an assumption that the fast time - scale is linear in the solution, in :cite:p:`Fish:24` it was proven that they also satisfy all nonlinear - order conditions up through their linear order. The lone exception is MERK54, where it was only proven to - satisfy all nonlinear conditions up to order 4, since :cite:p:`Fish:24` did not establish the formulas for - the order 5 conditions. All our numerical tests to date have shown MERK54 to achieve fifth order for - nonlinear problems, and so we conjecture that it also satisfies the nonlinear fifth order conditions. +#. Note A: although all MERK methods were derived in :cite:p:`Luan:20` under an assumption + that the fast function :math:`f^F(t,y)` is linear in :math:`y`, in :cite:p:`Fish:24` it + was proven that MERK methods also satisfy all nonlinear order conditions up through + their linear order. The lone exception is :index:`ARKODE_MERK54`, where it was only + proven to satisfy all nonlinear conditions up to order 4 (since :cite:p:`Fish:24` did + not establish the formulas for the order 5 conditions). All our numerical tests to + date have shown :index:`ARKODE_MERK54` to achieve fifth order for nonlinear problems, + and so we conjecture that it also satisfies the nonlinear fifth order conditions. .. table:: Diagonally-implicit, solve-decoupled MRI-GARK coupling tables. The default diff --git a/doc/shared/sunadaptcontroller/SUNAdaptController_Description.rst b/doc/shared/sunadaptcontroller/SUNAdaptController_Description.rst index fa7e048017..585b347b8f 100644 --- a/doc/shared/sunadaptcontroller/SUNAdaptController_Description.rst +++ b/doc/shared/sunadaptcontroller/SUNAdaptController_Description.rst @@ -86,7 +86,7 @@ The virtual table structure is defined as .. c:member:: SUNErrCode (*estimatesteptol)(SUNAdaptController C, sunrealtype H, sunrealtype tolfac, int P, sunrealtype DSM, sunrealtype dsm, sunrealtype* Hnew, sunrealtype* tolfacnew) The function implementing :c:func:`SUNAdaptController_EstimateStepTol` - + .. versionadded:: x.y.z .. c:member:: SUNErrCode (*reset)(SUNAdaptController C) @@ -148,7 +148,7 @@ following set of SUNAdaptController types: Controls both a slow time step and a tolerance factor to apply on the next-faster time scale within a multirate simulation that has an arbitrary number of time scales. - + .. versionadded:: x.y.z @@ -191,11 +191,6 @@ note these requirements below. Additionally, we note the behavior of the base SU :param C: the :c:type:`SUNAdaptController` object. :return: :c:type:`SUNErrCode` indicating success or failure. - Usage: - - .. code-block:: c - - retval = SUNAdaptController_DestroyEmpty(C); .. c:function:: SUNAdaptController_Type SUNAdaptController_GetType(SUNAdaptController C) @@ -205,11 +200,6 @@ note these requirements below. Additionally, we note the behavior of the base SU :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:: SUNErrCode SUNAdaptController_Destroy(SUNAdaptController C) @@ -223,11 +213,6 @@ note these requirements below. Additionally, we note the behavior of the base SU :param C: the :c:type:`SUNAdaptController` object. :return: :c:type:`SUNErrCode` indicating success or failure. - Usage: - - .. code-block:: c - - retval = SUNAdaptController_Destroy(C); .. c:function:: SUNErrCode SUNAdaptController_EstimateStep(SUNAdaptController C, sunrealtype h, int p, sunrealtype dsm, sunrealtype* hnew) @@ -242,20 +227,15 @@ note these requirements below. Additionally, we note the behavior of the base SU :param hnew: (output) the estimated step size. :return: :c:type:`SUNErrCode` indicating success or failure. - Usage: - - .. code-block:: c - - retval = SUNAdaptController_EstimateStep(C, hcur, p, dsm, &hnew); .. c:function:: SUNErrCode SUNAdaptController_EstimateStepTol(SUNAdaptController C, sunrealtype H, sunrealtype tolfac, int P, sunrealtype DSM, sunrealtype dsm, sunrealtype* Hnew, sunrealtype* tolfacnew) Estimates a slow step size and a fast tolerance multiplication factor for two adjacent time scales within a multirate application. - + This routine is required for controllers of type :c:enumerator`SUN_ADAPTCONTROLLER_MRI_TOL`. If the current time scale has relative tolerance ``rtol``, then the - next-faster time scale will be called with relative tolerance ``tolfac * rtol``. + next-faster time scale will be called with relative tolerance ``tolfac * rtol``. If this is not provided by the implementation, the base class method will set ``*Hnew = H`` and ``*tolfacnew = tolfac`` and return. @@ -270,11 +250,7 @@ note these requirements below. Additionally, we note the behavior of the base SU :return: :c:type:`SUNErrCode` indicating success or failure. .. versionadded:: x.y.z - Usage: - - .. code-block:: c - retval = SUNAdaptController_EstimateStepTol(C, Hcur, tolfac, P, DSM, dsm, &Hnew, &tolfacnew); .. c:function:: SUNErrCode SUNAdaptController_Reset(SUNAdaptController C) @@ -283,7 +259,7 @@ note these requirements below. Additionally, we note the behavior of the base SU :param C: the :c:type:`SUNAdaptController` object. :return: :c:type:`SUNErrCode` indicating success or failure. - + .. versionadded:: x.y.z @@ -293,7 +269,7 @@ note these requirements below. Additionally, we note the behavior of the base SU :param C: the :c:type:`SUNAdaptController` object. :return: :c:type:`SUNErrCode` indicating success or failure. - + .. versionadded:: x.y.z @@ -346,7 +322,7 @@ note these requirements below. Additionally, we note the behavior of the base SU :param DSM: the successful slow temporal error estimate. :param dsm: the successful fast temporal error estimate. :return: :c:type:`SUNErrCode` indicating success or failure. - + .. versionadded:: x.y.z From e5645fe49ddb2e543104bea84fb4f16452903c56 Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Wed, 23 Oct 2024 08:10:26 -0500 Subject: [PATCH 142/286] Formatting and spelling --- doc/arkode/guide/source/Mathematics.rst | 2 +- .../arkode/CXX_serial/ark_kpr_nestedmri.cpp | 110 +++++++++--------- examples/arkode/C_serial/ark_kpr_mri.c | 9 +- include/arkode/arkode_mristep.h | 15 ++- .../sunadaptcontroller_mrihtol.h | 6 +- src/arkode/arkode_mri_tables.c | 3 +- .../ark_test_brusselator_mriadapt.cpp | 2 +- 7 files changed, 71 insertions(+), 76 deletions(-) diff --git a/doc/arkode/guide/source/Mathematics.rst b/doc/arkode/guide/source/Mathematics.rst index 3ccb4b2246..ad230afadb 100644 --- a/doc/arkode/guide/source/Mathematics.rst +++ b/doc/arkode/guide/source/Mathematics.rst @@ -776,7 +776,7 @@ The implicit solve that follows each fast IVP must solve the algebraic equation We note that IMEX-MRI-SR methods are solve-decoupled by construction, and thus the structure of a given stage never needs to be deduced based on :math:`\Delta c_i^S`. However, ARKODE still checks the value of :math:`\gamma_{i,i}`, since if it zero then the stage update -equation :eq:`ARKODE_MRISR_implicit` simplifes to a simple explicit Runge--Kutta-like stage +equation :eq:`ARKODE_MRISR_implicit` simplifies to a simple explicit Runge--Kutta-like stage update. The overall time step solution is given by the final internal stage solution, diff --git a/examples/arkode/CXX_serial/ark_kpr_nestedmri.cpp b/examples/arkode/CXX_serial/ark_kpr_nestedmri.cpp index e82176cafe..a030282b07 100644 --- a/examples/arkode/CXX_serial/ark_kpr_nestedmri.cpp +++ b/examples/arkode/CXX_serial/ark_kpr_nestedmri.cpp @@ -934,11 +934,11 @@ int main(int argc, char* argv[]) // Main time-stepping loop: calls ARKodeEvolve to perform the // integration, then prints results. Stops when the final time // has been reached - sunrealtype t = T0; - sunrealtype t2 = T0; - sunrealtype dTout = (Tf - T0) / Nt; - sunrealtype tout = T0 + dTout; - sunrealtype* ydata = N_VGetArrayPointer(y); + sunrealtype t = T0; + sunrealtype t2 = T0; + sunrealtype dTout = (Tf - T0) / Nt; + sunrealtype tout = T0 + dTout; + sunrealtype* ydata = N_VGetArrayPointer(y); sunrealtype* yrefdata = N_VGetArrayPointer(yref); sunrealtype u, v, w, uerr, verr, werr, uerrtot, verrtot, werrtot, errtot, accuracy; @@ -948,8 +948,8 @@ int main(int argc, char* argv[]) printf(" " "---------------------------------------------------------------------" "-------\n"); - printf(" %10.6" FSYM " %10.6" FSYM " %10.6" FSYM " %10.6" FSYM - " %.2" ESYM " %.2" ESYM " %.2" ESYM "\n", + printf(" %10.6" FSYM " %10.6" FSYM " %10.6" FSYM " %10.6" FSYM " %.2" ESYM + " %.2" ESYM " %.2" ESYM "\n", t, ydata[0], ydata[1], ydata[2], uerr, verr, werr); while (Tf - t > SUN_RCONST(1.0e-8)) { @@ -1047,10 +1047,10 @@ int main(int argc, char* argv[]) check_flag(retval, "ERKStepGetNumRhsEvals"); // Print some final statistics - uerrtot = std::sqrt(uerrtot / (sunrealtype) nsts); - verrtot = std::sqrt(verrtot / (sunrealtype) nsts); - werrtot = std::sqrt(werrtot / (sunrealtype) nsts); - errtot = std::sqrt(errtot / SUN_RCONST(3.0) / (sunrealtype) nsts); + uerrtot = std::sqrt(uerrtot / (sunrealtype)nsts); + verrtot = std::sqrt(verrtot / (sunrealtype)nsts); + werrtot = std::sqrt(werrtot / (sunrealtype)nsts); + errtot = std::sqrt(errtot / SUN_RCONST(3.0) / (sunrealtype)nsts); std::cout << "\nFinal Solver Statistics:\n"; std::cout << " Slow steps = " << nsts << " (attempts = " << natts << ", fails = " << netfs << ")\n"; @@ -1074,12 +1074,12 @@ int main(int argc, char* argv[]) retval = ARKodeGetNumJacEvals(arkode_mem, &njes); check_flag(retval, "ARKodeGetNumJacEvals"); std::cout << " Slow Newton iters = " << nnis << std::endl; - std::cout << " Slow Newton iters/attempt = " - << (sunrealtype) nnis/natts << std::endl; + std::cout << " Slow Newton iters/attempt = " << (sunrealtype)nnis / natts + << std::endl; std::cout << " Slow Newton conv fails = " << nncs << std::endl; std::cout << " Slow Jacobian evals = " << njes << std::endl; - std::cout << " Slow Jacobian evals/Newton = " - << (sunrealtype) njes/nnis << std::endl; + std::cout << " Slow Jacobian evals/Newton = " << (sunrealtype)njes / nnis + << std::endl; } // Get/print intermediate integrator implicit solver statistics @@ -1092,11 +1092,11 @@ int main(int argc, char* argv[]) check_flag(retval, "ARKodeGetNumJacEvals"); std::cout << " Intermediate Newton iters = " << nnim << std::endl; std::cout << " Intermediate Newton iters/attempt = " - << (sunrealtype) nnim/nattm << std::endl; + << (sunrealtype)nnim / nattm << std::endl; std::cout << " Intermediate Newton conv fails = " << nncm << std::endl; std::cout << " Intermediate Jacobian evals = " << njem << std::endl; std::cout << " Intermediate Jacobian evals/Newton = " - << (sunrealtype) njem/nnim << std::endl; + << (sunrealtype)njem / nnim << std::endl; } // Clean up and return @@ -1148,14 +1148,12 @@ static int fn(sunrealtype t, N_Vector y, N_Vector ydot, void* user_data) // [ G e e ] [(u^2-p-2)/(2u)] + [ pdot(t)/(2u) ] // [ e al be ] [(v^2-q-2)/(2v)] [ qdot(t)/(2v) ] // [ e -be al ] [(w^2-r-2)/(2w)] [ rdot(t)/(2w) ] - tmp1 = (-TWO + u * u - p(t, *opts)) / (TWO * u); - tmp2 = (-TWO + v * v - q(t, *opts)) / (TWO * v); - tmp3 = (-TWO + w * w - r(t, *opts)) / (TWO * w); + tmp1 = (-TWO + u * u - p(t, *opts)) / (TWO * u); + tmp2 = (-TWO + v * v - q(t, *opts)) / (TWO * v); + tmp3 = (-TWO + w * w - r(t, *opts)) / (TWO * w); ydotdata[0] = G * tmp1 + e * tmp2 + e * tmp3 + pdot(t, *opts) / (TWO * u); - ydotdata[1] = e * tmp1 + al * tmp2 + be * tmp3 + - qdot(t, *opts) / (TWO * v); - ydotdata[2] = e * tmp1 - be * tmp2 + al * tmp3 + - rdot(t, *opts) / (TWO * w); + ydotdata[1] = e * tmp1 + al * tmp2 + be * tmp3 + qdot(t, *opts) / (TWO * v); + ydotdata[2] = e * tmp1 - be * tmp2 + al * tmp3 + rdot(t, *opts) / (TWO * w); // Return with success return 0; @@ -1179,13 +1177,12 @@ static int ff(sunrealtype t, N_Vector y, N_Vector ydot, void* user_data) // [ 0 0 0 ] [(u^2-p-2)/(2u)] + [ 0 ] // [ 0 0 0 ] [(v^2-q-2)/(2v)] [ 0 ] // [ e -be al ] [(w^2-r-2)/(2w)] [ rdot(t)/(2w) ] - tmp1 = (-TWO + u * u - p(t, *opts)) / (TWO * u); - tmp2 = (-TWO + v * v - q(t, *opts)) / (TWO * v); - tmp3 = (-TWO + w * w - r(t, *opts)) / (TWO * w); + tmp1 = (-TWO + u * u - p(t, *opts)) / (TWO * u); + tmp2 = (-TWO + v * v - q(t, *opts)) / (TWO * v); + tmp3 = (-TWO + w * w - r(t, *opts)) / (TWO * w); ydotdata[0] = ZERO; ydotdata[1] = ZERO; - ydotdata[2] = e * tmp1 - be * tmp2 + al * tmp3 + - rdot(t, *opts) / (TWO * w); + ydotdata[2] = e * tmp1 - be * tmp2 + al * tmp3 + rdot(t, *opts) / (TWO * w); // Return with success return 0; @@ -1209,12 +1206,11 @@ static int fm(sunrealtype t, N_Vector y, N_Vector ydot, void* user_data) // [ 0 0 0 ] [(u^2-p-2)/(2u)] + [ 0 ] // [ e al be ] [(v^2-q-2)/(2v)] [ qdot(t)/(2v) ] // [ 0 0 0 ] [(w^2-r-2)/(2w)] [ 0 ] - tmp1 = (-TWO + u * u - p(t, *opts)) / (TWO * u); - tmp2 = (-TWO + v * v - q(t, *opts)) / (TWO * v); - tmp3 = (-TWO + w * w - r(t, *opts)) / (TWO * w); + tmp1 = (-TWO + u * u - p(t, *opts)) / (TWO * u); + tmp2 = (-TWO + v * v - q(t, *opts)) / (TWO * v); + tmp3 = (-TWO + w * w - r(t, *opts)) / (TWO * w); ydotdata[0] = ZERO; - ydotdata[1] = e * tmp1 + al * tmp2 + be * tmp3 + - qdot(t, *opts) / (TWO * v); + ydotdata[1] = e * tmp1 + al * tmp2 + be * tmp3 + qdot(t, *opts) / (TWO * v); ydotdata[2] = ZERO; return 0; @@ -1285,9 +1281,9 @@ static int fs(sunrealtype t, N_Vector y, N_Vector ydot, void* user_data) // [ G e e ] [(u^2-p-2)/(2u)] + [ pdot(t)/(2u) ] // [ 0 0 0 ] [(v^2-q-2)/(2v)] [ 0 ] // [ 0 0 0 ] [(w^2-r-2)/(2w)] [ 0 ] - tmp1 = (-TWO + u * u - p(t, *opts)) / (TWO * u); - tmp2 = (-TWO + v * v - q(t, *opts)) / (TWO * v); - tmp3 = (-TWO + w * w - r(t, *opts)) / (TWO * w); + tmp1 = (-TWO + u * u - p(t, *opts)) / (TWO * u); + tmp2 = (-TWO + v * v - q(t, *opts)) / (TWO * v); + tmp3 = (-TWO + w * w - r(t, *opts)) / (TWO * w); ydotdata[0] = G * tmp1 + e * tmp2 + e * tmp3 + pdot(t, *opts) / (TWO * u); ydotdata[1] = ZERO; ydotdata[2] = ZERO; @@ -1346,11 +1342,11 @@ static int fsi(sunrealtype t, N_Vector y, N_Vector ydot, void* user_data) static int Jm(sunrealtype t, N_Vector y, N_Vector fy, SUNMatrix J, void* user_data, N_Vector tmp1, N_Vector tmp2, N_Vector tmp3) { - Options* opts = static_cast(user_data); - sunrealtype* ydata = N_VGetArrayPointer(y); - const sunrealtype u = ydata[0]; - const sunrealtype v = ydata[1]; - const sunrealtype w = ydata[2]; + Options* opts = static_cast(user_data); + sunrealtype* ydata = N_VGetArrayPointer(y); + const sunrealtype u = ydata[0]; + const sunrealtype v = ydata[1]; + const sunrealtype w = ydata[2]; sunrealtype t11, t22, t33; // fill in the Jacobian: @@ -1378,11 +1374,11 @@ static int Jm(sunrealtype t, N_Vector y, N_Vector fy, SUNMatrix J, static int Jmi(sunrealtype t, N_Vector y, N_Vector fy, SUNMatrix J, void* user_data, N_Vector tmp1, N_Vector tmp2, N_Vector tmp3) { - Options* opts = static_cast(user_data); - sunrealtype* ydata = N_VGetArrayPointer(y); - const sunrealtype u = ydata[0]; - const sunrealtype v = ydata[1]; - const sunrealtype w = ydata[2]; + Options* opts = static_cast(user_data); + sunrealtype* ydata = N_VGetArrayPointer(y); + const sunrealtype u = ydata[0]; + const sunrealtype v = ydata[1]; + const sunrealtype w = ydata[2]; sunrealtype t11, t22, t33; // fill in the Jacobian: @@ -1410,11 +1406,11 @@ static int Jmi(sunrealtype t, N_Vector y, N_Vector fy, SUNMatrix J, static int Js(sunrealtype t, N_Vector y, N_Vector fy, SUNMatrix J, void* user_data, N_Vector tmp1, N_Vector tmp2, N_Vector tmp3) { - Options* opts = static_cast(user_data); - sunrealtype* ydata = N_VGetArrayPointer(y); - const sunrealtype u = ydata[0]; - const sunrealtype v = ydata[1]; - const sunrealtype w = ydata[2]; + Options* opts = static_cast(user_data); + sunrealtype* ydata = N_VGetArrayPointer(y); + const sunrealtype u = ydata[0]; + const sunrealtype v = ydata[1]; + const sunrealtype w = ydata[2]; sunrealtype t11, t22, t33; // fill in the Jacobian: @@ -1442,11 +1438,11 @@ static int Js(sunrealtype t, N_Vector y, N_Vector fy, SUNMatrix J, static int Jsi(sunrealtype t, N_Vector y, N_Vector fy, SUNMatrix J, void* user_data, N_Vector tmp1, N_Vector tmp2, N_Vector tmp3) { - Options* opts = static_cast(user_data); - sunrealtype* ydata = N_VGetArrayPointer(y); - const sunrealtype u = ydata[0]; - const sunrealtype v = ydata[1]; - const sunrealtype w = ydata[2]; + Options* opts = static_cast(user_data); + sunrealtype* ydata = N_VGetArrayPointer(y); + const sunrealtype u = ydata[0]; + const sunrealtype v = ydata[1]; + const sunrealtype w = ydata[2]; sunrealtype t11, t22, t33; // fill in the Jacobian: diff --git a/examples/arkode/C_serial/ark_kpr_mri.c b/examples/arkode/C_serial/ark_kpr_mri.c index d9e96e6a1f..a940f71a47 100644 --- a/examples/arkode/C_serial/ark_kpr_mri.c +++ b/examples/arkode/C_serial/ark_kpr_mri.c @@ -190,8 +190,8 @@ int main(int argc, char* argv[]) printf(" ark_kpr_mri slow_type fast_type h G w e deduce_rhs"); return (-1); } - slow_type = atoi(argv[1]); - fast_type = atoi(argv[2]); + slow_type = atoi(argv[1]); + fast_type = atoi(argv[2]); if (argc > 3) { hs = SUNStrToReal(argv[3]); } if (argc > 4) { G = SUNStrToReal(argv[4]); } if (argc > 5) { w = SUNStrToReal(argv[5]); } @@ -212,7 +212,7 @@ int main(int argc, char* argv[]) } if ((fast_type < 0) || (fast_type > 5)) { - printf("ERROR: fast_type be an integer in [0,5] \n"); + printf("ERROR: fast_type be an integer in [0,5] \n"); return (-1); } if ((slow_type == 0) && (fast_type == 0)) @@ -432,8 +432,7 @@ int main(int argc, char* argv[]) /* Set Butcher table for fast integrator */ switch (fast_type) { - case (0): - break; + case (0): break; case (1): B = ARKodeButcherTable_Alloc(3, SUNFALSE); if (check_retval((void*)B, "ARKodeButcherTable_Alloc", 0)) { return 1; } diff --git a/include/arkode/arkode_mristep.h b/include/arkode/arkode_mristep.h index cd972e94ff..ba6cd831fb 100644 --- a/include/arkode/arkode_mristep.h +++ b/include/arkode/arkode_mristep.h @@ -118,7 +118,6 @@ typedef int (*MRIStepInnerGetAccumulatedError)(MRIStepInnerStepper stepper, typedef int (*MRIStepInnerResetAccumulatedError)(MRIStepInnerStepper stepper); - typedef int (*MRIStepInnerSetRTol)(MRIStepInnerStepper stepper, sunrealtype rtol); /*--------------------------------------------------------------- @@ -127,13 +126,13 @@ typedef int (*MRIStepInnerSetRTol)(MRIStepInnerStepper stepper, sunrealtype rtol struct MRIStepCouplingMem { MRISTEP_METHOD_TYPE type; /* flag to encode the MRI method type */ - int nmat; /* number of MRI coupling matrices */ - int stages; /* size of coupling matrices ((stages+1) * stages) */ - int q; /* method order of accuracy */ - int p; /* embedding order of accuracy */ - sunrealtype* c; /* stage abscissae */ - sunrealtype*** W; /* explicit coupling matrices [nmat][stages+1][stages] */ - sunrealtype*** G; /* implicit coupling matrices [nmat][stages+1][stages] */ + int nmat; /* number of MRI coupling matrices */ + int stages; /* size of coupling matrices ((stages+1) * stages) */ + int q; /* method order of accuracy */ + int p; /* embedding order of accuracy */ + sunrealtype* c; /* stage abscissae */ + sunrealtype*** W; /* explicit coupling matrices [nmat][stages+1][stages] */ + sunrealtype*** G; /* implicit coupling matrices [nmat][stages+1][stages] */ int ngroup; /* number of stage groups (MERK-specific) */ int** group; /* stages to integrate together (MERK-specific) */ diff --git a/include/sunadaptcontroller/sunadaptcontroller_mrihtol.h b/include/sunadaptcontroller/sunadaptcontroller_mrihtol.h index e53f17327f..56e3488e5d 100644 --- a/include/sunadaptcontroller/sunadaptcontroller_mrihtol.h +++ b/include/sunadaptcontroller/sunadaptcontroller_mrihtol.h @@ -44,9 +44,9 @@ typedef struct SUNAdaptControllerContent_MRIHTol_* SUNAdaptControllerContent_MRI * ------------------ */ SUNDIALS_EXPORT -SUNAdaptController SUNAdaptController_MRIHTol(SUNAdaptController HControl, - SUNAdaptController TolControl, - SUNContext sunctx); +SUNAdaptController SUNAdaptController_MRIHTol(SUNAdaptController HControl, + SUNAdaptController TolControl, + SUNContext sunctx); SUNDIALS_EXPORT SUNErrCode SUNAdaptController_SetParams_MRIHTol(SUNAdaptController C, sunrealtype inner_max_relch, diff --git a/src/arkode/arkode_mri_tables.c b/src/arkode/arkode_mri_tables.c index 11d8e14b17..0c85a2ea72 100644 --- a/src/arkode/arkode_mri_tables.c +++ b/src/arkode/arkode_mri_tables.c @@ -69,7 +69,8 @@ MRIStepCoupling MRIStepCoupling_LoadTableByName(const char* method) /*--------------------------------------------------------------- Routine to allocate an empty MRIStepCoupling structure ---------------------------------------------------------------*/ -MRIStepCoupling MRIStepCoupling_Alloc(int nmat, int stages, MRISTEP_METHOD_TYPE type) +MRIStepCoupling MRIStepCoupling_Alloc(int nmat, int stages, + MRISTEP_METHOD_TYPE type) { int i, j; sunbooleantype hasOmegas, hasGammas; diff --git a/test/unit_tests/arkode/CXX_serial/ark_test_brusselator_mriadapt.cpp b/test/unit_tests/arkode/CXX_serial/ark_test_brusselator_mriadapt.cpp index 16e9287f4d..d9328bd234 100644 --- a/test/unit_tests/arkode/CXX_serial/ark_test_brusselator_mriadapt.cpp +++ b/test/unit_tests/arkode/CXX_serial/ark_test_brusselator_mriadapt.cpp @@ -575,7 +575,7 @@ int main(int argc, char* argv[]) scontrol_Tol = SUNAdaptController_ImExGus(sunctx); if (check_ptr((void*)scontrol_Tol, "SUNAdaptController_ImExGus (slow Tol)")) return 1; - scontrol = SUNAdaptController_MRIHTol(scontrol_H, scontrol_Tol,sunctx); + scontrol = SUNAdaptController_MRIHTol(scontrol_H, scontrol_Tol, sunctx); if (check_ptr((void*)scontrol, "SUNAdaptController_MRIHTol")) return 1; if (std::min(opts.htol_relch, std::min(opts.htol_minfac, opts.htol_maxfac)) > -1) From 700e47fa58c934cfe5a1a65a84bbed62a2095062 Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Wed, 23 Oct 2024 08:13:35 -0500 Subject: [PATCH 143/286] Fixed conversion 'error' --- examples/arkode/CXX_serial/ark_kpr_nestedmri.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/examples/arkode/CXX_serial/ark_kpr_nestedmri.cpp b/examples/arkode/CXX_serial/ark_kpr_nestedmri.cpp index a030282b07..478356f790 100644 --- a/examples/arkode/CXX_serial/ark_kpr_nestedmri.cpp +++ b/examples/arkode/CXX_serial/ark_kpr_nestedmri.cpp @@ -1074,12 +1074,12 @@ int main(int argc, char* argv[]) retval = ARKodeGetNumJacEvals(arkode_mem, &njes); check_flag(retval, "ARKodeGetNumJacEvals"); std::cout << " Slow Newton iters = " << nnis << std::endl; - std::cout << " Slow Newton iters/attempt = " << (sunrealtype)nnis / natts - << std::endl; + std::cout << " Slow Newton iters/attempt = " + << (sunrealtype)nnis / (sunrealtype)natts << std::endl; std::cout << " Slow Newton conv fails = " << nncs << std::endl; std::cout << " Slow Jacobian evals = " << njes << std::endl; - std::cout << " Slow Jacobian evals/Newton = " << (sunrealtype)njes / nnis - << std::endl; + std::cout << " Slow Jacobian evals/Newton = " + << (sunrealtype)njes / (sunrealtype)nnis << std::endl; } // Get/print intermediate integrator implicit solver statistics @@ -1092,11 +1092,11 @@ int main(int argc, char* argv[]) check_flag(retval, "ARKodeGetNumJacEvals"); std::cout << " Intermediate Newton iters = " << nnim << std::endl; std::cout << " Intermediate Newton iters/attempt = " - << (sunrealtype)nnim / nattm << std::endl; + << (sunrealtype)nnim / (sunrealtype)nattm << std::endl; std::cout << " Intermediate Newton conv fails = " << nncm << std::endl; std::cout << " Intermediate Jacobian evals = " << njem << std::endl; std::cout << " Intermediate Jacobian evals/Newton = " - << (sunrealtype)njem / nnim << std::endl; + << (sunrealtype)njem / (sunrealtype)nnim << std::endl; } // Clean up and return From 7e4dd3f37b580fd875e9a069d5bbb06553754b58 Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Wed, 23 Oct 2024 08:27:01 -0500 Subject: [PATCH 144/286] Updated new examples/tests to use ARKodeGetNumRhs --- examples/arkode/CXX_serial/ark_kpr_nestedmri.cpp | 16 ++++++++++------ .../CXX_serial/ark_test_brusselator_mriadapt.cpp | 10 ++++++---- .../arkode/CXX_serial/ark_test_kpr_mriadapt.cpp | 10 ++++++---- 3 files changed, 22 insertions(+), 14 deletions(-) diff --git a/examples/arkode/CXX_serial/ark_kpr_nestedmri.cpp b/examples/arkode/CXX_serial/ark_kpr_nestedmri.cpp index 478356f790..50d021ba08 100644 --- a/examples/arkode/CXX_serial/ark_kpr_nestedmri.cpp +++ b/examples/arkode/CXX_serial/ark_kpr_nestedmri.cpp @@ -1021,8 +1021,10 @@ int main(int argc, char* argv[]) check_flag(retval, "ARKodeGetNumStepAttempts"); retval = ARKodeGetNumErrTestFails(arkode_mem, &netfs); check_flag(retval, "ARKodeGetNumErrTestFails"); - retval = MRIStepGetNumRhsEvals(arkode_mem, &nfse, &nfsi); - check_flag(retval, "MRIStepGetNumRhsEvals"); + retval = ARKodeGetNumRhsEvals(arkode_mem, 0, &nfse); + check_flag(retval, "ARKodeGetNumRhsEvals"); + retval = ARKodeGetNumRhsEvals(arkode_mem, 1, &nfsi); + check_flag(retval, "ARKodeGetNumRhsEvals"); // Get some intermediate integrator statistics long int nstm, nattm, netfm, nfme, nfmi; @@ -1032,8 +1034,10 @@ int main(int argc, char* argv[]) check_flag(retval, "ARKodeGetNumStepAttempts"); retval = ARKodeGetNumErrTestFails(mid_arkode_mem, &netfm); check_flag(retval, "ARKodeGetNumErrTestFails"); - retval = MRIStepGetNumRhsEvals(mid_arkode_mem, &nfme, &nfmi); - check_flag(retval, "MRIStepGetNumRhsEvals"); + retval = ARKodeGetNumRhsEvals(mid_arkode_mem, 0, &nfme); + check_flag(retval, "ARKodeGetNumRhsEvals"); + retval = ARKodeGetNumRhsEvals(mid_arkode_mem, 1, &nfmi); + check_flag(retval, "ARKodeGetNumRhsEvals"); // Get some fast integrator statistics long int nstf, nattf, netff, nff; @@ -1043,8 +1047,8 @@ int main(int argc, char* argv[]) check_flag(retval, "ARKodeGetNumStepAttempts"); retval = ARKodeGetNumErrTestFails(inner_arkode_mem, &netff); check_flag(retval, "ARKodeGetNumErrTestFails"); - retval = ERKStepGetNumRhsEvals(inner_arkode_mem, &nff); - check_flag(retval, "ERKStepGetNumRhsEvals"); + retval = ARKodeGetNumRhsEvals(inner_arkode_mem, 0, &nff); + check_flag(retval, "ARKodeGetNumRhsEvals"); // Print some final statistics uerrtot = std::sqrt(uerrtot / (sunrealtype)nsts); diff --git a/test/unit_tests/arkode/CXX_serial/ark_test_brusselator_mriadapt.cpp b/test/unit_tests/arkode/CXX_serial/ark_test_brusselator_mriadapt.cpp index d9328bd234..66ba885c1b 100644 --- a/test/unit_tests/arkode/CXX_serial/ark_test_brusselator_mriadapt.cpp +++ b/test/unit_tests/arkode/CXX_serial/ark_test_brusselator_mriadapt.cpp @@ -748,8 +748,10 @@ int main(int argc, char* argv[]) check_flag(retval, "ARKodeGetNumStepAttempts"); retval = ARKodeGetNumErrTestFails(arkode_mem, &netfs); check_flag(retval, "ARKodeGetNumErrTestFails"); - retval = MRIStepGetNumRhsEvals(arkode_mem, &nfse, &nfsi); - check_flag(retval, "MRIStepGetNumRhsEvals"); + retval = ARKodeGetNumRhsEvals(arkode_mem, 0, &nfse); + check_flag(retval, "ARKodeGetNumRhsEvals"); + retval = ARKodeGetNumRhsEvals(arkode_mem, 1, &nfsi); + check_flag(retval, "ARKodeGetNumRhsEvals"); // Get some fast integrator statistics long int nstf, nattf, netff, nff; @@ -759,8 +761,8 @@ int main(int argc, char* argv[]) check_flag(retval, "ARKodeGetNumStepAttempts"); retval = ARKodeGetNumErrTestFails(inner_arkode_mem, &netff); check_flag(retval, "ARKodeGetNumErrTestFails"); - retval = ERKStepGetNumRhsEvals(inner_arkode_mem, &nff); - check_flag(retval, "ERKStepGetNumRhsEvals"); + retval = ARKodeGetNumRhsEvals(inner_arkode_mem, 0, &nff); + check_flag(retval, "ARKodeGetNumRhsEvals"); // Print some final statistics std::cout << "\nFinal Solver Statistics:\n"; diff --git a/test/unit_tests/arkode/CXX_serial/ark_test_kpr_mriadapt.cpp b/test/unit_tests/arkode/CXX_serial/ark_test_kpr_mriadapt.cpp index 5611780f19..aaa0c1feaa 100644 --- a/test/unit_tests/arkode/CXX_serial/ark_test_kpr_mriadapt.cpp +++ b/test/unit_tests/arkode/CXX_serial/ark_test_kpr_mriadapt.cpp @@ -746,8 +746,10 @@ int main(int argc, char* argv[]) check_flag(retval, "ARKodeGetNumStepAttempts"); retval = ARKodeGetNumErrTestFails(arkode_mem, &netfs); check_flag(retval, "ARKodeGetNumErrTestFails"); - retval = MRIStepGetNumRhsEvals(arkode_mem, &nfse, &nfsi); - check_flag(retval, "MRIStepGetNumRhsEvals"); + retval = ARKodeGetNumRhsEvals(arkode_mem, 0, &nfse); + check_flag(retval, "ARKodeGetNumRhsEvals"); + retval = ARKodeGetNumRhsEvals(arkode_mem, 1, &nfsi); + check_flag(retval, "ARKodeGetNumRhsEvals"); // Get some fast integrator statistics long int nstf, nattf, netff, nff; @@ -757,8 +759,8 @@ int main(int argc, char* argv[]) check_flag(retval, "ARKodeGetNumStepAttempts"); retval = ARKodeGetNumErrTestFails(inner_arkode_mem, &netff); check_flag(retval, "ARKodeGetNumErrTestFails"); - retval = ERKStepGetNumRhsEvals(inner_arkode_mem, &nff); - check_flag(retval, "ERKStepGetNumRhsEvals"); + retval = ARKodeGetNumRhsEvals(inner_arkode_mem, 0, &nff); + check_flag(retval, "ARKodeGetNumRhsEvals"); // Print some final statistics std::cout << "\nFinal Solver Statistics:\n"; From a85dffe4febc2d3b0483c33b864c8f3cb75fb0bd Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Wed, 23 Oct 2024 09:23:06 -0500 Subject: [PATCH 145/286] Removed NV_Ith_S from new unit tests --- .../ark_test_accumerror_brusselator.cpp | 88 +++++++------- .../CXX_serial/ark_test_accumerror_kpr.cpp | 38 +++--- .../ark_test_brusselator_mriadapt.cpp | 109 ++++++++++-------- .../CXX_serial/ark_test_kpr_mriadapt.cpp | 95 ++++++++------- .../ark_test_slowerror_brusselator.cpp | 90 ++++++++------- .../CXX_serial/ark_test_slowerror_kpr.cpp | 62 +++++----- .../ark_test_slowerror_polynomial.cpp | 25 ++-- 7 files changed, 290 insertions(+), 217 deletions(-) diff --git a/test/unit_tests/arkode/CXX_serial/ark_test_accumerror_brusselator.cpp b/test/unit_tests/arkode/CXX_serial/ark_test_accumerror_brusselator.cpp index 7869048a90..6091dbc40d 100644 --- a/test/unit_tests/arkode/CXX_serial/ark_test_accumerror_brusselator.cpp +++ b/test/unit_tests/arkode/CXX_serial/ark_test_accumerror_brusselator.cpp @@ -155,6 +155,8 @@ int main(int argc, char* argv[]) SUNMatrix A = NULL; // empty matrix for solver SUNLinearSolver LS = NULL; // empty linear solver object UserData udata; // user-data structure + sunrealtype* ydata = NULL; + sunrealtype* yrefdata = NULL; udata.ep = SUN_RCONST(0.0004); // stiffness parameter udata.Npart = 20; // partition size @@ -256,12 +258,14 @@ int main(int argc, char* argv[]) if (check_retval((void*)y, "N_VNew_Serial", 0)) return 1; yref = N_VCloneVectorArray(udata.Npart + 1, y); if (check_retval((void*)yref, "N_VNew_Serial", 0)) return 1; + ydata = N_VGetArrayPointer(y); + if (check_retval((void*)ydata, "N_VGetArrayPointer", 0)) return 1; // Generate reference solution - NV_Ith_S(y, 0) = u0; - NV_Ith_S(y, 1) = v0; - NV_Ith_S(y, 2) = w0; - arkode_ref = ARKStepCreate(fn, NULL, T0, y, ctx); + ydata[0] = u0; + ydata[1] = v0; + ydata[2] = w0; + arkode_ref = ARKStepCreate(fn, NULL, T0, y, ctx); if (check_retval((void*)arkode_ref, "ARKStepCreate", 0)) return 1; retval = ARKodeSetUserData(arkode_ref, (void*)&udata); if (check_retval(&retval, "ARKodeSetUserData", 1)) return 1; @@ -285,9 +289,9 @@ int main(int argc, char* argv[]) ARKodeFree(&arkode_ref); // Set up ARKStep integrator - NV_Ith_S(y, 0) = u0; - NV_Ith_S(y, 1) = v0; - NV_Ith_S(y, 2) = w0; + ydata[0] = u0; + ydata[1] = v0; + ydata[2] = w0; if (rk_type == 0) { // DIRK method arkode_mem = ARKStepCreate(NULL, fn, T0, y, ctx); @@ -347,15 +351,17 @@ int main(int argc, char* argv[]) static int fn(sunrealtype t, N_Vector y, N_Vector ydot, void* user_data) { - UserData* udata = (UserData*)user_data; - sunrealtype u = NV_Ith_S(y, 0); // access solution values - sunrealtype v = NV_Ith_S(y, 1); - sunrealtype w = NV_Ith_S(y, 2); + UserData* udata = (UserData*)user_data; + sunrealtype* ydata = N_VGetArrayPointer(y); + sunrealtype* dydata = N_VGetArrayPointer(y); + const sunrealtype u = ydata[0]; // access solution values + const sunrealtype v = ydata[1]; + const sunrealtype w = ydata[2]; // fill in the RHS function - NV_Ith_S(ydot, 0) = udata->a - (w + ONE) * u + v * u * u; - NV_Ith_S(ydot, 1) = w * u - v * u * u; - NV_Ith_S(ydot, 2) = (udata->b - w) / udata->ep - w * u; + dydata[0] = udata->a - (w + ONE) * u + v * u * u; + dydata[1] = w * u - v * u * u; + dydata[2] = (udata->b - w) / udata->ep - w * u; // Return with success return 0; @@ -364,10 +370,11 @@ static int fn(sunrealtype t, N_Vector y, N_Vector ydot, void* user_data) static int Jac(sunrealtype t, N_Vector y, N_Vector fy, SUNMatrix J, void* user_data, N_Vector tmp1, N_Vector tmp2, N_Vector tmp3) { - UserData* udata = (UserData*)user_data; - sunrealtype u = NV_Ith_S(y, 0); // access solution values - sunrealtype v = NV_Ith_S(y, 1); - sunrealtype w = NV_Ith_S(y, 2); + UserData* udata = (UserData*)user_data; + sunrealtype* ydata = N_VGetArrayPointer(y); + const sunrealtype u = ydata[0]; // access solution values + const sunrealtype v = ydata[1]; + const sunrealtype w = ydata[2]; // fill in the Jacobian SM_ELEMENT_D(J, 0, 0) = -(w + ONE) + TWO * u * v; @@ -451,15 +458,14 @@ static int adaptive_run(void* arkode_mem, N_Vector y, sunrealtype T0, if (check_retval(&retval, "ARKodeGetNumSteps", 1)) break; // Compute/print solution error - sunrealtype uref = NV_Ith_S(yref[ipart + 1], 0); - sunrealtype vref = NV_Ith_S(yref[ipart + 1], 1); - sunrealtype wref = NV_Ith_S(yref[ipart + 1], 2); - sunrealtype udsm = abs(NV_Ith_S(y, 0) - uref) / - (abstol + rtols[irtol] * abs(uref)); - sunrealtype vdsm = abs(NV_Ith_S(y, 1) - vref) / - (abstol + rtols[irtol] * abs(vref)); - sunrealtype wdsm = abs(NV_Ith_S(y, 2) - wref) / - (abstol + rtols[irtol] * abs(wref)); + sunrealtype* ydata = N_VGetArrayPointer(y); + sunrealtype* yrefdata = N_VGetArrayPointer(yref[ipart + 1]); + const sunrealtype udsm = abs(ydata[0] - yrefdata[0]) / + (abstol + rtols[irtol] * abs(yrefdata[0])); + const sunrealtype vdsm = abs(ydata[1] - yrefdata[1]) / + (abstol + rtols[irtol] * abs(yrefdata[1])); + const sunrealtype wdsm = abs(ydata[2] - yrefdata[2]) / + (abstol + rtols[irtol] * abs(yrefdata[2])); dsm[ipart] = rtols[irtol] * sqrt((udsm * udsm + vdsm * vdsm + wdsm * wdsm) / SUN_RCONST(3.0)); @@ -550,12 +556,14 @@ static int fixed_run(void* arkode_mem, N_Vector y, sunrealtype T0, sunrealtype T if (check_retval(&retval, "ARKodeGetNumSteps", 1)) break; // Compute/print solution error - sunrealtype udsm = abs(NV_Ith_S(y, 0) - NV_Ith_S(yref[ipart + 1], 0)) / - (abstol + reltol * abs(NV_Ith_S(yref[ipart + 1], 0))); - sunrealtype vdsm = abs(NV_Ith_S(y, 1) - NV_Ith_S(yref[ipart + 1], 1)) / - (abstol + reltol * abs(NV_Ith_S(yref[ipart + 1], 1))); - sunrealtype wdsm = abs(NV_Ith_S(y, 2) - NV_Ith_S(yref[ipart + 1], 2)) / - (abstol + reltol * abs(NV_Ith_S(yref[ipart + 1], 2))); + sunrealtype* ydata = N_VGetArrayPointer(y); + sunrealtype* yrefdata = N_VGetArrayPointer(yref[ipart + 1]); + const sunrealtype udsm = abs(ydata[0] - yrefdata[0]) / + (abstol + reltol * abs(yrefdata[0])); + const sunrealtype vdsm = abs(ydata[1] - yrefdata[1]) / + (abstol + reltol * abs(yrefdata[1])); + const sunrealtype wdsm = abs(ydata[2] - yrefdata[2]) / + (abstol + reltol * abs(yrefdata[2])); dsm[ipart] = reltol * sqrt((udsm * udsm + vdsm * vdsm + wdsm * wdsm) / SUN_RCONST(3.0)); cout << " h " << hvals[ih] << " rk_type " << rk_type << " order " @@ -631,12 +639,14 @@ static int fixed_run(void* arkode_mem, N_Vector y, sunrealtype T0, sunrealtype T dsm_est[ipart] = reltol * N_VWrmsNorm(y2, ewt); Nsteps[ipart] += nsteps2; - sunrealtype udsm = abs(NV_Ith_S(y, 0) - NV_Ith_S(yref[ipart + 1], 0)) / - (abstol + reltol * abs(NV_Ith_S(yref[ipart + 1], 0))); - sunrealtype vdsm = abs(NV_Ith_S(y, 1) - NV_Ith_S(yref[ipart + 1], 1)) / - (abstol + reltol * abs(NV_Ith_S(yref[ipart + 1], 1))); - sunrealtype wdsm = abs(NV_Ith_S(y, 2) - NV_Ith_S(yref[ipart + 1], 2)) / - (abstol + reltol * abs(NV_Ith_S(yref[ipart + 1], 2))); + sunrealtype* ydata = N_VGetArrayPointer(y); + sunrealtype* yrefdata = N_VGetArrayPointer(yref[ipart + 1]); + const sunrealtype udsm = abs(ydata[0] - yrefdata[0]) / + (abstol + reltol * abs(yrefdata[0])); + const sunrealtype vdsm = abs(ydata[1] - yrefdata[1]) / + (abstol + reltol * abs(yrefdata[1])); + const sunrealtype wdsm = abs(ydata[2] - yrefdata[2]) / + (abstol + reltol * abs(yrefdata[2])); dsm[ipart] = reltol * sqrt((udsm * udsm + vdsm * vdsm + wdsm * wdsm) / SUN_RCONST(3.0)); cout << " h " << hvals[ih] << " rk_type " << rk_type << " order " diff --git a/test/unit_tests/arkode/CXX_serial/ark_test_accumerror_kpr.cpp b/test/unit_tests/arkode/CXX_serial/ark_test_accumerror_kpr.cpp index b5bf8f48ae..3d027981c2 100644 --- a/test/unit_tests/arkode/CXX_serial/ark_test_accumerror_kpr.cpp +++ b/test/unit_tests/arkode/CXX_serial/ark_test_accumerror_kpr.cpp @@ -298,17 +298,19 @@ int main(int argc, char* argv[]) static int fn(sunrealtype t, N_Vector y, N_Vector ydot, void* user_data) { UserData* udata = (UserData*)user_data; - const sunrealtype u = NV_Ith_S(y, 0); - const sunrealtype v = NV_Ith_S(y, 1); + sunrealtype* ydata = N_VGetArrayPointer(y); + sunrealtype* dydata = N_VGetArrayPointer(ydot); + const sunrealtype u = ydata[0]; + const sunrealtype v = ydata[1]; sunrealtype tmp1, tmp2; // fill in the RHS function: // [G e]*[(-2+u^2-p(t))/(2*u)] + [pdot(t)/(2u)] // [e -1] [(-2+v^2-s(t))/(2*v)] [qdot(t)/(2v)] - tmp1 = (-TWO + u * u - p(t)) / (TWO * u); - tmp2 = (-TWO + v * v - q(t, *udata)) / (TWO * v); - NV_Ith_S(ydot, 0) = udata->G * tmp1 + udata->e * tmp2 + pdot(t) / (TWO * u); - NV_Ith_S(ydot, 1) = udata->e * tmp1 - tmp2 + qdot(t, *udata) / (TWO * v); + tmp1 = (-TWO + u * u - p(t)) / (TWO * u); + tmp2 = (-TWO + v * v - q(t, *udata)) / (TWO * v); + dydata[0] = udata->G * tmp1 + udata->e * tmp2 + pdot(t) / (TWO * u); + dydata[1] = udata->e * tmp1 - tmp2 + qdot(t, *udata) / (TWO * v); // Return with success return 0; @@ -318,8 +320,9 @@ static int Jn(sunrealtype t, N_Vector y, N_Vector fy, SUNMatrix J, void* user_data, N_Vector tmp1, N_Vector tmp2, N_Vector tmp3) { UserData* udata = (UserData*)user_data; - const sunrealtype u = NV_Ith_S(y, 0); - const sunrealtype v = NV_Ith_S(y, 1); + sunrealtype* ydata = N_VGetArrayPointer(y); + const sunrealtype u = ydata[0]; + const sunrealtype v = ydata[1]; sunrealtype t11, t22; // fill in the Jacobian: @@ -355,6 +358,7 @@ static int adaptive_run(void* arkode_mem, N_Vector y, sunrealtype T0, vector dsm(udata.Npart); vector dsm_est(udata.Npart); vector Nsteps(udata.Npart); + sunrealtype* ydata = N_VGetArrayPointer(y); // Loop over tolerances cout << "\nAdaptive-step runs:\n"; @@ -416,9 +420,9 @@ static int adaptive_run(void* arkode_mem, N_Vector y, sunrealtype T0, } // Compute/print solution error - sunrealtype udsm = abs(NV_Ith_S(y, 0) - utrue(t)) / + sunrealtype udsm = abs(ydata[0] - utrue(t)) / (abstol + rtols[irtol] * abs(utrue(t))); - sunrealtype vdsm = abs(NV_Ith_S(y, 1) - vtrue(t, udata)) / + sunrealtype vdsm = abs(ydata[1] - vtrue(t, udata)) / (abstol + rtols[irtol] * abs(vtrue(t, udata))); dsm[ipart] = rtols[irtol] * sqrt(0.5 * (udsm * udsm + vdsm * vdsm)); cout << " rtol " << rtols[irtol] << " rk_type " << rk_type @@ -455,6 +459,7 @@ static int fixed_run(void* arkode_mem, N_Vector y, sunrealtype T0, vector dsm(udata.Npart); vector dsm_est(udata.Npart); vector Nsteps(udata.Npart); + sunrealtype* ydata = N_VGetArrayPointer(y); // Loop over step sizes cout << "\nFixed-step runs:\n"; @@ -526,9 +531,9 @@ static int fixed_run(void* arkode_mem, N_Vector y, sunrealtype T0, } // Compute/print solution error - sunrealtype udsm = abs(NV_Ith_S(y, 0) - utrue(t)) / + sunrealtype udsm = abs(ydata[0] - utrue(t)) / (abstol + reltol * abs(utrue(t))); - sunrealtype vdsm = abs(NV_Ith_S(y, 1) - vtrue(t, udata)) / + sunrealtype vdsm = abs(ydata[1] - vtrue(t, udata)) / (abstol + reltol * abs(vtrue(t, udata))); dsm[ipart] = reltol * sqrt(0.5 * (udsm * udsm + vdsm * vdsm)); cout << " h " << hvals[ih] << " rk_type " << rk_type << " order " @@ -620,9 +625,9 @@ static int fixed_run(void* arkode_mem, N_Vector y, sunrealtype T0, N_VLinearSum(ONE, y2, -ONE, y, y2); dsm_est[ipart] = reltol * N_VWrmsNorm(y2, ewt); Nsteps[ipart] += nsteps2; - sunrealtype udsm = abs(NV_Ith_S(y, 0) - utrue(t)) / + sunrealtype udsm = abs(ydata[0] - utrue(t)) / (abstol + reltol * abs(utrue(t))); - sunrealtype vdsm = abs(NV_Ith_S(y, 1) - vtrue(t, udata)) / + sunrealtype vdsm = abs(ydata[1] - vtrue(t, udata)) / (abstol + reltol * abs(vtrue(t, udata))); dsm[ipart] = reltol * sqrt(0.5 * (udsm * udsm + vdsm * vdsm)); cout << " h " << hvals[ih] << " rk_type " << rk_type << " order " @@ -662,8 +667,9 @@ static sunrealtype vtrue(sunrealtype t, UserData& udata) static int Ytrue(sunrealtype t, N_Vector y, UserData& udata) { - NV_Ith_S(y, 0) = utrue(t); - NV_Ith_S(y, 1) = vtrue(t, udata); + sunrealtype* ydata = N_VGetArrayPointer(y); + ydata[0] = utrue(t); + ydata[1] = vtrue(t, udata); return (0); } diff --git a/test/unit_tests/arkode/CXX_serial/ark_test_brusselator_mriadapt.cpp b/test/unit_tests/arkode/CXX_serial/ark_test_brusselator_mriadapt.cpp index 66ba885c1b..17f36134a5 100644 --- a/test/unit_tests/arkode/CXX_serial/ark_test_brusselator_mriadapt.cpp +++ b/test/unit_tests/arkode/CXX_serial/ark_test_brusselator_mriadapt.cpp @@ -265,9 +265,11 @@ int main(int argc, char* argv[]) if (check_ptr((void*)yref, "N_VNew_Serial")) return 1; // Set initial conditions - NV_Ith_S(y, 0) = SUN_RCONST(1.2); - NV_Ith_S(y, 1) = SUN_RCONST(3.1); - NV_Ith_S(y, 2) = SUN_RCONST(3.0); + sunrealtype* ydata = N_VGetArrayPointer(y); + sunrealtype* yrefdata = N_VGetArrayPointer(yref); + ydata[0] = SUN_RCONST(1.2); + ydata[1] = SUN_RCONST(3.1); + ydata[2] = SUN_RCONST(3.0); N_VScale(ONE, y, yref); // Create and configure reference solver object @@ -672,7 +674,7 @@ int main(int argc, char* argv[]) "----\n"); printf(" %10.6" FSYM " %10.6" FSYM " %10.6" FSYM " %10.6" FSYM " %.1" ESYM " %.1" ESYM " %.1" ESYM "\n", - t, NV_Ith_S(y, 0), NV_Ith_S(y, 1), NV_Ith_S(y, 2), uerr, verr, werr); + t, ydata[0], ydata[1], ydata[2], uerr, verr, werr); int Nout = 0; while (Tf - t > 1.0e-8) { @@ -700,22 +702,22 @@ int main(int argc, char* argv[]) } // access/print solution and error - u = NV_Ith_S(y, 0); - v = NV_Ith_S(y, 1); - w = NV_Ith_S(y, 2); - uerr = SUNRabs(NV_Ith_S(yref, 0) - u); - verr = SUNRabs(NV_Ith_S(yref, 1) - v); - werr = SUNRabs(NV_Ith_S(yref, 2) - w); + u = ydata[0]; + v = ydata[1]; + w = ydata[2]; + uerr = SUNRabs(yrefdata[0] - u); + verr = SUNRabs(yrefdata[1] - v); + werr = SUNRabs(yrefdata[2] - w); uerrtot += uerr * uerr; verrtot += verr * verr; werrtot += werr * werr; errtot += uerr * uerr + verr * verr + werr * werr; accuracy = std::max(accuracy, uerr / SUNRabs(opts.atol + - opts.rtol * NV_Ith_S(yref, 0))); + opts.rtol * yrefdata[0])); accuracy = std::max(accuracy, verr / SUNRabs(opts.atol + - opts.rtol * NV_Ith_S(yref, 1))); + opts.rtol * yrefdata[1])); accuracy = std::max(accuracy, werr / SUNRabs(opts.atol + - opts.rtol * NV_Ith_S(yref, 2))); + opts.rtol * yrefdata[2])); Nout++; // Periodically output current results to screen @@ -816,12 +818,14 @@ int main(int argc, char* argv[]) static int ff(sunrealtype t, N_Vector y, N_Vector ydot, void* user_data) { Options* opts = (Options*)user_data; - const sunrealtype w = NV_Ith_S(y, 2); + sunrealtype* ydata = N_VGetArrayPointer(y); + sunrealtype* dydata = N_VGetArrayPointer(ydot); + const sunrealtype w = ydata[2]; // fill in the RHS function: - NV_Ith_S(ydot, 0) = ZERO; - NV_Ith_S(ydot, 1) = ZERO; - NV_Ith_S(ydot, 2) = (opts->b - w) / opts->ep; + dydata[0] = ZERO; + dydata[1] = ZERO; + dydata[2] = (opts->b - w) / opts->ep; // Return with success return 0; @@ -831,14 +835,16 @@ static int ff(sunrealtype t, N_Vector y, N_Vector ydot, void* user_data) static int fs(sunrealtype t, N_Vector y, N_Vector ydot, void* user_data) { Options* opts = (Options*)user_data; - const sunrealtype u = NV_Ith_S(y, 0); - const sunrealtype v = NV_Ith_S(y, 1); - const sunrealtype w = NV_Ith_S(y, 2); + sunrealtype* ydata = N_VGetArrayPointer(y); + sunrealtype* dydata = N_VGetArrayPointer(ydot); + const sunrealtype u = ydata[0]; + const sunrealtype v = ydata[1]; + const sunrealtype w = ydata[2]; // fill in the RHS function: - NV_Ith_S(ydot, 0) = opts->a - (w + ONE) * u + v * u * u; - NV_Ith_S(ydot, 1) = w * u - v * u * u; - NV_Ith_S(ydot, 2) = -w * u; + dydata[0] = opts->a - (w + ONE) * u + v * u * u; + dydata[1] = w * u - v * u * u; + dydata[2] = -w * u; // Return with success return 0; @@ -848,13 +854,15 @@ static int fs(sunrealtype t, N_Vector y, N_Vector ydot, void* user_data) static int fse(sunrealtype t, N_Vector y, N_Vector ydot, void* user_data) { Options* opts = (Options*)user_data; - const sunrealtype u = NV_Ith_S(y, 0); - const sunrealtype v = NV_Ith_S(y, 1); + sunrealtype* ydata = N_VGetArrayPointer(y); + sunrealtype* dydata = N_VGetArrayPointer(ydot); + const sunrealtype u = ydata[0]; + const sunrealtype v = ydata[1]; // fill in the RHS function: - NV_Ith_S(ydot, 0) = opts->a + v * u * u; - NV_Ith_S(ydot, 1) = -v * u * u; - NV_Ith_S(ydot, 2) = ZERO; + dydata[0] = opts->a + v * u * u; + dydata[1] = -v * u * u; + dydata[2] = ZERO; // Return with success return 0; @@ -863,13 +871,15 @@ static int fse(sunrealtype t, N_Vector y, N_Vector ydot, void* user_data) // fsi routine to compute the slow portion of the ODE RHS.(currently same as fse) static int fsi(sunrealtype t, N_Vector y, N_Vector ydot, void* user_data) { - const sunrealtype u = NV_Ith_S(y, 0); - const sunrealtype w = NV_Ith_S(y, 2); + sunrealtype* ydata = N_VGetArrayPointer(y); + sunrealtype* dydata = N_VGetArrayPointer(ydot); + const sunrealtype u = ydata[0]; + const sunrealtype w = ydata[2]; // fill in the RHS function: - NV_Ith_S(ydot, 0) = -(w + ONE) * u; - NV_Ith_S(ydot, 1) = w * u; - NV_Ith_S(ydot, 2) = -w * u; + dydata[0] = -(w + ONE) * u; + dydata[1] = w * u; + dydata[2] = -w * u; // Return with success return 0; @@ -878,14 +888,16 @@ static int fsi(sunrealtype t, N_Vector y, N_Vector ydot, void* user_data) static int fn(sunrealtype t, N_Vector y, N_Vector ydot, void* user_data) { Options* opts = (Options*)user_data; - const sunrealtype u = NV_Ith_S(y, 0); - const sunrealtype v = NV_Ith_S(y, 1); - const sunrealtype w = NV_Ith_S(y, 2); + sunrealtype* ydata = N_VGetArrayPointer(y); + sunrealtype* dydata = N_VGetArrayPointer(ydot); + const sunrealtype u = ydata[0]; + const sunrealtype v = ydata[1]; + const sunrealtype w = ydata[2]; // fill in the RHS function: - NV_Ith_S(ydot, 0) = opts->a - (w + ONE) * u + v * u * u; - NV_Ith_S(ydot, 1) = w * u - v * u * u; - NV_Ith_S(ydot, 2) = (opts->b - w) / opts->ep - w * u; + dydata[0] = opts->a - (w + ONE) * u + v * u * u; + dydata[1] = w * u - v * u * u; + dydata[2] = (opts->b - w) / opts->ep - w * u; // Return with success return 0; @@ -900,9 +912,10 @@ static int f0(sunrealtype t, N_Vector y, N_Vector ydot, void* user_data) static int Js(sunrealtype t, N_Vector y, N_Vector fy, SUNMatrix J, void* user_data, N_Vector tmp1, N_Vector tmp2, N_Vector tmp3) { - const sunrealtype u = NV_Ith_S(y, 0); - const sunrealtype v = NV_Ith_S(y, 1); - const sunrealtype w = NV_Ith_S(y, 2); + sunrealtype* ydata = N_VGetArrayPointer(y); + const sunrealtype u = ydata[0]; + const sunrealtype v = ydata[1]; + const sunrealtype w = ydata[2]; // fill in the Jacobian: SM_ELEMENT_D(J, 0, 0) = -(w + ONE) + TWO * u * v; @@ -924,8 +937,9 @@ static int Js(sunrealtype t, N_Vector y, N_Vector fy, SUNMatrix J, static int Jsi(sunrealtype t, N_Vector y, N_Vector fy, SUNMatrix J, void* user_data, N_Vector tmp1, N_Vector tmp2, N_Vector tmp3) { - const sunrealtype u = NV_Ith_S(y, 0); - const sunrealtype w = NV_Ith_S(y, 2); + sunrealtype* ydata = N_VGetArrayPointer(y); + const sunrealtype u = ydata[0]; + const sunrealtype w = ydata[2]; // fill in the Jacobian: SM_ELEMENT_D(J, 0, 0) = -(w + ONE); @@ -948,9 +962,10 @@ static int Jn(sunrealtype t, N_Vector y, N_Vector fy, SUNMatrix J, void* user_data, N_Vector tmp1, N_Vector tmp2, N_Vector tmp3) { Options* opts = (Options*)user_data; - const sunrealtype u = NV_Ith_S(y, 0); - const sunrealtype v = NV_Ith_S(y, 1); - const sunrealtype w = NV_Ith_S(y, 2); + sunrealtype* ydata = N_VGetArrayPointer(y); + const sunrealtype u = ydata[0]; + const sunrealtype v = ydata[1]; + const sunrealtype w = ydata[2]; // fill in the Jacobian: SM_ELEMENT_D(J, 0, 0) = -(w + ONE) + TWO * u * v; diff --git a/test/unit_tests/arkode/CXX_serial/ark_test_kpr_mriadapt.cpp b/test/unit_tests/arkode/CXX_serial/ark_test_kpr_mriadapt.cpp index aaa0c1feaa..6f9afe805d 100644 --- a/test/unit_tests/arkode/CXX_serial/ark_test_kpr_mriadapt.cpp +++ b/test/unit_tests/arkode/CXX_serial/ark_test_kpr_mriadapt.cpp @@ -271,6 +271,10 @@ int main(int argc, char* argv[]) if (check_ptr((void*)y, "N_VNew_Serial")) return 1; N_Vector yref = N_VNew_Serial(NEQ, refctx); if (check_ptr((void*)yref, "N_VNew_Serial")) return 1; + sunrealtype* ydata = N_VGetArrayPointer(y); + if (check_ptr((void*)ydata, "N_VGetArrayPointer")) return 1; + sunrealtype* yrefdata = N_VGetArrayPointer(yref); + if (check_ptr((void*)yrefdata, "N_VGetArrayPointer")) return 1; // Set initial conditions retval = Ytrue(T0, y, &opts); @@ -677,8 +681,7 @@ int main(int argc, char* argv[]) printf(" t u v uerr verr\n"); printf(" ------------------------------------------------------\n"); printf(" %10.6" FSYM " %10.6" FSYM " %10.6" FSYM " %.2" ESYM " %.2" ESYM - "\n", - t, NV_Ith_S(y, 0), NV_Ith_S(y, 1), uerr, verr); + "\n", t, ydata[0], ydata[1], uerr, verr); int Nout = 0; while (Tf - t > 1.0e-8) { @@ -706,17 +709,17 @@ int main(int argc, char* argv[]) } // access/print solution and error - u = NV_Ith_S(y, 0); - v = NV_Ith_S(y, 1); - uerr = SUNRabs(NV_Ith_S(yref, 0) - u); - verr = SUNRabs(NV_Ith_S(yref, 1) - v); + u = ydata[0]; + v = ydata[1]; + uerr = SUNRabs(yrefdata[0] - u); + verr = SUNRabs(yrefdata[1] - v); uerrtot += uerr * uerr; verrtot += verr * verr; errtot += uerr * uerr + verr * verr; accuracy = std::max(accuracy, uerr / SUNRabs(opts.atol + - opts.rtol * NV_Ith_S(yref, 0))); + opts.rtol * yrefdata[0])); accuracy = std::max(accuracy, verr / SUNRabs(opts.atol + - opts.rtol * NV_Ith_S(yref, 1))); + opts.rtol * yrefdata[1])); Nout++; // Periodically output current results to screen @@ -813,17 +816,19 @@ int main(int argc, char* argv[]) static int ff(sunrealtype t, N_Vector y, N_Vector ydot, void* user_data) { Options* opts = (Options*)user_data; - const sunrealtype u = NV_Ith_S(y, 0); - const sunrealtype v = NV_Ith_S(y, 1); + sunrealtype* ydata = N_VGetArrayPointer(y); + sunrealtype* dydata = N_VGetArrayPointer(ydot); + const sunrealtype u = ydata[0]; + const sunrealtype v = ydata[1]; sunrealtype tmp1, tmp2; // fill in the RHS function: // [0 0]*[(-2+u^2-r(t))/(2*u)] + [ 0 ] // [e -1] [(-2+v^2-s(t))/(2*v)] [sdot(t)/(2v)] - tmp1 = (-TWO + u * u - r(t, opts)) / (TWO * u); - tmp2 = (-TWO + v * v - s(t, opts)) / (TWO * v); - NV_Ith_S(ydot, 0) = ZERO; - NV_Ith_S(ydot, 1) = opts->e * tmp1 - tmp2 + sdot(t, opts) / (TWO * v); + tmp1 = (-TWO + u * u - r(t, opts)) / (TWO * u); + tmp2 = (-TWO + v * v - s(t, opts)) / (TWO * v); + dydata[0] = ZERO; + dydata[1] = opts->e * tmp1 - tmp2 + sdot(t, opts) / (TWO * v); // Return with success return 0; @@ -833,8 +838,10 @@ static int ff(sunrealtype t, N_Vector y, N_Vector ydot, void* user_data) static int fs(sunrealtype t, N_Vector y, N_Vector ydot, void* user_data) { Options* opts = (Options*)user_data; - const sunrealtype u = NV_Ith_S(y, 0); - const sunrealtype v = NV_Ith_S(y, 1); + sunrealtype* ydata = N_VGetArrayPointer(y); + sunrealtype* dydata = N_VGetArrayPointer(ydot); + const sunrealtype u = ydata[0]; + const sunrealtype v = ydata[1]; sunrealtype tmp1, tmp2; // fill in the RHS function: @@ -842,8 +849,8 @@ static int fs(sunrealtype t, N_Vector y, N_Vector ydot, void* user_data) // [0 0] [(-2+v^2-s(t))/(2*v)] [ 0 ] tmp1 = (-TWO + u * u - r(t, opts)) / (TWO * u); tmp2 = (-TWO + v * v - s(t, opts)) / (TWO * v); - NV_Ith_S(ydot, 0) = opts->G * tmp1 + opts->e * tmp2 + rdot(t, opts) / (TWO * u); - NV_Ith_S(ydot, 1) = ZERO; + dydata[0] = opts->G * tmp1 + opts->e * tmp2 + rdot(t, opts) / (TWO * u); + dydata[1] = ZERO; // Return with success return 0; @@ -853,13 +860,15 @@ static int fs(sunrealtype t, N_Vector y, N_Vector ydot, void* user_data) static int fse(sunrealtype t, N_Vector y, N_Vector ydot, void* user_data) { Options* opts = (Options*)user_data; - const sunrealtype u = NV_Ith_S(y, 0); + sunrealtype* ydata = N_VGetArrayPointer(y); + sunrealtype* dydata = N_VGetArrayPointer(ydot); + const sunrealtype u = ydata[0]; // fill in the slow explicit RHS function: // [rdot(t)/(2u)] // [ 0 ] - NV_Ith_S(ydot, 0) = rdot(t, opts) / (TWO * u); - NV_Ith_S(ydot, 1) = ZERO; + dydata[0] = rdot(t, opts) / (TWO * u); + dydata[1] = ZERO; // Return with success return 0; @@ -869,17 +878,19 @@ static int fse(sunrealtype t, N_Vector y, N_Vector ydot, void* user_data) static int fsi(sunrealtype t, N_Vector y, N_Vector ydot, void* user_data) { Options* opts = (Options*)user_data; - const sunrealtype u = NV_Ith_S(y, 0); - const sunrealtype v = NV_Ith_S(y, 1); + sunrealtype* ydata = N_VGetArrayPointer(y); + sunrealtype* dydata = N_VGetArrayPointer(ydot); + const sunrealtype u = ydata[0]; + const sunrealtype v = ydata[1]; sunrealtype tmp1, tmp2; // fill in the slow implicit RHS function: // [G e]*[(-2+u^2-r(t))/(2*u)] // [0 0] [(-2+v^2-s(t))/(2*v)] - tmp1 = (-TWO + u * u - r(t, opts)) / (TWO * u); - tmp2 = (-TWO + v * v - s(t, opts)) / (TWO * v); - NV_Ith_S(ydot, 0) = opts->G * tmp1 + opts->e * tmp2; - NV_Ith_S(ydot, 1) = ZERO; + tmp1 = (-TWO + u * u - r(t, opts)) / (TWO * u); + tmp2 = (-TWO + v * v - s(t, opts)) / (TWO * v); + dydata[0] = opts->G * tmp1 + opts->e * tmp2; + dydata[1] = ZERO; // Return with success return 0; @@ -888,8 +899,10 @@ static int fsi(sunrealtype t, N_Vector y, N_Vector ydot, void* user_data) static int fn(sunrealtype t, N_Vector y, N_Vector ydot, void* user_data) { Options* opts = (Options*)user_data; - const sunrealtype u = NV_Ith_S(y, 0); - const sunrealtype v = NV_Ith_S(y, 1); + sunrealtype* ydata = N_VGetArrayPointer(y); + sunrealtype* dydata = N_VGetArrayPointer(ydot); + const sunrealtype u = ydata[0]; + const sunrealtype v = ydata[1]; sunrealtype tmp1, tmp2; // fill in the RHS function: @@ -897,8 +910,8 @@ static int fn(sunrealtype t, N_Vector y, N_Vector ydot, void* user_data) // [e -1] [(-2+v^2-s(t))/(2*v)] [sdot(t)/(2v)] tmp1 = (-TWO + u * u - r(t, opts)) / (TWO * u); tmp2 = (-TWO + v * v - s(t, opts)) / (TWO * v); - NV_Ith_S(ydot, 0) = opts->G * tmp1 + opts->e * tmp2 + rdot(t, opts) / (TWO * u); - NV_Ith_S(ydot, 1) = opts->e * tmp1 - tmp2 + sdot(t, opts) / (TWO * v); + dydata[0] = opts->G * tmp1 + opts->e * tmp2 + rdot(t, opts) / (TWO * u); + dydata[1] = opts->e * tmp1 - tmp2 + sdot(t, opts) / (TWO * v); // Return with success return 0; @@ -914,8 +927,9 @@ static int Js(sunrealtype t, N_Vector y, N_Vector fy, SUNMatrix J, void* user_data, N_Vector tmp1, N_Vector tmp2, N_Vector tmp3) { Options* opts = (Options*)user_data; - const sunrealtype u = NV_Ith_S(y, 0); - const sunrealtype v = NV_Ith_S(y, 1); + sunrealtype* ydata = N_VGetArrayPointer(y); + const sunrealtype u = ydata[0]; + const sunrealtype v = ydata[1]; sunrealtype t11, t22; // fill in the Jacobian: @@ -936,8 +950,9 @@ static int Jsi(sunrealtype t, N_Vector y, N_Vector fy, SUNMatrix J, void* user_data, N_Vector tmp1, N_Vector tmp2, N_Vector tmp3) { Options* opts = (Options*)user_data; - const sunrealtype u = NV_Ith_S(y, 0); - const sunrealtype v = NV_Ith_S(y, 1); + sunrealtype* ydata = N_VGetArrayPointer(y); + const sunrealtype u = ydata[0]; + const sunrealtype v = ydata[1]; sunrealtype t11, t22; // fill in the Jacobian: @@ -958,8 +973,9 @@ static int Jn(sunrealtype t, N_Vector y, N_Vector fy, SUNMatrix J, void* user_data, N_Vector tmp1, N_Vector tmp2, N_Vector tmp3) { Options* opts = (Options*)user_data; - const sunrealtype u = NV_Ith_S(y, 0); - const sunrealtype v = NV_Ith_S(y, 1); + sunrealtype* ydata = N_VGetArrayPointer(y); + const sunrealtype u = ydata[0]; + const sunrealtype v = ydata[1]; sunrealtype t11, t22; // fill in the Jacobian: @@ -1009,8 +1025,9 @@ static sunrealtype vtrue(sunrealtype t, Options* opts) static int Ytrue(sunrealtype t, N_Vector y, Options* opts) { - NV_Ith_S(y, 0) = utrue(t, opts); - NV_Ith_S(y, 1) = vtrue(t, opts); + sunrealtype* ydata = N_VGetArrayPointer(y); + ydata[0] = utrue(t, opts); + ydata[1] = vtrue(t, opts); return (0); } diff --git a/test/unit_tests/arkode/CXX_serial/ark_test_slowerror_brusselator.cpp b/test/unit_tests/arkode/CXX_serial/ark_test_slowerror_brusselator.cpp index cc0b1b5a11..f591a14085 100644 --- a/test/unit_tests/arkode/CXX_serial/ark_test_slowerror_brusselator.cpp +++ b/test/unit_tests/arkode/CXX_serial/ark_test_slowerror_brusselator.cpp @@ -252,11 +252,13 @@ int main(int argc, char* argv[]) if (check_retval((void*)y, "N_VNew_Serial", 0)) return 1; N_Vector* yref = N_VCloneVectorArray(udata.Npart + 1, y); if (check_retval((void*)yref, "N_VNew_Serial", 0)) return 1; + sunrealtype *ydata = N_VGetArrayPointer(y); + if (check_retval((void*)ydata, "N_VGetArrayPointer", 0)) return 1; + ydata[0] = u0; + ydata[1] = v0; + ydata[2] = w0; // Generate reference solution - NV_Ith_S(y, 0) = u0; - NV_Ith_S(y, 1) = v0; - NV_Ith_S(y, 2) = w0; void* arkode_ref = ERKStepCreate(fn, T0, y, ctx); if (check_retval((void*)arkode_ref, "ERKStepCreate", 0)) return 1; retval = ARKodeSetUserData(arkode_ref, (void*)&udata); @@ -280,9 +282,9 @@ int main(int argc, char* argv[]) } // Set up fast ERKStep integrator as fifth-order adaptive method - NV_Ith_S(y, 0) = u0; - NV_Ith_S(y, 1) = v0; - NV_Ith_S(y, 2) = w0; + ydata[0] = u0; + ydata[1] = v0; + ydata[2] = w0; void* inner_arkode_mem = ERKStepCreate(f0, T0, y, ctx); if (check_retval((void*)inner_arkode_mem, "ERKStepCreate", 0)) return 1; retval = ARKodeSetOrder(inner_arkode_mem, 5); @@ -374,15 +376,17 @@ static int f0(sunrealtype t, N_Vector y, N_Vector ydot, void* user_data) static int fn(sunrealtype t, N_Vector y, N_Vector ydot, void* user_data) { - UserData* udata = (UserData*)user_data; - sunrealtype u = NV_Ith_S(y, 0); // access solution values - sunrealtype v = NV_Ith_S(y, 1); - sunrealtype w = NV_Ith_S(y, 2); + UserData* udata = (UserData*)user_data; + sunrealtype* ydata = N_VGetArrayPointer(y); + sunrealtype* dydata = N_VGetArrayPointer(ydot); + const sunrealtype u = ydata[0]; // access solution values + const sunrealtype v = ydata[1]; + const sunrealtype w = ydata[2]; // fill in the RHS function - NV_Ith_S(ydot, 0) = udata->a - (w + ONE) * u + v * u * u; - NV_Ith_S(ydot, 1) = w * u - v * u * u; - NV_Ith_S(ydot, 2) = (udata->b - w) / udata->ep - w * u; + dydata[0] = udata->a - (w + ONE) * u + v * u * u; + dydata[1] = w * u - v * u * u; + dydata[2] = (udata->b - w) / udata->ep - w * u; // Return with success return 0; @@ -390,14 +394,16 @@ static int fn(sunrealtype t, N_Vector y, N_Vector ydot, void* user_data) static int fi(sunrealtype t, N_Vector y, N_Vector ydot, void* user_data) { - UserData* udata = (UserData*)user_data; - sunrealtype u = NV_Ith_S(y, 0); // access solution values - sunrealtype w = NV_Ith_S(y, 2); + UserData* udata = (UserData*)user_data; + sunrealtype* ydata = N_VGetArrayPointer(y); + sunrealtype* dydata = N_VGetArrayPointer(ydot); + const sunrealtype u = ydata[0]; // access solution values + const sunrealtype w = ydata[2]; // fill in the RHS function - NV_Ith_S(ydot, 0) = ZERO; - NV_Ith_S(ydot, 1) = ZERO; - NV_Ith_S(ydot, 2) = (udata->b - w) / udata->ep - w * u; + dydata[0] = ZERO; + dydata[1] = ZERO; + dydata[2] = (udata->b - w) / udata->ep - w * u; // Return with success return 0; @@ -405,15 +411,17 @@ static int fi(sunrealtype t, N_Vector y, N_Vector ydot, void* user_data) static int fe(sunrealtype t, N_Vector y, N_Vector ydot, void* user_data) { - UserData* udata = (UserData*)user_data; - sunrealtype u = NV_Ith_S(y, 0); // access solution values - sunrealtype v = NV_Ith_S(y, 1); - sunrealtype w = NV_Ith_S(y, 2); + UserData* udata = (UserData*)user_data; + sunrealtype* ydata = N_VGetArrayPointer(y); + sunrealtype* dydata = N_VGetArrayPointer(ydot); + const sunrealtype u = ydata[0]; // access solution values + const sunrealtype v = ydata[1]; + const sunrealtype w = ydata[2]; // fill in the RHS function - NV_Ith_S(ydot, 0) = udata->a - (w + ONE) * u + v * u * u; - NV_Ith_S(ydot, 1) = w * u - v * u * u; - NV_Ith_S(ydot, 2) = ZERO; + dydata[0] = udata->a - (w + ONE) * u + v * u * u; + dydata[1] = w * u - v * u * u; + dydata[2] = ZERO; // Return with success return 0; @@ -422,10 +430,11 @@ static int fe(sunrealtype t, N_Vector y, N_Vector ydot, void* user_data) static int Jn(sunrealtype t, N_Vector y, N_Vector fy, SUNMatrix J, void* user_data, N_Vector tmp1, N_Vector tmp2, N_Vector tmp3) { - UserData* udata = (UserData*)user_data; - sunrealtype u = NV_Ith_S(y, 0); // access solution values - sunrealtype v = NV_Ith_S(y, 1); - sunrealtype w = NV_Ith_S(y, 2); + UserData* udata = (UserData*)user_data; + sunrealtype* ydata = N_VGetArrayPointer(y); + const sunrealtype u = ydata[0]; // access solution values + const sunrealtype v = ydata[1]; + const sunrealtype w = ydata[2]; // fill in the Jacobian SM_ELEMENT_D(J, 0, 0) = -(w + ONE) + TWO * u * v; @@ -447,9 +456,10 @@ static int Jn(sunrealtype t, N_Vector y, N_Vector fy, SUNMatrix J, static int Ji(sunrealtype t, N_Vector y, N_Vector fy, SUNMatrix J, void* user_data, N_Vector tmp1, N_Vector tmp2, N_Vector tmp3) { - UserData* udata = (UserData*)user_data; - sunrealtype u = NV_Ith_S(y, 0); // access solution values - sunrealtype w = NV_Ith_S(y, 2); + UserData* udata = (UserData*)user_data; + sunrealtype* ydata = N_VGetArrayPointer(y); + const sunrealtype u = ydata[0]; // access solution values + const sunrealtype w = ydata[2]; // fill in the Jacobian SM_ELEMENT_D(J, 0, 0) = ZERO; @@ -485,6 +495,8 @@ static int run_test(void* mristep_mem, void* arkode_ref, N_Vector y, N_Vector ele = N_VClone(y); N_Vector ewt = N_VClone(y); N_Vector vtemp = N_VClone(y); + sunrealtype* ydata = N_VGetArrayPointer(y); + sunrealtype* y2data = N_VGetArrayPointer(y2); // Set storage for errors vector> dsm(Hvals.size(), @@ -525,12 +537,12 @@ static int run_test(void* mristep_mem, void* arkode_ref, N_Vector y, dsm_est[iH][ipart] = N_VWrmsNorm(ewt, ele); // Compute/print solution error - sunrealtype udsm = abs(NV_Ith_S(y, 0) - NV_Ith_S(y2, 0)) / - (abstol + reltol * abs(NV_Ith_S(y2, 0))); - sunrealtype vdsm = abs(NV_Ith_S(y, 1) - NV_Ith_S(y2, 1)) / - (abstol + reltol * abs(NV_Ith_S(y2, 1))); - sunrealtype wdsm = abs(NV_Ith_S(y, 2) - NV_Ith_S(y2, 2)) / - (abstol + reltol * abs(NV_Ith_S(y2, 2))); + sunrealtype udsm = abs(ydata[0] - y2data[0]) / + (abstol + reltol * abs(y2data[0])); + sunrealtype vdsm = abs(ydata[1] - y2data[1]) / + (abstol + reltol * abs(y2data[1])); + sunrealtype wdsm = abs(ydata[2] - y2data[2]) / + (abstol + reltol * abs(y2data[2])); dsm[iH][ipart] = sqrt((udsm * udsm + vdsm * vdsm + wdsm * wdsm) / SUN_RCONST(3.0)); cout << " H " << Hvals[iH] << " method " << method << " t " << t diff --git a/test/unit_tests/arkode/CXX_serial/ark_test_slowerror_kpr.cpp b/test/unit_tests/arkode/CXX_serial/ark_test_slowerror_kpr.cpp index ef9c5e97e6..a3cf3288c6 100644 --- a/test/unit_tests/arkode/CXX_serial/ark_test_slowerror_kpr.cpp +++ b/test/unit_tests/arkode/CXX_serial/ark_test_slowerror_kpr.cpp @@ -309,17 +309,19 @@ static int f0(sunrealtype t, N_Vector y, N_Vector ydot, void* user_data) static int fn(sunrealtype t, N_Vector y, N_Vector ydot, void* user_data) { UserData* udata = (UserData*)user_data; - const sunrealtype u = NV_Ith_S(y, 0); - const sunrealtype v = NV_Ith_S(y, 1); + sunrealtype* ydata = N_VGetArrayPointer(y); + sunrealtype* dydata = N_VGetArrayPointer(ydot); + const sunrealtype u = ydata[0]; + const sunrealtype v = ydata[1]; sunrealtype tmp1, tmp2; // fill in the RHS function: // [G e]*[(-2+u^2-p(t))/(2*u)] + [pdot(t)/(2u)] // [e -1] [(-2+v^2-s(t))/(2*v)] [qdot(t)/(2v)] - tmp1 = (-TWO + u * u - p(t)) / (TWO * u); - tmp2 = (-TWO + v * v - q(t, *udata)) / (TWO * v); - NV_Ith_S(ydot, 0) = udata->G * tmp1 + udata->e * tmp2 + pdot(t) / (TWO * u); - NV_Ith_S(ydot, 1) = udata->e * tmp1 - tmp2 + qdot(t, *udata) / (TWO * v); + tmp1 = (-TWO + u * u - p(t)) / (TWO * u); + tmp2 = (-TWO + v * v - q(t, *udata)) / (TWO * v); + dydata[0] = udata->G * tmp1 + udata->e * tmp2 + pdot(t) / (TWO * u); + dydata[1] = udata->e * tmp1 - tmp2 + qdot(t, *udata) / (TWO * v); // Return with success return 0; @@ -328,17 +330,19 @@ static int fn(sunrealtype t, N_Vector y, N_Vector ydot, void* user_data) static int fi(sunrealtype t, N_Vector y, N_Vector ydot, void* user_data) { UserData* udata = (UserData*)user_data; - const sunrealtype u = NV_Ith_S(y, 0); - const sunrealtype v = NV_Ith_S(y, 1); + sunrealtype* ydata = N_VGetArrayPointer(y); + sunrealtype* dydata = N_VGetArrayPointer(ydot); + const sunrealtype u = ydata[0]; + const sunrealtype v = ydata[1]; sunrealtype tmp1, tmp2; // fill in the RHS function: // [G e]*[(-2+u^2-p(t))/(2*u)] + [pdot(t)/(2u)] // [0 0] [(-2+v^2-s(t))/(2*v)] [ 0 ] - tmp1 = (-TWO + u * u - p(t)) / (TWO * u); - tmp2 = (-TWO + v * v - q(t, *udata)) / (TWO * v); - NV_Ith_S(ydot, 0) = udata->G * tmp1 + udata->e * tmp2 + pdot(t) / (TWO * u); - NV_Ith_S(ydot, 1) = ZERO; + tmp1 = (-TWO + u * u - p(t)) / (TWO * u); + tmp2 = (-TWO + v * v - q(t, *udata)) / (TWO * v); + dydata[0] = udata->G * tmp1 + udata->e * tmp2 + pdot(t) / (TWO * u); + dydata[1] = ZERO; // Return with success return 0; @@ -347,17 +351,19 @@ static int fi(sunrealtype t, N_Vector y, N_Vector ydot, void* user_data) static int fe(sunrealtype t, N_Vector y, N_Vector ydot, void* user_data) { UserData* udata = (UserData*)user_data; - const sunrealtype u = NV_Ith_S(y, 0); - const sunrealtype v = NV_Ith_S(y, 1); + sunrealtype* ydata = N_VGetArrayPointer(y); + sunrealtype* dydata = N_VGetArrayPointer(ydot); + const sunrealtype u = ydata[0]; + const sunrealtype v = ydata[1]; sunrealtype tmp1, tmp2; // fill in the RHS function: // [0 0]*[(-2+u^2-p(t))/(2*u)] + [ 0 ] // [e -1] [(-2+v^2-s(t))/(2*v)] [qdot(t)/(2v)] - tmp1 = (-TWO + u * u - p(t)) / (TWO * u); - tmp2 = (-TWO + v * v - q(t, *udata)) / (TWO * v); - NV_Ith_S(ydot, 0) = ZERO; - NV_Ith_S(ydot, 1) = udata->e * tmp1 - tmp2 + qdot(t, *udata) / (TWO * v); + tmp1 = (-TWO + u * u - p(t)) / (TWO * u); + tmp2 = (-TWO + v * v - q(t, *udata)) / (TWO * v); + dydata[0] = ZERO; + dydata[1] = udata->e * tmp1 - tmp2 + qdot(t, *udata) / (TWO * v); // Return with success return 0; @@ -367,8 +373,9 @@ static int Jn(sunrealtype t, N_Vector y, N_Vector fy, SUNMatrix J, void* user_data, N_Vector tmp1, N_Vector tmp2, N_Vector tmp3) { UserData* udata = (UserData*)user_data; - const sunrealtype u = NV_Ith_S(y, 0); - const sunrealtype v = NV_Ith_S(y, 1); + sunrealtype* ydata = N_VGetArrayPointer(y); + const sunrealtype u = ydata[0]; + const sunrealtype v = ydata[1]; sunrealtype t11, t22; // fill in the Jacobian: @@ -389,8 +396,9 @@ static int Ji(sunrealtype t, N_Vector y, N_Vector fy, SUNMatrix J, void* user_data, N_Vector tmp1, N_Vector tmp2, N_Vector tmp3) { UserData* udata = (UserData*)user_data; - const sunrealtype u = NV_Ith_S(y, 0); - const sunrealtype v = NV_Ith_S(y, 1); + sunrealtype* ydata = N_VGetArrayPointer(y); + const sunrealtype u = ydata[0]; + const sunrealtype v = ydata[1]; // fill in the Jacobian: // [G/2 + (G*(1+p(t))-pdot(t))/(2*u^2) e/2+e*(2+s(t))/(2*v^2)] @@ -421,6 +429,7 @@ static int run_test(void* mristep_mem, N_Vector y, sunrealtype T0, N_Vector ele = N_VClone(y); N_Vector ewt = N_VClone(y); N_Vector vtemp = N_VClone(y); + sunrealtype* ydata = N_VGetArrayPointer(y); // Set storage for errors vector> dsm(Hvals.size(), @@ -455,9 +464,9 @@ static int run_test(void* mristep_mem, N_Vector y, sunrealtype T0, dsm_est[iH][ipart] = N_VWrmsNorm(ewt, ele); // Compute/print solution error - sunrealtype udsm = abs(NV_Ith_S(y, 0) - utrue(t)) / + sunrealtype udsm = abs(ydata[0] - utrue(t)) / (abstol + reltol * abs(utrue(t))); - sunrealtype vdsm = abs(NV_Ith_S(y, 1) - vtrue(t, udata)) / + sunrealtype vdsm = abs(ydata[1] - vtrue(t, udata)) / (abstol + reltol * abs(vtrue(t, udata))); dsm[iH][ipart] = sqrt(0.5 * (udsm * udsm + vdsm * vdsm)); cout << " H " << Hvals[iH] << " method " << method << " t " << t @@ -505,8 +514,9 @@ static sunrealtype vtrue(sunrealtype t, UserData& udata) static int Ytrue(sunrealtype t, N_Vector y, UserData& udata) { - NV_Ith_S(y, 0) = utrue(t); - NV_Ith_S(y, 1) = vtrue(t, udata); + sunrealtype* ydata = N_VGetArrayPointer(y); + ydata[0] = utrue(t); + ydata[1] = vtrue(t, udata); return (0); } diff --git a/test/unit_tests/arkode/CXX_serial/ark_test_slowerror_polynomial.cpp b/test/unit_tests/arkode/CXX_serial/ark_test_slowerror_polynomial.cpp index 1f236da7d6..b624962617 100644 --- a/test/unit_tests/arkode/CXX_serial/ark_test_slowerror_polynomial.cpp +++ b/test/unit_tests/arkode/CXX_serial/ark_test_slowerror_polynomial.cpp @@ -241,7 +241,8 @@ static int fn(sunrealtype t, N_Vector y, N_Vector ydot, void* user_data) { // fill in the RHS function and return with success UserData* udata = (UserData*)user_data; - NV_Ith_S(ydot, 0) = udata->a * t * t + udata->b * t + udata->c; + sunrealtype* dydata = N_VGetArrayPointer(ydot); + dydata[0] = udata->a * t * t + udata->b * t + udata->c; return 0; } @@ -267,6 +268,8 @@ static int run_test(void* mristep_mem, N_Vector y, sunrealtype T0, N_Vector vtemp = N_VClone(y); N_Vector ele = N_VClone(y); N_Vector ewt = N_VClone(y); + sunrealtype* ydata = N_VGetArrayPointer(y); + sunrealtype* vdata = N_VGetArrayPointer(vtemp); // Set storage for errors vector dsm(Hvals.size(), ZERO); @@ -298,18 +301,17 @@ static int run_test(void* mristep_mem, N_Vector y, sunrealtype T0, // Compute/print solution error retval = Ytrue(t, vtemp, udata); if (check_retval(&retval, "Ytrue", 1)) return 1; - dsm[iH] = abs(NV_Ith_S(y, 0) - NV_Ith_S(vtemp, 0)) / - (abstol + reltol * abs(NV_Ith_S(vtemp, 0))); + dsm[iH] = abs(ydata[0] - vdata[0]) / (abstol + reltol * abs(vdata[0])); if (method == "ARKODE_MRI_GARK_ERK22a") { printf(" H %.5f dsm %.2e dsm_est %.2e dsm_anal %.2e " " dsm_est_anal %.2e\n", Hvals[iH], dsm[iH], dsm_est[iH], Hvals[iH] * Hvals[iH] * Hvals[iH] * abs(udata.a / 12.0) / - (abstol + reltol * abs(NV_Ith_S(vtemp, 0))), + (abstol + reltol * abs(vdata[0])), Hvals[iH] * Hvals[iH] * abs(udata.a * Hvals[iH] / 4.0 + udata.b / 2.0) / - (abstol + reltol * abs(NV_Ith_S(vtemp, 0)))); + (abstol + reltol * abs(vdata[0]))); } else if (method == "ARKODE_MRI_GARK_IRK21a") { @@ -317,10 +319,10 @@ static int run_test(void* mristep_mem, N_Vector y, sunrealtype T0, " dsm_est_anal %.2e\n", Hvals[iH], dsm[iH], dsm_est[iH], Hvals[iH] * Hvals[iH] * Hvals[iH] * abs(udata.a / 6.0) / - (abstol + reltol * abs(NV_Ith_S(vtemp, 0))), + (abstol + reltol * abs(vdata[0])), Hvals[iH] * Hvals[iH] * abs(udata.a * Hvals[iH] / 2.0 + udata.b / 2.0) / - (abstol + reltol * abs(NV_Ith_S(vtemp, 0)))); + (abstol + reltol * abs(vdata[0]))); } else if (method == "ARKODE_IMEX_MRI_SR21") { @@ -328,11 +330,11 @@ static int run_test(void* mristep_mem, N_Vector y, sunrealtype T0, " dsm_est_anal %.2e\n", Hvals[iH], dsm[iH], dsm_est[iH], Hvals[iH] * Hvals[iH] * Hvals[iH] * abs(udata.a * 3137.0 / 50370.0) / - (abstol + reltol * abs(NV_Ith_S(vtemp, 0))), + (abstol + reltol * abs(vdata[0])), Hvals[iH] * Hvals[iH] * abs(udata.a * Hvals[iH] * 20191.0 / 755550.0 - udata.b * 19.0 / 30.0) / - (abstol + reltol * abs(NV_Ith_S(vtemp, 0)))); + (abstol + reltol * abs(vdata[0]))); } else { @@ -349,8 +351,9 @@ static int run_test(void* mristep_mem, N_Vector y, sunrealtype T0, static int Ytrue(sunrealtype t, N_Vector y, UserData& udata) { - NV_Ith_S(y, 0) = udata.a / SUN_RCONST(3.0) * t * t * t + - udata.b / SUN_RCONST(2.0) * t * t + udata.c * t + ONE; + sunrealtype* ydata = N_VGetArrayPointer(y); + ydata[0] = udata.a / SUN_RCONST(3.0) * t * t * t + + udata.b / SUN_RCONST(2.0) * t * t + udata.c * t + ONE; return (0); } From 2749b8347031577519da5583ab3462574fcc4a56 Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Wed, 23 Oct 2024 09:25:08 -0500 Subject: [PATCH 146/286] Updated answers repository commit --- test/answers | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/answers b/test/answers index c79677ea5e..9a7c72d7f9 160000 --- a/test/answers +++ b/test/answers @@ -1 +1 @@ -Subproject commit c79677ea5ecd18b5a53456f7ec1314de1c637d6d +Subproject commit 9a7c72d7f9df24c80661d357297689af911ec7ff From eb2e79aa93d6ee436f4394fae25b8f74f8d1f356 Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Wed, 23 Oct 2024 09:34:34 -0500 Subject: [PATCH 147/286] Applied review suggestions to ark_test_erkstepsetforcing.c, and added this into CMakeLists.txt --- .../unit_tests/arkode/C_serial/CMakeLists.txt | 1 + .../C_serial/ark_test_erkstepsetforcing.c | 58 +++++++++---------- 2 files changed, 30 insertions(+), 29 deletions(-) diff --git a/test/unit_tests/arkode/C_serial/CMakeLists.txt b/test/unit_tests/arkode/C_serial/CMakeLists.txt index 6794a213b4..70363d8566 100644 --- a/test/unit_tests/arkode/C_serial/CMakeLists.txt +++ b/test/unit_tests/arkode/C_serial/CMakeLists.txt @@ -25,6 +25,7 @@ set(ARKODE_unit_tests "ark_test_arkstepsetforcing\;1 3 2.0 10.0" "ark_test_arkstepsetforcing\;1 3 2.0 10.0 2.0 8.0" "ark_test_arkstepsetforcing\;1 3 2.0 10.0 1.0 5.0" + "ark_test_erkstepsetforcing\;1 0" "ark_test_getuserdata\;" "ark_test_innerstepper\;" "ark_test_interp\;-100" diff --git a/test/unit_tests/arkode/C_serial/ark_test_erkstepsetforcing.c b/test/unit_tests/arkode/C_serial/ark_test_erkstepsetforcing.c index 1a40f17082..00f70bed66 100644 --- a/test/unit_tests/arkode/C_serial/ark_test_erkstepsetforcing.c +++ b/test/unit_tests/arkode/C_serial/ark_test_erkstepsetforcing.c @@ -16,7 +16,7 @@ * erkStep_SetInnerForcing is used to provide a polynomial forcing term in * ERKStep when it is used as the inner integrator under MRIStep. To check that * the forcing is computed and applied correctly we integrate an ODE in time - * with ERKStep where to RHS consists of only the polynomial forcing term. The + * with ERKStep where the RHS consists of only the polynomial forcing term. The * solution should be exact when the method order is greater than or equal to * the polynomial order. * ---------------------------------------------------------------------------*/ @@ -42,16 +42,16 @@ #endif /* User-supplied Functions Called by the Solver */ -static int f(realtype t, N_Vector y, N_Vector ydot, void* user_data); +static int f(sunrealtype t, N_Vector y, N_Vector ydot, void* user_data); /* Private function to check function return values */ static int check_flag(void* flagvalue, const char* funcname, int opt); /* Private function to check computed solution */ -static int compute_ans(realtype t, realtype tshift, realtype tscale, +static int compute_ans(sunrealtype t, sunrealtype tshift, sunrealtype tscale, N_Vector* forcing, int order, N_Vector ans); -static int compute_error(N_Vector y, N_Vector ans, N_Vector tmp, realtype rtol, - realtype atol); +static int compute_error(N_Vector y, N_Vector ans, N_Vector tmp, sunrealtype rtol, + sunrealtype atol); /* Main Program */ int main(int argc, char* argv[]) @@ -59,16 +59,16 @@ int main(int argc, char* argv[]) SUNContext sunctx = NULL; /* default input values */ - sunindextype NEQ = 1; /* number of dependent vars. */ - int order = 3; /* order of polynomial forcing */ - realtype T0 = RCONST(0.0); /* initial time */ - realtype Tf = RCONST(1.0); /* final time */ - realtype tshift = T0; /* time shift for normalization */ - realtype tscale = Tf; /* time scale for normalization */ + sunindextype NEQ = 1; /* number of dependent vars. */ + int order = 3; /* order of polynomial forcing */ + sunrealtype T0 = SUN_RCONST(0.0); /* initial time */ + sunrealtype Tf = SUN_RCONST(1.0); /* final time */ + sunrealtype tshift = T0; /* time shift for normalization */ + sunrealtype tscale = Tf; /* time scale for normalization */ /* tolerances */ - realtype reltol = SUNRsqrt(UNIT_ROUNDOFF); - realtype abstol = SUNRsqrt(UNIT_ROUNDOFF) / 100; + sunrealtype reltol = SUNRsqrt(SUN_UNIT_ROUNDOFF); + sunrealtype abstol = SUNRsqrt(SUN_UNIT_ROUNDOFF) / 100; /* general problem variables */ int flag; /* reusable error-checking flag */ @@ -78,8 +78,8 @@ int main(int argc, char* argv[]) N_Vector* forcing = NULL; /* array of forcing vectors */ void* arkode_mem = NULL; /* ARKode memory structure */ int i, j; /* loop counters */ - realtype tret; /* integrator return time */ - realtype* data; /* array for accessing vector data */ + sunrealtype tret; /* integrator return time */ + sunrealtype* data; /* array for accessing vector data */ long int nst, nst_a; /* number of integrator steps */ long int mxsteps = 100000; /* max steps before output */ @@ -96,7 +96,7 @@ int main(int argc, char* argv[]) if (argc > 2) { - order = (int)atol(argv[2]); + order = atoi(argv[2]); if (order < 0) { printf("ERROR: The polynomial order must be a non-negative integer\n"); @@ -111,8 +111,8 @@ int main(int argc, char* argv[]) printf("ERROR: Both the initial and final time are required\n"); return (1); } - T0 = (realtype)atof(argv[3]); - Tf = (realtype)atof(argv[4]); + T0 = SUNStrToReal(argv[3]); + Tf = SUNStrToReal(argv[4]); if (SUNRabs(T0) >= SUNRabs(Tf)) { printf("ERROR: |T0| must be less than |Tf|\n"); @@ -127,8 +127,8 @@ int main(int argc, char* argv[]) printf("ERROR: Both tshift and tscale are required\n"); return (1); } - tshift = (realtype)atof(argv[5]); - tscale = (realtype)atof(argv[6]); + tshift = SUNStrToReal(argv[5]); + tscale = SUNStrToReal(argv[6]); if (SUNRabs(tscale) < TINY) { printf("ERROR: |tscale| must be greater than %" GSYM "\n", TINY); @@ -174,7 +174,7 @@ int main(int argc, char* argv[]) data = N_VGetArrayPointer(forcing[i]); for (j = 0; j < NEQ; j++) { - data[j] = (realtype)rand() / (realtype)RAND_MAX; + data[j] = (sunrealtype)rand() / (sunrealtype)RAND_MAX; } } @@ -264,7 +264,7 @@ int main(int argc, char* argv[]) *-------------------------------*/ /* ODE RHS function */ -static int f(realtype t, N_Vector y, N_Vector ydot, void* user_data) +static int f(sunrealtype t, N_Vector y, N_Vector ydot, void* user_data) { N_VConst(ZERO, ydot); return 0; @@ -318,16 +318,16 @@ static int check_flag(void* flagvalue, const char* funcname, int opt) } /* computed the true solution at a given time */ -static int compute_ans(realtype t, realtype tshift, realtype tscale, +static int compute_ans(sunrealtype t, sunrealtype tshift, sunrealtype tscale, N_Vector* forcing, int order, N_Vector ans) { int i; - realtype tau; + sunrealtype tau; N_Vector* vecs; - realtype* vals; + sunrealtype* vals; vals = NULL; - vals = (realtype*)calloc(order + 1, sizeof(realtype)); + vals = (sunrealtype*)calloc(order + 1, sizeof(sunrealtype)); if (vals == NULL) return (1); vecs = NULL; @@ -352,11 +352,11 @@ static int compute_ans(realtype t, realtype tshift, realtype tscale, } /* compure the weighted max norm of the difference of two vectors */ -static int compute_error(N_Vector y, N_Vector ans, N_Vector tmp, realtype rtol, - realtype atol) +static int compute_error(N_Vector y, N_Vector ans, N_Vector tmp, sunrealtype rtol, + sunrealtype atol) { int status; /* success (0) or failure (1) flag */ - realtype error; + sunrealtype error; /* compute the error in y */ N_VLinearSum(ONE, y, -ONE, ans, y); From ff1cd67347275db24cd3ad6bb04a2e2306371c14 Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Wed, 23 Oct 2024 09:45:36 -0500 Subject: [PATCH 148/286] Applied suggestions from code review --- .../ark_test_brusselator_mriadapt.cpp | 36 +++++++++---------- .../CXX_serial/ark_test_kpr_mriadapt.cpp | 32 ++++++++--------- 2 files changed, 30 insertions(+), 38 deletions(-) diff --git a/test/unit_tests/arkode/CXX_serial/ark_test_brusselator_mriadapt.cpp b/test/unit_tests/arkode/CXX_serial/ark_test_brusselator_mriadapt.cpp index 17f36134a5..cf9f8593eb 100644 --- a/test/unit_tests/arkode/CXX_serial/ark_test_brusselator_mriadapt.cpp +++ b/test/unit_tests/arkode/CXX_serial/ark_test_brusselator_mriadapt.cpp @@ -675,16 +675,13 @@ int main(int argc, char* argv[]) printf(" %10.6" FSYM " %10.6" FSYM " %10.6" FSYM " %10.6" FSYM " %.1" ESYM " %.1" ESYM " %.1" ESYM "\n", t, ydata[0], ydata[1], ydata[2], uerr, verr, werr); - int Nout = 0; - while (Tf - t > 1.0e-8) + while (Tf - t > SUN_RCONST(1.0e-8)) { // reset reference solver so that it begins with identical state retval = ARKodeReset(arkode_ref, t, y); // evolve solution in one-step mode - retval = ARKodeSetStopTime(arkode_mem, tout); - if (check_flag(retval, "ARKodeSetStopTime")) return 1; - retval = ARKodeEvolve(arkode_mem, tout, y, &t, ARK_ONE_STEP); + retval = ARKodeEvolve(arkode_mem, Tf, y, &t, ARK_ONE_STEP); if (retval < 0) { printf("ARKodeEvolve error (%i)\n", retval); @@ -694,7 +691,7 @@ int main(int argc, char* argv[]) // evolve reference solver to same time in "normal" mode retval = ARKodeSetStopTime(arkode_ref, t); if (check_flag(retval, "ARKodeSetStopTime")) return 1; - retval = ARKodeEvolve(arkode_ref, t, yref, &t2, ARK_NORMAL); + retval = ARKodeEvolve(arkode_ref, Tf, yref, &t2, ARK_NORMAL); if (retval < 0) { printf("ARKodeEvolve reference solution error (%i)\n", retval); @@ -705,20 +702,19 @@ int main(int argc, char* argv[]) u = ydata[0]; v = ydata[1]; w = ydata[2]; - uerr = SUNRabs(yrefdata[0] - u); - verr = SUNRabs(yrefdata[1] - v); - werr = SUNRabs(yrefdata[2] - w); + uerr = std::abs(yrefdata[0] - u); + verr = std::abs(yrefdata[1] - v); + werr = std::abs(yrefdata[2] - w); uerrtot += uerr * uerr; verrtot += verr * verr; werrtot += werr * werr; errtot += uerr * uerr + verr * verr + werr * werr; - accuracy = std::max(accuracy, uerr / SUNRabs(opts.atol + - opts.rtol * yrefdata[0])); - accuracy = std::max(accuracy, verr / SUNRabs(opts.atol + - opts.rtol * yrefdata[1])); - accuracy = std::max(accuracy, werr / SUNRabs(opts.atol + - opts.rtol * yrefdata[2])); - Nout++; + accuracy = std::max(accuracy, uerr / std::abs(opts.atol + + opts.rtol * yrefdata[0])); + accuracy = std::max(accuracy, verr / std::abs(opts.atol + + opts.rtol * yrefdata[1])); + accuracy = std::max(accuracy, werr / std::abs(opts.atol + + opts.rtol * yrefdata[2])); // Periodically output current results to screen if (t >= tout) @@ -730,10 +726,6 @@ int main(int argc, char* argv[]) t, u, v, w, uerr, verr, werr); } } - uerrtot = SUNRsqrt(uerrtot / Nt); - verrtot = SUNRsqrt(verrtot / Nt); - werrtot = SUNRsqrt(werrtot / Nt); - errtot = SUNRsqrt(errtot / Nt / 3); printf(" " "---------------------------------------------------------------------" "----\n"); @@ -767,6 +759,10 @@ int main(int argc, char* argv[]) check_flag(retval, "ARKodeGetNumRhsEvals"); // Print some final statistics + uerrtot = std::sqrt(uerrtot / (sunrealtype)nsts); + verrtot = std::sqrt(verrtot / (sunrealtype)nsts); + werrtot = std::sqrt(werrtot / (sunrealtype)nsts); + errtot = std::sqrt(errtot / SUN_RCONST(3.0) / (sunrealtype)nsts); std::cout << "\nFinal Solver Statistics:\n"; std::cout << " Slow steps = " << nsts << " (attempts = " << natts << ", fails = " << netfs << ")\n"; diff --git a/test/unit_tests/arkode/CXX_serial/ark_test_kpr_mriadapt.cpp b/test/unit_tests/arkode/CXX_serial/ark_test_kpr_mriadapt.cpp index 6f9afe805d..fec9619a3d 100644 --- a/test/unit_tests/arkode/CXX_serial/ark_test_kpr_mriadapt.cpp +++ b/test/unit_tests/arkode/CXX_serial/ark_test_kpr_mriadapt.cpp @@ -682,16 +682,13 @@ int main(int argc, char* argv[]) printf(" ------------------------------------------------------\n"); printf(" %10.6" FSYM " %10.6" FSYM " %10.6" FSYM " %.2" ESYM " %.2" ESYM "\n", t, ydata[0], ydata[1], uerr, verr); - int Nout = 0; - while (Tf - t > 1.0e-8) + while (Tf - t > SUN_RCONST(1.0e-8)) { // reset reference solver so that it begins with identical state retval = ARKodeReset(arkode_ref, t, y); // evolve solution in one-step mode - retval = ARKodeSetStopTime(arkode_mem, tout); - if (check_flag(retval, "ARKodeSetStopTime")) return 1; - retval = ARKodeEvolve(arkode_mem, tout, y, &t, ARK_ONE_STEP); + retval = ARKodeEvolve(arkode_mem, Tf, y, &t, ARK_ONE_STEP); if (retval < 0) { printf("ARKodeEvolve error (%i)\n", retval); @@ -701,7 +698,7 @@ int main(int argc, char* argv[]) // evolve reference solver to same time in "normal" mode retval = ARKodeSetStopTime(arkode_ref, t); if (check_flag(retval, "ARKodeSetStopTime")) return 1; - retval = ARKodeEvolve(arkode_ref, t, yref, &t2, ARK_NORMAL); + retval = ARKodeEvolve(arkode_ref, Tf, yref, &t2, ARK_NORMAL); if (retval < 0) { printf("ARKodeEvolve reference solution error (%i)\n", retval); @@ -711,16 +708,15 @@ int main(int argc, char* argv[]) // access/print solution and error u = ydata[0]; v = ydata[1]; - uerr = SUNRabs(yrefdata[0] - u); - verr = SUNRabs(yrefdata[1] - v); + uerr = std::abs(yrefdata[0] - u); + verr = std::abs(yrefdata[1] - v); uerrtot += uerr * uerr; verrtot += verr * verr; errtot += uerr * uerr + verr * verr; - accuracy = std::max(accuracy, uerr / SUNRabs(opts.atol + - opts.rtol * yrefdata[0])); - accuracy = std::max(accuracy, verr / SUNRabs(opts.atol + - opts.rtol * yrefdata[1])); - Nout++; + accuracy = std::max(accuracy, uerr / std::abs(opts.atol + + opts.rtol * yrefdata[0])); + accuracy = std::max(accuracy, verr / std::abs(opts.atol + + opts.rtol * yrefdata[1])); // Periodically output current results to screen if (t >= tout) @@ -732,9 +728,6 @@ int main(int argc, char* argv[]) t, u, v, uerr, verr); } } - uerrtot = SUNRsqrt(uerrtot / Nt); - verrtot = SUNRsqrt(verrtot / Nt); - errtot = SUNRsqrt(errtot / Nt / 2); printf(" ------------------------------------------------------\n"); // @@ -766,6 +759,9 @@ int main(int argc, char* argv[]) check_flag(retval, "ARKodeGetNumRhsEvals"); // Print some final statistics + uerrtot = std::sqrt(uerrtot / (sunrealtype)nsts); + verrtot = std::sqrt(verrtot / (sunrealtype)nsts); + errtot = std::sqrt(errtot / SUN_RCONST(2.0) / (sunrealtype)nsts); std::cout << "\nFinal Solver Statistics:\n"; std::cout << " Slow steps = " << nsts << " (attempts = " << natts << ", fails = " << netfs << ")\n"; @@ -1015,12 +1011,12 @@ static sunrealtype sdot(sunrealtype t, Options* opts) static sunrealtype utrue(sunrealtype t, Options* opts) { - return (SUNRsqrt(TWO + r(t, opts))); + return (std::sqrt(TWO + r(t, opts))); } static sunrealtype vtrue(sunrealtype t, Options* opts) { - return (SUNRsqrt(TWO + s(t, opts))); + return (std::sqrt(TWO + s(t, opts))); } static int Ytrue(sunrealtype t, N_Vector y, Options* opts) From 1b8d3a0adc958868c4150067d62c6db8f19d9962 Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Thu, 24 Oct 2024 09:44:34 -0500 Subject: [PATCH 149/286] Updated documentation on how to set up and use adaptivity in MRIStep. --- .../guide/source/Usage/MRIStep/Skeleton.rst | 11 +++- .../guide/source/Usage/User_callable.rst | 48 ++++++++-------- .../SUNAdaptController_MRIHTol.rst | 57 +++++++++++++++++++ 3 files changed, 90 insertions(+), 26 deletions(-) diff --git a/doc/arkode/guide/source/Usage/MRIStep/Skeleton.rst b/doc/arkode/guide/source/Usage/MRIStep/Skeleton.rst index 1a7bf46c42..c8e239086c 100644 --- a/doc/arkode/guide/source/Usage/MRIStep/Skeleton.rst +++ b/doc/arkode/guide/source/Usage/MRIStep/Skeleton.rst @@ -85,11 +85,16 @@ unchanged from the skeleton program presented in inputs to :c:func:`MRIStepCreate` is the ``MRIStepInnerStepper`` object for solving the fast (inner) IVP created in the previous step. -#. Set the slow step size - - Call :c:func:`ARKodeSetFixedStep()` on the MRIStep object to specify the +#. If using fixed step sizes, then set the slow step size by calling + :c:func:`ARKodeSetFixedStep()` on the MRIStep object to specify the slow time step size. + If using adaptive slow steps, then specify the desired integration tolerances + as normal. By default, MRIStep will use a "decoupled" (see + :numref:`ARKODE.Mathematics.MultirateControllers`) I controller (see + :numref:`SUNAdaptController.Soderlind`), Alternately, create and attach a + multirate temporal controller (see :numref:`SUNAdaptController.MRIHTol`). + #. Create and configure implicit solvers (*as appropriate*) Specifically, if MRIStep is configured with an implicit slow right-hand side diff --git a/doc/arkode/guide/source/Usage/User_callable.rst b/doc/arkode/guide/source/Usage/User_callable.rst index 5c394b0de1..753c7b3bc4 100644 --- a/doc/arkode/guide/source/Usage/User_callable.rst +++ b/doc/arkode/guide/source/Usage/User_callable.rst @@ -1758,23 +1758,25 @@ Reset accumulated error :c:func:`ARKodeReset The following routines are used to control algorithms that ARKODE can use to estimate -the accumulated temporal error over multiple time steps. For time-stepping modules that -compute both a solution and embedding, :math:`y_n` and :math:`\tilde{y}_n`, these may be -combined to create a vector-valued local temporal error estimate for the current internal -step, :math:`y_n - \tilde{y}_n`. These local errors may be accumulated by ARKODE in a -variety of ways, as determined by the enumerated type :c:enum:`ARKAccumError`. In each -of the cases below, the accumulation is taken over all steps since the most recent -call to either :c:func:`ARKodeSetAccumulatedErrorType` or +the accumulated temporal error over multiple time steps. While these may be informational +for users on their applications, this functionality is required when using multirate +temporal adaptivity in MRIStep via the :ref:`SUNAdaptController_MRIHTol ` +module. For time-stepping modules that compute both a solution and embedding, :math:`y_n` +and :math:`\tilde{y}_n`, these may be combined to create a vector-valued local temporal error +estimate for the current internal step, :math:`y_n - \tilde{y}_n`. These local errors may be +accumulated by ARKODE in a variety of ways, as determined by the enumerated type +:c:enum:`ARKAccumError`. In each of the cases below, the accumulation is taken over all steps +since the most recent call to either :c:func:`ARKodeSetAccumulatedErrorType` or :c:func:`ARKodeResetAccumulatedError`. Below the set :math:`\mathcal{S}` contains the indices of the steps since the last call to either of the aforementioned functions. -The norm is taken using the tolerance-informed -error-weight vector (see :c:func:`ARKodeGetErrWeights`), and ``reltol`` is the -user-specified relative solution tolerance. +The norm is taken using the tolerance-informed error-weight vector (see +:c:func:`ARKodeGetErrWeights`), and ``reltol`` is the user-specified relative solution +tolerance. .. c:enum:: ARKAccumError The type of error accumulation that ARKODE should use. - + .. versionadded:: x.y.z .. c:enumerator:: ARK_ACCUMERROR_NONE @@ -1783,21 +1785,29 @@ user-specified relative solution tolerance. .. c:enumerator:: ARK_ACCUMERROR_MAX - Computes :math:`\text{reltol} \max_{i \in \mathcal{S}} \|y_i - \tilde{y}_i\|_{WRMS}` + Computes :math:`\text{reltol} \max\limits_{i \in \mathcal{S}} \|y_i - \tilde{y}_i\|_{WRMS}` .. c:enumerator:: ARK_ACCUMERROR_SUM - Computes :math:`\text{reltol} \sum_{i \in \mathcal{S}} \|y_i - \tilde{y}_i\|_{WRMS}` + Computes :math:`\text{reltol} \sum\limits_{i \in \mathcal{S}} \|y_i - \tilde{y}_i\|_{WRMS}` .. c:enumerator:: ARK_ACCUMERROR_AVG - Computes :math:`\frac{\text{reltol}}{|\mathcal{S}|} \sum_{i \in \mathcal{S}} \|y_i - \tilde{y}_i\|_{WRMS}`. + Computes :math:`\frac{\text{reltol}}{\Delta t_{\mathcal{S}}} \sum\limits_{i \in \mathcal{S}} h_i \|y_i - \tilde{y}_i\|_{WRMS}`, + where :math:`h_i` is the step size used when computing :math:`y_i`, and + :math:`\Delta t_{\mathcal{S}}` denotes the elapsed time over which + :math:`\mathcal{S}` is taken. .. c:function:: int ARKodeSetAccumulatedErrorType(void* arkode_mem, ARKAccumError accum_type) Sets the strategy to use for accumulating a temporal error estimate - over multiple time steps. + over multiple time steps. By default, ARKODE will not accumulate any + local error estimates (i.e., the default *accum_type* is ``ARK_ACCUMERROR_NONE``). + + A non-default error accumulation strategy can be disabled by calling + :c:func:`ARKodeSetAccumulatedErrorType` with the argument ``ARK_ACCUMERROR_NONE``. + :param arkode_mem: pointer to the ARKODE memory block. :param accum_type: accumulation strategy. @@ -1807,14 +1817,6 @@ user-specified relative solution tolerance. :retval ARK_STEPPER_UNSUPPORTED: temporal error estimation is not supported by the current time-stepping module. - .. note:: - - By default, ARKODE will not accumulate any local error estimates (i.e., - the default *accum_type* is ``ARK_ACCUMERROR_NONE``). - - A non-default error accumulation strategy can be disabled by calling - :c:func:`ARKodeSetAccumulatedErrorType` with the argument ``ARK_ACCUMERROR_NONE``. - .. versionadded:: x.y.z diff --git a/doc/shared/sunadaptcontroller/SUNAdaptController_MRIHTol.rst b/doc/shared/sunadaptcontroller/SUNAdaptController_MRIHTol.rst index db8136668b..1827fdd649 100644 --- a/doc/shared/sunadaptcontroller/SUNAdaptController_MRIHTol.rst +++ b/doc/shared/sunadaptcontroller/SUNAdaptController_MRIHTol.rst @@ -152,3 +152,60 @@ also provides the following additional user-callable routines: :param inner_min_tolfac: the parameter :math:`\text{tolfac}_{min}`. :param inner_max_tolfac: the parameter :math:`\text{tolfac}_{max}`. :returns: :c:type:`SUNErrCode` indicating success or failure. + + +Usage +----- + +Since this adaptivity controller is constructed using multiple single-rate adaptivity +controllers, there are a few steps required when setting this up in an application +(the steps below in *italics* correspond to the surrounding steps described in the +:ref:`MRIStep usage skeleton `. + +#. *Create an inner stepper object to solve the fast (inner) IVP* + +#. Configure the inner stepper to use temporal adaptivity. For exaple, when using + an ARKODE inner stepper and the :c:func:`ARKodeCreateMRIStepInnerStepper` + function, then either use its default adaptivity approach or supply a + single-rate SUNAdaptController object, e.g. + + .. code:: C + + void* inner_arkode_mem = ERKStepCreate(f_f, T0, y, sunctx); + MRIStepInnerStepper inner_stepper = nullptr; + retval = ARKodeCreateMRIStepInnerStepper(inner_arkode_mem, &inner_stepper); + SUNAdaptController fcontrol = SUNAdaptController_PID(sunctx); + retval = ARKodeSetAdaptController(inner_arkode_mem, fcontrol); + +#. If using an ARKODE inner stepper, then set the desired temporal error accumulation + estimation strategy via a call to :c:func:`ARKodeSetAccumulatedErrorType`, e.g., + + .. code:: C + + retval = ARKodeSetAccumulatedErrorType(inner_arkode_mem, ARK_ACCUMERROR_MAX); + +#. *Create an MRIStep object for the slow (outer) integration* + +#. Create single-rate controllers for both the slow step size and inner solver + tolerance, e.g., + + .. code:: C + + SUNAdaptController scontrol_H = SUNAdaptController_PI(sunctx); + SUNAdaptController scontrol_Tol = SUNAdaptController_I(sunctx); + +#. Create the multirate controller object, e.g., + + .. code:: C + + SUNAdaptController scontrol = SUNAdaptController_MRIHTol(scontrol_H, scontrol_Tol, sunctx); + +#. Attach the multirate controller object to MRIStep, e.g., + + .. code:: C + + retval = ARKodeSetAdaptController(arkode_mem, scontrol); + +An example showing the above steps is provided in +``examples/arkode/CXX_serial/ark_kpr_nestedmri.cpp``, where multirate controller objects +are used for both the slow and intermediate time scales in a 3-time-scale simulation. From 0790d9d9c4e725d4ccfcf1854d5241ca7eccc728 Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Thu, 24 Oct 2024 09:45:39 -0500 Subject: [PATCH 150/286] Fixed minor typo in error message --- src/arkode/arkode_arkstep_io.c | 2 +- src/arkode/arkode_erkstep_io.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/arkode/arkode_arkstep_io.c b/src/arkode/arkode_arkstep_io.c index 3ea4a5ce47..7c07248265 100644 --- a/src/arkode/arkode_arkstep_io.c +++ b/src/arkode/arkode_arkstep_io.c @@ -757,7 +757,7 @@ int arkStep_SetDefaults(ARKodeMem ark_mem) if (ark_mem->hadapt_mem->hcontroller == NULL) { arkProcessError(ark_mem, ARK_MEM_FAIL, __LINE__, __func__, __FILE__, - "SUNAdaptControllerPID allocation failure"); + "SUNAdaptController_PID allocation failure"); return (ARK_MEM_FAIL); } ark_mem->hadapt_mem->owncontroller = SUNTRUE; diff --git a/src/arkode/arkode_erkstep_io.c b/src/arkode/arkode_erkstep_io.c index d86a87317a..586d3bf580 100644 --- a/src/arkode/arkode_erkstep_io.c +++ b/src/arkode/arkode_erkstep_io.c @@ -326,7 +326,7 @@ int erkStep_SetDefaults(ARKodeMem ark_mem) if (ark_mem->hadapt_mem->hcontroller == NULL) { arkProcessError(ark_mem, ARK_MEM_FAIL, __LINE__, __func__, __FILE__, - "SUNAdaptControllerPI allocation failure"); + "SUNAdaptController_PI allocation failure"); return (ARK_MEM_FAIL); } ark_mem->hadapt_mem->owncontroller = SUNTRUE; From 54b7be12bc9040c722ccc57b4f327498079685cc Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Thu, 24 Oct 2024 09:46:24 -0500 Subject: [PATCH 151/286] Updated 'average' error accumulation strategy to use timestep-weighted average --- src/arkode/arkode.c | 9 ++++++++- src/arkode/arkode_impl.h | 6 +++--- src/arkode/arkode_io.c | 8 ++++---- 3 files changed, 15 insertions(+), 8 deletions(-) diff --git a/src/arkode/arkode.c b/src/arkode/arkode.c index 222a83a9e1..5c8b9a44be 100644 --- a/src/arkode/arkode.c +++ b/src/arkode/arkode.c @@ -2594,7 +2594,14 @@ int arkCompleteStep(ARKodeMem ark_mem, sunrealtype dsm) { ark_mem->AccumError = SUNMAX(dsm, ark_mem->AccumError); } - else { ark_mem->AccumError += dsm; } + else if (ark_mem->AccumErrorType == ARK_ACCUMERROR_SUM) + { + ark_mem->AccumError += dsm; + } + else /* ARK_ACCUMERROR_AVG */ + { + ark_mem->AccumError += (dsm * ark_mem->h); + } } /* apply user-supplied step postprocessing function (if supplied) */ diff --git a/src/arkode/arkode_impl.h b/src/arkode/arkode_impl.h index 669dd9b1e8..f56e89849e 100644 --- a/src/arkode/arkode_impl.h +++ b/src/arkode/arkode_impl.h @@ -539,9 +539,9 @@ struct ARKodeMemRec sunrealtype terr; /* error in tn for compensated sums */ sunrealtype hold; /* last successful h value used */ sunrealtype tolsf; /* tolerance scale factor (suggestion to user) */ - ARKAccumError AccumErrorType; /* accumulated error estimation type */ - long int AccumErrorStep; /* time step of last accumulated error reset */ - sunrealtype AccumError; /* accumulated error estimate */ + ARKAccumError AccumErrorType; /* accumulated error estimation type */ + sunrealtype AccumErrorStart; /* time of last accumulated error reset */ + sunrealtype AccumError; /* accumulated error estimate */ sunbooleantype VabstolMallocDone; sunbooleantype VRabstolMallocDone; sunbooleantype MallocDone; diff --git a/src/arkode/arkode_io.c b/src/arkode/arkode_io.c index dfa7281a9e..d22ff863a4 100644 --- a/src/arkode/arkode_io.c +++ b/src/arkode/arkode_io.c @@ -1992,8 +1992,8 @@ int ARKodeResetAccumulatedError(void* arkode_mem) } /* Reset value and counter, and return */ - ark_mem->AccumErrorStep = ark_mem->nst; - ark_mem->AccumError = ZERO; + ark_mem->AccumErrorStart = ark_mem->tn; + ark_mem->AccumError = ZERO; return (ARK_SUCCESS); } @@ -2447,7 +2447,7 @@ int ARKodeGetAccumulatedError(void* arkode_mem, sunrealtype* accum_error) /* Get number of steps since last accumulated error reset (set floor of 1 to safeguard against division-by-zero) */ - long int steps = SUNMAX(1, ark_mem->nst - ark_mem->AccumErrorStep); + sunrealtype time_interval = ark_mem->tcur - ark_mem->AccumErrorStart; /* Fill output based on error accumulation type */ if (ark_mem->AccumErrorType == ARK_ACCUMERROR_MAX) @@ -2460,7 +2460,7 @@ int ARKodeGetAccumulatedError(void* arkode_mem, sunrealtype* accum_error) } else if (ark_mem->AccumErrorType == ARK_ACCUMERROR_AVG) { - *accum_error = ark_mem->AccumError * ark_mem->reltol / ((sunrealtype)steps); + *accum_error = ark_mem->AccumError * ark_mem->reltol / time_interval; } else { From 041ff295bc8bfc74a54c9c85ee537fd3c603d734 Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Thu, 24 Oct 2024 09:47:06 -0500 Subject: [PATCH 152/286] Updated MRIStep to specify a default adaptivity strategy (decoupled, I-controller) --- include/arkode/arkode_mristep.h | 1 + src/arkode/arkode_mristep_io.c | 44 ++++++++++++++++++++++++++++++--- 2 files changed, 41 insertions(+), 4 deletions(-) diff --git a/include/arkode/arkode_mristep.h b/include/arkode/arkode_mristep.h index ba6cd831fb..39be4a4407 100644 --- a/include/arkode/arkode_mristep.h +++ b/include/arkode/arkode_mristep.h @@ -22,6 +22,7 @@ #include #include #include +#include #ifdef __cplusplus /* wrapper to enable C++ usage */ extern "C" { diff --git a/src/arkode/arkode_mristep_io.c b/src/arkode/arkode_mristep_io.c index c99e7ff0af..13514336a4 100644 --- a/src/arkode/arkode_mristep_io.c +++ b/src/arkode/arkode_mristep_io.c @@ -286,7 +286,8 @@ int mriStep_SetUserData(ARKodeMem ark_mem, void* user_data) int mriStep_SetDefaults(ARKodeMem ark_mem) { ARKodeMRIStepMem step_mem; - sunindextype lenrw, leniw; + sunindextype Clenrw, Cleniw; + long int lenrw, leniw; int retval; /* access ARKodeMRIStepMem structure */ @@ -319,12 +320,47 @@ int mriStep_SetDefaults(ARKodeMem ark_mem) /* Remove pre-existing coupling table */ if (step_mem->MRIC) { - MRIStepCoupling_Space(step_mem->MRIC, &leniw, &lenrw); - ark_mem->lrw -= lenrw; - ark_mem->liw -= leniw; + MRIStepCoupling_Space(step_mem->MRIC, &Cleniw, &Clenrw); + ark_mem->lrw -= Clenrw; + ark_mem->liw -= Cleniw; MRIStepCoupling_Free(step_mem->MRIC); } step_mem->MRIC = NULL; + + /* Remove pre-existing SUNAdaptController object, and replace with "I" */ + if (ark_mem->hadapt_mem->owncontroller) + { + retval = SUNAdaptController_Space(ark_mem->hadapt_mem->hcontroller, &lenrw, + &leniw); + if (retval == SUN_SUCCESS) + { + ark_mem->liw -= leniw; + ark_mem->lrw -= lenrw; + } + retval = SUNAdaptController_Destroy(ark_mem->hadapt_mem->hcontroller); + ark_mem->hadapt_mem->owncontroller = SUNFALSE; + if (retval != SUN_SUCCESS) + { + arkProcessError(ark_mem, ARK_MEM_FAIL, __LINE__, __func__, __FILE__, + "SUNAdaptController_Destroy failure"); + return (ARK_MEM_FAIL); + } + } + ark_mem->hadapt_mem->hcontroller = SUNAdaptController_I(ark_mem->sunctx); + if (ark_mem->hadapt_mem->hcontroller == NULL) + { + arkProcessError(ark_mem, ARK_MEM_FAIL, __LINE__, __func__, __FILE__, + "SUNAdaptController_I allocation failure"); + return (ARK_MEM_FAIL); + } + ark_mem->hadapt_mem->owncontroller = SUNTRUE; + retval = SUNAdaptController_Space(ark_mem->hadapt_mem->hcontroller, &lenrw, + &leniw); + if (retval == SUN_SUCCESS) + { + ark_mem->liw += leniw; + ark_mem->lrw += lenrw; + } return (ARK_SUCCESS); } From 80da66187b623b42dafabe5150a05e39ad67a3f2 Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Thu, 24 Oct 2024 09:53:54 -0500 Subject: [PATCH 153/286] Spelling --- doc/shared/sunadaptcontroller/SUNAdaptController_MRIHTol.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/shared/sunadaptcontroller/SUNAdaptController_MRIHTol.rst b/doc/shared/sunadaptcontroller/SUNAdaptController_MRIHTol.rst index 1827fdd649..6d1caaf1f7 100644 --- a/doc/shared/sunadaptcontroller/SUNAdaptController_MRIHTol.rst +++ b/doc/shared/sunadaptcontroller/SUNAdaptController_MRIHTol.rst @@ -164,7 +164,7 @@ controllers, there are a few steps required when setting this up in an applicati #. *Create an inner stepper object to solve the fast (inner) IVP* -#. Configure the inner stepper to use temporal adaptivity. For exaple, when using +#. Configure the inner stepper to use temporal adaptivity. For example, when using an ARKODE inner stepper and the :c:func:`ARKodeCreateMRIStepInnerStepper` function, then either use its default adaptivity approach or supply a single-rate SUNAdaptController object, e.g. From fce503545ea284c9a8ddb09ba9a7d194018a4d49 Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Thu, 24 Oct 2024 09:55:30 -0500 Subject: [PATCH 154/286] Fixed unused variable 'error' --- .../arkode/CXX_serial/ark_test_accumerror_brusselator.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/test/unit_tests/arkode/CXX_serial/ark_test_accumerror_brusselator.cpp b/test/unit_tests/arkode/CXX_serial/ark_test_accumerror_brusselator.cpp index 6091dbc40d..b9763bf765 100644 --- a/test/unit_tests/arkode/CXX_serial/ark_test_accumerror_brusselator.cpp +++ b/test/unit_tests/arkode/CXX_serial/ark_test_accumerror_brusselator.cpp @@ -156,7 +156,6 @@ int main(int argc, char* argv[]) SUNLinearSolver LS = NULL; // empty linear solver object UserData udata; // user-data structure sunrealtype* ydata = NULL; - sunrealtype* yrefdata = NULL; udata.ep = SUN_RCONST(0.0004); // stiffness parameter udata.Npart = 20; // partition size From db383592053df46bb1a3cc8e0574bdbd256efc07 Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Thu, 24 Oct 2024 10:04:21 -0500 Subject: [PATCH 155/286] Formatting --- src/arkode/arkode.c | 5 +--- src/arkode/arkode_impl.h | 4 +-- .../ark_test_accumerror_brusselator.cpp | 30 +++++++++---------- .../CXX_serial/ark_test_accumerror_kpr.cpp | 4 +-- .../ark_test_brusselator_mriadapt.cpp | 20 ++++++------- .../CXX_serial/ark_test_kpr_mriadapt.cpp | 23 +++++++------- .../ark_test_slowerror_brusselator.cpp | 18 +++++------ .../CXX_serial/ark_test_slowerror_kpr.cpp | 10 +++---- .../ark_test_slowerror_polynomial.cpp | 12 ++++---- .../C_serial/ark_test_erkstepsetforcing.c | 8 ++--- 10 files changed, 66 insertions(+), 68 deletions(-) diff --git a/src/arkode/arkode.c b/src/arkode/arkode.c index 5c8b9a44be..a663c1f93a 100644 --- a/src/arkode/arkode.c +++ b/src/arkode/arkode.c @@ -2598,10 +2598,7 @@ int arkCompleteStep(ARKodeMem ark_mem, sunrealtype dsm) { ark_mem->AccumError += dsm; } - else /* ARK_ACCUMERROR_AVG */ - { - ark_mem->AccumError += (dsm * ark_mem->h); - } + else /* ARK_ACCUMERROR_AVG */ { ark_mem->AccumError += (dsm * ark_mem->h); } } /* apply user-supplied step postprocessing function (if supplied) */ diff --git a/src/arkode/arkode_impl.h b/src/arkode/arkode_impl.h index f56e89849e..029ca962a6 100644 --- a/src/arkode/arkode_impl.h +++ b/src/arkode/arkode_impl.h @@ -540,8 +540,8 @@ struct ARKodeMemRec sunrealtype hold; /* last successful h value used */ sunrealtype tolsf; /* tolerance scale factor (suggestion to user) */ ARKAccumError AccumErrorType; /* accumulated error estimation type */ - sunrealtype AccumErrorStart; /* time of last accumulated error reset */ - sunrealtype AccumError; /* accumulated error estimate */ + sunrealtype AccumErrorStart; /* time of last accumulated error reset */ + sunrealtype AccumError; /* accumulated error estimate */ sunbooleantype VabstolMallocDone; sunbooleantype VRabstolMallocDone; sunbooleantype MallocDone; diff --git a/test/unit_tests/arkode/CXX_serial/ark_test_accumerror_brusselator.cpp b/test/unit_tests/arkode/CXX_serial/ark_test_accumerror_brusselator.cpp index b9763bf765..64835cf371 100644 --- a/test/unit_tests/arkode/CXX_serial/ark_test_accumerror_brusselator.cpp +++ b/test/unit_tests/arkode/CXX_serial/ark_test_accumerror_brusselator.cpp @@ -152,12 +152,12 @@ int main(int argc, char* argv[]) N_Vector* yref = NULL; // empty vectors for storing reference solution void* arkode_mem = NULL; // empty ARKStep memory structure void* arkode_ref = NULL; // empty ARKStep memory structure for reference solution - SUNMatrix A = NULL; // empty matrix for solver - SUNLinearSolver LS = NULL; // empty linear solver object - UserData udata; // user-data structure - sunrealtype* ydata = NULL; - udata.ep = SUN_RCONST(0.0004); // stiffness parameter - udata.Npart = 20; // partition size + SUNMatrix A = NULL; // empty matrix for solver + SUNLinearSolver LS = NULL; // empty linear solver object + UserData udata; // user-data structure + sunrealtype* ydata = NULL; + udata.ep = SUN_RCONST(0.0004); // stiffness parameter + udata.Npart = 20; // partition size // // Initialization @@ -261,9 +261,9 @@ int main(int argc, char* argv[]) if (check_retval((void*)ydata, "N_VGetArrayPointer", 0)) return 1; // Generate reference solution - ydata[0] = u0; - ydata[1] = v0; - ydata[2] = w0; + ydata[0] = u0; + ydata[1] = v0; + ydata[2] = w0; arkode_ref = ARKStepCreate(fn, NULL, T0, y, ctx); if (check_retval((void*)arkode_ref, "ARKStepCreate", 0)) return 1; retval = ARKodeSetUserData(arkode_ref, (void*)&udata); @@ -457,8 +457,8 @@ static int adaptive_run(void* arkode_mem, N_Vector y, sunrealtype T0, if (check_retval(&retval, "ARKodeGetNumSteps", 1)) break; // Compute/print solution error - sunrealtype* ydata = N_VGetArrayPointer(y); - sunrealtype* yrefdata = N_VGetArrayPointer(yref[ipart + 1]); + sunrealtype* ydata = N_VGetArrayPointer(y); + sunrealtype* yrefdata = N_VGetArrayPointer(yref[ipart + 1]); const sunrealtype udsm = abs(ydata[0] - yrefdata[0]) / (abstol + rtols[irtol] * abs(yrefdata[0])); const sunrealtype vdsm = abs(ydata[1] - yrefdata[1]) / @@ -555,8 +555,8 @@ static int fixed_run(void* arkode_mem, N_Vector y, sunrealtype T0, sunrealtype T if (check_retval(&retval, "ARKodeGetNumSteps", 1)) break; // Compute/print solution error - sunrealtype* ydata = N_VGetArrayPointer(y); - sunrealtype* yrefdata = N_VGetArrayPointer(yref[ipart + 1]); + sunrealtype* ydata = N_VGetArrayPointer(y); + sunrealtype* yrefdata = N_VGetArrayPointer(yref[ipart + 1]); const sunrealtype udsm = abs(ydata[0] - yrefdata[0]) / (abstol + reltol * abs(yrefdata[0])); const sunrealtype vdsm = abs(ydata[1] - yrefdata[1]) / @@ -638,8 +638,8 @@ static int fixed_run(void* arkode_mem, N_Vector y, sunrealtype T0, sunrealtype T dsm_est[ipart] = reltol * N_VWrmsNorm(y2, ewt); Nsteps[ipart] += nsteps2; - sunrealtype* ydata = N_VGetArrayPointer(y); - sunrealtype* yrefdata = N_VGetArrayPointer(yref[ipart + 1]); + sunrealtype* ydata = N_VGetArrayPointer(y); + sunrealtype* yrefdata = N_VGetArrayPointer(yref[ipart + 1]); const sunrealtype udsm = abs(ydata[0] - yrefdata[0]) / (abstol + reltol * abs(yrefdata[0])); const sunrealtype vdsm = abs(ydata[1] - yrefdata[1]) / diff --git a/test/unit_tests/arkode/CXX_serial/ark_test_accumerror_kpr.cpp b/test/unit_tests/arkode/CXX_serial/ark_test_accumerror_kpr.cpp index 3d027981c2..472b7453c9 100644 --- a/test/unit_tests/arkode/CXX_serial/ark_test_accumerror_kpr.cpp +++ b/test/unit_tests/arkode/CXX_serial/ark_test_accumerror_kpr.cpp @@ -668,8 +668,8 @@ static sunrealtype vtrue(sunrealtype t, UserData& udata) static int Ytrue(sunrealtype t, N_Vector y, UserData& udata) { sunrealtype* ydata = N_VGetArrayPointer(y); - ydata[0] = utrue(t); - ydata[1] = vtrue(t, udata); + ydata[0] = utrue(t); + ydata[1] = vtrue(t, udata); return (0); } diff --git a/test/unit_tests/arkode/CXX_serial/ark_test_brusselator_mriadapt.cpp b/test/unit_tests/arkode/CXX_serial/ark_test_brusselator_mriadapt.cpp index cf9f8593eb..63e2b4b39b 100644 --- a/test/unit_tests/arkode/CXX_serial/ark_test_brusselator_mriadapt.cpp +++ b/test/unit_tests/arkode/CXX_serial/ark_test_brusselator_mriadapt.cpp @@ -265,11 +265,11 @@ int main(int argc, char* argv[]) if (check_ptr((void*)yref, "N_VNew_Serial")) return 1; // Set initial conditions - sunrealtype* ydata = N_VGetArrayPointer(y); + sunrealtype* ydata = N_VGetArrayPointer(y); sunrealtype* yrefdata = N_VGetArrayPointer(yref); - ydata[0] = SUN_RCONST(1.2); - ydata[1] = SUN_RCONST(3.1); - ydata[2] = SUN_RCONST(3.0); + ydata[0] = SUN_RCONST(1.2); + ydata[1] = SUN_RCONST(3.1); + ydata[2] = SUN_RCONST(3.0); N_VScale(ONE, y, yref); // Create and configure reference solver object @@ -709,12 +709,12 @@ int main(int argc, char* argv[]) verrtot += verr * verr; werrtot += werr * werr; errtot += uerr * uerr + verr * verr + werr * werr; - accuracy = std::max(accuracy, uerr / std::abs(opts.atol + - opts.rtol * yrefdata[0])); - accuracy = std::max(accuracy, verr / std::abs(opts.atol + - opts.rtol * yrefdata[1])); - accuracy = std::max(accuracy, werr / std::abs(opts.atol + - opts.rtol * yrefdata[2])); + accuracy = std::max(accuracy, + uerr / std::abs(opts.atol + opts.rtol * yrefdata[0])); + accuracy = std::max(accuracy, + verr / std::abs(opts.atol + opts.rtol * yrefdata[1])); + accuracy = std::max(accuracy, + werr / std::abs(opts.atol + opts.rtol * yrefdata[2])); // Periodically output current results to screen if (t >= tout) diff --git a/test/unit_tests/arkode/CXX_serial/ark_test_kpr_mriadapt.cpp b/test/unit_tests/arkode/CXX_serial/ark_test_kpr_mriadapt.cpp index fec9619a3d..e6eb0ac097 100644 --- a/test/unit_tests/arkode/CXX_serial/ark_test_kpr_mriadapt.cpp +++ b/test/unit_tests/arkode/CXX_serial/ark_test_kpr_mriadapt.cpp @@ -681,7 +681,8 @@ int main(int argc, char* argv[]) printf(" t u v uerr verr\n"); printf(" ------------------------------------------------------\n"); printf(" %10.6" FSYM " %10.6" FSYM " %10.6" FSYM " %.2" ESYM " %.2" ESYM - "\n", t, ydata[0], ydata[1], uerr, verr); + "\n", + t, ydata[0], ydata[1], uerr, verr); while (Tf - t > SUN_RCONST(1.0e-8)) { // reset reference solver so that it begins with identical state @@ -713,10 +714,10 @@ int main(int argc, char* argv[]) uerrtot += uerr * uerr; verrtot += verr * verr; errtot += uerr * uerr + verr * verr; - accuracy = std::max(accuracy, uerr / std::abs(opts.atol + - opts.rtol * yrefdata[0])); - accuracy = std::max(accuracy, verr / std::abs(opts.atol + - opts.rtol * yrefdata[1])); + accuracy = std::max(accuracy, + uerr / std::abs(opts.atol + opts.rtol * yrefdata[0])); + accuracy = std::max(accuracy, + verr / std::abs(opts.atol + opts.rtol * yrefdata[1])); // Periodically output current results to screen if (t >= tout) @@ -843,8 +844,8 @@ static int fs(sunrealtype t, N_Vector y, N_Vector ydot, void* user_data) // fill in the RHS function: // [G e]*[(-2+u^2-r(t))/(2*u)] + [rdot(t)/(2u)] // [0 0] [(-2+v^2-s(t))/(2*v)] [ 0 ] - tmp1 = (-TWO + u * u - r(t, opts)) / (TWO * u); - tmp2 = (-TWO + v * v - s(t, opts)) / (TWO * v); + tmp1 = (-TWO + u * u - r(t, opts)) / (TWO * u); + tmp2 = (-TWO + v * v - s(t, opts)) / (TWO * v); dydata[0] = opts->G * tmp1 + opts->e * tmp2 + rdot(t, opts) / (TWO * u); dydata[1] = ZERO; @@ -904,8 +905,8 @@ static int fn(sunrealtype t, N_Vector y, N_Vector ydot, void* user_data) // fill in the RHS function: // [G e]*[(-2+u^2-r(t))/(2*u)] + [rdot(t)/(2u)] // [e -1] [(-2+v^2-s(t))/(2*v)] [sdot(t)/(2v)] - tmp1 = (-TWO + u * u - r(t, opts)) / (TWO * u); - tmp2 = (-TWO + v * v - s(t, opts)) / (TWO * v); + tmp1 = (-TWO + u * u - r(t, opts)) / (TWO * u); + tmp2 = (-TWO + v * v - s(t, opts)) / (TWO * v); dydata[0] = opts->G * tmp1 + opts->e * tmp2 + rdot(t, opts) / (TWO * u); dydata[1] = opts->e * tmp1 - tmp2 + sdot(t, opts) / (TWO * v); @@ -1022,8 +1023,8 @@ static sunrealtype vtrue(sunrealtype t, Options* opts) static int Ytrue(sunrealtype t, N_Vector y, Options* opts) { sunrealtype* ydata = N_VGetArrayPointer(y); - ydata[0] = utrue(t, opts); - ydata[1] = vtrue(t, opts); + ydata[0] = utrue(t, opts); + ydata[1] = vtrue(t, opts); return (0); } diff --git a/test/unit_tests/arkode/CXX_serial/ark_test_slowerror_brusselator.cpp b/test/unit_tests/arkode/CXX_serial/ark_test_slowerror_brusselator.cpp index f591a14085..8b74a377fe 100644 --- a/test/unit_tests/arkode/CXX_serial/ark_test_slowerror_brusselator.cpp +++ b/test/unit_tests/arkode/CXX_serial/ark_test_slowerror_brusselator.cpp @@ -252,7 +252,7 @@ int main(int argc, char* argv[]) if (check_retval((void*)y, "N_VNew_Serial", 0)) return 1; N_Vector* yref = N_VCloneVectorArray(udata.Npart + 1, y); if (check_retval((void*)yref, "N_VNew_Serial", 0)) return 1; - sunrealtype *ydata = N_VGetArrayPointer(y); + sunrealtype* ydata = N_VGetArrayPointer(y); if (check_retval((void*)ydata, "N_VGetArrayPointer", 0)) return 1; ydata[0] = u0; ydata[1] = v0; @@ -282,9 +282,9 @@ int main(int argc, char* argv[]) } // Set up fast ERKStep integrator as fifth-order adaptive method - ydata[0] = u0; - ydata[1] = v0; - ydata[2] = w0; + ydata[0] = u0; + ydata[1] = v0; + ydata[2] = w0; void* inner_arkode_mem = ERKStepCreate(f0, T0, y, ctx); if (check_retval((void*)inner_arkode_mem, "ERKStepCreate", 0)) return 1; retval = ARKodeSetOrder(inner_arkode_mem, 5); @@ -491,11 +491,11 @@ static int run_test(void* mristep_mem, void* arkode_ref, N_Vector y, int retval; sunrealtype hpart = (Tf - T0) / udata.Npart; sunrealtype t, t2; - N_Vector y2 = N_VClone(y); - N_Vector ele = N_VClone(y); - N_Vector ewt = N_VClone(y); - N_Vector vtemp = N_VClone(y); - sunrealtype* ydata = N_VGetArrayPointer(y); + N_Vector y2 = N_VClone(y); + N_Vector ele = N_VClone(y); + N_Vector ewt = N_VClone(y); + N_Vector vtemp = N_VClone(y); + sunrealtype* ydata = N_VGetArrayPointer(y); sunrealtype* y2data = N_VGetArrayPointer(y2); // Set storage for errors diff --git a/test/unit_tests/arkode/CXX_serial/ark_test_slowerror_kpr.cpp b/test/unit_tests/arkode/CXX_serial/ark_test_slowerror_kpr.cpp index a3cf3288c6..583be495ef 100644 --- a/test/unit_tests/arkode/CXX_serial/ark_test_slowerror_kpr.cpp +++ b/test/unit_tests/arkode/CXX_serial/ark_test_slowerror_kpr.cpp @@ -426,9 +426,9 @@ static int run_test(void* mristep_mem, N_Vector y, sunrealtype T0, int retval; sunrealtype hpart = (Tf - T0) / udata.Npart; sunrealtype t; - N_Vector ele = N_VClone(y); - N_Vector ewt = N_VClone(y); - N_Vector vtemp = N_VClone(y); + N_Vector ele = N_VClone(y); + N_Vector ewt = N_VClone(y); + N_Vector vtemp = N_VClone(y); sunrealtype* ydata = N_VGetArrayPointer(y); // Set storage for errors @@ -515,8 +515,8 @@ static sunrealtype vtrue(sunrealtype t, UserData& udata) static int Ytrue(sunrealtype t, N_Vector y, UserData& udata) { sunrealtype* ydata = N_VGetArrayPointer(y); - ydata[0] = utrue(t); - ydata[1] = vtrue(t, udata); + ydata[0] = utrue(t); + ydata[1] = vtrue(t, udata); return (0); } diff --git a/test/unit_tests/arkode/CXX_serial/ark_test_slowerror_polynomial.cpp b/test/unit_tests/arkode/CXX_serial/ark_test_slowerror_polynomial.cpp index b624962617..96541382b2 100644 --- a/test/unit_tests/arkode/CXX_serial/ark_test_slowerror_polynomial.cpp +++ b/test/unit_tests/arkode/CXX_serial/ark_test_slowerror_polynomial.cpp @@ -240,9 +240,9 @@ static int f0(sunrealtype t, N_Vector y, N_Vector ydot, void* user_data) static int fn(sunrealtype t, N_Vector y, N_Vector ydot, void* user_data) { // fill in the RHS function and return with success - UserData* udata = (UserData*)user_data; + UserData* udata = (UserData*)user_data; sunrealtype* dydata = N_VGetArrayPointer(ydot); - dydata[0] = udata->a * t * t + udata->b * t + udata->c; + dydata[0] = udata->a * t * t + udata->b * t + udata->c; return 0; } @@ -265,9 +265,9 @@ static int run_test(void* mristep_mem, N_Vector y, sunrealtype T0, // Reused variables int retval; sunrealtype t; - N_Vector vtemp = N_VClone(y); - N_Vector ele = N_VClone(y); - N_Vector ewt = N_VClone(y); + N_Vector vtemp = N_VClone(y); + N_Vector ele = N_VClone(y); + N_Vector ewt = N_VClone(y); sunrealtype* ydata = N_VGetArrayPointer(y); sunrealtype* vdata = N_VGetArrayPointer(vtemp); @@ -352,7 +352,7 @@ static int run_test(void* mristep_mem, N_Vector y, sunrealtype T0, static int Ytrue(sunrealtype t, N_Vector y, UserData& udata) { sunrealtype* ydata = N_VGetArrayPointer(y); - ydata[0] = udata.a / SUN_RCONST(3.0) * t * t * t + + ydata[0] = udata.a / SUN_RCONST(3.0) * t * t * t + udata.b / SUN_RCONST(2.0) * t * t + udata.c * t + ONE; return (0); } diff --git a/test/unit_tests/arkode/C_serial/ark_test_erkstepsetforcing.c b/test/unit_tests/arkode/C_serial/ark_test_erkstepsetforcing.c index 00f70bed66..df52e6e9c8 100644 --- a/test/unit_tests/arkode/C_serial/ark_test_erkstepsetforcing.c +++ b/test/unit_tests/arkode/C_serial/ark_test_erkstepsetforcing.c @@ -50,8 +50,8 @@ static int check_flag(void* flagvalue, const char* funcname, int opt); /* Private function to check computed solution */ static int compute_ans(sunrealtype t, sunrealtype tshift, sunrealtype tscale, N_Vector* forcing, int order, N_Vector ans); -static int compute_error(N_Vector y, N_Vector ans, N_Vector tmp, sunrealtype rtol, - sunrealtype atol); +static int compute_error(N_Vector y, N_Vector ans, N_Vector tmp, + sunrealtype rtol, sunrealtype atol); /* Main Program */ int main(int argc, char* argv[]) @@ -352,8 +352,8 @@ static int compute_ans(sunrealtype t, sunrealtype tshift, sunrealtype tscale, } /* compure the weighted max norm of the difference of two vectors */ -static int compute_error(N_Vector y, N_Vector ans, N_Vector tmp, sunrealtype rtol, - sunrealtype atol) +static int compute_error(N_Vector y, N_Vector ans, N_Vector tmp, + sunrealtype rtol, sunrealtype atol) { int status; /* success (0) or failure (1) flag */ sunrealtype error; From 990cb24da7c6b19d0edf193b33f699bfe4326738 Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Thu, 24 Oct 2024 10:16:54 -0500 Subject: [PATCH 156/286] Removed ark_test_erkstepsetforcing --- .../unit_tests/arkode/C_serial/CMakeLists.txt | 1 - .../C_serial/ark_test_erkstepsetforcing.c | 386 ------------------ 2 files changed, 387 deletions(-) delete mode 100644 test/unit_tests/arkode/C_serial/ark_test_erkstepsetforcing.c diff --git a/test/unit_tests/arkode/C_serial/CMakeLists.txt b/test/unit_tests/arkode/C_serial/CMakeLists.txt index 70363d8566..6794a213b4 100644 --- a/test/unit_tests/arkode/C_serial/CMakeLists.txt +++ b/test/unit_tests/arkode/C_serial/CMakeLists.txt @@ -25,7 +25,6 @@ set(ARKODE_unit_tests "ark_test_arkstepsetforcing\;1 3 2.0 10.0" "ark_test_arkstepsetforcing\;1 3 2.0 10.0 2.0 8.0" "ark_test_arkstepsetforcing\;1 3 2.0 10.0 1.0 5.0" - "ark_test_erkstepsetforcing\;1 0" "ark_test_getuserdata\;" "ark_test_innerstepper\;" "ark_test_interp\;-100" diff --git a/test/unit_tests/arkode/C_serial/ark_test_erkstepsetforcing.c b/test/unit_tests/arkode/C_serial/ark_test_erkstepsetforcing.c deleted file mode 100644 index df52e6e9c8..0000000000 --- a/test/unit_tests/arkode/C_serial/ark_test_erkstepsetforcing.c +++ /dev/null @@ -1,386 +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 - * ----------------------------------------------------------------------------- - * Unit test for erkStep_SetInnerForcing - * - * erkStep_SetInnerForcing is used to provide a polynomial forcing term in - * ERKStep when it is used as the inner integrator under MRIStep. To check that - * the forcing is computed and applied correctly we integrate an ODE in time - * with ERKStep where the RHS consists of only the polynomial forcing term. The - * solution should be exact when the method order is greater than or equal to - * the polynomial order. - * ---------------------------------------------------------------------------*/ - -#include -#include -#include - -#include "arkode/arkode_erkstep.h" -#include "arkode/arkode_erkstep_impl.h" -#include "nvector/nvector_serial.h" -#include "sundials/sundials_math.h" -#include "sundials/sundials_types.h" - -#if defined(SUNDIALS_EXTENDED_PRECISION) -#define GSYM "Lg" -#define ESYM "Le" -#define FSYM "Lf" -#else -#define GSYM "g" -#define ESYM "e" -#define FSYM "f" -#endif - -/* User-supplied Functions Called by the Solver */ -static int f(sunrealtype t, N_Vector y, N_Vector ydot, void* user_data); - -/* Private function to check function return values */ -static int check_flag(void* flagvalue, const char* funcname, int opt); - -/* Private function to check computed solution */ -static int compute_ans(sunrealtype t, sunrealtype tshift, sunrealtype tscale, - N_Vector* forcing, int order, N_Vector ans); -static int compute_error(N_Vector y, N_Vector ans, N_Vector tmp, - sunrealtype rtol, sunrealtype atol); - -/* Main Program */ -int main(int argc, char* argv[]) -{ - SUNContext sunctx = NULL; - - /* default input values */ - sunindextype NEQ = 1; /* number of dependent vars. */ - int order = 3; /* order of polynomial forcing */ - sunrealtype T0 = SUN_RCONST(0.0); /* initial time */ - sunrealtype Tf = SUN_RCONST(1.0); /* final time */ - sunrealtype tshift = T0; /* time shift for normalization */ - sunrealtype tscale = Tf; /* time scale for normalization */ - - /* tolerances */ - sunrealtype reltol = SUNRsqrt(SUN_UNIT_ROUNDOFF); - sunrealtype abstol = SUNRsqrt(SUN_UNIT_ROUNDOFF) / 100; - - /* general problem variables */ - int flag; /* reusable error-checking flag */ - N_Vector y = NULL; /* vector for storing the computed solution */ - N_Vector ans = NULL; /* vector for storing the true solution */ - N_Vector tmp = NULL; /* temporary workspace vector */ - N_Vector* forcing = NULL; /* array of forcing vectors */ - void* arkode_mem = NULL; /* ARKode memory structure */ - int i, j; /* loop counters */ - sunrealtype tret; /* integrator return time */ - sunrealtype* data; /* array for accessing vector data */ - long int nst, nst_a; /* number of integrator steps */ - long int mxsteps = 100000; /* max steps before output */ - - /* check inputs */ - if (argc > 1) - { - NEQ = (sunindextype)atol(argv[1]); - if (NEQ <= 0) - { - printf("ERROR: The problem size must be a positive integer\n"); - return (1); - } - } - - if (argc > 2) - { - order = atoi(argv[2]); - if (order < 0) - { - printf("ERROR: The polynomial order must be a non-negative integer\n"); - return (1); - } - } - - if (argc > 3) - { - if (argc < 5) - { - printf("ERROR: Both the initial and final time are required\n"); - return (1); - } - T0 = SUNStrToReal(argv[3]); - Tf = SUNStrToReal(argv[4]); - if (SUNRabs(T0) >= SUNRabs(Tf)) - { - printf("ERROR: |T0| must be less than |Tf|\n"); - return (1); - } - } - - if (argc > 5) - { - if (argc < 7) - { - printf("ERROR: Both tshift and tscale are required\n"); - return (1); - } - tshift = SUNStrToReal(argv[5]); - tscale = SUNStrToReal(argv[6]); - if (SUNRabs(tscale) < TINY) - { - printf("ERROR: |tscale| must be greater than %" GSYM "\n", TINY); - return (1); - } - } - - /* Output test setup */ - printf("\nerkStep_SetInnerForcing unit test:\n"); - printf(" NEQ = %li\n", (long int)NEQ); - printf(" order = %i\n", order); - printf(" t0 = %.1" GSYM "\n", T0); - printf(" tf = %.1" GSYM "\n", Tf); - printf(" tshift = %.1" GSYM "\n", tshift); - printf(" tscale = %.1" GSYM "\n", tscale); - printf(" reltol = %.1" ESYM "\n", reltol); - printf(" abstol = %.1" ESYM "\n\n", abstol); - - /* Create the SUNDIALS context object for this simulation. */ - SUNContext_Create(NULL, &sunctx); - - /* Create solution vector and initialize to zero */ - y = N_VNew_Serial(NEQ, sunctx); - if (check_flag((void*)y, "N_VNew_Serial", 0)) return 1; - - ans = N_VClone(y); - if (check_flag((void*)ans, "N_VClone", 0)) return 1; - - tmp = N_VClone(y); - if (check_flag((void*)tmp, "N_VClone", 0)) return 1; - - /* allocate vector array for polynomial forcing */ - forcing = N_VCloneVectorArray(order + 1, y); - if (check_flag((void*)forcing, "N_VCloneVectorArray", 0)) return 1; - for (i = 0; i < order + 1; i++) - { - if (check_flag((void*)forcing[i], "N_VCloneVectorArray", 0)) return 1; - } - - /* fill forcing vectors with random data */ - for (i = 0; i < order + 1; i++) - { - data = N_VGetArrayPointer(forcing[i]); - for (j = 0; j < NEQ; j++) - { - data[j] = (sunrealtype)rand() / (sunrealtype)RAND_MAX; - } - } - - /* compute the true solution */ - flag = compute_ans(Tf, tshift, tscale, forcing, order, ans); - if (check_flag(&flag, "compute_ans", 1)) return 1; - - printf("True solution:\n"); - N_VPrint_Serial(ans); - - /* --------------------------------------------------------------------------- - * explicit test - * -------------------------------------------------------------------------*/ - - /* initialize solution vector */ - flag = compute_ans(T0, tshift, tscale, forcing, order, y); - if (check_flag(&flag, "compute_ans", 1)) return 1; - - /* Create ARKode mem structure */ - arkode_mem = ERKStepCreate(f, T0, y, sunctx); - if (check_flag((void*)arkode_mem, "ERKStepCreate", 0)) return 1; - - /* Specify tolerances */ - flag = ARKodeSStolerances(arkode_mem, reltol, abstol); - if (check_flag(&flag, "ARKodeSStolerances", 1)) return 1; - - /* Set stop time */ - flag = ARKodeSetStopTime(arkode_mem, Tf); - if (check_flag(&flag, "ARKodeSetStopTime", 1)) return 1; - - /* Set max steps before output */ - flag = ARKodeSetMaxNumSteps(arkode_mem, mxsteps); - if (check_flag(&flag, "ARKodeSetMaxNumSteps", 1)) return 1; - - /* Set forcing */ - flag = erkStep_SetInnerForcing(arkode_mem, tshift, tscale, forcing, order + 1); - if (check_flag(&flag, "erkStep_SetInnerForcing", 1)) return 1; - - /* Integrate the problem */ - flag = ARKodeEvolve(arkode_mem, Tf, y, &tret, ARK_NORMAL); - - /* check for errors */ - if (flag < 0) - { - fprintf(stderr, "ARKodeEvolve failure, flag = %d\n", flag); - return 1; - } - - /* get some integrator stats */ - flag = ARKodeGetNumSteps(arkode_mem, &nst); - check_flag(&flag, "ARKodeGetNumSteps", 1); - - flag = ARKodeGetNumStepAttempts(arkode_mem, &nst_a); - check_flag(&flag, "ARKodeGetNumStepAttempts", 1); - - printf("Stats:\n"); - printf("Steps = %li (attempted = %li)\n\n", nst, nst_a); - - /* Free integrator memory */ - ARKodeFree(&arkode_mem); - arkode_mem = NULL; - - /* print solution */ - printf("Explicit solution:\n"); - N_VPrint_Serial(y); - - /* check the solution error */ - flag = compute_error(y, ans, tmp, reltol, abstol); - if (flag != 0) return (1); - - /* --------------------------------------------------------------------------- - * Clean up and return - * -------------------------------------------------------------------------*/ - - N_VDestroy(y); /* Free vectors */ - N_VDestroy(ans); - N_VDestroy(tmp); - - N_VDestroyVectorArray(forcing, order + 1); - - SUNContext_Free(&sunctx); - return flag; -} - -/*------------------------------- - * Functions called by the solver - *-------------------------------*/ - -/* ODE RHS function */ -static int f(sunrealtype t, N_Vector y, N_Vector ydot, void* user_data) -{ - N_VConst(ZERO, ydot); - return 0; -} - -/*------------------------------- - * Private helper functions - *-------------------------------*/ - -/* Check function return value... - opt == 0 means SUNDIALS function allocates memory so check if - returned NULL pointer - opt == 1 means SUNDIALS function returns a flag so check if - flag < 0 - opt == 2 means function allocates memory so check if returned - NULL pointer -*/ -static int check_flag(void* flagvalue, const char* funcname, int opt) -{ - int* errflag; - - /* Check if SUNDIALS function returned NULL pointer - no memory allocated */ - if (opt == 0 && flagvalue == NULL) - { - fprintf(stderr, "\nSUNDIALS_ERROR: %s() failed - returned NULL pointer\n\n", - funcname); - return 1; - } - - /* Check if flag < 0 */ - else if (opt == 1) - { - errflag = (int*)flagvalue; - if (*errflag < 0) - { - fprintf(stderr, "\nSUNDIALS_ERROR: %s() failed with flag = %d\n\n", - funcname, *errflag); - return 1; - } - } - - /* Check if function returned NULL pointer - no memory allocated */ - else if (opt == 2 && flagvalue == NULL) - { - fprintf(stderr, "\nMEMORY_ERROR: %s() failed - returned NULL pointer\n\n", - funcname); - return 1; - } - - return 0; -} - -/* computed the true solution at a given time */ -static int compute_ans(sunrealtype t, sunrealtype tshift, sunrealtype tscale, - N_Vector* forcing, int order, N_Vector ans) -{ - int i; - sunrealtype tau; - N_Vector* vecs; - sunrealtype* vals; - - vals = NULL; - vals = (sunrealtype*)calloc(order + 1, sizeof(sunrealtype)); - if (vals == NULL) return (1); - - vecs = NULL; - vecs = (N_Vector*)calloc(order + 1, sizeof(N_Vector)); - if (vecs == NULL) return (1); - - /* compute normalized time */ - tau = (t - tshift) / tscale; - - /* compute true solution */ - for (i = 0; i < order + 1; i++) - { - vals[i] = ((SUNRpowerI(tau, i + 1)) / (i + 1)) * tscale; - vecs[i] = forcing[i]; - } - N_VLinearCombination(order + 1, vals, vecs, ans); - - free(vals); - free(vecs); - - return (0); -} - -/* compure the weighted max norm of the difference of two vectors */ -static int compute_error(N_Vector y, N_Vector ans, N_Vector tmp, - sunrealtype rtol, sunrealtype atol) -{ - int status; /* success (0) or failure (1) flag */ - sunrealtype error; - - /* compute the error in y */ - N_VLinearSum(ONE, y, -ONE, ans, y); - - /* compute error weights */ - N_VAbs(ans, tmp); - N_VScale(rtol, tmp, tmp); - N_VAddConst(tmp, atol, tmp); - N_VInv(tmp, tmp); - - /* compute weighted max norm */ - N_VProd(tmp, y, y); - error = N_VMaxNorm(y); - - /* is the solution within the tolerances? */ - status = (error < ONE) ? 0 : 1; - - if (status) - fprintf(stdout, "ERROR: Test failed with wmax error = %" GSYM "\n\n", error); - else - fprintf(stdout, "SUCCESS: Test passed with wmax error = %" GSYM "\n\n", - error); - - return (status); -} - -/*---- end of file ----*/ From 704a6c035488d90592db7ab513e72e9bef69024f Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Thu, 24 Oct 2024 10:21:55 -0500 Subject: [PATCH 157/286] Moved one failing ark_kpr_Mt example back to double-precision testing only --- examples/arkode/CXX_serial/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/arkode/CXX_serial/CMakeLists.txt b/examples/arkode/CXX_serial/CMakeLists.txt index 51d5582a97..be64e1d748 100644 --- a/examples/arkode/CXX_serial/CMakeLists.txt +++ b/examples/arkode/CXX_serial/CMakeLists.txt @@ -28,7 +28,7 @@ set(ARKODE_examples "ark_kpr_Mt.cpp\;0 4 1\;develop" "ark_kpr_Mt.cpp\;0 -4\;exclude-single" "ark_kpr_Mt.cpp\;1 -5\;exclude-single" - "ark_kpr_Mt.cpp\;2 -5 0 -10\;develop" + "ark_kpr_Mt.cpp\;2 -5 0 -10\;exclude-single" "ark_kpr_Mt.cpp\;1 -3 0 -10 0\;exclude-single" "ark_kpr_Mt.cpp\;0 3 0 -10 0\;develop" "ark_kpr_Mt.cpp\;2 4 0 -10 0\;develop" From 69749e4da6ae66169fbb28e29d5ac5c99cad31ec Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Thu, 24 Oct 2024 15:33:10 -0500 Subject: [PATCH 158/286] Removed one more test from single precision; updated answers repository --- examples/arkode/C_serial/CMakeLists.txt | 2 +- test/answers | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/arkode/C_serial/CMakeLists.txt b/examples/arkode/C_serial/CMakeLists.txt index 74e5665ea9..5637d4b54a 100644 --- a/examples/arkode/C_serial/CMakeLists.txt +++ b/examples/arkode/C_serial/CMakeLists.txt @@ -61,7 +61,7 @@ set(ARKODE_examples "ark_kepler\;\;develop" "ark_kpr_mri\;0 1 0.005\;develop" "ark_kpr_mri\;1 0 0.01\;develop" - "ark_kpr_mri\;1 1 0.002\;develop" + "ark_kpr_mri\;1 1 0.002\;exclude-single" "ark_kpr_mri\;2 4 0.002\;develop" "ark_kpr_mri\;3 2 0.001\;develop" "ark_kpr_mri\;4 3 0.001\;develop" diff --git a/test/answers b/test/answers index 9a7c72d7f9..543beff82b 160000 --- a/test/answers +++ b/test/answers @@ -1 +1 @@ -Subproject commit 9a7c72d7f9df24c80661d357297689af911ec7ff +Subproject commit 543beff82be29bfda2c4ac921d998cd5c8b28919 From c3f1cf32de2e914d294eeaf2437c81a23e215bf9 Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Thu, 24 Oct 2024 17:12:07 -0500 Subject: [PATCH 159/286] Fixed recently-introduced bug --- .../arkode/CXX_serial/ark_test_accumerror_brusselator.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/unit_tests/arkode/CXX_serial/ark_test_accumerror_brusselator.cpp b/test/unit_tests/arkode/CXX_serial/ark_test_accumerror_brusselator.cpp index 64835cf371..730e7f2a84 100644 --- a/test/unit_tests/arkode/CXX_serial/ark_test_accumerror_brusselator.cpp +++ b/test/unit_tests/arkode/CXX_serial/ark_test_accumerror_brusselator.cpp @@ -352,7 +352,7 @@ static int fn(sunrealtype t, N_Vector y, N_Vector ydot, void* user_data) { UserData* udata = (UserData*)user_data; sunrealtype* ydata = N_VGetArrayPointer(y); - sunrealtype* dydata = N_VGetArrayPointer(y); + sunrealtype* dydata = N_VGetArrayPointer(ydot); const sunrealtype u = ydata[0]; // access solution values const sunrealtype v = ydata[1]; const sunrealtype w = ydata[2]; From a5526d551954777efee7217f7a7b6842f5e03f06 Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Thu, 24 Oct 2024 17:28:43 -0500 Subject: [PATCH 160/286] Removed a few remaining NV_Ith_S --- examples/arkode/CXX_serial/ark_kpr_nestedmri.cpp | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/examples/arkode/CXX_serial/ark_kpr_nestedmri.cpp b/examples/arkode/CXX_serial/ark_kpr_nestedmri.cpp index 50d021ba08..a0c783b72d 100644 --- a/examples/arkode/CXX_serial/ark_kpr_nestedmri.cpp +++ b/examples/arkode/CXX_serial/ark_kpr_nestedmri.cpp @@ -985,15 +985,9 @@ int main(int argc, char* argv[]) verrtot += verr * verr; werrtot += werr * werr; errtot += uerr * uerr + verr * verr + werr * werr; - accuracy = - std::max(accuracy, - uerr / std::abs(opts.atol + opts.rtol * NV_Ith_S(yref, 0))); - accuracy = - std::max(accuracy, - verr / std::abs(opts.atol + opts.rtol * NV_Ith_S(yref, 1))); - accuracy = - std::max(accuracy, - werr / std::abs(opts.atol + opts.rtol * NV_Ith_S(yref, 2))); + accuracy = std::max(accuracy, uerr / std::abs(opts.atol + opts.rtol * yrefdata[0])); + accuracy = std::max(accuracy, verr / std::abs(opts.atol + opts.rtol * yrefdata[1])); + accuracy = std::max(accuracy, werr / std::abs(opts.atol + opts.rtol * yrefdata[2])); // Periodically output current results to screen if (t >= tout) From 36370cf2fbf71f7728c3c8a9911e53945a2b9a35 Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Thu, 24 Oct 2024 17:30:10 -0500 Subject: [PATCH 161/286] Updated answers repository commit --- test/answers | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/answers b/test/answers index 543beff82b..f79b6c1dac 160000 --- a/test/answers +++ b/test/answers @@ -1 +1 @@ -Subproject commit 543beff82be29bfda2c4ac921d998cd5c8b28919 +Subproject commit f79b6c1dacb78e73c8fe9344eee0aa78692393f2 From 9ef8f547ecd86a5d3670edbf284ead6faa039d65 Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Thu, 24 Oct 2024 20:24:40 -0500 Subject: [PATCH 162/286] Updated error checking on input parameters as per PR review --- examples/arkode/C_serial/ark_kpr_mri.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/arkode/C_serial/ark_kpr_mri.c b/examples/arkode/C_serial/ark_kpr_mri.c index a940f71a47..6edfb14cee 100644 --- a/examples/arkode/C_serial/ark_kpr_mri.c +++ b/examples/arkode/C_serial/ark_kpr_mri.c @@ -220,7 +220,7 @@ int main(int argc, char* argv[]) printf("ERROR: at least one of slow_type and fast_type must be nonzero\n"); return (-1); } - if (((slow_type == 9) || (slow_type == 10)) && (fast_type == 0)) + if ((slow_type >= 9) && (fast_type == 0)) { printf("ERROR: example not configured for ImEx slow solver with no fast " "solver\n"); From 51c7c50ae93884c39f197f660c2904de6aa9e481 Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Thu, 24 Oct 2024 20:24:50 -0500 Subject: [PATCH 163/286] Updated answers repository commit --- test/answers | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/answers b/test/answers index f79b6c1dac..45f0dce737 160000 --- a/test/answers +++ b/test/answers @@ -1 +1 @@ -Subproject commit f79b6c1dacb78e73c8fe9344eee0aa78692393f2 +Subproject commit 45f0dce73762b88bcc62139b0f76fc9cd107739d From f767ecd36a65ca1eed8bcd53e20dc59abd188f77 Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Thu, 24 Oct 2024 20:27:31 -0500 Subject: [PATCH 164/286] Formatting --- examples/arkode/CXX_serial/ark_kpr_nestedmri.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/examples/arkode/CXX_serial/ark_kpr_nestedmri.cpp b/examples/arkode/CXX_serial/ark_kpr_nestedmri.cpp index a0c783b72d..56d4e68a1f 100644 --- a/examples/arkode/CXX_serial/ark_kpr_nestedmri.cpp +++ b/examples/arkode/CXX_serial/ark_kpr_nestedmri.cpp @@ -985,9 +985,12 @@ int main(int argc, char* argv[]) verrtot += verr * verr; werrtot += werr * werr; errtot += uerr * uerr + verr * verr + werr * werr; - accuracy = std::max(accuracy, uerr / std::abs(opts.atol + opts.rtol * yrefdata[0])); - accuracy = std::max(accuracy, verr / std::abs(opts.atol + opts.rtol * yrefdata[1])); - accuracy = std::max(accuracy, werr / std::abs(opts.atol + opts.rtol * yrefdata[2])); + accuracy = std::max(accuracy, + uerr / std::abs(opts.atol + opts.rtol * yrefdata[0])); + accuracy = std::max(accuracy, + verr / std::abs(opts.atol + opts.rtol * yrefdata[1])); + accuracy = std::max(accuracy, + werr / std::abs(opts.atol + opts.rtol * yrefdata[2])); // Periodically output current results to screen if (t >= tout) From 720755276bc51081fe8499dfe1aa7060463a2d0e Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Thu, 24 Oct 2024 22:54:11 -0500 Subject: [PATCH 165/286] Adding 'ark_kpr_Mt 2 -5 0 -10' back in as a single-precision test to re-investigate why it 'fails' in the CI, given that it's just a fixed-step test. --- examples/arkode/CXX_serial/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/arkode/CXX_serial/CMakeLists.txt b/examples/arkode/CXX_serial/CMakeLists.txt index be64e1d748..51d5582a97 100644 --- a/examples/arkode/CXX_serial/CMakeLists.txt +++ b/examples/arkode/CXX_serial/CMakeLists.txt @@ -28,7 +28,7 @@ set(ARKODE_examples "ark_kpr_Mt.cpp\;0 4 1\;develop" "ark_kpr_Mt.cpp\;0 -4\;exclude-single" "ark_kpr_Mt.cpp\;1 -5\;exclude-single" - "ark_kpr_Mt.cpp\;2 -5 0 -10\;exclude-single" + "ark_kpr_Mt.cpp\;2 -5 0 -10\;develop" "ark_kpr_Mt.cpp\;1 -3 0 -10 0\;exclude-single" "ark_kpr_Mt.cpp\;0 3 0 -10 0\;develop" "ark_kpr_Mt.cpp\;2 4 0 -10 0\;develop" From aac1473d3e699fb03c52a6c49413ebf0d52fa251 Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Thu, 24 Oct 2024 23:31:37 -0500 Subject: [PATCH 166/286] Removed 'too much accuracy requested' error/warning when running in fixed-step mode --- src/arkode/arkode.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/arkode/arkode.c b/src/arkode/arkode.c index a663c1f93a..5776349c3f 100644 --- a/src/arkode/arkode.c +++ b/src/arkode/arkode.c @@ -815,7 +815,7 @@ int ARKodeEvolve(void* arkode_mem, sunrealtype tout, N_Vector yout, /* Check for too much accuracy requested */ nrm = N_VWrmsNorm(ark_mem->yn, ark_mem->ewt); ark_mem->tolsf = ark_mem->uround * nrm; - if (ark_mem->tolsf > ONE) + if (ark_mem->tolsf > ONE && !ark_mem->fixedstep) { arkProcessError(ark_mem, ARK_TOO_MUCH_ACC, __LINE__, __func__, __FILE__, MSG_ARK_TOO_MUCH_ACC, ark_mem->tcur); From 7f503a513ea05911eb65acf30c25be6524e53ddc Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Thu, 24 Oct 2024 23:43:09 -0500 Subject: [PATCH 167/286] Renamed SUN_ADAPTCONTROLLER_MRI_TOL to SUN_ADAPTCONTROLLER_MRI_H_TOL --- .../MRIStep/Custom_Inner_Stepper/Description.rst | 6 +++--- doc/arkode/guide/source/Usage/User_callable.rst | 2 +- .../SUNAdaptController_Description.rst | 6 +++--- .../SUNAdaptController_MRIHTol.rst | 2 +- include/sundials/sundials_adaptcontroller.h | 4 ++-- src/arkode/arkode_mristep.c | 12 ++++++------ src/arkode/arkode_mristep_controller.c | 2 +- src/arkode/arkode_mristep_io.c | 2 +- .../mrihtol/sunadaptcontroller_mrihtol.c | 2 +- 9 files changed, 19 insertions(+), 19 deletions(-) diff --git a/doc/arkode/guide/source/Usage/MRIStep/Custom_Inner_Stepper/Description.rst b/doc/arkode/guide/source/Usage/MRIStep/Custom_Inner_Stepper/Description.rst index b4348e0d83..f301b3028f 100644 --- a/doc/arkode/guide/source/Usage/MRIStep/Custom_Inner_Stepper/Description.rst +++ b/doc/arkode/guide/source/Usage/MRIStep/Custom_Inner_Stepper/Description.rst @@ -459,7 +459,7 @@ following member functions: .. note:: This function is only called when multirate temporal adaptivity has been enabled, - using a :c:type:`SUNAdaptController` module having type :c:enumerator:`SUN_ADAPTCONTROLLER_MRI_TOL`. + using a :c:type:`SUNAdaptController` module having type :c:enumerator:`SUN_ADAPTCONTROLLER_MRI_H_TOL`. If provided, the :c:type:`MRIStepInnerGetAccumulatedError` function will always be called *after* a preceding call to the :c:type:`MRIStepInnerResetAccumulatedError` @@ -484,7 +484,7 @@ following member functions: .. note:: This function is only called when multirate temporal adaptivity has been enabled, - using a :c:type:`SUNAdaptController` module having type :c:enumerator:`SUN_ADAPTCONTROLLER_MRI_TOL`. + using a :c:type:`SUNAdaptController` module having type :c:enumerator:`SUN_ADAPTCONTROLLER_MRI_H_TOL`. The :c:type:`MRIStepInnerResetAccumulatedError` function will always be called *before* any calls to the :c:type:`MRIStepInnerGetAccumulatedError` function. @@ -513,7 +513,7 @@ following member functions: .. note:: This function is only called when multirate temporal adaptivity has been enabled - using a :c:type:`SUNAdaptController` module having type :c:enumerator:`SUN_ADAPTCONTROLLER_MRI_TOL`. + using a :c:type:`SUNAdaptController` module having type :c:enumerator:`SUN_ADAPTCONTROLLER_MRI_H_TOL`. It is assumed that if the inner stepper supports absolute tolerances as well, then these have been set up directly by the user to indicate the "noise" level for diff --git a/doc/arkode/guide/source/Usage/User_callable.rst b/doc/arkode/guide/source/Usage/User_callable.rst index 753c7b3bc4..e07b08d4e5 100644 --- a/doc/arkode/guide/source/Usage/User_callable.rst +++ b/doc/arkode/guide/source/Usage/User_callable.rst @@ -1452,7 +1452,7 @@ Reset accumulated error :c:func:`ARKodeReset Not all time-stepping modules are compatible with all types of :c:type:`SUNAdaptController` objects. While all steppers that support temporal adaptivity support controllers with :c:type:`SUNAdaptController_Type` type ``SUN_ADAPTCONTROLLER_H``, only MRIStep supports - inputs with type ``SUN_ADAPTCONTROLLER_MRI_TOL``. + inputs with type ``SUN_ADAPTCONTROLLER_MRI_H_TOL``. .. versionadded:: 6.1.0 diff --git a/doc/shared/sunadaptcontroller/SUNAdaptController_Description.rst b/doc/shared/sunadaptcontroller/SUNAdaptController_Description.rst index 585b347b8f..4445411b3f 100644 --- a/doc/shared/sunadaptcontroller/SUNAdaptController_Description.rst +++ b/doc/shared/sunadaptcontroller/SUNAdaptController_Description.rst @@ -144,7 +144,7 @@ following set of SUNAdaptController types: Controls a single-rate step size. -.. c:enumerator:: SUN_ADAPTCONTROLLER_MRI_TOL +.. c:enumerator:: SUN_ADAPTCONTROLLER_MRI_H_TOL Controls both a slow time step and a tolerance factor to apply on the next-faster time scale within a multirate simulation that has an arbitrary number of time scales. @@ -233,7 +233,7 @@ note these requirements below. Additionally, we note the behavior of the base SU Estimates a slow step size and a fast tolerance multiplication factor for two adjacent time scales within a multirate application. - This routine is required for controllers of type :c:enumerator`SUN_ADAPTCONTROLLER_MRI_TOL`. + This routine is required for controllers of type :c:enumerator`SUN_ADAPTCONTROLLER_MRI_H_TOL`. If the current time scale has relative tolerance ``rtol``, then the next-faster time scale will be called with relative tolerance ``tolfac * rtol``. If this is not provided by the implementation, the base class method will set @@ -310,7 +310,7 @@ note these requirements below. Additionally, we note the behavior of the base SU .. c:function:: SUNErrCode SUNAdaptController_UpdateMRITol(SUNAdaptController C, sunrealtype H, sunrealtype tolfac, sunrealtype DSM, sunrealtype dsm) - Notifies a controller of type :c:enumerator:`SUN_ADAPTCONTROLLER_MRI_TOL` that a successful time step + Notifies a controller of type :c:enumerator:`SUN_ADAPTCONTROLLER_MRI_H_TOL` that a successful time step was taken with slow stepsize ``H`` and fast relative tolerance factor ``tolfac``, and that the step had slow and fast local error factors ``DSM`` and ``dsm``, indicating that these can be saved for subsequent controller functions. This is typically relevant for controllers that diff --git a/doc/shared/sunadaptcontroller/SUNAdaptController_MRIHTol.rst b/doc/shared/sunadaptcontroller/SUNAdaptController_MRIHTol.rst index 6d1caaf1f7..a653f6404b 100644 --- a/doc/shared/sunadaptcontroller/SUNAdaptController_MRIHTol.rst +++ b/doc/shared/sunadaptcontroller/SUNAdaptController_MRIHTol.rst @@ -124,7 +124,7 @@ The header file to be included when using this module is ``sunadaptcontroller/sunadaptcontroller_mrihtol.h``. The SUNAdaptController_MRIHTol class provides implementations of all operations -relevant to a :c:enumerator:`SUN_ADAPTCONTROLLER_MRI_TOL` controller listed in +relevant to a :c:enumerator:`SUN_ADAPTCONTROLLER_MRI_H_TOL` controller listed in :numref:`SUNAdaptController.Description.operations`. This class also provides the following additional user-callable routines: diff --git a/include/sundials/sundials_adaptcontroller.h b/include/sundials/sundials_adaptcontroller.h index 4809ea64eb..8cb059cf4e 100644 --- a/include/sundials/sundials_adaptcontroller.h +++ b/include/sundials/sundials_adaptcontroller.h @@ -41,7 +41,7 @@ typedef enum { SUN_ADAPTCONTROLLER_NONE, SUN_ADAPTCONTROLLER_H, - SUN_ADAPTCONTROLLER_MRI_TOL + SUN_ADAPTCONTROLLER_MRI_H_TOL } SUNAdaptController_Type; /* ----------------------------------------------------------------- @@ -64,7 +64,7 @@ struct _generic_SUNAdaptController_Ops SUNErrCode (*estimatestep)(SUNAdaptController C, sunrealtype h, int p, sunrealtype dsm, sunrealtype* hnew); - /* REQUIRED for controllers of SUN_ADAPTCONTROLLER_MRI_TOL type. */ + /* REQUIRED for controllers of SUN_ADAPTCONTROLLER_MRI_H_TOL type. */ SUNErrCode (*estimatesteptol)(SUNAdaptController C, sunrealtype H, sunrealtype tolfac, int P, sunrealtype DSM, sunrealtype dsm, sunrealtype* Hnew, diff --git a/src/arkode/arkode_mristep.c b/src/arkode/arkode_mristep.c index 89d45597f0..0eacbb86dc 100644 --- a/src/arkode/arkode_mristep.c +++ b/src/arkode/arkode_mristep.c @@ -1258,7 +1258,7 @@ int mriStep_Init(ARKodeMem ark_mem, int init_type) else { /* ensure that a compatible adaptivity controller is provided */ - if ((adapt_type != SUN_ADAPTCONTROLLER_MRI_TOL) && + if ((adapt_type != SUN_ADAPTCONTROLLER_MRI_H_TOL) && (adapt_type != SUN_ADAPTCONTROLLER_H)) { arkProcessError(ark_mem, ARK_ILL_INPUT, __LINE__, __func__, __FILE__, @@ -1296,7 +1296,7 @@ int mriStep_Init(ARKodeMem ark_mem, int init_type) } /* Perform additional setup for (H,tol) controller */ - if (adapt_type == SUN_ADAPTCONTROLLER_MRI_TOL) + if (adapt_type == SUN_ADAPTCONTROLLER_MRI_H_TOL) { /* Verify that adaptivity type is supported by inner stepper */ if (!mriStepInnerStepper_SupportsRTolAdaptivity(step_mem->stepper)) @@ -1701,7 +1701,7 @@ int mriStep_TakeStepMRIGARK(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPt and send appropriate control parameter to the fast integrator */ adapt_type = SUNAdaptController_GetType(ark_mem->hadapt_mem->hcontroller); need_inner_dsm = SUNFALSE; - if (adapt_type == SUN_ADAPTCONTROLLER_MRI_TOL) + if (adapt_type == SUN_ADAPTCONTROLLER_MRI_H_TOL) { need_inner_dsm = SUNTRUE; step_mem->inner_dsm = ZERO; @@ -2167,7 +2167,7 @@ int mriStep_TakeStepMRISR(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr) and send appropriate control parameter to the fast integrator */ adapt_type = SUNAdaptController_GetType(ark_mem->hadapt_mem->hcontroller); need_inner_dsm = SUNFALSE; - if (adapt_type == SUN_ADAPTCONTROLLER_MRI_TOL) + if (adapt_type == SUN_ADAPTCONTROLLER_MRI_H_TOL) { need_inner_dsm = SUNTRUE; step_mem->inner_dsm = ZERO; @@ -2637,7 +2637,7 @@ int mriStep_TakeStepMERK(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr) and send appropriate control parameter to the fast integrator */ adapt_type = SUNAdaptController_GetType(ark_mem->hadapt_mem->hcontroller); need_inner_dsm = SUNFALSE; - if (adapt_type == SUN_ADAPTCONTROLLER_MRI_TOL) + if (adapt_type == SUN_ADAPTCONTROLLER_MRI_H_TOL) { need_inner_dsm = SUNTRUE; step_mem->inner_dsm = ZERO; @@ -3356,7 +3356,7 @@ int mriStep_StageERKFast(ARKodeMem ark_mem, ARKodeMRIStepMem step_mem, if (get_inner_dsm) { /* if the fast integrator uses adaptive steps, retrieve the error estimate */ - if (adapt_type == SUN_ADAPTCONTROLLER_MRI_TOL) + if (adapt_type == SUN_ADAPTCONTROLLER_MRI_H_TOL) { retval = mriStepInnerStepper_GetError(step_mem->stepper, &(step_mem->inner_dsm)); diff --git a/src/arkode/arkode_mristep_controller.c b/src/arkode/arkode_mristep_controller.c index bef6c5a711..df5e4c4612 100644 --- a/src/arkode/arkode_mristep_controller.c +++ b/src/arkode/arkode_mristep_controller.c @@ -41,7 +41,7 @@ SUNAdaptController SUNAdaptController_MRIStep(ARKodeMem ark_mem, /* Return with failure if input controller is NULL or has unsupported type */ if (CMRI == NULL) { return (NULL); } - if (SUNAdaptController_GetType(CMRI) != SUN_ADAPTCONTROLLER_MRI_TOL) + if (SUNAdaptController_GetType(CMRI) != SUN_ADAPTCONTROLLER_MRI_H_TOL) { return (NULL); } diff --git a/src/arkode/arkode_mristep_io.c b/src/arkode/arkode_mristep_io.c index 13514336a4..ed4eab3d5c 100644 --- a/src/arkode/arkode_mristep_io.c +++ b/src/arkode/arkode_mristep_io.c @@ -242,7 +242,7 @@ int mriStep_SetAdaptController(ARKodeMem ark_mem, SUNAdaptController C) SUNAdaptController_Type ctype = SUNAdaptController_GetType(C); /* If this does not have MRI type, then just pass to ARKODE */ - if (ctype != SUN_ADAPTCONTROLLER_MRI_TOL) + if (ctype != SUN_ADAPTCONTROLLER_MRI_H_TOL) { return (arkReplaceAdaptController(ark_mem, C)); } diff --git a/src/sunadaptcontroller/mrihtol/sunadaptcontroller_mrihtol.c b/src/sunadaptcontroller/mrihtol/sunadaptcontroller_mrihtol.c index ae8716258a..bc9f0bc39a 100644 --- a/src/sunadaptcontroller/mrihtol/sunadaptcontroller_mrihtol.c +++ b/src/sunadaptcontroller/mrihtol/sunadaptcontroller_mrihtol.c @@ -144,7 +144,7 @@ SUNAdaptController SUNAdaptController_GetFastController_MRIHTol(SUNAdaptControll SUNAdaptController_Type SUNAdaptController_GetType_MRIHTol( SUNDIALS_MAYBE_UNUSED SUNAdaptController C) { - return SUN_ADAPTCONTROLLER_MRI_TOL; + return SUN_ADAPTCONTROLLER_MRI_H_TOL; } SUNErrCode SUNAdaptController_EstimateStepTol_MRIHTol( From 8a2866466a8c48b069fed583dc61f6a9ff249881 Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Thu, 24 Oct 2024 23:46:20 -0500 Subject: [PATCH 168/286] Renamed SUNAdaptController_UpdateMRITol as SUNAdaptController_MRIHTol --- .../SUNAdaptController_Description.rst | 4 ++-- .../sunadaptcontroller/sunadaptcontroller_mrihtol.h | 6 +++--- include/sundials/sundials_adaptcontroller.h | 6 +++--- src/arkode/arkode_mristep_controller.c | 6 +++--- src/arkode/arkode_mristep_impl.h | 2 +- .../mrihtol/sunadaptcontroller_mrihtol.c | 12 ++++++------ 6 files changed, 18 insertions(+), 18 deletions(-) diff --git a/doc/shared/sunadaptcontroller/SUNAdaptController_Description.rst b/doc/shared/sunadaptcontroller/SUNAdaptController_Description.rst index 4445411b3f..3407edc9f4 100644 --- a/doc/shared/sunadaptcontroller/SUNAdaptController_Description.rst +++ b/doc/shared/sunadaptcontroller/SUNAdaptController_Description.rst @@ -111,7 +111,7 @@ The virtual table structure is defined as .. c:member:: SUNErrCode (*updatemritol)(SUNAdaptController C, sunrealtype H, sunrealtype tolfac, sunrealtype DSM, sunrealtype dsm) - The function implementing :c:func:`SUNAdaptController_UpdateMRITol` + The function implementing :c:func:`SUNAdaptController_UpdateMRIHTol` .. versionadded:: x.y.z @@ -308,7 +308,7 @@ note these requirements below. Additionally, we note the behavior of the base SU :return: :c:type:`SUNErrCode` indicating success or failure. -.. c:function:: SUNErrCode SUNAdaptController_UpdateMRITol(SUNAdaptController C, sunrealtype H, sunrealtype tolfac, sunrealtype DSM, sunrealtype dsm) +.. c:function:: SUNErrCode SUNAdaptController_UpdateMRIHTol(SUNAdaptController C, sunrealtype H, sunrealtype tolfac, sunrealtype DSM, sunrealtype dsm) Notifies a controller of type :c:enumerator:`SUN_ADAPTCONTROLLER_MRI_H_TOL` that a successful time step was taken with slow stepsize ``H`` and fast relative tolerance factor ``tolfac``, and that the diff --git a/include/sunadaptcontroller/sunadaptcontroller_mrihtol.h b/include/sunadaptcontroller/sunadaptcontroller_mrihtol.h index 56e3488e5d..8a2c3a46e3 100644 --- a/include/sunadaptcontroller/sunadaptcontroller_mrihtol.h +++ b/include/sunadaptcontroller/sunadaptcontroller_mrihtol.h @@ -74,9 +74,9 @@ SUNDIALS_EXPORT int SUNAdaptController_SetErrorBias_MRIHTol(SUNAdaptController C, sunrealtype bias); SUNDIALS_EXPORT -int SUNAdaptController_UpdateMRITol_MRIHTol(SUNAdaptController C, sunrealtype H, - sunrealtype tolfac, sunrealtype DSM, - sunrealtype dsm); +int SUNAdaptController_UpdateMRIHTol_MRIHTol(SUNAdaptController C, sunrealtype H, + sunrealtype tolfac, sunrealtype DSM, + sunrealtype dsm); SUNDIALS_EXPORT int SUNAdaptController_Space_MRIHTol(SUNAdaptController C, long int* lenrw, long int* leniw); diff --git a/include/sundials/sundials_adaptcontroller.h b/include/sundials/sundials_adaptcontroller.h index 8cb059cf4e..24ff59a874 100644 --- a/include/sundials/sundials_adaptcontroller.h +++ b/include/sundials/sundials_adaptcontroller.h @@ -174,9 +174,9 @@ SUNErrCode SUNAdaptController_UpdateH(SUNAdaptController C, sunrealtype h, DSM and dsm, indicating that the step size, tolerance factor, or local error factors can be saved for subsequent controller functions. */ SUNDIALS_EXPORT -SUNErrCode SUNAdaptController_UpdateMRITol(SUNAdaptController C, sunrealtype H, - sunrealtype tolfac, sunrealtype DSM, - sunrealtype dsm); +SUNErrCode SUNAdaptController_UpdateMRIHTol(SUNAdaptController C, sunrealtype H, + sunrealtype tolfac, sunrealtype DSM, + sunrealtype dsm); /* Function to return the memory requirements of the controller object. */ SUNDIALS_EXPORT diff --git a/src/arkode/arkode_mristep_controller.c b/src/arkode/arkode_mristep_controller.c index df5e4c4612..9331750bec 100644 --- a/src/arkode/arkode_mristep_controller.c +++ b/src/arkode/arkode_mristep_controller.c @@ -111,9 +111,9 @@ SUNErrCode SUNAdaptController_UpdateH_MRIStep(SUNAdaptController C, if ((ark_mem == NULL) || (step_mem == NULL)) { return SUN_ERR_MEM_FAIL; } /* Update MRI controller */ - SUNErrCode retval = SUNAdaptController_UpdateMRITol(MRICONTROL_C(C), H, - step_mem->inner_control, - DSM, step_mem->inner_dsm); + SUNErrCode retval = SUNAdaptController_UpdateMRIHTol(MRICONTROL_C(C), H, + step_mem->inner_control, + DSM, step_mem->inner_dsm); if (retval != SUN_SUCCESS) { return (retval); } /* Update inner controller parameter to most-recent prediction */ diff --git a/src/arkode/arkode_mristep_impl.h b/src/arkode/arkode_mristep_impl.h index 5d537e912c..c3bc789b4d 100644 --- a/src/arkode/arkode_mristep_impl.h +++ b/src/arkode/arkode_mristep_impl.h @@ -344,7 +344,7 @@ int mriStep_RKCoeffs(MRIStepCoupling MRIC, int is, int* stage_map, rate context, leveraging MRIStep-specific knowledge of the slow+fast time scale relationship to CALL multi-rate controller functions (e.g., EstimateMRISteps, EstimateStepTol, UpdateMRIH, - and UpdateMRITol) provided by the underlying multi-rate + and UpdateMRIHTol) provided by the underlying multi-rate controller. ===============================================================*/ diff --git a/src/sunadaptcontroller/mrihtol/sunadaptcontroller_mrihtol.c b/src/sunadaptcontroller/mrihtol/sunadaptcontroller_mrihtol.c index bc9f0bc39a..dc02ce58ab 100644 --- a/src/sunadaptcontroller/mrihtol/sunadaptcontroller_mrihtol.c +++ b/src/sunadaptcontroller/mrihtol/sunadaptcontroller_mrihtol.c @@ -82,7 +82,7 @@ SUNAdaptController SUNAdaptController_MRIHTol(SUNAdaptController HControl, C->ops->setdefaults = SUNAdaptController_SetDefaults_MRIHTol; C->ops->write = SUNAdaptController_Write_MRIHTol; C->ops->seterrorbias = SUNAdaptController_SetErrorBias_MRIHTol; - C->ops->updatemritol = SUNAdaptController_UpdateMRITol_MRIHTol; + C->ops->updatemritol = SUNAdaptController_UpdateMRIHTol_MRIHTol; C->ops->space = SUNAdaptController_Space_MRIHTol; /* Create content */ @@ -227,11 +227,11 @@ SUNErrCode SUNAdaptController_SetErrorBias_MRIHTol(SUNAdaptController C, return SUN_SUCCESS; } -SUNErrCode SUNAdaptController_UpdateMRITol_MRIHTol(SUNAdaptController C, - sunrealtype H, - sunrealtype tolfac, - sunrealtype DSM, - sunrealtype dsm) +SUNErrCode SUNAdaptController_UpdateMRIHTol_MRIHTol(SUNAdaptController C, + sunrealtype H, + sunrealtype tolfac, + sunrealtype DSM, + sunrealtype dsm) { SUNFunctionBegin(C->sunctx); SUNCheckCall(SUNAdaptController_UpdateH(MRIHTOL_CSLOW(C), H, DSM)); From f787627366514fee336c4ab605ba4b86ee061c15 Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Thu, 24 Oct 2024 23:46:58 -0500 Subject: [PATCH 169/286] Updated Swig interfaces --- .../fmod_int32/fsunadaptcontroller_mrihtol_mod.c | 4 ++-- .../fmod_int32/fsunadaptcontroller_mrihtol_mod.f90 | 10 +++++----- .../fmod_int64/fsunadaptcontroller_mrihtol_mod.c | 4 ++-- .../fmod_int64/fsunadaptcontroller_mrihtol_mod.f90 | 10 +++++----- src/sundials/fmod_int32/fsundials_core_mod.c | 4 ++-- src/sundials/fmod_int32/fsundials_core_mod.f90 | 14 +++++++------- src/sundials/fmod_int64/fsundials_core_mod.c | 4 ++-- src/sundials/fmod_int64/fsundials_core_mod.f90 | 14 +++++++------- 8 files changed, 32 insertions(+), 32 deletions(-) diff --git a/src/sunadaptcontroller/mrihtol/fmod_int32/fsunadaptcontroller_mrihtol_mod.c b/src/sunadaptcontroller/mrihtol/fmod_int32/fsunadaptcontroller_mrihtol_mod.c index dcb3ecddda..e8a0775fe4 100644 --- a/src/sunadaptcontroller/mrihtol/fmod_int32/fsunadaptcontroller_mrihtol_mod.c +++ b/src/sunadaptcontroller/mrihtol/fmod_int32/fsunadaptcontroller_mrihtol_mod.c @@ -596,7 +596,7 @@ SWIGEXPORT int _wrap_FSUNAdaptController_SetErrorBias_MRIHTol(SUNAdaptController } -SWIGEXPORT int _wrap_FSUNAdaptController_UpdateMRITol_MRIHTol(SUNAdaptController farg1, double const *farg2, double const *farg3, double const *farg4, double const *farg5) { +SWIGEXPORT int _wrap_FSUNAdaptController_UpdateMRIHTol_MRIHTol(SUNAdaptController farg1, double const *farg2, double const *farg3, double const *farg4, double const *farg5) { int fresult ; SUNAdaptController arg1 = (SUNAdaptController) 0 ; sunrealtype arg2 ; @@ -610,7 +610,7 @@ SWIGEXPORT int _wrap_FSUNAdaptController_UpdateMRITol_MRIHTol(SUNAdaptController arg3 = (sunrealtype)(*farg3); arg4 = (sunrealtype)(*farg4); arg5 = (sunrealtype)(*farg5); - result = (int)SUNAdaptController_UpdateMRITol_MRIHTol(arg1,arg2,arg3,arg4,arg5); + result = (int)SUNAdaptController_UpdateMRIHTol_MRIHTol(arg1,arg2,arg3,arg4,arg5); fresult = (int)(result); return fresult; } diff --git a/src/sunadaptcontroller/mrihtol/fmod_int32/fsunadaptcontroller_mrihtol_mod.f90 b/src/sunadaptcontroller/mrihtol/fmod_int32/fsunadaptcontroller_mrihtol_mod.f90 index c08850f180..d333a6dd9c 100644 --- a/src/sunadaptcontroller/mrihtol/fmod_int32/fsunadaptcontroller_mrihtol_mod.f90 +++ b/src/sunadaptcontroller/mrihtol/fmod_int32/fsunadaptcontroller_mrihtol_mod.f90 @@ -64,7 +64,7 @@ module fsunadaptcontroller_mrihtol_mod public :: FSUNAdaptController_SetDefaults_MRIHTol public :: FSUNAdaptController_Write_MRIHTol public :: FSUNAdaptController_SetErrorBias_MRIHTol - public :: FSUNAdaptController_UpdateMRITol_MRIHTol + public :: FSUNAdaptController_UpdateMRIHTol_MRIHTol public :: FSUNAdaptController_Space_MRIHTol ! WRAPPER DECLARATIONS @@ -271,8 +271,8 @@ function swigc_FSUNAdaptController_SetErrorBias_MRIHTol(farg1, farg2) & integer(C_INT) :: fresult end function -function swigc_FSUNAdaptController_UpdateMRITol_MRIHTol(farg1, farg2, farg3, farg4, farg5) & -bind(C, name="_wrap_FSUNAdaptController_UpdateMRITol_MRIHTol") & +function swigc_FSUNAdaptController_UpdateMRIHTol_MRIHTol(farg1, farg2, farg3, farg4, farg5) & +bind(C, name="_wrap_FSUNAdaptController_UpdateMRIHTol_MRIHTol") & result(fresult) use, intrinsic :: ISO_C_BINDING type(C_PTR), value :: farg1 @@ -632,7 +632,7 @@ function FSUNAdaptController_SetErrorBias_MRIHTol(c, bias) & swig_result = fresult end function -function FSUNAdaptController_UpdateMRITol_MRIHTol(c, h, tolfac, dsm, dsm4) & +function FSUNAdaptController_UpdateMRIHTol_MRIHTol(c, h, tolfac, dsm, dsm4) & result(swig_result) use, intrinsic :: ISO_C_BINDING integer(C_INT) :: swig_result @@ -653,7 +653,7 @@ function FSUNAdaptController_UpdateMRITol_MRIHTol(c, h, tolfac, dsm, dsm4) & farg3 = tolfac farg4 = dsm farg5 = dsm4 -fresult = swigc_FSUNAdaptController_UpdateMRITol_MRIHTol(farg1, farg2, farg3, farg4, farg5) +fresult = swigc_FSUNAdaptController_UpdateMRIHTol_MRIHTol(farg1, farg2, farg3, farg4, farg5) swig_result = fresult end function diff --git a/src/sunadaptcontroller/mrihtol/fmod_int64/fsunadaptcontroller_mrihtol_mod.c b/src/sunadaptcontroller/mrihtol/fmod_int64/fsunadaptcontroller_mrihtol_mod.c index dcb3ecddda..e8a0775fe4 100644 --- a/src/sunadaptcontroller/mrihtol/fmod_int64/fsunadaptcontroller_mrihtol_mod.c +++ b/src/sunadaptcontroller/mrihtol/fmod_int64/fsunadaptcontroller_mrihtol_mod.c @@ -596,7 +596,7 @@ SWIGEXPORT int _wrap_FSUNAdaptController_SetErrorBias_MRIHTol(SUNAdaptController } -SWIGEXPORT int _wrap_FSUNAdaptController_UpdateMRITol_MRIHTol(SUNAdaptController farg1, double const *farg2, double const *farg3, double const *farg4, double const *farg5) { +SWIGEXPORT int _wrap_FSUNAdaptController_UpdateMRIHTol_MRIHTol(SUNAdaptController farg1, double const *farg2, double const *farg3, double const *farg4, double const *farg5) { int fresult ; SUNAdaptController arg1 = (SUNAdaptController) 0 ; sunrealtype arg2 ; @@ -610,7 +610,7 @@ SWIGEXPORT int _wrap_FSUNAdaptController_UpdateMRITol_MRIHTol(SUNAdaptController arg3 = (sunrealtype)(*farg3); arg4 = (sunrealtype)(*farg4); arg5 = (sunrealtype)(*farg5); - result = (int)SUNAdaptController_UpdateMRITol_MRIHTol(arg1,arg2,arg3,arg4,arg5); + result = (int)SUNAdaptController_UpdateMRIHTol_MRIHTol(arg1,arg2,arg3,arg4,arg5); fresult = (int)(result); return fresult; } diff --git a/src/sunadaptcontroller/mrihtol/fmod_int64/fsunadaptcontroller_mrihtol_mod.f90 b/src/sunadaptcontroller/mrihtol/fmod_int64/fsunadaptcontroller_mrihtol_mod.f90 index c08850f180..d333a6dd9c 100644 --- a/src/sunadaptcontroller/mrihtol/fmod_int64/fsunadaptcontroller_mrihtol_mod.f90 +++ b/src/sunadaptcontroller/mrihtol/fmod_int64/fsunadaptcontroller_mrihtol_mod.f90 @@ -64,7 +64,7 @@ module fsunadaptcontroller_mrihtol_mod public :: FSUNAdaptController_SetDefaults_MRIHTol public :: FSUNAdaptController_Write_MRIHTol public :: FSUNAdaptController_SetErrorBias_MRIHTol - public :: FSUNAdaptController_UpdateMRITol_MRIHTol + public :: FSUNAdaptController_UpdateMRIHTol_MRIHTol public :: FSUNAdaptController_Space_MRIHTol ! WRAPPER DECLARATIONS @@ -271,8 +271,8 @@ function swigc_FSUNAdaptController_SetErrorBias_MRIHTol(farg1, farg2) & integer(C_INT) :: fresult end function -function swigc_FSUNAdaptController_UpdateMRITol_MRIHTol(farg1, farg2, farg3, farg4, farg5) & -bind(C, name="_wrap_FSUNAdaptController_UpdateMRITol_MRIHTol") & +function swigc_FSUNAdaptController_UpdateMRIHTol_MRIHTol(farg1, farg2, farg3, farg4, farg5) & +bind(C, name="_wrap_FSUNAdaptController_UpdateMRIHTol_MRIHTol") & result(fresult) use, intrinsic :: ISO_C_BINDING type(C_PTR), value :: farg1 @@ -632,7 +632,7 @@ function FSUNAdaptController_SetErrorBias_MRIHTol(c, bias) & swig_result = fresult end function -function FSUNAdaptController_UpdateMRITol_MRIHTol(c, h, tolfac, dsm, dsm4) & +function FSUNAdaptController_UpdateMRIHTol_MRIHTol(c, h, tolfac, dsm, dsm4) & result(swig_result) use, intrinsic :: ISO_C_BINDING integer(C_INT) :: swig_result @@ -653,7 +653,7 @@ function FSUNAdaptController_UpdateMRITol_MRIHTol(c, h, tolfac, dsm, dsm4) & farg3 = tolfac farg4 = dsm farg5 = dsm4 -fresult = swigc_FSUNAdaptController_UpdateMRITol_MRIHTol(farg1, farg2, farg3, farg4, farg5) +fresult = swigc_FSUNAdaptController_UpdateMRIHTol_MRIHTol(farg1, farg2, farg3, farg4, farg5) swig_result = fresult end function diff --git a/src/sundials/fmod_int32/fsundials_core_mod.c b/src/sundials/fmod_int32/fsundials_core_mod.c index 8590361c6a..d24e5f2f12 100644 --- a/src/sundials/fmod_int32/fsundials_core_mod.c +++ b/src/sundials/fmod_int32/fsundials_core_mod.c @@ -2651,7 +2651,7 @@ SWIGEXPORT int _wrap_FSUNAdaptController_UpdateH(SUNAdaptController farg1, doubl } -SWIGEXPORT int _wrap_FSUNAdaptController_UpdateMRITol(SUNAdaptController farg1, double const *farg2, double const *farg3, double const *farg4, double const *farg5) { +SWIGEXPORT int _wrap_FSUNAdaptController_UpdateMRIHTol(SUNAdaptController farg1, double const *farg2, double const *farg3, double const *farg4, double const *farg5) { int fresult ; SUNAdaptController arg1 = (SUNAdaptController) 0 ; sunrealtype arg2 ; @@ -2665,7 +2665,7 @@ SWIGEXPORT int _wrap_FSUNAdaptController_UpdateMRITol(SUNAdaptController farg1, arg3 = (sunrealtype)(*farg3); arg4 = (sunrealtype)(*farg4); arg5 = (sunrealtype)(*farg5); - result = (SUNErrCode)SUNAdaptController_UpdateMRITol(arg1,arg2,arg3,arg4,arg5); + result = (SUNErrCode)SUNAdaptController_UpdateMRIHTol(arg1,arg2,arg3,arg4,arg5); fresult = (SUNErrCode)(result); return fresult; } diff --git a/src/sundials/fmod_int32/fsundials_core_mod.f90 b/src/sundials/fmod_int32/fsundials_core_mod.f90 index ff9ffaa91c..6756c36b1a 100644 --- a/src/sundials/fmod_int32/fsundials_core_mod.f90 +++ b/src/sundials/fmod_int32/fsundials_core_mod.f90 @@ -511,10 +511,10 @@ module fsundials_core_mod enum, bind(c) enumerator :: SUN_ADAPTCONTROLLER_NONE enumerator :: SUN_ADAPTCONTROLLER_H - enumerator :: SUN_ADAPTCONTROLLER_MRI_TOL + enumerator :: SUN_ADAPTCONTROLLER_MRI_H_TOL end enum integer, parameter, public :: SUNAdaptController_Type = kind(SUN_ADAPTCONTROLLER_NONE) - public :: SUN_ADAPTCONTROLLER_NONE, SUN_ADAPTCONTROLLER_H, SUN_ADAPTCONTROLLER_MRI_TOL + public :: SUN_ADAPTCONTROLLER_NONE, SUN_ADAPTCONTROLLER_H, SUN_ADAPTCONTROLLER_MRI_H_TOL ! struct struct _generic_SUNAdaptController_Ops type, bind(C), public :: SUNAdaptController_Ops type(C_FUNPTR), public :: gettype @@ -546,7 +546,7 @@ module fsundials_core_mod public :: FSUNAdaptController_Write public :: FSUNAdaptController_SetErrorBias public :: FSUNAdaptController_UpdateH - public :: FSUNAdaptController_UpdateMRITol + public :: FSUNAdaptController_UpdateMRIHTol public :: FSUNAdaptController_Space ! WRAPPER DECLARATIONS @@ -2051,8 +2051,8 @@ function swigc_FSUNAdaptController_UpdateH(farg1, farg2, farg3) & integer(C_INT) :: fresult end function -function swigc_FSUNAdaptController_UpdateMRITol(farg1, farg2, farg3, farg4, farg5) & -bind(C, name="_wrap_FSUNAdaptController_UpdateMRITol") & +function swigc_FSUNAdaptController_UpdateMRIHTol(farg1, farg2, farg3, farg4, farg5) & +bind(C, name="_wrap_FSUNAdaptController_UpdateMRIHTol") & result(fresult) use, intrinsic :: ISO_C_BINDING type(C_PTR), value :: farg1 @@ -4829,7 +4829,7 @@ function FSUNAdaptController_UpdateH(c, h, dsm) & swig_result = fresult end function -function FSUNAdaptController_UpdateMRITol(c, h, tolfac, dsm, dsm4) & +function FSUNAdaptController_UpdateMRIHTol(c, h, tolfac, dsm, dsm4) & result(swig_result) use, intrinsic :: ISO_C_BINDING integer(C_INT) :: swig_result @@ -4850,7 +4850,7 @@ function FSUNAdaptController_UpdateMRITol(c, h, tolfac, dsm, dsm4) & farg3 = tolfac farg4 = dsm farg5 = dsm4 -fresult = swigc_FSUNAdaptController_UpdateMRITol(farg1, farg2, farg3, farg4, farg5) +fresult = swigc_FSUNAdaptController_UpdateMRIHTol(farg1, farg2, farg3, farg4, farg5) swig_result = fresult end function diff --git a/src/sundials/fmod_int64/fsundials_core_mod.c b/src/sundials/fmod_int64/fsundials_core_mod.c index 98cb592e42..ac00ce7477 100644 --- a/src/sundials/fmod_int64/fsundials_core_mod.c +++ b/src/sundials/fmod_int64/fsundials_core_mod.c @@ -2651,7 +2651,7 @@ SWIGEXPORT int _wrap_FSUNAdaptController_UpdateH(SUNAdaptController farg1, doubl } -SWIGEXPORT int _wrap_FSUNAdaptController_UpdateMRITol(SUNAdaptController farg1, double const *farg2, double const *farg3, double const *farg4, double const *farg5) { +SWIGEXPORT int _wrap_FSUNAdaptController_UpdateMRIHTol(SUNAdaptController farg1, double const *farg2, double const *farg3, double const *farg4, double const *farg5) { int fresult ; SUNAdaptController arg1 = (SUNAdaptController) 0 ; sunrealtype arg2 ; @@ -2665,7 +2665,7 @@ SWIGEXPORT int _wrap_FSUNAdaptController_UpdateMRITol(SUNAdaptController farg1, arg3 = (sunrealtype)(*farg3); arg4 = (sunrealtype)(*farg4); arg5 = (sunrealtype)(*farg5); - result = (SUNErrCode)SUNAdaptController_UpdateMRITol(arg1,arg2,arg3,arg4,arg5); + result = (SUNErrCode)SUNAdaptController_UpdateMRIHTol(arg1,arg2,arg3,arg4,arg5); fresult = (SUNErrCode)(result); return fresult; } diff --git a/src/sundials/fmod_int64/fsundials_core_mod.f90 b/src/sundials/fmod_int64/fsundials_core_mod.f90 index 117f0567a3..c0d5a10e05 100644 --- a/src/sundials/fmod_int64/fsundials_core_mod.f90 +++ b/src/sundials/fmod_int64/fsundials_core_mod.f90 @@ -511,10 +511,10 @@ module fsundials_core_mod enum, bind(c) enumerator :: SUN_ADAPTCONTROLLER_NONE enumerator :: SUN_ADAPTCONTROLLER_H - enumerator :: SUN_ADAPTCONTROLLER_MRI_TOL + enumerator :: SUN_ADAPTCONTROLLER_MRI_H_TOL end enum integer, parameter, public :: SUNAdaptController_Type = kind(SUN_ADAPTCONTROLLER_NONE) - public :: SUN_ADAPTCONTROLLER_NONE, SUN_ADAPTCONTROLLER_H, SUN_ADAPTCONTROLLER_MRI_TOL + public :: SUN_ADAPTCONTROLLER_NONE, SUN_ADAPTCONTROLLER_H, SUN_ADAPTCONTROLLER_MRI_H_TOL ! struct struct _generic_SUNAdaptController_Ops type, bind(C), public :: SUNAdaptController_Ops type(C_FUNPTR), public :: gettype @@ -546,7 +546,7 @@ module fsundials_core_mod public :: FSUNAdaptController_Write public :: FSUNAdaptController_SetErrorBias public :: FSUNAdaptController_UpdateH - public :: FSUNAdaptController_UpdateMRITol + public :: FSUNAdaptController_UpdateMRIHTol public :: FSUNAdaptController_Space ! WRAPPER DECLARATIONS @@ -2051,8 +2051,8 @@ function swigc_FSUNAdaptController_UpdateH(farg1, farg2, farg3) & integer(C_INT) :: fresult end function -function swigc_FSUNAdaptController_UpdateMRITol(farg1, farg2, farg3, farg4, farg5) & -bind(C, name="_wrap_FSUNAdaptController_UpdateMRITol") & +function swigc_FSUNAdaptController_UpdateMRIHTol(farg1, farg2, farg3, farg4, farg5) & +bind(C, name="_wrap_FSUNAdaptController_UpdateMRIHTol") & result(fresult) use, intrinsic :: ISO_C_BINDING type(C_PTR), value :: farg1 @@ -4829,7 +4829,7 @@ function FSUNAdaptController_UpdateH(c, h, dsm) & swig_result = fresult end function -function FSUNAdaptController_UpdateMRITol(c, h, tolfac, dsm, dsm4) & +function FSUNAdaptController_UpdateMRIHTol(c, h, tolfac, dsm, dsm4) & result(swig_result) use, intrinsic :: ISO_C_BINDING integer(C_INT) :: swig_result @@ -4850,7 +4850,7 @@ function FSUNAdaptController_UpdateMRITol(c, h, tolfac, dsm, dsm4) & farg3 = tolfac farg4 = dsm farg5 = dsm4 -fresult = swigc_FSUNAdaptController_UpdateMRITol(farg1, farg2, farg3, farg4, farg5) +fresult = swigc_FSUNAdaptController_UpdateMRIHTol(farg1, farg2, farg3, farg4, farg5) swig_result = fresult end function From 84d4f0dd76fd65a7023f042a1c7e7ac416d152db Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Thu, 24 Oct 2024 23:58:43 -0500 Subject: [PATCH 170/286] Bugfix from last commit --- include/sundials/sundials_adaptcontroller.h | 6 +++--- .../mrihtol/sunadaptcontroller_mrihtol.c | 2 +- src/sundials/sundials_adaptcontroller.c | 12 ++++++------ 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/include/sundials/sundials_adaptcontroller.h b/include/sundials/sundials_adaptcontroller.h index 24ff59a874..4d5c9bf9ca 100644 --- a/include/sundials/sundials_adaptcontroller.h +++ b/include/sundials/sundials_adaptcontroller.h @@ -77,9 +77,9 @@ struct _generic_SUNAdaptController_Ops SUNErrCode (*write)(SUNAdaptController C, FILE* fptr); SUNErrCode (*seterrorbias)(SUNAdaptController C, sunrealtype bias); SUNErrCode (*updateh)(SUNAdaptController C, sunrealtype h, sunrealtype dsm); - SUNErrCode (*updatemritol)(SUNAdaptController C, sunrealtype H, - sunrealtype tolfac, sunrealtype DSM, - sunrealtype dsm); + SUNErrCode (*updatemrihtol)(SUNAdaptController C, sunrealtype H, + sunrealtype tolfac, sunrealtype DSM, + sunrealtype dsm); SUNErrCode (*space)(SUNAdaptController C, long int* lenrw, long int* leniw); }; diff --git a/src/sunadaptcontroller/mrihtol/sunadaptcontroller_mrihtol.c b/src/sunadaptcontroller/mrihtol/sunadaptcontroller_mrihtol.c index dc02ce58ab..fd25b48221 100644 --- a/src/sunadaptcontroller/mrihtol/sunadaptcontroller_mrihtol.c +++ b/src/sunadaptcontroller/mrihtol/sunadaptcontroller_mrihtol.c @@ -82,7 +82,7 @@ SUNAdaptController SUNAdaptController_MRIHTol(SUNAdaptController HControl, C->ops->setdefaults = SUNAdaptController_SetDefaults_MRIHTol; C->ops->write = SUNAdaptController_Write_MRIHTol; C->ops->seterrorbias = SUNAdaptController_SetErrorBias_MRIHTol; - C->ops->updatemritol = SUNAdaptController_UpdateMRIHTol_MRIHTol; + C->ops->updatemrihtol = SUNAdaptController_UpdateMRIHTol_MRIHTol; C->ops->space = SUNAdaptController_Space_MRIHTol; /* Create content */ diff --git a/src/sundials/sundials_adaptcontroller.c b/src/sundials/sundials_adaptcontroller.c index e841b08a60..4641f1751c 100644 --- a/src/sundials/sundials_adaptcontroller.c +++ b/src/sundials/sundials_adaptcontroller.c @@ -55,7 +55,7 @@ SUNAdaptController SUNAdaptController_NewEmpty(SUNContext sunctx) ops->write = NULL; ops->seterrorbias = NULL; ops->updateh = NULL; - ops->updatemritol = NULL; + ops->updatemrihtol = NULL; ops->space = NULL; /* attach ops and initialize content to NULL */ @@ -206,16 +206,16 @@ SUNErrCode SUNAdaptController_UpdateH(SUNAdaptController C, sunrealtype h, return (ier); } -SUNErrCode SUNAdaptController_UpdateMRITol(SUNAdaptController C, sunrealtype H, - sunrealtype tolfac, sunrealtype DSM, - sunrealtype dsm) +SUNErrCode SUNAdaptController_UpdateMRIHTol(SUNAdaptController C, sunrealtype H, + sunrealtype tolfac, sunrealtype DSM, + sunrealtype dsm) { SUNErrCode ier = SUN_SUCCESS; if (C == NULL) { return SUN_ERR_ARG_CORRUPT; } SUNFunctionBegin(C->sunctx); - if (C->ops->updatemritol) + if (C->ops->updatemrihtol) { - ier = C->ops->updatemritol(C, H, tolfac, DSM, dsm); + ier = C->ops->updatemrihtol(C, H, tolfac, DSM, dsm); } return (ier); } From 1d87908219c3d628a0f2e754dfb4fa3766d302c4 Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Thu, 24 Oct 2024 23:59:34 -0500 Subject: [PATCH 171/286] Adjusted order of initial checks in arkInitialSetup --- src/arkode/arkode.c | 64 ++++++++++++++++++++++----------------------- 1 file changed, 32 insertions(+), 32 deletions(-) diff --git a/src/arkode/arkode.c b/src/arkode/arkode.c index 5776349c3f..c55c6bde33 100644 --- a/src/arkode/arkode.c +++ b/src/arkode/arkode.c @@ -1851,6 +1851,14 @@ int arkInitialSetup(ARKodeMem ark_mem, sunrealtype tout) sunrealtype tout_hin, rh, htmp; sunbooleantype conOK; + /* Check that user has supplied an initial step size if fixedstep mode is on */ + if ((ark_mem->fixedstep) && (ark_mem->hin == ZERO)) + { + arkProcessError(ark_mem, ARK_ILL_INPUT, __LINE__, __func__, __FILE__, + "Fixed step mode enabled, but no step size set"); + return (ARK_ILL_INPUT); + } + /* If using a built-in routine for error/residual weights with abstol==0, ensure that N_VMin is available */ if ((!ark_mem->user_efun) && (ark_mem->atolmin0) && (!ark_mem->yn->ops->nvmin)) @@ -1867,6 +1875,30 @@ int arkInitialSetup(ARKodeMem ark_mem, sunrealtype tout) return (ARK_ILL_INPUT); } + /* Test input tstop for legality (correct direction of integration) */ + if (ark_mem->tstopset) + { + htmp = (ark_mem->h == ZERO) ? tout - ark_mem->tcur : ark_mem->h; + if ((ark_mem->tstop - ark_mem->tcur) * htmp <= ZERO) + { + arkProcessError(ark_mem, ARK_ILL_INPUT, __LINE__, __func__, __FILE__, + MSG_ARK_BAD_TSTOP, ark_mem->tstop, ark_mem->tcur); + return (ARK_ILL_INPUT); + } + } + + /* Check to see if y0 satisfies constraints */ + if (ark_mem->constraintsSet) + { + conOK = N_VConstrMask(ark_mem->constraints, ark_mem->yn, ark_mem->tempv1); + if (!conOK) + { + arkProcessError(ark_mem, ARK_ILL_INPUT, __LINE__, __func__, __FILE__, + MSG_ARK_Y0_FAIL_CONSTR); + return (ARK_ILL_INPUT); + } + } + /* Load initial error weights */ retval = ark_mem->efun(ark_mem->yn, ark_mem->ewt, ark_mem->e_data); if (retval != 0) @@ -1923,38 +1955,6 @@ int arkInitialSetup(ARKodeMem ark_mem, sunrealtype tout) } } - /* Check that user has supplied an initial step size if fixedstep mode is on */ - if ((ark_mem->fixedstep) && (ark_mem->hin == ZERO)) - { - arkProcessError(ark_mem, ARK_ILL_INPUT, __LINE__, __func__, __FILE__, - "Fixed step mode enabled, but no step size set"); - return (ARK_ILL_INPUT); - } - - /* Test input tstop for legality (correct direction of integration) */ - if (ark_mem->tstopset) - { - htmp = (ark_mem->h == ZERO) ? tout - ark_mem->tcur : ark_mem->h; - if ((ark_mem->tstop - ark_mem->tcur) * htmp <= ZERO) - { - arkProcessError(ark_mem, ARK_ILL_INPUT, __LINE__, __func__, __FILE__, - MSG_ARK_BAD_TSTOP, ark_mem->tstop, ark_mem->tcur); - return (ARK_ILL_INPUT); - } - } - - /* Check to see if y0 satisfies constraints */ - if (ark_mem->constraintsSet) - { - conOK = N_VConstrMask(ark_mem->constraints, ark_mem->yn, ark_mem->tempv1); - if (!conOK) - { - arkProcessError(ark_mem, ARK_ILL_INPUT, __LINE__, __func__, __FILE__, - MSG_ARK_Y0_FAIL_CONSTR); - return (ARK_ILL_INPUT); - } - } - /* Create default Hermite interpolation module (if needed) */ if (ark_mem->interp_type != ARK_INTERP_NONE && !(ark_mem->interp)) { From c56a22960212e47af80d3af4888314c204aa7ef9 Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Fri, 25 Oct 2024 08:19:35 -0500 Subject: [PATCH 172/286] Apply logging-related suggestions from code review to src/arkode.c Co-authored-by: David Gardner --- src/arkode/arkode_arkstep.c | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/src/arkode/arkode_arkstep.c b/src/arkode/arkode_arkstep.c index b2a3f042aa..272cbd5acf 100644 --- a/src/arkode/arkode_arkstep.c +++ b/src/arkode/arkode_arkstep.c @@ -1806,20 +1806,20 @@ int arkStep_TakeStep_Z(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr) #ifdef SUNDIALS_LOGGING_EXTRA_DEBUG SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, "ARKODE::arkStep_TakeStep_Z", "explicit stage", - "z[%i] =", 0); + "z_%i(:) =", 0); N_VPrintFile(ark_mem->ycur, ARK_LOGGER->debug_fp); if (step_mem->implicit) { SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, "ARKODE::arkStep_TakeStep_Z", "implicit RHS", - "Fi[%i] =", 0); + "Fi_%i(:) =", 0); N_VPrintFile(step_mem->Fi[0], ARK_LOGGER->debug_fp); } if (step_mem->explicit) { SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, "ARKODE::arkStep_TakeStep_Z", "explicit RHS", - "Fe[%i] =", 0); + "Fe_%i(:) =", 0); N_VPrintFile(step_mem->Fe[0], ARK_LOGGER->debug_fp); } #endif @@ -1887,7 +1887,8 @@ int arkStep_TakeStep_Z(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr) #ifdef SUNDIALS_LOGGING_EXTRA_DEBUG SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, - "ARKODE::arkStep_TakeStep_Z", "predictor", "zpred =", ""); + "ARKODE::arkStep_TakeStep_Z", "predictor", + "zpred(:) =", ""); N_VPrintFile(step_mem->zpred, ARK_LOGGER->debug_fp); #endif @@ -1897,7 +1898,8 @@ int arkStep_TakeStep_Z(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr) #ifdef SUNDIALS_LOGGING_EXTRA_DEBUG SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, - "ARKODE::arkStep_TakeStep_Z", "rhs data", "sdata =", ""); + "ARKODE::arkStep_TakeStep_Z", "rhs data", + "sdata(:) =", ""); N_VPrintFile(step_mem->sdata, ARK_LOGGER->debug_fp); #endif @@ -1912,7 +1914,7 @@ int arkStep_TakeStep_Z(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr) #ifdef SUNDIALS_LOGGING_EXTRA_DEBUG SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, "ARKODE::arkStep_TakeStep_Z", "implicit stage", - "z[%i] =", is); + "z_%i(:) =", is); N_VPrintFile(ark_mem->ycur, ARK_LOGGER->debug_fp); #endif @@ -1936,7 +1938,7 @@ int arkStep_TakeStep_Z(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr) #ifdef SUNDIALS_LOGGING_EXTRA_DEBUG SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, "ARKODE::arkStep_TakeStep_Z", "explicit stage", - "z[%i] =", is); + "z_%i(:) =", is); N_VPrintFile(ark_mem->ycur, ARK_LOGGER->debug_fp); #endif } @@ -1981,7 +1983,7 @@ int arkStep_TakeStep_Z(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr) #ifdef SUNDIALS_LOGGING_EXTRA_DEBUG SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, "ARKODE::arkStep_TakeStep_Z", "implicit RHS", - "Fi[%i] =", is); + "Fi_%i(:) =", is); N_VPrintFile(step_mem->Fi[is], ARK_LOGGER->debug_fp); #endif @@ -1999,7 +2001,7 @@ int arkStep_TakeStep_Z(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr) #ifdef SUNDIALS_LOGGING_EXTRA_DEBUG SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, "ARKODE::arkStep_TakeStep_Z", "explicit RHS", - "Fe[%i] =", is); + "Fe_%i(:) =", is); N_VPrintFile(step_mem->Fe[is], ARK_LOGGER->debug_fp); #endif @@ -2018,7 +2020,7 @@ int arkStep_TakeStep_Z(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr) #ifdef SUNDIALS_LOGGING_EXTRA_DEBUG SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, "ARKODE::arkStep_TakeStep_Z", "M^{-1} implicit RHS", - "Fi[%i] =", is); + "Fi_%i(:) =", is); N_VPrintFile(step_mem->Fi[is], ARK_LOGGER->debug_fp); #endif if (*nflagPtr != ARK_SUCCESS) { return (TRY_AGAIN); } @@ -2030,7 +2032,7 @@ int arkStep_TakeStep_Z(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr) #ifdef SUNDIALS_LOGGING_EXTRA_DEBUG SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, "ARKODE::arkStep_TakeStep_Z", "M^{-1} explicit RHS", - "Fe[%i] =", is); + "Fe_%i(:) =", is); N_VPrintFile(step_mem->Fe[is], ARK_LOGGER->debug_fp); #endif if (*nflagPtr != ARK_SUCCESS) { return (TRY_AGAIN); } @@ -2052,16 +2054,15 @@ int arkStep_TakeStep_Z(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr) #ifdef SUNDIALS_LOGGING_EXTRA_DEBUG SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, "ARKODE::arkStep_TakeStep_Z", - "updated solution", "ycur =", ""); + "updated solution", "ycur(:) =", ""); N_VPrintFile(ark_mem->ycur, ARK_LOGGER->debug_fp); #endif #if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_INFO SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_INFO, "ARKODE::arkStep_TakeStep_Z", "end-step", - "step = %li, t = %" RSYM ", h = %" RSYM ", dsm = %" RSYM - ", nflag = %d", - ark_mem->nst, ark_mem->tn, ark_mem->h, *dsmPtr, *nflagPtr); + "step = %li, h = %" RSYM ", dsm = %" RSYM ", nflag = %d", + ark_mem->nst, ark_mem->h, *dsmPtr, *nflagPtr); #endif return (ARK_SUCCESS); From 5068c347fa8e4279142259192abf424388b3b5d3 Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Fri, 25 Oct 2024 08:32:59 -0500 Subject: [PATCH 173/286] Apply logging-related, and "obvious" suggestions from code review to ERKStep and MRIStep Co-authored-by: David Gardner --- src/arkode/arkode_erkstep.c | 13 +++--- src/arkode/arkode_mristep.c | 84 +++++++++++++++++-------------------- 2 files changed, 45 insertions(+), 52 deletions(-) diff --git a/src/arkode/arkode_erkstep.c b/src/arkode/arkode_erkstep.c index e8717f45db..3030ddcad2 100644 --- a/src/arkode/arkode_erkstep.c +++ b/src/arkode/arkode_erkstep.c @@ -690,10 +690,10 @@ int erkStep_TakeStep(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr) #ifdef SUNDIALS_LOGGING_EXTRA_DEBUG SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, "ARKODE::erkStep_TakeStep", - "stage", "z[0] =", ""); + "stage", "z_0(:) =", ""); N_VPrintFile(ark_mem->ycur, ARK_LOGGER->debug_fp); SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, "ARKODE::erkStep_TakeStep", - "stage RHS", "F[0] =", ""); + "stage RHS", "F_0(:) =", ""); N_VPrintFile(step_mem->F[0], ARK_LOGGER->debug_fp); #endif @@ -769,7 +769,7 @@ int erkStep_TakeStep(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr) #ifdef SUNDIALS_LOGGING_EXTRA_DEBUG SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, - "ARKODE::erkStep_TakeStep", "stage RHS", "F[%i] =", is); + "ARKODE::erkStep_TakeStep", "stage RHS", "F_%i(:) =", is); N_VPrintFile(step_mem->F[is], ARK_LOGGER->debug_fp); #endif @@ -781,15 +781,14 @@ int erkStep_TakeStep(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr) #ifdef SUNDIALS_LOGGING_EXTRA_DEBUG SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, "ARKODE::erkStep_TakeStep", - "updated solution", "ycur =", ""); + "updated solution", "ycur(:) =", ""); N_VPrintFile(ark_mem->ycur, ARK_LOGGER->debug_fp); #endif #if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_DEBUG SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, "ARKODE::erkStep_TakeStep", - "end-step", - "step = %li, t = %" RSYM ", h = %" RSYM ", dsm = %" RSYM, - ark_mem->nst, ark_mem->tn, ark_mem->h, *dsmPtr); + "error-test", "step = %li, h = %" RSYM ", dsm = %" RSYM, + ark_mem->nst, ark_mem->h, *dsmPtr); #endif return (ARK_SUCCESS); diff --git a/src/arkode/arkode_mristep.c b/src/arkode/arkode_mristep.c index 0eacbb86dc..89ff25ace3 100644 --- a/src/arkode/arkode_mristep.c +++ b/src/arkode/arkode_mristep.c @@ -885,7 +885,7 @@ int mriStep_GetGammas(ARKodeMem ark_mem, sunrealtype* gamma, sunrealtype* gamrat With initialization types FIRST_INIT this routine: - sets/checks the coefficient tables to be used - - allocates any internal memory that depend on the MRI method + - allocates any internal memory that depends on the MRI method structure or solver options With other initialization types, this routine does nothing. @@ -951,6 +951,10 @@ int mriStep_Init(ARKodeMem ark_mem, int init_type) case MRISTEP_IMEX: ark_mem->step = mriStep_TakeStepMRIGARK; break; case MRISTEP_MERK: ark_mem->step = mriStep_TakeStepMERK; break; case MRISTEP_MRISR: ark_mem->step = mriStep_TakeStepMRISR; break; + default: + arkProcessError(ark_mem, ARK_ILL_INPUT, __LINE__, __func__, + __FILE__, "Unknown method type"); + return (ARK_ILL_INPUT); } /* Retrieve/store method and embedding orders now that tables are finalized */ @@ -961,7 +965,7 @@ int mriStep_Init(ARKodeMem ark_mem, int init_type) /* Ensure that if adaptivity or error accumulation is enabled, then method includes embedding coefficients */ if ((!ark_mem->fixedstep || (ark_mem->AccumErrorType != ARK_ACCUMERROR_NONE)) && - (step_mem->p == 0)) + (step_mem->p <= 0)) { arkProcessError(ark_mem, ARK_ILL_INPUT, __LINE__, __func__, __FILE__, "Temporal error estimation cannot be performed without embedding coefficients"); @@ -1246,9 +1250,8 @@ int mriStep_Init(ARKodeMem ark_mem, int init_type) if (ark_mem->fixedstep) { - /* Non-adaptive controller: user must have supplied initial step - size, and indicated fixed time stepping */ - if ((ark_mem->hin == ZERO) || (ark_mem->fixedstep == SUNFALSE)) + /* Fixed step sizes: user must supply the initial step size */ + if (ark_mem->hin == ZERO) { arkProcessError(ark_mem, ARK_ILL_INPUT, __LINE__, __func__, __FILE__, "Timestep adaptivity disabled, but missing user-defined fixed stepsize"); @@ -1269,7 +1272,7 @@ int mriStep_Init(ARKodeMem ark_mem, int init_type) /* Controller provides adaptivity (at least at the slow time scale): - verify that the MRI method includes an embedding, and - estimate initial slow step size (store in ark_mem->hin) */ - if (step_mem->MRIC->p == 0) + if (step_mem->MRIC->p <= 0) { arkProcessError(ark_mem, ARK_ILL_INPUT, __LINE__, __func__, __FILE__, "Timestep adaptivity enabled, but non-embedded MRI table specified"); @@ -1302,7 +1305,7 @@ int mriStep_Init(ARKodeMem ark_mem, int init_type) if (!mriStepInnerStepper_SupportsRTolAdaptivity(step_mem->stepper)) { arkProcessError(ark_mem, ARK_ILL_INPUT, __LINE__, __func__, - __FILE__, "MRI-TOL SUNAdaptController provided, but unsupported by inner stepper"); + __FILE__, "MRI H-TOL SUNAdaptController provided, but unsupported by inner stepper"); return (ARK_ILL_INPUT); } @@ -1801,23 +1804,20 @@ int mriStep_TakeStepMRIGARK(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPt #endif #ifdef SUNDIALS_LOGGING_EXTRA_DEBUG - SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, - "ARKODE::mriStep_TakeStepMRIGARK", "slow stage", - "z[0] =", ""); - N_VPrintFile(ark_mem->yn, ARK_LOGGER->debug_fp); + SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, "ARKODE::mriStep_TakeStep", + "slow stage", "z_0(:) =", ""); + N_VPrintFile(ark_mem->ycur, ARK_LOGGER->debug_fp); if (step_mem->explicit_rhs) { - SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, - "ARKODE::mriStep_TakeStepMRIGARK", "slow explicit RHS", - "Fse[0] =", ""); + SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, "ARKODE::mriStep_TakeStep", + "slow explicit RHS", "Fse_0(:) =", "") N_VPrintFile(step_mem->Fse[0], ARK_LOGGER->debug_fp); } if (step_mem->implicit_rhs) { - SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, - "ARKODE::mriStep_TakeStepMRIGARK", "slow implicit RHS", - "Fsi[0] =", ""); + SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, "ARKODE::mriStep_TakeStep", + "slow implicit RHS", "Fsi_0(:) =", ""); N_VPrintFile(step_mem->Fsi[0], ARK_LOGGER->debug_fp); } #endif @@ -1835,7 +1835,7 @@ int mriStep_TakeStepMRIGARK(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPt /* Solver diagnostics reporting */ #if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_DEBUG SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, - "ARKODE::mriStep_TakeStepMRIGARK", "start-stage", + "ARKODE::mriStep_TakeStep", "start-stage", "step = %li, stage = %i, stage type = %d, h = %" RSYM ", tcur = %" RSYM, ark_mem->nst, is, step_mem->stagetypes[is], ark_mem->h, @@ -1873,8 +1873,7 @@ int mriStep_TakeStepMRIGARK(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPt #ifdef SUNDIALS_LOGGING_EXTRA_DEBUG SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, - "ARKODE::mriStep_TakeStepMRIGARK", "slow stage", - "z[%i] =", is); + "ARKODE::mriStep_TakeStep", "slow stage", "z_%i(:) =", is); N_VPrintFile(ark_mem->ycur, ARK_LOGGER->debug_fp); #endif @@ -1941,8 +1940,8 @@ int mriStep_TakeStepMRIGARK(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPt #ifdef SUNDIALS_LOGGING_EXTRA_DEBUG SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, - "ARKODE::mriStep_TakeStepMRIGARK", - "slow explicit RHS", "Fse[%i] =", is); + "ARKODE::mriStep_TakeStep", "slow explicit RHS", + "Fse_%i(:) =", is); N_VPrintFile(step_mem->Fse[step_mem->stage_map[is]], ARK_LOGGER->debug_fp); #endif @@ -1982,8 +1981,8 @@ int mriStep_TakeStepMRIGARK(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPt #ifdef SUNDIALS_LOGGING_EXTRA_DEBUG SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, - "ARKODE::mriStep_TakeStepMRIGARK", - "slow implicit RHS", "Fsi[%i] =", is); + "ARKODE::mriStep_TakeStep", "slow implicit RHS", + "Fsi_%i(:) =", is); N_VPrintFile(step_mem->Fsi[step_mem->stage_map[is]], ARK_LOGGER->debug_fp); #endif @@ -2000,9 +1999,8 @@ int mriStep_TakeStepMRIGARK(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPt } /* loop over stages */ #ifdef SUNDIALS_LOGGING_EXTRA_DEBUG - SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, - "ARKODE::mriStep_TakeStepMRIGARK", "updated solution", - "ycur =", ""); + SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, "ARKODE::mriStep_TakeStep", + "updated solution", "ycur(:) =", ""); N_VPrintFile(ark_mem->ycur, ARK_LOGGER->debug_fp); #endif @@ -2086,10 +2084,9 @@ int mriStep_TakeStepMRIGARK(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPt /* Solver diagnostics reporting */ #if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_DEBUG - SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, - "ARKODE::mriStep_TakeStepMRIGARK", "end-step", - "step = %li, t = %" RSYM ", h = %" RSYM ", dsm = %" RSYM, - ark_mem->nst, ark_mem->tn, ark_mem->h, *dsmPtr); + SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, "ARKODE::mriStep_TakeStep", + "error-test", "step = %li, h = %" RSYM ", dsm = %" RSYM, + ark_mem->nst, ark_mem->h, *dsmPtr); #endif return (ARK_SUCCESS); @@ -2705,13 +2702,10 @@ int mriStep_TakeStepMERK(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr) "ARKODE::mriStep_TakeStepMERK", "slow stage", "z[0] =", ""); N_VPrintFile(ark_mem->yn, ARK_LOGGER->debug_fp); - if (step_mem->explicit_rhs) - { - SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, - "ARKODE::mriStep_TakeStepMERK", "slow explicit RHS", - "Fse[0] =", ""); - N_VPrintFile(step_mem->Fse[0], ARK_LOGGER->debug_fp); - } + SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, + "ARKODE::mriStep_TakeStepMERK", "slow explicit RHS", + "Fse[0] =", ""); + N_VPrintFile(step_mem->Fse[0], ARK_LOGGER->debug_fp); #endif /* The first stage is the previous time-step solution, so its RHS @@ -3488,7 +3482,7 @@ int mriStep_StageDIRKNoFast(ARKodeMem ark_mem, ARKodeMRIStepMem step_mem, #ifdef SUNDIALS_LOGGING_EXTRA_DEBUG SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, "ARKODE::mriStep_StageDIRKNoFast", "predictor", - "zpred =", ""); + "zpred(:) =", ""); N_VPrintFile(step_mem->zpred, ARK_LOGGER->debug_fp); #endif @@ -3504,7 +3498,7 @@ int mriStep_StageDIRKNoFast(ARKodeMem ark_mem, ARKodeMRIStepMem step_mem, #ifdef SUNDIALS_LOGGING_EXTRA_DEBUG SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, "ARKODE::mriStep_StageDIRKNoFast", "rhs data", - "sdata =", ""); + "sdata(:) =", ""); N_VPrintFile(step_mem->sdata, ARK_LOGGER->debug_fp); #endif @@ -3677,7 +3671,7 @@ int mriStep_ComputeInnerForcing(SUNDIALS_MAYBE_UNUSED ARKodeMem ark_mem, { SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, "ARKODE::mriStep_ComputeInnerForcing", "forcing", - "forcing[%i] =", k); + "forcing_%i(:) =", k); N_VPrintFile(step_mem->stepper->forcing[k], ARK_LOGGER->debug_fp); } #endif @@ -3957,7 +3951,7 @@ int mriStep_StageSetup(ARKodeMem ark_mem) ARKTimestepFullRHSFn. This is only used to determine an initial slow time-step size to use when one is not specified by the user (i.e., mode should correspond with - ARK_FULLRHS_OTHER. + ARK_FULLRHS_START. ---------------------------------------------------------------*/ int mriStep_SlowRHS(ARKodeMem ark_mem, sunrealtype t, N_Vector y, N_Vector f, SUNDIALS_MAYBE_UNUSED int mode) @@ -4389,7 +4383,7 @@ int mriStepInnerStepper_Evolve(MRIStepInnerStepper stepper, sunrealtype t0, if (stepper->ops == NULL) { return ARK_ILL_INPUT; } if (stepper->ops->evolve == NULL) { return ARK_ILL_INPUT; } -#if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_INFO +#if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_DEBUG SUNLogger_QueueMsg(stepper->sunctx->logger, SUN_LOGLEVEL_INFO, "ARKODE::mriStepInnerStepper_Evolve", "start-inner-evolve", "t0 = %" RSYM ", tout = %" RSYM, t0, tout); @@ -4397,7 +4391,7 @@ int mriStepInnerStepper_Evolve(MRIStepInnerStepper stepper, sunrealtype t0, stepper->last_flag = stepper->ops->evolve(stepper, t0, tout, y); -#if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_INFO +#if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_DEBUG SUNLogger_QueueMsg(stepper->sunctx->logger, SUN_LOGLEVEL_INFO, "ARKODE::mriStepInnerStepper_Evolve", "end-inner-evolve", "flag = %i", stepper->last_flag); @@ -4670,7 +4664,7 @@ void mriStep_ApplyForcing(ARKodeMRIStepMem step_mem, sunrealtype t, Sets an array of coefficient vectors for a time-dependent external polynomial forcing term in the ODE RHS i.e., y' = f(t,y) + p(t). This function is primarily intended for using MRIStep as an inner integrator within another - [outer] instance of MRIStep, where this instance is is used to solve a + [outer] instance of MRIStep, where this instance is used to solve a modified ODE at a fast time scale. The polynomial is of the form p(t) = sum_{i = 0}^{nvecs - 1} forcing[i] * ((t - tshift) / (tscale))^i From 5a025937ac53e9c23d2319705cd4c043481b02a0 Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Fri, 25 Oct 2024 08:34:20 -0500 Subject: [PATCH 174/286] Updated Swig interfaces --- src/sundials/fmod_int32/fsundials_core_mod.f90 | 2 +- src/sundials/fmod_int64/fsundials_core_mod.f90 | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/sundials/fmod_int32/fsundials_core_mod.f90 b/src/sundials/fmod_int32/fsundials_core_mod.f90 index 6756c36b1a..60b6da39ce 100644 --- a/src/sundials/fmod_int32/fsundials_core_mod.f90 +++ b/src/sundials/fmod_int32/fsundials_core_mod.f90 @@ -526,7 +526,7 @@ module fsundials_core_mod type(C_FUNPTR), public :: write type(C_FUNPTR), public :: seterrorbias type(C_FUNPTR), public :: updateh - type(C_FUNPTR), public :: updatemritol + type(C_FUNPTR), public :: updatemrihtol type(C_FUNPTR), public :: space end type SUNAdaptController_Ops ! struct struct _generic_SUNAdaptController diff --git a/src/sundials/fmod_int64/fsundials_core_mod.f90 b/src/sundials/fmod_int64/fsundials_core_mod.f90 index c0d5a10e05..a157807b05 100644 --- a/src/sundials/fmod_int64/fsundials_core_mod.f90 +++ b/src/sundials/fmod_int64/fsundials_core_mod.f90 @@ -526,7 +526,7 @@ module fsundials_core_mod type(C_FUNPTR), public :: write type(C_FUNPTR), public :: seterrorbias type(C_FUNPTR), public :: updateh - type(C_FUNPTR), public :: updatemritol + type(C_FUNPTR), public :: updatemrihtol type(C_FUNPTR), public :: space end type SUNAdaptController_Ops ! struct struct _generic_SUNAdaptController From bb093b86f5709ab52faaab9c6326587469bfc58e Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Fri, 25 Oct 2024 08:34:54 -0500 Subject: [PATCH 175/286] Formatting --- include/sunadaptcontroller/sunadaptcontroller_mrihtol.h | 6 +++--- src/arkode/arkode_arkstep.c | 2 +- src/arkode/arkode_mristep.c | 6 +++--- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/include/sunadaptcontroller/sunadaptcontroller_mrihtol.h b/include/sunadaptcontroller/sunadaptcontroller_mrihtol.h index 8a2c3a46e3..9f100353f1 100644 --- a/include/sunadaptcontroller/sunadaptcontroller_mrihtol.h +++ b/include/sunadaptcontroller/sunadaptcontroller_mrihtol.h @@ -74,9 +74,9 @@ SUNDIALS_EXPORT int SUNAdaptController_SetErrorBias_MRIHTol(SUNAdaptController C, sunrealtype bias); SUNDIALS_EXPORT -int SUNAdaptController_UpdateMRIHTol_MRIHTol(SUNAdaptController C, sunrealtype H, - sunrealtype tolfac, sunrealtype DSM, - sunrealtype dsm); +int SUNAdaptController_UpdateMRIHTol_MRIHTol(SUNAdaptController C, + sunrealtype H, sunrealtype tolfac, + sunrealtype DSM, sunrealtype dsm); SUNDIALS_EXPORT int SUNAdaptController_Space_MRIHTol(SUNAdaptController C, long int* lenrw, long int* leniw); diff --git a/src/arkode/arkode_arkstep.c b/src/arkode/arkode_arkstep.c index 272cbd5acf..dfd941c6e9 100644 --- a/src/arkode/arkode_arkstep.c +++ b/src/arkode/arkode_arkstep.c @@ -2061,7 +2061,7 @@ int arkStep_TakeStep_Z(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr) #if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_INFO SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_INFO, "ARKODE::arkStep_TakeStep_Z", "end-step", - "step = %li, h = %" RSYM ", dsm = %" RSYM ", nflag = %d", + "step = %li, h = %" RSYM ", dsm = %" RSYM ", nflag = %d", ark_mem->nst, ark_mem->h, *dsmPtr, *nflagPtr); #endif diff --git a/src/arkode/arkode_mristep.c b/src/arkode/arkode_mristep.c index 89ff25ace3..02c986a147 100644 --- a/src/arkode/arkode_mristep.c +++ b/src/arkode/arkode_mristep.c @@ -952,8 +952,8 @@ int mriStep_Init(ARKodeMem ark_mem, int init_type) case MRISTEP_MERK: ark_mem->step = mriStep_TakeStepMERK; break; case MRISTEP_MRISR: ark_mem->step = mriStep_TakeStepMRISR; break; default: - arkProcessError(ark_mem, ARK_ILL_INPUT, __LINE__, __func__, - __FILE__, "Unknown method type"); + arkProcessError(ark_mem, ARK_ILL_INPUT, __LINE__, __func__, __FILE__, + "Unknown method type"); return (ARK_ILL_INPUT); } @@ -1812,7 +1812,7 @@ int mriStep_TakeStepMRIGARK(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPt { SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, "ARKODE::mriStep_TakeStep", "slow explicit RHS", "Fse_0(:) =", "") - N_VPrintFile(step_mem->Fse[0], ARK_LOGGER->debug_fp); + N_VPrintFile(step_mem->Fse[0], ARK_LOGGER->debug_fp); } if (step_mem->implicit_rhs) { From de3d2db8a4b76b240eaa34dabc912682642d026f Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Fri, 25 Oct 2024 08:39:43 -0500 Subject: [PATCH 176/286] Removed failing single-precision test (too much accuracy requested) --- examples/arkode/C_serial/CMakeLists.txt | 2 +- test/answers | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/arkode/C_serial/CMakeLists.txt b/examples/arkode/C_serial/CMakeLists.txt index 5637d4b54a..4efb840356 100644 --- a/examples/arkode/C_serial/CMakeLists.txt +++ b/examples/arkode/C_serial/CMakeLists.txt @@ -73,7 +73,7 @@ set(ARKODE_examples "ark_kpr_mri\;10 4 0.001 -100 100 0.5 1\;exclude-single" "ark_kpr_mri\;11 2 0.001\;develop" "ark_kpr_mri\;12 3 0.005\;develop" - "ark_kpr_mri\;13 4 0.01\;develop" + "ark_kpr_mri\;13 4 0.01\;exclude-single" "ark_KrylovDemo_prec\;\;exclude-single" "ark_KrylovDemo_prec\;1\;exclude-single" "ark_KrylovDemo_prec\;2\;exclude-single" diff --git a/test/answers b/test/answers index 45f0dce737..cbf335f7e2 160000 --- a/test/answers +++ b/test/answers @@ -1 +1 @@ -Subproject commit 45f0dce73762b88bcc62139b0f76fc9cd107739d +Subproject commit cbf335f7e244de7c12a4dbd638b4e0f02811a4a3 From b5d9a82fadb0fc0a1ccb48354e0e220a818453b2 Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Fri, 25 Oct 2024 08:43:50 -0500 Subject: [PATCH 177/286] Fixed error introduced from code suggestion --- src/arkode/arkode_mristep.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/arkode/arkode_mristep.c b/src/arkode/arkode_mristep.c index 02c986a147..9bb6c4ba5d 100644 --- a/src/arkode/arkode_mristep.c +++ b/src/arkode/arkode_mristep.c @@ -1811,8 +1811,8 @@ int mriStep_TakeStepMRIGARK(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPt if (step_mem->explicit_rhs) { SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, "ARKODE::mriStep_TakeStep", - "slow explicit RHS", "Fse_0(:) =", "") - N_VPrintFile(step_mem->Fse[0], ARK_LOGGER->debug_fp); + "slow explicit RHS", "Fse_0(:) =", ""); + N_VPrintFile(step_mem->Fse[0], ARK_LOGGER->debug_fp); } if (step_mem->implicit_rhs) { From 2fa3ee2ace558a120437f0cd7b845d61c225ffac Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Fri, 25 Oct 2024 09:50:50 -0500 Subject: [PATCH 178/286] Apply a few more minor/assorted suggestions from code review Co-authored-by: David Gardner --- src/arkode/arkode_mri_tables.c | 3 +-- src/arkode/arkode_mristep_impl.h | 2 +- src/sunadaptcontroller/mrihtol/sunadaptcontroller_mrihtol.c | 2 +- .../arkode/CXX_serial/ark_test_accumerror_kpr.cpp | 6 +----- 4 files changed, 4 insertions(+), 9 deletions(-) diff --git a/src/arkode/arkode_mri_tables.c b/src/arkode/arkode_mri_tables.c index 0c85a2ea72..ecae4773f3 100644 --- a/src/arkode/arkode_mri_tables.c +++ b/src/arkode/arkode_mri_tables.c @@ -895,8 +895,7 @@ int mriStepCoupling_GetStageMap(MRIStepCoupling MRIC, int* stage_map, /* Number of stage RHS vectors active */ *nstages_active = MRIC->stages; - /* Check if a stage corresponds to a column of zeros for all coupling - * matrices by computing the column sums */ + /* Create an identity map (all columns are non-zero) */ for (j = 0; j < MRIC->stages; j++) { stage_map[j] = j; } return (ARK_SUCCESS); } diff --git a/src/arkode/arkode_mristep_impl.h b/src/arkode/arkode_mristep_impl.h index c3bc789b4d..0a5fc99dc6 100644 --- a/src/arkode/arkode_mristep_impl.h +++ b/src/arkode/arkode_mristep_impl.h @@ -109,7 +109,7 @@ typedef struct ARKodeMRIStepMemRec sunrealtype nlscoef; /* coefficient in nonlin. convergence test */ int msbp; /* positive => max # steps between lsetup - negative => call at each Newton iter */ + negative => call at each Newton iter */ long int nstlp; /* step number of last setup call */ int maxcor; /* max num iterations for solving the diff --git a/src/sunadaptcontroller/mrihtol/sunadaptcontroller_mrihtol.c b/src/sunadaptcontroller/mrihtol/sunadaptcontroller_mrihtol.c index fd25b48221..202779f7ef 100644 --- a/src/sunadaptcontroller/mrihtol/sunadaptcontroller_mrihtol.c +++ b/src/sunadaptcontroller/mrihtol/sunadaptcontroller_mrihtol.c @@ -102,7 +102,7 @@ SUNAdaptController SUNAdaptController_MRIHTol(SUNAdaptController HControl, /* Attach content */ C->content = content; - return (C); + return C; } /* ----------------------------------------------------------------- diff --git a/test/unit_tests/arkode/CXX_serial/ark_test_accumerror_kpr.cpp b/test/unit_tests/arkode/CXX_serial/ark_test_accumerror_kpr.cpp index 472b7453c9..3707bff97c 100644 --- a/test/unit_tests/arkode/CXX_serial/ark_test_accumerror_kpr.cpp +++ b/test/unit_tests/arkode/CXX_serial/ark_test_accumerror_kpr.cpp @@ -280,11 +280,7 @@ int main(int argc, char* argv[]) } // Clean up and return - if (rk_type == 0) - { // Free integrator memory - ARKodeFree(&arkode_mem); - } - else { ARKodeFree(&arkode_mem); } + ARKodeFree(&arkode_mem); if (LS != NULL) SUNLinSolFree(LS); // free system linear solver if (A != NULL) SUNMatDestroy(A); // free system matrix N_VDestroy(y); // Free y vector From 676535af4bf5d3ce1a312ea3afb8aef9620669f8 Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Fri, 25 Oct 2024 17:43:57 -0500 Subject: [PATCH 179/286] Applied suggestion from code review regarding vector operation error test --- src/arkode/arkode_mristep.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/arkode/arkode_mristep.c b/src/arkode/arkode_mristep.c index 9bb6c4ba5d..cae37a4a48 100644 --- a/src/arkode/arkode_mristep.c +++ b/src/arkode/arkode_mristep.c @@ -2322,11 +2322,7 @@ int mriStep_TakeStepMRISR(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr) step_mem->explicit_rhs = SUNTRUE; retval = mriStep_ComputeInnerForcing(ark_mem, step_mem, stage, ark_mem->tn, ark_mem->tn + cstage * ark_mem->h); - if (retval != ARK_SUCCESS) - { - *nflagPtr = CONV_FAIL; - break; - } + if (retval != ARK_SUCCESS) { return retval; } step_mem->implicit_rhs = store_imprhs; step_mem->explicit_rhs = store_exprhs; From b01b640b170664a83f5e8b8eee023cdedaf846e4 Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Fri, 25 Oct 2024 17:51:04 -0500 Subject: [PATCH 180/286] Renamed mriStepInnerStepper_GetError and mriStepInnerStepper_ResetError to mriStepInnerStepper_GetAccumulatedError and mriStepInnerStepper_ResetAccumulatedError --- src/arkode/arkode_mristep.c | 16 ++++++++-------- src/arkode/arkode_mristep_impl.h | 6 +++--- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/arkode/arkode_mristep.c b/src/arkode/arkode_mristep.c index cae37a4a48..c82f444af9 100644 --- a/src/arkode/arkode_mristep.c +++ b/src/arkode/arkode_mristep.c @@ -1708,7 +1708,7 @@ int mriStep_TakeStepMRIGARK(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPt { need_inner_dsm = SUNTRUE; step_mem->inner_dsm = ZERO; - retval = mriStepInnerStepper_ResetError(step_mem->stepper); + retval = mriStepInnerStepper_ResetAccumulatedError(step_mem->stepper); if (retval != ARK_SUCCESS) { arkProcessError(ark_mem, ARK_INNERSTEP_FAIL, __LINE__, __func__, __FILE__, @@ -2168,7 +2168,7 @@ int mriStep_TakeStepMRISR(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr) { need_inner_dsm = SUNTRUE; step_mem->inner_dsm = ZERO; - retval = mriStepInnerStepper_ResetError(step_mem->stepper); + retval = mriStepInnerStepper_ResetAccumulatedError(step_mem->stepper); if (retval != ARK_SUCCESS) { arkProcessError(ark_mem, ARK_INNERSTEP_FAIL, __LINE__, __func__, __FILE__, @@ -2634,7 +2634,7 @@ int mriStep_TakeStepMERK(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr) { need_inner_dsm = SUNTRUE; step_mem->inner_dsm = ZERO; - retval = mriStepInnerStepper_ResetError(step_mem->stepper); + retval = mriStepInnerStepper_ResetAccumulatedError(step_mem->stepper); if (retval != ARK_SUCCESS) { arkProcessError(ark_mem, ARK_INNERSTEP_FAIL, __LINE__, __func__, __FILE__, @@ -3348,8 +3348,8 @@ int mriStep_StageERKFast(ARKodeMem ark_mem, ARKodeMRIStepMem step_mem, /* if the fast integrator uses adaptive steps, retrieve the error estimate */ if (adapt_type == SUN_ADAPTCONTROLLER_MRI_H_TOL) { - retval = mriStepInnerStepper_GetError(step_mem->stepper, - &(step_mem->inner_dsm)); + retval = mriStepInnerStepper_GetAccumulatedError(step_mem->stepper, + &(step_mem->inner_dsm)); if (retval != ARK_SUCCESS) { arkProcessError(ark_mem, ARK_INNERSTEP_FAIL, __LINE__, __func__, @@ -4436,8 +4436,8 @@ int mriStepInnerStepper_Reset(MRIStepInnerStepper stepper, sunrealtype tR, } /* Gets the inner (fast) stepper accumulated error */ -int mriStepInnerStepper_GetError(MRIStepInnerStepper stepper, - sunrealtype* accum_error) +int mriStepInnerStepper_GetAccumulatedError(MRIStepInnerStepper stepper, + sunrealtype* accum_error) { if (stepper == NULL) { return ARK_ILL_INPUT; } if (stepper->ops == NULL) { return ARK_ILL_INPUT; } @@ -4451,7 +4451,7 @@ int mriStepInnerStepper_GetError(MRIStepInnerStepper stepper, } /* Resets the inner (fast) stepper accumulated error */ -int mriStepInnerStepper_ResetError(MRIStepInnerStepper stepper) +int mriStepInnerStepper_ResetAccumulatedError(MRIStepInnerStepper stepper) { if (stepper == NULL) { return ARK_ILL_INPUT; } if (stepper->ops == NULL) { return ARK_ILL_INPUT; } diff --git a/src/arkode/arkode_mristep_impl.h b/src/arkode/arkode_mristep_impl.h index c3bc789b4d..588072468e 100644 --- a/src/arkode/arkode_mristep_impl.h +++ b/src/arkode/arkode_mristep_impl.h @@ -314,9 +314,9 @@ int mriStepInnerStepper_FullRhs(MRIStepInnerStepper stepper, sunrealtype t, N_Vector y, N_Vector f, int mode); int mriStepInnerStepper_Reset(MRIStepInnerStepper stepper, sunrealtype tR, N_Vector yR); -int mriStepInnerStepper_GetError(MRIStepInnerStepper stepper, - sunrealtype* accum_error); -int mriStepInnerStepper_ResetError(MRIStepInnerStepper stepper); +int mriStepInnerStepper_GetAccumulatedError(MRIStepInnerStepper stepper, + sunrealtype* accum_error); +int mriStepInnerStepper_ResetAccumulatedError(MRIStepInnerStepper stepper); int mriStepInnerStepper_SetRTol(MRIStepInnerStepper stepper, sunrealtype rtol); int mriStepInnerStepper_AllocVecs(MRIStepInnerStepper stepper, int count, N_Vector tmpl); From 7861a5f7f6affca6636453bb4b4cf1762c446ef1 Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Fri, 25 Oct 2024 17:55:54 -0500 Subject: [PATCH 181/286] Removed mriStep_FastRHS --- src/arkode/arkode_mristep.c | 32 -------------------------------- src/arkode/arkode_mristep_impl.h | 2 -- 2 files changed, 34 deletions(-) diff --git a/src/arkode/arkode_mristep.c b/src/arkode/arkode_mristep.c index c82f444af9..30bfd9feac 100644 --- a/src/arkode/arkode_mristep.c +++ b/src/arkode/arkode_mristep.c @@ -4019,38 +4019,6 @@ int mriStep_SlowRHS(ARKodeMem ark_mem, sunrealtype t, N_Vector y, N_Vector f, return (ARK_SUCCESS); } -/*--------------------------------------------------------------- - mriStep_FastRHS: - - This is just a wrapper to call the fast RHS function, - f(t,y) = ff(t,y), with API matching ARKTimestepFullRHSFn. This - is only used to determine an initial fast time-step size to use - when one is not specified by the user and H-H MRI time step - adaptivity is enabled. - ---------------------------------------------------------------*/ -int mriStep_FastRHS(ARKodeMem ark_mem, sunrealtype t, N_Vector y, N_Vector f, - SUNDIALS_MAYBE_UNUSED int mode) -{ - ARKodeMRIStepMem step_mem; - int retval; - - /* access ARKodeMRIStepMem structure */ - retval = mriStep_AccessStepMem(ark_mem, __func__, &step_mem); - if (retval != ARK_SUCCESS) { return (retval); } - - /* call ff */ - retval = mriStepInnerStepper_FullRhs(step_mem->stepper, t, y, f, - ARK_FULLRHS_OTHER); - if (retval != ARK_SUCCESS) - { - arkProcessError(ark_mem, ARK_RHSFUNC_FAIL, __LINE__, __func__, __FILE__, - MSG_ARK_RHSFUNC_FAILED, t); - return (ARK_RHSFUNC_FAIL); - } - - return (ARK_SUCCESS); -} - /*--------------------------------------------------------------- mriStep_Hin diff --git a/src/arkode/arkode_mristep_impl.h b/src/arkode/arkode_mristep_impl.h index d3a6ff57d5..dcafe48b05 100644 --- a/src/arkode/arkode_mristep_impl.h +++ b/src/arkode/arkode_mristep_impl.h @@ -288,8 +288,6 @@ int mriStep_NlsInit(ARKodeMem ark_mem); int mriStep_Nls(ARKodeMem ark_mem, int nflag); int mriStep_SlowRHS(ARKodeMem ark_mem, sunrealtype t, N_Vector y, N_Vector f, int mode); -int mriStep_FastRHS(ARKodeMem ark_mem, sunrealtype t, N_Vector y, N_Vector f, - int mode); int mriStep_Hin(ARKodeMem ark_mem, sunrealtype tcur, sunrealtype tout, N_Vector fcur, sunrealtype* h); void mriStep_ApplyForcing(ARKodeMRIStepMem step_mem, sunrealtype t, From a874f702749b987f27b1dff32a8a91d4986ba853 Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Fri, 25 Oct 2024 18:19:11 -0500 Subject: [PATCH 182/286] Applied suggestions from code review (primarily logging-based, plus some assorted readability changes --- src/arkode/arkode_mristep.c | 97 +++++++++++++++------------------- src/arkode/arkode_relaxation.c | 2 +- 2 files changed, 45 insertions(+), 54 deletions(-) diff --git a/src/arkode/arkode_mristep.c b/src/arkode/arkode_mristep.c index 30bfd9feac..dd1c5b80fb 100644 --- a/src/arkode/arkode_mristep.c +++ b/src/arkode/arkode_mristep.c @@ -1694,7 +1694,6 @@ int mriStep_TakeStepMRIGARK(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPt /* initial time and state for step */ N_VScale(ONE, ark_mem->yn, ark_mem->ycur); - t0 = ark_mem->tn; /* determine whether embedding stage is needed */ do_embedding = !ark_mem->fixedstep || @@ -1730,7 +1729,7 @@ int mriStep_TakeStepMRIGARK(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPt to the beginning of this step (in case of recomputation) */ if (!ark_mem->fixedstep) { - retval = mriStepInnerStepper_Reset(step_mem->stepper, t0, ark_mem->yn); + retval = mriStepInnerStepper_Reset(step_mem->stepper, ark_mem->tn, ark_mem->yn); if (retval != ARK_SUCCESS) { arkProcessError(ark_mem, ARK_INNERSTEP_FAIL, __LINE__, __func__, __FILE__, @@ -1760,7 +1759,7 @@ int mriStep_TakeStepMRIGARK(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPt /* compute the explicit component */ if (step_mem->explicit_rhs) { - retval = step_mem->fse(t0, ark_mem->yn, step_mem->Fse[0], + retval = step_mem->fse(ark_mem->tn, ark_mem->yn, step_mem->Fse[0], ark_mem->user_data); step_mem->nfse++; if (retval) { return ARK_RHSFUNC_FAIL; } @@ -1769,7 +1768,7 @@ int mriStep_TakeStepMRIGARK(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPt /* compute the implicit component */ if (step_mem->implicit_rhs) { - retval = step_mem->fsi(t0, ark_mem->yn, step_mem->Fsi[0], + retval = step_mem->fsi(ark_mem->tn, ark_mem->yn, step_mem->Fsi[0], ark_mem->user_data); step_mem->nfsi++; if (retval) { return ARK_RHSFUNC_FAIL; } @@ -1781,7 +1780,7 @@ int mriStep_TakeStepMRIGARK(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPt step_mem->cvals[0] = ONE; step_mem->Xvecs[0] = step_mem->Fse[0]; nvec = 1; - mriStep_ApplyForcing(step_mem, t0, ONE, &nvec); + mriStep_ApplyForcing(step_mem, ark_mem->tn, ONE, &nvec); N_VLinearCombination(nvec, step_mem->cvals, step_mem->Xvecs, step_mem->Fse[0]); } @@ -1790,7 +1789,7 @@ int mriStep_TakeStepMRIGARK(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPt step_mem->cvals[0] = ONE; step_mem->Xvecs[0] = step_mem->Fsi[0]; nvec = 1; - mriStep_ApplyForcing(step_mem, t0, ONE, &nvec); + mriStep_ApplyForcing(step_mem, ark_mem->tn, ONE, &nvec); N_VLinearCombination(nvec, step_mem->cvals, step_mem->Xvecs, step_mem->Fsi[0]); } @@ -1800,7 +1799,7 @@ int mriStep_TakeStepMRIGARK(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPt #ifdef SUNDIALS_DEBUG printf(" MRIStep step %li, stage 0, h = %" RSYM ", t_n = %" RSYM "\n", - ark_mem->nst, ark_mem->h, t0); + ark_mem->nst, ark_mem->h, ark_mem->tn); #endif #ifdef SUNDIALS_LOGGING_EXTRA_DEBUG @@ -1849,11 +1848,7 @@ int mriStep_TakeStepMRIGARK(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPt { case (MRISTAGE_ERK_FAST): retval = mriStep_ComputeInnerForcing(ark_mem, step_mem, is, t0, tf); - if (retval != ARK_SUCCESS) - { - *nflagPtr = CONV_FAIL; - break; - } + if (retval != ARK_SUCCESS) { return retval; } retval = mriStep_StageERKFast(ark_mem, step_mem, t0, tf, ark_mem->ycur, ark_mem->tempv2, SUNFALSE, need_inner_dsm); if (retval != ARK_SUCCESS) { *nflagPtr = CONV_FAIL; } @@ -1881,7 +1876,7 @@ int mriStep_TakeStepMRIGARK(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPt if ((ark_mem->ProcessStage != NULL) && (step_mem->stagetypes[is] != MRISTAGE_STIFF_ACC)) { - retval = ark_mem->ProcessStage(tf, ark_mem->ycur, ark_mem->user_data); + retval = ark_mem->ProcessStage(ark_mem->tcur, ark_mem->ycur, ark_mem->user_data); if (retval != 0) { return (ARK_POSTPROCESS_STAGE_FAIL); } } @@ -1920,7 +1915,7 @@ int mriStep_TakeStepMRIGARK(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPt /* store explicit slow rhs */ if (step_mem->explicit_rhs) { - retval = step_mem->fse(tf, ark_mem->ycur, + retval = step_mem->fse(ark_mem->tcur, ark_mem->ycur, step_mem->Fse[step_mem->stage_map[is]], ark_mem->user_data); step_mem->nfse++; @@ -1953,7 +1948,7 @@ int mriStep_TakeStepMRIGARK(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPt if (!step_mem->deduce_rhs || (step_mem->stagetypes[is] != MRISTAGE_DIRK_NOFAST)) { - retval = step_mem->fsi(tf, ark_mem->ycur, + retval = step_mem->fsi(ark_mem->tcur, ark_mem->ycur, step_mem->Fsi[step_mem->stage_map[is]], ark_mem->user_data); step_mem->nfsi++; @@ -2025,7 +2020,7 @@ int mriStep_TakeStepMRIGARK(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPt /* Solver diagnostics reporting */ #if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_DEBUG SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, - "ARKODE::mriStep_TakeStepMRIGARK", "embedding-stage", + "ARKODE::mriStep_TakeStep", "embedding-stage", "step = %li, stage = %i, stage type = %d, h = %" RSYM ", tcur = %" RSYM, ark_mem->nst, step_mem->stages, @@ -2041,11 +2036,7 @@ int mriStep_TakeStepMRIGARK(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPt case (MRISTAGE_ERK_FAST): retval = mriStep_ComputeInnerForcing(ark_mem, step_mem, step_mem->stages, t0, tf); - if (retval != ARK_SUCCESS) - { - *nflagPtr = CONV_FAIL; - break; - } + if (retval != ARK_SUCCESS) { return retval; } retval = mriStep_StageERKFast(ark_mem, step_mem, t0, tf, ark_mem->ycur, ark_mem->tempv2, SUNTRUE, SUNFALSE); if (retval != ARK_SUCCESS) { *nflagPtr = CONV_FAIL; } @@ -2066,8 +2057,8 @@ int mriStep_TakeStepMRIGARK(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPt #ifdef SUNDIALS_LOGGING_EXTRA_DEBUG SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, - "ARKODE::mriStep_TakeStepMRIGARK", "embedded solution", - "ytilde =", ""); + "ARKODE::mriStep_TakeStep", "embedded solution", + "ytilde(:) =", ""); N_VPrintFile(ark_mem->ycur, ARK_LOGGER->debug_fp); #endif @@ -2261,22 +2252,22 @@ int mriStep_TakeStepMRISR(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr) #ifdef SUNDIALS_LOGGING_EXTRA_DEBUG SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, - "ARKODE::mriStep_TakeStepMRISR", "slow stage", "z[0] =", ""); + "ARKODE::mriStep_TakeStep", "slow stage", "z_0(:) =", ""); N_VPrintFile(ark_mem->yn, ARK_LOGGER->debug_fp); if (step_mem->explicit_rhs) { SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, - "ARKODE::mriStep_TakeStepMRISR", "slow explicit RHS", - "Fse[0] =", ""); + "ARKODE::mriStep_TakeStep", "slow explicit RHS", + "Fse_0(:) =", ""); N_VPrintFile(step_mem->Fse[0], ARK_LOGGER->debug_fp); } if (step_mem->implicit_rhs) { SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, - "ARKODE::mriStep_TakeStepMRISR", "slow implicit RHS", - "Fsi[0] =", ""); + "ARKODE::mriStep_TakeStep", "slow implicit RHS", + "Fsi_0(:) =", ""); N_VPrintFile(step_mem->Fsi[0], ARK_LOGGER->debug_fp); } #endif @@ -2290,7 +2281,7 @@ int mriStep_TakeStepMRISR(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr) /* Solver diagnostics reporting */ #if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_DEBUG SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, - "ARKODE::mriStep_TakeStepMRISR", "start-stage", + "ARKODE::mriStep_TakeStep", "start-stage", "step = %li, stage = %i, h = %" RSYM, ark_mem->nst, stage, ark_mem->h); #endif @@ -2369,8 +2360,8 @@ int mriStep_TakeStepMRISR(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr) #ifdef SUNDIALS_LOGGING_EXTRA_DEBUG SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, - "ARKODE::mriStep_TakeStepMRISR", "predictor", - "zpred =", ""); + "ARKODE::mriStep_TakeStep", "predictor", + "zpred(:) =", ""); N_VPrintFile(step_mem->zpred, ARK_LOGGER->debug_fp); #endif @@ -2390,8 +2381,8 @@ int mriStep_TakeStepMRISR(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr) #ifdef SUNDIALS_LOGGING_EXTRA_DEBUG SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, - "ARKODE::mriStep_TakeStepMRISR", "rhs data", - "sdata =", ""); + "ARKODE::mriStep_TakeStep", "rhs data", + "sdata(:) =", ""); N_VPrintFile(step_mem->sdata, ARK_LOGGER->debug_fp); #endif @@ -2424,8 +2415,8 @@ int mriStep_TakeStepMRISR(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr) #ifdef SUNDIALS_LOGGING_EXTRA_DEBUG SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, - "ARKODE::mriStep_TakeStepMRISR", "slow stage", - "z[%i] =", stage); + "ARKODE::mriStep_TakeStep", "slow stage", + "z_%i(:) =", stage); N_VPrintFile(ark_mem->ycur, ARK_LOGGER->debug_fp); #endif @@ -2471,8 +2462,8 @@ int mriStep_TakeStepMRISR(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr) #ifdef SUNDIALS_LOGGING_EXTRA_DEBUG SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, - "ARKODE::mriStep_TakeStepMRISR", "slow explicit RHS", - "Fse[%i] =", stage); + "ARKODE::mriStep_TakeStep", "slow explicit RHS", + "Fse_%i(:) =", stage); N_VPrintFile(step_mem->Fse[stage], ARK_LOGGER->debug_fp); #endif } @@ -2509,8 +2500,8 @@ int mriStep_TakeStepMRISR(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr) #ifdef SUNDIALS_LOGGING_EXTRA_DEBUG SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, - "ARKODE::mriStep_TakeStepMRISR", "slow implicit RHS", - "Fsi[%i] =", stage); + "ARKODE::mriStep_TakeStep", "slow implicit RHS", + "Fsi_%i(:) =", stage); N_VPrintFile(step_mem->Fsi[stage], ARK_LOGGER->debug_fp); #endif } @@ -2530,8 +2521,8 @@ int mriStep_TakeStepMRISR(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr) #ifdef SUNDIALS_LOGGING_EXTRA_DEBUG SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, - "ARKODE::mriStep_TakeStepMRISR", "updated solution", - "ycur =", ""); + "ARKODE::mriStep_TakeStep", "updated solution", + "ycur(:) =", ""); N_VPrintFile(ark_mem->ycur, ARK_LOGGER->debug_fp); #endif @@ -2548,7 +2539,7 @@ int mriStep_TakeStepMRISR(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr) /* Solver diagnostics reporting */ #if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_DEBUG SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, - "ARKODE::mriStep_TakeStepMRISR", "end-step", + "ARKODE::mriStep_TakeStep", "end-step", "step = %li, t = %" RSYM ", h = %" RSYM ", dsm = %" RSYM, ark_mem->nst, ark_mem->tn, ark_mem->h, *dsmPtr); #endif @@ -2695,12 +2686,12 @@ int mriStep_TakeStepMERK(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr) #ifdef SUNDIALS_LOGGING_EXTRA_DEBUG SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, - "ARKODE::mriStep_TakeStepMERK", "slow stage", "z[0] =", ""); + "ARKODE::mriStep_TakeStep", "slow stage", "z_0(:) =", ""); N_VPrintFile(ark_mem->yn, ARK_LOGGER->debug_fp); SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, - "ARKODE::mriStep_TakeStepMERK", "slow explicit RHS", - "Fse[0] =", ""); + "ARKODE::mriStep_TakeStep", "slow explicit RHS", + "Fse_0(:) =", ""); N_VPrintFile(step_mem->Fse[0], ARK_LOGGER->debug_fp); #endif @@ -2713,7 +2704,7 @@ int mriStep_TakeStepMERK(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr) /* Solver diagnostics reporting */ #if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_DEBUG SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, - "ARKODE::mriStep_TakeStepMERK", "start-stage", + "ARKODE::mriStep_TakeStep", "start-stage", "step = %li, stage group = %i, h = %" RSYM, ark_mem->nst, ig, ark_mem->h); #endif @@ -2781,8 +2772,8 @@ int mriStep_TakeStepMERK(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr) #ifdef SUNDIALS_LOGGING_EXTRA_DEBUG SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, - "ARKODE::mriStep_TakeStepMERK", "slow stage", - "z[%i] =", stage); + "ARKODE::mriStep_TakeStep", "slow stage", + "z_%i(:) =", stage); N_VPrintFile(ark_mem->ycur, ARK_LOGGER->debug_fp); #endif @@ -2826,8 +2817,8 @@ int mriStep_TakeStepMERK(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr) #ifdef SUNDIALS_LOGGING_EXTRA_DEBUG SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, - "ARKODE::mriStep_TakeStepMERK", "slow explicit RHS", - "Fse[%i] =", is); + "ARKODE::mriStep_TakeStep", "slow explicit RHS", + "Fse_%i(:) =", is); N_VPrintFile(step_mem->Fse[stage], ARK_LOGGER->debug_fp); #endif } @@ -2841,8 +2832,8 @@ int mriStep_TakeStepMERK(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr) #ifdef SUNDIALS_LOGGING_EXTRA_DEBUG SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, - "ARKODE::mriStep_TakeStepMERK", "updated solution", - "ycur =", ""); + "ARKODE::mriStep_TakeStep", "updated solution", + "ycur(:) =", ""); N_VPrintFile(ark_mem->ycur, ARK_LOGGER->debug_fp); #endif @@ -2857,7 +2848,7 @@ int mriStep_TakeStepMERK(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr) /* Solver diagnostics reporting */ #if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_DEBUG SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, - "ARKODE::mriStep_TakeStepMERK", "end-step", + "ARKODE::mriStep_TakeStep", "end-step", "step = %li, t = %" RSYM ", h = %" RSYM ", dsm = %" RSYM, ark_mem->nst, ark_mem->tn, ark_mem->h, *dsmPtr); #endif diff --git a/src/arkode/arkode_relaxation.c b/src/arkode/arkode_relaxation.c index e2307448b9..c911077580 100644 --- a/src/arkode/arkode_relaxation.c +++ b/src/arkode/arkode_relaxation.c @@ -357,7 +357,7 @@ static int arkRelaxSolve(ARKodeMem ark_mem, ARKodeRelaxMem relax_mem, #ifdef SUNDIALS_LOGGING_EXTRA_DEBUG SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, "ARKODE::arkRelaxSolve", - "compute delta y", "delta_y =", ""); + "compute delta y", "delta_y(:) =", ""); N_VPrintFile(ark_mem->tempv2, ARK_LOGGER->debug_fp); #endif From bc38591976187338ae1540f9c6dcf04818dc3ed7 Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Fri, 25 Oct 2024 18:35:07 -0500 Subject: [PATCH 183/286] Applied documentation-related suggestions from code review. --- doc/arkode/guide/source/Mathematics.rst | 20 +++++++++----- .../Custom_Inner_Stepper/Description.rst | 26 +++++++++---------- 2 files changed, 26 insertions(+), 20 deletions(-) diff --git a/doc/arkode/guide/source/Mathematics.rst b/doc/arkode/guide/source/Mathematics.rst index ad230afadb..7222bee571 100644 --- a/doc/arkode/guide/source/Mathematics.rst +++ b/doc/arkode/guide/source/Mathematics.rst @@ -1126,17 +1126,25 @@ that it may have used a potentially different relative solution tolerance, estimates using either a "maximum accumulation" strategy, .. math:: - \varepsilon^F_{max} = \text{RTOL}^F \max_{m\in M} \|\varepsilon^F_{n,m}\|_{WRMS}, + \varepsilon^F_{max} = \text{RTOL}^F \max_{m\in \mathcal{S}} \|\varepsilon^F_{n,m}\|_{WRMS}, + :label: maximum_accumulation + +an "additive accumulation" strategy, + +.. math:: + \varepsilon^F_{sum} = \text{RTOL}^F \sum_{m\in \mathcal{S}} \|\varepsilon^F_{n,m}\|_{WRMS}, :label: maximum_accumulation or using an "averaged accumulation" strategy, .. math:: - \varepsilon^F_{avg} = \frac{\text{RTOL}^F}{|M|} \sum_{m\in M} \|\varepsilon^F_{n,m}\|_{WRMS}, + \varepsilon^F_{avg} = \frac{\text{RTOL}^F}{\Delta t_{\mathcal{S}}} \sum_{m\in \mathcal{S}} h_{n,m} \|\varepsilon^F_{n,m}\|_{WRMS}, :label: average_accumulation -where the norm is taken using the tolerance-informed error-weight vector. In -both cases, the sum or the maximum is taken over the set of all steps :math:`M` +where :math:`h_{n,m}` is the step size that gave rise to :math:`\varepsilon^F_{n,m}`, +:math:`\Delta t_{\mathcal{S}}` denotes the elapsed time over which :math:`\mathcal{S}` +is taken, and the norms are taken using the tolerance-informed error-weight vector. In +each case, the sum or the maximum is taken over the set of all steps :math:`\mathcal{S}` since the fast error accumulator has been reset. @@ -1215,7 +1223,7 @@ initial state, where we again satisfy the inequality with a value of :math:`\frac12` to obtain .. math:: - |h_0| = \frac{1}{2\left\| f(t_0,y_0)\right\|}, + |h_0| = \frac{1}{2\left\| f(t_0,y_0)\right\|}. :label: H0_TSExp0 @@ -1628,7 +1636,7 @@ but may be modified by the user. When using the dense and band SUNMatrix objects for the linear systems :eq:`ARKODE_modified_Newton_system`, the Jacobian :math:`J` may be supplied -by a user routine, or approximated internally by finite-differences. +by a user routine, or approximated internally with finite-differences. In the case of differencing, we use the standard approximation .. math:: diff --git a/doc/arkode/guide/source/Usage/MRIStep/Custom_Inner_Stepper/Description.rst b/doc/arkode/guide/source/Usage/MRIStep/Custom_Inner_Stepper/Description.rst index f301b3028f..4076cb5b0e 100644 --- a/doc/arkode/guide/source/Usage/MRIStep/Custom_Inner_Stepper/Description.rst +++ b/doc/arkode/guide/source/Usage/MRIStep/Custom_Inner_Stepper/Description.rst @@ -446,7 +446,11 @@ following member functions: .. c:type:: int (*MRIStepInnerGetAccumulatedError)(MRIStepInnerStepper stepper, sunrealtype* accum_error) - This function returns an estimate of the accumulated solution error arising from the inner stepper. + This function returns an estimate of the accumulated solution error arising from the + inner stepper. Both the :c:type:`MRIStepInnerGetAccumulatedError` and + :c:type:`MRIStepInnerResetAccumulatedError` functions should be provided, or not; if only + one is provided then MRIStep will disable multirate temporal adaptivity and call neither. + **Arguments:** * *stepper* -- the inner stepper object. @@ -465,14 +469,13 @@ following member functions: be called *after* a preceding call to the :c:type:`MRIStepInnerResetAccumulatedError` function. - Both the :c:type:`MRIStepInnerGetAccumulatedError` and - :c:type:`MRIStepInnerResetAccumulatedError` functions should be provided, or not; if only - one is provided then MRIStep will disable multirate temporal adaptivity and call neither. - .. c:type:: int (*MRIStepInnerResetAccumulatedError)(MRIStepInnerStepper stepper) This function resets the inner stepper's accumulated solution error to zero. + This function performs a different role within MRIStep than the + :c:type:`MRIStepInnerResetFn`, and thus an implementation should make no + assumptions about the frequency/ordering of calls to either. **Arguments:** * *stepper* -- the inner stepper object. @@ -493,14 +496,13 @@ following member functions: :c:type:`MRIStepInnerResetAccumulatedError` functions should be provided, or not; if only one is provided then MRIStep will disable multirate temporal adaptivity and call neither. - This function performs a different role within MRIStep than the - :c:type:`MRIStepInnerResetFn`, and thus an implementation should make no - assumptions about the frequency/ordering of calls to either. - .. c:type:: int (*MRIStepInnerSetRTol)(MRIStepInnerStepper stepper, sunrealtype rtol) - This function accepts a relative tolerance for the inner stepper to use in its upcoming adaptive solve. + This function accepts a relative tolerance for the inner stepper to use in its + upcoming adaptive solve. It is assumed that if the inner stepper supports absolute + tolerances as well, then these have been set up directly by the user to indicate the + "noise" level for solution components. **Arguments:** * *stepper* -- the inner stepper object. @@ -514,7 +516,3 @@ following member functions: This function is only called when multirate temporal adaptivity has been enabled using a :c:type:`SUNAdaptController` module having type :c:enumerator:`SUN_ADAPTCONTROLLER_MRI_H_TOL`. - - It is assumed that if the inner stepper supports absolute tolerances as well, then - these have been set up directly by the user to indicate the "noise" level for - solution components. From 8caad5945d5f36c908ff851d49945be90a6e9e5c Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Fri, 25 Oct 2024 18:56:01 -0500 Subject: [PATCH 184/286] Applied documentation-related suggestions from code review. --- .../SUNAdaptController_MRIHTol.rst | 41 ++++++++++--------- 1 file changed, 21 insertions(+), 20 deletions(-) diff --git a/doc/shared/sunadaptcontroller/SUNAdaptController_MRIHTol.rst b/doc/shared/sunadaptcontroller/SUNAdaptController_MRIHTol.rst index a653f6404b..1d7c8c9f8c 100644 --- a/doc/shared/sunadaptcontroller/SUNAdaptController_MRIHTol.rst +++ b/doc/shared/sunadaptcontroller/SUNAdaptController_MRIHTol.rst @@ -55,8 +55,8 @@ results from two types of error: :label: inner_solver_assumption where :math:`\text{RTOL}_n^F = \text{RTOL}^S \text{tolfac}_n^F`, - :math:`\text{RTOL}^S` is the relative tolerance that was supplied to the - current time scale solver, and where + the relative tolerance that was supplied to the current time scale + solver is :math:`\text{RTOL}^S`, and :math:`\kappa(t_n) = c(t_n) h_n^S \text{RTOL}^S` is independent of the relative tolerance factor, :math:`\text{tolfac}_n^F`. @@ -93,32 +93,33 @@ Implementation -------------- The SUNAdaptController_MRIHTol controller is implemented as a derived -SUNAdaptController class, and defines its *content* field as: +:c:type:`SUNAdaptController` class, and its *content* field is defined by +the :c:struct:`SUNAdaptControllerContent_MRIHTol_` structure: -.. code-block:: c +.. c:struct:: SUNAdaptControllerContent_MRIHTol_ - struct SUNAdaptControllerContent_MRIHTol_ - { - SUNAdaptController HControl; - SUNAdaptController TolControl; - sunrealtype inner_max_relch; - sunrealtype inner_min_tolfac; - sunrealtype inner_max_tolfac; - }; + The member data structure for an MRIHTol controller -These entries of the *content* field contain the following information: + .. c:member:: SUNAdaptController HControl -* ``HControl`` - single time-scale SUNAdaptController object to adapt - the current step size, :math:`h^S_n`. + A single time-scale controller to adapt the current step size, :math:`h^S_n`. -* ``TolControl`` - single time-scale SUNAdaptController object to adapt - the inner solver relative tolerance factor, :math:`\text{RTOL}^F_n`. + .. c:member:: SUNAdaptController TolControl -* ``inner_max_relch`` - the parameter :math:`relch_{\text{max}}` above. + A single time-scale controller to adapt the inner solver relative tolerance + factor, :math:`\text{reltol}^F_n`. -* ``inner_min_tolfac`` - the parameter :math:`\text{tolfac}_{min}` above. + .. c:member:: sunrealtype inner_max_relch -* ``inner_max_tolfac`` - the parameter :math:`\text{tolfac}_{max}` above. + The parameter :math:`relch_{\text{max}}` above. + + .. c:member:: sunrealtype inner_min_tolfac + + The parameter :math:`\text{tolfac}_{min}` above. + + .. c:member:: sunrealtype inner_max_tolfac + + The parameter :math:`\text{tolfac}_{max}` above. The header file to be included when using this module is ``sunadaptcontroller/sunadaptcontroller_mrihtol.h``. From 7ea9e15509f518c6af44cd820890f1da60db08d1 Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Fri, 25 Oct 2024 16:59:58 -0700 Subject: [PATCH 185/286] Apply suggestions from code review (CMakeLists and logging) Co-authored-by: David Gardner --- src/arkode/arkode_arkstep_nls.c | 2 +- src/sunadaptcontroller/mrihtol/fmod_int32/CMakeLists.txt | 1 - src/sunadaptcontroller/mrihtol/fmod_int64/CMakeLists.txt | 1 - 3 files changed, 1 insertion(+), 3 deletions(-) diff --git a/src/arkode/arkode_arkstep_nls.c b/src/arkode/arkode_arkstep_nls.c index 5f1811b156..939a82ad02 100644 --- a/src/arkode/arkode_arkstep_nls.c +++ b/src/arkode/arkode_arkstep_nls.c @@ -425,7 +425,7 @@ int arkStep_Nls(ARKodeMem ark_mem, int nflag) #ifdef SUNDIALS_LOGGING_EXTRA_DEBUG SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, "ARKODE::arkStep_Nls", - "correction", "zcor =", ""); + "correction", "zcor(:) =", ""); N_VPrintFile(step_mem->zcor, ARK_LOGGER->debug_fp); #endif diff --git a/src/sunadaptcontroller/mrihtol/fmod_int32/CMakeLists.txt b/src/sunadaptcontroller/mrihtol/fmod_int32/CMakeLists.txt index ecd215bc10..befc6cb2ed 100644 --- a/src/sunadaptcontroller/mrihtol/fmod_int32/CMakeLists.txt +++ b/src/sunadaptcontroller/mrihtol/fmod_int32/CMakeLists.txt @@ -16,7 +16,6 @@ sundials_add_f2003_library( sundials_fsunadaptcontrollermrihtol_mod SOURCES fsunadaptcontroller_mrihtol_mod.f90 fsunadaptcontroller_mrihtol_mod.c LINK_LIBRARIES PUBLIC sundials_fcore_mod - OBJECT_LIBRARIES OUTPUT_NAME sundials_fsunadaptcontrollermrihtol_mod OBJECT_LIB_ONLY) message(STATUS "Added SUNAdaptController_MRIHTol F2003 interface") diff --git a/src/sunadaptcontroller/mrihtol/fmod_int64/CMakeLists.txt b/src/sunadaptcontroller/mrihtol/fmod_int64/CMakeLists.txt index ecd215bc10..befc6cb2ed 100644 --- a/src/sunadaptcontroller/mrihtol/fmod_int64/CMakeLists.txt +++ b/src/sunadaptcontroller/mrihtol/fmod_int64/CMakeLists.txt @@ -16,7 +16,6 @@ sundials_add_f2003_library( sundials_fsunadaptcontrollermrihtol_mod SOURCES fsunadaptcontroller_mrihtol_mod.f90 fsunadaptcontroller_mrihtol_mod.c LINK_LIBRARIES PUBLIC sundials_fcore_mod - OBJECT_LIBRARIES OUTPUT_NAME sundials_fsunadaptcontrollermrihtol_mod OBJECT_LIB_ONLY) message(STATUS "Added SUNAdaptController_MRIHTol F2003 interface") From 851922129b82dc8194510f1a34bb4cc1556e60fd Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Fri, 25 Oct 2024 19:00:54 -0500 Subject: [PATCH 186/286] Formatting --- src/arkode/arkode_mristep.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/arkode/arkode_mristep.c b/src/arkode/arkode_mristep.c index dd1c5b80fb..7cc2080a5b 100644 --- a/src/arkode/arkode_mristep.c +++ b/src/arkode/arkode_mristep.c @@ -1707,7 +1707,7 @@ int mriStep_TakeStepMRIGARK(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPt { need_inner_dsm = SUNTRUE; step_mem->inner_dsm = ZERO; - retval = mriStepInnerStepper_ResetAccumulatedError(step_mem->stepper); + retval = mriStepInnerStepper_ResetAccumulatedError(step_mem->stepper); if (retval != ARK_SUCCESS) { arkProcessError(ark_mem, ARK_INNERSTEP_FAIL, __LINE__, __func__, __FILE__, @@ -2159,7 +2159,7 @@ int mriStep_TakeStepMRISR(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr) { need_inner_dsm = SUNTRUE; step_mem->inner_dsm = ZERO; - retval = mriStepInnerStepper_ResetAccumulatedError(step_mem->stepper); + retval = mriStepInnerStepper_ResetAccumulatedError(step_mem->stepper); if (retval != ARK_SUCCESS) { arkProcessError(ark_mem, ARK_INNERSTEP_FAIL, __LINE__, __func__, __FILE__, @@ -2625,7 +2625,7 @@ int mriStep_TakeStepMERK(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr) { need_inner_dsm = SUNTRUE; step_mem->inner_dsm = ZERO; - retval = mriStepInnerStepper_ResetAccumulatedError(step_mem->stepper); + retval = mriStepInnerStepper_ResetAccumulatedError(step_mem->stepper); if (retval != ARK_SUCCESS) { arkProcessError(ark_mem, ARK_INNERSTEP_FAIL, __LINE__, __func__, __FILE__, From 0d1ccfeecd2247233d821693e9caf6e234587d9f Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Sat, 26 Oct 2024 09:57:45 -0500 Subject: [PATCH 187/286] Formatting --- src/arkode/arkode_mristep.c | 71 +++++++++++++++++-------------------- 1 file changed, 32 insertions(+), 39 deletions(-) diff --git a/src/arkode/arkode_mristep.c b/src/arkode/arkode_mristep.c index 7cc2080a5b..f50450e2b2 100644 --- a/src/arkode/arkode_mristep.c +++ b/src/arkode/arkode_mristep.c @@ -1729,7 +1729,8 @@ int mriStep_TakeStepMRIGARK(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPt to the beginning of this step (in case of recomputation) */ if (!ark_mem->fixedstep) { - retval = mriStepInnerStepper_Reset(step_mem->stepper, ark_mem->tn, ark_mem->yn); + retval = mriStepInnerStepper_Reset(step_mem->stepper, ark_mem->tn, + ark_mem->yn); if (retval != ARK_SUCCESS) { arkProcessError(ark_mem, ARK_INNERSTEP_FAIL, __LINE__, __func__, __FILE__, @@ -1876,7 +1877,8 @@ int mriStep_TakeStepMRIGARK(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPt if ((ark_mem->ProcessStage != NULL) && (step_mem->stagetypes[is] != MRISTAGE_STIFF_ACC)) { - retval = ark_mem->ProcessStage(ark_mem->tcur, ark_mem->ycur, ark_mem->user_data); + retval = ark_mem->ProcessStage(ark_mem->tcur, ark_mem->ycur, + ark_mem->user_data); if (retval != 0) { return (ARK_POSTPROCESS_STAGE_FAIL); } } @@ -2056,9 +2058,8 @@ int mriStep_TakeStepMRIGARK(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPt if (retval != ARK_SUCCESS) { return (retval); } #ifdef SUNDIALS_LOGGING_EXTRA_DEBUG - SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, - "ARKODE::mriStep_TakeStep", "embedded solution", - "ytilde(:) =", ""); + SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, "ARKODE::mriStep_TakeStep", + "embedded solution", "ytilde(:) =", ""); N_VPrintFile(ark_mem->ycur, ARK_LOGGER->debug_fp); #endif @@ -2251,23 +2252,21 @@ int mriStep_TakeStepMRISR(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr) #endif #ifdef SUNDIALS_LOGGING_EXTRA_DEBUG - SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, - "ARKODE::mriStep_TakeStep", "slow stage", "z_0(:) =", ""); + SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, "ARKODE::mriStep_TakeStep", + "slow stage", "z_0(:) =", ""); N_VPrintFile(ark_mem->yn, ARK_LOGGER->debug_fp); if (step_mem->explicit_rhs) { - SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, - "ARKODE::mriStep_TakeStep", "slow explicit RHS", - "Fse_0(:) =", ""); + SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, "ARKODE::mriStep_TakeStep", + "slow explicit RHS", "Fse_0(:) =", ""); N_VPrintFile(step_mem->Fse[0], ARK_LOGGER->debug_fp); } if (step_mem->implicit_rhs) { - SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, - "ARKODE::mriStep_TakeStep", "slow implicit RHS", - "Fsi_0(:) =", ""); + SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, "ARKODE::mriStep_TakeStep", + "slow implicit RHS", "Fsi_0(:) =", ""); N_VPrintFile(step_mem->Fsi[0], ARK_LOGGER->debug_fp); } #endif @@ -2280,10 +2279,9 @@ int mriStep_TakeStepMRISR(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr) { /* Solver diagnostics reporting */ #if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_DEBUG - SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, - "ARKODE::mriStep_TakeStep", "start-stage", - "step = %li, stage = %i, h = %" RSYM, ark_mem->nst, - stage, ark_mem->h); + SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, "ARKODE::mriStep_TakeStep", + "start-stage", "step = %li, stage = %i, h = %" RSYM, + ark_mem->nst, stage, ark_mem->h); #endif /* Determine if this is an "embedding" or "solution" stage */ @@ -2414,9 +2412,8 @@ int mriStep_TakeStepMRISR(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr) } #ifdef SUNDIALS_LOGGING_EXTRA_DEBUG - SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, - "ARKODE::mriStep_TakeStep", "slow stage", - "z_%i(:) =", stage); + SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, "ARKODE::mriStep_TakeStep", + "slow stage", "z_%i(:) =", stage); N_VPrintFile(ark_mem->ycur, ARK_LOGGER->debug_fp); #endif @@ -2520,9 +2517,8 @@ int mriStep_TakeStepMRISR(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr) } /* loop over stages */ #ifdef SUNDIALS_LOGGING_EXTRA_DEBUG - SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, - "ARKODE::mriStep_TakeStep", "updated solution", - "ycur(:) =", ""); + SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, "ARKODE::mriStep_TakeStep", + "updated solution", "ycur(:) =", ""); N_VPrintFile(ark_mem->ycur, ARK_LOGGER->debug_fp); #endif @@ -2538,8 +2534,8 @@ int mriStep_TakeStepMRISR(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr) /* Solver diagnostics reporting */ #if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_DEBUG - SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, - "ARKODE::mriStep_TakeStep", "end-step", + SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, "ARKODE::mriStep_TakeStep", + "end-step", "step = %li, t = %" RSYM ", h = %" RSYM ", dsm = %" RSYM, ark_mem->nst, ark_mem->tn, ark_mem->h, *dsmPtr); #endif @@ -2685,13 +2681,12 @@ int mriStep_TakeStepMERK(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr) #endif #ifdef SUNDIALS_LOGGING_EXTRA_DEBUG - SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, - "ARKODE::mriStep_TakeStep", "slow stage", "z_0(:) =", ""); + SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, "ARKODE::mriStep_TakeStep", + "slow stage", "z_0(:) =", ""); N_VPrintFile(ark_mem->yn, ARK_LOGGER->debug_fp); - SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, - "ARKODE::mriStep_TakeStep", "slow explicit RHS", - "Fse_0(:) =", ""); + SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, "ARKODE::mriStep_TakeStep", + "slow explicit RHS", "Fse_0(:) =", ""); N_VPrintFile(step_mem->Fse[0], ARK_LOGGER->debug_fp); #endif @@ -2703,10 +2698,9 @@ int mriStep_TakeStepMERK(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr) { /* Solver diagnostics reporting */ #if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_DEBUG - SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, - "ARKODE::mriStep_TakeStep", "start-stage", - "step = %li, stage group = %i, h = %" RSYM, ark_mem->nst, - ig, ark_mem->h); + SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, "ARKODE::mriStep_TakeStep", + "start-stage", "step = %li, stage group = %i, h = %" RSYM, + ark_mem->nst, ig, ark_mem->h); #endif /* Set up fast RHS for this stage group */ @@ -2831,9 +2825,8 @@ int mriStep_TakeStepMERK(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr) } /* loop over stage groups */ #ifdef SUNDIALS_LOGGING_EXTRA_DEBUG - SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, - "ARKODE::mriStep_TakeStep", "updated solution", - "ycur(:) =", ""); + SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, "ARKODE::mriStep_TakeStep", + "updated solution", "ycur(:) =", ""); N_VPrintFile(ark_mem->ycur, ARK_LOGGER->debug_fp); #endif @@ -2847,8 +2840,8 @@ int mriStep_TakeStepMERK(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr) /* Solver diagnostics reporting */ #if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_DEBUG - SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, - "ARKODE::mriStep_TakeStep", "end-step", + SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, "ARKODE::mriStep_TakeStep", + "end-step", "step = %li, t = %" RSYM ", h = %" RSYM ", dsm = %" RSYM, ark_mem->nst, ark_mem->tn, ark_mem->h, *dsmPtr); #endif From 455f5c7bed459226544981914f86e8d9e4d2665f Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Mon, 28 Oct 2024 20:01:07 +0000 Subject: [PATCH 188/286] Renamed inner_control and inner_control_new to inner_rtol_factor and inner_rtol_factor_new --- src/arkode/arkode_mristep.c | 12 ++++++------ src/arkode/arkode_mristep_controller.c | 8 ++++---- src/arkode/arkode_mristep_impl.h | 6 +++--- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/arkode/arkode_mristep.c b/src/arkode/arkode_mristep.c index f4f9760c58..8a8fbea714 100644 --- a/src/arkode/arkode_mristep.c +++ b/src/arkode/arkode_mristep.c @@ -221,9 +221,9 @@ void* MRIStepCreate(ARKRhsFn fse, ARKRhsFn fsi, sunrealtype t0, N_Vector y0, step_mem->Xvecs = NULL; /* Initialize adaptivity parameters */ - step_mem->inner_control = ONE; + step_mem->inner_rtol_factor = ONE; step_mem->inner_dsm = ONE; - step_mem->inner_control_new = ONE; + step_mem->inner_rtol_factor_new = ONE; /* Initialize pre and post inner evolve functions */ step_mem->pre_inner_evolve = NULL; @@ -1308,7 +1308,7 @@ int mriStep_Init(ARKodeMem ark_mem, int init_type) } /* initialize fast stepper to use the same relative tolerance as MRIStep */ - step_mem->inner_control = ONE; + step_mem->inner_rtol_factor = ONE; } return (ARK_SUCCESS); @@ -1715,7 +1715,7 @@ int mriStep_TakeStepMRIGARK(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPt } retval = mriStepInnerStepper_SetRTol(step_mem->stepper, - step_mem->inner_control * ark_mem->reltol); + step_mem->inner_rtol_factor * ark_mem->reltol); if (retval != ARK_SUCCESS) { arkProcessError(ark_mem, ARK_INNERSTEP_FAIL, __LINE__, __func__, __FILE__, @@ -2181,7 +2181,7 @@ int mriStep_TakeStepMRISR(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr) } retval = mriStepInnerStepper_SetRTol(step_mem->stepper, - step_mem->inner_control * ark_mem->reltol); + step_mem->inner_rtol_factor * ark_mem->reltol); if (retval != ARK_SUCCESS) { arkProcessError(ark_mem, ARK_INNERSTEP_FAIL, __LINE__, __func__, __FILE__, @@ -2651,7 +2651,7 @@ int mriStep_TakeStepMERK(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr) } retval = mriStepInnerStepper_SetRTol(step_mem->stepper, - step_mem->inner_control * ark_mem->reltol); + step_mem->inner_rtol_factor * ark_mem->reltol); if (retval != ARK_SUCCESS) { arkProcessError(ark_mem, ARK_INNERSTEP_FAIL, __LINE__, __func__, __FILE__, diff --git a/src/arkode/arkode_mristep_controller.c b/src/arkode/arkode_mristep_controller.c index bef6c5a711..dc71c69762 100644 --- a/src/arkode/arkode_mristep_controller.c +++ b/src/arkode/arkode_mristep_controller.c @@ -97,9 +97,9 @@ SUNErrCode SUNAdaptController_EstimateStep_MRIStep(SUNAdaptController C, /* Estimate slow stepsize from MRI controller */ return SUNAdaptController_EstimateStepTol(MRICONTROL_C(C), H, - step_mem->inner_control, P, DSM, + step_mem->inner_rtol_factor, P, DSM, step_mem->inner_dsm, Hnew, - &(step_mem->inner_control_new)); + &(step_mem->inner_rtol_factor_new)); } SUNErrCode SUNAdaptController_UpdateH_MRIStep(SUNAdaptController C, @@ -112,12 +112,12 @@ SUNErrCode SUNAdaptController_UpdateH_MRIStep(SUNAdaptController C, /* Update MRI controller */ SUNErrCode retval = SUNAdaptController_UpdateMRITol(MRICONTROL_C(C), H, - step_mem->inner_control, + step_mem->inner_rtol_factor, DSM, step_mem->inner_dsm); if (retval != SUN_SUCCESS) { return (retval); } /* Update inner controller parameter to most-recent prediction */ - step_mem->inner_control = step_mem->inner_control_new; + step_mem->inner_rtol_factor = step_mem->inner_rtol_factor_new; /* return with success*/ return SUN_SUCCESS; diff --git a/src/arkode/arkode_mristep_impl.h b/src/arkode/arkode_mristep_impl.h index 5d537e912c..b84a36232c 100644 --- a/src/arkode/arkode_mristep_impl.h +++ b/src/arkode/arkode_mristep_impl.h @@ -133,9 +133,9 @@ typedef struct ARKodeMRIStepMemRec MRIStepPostInnerFn post_inner_evolve; /* MRI adaptivity parameters */ - sunrealtype inner_control; /* prev control parameter */ - sunrealtype inner_dsm; /* prev inner stepper accumulated error */ - sunrealtype inner_control_new; /* upcoming control parameter */ + sunrealtype inner_rtol_factor; /* prev control parameter */ + sunrealtype inner_dsm; /* prev inner stepper accumulated error */ + sunrealtype inner_rtol_factor_new; /* upcoming control parameter */ /* Counters */ long int nfse; /* num fse calls */ From 248d3e70baad7d75e49073bdddf8833cea254c03 Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Mon, 28 Oct 2024 20:06:41 +0000 Subject: [PATCH 189/286] Updated switch/case statement to explicitly list step routines (instead of leveraging implied fallthrough) --- src/arkode/arkode_mristep.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/arkode/arkode_mristep.c b/src/arkode/arkode_mristep.c index fc42735c13..89abd32501 100644 --- a/src/arkode/arkode_mristep.c +++ b/src/arkode/arkode_mristep.c @@ -946,8 +946,8 @@ int mriStep_Init(ARKodeMem ark_mem, int init_type) /* Attach correct TakeStep routine for this coupling table */ switch (step_mem->MRIC->type) { - case MRISTEP_EXPLICIT: - case MRISTEP_IMPLICIT: + case MRISTEP_EXPLICIT: ark_mem->step = mriStep_TakeStepMRIGARK; break; + case MRISTEP_IMPLICIT: ark_mem->step = mriStep_TakeStepMRIGARK; break; case MRISTEP_IMEX: ark_mem->step = mriStep_TakeStepMRIGARK; break; case MRISTEP_MERK: ark_mem->step = mriStep_TakeStepMERK; break; case MRISTEP_MRISR: ark_mem->step = mriStep_TakeStepMRISR; break; From e28b699791302ec862616e855bac3030a9f4aec4 Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Mon, 28 Oct 2024 20:17:35 +0000 Subject: [PATCH 190/286] incorporating logging-related PR suggestion --- src/arkode/arkode_mristep_nls.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/arkode/arkode_mristep_nls.c b/src/arkode/arkode_mristep_nls.c index 39119403ad..882eedad75 100644 --- a/src/arkode/arkode_mristep_nls.c +++ b/src/arkode/arkode_mristep_nls.c @@ -328,7 +328,7 @@ int mriStep_Nls(ARKodeMem ark_mem, int nflag) #ifdef SUNDIALS_LOGGING_EXTRA_DEBUG SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, "ARKODE::mriStep_Nls", - "correction", "zcor =", ""); + "correction", "zcor(:) =", ""); N_VPrintFile(step_mem->zcor, ARK_LOGGER->debug_fp); #endif From bdb9cf78e13b0680a12981662d37963f9f9fd814 Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Mon, 28 Oct 2024 20:17:51 +0000 Subject: [PATCH 191/286] Comment update --- src/arkode/arkode_mristep.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/arkode/arkode_mristep.c b/src/arkode/arkode_mristep.c index 89abd32501..471570b840 100644 --- a/src/arkode/arkode_mristep.c +++ b/src/arkode/arkode_mristep.c @@ -3325,7 +3325,7 @@ int mriStep_StageERKFast(ARKodeMem ark_mem, ARKodeMRIStepMem step_mem, return (ARK_INNERSTEP_FAIL); } - /* for normal stages with MRI adaptivity enabled, get an + /* for normal stages (i.e., not the embedding) with MRI adaptivity enabled, get an estimate for the fast time scale error */ if (get_inner_dsm) { From 60f865b3f82b82a51f525450910feda58a5a41f4 Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Mon, 28 Oct 2024 15:43:58 -0500 Subject: [PATCH 192/286] Formatting --- src/arkode/arkode_mristep.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/arkode/arkode_mristep.c b/src/arkode/arkode_mristep.c index 471570b840..e22f2e632a 100644 --- a/src/arkode/arkode_mristep.c +++ b/src/arkode/arkode_mristep.c @@ -220,8 +220,8 @@ void* MRIStepCreate(ARKRhsFn fse, ARKRhsFn fsi, sunrealtype t0, N_Vector y0, step_mem->Xvecs = NULL; /* Initialize adaptivity parameters */ - step_mem->inner_rtol_factor = ONE; - step_mem->inner_dsm = ONE; + step_mem->inner_rtol_factor = ONE; + step_mem->inner_dsm = ONE; step_mem->inner_rtol_factor_new = ONE; /* Initialize pre and post inner evolve functions */ @@ -1714,9 +1714,9 @@ int mriStep_TakeStepMRIGARK(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPt "Unable to reset the inner stepper error estimate"); return (ARK_INNERSTEP_FAIL); } - retval = - mriStepInnerStepper_SetRTol(step_mem->stepper, - step_mem->inner_rtol_factor * ark_mem->reltol); + retval = mriStepInnerStepper_SetRTol(step_mem->stepper, + step_mem->inner_rtol_factor * + ark_mem->reltol); if (retval != ARK_SUCCESS) { arkProcessError(ark_mem, ARK_INNERSTEP_FAIL, __LINE__, __func__, __FILE__, @@ -2167,9 +2167,9 @@ int mriStep_TakeStepMRISR(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr) "Unable to reset the inner stepper error estimate"); return (ARK_INNERSTEP_FAIL); } - retval = - mriStepInnerStepper_SetRTol(step_mem->stepper, - step_mem->inner_rtol_factor * ark_mem->reltol); + retval = mriStepInnerStepper_SetRTol(step_mem->stepper, + step_mem->inner_rtol_factor * + ark_mem->reltol); if (retval != ARK_SUCCESS) { arkProcessError(ark_mem, ARK_INNERSTEP_FAIL, __LINE__, __func__, __FILE__, @@ -2628,9 +2628,9 @@ int mriStep_TakeStepMERK(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr) "Unable to reset the inner stepper error estimate"); return (ARK_INNERSTEP_FAIL); } - retval = - mriStepInnerStepper_SetRTol(step_mem->stepper, - step_mem->inner_rtol_factor * ark_mem->reltol); + retval = mriStepInnerStepper_SetRTol(step_mem->stepper, + step_mem->inner_rtol_factor * + ark_mem->reltol); if (retval != ARK_SUCCESS) { arkProcessError(ark_mem, ARK_INNERSTEP_FAIL, __LINE__, __func__, __FILE__, From ab183fa455bb5b57ec68eb8761d20da3bac14020 Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Mon, 28 Oct 2024 16:10:54 -0500 Subject: [PATCH 193/286] Updated SUNAdaptController_SetParams_MRIHTol to handle illegal inputs, and ability to reset parameters to their defaults. --- .../SUNAdaptController_MRIHTol.rst | 9 ++-- .../mrihtol/sunadaptcontroller_mrihtol.c | 42 +++++++++++++++++-- 2 files changed, 44 insertions(+), 7 deletions(-) diff --git a/doc/shared/sunadaptcontroller/SUNAdaptController_MRIHTol.rst b/doc/shared/sunadaptcontroller/SUNAdaptController_MRIHTol.rst index 1d7c8c9f8c..4012dabab6 100644 --- a/doc/shared/sunadaptcontroller/SUNAdaptController_MRIHTol.rst +++ b/doc/shared/sunadaptcontroller/SUNAdaptController_MRIHTol.rst @@ -146,12 +146,13 @@ also provides the following additional user-callable routines: 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. + the problem. If any argument is negative, that parameter will be reset to its + default value. :param C: the SUNAdaptController_MRIHTol object. - :param inner_max_relch: the parameter :math:`relch_{\text{max}}`. - :param inner_min_tolfac: the parameter :math:`\text{tolfac}_{min}`. - :param inner_max_tolfac: the parameter :math:`\text{tolfac}_{max}`. + :param inner_max_relch: the parameter :math:`relch_{\text{max}}` (must be :math:`\ge 1`). + :param inner_min_tolfac: the parameter :math:`\text{tolfac}_{min}` (must be :math:`> 0`). + :param inner_max_tolfac: the parameter :math:`\text{tolfac}_{max}` (must be :math:`>= 1`). :returns: :c:type:`SUNErrCode` indicating success or failure. diff --git a/src/sunadaptcontroller/mrihtol/sunadaptcontroller_mrihtol.c b/src/sunadaptcontroller/mrihtol/sunadaptcontroller_mrihtol.c index 202779f7ef..73d1551d36 100644 --- a/src/sunadaptcontroller/mrihtol/sunadaptcontroller_mrihtol.c +++ b/src/sunadaptcontroller/mrihtol/sunadaptcontroller_mrihtol.c @@ -115,9 +115,45 @@ SUNErrCode SUNAdaptController_SetParams_MRIHTol(SUNAdaptController C, sunrealtype inner_max_tolfac) { SUNFunctionBegin(C->sunctx); - if (inner_max_relch != 0) MRIHTOL_INNER_MAX_RELCH(C) = inner_max_relch; - if (inner_min_tolfac != 0) MRIHTOL_INNER_MIN_TOLFAC(C) = inner_min_tolfac; - if (inner_max_tolfac != 0) MRIHTOL_INNER_MAX_TOLFAC(C) = inner_max_tolfac; + if (inner_max_relch < SUN_RCONST(0.0)) + { + MRIHTOL_INNER_MAX_RELCH(C) = INNER_MAX_RELCH; + } + else if (inner_max_relch < SUN_RCONST(1.0)) + { + return SUN_ERR_ARG_OUTOFRANGE; + } + else + { + MRIHTOL_INNER_MAX_RELCH(C) = inner_max_relch; + } + + if (inner_min_tolfac < SUN_RCONST(0.0)) + { + MRIHTOL_INNER_MIN_TOLFAC(C) = INNER_MIN_TOLFAC; + } + else if (inner_min_tolfac == SUN_RCONST(0.0)) + { + return SUN_ERR_ARG_OUTOFRANGE; + } + else + { + MRIHTOL_INNER_MIN_TOLFAC(C) = inner_min_tolfac; + } + + if (inner_max_tolfac < SUN_RCONST(0.0)) + { + MRIHTOL_INNER_MAX_RELCH(C) = INNER_MAX_RELCH; + } + else if (inner_max_tolfac < SUN_RCONST(1.0)) + { + return SUN_ERR_ARG_OUTOFRANGE; + } + else + { + MRIHTOL_INNER_MAX_TOLFAC(C) = inner_max_tolfac; + } + return SUN_SUCCESS; } From f806cddd9a34ec3e10f5dc7c5caefb58d98da975 Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Mon, 28 Oct 2024 16:11:26 -0500 Subject: [PATCH 194/286] formatting --- .../mrihtol/sunadaptcontroller_mrihtol.c | 20 ++++--------------- 1 file changed, 4 insertions(+), 16 deletions(-) diff --git a/src/sunadaptcontroller/mrihtol/sunadaptcontroller_mrihtol.c b/src/sunadaptcontroller/mrihtol/sunadaptcontroller_mrihtol.c index 73d1551d36..899f184905 100644 --- a/src/sunadaptcontroller/mrihtol/sunadaptcontroller_mrihtol.c +++ b/src/sunadaptcontroller/mrihtol/sunadaptcontroller_mrihtol.c @@ -119,14 +119,8 @@ SUNErrCode SUNAdaptController_SetParams_MRIHTol(SUNAdaptController C, { MRIHTOL_INNER_MAX_RELCH(C) = INNER_MAX_RELCH; } - else if (inner_max_relch < SUN_RCONST(1.0)) - { - return SUN_ERR_ARG_OUTOFRANGE; - } - else - { - MRIHTOL_INNER_MAX_RELCH(C) = inner_max_relch; - } + else if (inner_max_relch < SUN_RCONST(1.0)) { return SUN_ERR_ARG_OUTOFRANGE; } + else { MRIHTOL_INNER_MAX_RELCH(C) = inner_max_relch; } if (inner_min_tolfac < SUN_RCONST(0.0)) { @@ -136,10 +130,7 @@ SUNErrCode SUNAdaptController_SetParams_MRIHTol(SUNAdaptController C, { return SUN_ERR_ARG_OUTOFRANGE; } - else - { - MRIHTOL_INNER_MIN_TOLFAC(C) = inner_min_tolfac; - } + else { MRIHTOL_INNER_MIN_TOLFAC(C) = inner_min_tolfac; } if (inner_max_tolfac < SUN_RCONST(0.0)) { @@ -149,10 +140,7 @@ SUNErrCode SUNAdaptController_SetParams_MRIHTol(SUNAdaptController C, { return SUN_ERR_ARG_OUTOFRANGE; } - else - { - MRIHTOL_INNER_MAX_TOLFAC(C) = inner_max_tolfac; - } + else { MRIHTOL_INNER_MAX_TOLFAC(C) = inner_max_tolfac; } return SUN_SUCCESS; } From 370b391d0cb4745b6a5d674f3dda2a634f694a14 Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Mon, 28 Oct 2024 17:03:19 -0500 Subject: [PATCH 195/286] Updated documentation to more clearly state when the MRIStepInnerGetAccumulatedError, MRIStepInnerResetAccumulatedError, and MRIStepInnerSetRTol functions are *required* --- .../Usage/MRIStep/Custom_Inner_Stepper/Description.rst | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/doc/arkode/guide/source/Usage/MRIStep/Custom_Inner_Stepper/Description.rst b/doc/arkode/guide/source/Usage/MRIStep/Custom_Inner_Stepper/Description.rst index 4076cb5b0e..21909cc5d8 100644 --- a/doc/arkode/guide/source/Usage/MRIStep/Custom_Inner_Stepper/Description.rst +++ b/doc/arkode/guide/source/Usage/MRIStep/Custom_Inner_Stepper/Description.rst @@ -462,7 +462,7 @@ following member functions: .. note:: - This function is only called when multirate temporal adaptivity has been enabled, + This function is required when multirate temporal adaptivity has been enabled, using a :c:type:`SUNAdaptController` module having type :c:enumerator:`SUN_ADAPTCONTROLLER_MRI_H_TOL`. If provided, the :c:type:`MRIStepInnerGetAccumulatedError` function will always @@ -486,7 +486,7 @@ following member functions: .. note:: - This function is only called when multirate temporal adaptivity has been enabled, + This function is required when multirate temporal adaptivity has been enabled, using a :c:type:`SUNAdaptController` module having type :c:enumerator:`SUN_ADAPTCONTROLLER_MRI_H_TOL`. The :c:type:`MRIStepInnerResetAccumulatedError` function will always be called @@ -514,5 +514,5 @@ following member functions: .. note:: - This function is only called when multirate temporal adaptivity has been enabled + This function is required when multirate temporal adaptivity has been enabled using a :c:type:`SUNAdaptController` module having type :c:enumerator:`SUN_ADAPTCONTROLLER_MRI_H_TOL`. From 1c2472a0290e8ecb50b31176564883b9f9b95419 Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Tue, 29 Oct 2024 12:09:44 -0500 Subject: [PATCH 196/286] Removed explicit copy of yn to ycur at the start of mriStep_TakeStepMRIGARK --- src/arkode/arkode_mristep.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/arkode/arkode_mristep.c b/src/arkode/arkode_mristep.c index e22f2e632a..d60aa91b91 100644 --- a/src/arkode/arkode_mristep.c +++ b/src/arkode/arkode_mristep.c @@ -1692,9 +1692,6 @@ int mriStep_TakeStepMRIGARK(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPt *nflagPtr = ARK_SUCCESS; *dsmPtr = ZERO; - /* initial time and state for step */ - N_VScale(ONE, ark_mem->yn, ark_mem->ycur); - /* determine whether embedding stage is needed */ do_embedding = !ark_mem->fixedstep || (ark_mem->AccumErrorType != ARK_ACCUMERROR_NONE); From 78ab7c3cf2b31cc52f221c1a5267e9f906f8ca31 Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Tue, 29 Oct 2024 12:29:50 -0500 Subject: [PATCH 197/286] Removed force_reset flag from mriStep_StageERKFast (as requested in PR review) --- src/arkode/arkode_mristep.c | 53 ++++++++++++++++++-------------- src/arkode/arkode_mristep_impl.h | 3 +- 2 files changed, 31 insertions(+), 25 deletions(-) diff --git a/src/arkode/arkode_mristep.c b/src/arkode/arkode_mristep.c index d60aa91b91..610665926f 100644 --- a/src/arkode/arkode_mristep.c +++ b/src/arkode/arkode_mristep.c @@ -1848,7 +1848,7 @@ int mriStep_TakeStepMRIGARK(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPt retval = mriStep_ComputeInnerForcing(ark_mem, step_mem, is, t0, tf); if (retval != ARK_SUCCESS) { return retval; } retval = mriStep_StageERKFast(ark_mem, step_mem, t0, tf, ark_mem->ycur, - ark_mem->tempv2, SUNFALSE, need_inner_dsm); + ark_mem->tempv2, need_inner_dsm); if (retval != ARK_SUCCESS) { *nflagPtr = CONV_FAIL; } break; case (MRISTAGE_ERK_NOFAST): @@ -2036,8 +2036,15 @@ int mriStep_TakeStepMRIGARK(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPt retval = mriStep_ComputeInnerForcing(ark_mem, step_mem, step_mem->stages, t0, tf); if (retval != ARK_SUCCESS) { return retval; } + retval = mriStepInnerStepper_Reset(step_mem->stepper, t0, ark_mem->ycur); + if (retval != ARK_SUCCESS) + { + arkProcessError(ark_mem, ARK_INNERSTEP_FAIL, __LINE__, __func__, __FILE__, + "Unable to reset the inner stepper"); + return (ARK_INNERSTEP_FAIL); + } retval = mriStep_StageERKFast(ark_mem, step_mem, t0, tf, ark_mem->ycur, - ark_mem->tempv2, SUNTRUE, SUNFALSE); + ark_mem->tempv2, SUNFALSE); if (retval != ARK_SUCCESS) { *nflagPtr = CONV_FAIL; } break; case (MRISTAGE_ERK_NOFAST): @@ -2315,10 +2322,16 @@ int mriStep_TakeStepMRISR(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr) /* Evolve fast IVP for this stage: force reset due to "stage-restart" structure potentially get inner dsm on all non-embedding stages */ - retval = mriStep_StageERKFast(ark_mem, step_mem, ark_mem->tn, + retval = mriStepInnerStepper_Reset(step_mem->stepper, ark_mem->tn, ark_mem->ycur); + if (retval != ARK_SUCCESS) + { + arkProcessError(ark_mem, ARK_INNERSTEP_FAIL, __LINE__, __func__, __FILE__, + "Unable to reset the inner stepper"); + return (ARK_INNERSTEP_FAIL); + } + retval = mriStep_StageERKFast(ark_mem, step_mem, ark_mem->tn, ark_mem->tn + cstage * ark_mem->h, - ark_mem->ycur, ytemp, SUNTRUE, - need_inner_dsm && !embedding); + ark_mem->ycur, ytemp, need_inner_dsm && !embedding); if (retval != ARK_SUCCESS) { *nflagPtr = CONV_FAIL; } /* set current stage time for implicit correction, postprocessing @@ -2751,8 +2764,18 @@ int mriStep_TakeStepMERK(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr) /* Evolve fast IVP for this stage: force reset on first stage in group potentially get inner dsm on all non-embedding stages */ + if (is == 0) + { + retval = mriStepInnerStepper_Reset(step_mem->stepper, t0, ark_mem->ycur); + if (retval != ARK_SUCCESS) + { + arkProcessError(ark_mem, ARK_INNERSTEP_FAIL, __LINE__, __func__, __FILE__, + "Unable to reset the inner stepper"); + return (ARK_INNERSTEP_FAIL); + } + } retval = mriStep_StageERKFast(ark_mem, step_mem, t0, tf, ark_mem->ycur, - ytemp, is == 0, need_inner_dsm && !embedding); + ytemp, need_inner_dsm && !embedding); if (retval != ARK_SUCCESS) { *nflagPtr = CONV_FAIL; } /* Update "initial time" for next stage in group */ @@ -3268,17 +3291,13 @@ int mriStep_CheckCoupling(ARKodeMem ark_mem) The vector ytemp is only used if temporal adaptivity is enabled, and the fast error is not provided by the fast integrator. - force_reset indicates whether ycur differs from the result of - the previous fast evolution, in which case the inner integrator - needs to be reset. - get_inner_dsm indicates whether this stage is one that should accumulate an inner temporal error estimate. ---------------------------------------------------------------*/ int mriStep_StageERKFast(ARKodeMem ark_mem, ARKodeMRIStepMem step_mem, sunrealtype t0, sunrealtype tf, N_Vector ycur, SUNDIALS_MAYBE_UNUSED N_Vector ytemp, - sunbooleantype force_reset, sunbooleantype get_inner_dsm) + sunbooleantype get_inner_dsm) { int retval; /* reusable return flag */ SUNAdaptController_Type adapt_type; /* timestep adaptivity type */ @@ -3296,18 +3315,6 @@ int mriStep_StageERKFast(ARKodeMem ark_mem, ARKodeMRIStepMem step_mem, if (retval != 0) { return (ARK_OUTERTOINNER_FAIL); } } - /* if the input state has changed since last called, reset the inner integrator */ - if (force_reset) - { - retval = mriStepInnerStepper_Reset(step_mem->stepper, t0, ycur); - if (retval != ARK_SUCCESS) - { - arkProcessError(ark_mem, ARK_INNERSTEP_FAIL, __LINE__, __func__, __FILE__, - "Unable to reset the inner stepper"); - return (ARK_INNERSTEP_FAIL); - } - } - /* Get the adaptivity type (if applicable) */ adapt_type = (get_inner_dsm) ? SUNAdaptController_GetType(ark_mem->hadapt_mem->hcontroller) diff --git a/src/arkode/arkode_mristep_impl.h b/src/arkode/arkode_mristep_impl.h index 8a39fd3887..403efbc637 100644 --- a/src/arkode/arkode_mristep_impl.h +++ b/src/arkode/arkode_mristep_impl.h @@ -275,8 +275,7 @@ int mriStep_SetCoupling(ARKodeMem ark_mem); int mriStep_CheckCoupling(ARKodeMem ark_mem); int mriStep_StageERKFast(ARKodeMem ark_mem, ARKodeMRIStepMem step_mem, sunrealtype t0, sunrealtype tf, N_Vector ycur, - N_Vector ytemp, sunbooleantype force_reset, - sunbooleantype get_inner_dsm); + N_Vector ytemp, sunbooleantype get_inner_dsm); int mriStep_StageERKNoFast(ARKodeMem ark_mem, ARKodeMRIStepMem step_mem, int is); int mriStep_StageDIRKFast(ARKodeMem ark_mem, ARKodeMRIStepMem step_mem, int is, int* nflagPtr); From be6d73551e4ba2eddce93ca5269d22710ebd23ae Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Wed, 30 Oct 2024 08:22:07 -0500 Subject: [PATCH 198/286] Updated inner forcing in ERKStep to match approach in ARKStep, to ensure validity of reused RHS vectors --- src/arkode/arkode_erkstep.c | 185 ++++++++++++++++++++++--------- src/arkode/arkode_erkstep_impl.h | 15 ++- 2 files changed, 142 insertions(+), 58 deletions(-) diff --git a/src/arkode/arkode_erkstep.c b/src/arkode/arkode_erkstep.c index 3030ddcad2..5688feca92 100644 --- a/src/arkode/arkode_erkstep.c +++ b/src/arkode/arkode_erkstep.c @@ -317,6 +317,21 @@ void erkStep_Free(ARKodeMem ark_mem) } step_mem->nfusedopvecs = 0; + /* free work arrays for MRI forcing */ + if (step_mem->stage_times) + { + free(step_mem->stage_times); + step_mem->stage_times = NULL; + ark_mem->lrw -= step_mem->stages; + } + + if (step_mem->stage_coefs) + { + free(step_mem->stage_coefs); + step_mem->stage_coefs = NULL; + ark_mem->lrw -= step_mem->stages; + } + /* free the time stepper module itself */ free(ark_mem->step_mem); ark_mem->step_mem = NULL; @@ -457,7 +472,7 @@ int erkStep_Init(ARKodeMem ark_mem, int init_type) ark_mem->liw += step_mem->stages; /* pointers */ /* Allocate reusable arrays for fused vector interface */ - step_mem->nfusedopvecs = step_mem->stages + 1 + step_mem->nforcing; + step_mem->nfusedopvecs = 2 * step_mem->stages + 2 + step_mem->nforcing; if (step_mem->cvals == NULL) { step_mem->cvals = (sunrealtype*)calloc(step_mem->nfusedopvecs, @@ -472,6 +487,27 @@ int erkStep_Init(ARKodeMem ark_mem, int init_type) ark_mem->liw += step_mem->nfusedopvecs; /* pointers */ } + /* Allocate workspace for MRI forcing -- need to allocate here as the + number of stages may not bet set before this point and we assume + SetInnerForcing has been called before the first step i.e., methods + start with a fast integration */ + if (step_mem->nforcing > 0) + { + if (!(step_mem->stage_times)) + { + step_mem->stage_times = (sunrealtype*)calloc(step_mem->stages, + sizeof(sunrealtype)); + ark_mem->lrw += step_mem->stages; + } + + if (!(step_mem->stage_coefs)) + { + step_mem->stage_coefs = (sunrealtype*)calloc(step_mem->stages, + sizeof(sunrealtype)); + ark_mem->lrw += step_mem->stages; + } + } + /* Override the interpolant degree (if needed), used in arkInitialSetup */ if (step_mem->q > 1 && ark_mem->interp_degree > (step_mem->q - 1)) { @@ -528,6 +564,7 @@ int erkStep_FullRHS(ARKodeMem ark_mem, sunrealtype t, N_Vector y, N_Vector f, sunbooleantype recomputeRHS; sunrealtype* cvals; N_Vector* Xvecs; + sunrealtype stage_coefs = ONE; /* access ARKodeERKStepMem structure */ retval = erkStep_AccessStepMem(ark_mem, __func__, &step_mem); @@ -542,7 +579,7 @@ int erkStep_FullRHS(ARKodeMem ark_mem, sunrealtype t, N_Vector y, N_Vector f, { case ARK_FULLRHS_START: - /* compute the RHS */ + /* compute the RHS if needed */ if (!(ark_mem->fn_is_current)) { retval = step_mem->f(t, y, step_mem->F[0], ark_mem->user_data); @@ -553,21 +590,21 @@ int erkStep_FullRHS(ARKodeMem ark_mem, sunrealtype t, N_Vector y, N_Vector f, MSG_ARK_RHSFUNC_FAILED, t); return (ARK_RHSFUNC_FAIL); } - - /* apply external polynomial forcing */ - if (step_mem->nforcing > 0) - { - cvals[0] = ONE; - Xvecs[0] = step_mem->F[0]; - nvec = 1; - erkStep_ApplyForcing(step_mem, t, ONE, &nvec); - N_VLinearCombination(nvec, cvals, Xvecs, step_mem->F[0]); - } } - /* copy RHS vector into output */ + /* copy RHS into output */ N_VScale(ONE, step_mem->F[0], f); + /* apply external polynomial forcing */ + if (step_mem->nforcing > 0) + { + cvals[0] = ONE; + Xvecs[0] = f; + nvec = 1; + erkStep_ApplyForcing(step_mem, &t, &stage_coefs, 1, &nvec); + N_VLinearCombination(nvec, cvals, Xvecs, f); + } + break; case ARK_FULLRHS_END: @@ -580,7 +617,7 @@ int erkStep_FullRHS(ARKodeMem ark_mem, sunrealtype t, N_Vector y, N_Vector f, /* First Same As Last methods are not FSAL when relaxation is enabled */ if (ark_mem->relax_enabled) { recomputeRHS = SUNTRUE; } - /* base RHS calls on recomputeRHS argument */ + /* base RHS call on recomputeRHS argument */ if (recomputeRHS) { /* call f */ @@ -592,21 +629,22 @@ int erkStep_FullRHS(ARKodeMem ark_mem, sunrealtype t, N_Vector y, N_Vector f, __FILE__, MSG_ARK_RHSFUNC_FAILED, t); return (ARK_RHSFUNC_FAIL); } - /* apply external polynomial forcing */ - if (step_mem->nforcing > 0) - { - cvals[0] = ONE; - Xvecs[0] = step_mem->F[0]; - nvec = 1; - erkStep_ApplyForcing(step_mem, t, ONE, &nvec); - N_VLinearCombination(nvec, cvals, Xvecs, step_mem->F[0]); - } } else { N_VScale(ONE, step_mem->F[step_mem->stages - 1], step_mem->F[0]); } - } - /* copy RHS vector into output */ - N_VScale(ONE, step_mem->F[0], f); + /* copy RHS vector into output */ + N_VScale(ONE, step_mem->F[0], f); + + /* apply external polynomial forcing */ + if (step_mem->nforcing > 0) + { + cvals[0] = ONE; + Xvecs[0] = f; + nvec = 1; + erkStep_ApplyForcing(step_mem, &t, &stage_coefs, 1, &nvec); + N_VLinearCombination(nvec, cvals, Xvecs, f); + } + } break; @@ -627,7 +665,7 @@ int erkStep_FullRHS(ARKodeMem ark_mem, sunrealtype t, N_Vector y, N_Vector f, cvals[0] = ONE; Xvecs[0] = f; nvec = 1; - erkStep_ApplyForcing(step_mem, t, ONE, &nvec); + erkStep_ApplyForcing(step_mem, &t, &stage_coefs, 1, &nvec); N_VLinearCombination(nvec, cvals, Xvecs, f); } @@ -738,6 +776,18 @@ int erkStep_TakeStep(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr) Xvecs[nvec] = ark_mem->yn; nvec += 1; + /* apply external polynomial forcing */ + if (step_mem->nforcing > 0) + { + for (js = 0; js < is; js++) + { + step_mem->stage_times[js] = ark_mem->tn + step_mem->B->c[js] * ark_mem->h; + step_mem->stage_coefs[js] = ark_mem->h * step_mem->B->A[is][js]; + } + erkStep_ApplyForcing(step_mem, step_mem->stage_times, step_mem->stage_coefs, + is, &nvec); + } + /* call fused vector operation to do the work */ retval = N_VLinearCombination(nvec, cvals, Xvecs, ark_mem->ycur); if (retval != 0) { return (ARK_VECTOROP_ERR); } @@ -757,16 +807,6 @@ int erkStep_TakeStep(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr) if (retval < 0) { return (ARK_RHSFUNC_FAIL); } if (retval > 0) { return (ARK_UNREC_RHSFUNC_ERR); } - /* apply external polynomial forcing */ - if (step_mem->nforcing > 0) - { - cvals[0] = ONE; - Xvecs[0] = step_mem->F[is]; - nvec = 1; - erkStep_ApplyForcing(step_mem, ark_mem->tcur, ONE, &nvec); - N_VLinearCombination(nvec, cvals, Xvecs, step_mem->F[is]); - } - #ifdef SUNDIALS_LOGGING_EXTRA_DEBUG SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, "ARKODE::erkStep_TakeStep", "stage RHS", "F_%i(:) =", is); @@ -1087,6 +1127,18 @@ int erkStep_ComputeSolutions(ARKodeMem ark_mem, sunrealtype* dsmPtr) Xvecs[nvec] = ark_mem->yn; nvec += 1; + /* apply external polynomial forcing */ + if (step_mem->nforcing > 0) + { + for (j = 0; j < step_mem->stages; j++) + { + step_mem->stage_times[j] = ark_mem->tn + step_mem->B->c[j] * ark_mem->h; + step_mem->stage_coefs[j] = ark_mem->h * step_mem->B->b[j]; + } + erkStep_ApplyForcing(step_mem, step_mem->stage_times, step_mem->stage_coefs, + step_mem->stages, &nvec); + } + /* call fused vector operation to do the work */ retval = N_VLinearCombination(nvec, cvals, Xvecs, y); if (retval != 0) { return (ARK_VECTOROP_ERR); } @@ -1103,6 +1155,18 @@ int erkStep_ComputeSolutions(ARKodeMem ark_mem, sunrealtype* dsmPtr) nvec += 1; } + /* apply external polynomial forcing */ + if (step_mem->nforcing > 0) + { + for (j = 0; j < step_mem->stages; j++) + { + step_mem->stage_times[j] = ark_mem->tn + step_mem->B->c[j] * ark_mem->h; + step_mem->stage_coefs[j] = ark_mem->h * (step_mem->B->b[j] - step_mem->B->d[j]); + } + erkStep_ApplyForcing(step_mem, step_mem->stage_times, step_mem->stage_coefs, + step_mem->stages, &nvec); + } + /* call fused vector operation to do the work */ retval = N_VLinearCombination(nvec, cvals, Xvecs, yerr); if (retval != 0) { return (ARK_VECTOROP_ERR); } @@ -1224,27 +1288,44 @@ int erkStep_GetOrder(ARKodeMem ark_mem) scaling factor that should be applied to each of these coefficients. ----------------------------------------------------------------------------*/ -void erkStep_ApplyForcing(ARKodeERKStepMem step_mem, sunrealtype t, - sunrealtype s, int* nvec) +void erkStep_ApplyForcing(ARKodeERKStepMem step_mem, sunrealtype* stage_times, + sunrealtype* stage_coefs, int jmax, int* nvec) { sunrealtype tau, taui; - int i; + int j, k; + + /* Shortcuts to step_mem data */ + sunrealtype* vals = step_mem->cvals; + N_Vector* vecs = step_mem->Xvecs; + sunrealtype tshift = step_mem->tshift; + sunrealtype tscale = step_mem->tscale; + int nforcing = step_mem->nforcing; + N_Vector* forcing = step_mem->forcing; - /* always append the constant forcing term */ - step_mem->cvals[*nvec] = s; - step_mem->Xvecs[*nvec] = step_mem->forcing[0]; - (*nvec) += 1; + /* Offset into vals and vecs arrays */ + int offset = *nvec; - /* compute normalized time tau and initialize tau^i */ - tau = (t - step_mem->tshift) / (step_mem->tscale); - taui = tau; - for (i = 1; i < step_mem->nforcing; i++) + /* Initialize scaling values, set vectors */ + for (k = 0; k < nforcing; k++) { - step_mem->cvals[*nvec] = s * taui; - step_mem->Xvecs[*nvec] = step_mem->forcing[i]; - taui *= tau; - (*nvec) += 1; + vals[offset + k] = ZERO; + vecs[offset + k] = forcing[k]; } + + for (j = 0; j < jmax; j++) + { + tau = (stage_times[j] - tshift) / tscale; + taui = ONE; + + for (k = 0; k < nforcing; k++) + { + vals[offset + k] += stage_coefs[j] * taui; + taui *= tau; + } + } + + /* Update vector count for linear combination */ + *nvec += nforcing; } /*------------------------------------------------------------------------------ diff --git a/src/arkode/arkode_erkstep_impl.h b/src/arkode/arkode_erkstep_impl.h index 907e457e3e..6397880b39 100644 --- a/src/arkode/arkode_erkstep_impl.h +++ b/src/arkode/arkode_erkstep_impl.h @@ -63,10 +63,13 @@ typedef struct ARKodeERKStepMemRec int nfusedopvecs; /* length of cvals and Xvecs arrays */ /* Data for using ERKStep with external polynomial forcing */ - sunrealtype tshift; /* time normalization shift */ - sunrealtype tscale; /* time normalization scaling */ - N_Vector* forcing; /* array of forcing vectors */ - int nforcing; /* number of forcing vectors */ + sunrealtype tshift; /* time normalization shift */ + sunrealtype tscale; /* time normalization scaling */ + N_Vector* forcing; /* array of forcing vectors */ + int nforcing; /* number of forcing vectors */ + sunrealtype* stage_times; /* workspace for applying forcing */ + sunrealtype* stage_coefs; /* workspace for applying forcing */ + }* ARKodeERKStepMem; @@ -104,8 +107,8 @@ sunbooleantype erkStep_CheckNVector(N_Vector tmpl); int erkStep_SetButcherTable(ARKodeMem ark_mem); int erkStep_CheckButcherTable(ARKodeMem ark_mem); int erkStep_ComputeSolutions(ARKodeMem ark_mem, sunrealtype* dsm); -void erkStep_ApplyForcing(ARKodeERKStepMem step_mem, sunrealtype t, - sunrealtype s, int* nvec); +void erkStep_ApplyForcing(ARKodeERKStepMem step_mem, sunrealtype* stage_times, + sunrealtype* stage_coefs, int jmax, int* nvec); /* private functions for relaxation */ int erkStep_SetRelaxFn(ARKodeMem ark_mem, ARKRelaxFn rfn, ARKRelaxJacFn rjac); From b31b6dfb8dc7b6ba1bf74756425002a2bc4b54c0 Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Wed, 30 Oct 2024 08:41:21 -0500 Subject: [PATCH 199/286] Reverted changes to arkHin, arkYddNorm, and arkUpperBoundH0 --- src/arkode/arkode.c | 84 +++++++++++++++++++--------------------- src/arkode/arkode_impl.h | 11 ++---- 2 files changed, 43 insertions(+), 52 deletions(-) diff --git a/src/arkode/arkode.c b/src/arkode/arkode.c index c55c6bde33..68005fd7c0 100644 --- a/src/arkode/arkode.c +++ b/src/arkode/arkode.c @@ -2046,15 +2046,6 @@ int arkInitialSetup(ARKodeMem ark_mem, sunrealtype tout) ark_mem->h = SUNRabs(tout - ark_mem->tcur); if (ark_mem->h == ZERO) ark_mem->h = ONE; - /* Call fullrhs if needed */ - if (!(ark_mem->fn_is_current)) - { - retval = ark_mem->step_fullrhs(ark_mem, ark_mem->tcur, ark_mem->yn, - ark_mem->fn, ARK_FULLRHS_START); - if (retval != 0) { return (ARK_RHSFUNC_FAIL); } - ark_mem->fn_is_current = SUNTRUE; - } - /* Estimate the first step size */ tout_hin = tout; if (ark_mem->tstopset && @@ -2062,14 +2053,13 @@ int arkInitialSetup(ARKodeMem ark_mem, sunrealtype tout) { tout_hin = ark_mem->tstop; } - hflag = arkHin(ark_mem, ark_mem->tcur, tout_hin, ark_mem->yn, ark_mem->fn, - ark_mem->ycur, ark_mem->tempv1, ark_mem->tempv2, - ark_mem->step_fullrhs, &ark_mem->h); + hflag = arkHin(ark_mem, tout_hin); if (hflag != ARK_SUCCESS) { 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; } @@ -2364,9 +2354,7 @@ int arkStopTests(ARKodeMem ark_mem, sunrealtype tout, N_Vector yout, Finally, we apply a bias (0.5) and verify that h0 is within bounds. ---------------------------------------------------------------*/ -int arkHin(ARKodeMem ark_mem, sunrealtype tcur, sunrealtype tout, N_Vector ycur, - N_Vector fcur, N_Vector ytmp, N_Vector temp1, N_Vector temp2, - ARKTimestepFullRHSFn rhs, sunrealtype* h) +int arkHin(ARKodeMem ark_mem, sunrealtype tout) { int retval, sign, count1, count2; sunrealtype tdiff, tdist, tround, hlb, hub; @@ -2374,26 +2362,39 @@ int arkHin(ARKodeMem ark_mem, sunrealtype tcur, sunrealtype tout, N_Vector ycur, sunbooleantype hgOK; /* If tout is too close to tn, give up */ - if ((tdiff = tout - tcur) == ZERO) { return (ARK_TOO_CLOSE); } + if ((tdiff = tout - ark_mem->tcur) == ZERO) { return (ARK_TOO_CLOSE); } sign = (tdiff > ZERO) ? 1 : -1; tdist = SUNRabs(tdiff); - tround = ark_mem->uround * SUNMAX(SUNRabs(tcur), SUNRabs(tout)); + tround = ark_mem->uround * SUNMAX(SUNRabs(ark_mem->tcur), SUNRabs(tout)); if (tdist < TWO * tround) { return (ARK_TOO_CLOSE); } + /* call full RHS if needed */ + if (!(ark_mem->fn_is_current)) + { + /* NOTE: The step size (h) is used in setting the tolerance in a potential + mass matrix solve when computing the full RHS. Before calling arkHin, h + is set to |tout - tcur| or 1 and so we do not need to guard against + h == 0 here before calling the full RHS. */ + retval = ark_mem->step_fullrhs(ark_mem, ark_mem->tn, ark_mem->yn, + ark_mem->fn, ARK_FULLRHS_START); + if (retval) { return ARK_RHSFUNC_FAIL; } + ark_mem->fn_is_current = SUNTRUE; + } + /* Set lower and upper bounds on h0, and take geometric mean as first trial value. Exit with this value if the bounds cross each other. */ hlb = H0_LBFACTOR * tround; - hub = arkUpperBoundH0(ark_mem, tdist, ycur, fcur, temp1, temp2); + hub = arkUpperBoundH0(ark_mem, tdist); hg = SUNRsqrt(hlb * hub); if (hub < hlb) { - if (sign == -1) { *h = -hg; } - else { *h = hg; } + if (sign == -1) { ark_mem->h = -hg; } + else { ark_mem->h = hg; } return (ARK_SUCCESS); } @@ -2407,8 +2408,7 @@ int arkHin(ARKodeMem ark_mem, sunrealtype tcur, sunrealtype tout, N_Vector ycur, for (count2 = 1; count2 <= H0_ITERS; count2++) { hgs = hg * sign; - retval = arkYddNorm(ark_mem, hgs, tcur, ycur, fcur, ytmp, temp1, rhs, - &yddnrm); + retval = arkYddNorm(ark_mem, hgs, &yddnrm); /* If f() failed unrecoverably, give up */ if (retval < 0) { return (ARK_RHSFUNC_FAIL); } /* If successful, we can use ydd */ @@ -2463,7 +2463,7 @@ int arkHin(ARKodeMem ark_mem, sunrealtype tcur, sunrealtype tout, N_Vector ycur, if (h0 < hlb) { h0 = hlb; } if (h0 > hub) { h0 = hub; } if (sign == -1) { h0 = -h0; } - *h = h0; + ark_mem->h = h0; return (ARK_SUCCESS); } @@ -2473,24 +2473,24 @@ int arkHin(ARKodeMem ark_mem, sunrealtype tcur, sunrealtype tout, N_Vector ycur, This routine sets an upper bound on abs(h0) based on tdist = tn - t0 and the values of y[i]/y'[i]. - - It is assumed that the input f equals y', and that - temp1 and temp2 may be modified as desired. ---------------------------------------------------------------*/ -sunrealtype arkUpperBoundH0(ARKodeMem ark_mem, sunrealtype tdist, N_Vector y, - N_Vector f, N_Vector temp1, N_Vector temp2) +sunrealtype arkUpperBoundH0(ARKodeMem ark_mem, sunrealtype tdist) { sunrealtype hub_inv, hub; + N_Vector temp1, temp2; /* Bound based on |y0|/|y0'| -- allow at most an increase of * H0_UBFACTOR in y0 (based on a forward Euler step). The weight * factor is used as a safeguard against zero components in y0. */ - N_VAbs(y, temp2); - ark_mem->efun(y, temp1, ark_mem->e_data); + temp1 = ark_mem->tempv1; + temp2 = ark_mem->tempv2; + + N_VAbs(ark_mem->yn, temp2); + ark_mem->efun(ark_mem->yn, temp1, ark_mem->e_data); N_VInv(temp1, temp1); N_VLinearSum(H0_UBFACTOR, temp2, ONE, temp1, temp1); - N_VAbs(f, temp2); + N_VAbs(ark_mem->fn, temp2); N_VDiv(temp2, temp1, temp1); hub_inv = N_VMaxNorm(temp1); @@ -2510,32 +2510,28 @@ sunrealtype arkUpperBoundH0(ARKodeMem ark_mem, sunrealtype tdist, N_Vector y, This routine computes an estimate of the second derivative of y using a difference quotient, and returns its WRMS norm. - - It is assumed that the input f equals y'(t), that ycur can - be modified as desired, but upon return to equal y, and that - temp1 may be modified as desired. ---------------------------------------------------------------*/ -int arkYddNorm(ARKodeMem ark_mem, sunrealtype hg, sunrealtype t, N_Vector y, - N_Vector f, N_Vector ycur, N_Vector temp1, - ARKTimestepFullRHSFn rhs, sunrealtype* yddnrm) +int arkYddNorm(ARKodeMem ark_mem, sunrealtype hg, sunrealtype* yddnrm) { int retval; /* increment y with a multiple of f */ - N_VLinearSum(hg, f, ONE, y, ycur); + N_VLinearSum(hg, ark_mem->fn, ONE, ark_mem->yn, ark_mem->ycur); /* compute y', via the ODE RHS routine */ - retval = rhs(ark_mem, t + hg, ycur, temp1, ARK_FULLRHS_OTHER); - if (retval != 0) return (ARK_RHSFUNC_FAIL); + retval = ark_mem->step_fullrhs(ark_mem, ark_mem->tcur + hg, ark_mem->ycur, + ark_mem->tempv1, ARK_FULLRHS_OTHER); + if (retval != 0) { return (ARK_RHSFUNC_FAIL); } /* difference new f and original f to estimate y'' */ - N_VLinearSum(ONE / hg, temp1, -ONE / hg, f, temp1); + N_VLinearSum(ONE / hg, ark_mem->tempv1, -ONE / hg, ark_mem->fn, + ark_mem->tempv1); /* reset ycur to equal yn (unnecessary?) */ - N_VScale(ONE, y, ycur); + N_VScale(ONE, ark_mem->yn, ark_mem->ycur); /* compute norm of y'' */ - *yddnrm = N_VWrmsNorm(temp1, ark_mem->ewt); + *yddnrm = N_VWrmsNorm(ark_mem->tempv1, ark_mem->ewt); return (ARK_SUCCESS); } diff --git a/src/arkode/arkode_impl.h b/src/arkode/arkode_impl.h index 029ca962a6..652fbb24c7 100644 --- a/src/arkode/arkode_impl.h +++ b/src/arkode/arkode_impl.h @@ -628,14 +628,9 @@ sunbooleantype arkCheckNvector(N_Vector tmpl); int arkInitialSetup(ARKodeMem ark_mem, sunrealtype tout); int arkStopTests(ARKodeMem ark_mem, sunrealtype tout, N_Vector yout, sunrealtype* tret, int itask, int* ier); -int arkHin(ARKodeMem ark_mem, sunrealtype tcur, sunrealtype tout, N_Vector ycur, - N_Vector fcur, N_Vector ytmp, N_Vector temp1, N_Vector temp2, - ARKTimestepFullRHSFn rhs, sunrealtype* h); -sunrealtype arkUpperBoundH0(ARKodeMem ark_mem, sunrealtype tdist, N_Vector y, - N_Vector f, N_Vector temp1, N_Vector temp2); -int arkYddNorm(ARKodeMem ark_mem, sunrealtype hg, sunrealtype t, N_Vector y, - N_Vector f, N_Vector ycur, N_Vector temp1, - ARKTimestepFullRHSFn rhs, sunrealtype* yddnrm); +int arkHin(ARKodeMem ark_mem, sunrealtype tout); +sunrealtype arkUpperBoundH0(ARKodeMem ark_mem, sunrealtype tdist); +int arkYddNorm(ARKodeMem ark_mem, sunrealtype hg, sunrealtype* yddnrm); int arkCompleteStep(ARKodeMem ark_mem, sunrealtype dsm); int arkHandleFailure(ARKodeMem ark_mem, int flag); From bc7908165442fda773a0e832933599785979e837 Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Wed, 30 Oct 2024 09:17:02 -0500 Subject: [PATCH 200/286] Updated documentation for custom MRIStepInnerSteppers --- .../Usage/MRIStep/Custom_Inner_Stepper/Description.rst | 9 +++++++-- src/arkode/arkode_mristep.c | 5 ++--- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/doc/arkode/guide/source/Usage/MRIStep/Custom_Inner_Stepper/Description.rst b/doc/arkode/guide/source/Usage/MRIStep/Custom_Inner_Stepper/Description.rst index 21909cc5d8..1f2042cfb2 100644 --- a/doc/arkode/guide/source/Usage/MRIStep/Custom_Inner_Stepper/Description.rst +++ b/doc/arkode/guide/source/Usage/MRIStep/Custom_Inner_Stepper/Description.rst @@ -280,7 +280,10 @@ responsible for evaluating ODE right-hand side function :math:`f^F(t,v)` as well as computing and applying the forcing term :eq:`ARKODE_MRI_forcing_poly` to obtain the full right-hand side of the inner (fast) ODE :eq:`ARKODE_MRI_IVP`. The functions in this section can be used to either apply the inner (fast) forcing or access the -data necessary to construct the inner (fast) forcing polynomial. +data necessary to construct the inner (fast) forcing polynomial. While the first of +these is less intrusive and may be used to package an existing black-box IVP solver +as an MRIStepInnerStepper, the latter may be more computationally efficient since it +does not traverse the data directly. .. c:function:: int MRIStepInnerStepper_AddForcing(MRIStepInnerStepper stepper, sunrealtype t, N_Vector ff) @@ -300,6 +303,7 @@ data necessary to construct the inner (fast) forcing polynomial. * ``examples/arkode/CXX_parallel/ark_diffusion_reaction_p.cpp`` + .. c:function:: int MRIStepInnerStepper_GetForcingData(MRIStepInnerStepper stepper, sunrealtype *tshift, sunrealtype *tscale, N_Vector **forcing, int *nforcing) This function provides access to data necessary to compute the forcing term @@ -394,7 +398,8 @@ following member functions: This function computes the full right-hand side function of the inner (fast) ODE, :math:`f^F(t,v)` in :eq:`ARKODE_MRI_IVP` for a given value of the independent - variable *t* and state vector *y*. + variable *t* and state vector *y*. We note that this routine should *not* include + contributions from the forcing term :eq:`ARKODE_MRI_forcing_poly`. **Arguments:** * *stepper* -- the inner stepper object. diff --git a/src/arkode/arkode_mristep.c b/src/arkode/arkode_mristep.c index 610665926f..25355a4df7 100644 --- a/src/arkode/arkode_mristep.c +++ b/src/arkode/arkode_mristep.c @@ -1749,9 +1749,8 @@ int mriStep_TakeStepMRIGARK(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPt } /* Evaluate the slow RHS functions if needed. NOTE: We do not use the full RHS - function here (unlike ERKStep and ARKStep) since it does not need to check - for FSAL or SA methods and thus avoids potentially unnecessary evaluations - of the inner (fast) RHS function */ + function here since it does not need to check for FSAL or SA methods and + thus avoids potentially unnecessary evaluations of the inner (fast) RHS function */ if (!(ark_mem->fn_is_current)) { /* compute the explicit component */ From f8480f36c632a904fa2a5db68551576bf16ee97b Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Wed, 30 Oct 2024 09:17:53 -0500 Subject: [PATCH 201/286] formatting --- src/arkode/arkode_erkstep.c | 15 ++++++++------- src/arkode/arkode_erkstep_impl.h | 13 ++++++------- src/arkode/arkode_mristep.c | 16 +++++++++------- 3 files changed, 23 insertions(+), 21 deletions(-) diff --git a/src/arkode/arkode_erkstep.c b/src/arkode/arkode_erkstep.c index 5688feca92..5d85477195 100644 --- a/src/arkode/arkode_erkstep.c +++ b/src/arkode/arkode_erkstep.c @@ -601,8 +601,8 @@ int erkStep_FullRHS(ARKodeMem ark_mem, sunrealtype t, N_Vector y, N_Vector f, cvals[0] = ONE; Xvecs[0] = f; nvec = 1; - erkStep_ApplyForcing(step_mem, &t, &stage_coefs, 1, &nvec); - N_VLinearCombination(nvec, cvals, Xvecs, f); + erkStep_ApplyForcing(step_mem, &t, &stage_coefs, 1, &nvec); + N_VLinearCombination(nvec, cvals, Xvecs, f); } break; @@ -784,8 +784,8 @@ int erkStep_TakeStep(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr) step_mem->stage_times[js] = ark_mem->tn + step_mem->B->c[js] * ark_mem->h; step_mem->stage_coefs[js] = ark_mem->h * step_mem->B->A[is][js]; } - erkStep_ApplyForcing(step_mem, step_mem->stage_times, step_mem->stage_coefs, - is, &nvec); + erkStep_ApplyForcing(step_mem, step_mem->stage_times, + step_mem->stage_coefs, is, &nvec); } /* call fused vector operation to do the work */ @@ -1161,10 +1161,11 @@ int erkStep_ComputeSolutions(ARKodeMem ark_mem, sunrealtype* dsmPtr) for (j = 0; j < step_mem->stages; j++) { step_mem->stage_times[j] = ark_mem->tn + step_mem->B->c[j] * ark_mem->h; - step_mem->stage_coefs[j] = ark_mem->h * (step_mem->B->b[j] - step_mem->B->d[j]); + step_mem->stage_coefs[j] = ark_mem->h * + (step_mem->B->b[j] - step_mem->B->d[j]); } - erkStep_ApplyForcing(step_mem, step_mem->stage_times, step_mem->stage_coefs, - step_mem->stages, &nvec); + erkStep_ApplyForcing(step_mem, step_mem->stage_times, + step_mem->stage_coefs, step_mem->stages, &nvec); } /* call fused vector operation to do the work */ diff --git a/src/arkode/arkode_erkstep_impl.h b/src/arkode/arkode_erkstep_impl.h index 6397880b39..91af4cce30 100644 --- a/src/arkode/arkode_erkstep_impl.h +++ b/src/arkode/arkode_erkstep_impl.h @@ -63,13 +63,12 @@ typedef struct ARKodeERKStepMemRec int nfusedopvecs; /* length of cvals and Xvecs arrays */ /* Data for using ERKStep with external polynomial forcing */ - sunrealtype tshift; /* time normalization shift */ - sunrealtype tscale; /* time normalization scaling */ - N_Vector* forcing; /* array of forcing vectors */ - int nforcing; /* number of forcing vectors */ - sunrealtype* stage_times; /* workspace for applying forcing */ - sunrealtype* stage_coefs; /* workspace for applying forcing */ - + sunrealtype tshift; /* time normalization shift */ + sunrealtype tscale; /* time normalization scaling */ + N_Vector* forcing; /* array of forcing vectors */ + int nforcing; /* number of forcing vectors */ + sunrealtype* stage_times; /* workspace for applying forcing */ + sunrealtype* stage_coefs; /* workspace for applying forcing */ }* ARKodeERKStepMem; diff --git a/src/arkode/arkode_mristep.c b/src/arkode/arkode_mristep.c index 25355a4df7..19a90d99d1 100644 --- a/src/arkode/arkode_mristep.c +++ b/src/arkode/arkode_mristep.c @@ -2038,8 +2038,8 @@ int mriStep_TakeStepMRIGARK(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPt retval = mriStepInnerStepper_Reset(step_mem->stepper, t0, ark_mem->ycur); if (retval != ARK_SUCCESS) { - arkProcessError(ark_mem, ARK_INNERSTEP_FAIL, __LINE__, __func__, __FILE__, - "Unable to reset the inner stepper"); + arkProcessError(ark_mem, ARK_INNERSTEP_FAIL, __LINE__, __func__, + __FILE__, "Unable to reset the inner stepper"); return (ARK_INNERSTEP_FAIL); } retval = mriStep_StageERKFast(ark_mem, step_mem, t0, tf, ark_mem->ycur, @@ -2321,16 +2321,18 @@ int mriStep_TakeStepMRISR(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr) /* Evolve fast IVP for this stage: force reset due to "stage-restart" structure potentially get inner dsm on all non-embedding stages */ - retval = mriStepInnerStepper_Reset(step_mem->stepper, ark_mem->tn, ark_mem->ycur); + retval = mriStepInnerStepper_Reset(step_mem->stepper, ark_mem->tn, + ark_mem->ycur); if (retval != ARK_SUCCESS) { arkProcessError(ark_mem, ARK_INNERSTEP_FAIL, __LINE__, __func__, __FILE__, "Unable to reset the inner stepper"); return (ARK_INNERSTEP_FAIL); } - retval = mriStep_StageERKFast(ark_mem, step_mem, ark_mem->tn, + retval = mriStep_StageERKFast(ark_mem, step_mem, ark_mem->tn, ark_mem->tn + cstage * ark_mem->h, - ark_mem->ycur, ytemp, need_inner_dsm && !embedding); + ark_mem->ycur, ytemp, + need_inner_dsm && !embedding); if (retval != ARK_SUCCESS) { *nflagPtr = CONV_FAIL; } /* set current stage time for implicit correction, postprocessing @@ -2768,8 +2770,8 @@ int mriStep_TakeStepMERK(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr) retval = mriStepInnerStepper_Reset(step_mem->stepper, t0, ark_mem->ycur); if (retval != ARK_SUCCESS) { - arkProcessError(ark_mem, ARK_INNERSTEP_FAIL, __LINE__, __func__, __FILE__, - "Unable to reset the inner stepper"); + arkProcessError(ark_mem, ARK_INNERSTEP_FAIL, __LINE__, __func__, + __FILE__, "Unable to reset the inner stepper"); return (ARK_INNERSTEP_FAIL); } } From f812758c0e0bc085816e91f4f0c9003bde066db3 Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Wed, 30 Oct 2024 09:22:21 -0500 Subject: [PATCH 202/286] Updated answers repository commit --- test/answers | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/answers b/test/answers index cbf335f7e2..effad098bc 160000 --- a/test/answers +++ b/test/answers @@ -1 +1 @@ -Subproject commit cbf335f7e244de7c12a4dbd638b4e0f02811a4a3 +Subproject commit effad098bc89ed78e2300d9ba03b507cab1ab435 From 9661e51a6f7da1aef30c58b88b74ffdeeca438c5 Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Wed, 30 Oct 2024 11:05:10 -0500 Subject: [PATCH 203/286] Removed tout from ark_mem structure, and added it to the stepper initialization routine --- .../arkode/CXX_serial/ark_kpr_nestedmri.out | 52 +++++++++---------- .../arkode/C_serial/ark_kpr_mri_1_0_0.01.out | 2 +- src/arkode/arkode.c | 5 +- src/arkode/arkode_arkstep.c | 2 +- src/arkode/arkode_arkstep_impl.h | 2 +- src/arkode/arkode_erkstep.c | 2 +- src/arkode/arkode_erkstep_impl.h | 2 +- src/arkode/arkode_impl.h | 3 +- src/arkode/arkode_mristep.c | 4 +- src/arkode/arkode_mristep_impl.h | 2 +- src/arkode/arkode_sprkstep.c | 2 +- src/arkode/arkode_sprkstep_impl.h | 2 +- 12 files changed, 38 insertions(+), 42 deletions(-) diff --git a/examples/arkode/CXX_serial/ark_kpr_nestedmri.out b/examples/arkode/CXX_serial/ark_kpr_nestedmri.out index 9b76d6015a..3266fbb806 100644 --- a/examples/arkode/CXX_serial/ark_kpr_nestedmri.out +++ b/examples/arkode/CXX_serial/ark_kpr_nestedmri.out @@ -20,32 +20,32 @@ Adaptive nested multirate nonlinear Kvaerno-Prothero-Robinson test problem: t u v w uerr verr werr ---------------------------------------------------------------------------- 0.000000 1.581139 1.732051 1.732051 0.00e+00 0.00e+00 0.00e+00 - 0.250000 1.576185 1.693772 1.005263 2.68e-05 6.50e-06 7.40e-05 - 0.500000 1.561493 1.094294 1.236926 1.98e-06 4.53e-05 3.20e-05 - 0.750000 1.537292 1.480065 1.289834 8.10e-04 2.26e-04 1.94e-04 - 1.000000 1.506079 1.658256 1.566295 1.75e-07 2.30e-05 6.87e-06 - 1.250000 1.468771 1.117271 1.128804 4.06e-06 1.73e-04 2.48e-05 - 1.500000 1.426610 1.451084 1.383739 1.21e-06 1.17e-04 5.91e-05 - 1.750000 1.382269 1.731247 1.400679 3.60e-06 6.78e-05 9.82e-05 - 2.000000 1.338568 1.577290 1.004829 2.15e-06 5.96e-04 1.62e-04 - 2.250000 1.298417 1.357868 1.203073 6.37e-07 6.53e-07 5.92e-05 - 2.500000 1.264630 1.111890 1.079994 6.16e-06 4.54e-06 1.67e-04 - 2.750000 1.240048 1.181637 1.688472 2.78e-05 1.03e-04 2.38e-04 - 3.000000 1.226780 1.199832 1.243793 2.58e-06 2.08e-05 1.47e-04 - 3.250000 1.225866 1.336964 1.695773 2.72e-06 2.03e-05 3.74e-05 - 3.500000 1.237694 1.494251 1.577827 1.77e-06 5.51e-07 2.05e-05 - 3.750000 1.260876 1.441515 1.440466 2.99e-08 1.89e-06 8.19e-05 - 4.000000 1.294347 1.067920 1.718693 8.82e-04 8.63e-05 1.41e-04 - 4.250000 1.333409 1.724804 1.004034 4.31e-07 6.75e-07 4.49e-05 - 4.500000 1.376493 1.650147 1.499995 5.63e-05 1.87e-05 1.84e-05 - 4.750000 1.420959 1.555056 1.167670 1.39e-04 6.07e-05 2.39e-05 - 5.000000 1.463494 1.506542 1.644772 6.74e-06 1.24e-05 6.69e-05 + 0.271582 1.575296 1.368971 1.648718 1.09e-05 1.20e-04 5.83e-05 + 0.617473 1.551202 1.168347 1.006336 4.55e-04 3.77e-04 3.17e-04 + 0.844568 1.526410 1.001343 1.370195 6.30e-04 2.76e-05 1.67e-04 + 1.055010 1.498331 1.580272 1.237958 4.31e-04 3.89e-06 1.31e-04 + 1.442729 1.436320 1.672339 1.573390 2.18e-04 2.55e-05 1.27e-04 + 1.636588 1.402356 1.038742 1.211055 1.10e-04 2.03e-04 1.45e-04 + 1.823369 1.369205 1.051418 1.514343 4.93e-05 9.62e-05 1.80e-04 + 2.149511 1.313959 1.579270 1.556854 4.00e-05 4.69e-05 2.62e-04 + 2.404891 1.276887 1.124406 1.126849 3.60e-04 1.03e-04 5.45e-04 + 2.608190 1.252993 1.682786 1.600337 2.28e-04 1.05e-04 3.41e-04 + 2.811489 1.235928 1.719503 1.397056 2.51e-04 3.97e-05 4.08e-04 + 3.014788 1.226738 1.030877 1.574038 4.02e-04 1.00e-04 2.15e-04 + 3.413391 1.232704 1.604116 1.712849 4.90e-04 4.92e-05 1.65e-05 + 3.599447 1.245912 1.625915 1.725917 2.94e-04 1.26e-05 2.48e-05 + 3.785502 1.265227 1.152518 1.652681 2.57e-04 9.10e-05 1.44e-04 + 4.157612 1.317986 1.091120 1.101285 1.64e-04 9.70e-05 2.34e-04 + 4.343667 1.349100 1.318672 1.053462 1.07e-04 5.19e-06 1.49e-04 + 4.529723 1.381861 1.668675 1.698826 1.44e-04 7.79e-05 6.19e-05 + 4.880130 1.443414 1.599766 1.152755 3.66e-06 1.09e-04 8.97e-05 + 5.200430 1.493844 1.117407 1.002177 3.04e-02 3.89e-01 6.43e-01 ---------------------------------------------------------------------------- Final Solver Statistics: - Slow steps = 42 (attempts = 44, fails = 2) - Intermediate steps = 684 (attempts = 837, fails = 153) - Fast steps = 142883 (attempts = 159706, fails = 16823) - u error = 0.000344385, v error = 0.000171906, total error = 0.000253474 - Relative accuracy = 6.8157 - Total RHS evals: Fse = 219, Fsi = 0, Fme = 4033, Fmi = 0, Ff = 781709 + Slow steps = 27 (attempts = 30, fails = 3) + Intermediate steps = 720 (attempts = 890, fails = 170) + Fast steps = 153065 (attempts = 170906, fails = 17841) + u error = 0.00584855, v error = 0.0749367, total error = 0.0835489 + Relative accuracy = 3906.73 + Total RHS evals: Fse = 148, Fsi = 0, Fme = 4281, Fmi = 0, Ff = 836691 diff --git a/examples/arkode/C_serial/ark_kpr_mri_1_0_0.01.out b/examples/arkode/C_serial/ark_kpr_mri_1_0_0.01.out index 2c625caeca..0c41ada159 100644 --- a/examples/arkode/C_serial/ark_kpr_mri_1_0_0.01.out +++ b/examples/arkode/C_serial/ark_kpr_mri_1_0_0.01.out @@ -66,4 +66,4 @@ Multirate nonlinear Kvaerno-Prothero-Robinson test problem: Final Solver Statistics: Steps: nsts = 501, nstf = 50601 u error = 5.052e-05, v error = 7.684e-04, total error = 5.445e-04 - Total RHS evals: Fs = 1504, Ff = 151853 + Total RHS evals: Fs = 1504, Ff = 253055 diff --git a/src/arkode/arkode.c b/src/arkode/arkode.c index 68005fd7c0..fdd4e59b9b 100644 --- a/src/arkode/arkode.c +++ b/src/arkode/arkode.c @@ -702,9 +702,6 @@ int ARKodeEvolve(void* arkode_mem, sunrealtype tout, N_Vector yout, ark_mem->root_mem->taskc = itask; } - /* store copy of tout, in case it is required for stepper initialization */ - ark_mem->tout = tout; - /* perform first-step-specific initializations: - initialize tret values to initialization time - perform initial integrator setup */ @@ -1923,7 +1920,7 @@ int arkInitialSetup(ARKodeMem ark_mem, sunrealtype tout) "Time stepper module is missing"); return (ARK_ILL_INPUT); } - retval = ark_mem->step_init(ark_mem, ark_mem->init_type); + retval = ark_mem->step_init(ark_mem, tout, ark_mem->init_type); if (retval != ARK_SUCCESS) { arkProcessError(ark_mem, retval, __LINE__, __func__, __FILE__, diff --git a/src/arkode/arkode_arkstep.c b/src/arkode/arkode_arkstep.c index dfd941c6e9..bae0f9fe8b 100644 --- a/src/arkode/arkode_arkstep.c +++ b/src/arkode/arkode_arkstep.c @@ -939,7 +939,7 @@ int arkStep_GetGammas(ARKodeMem ark_mem, sunrealtype* gamma, sunrealtype* gamrat With initialization type RESET_INIT, this routine does nothing. ---------------------------------------------------------------*/ -int arkStep_Init(ARKodeMem ark_mem, int init_type) +int arkStep_Init(ARKodeMem ark_mem, SUNDIALS_MAYBE_UNUSED sunrealtype tout, int init_type) { ARKodeARKStepMem step_mem; int j, retval; diff --git a/src/arkode/arkode_arkstep_impl.h b/src/arkode/arkode_arkstep_impl.h index 5b0e278184..1d5c15e4a3 100644 --- a/src/arkode/arkode_arkstep_impl.h +++ b/src/arkode/arkode_arkstep_impl.h @@ -181,7 +181,7 @@ int arkStep_AttachMasssol(ARKodeMem ark_mem, ARKMassInitFn minit, SUNLinearSolver_Type msolve_type, void* mass_mem); void arkStep_DisableLSetup(ARKodeMem ark_mem); void arkStep_DisableMSetup(ARKodeMem ark_mem); -int arkStep_Init(ARKodeMem ark_mem, int init_type); +int arkStep_Init(ARKodeMem ark_mem, sunrealtype tout, int init_type); void* arkStep_GetLmem(ARKodeMem ark_mem); void* arkStep_GetMassMem(ARKodeMem ark_mem); ARKRhsFn arkStep_GetImplicitRHS(ARKodeMem ark_mem); diff --git a/src/arkode/arkode_erkstep.c b/src/arkode/arkode_erkstep.c index 5d85477195..e1df315d24 100644 --- a/src/arkode/arkode_erkstep.c +++ b/src/arkode/arkode_erkstep.c @@ -394,7 +394,7 @@ void erkStep_PrintMem(ARKodeMem ark_mem, FILE* outfile) With other initialization types, this routine does nothing. ---------------------------------------------------------------*/ -int erkStep_Init(ARKodeMem ark_mem, int init_type) +int erkStep_Init(ARKodeMem ark_mem, SUNDIALS_MAYBE_UNUSED sunrealtype tout, int init_type) { ARKodeERKStepMem step_mem; sunbooleantype reset_efun; diff --git a/src/arkode/arkode_erkstep_impl.h b/src/arkode/arkode_erkstep_impl.h index 91af4cce30..c83b344b48 100644 --- a/src/arkode/arkode_erkstep_impl.h +++ b/src/arkode/arkode_erkstep_impl.h @@ -77,7 +77,7 @@ typedef struct ARKodeERKStepMemRec ===============================================================*/ /* Interface routines supplied to ARKODE */ -int erkStep_Init(ARKodeMem ark_mem, int init_type); +int erkStep_Init(ARKodeMem ark_mem, sunrealtype tout, int init_type); int erkStep_FullRHS(ARKodeMem ark_mem, sunrealtype t, N_Vector y, N_Vector f, int mode); int erkStep_TakeStep(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr); diff --git a/src/arkode/arkode_impl.h b/src/arkode/arkode_impl.h index 652fbb24c7..4e9e963c26 100644 --- a/src/arkode/arkode_impl.h +++ b/src/arkode/arkode_impl.h @@ -209,7 +209,7 @@ typedef int (*ARKMassSolveFn)(ARKodeMem ark_mem, N_Vector b, typedef int (*ARKMassFreeFn)(ARKodeMem ark_mem); /* time stepper interface functions -- general */ -typedef int (*ARKTimestepInitFn)(ARKodeMem ark_mem, int init_type); +typedef int (*ARKTimestepInitFn)(ARKodeMem ark_mem, sunrealtype tout, int init_type); typedef int (*ARKTimestepFullRHSFn)(ARKodeMem ark_mem, sunrealtype t, N_Vector y, N_Vector f, int mode); typedef int (*ARKTimestepStepFn)(ARKodeMem ark_mem, sunrealtype* dsm, int* nflag); @@ -505,7 +505,6 @@ struct ARKodeMemRec sunrealtype eta; /* eta = hprime / h */ sunrealtype tcur; /* current internal value of t (changes with each stage) */ - sunrealtype tout; /* user's requested output time */ sunrealtype tretlast; /* value of tret last returned by ARKODE */ sunbooleantype fixedstep; /* flag to disable temporal adaptivity */ ARKodeHAdaptMem hadapt_mem; /* time step adaptivity structure */ diff --git a/src/arkode/arkode_mristep.c b/src/arkode/arkode_mristep.c index 19a90d99d1..3e8cb61bb0 100644 --- a/src/arkode/arkode_mristep.c +++ b/src/arkode/arkode_mristep.c @@ -890,7 +890,7 @@ int mriStep_GetGammas(ARKodeMem ark_mem, sunrealtype* gamma, sunrealtype* gamrat With other initialization types, this routine does nothing. ---------------------------------------------------------------*/ -int mriStep_Init(ARKodeMem ark_mem, int init_type) +int mriStep_Init(ARKodeMem ark_mem, sunrealtype tout, int init_type) { ARKodeMRIStepMem step_mem; int retval, j; @@ -1288,7 +1288,7 @@ int mriStep_Init(ARKodeMem ark_mem, int init_type) "error calling slow RHS function(s)"); return (ARK_RHSFUNC_FAIL); } - retval = mriStep_Hin(ark_mem, ark_mem->tcur, ark_mem->tout, + retval = mriStep_Hin(ark_mem, ark_mem->tcur, tout, ark_mem->tempv1, &(ark_mem->hin)); if (retval != ARK_SUCCESS) { diff --git a/src/arkode/arkode_mristep_impl.h b/src/arkode/arkode_mristep_impl.h index 403efbc637..d39e53631e 100644 --- a/src/arkode/arkode_mristep_impl.h +++ b/src/arkode/arkode_mristep_impl.h @@ -213,7 +213,7 @@ int mriStep_AttachLinsol(ARKodeMem ark_mem, ARKLinsolInitFn linit, ARKLinsolFreeFn lfree, SUNLinearSolver_Type lsolve_type, void* lmem); void mriStep_DisableLSetup(ARKodeMem ark_mem); -int mriStep_Init(ARKodeMem ark_mem, int init_type); +int mriStep_Init(ARKodeMem ark_mem, sunrealtype tout, int init_type); void* mriStep_GetLmem(ARKodeMem ark_mem); ARKRhsFn mriStep_GetImplicitRHS(ARKodeMem ark_mem); int mriStep_GetGammas(ARKodeMem ark_mem, sunrealtype* gamma, sunrealtype* gamrat, diff --git a/src/arkode/arkode_sprkstep.c b/src/arkode/arkode_sprkstep.c index 6c3cf4a669..fb6addd653 100644 --- a/src/arkode/arkode_sprkstep.c +++ b/src/arkode/arkode_sprkstep.c @@ -362,7 +362,7 @@ void sprkStep_Free(ARKodeMem ark_mem) With initialization type RESET_INIT, this routine does nothing. ---------------------------------------------------------------*/ -int sprkStep_Init(ARKodeMem ark_mem, int init_type) +int sprkStep_Init(ARKodeMem ark_mem, SUNDIALS_MAYBE_UNUSED sunrealtype tout, int init_type) { ARKodeSPRKStepMem step_mem = NULL; int retval = 0; diff --git a/src/arkode/arkode_sprkstep_impl.h b/src/arkode/arkode_sprkstep_impl.h index d94f5c5c80..543adc5ef5 100644 --- a/src/arkode/arkode_sprkstep_impl.h +++ b/src/arkode/arkode_sprkstep_impl.h @@ -67,7 +67,7 @@ typedef struct ARKodeSPRKStepMemRec ===============================================================*/ /* Interface routines supplied to ARKODE */ -int sprkStep_Init(ARKodeMem ark_mem, int init_type); +int sprkStep_Init(ARKodeMem ark_mem, sunrealtype tout, int init_type); int sprkStep_FullRHS(ARKodeMem ark_mem, sunrealtype t, N_Vector y, N_Vector f, int mode); int sprkStep_TakeStep(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr); From 3ce03dcf0543d9aa7072ecfdfd26d45920503dfd Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Wed, 30 Oct 2024 11:33:47 -0500 Subject: [PATCH 204/286] Formatting --- src/arkode/arkode_arkstep.c | 3 ++- src/arkode/arkode_erkstep.c | 3 ++- src/arkode/arkode_impl.h | 3 ++- src/arkode/arkode_mristep.c | 4 ++-- src/arkode/arkode_sprkstep.c | 3 ++- 5 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/arkode/arkode_arkstep.c b/src/arkode/arkode_arkstep.c index bae0f9fe8b..c190edce5f 100644 --- a/src/arkode/arkode_arkstep.c +++ b/src/arkode/arkode_arkstep.c @@ -939,7 +939,8 @@ int arkStep_GetGammas(ARKodeMem ark_mem, sunrealtype* gamma, sunrealtype* gamrat With initialization type RESET_INIT, this routine does nothing. ---------------------------------------------------------------*/ -int arkStep_Init(ARKodeMem ark_mem, SUNDIALS_MAYBE_UNUSED sunrealtype tout, int init_type) +int arkStep_Init(ARKodeMem ark_mem, SUNDIALS_MAYBE_UNUSED sunrealtype tout, + int init_type) { ARKodeARKStepMem step_mem; int j, retval; diff --git a/src/arkode/arkode_erkstep.c b/src/arkode/arkode_erkstep.c index e1df315d24..f56dbf782c 100644 --- a/src/arkode/arkode_erkstep.c +++ b/src/arkode/arkode_erkstep.c @@ -394,7 +394,8 @@ void erkStep_PrintMem(ARKodeMem ark_mem, FILE* outfile) With other initialization types, this routine does nothing. ---------------------------------------------------------------*/ -int erkStep_Init(ARKodeMem ark_mem, SUNDIALS_MAYBE_UNUSED sunrealtype tout, int init_type) +int erkStep_Init(ARKodeMem ark_mem, SUNDIALS_MAYBE_UNUSED sunrealtype tout, + int init_type) { ARKodeERKStepMem step_mem; sunbooleantype reset_efun; diff --git a/src/arkode/arkode_impl.h b/src/arkode/arkode_impl.h index 4e9e963c26..c0fc6cee19 100644 --- a/src/arkode/arkode_impl.h +++ b/src/arkode/arkode_impl.h @@ -209,7 +209,8 @@ typedef int (*ARKMassSolveFn)(ARKodeMem ark_mem, N_Vector b, typedef int (*ARKMassFreeFn)(ARKodeMem ark_mem); /* time stepper interface functions -- general */ -typedef int (*ARKTimestepInitFn)(ARKodeMem ark_mem, sunrealtype tout, int init_type); +typedef int (*ARKTimestepInitFn)(ARKodeMem ark_mem, sunrealtype tout, + int init_type); typedef int (*ARKTimestepFullRHSFn)(ARKodeMem ark_mem, sunrealtype t, N_Vector y, N_Vector f, int mode); typedef int (*ARKTimestepStepFn)(ARKodeMem ark_mem, sunrealtype* dsm, int* nflag); diff --git a/src/arkode/arkode_mristep.c b/src/arkode/arkode_mristep.c index 3e8cb61bb0..45fcadd203 100644 --- a/src/arkode/arkode_mristep.c +++ b/src/arkode/arkode_mristep.c @@ -1288,8 +1288,8 @@ int mriStep_Init(ARKodeMem ark_mem, sunrealtype tout, int init_type) "error calling slow RHS function(s)"); return (ARK_RHSFUNC_FAIL); } - retval = mriStep_Hin(ark_mem, ark_mem->tcur, tout, - ark_mem->tempv1, &(ark_mem->hin)); + retval = mriStep_Hin(ark_mem, ark_mem->tcur, tout, ark_mem->tempv1, + &(ark_mem->hin)); if (retval != ARK_SUCCESS) { retval = arkHandleFailure(ark_mem, retval); diff --git a/src/arkode/arkode_sprkstep.c b/src/arkode/arkode_sprkstep.c index fb6addd653..4e4ff84465 100644 --- a/src/arkode/arkode_sprkstep.c +++ b/src/arkode/arkode_sprkstep.c @@ -362,7 +362,8 @@ void sprkStep_Free(ARKodeMem ark_mem) With initialization type RESET_INIT, this routine does nothing. ---------------------------------------------------------------*/ -int sprkStep_Init(ARKodeMem ark_mem, SUNDIALS_MAYBE_UNUSED sunrealtype tout, int init_type) +int sprkStep_Init(ARKodeMem ark_mem, SUNDIALS_MAYBE_UNUSED sunrealtype tout, + int init_type) { ARKodeSPRKStepMem step_mem = NULL; int retval = 0; From 3935f09891fed26666560d867eab4aef2f7fde1d Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Wed, 30 Oct 2024 12:00:36 -0500 Subject: [PATCH 205/286] Added additional return warning if temporal error accumulation is disabled --- doc/arkode/guide/source/Usage/User_callable.rst | 4 ++-- src/arkode/arkode_io.c | 14 +++++++++++--- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/doc/arkode/guide/source/Usage/User_callable.rst b/doc/arkode/guide/source/Usage/User_callable.rst index e07b08d4e5..7ab5e90030 100644 --- a/doc/arkode/guide/source/Usage/User_callable.rst +++ b/doc/arkode/guide/source/Usage/User_callable.rst @@ -3699,9 +3699,9 @@ Retrieve the accumulated temporal error estimate :c:func:`ARKodeGetAccumul :retval ARK_SUCCESS: the function exited successfully. :retval ARK_MEM_NULL: ``arkode_mem`` was ``NULL``. + :retval ARK_WARNING: accumulated error estimation is currently disabled. :retval ARK_STEPPER_UNSUPPORTED: temporal error estimation is not supported - by the current time-stepping module, or accumulated - error estimation is currently disabled in the stepper. + by the current time-stepping module. .. versionadded:: x.y.z diff --git a/src/arkode/arkode_io.c b/src/arkode/arkode_io.c index d22ff863a4..48e3379e81 100644 --- a/src/arkode/arkode_io.c +++ b/src/arkode/arkode_io.c @@ -2445,6 +2445,14 @@ int ARKodeGetAccumulatedError(void* arkode_mem, sunrealtype* accum_error) } ark_mem = (ARKodeMem)arkode_mem; + /* Return an error if the stepper cannot accumulate temporal error */ + if (!ark_mem->step_supports_adaptive) + { + arkProcessError(ark_mem, ARK_STEPPER_UNSUPPORTED, __LINE__, __func__, + __FILE__, "time-stepping module does not support accumulated error estimation"); + return (ARK_STEPPER_UNSUPPORTED); + } + /* Get number of steps since last accumulated error reset (set floor of 1 to safeguard against division-by-zero) */ sunrealtype time_interval = ark_mem->tcur - ark_mem->AccumErrorStart; @@ -2464,9 +2472,9 @@ int ARKodeGetAccumulatedError(void* arkode_mem, sunrealtype* accum_error) } else { - arkProcessError(ark_mem, ARK_STEPPER_UNSUPPORTED, __LINE__, __func__, - __FILE__, "time-stepping module does not support accumulated error estimation"); - return (ARK_STEPPER_UNSUPPORTED); + arkProcessError(ark_mem, ARK_WARNING, __LINE__, __func__, + __FILE__, "temporal error accumulation is currently disabled"); + return (ARK_WARNING); } return (ARK_SUCCESS); From ca0efd7c18b795648ce9986ea7f453e7754ed885 Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Wed, 30 Oct 2024 13:02:59 -0500 Subject: [PATCH 206/286] Updated checks on MRI coupling tables (as per PR request). --- src/arkode/arkode_mri_tables.c | 4 ++-- src/arkode/arkode_mristep.c | 39 +++++++++++++++++++++++++++++----- 2 files changed, 36 insertions(+), 7 deletions(-) diff --git a/src/arkode/arkode_mri_tables.c b/src/arkode/arkode_mri_tables.c index ecae4773f3..1fe04f672b 100644 --- a/src/arkode/arkode_mri_tables.c +++ b/src/arkode/arkode_mri_tables.c @@ -774,7 +774,7 @@ int mriStepCoupling_GetStageType(MRIStepCoupling MRIC, int is) sunbooleantype Gdiag, Grow, Wrow, cdiff; const sunrealtype tol = SUN_RCONST(100.0) * SUN_UNIT_ROUNDOFF; - if ((is < 1) || (is > MRIC->stages)) { return ARK_INVALID_TABLE; } + if ((is < 0) || (is > MRIC->stages)) { return ARK_INVALID_TABLE; } /* report MRISTAGE_ERK_FAST for MERK and MRI-SR methods */ if ((MRIC->type == MRISTEP_MRISR) || (MRIC->type == MRISTEP_MERK)) @@ -839,7 +839,7 @@ int mriStepCoupling_GetStageType(MRIStepCoupling MRIC, int is) } /* make determination */ - if (!(Gdiag || Grow || Wrow || cdiff)) + if (!(Gdiag || Grow || Wrow || cdiff) && (is > 0)) { /* stiffly-accurate stage */ return (MRISTAGE_STIFF_ACC); } diff --git a/src/arkode/arkode_mristep.c b/src/arkode/arkode_mristep.c index 45fcadd203..671d0aef2c 100644 --- a/src/arkode/arkode_mristep.c +++ b/src/arkode/arkode_mristep.c @@ -1013,9 +1013,7 @@ int mriStep_Init(ARKodeMem ark_mem, sunrealtype tout, int init_type) return (ARK_MEM_FAIL); } ark_mem->liw += (step_mem->MRIC->stages + 1); - step_mem->stagetypes[0] = - MRISTAGE_ERK_NOFAST; /* 1st stage is always ERK_NOFAST */ - for (j = 1; j <= step_mem->MRIC->stages; j++) + for (j = 0; j <= step_mem->MRIC->stages; j++) { step_mem->stagetypes[j] = mriStepCoupling_GetStageType(step_mem->MRIC, j); } @@ -3141,7 +3139,7 @@ int mriStep_CheckCoupling(ARKodeMem ark_mem) } /* Check that the matrices are defined appropriately */ - if (step_mem->MRIC->type == MRISTEP_IMEX) + if ((step_mem->MRIC->type == MRISTEP_IMEX) || (step_mem->MRIC->type == MRISTEP_MRISR)) { /* ImEx */ if (!(step_mem->MRIC->W) || !(step_mem->MRIC->G)) @@ -3151,7 +3149,7 @@ int mriStep_CheckCoupling(ARKodeMem ark_mem) return (ARK_ILL_INPUT); } } - else if (step_mem->MRIC->type == MRISTEP_EXPLICIT) + else if ((step_mem->MRIC->type == MRISTEP_EXPLICIT) || (step_mem->MRIC->type == MRISTEP_MERK)) { /* Explicit */ if (!(step_mem->MRIC->W) || step_mem->MRIC->G) @@ -3216,6 +3214,37 @@ int mriStep_CheckCoupling(ARKodeMem ark_mem) } } + /* Check that MERK "groups" are structured appropriately */ + if (step_mem->MRIC->type == MRISTEP_MERK) + { + int* group_counter = (int*)calloc(step_mem->MRIC->stages + 1, sizeof(int)); + for (i = 0; i < step_mem->MRIC->ngroup; i++) + { + for (j = 0; j < step_mem->MRIC->stages; j++) + { + k = step_mem->MRIC->group[i][j]; + if (k == -1) { break; } + if ((k < 0) || (k > step_mem->MRIC->stages)) + { + arkProcessError(ark_mem, ARK_INVALID_TABLE, __LINE__, __func__, __FILE__, + "Invalid MERK group index!"); + return (ARK_INVALID_TABLE); + } + group_counter[k]++; + } + } + for (i = 1; i <= step_mem->MRIC->stages; i++) + { + if ((group_counter[i] == 0) || (group_counter[i] > 1)) + { + arkProcessError(ark_mem, ARK_INVALID_TABLE, __LINE__, __func__, __FILE__, + "Duplicated/missing stages from MERK groups!"); + return (ARK_INVALID_TABLE); + } + } + free(group_counter); + } + /* Check that no stage has MRISTAGE_DIRK_FAST type (for now) */ okay = SUNTRUE; for (i = 0; i < step_mem->MRIC->stages; i++) From b727b0354b3fe16478aef6541944af3ce0710ea3 Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Wed, 30 Oct 2024 13:03:37 -0500 Subject: [PATCH 207/286] formatting --- src/arkode/arkode_io.c | 4 ++-- src/arkode/arkode_mristep.c | 16 +++++++++------- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/src/arkode/arkode_io.c b/src/arkode/arkode_io.c index 48e3379e81..15a71450e0 100644 --- a/src/arkode/arkode_io.c +++ b/src/arkode/arkode_io.c @@ -2472,8 +2472,8 @@ int ARKodeGetAccumulatedError(void* arkode_mem, sunrealtype* accum_error) } else { - arkProcessError(ark_mem, ARK_WARNING, __LINE__, __func__, - __FILE__, "temporal error accumulation is currently disabled"); + arkProcessError(ark_mem, ARK_WARNING, __LINE__, __func__, __FILE__, + "temporal error accumulation is currently disabled"); return (ARK_WARNING); } diff --git a/src/arkode/arkode_mristep.c b/src/arkode/arkode_mristep.c index 671d0aef2c..a8bc700f4b 100644 --- a/src/arkode/arkode_mristep.c +++ b/src/arkode/arkode_mristep.c @@ -3139,7 +3139,8 @@ int mriStep_CheckCoupling(ARKodeMem ark_mem) } /* Check that the matrices are defined appropriately */ - if ((step_mem->MRIC->type == MRISTEP_IMEX) || (step_mem->MRIC->type == MRISTEP_MRISR)) + if ((step_mem->MRIC->type == MRISTEP_IMEX) || + (step_mem->MRIC->type == MRISTEP_MRISR)) { /* ImEx */ if (!(step_mem->MRIC->W) || !(step_mem->MRIC->G)) @@ -3149,7 +3150,8 @@ int mriStep_CheckCoupling(ARKodeMem ark_mem) return (ARK_ILL_INPUT); } } - else if ((step_mem->MRIC->type == MRISTEP_EXPLICIT) || (step_mem->MRIC->type == MRISTEP_MERK)) + else if ((step_mem->MRIC->type == MRISTEP_EXPLICIT) || + (step_mem->MRIC->type == MRISTEP_MERK)) { /* Explicit */ if (!(step_mem->MRIC->W) || step_mem->MRIC->G) @@ -3226,8 +3228,8 @@ int mriStep_CheckCoupling(ARKodeMem ark_mem) if (k == -1) { break; } if ((k < 0) || (k > step_mem->MRIC->stages)) { - arkProcessError(ark_mem, ARK_INVALID_TABLE, __LINE__, __func__, __FILE__, - "Invalid MERK group index!"); + arkProcessError(ark_mem, ARK_INVALID_TABLE, __LINE__, __func__, + __FILE__, "Invalid MERK group index!"); return (ARK_INVALID_TABLE); } group_counter[k]++; @@ -3237,9 +3239,9 @@ int mriStep_CheckCoupling(ARKodeMem ark_mem) { if ((group_counter[i] == 0) || (group_counter[i] > 1)) { - arkProcessError(ark_mem, ARK_INVALID_TABLE, __LINE__, __func__, __FILE__, - "Duplicated/missing stages from MERK groups!"); - return (ARK_INVALID_TABLE); + arkProcessError(ark_mem, ARK_INVALID_TABLE, __LINE__, __func__, + __FILE__, "Duplicated/missing stages from MERK groups!"); + return (ARK_INVALID_TABLE); } } free(group_counter); From 00ab53a4b7eea5fe0782a6ff5ad28e1f55ea969a Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Wed, 30 Oct 2024 13:03:59 -0500 Subject: [PATCH 208/286] Updated some .out files to reflect changes arising from PR revisions --- ...ark_test_accumerror_brusselator_20_3_1.out | 120 +++++++++--------- .../ark_test_accumerror_kpr_20_2_0.out | 120 +++++++++--------- .../ark_test_accumerror_kpr_20_3_1.out | 120 +++++++++--------- ..._mriadapt_--rtol_0.000004_--scontrol_0.out | 37 +++--- ...-hs_0.002_--rtol_0.000004_--scontrol_0.out | 39 +++--- 5 files changed, 217 insertions(+), 219 deletions(-) diff --git a/test/unit_tests/arkode/CXX_serial/ark_test_accumerror_brusselator_20_3_1.out b/test/unit_tests/arkode/CXX_serial/ark_test_accumerror_brusselator_20_3_1.out index ab7079a647..8e2a11d1e1 100644 --- a/test/unit_tests/arkode/CXX_serial/ark_test_accumerror_brusselator_20_3_1.out +++ b/test/unit_tests/arkode/CXX_serial/ark_test_accumerror_brusselator_20_3_1.out @@ -47,26 +47,26 @@ Adaptive-step runs: rtol 0.01 rk_type 1 order 3 acc 2 t 9 dsm 0.00530688 dsm_est 1.94856 nsteps 460 rtol 0.01 rk_type 1 order 3 acc 2 t 9.5 dsm 0.00453492 dsm_est 1.91705 nsteps 461 rtol 0.01 rk_type 1 order 3 acc 2 t 10 dsm 0.000530102 dsm_est 1.91042 nsteps 461 - rtol 0.01 rk_type 1 order 3 acc 3 t 0.5 dsm 0.00199866 dsm_est 0.00426439 nsteps 492 - rtol 0.01 rk_type 1 order 3 acc 3 t 1 dsm 0.00148824 dsm_est 0.00401684 nsteps 473 - rtol 0.01 rk_type 1 order 3 acc 3 t 1.5 dsm 0.00330184 dsm_est 0.00429906 nsteps 459 - rtol 0.01 rk_type 1 order 3 acc 3 t 2 dsm 0.000346469 dsm_est 0.00422221 nsteps 450 - rtol 0.01 rk_type 1 order 3 acc 3 t 2.5 dsm 0.0103541 dsm_est 0.0039254 nsteps 430 - rtol 0.01 rk_type 1 order 3 acc 3 t 3 dsm 0.0108871 dsm_est 0.00418766 nsteps 447 - rtol 0.01 rk_type 1 order 3 acc 3 t 3.5 dsm 0.00245302 dsm_est 0.00418645 nsteps 465 - rtol 0.01 rk_type 1 order 3 acc 3 t 4 dsm 0.00613073 dsm_est 0.00418211 nsteps 464 - rtol 0.01 rk_type 1 order 3 acc 3 t 4.5 dsm 0.00368671 dsm_est 0.00418783 nsteps 464 - rtol 0.01 rk_type 1 order 3 acc 3 t 5 dsm 0.000382639 dsm_est 0.00393723 nsteps 466 - rtol 0.01 rk_type 1 order 3 acc 3 t 5.5 dsm 0.00138001 dsm_est 0.00421341 nsteps 443 - rtol 0.01 rk_type 1 order 3 acc 3 t 6 dsm 0.00204504 dsm_est 0.00419418 nsteps 463 - rtol 0.01 rk_type 1 order 3 acc 3 t 6.5 dsm 0.00544154 dsm_est 0.00421996 nsteps 465 - rtol 0.01 rk_type 1 order 3 acc 3 t 7 dsm 0.00167909 dsm_est 0.00415345 nsteps 459 - rtol 0.01 rk_type 1 order 3 acc 3 t 7.5 dsm 0.00762228 dsm_est 0.00386309 nsteps 464 - rtol 0.01 rk_type 1 order 3 acc 3 t 8 dsm 0.00815849 dsm_est 0.0039821 nsteps 463 - rtol 0.01 rk_type 1 order 3 acc 3 t 8.5 dsm 0.00479833 dsm_est 0.00427435 nsteps 463 - rtol 0.01 rk_type 1 order 3 acc 3 t 9 dsm 0.00530688 dsm_est 0.004236 nsteps 460 - rtol 0.01 rk_type 1 order 3 acc 3 t 9.5 dsm 0.00453492 dsm_est 0.00415846 nsteps 461 - rtol 0.01 rk_type 1 order 3 acc 3 t 10 dsm 0.000530102 dsm_est 0.00414409 nsteps 461 + rtol 0.01 rk_type 1 order 3 acc 3 t 0.5 dsm 0.00199866 dsm_est 0.00443873 nsteps 492 + rtol 0.01 rk_type 1 order 3 acc 3 t 1 dsm 0.00148824 dsm_est 0.00401521 nsteps 473 + rtol 0.01 rk_type 1 order 3 acc 3 t 1.5 dsm 0.00330184 dsm_est 0.00441678 nsteps 459 + rtol 0.01 rk_type 1 order 3 acc 3 t 2 dsm 0.000346469 dsm_est 0.00425191 nsteps 450 + rtol 0.01 rk_type 1 order 3 acc 3 t 2.5 dsm 0.0103541 dsm_est 0.00381705 nsteps 430 + rtol 0.01 rk_type 1 order 3 acc 3 t 3 dsm 0.0108871 dsm_est 0.0041182 nsteps 447 + rtol 0.01 rk_type 1 order 3 acc 3 t 3.5 dsm 0.00245302 dsm_est 0.00412426 nsteps 465 + rtol 0.01 rk_type 1 order 3 acc 3 t 4 dsm 0.00613073 dsm_est 0.00411939 nsteps 464 + rtol 0.01 rk_type 1 order 3 acc 3 t 4.5 dsm 0.00368671 dsm_est 0.00412003 nsteps 464 + rtol 0.01 rk_type 1 order 3 acc 3 t 5 dsm 0.000382639 dsm_est 0.00388215 nsteps 466 + rtol 0.01 rk_type 1 order 3 acc 3 t 5.5 dsm 0.00138001 dsm_est 0.00418117 nsteps 443 + rtol 0.01 rk_type 1 order 3 acc 3 t 6 dsm 0.00204504 dsm_est 0.00411411 nsteps 463 + rtol 0.01 rk_type 1 order 3 acc 3 t 6.5 dsm 0.00544154 dsm_est 0.00415099 nsteps 465 + rtol 0.01 rk_type 1 order 3 acc 3 t 7 dsm 0.00167909 dsm_est 0.00420804 nsteps 459 + rtol 0.01 rk_type 1 order 3 acc 3 t 7.5 dsm 0.00762228 dsm_est 0.00381522 nsteps 464 + rtol 0.01 rk_type 1 order 3 acc 3 t 8 dsm 0.00815849 dsm_est 0.00390452 nsteps 463 + rtol 0.01 rk_type 1 order 3 acc 3 t 8.5 dsm 0.00479833 dsm_est 0.0042077 nsteps 463 + rtol 0.01 rk_type 1 order 3 acc 3 t 9 dsm 0.00530688 dsm_est 0.00413179 nsteps 460 + rtol 0.01 rk_type 1 order 3 acc 3 t 9.5 dsm 0.00453492 dsm_est 0.00406231 nsteps 461 + rtol 0.01 rk_type 1 order 3 acc 3 t 10 dsm 0.000530102 dsm_est 0.00404373 nsteps 461 rtol 0.0001 rk_type 1 order 3 acc 1 t 0.5 dsm 4.52215e-05 dsm_est 9.69104e-05 nsteps 501 rtol 0.0001 rk_type 1 order 3 acc 1 t 1 dsm 1.81631e-05 dsm_est 9.49781e-05 nsteps 474 rtol 0.0001 rk_type 1 order 3 acc 1 t 1.5 dsm 2.77186e-05 dsm_est 9.49662e-05 nsteps 474 @@ -107,26 +107,26 @@ Adaptive-step runs: rtol 0.0001 rk_type 1 order 3 acc 2 t 9 dsm 9.3894e-06 dsm_est 0.0195109 nsteps 475 rtol 0.0001 rk_type 1 order 3 acc 2 t 9.5 dsm 1.95141e-05 dsm_est 0.0192328 nsteps 482 rtol 0.0001 rk_type 1 order 3 acc 2 t 10 dsm 2.83938e-05 dsm_est 0.0195692 nsteps 479 - rtol 0.0001 rk_type 1 order 3 acc 3 t 0.5 dsm 4.52215e-05 dsm_est 4.08107e-05 nsteps 501 - rtol 0.0001 rk_type 1 order 3 acc 3 t 1 dsm 1.81631e-05 dsm_est 4.12007e-05 nsteps 474 - rtol 0.0001 rk_type 1 order 3 acc 3 t 1.5 dsm 2.77186e-05 dsm_est 3.92848e-05 nsteps 474 - rtol 0.0001 rk_type 1 order 3 acc 3 t 2 dsm 1.52803e-05 dsm_est 4.11758e-05 nsteps 470 - rtol 0.0001 rk_type 1 order 3 acc 3 t 2.5 dsm 4.78098e-05 dsm_est 4.06774e-05 nsteps 464 - rtol 0.0001 rk_type 1 order 3 acc 3 t 3 dsm 2.25476e-05 dsm_est 4.05186e-05 nsteps 465 - rtol 0.0001 rk_type 1 order 3 acc 3 t 3.5 dsm 5.07755e-05 dsm_est 3.94363e-05 nsteps 474 - rtol 0.0001 rk_type 1 order 3 acc 3 t 4 dsm 2.29469e-05 dsm_est 4.0612e-05 nsteps 474 - rtol 0.0001 rk_type 1 order 3 acc 3 t 4.5 dsm 3.88359e-05 dsm_est 4.04377e-05 nsteps 470 - rtol 0.0001 rk_type 1 order 3 acc 3 t 5 dsm 1.51443e-05 dsm_est 4.10883e-05 nsteps 469 - rtol 0.0001 rk_type 1 order 3 acc 3 t 5.5 dsm 1.12906e-05 dsm_est 4.03674e-05 nsteps 470 - rtol 0.0001 rk_type 1 order 3 acc 3 t 6 dsm 2.05734e-05 dsm_est 3.92226e-05 nsteps 474 - rtol 0.0001 rk_type 1 order 3 acc 3 t 6.5 dsm 2.51686e-05 dsm_est 4.05458e-05 nsteps 481 - rtol 0.0001 rk_type 1 order 3 acc 3 t 7 dsm 6.45125e-05 dsm_est 4.1002e-05 nsteps 481 - rtol 0.0001 rk_type 1 order 3 acc 3 t 7.5 dsm 6.30239e-05 dsm_est 3.79447e-05 nsteps 475 - rtol 0.0001 rk_type 1 order 3 acc 3 t 8 dsm 2.85855e-05 dsm_est 4.09141e-05 nsteps 478 - rtol 0.0001 rk_type 1 order 3 acc 3 t 8.5 dsm 4.15619e-05 dsm_est 4.07839e-05 nsteps 480 - rtol 0.0001 rk_type 1 order 3 acc 3 t 9 dsm 9.3894e-06 dsm_est 4.10757e-05 nsteps 475 - rtol 0.0001 rk_type 1 order 3 acc 3 t 9.5 dsm 1.95141e-05 dsm_est 3.99021e-05 nsteps 482 - rtol 0.0001 rk_type 1 order 3 acc 3 t 10 dsm 2.83938e-05 dsm_est 4.08542e-05 nsteps 479 + rtol 0.0001 rk_type 1 order 3 acc 3 t 0.5 dsm 4.52215e-05 dsm_est 4.27945e-05 nsteps 501 + rtol 0.0001 rk_type 1 order 3 acc 3 t 1 dsm 1.81631e-05 dsm_est 4.18953e-05 nsteps 474 + rtol 0.0001 rk_type 1 order 3 acc 3 t 1.5 dsm 2.77186e-05 dsm_est 4.01946e-05 nsteps 474 + rtol 0.0001 rk_type 1 order 3 acc 3 t 2 dsm 1.52803e-05 dsm_est 4.11232e-05 nsteps 470 + rtol 0.0001 rk_type 1 order 3 acc 3 t 2.5 dsm 4.78098e-05 dsm_est 4.02797e-05 nsteps 464 + rtol 0.0001 rk_type 1 order 3 acc 3 t 3 dsm 2.25476e-05 dsm_est 4.21717e-05 nsteps 465 + rtol 0.0001 rk_type 1 order 3 acc 3 t 3.5 dsm 5.07755e-05 dsm_est 4.02733e-05 nsteps 474 + rtol 0.0001 rk_type 1 order 3 acc 3 t 4 dsm 2.29469e-05 dsm_est 4.06438e-05 nsteps 474 + rtol 0.0001 rk_type 1 order 3 acc 3 t 4.5 dsm 3.88359e-05 dsm_est 4.00905e-05 nsteps 470 + rtol 0.0001 rk_type 1 order 3 acc 3 t 5 dsm 1.51443e-05 dsm_est 4.10729e-05 nsteps 469 + rtol 0.0001 rk_type 1 order 3 acc 3 t 5.5 dsm 1.12906e-05 dsm_est 4.00276e-05 nsteps 470 + rtol 0.0001 rk_type 1 order 3 acc 3 t 6 dsm 2.05734e-05 dsm_est 4.01607e-05 nsteps 474 + rtol 0.0001 rk_type 1 order 3 acc 3 t 6.5 dsm 2.51686e-05 dsm_est 4.12268e-05 nsteps 481 + rtol 0.0001 rk_type 1 order 3 acc 3 t 7 dsm 6.45125e-05 dsm_est 4.17595e-05 nsteps 481 + rtol 0.0001 rk_type 1 order 3 acc 3 t 7.5 dsm 6.30239e-05 dsm_est 3.85507e-05 nsteps 475 + rtol 0.0001 rk_type 1 order 3 acc 3 t 8 dsm 2.85855e-05 dsm_est 4.15334e-05 nsteps 478 + rtol 0.0001 rk_type 1 order 3 acc 3 t 8.5 dsm 4.15619e-05 dsm_est 4.13654e-05 nsteps 480 + rtol 0.0001 rk_type 1 order 3 acc 3 t 9 dsm 9.3894e-06 dsm_est 4.17504e-05 nsteps 475 + rtol 0.0001 rk_type 1 order 3 acc 3 t 9.5 dsm 1.95141e-05 dsm_est 4.05915e-05 nsteps 482 + rtol 0.0001 rk_type 1 order 3 acc 3 t 10 dsm 2.83938e-05 dsm_est 4.15708e-05 nsteps 479 rtol 1e-06 rk_type 1 order 3 acc 1 t 0.5 dsm 6.49367e-08 dsm_est 9.89086e-07 nsteps 550 rtol 1e-06 rk_type 1 order 3 acc 1 t 1 dsm 5.83524e-07 dsm_est 9.4678e-07 nsteps 488 rtol 1e-06 rk_type 1 order 3 acc 1 t 1.5 dsm 2.01442e-08 dsm_est 9.47358e-07 nsteps 491 @@ -167,23 +167,23 @@ Adaptive-step runs: rtol 1e-06 rk_type 1 order 3 acc 2 t 9 dsm 2.03978e-07 dsm_est 0.000189873 nsteps 468 rtol 1e-06 rk_type 1 order 3 acc 2 t 9.5 dsm 2.77163e-07 dsm_est 0.000192779 nsteps 475 rtol 1e-06 rk_type 1 order 3 acc 2 t 10 dsm 4.2482e-07 dsm_est 0.000186705 nsteps 476 - rtol 1e-06 rk_type 1 order 3 acc 3 t 0.5 dsm 6.49367e-08 dsm_est 3.45481e-07 nsteps 550 - rtol 1e-06 rk_type 1 order 3 acc 3 t 1 dsm 5.83524e-07 dsm_est 3.92843e-07 nsteps 488 - rtol 1e-06 rk_type 1 order 3 acc 3 t 1.5 dsm 2.01442e-08 dsm_est 3.15167e-07 nsteps 491 - rtol 1e-06 rk_type 1 order 3 acc 3 t 2 dsm 6.89174e-08 dsm_est 3.94168e-07 nsteps 485 - rtol 1e-06 rk_type 1 order 3 acc 3 t 2.5 dsm 3.25214e-07 dsm_est 4.0852e-07 nsteps 463 - rtol 1e-06 rk_type 1 order 3 acc 3 t 3 dsm 3.48745e-07 dsm_est 4.02669e-07 nsteps 481 - rtol 1e-06 rk_type 1 order 3 acc 3 t 3.5 dsm 1.27971e-06 dsm_est 4.10995e-07 nsteps 484 - rtol 1e-06 rk_type 1 order 3 acc 3 t 4 dsm 5.22124e-07 dsm_est 4.06335e-07 nsteps 485 - rtol 1e-06 rk_type 1 order 3 acc 3 t 4.5 dsm 6.25795e-07 dsm_est 3.93901e-07 nsteps 486 - rtol 1e-06 rk_type 1 order 3 acc 3 t 5 dsm 5.82624e-07 dsm_est 4.02844e-07 nsteps 487 - rtol 1e-06 rk_type 1 order 3 acc 3 t 5.5 dsm 5.29296e-07 dsm_est 4.12265e-07 nsteps 483 - rtol 1e-06 rk_type 1 order 3 acc 3 t 6 dsm 3.47222e-07 dsm_est 4.13091e-07 nsteps 484 - rtol 1e-06 rk_type 1 order 3 acc 3 t 6.5 dsm 8.05504e-07 dsm_est 4.05024e-07 nsteps 477 - rtol 1e-06 rk_type 1 order 3 acc 3 t 7 dsm 4.05624e-08 dsm_est 4.06655e-07 nsteps 487 - rtol 1e-06 rk_type 1 order 3 acc 3 t 7.5 dsm 7.28832e-08 dsm_est 4.09645e-07 nsteps 487 - rtol 1e-06 rk_type 1 order 3 acc 3 t 8 dsm 9.01356e-07 dsm_est 4.07695e-07 nsteps 485 - rtol 1e-06 rk_type 1 order 3 acc 3 t 8.5 dsm 9.82212e-07 dsm_est 3.86761e-07 nsteps 489 - rtol 1e-06 rk_type 1 order 3 acc 3 t 9 dsm 2.03978e-07 dsm_est 4.05711e-07 nsteps 468 - rtol 1e-06 rk_type 1 order 3 acc 3 t 9.5 dsm 2.77163e-07 dsm_est 4.05851e-07 nsteps 475 - rtol 1e-06 rk_type 1 order 3 acc 3 t 10 dsm 4.2482e-07 dsm_est 3.92237e-07 nsteps 476 + rtol 1e-06 rk_type 1 order 3 acc 3 t 0.5 dsm 6.49367e-08 dsm_est 3.76189e-07 nsteps 550 + rtol 1e-06 rk_type 1 order 3 acc 3 t 1 dsm 5.83524e-07 dsm_est 4.03986e-07 nsteps 488 + rtol 1e-06 rk_type 1 order 3 acc 3 t 1.5 dsm 2.01442e-08 dsm_est 3.17531e-07 nsteps 491 + rtol 1e-06 rk_type 1 order 3 acc 3 t 2 dsm 6.89174e-08 dsm_est 4.03334e-07 nsteps 485 + rtol 1e-06 rk_type 1 order 3 acc 3 t 2.5 dsm 3.25214e-07 dsm_est 4.26069e-07 nsteps 463 + rtol 1e-06 rk_type 1 order 3 acc 3 t 3 dsm 3.48745e-07 dsm_est 4.13425e-07 nsteps 481 + rtol 1e-06 rk_type 1 order 3 acc 3 t 3.5 dsm 1.27971e-06 dsm_est 4.2656e-07 nsteps 484 + rtol 1e-06 rk_type 1 order 3 acc 3 t 4 dsm 5.22124e-07 dsm_est 4.19481e-07 nsteps 485 + rtol 1e-06 rk_type 1 order 3 acc 3 t 4.5 dsm 6.25795e-07 dsm_est 4.03617e-07 nsteps 486 + rtol 1e-06 rk_type 1 order 3 acc 3 t 5 dsm 5.82624e-07 dsm_est 4.13815e-07 nsteps 487 + rtol 1e-06 rk_type 1 order 3 acc 3 t 5.5 dsm 5.29296e-07 dsm_est 4.27331e-07 nsteps 483 + rtol 1e-06 rk_type 1 order 3 acc 3 t 6 dsm 3.47222e-07 dsm_est 4.28557e-07 nsteps 484 + rtol 1e-06 rk_type 1 order 3 acc 3 t 6.5 dsm 8.05504e-07 dsm_est 4.16753e-07 nsteps 477 + rtol 1e-06 rk_type 1 order 3 acc 3 t 7 dsm 4.05624e-08 dsm_est 4.18718e-07 nsteps 487 + rtol 1e-06 rk_type 1 order 3 acc 3 t 7.5 dsm 7.28832e-08 dsm_est 4.22063e-07 nsteps 487 + rtol 1e-06 rk_type 1 order 3 acc 3 t 8 dsm 9.01356e-07 dsm_est 4.22563e-07 nsteps 485 + rtol 1e-06 rk_type 1 order 3 acc 3 t 8.5 dsm 9.82212e-07 dsm_est 3.97686e-07 nsteps 489 + rtol 1e-06 rk_type 1 order 3 acc 3 t 9 dsm 2.03978e-07 dsm_est 4.06169e-07 nsteps 468 + rtol 1e-06 rk_type 1 order 3 acc 3 t 9.5 dsm 2.77163e-07 dsm_est 4.12601e-07 nsteps 475 + rtol 1e-06 rk_type 1 order 3 acc 3 t 10 dsm 4.2482e-07 dsm_est 3.9924e-07 nsteps 476 diff --git a/test/unit_tests/arkode/CXX_serial/ark_test_accumerror_kpr_20_2_0.out b/test/unit_tests/arkode/CXX_serial/ark_test_accumerror_kpr_20_2_0.out index 766322cfac..8809b5e0a0 100644 --- a/test/unit_tests/arkode/CXX_serial/ark_test_accumerror_kpr_20_2_0.out +++ b/test/unit_tests/arkode/CXX_serial/ark_test_accumerror_kpr_20_2_0.out @@ -48,26 +48,26 @@ Adaptive-step runs: rtol 0.01 rk_type 0 order 2 acc 2 t 4.5 dsm 0.000322019 dsm_est 0.0262973 nsteps 11 rtol 0.01 rk_type 0 order 2 acc 2 t 4.75 dsm 0.00405487 dsm_est 0.00626689 nsteps 7 rtol 0.01 rk_type 0 order 2 acc 2 t 5 dsm 0.000699178 dsm_est 0.0128716 nsteps 8 - rtol 0.01 rk_type 0 order 2 acc 3 t 0.25 dsm 5.77245e-05 dsm_est 0.00183312 nsteps 9 - rtol 0.01 rk_type 0 order 2 acc 3 t 0.5 dsm 0.00372257 dsm_est 0.0026276 nsteps 8 - rtol 0.01 rk_type 0 order 2 acc 3 t 0.75 dsm 0.000232425 dsm_est 0.00237463 nsteps 13 - rtol 0.01 rk_type 0 order 2 acc 3 t 1 dsm 0.00327055 dsm_est 0.00377797 nsteps 9 - rtol 0.01 rk_type 0 order 2 acc 3 t 1.25 dsm 0.00363058 dsm_est 0.00286963 nsteps 16 - rtol 0.01 rk_type 0 order 2 acc 3 t 1.5 dsm 0.00267076 dsm_est 0.00422946 nsteps 12 - rtol 0.01 rk_type 0 order 2 acc 3 t 1.75 dsm 0.00971976 dsm_est 0.00351813 nsteps 16 - rtol 0.01 rk_type 0 order 2 acc 3 t 2 dsm 0.000918207 dsm_est 0.00268129 nsteps 14 - rtol 0.01 rk_type 0 order 2 acc 3 t 2.25 dsm 0.0016944 dsm_est 0.0031166 nsteps 10 - rtol 0.01 rk_type 0 order 2 acc 3 t 2.5 dsm 0.0056199 dsm_est 0.00138151 nsteps 7 - rtol 0.01 rk_type 0 order 2 acc 3 t 2.75 dsm 0.00855479 dsm_est 0.00234303 nsteps 6 - rtol 0.01 rk_type 0 order 2 acc 3 t 3 dsm 0.0023308 dsm_est 0.00207814 nsteps 7 - rtol 0.01 rk_type 0 order 2 acc 3 t 3.25 dsm 0.000539467 dsm_est 0.00139745 nsteps 8 - rtol 0.01 rk_type 0 order 2 acc 3 t 3.5 dsm 0.000312605 dsm_est 0.00128426 nsteps 6 - rtol 0.01 rk_type 0 order 2 acc 3 t 3.75 dsm 0.00144605 dsm_est 0.00243161 nsteps 4 - rtol 0.01 rk_type 0 order 2 acc 3 t 4 dsm 0.00023147 dsm_est 0.00140273 nsteps 7 - rtol 0.01 rk_type 0 order 2 acc 3 t 4.25 dsm 0.00806953 dsm_est 0.00295759 nsteps 4 - rtol 0.01 rk_type 0 order 2 acc 3 t 4.5 dsm 0.000322019 dsm_est 0.00239066 nsteps 11 - rtol 0.01 rk_type 0 order 2 acc 3 t 4.75 dsm 0.00405487 dsm_est 0.00089527 nsteps 7 - rtol 0.01 rk_type 0 order 2 acc 3 t 5 dsm 0.000699178 dsm_est 0.00160895 nsteps 8 + rtol 0.01 rk_type 0 order 2 acc 3 t 0.25 dsm 5.77245e-05 dsm_est 0.00353036 nsteps 9 + rtol 0.01 rk_type 0 order 2 acc 3 t 0.5 dsm 0.00372257 dsm_est 0.00558255 nsteps 8 + rtol 0.01 rk_type 0 order 2 acc 3 t 0.75 dsm 0.000232425 dsm_est 0.00326237 nsteps 13 + rtol 0.01 rk_type 0 order 2 acc 3 t 1 dsm 0.00327055 dsm_est 0.00560468 nsteps 9 + rtol 0.01 rk_type 0 order 2 acc 3 t 1.25 dsm 0.00363058 dsm_est 0.00326167 nsteps 16 + rtol 0.01 rk_type 0 order 2 acc 3 t 1.5 dsm 0.00267076 dsm_est 0.00448671 nsteps 12 + rtol 0.01 rk_type 0 order 2 acc 3 t 1.75 dsm 0.00971976 dsm_est 0.00430156 nsteps 16 + rtol 0.01 rk_type 0 order 2 acc 3 t 2 dsm 0.000918207 dsm_est 0.00360429 nsteps 14 + rtol 0.01 rk_type 0 order 2 acc 3 t 2.25 dsm 0.0016944 dsm_est 0.00427241 nsteps 10 + rtol 0.01 rk_type 0 order 2 acc 3 t 2.5 dsm 0.0056199 dsm_est 0.0029018 nsteps 7 + rtol 0.01 rk_type 0 order 2 acc 3 t 2.75 dsm 0.00855479 dsm_est 0.00614645 nsteps 6 + rtol 0.01 rk_type 0 order 2 acc 3 t 3 dsm 0.0023308 dsm_est 0.00499894 nsteps 7 + rtol 0.01 rk_type 0 order 2 acc 3 t 3.25 dsm 0.000539467 dsm_est 0.00271774 nsteps 8 + rtol 0.01 rk_type 0 order 2 acc 3 t 3.5 dsm 0.000312605 dsm_est 0.0029728 nsteps 6 + rtol 0.01 rk_type 0 order 2 acc 3 t 3.75 dsm 0.00144605 dsm_est 0.00565195 nsteps 4 + rtol 0.01 rk_type 0 order 2 acc 3 t 4 dsm 0.00023147 dsm_est 0.00239782 nsteps 7 + rtol 0.01 rk_type 0 order 2 acc 3 t 4.25 dsm 0.00806953 dsm_est 0.00616552 nsteps 4 + rtol 0.01 rk_type 0 order 2 acc 3 t 4.5 dsm 0.000322019 dsm_est 0.00389097 nsteps 11 + rtol 0.01 rk_type 0 order 2 acc 3 t 4.75 dsm 0.00405487 dsm_est 0.00155112 nsteps 7 + rtol 0.01 rk_type 0 order 2 acc 3 t 5 dsm 0.000699178 dsm_est 0.00252209 nsteps 8 rtol 0.0001 rk_type 0 order 2 acc 1 t 0.25 dsm 7.46709e-07 dsm_est 7.18663e-05 nsteps 49 rtol 0.0001 rk_type 0 order 2 acc 1 t 0.5 dsm 6.50352e-05 dsm_est 7.49302e-05 nsteps 42 rtol 0.0001 rk_type 0 order 2 acc 1 t 0.75 dsm 4.48379e-06 dsm_est 7.39118e-05 nsteps 84 @@ -108,26 +108,26 @@ Adaptive-step runs: rtol 0.0001 rk_type 0 order 2 acc 2 t 4.5 dsm 8.06381e-06 dsm_est 0.00333997 nsteps 60 rtol 0.0001 rk_type 0 order 2 acc 2 t 4.75 dsm 3.08146e-05 dsm_est 0.00136969 nsteps 36 rtol 0.0001 rk_type 0 order 2 acc 2 t 5 dsm 1.43844e-05 dsm_est 0.00206727 nsteps 37 - rtol 0.0001 rk_type 0 order 2 acc 3 t 0.25 dsm 7.46709e-07 dsm_est 3.89514e-05 nsteps 49 - rtol 0.0001 rk_type 0 order 2 acc 3 t 0.5 dsm 6.50352e-05 dsm_est 4.87422e-05 nsteps 42 - rtol 0.0001 rk_type 0 order 2 acc 3 t 0.75 dsm 4.48379e-06 dsm_est 4.52376e-05 nsteps 84 - rtol 0.0001 rk_type 0 order 2 acc 3 t 1 dsm 3.76158e-05 dsm_est 5.97057e-05 nsteps 61 - rtol 0.0001 rk_type 0 order 2 acc 3 t 1.25 dsm 6.82164e-05 dsm_est 5.09587e-05 nsteps 110 - rtol 0.0001 rk_type 0 order 2 acc 3 t 1.5 dsm 3.68171e-05 dsm_est 5.14096e-05 nsteps 109 - rtol 0.0001 rk_type 0 order 2 acc 3 t 1.75 dsm 2.35133e-05 dsm_est 4.76173e-05 nsteps 136 - rtol 0.0001 rk_type 0 order 2 acc 3 t 2 dsm 1.61655e-05 dsm_est 5.09324e-05 nsteps 91 - rtol 0.0001 rk_type 0 order 2 acc 3 t 2.25 dsm 6.22229e-05 dsm_est 5.36928e-05 nsteps 65 - rtol 0.0001 rk_type 0 order 2 acc 3 t 2.5 dsm 4.95459e-05 dsm_est 4.4449e-05 nsteps 38 - rtol 0.0001 rk_type 0 order 2 acc 3 t 2.75 dsm 4.09894e-05 dsm_est 5.85403e-05 nsteps 35 - rtol 0.0001 rk_type 0 order 2 acc 3 t 3 dsm 3.51226e-05 dsm_est 3.83191e-05 nsteps 41 - rtol 0.0001 rk_type 0 order 2 acc 3 t 3.25 dsm 9.918e-06 dsm_est 4.95986e-05 nsteps 34 - rtol 0.0001 rk_type 0 order 2 acc 3 t 3.5 dsm 6.68205e-06 dsm_est 3.60708e-05 nsteps 29 - rtol 0.0001 rk_type 0 order 2 acc 3 t 3.75 dsm 1.12533e-05 dsm_est 5.1455e-05 nsteps 22 - rtol 0.0001 rk_type 0 order 2 acc 3 t 4 dsm 4.18856e-06 dsm_est 4.77684e-05 nsteps 31 - rtol 0.0001 rk_type 0 order 2 acc 3 t 4.25 dsm 5.65033e-05 dsm_est 4.91962e-05 nsteps 27 - rtol 0.0001 rk_type 0 order 2 acc 3 t 4.5 dsm 8.06381e-06 dsm_est 5.56661e-05 nsteps 60 - rtol 0.0001 rk_type 0 order 2 acc 3 t 4.75 dsm 3.08146e-05 dsm_est 3.80468e-05 nsteps 36 - rtol 0.0001 rk_type 0 order 2 acc 3 t 5 dsm 1.43844e-05 dsm_est 5.58721e-05 nsteps 37 + rtol 0.0001 rk_type 0 order 2 acc 3 t 0.25 dsm 7.46709e-07 dsm_est 3.95038e-05 nsteps 49 + rtol 0.0001 rk_type 0 order 2 acc 3 t 0.5 dsm 6.50352e-05 dsm_est 4.6374e-05 nsteps 42 + rtol 0.0001 rk_type 0 order 2 acc 3 t 0.75 dsm 4.48379e-06 dsm_est 4.43011e-05 nsteps 84 + rtol 0.0001 rk_type 0 order 2 acc 3 t 1 dsm 3.76158e-05 dsm_est 5.97518e-05 nsteps 61 + rtol 0.0001 rk_type 0 order 2 acc 3 t 1.25 dsm 6.82164e-05 dsm_est 4.87769e-05 nsteps 110 + rtol 0.0001 rk_type 0 order 2 acc 3 t 1.5 dsm 3.68171e-05 dsm_est 5.35469e-05 nsteps 109 + rtol 0.0001 rk_type 0 order 2 acc 3 t 1.75 dsm 2.35133e-05 dsm_est 4.62728e-05 nsteps 136 + rtol 0.0001 rk_type 0 order 2 acc 3 t 2 dsm 1.61655e-05 dsm_est 5.09881e-05 nsteps 91 + rtol 0.0001 rk_type 0 order 2 acc 3 t 2.25 dsm 6.22229e-05 dsm_est 5.36889e-05 nsteps 65 + rtol 0.0001 rk_type 0 order 2 acc 3 t 2.5 dsm 4.95459e-05 dsm_est 5.23304e-05 nsteps 38 + rtol 0.0001 rk_type 0 order 2 acc 3 t 2.75 dsm 4.09894e-05 dsm_est 5.62503e-05 nsteps 35 + rtol 0.0001 rk_type 0 order 2 acc 3 t 3 dsm 3.51226e-05 dsm_est 4.33776e-05 nsteps 41 + rtol 0.0001 rk_type 0 order 2 acc 3 t 3.25 dsm 9.918e-06 dsm_est 5.1345e-05 nsteps 34 + rtol 0.0001 rk_type 0 order 2 acc 3 t 3.5 dsm 6.68205e-06 dsm_est 3.84131e-05 nsteps 29 + rtol 0.0001 rk_type 0 order 2 acc 3 t 3.75 dsm 1.12533e-05 dsm_est 5.1961e-05 nsteps 22 + rtol 0.0001 rk_type 0 order 2 acc 3 t 4 dsm 4.18856e-06 dsm_est 4.8569e-05 nsteps 31 + rtol 0.0001 rk_type 0 order 2 acc 3 t 4.25 dsm 5.65033e-05 dsm_est 4.99955e-05 nsteps 27 + rtol 0.0001 rk_type 0 order 2 acc 3 t 4.5 dsm 8.06381e-06 dsm_est 5.6039e-05 nsteps 60 + rtol 0.0001 rk_type 0 order 2 acc 3 t 4.75 dsm 3.08146e-05 dsm_est 3.95264e-05 nsteps 36 + rtol 0.0001 rk_type 0 order 2 acc 3 t 5 dsm 1.43844e-05 dsm_est 5.62992e-05 nsteps 37 rtol 1e-06 rk_type 0 order 2 acc 1 t 0.25 dsm 5.66725e-09 dsm_est 7.18787e-07 nsteps 488 rtol 1e-06 rk_type 0 order 2 acc 1 t 0.5 dsm 9.92276e-07 dsm_est 8.1602e-07 nsteps 403 rtol 1e-06 rk_type 0 order 2 acc 1 t 0.75 dsm 8.0717e-08 dsm_est 7.2088e-07 nsteps 823 @@ -168,23 +168,23 @@ Adaptive-step runs: rtol 1e-06 rk_type 0 order 2 acc 2 t 4.5 dsm 7.4366e-08 dsm_est 0.000335997 nsteps 597 rtol 1e-06 rk_type 0 order 2 acc 2 t 4.75 dsm 5.08713e-07 dsm_est 0.000143029 nsteps 347 rtol 1e-06 rk_type 0 order 2 acc 2 t 5 dsm 1.42752e-07 dsm_est 0.000210843 nsteps 366 - rtol 1e-06 rk_type 0 order 2 acc 3 t 0.25 dsm 5.66725e-09 dsm_est 3.91786e-07 nsteps 488 - rtol 1e-06 rk_type 0 order 2 acc 3 t 0.5 dsm 9.92276e-07 dsm_est 5.14717e-07 nsteps 403 - rtol 1e-06 rk_type 0 order 2 acc 3 t 0.75 dsm 8.0717e-08 dsm_est 4.71859e-07 nsteps 823 - rtol 1e-06 rk_type 0 order 2 acc 3 t 1 dsm 5.67858e-07 dsm_est 6.13342e-07 nsteps 596 - rtol 1e-06 rk_type 0 order 2 acc 3 t 1.25 dsm 1.03484e-06 dsm_est 5.1167e-07 nsteps 1091 - rtol 1e-06 rk_type 0 order 2 acc 3 t 1.5 dsm 5.45182e-07 dsm_est 5.19559e-07 nsteps 1080 - rtol 1e-06 rk_type 0 order 2 acc 3 t 1.75 dsm 3.61096e-07 dsm_est 4.83426e-07 nsteps 1337 - rtol 1e-06 rk_type 0 order 2 acc 3 t 2 dsm 2.2003e-07 dsm_est 5.21923e-07 nsteps 898 - rtol 1e-06 rk_type 0 order 2 acc 3 t 2.25 dsm 9.38782e-07 dsm_est 5.48693e-07 nsteps 635 - rtol 1e-06 rk_type 0 order 2 acc 3 t 2.5 dsm 5.20042e-07 dsm_est 4.49869e-07 nsteps 372 - rtol 1e-06 rk_type 0 order 2 acc 3 t 2.75 dsm 4.66825e-07 dsm_est 5.75673e-07 nsteps 354 - rtol 1e-06 rk_type 0 order 2 acc 3 t 3 dsm 3.30086e-07 dsm_est 3.88553e-07 nsteps 409 - rtol 1e-06 rk_type 0 order 2 acc 3 t 3.25 dsm 1.19548e-07 dsm_est 5.56086e-07 nsteps 320 - rtol 1e-06 rk_type 0 order 2 acc 3 t 3.5 dsm 4.13474e-08 dsm_est 3.61457e-07 nsteps 288 - rtol 1e-06 rk_type 0 order 2 acc 3 t 3.75 dsm 1.02293e-07 dsm_est 5.03828e-07 nsteps 225 - rtol 1e-06 rk_type 0 order 2 acc 3 t 4 dsm 3.98477e-08 dsm_est 4.97667e-07 nsteps 304 - rtol 1e-06 rk_type 0 order 2 acc 3 t 4.25 dsm 7.93335e-07 dsm_est 4.85132e-07 nsteps 268 - rtol 1e-06 rk_type 0 order 2 acc 3 t 4.5 dsm 7.4366e-08 dsm_est 5.62809e-07 nsteps 597 - rtol 1e-06 rk_type 0 order 2 acc 3 t 4.75 dsm 5.08713e-07 dsm_est 4.12187e-07 nsteps 347 - rtol 1e-06 rk_type 0 order 2 acc 3 t 5 dsm 1.42752e-07 dsm_est 5.76073e-07 nsteps 366 + rtol 1e-06 rk_type 0 order 2 acc 3 t 0.25 dsm 5.66725e-09 dsm_est 3.9261e-07 nsteps 488 + rtol 1e-06 rk_type 0 order 2 acc 3 t 0.5 dsm 9.92276e-07 dsm_est 5.09315e-07 nsteps 403 + rtol 1e-06 rk_type 0 order 2 acc 3 t 0.75 dsm 8.0717e-08 dsm_est 4.63477e-07 nsteps 823 + rtol 1e-06 rk_type 0 order 2 acc 3 t 1 dsm 5.67858e-07 dsm_est 6.16216e-07 nsteps 596 + rtol 1e-06 rk_type 0 order 2 acc 3 t 1.25 dsm 1.03484e-06 dsm_est 4.92364e-07 nsteps 1091 + rtol 1e-06 rk_type 0 order 2 acc 3 t 1.5 dsm 5.45182e-07 dsm_est 5.41053e-07 nsteps 1080 + rtol 1e-06 rk_type 0 order 2 acc 3 t 1.75 dsm 3.61096e-07 dsm_est 4.72477e-07 nsteps 1337 + rtol 1e-06 rk_type 0 order 2 acc 3 t 2 dsm 2.2003e-07 dsm_est 5.24929e-07 nsteps 898 + rtol 1e-06 rk_type 0 order 2 acc 3 t 2.25 dsm 9.38782e-07 dsm_est 5.42556e-07 nsteps 635 + rtol 1e-06 rk_type 0 order 2 acc 3 t 2.5 dsm 5.20042e-07 dsm_est 4.96892e-07 nsteps 372 + rtol 1e-06 rk_type 0 order 2 acc 3 t 2.75 dsm 4.66825e-07 dsm_est 5.60217e-07 nsteps 354 + rtol 1e-06 rk_type 0 order 2 acc 3 t 3 dsm 3.30086e-07 dsm_est 4.24795e-07 nsteps 409 + rtol 1e-06 rk_type 0 order 2 acc 3 t 3.25 dsm 1.19548e-07 dsm_est 5.56477e-07 nsteps 320 + rtol 1e-06 rk_type 0 order 2 acc 3 t 3.5 dsm 4.13474e-08 dsm_est 3.67781e-07 nsteps 288 + rtol 1e-06 rk_type 0 order 2 acc 3 t 3.75 dsm 1.02293e-07 dsm_est 5.03214e-07 nsteps 225 + rtol 1e-06 rk_type 0 order 2 acc 3 t 4 dsm 3.98477e-08 dsm_est 4.99206e-07 nsteps 304 + rtol 1e-06 rk_type 0 order 2 acc 3 t 4.25 dsm 7.93335e-07 dsm_est 4.93361e-07 nsteps 268 + rtol 1e-06 rk_type 0 order 2 acc 3 t 4.5 dsm 7.4366e-08 dsm_est 5.62432e-07 nsteps 597 + rtol 1e-06 rk_type 0 order 2 acc 3 t 4.75 dsm 5.08713e-07 dsm_est 4.57462e-07 nsteps 347 + rtol 1e-06 rk_type 0 order 2 acc 3 t 5 dsm 1.42752e-07 dsm_est 5.75749e-07 nsteps 366 diff --git a/test/unit_tests/arkode/CXX_serial/ark_test_accumerror_kpr_20_3_1.out b/test/unit_tests/arkode/CXX_serial/ark_test_accumerror_kpr_20_3_1.out index 5e13fabf2e..9c8d250c22 100644 --- a/test/unit_tests/arkode/CXX_serial/ark_test_accumerror_kpr_20_3_1.out +++ b/test/unit_tests/arkode/CXX_serial/ark_test_accumerror_kpr_20_3_1.out @@ -48,26 +48,26 @@ Adaptive-step runs: rtol 0.01 rk_type 1 order 3 acc 2 t 4.5 dsm 1.84821e-05 dsm_est 0.000782096 nsteps 5 rtol 0.01 rk_type 1 order 3 acc 2 t 4.75 dsm 6.25225e-05 dsm_est 0.00123861 nsteps 5 rtol 0.01 rk_type 1 order 3 acc 2 t 5 dsm 1.27772e-05 dsm_est 0.000335449 nsteps 5 - rtol 0.01 rk_type 1 order 3 acc 3 t 0.25 dsm 6.04149e-05 dsm_est 2.84962e-05 nsteps 5 - rtol 0.01 rk_type 1 order 3 acc 3 t 0.5 dsm 0.000268262 dsm_est 0.00035888 nsteps 5 - rtol 0.01 rk_type 1 order 3 acc 3 t 0.75 dsm 0.000162426 dsm_est 0.000612632 nsteps 5 - rtol 0.01 rk_type 1 order 3 acc 3 t 1 dsm 0.00010345 dsm_est 0.000591054 nsteps 5 - rtol 0.01 rk_type 1 order 3 acc 3 t 1.25 dsm 0.00145293 dsm_est 0.000651262 nsteps 7 - rtol 0.01 rk_type 1 order 3 acc 3 t 1.5 dsm 0.000475504 dsm_est 0.000619088 nsteps 6 - rtol 0.01 rk_type 1 order 3 acc 3 t 1.75 dsm 0.000953909 dsm_est 0.00225203 nsteps 5 - rtol 0.01 rk_type 1 order 3 acc 3 t 2 dsm 0.00190469 dsm_est 0.00106139 nsteps 6 - rtol 0.01 rk_type 1 order 3 acc 3 t 2.25 dsm 0.00091692 dsm_est 0.000519458 nsteps 5 - rtol 0.01 rk_type 1 order 3 acc 3 t 2.5 dsm 0.000303064 dsm_est 0.000373224 nsteps 5 - rtol 0.01 rk_type 1 order 3 acc 3 t 2.75 dsm 8.75302e-05 dsm_est 0.000251533 nsteps 5 - rtol 0.01 rk_type 1 order 3 acc 3 t 3 dsm 0.000106108 dsm_est 0.000216057 nsteps 5 - rtol 0.01 rk_type 1 order 3 acc 3 t 3.25 dsm 0.000146676 dsm_est 5.74422e-05 nsteps 5 - rtol 0.01 rk_type 1 order 3 acc 3 t 3.5 dsm 0.000132279 dsm_est 3.97606e-05 nsteps 5 - rtol 0.01 rk_type 1 order 3 acc 3 t 3.75 dsm 0.000106549 dsm_est 2.55114e-05 nsteps 5 - rtol 0.01 rk_type 1 order 3 acc 3 t 4 dsm 7.68783e-05 dsm_est 1.97574e-05 nsteps 5 - rtol 0.01 rk_type 1 order 3 acc 3 t 4.25 dsm 9.2941e-05 dsm_est 0.000147815 nsteps 5 - rtol 0.01 rk_type 1 order 3 acc 3 t 4.5 dsm 1.84821e-05 dsm_est 0.000156419 nsteps 5 - rtol 0.01 rk_type 1 order 3 acc 3 t 4.75 dsm 6.25225e-05 dsm_est 0.000247722 nsteps 5 - rtol 0.01 rk_type 1 order 3 acc 3 t 5 dsm 1.27772e-05 dsm_est 6.70899e-05 nsteps 5 + rtol 0.01 rk_type 1 order 3 acc 3 t 0.25 dsm 6.04149e-05 dsm_est 5.47626e-05 nsteps 5 + rtol 0.01 rk_type 1 order 3 acc 3 t 0.5 dsm 0.000268262 dsm_est 0.000688366 nsteps 5 + rtol 0.01 rk_type 1 order 3 acc 3 t 0.75 dsm 0.000162426 dsm_est 0.00119286 nsteps 5 + rtol 0.01 rk_type 1 order 3 acc 3 t 1 dsm 0.00010345 dsm_est 0.00117728 nsteps 5 + rtol 0.01 rk_type 1 order 3 acc 3 t 1.25 dsm 0.00145293 dsm_est 0.00131716 nsteps 7 + rtol 0.01 rk_type 1 order 3 acc 3 t 1.5 dsm 0.000475504 dsm_est 0.00085833 nsteps 6 + rtol 0.01 rk_type 1 order 3 acc 3 t 1.75 dsm 0.000953909 dsm_est 0.0042376 nsteps 5 + rtol 0.01 rk_type 1 order 3 acc 3 t 2 dsm 0.00190469 dsm_est 0.00253135 nsteps 6 + rtol 0.01 rk_type 1 order 3 acc 3 t 2.25 dsm 0.00091692 dsm_est 0.00101199 nsteps 5 + rtol 0.01 rk_type 1 order 3 acc 3 t 2.5 dsm 0.000303064 dsm_est 0.000742258 nsteps 5 + rtol 0.01 rk_type 1 order 3 acc 3 t 2.75 dsm 8.75302e-05 dsm_est 0.000500525 nsteps 5 + rtol 0.01 rk_type 1 order 3 acc 3 t 3 dsm 0.000106108 dsm_est 0.000425438 nsteps 5 + rtol 0.01 rk_type 1 order 3 acc 3 t 3.25 dsm 0.000146676 dsm_est 0.000113454 nsteps 5 + rtol 0.01 rk_type 1 order 3 acc 3 t 3.5 dsm 0.000132279 dsm_est 7.91918e-05 nsteps 5 + rtol 0.01 rk_type 1 order 3 acc 3 t 3.75 dsm 0.000106549 dsm_est 5.03981e-05 nsteps 5 + rtol 0.01 rk_type 1 order 3 acc 3 t 4 dsm 7.68783e-05 dsm_est 3.86745e-05 nsteps 5 + rtol 0.01 rk_type 1 order 3 acc 3 t 4.25 dsm 9.2941e-05 dsm_est 0.00028618 nsteps 5 + rtol 0.01 rk_type 1 order 3 acc 3 t 4.5 dsm 1.84821e-05 dsm_est 0.000303327 nsteps 5 + rtol 0.01 rk_type 1 order 3 acc 3 t 4.75 dsm 6.25225e-05 dsm_est 0.000490051 nsteps 5 + rtol 0.01 rk_type 1 order 3 acc 3 t 5 dsm 1.27772e-05 dsm_est 0.000133564 nsteps 5 rtol 0.0001 rk_type 1 order 3 acc 1 t 0.25 dsm 2.72131e-05 dsm_est 1.82775e-05 nsteps 6 rtol 0.0001 rk_type 1 order 3 acc 1 t 0.5 dsm 1.24325e-05 dsm_est 7.57337e-05 nsteps 10 rtol 0.0001 rk_type 1 order 3 acc 1 t 0.75 dsm 3.04294e-06 dsm_est 5.32249e-05 nsteps 11 @@ -108,26 +108,26 @@ Adaptive-step runs: rtol 0.0001 rk_type 1 order 3 acc 2 t 4.5 dsm 3.00465e-06 dsm_est 0.00017063 nsteps 9 rtol 0.0001 rk_type 1 order 3 acc 2 t 4.75 dsm 2.24177e-06 dsm_est 0.000176806 nsteps 9 rtol 0.0001 rk_type 1 order 3 acc 2 t 5 dsm 4.61559e-06 dsm_est 8.40566e-05 nsteps 7 - rtol 0.0001 rk_type 1 order 3 acc 3 t 0.25 dsm 2.72131e-05 dsm_est 8.20667e-06 nsteps 6 - rtol 0.0001 rk_type 1 order 3 acc 3 t 0.5 dsm 1.24325e-05 dsm_est 2.77893e-05 nsteps 10 - rtol 0.0001 rk_type 1 order 3 acc 3 t 0.75 dsm 3.04294e-06 dsm_est 2.4191e-05 nsteps 11 - rtol 0.0001 rk_type 1 order 3 acc 3 t 1 dsm 5.56473e-06 dsm_est 2.1078e-05 nsteps 10 - rtol 0.0001 rk_type 1 order 3 acc 3 t 1.25 dsm 2.64925e-05 dsm_est 4.37622e-05 nsteps 14 - rtol 0.0001 rk_type 1 order 3 acc 3 t 1.5 dsm 3.99013e-05 dsm_est 2.21272e-05 nsteps 17 - rtol 0.0001 rk_type 1 order 3 acc 3 t 1.75 dsm 6.46566e-06 dsm_est 3.32327e-05 nsteps 20 - rtol 0.0001 rk_type 1 order 3 acc 3 t 2 dsm 2.27591e-05 dsm_est 1.88101e-05 nsteps 14 - rtol 0.0001 rk_type 1 order 3 acc 3 t 2.25 dsm 2.35987e-05 dsm_est 1.82395e-05 nsteps 12 - rtol 0.0001 rk_type 1 order 3 acc 3 t 2.5 dsm 1.9839e-05 dsm_est 1.44657e-05 nsteps 10 - rtol 0.0001 rk_type 1 order 3 acc 3 t 2.75 dsm 4.82543e-06 dsm_est 2.04852e-05 nsteps 9 - rtol 0.0001 rk_type 1 order 3 acc 3 t 3 dsm 1.42111e-05 dsm_est 2.59031e-05 nsteps 9 - rtol 0.0001 rk_type 1 order 3 acc 3 t 3.25 dsm 8.99237e-05 dsm_est 1.52677e-05 nsteps 6 - rtol 0.0001 rk_type 1 order 3 acc 3 t 3.5 dsm 7.05943e-05 dsm_est 1.07712e-05 nsteps 6 - rtol 0.0001 rk_type 1 order 3 acc 3 t 3.75 dsm 0.00011745 dsm_est 2.59539e-05 nsteps 5 - rtol 0.0001 rk_type 1 order 3 acc 3 t 4 dsm 8.6392e-05 dsm_est 2.17376e-05 nsteps 5 - rtol 0.0001 rk_type 1 order 3 acc 3 t 4.25 dsm 1.06282e-05 dsm_est 2.59085e-05 nsteps 8 - rtol 0.0001 rk_type 1 order 3 acc 3 t 4.5 dsm 3.00465e-06 dsm_est 1.89589e-05 nsteps 9 - rtol 0.0001 rk_type 1 order 3 acc 3 t 4.75 dsm 2.24177e-06 dsm_est 1.96451e-05 nsteps 9 - rtol 0.0001 rk_type 1 order 3 acc 3 t 5 dsm 4.61559e-06 dsm_est 1.20081e-05 nsteps 7 + rtol 0.0001 rk_type 1 order 3 acc 3 t 0.25 dsm 2.72131e-05 dsm_est 1.26444e-05 nsteps 6 + rtol 0.0001 rk_type 1 order 3 acc 3 t 0.5 dsm 1.24325e-05 dsm_est 3.83049e-05 nsteps 10 + rtol 0.0001 rk_type 1 order 3 acc 3 t 0.75 dsm 3.04294e-06 dsm_est 3.06274e-05 nsteps 11 + rtol 0.0001 rk_type 1 order 3 acc 3 t 1 dsm 5.56473e-06 dsm_est 2.34303e-05 nsteps 10 + rtol 0.0001 rk_type 1 order 3 acc 3 t 1.25 dsm 2.64925e-05 dsm_est 4.97711e-05 nsteps 14 + rtol 0.0001 rk_type 1 order 3 acc 3 t 1.5 dsm 3.99013e-05 dsm_est 2.68233e-05 nsteps 17 + rtol 0.0001 rk_type 1 order 3 acc 3 t 1.75 dsm 6.46566e-06 dsm_est 4.0356e-05 nsteps 20 + rtol 0.0001 rk_type 1 order 3 acc 3 t 2 dsm 2.27591e-05 dsm_est 2.34866e-05 nsteps 14 + rtol 0.0001 rk_type 1 order 3 acc 3 t 2.25 dsm 2.35987e-05 dsm_est 2.21042e-05 nsteps 12 + rtol 0.0001 rk_type 1 order 3 acc 3 t 2.5 dsm 1.9839e-05 dsm_est 1.76794e-05 nsteps 10 + rtol 0.0001 rk_type 1 order 3 acc 3 t 2.75 dsm 4.82543e-06 dsm_est 2.9381e-05 nsteps 9 + rtol 0.0001 rk_type 1 order 3 acc 3 t 3 dsm 1.42111e-05 dsm_est 4.44933e-05 nsteps 9 + rtol 0.0001 rk_type 1 order 3 acc 3 t 3.25 dsm 8.99237e-05 dsm_est 2.62142e-05 nsteps 6 + rtol 0.0001 rk_type 1 order 3 acc 3 t 3.5 dsm 7.05943e-05 dsm_est 1.71657e-05 nsteps 6 + rtol 0.0001 rk_type 1 order 3 acc 3 t 3.75 dsm 0.00011745 dsm_est 5.1548e-05 nsteps 5 + rtol 0.0001 rk_type 1 order 3 acc 3 t 4 dsm 8.6392e-05 dsm_est 4.3218e-05 nsteps 5 + rtol 0.0001 rk_type 1 order 3 acc 3 t 4.25 dsm 1.06282e-05 dsm_est 4.16064e-05 nsteps 8 + rtol 0.0001 rk_type 1 order 3 acc 3 t 4.5 dsm 3.00465e-06 dsm_est 3.06597e-05 nsteps 9 + rtol 0.0001 rk_type 1 order 3 acc 3 t 4.75 dsm 2.24177e-06 dsm_est 2.78662e-05 nsteps 9 + rtol 0.0001 rk_type 1 order 3 acc 3 t 5 dsm 4.61559e-06 dsm_est 2.06734e-05 nsteps 7 rtol 1e-06 rk_type 1 order 3 acc 1 t 0.25 dsm 4.12033e-07 dsm_est 8.83529e-07 nsteps 17 rtol 1e-06 rk_type 1 order 3 acc 1 t 0.5 dsm 2.46326e-07 dsm_est 8.87311e-07 nsteps 31 rtol 1e-06 rk_type 1 order 3 acc 1 t 0.75 dsm 3.64026e-08 dsm_est 8.31388e-07 nsteps 39 @@ -168,23 +168,23 @@ Adaptive-step runs: rtol 1e-06 rk_type 1 order 3 acc 2 t 4.5 dsm 4.23449e-08 dsm_est 9.97609e-06 nsteps 29 rtol 1e-06 rk_type 1 order 3 acc 2 t 4.75 dsm 1.70945e-08 dsm_est 8.39064e-06 nsteps 35 rtol 1e-06 rk_type 1 order 3 acc 2 t 5 dsm 4.21376e-08 dsm_est 4.92976e-06 nsteps 23 - rtol 1e-06 rk_type 1 order 3 acc 3 t 0.25 dsm 4.12033e-07 dsm_est 3.17288e-07 nsteps 17 - rtol 1e-06 rk_type 1 order 3 acc 3 t 0.5 dsm 2.46326e-07 dsm_est 6.20547e-07 nsteps 31 - rtol 1e-06 rk_type 1 order 3 acc 3 t 0.75 dsm 3.64026e-08 dsm_est 4.69255e-07 nsteps 39 - rtol 1e-06 rk_type 1 order 3 acc 3 t 1 dsm 2.25687e-07 dsm_est 2.13052e-07 nsteps 45 - rtol 1e-06 rk_type 1 order 3 acc 3 t 1.25 dsm 5.93423e-07 dsm_est 6.03951e-07 nsteps 53 - rtol 1e-06 rk_type 1 order 3 acc 3 t 1.5 dsm 6.11123e-07 dsm_est 2.8192e-07 nsteps 68 - rtol 1e-06 rk_type 1 order 3 acc 3 t 1.75 dsm 1.11041e-07 dsm_est 4.94913e-07 nsteps 76 - rtol 1e-06 rk_type 1 order 3 acc 3 t 2 dsm 4.68945e-07 dsm_est 3.61283e-07 nsteps 49 - rtol 1e-06 rk_type 1 order 3 acc 3 t 2.25 dsm 2.82077e-07 dsm_est 3.07636e-07 nsteps 46 - rtol 1e-06 rk_type 1 order 3 acc 3 t 2.5 dsm 3.42754e-07 dsm_est 2.3822e-07 nsteps 37 - rtol 1e-06 rk_type 1 order 3 acc 3 t 2.75 dsm 8.76441e-08 dsm_est 3.52094e-07 nsteps 30 - rtol 1e-06 rk_type 1 order 3 acc 3 t 3 dsm 9.61476e-08 dsm_est 3.53089e-07 nsteps 29 - rtol 1e-06 rk_type 1 order 3 acc 3 t 3.25 dsm 1.10578e-06 dsm_est 3.08489e-07 nsteps 19 - rtol 1e-06 rk_type 1 order 3 acc 3 t 3.5 dsm 8.13041e-07 dsm_est 2.17804e-07 nsteps 19 - rtol 1e-06 rk_type 1 order 3 acc 3 t 3.75 dsm 8.63105e-07 dsm_est 3.30737e-07 nsteps 15 - rtol 1e-06 rk_type 1 order 3 acc 3 t 4 dsm 6.24598e-07 dsm_est 2.01343e-07 nsteps 17 - rtol 1e-06 rk_type 1 order 3 acc 3 t 4.25 dsm 1.79535e-07 dsm_est 5.65678e-07 nsteps 24 - rtol 1e-06 rk_type 1 order 3 acc 3 t 4.5 dsm 4.23449e-08 dsm_est 3.44003e-07 nsteps 29 - rtol 1e-06 rk_type 1 order 3 acc 3 t 4.75 dsm 1.70945e-08 dsm_est 2.39733e-07 nsteps 35 - rtol 1e-06 rk_type 1 order 3 acc 3 t 5 dsm 4.21376e-08 dsm_est 2.14337e-07 nsteps 23 + rtol 1e-06 rk_type 1 order 3 acc 3 t 0.25 dsm 4.12033e-07 dsm_est 3.51639e-07 nsteps 17 + rtol 1e-06 rk_type 1 order 3 acc 3 t 0.5 dsm 2.46326e-07 dsm_est 6.81523e-07 nsteps 31 + rtol 1e-06 rk_type 1 order 3 acc 3 t 0.75 dsm 3.64026e-08 dsm_est 5.27456e-07 nsteps 39 + rtol 1e-06 rk_type 1 order 3 acc 3 t 1 dsm 2.25687e-07 dsm_est 2.33885e-07 nsteps 45 + rtol 1e-06 rk_type 1 order 3 acc 3 t 1.25 dsm 5.93423e-07 dsm_est 6.2587e-07 nsteps 53 + rtol 1e-06 rk_type 1 order 3 acc 3 t 1.5 dsm 6.11123e-07 dsm_est 3.04709e-07 nsteps 68 + rtol 1e-06 rk_type 1 order 3 acc 3 t 1.75 dsm 1.11041e-07 dsm_est 5.31606e-07 nsteps 76 + rtol 1e-06 rk_type 1 order 3 acc 3 t 2 dsm 4.68945e-07 dsm_est 4.08204e-07 nsteps 49 + rtol 1e-06 rk_type 1 order 3 acc 3 t 2.25 dsm 2.82077e-07 dsm_est 3.48802e-07 nsteps 46 + rtol 1e-06 rk_type 1 order 3 acc 3 t 2.5 dsm 3.42754e-07 dsm_est 2.65247e-07 nsteps 37 + rtol 1e-06 rk_type 1 order 3 acc 3 t 2.75 dsm 8.76441e-08 dsm_est 3.82534e-07 nsteps 30 + rtol 1e-06 rk_type 1 order 3 acc 3 t 3 dsm 9.61476e-08 dsm_est 3.90658e-07 nsteps 29 + rtol 1e-06 rk_type 1 order 3 acc 3 t 3.25 dsm 1.10578e-06 dsm_est 3.96373e-07 nsteps 19 + rtol 1e-06 rk_type 1 order 3 acc 3 t 3.5 dsm 8.13041e-07 dsm_est 2.65458e-07 nsteps 19 + rtol 1e-06 rk_type 1 order 3 acc 3 t 3.75 dsm 8.63105e-07 dsm_est 4.14868e-07 nsteps 15 + rtol 1e-06 rk_type 1 order 3 acc 3 t 4 dsm 6.24598e-07 dsm_est 2.48565e-07 nsteps 17 + rtol 1e-06 rk_type 1 order 3 acc 3 t 4.25 dsm 1.79535e-07 dsm_est 6.40873e-07 nsteps 24 + rtol 1e-06 rk_type 1 order 3 acc 3 t 4.5 dsm 4.23449e-08 dsm_est 4.08016e-07 nsteps 29 + rtol 1e-06 rk_type 1 order 3 acc 3 t 4.75 dsm 1.70945e-08 dsm_est 2.72362e-07 nsteps 35 + rtol 1e-06 rk_type 1 order 3 acc 3 t 5 dsm 4.21376e-08 dsm_est 2.53485e-07 nsteps 23 diff --git a/test/unit_tests/arkode/CXX_serial/ark_test_brusselator_mriadapt_--rtol_0.000004_--scontrol_0.out b/test/unit_tests/arkode/CXX_serial/ark_test_brusselator_mriadapt_--rtol_0.000004_--scontrol_0.out index 4609777e89..8f3f732b3f 100644 --- a/test/unit_tests/arkode/CXX_serial/ark_test_brusselator_mriadapt_--rtol_0.000004_--scontrol_0.out +++ b/test/unit_tests/arkode/CXX_serial/ark_test_brusselator_mriadapt_--rtol_0.000004_--scontrol_0.out @@ -17,27 +17,26 @@ Adaptive multirate stiff Brusselator test problem: 1.000000 1.107158 3.008131 3.498438 1.2e-07 1.2e-07 1.3e-05 1.500000 0.917798 3.188082 3.498698 1.0e-07 1.0e-07 1.7e-05 2.000000 0.691486 3.512327 3.499015 7.6e-08 7.6e-08 1.7e-05 - 2.500000 0.510160 3.896431 3.499274 5.5e-08 5.5e-08 1.2e-05 - 3.000000 0.410222 4.269502 3.499416 4.6e-08 4.6e-08 9.6e-06 - 3.500000 0.372044 4.614020 3.499469 3.0e-08 3.0e-08 9.8e-06 - 4.000000 0.367587 4.934562 3.499472 3.2e-08 3.2e-08 1.3e-05 - 4.500000 0.382207 5.233152 3.499474 3.2e-08 3.2e-08 9.1e-06 - 5.000000 0.412957 5.504350 3.499431 4.1e-08 4.1e-08 8.5e-06 - 5.500000 0.467991 5.730484 3.499356 5.5e-08 5.5e-08 1.1e-05 - 6.000000 0.585319 5.854259 3.499196 6.5e-08 6.6e-08 1.5e-05 - 6.500000 1.060816 5.503421 3.498555 5.4e-07 5.5e-07 3.8e-05 - 7.000000 4.794985 0.734608 3.493240 3.6e-06 3.6e-06 5.8e-05 - 7.500000 3.037697 1.057906 3.495704 2.0e-06 2.0e-06 4.7e-05 - 8.000000 1.833967 1.562361 3.497406 7.7e-07 7.8e-07 2.7e-05 - 8.500000 1.008514 2.191339 3.498570 2.5e-07 2.5e-07 1.8e-05 - 9.000000 0.534095 2.794916 3.499237 6.6e-08 6.7e-08 1.5e-05 - 9.500000 0.352784 3.263323 3.499486 4.3e-08 4.3e-08 2.0e-05 - 10.000000 0.305955 3.648442 3.499562 2.5e-08 2.5e-08 9.8e-06 + 2.510000 0.507365 3.904138 3.499277 5.4e-08 5.5e-08 1.2e-05 + 3.010000 0.408962 4.276667 3.499418 4.5e-08 4.6e-08 9.5e-06 + 3.510000 0.371697 4.620648 3.499470 3.0e-08 3.0e-08 9.9e-06 + 4.010000 0.367719 4.940753 3.499477 5.3e-08 5.4e-08 8.0e-06 + 4.510000 0.382657 5.238877 3.499473 3.2e-08 3.3e-08 9.1e-06 + 5.010000 0.413767 5.509406 3.499429 4.1e-08 4.1e-08 8.5e-06 + 5.510000 0.469496 5.734291 3.499354 5.5e-08 5.5e-08 1.1e-05 + 6.010000 0.589086 5.854619 3.499191 6.5e-08 6.6e-08 1.5e-05 + 6.510000 1.085778 5.477727 3.498540 6.0e-07 6.1e-07 5.8e-05 + 7.010000 4.757865 0.733961 3.493291 3.9e-06 4.0e-06 5.9e-05 + 7.510000 3.008865 1.066505 3.495744 1.9e-06 1.9e-06 4.7e-05 + 8.010000 1.814106 1.573981 3.497434 7.5e-07 7.6e-07 2.7e-05 + 8.510000 0.995504 2.204329 3.498588 2.4e-07 2.4e-07 1.8e-05 + 9.010000 0.528098 2.805602 3.499245 6.5e-08 6.6e-08 1.5e-05 + 9.510000 0.350997 3.271591 3.499488 4.4e-08 4.5e-08 2.0e-05 ------------------------------------------------------------------------- Final Solver Statistics: Slow steps = 1000 (attempts = 1000, fails = 0) - Fast steps = 11775 (attempts = 16695, fails = 4920) - u error = 1.29633e-05, v error = 1.15346e-05, w error = 0.000392775, total error = 0.00022699 + Fast steps = 11774 (attempts = 16690, fails = 4916) + u error = 1.83331e-06, v error = 1.63126e-06, w error = 5.55533e-05, total error = 3.2105e-05 Relative accuracy = 83.5081 - Total RHS evals: Fse = 5000, Fsi = 0, Ff = 78557 + Total RHS evals: Fse = 5000, Fsi = 0, Ff = 78536 diff --git a/test/unit_tests/arkode/CXX_serial/ark_test_kpr_mriadapt_--hs_0.002_--rtol_0.000004_--scontrol_0.out b/test/unit_tests/arkode/CXX_serial/ark_test_kpr_mriadapt_--hs_0.002_--rtol_0.000004_--scontrol_0.out index a2776b60d6..29c1f3929e 100644 --- a/test/unit_tests/arkode/CXX_serial/ark_test_kpr_mriadapt_--hs_0.002_--rtol_0.000004_--scontrol_0.out +++ b/test/unit_tests/arkode/CXX_serial/ark_test_kpr_mriadapt_--hs_0.002_--rtol_0.000004_--scontrol_0.out @@ -16,30 +16,29 @@ Adaptive multirate nonlinear Kvaerno-Prothero-Robinson test problem: ------------------------------------------------------ 0.000000 1.732051 1.732051 0.00e+00 0.00e+00 0.250000 1.723053 1.584050 5.10e-11 1.74e-10 - 0.500000 1.696344 1.512598 4.32e-11 2.69e-10 - 0.750000 1.652782 1.036015 4.04e-11 3.14e-09 - 1.000000 1.593833 1.458873 3.27e-11 2.89e-09 - 1.250000 1.521618 1.458201 3.54e-11 1.27e-08 - 1.500000 1.439006 1.011474 4.37e-11 6.25e-08 - 1.750000 1.349724 1.730452 3.08e-12 3.71e-09 - 2.000000 1.258512 1.214374 1.24e-11 5.83e-09 - 2.250000 1.171250 1.024071 2.70e-11 1.63e-10 - 2.500000 1.094923 1.471085 4.59e-11 3.37e-13 - 2.750000 1.037158 1.313348 6.36e-11 2.73e-11 - 3.000000 1.004991 1.274175 7.66e-11 3.08e-11 - 3.250000 1.002931 1.043458 7.94e-11 6.65e-12 - 3.500000 1.031282 1.053648 6.81e-11 1.65e-13 - 3.750000 1.086021 1.006374 5.17e-11 2.69e-12 - 4.000000 1.160326 1.571824 3.06e-11 1.90e-11 - 4.250000 1.246560 1.705136 1.25e-11 2.07e-11 - 4.500000 1.337611 1.431830 3.29e-12 5.45e-11 - 4.750000 1.427446 1.162908 1.55e-11 1.82e-10 - 5.000000 1.511179 1.070831 2.51e-11 3.34e-10 + 0.500000 1.696344 1.512598 4.29e-11 2.73e-10 + 0.750000 1.652782 1.036015 4.03e-11 3.14e-09 + 1.000000 1.593833 1.458873 3.25e-11 2.89e-09 + 1.250000 1.521618 1.458201 3.36e-11 1.27e-08 + 1.500000 1.439006 1.011474 4.38e-11 6.25e-08 + 1.750000 1.349724 1.730452 4.07e-12 3.64e-09 + 2.000000 1.258512 1.214374 1.23e-11 5.82e-09 + 2.252000 1.170586 1.004732 2.73e-11 1.04e-10 + 2.502000 1.094377 1.459495 4.60e-11 3.22e-13 + 2.752000 1.036791 1.256387 6.39e-11 3.22e-11 + 3.002000 1.004852 1.335466 7.65e-11 2.48e-11 + 3.252000 1.003040 1.026042 8.00e-11 3.09e-12 + 3.502000 1.031623 1.053676 6.80e-11 1.62e-13 + 3.752000 1.086547 1.001339 5.18e-11 1.65e-13 + 4.002000 1.160979 1.610394 3.05e-11 2.03e-11 + 4.252000 1.247278 1.679067 8.92e-12 4.85e-11 + 4.502000 1.338342 1.496510 3.50e-12 6.62e-11 + 4.752000 1.428146 1.230596 1.57e-11 1.02e-10 ------------------------------------------------------ Final Solver Statistics: Slow steps = 2500 (attempts = 2500, fails = 0) Fast steps = 12502 (attempts = 12502, fails = 0) - u error = 4.83189e-10, v error = 1.06446e-07, total error = 7.52694e-08 + u error = 4.31336e-11, v error = 9.52085e-09, total error = 6.73232e-09 Relative accuracy = 0.0160088 Total RHS evals: Fse = 12500, Fsi = 0, Ff = 62512 From c08cafae9010194202d27ccfbd85f7923064ae47 Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Wed, 30 Oct 2024 16:17:42 -0500 Subject: [PATCH 209/286] Added fse_is_current and fsi_is_current flags to MRIStep to aid in reuse of RHS vectors when it is used as an inner stepper --- src/arkode/arkode_mristep.c | 265 +++++++++++++++++-------------- src/arkode/arkode_mristep_impl.h | 6 +- 2 files changed, 153 insertions(+), 118 deletions(-) diff --git a/src/arkode/arkode_mristep.c b/src/arkode/arkode_mristep.c index a8bc700f4b..1bd75234f8 100644 --- a/src/arkode/arkode_mristep.c +++ b/src/arkode/arkode_mristep.c @@ -162,6 +162,8 @@ void* MRIStepCreate(ARKRhsFn fse, ARKRhsFn fsi, sunrealtype t0, N_Vector y0, /* Copy the slow RHS functions into stepper memory */ step_mem->fse = fse; step_mem->fsi = fsi; + step_mem->fse_is_current = SUNFALSE; + step_mem->fsi_is_current = SUNFALSE; /* Set implicit/explicit problem based on function pointers */ step_mem->explicit_rhs = (fse == NULL) ? SUNFALSE : SUNTRUE; @@ -346,6 +348,8 @@ int MRIStepReInit(void* arkode_mem, ARKRhsFn fse, ARKRhsFn fsi, sunrealtype t0, /* Copy the input parameters into ARKODE state */ step_mem->fse = fse; step_mem->fsi = fsi; + step_mem->fse_is_current = SUNFALSE; + step_mem->fsi_is_current = SUNFALSE; /* Initialize all the counters */ step_mem->nfse = 0; @@ -1366,57 +1370,67 @@ int mriStep_FullRHS(ARKodeMem ark_mem, sunrealtype t, N_Vector y, N_Vector f, { case ARK_FULLRHS_START: - /* compute the full RHS */ - if (!(ark_mem->fn_is_current)) + /* compute the components that comprise the full RHS */ + + /* explicit component */ + if (step_mem->explicit_rhs) { - /* compute the explicit component */ - if (step_mem->explicit_rhs) + /* if either ARKODE or MRIStep consider Fse[0] stale, then recompute */ + if (!step_mem->fse_is_current || !ark_mem->fn_is_current) { retval = step_mem->fse(t, y, step_mem->Fse[0], ark_mem->user_data); step_mem->nfse++; + step_mem->fse_is_current = SUNTRUE; if (retval != 0) { arkProcessError(ark_mem, ARK_RHSFUNC_FAIL, __LINE__, __func__, __FILE__, MSG_ARK_RHSFUNC_FAILED, t); return (ARK_RHSFUNC_FAIL); } + + /* Add external forcing, if applicable */ + if (step_mem->expforcing) + { + step_mem->cvals[0] = ONE; + step_mem->Xvecs[0] = step_mem->Fse[0]; + nvec = 1; + mriStep_ApplyForcing(step_mem, t, ONE, &nvec); + N_VLinearCombination(nvec, step_mem->cvals, step_mem->Xvecs, + step_mem->Fse[0]); + } } + } - /* compute the implicit component */ - if (step_mem->implicit_rhs) + /* implicit component */ + if (step_mem->implicit_rhs) + { + /* if either ARKODE or MRIStep consider Fsi[0] stale, then recompute */ + if (!step_mem->fsi_is_current || !ark_mem->fn_is_current) { retval = step_mem->fsi(t, y, step_mem->Fsi[0], ark_mem->user_data); step_mem->nfsi++; + step_mem->fsi_is_current = SUNTRUE; if (retval != 0) { arkProcessError(ark_mem, ARK_RHSFUNC_FAIL, __LINE__, __func__, __FILE__, MSG_ARK_RHSFUNC_FAILED, t); return (ARK_RHSFUNC_FAIL); } - } - /* Add external forcing to Fse[0] or Fsi[0], if applicable */ - if (step_mem->expforcing) - { - step_mem->cvals[0] = ONE; - step_mem->Xvecs[0] = step_mem->Fse[0]; - nvec = 1; - mriStep_ApplyForcing(step_mem, t, ONE, &nvec); - N_VLinearCombination(nvec, step_mem->cvals, step_mem->Xvecs, - step_mem->Fse[0]); - } - if (step_mem->impforcing) - { - step_mem->cvals[0] = ONE; - step_mem->Xvecs[0] = step_mem->Fsi[0]; - nvec = 1; - mriStep_ApplyForcing(step_mem, t, ONE, &nvec); - N_VLinearCombination(nvec, step_mem->cvals, step_mem->Xvecs, - step_mem->Fsi[0]); + /* Add external forcing, if applicable */ + if (step_mem->impforcing) + { + step_mem->cvals[0] = ONE; + step_mem->Xvecs[0] = step_mem->Fsi[0]; + nvec = 1; + mriStep_ApplyForcing(step_mem, t, ONE, &nvec); + N_VLinearCombination(nvec, step_mem->cvals, step_mem->Xvecs, + step_mem->Fsi[0]); + } } } - /* compute the fast component (force new RHS computation) */ + /* fast component */ retval = mriStepInnerStepper_FullRhs(step_mem->stepper, t, y, f, ARK_FULLRHS_OTHER); if (retval != ARK_SUCCESS) @@ -1426,7 +1440,7 @@ int mriStep_FullRHS(ARKodeMem ark_mem, sunrealtype t, N_Vector y, N_Vector f, return (ARK_RHSFUNC_FAIL); } - /* combine RHS vectors into output */ + /* combine RHS vectors into output */ if (step_mem->explicit_rhs && step_mem->implicit_rhs) { /* ImEx */ @@ -1488,12 +1502,24 @@ int mriStep_FullRHS(ARKodeMem ark_mem, sunrealtype t, N_Vector y, N_Vector f, { retval = step_mem->fse(t, y, step_mem->Fse[0], ark_mem->user_data); step_mem->nfse++; + step_mem->fse_is_current = SUNTRUE; if (retval != 0) { arkProcessError(ark_mem, ARK_RHSFUNC_FAIL, __LINE__, __func__, __FILE__, MSG_ARK_RHSFUNC_FAILED, t); return (ARK_RHSFUNC_FAIL); } + + /* Add external forcing, as appropriate */ + if (step_mem->expforcing) + { + step_mem->cvals[0] = ONE; + step_mem->Xvecs[0] = step_mem->Fse[0]; + nvec = 1; + mriStep_ApplyForcing(step_mem, t, ONE, &nvec); + N_VLinearCombination(nvec, step_mem->cvals, step_mem->Xvecs, + step_mem->Fse[0]); + } } /* compute the implicit component */ @@ -1501,32 +1527,24 @@ int mriStep_FullRHS(ARKodeMem ark_mem, sunrealtype t, N_Vector y, N_Vector f, { retval = step_mem->fsi(t, y, step_mem->Fsi[0], ark_mem->user_data); step_mem->nfsi++; + step_mem->fsi_is_current = SUNTRUE; if (retval != 0) { arkProcessError(ark_mem, ARK_RHSFUNC_FAIL, __LINE__, __func__, __FILE__, MSG_ARK_RHSFUNC_FAILED, t); return (ARK_RHSFUNC_FAIL); } - } - /* Add external forcing to Fse[0] or Fsi[0], as appropriate */ - if (step_mem->expforcing) - { - step_mem->cvals[0] = ONE; - step_mem->Xvecs[0] = step_mem->Fse[0]; - nvec = 1; - mriStep_ApplyForcing(step_mem, t, ONE, &nvec); - N_VLinearCombination(nvec, step_mem->cvals, step_mem->Xvecs, - step_mem->Fse[0]); - } - if (step_mem->impforcing) - { - step_mem->cvals[0] = ONE; - step_mem->Xvecs[0] = step_mem->Fsi[0]; - nvec = 1; - mriStep_ApplyForcing(step_mem, t, ONE, &nvec); - N_VLinearCombination(nvec, step_mem->cvals, step_mem->Xvecs, - step_mem->Fsi[0]); + /* Add external forcing, as appropriate */ + if (step_mem->impforcing) + { + step_mem->cvals[0] = ONE; + step_mem->Xvecs[0] = step_mem->Fsi[0]; + nvec = 1; + mriStep_ApplyForcing(step_mem, t, ONE, &nvec); + N_VLinearCombination(nvec, step_mem->cvals, step_mem->Xvecs, + step_mem->Fsi[0]); + } } } } @@ -1749,48 +1767,54 @@ int mriStep_TakeStepMRIGARK(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPt /* Evaluate the slow RHS functions if needed. NOTE: We do not use the full RHS function here since it does not need to check for FSAL or SA methods and thus avoids potentially unnecessary evaluations of the inner (fast) RHS function */ - if (!(ark_mem->fn_is_current)) + /* compute the explicit component */ + if (step_mem->explicit_rhs) { - /* compute the explicit component */ - if (step_mem->explicit_rhs) + if (!ark_mem->fn_is_current || !step_mem->fse_is_current) { retval = step_mem->fse(ark_mem->tn, ark_mem->yn, step_mem->Fse[0], ark_mem->user_data); step_mem->nfse++; + step_mem->fse_is_current = SUNTRUE; if (retval) { return ARK_RHSFUNC_FAIL; } + + /* Add external forcing, if appropriate */ + if (step_mem->expforcing) + { + step_mem->cvals[0] = ONE; + step_mem->Xvecs[0] = step_mem->Fse[0]; + nvec = 1; + mriStep_ApplyForcing(step_mem, ark_mem->tn, ONE, &nvec); + N_VLinearCombination(nvec, step_mem->cvals, step_mem->Xvecs, + step_mem->Fse[0]); + } } + } - /* compute the implicit component */ - if (step_mem->implicit_rhs) + /* compute the implicit component */ + if (step_mem->implicit_rhs) + { + if (!ark_mem->fn_is_current || !step_mem->fsi_is_current) { retval = step_mem->fsi(ark_mem->tn, ark_mem->yn, step_mem->Fsi[0], ark_mem->user_data); step_mem->nfsi++; + step_mem->fsi_is_current = SUNTRUE; if (retval) { return ARK_RHSFUNC_FAIL; } - } - /* Add external forcing to Fse[0] or Fsi[0], if appropriate */ - if (step_mem->expforcing) - { - step_mem->cvals[0] = ONE; - step_mem->Xvecs[0] = step_mem->Fse[0]; - nvec = 1; - mriStep_ApplyForcing(step_mem, ark_mem->tn, ONE, &nvec); - N_VLinearCombination(nvec, step_mem->cvals, step_mem->Xvecs, - step_mem->Fse[0]); - } - if (step_mem->impforcing) - { - step_mem->cvals[0] = ONE; - step_mem->Xvecs[0] = step_mem->Fsi[0]; - nvec = 1; - mriStep_ApplyForcing(step_mem, ark_mem->tn, ONE, &nvec); - N_VLinearCombination(nvec, step_mem->cvals, step_mem->Xvecs, - step_mem->Fsi[0]); + /* Add external forcing, if appropriate */ + if (step_mem->impforcing) + { + step_mem->cvals[0] = ONE; + step_mem->Xvecs[0] = step_mem->Fsi[0]; + nvec = 1; + mriStep_ApplyForcing(step_mem, ark_mem->tn, ONE, &nvec); + N_VLinearCombination(nvec, step_mem->cvals, step_mem->Xvecs, + step_mem->Fsi[0]); + } } - - ark_mem->fn_is_current = SUNTRUE; } + ark_mem->fn_is_current = SUNTRUE; #ifdef SUNDIALS_DEBUG printf(" MRIStep step %li, stage 0, h = %" RSYM ", t_n = %" RSYM "\n", @@ -2197,6 +2221,7 @@ int mriStep_TakeStepMRISR(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr) function here (unlike ERKStep and ARKStep) since it does not need to check for FSAL or SA methods and thus avoids potentially unnecessary evaluations of the inner (fast) RHS function */ + if (!(ark_mem->fn_is_current)) { /* compute the explicit component */ @@ -2205,7 +2230,19 @@ int mriStep_TakeStepMRISR(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr) retval = step_mem->fse(ark_mem->tn, ark_mem->yn, step_mem->Fse[0], ark_mem->user_data); step_mem->nfse++; + step_mem->fse_is_current = SUNTRUE; if (retval) { return ARK_RHSFUNC_FAIL; } + + /* Add external forcing, if applicable */ + if (step_mem->expforcing) + { + step_mem->cvals[0] = ONE; + step_mem->Xvecs[0] = step_mem->Fse[0]; + nvec = 1; + mriStep_ApplyForcing(step_mem, ark_mem->tn, ONE, &nvec); + N_VLinearCombination(nvec, step_mem->cvals, step_mem->Xvecs, + step_mem->Fse[0]); + } } /* compute the implicit component */ @@ -2214,27 +2251,19 @@ int mriStep_TakeStepMRISR(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr) retval = step_mem->fsi(ark_mem->tn, ark_mem->yn, step_mem->Fsi[0], ark_mem->user_data); step_mem->nfsi++; + step_mem->fsi_is_current = SUNTRUE; if (retval) { return ARK_RHSFUNC_FAIL; } - } - /* Add external forcing to Fse[0] or Fse[0], if applicable */ - if (step_mem->expforcing) - { - step_mem->cvals[0] = ONE; - step_mem->Xvecs[0] = step_mem->Fse[0]; - nvec = 1; - mriStep_ApplyForcing(step_mem, ark_mem->tn, ONE, &nvec); - N_VLinearCombination(nvec, step_mem->cvals, step_mem->Xvecs, - step_mem->Fse[0]); - } - if (step_mem->impforcing) - { - step_mem->cvals[0] = ONE; - step_mem->Xvecs[0] = step_mem->Fsi[0]; - nvec = 1; - mriStep_ApplyForcing(step_mem, ark_mem->tn, ONE, &nvec); - N_VLinearCombination(nvec, step_mem->cvals, step_mem->Xvecs, - step_mem->Fsi[0]); + /* Add external forcing, if applicable */ + if (step_mem->impforcing) + { + step_mem->cvals[0] = ONE; + step_mem->Xvecs[0] = step_mem->Fsi[0]; + nvec = 1; + mriStep_ApplyForcing(step_mem, ark_mem->tn, ONE, &nvec); + N_VLinearCombination(nvec, step_mem->cvals, step_mem->Xvecs, + step_mem->Fsi[0]); + } } /* combine both RHS into Fse for ImEx problems */ @@ -2665,11 +2694,12 @@ int mriStep_TakeStepMERK(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr) (unlike ERKStep and ARKStep) since it does not need to check for FSAL or SA methods and thus avoids potentially unnecessary evaluations of the inner (fast) RHS function */ - if (!(ark_mem->fn_is_current)) + if (!ark_mem->fn_is_current) { retval = step_mem->fse(t0, ark_mem->yn, step_mem->Fse[0], ark_mem->user_data); step_mem->nfse++; if (retval) { return ARK_RHSFUNC_FAIL; } + step_mem->fse_is_current = SUNTRUE; ark_mem->fn_is_current = SUNTRUE; /* Add external forcing to Fse[0], if applicable */ @@ -3984,12 +4014,24 @@ int mriStep_SlowRHS(ARKodeMem ark_mem, sunrealtype t, N_Vector y, N_Vector f, { retval = step_mem->fse(t, y, step_mem->Fse[0], ark_mem->user_data); step_mem->nfse++; + step_mem->fse_is_current = SUNTRUE; if (retval != 0) { arkProcessError(ark_mem, ARK_RHSFUNC_FAIL, __LINE__, __func__, __FILE__, MSG_ARK_RHSFUNC_FAILED, t); return (ARK_RHSFUNC_FAIL); } + + /* Add external forcing, if applicable */ + if (step_mem->expforcing) + { + step_mem->cvals[0] = ONE; + step_mem->Xvecs[0] = step_mem->Fse[0]; + nvec = 1; + mriStep_ApplyForcing(step_mem, t, ONE, &nvec); + N_VLinearCombination(nvec, step_mem->cvals, step_mem->Xvecs, + step_mem->Fse[0]); + } } /* call fsi if the problem has an implicit component */ @@ -3997,32 +4039,24 @@ int mriStep_SlowRHS(ARKodeMem ark_mem, sunrealtype t, N_Vector y, N_Vector f, { retval = step_mem->fsi(t, y, step_mem->Fsi[0], ark_mem->user_data); step_mem->nfsi++; + step_mem->fsi_is_current = SUNTRUE; if (retval != 0) { arkProcessError(ark_mem, ARK_RHSFUNC_FAIL, __LINE__, __func__, __FILE__, MSG_ARK_RHSFUNC_FAILED, t); return (ARK_RHSFUNC_FAIL); } - } - /* Add external forcing to Fse[0] or Fsi[0], if applicable */ - if (step_mem->expforcing) - { - step_mem->cvals[0] = ONE; - step_mem->Xvecs[0] = step_mem->Fse[0]; - nvec = 1; - mriStep_ApplyForcing(step_mem, t, ONE, &nvec); - N_VLinearCombination(nvec, step_mem->cvals, step_mem->Xvecs, - step_mem->Fse[0]); - } - if (step_mem->impforcing) - { - step_mem->cvals[0] = ONE; - step_mem->Xvecs[0] = step_mem->Fsi[0]; - nvec = 1; - mriStep_ApplyForcing(step_mem, t, ONE, &nvec); - N_VLinearCombination(nvec, step_mem->cvals, step_mem->Xvecs, - step_mem->Fsi[0]); + /* Add external forcing, if applicable */ + if (step_mem->impforcing) + { + step_mem->cvals[0] = ONE; + step_mem->Xvecs[0] = step_mem->Fsi[0]; + nvec = 1; + mriStep_ApplyForcing(step_mem, t, ONE, &nvec); + N_VLinearCombination(nvec, step_mem->cvals, step_mem->Xvecs, + step_mem->Fsi[0]); + } } /* combine RHS vectors into output */ @@ -4669,26 +4703,25 @@ int mriStep_SetInnerForcing(ARKodeMem ark_mem, sunrealtype tshift, if (nvecs > 0) { - /* enable forcing */ + /* enable forcing, and signal that the corresponding pre-existing RHS + vector is no longer current, since it has a stale forcing function */ if (step_mem->explicit_rhs) { step_mem->expforcing = SUNTRUE; step_mem->impforcing = SUNFALSE; + step_mem->fse_is_current = SUNFALSE; } else { step_mem->expforcing = SUNFALSE; step_mem->impforcing = SUNTRUE; + step_mem->fsi_is_current = SUNFALSE; } step_mem->tshift = tshift; step_mem->tscale = tscale; step_mem->forcing = forcing; step_mem->nforcing = nvecs; - /* Signal that any pre-existing RHS vector is no longer current, since it - has a stale forcing function */ - ark_mem->fn_is_current = SUNFALSE; - /* If cvals and Xvecs are not allocated then mriStep_Init has not been called and the number of stages has not been set yet. These arrays will be allocated in mriStep_Init and take into account the value of nforcing. diff --git a/src/arkode/arkode_mristep_impl.h b/src/arkode/arkode_mristep_impl.h index d39e53631e..e5f71e860d 100644 --- a/src/arkode/arkode_mristep_impl.h +++ b/src/arkode/arkode_mristep_impl.h @@ -75,7 +75,9 @@ typedef struct ARKodeMRIStepMemRec /* Outer RK method storage and parameters */ N_Vector* Fse; /* explicit RHS at each stage */ N_Vector* Fsi; /* implicit RHS at each stage */ - sunbooleantype unify_Fs; /* Fse and Fsi point at the same memory */ + sunbooleantype unify_Fs; /* Fse and Fsi point at the same memory */ + sunbooleantype fse_is_current; + sunbooleantype fsi_is_current; MRIStepCoupling MRIC; /* slow->fast coupling table */ int q; /* method order */ int p; /* embedding order */ @@ -145,7 +147,7 @@ typedef struct ARKodeMRIStepMemRec long int nls_fails; /* num nonlinear solver fails */ int nfusedopvecs; /* length of cvals and Xvecs arrays */ - /* Data for using ERKStep with external polynomial forcing */ + /* Data for using MRIStep with external polynomial forcing */ sunbooleantype expforcing; /* add forcing to explicit RHS */ sunbooleantype impforcing; /* add forcing to implicit RHS */ sunrealtype tshift; /* time normalization shift */ From bacd4d88d350c4fb4dae150eab61ed85691fe132 Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Wed, 30 Oct 2024 17:11:23 -0500 Subject: [PATCH 210/286] Adjusted structure of mriStep_TakeStepMRIGARK to perform embedded stage before final solution (as per PR request) --- .../arkode/CXX_serial/ark_kpr_nestedmri.out | 52 ++--- src/arkode/arkode_mristep.c | 180 ++++++++++++------ 2 files changed, 148 insertions(+), 84 deletions(-) diff --git a/examples/arkode/CXX_serial/ark_kpr_nestedmri.out b/examples/arkode/CXX_serial/ark_kpr_nestedmri.out index 3266fbb806..355b43d35d 100644 --- a/examples/arkode/CXX_serial/ark_kpr_nestedmri.out +++ b/examples/arkode/CXX_serial/ark_kpr_nestedmri.out @@ -20,32 +20,32 @@ Adaptive nested multirate nonlinear Kvaerno-Prothero-Robinson test problem: t u v w uerr verr werr ---------------------------------------------------------------------------- 0.000000 1.581139 1.732051 1.732051 0.00e+00 0.00e+00 0.00e+00 - 0.271582 1.575296 1.368971 1.648718 1.09e-05 1.20e-04 5.83e-05 - 0.617473 1.551202 1.168347 1.006336 4.55e-04 3.77e-04 3.17e-04 - 0.844568 1.526410 1.001343 1.370195 6.30e-04 2.76e-05 1.67e-04 - 1.055010 1.498331 1.580272 1.237958 4.31e-04 3.89e-06 1.31e-04 - 1.442729 1.436320 1.672339 1.573390 2.18e-04 2.55e-05 1.27e-04 - 1.636588 1.402356 1.038742 1.211055 1.10e-04 2.03e-04 1.45e-04 - 1.823369 1.369205 1.051418 1.514343 4.93e-05 9.62e-05 1.80e-04 - 2.149511 1.313959 1.579270 1.556854 4.00e-05 4.69e-05 2.62e-04 - 2.404891 1.276887 1.124406 1.126849 3.60e-04 1.03e-04 5.45e-04 - 2.608190 1.252993 1.682786 1.600337 2.28e-04 1.05e-04 3.41e-04 - 2.811489 1.235928 1.719503 1.397056 2.51e-04 3.97e-05 4.08e-04 - 3.014788 1.226738 1.030877 1.574038 4.02e-04 1.00e-04 2.15e-04 - 3.413391 1.232704 1.604116 1.712849 4.90e-04 4.92e-05 1.65e-05 - 3.599447 1.245912 1.625915 1.725917 2.94e-04 1.26e-05 2.48e-05 - 3.785502 1.265227 1.152518 1.652681 2.57e-04 9.10e-05 1.44e-04 - 4.157612 1.317986 1.091120 1.101285 1.64e-04 9.70e-05 2.34e-04 - 4.343667 1.349100 1.318672 1.053462 1.07e-04 5.19e-06 1.49e-04 - 4.529723 1.381861 1.668675 1.698826 1.44e-04 7.79e-05 6.19e-05 - 4.880130 1.443414 1.599766 1.152755 3.66e-06 1.09e-04 8.97e-05 - 5.200430 1.493844 1.117407 1.002177 3.04e-02 3.89e-01 6.43e-01 + 0.306567 1.573663 1.057506 1.707888 6.57e-05 1.14e-05 6.66e-05 + 0.679173 1.545173 1.190170 1.007373 4.54e-04 1.92e-04 1.36e-04 + 0.898497 1.519773 1.357245 1.554645 4.76e-04 2.75e-05 1.79e-04 + 1.117820 1.488989 1.729585 1.161054 4.89e-04 6.14e-05 1.24e-04 + 1.337144 1.454037 0.999230 1.011387 4.37e-04 3.78e-04 1.56e-04 + 1.556467 1.416269 1.033661 1.136147 3.76e-04 1.76e-04 1.53e-04 + 1.775791 1.377419 1.045312 1.049355 2.46e-04 8.35e-05 3.18e-04 + 2.277112 1.294563 1.677791 1.277956 2.12e-04 9.38e-05 5.83e-04 + 2.492214 1.265827 1.094693 1.620888 2.52e-04 1.65e-05 3.87e-04 + 2.707315 1.243852 1.103429 1.727904 3.37e-04 1.60e-04 3.32e-04 + 2.922416 1.229985 1.543386 1.101349 4.05e-04 2.55e-05 4.51e-04 + 3.137517 1.225306 1.544485 1.144447 5.86e-04 4.32e-05 3.03e-04 + 3.333351 1.228952 1.730946 1.666254 4.60e-04 2.32e-05 8.09e-06 + 3.524276 1.239836 1.502950 1.007933 3.97e-04 2.62e-05 1.54e-05 + 3.906127 1.280639 1.681423 1.730832 3.32e-04 1.82e-05 1.44e-04 + 4.097053 1.308487 1.731560 1.040636 2.72e-04 2.71e-05 1.52e-04 + 4.287978 1.339687 1.289705 1.670830 2.29e-04 3.01e-05 9.21e-05 + 4.669829 1.406791 1.536669 1.124555 1.25e-04 3.16e-04 7.84e-05 + 4.964361 1.457698 1.001374 1.699997 7.52e-05 2.06e-04 4.93e-05 + 5.258893 1.502725 1.608602 1.573351 3.92e-02 1.02e-01 7.14e-02 ---------------------------------------------------------------------------- Final Solver Statistics: - Slow steps = 27 (attempts = 30, fails = 3) - Intermediate steps = 720 (attempts = 890, fails = 170) - Fast steps = 153065 (attempts = 170906, fails = 17841) - u error = 0.00584855, v error = 0.0749367, total error = 0.0835489 - Relative accuracy = 3906.73 - Total RHS evals: Fse = 148, Fsi = 0, Fme = 4281, Fmi = 0, Ff = 836691 + Slow steps = 25 (attempts = 29, fails = 4) + Intermediate steps = 769 (attempts = 975, fails = 206) + Fast steps = 193380 (attempts = 215494, fails = 22114) + u error = 0.00784081, v error = 0.0203181, total error = 0.0150336 + Relative accuracy = 674.105 + Total RHS evals: Fse = 142, Fsi = 0, Fme = 4670, Fmi = 0, Ff = 1055358 diff --git a/src/arkode/arkode_mristep.c b/src/arkode/arkode_mristep.c index 1bd75234f8..4e2cd7ee25 100644 --- a/src/arkode/arkode_mristep.c +++ b/src/arkode/arkode_mristep.c @@ -1697,6 +1697,7 @@ int mriStep_TakeStepMRIGARK(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPt sunbooleantype calc_fslow; sunbooleantype need_inner_dsm; sunbooleantype do_embedding; + sunbooleantype force_reset = (*nflagPtr == PREV_ERR_FAIL); int nvec; /* access the MRIStep mem structure */ @@ -1738,9 +1739,9 @@ int mriStep_TakeStepMRIGARK(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPt } } - /* if any temporal adaptivity is enabled: reset the inner integrator + /* if the previous step was rejected, reset the inner integrator to the beginning of this step (in case of recomputation) */ - if (!ark_mem->fixedstep) + if (force_reset) { retval = mriStepInnerStepper_Reset(step_mem->stepper, ark_mem->tn, ark_mem->yn); @@ -1843,8 +1844,8 @@ int mriStep_TakeStepMRIGARK(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPt /* The first stage is the previous time-step solution, so its RHS is the [already-computed] slow RHS from the start of the step */ - /* Loop over remaining stages */ - for (is = 1; is < step_mem->stages; is++) + /* Loop over remaining internal stages */ + for (is = 1; is < step_mem->stages-1; is++) { /* Set relevant stage times (including desired stage time for implicit solves) */ t0 = ark_mem->tn + step_mem->MRIC->c[is - 1] * ark_mem->h; @@ -1917,18 +1918,13 @@ int mriStep_TakeStepMRIGARK(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPt } /* Compute updated slow RHS, except: - 1. at last stage which is the new solution, since that RHS occurs in arkCompleteStep. - 2. if the stage is excluded from stage_map + 1. if the stage is excluded from stage_map 3. if the next stage has "STIFF_ACC" type, and temporal estimation is disabled */ calc_fslow = SUNTRUE; - if (is == step_mem->stages - 1) { calc_fslow = SUNFALSE; } if (step_mem->stage_map[is] == -1) { calc_fslow = SUNFALSE; } - if (is < step_mem->stages - 1) + if (!do_embedding && (step_mem->stagetypes[is + 1] == MRISTAGE_STIFF_ACC)) { - if (!do_embedding && (step_mem->stagetypes[is + 1] == MRISTAGE_STIFF_ACC)) - { - calc_fslow = SUNFALSE; - } + calc_fslow = SUNFALSE; } if (calc_fslow) { @@ -2002,40 +1998,28 @@ int mriStep_TakeStepMRIGARK(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPt ARK_LOGGER->debug_fp); #endif } - - /* if this is the next-to-last internal stage, and if temporal error estimation - is enabled, save ycur into ark_mem->tempv4 (needed for embedding) */ - if ((is == step_mem->stages - 2) && do_embedding) - { - N_VScale(ONE, ark_mem->ycur, ark_mem->tempv4); - } - } /* compute slow RHS */ } /* loop over stages */ -#ifdef SUNDIALS_LOGGING_EXTRA_DEBUG - SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, "ARKODE::mriStep_TakeStep", - "updated solution", "ycur(:) =", ""); - N_VPrintFile(ark_mem->ycur, ARK_LOGGER->debug_fp); -#endif - - /* perform embedded stage (if needed) to compute error and store in dsmPtr */ + /* perform embedded stage (if needed) */ if (do_embedding) { - /* Temporarily swap ark_mem->ycur and ark_mem->tempv4 pointers, so that - during this embedding "stage": - - ark_mem->ycur starts out as what it was for the last internal stage, - and ends up as the embedded solution. - - ark_mem->tempv4 archives the current time step solution vector. */ + is = step_mem->stages; + + /* Temporarily swap ark_mem->ycur and ark_mem->tempv4 pointers, copying + data so that both hold the current ark_mem->ycur value. This ensures + that during this embedding "stage": + - ark_mem->ycur will be the correct initial condition for the final stage. + - ark_mem->tempv4 will hold the embeded solution vector. */ + N_VScale(ONE, ark_mem->ycur, ark_mem->tempv4); tmp = ark_mem->ycur; ark_mem->ycur = ark_mem->tempv4; ark_mem->tempv4 = tmp; /* Reset ark_mem->tcur as the time value corresponding with the end of the step */ /* Set relevant stage times (including desired stage time for implicit solves) */ - t0 = ark_mem->tn + step_mem->MRIC->c[step_mem->stages - 2] * ark_mem->h; - tf = ark_mem->tcur = ark_mem->tn + - step_mem->MRIC->c[step_mem->stages - 1] * ark_mem->h; + t0 = ark_mem->tn + step_mem->MRIC->c[is-2] * ark_mem->h; + tf = ark_mem->tcur = ark_mem->tn + ark_mem->h; /* Solver diagnostics reporting */ #if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_DEBUG @@ -2043,41 +2027,30 @@ int mriStep_TakeStepMRIGARK(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPt "ARKODE::mriStep_TakeStep", "embedding-stage", "step = %li, stage = %i, stage type = %d, h = %" RSYM ", tcur = %" RSYM, - ark_mem->nst, step_mem->stages, - step_mem->stagetypes[step_mem->stages], ark_mem->h, + ark_mem->nst, is, step_mem->stagetypes[is], ark_mem->h, ark_mem->tcur); #endif /* Determine embedding stage type, and call corresponding routine; the vector ark_mem->ycur stores the previous stage solution on input, and should store the result of this stage solution on output. */ - switch (step_mem->stagetypes[step_mem->stages]) + switch (step_mem->stagetypes[is]) { case (MRISTAGE_ERK_FAST): - retval = mriStep_ComputeInnerForcing(ark_mem, step_mem, step_mem->stages, - t0, tf); + retval = mriStep_ComputeInnerForcing(ark_mem, step_mem, is, t0, tf); if (retval != ARK_SUCCESS) { return retval; } - retval = mriStepInnerStepper_Reset(step_mem->stepper, t0, ark_mem->ycur); - if (retval != ARK_SUCCESS) - { - arkProcessError(ark_mem, ARK_INNERSTEP_FAIL, __LINE__, __func__, - __FILE__, "Unable to reset the inner stepper"); - return (ARK_INNERSTEP_FAIL); - } retval = mriStep_StageERKFast(ark_mem, step_mem, t0, tf, ark_mem->ycur, ark_mem->tempv2, SUNFALSE); if (retval != ARK_SUCCESS) { *nflagPtr = CONV_FAIL; } break; case (MRISTAGE_ERK_NOFAST): - retval = mriStep_StageERKNoFast(ark_mem, step_mem, step_mem->stages); + retval = mriStep_StageERKNoFast(ark_mem, step_mem, is); break; case (MRISTAGE_DIRK_NOFAST): - retval = mriStep_StageDIRKNoFast(ark_mem, step_mem, step_mem->stages, - nflagPtr); + retval = mriStep_StageDIRKNoFast(ark_mem, step_mem, is, nflagPtr); break; case (MRISTAGE_DIRK_FAST): - retval = mriStep_StageDIRKFast(ark_mem, step_mem, step_mem->stages, - nflagPtr); + retval = mriStep_StageDIRKFast(ark_mem, step_mem, is, nflagPtr); break; } if (retval != ARK_SUCCESS) { return (retval); } @@ -2088,18 +2061,109 @@ int mriStep_TakeStepMRIGARK(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPt N_VPrintFile(ark_mem->ycur, ARK_LOGGER->debug_fp); #endif - /* Compute temporal error estimate via difference between step - solution and embedding, store in ark_mem->tempv1, and take norm. */ - N_VLinearSum(ONE, ark_mem->tempv4, -ONE, ark_mem->ycur, ark_mem->tempv1); - *dsmPtr = N_VWrmsNorm(ark_mem->tempv1, ark_mem->ewt); - - /* Swap back ark_mem->ycur with ark_mem->tempv4. */ + /* Swap back ark_mem->ycur with ark_mem->tempv4, and reset the inner integrator */ tmp = ark_mem->ycur; ark_mem->ycur = ark_mem->tempv4; ark_mem->tempv4 = tmp; + retval = mriStepInnerStepper_Reset(step_mem->stepper, t0, ark_mem->ycur); + if (retval != ARK_SUCCESS) + { + arkProcessError(ark_mem, ARK_INNERSTEP_FAIL, __LINE__, __func__, + __FILE__, "Unable to reset the inner stepper"); + return (ARK_INNERSTEP_FAIL); + } } + /* Compute final stage (for evolved solution), along with error estimate */ + { + is = step_mem->stages-1; + + /* Set relevant stage times (including desired stage time for implicit solves) */ + t0 = ark_mem->tn + step_mem->MRIC->c[is - 1] * ark_mem->h; + tf = ark_mem->tcur = ark_mem->tn + ark_mem->h; + + /* Solver diagnostics reporting */ +#if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_DEBUG + SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, + "ARKODE::mriStep_TakeStep", "start-stage", + "step = %li, stage = %i, stage type = %d, h = %" RSYM + ", tcur = %" RSYM, + ark_mem->nst, is, step_mem->stagetypes[is], ark_mem->h, + ark_mem->tcur); +#endif + + /* Determine final stage type, and call corresponding routine; the + vector ark_mem->ycur stores the previous stage solution on input, and + should store the result of this stage solution on output. */ + switch (step_mem->stagetypes[is]) + { + case (MRISTAGE_ERK_FAST): + retval = mriStep_ComputeInnerForcing(ark_mem, step_mem, is, t0, tf); + if (retval != ARK_SUCCESS) { return retval; } + retval = mriStep_StageERKFast(ark_mem, step_mem, t0, tf, ark_mem->ycur, + ark_mem->tempv2, need_inner_dsm); + if (retval != ARK_SUCCESS) { *nflagPtr = CONV_FAIL; } + break; + case (MRISTAGE_ERK_NOFAST): + retval = mriStep_StageERKNoFast(ark_mem, step_mem, is); + break; + case (MRISTAGE_DIRK_NOFAST): + retval = mriStep_StageDIRKNoFast(ark_mem, step_mem, is, nflagPtr); + break; + case (MRISTAGE_DIRK_FAST): + retval = mriStep_StageDIRKFast(ark_mem, step_mem, is, nflagPtr); + break; + case (MRISTAGE_STIFF_ACC): retval = ARK_SUCCESS; break; + } + if (retval != ARK_SUCCESS) { return (retval); } + +#ifdef SUNDIALS_LOGGING_EXTRA_DEBUG + SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, + "ARKODE::mriStep_TakeStep", "slow stage", "z_%i(:) =", is); + N_VPrintFile(ark_mem->ycur, ARK_LOGGER->debug_fp); +#endif + + /* apply user-supplied stage postprocessing function (if supplied) */ + if ((ark_mem->ProcessStage != NULL) && + (step_mem->stagetypes[is] != MRISTAGE_STIFF_ACC)) + { + retval = ark_mem->ProcessStage(ark_mem->tcur, ark_mem->ycur, + ark_mem->user_data); + if (retval != 0) { return (ARK_POSTPROCESS_STAGE_FAIL); } + } + + /* conditionally reset the inner integrator with the modified stage solution */ + if (step_mem->stagetypes[is] != MRISTAGE_STIFF_ACC) + { + if ((step_mem->stagetypes[is] != MRISTAGE_ERK_FAST) || + (ark_mem->ProcessStage != NULL)) + { + retval = mriStepInnerStepper_Reset(step_mem->stepper, tf, ark_mem->ycur); + if (retval != ARK_SUCCESS) + { + arkProcessError(ark_mem, ARK_INNERSTEP_FAIL, __LINE__, __func__, + __FILE__, "Unable to reset the inner stepper"); + return (ARK_INNERSTEP_FAIL); + } + } + } + + /* Compute temporal error estimate via difference between step + solution and embedding, store in ark_mem->tempv1, and take norm. */ + if (do_embedding) + { + N_VLinearSum(ONE, ark_mem->tempv4, -ONE, ark_mem->ycur, ark_mem->tempv1); + *dsmPtr = N_VWrmsNorm(ark_mem->tempv1, ark_mem->ewt); + } + + } /* loop over stages */ + /* Solver diagnostics reporting */ +#ifdef SUNDIALS_LOGGING_EXTRA_DEBUG + SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, "ARKODE::mriStep_TakeStep", + "updated solution", "ycur(:) =", ""); + N_VPrintFile(ark_mem->ycur, ARK_LOGGER->debug_fp); +#endif #if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_DEBUG SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, "ARKODE::mriStep_TakeStep", "error-test", "step = %li, h = %" RSYM ", dsm = %" RSYM, From 9147566b8f5c8281ce6204c2dca48c6ca07adbb0 Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Wed, 30 Oct 2024 17:15:19 -0500 Subject: [PATCH 211/286] formatting --- src/arkode/arkode_mristep.c | 48 ++++++++++++++++---------------- src/arkode/arkode_mristep_impl.h | 20 ++++++------- 2 files changed, 34 insertions(+), 34 deletions(-) diff --git a/src/arkode/arkode_mristep.c b/src/arkode/arkode_mristep.c index 4e2cd7ee25..8fa6ec0847 100644 --- a/src/arkode/arkode_mristep.c +++ b/src/arkode/arkode_mristep.c @@ -160,8 +160,8 @@ void* MRIStepCreate(ARKRhsFn fse, ARKRhsFn fsi, sunrealtype t0, N_Vector y0, be allocated later on (based on the MRI method) */ /* Copy the slow RHS functions into stepper memory */ - step_mem->fse = fse; - step_mem->fsi = fsi; + step_mem->fse = fse; + step_mem->fsi = fsi; step_mem->fse_is_current = SUNFALSE; step_mem->fsi_is_current = SUNFALSE; @@ -346,8 +346,8 @@ int MRIStepReInit(void* arkode_mem, ARKRhsFn fse, ARKRhsFn fsi, sunrealtype t0, } /* Copy the input parameters into ARKODE state */ - step_mem->fse = fse; - step_mem->fsi = fsi; + step_mem->fse = fse; + step_mem->fsi = fsi; step_mem->fse_is_current = SUNFALSE; step_mem->fsi_is_current = SUNFALSE; @@ -1425,7 +1425,7 @@ int mriStep_FullRHS(ARKodeMem ark_mem, sunrealtype t, N_Vector y, N_Vector f, nvec = 1; mriStep_ApplyForcing(step_mem, t, ONE, &nvec); N_VLinearCombination(nvec, step_mem->cvals, step_mem->Xvecs, - step_mem->Fsi[0]); + step_mem->Fsi[0]); } } } @@ -1518,7 +1518,7 @@ int mriStep_FullRHS(ARKodeMem ark_mem, sunrealtype t, N_Vector y, N_Vector f, nvec = 1; mriStep_ApplyForcing(step_mem, t, ONE, &nvec); N_VLinearCombination(nvec, step_mem->cvals, step_mem->Xvecs, - step_mem->Fse[0]); + step_mem->Fse[0]); } } @@ -1543,7 +1543,7 @@ int mriStep_FullRHS(ARKodeMem ark_mem, sunrealtype t, N_Vector y, N_Vector f, nvec = 1; mriStep_ApplyForcing(step_mem, t, ONE, &nvec); N_VLinearCombination(nvec, step_mem->cvals, step_mem->Xvecs, - step_mem->Fsi[0]); + step_mem->Fsi[0]); } } } @@ -1787,7 +1787,7 @@ int mriStep_TakeStepMRIGARK(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPt nvec = 1; mriStep_ApplyForcing(step_mem, ark_mem->tn, ONE, &nvec); N_VLinearCombination(nvec, step_mem->cvals, step_mem->Xvecs, - step_mem->Fse[0]); + step_mem->Fse[0]); } } } @@ -1811,7 +1811,7 @@ int mriStep_TakeStepMRIGARK(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPt nvec = 1; mriStep_ApplyForcing(step_mem, ark_mem->tn, ONE, &nvec); N_VLinearCombination(nvec, step_mem->cvals, step_mem->Xvecs, - step_mem->Fsi[0]); + step_mem->Fsi[0]); } } } @@ -1845,7 +1845,7 @@ int mriStep_TakeStepMRIGARK(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPt is the [already-computed] slow RHS from the start of the step */ /* Loop over remaining internal stages */ - for (is = 1; is < step_mem->stages-1; is++) + for (is = 1; is < step_mem->stages - 1; is++) { /* Set relevant stage times (including desired stage time for implicit solves) */ t0 = ark_mem->tn + step_mem->MRIC->c[is - 1] * ark_mem->h; @@ -2018,7 +2018,7 @@ int mriStep_TakeStepMRIGARK(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPt /* Reset ark_mem->tcur as the time value corresponding with the end of the step */ /* Set relevant stage times (including desired stage time for implicit solves) */ - t0 = ark_mem->tn + step_mem->MRIC->c[is-2] * ark_mem->h; + t0 = ark_mem->tn + step_mem->MRIC->c[is - 2] * ark_mem->h; tf = ark_mem->tcur = ark_mem->tn + ark_mem->h; /* Solver diagnostics reporting */ @@ -2068,15 +2068,15 @@ int mriStep_TakeStepMRIGARK(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPt retval = mriStepInnerStepper_Reset(step_mem->stepper, t0, ark_mem->ycur); if (retval != ARK_SUCCESS) { - arkProcessError(ark_mem, ARK_INNERSTEP_FAIL, __LINE__, __func__, - __FILE__, "Unable to reset the inner stepper"); + arkProcessError(ark_mem, ARK_INNERSTEP_FAIL, __LINE__, __func__, __FILE__, + "Unable to reset the inner stepper"); return (ARK_INNERSTEP_FAIL); } } /* Compute final stage (for evolved solution), along with error estimate */ { - is = step_mem->stages-1; + is = step_mem->stages - 1; /* Set relevant stage times (including desired stage time for implicit solves) */ t0 = ark_mem->tn + step_mem->MRIC->c[is - 1] * ark_mem->h; @@ -2156,7 +2156,7 @@ int mriStep_TakeStepMRIGARK(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPt *dsmPtr = N_VWrmsNorm(ark_mem->tempv1, ark_mem->ewt); } - } /* loop over stages */ + } /* loop over stages */ /* Solver diagnostics reporting */ #ifdef SUNDIALS_LOGGING_EXTRA_DEBUG @@ -2285,7 +2285,7 @@ int mriStep_TakeStepMRISR(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr) function here (unlike ERKStep and ARKStep) since it does not need to check for FSAL or SA methods and thus avoids potentially unnecessary evaluations of the inner (fast) RHS function */ - + if (!(ark_mem->fn_is_current)) { /* compute the explicit component */ @@ -2305,7 +2305,7 @@ int mriStep_TakeStepMRISR(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr) nvec = 1; mriStep_ApplyForcing(step_mem, ark_mem->tn, ONE, &nvec); N_VLinearCombination(nvec, step_mem->cvals, step_mem->Xvecs, - step_mem->Fse[0]); + step_mem->Fse[0]); } } @@ -2326,7 +2326,7 @@ int mriStep_TakeStepMRISR(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr) nvec = 1; mriStep_ApplyForcing(step_mem, ark_mem->tn, ONE, &nvec); N_VLinearCombination(nvec, step_mem->cvals, step_mem->Xvecs, - step_mem->Fsi[0]); + step_mem->Fsi[0]); } } @@ -2764,7 +2764,7 @@ int mriStep_TakeStepMERK(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr) step_mem->nfse++; if (retval) { return ARK_RHSFUNC_FAIL; } step_mem->fse_is_current = SUNTRUE; - ark_mem->fn_is_current = SUNTRUE; + ark_mem->fn_is_current = SUNTRUE; /* Add external forcing to Fse[0], if applicable */ if (step_mem->expforcing) @@ -4119,7 +4119,7 @@ int mriStep_SlowRHS(ARKodeMem ark_mem, sunrealtype t, N_Vector y, N_Vector f, nvec = 1; mriStep_ApplyForcing(step_mem, t, ONE, &nvec); N_VLinearCombination(nvec, step_mem->cvals, step_mem->Xvecs, - step_mem->Fsi[0]); + step_mem->Fsi[0]); } } @@ -4771,14 +4771,14 @@ int mriStep_SetInnerForcing(ARKodeMem ark_mem, sunrealtype tshift, vector is no longer current, since it has a stale forcing function */ if (step_mem->explicit_rhs) { - step_mem->expforcing = SUNTRUE; - step_mem->impforcing = SUNFALSE; + step_mem->expforcing = SUNTRUE; + step_mem->impforcing = SUNFALSE; step_mem->fse_is_current = SUNFALSE; } else { - step_mem->expforcing = SUNFALSE; - step_mem->impforcing = SUNTRUE; + step_mem->expforcing = SUNFALSE; + step_mem->impforcing = SUNTRUE; step_mem->fsi_is_current = SUNFALSE; } step_mem->tshift = tshift; diff --git a/src/arkode/arkode_mristep_impl.h b/src/arkode/arkode_mristep_impl.h index e5f71e860d..8b4a7d5ac5 100644 --- a/src/arkode/arkode_mristep_impl.h +++ b/src/arkode/arkode_mristep_impl.h @@ -78,16 +78,16 @@ typedef struct ARKodeMRIStepMemRec sunbooleantype unify_Fs; /* Fse and Fsi point at the same memory */ sunbooleantype fse_is_current; sunbooleantype fsi_is_current; - MRIStepCoupling MRIC; /* slow->fast coupling table */ - int q; /* method order */ - int p; /* embedding order */ - int stages; /* total number of stages */ - int nstages_active; /* number of active stage RHS vectors */ - int nstages_allocated; /* number of stage RHS vectors allocated */ - int* stage_map; /* index map for storing stage RHS vectors */ - int* stagetypes; /* type flags for stages */ - sunrealtype* Ae_row; /* equivalent explicit RK coeffs */ - sunrealtype* Ai_row; /* equivalent implicit RK coeffs */ + MRIStepCoupling MRIC; /* slow->fast coupling table */ + int q; /* method order */ + int p; /* embedding order */ + int stages; /* total number of stages */ + int nstages_active; /* number of active stage RHS vectors */ + int nstages_allocated; /* number of stage RHS vectors allocated */ + int* stage_map; /* index map for storing stage RHS vectors */ + int* stagetypes; /* type flags for stages */ + sunrealtype* Ae_row; /* equivalent explicit RK coeffs */ + sunrealtype* Ai_row; /* equivalent implicit RK coeffs */ /* Algebraic solver data and parameters */ N_Vector sdata; /* old stage data in residual */ From f16198ca6c84c24e3e463cb91baf9834d3b29ba6 Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Wed, 30 Oct 2024 17:29:09 -0500 Subject: [PATCH 212/286] Updated mriStep_TakeStepMRISR and mriStep_TakeStepMERK to eliminate inner stepper reset calls on the first stage that follows a successful step (as per PR request). --- .../C_serial/ark_kpr_mri_12_3_0.005.out | 102 +++++++++--------- src/arkode/arkode_mristep.c | 45 ++++---- 2 files changed, 77 insertions(+), 70 deletions(-) diff --git a/examples/arkode/C_serial/ark_kpr_mri_12_3_0.005.out b/examples/arkode/C_serial/ark_kpr_mri_12_3_0.005.out index 9004de672b..f3b4cf92dc 100644 --- a/examples/arkode/C_serial/ark_kpr_mri_12_3_0.005.out +++ b/examples/arkode/C_serial/ark_kpr_mri_12_3_0.005.out @@ -12,61 +12,61 @@ Multirate nonlinear Kvaerno-Prothero-Robinson test problem: t u v uerr verr ------------------------------------------------------ 0.000000 1.224745 1.732051 0.00e+00 0.00e+00 - 0.100000 1.223725 1.077464 2.84e-08 3.07e-09 - 0.200000 1.220669 1.551800 2.84e-08 5.68e-09 - 0.300000 1.215594 1.467737 2.92e-08 8.00e-09 - 0.400000 1.208524 1.154583 2.94e-08 1.01e-08 - 0.500000 1.199496 1.721908 2.86e-08 1.18e-08 - 0.600000 1.188557 1.023517 2.66e-08 1.34e-08 - 0.700000 1.175764 1.622750 2.55e-08 1.47e-08 - 0.800000 1.161186 1.374632 2.74e-08 1.57e-08 - 0.900000 1.144904 1.245763 2.77e-08 1.65e-08 - 1.000000 1.127010 1.691839 2.65e-08 1.71e-08 - 1.100000 1.107609 1.000489 2.19e-08 1.75e-08 - 1.200000 1.086821 1.677552 1.79e-08 1.76e-08 - 1.300000 1.064777 1.277775 1.99e-08 1.76e-08 - 1.400000 1.041625 1.342455 2.04e-08 1.73e-08 - 1.500000 1.017531 1.642940 1.99e-08 1.67e-08 - 1.600000 0.992673 1.012112 1.36e-08 1.60e-08 - 1.700000 0.967253 1.714058 6.17e-09 1.50e-08 - 1.800000 0.941488 1.183867 5.03e-09 1.38e-08 - 1.900000 0.915617 1.437465 4.85e-09 1.24e-08 - 2.000000 0.889903 1.577082 5.33e-09 1.06e-08 - 2.100000 0.864625 1.056467 1.38e-09 8.64e-09 - 2.200000 0.840089 1.730920 1.11e-08 6.36e-09 - 2.300000 0.816616 1.101047 1.77e-08 3.89e-09 - 2.400000 0.794546 1.525051 2.04e-08 1.22e-09 - 2.500000 0.774227 1.496993 1.96e-08 1.74e-09 - 2.600000 0.756013 1.126857 2.53e-08 4.94e-09 - 2.700000 0.740246 1.727536 3.36e-08 8.35e-09 - 2.800000 0.727247 1.038393 4.17e-08 1.18e-08 - 2.900000 0.717301 1.600759 4.50e-08 1.53e-08 - 3.000000 0.710636 1.406380 4.43e-08 1.88e-08 - 3.100000 0.707412 1.214353 4.62e-08 2.20e-08 - 3.200000 0.707709 1.704026 4.79e-08 2.50e-08 - 3.300000 0.711520 1.004391 4.75e-08 2.76e-08 - 3.400000 0.718749 1.661225 4.48e-08 2.98e-08 - 3.500000 0.729227 1.310102 1.02e-07 3.08e-08 - 3.600000 0.742712 1.310080 4.22e-08 3.17e-08 - 3.700000 0.758914 1.661237 4.00e-08 3.23e-08 - 3.800000 0.777506 1.004387 3.22e-08 3.23e-08 - 3.900000 0.798144 1.704019 2.37e-08 3.17e-08 - 4.000000 0.820474 1.214374 2.24e-08 3.08e-08 - 4.100000 0.844149 1.406358 2.13e-08 2.95e-08 - 4.200000 0.868832 1.600774 2.06e-08 2.78e-08 - 4.300000 0.894204 1.038382 1.34e-08 2.58e-08 - 4.400000 0.919964 1.727533 4.37e-09 2.35e-08 - 4.500000 0.945834 1.126875 4.59e-10 2.11e-08 - 4.600000 0.971557 1.496974 1.59e-10 1.87e-08 - 4.700000 0.996898 1.525070 1.78e-09 1.61e-08 - 4.800000 1.021641 1.101030 2.16e-09 1.34e-08 - 4.900000 1.045589 1.730922 8.50e-09 1.07e-08 - 5.000000 1.068565 1.056480 1.41e-08 8.06e-09 + 0.100000 1.223725 1.077464 1.04e-07 1.78e-10 + 0.200000 1.220669 1.551800 1.03e-07 3.41e-10 + 0.300000 1.215594 1.467737 1.04e-07 8.22e-10 + 0.400000 1.208524 1.154583 1.03e-07 1.27e-09 + 0.500000 1.199496 1.721908 1.01e-07 1.71e-09 + 0.600000 1.188557 1.023517 9.63e-08 2.09e-09 + 0.700000 1.175764 1.622751 9.18e-08 2.41e-09 + 0.800000 1.161186 1.374632 9.21e-08 2.69e-09 + 0.900000 1.144904 1.245763 8.98e-08 2.96e-09 + 1.000000 1.127010 1.691839 8.66e-08 3.25e-09 + 1.100000 1.107609 1.000489 7.61e-08 3.49e-09 + 1.200000 1.086821 1.677552 6.53e-08 3.63e-09 + 1.300000 1.064777 1.277775 6.27e-08 3.72e-09 + 1.400000 1.041626 1.342455 5.85e-08 3.79e-09 + 1.500000 1.017531 1.642940 5.47e-08 3.89e-09 + 1.600000 0.992673 1.012112 3.94e-08 3.97e-09 + 1.700000 0.967253 1.714058 2.18e-08 3.99e-09 + 1.800000 0.941488 1.183867 1.09e-08 3.88e-09 + 1.900000 0.915617 1.437465 2.03e-09 3.68e-09 + 2.000000 0.889903 1.577082 3.28e-09 3.54e-09 + 2.100000 0.864625 1.056467 2.22e-08 3.40e-09 + 2.200000 0.840089 1.730920 4.49e-08 3.23e-09 + 2.300000 0.816616 1.101047 6.69e-08 2.88e-09 + 2.400000 0.794546 1.525051 8.32e-08 2.38e-09 + 2.500000 0.774227 1.496993 9.13e-08 1.92e-09 + 2.600000 0.756013 1.126857 1.10e-07 1.46e-09 + 2.700000 0.740246 1.727536 1.30e-07 9.94e-10 + 2.800000 0.727247 1.038393 1.52e-07 3.98e-10 + 2.900000 0.717301 1.600759 1.66e-07 3.09e-10 + 3.000000 0.710636 1.406380 1.70e-07 9.31e-10 + 3.100000 0.707412 1.214353 1.76e-07 1.61e-09 + 3.200000 0.707709 1.704026 1.78e-07 2.26e-09 + 3.300000 0.711519 1.004391 1.75e-07 2.89e-09 + 3.400000 0.718749 1.661225 1.66e-07 3.48e-09 + 3.500000 0.729227 1.310102 2.06e-07 4.61e-09 + 3.600000 0.742712 1.310080 1.46e-07 5.20e-09 + 3.700000 0.758914 1.661237 1.35e-07 5.53e-09 + 3.800000 0.777506 1.004387 1.13e-07 5.79e-09 + 3.900000 0.798144 1.704019 8.93e-08 6.17e-09 + 4.000000 0.820474 1.214374 7.47e-08 6.15e-09 + 4.100000 0.844149 1.406358 6.22e-08 6.02e-09 + 4.200000 0.868832 1.600774 5.40e-08 5.94e-09 + 4.300000 0.894204 1.038382 3.41e-08 5.84e-09 + 4.400000 0.919964 1.727533 1.30e-08 5.69e-09 + 4.500000 0.945834 1.126875 2.93e-09 5.39e-09 + 4.600000 0.971557 1.496974 1.25e-08 4.97e-09 + 4.700000 0.996898 1.525070 1.46e-08 4.61e-09 + 4.800000 1.021641 1.101030 2.63e-08 4.29e-09 + 4.900000 1.045589 1.730922 3.94e-08 3.99e-09 + 5.000000 1.068565 1.056480 5.40e-08 3.58e-09 ------------------------------------------------------ Final Solver Statistics: Steps: nsts = 1001, nstf = 362362 - u error = 2.987e-08, v error = 1.896e-08, total error = 2.502e-08 + u error = 9.913e-08, v error = 3.753e-09, total error = 7.015e-08 Total RHS evals: Fse = 4005, Fsi = 12096, Ff = 1087136 Slow Newton iters = 8091 Slow Newton conv fails = 0 diff --git a/src/arkode/arkode_mristep.c b/src/arkode/arkode_mristep.c index 8fa6ec0847..43708934c2 100644 --- a/src/arkode/arkode_mristep.c +++ b/src/arkode/arkode_mristep.c @@ -2225,6 +2225,7 @@ int mriStep_TakeStepMRISR(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr) sunbooleantype store_exprhs; sunrealtype cstage; /* current stage abscissa */ sunbooleantype need_inner_dsm; + sunbooleantype force_reset = (*dsmPtr == PREV_ERR_FAIL); int nvec; const sunrealtype tol = SUN_RCONST(100.0) * SUN_UNIT_ROUNDOFF; @@ -2267,9 +2268,8 @@ int mriStep_TakeStepMRISR(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr) } } - /* if any temporal adaptivity is enabled: reset the inner integrator - to the beginning of this step (in case of recomputation) */ - if (!ark_mem->fixedstep) + /* following an error test failure, reset the inner integrator */ + if (force_reset) { retval = mriStepInnerStepper_Reset(step_mem->stepper, ark_mem->tn, ark_mem->yn); @@ -2409,17 +2409,22 @@ int mriStep_TakeStepMRISR(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr) step_mem->implicit_rhs = store_imprhs; step_mem->explicit_rhs = store_exprhs; - /* Evolve fast IVP for this stage: - force reset due to "stage-restart" structure - potentially get inner dsm on all non-embedding stages */ - retval = mriStepInnerStepper_Reset(step_mem->stepper, ark_mem->tn, - ark_mem->ycur); - if (retval != ARK_SUCCESS) + /* Reset the inner stepper on all but the first stage due to + "stage-restart" structure */ + if (stage > 1) { - arkProcessError(ark_mem, ARK_INNERSTEP_FAIL, __LINE__, __func__, __FILE__, - "Unable to reset the inner stepper"); - return (ARK_INNERSTEP_FAIL); + retval = mriStepInnerStepper_Reset(step_mem->stepper, ark_mem->tn, + ark_mem->ycur); + if (retval != ARK_SUCCESS) + { + arkProcessError(ark_mem, ARK_INNERSTEP_FAIL, __LINE__, __func__, __FILE__, + "Unable to reset the inner stepper"); + return (ARK_INNERSTEP_FAIL); + } } + + /* Evolve fast IVP for this stage, potentially get inner dsm on + all non-embedding stages */ retval = mriStep_StageERKFast(ark_mem, step_mem, ark_mem->tn, ark_mem->tn + cstage * ark_mem->h, ark_mem->ycur, ytemp, @@ -2697,6 +2702,7 @@ int mriStep_TakeStepMERK(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr) sunbooleantype solution; /* or solution stages */ sunrealtype cstage; /* current stage abscissa */ sunbooleantype need_inner_dsm; + sunbooleantype force_reset = (*nflagPtr == PREV_ERR_FAIL); int nvec; /* access the MRIStep mem structure */ @@ -2741,9 +2747,8 @@ int mriStep_TakeStepMERK(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr) } } - /* if any temporal adaptivity is enabled: reset the inner integrator - to the beginning of this step (in case of recomputation) */ - if (!ark_mem->fixedstep) + /* following an error test failure, reset the inner integrator */ + if (force_reset) { retval = mriStepInnerStepper_Reset(step_mem->stepper, t0, ark_mem->yn); if (retval != ARK_SUCCESS) @@ -2854,10 +2859,9 @@ int mriStep_TakeStepMERK(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr) /* Set desired output time for subinterval */ tf = ark_mem->tn + cstage * ark_mem->h; - /* Evolve fast IVP for this stage: - force reset on first stage in group - potentially get inner dsm on all non-embedding stages */ - if (is == 0) + /* Reset the inner stepper on the first stage within all but the + first stage group due to "stage-restart" structure */ + if ((stage > 1) && (is == 0)) { retval = mriStepInnerStepper_Reset(step_mem->stepper, t0, ark_mem->ycur); if (retval != ARK_SUCCESS) @@ -2867,6 +2871,9 @@ int mriStep_TakeStepMERK(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr) return (ARK_INNERSTEP_FAIL); } } + + /* Evolve fast IVP for this stage, potentially get inner dsm on all + non-embedding stages */ retval = mriStep_StageERKFast(ark_mem, step_mem, t0, tf, ark_mem->ycur, ytemp, need_inner_dsm && !embedding); if (retval != ARK_SUCCESS) { *nflagPtr = CONV_FAIL; } From bf0762748f005b02bb1938f71ff2008d190073da Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Wed, 30 Oct 2024 17:29:54 -0500 Subject: [PATCH 213/286] formatting --- src/arkode/arkode_mristep.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/arkode/arkode_mristep.c b/src/arkode/arkode_mristep.c index 43708934c2..dd74556889 100644 --- a/src/arkode/arkode_mristep.c +++ b/src/arkode/arkode_mristep.c @@ -2417,8 +2417,8 @@ int mriStep_TakeStepMRISR(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr) ark_mem->ycur); if (retval != ARK_SUCCESS) { - arkProcessError(ark_mem, ARK_INNERSTEP_FAIL, __LINE__, __func__, __FILE__, - "Unable to reset the inner stepper"); + arkProcessError(ark_mem, ARK_INNERSTEP_FAIL, __LINE__, __func__, + __FILE__, "Unable to reset the inner stepper"); return (ARK_INNERSTEP_FAIL); } } From 45faa466df61a20dfa563c8fa4a2db6fe8286bce Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Wed, 30 Oct 2024 17:39:18 -0500 Subject: [PATCH 214/286] removed 'if' statement from inside MRISR stage loop --- src/arkode/arkode_mristep.c | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/src/arkode/arkode_mristep.c b/src/arkode/arkode_mristep.c index dd74556889..4d2ba58bf9 100644 --- a/src/arkode/arkode_mristep.c +++ b/src/arkode/arkode_mristep.c @@ -2226,7 +2226,7 @@ int mriStep_TakeStepMRISR(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr) sunrealtype cstage; /* current stage abscissa */ sunbooleantype need_inner_dsm; sunbooleantype force_reset = (*dsmPtr == PREV_ERR_FAIL); - int nvec; + int nvec, max_stages; const sunrealtype tol = SUN_RCONST(100.0) * SUN_UNIT_ROUNDOFF; /* access the MRIStep mem structure */ @@ -2368,8 +2368,12 @@ int mriStep_TakeStepMRISR(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr) /* The first stage is the previous time-step solution, so its RHS is the [already-computed] slow RHS from the start of the step */ + /* Determine how many stages will be needed */ + max_stages = (ark_mem->fixedstep && (ark_mem->AccumErrorType == ARK_ACCUMERROR_NONE)) ? + step_mem->stages : step_mem->stages+1; + /* Loop over stages */ - for (stage = 1; stage <= step_mem->stages; stage++) + for (stage = 1; stage < max_stages; stage++) { /* Solver diagnostics reporting */ #if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_DEBUG @@ -2382,14 +2386,6 @@ int mriStep_TakeStepMRISR(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr) solution = (stage == step_mem->stages - 1); embedding = (stage == step_mem->stages); - /* Skip the embedding if we're using fixed time-stepping and - temporal error estimation is disabled */ - if (ark_mem->fixedstep && embedding && - (ark_mem->AccumErrorType == ARK_ACCUMERROR_NONE)) - { - break; - } - /* Set initial condition for this stage */ N_VScale(ONE, ark_mem->yn, ark_mem->ycur); From 58122a286302cce13fd443f89f34f1b90c7b0192 Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Wed, 30 Oct 2024 17:40:37 -0500 Subject: [PATCH 215/286] formatting --- src/arkode/arkode_mristep.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/arkode/arkode_mristep.c b/src/arkode/arkode_mristep.c index 4d2ba58bf9..351c215028 100644 --- a/src/arkode/arkode_mristep.c +++ b/src/arkode/arkode_mristep.c @@ -2369,8 +2369,10 @@ int mriStep_TakeStepMRISR(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr) is the [already-computed] slow RHS from the start of the step */ /* Determine how many stages will be needed */ - max_stages = (ark_mem->fixedstep && (ark_mem->AccumErrorType == ARK_ACCUMERROR_NONE)) ? - step_mem->stages : step_mem->stages+1; + max_stages = (ark_mem->fixedstep && + (ark_mem->AccumErrorType == ARK_ACCUMERROR_NONE)) + ? step_mem->stages + : step_mem->stages + 1; /* Loop over stages */ for (stage = 1; stage < max_stages; stage++) From 3a7be2ef7b03125efa584f233bbdb8e1c2b3c544 Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Wed, 30 Oct 2024 21:00:08 -0500 Subject: [PATCH 216/286] Updated answers repository commit --- test/answers | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/answers b/test/answers index effad098bc..3cd9e193a6 160000 --- a/test/answers +++ b/test/answers @@ -1 +1 @@ -Subproject commit effad098bc89ed78e2300d9ba03b507cab1ab435 +Subproject commit 3cd9e193a65c285e67e4351733772f0e3cb4db78 From 143a7f3dbc7369a1ccf4ca4c5fdb5fa9b5447f67 Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Wed, 30 Oct 2024 21:16:17 -0500 Subject: [PATCH 217/286] Optimized interaction of mriStep_TakeStepMRISR with mriStep_ComputeInnerForcing (as suggested in PR review) --- src/arkode/arkode_mristep.c | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/src/arkode/arkode_mristep.c b/src/arkode/arkode_mristep.c index 351c215028..e6e6de389b 100644 --- a/src/arkode/arkode_mristep.c +++ b/src/arkode/arkode_mristep.c @@ -2221,9 +2221,7 @@ int mriStep_TakeStepMRISR(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr) sunbooleantype embedding; /* flag indicating embedding */ sunbooleantype solution; /* or solution stages */ sunbooleantype impl_corr; /* is slow correct. implicit? */ - sunbooleantype store_imprhs; /* temporary storage */ - sunbooleantype store_exprhs; - sunrealtype cstage; /* current stage abscissa */ + sunrealtype cstage; /* current stage abscissa */ sunbooleantype need_inner_dsm; sunbooleantype force_reset = (*dsmPtr == PREV_ERR_FAIL); int nvec, max_stages; @@ -2394,18 +2392,10 @@ int mriStep_TakeStepMRISR(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr) /* Set current stage abscissa */ cstage = (embedding) ? ONE : step_mem->MRIC->c[stage]; - /* Compute forcing function for inner solver: temporarily - force explicit_rhs and disable implicit_rhs flag since MRISR - methods ignore the G coefficients in the forcing function. */ - store_imprhs = step_mem->implicit_rhs; - store_exprhs = step_mem->explicit_rhs; - step_mem->implicit_rhs = SUNFALSE; - step_mem->explicit_rhs = SUNTRUE; + /* Compute forcing function for inner solver */ retval = mriStep_ComputeInnerForcing(ark_mem, step_mem, stage, ark_mem->tn, ark_mem->tn + cstage * ark_mem->h); if (retval != ARK_SUCCESS) { return retval; } - step_mem->implicit_rhs = store_imprhs; - step_mem->explicit_rhs = store_exprhs; /* Reset the inner stepper on all but the first stage due to "stage-restart" structure */ @@ -3718,6 +3708,8 @@ int mriStep_ComputeInnerForcing(SUNDIALS_MAYBE_UNUSED ARKodeMem ark_mem, int j, k, nmat, nstore, retval; sunrealtype* cvals; N_Vector* Xvecs; + sunbooleantype implicit_rhs = step_mem->implicit_rhs; + sunbooleantype explicit_rhs = step_mem->explicit_rhs; /* local shortcuts for fused vector operations */ cvals = step_mem->cvals; @@ -3727,16 +3719,24 @@ int mriStep_ComputeInnerForcing(SUNDIALS_MAYBE_UNUSED ARKodeMem ark_mem, step_mem->stepper->tshift = t0; step_mem->stepper->tscale = tf - t0; + /* Adjust implicit/explicit RHS flags for MRISR methods, since these + ignore the G coefficients in the forcing function */ + if (step_mem->MRIC->type == MRISTEP_MRISR) + { + implicit_rhs = SUNFALSE; + explicit_rhs = SUNTRUE; + } + /* compute inner forcing vectors (assumes cdiff != 0) */ nstore = 0; for (j = 0; j < SUNMIN(stage, step_mem->stages); j++) { - if (step_mem->explicit_rhs && step_mem->stage_map[j] > -1) + if (explicit_rhs && step_mem->stage_map[j] > -1) { Xvecs[nstore] = step_mem->Fse[step_mem->stage_map[j]]; nstore += 1; } - if (step_mem->implicit_rhs && step_mem->stage_map[j] > -1) + if (implicit_rhs && step_mem->stage_map[j] > -1) { Xvecs[nstore] = step_mem->Fsi[step_mem->stage_map[j]]; nstore += 1; @@ -3753,7 +3753,7 @@ int mriStep_ComputeInnerForcing(SUNDIALS_MAYBE_UNUSED ARKodeMem ark_mem, { if (step_mem->stage_map[j] > -1) { - if (step_mem->explicit_rhs && step_mem->implicit_rhs) + if (explicit_rhs && implicit_rhs) { /* ImEx */ cvals[nstore] = rcdiff * step_mem->MRIC->W[k][stage][j]; @@ -3761,7 +3761,7 @@ int mriStep_ComputeInnerForcing(SUNDIALS_MAYBE_UNUSED ARKodeMem ark_mem, cvals[nstore] = rcdiff * step_mem->MRIC->G[k][stage][j]; nstore += 1; } - else if (step_mem->explicit_rhs) + else if (explicit_rhs) { /* explicit only */ cvals[nstore] = rcdiff * step_mem->MRIC->W[k][stage][j]; From d2d2762a70fb7f97227d33cef9edd0c259d90c1d Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Wed, 30 Oct 2024 21:19:43 -0500 Subject: [PATCH 218/286] spelling --- src/arkode/arkode_mristep.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/arkode/arkode_mristep.c b/src/arkode/arkode_mristep.c index e6e6de389b..e92a19db1c 100644 --- a/src/arkode/arkode_mristep.c +++ b/src/arkode/arkode_mristep.c @@ -2010,7 +2010,7 @@ int mriStep_TakeStepMRIGARK(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPt data so that both hold the current ark_mem->ycur value. This ensures that during this embedding "stage": - ark_mem->ycur will be the correct initial condition for the final stage. - - ark_mem->tempv4 will hold the embeded solution vector. */ + - ark_mem->tempv4 will hold the embedded solution vector. */ N_VScale(ONE, ark_mem->ycur, ark_mem->tempv4); tmp = ark_mem->ycur; ark_mem->ycur = ark_mem->tempv4; From 68b9562d6a34d0625225814729a95483703c1e9f Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Wed, 30 Oct 2024 21:41:20 -0500 Subject: [PATCH 219/286] Updated answers repository commit --- test/answers | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/answers b/test/answers index 3cd9e193a6..b44b35fb63 160000 --- a/test/answers +++ b/test/answers @@ -1 +1 @@ -Subproject commit 3cd9e193a65c285e67e4351733772f0e3cb4db78 +Subproject commit b44b35fb63bf35aae3a8340e876fd711587ca986 From be752365041498e8fa312825e0b2244def1b66f4 Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Wed, 30 Oct 2024 22:29:02 -0500 Subject: [PATCH 220/286] Updated MRIStep to allow recoverable failures from the inner solver, and clarified documentation regarding which inner stepper functions could return recoverable failure values. --- .../Custom_Inner_Stepper/Description.rst | 27 ++++++++++--------- src/arkode/arkode_mristep.c | 24 ++++++++++++----- 2 files changed, 31 insertions(+), 20 deletions(-) diff --git a/doc/arkode/guide/source/Usage/MRIStep/Custom_Inner_Stepper/Description.rst b/doc/arkode/guide/source/Usage/MRIStep/Custom_Inner_Stepper/Description.rst index 1f2042cfb2..ad38c6bc40 100644 --- a/doc/arkode/guide/source/Usage/MRIStep/Custom_Inner_Stepper/Description.rst +++ b/doc/arkode/guide/source/Usage/MRIStep/Custom_Inner_Stepper/Description.rst @@ -382,8 +382,9 @@ member functions: **Return value:** An :c:type:`MRIStepInnerEvolveFn` should return 0 if successful, a positive - value if a recoverable error occurred, or a negative value if it failed - unrecoverably. + value if a recoverable error occurred (i.e., the function could be successful if + called over a smaller time interval :math:`[t0,tout]`), or a negative value if + it failed unrecoverably. **Example codes:** * ``examples/arkode/CXX_parallel/ark_diffusion_reaction_p.cpp`` @@ -415,9 +416,8 @@ following member functions: * ``ARK_FULLRHS_OTHER`` -- called elsewhere e.g., for dense output **Return value:** - An :c:type:`MRIStepInnerFullRhsFn` should return 0 if successful, a positive - value if a recoverable error occurred, or a negative value if it failed - unrecoverably. + An :c:type:`MRIStepInnerFullRhsFn` should return 0 if successful, or + a nonzero value upon failure. **Example codes:** * ``examples/arkode/CXX_parallel/ark_diffusion_reaction_p.cpp`` @@ -441,9 +441,8 @@ following member functions: * *vR* -- the value of the dependent variable vector :math:`v(t_R)`. **Return value:** - An :c:type:`MRIStepInnerResetFn` should return 0 if successful, a positive - value if a recoverable error occurred, or a negative value if it failed - unrecoverably. + An :c:type:`MRIStepInnerResetFn` should return 0 if successful, or a nonzero + value upon failure. **Example codes:** * ``examples/arkode/CXX_parallel/ark_diffusion_reaction_p.cpp`` @@ -463,7 +462,9 @@ following member functions: **Return value:** An :c:type:`MRIStepInnerGetAccumulatedError` should return 0 if successful, a positive - value if a recoverable error occurred, or a negative value if it failed unrecoverably. + value if a recoverable error occurred (i.e., the function could be successful if + called over a smaller time interval :math:`[t0,tout]`), or a negative value if it + failed unrecoverably. .. note:: @@ -486,8 +487,8 @@ following member functions: * *stepper* -- the inner stepper object. **Return value:** - An :c:type:`MRIStepInnerResetAccumulatedError` should return 0 if successful, a positive` - value if a recoverable error occurred, or a negative value if it failed unrecoverably. + An :c:type:`MRIStepInnerResetAccumulatedError` should return 0 if successful, or + a nonzero value upon failure. .. note:: @@ -514,8 +515,8 @@ following member functions: * *rtol* -- relative tolerance to use on the upcoming solve. **Return value:** - An :c:type:`MRIStepInnerSetRTol` should return 0 if successful, a positive` - value if a recoverable error occurred, or a negative value if it failed unrecoverably. + An :c:type:`MRIStepInnerSetRTol` should return 0 if successful, or a nonzero value + upon failure. .. note:: diff --git a/src/arkode/arkode_mristep.c b/src/arkode/arkode_mristep.c index e92a19db1c..4234382ae8 100644 --- a/src/arkode/arkode_mristep.c +++ b/src/arkode/arkode_mristep.c @@ -1884,7 +1884,7 @@ int mriStep_TakeStepMRIGARK(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPt break; case (MRISTAGE_STIFF_ACC): retval = ARK_SUCCESS; break; } - if (retval != ARK_SUCCESS) { return (retval); } + if (retval != ARK_SUCCESS) { return retval; } #ifdef SUNDIALS_LOGGING_EXTRA_DEBUG SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, @@ -2053,7 +2053,7 @@ int mriStep_TakeStepMRIGARK(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPt retval = mriStep_StageDIRKFast(ark_mem, step_mem, is, nflagPtr); break; } - if (retval != ARK_SUCCESS) { return (retval); } + if (retval != ARK_SUCCESS) { return retval; } #ifdef SUNDIALS_LOGGING_EXTRA_DEBUG SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, "ARKODE::mriStep_TakeStep", @@ -2115,7 +2115,7 @@ int mriStep_TakeStepMRIGARK(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPt break; case (MRISTAGE_STIFF_ACC): retval = ARK_SUCCESS; break; } - if (retval != ARK_SUCCESS) { return (retval); } + if (retval != ARK_SUCCESS) { return retval; } #ifdef SUNDIALS_LOGGING_EXTRA_DEBUG SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, @@ -2417,7 +2417,11 @@ int mriStep_TakeStepMRISR(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr) ark_mem->tn + cstage * ark_mem->h, ark_mem->ycur, ytemp, need_inner_dsm && !embedding); - if (retval != ARK_SUCCESS) { *nflagPtr = CONV_FAIL; } + if (retval != ARK_SUCCESS) + { + *nflagPtr = CONV_FAIL; + return retval; + } /* set current stage time for implicit correction, postprocessing and RHS calls */ @@ -2864,7 +2868,11 @@ int mriStep_TakeStepMERK(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr) non-embedding stages */ retval = mriStep_StageERKFast(ark_mem, step_mem, t0, tf, ark_mem->ycur, ytemp, need_inner_dsm && !embedding); - if (retval != ARK_SUCCESS) { *nflagPtr = CONV_FAIL; } + if (retval != ARK_SUCCESS) + { + *nflagPtr = CONV_FAIL; + return retval; + } /* Update "initial time" for next stage in group */ t0 = tf; @@ -3443,12 +3451,13 @@ int mriStep_StageERKFast(ARKodeMem ark_mem, ARKodeMRIStepMem step_mem, /* advance inner method in time */ retval = mriStepInnerStepper_Evolve(step_mem->stepper, t0, tf, ycur); - if (retval != ARK_SUCCESS) + if (retval < 0) { arkProcessError(ark_mem, ARK_INNERSTEP_FAIL, __LINE__, __func__, __FILE__, "Failure when evolving the inner stepper"); return (ARK_INNERSTEP_FAIL); } + if (retval > 0) { return TRY_AGAIN; } /* for normal stages (i.e., not the embedding) with MRI adaptivity enabled, get an estimate for the fast time scale error */ @@ -3459,12 +3468,13 @@ int mriStep_StageERKFast(ARKodeMem ark_mem, ARKodeMRIStepMem step_mem, { retval = mriStepInnerStepper_GetAccumulatedError(step_mem->stepper, &(step_mem->inner_dsm)); - if (retval != ARK_SUCCESS) + if (retval < 0) { arkProcessError(ark_mem, ARK_INNERSTEP_FAIL, __LINE__, __func__, __FILE__, "Unable to get accumulated error from the inner stepper"); return (ARK_INNERSTEP_FAIL); } + if (retval > 0) { return TRY_AGAIN; } } } From 333ac9f89ab978fe56ed5bc0ed6ec4f25c5edf8d Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Wed, 30 Oct 2024 22:29:21 -0500 Subject: [PATCH 221/286] Updated answers repository commit --- test/answers | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/answers b/test/answers index b44b35fb63..3cd9e193a6 160000 --- a/test/answers +++ b/test/answers @@ -1 +1 @@ -Subproject commit b44b35fb63bf35aae3a8340e876fd711587ca986 +Subproject commit 3cd9e193a65c285e67e4351733772f0e3cb4db78 From 07ac91c5bdadd6714abbbf0c16c244b9d848441a Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Wed, 30 Oct 2024 22:36:19 -0500 Subject: [PATCH 222/286] Updated ARKODE MRIStepInnerStepper interface routines to send appropriate success/recoverable/unrecoverable flags --- src/arkode/arkode.c | 94 ++++++++++++++++++++++----------------------- 1 file changed, 46 insertions(+), 48 deletions(-) diff --git a/src/arkode/arkode.c b/src/arkode/arkode.c index fdd4e59b9b..f9206e7036 100644 --- a/src/arkode/arkode.c +++ b/src/arkode/arkode.c @@ -3662,7 +3662,10 @@ void arkProcessError(ARKodeMem ark_mem, int error_code, int line, ark_MRIStepInnerEvolve Implementation of MRIStepInnerStepperEvolveFn to advance the inner (fast) - ODE IVP. + ODE IVP. Since the raw return value from an MRIStepInnerStepper is + meaningless, aside from whether it is 0 (success), >0 (recoverable failure), + and <0 (unrecoverable failure), we map various ARKODE return values + accordingly. ----------------------------------------------------------------------------*/ int ark_MRIStepInnerEvolve(MRIStepInnerStepper stepper, @@ -3679,37 +3682,46 @@ int ark_MRIStepInnerEvolve(MRIStepInnerStepper stepper, /* extract the ARKODE memory struct */ retval = MRIStepInnerStepper_GetContent(stepper, &arkode_mem); - if (retval != ARK_SUCCESS) { return (retval); } + if (retval != ARK_SUCCESS) { return -1; } if (arkode_mem == NULL) { arkProcessError(NULL, ARK_MEM_NULL, __LINE__, __func__, __FILE__, MSG_ARK_NO_MEM); - return ARK_MEM_NULL; + return -1; } ark_mem = (ARKodeMem)arkode_mem; /* get the forcing data */ retval = MRIStepInnerStepper_GetForcingData(stepper, &tshift, &tscale, &forcing, &nforcing); - if (retval != ARK_SUCCESS) { return (retval); } + if (retval != ARK_SUCCESS) { return -1; } /* set the inner forcing data */ retval = ark_mem->step_setforcing(ark_mem, tshift, tscale, forcing, nforcing); - if (retval != ARK_SUCCESS) { return (retval); } + if (retval != ARK_SUCCESS) { return -1; } /* set the stop time */ retval = ARKodeSetStopTime(arkode_mem, tout); - if (retval != ARK_SUCCESS) { return (retval); } + if (retval != ARK_SUCCESS) { return -1; } - /* evolve inner ODE */ + /* evolve inner ODE, consider all positive return values as 'success' */ retval = ARKodeEvolve(arkode_mem, tout, y, &tret, ARK_NORMAL); - if (retval < 0) { return (retval); } + if (retval > 0) { retval = 0; } + + /* set a recoverable failure for a few ARKODE failure modes; + on other ARKODE errors return with an unrecoverable failure */ + if (retval < 0) { + if ((retval == ARK_TOO_MUCH_WORK) || (retval == ARK_ERR_FAILURE) || + (retval == ARK_CONV_FAILURE)) + { retval = 1; } + else { return -1; } + } /* disable inner forcing */ - retval = ark_mem->step_setforcing(ark_mem, ZERO, ONE, NULL, 0); - if (retval != ARK_SUCCESS) { return (retval); } + if (ark_mem->step_setforcing(ark_mem, ZERO, ONE, NULL, 0) + != ARK_SUCCESS) { return -1; } - return (ARK_SUCCESS); + return retval; } /*------------------------------------------------------------------------------ @@ -3724,20 +3736,19 @@ int ark_MRIStepInnerFullRhs(MRIStepInnerStepper stepper, sunrealtype t, { void* arkode_mem; /* arkode memory */ ARKodeMem ark_mem; - int retval; /* return value */ - - /* extract the ARKODE memory struct */ - retval = MRIStepInnerStepper_GetContent(stepper, &arkode_mem); - if (retval != ARK_SUCCESS) { return (retval); } + int retval = MRIStepInnerStepper_GetContent(stepper, &arkode_mem); + if (retval != ARK_SUCCESS) { return -1; } if (arkode_mem == NULL) { arkProcessError(NULL, ARK_MEM_NULL, __LINE__, __func__, __FILE__, MSG_ARK_NO_MEM); - return ARK_MEM_NULL; + return -1; } ark_mem = (ARKodeMem)arkode_mem; - return (ark_mem->step_fullrhs(arkode_mem, t, y, f, mode)); + if (ark_mem->step_fullrhs(arkode_mem, t, y, f, mode) != ARK_SUCCESS) + { return -1; } + return 0; } /*------------------------------------------------------------------------------ @@ -3750,13 +3761,9 @@ int ark_MRIStepInnerFullRhs(MRIStepInnerStepper stepper, sunrealtype t, int ark_MRIStepInnerReset(MRIStepInnerStepper stepper, sunrealtype tR, N_Vector yR) { void* arkode_mem; - int retval; - - /* extract the ARKODE memory struct */ - retval = MRIStepInnerStepper_GetContent(stepper, &arkode_mem); - if (retval != ARK_SUCCESS) { return (retval); } - - return (ARKodeReset(arkode_mem, tR, yR)); + int retval = MRIStepInnerStepper_GetContent(stepper, &arkode_mem); + if (retval != ARK_SUCCESS) { return -1; } + if (ARKodeReset(arkode_mem, tR, yR) != ARK_SUCCESS) { return -1; } } /*------------------------------------------------------------------------------ @@ -3770,13 +3777,12 @@ int ark_MRIStepInnerGetAccumulatedError(MRIStepInnerStepper stepper, sunrealtype* accum_error) { void* arkode_mem; - int retval; - - /* extract the ARKODE memory struct */ - retval = MRIStepInnerStepper_GetContent(stepper, &arkode_mem); - if (retval != ARK_SUCCESS) { return (retval); } - - return (ARKodeGetAccumulatedError(arkode_mem, accum_error)); + int retval = MRIStepInnerStepper_GetContent(stepper, &arkode_mem); + if (retval != ARK_SUCCESS) { return -1; } + retval = ARKodeGetAccumulatedError(arkode_mem, accum_error); + if (retval == ARK_SUCCESS) { return 0; } + if (retval > 0) { return 1; } + return -1; } /*------------------------------------------------------------------------------ @@ -3789,13 +3795,9 @@ int ark_MRIStepInnerGetAccumulatedError(MRIStepInnerStepper stepper, int ark_MRIStepInnerResetAccumulatedError(MRIStepInnerStepper stepper) { void* arkode_mem; - int retval; - - /* extract the ARKODE memory struct */ - retval = MRIStepInnerStepper_GetContent(stepper, &arkode_mem); - if (retval != ARK_SUCCESS) { return (retval); } - - return (ARKodeResetAccumulatedError(arkode_mem)); + int retval = MRIStepInnerStepper_GetContent(stepper, &arkode_mem); + if (retval != ARK_SUCCESS) { return -1; } + if (ARKodeResetAccumulatedError(arkode_mem) != ARK_SUCCESS) { return -1; } } /*------------------------------------------------------------------------------ @@ -3809,25 +3811,21 @@ int ark_MRIStepInnerSetRTol(MRIStepInnerStepper stepper, sunrealtype rtol) { void* arkode_mem; ARKodeMem ark_mem; - int retval; - - /* extract the ARKODE memory struct */ - retval = MRIStepInnerStepper_GetContent(stepper, &arkode_mem); - if (retval != ARK_SUCCESS) { return (retval); } + int retval = MRIStepInnerStepper_GetContent(stepper, &arkode_mem); + if (retval != ARK_SUCCESS) { return -1; } if (arkode_mem == NULL) { arkProcessError(NULL, ARK_MEM_NULL, __LINE__, __func__, __FILE__, MSG_ARK_NO_MEM); - return ARK_MEM_NULL; + return -1; } ark_mem = (ARKodeMem)arkode_mem; - if (rtol > ZERO) { ark_mem->reltol = rtol; - return (ARK_SUCCESS); + return 0; } - else { return (ARK_ILL_INPUT); } + else { return -1; } } /*=============================================================== From 930da2cffaa692325aa052dd181afbdefdf58401 Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Wed, 30 Oct 2024 22:36:58 -0500 Subject: [PATCH 223/286] formatting --- src/arkode/arkode.c | 17 ++++++++++++----- src/arkode/arkode_mristep.c | 14 +++++++------- 2 files changed, 19 insertions(+), 12 deletions(-) diff --git a/src/arkode/arkode.c b/src/arkode/arkode.c index f9206e7036..48d9de8edb 100644 --- a/src/arkode/arkode.c +++ b/src/arkode/arkode.c @@ -3710,16 +3710,21 @@ int ark_MRIStepInnerEvolve(MRIStepInnerStepper stepper, /* set a recoverable failure for a few ARKODE failure modes; on other ARKODE errors return with an unrecoverable failure */ - if (retval < 0) { + if (retval < 0) + { if ((retval == ARK_TOO_MUCH_WORK) || (retval == ARK_ERR_FAILURE) || (retval == ARK_CONV_FAILURE)) - { retval = 1; } + { + retval = 1; + } else { return -1; } } /* disable inner forcing */ - if (ark_mem->step_setforcing(ark_mem, ZERO, ONE, NULL, 0) - != ARK_SUCCESS) { return -1; } + if (ark_mem->step_setforcing(ark_mem, ZERO, ONE, NULL, 0) != ARK_SUCCESS) + { + return -1; + } return retval; } @@ -3747,7 +3752,9 @@ int ark_MRIStepInnerFullRhs(MRIStepInnerStepper stepper, sunrealtype t, ark_mem = (ARKodeMem)arkode_mem; if (ark_mem->step_fullrhs(arkode_mem, t, y, f, mode) != ARK_SUCCESS) - { return -1; } + { + return -1; + } return 0; } diff --git a/src/arkode/arkode_mristep.c b/src/arkode/arkode_mristep.c index 4234382ae8..fbc71f9213 100644 --- a/src/arkode/arkode_mristep.c +++ b/src/arkode/arkode_mristep.c @@ -2417,9 +2417,9 @@ int mriStep_TakeStepMRISR(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr) ark_mem->tn + cstage * ark_mem->h, ark_mem->ycur, ytemp, need_inner_dsm && !embedding); - if (retval != ARK_SUCCESS) - { - *nflagPtr = CONV_FAIL; + if (retval != ARK_SUCCESS) + { + *nflagPtr = CONV_FAIL; return retval; } @@ -2868,9 +2868,9 @@ int mriStep_TakeStepMERK(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr) non-embedding stages */ retval = mriStep_StageERKFast(ark_mem, step_mem, t0, tf, ark_mem->ycur, ytemp, need_inner_dsm && !embedding); - if (retval != ARK_SUCCESS) - { - *nflagPtr = CONV_FAIL; + if (retval != ARK_SUCCESS) + { + *nflagPtr = CONV_FAIL; return retval; } @@ -3474,7 +3474,7 @@ int mriStep_StageERKFast(ARKodeMem ark_mem, ARKodeMRIStepMem step_mem, __FILE__, "Unable to get accumulated error from the inner stepper"); return (ARK_INNERSTEP_FAIL); } - if (retval > 0) { return TRY_AGAIN; } + if (retval > 0) { return TRY_AGAIN; } } } From f81c9e8781fb92c30df5ec2995e998ff21186321 Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Wed, 30 Oct 2024 22:44:21 -0500 Subject: [PATCH 224/286] Updated answers repository commit --- test/answers | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/answers b/test/answers index 3cd9e193a6..b44b35fb63 160000 --- a/test/answers +++ b/test/answers @@ -1 +1 @@ -Subproject commit 3cd9e193a65c285e67e4351733772f0e3cb4db78 +Subproject commit b44b35fb63bf35aae3a8340e876fd711587ca986 From 23cbb08661457304a7af9b4a5125a2053a8ec8f2 Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Wed, 30 Oct 2024 22:47:04 -0500 Subject: [PATCH 225/286] Updated answers repository commit --- test/answers | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/answers b/test/answers index b44b35fb63..3cd9e193a6 160000 --- a/test/answers +++ b/test/answers @@ -1 +1 @@ -Subproject commit b44b35fb63bf35aae3a8340e876fd711587ca986 +Subproject commit 3cd9e193a65c285e67e4351733772f0e3cb4db78 From 1c7db4eb6c48af4c7175bc760694fc2dd40db65b Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Thu, 31 Oct 2024 11:19:13 -0500 Subject: [PATCH 226/286] Added missing return values --- src/arkode/arkode.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/arkode/arkode.c b/src/arkode/arkode.c index 48d9de8edb..14735810d2 100644 --- a/src/arkode/arkode.c +++ b/src/arkode/arkode.c @@ -3662,8 +3662,8 @@ void arkProcessError(ARKodeMem ark_mem, int error_code, int line, ark_MRIStepInnerEvolve Implementation of MRIStepInnerStepperEvolveFn to advance the inner (fast) - ODE IVP. Since the raw return value from an MRIStepInnerStepper is - meaningless, aside from whether it is 0 (success), >0 (recoverable failure), + ODE IVP. Since the raw return value from an MRIStepInnerStepper is + meaningless, aside from whether it is 0 (success), >0 (recoverable failure), and <0 (unrecoverable failure), we map various ARKODE return values accordingly. ----------------------------------------------------------------------------*/ @@ -3771,6 +3771,7 @@ int ark_MRIStepInnerReset(MRIStepInnerStepper stepper, sunrealtype tR, N_Vector int retval = MRIStepInnerStepper_GetContent(stepper, &arkode_mem); if (retval != ARK_SUCCESS) { return -1; } if (ARKodeReset(arkode_mem, tR, yR) != ARK_SUCCESS) { return -1; } + return 0; } /*------------------------------------------------------------------------------ @@ -3805,6 +3806,7 @@ int ark_MRIStepInnerResetAccumulatedError(MRIStepInnerStepper stepper) int retval = MRIStepInnerStepper_GetContent(stepper, &arkode_mem); if (retval != ARK_SUCCESS) { return -1; } if (ARKodeResetAccumulatedError(arkode_mem) != ARK_SUCCESS) { return -1; } + return 0; } /*------------------------------------------------------------------------------ From a998610ba4b9e12363563ba99b4b1702e19f8e1b Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Thu, 31 Oct 2024 11:22:01 -0500 Subject: [PATCH 227/286] Updated answers repository commit --- test/answers | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/answers b/test/answers index 3cd9e193a6..b44b35fb63 160000 --- a/test/answers +++ b/test/answers @@ -1 +1 @@ -Subproject commit 3cd9e193a65c285e67e4351733772f0e3cb4db78 +Subproject commit b44b35fb63bf35aae3a8340e876fd711587ca986 From 55704c375014e89a832acc3fdaaa928a91825d86 Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Fri, 1 Nov 2024 11:57:59 -0500 Subject: [PATCH 228/286] Reverted changes in experimental setup to re-establish appropriate 'controls' for multirate temporal error --- examples/arkode/CXX_serial/ark_kpr_nestedmri.cpp | 6 ++++-- .../arkode/CXX_serial/ark_test_brusselator_mriadapt.cpp | 6 ++++-- test/unit_tests/arkode/CXX_serial/ark_test_kpr_mriadapt.cpp | 6 ++++-- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/examples/arkode/CXX_serial/ark_kpr_nestedmri.cpp b/examples/arkode/CXX_serial/ark_kpr_nestedmri.cpp index 56d4e68a1f..e71ecdba09 100644 --- a/examples/arkode/CXX_serial/ark_kpr_nestedmri.cpp +++ b/examples/arkode/CXX_serial/ark_kpr_nestedmri.cpp @@ -957,7 +957,9 @@ int main(int argc, char* argv[]) retval = ARKodeReset(arkode_ref, t, y); // evolve solution in one-step mode - retval = ARKodeEvolve(arkode_mem, Tf, y, &t, ARK_ONE_STEP); + retval = ARKodeSetStopTime(arkode_mem, tout); + if (check_flag(retval, "ARKodeSetStopTime")) return 1; + retval = ARKodeEvolve(arkode_mem, tout, y, &t, ARK_ONE_STEP); if (retval < 0) { printf("ARKodeEvolve error (%i)\n", retval); @@ -967,7 +969,7 @@ int main(int argc, char* argv[]) // evolve reference solver to same time in "normal" mode retval = ARKodeSetStopTime(arkode_ref, t); if (check_flag(retval, "ARKodeSetStopTime")) return 1; - retval = ARKodeEvolve(arkode_ref, Tf, yref, &t2, ARK_NORMAL); + retval = ARKodeEvolve(arkode_ref, t, yref, &t2, ARK_NORMAL); if (retval < 0) { printf("ARKodeEvolve reference solution error (%i)\n", retval); diff --git a/test/unit_tests/arkode/CXX_serial/ark_test_brusselator_mriadapt.cpp b/test/unit_tests/arkode/CXX_serial/ark_test_brusselator_mriadapt.cpp index 63e2b4b39b..1169aabc17 100644 --- a/test/unit_tests/arkode/CXX_serial/ark_test_brusselator_mriadapt.cpp +++ b/test/unit_tests/arkode/CXX_serial/ark_test_brusselator_mriadapt.cpp @@ -681,7 +681,9 @@ int main(int argc, char* argv[]) retval = ARKodeReset(arkode_ref, t, y); // evolve solution in one-step mode - retval = ARKodeEvolve(arkode_mem, Tf, y, &t, ARK_ONE_STEP); + retval = ARKodeSetStopTime(arkode_mem, tout); + if (check_flag(retval, "ARKodeSetStopTime")) return 1; + retval = ARKodeEvolve(arkode_mem, tout, y, &t, ARK_ONE_STEP); if (retval < 0) { printf("ARKodeEvolve error (%i)\n", retval); @@ -691,7 +693,7 @@ int main(int argc, char* argv[]) // evolve reference solver to same time in "normal" mode retval = ARKodeSetStopTime(arkode_ref, t); if (check_flag(retval, "ARKodeSetStopTime")) return 1; - retval = ARKodeEvolve(arkode_ref, Tf, yref, &t2, ARK_NORMAL); + retval = ARKodeEvolve(arkode_ref, t, yref, &t2, ARK_NORMAL); if (retval < 0) { printf("ARKodeEvolve reference solution error (%i)\n", retval); diff --git a/test/unit_tests/arkode/CXX_serial/ark_test_kpr_mriadapt.cpp b/test/unit_tests/arkode/CXX_serial/ark_test_kpr_mriadapt.cpp index e6eb0ac097..67d7d0e162 100644 --- a/test/unit_tests/arkode/CXX_serial/ark_test_kpr_mriadapt.cpp +++ b/test/unit_tests/arkode/CXX_serial/ark_test_kpr_mriadapt.cpp @@ -689,7 +689,9 @@ int main(int argc, char* argv[]) retval = ARKodeReset(arkode_ref, t, y); // evolve solution in one-step mode - retval = ARKodeEvolve(arkode_mem, Tf, y, &t, ARK_ONE_STEP); + retval = ARKodeSetStopTime(arkode_mem, tout); + if (check_flag(retval, "ARKodeSetStopTime")) return 1; + retval = ARKodeEvolve(arkode_mem, tout, y, &t, ARK_ONE_STEP); if (retval < 0) { printf("ARKodeEvolve error (%i)\n", retval); @@ -699,7 +701,7 @@ int main(int argc, char* argv[]) // evolve reference solver to same time in "normal" mode retval = ARKodeSetStopTime(arkode_ref, t); if (check_flag(retval, "ARKodeSetStopTime")) return 1; - retval = ARKodeEvolve(arkode_ref, Tf, yref, &t2, ARK_NORMAL); + retval = ARKodeEvolve(arkode_ref, t, yref, &t2, ARK_NORMAL); if (retval < 0) { printf("ARKodeEvolve reference solution error (%i)\n", retval); From 647ec533b156e6cd588d63164aaac32d843d4e89 Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Fri, 1 Nov 2024 12:00:36 -0500 Subject: [PATCH 229/286] Reverted recommended optimizations regarding inner integrator reset at the start of an adaptive step attempt. The previous attempt at this logic was insufficient. I recommend that we defer further optimization until this can be used with application partners. --- src/arkode/arkode_mristep.c | 30 +++++++++++++----------------- 1 file changed, 13 insertions(+), 17 deletions(-) diff --git a/src/arkode/arkode_mristep.c b/src/arkode/arkode_mristep.c index fbc71f9213..c3efcb06e2 100644 --- a/src/arkode/arkode_mristep.c +++ b/src/arkode/arkode_mristep.c @@ -1697,7 +1697,6 @@ int mriStep_TakeStepMRIGARK(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPt sunbooleantype calc_fslow; sunbooleantype need_inner_dsm; sunbooleantype do_embedding; - sunbooleantype force_reset = (*nflagPtr == PREV_ERR_FAIL); int nvec; /* access the MRIStep mem structure */ @@ -1739,9 +1738,8 @@ int mriStep_TakeStepMRIGARK(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPt } } - /* if the previous step was rejected, reset the inner integrator - to the beginning of this step (in case of recomputation) */ - if (force_reset) + /* for adaptive computations, reset the inner integrator to the beginning of this step */ + if (!ark_mem->fixedstep) { retval = mriStepInnerStepper_Reset(step_mem->stepper, ark_mem->tn, ark_mem->yn); @@ -1766,7 +1764,7 @@ int mriStep_TakeStepMRIGARK(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPt } /* Evaluate the slow RHS functions if needed. NOTE: We do not use the full RHS - function here since it does not need to check for FSAL or SA methods and + function here since it does not need to check for FSAL or SA methods and thus avoids potentially unnecessary evaluations of the inner (fast) RHS function */ /* compute the explicit component */ if (step_mem->explicit_rhs) @@ -2006,7 +2004,7 @@ int mriStep_TakeStepMRIGARK(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPt { is = step_mem->stages; - /* Temporarily swap ark_mem->ycur and ark_mem->tempv4 pointers, copying + /* Temporarily swap ark_mem->ycur and ark_mem->tempv4 pointers, copying data so that both hold the current ark_mem->ycur value. This ensures that during this embedding "stage": - ark_mem->ycur will be the correct initial condition for the final stage. @@ -2223,7 +2221,6 @@ int mriStep_TakeStepMRISR(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr) sunbooleantype impl_corr; /* is slow correct. implicit? */ sunrealtype cstage; /* current stage abscissa */ sunbooleantype need_inner_dsm; - sunbooleantype force_reset = (*dsmPtr == PREV_ERR_FAIL); int nvec, max_stages; const sunrealtype tol = SUN_RCONST(100.0) * SUN_UNIT_ROUNDOFF; @@ -2266,8 +2263,8 @@ int mriStep_TakeStepMRISR(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr) } } - /* following an error test failure, reset the inner integrator */ - if (force_reset) + /* for adaptive computations, reset the inner integrator to the beginning of this step */ + if (!ark_mem->fixedstep) { retval = mriStepInnerStepper_Reset(step_mem->stepper, ark_mem->tn, ark_mem->yn); @@ -2397,7 +2394,7 @@ int mriStep_TakeStepMRISR(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr) ark_mem->tn + cstage * ark_mem->h); if (retval != ARK_SUCCESS) { return retval; } - /* Reset the inner stepper on all but the first stage due to + /* Reset the inner stepper on all but the first stage due to "stage-restart" structure */ if (stage > 1) { @@ -2411,7 +2408,7 @@ int mriStep_TakeStepMRISR(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr) } } - /* Evolve fast IVP for this stage, potentially get inner dsm on + /* Evolve fast IVP for this stage, potentially get inner dsm on all non-embedding stages */ retval = mriStep_StageERKFast(ark_mem, step_mem, ark_mem->tn, ark_mem->tn + cstage * ark_mem->h, @@ -2694,7 +2691,6 @@ int mriStep_TakeStepMERK(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr) sunbooleantype solution; /* or solution stages */ sunrealtype cstage; /* current stage abscissa */ sunbooleantype need_inner_dsm; - sunbooleantype force_reset = (*nflagPtr == PREV_ERR_FAIL); int nvec; /* access the MRIStep mem structure */ @@ -2739,8 +2735,8 @@ int mriStep_TakeStepMERK(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr) } } - /* following an error test failure, reset the inner integrator */ - if (force_reset) + /* for adaptive computations, reset the inner integrator to the beginning of this step */ + if (!ark_mem->fixedstep) { retval = mriStepInnerStepper_Reset(step_mem->stepper, t0, ark_mem->yn); if (retval != ARK_SUCCESS) @@ -2851,7 +2847,7 @@ int mriStep_TakeStepMERK(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr) /* Set desired output time for subinterval */ tf = ark_mem->tn + cstage * ark_mem->h; - /* Reset the inner stepper on the first stage within all but the + /* Reset the inner stepper on the first stage within all but the first stage group due to "stage-restart" structure */ if ((stage > 1) && (is == 0)) { @@ -2864,7 +2860,7 @@ int mriStep_TakeStepMERK(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr) } } - /* Evolve fast IVP for this stage, potentially get inner dsm on all + /* Evolve fast IVP for this stage, potentially get inner dsm on all non-embedding stages */ retval = mriStep_StageERKFast(ark_mem, step_mem, t0, tf, ark_mem->ycur, ytemp, need_inner_dsm && !embedding); @@ -3729,7 +3725,7 @@ int mriStep_ComputeInnerForcing(SUNDIALS_MAYBE_UNUSED ARKodeMem ark_mem, step_mem->stepper->tshift = t0; step_mem->stepper->tscale = tf - t0; - /* Adjust implicit/explicit RHS flags for MRISR methods, since these + /* Adjust implicit/explicit RHS flags for MRISR methods, since these ignore the G coefficients in the forcing function */ if (step_mem->MRIC->type == MRISTEP_MRISR) { From 4d9c92ae9bb30ccae83aa97f04a6fb7e671a1c42 Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Fri, 1 Nov 2024 12:01:34 -0500 Subject: [PATCH 230/286] Minor cleanup on ARKODE-provided MRIStepInnerStepper interface --- src/arkode/arkode.c | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/src/arkode/arkode.c b/src/arkode/arkode.c index 14735810d2..a777103cf5 100644 --- a/src/arkode/arkode.c +++ b/src/arkode/arkode.c @@ -3712,8 +3712,8 @@ int ark_MRIStepInnerEvolve(MRIStepInnerStepper stepper, on other ARKODE errors return with an unrecoverable failure */ if (retval < 0) { - if ((retval == ARK_TOO_MUCH_WORK) || (retval == ARK_ERR_FAILURE) || - (retval == ARK_CONV_FAILURE)) + if ((retval == ARK_TOO_MUCH_WORK) || (retval == ARK_CONV_FAILURE) || + (retval == ARK_ERR_FAILURE)) { retval = 1; } @@ -3750,12 +3750,9 @@ int ark_MRIStepInnerFullRhs(MRIStepInnerStepper stepper, sunrealtype t, return -1; } ark_mem = (ARKodeMem)arkode_mem; - - if (ark_mem->step_fullrhs(arkode_mem, t, y, f, mode) != ARK_SUCCESS) - { - return -1; - } - return 0; + retval = ark_mem->step_fullrhs(arkode_mem, t, y, f, mode); + if (retval == ARK_SUCCESS) { return 0; } + return -1; } /*------------------------------------------------------------------------------ @@ -3770,8 +3767,9 @@ int ark_MRIStepInnerReset(MRIStepInnerStepper stepper, sunrealtype tR, N_Vector void* arkode_mem; int retval = MRIStepInnerStepper_GetContent(stepper, &arkode_mem); if (retval != ARK_SUCCESS) { return -1; } - if (ARKodeReset(arkode_mem, tR, yR) != ARK_SUCCESS) { return -1; } - return 0; + retval = ARKodeReset(arkode_mem, tR, yR); + if (retval == ARK_SUCCESS) { return 0; } + return -1; } /*------------------------------------------------------------------------------ @@ -3805,8 +3803,9 @@ int ark_MRIStepInnerResetAccumulatedError(MRIStepInnerStepper stepper) void* arkode_mem; int retval = MRIStepInnerStepper_GetContent(stepper, &arkode_mem); if (retval != ARK_SUCCESS) { return -1; } - if (ARKodeResetAccumulatedError(arkode_mem) != ARK_SUCCESS) { return -1; } - return 0; + retval = ARKodeResetAccumulatedError(arkode_mem); + if (retval == ARK_SUCCESS) { return 0; } + return -1; } /*------------------------------------------------------------------------------ From d7e6198885b4974bc1fdcf12a79e5fb58acc7281 Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Fri, 1 Nov 2024 12:29:23 -0500 Subject: [PATCH 231/286] Updated answers repository commit --- test/answers | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/answers b/test/answers index b44b35fb63..2ae1822304 160000 --- a/test/answers +++ b/test/answers @@ -1 +1 @@ -Subproject commit b44b35fb63bf35aae3a8340e876fd711587ca986 +Subproject commit 2ae182230435af05ddcb312e7a1decef32a865e6 From 8b71729376c6dadef50abc2ae6e7c153146021af Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Fri, 1 Nov 2024 15:55:57 -0500 Subject: [PATCH 232/286] Added counter for the number of recoverable failures reported by the MRIStepInnerStepper --- CHANGELOG.md | 4 +- .../source/Usage/MRIStep/User_callable.rst | 15 +++++++- doc/shared/RecentChanges.rst | 4 +- .../arkode/CXX_serial/ark_kpr_nestedmri.cpp | 12 ++++-- .../arkode/CXX_serial/ark_kpr_nestedmri.out | 4 +- include/arkode/arkode_mristep.h | 2 + src/arkode/arkode_mristep.c | 38 +++++++++++++------ src/arkode/arkode_mristep_impl.h | 13 ++++--- src/arkode/arkode_mristep_io.c | 29 +++++++++++++- 9 files changed, 92 insertions(+), 29 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 94734867e2..d12b8529b6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -35,7 +35,9 @@ Added support for multirate time step adaptivity controllers, based on the recently introduced `SUNAdaptController` base class, to ARKODE's MRIStep module. As a part of this, we added embeddings for existing MRI-GARK methods, as well as support for embedded MERK and IMEX-MRI-SR methods. Added new default MRI methods -for temporally adaptive versus fixed-step runs. +for temporally adaptive versus fixed-step runs. Added the function +`MRIStepGetNumInnerStepperFails` to retrieve the number of recoverable +failures reported by the MRIStepInnerStepper. Added functionality to ARKODE to accumulate a temporal error estimate over multiple time steps. See the routines `ARKodeSetAccumulatedErrorType`, diff --git a/doc/arkode/guide/source/Usage/MRIStep/User_callable.rst b/doc/arkode/guide/source/Usage/MRIStep/User_callable.rst index 553375f16e..24b23e75d9 100644 --- a/doc/arkode/guide/source/Usage/MRIStep/User_callable.rst +++ b/doc/arkode/guide/source/Usage/MRIStep/User_callable.rst @@ -338,7 +338,7 @@ MRIStep solver function :retval ARK_ROOT_RETURN: if :c:func:`MRIStepEvolve()` succeeded, and found one or more roots. If the number of root functions, *nrtfn*, is greater than 1, call - :c:func:`MRIStepGetRootInfo()` to see which + :c:func:`ARKodeGetRootInfo()` to see which :math:`g_i` were found to have a root at (*\*tret*). :retval ARK_TSTOP_RETURN: if :c:func:`MRIStepEvolve()` succeeded and returned at *tstop*. @@ -1547,6 +1547,19 @@ Main solver optional output functions ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +.. c:function:: int MRIStepGetNumInnerStepperFails(void* arkode_mem, long int* inner_fails) + + Returns the number of recoverable failures reported by the inner stepper (so far). + + :param arkode_mem: pointer to the MRIStep memory block. + :param inner_fails: number of slow steps taken in the solver. + + :retval ARK_SUCCESS: if successful + :retval ARK_MEM_NULL: if the MRIStep memory was ``NULL`` + + .. versionadded:: x.y.z + + .. c:function:: int MRIStepGetWorkSpace(void* arkode_mem, long int* lenrw, long int* leniw) Returns the MRIStep real and integer workspace sizes. diff --git a/doc/shared/RecentChanges.rst b/doc/shared/RecentChanges.rst index 51638cb9d9..aaea73efe9 100644 --- a/doc/shared/RecentChanges.rst +++ b/doc/shared/RecentChanges.rst @@ -37,7 +37,9 @@ Added support for multirate time step adaptivity controllers, based on the recently introduced :c:type:`SUNAdaptController` base class, to ARKODE's MRIStep module. As a part of this, we added embeddings for existing MRI-GARK methods, as well as support for embedded MERK and IMEX-MRI-SR methods. Added new default MRI methods -for temporally adaptive versus fixed-step runs. +for temporally adaptive versus fixed-step runs. Added the function +:c:func:`MRIStepGetNumInnerStepperFails` to retrieve the number of recoverable +failures reported by the MRIStepInnerStepper. Added functionality to ARKODE to accumulate a temporal error estimate over multiple time steps. See the routines diff --git a/examples/arkode/CXX_serial/ark_kpr_nestedmri.cpp b/examples/arkode/CXX_serial/ark_kpr_nestedmri.cpp index e71ecdba09..0a486a7a95 100644 --- a/examples/arkode/CXX_serial/ark_kpr_nestedmri.cpp +++ b/examples/arkode/CXX_serial/ark_kpr_nestedmri.cpp @@ -1013,7 +1013,7 @@ int main(int argc, char* argv[]) // // Get some slow integrator statistics - long int nsts, natts, netfs, nfse, nfsi; + long int nsts, natts, netfs, nfse, nfsi, nifs; retval = ARKodeGetNumSteps(arkode_mem, &nsts); check_flag(retval, "ARKodeGetNumSteps"); retval = ARKodeGetNumStepAttempts(arkode_mem, &natts); @@ -1024,9 +1024,11 @@ int main(int argc, char* argv[]) check_flag(retval, "ARKodeGetNumRhsEvals"); retval = ARKodeGetNumRhsEvals(arkode_mem, 1, &nfsi); check_flag(retval, "ARKodeGetNumRhsEvals"); + retval = MRIStepGetNumInnerStepperFails(arkode_mem, &nifs); + check_flag(retval, "MRIStepGetNumInnerStepperFails"); // Get some intermediate integrator statistics - long int nstm, nattm, netfm, nfme, nfmi; + long int nstm, nattm, netfm, nfme, nfmi, nifm; retval = ARKodeGetNumSteps(mid_arkode_mem, &nstm); check_flag(retval, "ARKodeGetNumSteps"); retval = ARKodeGetNumStepAttempts(mid_arkode_mem, &nattm); @@ -1037,6 +1039,8 @@ int main(int argc, char* argv[]) check_flag(retval, "ARKodeGetNumRhsEvals"); retval = ARKodeGetNumRhsEvals(mid_arkode_mem, 1, &nfmi); check_flag(retval, "ARKodeGetNumRhsEvals"); + retval = MRIStepGetNumInnerStepperFails(mid_arkode_mem, &nifm); + check_flag(retval, "MRIStepGetNumInnerStepperFails"); // Get some fast integrator statistics long int nstf, nattf, netff, nff; @@ -1056,9 +1060,9 @@ int main(int argc, char* argv[]) errtot = std::sqrt(errtot / SUN_RCONST(3.0) / (sunrealtype)nsts); std::cout << "\nFinal Solver Statistics:\n"; std::cout << " Slow steps = " << nsts << " (attempts = " << natts - << ", fails = " << netfs << ")\n"; + << ", fails = " << netfs << ", innerfails = " << nifs << ")\n"; std::cout << " Intermediate steps = " << nstm << " (attempts = " << nattm - << ", fails = " << netfm << ")\n"; + << ", fails = " << netfm << ", innerfails = " << nifm << ")\n"; std::cout << " Fast steps = " << nstf << " (attempts = " << nattf << ", fails = " << netff << ")\n"; std::cout << " u error = " << uerrtot << ", v error = " << verrtot diff --git a/examples/arkode/CXX_serial/ark_kpr_nestedmri.out b/examples/arkode/CXX_serial/ark_kpr_nestedmri.out index 355b43d35d..5b1c1c4f87 100644 --- a/examples/arkode/CXX_serial/ark_kpr_nestedmri.out +++ b/examples/arkode/CXX_serial/ark_kpr_nestedmri.out @@ -43,8 +43,8 @@ Adaptive nested multirate nonlinear Kvaerno-Prothero-Robinson test problem: ---------------------------------------------------------------------------- Final Solver Statistics: - Slow steps = 25 (attempts = 29, fails = 4) - Intermediate steps = 769 (attempts = 975, fails = 206) + Slow steps = 25 (attempts = 29, fails = 4, innerfails = 0) + Intermediate steps = 769 (attempts = 975, fails = 206, innerfails = 0) Fast steps = 193380 (attempts = 215494, fails = 22114) u error = 0.00784081, v error = 0.0203181, total error = 0.0150336 Relative accuracy = 674.105 diff --git a/include/arkode/arkode_mristep.h b/include/arkode/arkode_mristep.h index 39be4a4407..fe3888bb58 100644 --- a/include/arkode/arkode_mristep.h +++ b/include/arkode/arkode_mristep.h @@ -194,6 +194,8 @@ SUNDIALS_EXPORT int MRIStepSetPostInnerFn(void* arkode_mem, SUNDIALS_EXPORT int MRIStepGetCurrentCoupling(void* arkode_mem, MRIStepCoupling* MRIC); SUNDIALS_EXPORT int MRIStepGetLastInnerStepFlag(void* arkode_mem, int* flag); +SUNDIALS_EXPORT int MRIStepGetNumInnerStepperFails(void* arkode_mem, + long int* inner_fails); /* Custom inner stepper functions */ SUNDIALS_EXPORT int MRIStepInnerStepper_Create(SUNContext sunctx, diff --git a/src/arkode/arkode_mristep.c b/src/arkode/arkode_mristep.c index c3efcb06e2..52237bfa33 100644 --- a/src/arkode/arkode_mristep.c +++ b/src/arkode/arkode_mristep.c @@ -210,12 +210,13 @@ void* MRIStepCreate(ARKRhsFn fse, ARKRhsFn fsi, sunrealtype t0, N_Vector y0, step_mem->eRNrm = ONE; /* Initialize all the counters */ - step_mem->nfse = 0; - step_mem->nfsi = 0; - step_mem->nsetups = 0; - step_mem->nstlp = 0; - step_mem->nls_iters = 0; - step_mem->nls_fails = 0; + step_mem->nfse = 0; + step_mem->nfsi = 0; + step_mem->nsetups = 0; + step_mem->nstlp = 0; + step_mem->nls_iters = 0; + step_mem->nls_fails = 0; + step_mem->inner_fails = 0; /* Initialize fused op work space */ step_mem->cvals = NULL; @@ -352,11 +353,13 @@ int MRIStepReInit(void* arkode_mem, ARKRhsFn fse, ARKRhsFn fsi, sunrealtype t0, step_mem->fsi_is_current = SUNFALSE; /* Initialize all the counters */ - step_mem->nfse = 0; - step_mem->nfsi = 0; - step_mem->nsetups = 0; - step_mem->nstlp = 0; - step_mem->nls_iters = 0; + step_mem->nfse = 0; + step_mem->nfsi = 0; + step_mem->nsetups = 0; + step_mem->nstlp = 0; + step_mem->nls_iters = 0; + step_mem->nls_fails = 0; + step_mem->inner_fails = 0; return (ARK_SUCCESS); } @@ -701,6 +704,8 @@ void mriStep_PrintMem(ARKodeMem ark_mem, FILE* outfile) fprintf(outfile, "MRIStep: nsetups = %li\n", step_mem->nsetups); fprintf(outfile, "MRIStep: nstlp = %li\n", step_mem->nstlp); fprintf(outfile, "MRIStep: nls_iters = %li\n", step_mem->nls_iters); + fprintf(outfile, "MRIStep: nls_fails = %li\n", step_mem->nls_fails); + fprintf(outfile, "MRIStep: inner_fails = %li\n", step_mem->inner_fails); /* output boolean quantities */ fprintf(outfile, "MRIStep: user_linear = %i\n", step_mem->linear); @@ -3453,7 +3458,16 @@ int mriStep_StageERKFast(ARKodeMem ark_mem, ARKodeMRIStepMem step_mem, "Failure when evolving the inner stepper"); return (ARK_INNERSTEP_FAIL); } - if (retval > 0) { return TRY_AGAIN; } + if (retval > 0) + { + /* increment stepper-specific counter, and decrement ARKODE-level nonlinear + solver counter (since that will be incremented automatically by ARKODE). + Return with "TRY_AGAIN" which should cause ARKODE to cut the step size + and retry the step. */ + step_mem->inner_fails++; + ark_mem->ncfn--; + return TRY_AGAIN; + } /* for normal stages (i.e., not the embedding) with MRI adaptivity enabled, get an estimate for the fast time scale error */ diff --git a/src/arkode/arkode_mristep_impl.h b/src/arkode/arkode_mristep_impl.h index 8b4a7d5ac5..0db8ec9768 100644 --- a/src/arkode/arkode_mristep_impl.h +++ b/src/arkode/arkode_mristep_impl.h @@ -140,12 +140,13 @@ typedef struct ARKodeMRIStepMemRec sunrealtype inner_rtol_factor_new; /* upcoming control parameter */ /* Counters */ - long int nfse; /* num fse calls */ - long int nfsi; /* num fsi calls */ - long int nsetups; /* num linear solver setup calls */ - long int nls_iters; /* num nonlinear solver iters */ - long int nls_fails; /* num nonlinear solver fails */ - int nfusedopvecs; /* length of cvals and Xvecs arrays */ + long int nfse; /* num fse calls */ + long int nfsi; /* num fsi calls */ + long int nsetups; /* num linear solver setup calls */ + long int nls_iters; /* num nonlinear solver iters */ + long int nls_fails; /* num nonlinear solver fails */ + long int inner_fails; /* num recov. inner solver fails */ + int nfusedopvecs; /* length of cvals and Xvecs arrays */ /* Data for using MRIStep with external polynomial forcing */ sunbooleantype expforcing; /* add forcing to explicit RHS */ diff --git a/src/arkode/arkode_mristep_io.c b/src/arkode/arkode_mristep_io.c index ed4eab3d5c..3642612870 100644 --- a/src/arkode/arkode_mristep_io.c +++ b/src/arkode/arkode_mristep_io.c @@ -222,6 +222,28 @@ int MRIStepGetLastInnerStepFlag(void* arkode_mem, int* flag) return (ARK_SUCCESS); } +/*--------------------------------------------------------------- + MRIStepGetNumInnerStepperFails: + + Returns the number of recoverable failures encountered by the + inner stepper. + ---------------------------------------------------------------*/ +int MRIStepGetNumInnerStepperFails(void* arkode_mem, long int* inner_fails) +{ + ARKodeMem ark_mem; + ARKodeMRIStepMem step_mem; + int retval; + + /* access ARKodeMem and ARKodeMRIStepMem structures */ + retval = mriStep_AccessARKODEStepMem(arkode_mem, __func__, &ark_mem, &step_mem); + if (retval != ARK_SUCCESS) { return (retval); } + + /* set output from step_mem */ + *inner_fails = step_mem->inner_fails; + + return (ARK_SUCCESS); +} + /*=============================================================== Private functions attached to ARKODE ===============================================================*/ @@ -811,7 +833,9 @@ int mriStep_PrintAllStats(ARKodeMem ark_mem, FILE* outfile, SUNOutputFormat fmt) fprintf(outfile, "Explicit slow RHS fn evals = %ld\n", step_mem->nfse); fprintf(outfile, "Implicit slow RHS fn evals = %ld\n", step_mem->nfsi); - /* nonlinear solver stats */ + /* inner stepper and nonlinear solver stats */ + fprintf(outfile, "Inner stepper failures = %ld\n", + step_mem->inner_fails); fprintf(outfile, "NLS iters = %ld\n", step_mem->nls_iters); fprintf(outfile, "NLS fails = %ld\n", step_mem->nls_fails); if (ark_mem->nst > 0) @@ -852,7 +876,8 @@ int mriStep_PrintAllStats(ARKodeMem ark_mem, FILE* outfile, SUNOutputFormat fmt) fprintf(outfile, ",Explicit slow RHS fn evals,%ld", step_mem->nfse); fprintf(outfile, ",Implicit slow RHS fn evals,%ld", step_mem->nfsi); - /* nonlinear solver stats */ + /* inner stepper and nonlinear solver stats */ + fprintf(outfile, ",Inner stepper failures,%ld", step_mem->inner_fails); fprintf(outfile, ",NLS iters,%ld", step_mem->nls_iters); fprintf(outfile, ",NLS fails,%ld", step_mem->nls_fails); if (ark_mem->nst > 0) From e3bd2df9065397003cd5d098cf064053008f2f5f Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Fri, 1 Nov 2024 15:59:53 -0500 Subject: [PATCH 233/286] Updated Swig interfaces --- src/arkode/fmod_int32/farkode_mristep_mod.c | 14 ++++++++++ src/arkode/fmod_int32/farkode_mristep_mod.f90 | 26 +++++++++++++++++++ src/arkode/fmod_int64/farkode_mristep_mod.c | 14 ++++++++++ src/arkode/fmod_int64/farkode_mristep_mod.f90 | 26 +++++++++++++++++++ 4 files changed, 80 insertions(+) diff --git a/src/arkode/fmod_int32/farkode_mristep_mod.c b/src/arkode/fmod_int32/farkode_mristep_mod.c index 8f665dde6e..f882275ea2 100644 --- a/src/arkode/fmod_int32/farkode_mristep_mod.c +++ b/src/arkode/fmod_int32/farkode_mristep_mod.c @@ -813,6 +813,20 @@ SWIGEXPORT int _wrap_FMRIStepGetLastInnerStepFlag(void *farg1, int *farg2) { } +SWIGEXPORT int _wrap_FMRIStepGetNumInnerStepperFails(void *farg1, long *farg2) { + int fresult ; + void *arg1 = (void *) 0 ; + long *arg2 = (long *) 0 ; + int result; + + arg1 = (void *)(farg1); + arg2 = (long *)(farg2); + result = (int)MRIStepGetNumInnerStepperFails(arg1,arg2); + fresult = (int)(result); + return fresult; +} + + SWIGEXPORT int _wrap_FMRIStepInnerStepper_Create(void *farg1, void *farg2) { int fresult ; SUNContext arg1 = (SUNContext) 0 ; diff --git a/src/arkode/fmod_int32/farkode_mristep_mod.f90 b/src/arkode/fmod_int32/farkode_mristep_mod.f90 index 879eb8d9ed..86b8833d43 100644 --- a/src/arkode/fmod_int32/farkode_mristep_mod.f90 +++ b/src/arkode/fmod_int32/farkode_mristep_mod.f90 @@ -154,6 +154,7 @@ module farkode_mristep_mod public :: FMRIStepSetPostInnerFn public :: FMRIStepGetCurrentCoupling public :: FMRIStepGetLastInnerStepFlag + public :: FMRIStepGetNumInnerStepperFails public :: FMRIStepInnerStepper_Create public :: FMRIStepInnerStepper_Free public :: FMRIStepInnerStepper_SetContent @@ -598,6 +599,15 @@ function swigc_FMRIStepGetLastInnerStepFlag(farg1, farg2) & integer(C_INT) :: fresult end function +function swigc_FMRIStepGetNumInnerStepperFails(farg1, farg2) & +bind(C, name="_wrap_FMRIStepGetNumInnerStepperFails") & +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_FMRIStepInnerStepper_Create(farg1, farg2) & bind(C, name="_wrap_FMRIStepInnerStepper_Create") & result(fresult) @@ -2094,6 +2104,22 @@ function FMRIStepGetLastInnerStepFlag(arkode_mem, flag) & swig_result = fresult end function +function FMRIStepGetNumInnerStepperFails(arkode_mem, inner_fails) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(C_PTR) :: arkode_mem +integer(C_LONG), dimension(*), target, intent(inout) :: inner_fails +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 + +farg1 = arkode_mem +farg2 = c_loc(inner_fails(1)) +fresult = swigc_FMRIStepGetNumInnerStepperFails(farg1, farg2) +swig_result = fresult +end function + function FMRIStepInnerStepper_Create(sunctx, stepper) & result(swig_result) use, intrinsic :: ISO_C_BINDING diff --git a/src/arkode/fmod_int64/farkode_mristep_mod.c b/src/arkode/fmod_int64/farkode_mristep_mod.c index 1eec16bb13..b6e3b0483b 100644 --- a/src/arkode/fmod_int64/farkode_mristep_mod.c +++ b/src/arkode/fmod_int64/farkode_mristep_mod.c @@ -813,6 +813,20 @@ SWIGEXPORT int _wrap_FMRIStepGetLastInnerStepFlag(void *farg1, int *farg2) { } +SWIGEXPORT int _wrap_FMRIStepGetNumInnerStepperFails(void *farg1, long *farg2) { + int fresult ; + void *arg1 = (void *) 0 ; + long *arg2 = (long *) 0 ; + int result; + + arg1 = (void *)(farg1); + arg2 = (long *)(farg2); + result = (int)MRIStepGetNumInnerStepperFails(arg1,arg2); + fresult = (int)(result); + return fresult; +} + + SWIGEXPORT int _wrap_FMRIStepInnerStepper_Create(void *farg1, void *farg2) { int fresult ; SUNContext arg1 = (SUNContext) 0 ; diff --git a/src/arkode/fmod_int64/farkode_mristep_mod.f90 b/src/arkode/fmod_int64/farkode_mristep_mod.f90 index 395babfce3..59dfb37340 100644 --- a/src/arkode/fmod_int64/farkode_mristep_mod.f90 +++ b/src/arkode/fmod_int64/farkode_mristep_mod.f90 @@ -154,6 +154,7 @@ module farkode_mristep_mod public :: FMRIStepSetPostInnerFn public :: FMRIStepGetCurrentCoupling public :: FMRIStepGetLastInnerStepFlag + public :: FMRIStepGetNumInnerStepperFails public :: FMRIStepInnerStepper_Create public :: FMRIStepInnerStepper_Free public :: FMRIStepInnerStepper_SetContent @@ -598,6 +599,15 @@ function swigc_FMRIStepGetLastInnerStepFlag(farg1, farg2) & integer(C_INT) :: fresult end function +function swigc_FMRIStepGetNumInnerStepperFails(farg1, farg2) & +bind(C, name="_wrap_FMRIStepGetNumInnerStepperFails") & +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_FMRIStepInnerStepper_Create(farg1, farg2) & bind(C, name="_wrap_FMRIStepInnerStepper_Create") & result(fresult) @@ -2094,6 +2104,22 @@ function FMRIStepGetLastInnerStepFlag(arkode_mem, flag) & swig_result = fresult end function +function FMRIStepGetNumInnerStepperFails(arkode_mem, inner_fails) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(C_PTR) :: arkode_mem +integer(C_LONG), dimension(*), target, intent(inout) :: inner_fails +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 + +farg1 = arkode_mem +farg2 = c_loc(inner_fails(1)) +fresult = swigc_FMRIStepGetNumInnerStepperFails(farg1, farg2) +swig_result = fresult +end function + function FMRIStepInnerStepper_Create(sunctx, stepper) & result(swig_result) use, intrinsic :: ISO_C_BINDING From 6bc2f06199081ed9670246af8d2160914e59db12 Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Fri, 1 Nov 2024 16:10:46 -0500 Subject: [PATCH 234/286] Updated answers repository commit --- test/answers | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/answers b/test/answers index 2ae1822304..7cdd3dc68d 160000 --- a/test/answers +++ b/test/answers @@ -1 +1 @@ -Subproject commit 2ae182230435af05ddcb312e7a1decef32a865e6 +Subproject commit 7cdd3dc68d550ff1f97ef96c33ccc205fae05d1c From f49cb8777972ce27d093e7528492cd1f4d52ece4 Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Fri, 1 Nov 2024 16:29:20 -0500 Subject: [PATCH 235/286] Updated answers repository commit --- test/answers | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/answers b/test/answers index 7cdd3dc68d..0bfe38373e 160000 --- a/test/answers +++ b/test/answers @@ -1 +1 @@ -Subproject commit 7cdd3dc68d550ff1f97ef96c33ccc205fae05d1c +Subproject commit 0bfe38373ec290e46247dc950581389dda9ce2f3 From c13b9eca4f9bb693cbba55df26e6e9d086c69a0c Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Sat, 2 Nov 2024 12:03:28 -0500 Subject: [PATCH 236/286] Removed heuristic DSM floor for MRIStep controller interface --- src/arkode/arkode_mristep_controller.c | 7 ------- 1 file changed, 7 deletions(-) diff --git a/src/arkode/arkode_mristep_controller.c b/src/arkode/arkode_mristep_controller.c index f0e399b58d..4e026c061f 100644 --- a/src/arkode/arkode_mristep_controller.c +++ b/src/arkode/arkode_mristep_controller.c @@ -22,10 +22,6 @@ #include "arkode_impl.h" #include "arkode_mristep_impl.h" -/* SUNAdaptController_MRIStep heuristic constant: */ -/* minimum estimated temporal error for inner solver */ -#define INNER_MIN_DSM SUNRsqrt(SUN_UNIT_ROUNDOFF) - /*-------------------------------------------- MRIStep SUNAdaptController wrapper functions --------------------------------------------*/ @@ -92,9 +88,6 @@ SUNErrCode SUNAdaptController_EstimateStep_MRIStep(SUNAdaptController C, ARKodeMRIStepMem step_mem = MRICONTROL_S(C); if ((ark_mem == NULL) || (step_mem == NULL)) { return SUN_ERR_MEM_FAIL; } - /* Enforce bound on inner_dsm */ - step_mem->inner_dsm = SUNMAX(step_mem->inner_dsm, INNER_MIN_DSM); - /* Estimate slow stepsize from MRI controller */ return SUNAdaptController_EstimateStepTol(MRICONTROL_C(C), H, step_mem->inner_rtol_factor, P, DSM, From 7a1c8c2c423140c5b7192db04118e39e342dca3c Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Mon, 4 Nov 2024 08:32:37 -0600 Subject: [PATCH 237/286] Fixed duplicate equation label --- doc/arkode/guide/source/Mathematics.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/arkode/guide/source/Mathematics.rst b/doc/arkode/guide/source/Mathematics.rst index 7222bee571..17e35498de 100644 --- a/doc/arkode/guide/source/Mathematics.rst +++ b/doc/arkode/guide/source/Mathematics.rst @@ -1133,7 +1133,7 @@ an "additive accumulation" strategy, .. math:: \varepsilon^F_{sum} = \text{RTOL}^F \sum_{m\in \mathcal{S}} \|\varepsilon^F_{n,m}\|_{WRMS}, - :label: maximum_accumulation + :label: additive_accumulation or using an "averaged accumulation" strategy, From 779933538f0a6952274166be93addf687ec25109 Mon Sep 17 00:00:00 2001 From: "David J. Gardner" Date: Mon, 4 Nov 2024 09:14:11 -0800 Subject: [PATCH 238/286] update output files --- .../arkode/CXX_serial/ark_kpr_nestedmri.out | 52 ++++---- .../C_serial/ark_kpr_mri_11_2_0.001.out | 102 +++++++-------- .../arkode/C_serial/ark_kpr_mri_6_5_0.001.out | 2 +- .../C_serial/ark_reaction_diffusion_mri.out | 1 + ...rk_test_accumerror_brusselator_20_-4_0.out | 28 ++-- ...ark_test_accumerror_brusselator_20_5_0.out | 120 +++++++++--------- .../ark_test_accumerror_kpr_20_-4_1.out | 50 ++++---- ..._mriadapt_--rtol_0.000004_--scontrol_0.out | 37 +++--- ...-hs_0.002_--rtol_0.000004_--scontrol_0.out | 39 +++--- .../ark_test_slowerror_brusselator.out | 60 ++++----- .../CXX_serial/ark_test_slowerror_kpr.out | 72 +++++------ 11 files changed, 283 insertions(+), 280 deletions(-) diff --git a/examples/arkode/CXX_serial/ark_kpr_nestedmri.out b/examples/arkode/CXX_serial/ark_kpr_nestedmri.out index 5b1c1c4f87..f45a637e61 100644 --- a/examples/arkode/CXX_serial/ark_kpr_nestedmri.out +++ b/examples/arkode/CXX_serial/ark_kpr_nestedmri.out @@ -20,32 +20,32 @@ Adaptive nested multirate nonlinear Kvaerno-Prothero-Robinson test problem: t u v w uerr verr werr ---------------------------------------------------------------------------- 0.000000 1.581139 1.732051 1.732051 0.00e+00 0.00e+00 0.00e+00 - 0.306567 1.573663 1.057506 1.707888 6.57e-05 1.14e-05 6.66e-05 - 0.679173 1.545173 1.190170 1.007373 4.54e-04 1.92e-04 1.36e-04 - 0.898497 1.519773 1.357245 1.554645 4.76e-04 2.75e-05 1.79e-04 - 1.117820 1.488989 1.729585 1.161054 4.89e-04 6.14e-05 1.24e-04 - 1.337144 1.454037 0.999230 1.011387 4.37e-04 3.78e-04 1.56e-04 - 1.556467 1.416269 1.033661 1.136147 3.76e-04 1.76e-04 1.53e-04 - 1.775791 1.377419 1.045312 1.049355 2.46e-04 8.35e-05 3.18e-04 - 2.277112 1.294563 1.677791 1.277956 2.12e-04 9.38e-05 5.83e-04 - 2.492214 1.265827 1.094693 1.620888 2.52e-04 1.65e-05 3.87e-04 - 2.707315 1.243852 1.103429 1.727904 3.37e-04 1.60e-04 3.32e-04 - 2.922416 1.229985 1.543386 1.101349 4.05e-04 2.55e-05 4.51e-04 - 3.137517 1.225306 1.544485 1.144447 5.86e-04 4.32e-05 3.03e-04 - 3.333351 1.228952 1.730946 1.666254 4.60e-04 2.32e-05 8.09e-06 - 3.524276 1.239836 1.502950 1.007933 3.97e-04 2.62e-05 1.54e-05 - 3.906127 1.280639 1.681423 1.730832 3.32e-04 1.82e-05 1.44e-04 - 4.097053 1.308487 1.731560 1.040636 2.72e-04 2.71e-05 1.52e-04 - 4.287978 1.339687 1.289705 1.670830 2.29e-04 3.01e-05 9.21e-05 - 4.669829 1.406791 1.536669 1.124555 1.25e-04 3.16e-04 7.84e-05 - 4.964361 1.457698 1.001374 1.699997 7.52e-05 2.06e-04 4.93e-05 - 5.258893 1.502725 1.608602 1.573351 3.92e-02 1.02e-01 7.14e-02 + 0.250000 1.576193 1.693804 1.005260 3.23e-06 1.18e-04 7.57e-05 + 0.500000 1.561425 1.094399 1.236935 2.15e-08 1.54e-05 2.85e-05 + 0.750000 1.537204 1.480202 1.289772 8.95e-04 1.47e-04 2.43e-04 + 1.000000 1.506472 1.658437 1.566267 2.26e-07 2.27e-05 1.87e-05 + 1.250000 1.468674 1.117329 1.128753 4.45e-06 8.37e-05 5.27e-06 + 1.500000 1.426602 1.451384 1.383651 1.49e-07 4.03e-06 2.37e-05 + 1.750000 1.382272 1.731275 1.400561 3.01e-05 6.40e-05 1.96e-04 + 2.000000 1.338548 1.576713 1.004568 1.72e-05 4.85e-05 3.52e-04 + 2.250000 1.298433 1.357466 1.203013 3.98e-06 7.57e-06 1.04e-04 + 2.500000 1.264637 1.111610 1.079957 3.74e-07 2.59e-05 3.61e-04 + 2.750000 1.240344 1.181466 1.688515 2.92e-06 3.40e-06 6.04e-05 + 3.000000 1.226753 1.199667 1.243892 3.15e-06 2.39e-06 5.78e-05 + 3.250000 1.225940 1.337036 1.695808 8.05e-05 2.56e-05 5.93e-05 + 3.500000 1.237625 1.494269 1.577837 3.48e-05 1.55e-06 2.09e-05 + 3.750000 1.261615 1.441503 1.440542 1.35e-07 1.70e-08 6.25e-06 + 4.000000 1.293574 1.067975 1.718719 4.77e-05 2.22e-05 1.30e-04 + 4.250000 1.333622 1.725039 1.003950 1.49e-11 6.53e-14 5.93e-10 + 4.500000 1.376484 1.650381 1.499914 2.63e-08 1.70e-06 6.88e-07 + 4.750000 1.420897 1.555399 1.167629 4.82e-08 1.80e-08 5.03e-06 + 5.000000 1.463498 1.506851 1.644668 7.85e-07 1.26e-05 2.66e-05 ---------------------------------------------------------------------------- Final Solver Statistics: - Slow steps = 25 (attempts = 29, fails = 4, innerfails = 0) - Intermediate steps = 769 (attempts = 975, fails = 206, innerfails = 0) - Fast steps = 193380 (attempts = 215494, fails = 22114) - u error = 0.00784081, v error = 0.0203181, total error = 0.0150336 - Relative accuracy = 674.105 - Total RHS evals: Fse = 142, Fsi = 0, Fme = 4670, Fmi = 0, Ff = 1055358 + Slow steps = 47 (attempts = 48, fails = 1, innerfails = 0) + Intermediate steps = 714 (attempts = 868, fails = 154, innerfails = 0) + Fast steps = 129455 (attempts = 144940, fails = 15485) + u error = 0.000228112, v error = 8.70956e-05, total error = 0.000169225 + Relative accuracy = 6.75352 + Total RHS evals: Fse = 240, Fsi = 0, Fme = 4187, Fmi = 0, Ff = 709217 diff --git a/examples/arkode/C_serial/ark_kpr_mri_11_2_0.001.out b/examples/arkode/C_serial/ark_kpr_mri_11_2_0.001.out index 6ace2a0eae..0e1f1aff7f 100644 --- a/examples/arkode/C_serial/ark_kpr_mri_11_2_0.001.out +++ b/examples/arkode/C_serial/ark_kpr_mri_11_2_0.001.out @@ -12,61 +12,61 @@ Multirate nonlinear Kvaerno-Prothero-Robinson test problem: t u v uerr verr ------------------------------------------------------ 0.000000 1.224745 1.732051 0.00e+00 0.00e+00 - 0.100000 1.223724 1.077464 3.41e-07 4.18e-08 - 0.200000 1.220669 1.551800 4.37e-07 9.15e-09 - 0.300000 1.215593 1.467737 1.19e-06 1.93e-08 - 0.400000 1.208524 1.154583 5.25e-07 3.04e-09 - 0.500000 1.199497 1.721908 2.75e-07 4.77e-08 - 0.600000 1.188557 1.023517 8.00e-08 1.04e-08 - 0.700000 1.175764 1.622750 3.49e-07 5.45e-08 - 0.800000 1.161186 1.374632 2.49e-07 5.22e-08 - 0.900000 1.144903 1.245763 5.52e-07 4.13e-08 - 1.000000 1.127010 1.691839 2.30e-07 7.24e-08 - 1.100000 1.107609 1.000489 4.75e-08 1.07e-08 - 1.200000 1.086820 1.677552 2.41e-07 8.61e-08 - 1.300000 1.064776 1.277775 2.56e-07 6.28e-08 - 1.400000 1.041625 1.342455 5.27e-07 6.87e-08 - 1.500000 1.017531 1.642940 6.76e-08 8.58e-08 - 1.600000 0.992673 1.012112 1.98e-07 3.21e-08 - 1.700000 0.967253 1.714058 6.85e-08 1.01e-07 - 1.800000 0.941487 1.183866 9.72e-07 6.42e-08 - 1.900000 0.915617 1.437465 5.69e-07 8.59e-08 - 2.000000 0.889902 1.577082 5.85e-07 9.51e-08 - 2.100000 0.864625 1.056467 3.94e-07 4.96e-08 - 2.200000 0.840089 1.730920 1.99e-07 1.03e-07 - 2.300000 0.816616 1.101047 5.02e-07 5.52e-08 - 2.400000 0.794545 1.525051 5.04e-07 9.24e-08 - 2.500000 0.774227 1.496993 1.29e-07 9.43e-08 - 2.600000 0.756012 1.126857 5.61e-07 6.08e-08 - 2.700000 0.740246 1.727536 1.76e-07 1.06e-07 - 2.800000 0.727247 1.038393 2.22e-07 4.56e-08 - 2.900000 0.717301 1.600759 4.60e-07 1.01e-07 - 3.000000 0.710636 1.406379 1.73e-07 8.99e-08 - 3.100000 0.707412 1.214353 5.27e-07 7.13e-08 - 3.200000 0.707710 1.704026 1.97e-07 1.04e-07 - 3.300000 0.711519 1.004391 1.04e-07 4.02e-08 - 3.400000 0.718749 1.661225 2.20e-07 1.04e-07 - 3.500000 0.729226 1.310102 2.64e-07 8.23e-08 - 3.600000 0.742711 1.310080 3.67e-07 8.33e-08 - 3.700000 0.758914 1.661237 1.20e-08 1.02e-07 - 3.800000 0.777506 1.004387 1.78e-07 4.32e-08 - 3.900000 0.798144 1.704018 1.64e-08 1.06e-07 - 4.000000 0.820473 1.214374 1.14e-06 7.40e-08 - 4.100000 0.844149 1.406358 4.80e-07 9.06e-08 - 4.200000 0.868832 1.600774 4.07e-07 1.01e-07 - 4.300000 0.894203 1.038382 3.42e-07 5.61e-08 - 4.400000 0.919964 1.727533 1.65e-07 1.12e-07 - 4.500000 0.945833 1.126875 6.61e-07 6.93e-08 - 4.600000 0.971557 1.496973 5.02e-07 9.91e-08 - 4.700000 0.996897 1.525070 9.23e-07 1.04e-07 - 4.800000 1.021640 1.101030 4.76e-07 6.78e-08 - 4.900000 1.045589 1.730922 3.12e-07 1.11e-07 - 5.000000 1.068565 1.056480 2.37e-07 5.32e-08 + 0.100000 1.223724 1.077464 3.33e-07 4.20e-08 + 0.200000 1.220669 1.551800 4.24e-07 8.82e-09 + 0.300000 1.215593 1.467737 1.15e-06 1.85e-08 + 0.400000 1.208524 1.154583 5.07e-07 2.01e-09 + 0.500000 1.199497 1.721908 2.65e-07 4.66e-08 + 0.600000 1.188557 1.023517 7.96e-08 1.16e-08 + 0.700000 1.175764 1.622750 3.38e-07 5.31e-08 + 0.800000 1.161186 1.374632 2.38e-07 5.04e-08 + 0.900000 1.144903 1.245763 5.34e-07 3.96e-08 + 1.000000 1.127010 1.691839 2.21e-07 7.06e-08 + 1.100000 1.107609 1.000489 4.62e-08 8.93e-09 + 1.200000 1.086820 1.677552 2.34e-07 8.40e-08 + 1.300000 1.064776 1.277775 2.44e-07 6.06e-08 + 1.400000 1.041625 1.342455 5.10e-07 6.65e-08 + 1.500000 1.017531 1.642940 6.50e-08 8.37e-08 + 1.600000 0.992673 1.012112 1.90e-07 2.98e-08 + 1.700000 0.967253 1.714058 6.43e-08 9.85e-08 + 1.800000 0.941487 1.183866 9.42e-07 6.17e-08 + 1.900000 0.915617 1.437465 5.51e-07 8.34e-08 + 2.000000 0.889902 1.577082 5.63e-07 9.25e-08 + 2.100000 0.864625 1.056467 3.79e-07 4.69e-08 + 2.200000 0.840089 1.730920 1.91e-07 1.00e-07 + 2.300000 0.816616 1.101047 4.88e-07 5.26e-08 + 2.400000 0.794545 1.525051 4.88e-07 8.97e-08 + 2.500000 0.774227 1.496993 1.22e-07 9.15e-08 + 2.600000 0.756012 1.126857 5.41e-07 5.80e-08 + 2.700000 0.740246 1.727536 1.69e-07 1.03e-07 + 2.800000 0.727247 1.038393 2.16e-07 4.27e-08 + 2.900000 0.717301 1.600759 4.45e-07 9.79e-08 + 3.000000 0.710636 1.406379 1.65e-07 8.68e-08 + 3.100000 0.707412 1.214353 5.06e-07 6.83e-08 + 3.200000 0.707710 1.704026 1.90e-07 1.01e-07 + 3.300000 0.711519 1.004391 1.00e-07 3.71e-08 + 3.400000 0.718749 1.661225 2.14e-07 1.00e-07 + 3.500000 0.729226 1.310102 2.53e-07 7.91e-08 + 3.600000 0.742711 1.310080 3.52e-07 8.01e-08 + 3.700000 0.758914 1.661237 1.20e-08 9.86e-08 + 3.800000 0.777506 1.004387 1.70e-07 3.99e-08 + 3.900000 0.798144 1.704018 1.75e-08 1.03e-07 + 4.000000 0.820473 1.214374 1.10e-06 7.07e-08 + 4.100000 0.844149 1.406358 4.60e-07 8.74e-08 + 4.200000 0.868832 1.600774 3.92e-07 9.77e-08 + 4.300000 0.894203 1.038382 3.30e-07 5.28e-08 + 4.400000 0.919964 1.727533 1.58e-07 1.08e-07 + 4.500000 0.945833 1.126875 6.42e-07 6.60e-08 + 4.600000 0.971557 1.496973 4.87e-07 9.60e-08 + 4.700000 0.996897 1.525070 8.90e-07 1.01e-07 + 4.800000 1.021640 1.101030 4.60e-07 6.45e-08 + 4.900000 1.045589 1.730922 3.00e-07 1.08e-07 + 5.000000 1.068565 1.056480 2.32e-07 5.02e-08 ------------------------------------------------------ Final Solver Statistics: Steps: nsts = 5000, nstf = 935000 - u error = 4.564e-07, v error = 7.637e-08, total error = 3.272e-07 + u error = 4.409e-07, v error = 7.386e-08, total error = 3.161e-07 Total RHS evals: Fse = 15001, Fsi = 32981, Ff = 1870050 Slow Newton iters = 17980 Slow Newton conv fails = 0 diff --git a/examples/arkode/C_serial/ark_kpr_mri_6_5_0.001.out b/examples/arkode/C_serial/ark_kpr_mri_6_5_0.001.out index a60e450a90..2f083931c6 100644 --- a/examples/arkode/C_serial/ark_kpr_mri_6_5_0.001.out +++ b/examples/arkode/C_serial/ark_kpr_mri_6_5_0.001.out @@ -66,4 +66,4 @@ Multirate nonlinear Kvaerno-Prothero-Robinson test problem: Final Solver Statistics: Steps: nsts = 5000, nstf = 1615000 u error = 4.211e-13, v error = 8.987e-12, total error = 6.362e-12 - Total RHS evals: Fs = 50051, Ff = 9715100 + Total RHS evals: Fs = 50051, Ff = 9710101 diff --git a/examples/arkode/C_serial/ark_reaction_diffusion_mri.out b/examples/arkode/C_serial/ark_reaction_diffusion_mri.out index f8cd47dfdc..aae34dd19e 100644 --- a/examples/arkode/C_serial/ark_reaction_diffusion_mri.out +++ b/examples/arkode/C_serial/ark_reaction_diffusion_mri.out @@ -51,6 +51,7 @@ Last step size = 0.001 Current step size = 0.001 Explicit slow RHS fn evals = 9004 Implicit slow RHS fn evals = 0 +Inner stepper failures = 0 NLS iters = 0 NLS fails = 0 NLS iters per step = 0 diff --git a/test/unit_tests/arkode/CXX_serial/ark_test_accumerror_brusselator_20_-4_0.out b/test/unit_tests/arkode/CXX_serial/ark_test_accumerror_brusselator_20_-4_0.out index 029ea6d134..717234ba15 100644 --- a/test/unit_tests/arkode/CXX_serial/ark_test_accumerror_brusselator_20_-4_0.out +++ b/test/unit_tests/arkode/CXX_serial/ark_test_accumerror_brusselator_20_-4_0.out @@ -287,26 +287,26 @@ Fixed-step runs: h 0.000390625 rk_type 0 order 4 acc 2 t 9 dsm 2.496e-11 dsm_est 5.49027e-13 nsteps 1281 h 0.000390625 rk_type 0 order 4 acc 2 t 9.5 dsm 1.2967e-11 dsm_est 1.50929e-12 nsteps 1281 h 0.000390625 rk_type 0 order 4 acc 2 t 10 dsm 4.44606e-12 dsm_est 8.49403e-13 nsteps 1281 - h 0.000390625 rk_type 0 order 4 acc 3 t 0.5 dsm 4.75504e-11 dsm_est 4.32867e-07 nsteps 1281 - h 0.000390625 rk_type 0 order 4 acc 3 t 1 dsm 8.83253e-12 dsm_est 1.65206e-16 nsteps 1281 + h 0.000390625 rk_type 0 order 4 acc 3 t 0.5 dsm 4.75504e-11 dsm_est 4.33205e-07 nsteps 1281 + h 0.000390625 rk_type 0 order 4 acc 3 t 1 dsm 8.83253e-12 dsm_est 1.65335e-16 nsteps 1281 h 0.000390625 rk_type 0 order 4 acc 3 t 1.5 dsm 1.8399e-12 dsm_est 1.14767e-16 nsteps 1280 h 0.000390625 rk_type 0 order 4 acc 3 t 2 dsm 2.21232e-13 dsm_est 6.3138e-17 nsteps 1280 h 0.000390625 rk_type 0 order 4 acc 3 t 2.5 dsm 5.57029e-13 dsm_est 4.78256e-17 nsteps 1280 h 0.000390625 rk_type 0 order 4 acc 3 t 3 dsm 6.33194e-12 dsm_est 9.84357e-17 nsteps 1280 h 0.000390625 rk_type 0 order 4 acc 3 t 3.5 dsm 4.31407e-12 dsm_est 1.14709e-16 nsteps 1280 h 0.000390625 rk_type 0 order 4 acc 3 t 4 dsm 5.25853e-12 dsm_est 6.48108e-17 nsteps 1280 - h 0.000390625 rk_type 0 order 4 acc 3 t 4.5 dsm 3.00881e-11 dsm_est 5.75437e-17 nsteps 1281 - h 0.000390625 rk_type 0 order 4 acc 3 t 5 dsm 1.04964e-12 dsm_est 1.8087e-16 nsteps 1281 - h 0.000390625 rk_type 0 order 4 acc 3 t 5.5 dsm 6.97849e-12 dsm_est 6.30545e-17 nsteps 1281 - h 0.000390625 rk_type 0 order 4 acc 3 t 6 dsm 5.9817e-11 dsm_est 1.32311e-16 nsteps 1281 - h 0.000390625 rk_type 0 order 4 acc 3 t 6.5 dsm 1.43381e-11 dsm_est 9.62831e-15 nsteps 1281 - h 0.000390625 rk_type 0 order 4 acc 3 t 7 dsm 2.94602e-12 dsm_est 1.83666e-12 nsteps 1281 - h 0.000390625 rk_type 0 order 4 acc 3 t 7.5 dsm 1.82124e-11 dsm_est 1.00979e-13 nsteps 1281 - h 0.000390625 rk_type 0 order 4 acc 3 t 8 dsm 1.77421e-10 dsm_est 3.54707e-15 nsteps 1281 - h 0.000390625 rk_type 0 order 4 acc 3 t 8.5 dsm 2.81466e-12 dsm_est 1.71467e-15 nsteps 1281 - h 0.000390625 rk_type 0 order 4 acc 3 t 9 dsm 2.496e-11 dsm_est 4.28593e-16 nsteps 1281 - h 0.000390625 rk_type 0 order 4 acc 3 t 9.5 dsm 1.2967e-11 dsm_est 1.17821e-15 nsteps 1281 - h 0.000390625 rk_type 0 order 4 acc 3 t 10 dsm 4.44606e-12 dsm_est 6.63078e-16 nsteps 1281 + h 0.000390625 rk_type 0 order 4 acc 3 t 4.5 dsm 3.00881e-11 dsm_est 5.75886e-17 nsteps 1281 + h 0.000390625 rk_type 0 order 4 acc 3 t 5 dsm 1.04964e-12 dsm_est 1.81011e-16 nsteps 1281 + h 0.000390625 rk_type 0 order 4 acc 3 t 5.5 dsm 6.97849e-12 dsm_est 6.31038e-17 nsteps 1281 + h 0.000390625 rk_type 0 order 4 acc 3 t 6 dsm 5.9817e-11 dsm_est 1.32414e-16 nsteps 1281 + h 0.000390625 rk_type 0 order 4 acc 3 t 6.5 dsm 1.43381e-11 dsm_est 9.63583e-15 nsteps 1281 + h 0.000390625 rk_type 0 order 4 acc 3 t 7 dsm 2.94602e-12 dsm_est 1.8381e-12 nsteps 1281 + h 0.000390625 rk_type 0 order 4 acc 3 t 7.5 dsm 1.82124e-11 dsm_est 1.01058e-13 nsteps 1281 + h 0.000390625 rk_type 0 order 4 acc 3 t 8 dsm 1.77421e-10 dsm_est 3.54984e-15 nsteps 1281 + h 0.000390625 rk_type 0 order 4 acc 3 t 8.5 dsm 2.81466e-12 dsm_est 1.71601e-15 nsteps 1281 + h 0.000390625 rk_type 0 order 4 acc 3 t 9 dsm 2.496e-11 dsm_est 4.28927e-16 nsteps 1281 + h 0.000390625 rk_type 0 order 4 acc 3 t 9.5 dsm 1.2967e-11 dsm_est 1.17913e-15 nsteps 1281 + h 0.000390625 rk_type 0 order 4 acc 3 t 10 dsm 4.44606e-12 dsm_est 6.63596e-16 nsteps 1281 h 0.000390625 rk_type 0 order 4 acc 2 t 0.5 dsm 4.75504e-11 dsm_est 2.63435e-10 nsteps 1921 h 0.000390625 rk_type 0 order 4 acc 2 t 1 dsm 8.83253e-12 dsm_est 2.03794e-15 nsteps 1922 h 0.000390625 rk_type 0 order 4 acc 2 t 1.5 dsm 1.8399e-12 dsm_est 3.00814e-14 nsteps 1920 diff --git a/test/unit_tests/arkode/CXX_serial/ark_test_accumerror_brusselator_20_5_0.out b/test/unit_tests/arkode/CXX_serial/ark_test_accumerror_brusselator_20_5_0.out index 4fb78b4cf9..36b63bfbfd 100644 --- a/test/unit_tests/arkode/CXX_serial/ark_test_accumerror_brusselator_20_5_0.out +++ b/test/unit_tests/arkode/CXX_serial/ark_test_accumerror_brusselator_20_5_0.out @@ -47,26 +47,26 @@ Adaptive-step runs: rtol 0.01 rk_type 0 order 5 acc 2 t 9 dsm 0.00058073 dsm_est 4.93642e-06 nsteps 6 rtol 0.01 rk_type 0 order 5 acc 2 t 9.5 dsm 6.70214e-05 dsm_est 2.55332e-06 nsteps 6 rtol 0.01 rk_type 0 order 5 acc 2 t 10 dsm 0.000490488 dsm_est 4.66143e-06 nsteps 6 - rtol 0.01 rk_type 0 order 5 acc 3 t 0.5 dsm 7.48644e-05 dsm_est 6.06577e-06 nsteps 9 - rtol 0.01 rk_type 0 order 5 acc 3 t 1 dsm 0.000110257 dsm_est 4.46624e-07 nsteps 5 - rtol 0.01 rk_type 0 order 5 acc 3 t 1.5 dsm 0.00132404 dsm_est 3.96295e-07 nsteps 6 - rtol 0.01 rk_type 0 order 5 acc 3 t 2 dsm 0.00110273 dsm_est 1.36233e-07 nsteps 6 - rtol 0.01 rk_type 0 order 5 acc 3 t 2.5 dsm 6.10485e-05 dsm_est 5.46756e-08 nsteps 6 - rtol 0.01 rk_type 0 order 5 acc 3 t 3 dsm 0.000275174 dsm_est 1.12723e-07 nsteps 6 - rtol 0.01 rk_type 0 order 5 acc 3 t 3.5 dsm 0.00032811 dsm_est 2.82543e-07 nsteps 6 - rtol 0.01 rk_type 0 order 5 acc 3 t 4 dsm 7.35974e-05 dsm_est 8.23161e-08 nsteps 6 - rtol 0.01 rk_type 0 order 5 acc 3 t 4.5 dsm 0.000394423 dsm_est 2.90774e-07 nsteps 6 - rtol 0.01 rk_type 0 order 5 acc 3 t 5 dsm 4.44693e-05 dsm_est 8.19327e-08 nsteps 6 - rtol 0.01 rk_type 0 order 5 acc 3 t 5.5 dsm 0.000153383 dsm_est 1.38044e-07 nsteps 5 - rtol 0.01 rk_type 0 order 5 acc 3 t 6 dsm 0.00039377 dsm_est 7.71683e-07 nsteps 6 - rtol 0.01 rk_type 0 order 5 acc 3 t 6.5 dsm 0.000506258 dsm_est 2.97917e-07 nsteps 6 - rtol 0.01 rk_type 0 order 5 acc 3 t 7 dsm 0.00148699 dsm_est 6.06974e-06 nsteps 12 - rtol 0.01 rk_type 0 order 5 acc 3 t 7.5 dsm 0.000435975 dsm_est 5.85078e-05 nsteps 4 - rtol 0.01 rk_type 0 order 5 acc 3 t 8 dsm 0.000824606 dsm_est 3.65766e-06 nsteps 7 - rtol 0.01 rk_type 0 order 5 acc 3 t 8.5 dsm 0.00100819 dsm_est 1.8302e-06 nsteps 6 - rtol 0.01 rk_type 0 order 5 acc 3 t 9 dsm 0.00058073 dsm_est 8.22737e-07 nsteps 6 - rtol 0.01 rk_type 0 order 5 acc 3 t 9.5 dsm 6.70214e-05 dsm_est 4.25553e-07 nsteps 6 - rtol 0.01 rk_type 0 order 5 acc 3 t 10 dsm 0.000490488 dsm_est 7.76906e-07 nsteps 6 + rtol 0.01 rk_type 0 order 5 acc 3 t 0.5 dsm 7.48644e-05 dsm_est 8.43563e-06 nsteps 9 + rtol 0.01 rk_type 0 order 5 acc 3 t 1 dsm 0.000110257 dsm_est 1.92448e-06 nsteps 5 + rtol 0.01 rk_type 0 order 5 acc 3 t 1.5 dsm 0.00132404 dsm_est 1.36392e-06 nsteps 6 + rtol 0.01 rk_type 0 order 5 acc 3 t 2 dsm 0.00110273 dsm_est 3.97765e-07 nsteps 6 + rtol 0.01 rk_type 0 order 5 acc 3 t 2.5 dsm 6.10485e-05 dsm_est 1.42453e-07 nsteps 6 + rtol 0.01 rk_type 0 order 5 acc 3 t 3 dsm 0.000275174 dsm_est 3.75126e-07 nsteps 6 + rtol 0.01 rk_type 0 order 5 acc 3 t 3.5 dsm 0.00032811 dsm_est 1.23035e-06 nsteps 6 + rtol 0.01 rk_type 0 order 5 acc 3 t 4 dsm 7.35974e-05 dsm_est 3.49622e-07 nsteps 6 + rtol 0.01 rk_type 0 order 5 acc 3 t 4.5 dsm 0.000394423 dsm_est 1.33208e-06 nsteps 6 + rtol 0.01 rk_type 0 order 5 acc 3 t 5 dsm 4.44693e-05 dsm_est 3.3167e-07 nsteps 6 + rtol 0.01 rk_type 0 order 5 acc 3 t 5.5 dsm 0.000153383 dsm_est 5.43622e-07 nsteps 5 + rtol 0.01 rk_type 0 order 5 acc 3 t 6 dsm 0.00039377 dsm_est 1.51647e-06 nsteps 6 + rtol 0.01 rk_type 0 order 5 acc 3 t 6.5 dsm 0.000506258 dsm_est 6.62913e-07 nsteps 6 + rtol 0.01 rk_type 0 order 5 acc 3 t 7 dsm 0.00148699 dsm_est 1.33552e-05 nsteps 12 + rtol 0.01 rk_type 0 order 5 acc 3 t 7.5 dsm 0.000435975 dsm_est 0.000128373 nsteps 4 + rtol 0.01 rk_type 0 order 5 acc 3 t 8 dsm 0.000824606 dsm_est 9.87403e-06 nsteps 7 + rtol 0.01 rk_type 0 order 5 acc 3 t 8.5 dsm 0.00100819 dsm_est 5.15624e-06 nsteps 6 + rtol 0.01 rk_type 0 order 5 acc 3 t 9 dsm 0.00058073 dsm_est 2.61771e-06 nsteps 6 + rtol 0.01 rk_type 0 order 5 acc 3 t 9.5 dsm 6.70214e-05 dsm_est 1.42911e-06 nsteps 6 + rtol 0.01 rk_type 0 order 5 acc 3 t 10 dsm 0.000490488 dsm_est 3.46267e-06 nsteps 6 rtol 0.0001 rk_type 0 order 5 acc 1 t 0.5 dsm 1.9124e-05 dsm_est 4.10549e-06 nsteps 13 rtol 0.0001 rk_type 0 order 5 acc 1 t 1 dsm 1.46639e-06 dsm_est 2.99051e-08 nsteps 3 rtol 0.0001 rk_type 0 order 5 acc 1 t 1.5 dsm 1.49779e-06 dsm_est 2.8794e-08 nsteps 3 @@ -107,26 +107,26 @@ Adaptive-step runs: rtol 0.0001 rk_type 0 order 5 acc 2 t 9 dsm 1.10466e-05 dsm_est 3.06823e-08 nsteps 4 rtol 0.0001 rk_type 0 order 5 acc 2 t 9.5 dsm 1.12334e-05 dsm_est 1.36785e-07 nsteps 4 rtol 0.0001 rk_type 0 order 5 acc 2 t 10 dsm 9.05222e-07 dsm_est 3.2806e-08 nsteps 4 - rtol 0.0001 rk_type 0 order 5 acc 3 t 0.5 dsm 1.9124e-05 dsm_est 4.39976e-07 nsteps 13 - rtol 0.0001 rk_type 0 order 5 acc 3 t 1 dsm 1.46639e-06 dsm_est 9.99964e-09 nsteps 3 - rtol 0.0001 rk_type 0 order 5 acc 3 t 1.5 dsm 1.49779e-06 dsm_est 9.65784e-09 nsteps 3 - rtol 0.0001 rk_type 0 order 5 acc 3 t 2 dsm 2.48711e-06 dsm_est 1.78583e-08 nsteps 3 - rtol 0.0001 rk_type 0 order 5 acc 3 t 2.5 dsm 8.68487e-07 dsm_est 3.53288e-09 nsteps 3 - rtol 0.0001 rk_type 0 order 5 acc 3 t 3 dsm 4.6854e-06 dsm_est 8.97419e-09 nsteps 4 - rtol 0.0001 rk_type 0 order 5 acc 3 t 3.5 dsm 4.86491e-06 dsm_est 3.82982e-09 nsteps 4 - rtol 0.0001 rk_type 0 order 5 acc 3 t 4 dsm 9.38226e-06 dsm_est 3.82569e-10 nsteps 3 - rtol 0.0001 rk_type 0 order 5 acc 3 t 4.5 dsm 3.64804e-06 dsm_est 2.71444e-10 nsteps 3 - rtol 0.0001 rk_type 0 order 5 acc 3 t 5 dsm 1.20837e-06 dsm_est 3.93773e-09 nsteps 3 - rtol 0.0001 rk_type 0 order 5 acc 3 t 5.5 dsm 1.96373e-05 dsm_est 5.04674e-09 nsteps 3 - rtol 0.0001 rk_type 0 order 5 acc 3 t 6 dsm 6.78601e-06 dsm_est 2.03601e-08 nsteps 4 - rtol 0.0001 rk_type 0 order 5 acc 3 t 6.5 dsm 3.28653e-05 dsm_est 1.42284e-08 nsteps 8 - rtol 0.0001 rk_type 0 order 5 acc 3 t 7 dsm 1.0851e-05 dsm_est 2.55057e-07 nsteps 17 - rtol 0.0001 rk_type 0 order 5 acc 3 t 7.5 dsm 8.11463e-06 dsm_est 1.57107e-08 nsteps 13 - rtol 0.0001 rk_type 0 order 5 acc 3 t 8 dsm 1.12113e-05 dsm_est 9.4603e-09 nsteps 7 - rtol 0.0001 rk_type 0 order 5 acc 3 t 8.5 dsm 7.59151e-06 dsm_est 1.73402e-08 nsteps 5 - rtol 0.0001 rk_type 0 order 5 acc 3 t 9 dsm 1.10466e-05 dsm_est 7.67057e-09 nsteps 4 - rtol 0.0001 rk_type 0 order 5 acc 3 t 9.5 dsm 1.12334e-05 dsm_est 3.41962e-08 nsteps 4 - rtol 0.0001 rk_type 0 order 5 acc 3 t 10 dsm 9.05222e-07 dsm_est 8.2015e-09 nsteps 4 + rtol 0.0001 rk_type 0 order 5 acc 3 t 0.5 dsm 1.9124e-05 dsm_est 8.037e-08 nsteps 13 + rtol 0.0001 rk_type 0 order 5 acc 3 t 1 dsm 1.46639e-06 dsm_est 1.96624e-08 nsteps 3 + rtol 0.0001 rk_type 0 order 5 acc 3 t 1.5 dsm 1.49779e-06 dsm_est 1.97143e-08 nsteps 3 + rtol 0.0001 rk_type 0 order 5 acc 3 t 2 dsm 2.48711e-06 dsm_est 3.32323e-08 nsteps 3 + rtol 0.0001 rk_type 0 order 5 acc 3 t 2.5 dsm 8.68487e-07 dsm_est 5.8804e-09 nsteps 3 + rtol 0.0001 rk_type 0 order 5 acc 3 t 3 dsm 4.6854e-06 dsm_est 2.06494e-08 nsteps 4 + rtol 0.0001 rk_type 0 order 5 acc 3 t 3.5 dsm 4.86491e-06 dsm_est 7.91268e-09 nsteps 4 + rtol 0.0001 rk_type 0 order 5 acc 3 t 4 dsm 9.38226e-06 dsm_est 5.58758e-10 nsteps 3 + rtol 0.0001 rk_type 0 order 5 acc 3 t 4.5 dsm 3.64804e-06 dsm_est 4.12749e-10 nsteps 3 + rtol 0.0001 rk_type 0 order 5 acc 3 t 5 dsm 1.20837e-06 dsm_est 6.31634e-09 nsteps 3 + rtol 0.0001 rk_type 0 order 5 acc 3 t 5.5 dsm 1.96373e-05 dsm_est 7.63049e-09 nsteps 3 + rtol 0.0001 rk_type 0 order 5 acc 3 t 6 dsm 6.78601e-06 dsm_est 3.45501e-08 nsteps 4 + rtol 0.0001 rk_type 0 order 5 acc 3 t 6.5 dsm 3.28653e-05 dsm_est 2.5131e-08 nsteps 8 + rtol 0.0001 rk_type 0 order 5 acc 3 t 7 dsm 1.0851e-05 dsm_est 4.68539e-07 nsteps 17 + rtol 0.0001 rk_type 0 order 5 acc 3 t 7.5 dsm 8.11463e-06 dsm_est 1.75019e-08 nsteps 13 + rtol 0.0001 rk_type 0 order 5 acc 3 t 8 dsm 1.12113e-05 dsm_est 2.06416e-08 nsteps 7 + rtol 0.0001 rk_type 0 order 5 acc 3 t 8.5 dsm 7.59151e-06 dsm_est 4.50463e-08 nsteps 5 + rtol 0.0001 rk_type 0 order 5 acc 3 t 9 dsm 1.10466e-05 dsm_est 1.18403e-08 nsteps 4 + rtol 0.0001 rk_type 0 order 5 acc 3 t 9.5 dsm 1.12334e-05 dsm_est 6.19359e-08 nsteps 4 + rtol 0.0001 rk_type 0 order 5 acc 3 t 10 dsm 9.05222e-07 dsm_est 1.24356e-08 nsteps 4 rtol 1e-06 rk_type 0 order 5 acc 1 t 0.5 dsm 1.88136e-07 dsm_est 1.26411e-07 nsteps 20 rtol 1e-06 rk_type 0 order 5 acc 1 t 1 dsm 3.6815e-08 dsm_est 2.79712e-09 nsteps 5 rtol 1e-06 rk_type 0 order 5 acc 1 t 1.5 dsm 3.46973e-08 dsm_est 3.51635e-09 nsteps 7 @@ -167,23 +167,23 @@ Adaptive-step runs: rtol 1e-06 rk_type 0 order 5 acc 2 t 9 dsm 1.33343e-07 dsm_est 1.22048e-08 nsteps 7 rtol 1e-06 rk_type 0 order 5 acc 2 t 9.5 dsm 1.44237e-07 dsm_est 3.40516e-08 nsteps 6 rtol 1e-06 rk_type 0 order 5 acc 2 t 10 dsm 1.34853e-07 dsm_est 3.35247e-08 nsteps 6 - rtol 1e-06 rk_type 0 order 5 acc 3 t 0.5 dsm 1.88136e-07 dsm_est 1.55378e-08 nsteps 20 - rtol 1e-06 rk_type 0 order 5 acc 3 t 1 dsm 3.6815e-08 dsm_est 5.70344e-10 nsteps 5 - rtol 1e-06 rk_type 0 order 5 acc 3 t 1.5 dsm 3.46973e-08 dsm_est 5.04993e-10 nsteps 7 - rtol 1e-06 rk_type 0 order 5 acc 3 t 2 dsm 2.15722e-07 dsm_est 8.8739e-10 nsteps 7 - rtol 1e-06 rk_type 0 order 5 acc 3 t 2.5 dsm 9.55646e-08 dsm_est 2.79785e-10 nsteps 7 - rtol 1e-06 rk_type 0 order 5 acc 3 t 3 dsm 1.61192e-07 dsm_est 2.84751e-09 nsteps 5 - rtol 1e-06 rk_type 0 order 5 acc 3 t 3.5 dsm 4.89781e-08 dsm_est 1.08999e-09 nsteps 5 - rtol 1e-06 rk_type 0 order 5 acc 3 t 4 dsm 2.89671e-09 dsm_est 4.1169e-11 nsteps 5 - rtol 1e-06 rk_type 0 order 5 acc 3 t 4.5 dsm 1.33856e-07 dsm_est 3.63099e-11 nsteps 4 - rtol 1e-06 rk_type 0 order 5 acc 3 t 5 dsm 1.14768e-07 dsm_est 7.94799e-10 nsteps 5 - rtol 1e-06 rk_type 0 order 5 acc 3 t 5.5 dsm 3.35877e-07 dsm_est 7.7014e-10 nsteps 7 - rtol 1e-06 rk_type 0 order 5 acc 3 t 6 dsm 3.66079e-07 dsm_est 5.04916e-10 nsteps 9 - rtol 1e-06 rk_type 0 order 5 acc 3 t 6.5 dsm 1.18284e-06 dsm_est 1.10349e-09 nsteps 13 - rtol 1e-06 rk_type 0 order 5 acc 3 t 7 dsm 6.15151e-07 dsm_est 1.15991e-08 nsteps 32 - rtol 1e-06 rk_type 0 order 5 acc 3 t 7.5 dsm 7.6586e-08 dsm_est 6.18109e-10 nsteps 17 - rtol 1e-06 rk_type 0 order 5 acc 3 t 8 dsm 4.14322e-07 dsm_est 1.39091e-10 nsteps 13 - rtol 1e-06 rk_type 0 order 5 acc 3 t 8.5 dsm 2.50606e-07 dsm_est 2.08704e-09 nsteps 9 - rtol 1e-06 rk_type 0 order 5 acc 3 t 9 dsm 1.33343e-07 dsm_est 1.74354e-09 nsteps 7 - rtol 1e-06 rk_type 0 order 5 acc 3 t 9.5 dsm 1.44237e-07 dsm_est 5.67526e-09 nsteps 6 - rtol 1e-06 rk_type 0 order 5 acc 3 t 10 dsm 1.34853e-07 dsm_est 5.58746e-09 nsteps 6 + rtol 1e-06 rk_type 0 order 5 acc 3 t 0.5 dsm 1.88136e-07 dsm_est 1.26851e-08 nsteps 20 + rtol 1e-06 rk_type 0 order 5 acc 3 t 1 dsm 3.6815e-08 dsm_est 1.6608e-09 nsteps 5 + rtol 1e-06 rk_type 0 order 5 acc 3 t 1.5 dsm 3.46973e-08 dsm_est 1.70095e-09 nsteps 7 + rtol 1e-06 rk_type 0 order 5 acc 3 t 2 dsm 2.15722e-07 dsm_est 2.55077e-09 nsteps 7 + rtol 1e-06 rk_type 0 order 5 acc 3 t 2.5 dsm 9.55646e-08 dsm_est 8.55183e-10 nsteps 7 + rtol 1e-06 rk_type 0 order 5 acc 3 t 3 dsm 1.61192e-07 dsm_est 6.55528e-09 nsteps 5 + rtol 1e-06 rk_type 0 order 5 acc 3 t 3.5 dsm 4.89781e-08 dsm_est 2.24419e-09 nsteps 5 + rtol 1e-06 rk_type 0 order 5 acc 3 t 4 dsm 2.89671e-09 dsm_est 1.14512e-10 nsteps 5 + rtol 1e-06 rk_type 0 order 5 acc 3 t 4.5 dsm 1.33856e-07 dsm_est 9.42445e-11 nsteps 4 + rtol 1e-06 rk_type 0 order 5 acc 3 t 5 dsm 1.14768e-07 dsm_est 2.14148e-09 nsteps 5 + rtol 1e-06 rk_type 0 order 5 acc 3 t 5.5 dsm 3.35877e-07 dsm_est 2.26456e-09 nsteps 7 + rtol 1e-06 rk_type 0 order 5 acc 3 t 6 dsm 3.66079e-07 dsm_est 1.25374e-09 nsteps 9 + rtol 1e-06 rk_type 0 order 5 acc 3 t 6.5 dsm 1.18284e-06 dsm_est 2.39129e-09 nsteps 13 + rtol 1e-06 rk_type 0 order 5 acc 3 t 7 dsm 6.15151e-07 dsm_est 2.56642e-08 nsteps 32 + rtol 1e-06 rk_type 0 order 5 acc 3 t 7.5 dsm 7.6586e-08 dsm_est 1.02588e-09 nsteps 17 + rtol 1e-06 rk_type 0 order 5 acc 3 t 8 dsm 4.14322e-07 dsm_est 2.56944e-10 nsteps 13 + rtol 1e-06 rk_type 0 order 5 acc 3 t 8.5 dsm 2.50606e-07 dsm_est 7.50375e-09 nsteps 9 + rtol 1e-06 rk_type 0 order 5 acc 3 t 9 dsm 1.33343e-07 dsm_est 3.79527e-09 nsteps 7 + rtol 1e-06 rk_type 0 order 5 acc 3 t 9.5 dsm 1.44237e-07 dsm_est 1.06042e-08 nsteps 6 + rtol 1e-06 rk_type 0 order 5 acc 3 t 10 dsm 1.34853e-07 dsm_est 1.51614e-08 nsteps 6 diff --git a/test/unit_tests/arkode/CXX_serial/ark_test_accumerror_kpr_20_-4_1.out b/test/unit_tests/arkode/CXX_serial/ark_test_accumerror_kpr_20_-4_1.out index f45276a7a9..0ddc51a414 100644 --- a/test/unit_tests/arkode/CXX_serial/ark_test_accumerror_kpr_20_-4_1.out +++ b/test/unit_tests/arkode/CXX_serial/ark_test_accumerror_kpr_20_-4_1.out @@ -212,10 +212,10 @@ Fixed-step runs: h 0.0003125 rk_type 1 order 4 acc 3 t 0.5 dsm 7.34738e-15 dsm_est 1.05726e-13 nsteps 800 h 0.0003125 rk_type 1 order 4 acc 3 t 0.75 dsm 1.89479e-14 dsm_est 3.40303e-13 nsteps 800 h 0.0003125 rk_type 1 order 4 acc 3 t 1 dsm 6.41345e-15 dsm_est 1.18696e-13 nsteps 800 - h 0.0003125 rk_type 1 order 4 acc 3 t 1.25 dsm 1.49538e-13 dsm_est 2.91382e-12 nsteps 801 - h 0.0003125 rk_type 1 order 4 acc 3 t 1.5 dsm 1.0257e-13 dsm_est 1.48008e-12 nsteps 801 - h 0.0003125 rk_type 1 order 4 acc 3 t 1.75 dsm 4.74681e-14 dsm_est 4.83572e-12 nsteps 801 - h 0.0003125 rk_type 1 order 4 acc 3 t 2 dsm 3.28771e-14 dsm_est 9.73028e-13 nsteps 801 + h 0.0003125 rk_type 1 order 4 acc 3 t 1.25 dsm 1.49538e-13 dsm_est 2.91746e-12 nsteps 801 + h 0.0003125 rk_type 1 order 4 acc 3 t 1.5 dsm 1.0257e-13 dsm_est 1.48193e-12 nsteps 801 + h 0.0003125 rk_type 1 order 4 acc 3 t 1.75 dsm 4.74681e-14 dsm_est 4.84176e-12 nsteps 801 + h 0.0003125 rk_type 1 order 4 acc 3 t 2 dsm 3.28771e-14 dsm_est 9.74244e-13 nsteps 801 h 0.0003125 rk_type 1 order 4 acc 3 t 2.25 dsm 2.08777e-13 dsm_est 4.1965e-13 nsteps 800 h 0.0003125 rk_type 1 order 4 acc 3 t 2.5 dsm 1.03256e-14 dsm_est 1.74409e-13 nsteps 800 h 0.0003125 rk_type 1 order 4 acc 3 t 2.75 dsm 1.44079e-14 dsm_est 8.83656e-14 nsteps 800 @@ -224,10 +224,10 @@ Fixed-step runs: h 0.0003125 rk_type 1 order 4 acc 3 t 3.5 dsm 1.14798e-14 dsm_est 8.18506e-15 nsteps 800 h 0.0003125 rk_type 1 order 4 acc 3 t 3.75 dsm 1.10427e-14 dsm_est 6.13312e-15 nsteps 800 h 0.0003125 rk_type 1 order 4 acc 3 t 4 dsm 5.31806e-14 dsm_est 1.45159e-14 nsteps 800 - h 0.0003125 rk_type 1 order 4 acc 3 t 4.25 dsm 2.08119e-13 dsm_est 3.69873e-14 nsteps 801 - h 0.0003125 rk_type 1 order 4 acc 3 t 4.5 dsm 1.57233e-14 dsm_est 1.13245e-13 nsteps 801 - h 0.0003125 rk_type 1 order 4 acc 3 t 4.75 dsm 1.39902e-13 dsm_est 2.66213e-14 nsteps 801 - h 0.0003125 rk_type 1 order 4 acc 3 t 5 dsm 7.63042e-14 dsm_est 1.85072e-14 nsteps 801 + h 0.0003125 rk_type 1 order 4 acc 3 t 4.25 dsm 2.08119e-13 dsm_est 3.70335e-14 nsteps 801 + h 0.0003125 rk_type 1 order 4 acc 3 t 4.5 dsm 1.57233e-14 dsm_est 1.13386e-13 nsteps 801 + h 0.0003125 rk_type 1 order 4 acc 3 t 4.75 dsm 1.39902e-13 dsm_est 2.66546e-14 nsteps 801 + h 0.0003125 rk_type 1 order 4 acc 3 t 5 dsm 7.63042e-14 dsm_est 1.85303e-14 nsteps 801 h 0.0003125 rk_type 1 order 4 acc 2 t 0.25 dsm 9.97977e-16 dsm_est 1.35296e-14 nsteps 1200 h 0.0003125 rk_type 1 order 4 acc 2 t 0.5 dsm 7.34738e-15 dsm_est 3.14131e-14 nsteps 1200 h 0.0003125 rk_type 1 order 4 acc 2 t 0.75 dsm 1.89479e-14 dsm_est 6.96153e-14 nsteps 1200 @@ -289,25 +289,25 @@ Fixed-step runs: h 7.8125e-05 rk_type 1 order 4 acc 2 t 4.75 dsm 1.39177e-13 dsm_est 3.32669e-13 nsteps 3201 h 7.8125e-05 rk_type 1 order 4 acc 2 t 5 dsm 7.51104e-14 dsm_est 2.32583e-13 nsteps 3201 h 7.8125e-05 rk_type 1 order 4 acc 3 t 0.25 dsm 1.20076e-14 dsm_est 8.25514e-17 nsteps 3200 - h 7.8125e-05 rk_type 1 order 4 acc 3 t 0.5 dsm 6.92895e-14 dsm_est 4.12935e-16 nsteps 3201 + h 7.8125e-05 rk_type 1 order 4 acc 3 t 0.5 dsm 6.92895e-14 dsm_est 4.13064e-16 nsteps 3201 h 7.8125e-05 rk_type 1 order 4 acc 3 t 0.75 dsm 7.1887e-14 dsm_est 1.32929e-15 nsteps 3200 h 7.8125e-05 rk_type 1 order 4 acc 3 t 1 dsm 5.29714e-14 dsm_est 4.63079e-16 nsteps 3200 - h 7.8125e-05 rk_type 1 order 4 acc 3 t 1.25 dsm 4.54758e-13 dsm_est 1.13947e-14 nsteps 3201 - h 7.8125e-05 rk_type 1 order 4 acc 3 t 1.5 dsm 1.61784e-13 dsm_est 5.78442e-15 nsteps 3201 - h 7.8125e-05 rk_type 1 order 4 acc 3 t 1.75 dsm 1.4649e-13 dsm_est 1.89102e-14 nsteps 3201 - h 7.8125e-05 rk_type 1 order 4 acc 3 t 2 dsm 6.85301e-14 dsm_est 3.80224e-15 nsteps 3201 - h 7.8125e-05 rk_type 1 order 4 acc 3 t 2.25 dsm 3.74507e-13 dsm_est 1.6387e-15 nsteps 3201 - h 7.8125e-05 rk_type 1 order 4 acc 3 t 2.5 dsm 1.92671e-14 dsm_est 6.81275e-16 nsteps 3201 - h 7.8125e-05 rk_type 1 order 4 acc 3 t 2.75 dsm 1.93516e-14 dsm_est 3.45213e-16 nsteps 3201 - h 7.8125e-05 rk_type 1 order 4 acc 3 t 3 dsm 1.23711e-13 dsm_est 2.67136e-16 nsteps 3201 - h 7.8125e-05 rk_type 1 order 4 acc 3 t 3.25 dsm 8.16997e-14 dsm_est 1.30768e-16 nsteps 3201 - h 7.8125e-05 rk_type 1 order 4 acc 3 t 3.5 dsm 1.95956e-14 dsm_est 3.19583e-17 nsteps 3201 - h 7.8125e-05 rk_type 1 order 4 acc 3 t 3.75 dsm 2.16401e-14 dsm_est 2.39388e-17 nsteps 3201 - h 7.8125e-05 rk_type 1 order 4 acc 3 t 4 dsm 9.37664e-14 dsm_est 5.67508e-17 nsteps 3201 - h 7.8125e-05 rk_type 1 order 4 acc 3 t 4.25 dsm 2.10442e-13 dsm_est 1.44544e-16 nsteps 3201 - h 7.8125e-05 rk_type 1 order 4 acc 3 t 4.5 dsm 1.64627e-14 dsm_est 4.4406e-16 nsteps 3201 - h 7.8125e-05 rk_type 1 order 4 acc 3 t 4.75 dsm 1.39177e-13 dsm_est 1.03927e-16 nsteps 3201 - h 7.8125e-05 rk_type 1 order 4 acc 3 t 5 dsm 7.51104e-14 dsm_est 7.26595e-17 nsteps 3201 + h 7.8125e-05 rk_type 1 order 4 acc 3 t 1.25 dsm 4.54758e-13 dsm_est 1.13982e-14 nsteps 3201 + h 7.8125e-05 rk_type 1 order 4 acc 3 t 1.5 dsm 1.61784e-13 dsm_est 5.78623e-15 nsteps 3201 + h 7.8125e-05 rk_type 1 order 4 acc 3 t 1.75 dsm 1.4649e-13 dsm_est 1.89161e-14 nsteps 3201 + h 7.8125e-05 rk_type 1 order 4 acc 3 t 2 dsm 6.85301e-14 dsm_est 3.80343e-15 nsteps 3201 + h 7.8125e-05 rk_type 1 order 4 acc 3 t 2.25 dsm 3.74507e-13 dsm_est 1.63922e-15 nsteps 3201 + h 7.8125e-05 rk_type 1 order 4 acc 3 t 2.5 dsm 1.92671e-14 dsm_est 6.81488e-16 nsteps 3201 + h 7.8125e-05 rk_type 1 order 4 acc 3 t 2.75 dsm 1.93516e-14 dsm_est 3.45321e-16 nsteps 3201 + h 7.8125e-05 rk_type 1 order 4 acc 3 t 3 dsm 1.23711e-13 dsm_est 2.67219e-16 nsteps 3201 + h 7.8125e-05 rk_type 1 order 4 acc 3 t 3.25 dsm 8.16997e-14 dsm_est 1.30809e-16 nsteps 3201 + h 7.8125e-05 rk_type 1 order 4 acc 3 t 3.5 dsm 1.95956e-14 dsm_est 3.19683e-17 nsteps 3201 + h 7.8125e-05 rk_type 1 order 4 acc 3 t 3.75 dsm 2.16401e-14 dsm_est 2.39462e-17 nsteps 3201 + h 7.8125e-05 rk_type 1 order 4 acc 3 t 4 dsm 9.37664e-14 dsm_est 5.67685e-17 nsteps 3201 + h 7.8125e-05 rk_type 1 order 4 acc 3 t 4.25 dsm 2.10442e-13 dsm_est 1.4459e-16 nsteps 3201 + h 7.8125e-05 rk_type 1 order 4 acc 3 t 4.5 dsm 1.64627e-14 dsm_est 4.44199e-16 nsteps 3201 + h 7.8125e-05 rk_type 1 order 4 acc 3 t 4.75 dsm 1.39177e-13 dsm_est 1.03959e-16 nsteps 3201 + h 7.8125e-05 rk_type 1 order 4 acc 3 t 5 dsm 7.51104e-14 dsm_est 7.26822e-17 nsteps 3201 h 7.8125e-05 rk_type 1 order 4 acc 2 t 0.25 dsm 1.20076e-14 dsm_est 9.70841e-15 nsteps 4800 h 7.8125e-05 rk_type 1 order 4 acc 2 t 0.5 dsm 6.92895e-14 dsm_est 1.22494e-13 nsteps 4801 h 7.8125e-05 rk_type 1 order 4 acc 2 t 0.75 dsm 7.1887e-14 dsm_est 1.01008e-13 nsteps 4801 diff --git a/test/unit_tests/arkode/CXX_serial/ark_test_brusselator_mriadapt_--rtol_0.000004_--scontrol_0.out b/test/unit_tests/arkode/CXX_serial/ark_test_brusselator_mriadapt_--rtol_0.000004_--scontrol_0.out index 8f3f732b3f..18ebb4b2b5 100644 --- a/test/unit_tests/arkode/CXX_serial/ark_test_brusselator_mriadapt_--rtol_0.000004_--scontrol_0.out +++ b/test/unit_tests/arkode/CXX_serial/ark_test_brusselator_mriadapt_--rtol_0.000004_--scontrol_0.out @@ -17,26 +17,27 @@ Adaptive multirate stiff Brusselator test problem: 1.000000 1.107158 3.008131 3.498438 1.2e-07 1.2e-07 1.3e-05 1.500000 0.917798 3.188082 3.498698 1.0e-07 1.0e-07 1.7e-05 2.000000 0.691486 3.512327 3.499015 7.6e-08 7.6e-08 1.7e-05 - 2.510000 0.507365 3.904138 3.499277 5.4e-08 5.5e-08 1.2e-05 - 3.010000 0.408962 4.276667 3.499418 4.5e-08 4.6e-08 9.5e-06 - 3.510000 0.371697 4.620648 3.499470 3.0e-08 3.0e-08 9.9e-06 - 4.010000 0.367719 4.940753 3.499477 5.3e-08 5.4e-08 8.0e-06 - 4.510000 0.382657 5.238877 3.499473 3.2e-08 3.3e-08 9.1e-06 - 5.010000 0.413767 5.509406 3.499429 4.1e-08 4.1e-08 8.5e-06 - 5.510000 0.469496 5.734291 3.499354 5.5e-08 5.5e-08 1.1e-05 - 6.010000 0.589086 5.854619 3.499191 6.5e-08 6.6e-08 1.5e-05 - 6.510000 1.085778 5.477727 3.498540 6.0e-07 6.1e-07 5.8e-05 - 7.010000 4.757865 0.733961 3.493291 3.9e-06 4.0e-06 5.9e-05 - 7.510000 3.008865 1.066505 3.495744 1.9e-06 1.9e-06 4.7e-05 - 8.010000 1.814106 1.573981 3.497434 7.5e-07 7.6e-07 2.7e-05 - 8.510000 0.995504 2.204329 3.498588 2.4e-07 2.4e-07 1.8e-05 - 9.010000 0.528098 2.805602 3.499245 6.5e-08 6.6e-08 1.5e-05 - 9.510000 0.350997 3.271591 3.499488 4.4e-08 4.5e-08 2.0e-05 + 2.500000 0.510160 3.896431 3.499274 5.5e-08 5.5e-08 1.2e-05 + 3.000000 0.410222 4.269502 3.499416 4.6e-08 4.6e-08 9.6e-06 + 3.500000 0.372044 4.614020 3.499469 3.0e-08 3.0e-08 9.8e-06 + 4.000000 0.367587 4.934562 3.499478 5.3e-08 5.3e-08 7.9e-06 + 4.500000 0.382205 5.233154 3.499474 3.2e-08 3.2e-08 9.1e-06 + 5.000000 0.412956 5.504352 3.499431 4.1e-08 4.1e-08 8.5e-06 + 5.500000 0.467990 5.730486 3.499356 5.5e-08 5.5e-08 1.1e-05 + 6.000000 0.585318 5.854262 3.499196 6.5e-08 6.6e-08 1.5e-05 + 6.500000 1.060808 5.503433 3.498555 5.4e-07 5.5e-07 3.8e-05 + 7.000000 4.794999 0.734608 3.493240 3.6e-06 3.6e-06 5.8e-05 + 7.500000 3.037708 1.057903 3.495704 2.0e-06 2.0e-06 4.7e-05 + 8.000000 1.833974 1.562357 3.497406 7.7e-07 7.8e-07 2.7e-05 + 8.500000 1.008519 2.191334 3.498570 2.5e-07 2.5e-07 1.8e-05 + 9.000000 0.534097 2.794912 3.499237 6.6e-08 6.7e-08 1.5e-05 + 9.500000 0.352784 3.263320 3.499486 4.3e-08 4.3e-08 2.0e-05 + 10.000000 0.305955 3.648439 3.499562 2.5e-08 2.5e-08 9.8e-06 ------------------------------------------------------------------------- Final Solver Statistics: Slow steps = 1000 (attempts = 1000, fails = 0) - Fast steps = 11774 (attempts = 16690, fails = 4916) - u error = 1.83331e-06, v error = 1.63126e-06, w error = 5.55533e-05, total error = 3.2105e-05 + Fast steps = 11777 (attempts = 16708, fails = 4931) + u error = 1.83324e-06, v error = 1.63119e-06, w error = 5.54867e-05, total error = 3.20666e-05 Relative accuracy = 83.5081 - Total RHS evals: Fse = 5000, Fsi = 0, Ff = 78536 + Total RHS evals: Fse = 5000, Fsi = 0, Ff = 78611 diff --git a/test/unit_tests/arkode/CXX_serial/ark_test_kpr_mriadapt_--hs_0.002_--rtol_0.000004_--scontrol_0.out b/test/unit_tests/arkode/CXX_serial/ark_test_kpr_mriadapt_--hs_0.002_--rtol_0.000004_--scontrol_0.out index 29c1f3929e..919af7ddc9 100644 --- a/test/unit_tests/arkode/CXX_serial/ark_test_kpr_mriadapt_--hs_0.002_--rtol_0.000004_--scontrol_0.out +++ b/test/unit_tests/arkode/CXX_serial/ark_test_kpr_mriadapt_--hs_0.002_--rtol_0.000004_--scontrol_0.out @@ -16,29 +16,30 @@ Adaptive multirate nonlinear Kvaerno-Prothero-Robinson test problem: ------------------------------------------------------ 0.000000 1.732051 1.732051 0.00e+00 0.00e+00 0.250000 1.723053 1.584050 5.10e-11 1.74e-10 - 0.500000 1.696344 1.512598 4.29e-11 2.73e-10 - 0.750000 1.652782 1.036015 4.03e-11 3.14e-09 + 0.500000 1.696344 1.512598 4.30e-11 2.73e-10 + 0.750000 1.652782 1.036015 4.02e-11 3.15e-09 1.000000 1.593833 1.458873 3.25e-11 2.89e-09 - 1.250000 1.521618 1.458201 3.36e-11 1.27e-08 - 1.500000 1.439006 1.011474 4.38e-11 6.25e-08 - 1.750000 1.349724 1.730452 4.07e-12 3.64e-09 - 2.000000 1.258512 1.214374 1.23e-11 5.82e-09 - 2.252000 1.170586 1.004732 2.73e-11 1.04e-10 - 2.502000 1.094377 1.459495 4.60e-11 3.22e-13 - 2.752000 1.036791 1.256387 6.39e-11 3.22e-11 - 3.002000 1.004852 1.335466 7.65e-11 2.48e-11 - 3.252000 1.003040 1.026042 8.00e-11 3.09e-12 - 3.502000 1.031623 1.053676 6.80e-11 1.62e-13 - 3.752000 1.086547 1.001339 5.18e-11 1.65e-13 - 4.002000 1.160979 1.610394 3.05e-11 2.03e-11 - 4.252000 1.247278 1.679067 8.92e-12 4.85e-11 - 4.502000 1.338342 1.496510 3.50e-12 6.62e-11 - 4.752000 1.428146 1.230596 1.57e-11 1.02e-10 + 1.250000 1.521618 1.458201 3.35e-11 1.27e-08 + 1.500000 1.439006 1.011474 4.36e-11 6.25e-08 + 1.750000 1.349724 1.730452 3.65e-12 3.67e-09 + 2.000000 1.258512 1.214374 1.24e-11 5.83e-09 + 2.250000 1.171250 1.024071 2.70e-11 1.63e-10 + 2.500000 1.094923 1.471085 4.59e-11 3.37e-13 + 2.750000 1.037158 1.313348 6.43e-11 2.13e-11 + 3.000000 1.004991 1.274175 7.65e-11 2.92e-11 + 3.250000 1.002931 1.043458 7.96e-11 6.41e-12 + 3.500000 1.031282 1.053648 6.81e-11 1.65e-13 + 3.750000 1.086021 1.006374 5.10e-11 3.61e-12 + 4.000000 1.160326 1.571824 3.06e-11 1.90e-11 + 4.250000 1.246560 1.705136 7.61e-12 4.47e-11 + 4.500000 1.337611 1.431830 3.19e-12 5.54e-11 + 4.750000 1.427446 1.162908 1.55e-11 1.82e-10 + 5.000000 1.511179 1.070831 2.51e-11 3.35e-10 ------------------------------------------------------ Final Solver Statistics: Slow steps = 2500 (attempts = 2500, fails = 0) Fast steps = 12502 (attempts = 12502, fails = 0) - u error = 4.31336e-11, v error = 9.52085e-09, total error = 6.73232e-09 - Relative accuracy = 0.0160088 + u error = 4.31846e-11, v error = 9.52053e-09, total error = 6.7321e-09 + Relative accuracy = 0.0160086 Total RHS evals: Fse = 12500, Fsi = 0, Ff = 62512 diff --git a/test/unit_tests/arkode/CXX_serial/ark_test_slowerror_brusselator.out b/test/unit_tests/arkode/CXX_serial/ark_test_slowerror_brusselator.out index cfe44382f2..80f4ea9e89 100644 --- a/test/unit_tests/arkode/CXX_serial/ark_test_slowerror_brusselator.out +++ b/test/unit_tests/arkode/CXX_serial/ark_test_slowerror_brusselator.out @@ -49,13 +49,13 @@ Slow error estimation test (stiff Brusselator ODE problem): H 0.0015625 method ARKODE_MRI_GARK_ERK33a t 0.501563 dsm 0.124019 dsm_est 0.300808 H 0.0015625 method ARKODE_MRI_GARK_ERK33a t 1.00156 dsm 0.4016 dsm_est 0.177725 H 0.0015625 method ARKODE_MRI_GARK_ERK33a t 1.50156 dsm 1.08417 dsm_est 0.634969 - H 0.0015625 method ARKODE_MRI_GARK_ERK33a t 2.00156 dsm 1.63593 dsm_est 0.730608 + H 0.0015625 method ARKODE_MRI_GARK_ERK33a t 2.00156 dsm 1.63593 dsm_est 0.730609 H 0.0015625 method ARKODE_MRI_GARK_ERK33a t 2.50156 dsm 1.21684 dsm_est 0.522198 H 0.0015625 method ARKODE_MRI_GARK_ERK33a t 3.00156 dsm 0.297567 dsm_est 0.53854 H 0.0015625 method ARKODE_MRI_GARK_ERK33a t 3.50156 dsm 0.843901 dsm_est 0.496086 - H 0.0015625 method ARKODE_MRI_GARK_ERK33a t 4.00156 dsm 0.0984512 dsm_est 0.150722 + H 0.0015625 method ARKODE_MRI_GARK_ERK33a t 4.00156 dsm 0.0984505 dsm_est 0.150722 H 0.0015625 method ARKODE_MRI_GARK_ERK33a t 4.50156 dsm 3.172 dsm_est 1.06726 - H 0.0015625 method ARKODE_MRI_GARK_ERK33a t 5.00156 dsm 0.177228 dsm_est 0.114247 + H 0.0015625 method ARKODE_MRI_GARK_ERK33a t 5.00156 dsm 0.177227 dsm_est 0.114246 H 0.0015625 method ARKODE_MRI_GARK_ERK33a t 5.50156 dsm 0.153004 dsm_est 0.496739 H 0.0015625 method ARKODE_MRI_GARK_ERK33a t 6.00156 dsm 0.2503 dsm_est 3.45242 H 0.0015625 method ARKODE_MRI_GARK_ERK33a t 6.50156 dsm 0.94962 dsm_est 81.8018 @@ -66,45 +66,45 @@ Slow error estimation test (stiff Brusselator ODE problem): H 0.0015625 method ARKODE_MRI_GARK_ERK33a t 9.00156 dsm 0.118533 dsm_est 2.54788 H 0.0015625 method ARKODE_MRI_GARK_ERK33a t 9.50156 dsm 0.220342 dsm_est 2.57065 H 0.000390625 method ARKODE_MRI_GARK_ERK33a t 0.000390625 dsm 2.73843e+07 dsm_est 2.97866e+07 - H 0.000390625 method ARKODE_MRI_GARK_ERK33a t 0.500391 dsm 0.00068624 dsm_est 0.0047023 - H 0.000390625 method ARKODE_MRI_GARK_ERK33a t 1.00039 dsm 0.00193295 dsm_est 0.00277776 - H 0.000390625 method ARKODE_MRI_GARK_ERK33a t 1.50039 dsm 0.00652841 dsm_est 0.00992033 - H 0.000390625 method ARKODE_MRI_GARK_ERK33a t 2.00039 dsm 0.007873 dsm_est 0.0114175 + H 0.000390625 method ARKODE_MRI_GARK_ERK33a t 0.500391 dsm 0.00068624 dsm_est 0.00470174 + H 0.000390625 method ARKODE_MRI_GARK_ERK33a t 1.00039 dsm 0.00193295 dsm_est 0.00277739 + H 0.000390625 method ARKODE_MRI_GARK_ERK33a t 1.50039 dsm 0.00652841 dsm_est 0.00992044 + H 0.000390625 method ARKODE_MRI_GARK_ERK33a t 2.00039 dsm 0.007873 dsm_est 0.0114169 H 0.000390625 method ARKODE_MRI_GARK_ERK33a t 2.50039 dsm 0.00699861 dsm_est 0.00815712 H 0.000390625 method ARKODE_MRI_GARK_ERK33a t 3.00039 dsm 0.00143196 dsm_est 0.00840977 - H 0.000390625 method ARKODE_MRI_GARK_ERK33a t 3.50039 dsm 0.00507095 dsm_est 0.00775126 - H 0.000390625 method ARKODE_MRI_GARK_ERK33a t 4.00039 dsm 0.000473416 dsm_est 0.00235627 - H 0.000390625 method ARKODE_MRI_GARK_ERK33a t 4.50039 dsm 0.0152611 dsm_est 0.016676 + H 0.000390625 method ARKODE_MRI_GARK_ERK33a t 3.50039 dsm 0.00507095 dsm_est 0.00775185 + H 0.000390625 method ARKODE_MRI_GARK_ERK33a t 4.00039 dsm 0.000473415 dsm_est 0.00235627 + H 0.000390625 method ARKODE_MRI_GARK_ERK33a t 4.50039 dsm 0.0152604 dsm_est 0.0166753 H 0.000390625 method ARKODE_MRI_GARK_ERK33a t 5.00039 dsm 0.00103306 dsm_est 0.00178339 - H 0.000390625 method ARKODE_MRI_GARK_ERK33a t 5.50039 dsm 0.000737183 dsm_est 0.00775511 + H 0.000390625 method ARKODE_MRI_GARK_ERK33a t 5.50039 dsm 0.000737914 dsm_est 0.00775519 H 0.000390625 method ARKODE_MRI_GARK_ERK33a t 6.00039 dsm 0.00150366 dsm_est 0.0539128 H 0.000390625 method ARKODE_MRI_GARK_ERK33a t 6.50039 dsm 0.00386116 dsm_est 1.27888 - H 0.000390625 method ARKODE_MRI_GARK_ERK33a t 7.00039 dsm 0.0511054 dsm_est 5.9684 - H 0.000390625 method ARKODE_MRI_GARK_ERK33a t 7.50039 dsm 0.00692145 dsm_est 0.074037 - H 0.000390625 method ARKODE_MRI_GARK_ERK33a t 8.00039 dsm 0.00073325 dsm_est 0.0248322 - H 0.000390625 method ARKODE_MRI_GARK_ERK33a t 8.50039 dsm 0.000872562 dsm_est 0.00893466 - H 0.000390625 method ARKODE_MRI_GARK_ERK33a t 9.00039 dsm 0.000621579 dsm_est 0.0397209 - H 0.000390625 method ARKODE_MRI_GARK_ERK33a t 9.50039 dsm 0.00106005 dsm_est 0.0401378 + H 0.000390625 method ARKODE_MRI_GARK_ERK33a t 7.00039 dsm 0.0511055 dsm_est 5.9684 + H 0.000390625 method ARKODE_MRI_GARK_ERK33a t 7.50039 dsm 0.00692078 dsm_est 0.074038 + H 0.000390625 method ARKODE_MRI_GARK_ERK33a t 8.00039 dsm 0.000733274 dsm_est 0.0248325 + H 0.000390625 method ARKODE_MRI_GARK_ERK33a t 8.50039 dsm 0.000872554 dsm_est 0.00893449 + H 0.000390625 method ARKODE_MRI_GARK_ERK33a t 9.00039 dsm 0.000620849 dsm_est 0.0397209 + H 0.000390625 method ARKODE_MRI_GARK_ERK33a t 9.50039 dsm 0.00105929 dsm_est 0.0401369 H 9.76563e-05 method ARKODE_MRI_GARK_ERK33a t 9.76563e-05 dsm 130431 dsm_est 498019 H 9.76563e-05 method ARKODE_MRI_GARK_ERK33a t 0.500098 dsm 3.22403e-06 dsm_est 7.35991e-05 - H 9.76563e-05 method ARKODE_MRI_GARK_ERK33a t 1.0001 dsm 8.81057e-06 dsm_est 4.30975e-05 - H 9.76563e-05 method ARKODE_MRI_GARK_ERK33a t 1.5001 dsm 2.85071e-05 dsm_est 0.000154738 - H 9.76563e-05 method ARKODE_MRI_GARK_ERK33a t 2.0001 dsm 3.50798e-05 dsm_est 0.000177855 + H 9.76563e-05 method ARKODE_MRI_GARK_ERK33a t 1.0001 dsm 8.76951e-06 dsm_est 4.34727e-05 + H 9.76563e-05 method ARKODE_MRI_GARK_ERK33a t 1.5001 dsm 2.85184e-05 dsm_est 0.000154848 + H 9.76563e-05 method ARKODE_MRI_GARK_ERK33a t 2.0001 dsm 3.58103e-05 dsm_est 0.000178405 H 9.76563e-05 method ARKODE_MRI_GARK_ERK33a t 2.5001 dsm 3.14166e-05 dsm_est 0.000127273 - H 9.76563e-05 method ARKODE_MRI_GARK_ERK33a t 3.0001 dsm 6.57531e-06 dsm_est 0.000131139 - H 9.76563e-05 method ARKODE_MRI_GARK_ERK33a t 3.5001 dsm 2.19174e-05 dsm_est 0.000120883 + H 9.76563e-05 method ARKODE_MRI_GARK_ERK33a t 3.0001 dsm 6.6836e-06 dsm_est 0.000131134 + H 9.76563e-05 method ARKODE_MRI_GARK_ERK33a t 3.5001 dsm 2.19334e-05 dsm_est 0.000121472 H 9.76563e-05 method ARKODE_MRI_GARK_ERK33a t 4.0001 dsm 1.46115e-06 dsm_est 3.65453e-05 H 9.76563e-05 method ARKODE_MRI_GARK_ERK33a t 4.5001 dsm 6.79441e-05 dsm_est 0.000260953 - H 9.76563e-05 method ARKODE_MRI_GARK_ERK33a t 5.0001 dsm 4.44856e-06 dsm_est 2.79151e-05 - H 9.76563e-05 method ARKODE_MRI_GARK_ERK33a t 5.5001 dsm 3.89141e-06 dsm_est 0.000121321 - H 9.76563e-05 method ARKODE_MRI_GARK_ERK33a t 6.0001 dsm 7.43691e-06 dsm_est 0.000842843 - H 9.76563e-05 method ARKODE_MRI_GARK_ERK33a t 6.5001 dsm 1.887e-05 dsm_est 0.0199854 + H 9.76563e-05 method ARKODE_MRI_GARK_ERK33a t 5.0001 dsm 4.63814e-06 dsm_est 2.73436e-05 + H 9.76563e-05 method ARKODE_MRI_GARK_ERK33a t 5.5001 dsm 3.99263e-06 dsm_est 0.000121193 + H 9.76563e-05 method ARKODE_MRI_GARK_ERK33a t 6.0001 dsm 7.38533e-06 dsm_est 0.000842724 + H 9.76563e-05 method ARKODE_MRI_GARK_ERK33a t 6.5001 dsm 1.91204e-05 dsm_est 0.0199852 H 9.76563e-05 method ARKODE_MRI_GARK_ERK33a t 7.0001 dsm 0.00020015 dsm_est 0.0932838 - H 9.76563e-05 method ARKODE_MRI_GARK_ERK33a t 7.5001 dsm 3.10301e-05 dsm_est 0.00115562 - H 9.76563e-05 method ARKODE_MRI_GARK_ERK33a t 8.0001 dsm 4.87344e-06 dsm_est 0.00038836 + H 9.76563e-05 method ARKODE_MRI_GARK_ERK33a t 7.5001 dsm 3.17543e-05 dsm_est 0.00115569 + H 9.76563e-05 method ARKODE_MRI_GARK_ERK33a t 8.0001 dsm 4.92456e-06 dsm_est 0.000387364 H 9.76563e-05 method ARKODE_MRI_GARK_ERK33a t 8.5001 dsm 3.86449e-06 dsm_est 0.000139579 - H 9.76563e-05 method ARKODE_MRI_GARK_ERK33a t 9.0001 dsm 4.17539e-06 dsm_est 0.000619455 - H 9.76563e-05 method ARKODE_MRI_GARK_ERK33a t 9.5001 dsm 4.45287e-06 dsm_est 0.000626933 + H 9.76563e-05 method ARKODE_MRI_GARK_ERK33a t 9.0001 dsm 3.70097e-06 dsm_est 0.000619442 + H 9.76563e-05 method ARKODE_MRI_GARK_ERK33a t 9.5001 dsm 3.7359e-06 dsm_est 0.000626912 ARKODE_MRI_GARK_ERK33a summary: Stepsize 0.025 maxdsm 3.18615e+13 maxdsmest 2.87651e+09 diff --git a/test/unit_tests/arkode/CXX_serial/ark_test_slowerror_kpr.out b/test/unit_tests/arkode/CXX_serial/ark_test_slowerror_kpr.out index 21eb6c79f2..87e6b5cc1e 100644 --- a/test/unit_tests/arkode/CXX_serial/ark_test_slowerror_kpr.out +++ b/test/unit_tests/arkode/CXX_serial/ark_test_slowerror_kpr.out @@ -32,21 +32,21 @@ Slow error estimation test (Nonlinear Kvaerno-Prothero-Robinson problem): H 0.003125 method ARKODE_MRI_GARK_ERK33a t 1.25313 dsm 37.2232 dsm_est 3954.15 H 0.003125 method ARKODE_MRI_GARK_ERK33a t 1.50313 dsm 17.7805 dsm_est 786.062 H 0.003125 method ARKODE_MRI_GARK_ERK33a t 1.75313 dsm 58.1561 dsm_est 2999.34 - H 0.003125 method ARKODE_MRI_GARK_ERK33a t 2.00312 dsm 0.615847 dsm_est 764.348 + H 0.003125 method ARKODE_MRI_GARK_ERK33a t 2.00312 dsm 0.615846 dsm_est 764.348 H 0.003125 method ARKODE_MRI_GARK_ERK33a t 2.25312 dsm 0.208735 dsm_est 542.352 H 0.003125 method ARKODE_MRI_GARK_ERK33a t 2.50312 dsm 1.15342 dsm_est 106.225 H 0.003125 method ARKODE_MRI_GARK_ERK33a t 2.75312 dsm 1.54621 dsm_est 59.6688 H 0.003125 method ARKODE_MRI_GARK_ERK33a t 3.00312 dsm 1.18391 dsm_est 80.2941 H 0.003125 method ARKODE_MRI_GARK_ERK33a t 3.25312 dsm 1.00984 dsm_est 46.1362 H 0.003125 method ARKODE_MRI_GARK_ERK33a t 3.50312 dsm 0.853892 dsm_est 19.4476 - H 0.003125 method ARKODE_MRI_GARK_ERK33a t 3.75312 dsm 0.637605 dsm_est 20.4096 + H 0.003125 method ARKODE_MRI_GARK_ERK33a t 3.75312 dsm 0.637603 dsm_est 20.4096 H 0.003125 method ARKODE_MRI_GARK_ERK33a t 4.00312 dsm 0.50676 dsm_est 35.5067 H 0.003125 method ARKODE_MRI_GARK_ERK33a t 4.25312 dsm 0.0997811 dsm_est 197.159 - H 0.003125 method ARKODE_MRI_GARK_ERK33a t 4.50312 dsm 0.60266 dsm_est 244.1 + H 0.003125 method ARKODE_MRI_GARK_ERK33a t 4.50312 dsm 0.602658 dsm_est 244.1 H 0.003125 method ARKODE_MRI_GARK_ERK33a t 4.75312 dsm 0.3657 dsm_est 59.8484 - H 0.00078125 method ARKODE_MRI_GARK_ERK33a t 0.00078125 dsm 0.000907653 dsm_est 0.1702 + H 0.00078125 method ARKODE_MRI_GARK_ERK33a t 0.00078125 dsm 0.000906789 dsm_est 0.1702 H 0.00078125 method ARKODE_MRI_GARK_ERK33a t 0.250781 dsm 0.00229725 dsm_est 1.09748 - H 0.00078125 method ARKODE_MRI_GARK_ERK33a t 0.500781 dsm 0.0052905 dsm_est 8.25834 + H 0.00078125 method ARKODE_MRI_GARK_ERK33a t 0.500781 dsm 0.00528907 dsm_est 8.25834 H 0.00078125 method ARKODE_MRI_GARK_ERK33a t 0.750781 dsm 0.0112664 dsm_est 8.18019 H 0.00078125 method ARKODE_MRI_GARK_ERK33a t 1.00078 dsm 0.0172485 dsm_est 0.149038 H 0.00078125 method ARKODE_MRI_GARK_ERK33a t 1.25078 dsm 0.162364 dsm_est 60.7616 @@ -55,59 +55,59 @@ Slow error estimation test (Nonlinear Kvaerno-Prothero-Robinson problem): H 0.00078125 method ARKODE_MRI_GARK_ERK33a t 2.00078 dsm 0.00251159 dsm_est 11.9018 H 0.00078125 method ARKODE_MRI_GARK_ERK33a t 2.25078 dsm 0.000388484 dsm_est 8.4539 H 0.00078125 method ARKODE_MRI_GARK_ERK33a t 2.50078 dsm 0.00453393 dsm_est 1.64038 - H 0.00078125 method ARKODE_MRI_GARK_ERK33a t 2.75078 dsm 0.00608272 dsm_est 0.90159 + H 0.00078125 method ARKODE_MRI_GARK_ERK33a t 2.75078 dsm 0.00608412 dsm_est 0.901588 H 0.00078125 method ARKODE_MRI_GARK_ERK33a t 3.00078 dsm 0.00463348 dsm_est 1.26635 - H 0.00078125 method ARKODE_MRI_GARK_ERK33a t 3.25078 dsm 0.00394421 dsm_est 0.719304 - H 0.00078125 method ARKODE_MRI_GARK_ERK33a t 3.50078 dsm 0.00333748 dsm_est 0.302407 + H 0.00078125 method ARKODE_MRI_GARK_ERK33a t 3.25078 dsm 0.00394414 dsm_est 0.719303 + H 0.00078125 method ARKODE_MRI_GARK_ERK33a t 3.50078 dsm 0.00333765 dsm_est 0.302408 H 0.00078125 method ARKODE_MRI_GARK_ERK33a t 3.75078 dsm 0.00249229 dsm_est 0.318005 H 0.00078125 method ARKODE_MRI_GARK_ERK33a t 4.00078 dsm 0.00197527 dsm_est 0.548996 H 0.00078125 method ARKODE_MRI_GARK_ERK33a t 4.25078 dsm 0.000423031 dsm_est 3.07331 H 0.00078125 method ARKODE_MRI_GARK_ERK33a t 4.50078 dsm 0.00226465 dsm_est 3.80981 - H 0.00078125 method ARKODE_MRI_GARK_ERK33a t 4.75078 dsm 0.00143601 dsm_est 0.942032 - H 0.000195313 method ARKODE_MRI_GARK_ERK33a t 0.000195313 dsm 3.24965e-06 dsm_est 0.00265343 - H 0.000195313 method ARKODE_MRI_GARK_ERK33a t 0.250195 dsm 9.45845e-06 dsm_est 0.0171085 + H 0.00078125 method ARKODE_MRI_GARK_ERK33a t 4.75078 dsm 0.00143499 dsm_est 0.942031 + H 0.000195313 method ARKODE_MRI_GARK_ERK33a t 0.000195313 dsm 2.85013e-06 dsm_est 0.00265424 + H 0.000195313 method ARKODE_MRI_GARK_ERK33a t 0.250195 dsm 9.05953e-06 dsm_est 0.0171084 H 0.000195313 method ARKODE_MRI_GARK_ERK33a t 0.500195 dsm 2.05759e-05 dsm_est 0.129079 - H 0.000195313 method ARKODE_MRI_GARK_ERK33a t 0.750195 dsm 4.54636e-05 dsm_est 0.127986 - H 0.000195313 method ARKODE_MRI_GARK_ERK33a t 1.0002 dsm 6.66187e-05 dsm_est 0.00213239 + H 0.000195313 method ARKODE_MRI_GARK_ERK33a t 0.750195 dsm 4.6605e-05 dsm_est 0.127987 + H 0.000195313 method ARKODE_MRI_GARK_ERK33a t 1.0002 dsm 6.66547e-05 dsm_est 0.00213263 H 0.000195313 method ARKODE_MRI_GARK_ERK33a t 1.2502 dsm 0.000653038 dsm_est 0.945246 H 0.000195313 method ARKODE_MRI_GARK_ERK33a t 1.5002 dsm 0.000267427 dsm_est 0.186783 - H 0.000195313 method ARKODE_MRI_GARK_ERK33a t 1.7502 dsm 0.000909843 dsm_est 0.751614 - H 0.000195313 method ARKODE_MRI_GARK_ERK33a t 2.0002 dsm 1.01505e-05 dsm_est 0.185806 - H 0.000195313 method ARKODE_MRI_GARK_ERK33a t 2.2502 dsm 2.03685e-06 dsm_est 0.132009 - H 0.000195313 method ARKODE_MRI_GARK_ERK33a t 2.5002 dsm 1.75355e-05 dsm_est 0.025555 + H 0.000195313 method ARKODE_MRI_GARK_ERK33a t 1.7502 dsm 0.000909834 dsm_est 0.751614 + H 0.000195313 method ARKODE_MRI_GARK_ERK33a t 2.0002 dsm 1.02331e-05 dsm_est 0.185807 + H 0.000195313 method ARKODE_MRI_GARK_ERK33a t 2.2502 dsm 1.54333e-06 dsm_est 0.132009 + H 0.000195313 method ARKODE_MRI_GARK_ERK33a t 2.5002 dsm 1.7004e-05 dsm_est 0.0255566 H 0.000195313 method ARKODE_MRI_GARK_ERK33a t 2.7502 dsm 2.75731e-05 dsm_est 0.0139673 - H 0.000195313 method ARKODE_MRI_GARK_ERK33a t 3.0002 dsm 1.65995e-05 dsm_est 0.0198329 - H 0.000195313 method ARKODE_MRI_GARK_ERK33a t 3.2502 dsm 1.74696e-05 dsm_est 0.0112335 + H 0.000195313 method ARKODE_MRI_GARK_ERK33a t 3.0002 dsm 1.60122e-05 dsm_est 0.0198318 + H 0.000195313 method ARKODE_MRI_GARK_ERK33a t 3.2502 dsm 1.59604e-05 dsm_est 0.0112328 H 0.000195313 method ARKODE_MRI_GARK_ERK33a t 3.5002 dsm 1.2611e-05 dsm_est 0.00471821 - H 0.000195313 method ARKODE_MRI_GARK_ERK33a t 3.7502 dsm 1.02048e-05 dsm_est 0.00496587 - H 0.000195313 method ARKODE_MRI_GARK_ERK33a t 4.0002 dsm 6.90932e-06 dsm_est 0.00855639 + H 0.000195313 method ARKODE_MRI_GARK_ERK33a t 3.7502 dsm 1.0072e-05 dsm_est 0.00496521 + H 0.000195313 method ARKODE_MRI_GARK_ERK33a t 4.0002 dsm 7.64165e-06 dsm_est 0.00855534 H 0.000195313 method ARKODE_MRI_GARK_ERK33a t 4.2502 dsm 3.12732e-06 dsm_est 0.0479914 - H 0.000195313 method ARKODE_MRI_GARK_ERK33a t 4.5002 dsm 6.7755e-06 dsm_est 0.0595108 - H 0.000195313 method ARKODE_MRI_GARK_ERK33a t 4.7502 dsm 1.07392e-05 dsm_est 0.0147462 + H 0.000195313 method ARKODE_MRI_GARK_ERK33a t 4.5002 dsm 6.25467e-06 dsm_est 0.0595107 + H 0.000195313 method ARKODE_MRI_GARK_ERK33a t 4.7502 dsm 1.05712e-05 dsm_est 0.0147462 H 4.88281e-05 method ARKODE_MRI_GARK_ERK33a t 4.88281e-05 dsm 2.01535e-06 dsm_est 4.1115e-05 H 4.88281e-05 method ARKODE_MRI_GARK_ERK33a t 0.250049 dsm 0 dsm_est 0.000267507 - H 4.88281e-05 method ARKODE_MRI_GARK_ERK33a t 0.500049 dsm 0 dsm_est 0.00201736 - H 4.88281e-05 method ARKODE_MRI_GARK_ERK33a t 0.750049 dsm 1.15371e-06 dsm_est 0.00200067 + H 4.88281e-05 method ARKODE_MRI_GARK_ERK33a t 0.500049 dsm 1.50297e-06 dsm_est 0.00201586 + H 4.88281e-05 method ARKODE_MRI_GARK_ERK33a t 0.750049 dsm 1.49086e-06 dsm_est 0.00200068 H 4.88281e-05 method ARKODE_MRI_GARK_ERK33a t 1.00005 dsm 9.78971e-07 dsm_est 3.2652e-05 - H 4.88281e-05 method ARKODE_MRI_GARK_ERK33a t 1.25005 dsm 4.617e-06 dsm_est 0.0147526 - H 4.88281e-05 method ARKODE_MRI_GARK_ERK33a t 1.50005 dsm 1.89456e-06 dsm_est 0.00291509 + H 4.88281e-05 method ARKODE_MRI_GARK_ERK33a t 1.25005 dsm 3.17142e-06 dsm_est 0.0147541 + H 4.88281e-05 method ARKODE_MRI_GARK_ERK33a t 1.50005 dsm 2.18254e-06 dsm_est 0.0029151 H 4.88281e-05 method ARKODE_MRI_GARK_ERK33a t 1.75005 dsm 2.39243e-06 dsm_est 0.0117588 H 4.88281e-05 method ARKODE_MRI_GARK_ERK33a t 2.00005 dsm 1.0054e-06 dsm_est 0.00290265 - H 4.88281e-05 method ARKODE_MRI_GARK_ERK33a t 2.25005 dsm 3.36053e-06 dsm_est 0.00206332 - H 4.88281e-05 method ARKODE_MRI_GARK_ERK33a t 2.50005 dsm 4.81145e-06 dsm_est 0.000399972 - H 4.88281e-05 method ARKODE_MRI_GARK_ERK33a t 2.75005 dsm 3.34545e-06 dsm_est 0.000216445 - H 4.88281e-05 method ARKODE_MRI_GARK_ERK33a t 3.00005 dsm 5.65058e-06 dsm_est 0.000309645 + H 4.88281e-05 method ARKODE_MRI_GARK_ERK33a t 2.25005 dsm 2.03676e-06 dsm_est 0.00206178 + H 4.88281e-05 method ARKODE_MRI_GARK_ERK33a t 2.50005 dsm 3.37798e-06 dsm_est 0.000398446 + H 4.88281e-05 method ARKODE_MRI_GARK_ERK33a t 2.75005 dsm 4.72989e-06 dsm_est 0.000217912 + H 4.88281e-05 method ARKODE_MRI_GARK_ERK33a t 3.00005 dsm 6.95491e-06 dsm_est 0.000310377 H 4.88281e-05 method ARKODE_MRI_GARK_ERK33a t 3.25005 dsm 1.55004e-06 dsm_est 0.000175458 H 4.88281e-05 method ARKODE_MRI_GARK_ERK33a t 3.50005 dsm 9.19766e-07 dsm_est 7.37004e-05 H 4.88281e-05 method ARKODE_MRI_GARK_ERK33a t 3.75005 dsm 0 dsm_est 7.66833e-05 - H 4.88281e-05 method ARKODE_MRI_GARK_ERK33a t 4.00005 dsm 2.55629e-06 dsm_est 0.000133394 - H 4.88281e-05 method ARKODE_MRI_GARK_ERK33a t 4.25005 dsm 4.47754e-06 dsm_est 0.000749612 - H 4.88281e-05 method ARKODE_MRI_GARK_ERK33a t 4.50005 dsm 0 dsm_est 0.000930338 + H 4.88281e-05 method ARKODE_MRI_GARK_ERK33a t 4.00005 dsm 1.08798e-06 dsm_est 0.000134086 + H 4.88281e-05 method ARKODE_MRI_GARK_ERK33a t 4.25005 dsm 3.12694e-06 dsm_est 0.000748179 + H 4.88281e-05 method ARKODE_MRI_GARK_ERK33a t 4.50005 dsm 1.16508e-06 dsm_est 0.000930348 H 4.88281e-05 method ARKODE_MRI_GARK_ERK33a t 4.75005 dsm 6.40365e-06 dsm_est 0.000231401 ARKODE_MRI_GARK_ERK33a summary: Stepsize 0.0125 maxdsm 13680.4 maxdsmest 267128 Stepsize 0.003125 maxdsm 58.1561 maxdsmest 3954.15 Stepsize 0.00078125 maxdsm 0.231817 maxdsmest 60.7616 - Stepsize 0.000195313 maxdsm 0.000909843 maxdsmest 0.945246 - Stepsize 4.88281e-05 maxdsm 6.40365e-06 maxdsmest 0.0147526 + Stepsize 0.000195313 maxdsm 0.000909834 maxdsmest 0.945246 + Stepsize 4.88281e-05 maxdsm 6.95491e-06 maxdsmest 0.0147541 From b6e9ede9c2d9e0f17efd8cebab9b44d5766cd639 Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Thu, 7 Nov 2024 12:01:05 -0600 Subject: [PATCH 239/286] Added manual specification of ERK-3-3 Butcher table for fast_type == 0 --- examples/arkode/C_serial/ark_kpr_mri.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/examples/arkode/C_serial/ark_kpr_mri.c b/examples/arkode/C_serial/ark_kpr_mri.c index 6edfb14cee..55f3dd3425 100644 --- a/examples/arkode/C_serial/ark_kpr_mri.c +++ b/examples/arkode/C_serial/ark_kpr_mri.c @@ -432,7 +432,23 @@ int main(int argc, char* argv[]) /* Set Butcher table for fast integrator */ switch (fast_type) { - case (0): break; + case (0): + B = ARKodeButcherTable_Alloc(3, SUNTRUE); + if (check_retval((void*)B, "ARKodeButcherTable_Alloc", 0)) { return 1; } + B->A[1][0] = SUN_RCONST(0.5); + B->A[2][0] = -ONE; + B->A[2][1] = TWO; + B->b[0] = ONE / SUN_RCONST(6.0); + B->b[1] = TWO / SUN_RCONST(3.0); + B->b[2] = ONE / SUN_RCONST(6.0); + B->d[1] = ONE; + B->c[1] = SUN_RCONST(0.5); + B->c[2] = ONE; + B->q = 3; + B->p = 2; + retval = ARKStepSetTables(inner_arkode_mem, 3, 2, NULL, B); + if (check_retval(&retval, "ARKStepSetTables", 1)) { return 1; } + break; case (1): B = ARKodeButcherTable_Alloc(3, SUNFALSE); if (check_retval((void*)B, "ARKodeButcherTable_Alloc", 0)) { return 1; } From 359ae44694dcd7c759abc101c0471b088c568280 Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Thu, 7 Nov 2024 12:10:04 -0600 Subject: [PATCH 240/286] Updated answers repository commit --- test/answers | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/answers b/test/answers index 0bfe38373e..5b22a2e7e3 160000 --- a/test/answers +++ b/test/answers @@ -1 +1 @@ -Subproject commit 0bfe38373ec290e46247dc950581389dda9ce2f3 +Subproject commit 5b22a2e7e37427861aa572ea19a820df9773ccd6 From 6dba236427702a9b137c55fd95aec3ebd90e1f30 Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Thu, 7 Nov 2024 13:02:45 -0600 Subject: [PATCH 241/286] Updated answers repository commit --- examples/arkode/C_serial/ark_kpr_mri_1_0_0.01.out | 2 +- test/answers | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/arkode/C_serial/ark_kpr_mri_1_0_0.01.out b/examples/arkode/C_serial/ark_kpr_mri_1_0_0.01.out index 0c41ada159..2c625caeca 100644 --- a/examples/arkode/C_serial/ark_kpr_mri_1_0_0.01.out +++ b/examples/arkode/C_serial/ark_kpr_mri_1_0_0.01.out @@ -66,4 +66,4 @@ Multirate nonlinear Kvaerno-Prothero-Robinson test problem: Final Solver Statistics: Steps: nsts = 501, nstf = 50601 u error = 5.052e-05, v error = 7.684e-04, total error = 5.445e-04 - Total RHS evals: Fs = 1504, Ff = 253055 + Total RHS evals: Fs = 1504, Ff = 151853 diff --git a/test/answers b/test/answers index 5b22a2e7e3..f3b9604097 160000 --- a/test/answers +++ b/test/answers @@ -1 +1 @@ -Subproject commit 5b22a2e7e37427861aa572ea19a820df9773ccd6 +Subproject commit f3b960409731ab85ea6be6eef99f1277665daade From c0197277ff2b139c5da671d32c91283e8327167b Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Mon, 18 Nov 2024 13:01:59 -0600 Subject: [PATCH 242/286] Apply documentation-related suggestions from code review Co-authored-by: David Gardner --- doc/arkode/guide/source/Mathematics.rst | 12 ++++++------ .../guide/source/Usage/MRIStep/User_callable.rst | 2 +- .../SUNAdaptController_MRIHTol.rst | 4 +++- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/doc/arkode/guide/source/Mathematics.rst b/doc/arkode/guide/source/Mathematics.rst index 17e35498de..119d19c41f 100644 --- a/doc/arkode/guide/source/Mathematics.rst +++ b/doc/arkode/guide/source/Mathematics.rst @@ -644,7 +644,7 @@ algorithm for a single step: z_i - \theta_{i,i} h^S f^I(t_{n,i}^S, z_i) = a_i. :label: MRI_implicit_solve - where :math:`t_{n,j}^S = t_{n-1}*h^S c^S_j`. + where :math:`t_{n,j}^S = t_{n-1} + h^S c^S_j`. #. Set :math:`y_{n} = z_{s}`. @@ -732,7 +732,7 @@ matrices in :math:`\Gamma`. Typically, MRI-GARK and IMEX-MRI-GARK methods are at most diagonally-implicit (i.e., :math:`\Gamma_{i,j,k}=0` for all :math:`k` and :math:`j>i`). Furthermore, diagonally-implicit stages are characterized as being "solve-decoupled" if :math:`\Delta c_i^S = 0` when :math:`\Gamma_{i,i,k} \ne 0`, -in which case the stage is computed as standard ARK or DIRK update. Alternately, +in which case the stage is computed as a standard ARK or DIRK update. Alternately, a diagonally-implicit stage :math:`i` is considered "solve-coupled" if :math:`\Delta c^S_i \, \Gamma_{i,j,k} \ne 0`, in which case the stage solution :math:`z_i` is *both* an input to :math:`r_i(t)` and the @@ -783,7 +783,7 @@ The overall time step solution is given by the final internal stage solution, i.e., :math:`y_{n} = z_{s}`. The embedded solution is computing using the above algorithm for stage index :math:`s+1`, under the definition that :math:`c_{s+1}^S=1` (and thus the fast IVP portion is evolved over the full time step, -:math:`[t_{0,i},t_{F,i}] = [t_{n-1}, t_{n}]`). +:math:`[\tilde{t}_{0}, \tilde{t}_{F}] = [t_{n-1}, t_{n}]`). @@ -796,7 +796,7 @@ nearly identical to IMEX-MRI-SR methods. Specifically, like IMEX-MRI-SR methods these evolve the fast IVPs :eq:`MRI_fast_IVP` and :eq:`MRI_embedding_fast_IVP` over the intervals :math:`[t_{0,i},t_{F,i}] = [t_{n-1}, t_{n,i}^S]` and -:math:`[t_{0,i},t_{F,i}] = [t_{n-1}, t_{n}]`, respectively, and begin +:math:`[\tilde{t}_{0}, \tilde{t}_{F}] = [t_{n-1}, t_{n}]`, respectively, and begin with the initial condition :math:`v_{0,i}=y_{n-1}`. Furthermore, the fast IVP forcing functions are given by :eq:`IMEXMRISR_forcing` with :math:`f^I=0`. As MERK-based applications lack the implicit slow operator, they do not require @@ -1116,7 +1116,7 @@ arise at *both* the slow and fast time scales, which we denote here as :math:`\varepsilon^S` and :math:`\varepsilon^F`, respectively. While the slow error may be estimated as :math:`\varepsilon^S = \|y_n - \tilde{y}_n\|`, non-intrusive approaches for estimating :math:`\varepsilon^F` are more -challenging. ARKODE provides two strategies to help provide this estimate, both +challenging. ARKODE provides several strategies to help provide this estimate, all of which assume the fast integrator is temporally adaptive and, at each of its :math:`m` steps to reach :math:`t_n`, computes an estimate of the local temporal error, :math:`\varepsilon^F_{n,m}`. In this case, we assume that the @@ -1228,7 +1228,7 @@ where we again satisfy the inequality with a value of :math:`\frac12` to obtain -Comparing the two estimates :eq:`H0_TSExp0` and :eq:`H0_TSExp1`, we see that the +Comparing the two estimates :eq:`H0_TSExp1` and :eq:`H0_TSExp0`, we see that the former has double the number of :math:`f` evaluations, but that it has a less conservative estimate of :math:`h_0`, particularly since we expect any valid time integration method to have at least :math:`\mathcal{O}(h)` accuracy. diff --git a/doc/arkode/guide/source/Usage/MRIStep/User_callable.rst b/doc/arkode/guide/source/Usage/MRIStep/User_callable.rst index 24b23e75d9..04108da3bf 100644 --- a/doc/arkode/guide/source/Usage/MRIStep/User_callable.rst +++ b/doc/arkode/guide/source/Usage/MRIStep/User_callable.rst @@ -1552,7 +1552,7 @@ Main solver optional output functions Returns the number of recoverable failures reported by the inner stepper (so far). :param arkode_mem: pointer to the MRIStep memory block. - :param inner_fails: number of slow steps taken in the solver. + :param inner_fails: number of failed fast (inner) integrations. :retval ARK_SUCCESS: if successful :retval ARK_MEM_NULL: if the MRIStep memory was ``NULL`` diff --git a/doc/shared/sunadaptcontroller/SUNAdaptController_MRIHTol.rst b/doc/shared/sunadaptcontroller/SUNAdaptController_MRIHTol.rst index 4012dabab6..10e314dd40 100644 --- a/doc/shared/sunadaptcontroller/SUNAdaptController_MRIHTol.rst +++ b/doc/shared/sunadaptcontroller/SUNAdaptController_MRIHTol.rst @@ -138,6 +138,7 @@ also provides the following additional user-callable routines: :param HControl: the slow time step adaptivity controller object. :param TolControl: the inner solver tolerance factor adaptivity controller object. :param sunctx: the current :c:type:`SUNContext` object. + :returns: if successful, a usable :c:type:`SUNAdaptController` object; otherwise it will return ``NULL``. @@ -152,7 +153,8 @@ also provides the following additional user-callable routines: :param C: the SUNAdaptController_MRIHTol object. :param inner_max_relch: the parameter :math:`relch_{\text{max}}` (must be :math:`\ge 1`). :param inner_min_tolfac: the parameter :math:`\text{tolfac}_{min}` (must be :math:`> 0`). - :param inner_max_tolfac: the parameter :math:`\text{tolfac}_{max}` (must be :math:`>= 1`). + :param inner_max_tolfac: the parameter :math:`\text{tolfac}_{max}` (must be :math:`\ge 1`). + :returns: :c:type:`SUNErrCode` indicating success or failure. From b400ad81cde7833a319a175815b73ae32d223812 Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Mon, 18 Nov 2024 13:04:45 -0600 Subject: [PATCH 243/286] Apply documentation suggestion from code review Co-authored-by: David Gardner --- doc/shared/sunadaptcontroller/SUNAdaptController_MRIHTol.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/shared/sunadaptcontroller/SUNAdaptController_MRIHTol.rst b/doc/shared/sunadaptcontroller/SUNAdaptController_MRIHTol.rst index 10e314dd40..514c8d923e 100644 --- a/doc/shared/sunadaptcontroller/SUNAdaptController_MRIHTol.rst +++ b/doc/shared/sunadaptcontroller/SUNAdaptController_MRIHTol.rst @@ -81,7 +81,7 @@ results from *TolControl*. If *TolControl* predicts a control parameter enforcing the following bounds: .. math:: - \frac{\text{tolfac}_{n}^F}{\text{tolfac}'} &\ge relch_{\text{max}},\\ + \frac{\text{tolfac}_{n}^F}{\text{tolfac}'} &\le relch_{\text{max}},\\ \frac{\text{tolfac}'}{\text{tolfac}_{n}^F} &\le relch_{\text{max}},\\ \text{tolfac}_{min} &\le \text{tolfac}' \le \text{tolfac}_{max}. From 3cde505b883593f9b5d3b71fa4a7e2d8b53590ee Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Mon, 18 Nov 2024 13:40:34 -0600 Subject: [PATCH 244/286] Adjusted bounds on MRIHTol parameters according to PR comments --- .../SUNAdaptController_MRIHTol.rst | 6 ++--- .../mrihtol/sunadaptcontroller_mrihtol.c | 24 ++++++------------- 2 files changed, 10 insertions(+), 20 deletions(-) diff --git a/doc/shared/sunadaptcontroller/SUNAdaptController_MRIHTol.rst b/doc/shared/sunadaptcontroller/SUNAdaptController_MRIHTol.rst index 514c8d923e..5d1e4c4fc6 100644 --- a/doc/shared/sunadaptcontroller/SUNAdaptController_MRIHTol.rst +++ b/doc/shared/sunadaptcontroller/SUNAdaptController_MRIHTol.rst @@ -147,13 +147,13 @@ also provides the following additional user-callable routines: 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. If any argument is negative, that parameter will be reset to its - default value. + the problem. If any argument is outside the allowable range, that parameter + will be reset to its default value. :param C: the SUNAdaptController_MRIHTol object. :param inner_max_relch: the parameter :math:`relch_{\text{max}}` (must be :math:`\ge 1`). :param inner_min_tolfac: the parameter :math:`\text{tolfac}_{min}` (must be :math:`> 0`). - :param inner_max_tolfac: the parameter :math:`\text{tolfac}_{max}` (must be :math:`\ge 1`). + :param inner_max_tolfac: the parameter :math:`\text{tolfac}_{max}` (must be :math:`> 0` and :math:`\le 1`). :returns: :c:type:`SUNErrCode` indicating success or failure. diff --git a/src/sunadaptcontroller/mrihtol/sunadaptcontroller_mrihtol.c b/src/sunadaptcontroller/mrihtol/sunadaptcontroller_mrihtol.c index 899f184905..1a7990728c 100644 --- a/src/sunadaptcontroller/mrihtol/sunadaptcontroller_mrihtol.c +++ b/src/sunadaptcontroller/mrihtol/sunadaptcontroller_mrihtol.c @@ -34,7 +34,7 @@ /* minimum tolerance factor for inner solver */ #define INNER_MIN_TOLFAC SUN_RCONST(1.e-5) /* maximum tolerance factor for inner solver */ -#define INNER_MAX_TOLFAC SUN_RCONST(1.e0) +#define INNER_MAX_TOLFAC SUN_RCONST(1.0) /* --------------- * Macro accessors @@ -115,33 +115,23 @@ SUNErrCode SUNAdaptController_SetParams_MRIHTol(SUNAdaptController C, sunrealtype inner_max_tolfac) { SUNFunctionBegin(C->sunctx); - if (inner_max_relch < SUN_RCONST(0.0)) + SUNAssert(inner_max_tolfac > inner_min_tolfac, SUN_ERR_ARG_OUTOFRANGE); + if (inner_max_relch < SUN_RCONST(1.0)) { MRIHTOL_INNER_MAX_RELCH(C) = INNER_MAX_RELCH; } - else if (inner_max_relch < SUN_RCONST(1.0)) { return SUN_ERR_ARG_OUTOFRANGE; } else { MRIHTOL_INNER_MAX_RELCH(C) = inner_max_relch; } - - if (inner_min_tolfac < SUN_RCONST(0.0)) + if (inner_min_tolfac <= SUN_RCONST(0.0)) { MRIHTOL_INNER_MIN_TOLFAC(C) = INNER_MIN_TOLFAC; } - else if (inner_min_tolfac == SUN_RCONST(0.0)) - { - return SUN_ERR_ARG_OUTOFRANGE; - } else { MRIHTOL_INNER_MIN_TOLFAC(C) = inner_min_tolfac; } - - if (inner_max_tolfac < SUN_RCONST(0.0)) + if ((inner_max_tolfac <= SUN_RCONST(0.0)) || + (inner_max_tolfac > SUN_RCONST(1.0))) { - MRIHTOL_INNER_MAX_RELCH(C) = INNER_MAX_RELCH; - } - else if (inner_max_tolfac < SUN_RCONST(1.0)) - { - return SUN_ERR_ARG_OUTOFRANGE; + MRIHTOL_INNER_MAX_TOLFAC(C) = INNER_MAX_TOLFAC; } else { MRIHTOL_INNER_MAX_TOLFAC(C) = inner_max_tolfac; } - return SUN_SUCCESS; } From 35572be9382d5cfd62fb77299fc847d44ee154a9 Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Mon, 18 Nov 2024 14:32:01 -0600 Subject: [PATCH 245/286] Apply minor suggestions from code review Co-authored-by: David Gardner --- src/arkode/arkode.c | 2 +- src/arkode/arkode_mristep.c | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/arkode/arkode.c b/src/arkode/arkode.c index a777103cf5..12912fbde8 100644 --- a/src/arkode/arkode.c +++ b/src/arkode/arkode.c @@ -2041,7 +2041,7 @@ int arkInitialSetup(ARKodeMem ark_mem, sunrealtype tout) /* If necessary, temporarily set h as it is used to compute the tolerance in a potential mass matrix solve when computing the full rhs */ ark_mem->h = SUNRabs(tout - ark_mem->tcur); - if (ark_mem->h == ZERO) ark_mem->h = ONE; + if (ark_mem->h == ZERO) { ark_mem->h = ONE; } /* Estimate the first step size */ tout_hin = tout; diff --git a/src/arkode/arkode_mristep.c b/src/arkode/arkode_mristep.c index 52237bfa33..25db4ce1dc 100644 --- a/src/arkode/arkode_mristep.c +++ b/src/arkode/arkode_mristep.c @@ -1922,7 +1922,7 @@ int mriStep_TakeStepMRIGARK(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPt /* Compute updated slow RHS, except: 1. if the stage is excluded from stage_map - 3. if the next stage has "STIFF_ACC" type, and temporal estimation is disabled */ + 2. if the next stage has "STIFF_ACC" type, and temporal estimation is disabled */ calc_fslow = SUNTRUE; if (step_mem->stage_map[is] == -1) { calc_fslow = SUNFALSE; } if (!do_embedding && (step_mem->stagetypes[is + 1] == MRISTAGE_STIFF_ACC)) @@ -3326,6 +3326,7 @@ int mriStep_CheckCoupling(ARKodeMem ark_mem) if (k == -1) { break; } if ((k < 0) || (k > step_mem->MRIC->stages)) { + free(group_counter); arkProcessError(ark_mem, ARK_INVALID_TABLE, __LINE__, __func__, __FILE__, "Invalid MERK group index!"); return (ARK_INVALID_TABLE); @@ -3337,6 +3338,7 @@ int mriStep_CheckCoupling(ARKodeMem ark_mem) { if ((group_counter[i] == 0) || (group_counter[i] > 1)) { + free(group_counter); arkProcessError(ark_mem, ARK_INVALID_TABLE, __LINE__, __func__, __FILE__, "Duplicated/missing stages from MERK groups!"); return (ARK_INVALID_TABLE); @@ -3478,13 +3480,12 @@ int mriStep_StageERKFast(ARKodeMem ark_mem, ARKodeMRIStepMem step_mem, { retval = mriStepInnerStepper_GetAccumulatedError(step_mem->stepper, &(step_mem->inner_dsm)); - if (retval < 0) + if (retval != ARK_SUCCESS) { arkProcessError(ark_mem, ARK_INNERSTEP_FAIL, __LINE__, __func__, __FILE__, "Unable to get accumulated error from the inner stepper"); return (ARK_INNERSTEP_FAIL); } - if (retval > 0) { return TRY_AGAIN; } } } From f18f722054784de757133adf741995b0ab0e3c44 Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Mon, 18 Nov 2024 14:47:38 -0600 Subject: [PATCH 246/286] Comment fix --- src/arkode/arkode_io.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/arkode/arkode_io.c b/src/arkode/arkode_io.c index 15a71450e0..4c63222bec 100644 --- a/src/arkode/arkode_io.c +++ b/src/arkode/arkode_io.c @@ -2453,8 +2453,7 @@ int ARKodeGetAccumulatedError(void* arkode_mem, sunrealtype* accum_error) return (ARK_STEPPER_UNSUPPORTED); } - /* Get number of steps since last accumulated error reset - (set floor of 1 to safeguard against division-by-zero) */ + /* Get time since last accumulated error reset */ sunrealtype time_interval = ark_mem->tcur - ark_mem->AccumErrorStart; /* Fill output based on error accumulation type */ From c0aab9e83540b5f1548d7264608c28ce66b412e0 Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Mon, 18 Nov 2024 14:48:16 -0600 Subject: [PATCH 247/286] Updated handling of stiffly-accurate MRI stages in ARK_FULLRHS_END mode --- src/arkode/arkode_mristep.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/src/arkode/arkode_mristep.c b/src/arkode/arkode_mristep.c index 25db4ce1dc..b96281a07d 100644 --- a/src/arkode/arkode_mristep.c +++ b/src/arkode/arkode_mristep.c @@ -1478,26 +1478,22 @@ int mriStep_FullRHS(ARKodeMem ark_mem, sunrealtype t, N_Vector y, N_Vector f, { /* if the method had a stiffly-accurate internal stage, use the already-computed RHS vectors */ - sa_stage = -1; - for (i = 1; i < step_mem->stages; i++) - { - if (step_mem->stagetypes[i] == MRISTAGE_STIFF_ACC) - { - sa_stage = step_mem->stage_map[i - 1]; - } - } + sa_stage = (step_mem->stagetypes[step_mem->stages-1] == MRISTAGE_STIFF_ACC) ? + step_mem->stage_map[step_mem->stages - 2] : -1; if (sa_stage > -1) { /* copy the explicit component */ if (step_mem->explicit_rhs) { N_VScale(ONE, step_mem->Fse[sa_stage], step_mem->Fse[0]); + step_mem->fse_is_current = SUNTRUE; } /* copy the implicit component */ if (step_mem->implicit_rhs) { N_VScale(ONE, step_mem->Fsi[sa_stage], step_mem->Fsi[0]); + step_mem->fsi_is_current = SUNTRUE; } } else From 46eeed1245d9aead2262c71d66e2431cfe2da78c Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Tue, 19 Nov 2024 10:09:16 -0600 Subject: [PATCH 248/286] Fixed incorrect internal documentation regarding how the FullRHS 'modes' are used --- src/arkode/arkode_arkstep.c | 74 ++++++++++++++++++--------- src/arkode/arkode_erkstep.c | 62 +++++++++++++++-------- src/arkode/arkode_impl.h | 99 ++++++++++++++++++++++++++++++------- src/arkode/arkode_mristep.c | 86 +++++++++++++++++++++++--------- 4 files changed, 237 insertions(+), 84 deletions(-) diff --git a/src/arkode/arkode_arkstep.c b/src/arkode/arkode_arkstep.c index c190edce5f..e4561d2ba7 100644 --- a/src/arkode/arkode_arkstep.c +++ b/src/arkode/arkode_arkstep.c @@ -1234,28 +1234,58 @@ int arkStep_Init(ARKodeMem ark_mem, SUNDIALS_MAYBE_UNUSED sunrealtype tout, This will be called in one of three 'modes': - ARK_FULLRHS_START -> called at the beginning of a simulation i.e., at - (tn, yn) = (t0, y0) or (tR, yR) - - ARK_FULLRHS_END -> called at the end of a successful step i.e, at - (tcur, ycur) or the start of the subsequent step i.e., - at (tn, yn) = (tcur, ycur) from the end of the last - step - - ARK_FULLRHS_OTHER -> called elsewhere (e.g. for dense output) - - If this function is called in ARK_FULLRHS_START or ARK_FULLRHS_END mode and - evaluating the RHS functions is necessary, we store the vectors fe(t,y) and - fi(t,y) in Fe[0] and Fi[0] for possible reuse in the first stage of the - subsequent time step. - - In ARK_FULLRHS_END mode we check if the method is stiffly accurate and, if - appropriate, copy the vectors Fe[stages - 1] and Fi[stages - 1] to Fe[0] and - Fi[0] for possible reuse in the first stage of the subsequent time step. - - ARK_FULLRHS_OTHER mode is only called for dense output in-between steps, or - when estimating the initial time step size, so we strive to store the - intermediate parts so that they do not interfere with the other two modes. + ARK_FULLRHS_START -> called in the following circumstances: + (a) at the beginning of a simulation i.e., at + (tn, yn) = (t0, y0) or (tR, yR), + (b) when transitioning between time steps t_{n-1} + \to t_{n} to fill f_{n-1} within the Hermite + interpolation module, or + (c) by ARKStep at the start of the first internal step. + In each case, we may check the fn_is_current flag to + know whether the values stored in Fe[0] and Fi[0] are + up-to-date, allowing us to copy those values instead of + recomputing. If these values are not current, then the RHS + should be stored in Fe[0] and Fi[0] for reuse later, + before copying the values into the output vector. + + ARK_FULLRHS_END -> called in the following circumstances: + (a) when temporal root-finding is enabled, this will be + called in-between steps t_{n-1} \to t_{n} to fill f_{n}, + (b) when high-order dense output is requested from the + Hermite interpolation module in-between steps t_{n-1} + \to t_{n} to fill f_{n}, + (c) when an implicit predictor is requested from the Hermite + interpolation module within the time step t_{n} \to + t_{n+1}, in which case f_{n} needs to be filled, or + (d) by ARKStep when starting a time step t_{n} \to t_{n+1} + and when using an FSAL method. + Again, we may check the fn_is_current flag to know whether + ARKODE believes that the values stored in Fe[0] and Fi[0] + are up-to-date, and may just be copied. If those values + are not current, then the only instance where recomputation + is not needed is (d), since the values in Fe[stages - 1] + and Fi[stages - 1] may be copied into Fe[0] and Fi[0], + respectively. In all other cases, the RHS should be + recomputed and stored in Fe[0] and Fi[0] for reuse + later, before copying the values into the output vector. + + ARK_FULLRHS_OTHER -> called in the following circumstances: + (a) when estimating the initial time step size, + (b) for high-order dense output with the Hermite + interpolation module, + (c) by an "outer" stepper when ARKStep is used as an + inner solver), or + (d) when a high-order implicit predictor is requested from + the Hermite interpolation module within the time step + t_{n} \to t_{n+1}. + While instances (a)-(c) will occur in-between ARKStep time + steps, instance (d) can occur at the start of each internal + ARKStep stage. Since the (t,y) input does not correspond + to an "official" time step, thus the RHS functions should + always be evaluated, and the values should *not* be stored + anywhere that will interfere with other reused ARKStep data + from one stage to the next (but it may use nonlinear solver + scratch space). ----------------------------------------------------------------------------*/ int arkStep_FullRHS(ARKodeMem ark_mem, sunrealtype t, N_Vector y, N_Vector f, int mode) diff --git a/src/arkode/arkode_erkstep.c b/src/arkode/arkode_erkstep.c index f56dbf782c..da2cc18f03 100644 --- a/src/arkode/arkode_erkstep.c +++ b/src/arkode/arkode_erkstep.c @@ -535,27 +535,47 @@ int erkStep_Init(ARKodeMem ark_mem, SUNDIALS_MAYBE_UNUSED sunrealtype tout, This will be called in one of three 'modes': - ARK_FULLRHS_START -> called at the beginning of a simulation i.e., at - (tn, yn) = (t0, y0) or (tR, yR) - - ARK_FULLRHS_END -> called at the end of a successful step i.e, at - (tcur, ycur) or the start of the subsequent step i.e., - at (tn, yn) = (tcur, ycur) from the end of the last - step - - ARK_FULLRHS_OTHER -> called elsewhere (e.g. for dense output) - - If this function is called in ARK_FULLRHS_START or ARK_FULLRHS_END mode and - evaluating the RHS functions is necessary, we store the vector f(t,y) in Fe[0] - for reuse in the first stage of the subsequent time step. - - In ARK_FULLRHS_END mode we check if the method is "stiffly accurate" and, if - appropriate, copy the vector F[stages - 1] to F[0] for reuse in the first - stage of the subsequent time step. - - ARK_FULLRHS_OTHER mode is only called for dense output in-between steps, or - when estimating the initial time step size, so we strive to store the - intermediate parts so that they do not interfere with the other two modes. + ARK_FULLRHS_START -> called in the following circumstances: + (a) at the beginning of a simulation i.e., at + (tn, yn) = (t0, y0) or (tR, yR), + (b) when transitioning between time steps t_{n-1} + \to t_{n} to fill f_{n-1} within the Hermite + interpolation module, or + (c) by ERKStep at the start of the first internal step. + In each case, we may check the fn_is_current flag to + know whether the values stored in F[0] are up-to-date, + allowing us to copy those values instead of recomputing. + If these values are not current, then the RHS should be + stored in F[0] for reuse later, before copying the values + into the output vector. + + ARK_FULLRHS_END -> called in the following circumstances: + (a) when temporal root-finding is enabled, this will be + called in-between steps t_{n-1} \to t_{n} to fill f_{n}, + (b) when high-order dense output is requested from the + Hermite interpolation module in-between steps t_{n-1} + \to t_{n} to fill f_{n}, or + (c) by ERKStep when starting a time step t_{n} \to t_{n+1} + and when using an FSAL method. + Again, we may check the fn_is_current flag to know whether + ARKODE believes that the values stored in F[0] are + up-to-date, and may just be copied. If the values stored + in F[0] are not current, then the only instance where + recomputation is not needed is (c), since the values in + F[stages - 1] may be copied into F[0]. In all other cases, + the RHS should be recomputed and stored in F[0] for reuse + later, before copying the values into the output vector. + + ARK_FULLRHS_OTHER -> called in the following circumstances: + (a) when estimating the initial time step size, + (b) for high-order dense output with the Hermite + interpolation module, or + (c) by an "outer" stepper when ERKStep is used as an + inner solver). + All of these instances will occur in-between ERKStep time + steps, but the (t,y) input does not correspond to an + "official" time step, thus the RHS should always be + evaluated, with the values *not* stored in F[0]. ----------------------------------------------------------------------------*/ int erkStep_FullRHS(ARKodeMem ark_mem, sunrealtype t, N_Vector y, N_Vector f, int mode) diff --git a/src/arkode/arkode_impl.h b/src/arkode/arkode_impl.h index c0fc6cee19..a4049afcf1 100644 --- a/src/arkode/arkode_impl.h +++ b/src/arkode/arkode_impl.h @@ -1022,31 +1022,92 @@ int arkGetLastKFlag(void* arkode_mem, int* last_kflag); This routine must compute the full ODE right-hand side function at the inputs (t,y), and store the result in the N_Vector f. Depending on the type of stepper, this may be just the single - ODE RHS function supplied (e.g. ERK, DIRK, IRK), or it may be + ODE RHS function supplied (e.g. ERK, DIRK), or it may be the sum of many ODE RHS functions (e.g. ARK, MRI). The 'mode' indicates where this routine is called: - ARK_FULLRHS_START -> called at the beginning of a simulation - i.e., at (tn, yn) = (t0, y0) or (tR, yR) - - ARK_FULLRHS_END -> called at the end of a successful step i.e, - at (tcur, ycur) or the start of the subsequent - step i.e., at (tn, yn) = (tcur, ycur) from - the end of the last step - - ARK_FULLRHS_OTHER -> called elsewhere (e.g. for dense output) - - It is recommended that the stepper use the mode information to - maximize reuse between calls to this function and RHS - evaluations inside the stepper itself. - - This routine is only required to be supplied to ARKODE if: - * ARKODE's initial time step selection algorithm is used, + ARK_FULLRHS_START -> called in the following circumstances: + (a) at the beginning of a simulation + i.e., at (tn, yn) = (t0, y0) or + (tR, yR), or + (b) when transitioning between time + steps t_{n-1} \to t_{n} to fill + f_{n-1} within the Hermite + interpolation module. + In each case, the stepper may check the + fn_is_current flag to know whether + ARKODE believes that the RHS may have + already been computed at this (t,y) + value, in which case the stepper can + copy the RHS data from its own internal + storage instead of recomputing. If + these values are not current, then the + RHS should be recomputed, and the + stepper should consider storing the + values internally, for potential reuse + later. + + ARK_FULLRHS_END -> called in the following circumstances: + (a) when temporal root-finding is + enabled, this will be called + in-between steps t_{n-1} \to t_{n} + to fill f_{n}, + (b) when high-order dense output is + requested from the Hermite + interpolation module in-between + steps t_{n-1} \to t_{n} to fill + f_{n}, or + (c) when an implicit predictor is + requested from the Hermite + interpolation module within the + time step t_{n} \to t_{n+1}, in + which case f_{n} needs to be + filled. + Again, the stepper may check the + fn_is_current flag to know whether + ARKODE believes that the RHS may have + already been computed at this (t,y) + value, in which case the stepper can + copy the RHS data from its own + internal storage instead of + recomputing. If these values are not + current, then the RHS should be + recomputed, and the stepper should + consider storing the values internally, + for potential reuse later. + + ARK_FULLRHS_OTHER -> called in the following circumstances: + (a) when estimating the initial time + step size, + (b) for high-order dense output with the + Hermite interpolation module, + (c) by an "outer" stepper when ARKODE is + used as an inner solver), or + (d) when a high-order implicit predictor + is requested from the Hermite + interpolation module within the time + step t_{n} \to t_{n+1}. + While instances (a)-(c) will occur + in-between calls to the stepper's + ARKTimestepStepFn, instance (d) would + occur from within the ARKTimestepStepFn + (only if it calls an arkPredict_* function + that internally calls arkInterpEvaluate). + Since the (t,y) input does not correspond + to an "official" time step, the RHS + functions should always be evaluated, and + the values should *not* be stored anywhere + that will interfere with other reused + stepper data. + + This routine is only *required* to be supplied to ARKODE if: + * ARKODE's initial time step selection algorithm (arkHin) is used, * the user requests temporal root-finding, * the Hermite interpolation module is used, or - * the user requests the "bootstrap" implicit predictor. + * the time-stepping module requests the "bootstrap" implicit predictor. Note that any stepper can itself require that this routine - exist for its own internal business (e.g., ERKStep). + exist for its own internal business (as in both ERKStep and ARKStep), + and/or call this routine for its own internal purposes. This routine should return 0 if successful, and a negative value otherwise. If an error does occur, an appropriate message diff --git a/src/arkode/arkode_mristep.c b/src/arkode/arkode_mristep.c index b96281a07d..9938bceb2e 100644 --- a/src/arkode/arkode_mristep.c +++ b/src/arkode/arkode_mristep.c @@ -1329,28 +1329,70 @@ int mriStep_Init(ARKodeMem ark_mem, sunrealtype tout, int init_type) This is just a wrapper to call the user-supplied RHS functions, f(t,y) = fse(t,y) + fsi(t,y) + ff(t,y). - This will be called in one of three 'modes': - - ARK_FULLRHS_START -> called at the beginning of a simulation i.e., at - (tn, yn) = (t0, y0) or (tR, yR) - - ARK_FULLRHS_END -> called at the end of a successful step i.e, at - (tcur, ycur) or the start of the subsequent step i.e., - at (tn, yn) = (tcur, ycur) from the end of the last - step - - ARK_FULLRHS_OTHER -> called elsewhere (e.g. for dense output) - - If this function is called in ARK_FULLRHS_START or ARK_FULLRHS_END mode and - evaluating the RHS functions is necessary, we store the vectors fse(t,y) and - fsi(t,y) in Fse[0] and Fsi[0] for possible reuse in the first stage of the - subsequent time step. - - ARK_FULLRHS_OTHER mode is only called for dense output in-between steps, or - when estimating the initial time step size, so we strive to store the - intermediate parts so that they do not interfere with the other two modes. - - Presently ff(t,y) is always called with ARK_FULLRHS_OTHER mode. + ARK_FULLRHS_START -> called in the following circumstances: + (a) at the beginning of a simulation i.e., at + (tn, yn) = (t0, y0) or (tR, yR), or + (b) when transitioning between time steps t_{n-1} + \to t_{n} to fill f_{n-1} within the Hermite + interpolation module. + In each case, we may check the fn_is_current flag to + know whether ARKODE believes the values stored in + Fse[0] and Fsi[0] are up-to-date, allowing us to copy + those values instead of recomputing. MRIStep + additionally stores internal fse_is_current and + fsi_is_current flags to denote whether it + additionally believes recomputation is necessary -- + this is because unlike ARKStep and ERKStep, when + MRIStep is used as an inner stepper for an outer + MRIStep calculation, it must store any forcing terms + *inside* its own values of one of Fse or Fsi (to + avoid a combinatorial explosion of separate forcing + vectors when used in a telescopic MRI calculation). + For whichever of Fse[0] and Fsi[0] are deemed not + current, the corresponding RHS function is + recomputed and stored in Fe[0] and/or Fi[0] for + reuse later, before copying the values into the + output vector. + + ARK_FULLRHS_END -> called in the following circumstances: + (a) when temporal root-finding is enabled, this will be + called in-between steps t_{n-1} \to t_{n} to fill f_{n}, + (b) when high-order dense output is requested from the + Hermite interpolation module in-between steps t_{n-1} + \to t_{n} to fill f_{n}, or + (c) when an implicit predictor is requested from the Hermite + interpolation module within the time step t_{n} \to + t_{n+1}, in which case f_{n} needs to be filled. + Again, we may check the fn_is_current flags to know whether + ARKODE believes that the values stored in Fse[0] and Fsi[0] + are up-to-date, and may just be copied. We also again + verify the ability to copy by viewing the MRIStep-specific + fse_is_current and fsi_is_current flags. If one or both of + Fse[0] and Fsi[0] are determined to be not current. In all + other cases, the RHS should be recomputed and stored in + Fse[0] and Fsi[0] for reuse later, before copying the + values into the output vector. + + ARK_FULLRHS_OTHER -> called in the following circumstances: + (a) when estimating the initial time step size, + (b) for high-order dense output with the Hermite + interpolation module, + (c) by an "outer" stepper when MRIStep is used as an + inner solver), or + (d) when a high-order implicit predictor is requested from + the Hermite interpolation module within the time step + t_{n} \to t_{n+1}. + While instances (a)-(c) will occur in-between MRIStep time + steps, instance (d) can occur at the start of each internal + MRIStep stage. Since the (t,y) input does not correspond + to an "official" time step, thus the RHS functions should + always be evaluated, and the values should *not* be stored + anywhere that will interfere with other reused MRIStep data + from one stage to the next (but it may use nonlinear solver + scratch space). + + Note that this routine always calls the fast RHS function, ff(t,y), in + ARK_FULLRHS_OTHER mode. ----------------------------------------------------------------------------*/ int mriStep_FullRHS(ARKodeMem ark_mem, sunrealtype t, N_Vector y, N_Vector f, int mode) From f9d23e177752a54b0bea522c6771e957c65f43d5 Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Tue, 19 Nov 2024 12:01:58 -0600 Subject: [PATCH 249/286] Updated SUNAdaptController_Get*Controller_MRIHTol to return a SUNErrCode --- .../sunadaptcontroller_mrihtol.h | 8 ++--- .../fsunadaptcontroller_mrihtol_mod.c | 24 +++++++------ .../fsunadaptcontroller_mrihtol_mod.f90 | 36 +++++++++++-------- .../fsunadaptcontroller_mrihtol_mod.c | 24 +++++++------ .../fsunadaptcontroller_mrihtol_mod.f90 | 36 +++++++++++-------- .../mrihtol/sunadaptcontroller_mrihtol.c | 14 +++++--- 6 files changed, 86 insertions(+), 56 deletions(-) diff --git a/include/sunadaptcontroller/sunadaptcontroller_mrihtol.h b/include/sunadaptcontroller/sunadaptcontroller_mrihtol.h index 9f100353f1..720201cf97 100644 --- a/include/sunadaptcontroller/sunadaptcontroller_mrihtol.h +++ b/include/sunadaptcontroller/sunadaptcontroller_mrihtol.h @@ -53,11 +53,11 @@ SUNErrCode SUNAdaptController_SetParams_MRIHTol(SUNAdaptController C, sunrealtype inner_min_tolfac, sunrealtype inner_max_tolfac); SUNDIALS_EXPORT -SUNAdaptController SUNAdaptController_GetSlowController_MRIHTol( - SUNAdaptController C); +SUNErrCode SUNAdaptController_GetSlowController_MRIHTol( + SUNAdaptController C, SUNAdaptController* Cslow); SUNDIALS_EXPORT -SUNAdaptController SUNAdaptController_GetFastController_MRIHTol( - SUNAdaptController C); +SUNErrCode SUNAdaptController_GetFastController_MRIHTol( + SUNAdaptController C, SUNAdaptController* Cfast); SUNDIALS_EXPORT SUNAdaptController_Type SUNAdaptController_GetType_MRIHTol(SUNAdaptController C); SUNDIALS_EXPORT diff --git a/src/sunadaptcontroller/mrihtol/fmod_int32/fsunadaptcontroller_mrihtol_mod.c b/src/sunadaptcontroller/mrihtol/fmod_int32/fsunadaptcontroller_mrihtol_mod.c index e8a0775fe4..f01662c5a8 100644 --- a/src/sunadaptcontroller/mrihtol/fmod_int32/fsunadaptcontroller_mrihtol_mod.c +++ b/src/sunadaptcontroller/mrihtol/fmod_int32/fsunadaptcontroller_mrihtol_mod.c @@ -482,26 +482,30 @@ SWIGEXPORT int _wrap_FSUNAdaptController_SetParams_MRIHTol(SUNAdaptController fa } -SWIGEXPORT SUNAdaptController _wrap_FSUNAdaptController_GetSlowController_MRIHTol(SUNAdaptController farg1) { - SUNAdaptController fresult ; +SWIGEXPORT int _wrap_FSUNAdaptController_GetSlowController_MRIHTol(SUNAdaptController farg1, void *farg2) { + int fresult ; SUNAdaptController arg1 = (SUNAdaptController) 0 ; - SUNAdaptController result; + SUNAdaptController *arg2 = (SUNAdaptController *) 0 ; + SUNErrCode result; arg1 = (SUNAdaptController)(farg1); - result = (SUNAdaptController)SUNAdaptController_GetSlowController_MRIHTol(arg1); - fresult = result; + arg2 = (SUNAdaptController *)(farg2); + result = (SUNErrCode)SUNAdaptController_GetSlowController_MRIHTol(arg1,arg2); + fresult = (SUNErrCode)(result); return fresult; } -SWIGEXPORT SUNAdaptController _wrap_FSUNAdaptController_GetFastController_MRIHTol(SUNAdaptController farg1) { - SUNAdaptController fresult ; +SWIGEXPORT int _wrap_FSUNAdaptController_GetFastController_MRIHTol(SUNAdaptController farg1, void *farg2) { + int fresult ; SUNAdaptController arg1 = (SUNAdaptController) 0 ; - SUNAdaptController result; + SUNAdaptController *arg2 = (SUNAdaptController *) 0 ; + SUNErrCode result; arg1 = (SUNAdaptController)(farg1); - result = (SUNAdaptController)SUNAdaptController_GetFastController_MRIHTol(arg1); - fresult = result; + arg2 = (SUNAdaptController *)(farg2); + result = (SUNErrCode)SUNAdaptController_GetFastController_MRIHTol(arg1,arg2); + fresult = (SUNErrCode)(result); return fresult; } diff --git a/src/sunadaptcontroller/mrihtol/fmod_int32/fsunadaptcontroller_mrihtol_mod.f90 b/src/sunadaptcontroller/mrihtol/fmod_int32/fsunadaptcontroller_mrihtol_mod.f90 index d333a6dd9c..5d38166728 100644 --- a/src/sunadaptcontroller/mrihtol/fmod_int32/fsunadaptcontroller_mrihtol_mod.f90 +++ b/src/sunadaptcontroller/mrihtol/fmod_int32/fsunadaptcontroller_mrihtol_mod.f90 @@ -198,20 +198,22 @@ function swigc_FSUNAdaptController_SetParams_MRIHTol(farg1, farg2, farg3, farg4) integer(C_INT) :: fresult end function -function swigc_FSUNAdaptController_GetSlowController_MRIHTol(farg1) & +function swigc_FSUNAdaptController_GetSlowController_MRIHTol(farg1, farg2) & bind(C, name="_wrap_FSUNAdaptController_GetSlowController_MRIHTol") & result(fresult) use, intrinsic :: ISO_C_BINDING type(C_PTR), value :: farg1 -type(C_PTR) :: fresult +type(C_PTR), value :: farg2 +integer(C_INT) :: fresult end function -function swigc_FSUNAdaptController_GetFastController_MRIHTol(farg1) & +function swigc_FSUNAdaptController_GetFastController_MRIHTol(farg1, farg2) & bind(C, name="_wrap_FSUNAdaptController_GetFastController_MRIHTol") & result(fresult) use, intrinsic :: ISO_C_BINDING type(C_PTR), value :: farg1 -type(C_PTR) :: fresult +type(C_PTR), value :: farg2 +integer(C_INT) :: fresult end function function swigc_FSUNAdaptController_GetType_MRIHTol(farg1) & @@ -501,30 +503,36 @@ function FSUNAdaptController_SetParams_MRIHTol(c, inner_max_relch, inner_min_tol swig_result = fresult end function -function FSUNAdaptController_GetSlowController_MRIHTol(c) & +function FSUNAdaptController_GetSlowController_MRIHTol(c, cslow) & result(swig_result) use, intrinsic :: ISO_C_BINDING -type(SUNAdaptController), pointer :: swig_result +integer(C_INT) :: swig_result type(SUNAdaptController), target, intent(inout) :: c -type(C_PTR) :: fresult +type(C_PTR), target, intent(inout) :: cslow +integer(C_INT) :: fresult type(C_PTR) :: farg1 +type(C_PTR) :: farg2 farg1 = c_loc(c) -fresult = swigc_FSUNAdaptController_GetSlowController_MRIHTol(farg1) -call c_f_pointer(fresult, swig_result) +farg2 = c_loc(cslow) +fresult = swigc_FSUNAdaptController_GetSlowController_MRIHTol(farg1, farg2) +swig_result = fresult end function -function FSUNAdaptController_GetFastController_MRIHTol(c) & +function FSUNAdaptController_GetFastController_MRIHTol(c, cfast) & result(swig_result) use, intrinsic :: ISO_C_BINDING -type(SUNAdaptController), pointer :: swig_result +integer(C_INT) :: swig_result type(SUNAdaptController), target, intent(inout) :: c -type(C_PTR) :: fresult +type(C_PTR), target, intent(inout) :: cfast +integer(C_INT) :: fresult type(C_PTR) :: farg1 +type(C_PTR) :: farg2 farg1 = c_loc(c) -fresult = swigc_FSUNAdaptController_GetFastController_MRIHTol(farg1) -call c_f_pointer(fresult, swig_result) +farg2 = c_loc(cfast) +fresult = swigc_FSUNAdaptController_GetFastController_MRIHTol(farg1, farg2) +swig_result = fresult end function function FSUNAdaptController_GetType_MRIHTol(c) & diff --git a/src/sunadaptcontroller/mrihtol/fmod_int64/fsunadaptcontroller_mrihtol_mod.c b/src/sunadaptcontroller/mrihtol/fmod_int64/fsunadaptcontroller_mrihtol_mod.c index e8a0775fe4..f01662c5a8 100644 --- a/src/sunadaptcontroller/mrihtol/fmod_int64/fsunadaptcontroller_mrihtol_mod.c +++ b/src/sunadaptcontroller/mrihtol/fmod_int64/fsunadaptcontroller_mrihtol_mod.c @@ -482,26 +482,30 @@ SWIGEXPORT int _wrap_FSUNAdaptController_SetParams_MRIHTol(SUNAdaptController fa } -SWIGEXPORT SUNAdaptController _wrap_FSUNAdaptController_GetSlowController_MRIHTol(SUNAdaptController farg1) { - SUNAdaptController fresult ; +SWIGEXPORT int _wrap_FSUNAdaptController_GetSlowController_MRIHTol(SUNAdaptController farg1, void *farg2) { + int fresult ; SUNAdaptController arg1 = (SUNAdaptController) 0 ; - SUNAdaptController result; + SUNAdaptController *arg2 = (SUNAdaptController *) 0 ; + SUNErrCode result; arg1 = (SUNAdaptController)(farg1); - result = (SUNAdaptController)SUNAdaptController_GetSlowController_MRIHTol(arg1); - fresult = result; + arg2 = (SUNAdaptController *)(farg2); + result = (SUNErrCode)SUNAdaptController_GetSlowController_MRIHTol(arg1,arg2); + fresult = (SUNErrCode)(result); return fresult; } -SWIGEXPORT SUNAdaptController _wrap_FSUNAdaptController_GetFastController_MRIHTol(SUNAdaptController farg1) { - SUNAdaptController fresult ; +SWIGEXPORT int _wrap_FSUNAdaptController_GetFastController_MRIHTol(SUNAdaptController farg1, void *farg2) { + int fresult ; SUNAdaptController arg1 = (SUNAdaptController) 0 ; - SUNAdaptController result; + SUNAdaptController *arg2 = (SUNAdaptController *) 0 ; + SUNErrCode result; arg1 = (SUNAdaptController)(farg1); - result = (SUNAdaptController)SUNAdaptController_GetFastController_MRIHTol(arg1); - fresult = result; + arg2 = (SUNAdaptController *)(farg2); + result = (SUNErrCode)SUNAdaptController_GetFastController_MRIHTol(arg1,arg2); + fresult = (SUNErrCode)(result); return fresult; } diff --git a/src/sunadaptcontroller/mrihtol/fmod_int64/fsunadaptcontroller_mrihtol_mod.f90 b/src/sunadaptcontroller/mrihtol/fmod_int64/fsunadaptcontroller_mrihtol_mod.f90 index d333a6dd9c..5d38166728 100644 --- a/src/sunadaptcontroller/mrihtol/fmod_int64/fsunadaptcontroller_mrihtol_mod.f90 +++ b/src/sunadaptcontroller/mrihtol/fmod_int64/fsunadaptcontroller_mrihtol_mod.f90 @@ -198,20 +198,22 @@ function swigc_FSUNAdaptController_SetParams_MRIHTol(farg1, farg2, farg3, farg4) integer(C_INT) :: fresult end function -function swigc_FSUNAdaptController_GetSlowController_MRIHTol(farg1) & +function swigc_FSUNAdaptController_GetSlowController_MRIHTol(farg1, farg2) & bind(C, name="_wrap_FSUNAdaptController_GetSlowController_MRIHTol") & result(fresult) use, intrinsic :: ISO_C_BINDING type(C_PTR), value :: farg1 -type(C_PTR) :: fresult +type(C_PTR), value :: farg2 +integer(C_INT) :: fresult end function -function swigc_FSUNAdaptController_GetFastController_MRIHTol(farg1) & +function swigc_FSUNAdaptController_GetFastController_MRIHTol(farg1, farg2) & bind(C, name="_wrap_FSUNAdaptController_GetFastController_MRIHTol") & result(fresult) use, intrinsic :: ISO_C_BINDING type(C_PTR), value :: farg1 -type(C_PTR) :: fresult +type(C_PTR), value :: farg2 +integer(C_INT) :: fresult end function function swigc_FSUNAdaptController_GetType_MRIHTol(farg1) & @@ -501,30 +503,36 @@ function FSUNAdaptController_SetParams_MRIHTol(c, inner_max_relch, inner_min_tol swig_result = fresult end function -function FSUNAdaptController_GetSlowController_MRIHTol(c) & +function FSUNAdaptController_GetSlowController_MRIHTol(c, cslow) & result(swig_result) use, intrinsic :: ISO_C_BINDING -type(SUNAdaptController), pointer :: swig_result +integer(C_INT) :: swig_result type(SUNAdaptController), target, intent(inout) :: c -type(C_PTR) :: fresult +type(C_PTR), target, intent(inout) :: cslow +integer(C_INT) :: fresult type(C_PTR) :: farg1 +type(C_PTR) :: farg2 farg1 = c_loc(c) -fresult = swigc_FSUNAdaptController_GetSlowController_MRIHTol(farg1) -call c_f_pointer(fresult, swig_result) +farg2 = c_loc(cslow) +fresult = swigc_FSUNAdaptController_GetSlowController_MRIHTol(farg1, farg2) +swig_result = fresult end function -function FSUNAdaptController_GetFastController_MRIHTol(c) & +function FSUNAdaptController_GetFastController_MRIHTol(c, cfast) & result(swig_result) use, intrinsic :: ISO_C_BINDING -type(SUNAdaptController), pointer :: swig_result +integer(C_INT) :: swig_result type(SUNAdaptController), target, intent(inout) :: c -type(C_PTR) :: fresult +type(C_PTR), target, intent(inout) :: cfast +integer(C_INT) :: fresult type(C_PTR) :: farg1 +type(C_PTR) :: farg2 farg1 = c_loc(c) -fresult = swigc_FSUNAdaptController_GetFastController_MRIHTol(farg1) -call c_f_pointer(fresult, swig_result) +farg2 = c_loc(cfast) +fresult = swigc_FSUNAdaptController_GetFastController_MRIHTol(farg1, farg2) +swig_result = fresult end function function FSUNAdaptController_GetType_MRIHTol(c) & diff --git a/src/sunadaptcontroller/mrihtol/sunadaptcontroller_mrihtol.c b/src/sunadaptcontroller/mrihtol/sunadaptcontroller_mrihtol.c index 1a7990728c..774bb87be9 100644 --- a/src/sunadaptcontroller/mrihtol/sunadaptcontroller_mrihtol.c +++ b/src/sunadaptcontroller/mrihtol/sunadaptcontroller_mrihtol.c @@ -139,16 +139,22 @@ SUNErrCode SUNAdaptController_SetParams_MRIHTol(SUNAdaptController C, * Function to get slow and fast sub-controllers */ -SUNAdaptController SUNAdaptController_GetSlowController_MRIHTol(SUNAdaptController C) +SUNErrCode SUNAdaptController_GetSlowController_MRIHTol(SUNAdaptController C, + SUNAdaptController* Cslow) { SUNFunctionBegin(C->sunctx); - return MRIHTOL_CSLOW(C); + SUNAssert(Cslow, SUN_ERR_ARG_CORRUPT); + *Cslow = MRIHTOL_CSLOW(C); + return SUN_SUCCESS; } -SUNAdaptController SUNAdaptController_GetFastController_MRIHTol(SUNAdaptController C) +SUNErrCode SUNAdaptController_GetFastController_MRIHTol(SUNAdaptController C, + SUNAdaptController* Cfast) { SUNFunctionBegin(C->sunctx); - return MRIHTOL_CFAST(C); + SUNAssert(Cfast, SUN_ERR_ARG_CORRUPT); + *Cfast = MRIHTOL_CFAST(C); + return SUN_SUCCESS; } /* ----------------------------------------------------------------- From 3f8b3cd97f8d327751b2859dd879ce8ccb558576 Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Tue, 19 Nov 2024 15:14:15 -0600 Subject: [PATCH 250/286] Minor documentation edits --- src/arkode/arkode_arkstep.c | 10 +++++++--- src/arkode/arkode_erkstep.c | 3 +++ src/arkode/arkode_impl.h | 3 +++ 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/src/arkode/arkode_arkstep.c b/src/arkode/arkode_arkstep.c index e4561d2ba7..911a6531d5 100644 --- a/src/arkode/arkode_arkstep.c +++ b/src/arkode/arkode_arkstep.c @@ -1240,7 +1240,9 @@ int arkStep_Init(ARKodeMem ark_mem, SUNDIALS_MAYBE_UNUSED sunrealtype tout, (b) when transitioning between time steps t_{n-1} \to t_{n} to fill f_{n-1} within the Hermite interpolation module, or - (c) by ARKStep at the start of the first internal step. + (c) potentially by ARKStep at the start of the first + internal step. + In each case, we may check the fn_is_current flag to know whether the values stored in Fe[0] and Fi[0] are up-to-date, allowing us to copy those values instead of @@ -1257,8 +1259,9 @@ int arkStep_Init(ARKodeMem ark_mem, SUNDIALS_MAYBE_UNUSED sunrealtype tout, (c) when an implicit predictor is requested from the Hermite interpolation module within the time step t_{n} \to t_{n+1}, in which case f_{n} needs to be filled, or - (d) by ARKStep when starting a time step t_{n} \to t_{n+1} - and when using an FSAL method. + (d) potentially by ARKStep when starting a time step t_{n} + \to t_{n+1}. + Again, we may check the fn_is_current flag to know whether ARKODE believes that the values stored in Fe[0] and Fi[0] are up-to-date, and may just be copied. If those values @@ -1278,6 +1281,7 @@ int arkStep_Init(ARKodeMem ark_mem, SUNDIALS_MAYBE_UNUSED sunrealtype tout, (d) when a high-order implicit predictor is requested from the Hermite interpolation module within the time step t_{n} \to t_{n+1}. + While instances (a)-(c) will occur in-between ARKStep time steps, instance (d) can occur at the start of each internal ARKStep stage. Since the (t,y) input does not correspond diff --git a/src/arkode/arkode_erkstep.c b/src/arkode/arkode_erkstep.c index da2cc18f03..a62b732afc 100644 --- a/src/arkode/arkode_erkstep.c +++ b/src/arkode/arkode_erkstep.c @@ -542,6 +542,7 @@ int erkStep_Init(ARKodeMem ark_mem, SUNDIALS_MAYBE_UNUSED sunrealtype tout, \to t_{n} to fill f_{n-1} within the Hermite interpolation module, or (c) by ERKStep at the start of the first internal step. + In each case, we may check the fn_is_current flag to know whether the values stored in F[0] are up-to-date, allowing us to copy those values instead of recomputing. @@ -557,6 +558,7 @@ int erkStep_Init(ARKodeMem ark_mem, SUNDIALS_MAYBE_UNUSED sunrealtype tout, \to t_{n} to fill f_{n}, or (c) by ERKStep when starting a time step t_{n} \to t_{n+1} and when using an FSAL method. + Again, we may check the fn_is_current flag to know whether ARKODE believes that the values stored in F[0] are up-to-date, and may just be copied. If the values stored @@ -572,6 +574,7 @@ int erkStep_Init(ARKodeMem ark_mem, SUNDIALS_MAYBE_UNUSED sunrealtype tout, interpolation module, or (c) by an "outer" stepper when ERKStep is used as an inner solver). + All of these instances will occur in-between ERKStep time steps, but the (t,y) input does not correspond to an "official" time step, thus the RHS should always be diff --git a/src/arkode/arkode_impl.h b/src/arkode/arkode_impl.h index a4049afcf1..e0a6c088bf 100644 --- a/src/arkode/arkode_impl.h +++ b/src/arkode/arkode_impl.h @@ -1034,6 +1034,7 @@ int arkGetLastKFlag(void* arkode_mem, int* last_kflag); steps t_{n-1} \to t_{n} to fill f_{n-1} within the Hermite interpolation module. + In each case, the stepper may check the fn_is_current flag to know whether ARKODE believes that the RHS may have @@ -1063,6 +1064,7 @@ int arkGetLastKFlag(void* arkode_mem, int* last_kflag); time step t_{n} \to t_{n+1}, in which case f_{n} needs to be filled. + Again, the stepper may check the fn_is_current flag to know whether ARKODE believes that the RHS may have @@ -1087,6 +1089,7 @@ int arkGetLastKFlag(void* arkode_mem, int* last_kflag); is requested from the Hermite interpolation module within the time step t_{n} \to t_{n+1}. + While instances (a)-(c) will occur in-between calls to the stepper's ARKTimestepStepFn, instance (d) would From 43ca35db88c4a740f86548f31c47fcb375a6f32f Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Tue, 19 Nov 2024 15:37:10 -0600 Subject: [PATCH 251/286] Added utility routine to conditionally update Fse[0] and Fsi[0] (independently of the FullRHS function) to simplify the various takestep routines --- src/arkode/arkode_mristep.c | 400 +++++++++++++++++-------------- src/arkode/arkode_mristep_impl.h | 1 + 2 files changed, 219 insertions(+), 182 deletions(-) diff --git a/src/arkode/arkode_mristep.c b/src/arkode/arkode_mristep.c index 9938bceb2e..26b2b05e50 100644 --- a/src/arkode/arkode_mristep.c +++ b/src/arkode/arkode_mristep.c @@ -1329,67 +1329,31 @@ int mriStep_Init(ARKodeMem ark_mem, sunrealtype tout, int init_type) This is just a wrapper to call the user-supplied RHS functions, f(t,y) = fse(t,y) + fsi(t,y) + ff(t,y). - ARK_FULLRHS_START -> called in the following circumstances: - (a) at the beginning of a simulation i.e., at - (tn, yn) = (t0, y0) or (tR, yR), or - (b) when transitioning between time steps t_{n-1} - \to t_{n} to fill f_{n-1} within the Hermite - interpolation module. - In each case, we may check the fn_is_current flag to - know whether ARKODE believes the values stored in - Fse[0] and Fsi[0] are up-to-date, allowing us to copy - those values instead of recomputing. MRIStep - additionally stores internal fse_is_current and - fsi_is_current flags to denote whether it - additionally believes recomputation is necessary -- - this is because unlike ARKStep and ERKStep, when - MRIStep is used as an inner stepper for an outer - MRIStep calculation, it must store any forcing terms - *inside* its own values of one of Fse or Fsi (to - avoid a combinatorial explosion of separate forcing - vectors when used in a telescopic MRI calculation). - For whichever of Fse[0] and Fsi[0] are deemed not - current, the corresponding RHS function is - recomputed and stored in Fe[0] and/or Fi[0] for - reuse later, before copying the values into the - output vector. - - ARK_FULLRHS_END -> called in the following circumstances: - (a) when temporal root-finding is enabled, this will be - called in-between steps t_{n-1} \to t_{n} to fill f_{n}, - (b) when high-order dense output is requested from the - Hermite interpolation module in-between steps t_{n-1} - \to t_{n} to fill f_{n}, or - (c) when an implicit predictor is requested from the Hermite - interpolation module within the time step t_{n} \to - t_{n+1}, in which case f_{n} needs to be filled. - Again, we may check the fn_is_current flags to know whether - ARKODE believes that the values stored in Fse[0] and Fsi[0] - are up-to-date, and may just be copied. We also again - verify the ability to copy by viewing the MRIStep-specific - fse_is_current and fsi_is_current flags. If one or both of - Fse[0] and Fsi[0] are determined to be not current. In all - other cases, the RHS should be recomputed and stored in - Fse[0] and Fsi[0] for reuse later, before copying the - values into the output vector. - - ARK_FULLRHS_OTHER -> called in the following circumstances: - (a) when estimating the initial time step size, - (b) for high-order dense output with the Hermite - interpolation module, - (c) by an "outer" stepper when MRIStep is used as an - inner solver), or - (d) when a high-order implicit predictor is requested from - the Hermite interpolation module within the time step - t_{n} \to t_{n+1}. - While instances (a)-(c) will occur in-between MRIStep time - steps, instance (d) can occur at the start of each internal - MRIStep stage. Since the (t,y) input does not correspond - to an "official" time step, thus the RHS functions should - always be evaluated, and the values should *not* be stored - anywhere that will interfere with other reused MRIStep data - from one stage to the next (but it may use nonlinear solver - scratch space). + Note: this relies on the utility routine mriStep_UpdateF0 to update Fse[0] + and Fsi[0] as appropriate (i.e., leveraging previous evaluations, etc.), and + merely combines the resulting values together with ff to construct the output. + + However, in ARK_FULLRHS_OTHER mode, this routine must call all slow RHS + functions directly, since that mode cannot reuse internally stored values. + + ARK_FULLRHS_OTHER -> called in the following circumstances: + (a) when estimating the initial time step size, + (b) for high-order dense output with the Hermite + interpolation module, + (c) by an "outer" stepper when MRIStep is used as an + inner solver), or + (d) when a high-order implicit predictor is requested from + the Hermite interpolation module within the time step + t_{n} \to t_{n+1}. + + While instances (a)-(c) will occur in-between MRIStep time + steps, instance (d) can occur at the start of each internal + MRIStep stage. Since the (t,y) input does not correspond + to an "official" time step, thus the RHS functions should + always be evaluated, and the values should *not* be stored + anywhere that will interfere with other reused MRIStep data + from one stage to the next (but it may use nonlinear solver + scratch space). Note that this routine always calls the fast RHS function, ff(t,y), in ARK_FULLRHS_OTHER mode. @@ -1412,6 +1376,199 @@ int mriStep_FullRHS(ARKodeMem ark_mem, sunrealtype t, N_Vector y, N_Vector f, return ARK_ILL_INPUT; } + /* perform RHS functions contingent on 'mode' argument */ + switch (mode) + { + case ARK_FULLRHS_START: + case ARK_FULLRHS_END: + + /* update the internal storage for Fse[0] and Fsi[0] */ + retval = mriStep_UpdateF0(ark_mem, t, y, mode); + if (retval != 0) + { + arkProcessError(ark_mem, ARK_RHSFUNC_FAIL, __LINE__, __func__, + __FILE__, MSG_ARK_RHSFUNC_FAILED, t); + return (ARK_RHSFUNC_FAIL); + } + + /* evaluate fast component */ + retval = mriStepInnerStepper_FullRhs(step_mem->stepper, t, y, f, + ARK_FULLRHS_OTHER); + if (retval != ARK_SUCCESS) + { + arkProcessError(ark_mem, ARK_RHSFUNC_FAIL, __LINE__, __func__, __FILE__, + MSG_ARK_RHSFUNC_FAILED, t); + return (ARK_RHSFUNC_FAIL); + } + + /* combine RHS vectors into output */ + if (step_mem->explicit_rhs && step_mem->implicit_rhs) + { + /* ImEx */ + step_mem->cvals[0] = ONE; + step_mem->Xvecs[0] = f; + step_mem->cvals[1] = ONE; + step_mem->Xvecs[1] = step_mem->Fse[0]; + step_mem->cvals[2] = ONE; + step_mem->Xvecs[2] = step_mem->Fsi[0]; + nvec = 3; + N_VLinearCombination(nvec, step_mem->cvals, step_mem->Xvecs, f); + } + else if (step_mem->implicit_rhs) + { + /* implicit */ + N_VLinearSum(ONE, step_mem->Fsi[0], ONE, f, f); + } + else + { + /* explicit */ + N_VLinearSum(ONE, step_mem->Fse[0], ONE, f, f); + } + + break; + + case ARK_FULLRHS_OTHER: + + /* compute the fast component (force new RHS computation) */ + nvec = 0; + retval = mriStepInnerStepper_FullRhs(step_mem->stepper, t, y, f, + ARK_FULLRHS_OTHER); + if (retval != ARK_SUCCESS) + { + arkProcessError(ark_mem, ARK_RHSFUNC_FAIL, __LINE__, __func__, __FILE__, + MSG_ARK_RHSFUNC_FAILED, t); + return (ARK_RHSFUNC_FAIL); + } + step_mem->cvals[nvec] = ONE; + step_mem->Xvecs[nvec] = f; + nvec++; + + /* compute the explicit component and store in ark_tempv2 */ + if (step_mem->explicit_rhs) + { + retval = step_mem->fse(t, y, ark_mem->tempv2, ark_mem->user_data); + step_mem->nfse++; + if (retval != 0) + { + arkProcessError(ark_mem, ARK_RHSFUNC_FAIL, __LINE__, __func__, __FILE__, + MSG_ARK_RHSFUNC_FAILED, t); + return (ARK_RHSFUNC_FAIL); + } + step_mem->cvals[nvec] = ONE; + step_mem->Xvecs[nvec] = ark_mem->tempv2; + nvec++; + } + + /* compute the implicit component and store in sdata */ + if (step_mem->implicit_rhs) + { + retval = step_mem->fsi(t, y, step_mem->sdata, ark_mem->user_data); + step_mem->nfsi++; + if (retval != 0) + { + arkProcessError(ark_mem, ARK_RHSFUNC_FAIL, __LINE__, __func__, __FILE__, + MSG_ARK_RHSFUNC_FAILED, t); + return (ARK_RHSFUNC_FAIL); + } + step_mem->cvals[nvec] = ONE; + step_mem->Xvecs[nvec] = step_mem->sdata; + nvec++; + } + + /* Add external forcing components to linear combination */ + if (step_mem->expforcing || step_mem->impforcing) + { + mriStep_ApplyForcing(step_mem, t, ONE, &nvec); + } + + /* combine RHS vectors into output */ + N_VLinearCombination(nvec, step_mem->cvals, step_mem->Xvecs, f); + + break; + + default: + /* return with RHS failure if unknown mode is passed */ + arkProcessError(ark_mem, ARK_RHSFUNC_FAIL, __LINE__, __func__, __FILE__, + "Unknown full RHS mode"); + return (ARK_RHSFUNC_FAIL); + } + + return (ARK_SUCCESS); +} + +/*------------------------------------------------------------------------------ + mriStep_UpdateF0: + + This routine is called by mriStep_FullRHS to update the internal storage for + Fse[0] and Fsi[0], incorporating forcing from a slower time scale as necessary. + This supports the ARK_FULLRHS_START and ARK_FULLRHS_END "mode" values + provided to mriStep_FullRHS, and contains all internal logic regarding whether + RHS functions must be called, versus if the relevant data can just be copied. + + ARK_FULLRHS_START -> called in the following circumstances: + (a) at the beginning of a simulation i.e., at + (tn, yn) = (t0, y0) or (tR, yR), or + (b) when transitioning between time steps t_{n-1} + \to t_{n} to fill f_{n-1} within the Hermite + interpolation module. + + In each case, we may check the fn_is_current flag to + know whether ARKODE believes the values stored in + Fse[0] and Fsi[0] are up-to-date, allowing us to copy + those values instead of recomputing. MRIStep + additionally stores internal fse_is_current and + fsi_is_current flags to denote whether it + additionally believes recomputation is necessary -- + this is because unlike ARKStep and ERKStep, when + MRIStep is used as an inner stepper for an outer + MRIStep calculation, it must store any forcing terms + *inside* its own values of one of Fse or Fsi (to + avoid a combinatorial explosion of separate forcing + vectors when used in a telescopic MRI calculation). + For whichever of Fse[0] and Fsi[0] are deemed not + current, the corresponding RHS function is + recomputed and stored in Fe[0] and/or Fi[0] for + reuse later, before copying the values into the + output vector. + + ARK_FULLRHS_END -> called in the following circumstances: + (a) when temporal root-finding is enabled, this will be + called in-between steps t_{n-1} \to t_{n} to fill f_{n}, + (b) when high-order dense output is requested from the + Hermite interpolation module in-between steps t_{n-1} + \to t_{n} to fill f_{n}, or + (c) when an implicit predictor is requested from the Hermite + interpolation module within the time step t_{n} \to + t_{n+1}, in which case f_{n} needs to be filled. + + Again, we may check the fn_is_current flags to know whether + ARKODE believes that the values stored in Fse[0] and Fsi[0] + are up-to-date, and may just be copied. We also again + verify the ability to copy by viewing the MRIStep-specific + fse_is_current and fsi_is_current flags. If one or both of + Fse[0] and Fsi[0] are determined to be not current. In all + other cases, the RHS should be recomputed and stored in + Fse[0] and Fsi[0] for reuse later, before copying the + values into the output vector. + + ----------------------------------------------------------------------------*/ +int mriStep_UpdateF0(ARKodeMem ark_mem, sunrealtype t, N_Vector y, int mode) +{ + ARKodeMRIStepMem step_mem; + int i, sa_stage, nvec, retval; + + /* access ARKodeMRIStepMem structure */ + retval = mriStep_AccessStepMem(ark_mem, __func__, &step_mem); + if (retval != ARK_SUCCESS) { return (retval); } + + /* ensure that inner stepper provides fullrhs function */ + if (!(step_mem->stepper->ops->fullrhs)) + { + arkProcessError(ark_mem, ARK_ILL_INPUT, __LINE__, __func__, __FILE__, + MSG_ARK_MISSING_FULLRHS); + return ARK_ILL_INPUT; + } + /* perform RHS functions contingent on 'mode' argument */ switch (mode) { @@ -1477,40 +1634,6 @@ int mriStep_FullRHS(ARKodeMem ark_mem, sunrealtype t, N_Vector y, N_Vector f, } } - /* fast component */ - retval = mriStepInnerStepper_FullRhs(step_mem->stepper, t, y, f, - ARK_FULLRHS_OTHER); - if (retval != ARK_SUCCESS) - { - arkProcessError(ark_mem, ARK_RHSFUNC_FAIL, __LINE__, __func__, __FILE__, - MSG_ARK_RHSFUNC_FAILED, t); - return (ARK_RHSFUNC_FAIL); - } - - /* combine RHS vectors into output */ - if (step_mem->explicit_rhs && step_mem->implicit_rhs) - { - /* ImEx */ - step_mem->cvals[0] = ONE; - step_mem->Xvecs[0] = f; - step_mem->cvals[1] = ONE; - step_mem->Xvecs[1] = step_mem->Fse[0]; - step_mem->cvals[2] = ONE; - step_mem->Xvecs[2] = step_mem->Fsi[0]; - nvec = 3; - N_VLinearCombination(nvec, step_mem->cvals, step_mem->Xvecs, f); - } - else if (step_mem->implicit_rhs) - { - /* implicit */ - N_VLinearSum(ONE, step_mem->Fsi[0], ONE, f, f); - } - else - { - /* explicit */ - N_VLinearSum(ONE, step_mem->Fse[0], ONE, f, f); - } - break; case ARK_FULLRHS_END: @@ -1592,93 +1715,6 @@ int mriStep_FullRHS(ARKodeMem ark_mem, sunrealtype t, N_Vector y, N_Vector f, } } - /* compute the fast component (force new RHS computation) */ - retval = mriStepInnerStepper_FullRhs(step_mem->stepper, t, y, f, - ARK_FULLRHS_OTHER); - if (retval != ARK_SUCCESS) - { - arkProcessError(ark_mem, ARK_RHSFUNC_FAIL, __LINE__, __func__, __FILE__, - MSG_ARK_RHSFUNC_FAILED, t); - return (ARK_RHSFUNC_FAIL); - } - - /* combine RHS vectors into output */ - if (step_mem->explicit_rhs && step_mem->implicit_rhs) - { - /* ImEx */ - N_VLinearSum(ONE, step_mem->Fse[0], ONE, f, f); - N_VLinearSum(ONE, step_mem->Fsi[0], ONE, f, f); - } - else if (step_mem->implicit_rhs) - { - /* implicit */ - N_VLinearSum(ONE, step_mem->Fsi[0], ONE, f, f); - } - else - { - /* explicit */ - N_VLinearSum(ONE, step_mem->Fse[0], ONE, f, f); - } - - break; - - case ARK_FULLRHS_OTHER: - - /* compute the fast component (force new RHS computation) */ - nvec = 0; - retval = mriStepInnerStepper_FullRhs(step_mem->stepper, t, y, f, - ARK_FULLRHS_OTHER); - if (retval != ARK_SUCCESS) - { - arkProcessError(ark_mem, ARK_RHSFUNC_FAIL, __LINE__, __func__, __FILE__, - MSG_ARK_RHSFUNC_FAILED, t); - return (ARK_RHSFUNC_FAIL); - } - step_mem->cvals[nvec] = ONE; - step_mem->Xvecs[nvec] = f; - nvec++; - - /* compute the explicit component and store in ark_tempv2 */ - if (step_mem->explicit_rhs) - { - retval = step_mem->fse(t, y, ark_mem->tempv2, ark_mem->user_data); - step_mem->nfse++; - if (retval != 0) - { - arkProcessError(ark_mem, ARK_RHSFUNC_FAIL, __LINE__, __func__, __FILE__, - MSG_ARK_RHSFUNC_FAILED, t); - return (ARK_RHSFUNC_FAIL); - } - step_mem->cvals[nvec] = ONE; - step_mem->Xvecs[nvec] = ark_mem->tempv2; - nvec++; - } - - /* compute the implicit component and store in sdata */ - if (step_mem->implicit_rhs) - { - retval = step_mem->fsi(t, y, step_mem->sdata, ark_mem->user_data); - step_mem->nfsi++; - if (retval != 0) - { - arkProcessError(ark_mem, ARK_RHSFUNC_FAIL, __LINE__, __func__, __FILE__, - MSG_ARK_RHSFUNC_FAILED, t); - return (ARK_RHSFUNC_FAIL); - } - step_mem->cvals[nvec] = ONE; - step_mem->Xvecs[nvec] = step_mem->sdata; - nvec++; - } - - /* Add external forcing components to linear combination */ - if (step_mem->expforcing || step_mem->impforcing) - { - mriStep_ApplyForcing(step_mem, t, ONE, &nvec); - } - - /* combine RHS vectors into output */ - N_VLinearCombination(nvec, step_mem->cvals, step_mem->Xvecs, f); - break; default: diff --git a/src/arkode/arkode_mristep_impl.h b/src/arkode/arkode_mristep_impl.h index 0db8ec9768..d1951c0fd3 100644 --- a/src/arkode/arkode_mristep_impl.h +++ b/src/arkode/arkode_mristep_impl.h @@ -223,6 +223,7 @@ int mriStep_GetGammas(ARKodeMem ark_mem, sunrealtype* gamma, sunrealtype* gamrat sunbooleantype** jcur, sunbooleantype* dgamma_fail); int mriStep_FullRHS(ARKodeMem ark_mem, sunrealtype t, N_Vector y, N_Vector f, int mode); +int mriStep_UpdateF0(ARKodeMem ark_mem, sunrealtype t, N_Vector y, int mode); int mriStep_TakeStepMRIGARK(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr); int mriStep_TakeStepMRISR(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr); From a524699fdec45c77dbfcc109d48f1786f49af1a1 Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Wed, 20 Nov 2024 10:11:53 -0600 Subject: [PATCH 252/286] Minor updates to new mriStep_UpdateF0 routine --- src/arkode/arkode_mristep.c | 156 +++++-------------------------- src/arkode/arkode_mristep_impl.h | 3 +- 2 files changed, 23 insertions(+), 136 deletions(-) diff --git a/src/arkode/arkode_mristep.c b/src/arkode/arkode_mristep.c index 26b2b05e50..5d432efa1d 100644 --- a/src/arkode/arkode_mristep.c +++ b/src/arkode/arkode_mristep.c @@ -1362,7 +1362,7 @@ int mriStep_FullRHS(ARKodeMem ark_mem, sunrealtype t, N_Vector y, N_Vector f, int mode) { ARKodeMRIStepMem step_mem; - int i, sa_stage, nvec, retval; + int nvec, retval; /* access ARKodeMRIStepMem structure */ retval = mriStep_AccessStepMem(ark_mem, __func__, &step_mem); @@ -1383,7 +1383,7 @@ int mriStep_FullRHS(ARKodeMem ark_mem, sunrealtype t, N_Vector y, N_Vector f, case ARK_FULLRHS_END: /* update the internal storage for Fse[0] and Fsi[0] */ - retval = mriStep_UpdateF0(ark_mem, t, y, mode); + retval = mriStep_UpdateF0(ark_mem, step_mem, t, y, mode); if (retval != 0) { arkProcessError(ark_mem, ARK_RHSFUNC_FAIL, __LINE__, __func__, @@ -1552,22 +1552,10 @@ int mriStep_FullRHS(ARKodeMem ark_mem, sunrealtype t, N_Vector y, N_Vector f, values into the output vector. ----------------------------------------------------------------------------*/ -int mriStep_UpdateF0(ARKodeMem ark_mem, sunrealtype t, N_Vector y, int mode) +int mriStep_UpdateF0(ARKodeMem ark_mem, ARKodeMRIStepMem step_mem, + sunrealtype t, N_Vector y, int mode) { - ARKodeMRIStepMem step_mem; - int i, sa_stage, nvec, retval; - - /* access ARKodeMRIStepMem structure */ - retval = mriStep_AccessStepMem(ark_mem, __func__, &step_mem); - if (retval != ARK_SUCCESS) { return (retval); } - - /* ensure that inner stepper provides fullrhs function */ - if (!(step_mem->stepper->ops->fullrhs)) - { - arkProcessError(ark_mem, ARK_ILL_INPUT, __LINE__, __func__, __FILE__, - MSG_ARK_MISSING_FULLRHS); - return ARK_ILL_INPUT; - } + int sa_stage, nvec, retval; /* perform RHS functions contingent on 'mode' argument */ switch (mode) @@ -1845,53 +1833,8 @@ int mriStep_TakeStepMRIGARK(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPt /* Evaluate the slow RHS functions if needed. NOTE: We do not use the full RHS function here since it does not need to check for FSAL or SA methods and thus avoids potentially unnecessary evaluations of the inner (fast) RHS function */ - /* compute the explicit component */ - if (step_mem->explicit_rhs) - { - if (!ark_mem->fn_is_current || !step_mem->fse_is_current) - { - retval = step_mem->fse(ark_mem->tn, ark_mem->yn, step_mem->Fse[0], - ark_mem->user_data); - step_mem->nfse++; - step_mem->fse_is_current = SUNTRUE; - if (retval) { return ARK_RHSFUNC_FAIL; } - - /* Add external forcing, if appropriate */ - if (step_mem->expforcing) - { - step_mem->cvals[0] = ONE; - step_mem->Xvecs[0] = step_mem->Fse[0]; - nvec = 1; - mriStep_ApplyForcing(step_mem, ark_mem->tn, ONE, &nvec); - N_VLinearCombination(nvec, step_mem->cvals, step_mem->Xvecs, - step_mem->Fse[0]); - } - } - } - - /* compute the implicit component */ - if (step_mem->implicit_rhs) - { - if (!ark_mem->fn_is_current || !step_mem->fsi_is_current) - { - retval = step_mem->fsi(ark_mem->tn, ark_mem->yn, step_mem->Fsi[0], - ark_mem->user_data); - step_mem->nfsi++; - step_mem->fsi_is_current = SUNTRUE; - if (retval) { return ARK_RHSFUNC_FAIL; } - - /* Add external forcing, if appropriate */ - if (step_mem->impforcing) - { - step_mem->cvals[0] = ONE; - step_mem->Xvecs[0] = step_mem->Fsi[0]; - nvec = 1; - mriStep_ApplyForcing(step_mem, ark_mem->tn, ONE, &nvec); - N_VLinearCombination(nvec, step_mem->cvals, step_mem->Xvecs, - step_mem->Fsi[0]); - } - } - } + retval = mriStep_UpdateF0(ark_mem, step_mem, ark_mem->tn, ark_mem->yn, ARK_FULLRHS_START); + if (retval) { return ARK_RHSFUNC_FAIL; } ark_mem->fn_is_current = SUNTRUE; #ifdef SUNDIALS_DEBUG @@ -2359,59 +2302,16 @@ int mriStep_TakeStepMRISR(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr) function here (unlike ERKStep and ARKStep) since it does not need to check for FSAL or SA methods and thus avoids potentially unnecessary evaluations of the inner (fast) RHS function */ + retval = mriStep_UpdateF0(ark_mem, step_mem, ark_mem->tn, ark_mem->yn, ARK_FULLRHS_START); + if (retval) { return ARK_RHSFUNC_FAIL; } + ark_mem->fn_is_current = SUNTRUE; - if (!(ark_mem->fn_is_current)) + /* combine both RHS into FSE for ImEx problems and zero out Fsi[0], since + MRISR fast forcing function only depends on Omega coefficients */ + if (step_mem->implicit_rhs && step_mem->explicit_rhs) { - /* compute the explicit component */ - if (step_mem->explicit_rhs) - { - retval = step_mem->fse(ark_mem->tn, ark_mem->yn, step_mem->Fse[0], - ark_mem->user_data); - step_mem->nfse++; - step_mem->fse_is_current = SUNTRUE; - if (retval) { return ARK_RHSFUNC_FAIL; } - - /* Add external forcing, if applicable */ - if (step_mem->expforcing) - { - step_mem->cvals[0] = ONE; - step_mem->Xvecs[0] = step_mem->Fse[0]; - nvec = 1; - mriStep_ApplyForcing(step_mem, ark_mem->tn, ONE, &nvec); - N_VLinearCombination(nvec, step_mem->cvals, step_mem->Xvecs, - step_mem->Fse[0]); - } - } - - /* compute the implicit component */ - if (step_mem->implicit_rhs) - { - retval = step_mem->fsi(ark_mem->tn, ark_mem->yn, step_mem->Fsi[0], - ark_mem->user_data); - step_mem->nfsi++; - step_mem->fsi_is_current = SUNTRUE; - if (retval) { return ARK_RHSFUNC_FAIL; } - - /* Add external forcing, if applicable */ - if (step_mem->impforcing) - { - step_mem->cvals[0] = ONE; - step_mem->Xvecs[0] = step_mem->Fsi[0]; - nvec = 1; - mriStep_ApplyForcing(step_mem, ark_mem->tn, ONE, &nvec); - N_VLinearCombination(nvec, step_mem->cvals, step_mem->Xvecs, - step_mem->Fsi[0]); - } - } - - /* combine both RHS into Fse for ImEx problems */ - if (step_mem->implicit_rhs && step_mem->explicit_rhs) - { - N_VLinearSum(ONE, step_mem->Fse[0], ONE, step_mem->Fsi[0], - step_mem->Fse[0]); - } - - ark_mem->fn_is_current = SUNTRUE; + N_VLinearSum(ONE, step_mem->Fse[0], ONE, step_mem->Fsi[0], step_mem->Fse[0]); + /* N_VConst(ZERO, step_mem->Fsi[0]);*/ } #ifdef SUNDIALS_DEBUG @@ -2678,11 +2578,13 @@ int mriStep_TakeStepMRISR(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr) #endif } - /* combine both RHS into Fse for ImEx problems */ + /* combine both RHS into Fse for ImEx problems, and zero Fsi[0] since + fast forcing function only depends on Omega coefficients */ if (step_mem->implicit_rhs && step_mem->explicit_rhs) { N_VLinearSum(ONE, step_mem->Fse[stage], ONE, step_mem->Fsi[stage], step_mem->Fse[stage]); + /*N_VConst(ZERO, step_mem->Fsi[stage]);*/ } } @@ -2830,25 +2732,9 @@ int mriStep_TakeStepMERK(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr) (unlike ERKStep and ARKStep) since it does not need to check for FSAL or SA methods and thus avoids potentially unnecessary evaluations of the inner (fast) RHS function */ - if (!ark_mem->fn_is_current) - { - retval = step_mem->fse(t0, ark_mem->yn, step_mem->Fse[0], ark_mem->user_data); - step_mem->nfse++; - if (retval) { return ARK_RHSFUNC_FAIL; } - step_mem->fse_is_current = SUNTRUE; - ark_mem->fn_is_current = SUNTRUE; - - /* Add external forcing to Fse[0], if applicable */ - if (step_mem->expforcing) - { - step_mem->cvals[0] = ONE; - step_mem->Xvecs[0] = step_mem->Fse[0]; - nvec = 1; - mriStep_ApplyForcing(step_mem, t0, ONE, &nvec); - N_VLinearCombination(nvec, step_mem->cvals, step_mem->Xvecs, - step_mem->Fse[0]); - } - } + retval = mriStep_UpdateF0(ark_mem, step_mem, t0, ark_mem->yn, ARK_FULLRHS_START); + if (retval) { return ARK_RHSFUNC_FAIL; } + ark_mem->fn_is_current = SUNTRUE; #ifdef SUNDIALS_DEBUG printf(" MRIStep step %li, stage 0, h = %" RSYM ", t_n = %" RSYM "\n", diff --git a/src/arkode/arkode_mristep_impl.h b/src/arkode/arkode_mristep_impl.h index d1951c0fd3..91e28f16f6 100644 --- a/src/arkode/arkode_mristep_impl.h +++ b/src/arkode/arkode_mristep_impl.h @@ -223,7 +223,8 @@ int mriStep_GetGammas(ARKodeMem ark_mem, sunrealtype* gamma, sunrealtype* gamrat sunbooleantype** jcur, sunbooleantype* dgamma_fail); int mriStep_FullRHS(ARKodeMem ark_mem, sunrealtype t, N_Vector y, N_Vector f, int mode); -int mriStep_UpdateF0(ARKodeMem ark_mem, sunrealtype t, N_Vector y, int mode); +int mriStep_UpdateF0(ARKodeMem ark_mem, ARKodeMRIStepMem step_mem, + sunrealtype t, N_Vector y, int mode); int mriStep_TakeStepMRIGARK(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr); int mriStep_TakeStepMRISR(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr); From fd494311b25df1aebabbcadea31d6a5306ce3a2e Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Wed, 20 Nov 2024 11:25:37 -0600 Subject: [PATCH 253/286] Fixed ark_test_innerstepper.c -- since it does not provide a FullRHS function, it cannot specify the ARK_INTERP_HERMITE module. --- test/unit_tests/arkode/C_serial/ark_test_innerstepper.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/unit_tests/arkode/C_serial/ark_test_innerstepper.c b/test/unit_tests/arkode/C_serial/ark_test_innerstepper.c index 7e16e77946..99b83e3118 100644 --- a/test/unit_tests/arkode/C_serial/ark_test_innerstepper.c +++ b/test/unit_tests/arkode/C_serial/ark_test_innerstepper.c @@ -99,7 +99,7 @@ int main(int argc, char* argv[]) flag = ARKodeSetFixedStep(arkode_mem, SUN_RCONST(0.01)); if (flag) { return 1; } - flag = ARKodeSetInterpolantType(arkode_mem, ARK_INTERP_HERMITE); + flag = ARKodeSetInterpolantType(arkode_mem, ARK_INTERP_LAGRANGE); if (flag) { return 1; } /* --------------- @@ -120,7 +120,7 @@ int main(int argc, char* argv[]) flag = MRIStepReInit(arkode_mem, ode_slow_rhs, NULL, ZERO, y); if (flag) { return 1; } - flag = ARKodeSetInterpolantType(arkode_mem, ARK_INTERP_LAGRANGE); + flag = ARKodeSetInterpolantType(arkode_mem, ARK_INTERP_NONE); if (flag) { return 1; } /* --------------- From 14485ff1f36bd2636864273d498a6f5649981947 Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Wed, 20 Nov 2024 11:26:15 -0600 Subject: [PATCH 254/286] Guarded printing ark_mem->fn based on whether that vector is allocated --- src/arkode/arkode.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/arkode/arkode.c b/src/arkode/arkode.c index 12912fbde8..b67f1987ac 100644 --- a/src/arkode/arkode.c +++ b/src/arkode/arkode.c @@ -1329,7 +1329,7 @@ void ARKodePrintMem(void* arkode_mem, FILE* outfile) fprintf(outfile, "yn:\n"); N_VPrintFile(ark_mem->yn, outfile); fprintf(outfile, "fn:\n"); - N_VPrintFile(ark_mem->fn, outfile); + if (ark_mem->fn) { N_VPrintFile(ark_mem->fn, outfile); } fprintf(outfile, "tempv1:\n"); N_VPrintFile(ark_mem->tempv1, outfile); fprintf(outfile, "tempv2:\n"); From 3de7384fc7056c066deb3a00d70fe902865b7a4d Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Wed, 20 Nov 2024 11:26:32 -0600 Subject: [PATCH 255/286] Comment update --- src/arkode/arkode_io.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/arkode/arkode_io.c b/src/arkode/arkode_io.c index 4c63222bec..42e613b707 100644 --- a/src/arkode/arkode_io.c +++ b/src/arkode/arkode_io.c @@ -148,6 +148,7 @@ int ARKodeSetOrder(void* arkode_mem, int ord) interpolation module. itype == ARK_INTERP_LAGRANGE specifies the Lagrange (stiff) interpolation module. + itype == ARK_INTERP_NONE disables interpolation. Return values: ARK_SUCCESS on success. From bcf4b8d2203678eac5b5b20ba30cd4e8a79cea61 Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Wed, 20 Nov 2024 11:38:11 -0600 Subject: [PATCH 256/286] Added code to update ark_mem->fn (if allocated) from various take-step routines --- src/arkode/arkode_mristep.c | 85 ++++++++++++++++++++++++++++--------- 1 file changed, 65 insertions(+), 20 deletions(-) diff --git a/src/arkode/arkode_mristep.c b/src/arkode/arkode_mristep.c index 5d432efa1d..79205bbefe 100644 --- a/src/arkode/arkode_mristep.c +++ b/src/arkode/arkode_mristep.c @@ -218,9 +218,31 @@ void* MRIStepCreate(ARKRhsFn fse, ARKRhsFn fsi, sunrealtype t0, N_Vector y0, step_mem->nls_fails = 0; step_mem->inner_fails = 0; - /* Initialize fused op work space */ + /* Initialize fused op work space with sufficient storage for + at least filling the full RHS on an ImEx problem */ + step_mem->nfusedopvecs = 3; step_mem->cvals = NULL; + step_mem->cvals = (sunrealtype*)calloc(step_mem->nfusedopvecs, + sizeof(sunrealtype)); + if (step_mem->cvals == NULL) + { + arkProcessError(ark_mem, ARK_MEM_FAIL, __LINE__, __func__, __FILE__, + "Error allocating MRIStep storage"); + ARKodeFree((void**)&ark_mem); + return (NULL); + } + ark_mem->lrw += step_mem->nfusedopvecs; step_mem->Xvecs = NULL; + step_mem->Xvecs = (N_Vector*)calloc(step_mem->nfusedopvecs, + sizeof(N_Vector)); + if (step_mem->Xvecs == NULL) + { + arkProcessError(ark_mem, ARK_MEM_FAIL, __LINE__, __func__, __FILE__, + "Error allocating MRIStep storage"); + ARKodeFree((void**)&ark_mem); + return (NULL); + } + ark_mem->liw += step_mem->nfusedopvecs; /* Initialize adaptivity parameters */ step_mem->inner_rtol_factor = ONE; @@ -1371,9 +1393,9 @@ int mriStep_FullRHS(ARKodeMem ark_mem, sunrealtype t, N_Vector y, N_Vector f, /* ensure that inner stepper provides fullrhs function */ if (!(step_mem->stepper->ops->fullrhs)) { - arkProcessError(ark_mem, ARK_ILL_INPUT, __LINE__, __func__, __FILE__, + arkProcessError(ark_mem, ARK_RHSFUNC_FAIL, __LINE__, __func__, __FILE__, MSG_ARK_MISSING_FULLRHS); - return ARK_ILL_INPUT; + return ARK_RHSFUNC_FAIL; } /* perform RHS functions contingent on 'mode' argument */ @@ -1830,11 +1852,19 @@ int mriStep_TakeStepMRIGARK(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPt } } - /* Evaluate the slow RHS functions if needed. NOTE: We do not use the full RHS - function here since it does not need to check for FSAL or SA methods and - thus avoids potentially unnecessary evaluations of the inner (fast) RHS function */ - retval = mriStep_UpdateF0(ark_mem, step_mem, ark_mem->tn, ark_mem->yn, ARK_FULLRHS_START); - if (retval) { return ARK_RHSFUNC_FAIL; } + /* Evaluate the slow RHS functions if needed. NOTE: we decide between calling the full RHS + function (if ark_mem->fn is non-NULL) versus just updating the stored values of + Fse[0] and Fsi[0]. */ + if (ark_mem->fn != NULL) + { + retval = mriStep_FullRHS(ark_mem, ark_mem->tn, ark_mem->yn, ark_mem->fn, ARK_FULLRHS_START); + if (retval) { return ARK_RHSFUNC_FAIL; } + } + else + { + retval = mriStep_UpdateF0(ark_mem, step_mem, ark_mem->tn, ark_mem->yn, ARK_FULLRHS_START); + if (retval) { return ARK_RHSFUNC_FAIL; } + } ark_mem->fn_is_current = SUNTRUE; #ifdef SUNDIALS_DEBUG @@ -2298,12 +2328,19 @@ int mriStep_TakeStepMRISR(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr) } } - /* Evaluate the slow RHS functions if needed. NOTE: We do not use the full RHS - function here (unlike ERKStep and ARKStep) since it does not need to check - for FSAL or SA methods and thus avoids potentially unnecessary evaluations - of the inner (fast) RHS function */ - retval = mriStep_UpdateF0(ark_mem, step_mem, ark_mem->tn, ark_mem->yn, ARK_FULLRHS_START); - if (retval) { return ARK_RHSFUNC_FAIL; } + /* Evaluate the slow RHS functions if needed. NOTE: we decide between calling the full RHS + function (if ark_mem->fn is non-NULL) versus just updating the stored values of + Fse[0] and Fsi[0]. */ + if (ark_mem->fn != NULL) + { + retval = mriStep_FullRHS(ark_mem, ark_mem->tn, ark_mem->yn, ark_mem->fn, ARK_FULLRHS_START); + if (retval) { return ARK_RHSFUNC_FAIL; } + } + else + { + retval = mriStep_UpdateF0(ark_mem, step_mem, ark_mem->tn, ark_mem->yn, ARK_FULLRHS_START); + if (retval) { return ARK_RHSFUNC_FAIL; } + } ark_mem->fn_is_current = SUNTRUE; /* combine both RHS into FSE for ImEx problems and zero out Fsi[0], since @@ -2728,13 +2765,21 @@ int mriStep_TakeStepMERK(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr) } } - /* Evaluate the slow RHS if needed. NOTE: We do not use the full RHS here - (unlike ERKStep and ARKStep) since it does not need to check for FSAL - or SA methods and thus avoids potentially unnecessary evaluations of the - inner (fast) RHS function */ - retval = mriStep_UpdateF0(ark_mem, step_mem, t0, ark_mem->yn, ARK_FULLRHS_START); +/* Evaluate the slow RHS function if needed. NOTE: we decide between calling the full RHS + function (if ark_mem->fn is non-NULL) versus just updating the stored value of + Fse[0]. In either case, we use ARK_FULLRHS_START mode because MERK methods do not + evaluate Fse at the end of the time step (so nothing can be leveraged). */ +if (ark_mem->fn != NULL) +{ + retval = mriStep_FullRHS(ark_mem, ark_mem->tn, ark_mem->yn, ark_mem->fn, ARK_FULLRHS_START); if (retval) { return ARK_RHSFUNC_FAIL; } - ark_mem->fn_is_current = SUNTRUE; +} +else +{ + retval = mriStep_UpdateF0(ark_mem, step_mem, ark_mem->tn, ark_mem->yn, ARK_FULLRHS_START); + if (retval) { return ARK_RHSFUNC_FAIL; } +} +ark_mem->fn_is_current = SUNTRUE; #ifdef SUNDIALS_DEBUG printf(" MRIStep step %li, stage 0, h = %" RSYM ", t_n = %" RSYM "\n", From e293fd1f4335a14174c59654463350aa95f978e5 Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Wed, 20 Nov 2024 11:43:40 -0600 Subject: [PATCH 257/286] Reverted previous commit to ark_test_innerstepper.c --- test/unit_tests/arkode/C_serial/ark_test_innerstepper.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/unit_tests/arkode/C_serial/ark_test_innerstepper.c b/test/unit_tests/arkode/C_serial/ark_test_innerstepper.c index 99b83e3118..7e16e77946 100644 --- a/test/unit_tests/arkode/C_serial/ark_test_innerstepper.c +++ b/test/unit_tests/arkode/C_serial/ark_test_innerstepper.c @@ -99,7 +99,7 @@ int main(int argc, char* argv[]) flag = ARKodeSetFixedStep(arkode_mem, SUN_RCONST(0.01)); if (flag) { return 1; } - flag = ARKodeSetInterpolantType(arkode_mem, ARK_INTERP_LAGRANGE); + flag = ARKodeSetInterpolantType(arkode_mem, ARK_INTERP_HERMITE); if (flag) { return 1; } /* --------------- @@ -120,7 +120,7 @@ int main(int argc, char* argv[]) flag = MRIStepReInit(arkode_mem, ode_slow_rhs, NULL, ZERO, y); if (flag) { return 1; } - flag = ARKodeSetInterpolantType(arkode_mem, ARK_INTERP_NONE); + flag = ARKodeSetInterpolantType(arkode_mem, ARK_INTERP_LAGRANGE); if (flag) { return 1; } /* --------------- From c122289583384aeb8177dab47ff21b262cf89d18 Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Wed, 20 Nov 2024 11:56:41 -0600 Subject: [PATCH 258/286] During initialization, if ark_mem->fn will be unused but is already allocated (e.g., after a ReInit), then free it from memory --- src/arkode/arkode.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/arkode/arkode.c b/src/arkode/arkode.c index b67f1987ac..1a331f7d6f 100644 --- a/src/arkode/arkode.c +++ b/src/arkode/arkode.c @@ -2001,7 +2001,8 @@ int arkInitialSetup(ARKodeMem ark_mem, sunrealtype tout) /* If fullrhs will be called (to estimate initial step, explicit steppers, Hermite interpolation module, and possibly (but not always) arkRootCheck1), then - ensure that it is provided, and space is allocated for fn. */ + ensure that it is provided, and space is allocated for fn. Otherwise, + we should free ark_mem->fn if it is allocated. */ if (ark_mem->call_fullrhs || (ark_mem->h0u == ZERO && ark_mem->hin == ZERO) || ark_mem->root_mem) { @@ -2019,6 +2020,10 @@ int arkInitialSetup(ARKodeMem ark_mem, sunrealtype tout) return (ARK_MEM_FAIL); } } + else + { + if (ark_mem->fn != NULL) { arkFreeVec(ark_mem, &ark_mem->fn); } + } /* initialization complete */ ark_mem->initialized = SUNTRUE; From 439ce0adc37726b2544bdfc090ffa3255f4313aa Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Wed, 20 Nov 2024 13:32:26 -0600 Subject: [PATCH 259/286] Comment updates --- src/arkode/arkode_mristep.c | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/src/arkode/arkode_mristep.c b/src/arkode/arkode_mristep.c index 79205bbefe..cb8389d733 100644 --- a/src/arkode/arkode_mristep.c +++ b/src/arkode/arkode_mristep.c @@ -1584,7 +1584,7 @@ int mriStep_UpdateF0(ARKodeMem ark_mem, ARKodeMRIStepMem step_mem, { case ARK_FULLRHS_START: - /* compute the components that comprise the full RHS */ + /* update the RHS components */ /* explicit component */ if (step_mem->explicit_rhs) @@ -1728,7 +1728,7 @@ int mriStep_UpdateF0(ARKodeMem ark_mem, ARKodeMRIStepMem step_mem, break; default: - /* return with RHS failure if unknown mode is passed */ + /* return with RHS failure if unknown mode is requested */ arkProcessError(ark_mem, ARK_RHSFUNC_FAIL, __LINE__, __func__, __FILE__, "Unknown full RHS mode"); return (ARK_RHSFUNC_FAIL); @@ -1852,9 +1852,11 @@ int mriStep_TakeStepMRIGARK(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPt } } - /* Evaluate the slow RHS functions if needed. NOTE: we decide between calling the full RHS - function (if ark_mem->fn is non-NULL) versus just updating the stored values of - Fse[0] and Fsi[0]. */ + /* Evaluate the slow RHS functions if needed. NOTE: we decide between calling the + full RHS function (if ark_mem->fn is non-NULL) versus just updating the stored + values of Fse[0] and Fsi[0]. In either case, we use ARK_FULLRHS_START mode + because MRISR methods do not evaluate the RHS functions at the end of the + time step (so nothing can be leveraged). */ if (ark_mem->fn != NULL) { retval = mriStep_FullRHS(ark_mem, ark_mem->tn, ark_mem->yn, ark_mem->fn, ARK_FULLRHS_START); @@ -2328,9 +2330,11 @@ int mriStep_TakeStepMRISR(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr) } } - /* Evaluate the slow RHS functions if needed. NOTE: we decide between calling the full RHS - function (if ark_mem->fn is non-NULL) versus just updating the stored values of - Fse[0] and Fsi[0]. */ + /* Evaluate the slow RHS functions if needed. NOTE: we decide between calling the + full RHS function (if ark_mem->fn is non-NULL) versus just updating the stored + values of Fse[0] and Fsi[0]. In either case, we use ARK_FULLRHS_START mode + because MRISR methods do not evaluate the RHS functions at the end of the + time step (so nothing can be leveraged). */ if (ark_mem->fn != NULL) { retval = mriStep_FullRHS(ark_mem, ark_mem->tn, ark_mem->yn, ark_mem->fn, ARK_FULLRHS_START); From 7cc8c608247294b0058f716c4b406fb3ae214db3 Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Wed, 20 Nov 2024 13:37:15 -0600 Subject: [PATCH 260/286] Accepted suggestion to reset fn_is_current when external forcing function is changed --- src/arkode/arkode_mristep.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/arkode/arkode_mristep.c b/src/arkode/arkode_mristep.c index cb8389d733..3036a9309c 100644 --- a/src/arkode/arkode_mristep.c +++ b/src/arkode/arkode_mristep.c @@ -4821,6 +4821,10 @@ int mriStep_SetInnerForcing(ARKodeMem ark_mem, sunrealtype tshift, step_mem->forcing = forcing; step_mem->nforcing = nvecs; + /* Signal that any pre-existing RHS vector is no longer current, since it + has a stale forcing function */ + ark_mem->fn_is_current = SUNFALSE; + /* If cvals and Xvecs are not allocated then mriStep_Init has not been called and the number of stages has not been set yet. These arrays will be allocated in mriStep_Init and take into account the value of nforcing. From 54e1bc4af384456b35f9c00bf5211d25b42577af Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Wed, 20 Nov 2024 13:44:38 -0600 Subject: [PATCH 261/286] Removed sa_stage check from ARK_FULLRHS_END case, since it is not mathematically correct. This causes some updated .out files to fail because the statistics actually return to original MRIStep behavior. --- src/arkode/arkode_mristep.c | 95 ++++++++++++++----------------------- 1 file changed, 36 insertions(+), 59 deletions(-) diff --git a/src/arkode/arkode_mristep.c b/src/arkode/arkode_mristep.c index 3036a9309c..2523222b8e 100644 --- a/src/arkode/arkode_mristep.c +++ b/src/arkode/arkode_mristep.c @@ -1577,7 +1577,7 @@ int mriStep_FullRHS(ARKodeMem ark_mem, sunrealtype t, N_Vector y, N_Vector f, int mriStep_UpdateF0(ARKodeMem ark_mem, ARKodeMRIStepMem step_mem, sunrealtype t, N_Vector y, int mode) { - int sa_stage, nvec, retval; + int nvec, retval; /* perform RHS functions contingent on 'mode' argument */ switch (mode) @@ -1651,76 +1651,53 @@ int mriStep_UpdateF0(ARKodeMem ark_mem, ARKodeMRIStepMem step_mem, /* compute the full RHS */ if (!(ark_mem->fn_is_current)) { - /* if the method had a stiffly-accurate internal stage, use the - already-computed RHS vectors */ - sa_stage = (step_mem->stagetypes[step_mem->stages-1] == MRISTAGE_STIFF_ACC) ? - step_mem->stage_map[step_mem->stages - 2] : -1; - if (sa_stage > -1) + /* compute the explicit component */ + if (step_mem->explicit_rhs) { - /* copy the explicit component */ - if (step_mem->explicit_rhs) + retval = step_mem->fse(t, y, step_mem->Fse[0], ark_mem->user_data); + step_mem->nfse++; + step_mem->fse_is_current = SUNTRUE; + if (retval != 0) { - N_VScale(ONE, step_mem->Fse[sa_stage], step_mem->Fse[0]); - step_mem->fse_is_current = SUNTRUE; + arkProcessError(ark_mem, ARK_RHSFUNC_FAIL, __LINE__, __func__, + __FILE__, MSG_ARK_RHSFUNC_FAILED, t); + return (ARK_RHSFUNC_FAIL); } - /* copy the implicit component */ - if (step_mem->implicit_rhs) + /* Add external forcing, as appropriate */ + if (step_mem->expforcing) { - N_VScale(ONE, step_mem->Fsi[sa_stage], step_mem->Fsi[0]); - step_mem->fsi_is_current = SUNTRUE; + step_mem->cvals[0] = ONE; + step_mem->Xvecs[0] = step_mem->Fse[0]; + nvec = 1; + mriStep_ApplyForcing(step_mem, t, ONE, &nvec); + N_VLinearCombination(nvec, step_mem->cvals, step_mem->Xvecs, + step_mem->Fse[0]); } } - else + + /* compute the implicit component */ + if (step_mem->implicit_rhs) { - /* compute the explicit component */ - if (step_mem->explicit_rhs) + retval = step_mem->fsi(t, y, step_mem->Fsi[0], ark_mem->user_data); + step_mem->nfsi++; + step_mem->fsi_is_current = SUNTRUE; + if (retval != 0) { - retval = step_mem->fse(t, y, step_mem->Fse[0], ark_mem->user_data); - step_mem->nfse++; - step_mem->fse_is_current = SUNTRUE; - if (retval != 0) - { - arkProcessError(ark_mem, ARK_RHSFUNC_FAIL, __LINE__, __func__, - __FILE__, MSG_ARK_RHSFUNC_FAILED, t); - return (ARK_RHSFUNC_FAIL); - } - - /* Add external forcing, as appropriate */ - if (step_mem->expforcing) - { - step_mem->cvals[0] = ONE; - step_mem->Xvecs[0] = step_mem->Fse[0]; - nvec = 1; - mriStep_ApplyForcing(step_mem, t, ONE, &nvec); - N_VLinearCombination(nvec, step_mem->cvals, step_mem->Xvecs, - step_mem->Fse[0]); - } + arkProcessError(ark_mem, ARK_RHSFUNC_FAIL, __LINE__, __func__, + __FILE__, MSG_ARK_RHSFUNC_FAILED, t); + return (ARK_RHSFUNC_FAIL); } - /* compute the implicit component */ - if (step_mem->implicit_rhs) + /* Add external forcing, as appropriate */ + if (step_mem->impforcing) { - retval = step_mem->fsi(t, y, step_mem->Fsi[0], ark_mem->user_data); - step_mem->nfsi++; - step_mem->fsi_is_current = SUNTRUE; - if (retval != 0) - { - arkProcessError(ark_mem, ARK_RHSFUNC_FAIL, __LINE__, __func__, - __FILE__, MSG_ARK_RHSFUNC_FAILED, t); - return (ARK_RHSFUNC_FAIL); - } - - /* Add external forcing, as appropriate */ - if (step_mem->impforcing) - { - step_mem->cvals[0] = ONE; - step_mem->Xvecs[0] = step_mem->Fsi[0]; - nvec = 1; - mriStep_ApplyForcing(step_mem, t, ONE, &nvec); - N_VLinearCombination(nvec, step_mem->cvals, step_mem->Xvecs, - step_mem->Fsi[0]); - } + step_mem->cvals[0] = ONE; + step_mem->Xvecs[0] = step_mem->Fsi[0]; + nvec = 1; + mriStep_ApplyForcing(step_mem, t, ONE, &nvec); + N_VLinearCombination(nvec, step_mem->cvals, step_mem->Xvecs, + step_mem->Fsi[0]); } } } From 2f5d8f6a3c4bc1390fd8b801365ec31f2be9d45c Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Wed, 27 Nov 2024 21:21:13 -0600 Subject: [PATCH 262/286] Applied minor code review suggestions from @gardner48 --- src/arkode/arkode_mristep.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/src/arkode/arkode_mristep.c b/src/arkode/arkode_mristep.c index 2523222b8e..812947c13f 100644 --- a/src/arkode/arkode_mristep.c +++ b/src/arkode/arkode_mristep.c @@ -1594,13 +1594,13 @@ int mriStep_UpdateF0(ARKodeMem ark_mem, ARKodeMRIStepMem step_mem, { retval = step_mem->fse(t, y, step_mem->Fse[0], ark_mem->user_data); step_mem->nfse++; - step_mem->fse_is_current = SUNTRUE; if (retval != 0) { arkProcessError(ark_mem, ARK_RHSFUNC_FAIL, __LINE__, __func__, __FILE__, MSG_ARK_RHSFUNC_FAILED, t); return (ARK_RHSFUNC_FAIL); } + step_mem->fse_is_current = SUNTRUE; /* Add external forcing, if applicable */ if (step_mem->expforcing) @@ -1623,13 +1623,13 @@ int mriStep_UpdateF0(ARKodeMem ark_mem, ARKodeMRIStepMem step_mem, { retval = step_mem->fsi(t, y, step_mem->Fsi[0], ark_mem->user_data); step_mem->nfsi++; - step_mem->fsi_is_current = SUNTRUE; if (retval != 0) { arkProcessError(ark_mem, ARK_RHSFUNC_FAIL, __LINE__, __func__, __FILE__, MSG_ARK_RHSFUNC_FAILED, t); return (ARK_RHSFUNC_FAIL); } + step_mem->fsi_is_current = SUNTRUE; /* Add external forcing, if applicable */ if (step_mem->impforcing) @@ -1656,13 +1656,13 @@ int mriStep_UpdateF0(ARKodeMem ark_mem, ARKodeMRIStepMem step_mem, { retval = step_mem->fse(t, y, step_mem->Fse[0], ark_mem->user_data); step_mem->nfse++; - step_mem->fse_is_current = SUNTRUE; if (retval != 0) { arkProcessError(ark_mem, ARK_RHSFUNC_FAIL, __LINE__, __func__, __FILE__, MSG_ARK_RHSFUNC_FAILED, t); return (ARK_RHSFUNC_FAIL); } + step_mem->fse_is_current = SUNTRUE; /* Add external forcing, as appropriate */ if (step_mem->expforcing) @@ -1681,13 +1681,13 @@ int mriStep_UpdateF0(ARKodeMem ark_mem, ARKodeMRIStepMem step_mem, { retval = step_mem->fsi(t, y, step_mem->Fsi[0], ark_mem->user_data); step_mem->nfsi++; - step_mem->fsi_is_current = SUNTRUE; if (retval != 0) { arkProcessError(ark_mem, ARK_RHSFUNC_FAIL, __LINE__, __func__, __FILE__, MSG_ARK_RHSFUNC_FAILED, t); return (ARK_RHSFUNC_FAIL); } + step_mem->fsi_is_current = SUNTRUE; /* Add external forcing, as appropriate */ if (step_mem->impforcing) @@ -1832,7 +1832,7 @@ int mriStep_TakeStepMRIGARK(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPt /* Evaluate the slow RHS functions if needed. NOTE: we decide between calling the full RHS function (if ark_mem->fn is non-NULL) versus just updating the stored values of Fse[0] and Fsi[0]. In either case, we use ARK_FULLRHS_START mode - because MRISR methods do not evaluate the RHS functions at the end of the + because MRIGARK methods do not evaluate the RHS functions at the end of the time step (so nothing can be leveraged). */ if (ark_mem->fn != NULL) { @@ -2324,12 +2324,11 @@ int mriStep_TakeStepMRISR(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr) } ark_mem->fn_is_current = SUNTRUE; - /* combine both RHS into FSE for ImEx problems and zero out Fsi[0], since - MRISR fast forcing function only depends on Omega coefficients */ + /* combine both RHS into FSE for ImEx problems, since MRISR fast forcing function + only depends on Omega coefficients */ if (step_mem->implicit_rhs && step_mem->explicit_rhs) { N_VLinearSum(ONE, step_mem->Fse[0], ONE, step_mem->Fsi[0], step_mem->Fse[0]); - /* N_VConst(ZERO, step_mem->Fsi[0]);*/ } #ifdef SUNDIALS_DEBUG From 720c407fd2ad09c5899e22f788a627c7604fee0d Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Wed, 27 Nov 2024 21:26:06 -0600 Subject: [PATCH 263/286] Changed k index to \ell as suggested by @Steven-Roberts --- doc/arkode/guide/source/Mathematics.rst | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/doc/arkode/guide/source/Mathematics.rst b/doc/arkode/guide/source/Mathematics.rst index 119d19c41f..efc65f205c 100644 --- a/doc/arkode/guide/source/Mathematics.rst +++ b/doc/arkode/guide/source/Mathematics.rst @@ -701,12 +701,12 @@ given by where :math:`\Delta c_i^S=\left(c^S_i - c^S_{i-1}\right)`, :math:`\tau = (t - t_{n,i-1}^S)/(h^S \Delta c_i^S)` is the normalized time, the coefficients :math:`\omega_{i,j}` and :math:`\gamma_{i,j}` are polynomials in time of degree -:math:`k` given by +:math:`k-1` given by .. math:: - \omega_{i,j}(\tau) = \sum_{k\geq 1} \Omega_{i,j,k} \, \tau^{k-1} + \omega_{i,j}(\tau) = \sum_{\ell\geq 1} \Omega_{i,j,\ell} \, \tau^{\ell-1} \quad\text{and}\quad - \gamma_{i,j}(\tau) = \sum_{k\geq 1} \Gamma_{i,j,k} \, \tau^{k-1}. + \gamma_{i,j}(\tau) = \sum_{\ell\geq 1} \Gamma_{i,j,\ell} \, \tau^{\ell-1}. :label: ARKODE_MRI_coupling When the slow abscissa are repeated, i.e. :math:`\Delta c_i^S = 0`, the fast IVP @@ -716,10 +716,10 @@ stage is computed as .. math:: z_i = z_{i-1} - + h^S \sum_{j=1}^{i-1} \left(\sum_{k\geq 1} - \frac{\Omega_{i,j,k}}{k}\right) f^E(t_{n,j}^S, z_j) - + h^S \sum_{j=1}^i \left(\sum_{k\geq 1} - \frac{\Gamma_{i,j,k}}{k}\right) f^I(t_{n,j}^S, z_j). + + h^S \sum_{j=1}^{i-1} \left(\sum_{\ell\geq 1} + \frac{\Omega_{i,j,\ell}}{\ell}\right) f^E(t_{n,j}^S, z_j) + + h^S \sum_{j=1}^i \left(\sum_{\ell\geq 1} + \frac{\Gamma_{i,j,\ell}}{\ell}\right) f^I(t_{n,j}^S, z_j). :label: ARKODE_MRI_delta_c_zero Similarly, the embedded solution IVP, :eq:`MRI_embedding_fast_IVP`, is evolved @@ -729,12 +729,12 @@ with the initial condition :math:`\tilde{v}_0=z_{s-1}`. As with standard ARK and DIRK methods, implicitness at the slow time scale is characterized by nonzero values on or above the diagonal of the :math:`k` matrices in :math:`\Gamma`. Typically, MRI-GARK and IMEX-MRI-GARK methods are at -most diagonally-implicit (i.e., :math:`\Gamma_{i,j,k}=0` for all :math:`k` and +most diagonally-implicit (i.e., :math:`\Gamma_{i,j,\ell}=0` for all :math:`\ell` and :math:`j>i`). Furthermore, diagonally-implicit stages are characterized as being -"solve-decoupled" if :math:`\Delta c_i^S = 0` when :math:`\Gamma_{i,i,k} \ne 0`, +"solve-decoupled" if :math:`\Delta c_i^S = 0` when :math:`\Gamma_{i,i,\ell} \ne 0`, in which case the stage is computed as a standard ARK or DIRK update. Alternately, a diagonally-implicit stage :math:`i` is considered "solve-coupled" if -:math:`\Delta c^S_i \, \Gamma_{i,j,k} \ne 0`, in which +:math:`\Delta c^S_i \, \Gamma_{i,j,\ell} \ne 0`, in which case the stage solution :math:`z_i` is *both* an input to :math:`r_i(t)` and the result of time-evolution of the fast IVP, necessitating an implicit solve that is coupled to the fast evolution. At present, only "solve-decoupled" @@ -750,7 +750,7 @@ The IMEX-MRI-SR family of methods perform *both* the fast IVP evolution, (but these methods typically have far fewer stages than implicit MRI-GARK or IMEX-MRI-GARK methods). These methods are defined by a vector of slow stage time abscissae :math:`c^S \in \mathbb{R}^{s}`, a set of coupling tensors -:math:`\Omega\in\mathbb{R}^{(s+1)\times s\times k}`, and a Butcher table of +:math:`\Omega\in\mathbb{R}^{(s+1)\times s\times \ell}`, and a Butcher table of slow-implicit coefficients, :math:`\Gamma\in\mathbb{R}^{(s+1) \times s}`. The fast stage IVPs, :eq:`MRI_fast_IVP`, are evolved on overlapping @@ -763,7 +763,7 @@ given by :label: IMEXMRISR_forcing where :math:`\tau = (t - t_n)/(h^S c_i^S)` is the normalized time, and the coefficients -:math:`\omega_{i,j}` are polynomials in time of degree :math:`k` that are also given by +:math:`\omega_{i,j}` are polynomials in time of degree :math:`k-1` that are also given by :eq:`ARKODE_MRI_coupling`. The solution of these fast IVPs defines an intermediate stage solution, :math:`\tilde{z}_i`. From 9e60c90316d39efe2e3f457e74f4e90d67aa1385 Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Wed, 27 Nov 2024 21:29:58 -0600 Subject: [PATCH 264/286] Renamed MRISTEP_MRISR as MRISTEP_SR as per @Steven-Roberts suggestion --- .../source/Usage/MRIStep/MRIStepCoupling.rst | 6 ++--- include/arkode/arkode_mristep.h | 2 +- src/arkode/arkode_mri_tables.c | 10 ++++----- src/arkode/arkode_mri_tables.def | 6 ++--- src/arkode/arkode_mristep.c | 14 ++++++------ src/arkode/fmod_int32/farkode_mristep_mod.f90 | 4 ++-- src/arkode/fmod_int64/farkode_mristep_mod.f90 | 4 ++-- .../CXX_serial/ark_test_dahlquist_mri.cpp | 22 +++++++++---------- 8 files changed, 34 insertions(+), 34 deletions(-) diff --git a/doc/arkode/guide/source/Usage/MRIStep/MRIStepCoupling.rst b/doc/arkode/guide/source/Usage/MRIStep/MRIStepCoupling.rst index 46590c75a7..6da195368f 100644 --- a/doc/arkode/guide/source/Usage/MRIStep/MRIStepCoupling.rst +++ b/doc/arkode/guide/source/Usage/MRIStep/MRIStepCoupling.rst @@ -46,7 +46,7 @@ by the table is determined by an enumerated type, :c:enum:`MRISTEP_METHOD_TYPE`: A explicit MERK method (does not support a slow implicit operator, :math:`f^I`). - .. c:enumerator:: MRISTEP_MRISR + .. c:enumerator:: MRISTEP_SR An IMEX-MRI-SR method. @@ -206,7 +206,7 @@ are defined ``arkode/arkode_mristep.h``. For :c:enumerator:`MRISTEP_MERK` tables, the *G* array is not allocated. - For :c:enumerator:`MRISTEP_MRISR` tables, the *group* array is not allocated. + For :c:enumerator:`MRISTEP_SR` tables, the *group* array is not allocated. When allocated, both :math:`\Omega` and :math:`\Gamma` are initialized to all zeros, so only nonzero coefficients need to be provided. @@ -241,7 +241,7 @@ are defined ``arkode/arkode_mristep.h``. ``MRISTEP_EXPLICIT``, ``MRISTEP_IMPLICIT``, or ``MRISTEP_IMEX``. The routine determines the relevant type based on whether either of the arguments *W* and *G* are ``NULL``. Users who wish to create MRI - methods of type ``MRISTEP_MERK`` or ``MRISTEP_MRISR`` must currently + methods of type ``MRISTEP_MERK`` or ``MRISTEP_SR`` must currently do so manually. The assumed size of the input arrays *W* and *G* depends on the diff --git a/include/arkode/arkode_mristep.h b/include/arkode/arkode_mristep.h index fe3888bb58..c71d8ad4a3 100644 --- a/include/arkode/arkode_mristep.h +++ b/include/arkode/arkode_mristep.h @@ -39,7 +39,7 @@ typedef enum MRISTEP_IMPLICIT, MRISTEP_IMEX, MRISTEP_MERK, - MRISTEP_MRISR + MRISTEP_SR } MRISTEP_METHOD_TYPE; /* MRI coupling table IDs */ diff --git a/src/arkode/arkode_mri_tables.c b/src/arkode/arkode_mri_tables.c index 1fe04f672b..75db52c6de 100644 --- a/src/arkode/arkode_mri_tables.c +++ b/src/arkode/arkode_mri_tables.c @@ -103,12 +103,12 @@ MRIStepCoupling MRIStepCoupling_Alloc(int nmat, int stages, hasOmegas = hasGammas = SUNFALSE; if ((type == MRISTEP_EXPLICIT) || (type == MRISTEP_IMEX) || - (type == MRISTEP_MERK) || (type == MRISTEP_MRISR)) + (type == MRISTEP_MERK) || (type == MRISTEP_SR)) { hasOmegas = SUNTRUE; } if ((type == MRISTEP_IMPLICIT) || (type == MRISTEP_IMEX) || - (type == MRISTEP_MRISR)) + (type == MRISTEP_SR)) { hasGammas = SUNTRUE; } @@ -674,7 +674,7 @@ void MRIStepCoupling_Write(MRIStepCoupling MRIC, FILE* outfile) case MRISTEP_IMPLICIT: fprintf(outfile, " type = implicit MRI\n"); break; case MRISTEP_IMEX: fprintf(outfile, " type = ImEx MRI\n"); break; case MRISTEP_MERK: fprintf(outfile, " type = MERK\n"); break; - case MRISTEP_MRISR: fprintf(outfile, " type = MRISR\n"); break; + case MRISTEP_SR: fprintf(outfile, " type = MRISR\n"); break; default: fprintf(outfile, " type = unknown\n"); } fprintf(outfile, " nmat = %i\n", MRIC->nmat); @@ -777,7 +777,7 @@ int mriStepCoupling_GetStageType(MRIStepCoupling MRIC, int is) if ((is < 0) || (is > MRIC->stages)) { return ARK_INVALID_TABLE; } /* report MRISTAGE_ERK_FAST for MERK and MRI-SR methods */ - if ((MRIC->type == MRISTEP_MRISR) || (MRIC->type == MRISTEP_MERK)) + if ((MRIC->type == MRISTEP_SR) || (MRIC->type == MRISTEP_MERK)) { return (MRISTAGE_ERK_FAST); } @@ -890,7 +890,7 @@ int mriStepCoupling_GetStageMap(MRIStepCoupling MRIC, int* stage_map, * MERK and MRI-SR have "identity" storage map * ------------------------------------------- */ - if ((MRIC->type == MRISTEP_MERK) || (MRIC->type == MRISTEP_MRISR)) + if ((MRIC->type == MRISTEP_MERK) || (MRIC->type == MRISTEP_SR)) { /* Number of stage RHS vectors active */ *nstages_active = MRIC->stages; diff --git a/src/arkode/arkode_mri_tables.def b/src/arkode/arkode_mri_tables.def index b6f9f6cc2f..9e6bb316a8 100644 --- a/src/arkode/arkode_mri_tables.def +++ b/src/arkode/arkode_mri_tables.def @@ -657,7 +657,7 @@ ARK_MRI_TABLE(ARKODE_IMEX_MRI_GARK4, { /* R. Chinomona & D. Reynolds SINUM 43(5) }) ARK_MRI_TABLE(ARKODE_IMEX_MRI_SR21, { /* A.C. Fish, D.R. Reynolds, S.B. Roberts, JCAM 438:115534, 2024 */ - MRIStepCoupling C = MRIStepCoupling_Alloc(1, 4, MRISTEP_MRISR); + MRIStepCoupling C = MRIStepCoupling_Alloc(1, 4, MRISTEP_SR); C->q = 2; C->p = 1; @@ -692,7 +692,7 @@ ARK_MRI_TABLE(ARKODE_IMEX_MRI_SR21, { /* A.C. Fish, D.R. Reynolds, S.B. Roberts, }) ARK_MRI_TABLE(ARKODE_IMEX_MRI_SR32, { /* A.C. Fish, D.R. Reynolds, S.B. Roberts, JCAM 438:115534, 2024 */ - MRIStepCoupling C = MRIStepCoupling_Alloc(2, 5, MRISTEP_MRISR); + MRIStepCoupling C = MRIStepCoupling_Alloc(2, 5, MRISTEP_SR); C->q = 3; C->p = 2; @@ -753,7 +753,7 @@ ARK_MRI_TABLE(ARKODE_IMEX_MRI_SR32, { /* A.C. Fish, D.R. Reynolds, S.B. Roberts, }) ARK_MRI_TABLE(ARKODE_IMEX_MRI_SR43, { /* A.C. Fish, D.R. Reynolds, S.B. Roberts, arXiv:2301.00865, 2023 */ - MRIStepCoupling C = MRIStepCoupling_Alloc(2, 7, MRISTEP_MRISR); + MRIStepCoupling C = MRIStepCoupling_Alloc(2, 7, MRISTEP_SR); C->q = 4; C->p = 3; diff --git a/src/arkode/arkode_mristep.c b/src/arkode/arkode_mristep.c index 812947c13f..9cb08457d3 100644 --- a/src/arkode/arkode_mristep.c +++ b/src/arkode/arkode_mristep.c @@ -981,7 +981,7 @@ int mriStep_Init(ARKodeMem ark_mem, sunrealtype tout, int init_type) case MRISTEP_IMPLICIT: ark_mem->step = mriStep_TakeStepMRIGARK; break; case MRISTEP_IMEX: ark_mem->step = mriStep_TakeStepMRIGARK; break; case MRISTEP_MERK: ark_mem->step = mriStep_TakeStepMERK; break; - case MRISTEP_MRISR: ark_mem->step = mriStep_TakeStepMRISR; break; + case MRISTEP_SR: ark_mem->step = mriStep_TakeStepMRISR; break; default: arkProcessError(ark_mem, ARK_ILL_INPUT, __LINE__, __func__, __FILE__, "Unknown method type"); @@ -1121,7 +1121,7 @@ int mriStep_Init(ARKodeMem ark_mem, sunrealtype tout, int init_type) /* If an MRISR method is applied to a non-ImEx problem, we "unify" the Fse and Fsi vectors to point at the same memory */ step_mem->unify_Fs = SUNFALSE; - if ((step_mem->MRIC->type == MRISTEP_MRISR) && + if ((step_mem->MRIC->type == MRISTEP_SR) && ((step_mem->explicit_rhs && !step_mem->implicit_rhs) || (!step_mem->explicit_rhs && step_mem->implicit_rhs))) { @@ -3197,7 +3197,7 @@ int mriStep_CheckCoupling(ARKodeMem ark_mem) /* Check that coupling table has compatible type */ if (step_mem->implicit_rhs && step_mem->explicit_rhs && (step_mem->MRIC->type != MRISTEP_IMEX) && - (step_mem->MRIC->type != MRISTEP_MRISR)) + (step_mem->MRIC->type != MRISTEP_SR)) { arkProcessError(ark_mem, ARK_ILL_INPUT, __LINE__, __func__, __FILE__, "Invalid coupling table for an IMEX problem!"); @@ -3206,7 +3206,7 @@ int mriStep_CheckCoupling(ARKodeMem ark_mem) if (step_mem->explicit_rhs && (step_mem->MRIC->type != MRISTEP_EXPLICIT) && (step_mem->MRIC->type != MRISTEP_IMEX) && (step_mem->MRIC->type != MRISTEP_MERK) && - (step_mem->MRIC->type != MRISTEP_MRISR)) + (step_mem->MRIC->type != MRISTEP_SR)) { arkProcessError(ark_mem, ARK_ILL_INPUT, __LINE__, __func__, __FILE__, "Invalid coupling table for an explicit problem!"); @@ -3214,7 +3214,7 @@ int mriStep_CheckCoupling(ARKodeMem ark_mem) } if (step_mem->implicit_rhs && (step_mem->MRIC->type != MRISTEP_IMPLICIT) && (step_mem->MRIC->type != MRISTEP_IMEX) && - (step_mem->MRIC->type != MRISTEP_MRISR)) + (step_mem->MRIC->type != MRISTEP_SR)) { arkProcessError(ark_mem, ARK_ILL_INPUT, __LINE__, __func__, __FILE__, "Invalid coupling table for an implicit problem!"); @@ -3223,7 +3223,7 @@ int mriStep_CheckCoupling(ARKodeMem ark_mem) /* Check that the matrices are defined appropriately */ if ((step_mem->MRIC->type == MRISTEP_IMEX) || - (step_mem->MRIC->type == MRISTEP_MRISR)) + (step_mem->MRIC->type == MRISTEP_SR)) { /* ImEx */ if (!(step_mem->MRIC->W) || !(step_mem->MRIC->G)) @@ -3727,7 +3727,7 @@ int mriStep_ComputeInnerForcing(SUNDIALS_MAYBE_UNUSED ARKodeMem ark_mem, /* Adjust implicit/explicit RHS flags for MRISR methods, since these ignore the G coefficients in the forcing function */ - if (step_mem->MRIC->type == MRISTEP_MRISR) + if (step_mem->MRIC->type == MRISTEP_SR) { implicit_rhs = SUNFALSE; explicit_rhs = SUNTRUE; diff --git a/src/arkode/fmod_int32/farkode_mristep_mod.f90 b/src/arkode/fmod_int32/farkode_mristep_mod.f90 index 86b8833d43..3762a1f9c8 100644 --- a/src/arkode/fmod_int32/farkode_mristep_mod.f90 +++ b/src/arkode/fmod_int32/farkode_mristep_mod.f90 @@ -32,10 +32,10 @@ module farkode_mristep_mod enumerator :: MRISTEP_IMPLICIT enumerator :: MRISTEP_IMEX enumerator :: MRISTEP_MERK - enumerator :: MRISTEP_MRISR + enumerator :: MRISTEP_SR end enum integer, parameter, public :: MRISTEP_METHOD_TYPE = kind(MRISTEP_EXPLICIT) - public :: MRISTEP_EXPLICIT, MRISTEP_IMPLICIT, MRISTEP_IMEX, MRISTEP_MERK, MRISTEP_MRISR + public :: MRISTEP_EXPLICIT, MRISTEP_IMPLICIT, MRISTEP_IMEX, MRISTEP_MERK, MRISTEP_SR ! typedef enum ARKODE_MRITableID enum, bind(c) enumerator :: ARKODE_MRI_NONE = -1 diff --git a/src/arkode/fmod_int64/farkode_mristep_mod.f90 b/src/arkode/fmod_int64/farkode_mristep_mod.f90 index 59dfb37340..657ce9a979 100644 --- a/src/arkode/fmod_int64/farkode_mristep_mod.f90 +++ b/src/arkode/fmod_int64/farkode_mristep_mod.f90 @@ -32,10 +32,10 @@ module farkode_mristep_mod enumerator :: MRISTEP_IMPLICIT enumerator :: MRISTEP_IMEX enumerator :: MRISTEP_MERK - enumerator :: MRISTEP_MRISR + enumerator :: MRISTEP_SR end enum integer, parameter, public :: MRISTEP_METHOD_TYPE = kind(MRISTEP_EXPLICIT) - public :: MRISTEP_EXPLICIT, MRISTEP_IMPLICIT, MRISTEP_IMEX, MRISTEP_MERK, MRISTEP_MRISR + public :: MRISTEP_EXPLICIT, MRISTEP_IMPLICIT, MRISTEP_IMEX, MRISTEP_MERK, MRISTEP_SR ! typedef enum ARKODE_MRITableID enum, bind(c) enumerator :: ARKODE_MRI_NONE = -1 diff --git a/test/unit_tests/arkode/CXX_serial/ark_test_dahlquist_mri.cpp b/test/unit_tests/arkode/CXX_serial/ark_test_dahlquist_mri.cpp index 4db8264121..4134c124bd 100644 --- a/test/unit_tests/arkode/CXX_serial/ark_test_dahlquist_mri.cpp +++ b/test/unit_tests/arkode/CXX_serial/ark_test_dahlquist_mri.cpp @@ -157,7 +157,7 @@ int main(int argc, char* argv[]) numfails += run_tests(MRISTEP_MERK, prob_opts, prob_data, sunctx); - numfails += run_tests(MRISTEP_MRISR, prob_opts, prob_data, sunctx); + numfails += run_tests(MRISTEP_SR, prob_opts, prob_data, sunctx); if (numfails) { std::cout << "\n\nFailed " << numfails << " tests!\n"; } else { std::cout << "\n\nAll tests passed!\n"; } @@ -189,7 +189,7 @@ int run_tests(MRISTEP_METHOD_TYPE type, ProblemOptions& prob_opts, SUNMatrix A = nullptr; SUNLinearSolver LS = nullptr; - if (type == MRISTEP_IMPLICIT || type == MRISTEP_IMEX || type == MRISTEP_MRISR) + if (type == MRISTEP_IMPLICIT || type == MRISTEP_IMEX || type == MRISTEP_SR) { // Initialize dense matrix data structures and solvers A = SUNDenseMatrix(1, 1, sunctx); @@ -253,7 +253,7 @@ int run_tests(MRISTEP_METHOD_TYPE type, ProblemOptions& prob_opts, mristep_mem = MRIStepCreate(nullptr, fi, prob_opts.t0, y, inner_stepper, sunctx); } - else if ((type == MRISTEP_IMEX) || (type == MRISTEP_MRISR)) + else if ((type == MRISTEP_IMEX) || (type == MRISTEP_SR)) { mristep_mem = MRIStepCreate(fe, fi, prob_opts.t0, y, inner_stepper, sunctx); } @@ -272,7 +272,7 @@ int run_tests(MRISTEP_METHOD_TYPE type, ProblemOptions& prob_opts, flag = ARKodeSetFixedStep(mristep_mem, prob_opts.hs); if (check_flag(&flag, "ARKodeSetFixedStep", 1)) { return 1; } - if (type == MRISTEP_IMPLICIT || type == MRISTEP_IMEX || type == MRISTEP_MRISR) + if (type == MRISTEP_IMPLICIT || type == MRISTEP_IMEX || type == MRISTEP_SR) { // Attach linear solver flag = ARKodeSetLinearSolver(mristep_mem, LS, A); @@ -357,7 +357,7 @@ int run_tests(MRISTEP_METHOD_TYPE type, ProblemOptions& prob_opts, {"ARKODE_IMEX_MRI_GARK3b", false}, {"ARKODE_IMEX_MRI_GARK4", false}}); } - else if (type == MRISTEP_MRISR) + else if (type == MRISTEP_SR) { std::cout << "\n========================\n"; std::cout << "Test IMEX MRI SR methods\n"; @@ -434,7 +434,7 @@ int run_tests(MRISTEP_METHOD_TYPE type, ProblemOptions& prob_opts, flag = ARKodeGetNumRhsEvals(mristep_mem, 1, &mri_nfsi); if (check_flag(&flag, "ARKodeGetNumRhsEvals", 1)) { return 1; } - if (type == MRISTEP_IMPLICIT || type == MRISTEP_IMEX || type == MRISTEP_MRISR) + if (type == MRISTEP_IMPLICIT || type == MRISTEP_IMEX || type == MRISTEP_SR) { flag = ARKodeGetNumNonlinSolvIters(mristep_mem, &mri_nni); if (check_flag(&flag, "ARKodeGetNumNonlinSolvIters", 1)) { return 1; } @@ -454,7 +454,7 @@ int run_tests(MRISTEP_METHOD_TYPE type, ProblemOptions& prob_opts, sunrealtype pow = prob_data.lambda_f; if (type != MRISTEP_IMPLICIT) { pow += prob_data.lambda_e; } - if (type == MRISTEP_IMPLICIT || type == MRISTEP_IMEX || type == MRISTEP_MRISR) + if (type == MRISTEP_IMPLICIT || type == MRISTEP_IMEX || type == MRISTEP_SR) { pow += prob_data.lambda_i; } @@ -472,7 +472,7 @@ int run_tests(MRISTEP_METHOD_TYPE type, ProblemOptions& prob_opts, std::cout << " Fe evals = " << mri_nfse << "\n"; std::cout << " Fi evals = " << mri_nfsi << "\n"; - if (type == MRISTEP_IMPLICIT || type == MRISTEP_IMEX || type == MRISTEP_MRISR) + if (type == MRISTEP_IMPLICIT || type == MRISTEP_IMEX || type == MRISTEP_SR) { std::cout << " NLS iters = " << mri_nni << "\n"; std::cout << " NLS fails = " << mri_ncfn << "\n"; @@ -499,7 +499,7 @@ int run_tests(MRISTEP_METHOD_TYPE type, ProblemOptions& prob_opts, } long int fi_evals = 0; - if (type == MRISTEP_IMPLICIT || type == MRISTEP_IMEX || type == MRISTEP_MRISR) + if (type == MRISTEP_IMPLICIT || type == MRISTEP_IMEX || type == MRISTEP_SR) { fi_evals = mri_nst * nstages_evaluated + mri_nni; } @@ -537,7 +537,7 @@ int run_tests(MRISTEP_METHOD_TYPE type, ProblemOptions& prob_opts, { flag = MRIStepReInit(mristep_mem, nullptr, fi, prob_opts.t0, y); } - else if (type == MRISTEP_IMEX || type == MRISTEP_MRISR) + else if (type == MRISTEP_IMEX || type == MRISTEP_SR) { flag = MRIStepReInit(mristep_mem, fe, fi, prob_opts.t0, y); } @@ -549,7 +549,7 @@ int run_tests(MRISTEP_METHOD_TYPE type, ProblemOptions& prob_opts, MRIStepInnerStepper_Free(&inner_stepper); ARKodeFree(&mristep_mem); ARKodeFree(&arkstep_mem); - if (type == MRISTEP_IMPLICIT || type == MRISTEP_IMEX || type == MRISTEP_MRISR) + if (type == MRISTEP_IMPLICIT || type == MRISTEP_IMEX || type == MRISTEP_SR) { SUNLinSolFree(LS); SUNMatDestroy(A); From ae3bf51982056ad2f495fda146dfe3ffd78dcd10 Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Wed, 27 Nov 2024 21:35:23 -0600 Subject: [PATCH 265/286] Updated handling of command-line arguments as per @Steven-Roberts suggestion --- .../CXX_serial/ark_test_accumerror_brusselator.cpp | 10 +++++----- .../arkode/CXX_serial/ark_test_accumerror_kpr.cpp | 12 ++++++------ .../CXX_serial/ark_test_slowerror_brusselator.cpp | 6 +++--- .../arkode/CXX_serial/ark_test_slowerror_kpr.cpp | 8 ++++---- .../CXX_serial/ark_test_slowerror_polynomial.cpp | 6 +++--- 5 files changed, 21 insertions(+), 21 deletions(-) diff --git a/test/unit_tests/arkode/CXX_serial/ark_test_accumerror_brusselator.cpp b/test/unit_tests/arkode/CXX_serial/ark_test_accumerror_brusselator.cpp index 730e7f2a84..2d01042362 100644 --- a/test/unit_tests/arkode/CXX_serial/ark_test_accumerror_brusselator.cpp +++ b/test/unit_tests/arkode/CXX_serial/ark_test_accumerror_brusselator.cpp @@ -164,11 +164,11 @@ int main(int argc, char* argv[]) // // Retrieve the command-line options: Npart ord method ep test - if (argc > 1) udata.Npart = (int)atoi(argv[1]); - if (argc > 2) order = (int)atoi(argv[2]); - if (argc > 3) rk_type = (int)atoi(argv[3]); - if (argc > 4) udata.ep = (sunrealtype)atof(argv[4]); - if (argc > 5) test = (int)atoi(argv[5]); + if (argc > 1) udata.Npart = atoi(argv[1]); + if (argc > 2) order = atoi(argv[2]); + if (argc > 3) rk_type = atoi(argv[3]); + if (argc > 4) udata.ep = SUNStrToReal(argv[4]); + if (argc > 5) test = atoi(argv[5]); // Check arguments for validity // method = {0, 1} diff --git a/test/unit_tests/arkode/CXX_serial/ark_test_accumerror_kpr.cpp b/test/unit_tests/arkode/CXX_serial/ark_test_accumerror_kpr.cpp index 3707bff97c..4a7cd7535e 100644 --- a/test/unit_tests/arkode/CXX_serial/ark_test_accumerror_kpr.cpp +++ b/test/unit_tests/arkode/CXX_serial/ark_test_accumerror_kpr.cpp @@ -155,12 +155,12 @@ int main(int argc, char* argv[]) // // Retrieve the command-line options: Npart ord method G e omega - if (argc > 1) udata.Npart = (int)atoi(argv[1]); - if (argc > 2) order = (int)atoi(argv[2]); - if (argc > 3) rk_type = (int)atoi(argv[3]); - if (argc > 4) udata.G = (sunrealtype)atof(argv[4]); - if (argc > 5) udata.e = (sunrealtype)atof(argv[5]); - if (argc > 6) udata.omega = (sunrealtype)atof(argv[6]); + if (argc > 1) udata.Npart = atoi(argv[1]); + if (argc > 2) order = atoi(argv[2]); + if (argc > 3) rk_type = atoi(argv[3]); + if (argc > 4) udata.G = SUNStrToReal(argv[4]); + if (argc > 5) udata.e = SUNStrToReal(argv[5]); + if (argc > 6) udata.omega = SUNStrToReal(argv[6]); // Check arguments for validity // 0 <= rk_type <= 1 diff --git a/test/unit_tests/arkode/CXX_serial/ark_test_slowerror_brusselator.cpp b/test/unit_tests/arkode/CXX_serial/ark_test_slowerror_brusselator.cpp index 8b74a377fe..e094279c41 100644 --- a/test/unit_tests/arkode/CXX_serial/ark_test_slowerror_brusselator.cpp +++ b/test/unit_tests/arkode/CXX_serial/ark_test_slowerror_brusselator.cpp @@ -162,9 +162,9 @@ int main(int argc, char* argv[]) // Retrieve the command-line options: method Npart ep test if (argc > 1) { method = argv[1]; } else { method = "ARKODE_MRI_GARK_ERK33a"; } - if (argc > 2) udata.Npart = (int)atoi(argv[2]); - if (argc > 3) udata.ep = (sunrealtype)atof(argv[3]); - if (argc > 4) test = (int)atoi(argv[4]); + if (argc > 2) udata.Npart = atoi(argv[2]); + if (argc > 3) udata.ep = SUNStrToReal(argv[3]); + if (argc > 4) test = atoi(argv[4]); // Check arguments for validity // Npart > 0 diff --git a/test/unit_tests/arkode/CXX_serial/ark_test_slowerror_kpr.cpp b/test/unit_tests/arkode/CXX_serial/ark_test_slowerror_kpr.cpp index 583be495ef..a7346214c4 100644 --- a/test/unit_tests/arkode/CXX_serial/ark_test_slowerror_kpr.cpp +++ b/test/unit_tests/arkode/CXX_serial/ark_test_slowerror_kpr.cpp @@ -154,10 +154,10 @@ int main(int argc, char* argv[]) // Retrieve the command-line options: method Npart G e omega if (argc > 1) { method = argv[1]; } else { method = "ARKODE_MRI_GARK_ERK33a"; } - if (argc > 2) udata.Npart = (int)atoi(argv[2]); - if (argc > 3) udata.G = (sunrealtype)atof(argv[3]); - if (argc > 4) udata.e = (sunrealtype)atof(argv[4]); - if (argc > 5) udata.omega = (sunrealtype)atof(argv[5]); + if (argc > 2) udata.Npart = atoi(argv[2]); + if (argc > 3) udata.G = SUNStrToReal(argv[3]); + if (argc > 4) udata.e = SUNStrToReal(argv[4]); + if (argc > 5) udata.omega = SUNStrToReal(argv[5]); // Check arguments for validity // G < 0.0 diff --git a/test/unit_tests/arkode/CXX_serial/ark_test_slowerror_polynomial.cpp b/test/unit_tests/arkode/CXX_serial/ark_test_slowerror_polynomial.cpp index 96541382b2..4d9105c163 100644 --- a/test/unit_tests/arkode/CXX_serial/ark_test_slowerror_polynomial.cpp +++ b/test/unit_tests/arkode/CXX_serial/ark_test_slowerror_polynomial.cpp @@ -115,11 +115,11 @@ int main(int argc, char* argv[]) // Retrieve the command-line options: method Npart ep test if (argc > 1) { method = argv[1]; } else { method = "ARKODE_MRI_GARK_ERK22a"; } - if (argc > 2) { udata.a = (sunrealtype)atof(argv[2]); } + if (argc > 2) { udata.a = SUNStrToReal(argv[2]); } else { udata.a = ONE; } - if (argc > 3) { udata.b = (sunrealtype)atof(argv[3]); } + if (argc > 3) { udata.b = SUNStrToReal(argv[3]); } else { udata.b = ONE; } - if (argc > 4) { udata.c = (sunrealtype)atof(argv[4]); } + if (argc > 4) { udata.c = SUNStrToReal(argv[4]); } else { udata.c = ONE; } sunbooleantype implicit = SUNFALSE; From 39e749b3c620c1cec12af3fdbebf95a8cf5d2b56 Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Wed, 27 Nov 2024 21:54:14 -0600 Subject: [PATCH 266/286] Fixed merge issues; applied formatter --- src/arkode/arkode_arkstep.c | 1 + src/arkode/arkode_lsrkstep.c | 3 ++- src/arkode/arkode_lsrkstep_impl.h | 4 ++-- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/arkode/arkode_arkstep.c b/src/arkode/arkode_arkstep.c index 22e2f3b2c3..eb7ccedc68 100644 --- a/src/arkode/arkode_arkstep.c +++ b/src/arkode/arkode_arkstep.c @@ -3247,6 +3247,7 @@ int arkStep_SetInnerForcing(ARKodeMem ark_mem, sunrealtype tshift, sunrealtype tscale, N_Vector* forcing, int nvecs) { ARKodeARKStepMem step_mem; + int retval; /* access ARKodeARKStepMem structure */ retval = arkStep_AccessStepMem(ark_mem, __func__, &step_mem); diff --git a/src/arkode/arkode_lsrkstep.c b/src/arkode/arkode_lsrkstep.c index 9cae2f4300..ce6d56fc6b 100644 --- a/src/arkode/arkode_lsrkstep.c +++ b/src/arkode/arkode_lsrkstep.c @@ -309,7 +309,8 @@ int lsrkStep_ReInit_Commons(void* arkode_mem, ARKRhsFn rhs, sunrealtype t0, With other initialization types, this routine does nothing. ---------------------------------------------------------------*/ -int lsrkStep_Init(ARKodeMem ark_mem, int init_type) +int lsrkStep_Init(ARKodeMem ark_mem, SUNDIALS_MAYBE_UNUSED sunrealtype tout, + int init_type) { ARKodeLSRKStepMem step_mem; int retval; diff --git a/src/arkode/arkode_lsrkstep_impl.h b/src/arkode/arkode_lsrkstep_impl.h index d6cec7f545..9b51b92963 100644 --- a/src/arkode/arkode_lsrkstep_impl.h +++ b/src/arkode/arkode_lsrkstep_impl.h @@ -34,7 +34,7 @@ extern "C" { LSRK time step module private math function macros =============================================================== * SUNRlog calls the appropriate version of log - * + * * SUNRsinh calls the appropriate version of sinh * * SUNRcosh calls the appropriate version of cosh @@ -176,7 +176,7 @@ void* lsrkStep_Create_Commons(ARKRhsFn rhs, sunrealtype t0, N_Vector y0, SUNContext sunctx); int lsrkStep_ReInit_Commons(void* arkode_mem, ARKRhsFn rhs, sunrealtype t0, N_Vector y0); -int lsrkStep_Init(ARKodeMem ark_mem, int init_type); +int lsrkStep_Init(ARKodeMem ark_mem, sunrealtype tout, int init_type); int lsrkStep_FullRHS(ARKodeMem ark_mem, sunrealtype t, N_Vector y, N_Vector f, int mode); int lsrkStep_TakeStepRKC(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr); From 2995955a710a8d3e12b1e5c8d38644206c9134a1 Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Wed, 27 Nov 2024 21:59:36 -0600 Subject: [PATCH 267/286] Formatting --- .../sunadaptcontroller_mrihtol.h | 8 +-- src/arkode/arkode_mristep.c | 51 ++++++++++--------- 2 files changed, 32 insertions(+), 27 deletions(-) diff --git a/include/sunadaptcontroller/sunadaptcontroller_mrihtol.h b/include/sunadaptcontroller/sunadaptcontroller_mrihtol.h index 720201cf97..baeffe7f73 100644 --- a/include/sunadaptcontroller/sunadaptcontroller_mrihtol.h +++ b/include/sunadaptcontroller/sunadaptcontroller_mrihtol.h @@ -53,11 +53,11 @@ SUNErrCode SUNAdaptController_SetParams_MRIHTol(SUNAdaptController C, sunrealtype inner_min_tolfac, sunrealtype inner_max_tolfac); SUNDIALS_EXPORT -SUNErrCode SUNAdaptController_GetSlowController_MRIHTol( - SUNAdaptController C, SUNAdaptController* Cslow); +SUNErrCode SUNAdaptController_GetSlowController_MRIHTol(SUNAdaptController C, + SUNAdaptController* Cslow); SUNDIALS_EXPORT -SUNErrCode SUNAdaptController_GetFastController_MRIHTol( - SUNAdaptController C, SUNAdaptController* Cfast); +SUNErrCode SUNAdaptController_GetFastController_MRIHTol(SUNAdaptController C, + SUNAdaptController* Cfast); SUNDIALS_EXPORT SUNAdaptController_Type SUNAdaptController_GetType_MRIHTol(SUNAdaptController C); SUNDIALS_EXPORT diff --git a/src/arkode/arkode_mristep.c b/src/arkode/arkode_mristep.c index e8fbefd197..0bc1005350 100644 --- a/src/arkode/arkode_mristep.c +++ b/src/arkode/arkode_mristep.c @@ -224,9 +224,9 @@ void* MRIStepCreate(ARKRhsFn fse, ARKRhsFn fsi, sunrealtype t0, N_Vector y0, /* Initialize fused op work space with sufficient storage for at least filling the full RHS on an ImEx problem */ step_mem->nfusedopvecs = 3; - step_mem->cvals = NULL; - step_mem->cvals = (sunrealtype*)calloc(step_mem->nfusedopvecs, - sizeof(sunrealtype)); + step_mem->cvals = NULL; + step_mem->cvals = (sunrealtype*)calloc(step_mem->nfusedopvecs, + sizeof(sunrealtype)); if (step_mem->cvals == NULL) { arkProcessError(ark_mem, ARK_MEM_FAIL, __LINE__, __func__, __FILE__, @@ -236,8 +236,7 @@ void* MRIStepCreate(ARKRhsFn fse, ARKRhsFn fsi, sunrealtype t0, N_Vector y0, } ark_mem->lrw += step_mem->nfusedopvecs; step_mem->Xvecs = NULL; - step_mem->Xvecs = (N_Vector*)calloc(step_mem->nfusedopvecs, - sizeof(N_Vector)); + step_mem->Xvecs = (N_Vector*)calloc(step_mem->nfusedopvecs, sizeof(N_Vector)); if (step_mem->Xvecs == NULL) { arkProcessError(ark_mem, ARK_MEM_FAIL, __LINE__, __func__, __FILE__, @@ -1411,8 +1410,8 @@ int mriStep_FullRHS(ARKodeMem ark_mem, sunrealtype t, N_Vector y, N_Vector f, retval = mriStep_UpdateF0(ark_mem, step_mem, t, y, mode); if (retval != 0) { - arkProcessError(ark_mem, ARK_RHSFUNC_FAIL, __LINE__, __func__, - __FILE__, MSG_ARK_RHSFUNC_FAILED, t); + arkProcessError(ark_mem, ARK_RHSFUNC_FAIL, __LINE__, __func__, __FILE__, + MSG_ARK_RHSFUNC_FAILED, t); return (ARK_RHSFUNC_FAIL); } @@ -1839,12 +1838,14 @@ int mriStep_TakeStepMRIGARK(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPt time step (so nothing can be leveraged). */ if (ark_mem->fn != NULL) { - retval = mriStep_FullRHS(ark_mem, ark_mem->tn, ark_mem->yn, ark_mem->fn, ARK_FULLRHS_START); + retval = mriStep_FullRHS(ark_mem, ark_mem->tn, ark_mem->yn, ark_mem->fn, + ARK_FULLRHS_START); if (retval) { return ARK_RHSFUNC_FAIL; } } else { - retval = mriStep_UpdateF0(ark_mem, step_mem, ark_mem->tn, ark_mem->yn, ARK_FULLRHS_START); + retval = mriStep_UpdateF0(ark_mem, step_mem, ark_mem->tn, ark_mem->yn, + ARK_FULLRHS_START); if (retval) { return ARK_RHSFUNC_FAIL; } } ark_mem->fn_is_current = SUNTRUE; @@ -2317,12 +2318,14 @@ int mriStep_TakeStepMRISR(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr) time step (so nothing can be leveraged). */ if (ark_mem->fn != NULL) { - retval = mriStep_FullRHS(ark_mem, ark_mem->tn, ark_mem->yn, ark_mem->fn, ARK_FULLRHS_START); + retval = mriStep_FullRHS(ark_mem, ark_mem->tn, ark_mem->yn, ark_mem->fn, + ARK_FULLRHS_START); if (retval) { return ARK_RHSFUNC_FAIL; } } else { - retval = mriStep_UpdateF0(ark_mem, step_mem, ark_mem->tn, ark_mem->yn, ARK_FULLRHS_START); + retval = mriStep_UpdateF0(ark_mem, step_mem, ark_mem->tn, ark_mem->yn, + ARK_FULLRHS_START); if (retval) { return ARK_RHSFUNC_FAIL; } } ark_mem->fn_is_current = SUNTRUE; @@ -2748,21 +2751,23 @@ int mriStep_TakeStepMERK(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr) } } -/* Evaluate the slow RHS function if needed. NOTE: we decide between calling the full RHS + /* Evaluate the slow RHS function if needed. NOTE: we decide between calling the full RHS function (if ark_mem->fn is non-NULL) versus just updating the stored value of Fse[0]. In either case, we use ARK_FULLRHS_START mode because MERK methods do not evaluate Fse at the end of the time step (so nothing can be leveraged). */ -if (ark_mem->fn != NULL) -{ - retval = mriStep_FullRHS(ark_mem, ark_mem->tn, ark_mem->yn, ark_mem->fn, ARK_FULLRHS_START); - if (retval) { return ARK_RHSFUNC_FAIL; } -} -else -{ - retval = mriStep_UpdateF0(ark_mem, step_mem, ark_mem->tn, ark_mem->yn, ARK_FULLRHS_START); - if (retval) { return ARK_RHSFUNC_FAIL; } -} -ark_mem->fn_is_current = SUNTRUE; + if (ark_mem->fn != NULL) + { + retval = mriStep_FullRHS(ark_mem, ark_mem->tn, ark_mem->yn, ark_mem->fn, + ARK_FULLRHS_START); + if (retval) { return ARK_RHSFUNC_FAIL; } + } + else + { + retval = mriStep_UpdateF0(ark_mem, step_mem, ark_mem->tn, ark_mem->yn, + ARK_FULLRHS_START); + if (retval) { return ARK_RHSFUNC_FAIL; } + } + ark_mem->fn_is_current = SUNTRUE; #ifdef SUNDIALS_DEBUG printf(" MRIStep step %li, stage 0, h = %" RSYM ", t_n = %" RSYM "\n", From 5e3e7b975482795e9d4dc5fb6c9deab5005685aa Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Wed, 27 Nov 2024 22:08:03 -0600 Subject: [PATCH 268/286] Updated submodule commit --- test/answers | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/answers b/test/answers index da404c61c7..0a8b87cd50 160000 --- a/test/answers +++ b/test/answers @@ -1 +1 @@ -Subproject commit da404c61c7b8eb2fb575e22a1b8578018ff1d076 +Subproject commit 0a8b87cd5062ee4cc9ebc0909b05fc3b40329c21 From 18ca63301db4b3d054fa91d206f411e3c387a2f0 Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Wed, 27 Nov 2024 22:31:31 -0600 Subject: [PATCH 269/286] Updated submodule commit --- test/answers | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/answers b/test/answers index 0a8b87cd50..a3668d9a5e 160000 --- a/test/answers +++ b/test/answers @@ -1 +1 @@ -Subproject commit 0a8b87cd5062ee4cc9ebc0909b05fc3b40329c21 +Subproject commit a3668d9a5e3c9e605dd497158925907bbf60434b From 24875f37abafbbb303e55f21379e366a3789451a Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Sun, 1 Dec 2024 10:15:43 -0600 Subject: [PATCH 270/286] Updated submodule commit --- test/answers | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/answers b/test/answers index a3668d9a5e..75bd7fe761 160000 --- a/test/answers +++ b/test/answers @@ -1 +1 @@ -Subproject commit a3668d9a5e3c9e605dd497158925907bbf60434b +Subproject commit 75bd7fe7617b1bad926f8203eac32430890880e3 From 5c11055ab84fcb99b605cbfa118754eb2affad12 Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Sun, 1 Dec 2024 22:35:09 -0600 Subject: [PATCH 271/286] Updated .out files for Jenkins --- ...sion_reaction_p_--np_2_2_--mri-arkstep.out | 76 ++++++------- ...reaction_p_--np_2_2_--mri-cvode-global.out | 71 ++++++------ ..._reaction_p_--np_2_2_--mri-cvode-local.out | 75 +++++++------ .../ark_heat2D_hypre_pfmg_mri_--np_2_2.out | 17 ++- .../arkode/CXX_serial/ark_kpr_nestedmri.out | 2 +- .../ark_brusselator1D_imexmri_0_0.001.out | 2 +- .../ark_brusselator1D_imexmri_2_0.001.out | 2 +- .../ark_brusselator1D_imexmri_3_0.001.out | 2 +- .../ark_brusselator1D_imexmri_4_0.001.out | 2 +- .../ark_brusselator1D_imexmri_5_0.001.out | 2 +- .../ark_brusselator1D_imexmri_6_0.001.out | 2 +- .../ark_brusselator1D_imexmri_7_0.001.out | 2 +- .../C_serial/ark_brusselator_1D_mri.out | 2 +- .../arkode/C_serial/ark_brusselator_mri.out | 2 +- .../ark_kpr_mri_10_4_0.001_-100_100_0.5_1.out | 82 +++++++------- .../C_serial/ark_kpr_mri_11_2_0.001.out | 94 ++++++++-------- .../C_serial/ark_kpr_mri_12_3_0.005.out | 102 +++++++++--------- .../arkode/C_serial/ark_kpr_mri_13_4_0.01.out | 48 ++++----- .../arkode/C_serial/ark_kpr_mri_1_0_0.01.out | 2 +- .../arkode/C_serial/ark_kpr_mri_2_4_0.002.out | 62 +++++------ .../arkode/C_serial/ark_kpr_mri_3_2_0.001.out | 2 +- .../arkode/C_serial/ark_kpr_mri_4_3_0.001.out | 2 +- .../arkode/C_serial/ark_kpr_mri_5_4_0.001.out | 82 +++++++------- .../arkode/C_serial/ark_kpr_mri_6_5_0.001.out | 80 +++++++------- .../arkode/C_serial/ark_kpr_mri_7_2_0.002.out | 102 +++++++++--------- .../ark_kpr_mri_8_3_0.001_-100_100_0.5_1.out | 102 +++++++++--------- .../ark_kpr_mri_9_3_0.001_-100_100_0.5_1.out | 2 +- .../arkode/C_serial/ark_onewaycouple_mri.out | 2 +- .../C_serial/ark_reaction_diffusion_mri.out | 2 +- .../arkode/C_serial/ark_twowaycouple_mri.out | 2 +- ..._mriadapt_--rtol_0.000004_--scontrol_0.out | 2 +- ...-hs_0.002_--rtol_0.000004_--scontrol_0.out | 2 +- 32 files changed, 514 insertions(+), 517 deletions(-) diff --git a/examples/arkode/CXX_parallel/ark_diffusion_reaction_p_--np_2_2_--mri-arkstep.out b/examples/arkode/CXX_parallel/ark_diffusion_reaction_p_--np_2_2_--mri-arkstep.out index 5f04385a88..b899fc5983 100644 --- a/examples/arkode/CXX_parallel/ark_diffusion_reaction_p_--np_2_2_--mri-arkstep.out +++ b/examples/arkode/CXX_parallel/ark_diffusion_reaction_p_--np_2_2_--mri-arkstep.out @@ -1,23 +1,23 @@ 2D Heat PDE test problem: - --------------------------------- + --------------------------------- nprocs = 4 npx = 2 npy = 2 - --------------------------------- + --------------------------------- Dux = 0.001 Duy = 0.001 Dvx = 0.001 Dvy = 0.001 A = 1 B = 3 - --------------------------------- + --------------------------------- tf = 10 xl = -0.5 xu = 0.5 yl = -0.5 yu = 0.5 - --------------------------------- + --------------------------------- nx = 128 ny = 128 dx = 0.0078125 @@ -28,7 +28,7 @@ ie (proc 0) = 63 je (proc 0) = 0 je (proc 0) = 63 - --------------------------------- + --------------------------------- rtol_slow = 0.0001 atol_slow = 1e-08 rtol_fast = 1e-05 @@ -38,62 +38,62 @@ fixed h fast = 0 controller = 0 linear = 1 - --------------------------------- + --------------------------------- linear solver = PCG lin iters = 10 eps lin = 0 prec = 1 msbp = 0 - --------------------------------- + --------------------------------- output = 1 - --------------------------------- + --------------------------------- - t ||u||_rms + t ||u||_rms ---------------------------------------------- 0.000000000000000e+00 3.172144385112383e+00 - 5.000000000000000e-01 3.136716116752151e+00 - 1.000000000000000e+00 3.125028912300580e+00 - 1.500000000000000e+00 3.152560626843121e+00 - 2.000000000000000e+00 3.251993026870305e+00 - 2.500000000000000e+00 3.404745650420647e+00 - 3.000000000000000e+00 3.570247335718721e+00 - 3.500000000000000e+00 3.700181440066816e+00 - 4.000000000000000e+00 3.695239773881522e+00 - 4.500000000000000e+00 3.628545878812146e+00 - 5.000000000000000e+00 3.475390052955260e+00 - 5.500000000000000e+00 3.343649932324244e+00 - 6.000000000000000e+00 3.233461171842096e+00 - 6.500000000000000e+00 3.081704256364488e+00 - 7.000000000000000e+00 2.889974509887209e+00 - 7.500000000000000e+00 2.836697779989570e+00 - 8.000000000000000e+00 2.897726300079596e+00 - 8.500000000000000e+00 3.139640427884362e+00 - 9.000000000000000e+00 3.441880223463777e+00 - 9.500000000000000e+00 3.740116847697612e+00 - 1.000000000000000e+01 4.014265455712714e+00 + 5.000000000000000e-01 3.136741760652099e+00 + 1.000000000000000e+00 3.125063175301384e+00 + 1.500000000000000e+00 3.152612863412849e+00 + 2.000000000000000e+00 3.252046440476493e+00 + 2.500000000000000e+00 3.404770348632562e+00 + 3.000000000000000e+00 3.570197872739926e+00 + 3.500000000000000e+00 3.699979354348030e+00 + 4.000000000000000e+00 3.694673808835031e+00 + 4.500000000000000e+00 3.628192806293943e+00 + 5.000000000000000e+00 3.475181810897179e+00 + 5.500000000000000e+00 3.343883397076133e+00 + 6.000000000000000e+00 3.234019997282326e+00 + 6.500000000000000e+00 3.082396794749013e+00 + 7.000000000000000e+00 2.890645249288640e+00 + 7.500000000000000e+00 2.837264083079534e+00 + 8.000000000000000e+00 2.898204488519986e+00 + 8.500000000000000e+00 3.140043990739560e+00 + 9.000000000000000e+00 3.442235032838624e+00 + 9.500000000000000e+00 3.740410563929244e+00 + 1.000000000000000e+01 4.014486664210758e+00 ---------------------------------------------- Final integrator statistics: Slow Integrator: Steps = 132 - RHS diffusion = 773 + RHS diffusion = 792 NLS iters = 396 NLS fails = 0 - LS iters = 2639 + LS iters = 2648 LS fails = 0 LS setups = 0 - LS RHS evals = 2639 - Jv products = 2639 + LS RHS evals = 2648 + Jv products = 2648 Avg NLS iters per step attempt = 3.000000 - Avg LS iters per NLS iter = 6.664141 + Avg LS iters per NLS iter = 6.686869 Preconditioner setups = 0 - Preconditioner solves = 2639 + Preconditioner solves = 2648 Fast Integrator: - Steps = 495 - Step attempts = 495 + Steps = 470 + Step attempts = 470 Error test fails = 0 - RHS reaction = 1902 + RHS reaction = 1959 diff --git a/examples/arkode/CXX_parallel/ark_diffusion_reaction_p_--np_2_2_--mri-cvode-global.out b/examples/arkode/CXX_parallel/ark_diffusion_reaction_p_--np_2_2_--mri-cvode-global.out index 1d47d636e7..841bdda608 100644 --- a/examples/arkode/CXX_parallel/ark_diffusion_reaction_p_--np_2_2_--mri-cvode-global.out +++ b/examples/arkode/CXX_parallel/ark_diffusion_reaction_p_--np_2_2_--mri-cvode-global.out @@ -1,23 +1,23 @@ 2D Heat PDE test problem: - --------------------------------- + --------------------------------- nprocs = 4 npx = 2 npy = 2 - --------------------------------- + --------------------------------- Dux = 0.001 Duy = 0.001 Dvx = 0.001 Dvy = 0.001 A = 1 B = 3 - --------------------------------- + --------------------------------- tf = 10 xl = -0.5 xu = 0.5 yl = -0.5 yu = 0.5 - --------------------------------- + --------------------------------- nx = 128 ny = 128 dx = 0.0078125 @@ -28,7 +28,7 @@ ie (proc 0) = 63 je (proc 0) = 0 je (proc 0) = 63 - --------------------------------- + --------------------------------- rtol_slow = 0.0001 atol_slow = 1e-08 rtol_fast = 1e-05 @@ -38,59 +38,59 @@ fixed h fast = 0 controller = 0 linear = 1 - --------------------------------- + --------------------------------- linear solver = PCG lin iters = 10 eps lin = 0 prec = 1 msbp = 0 - --------------------------------- + --------------------------------- output = 1 - --------------------------------- + --------------------------------- - t ||u||_rms + t ||u||_rms ---------------------------------------------- 0.000000000000000e+00 3.172144385112383e+00 - 5.000000000000000e-01 3.136696996015633e+00 - 1.000000000000000e+00 3.125023309552764e+00 - 1.500000000000000e+00 3.152584771052598e+00 - 2.000000000000000e+00 3.252032392844841e+00 - 2.500000000000000e+00 3.404766961732514e+00 - 3.000000000000000e+00 3.570225378226986e+00 - 3.500000000000000e+00 3.700073897359325e+00 - 4.000000000000000e+00 3.694920292161422e+00 - 4.500000000000000e+00 3.628220467849570e+00 - 5.000000000000000e+00 3.475064822948501e+00 - 5.500000000000000e+00 3.343406087685922e+00 - 6.000000000000000e+00 3.233285038314854e+00 - 6.500000000000000e+00 3.081558692824315e+00 - 7.000000000000000e+00 2.889915001737479e+00 - 7.500000000000000e+00 2.836750836297845e+00 - 8.000000000000000e+00 2.897946724170101e+00 - 8.500000000000000e+00 3.139887229890297e+00 - 9.000000000000000e+00 3.442102260946054e+00 - 9.500000000000000e+00 3.740306358594533e+00 - 1.000000000000000e+01 4.014411828428858e+00 + 5.000000000000000e-01 3.136722629482694e+00 + 1.000000000000000e+00 3.125057552043193e+00 + 1.500000000000000e+00 3.152636979427879e+00 + 2.000000000000000e+00 3.252085798917689e+00 + 2.500000000000000e+00 3.404791659743048e+00 + 3.000000000000000e+00 3.570175896142432e+00 + 3.500000000000000e+00 3.699871775695501e+00 + 4.000000000000000e+00 3.694354328938385e+00 + 4.500000000000000e+00 3.627867445226587e+00 + 5.000000000000000e+00 3.474857036434463e+00 + 5.500000000000000e+00 3.343639835515735e+00 + 6.000000000000000e+00 3.233843797982778e+00 + 6.500000000000000e+00 3.082250805521703e+00 + 7.000000000000000e+00 2.890585190235564e+00 + 7.500000000000000e+00 2.837315402792927e+00 + 8.000000000000000e+00 2.898424997635716e+00 + 8.500000000000000e+00 3.140291193581129e+00 + 9.000000000000000e+00 3.442457501250356e+00 + 9.500000000000000e+00 3.740600449220181e+00 + 1.000000000000000e+01 4.014633315935895e+00 ---------------------------------------------- Final integrator statistics: Slow Integrator: Steps = 132 - RHS diffusion = 773 + RHS diffusion = 792 NLS iters = 396 NLS fails = 0 - LS iters = 2630 + LS iters = 2645 LS fails = 0 LS setups = 0 - LS RHS evals = 2630 - Jv products = 2630 + LS RHS evals = 2645 + Jv products = 2645 Avg NLS iters per step attempt = 3.000000 - Avg LS iters per NLS iter = 6.641414 + Avg LS iters per NLS iter = 6.679293 Preconditioner setups = 0 - Preconditioner solves = 2630 + Preconditioner solves = 2645 Fast Integrator: Steps = 2057 @@ -98,4 +98,3 @@ Fast Integrator: RHS reaction = 4991 NLS iters = 3803 NLS fails = 0 - diff --git a/examples/arkode/CXX_parallel/ark_diffusion_reaction_p_--np_2_2_--mri-cvode-local.out b/examples/arkode/CXX_parallel/ark_diffusion_reaction_p_--np_2_2_--mri-cvode-local.out index 395fce5774..896e702868 100644 --- a/examples/arkode/CXX_parallel/ark_diffusion_reaction_p_--np_2_2_--mri-cvode-local.out +++ b/examples/arkode/CXX_parallel/ark_diffusion_reaction_p_--np_2_2_--mri-cvode-local.out @@ -1,23 +1,23 @@ 2D Heat PDE test problem: - --------------------------------- + --------------------------------- nprocs = 4 npx = 2 npy = 2 - --------------------------------- + --------------------------------- Dux = 0.001 Duy = 0.001 Dvx = 0.001 Dvy = 0.001 A = 1 B = 3 - --------------------------------- + --------------------------------- tf = 10 xl = -0.5 xu = 0.5 yl = -0.5 yu = 0.5 - --------------------------------- + --------------------------------- nx = 128 ny = 128 dx = 0.0078125 @@ -28,7 +28,7 @@ ie (proc 0) = 63 je (proc 0) = 0 je (proc 0) = 63 - --------------------------------- + --------------------------------- rtol_slow = 0.0001 atol_slow = 1e-08 rtol_fast = 1e-05 @@ -38,64 +38,63 @@ fixed h fast = 0 controller = 0 linear = 1 - --------------------------------- + --------------------------------- linear solver = PCG lin iters = 10 eps lin = 0 prec = 1 msbp = 0 - --------------------------------- + --------------------------------- output = 1 - --------------------------------- + --------------------------------- - t ||u||_rms + t ||u||_rms ---------------------------------------------- 0.000000000000000e+00 3.172144385112383e+00 - 5.000000000000000e-01 3.136702506772491e+00 - 1.000000000000000e+00 3.125019831337103e+00 - 1.500000000000000e+00 3.152553269284723e+00 - 2.000000000000000e+00 3.251969494381176e+00 - 2.500000000000000e+00 3.404673933063467e+00 - 3.000000000000000e+00 3.570103152366130e+00 - 3.500000000000000e+00 3.699922896883436e+00 - 4.000000000000000e+00 3.694726101643302e+00 - 4.500000000000000e+00 3.628066610591935e+00 - 5.000000000000000e+00 3.474943316767684e+00 - 5.500000000000000e+00 3.343373209172369e+00 - 6.000000000000000e+00 3.233355958070737e+00 - 6.500000000000000e+00 3.081713311546319e+00 - 7.000000000000000e+00 2.890064956811404e+00 - 7.500000000000000e+00 2.836866861961995e+00 - 8.000000000000000e+00 2.897962217732046e+00 - 8.500000000000000e+00 3.139852442835502e+00 - 9.000000000000000e+00 3.442051478499238e+00 - 9.500000000000000e+00 3.740244912270594e+00 - 1.000000000000000e+01 4.014337597219764e+00 + 5.000000000000000e-01 3.136728141568426e+00 + 1.000000000000000e+00 3.125054078969577e+00 + 1.500000000000000e+00 3.152605475502359e+00 + 2.000000000000000e+00 3.252022912635215e+00 + 2.500000000000000e+00 3.404698691374345e+00 + 3.000000000000000e+00 3.570053772321209e+00 + 3.500000000000000e+00 3.699720878679964e+00 + 4.000000000000000e+00 3.694158055925352e+00 + 4.500000000000000e+00 3.627712121494570e+00 + 5.000000000000000e+00 3.474734332229006e+00 + 5.500000000000000e+00 3.343606665593759e+00 + 6.000000000000000e+00 3.233915182257314e+00 + 6.500000000000000e+00 3.082406235095853e+00 + 7.000000000000000e+00 2.890736346480939e+00 + 7.500000000000000e+00 2.837432523592805e+00 + 8.000000000000000e+00 2.898441382813875e+00 + 8.500000000000000e+00 3.140257099040540e+00 + 9.000000000000000e+00 3.442407273754965e+00 + 9.500000000000000e+00 3.740539414769367e+00 + 1.000000000000000e+01 4.014559307692970e+00 ---------------------------------------------- Final integrator statistics: Slow Integrator: Steps = 132 - RHS diffusion = 773 + RHS diffusion = 792 NLS iters = 396 NLS fails = 0 - LS iters = 2645 + LS iters = 2625 LS fails = 0 LS setups = 0 - LS RHS evals = 2645 - Jv products = 2645 + LS RHS evals = 2625 + Jv products = 2625 Avg NLS iters per step attempt = 3.000000 - Avg LS iters per NLS iter = 6.679293 + Avg LS iters per NLS iter = 6.628788 Preconditioner setups = 0 - Preconditioner solves = 2645 + Preconditioner solves = 2625 Fast Integrator: - Steps = 2001 - Error test fails = 398 + Steps = 2002 + Error test fails = 397 RHS reaction = 4898 NLS iters = 3710 NLS fails = 0 - diff --git a/examples/arkode/CXX_parhyp/ark_heat2D_hypre_pfmg_mri_--np_2_2.out b/examples/arkode/CXX_parhyp/ark_heat2D_hypre_pfmg_mri_--np_2_2.out index bd49261abd..89830fcbdd 100644 --- a/examples/arkode/CXX_parhyp/ark_heat2D_hypre_pfmg_mri_--np_2_2.out +++ b/examples/arkode/CXX_parhyp/ark_heat2D_hypre_pfmg_mri_--np_2_2.out @@ -1,10 +1,10 @@ 2D Heat PDE test problem: - --------------------------------- + --------------------------------- nprocs = 4 npx = 2 npy = 2 - --------------------------------- + --------------------------------- kx = 1 ky = 1 ax = 1 @@ -19,7 +19,7 @@ nyl (proc 0) = 32 dx = 0.015873 dy = 0.015873 - --------------------------------- + --------------------------------- rtol = 1e-05 atol = 1e-10 sorder = 3 @@ -28,18 +28,18 @@ hs = 0.001 controller = 0 linear = 0 - --------------------------------- + --------------------------------- lin iters = 10 eps lins = -1 prectype = 1 msbp = 0 pfmg_relax = 2 pfmg_nrelax = 2 - --------------------------------- + --------------------------------- output = 1 - --------------------------------- + --------------------------------- - t ||u||_rms + t ||u||_rms ---------------------------------------------- 0.000000000000000e+00 3.691406249999997e-01 1.000000000000000e-01 5.162014241945451e-02 @@ -75,7 +75,7 @@ Final fast integrator statistics: Steps = 3003 Step attempts = 3003 Error test fails = 0 - RHS evals = 29862 + RHS evals = 30862 NLS iters = 17842 NLS fails = 0 LS iters = 10048 @@ -89,4 +89,3 @@ Final fast integrator statistics: Preconditioner setups = 0 Preconditioner solves = 0 PFMG iters = 10603 - diff --git a/examples/arkode/CXX_serial/ark_kpr_nestedmri.out b/examples/arkode/CXX_serial/ark_kpr_nestedmri.out index f45a637e61..dacfc6fd90 100644 --- a/examples/arkode/CXX_serial/ark_kpr_nestedmri.out +++ b/examples/arkode/CXX_serial/ark_kpr_nestedmri.out @@ -48,4 +48,4 @@ Final Solver Statistics: Fast steps = 129455 (attempts = 144940, fails = 15485) u error = 0.000228112, v error = 8.70956e-05, total error = 0.000169225 Relative accuracy = 6.75352 - Total RHS evals: Fse = 240, Fsi = 0, Fme = 4187, Fmi = 0, Ff = 709217 + Total RHS evals: Fse = 240, Fsi = 0, Fme = 4235, Fmi = 0, Ff = 710133 diff --git a/examples/arkode/C_serial/ark_brusselator1D_imexmri_0_0.001.out b/examples/arkode/C_serial/ark_brusselator1D_imexmri_0_0.001.out index cadd7e5310..62373f3629 100644 --- a/examples/arkode/C_serial/ark_brusselator1D_imexmri_0_0.001.out +++ b/examples/arkode/C_serial/ark_brusselator1D_imexmri_0_0.001.out @@ -30,7 +30,7 @@ Final Solver Statistics: Slow Steps: nsts = 10001 Fast Steps: nstf = 120012 - Total RHS evals: Fs = 30004, Ff = 864983 + Total RHS evals: Fs = 30004, Ff = 874984 Fast Newton iters = 504937 Fast Newton conv fails = 0 Fast Jacobian evals = 2308 diff --git a/examples/arkode/C_serial/ark_brusselator1D_imexmri_2_0.001.out b/examples/arkode/C_serial/ark_brusselator1D_imexmri_2_0.001.out index 2f5cb90061..c9dfa5f415 100644 --- a/examples/arkode/C_serial/ark_brusselator1D_imexmri_2_0.001.out +++ b/examples/arkode/C_serial/ark_brusselator1D_imexmri_2_0.001.out @@ -30,7 +30,7 @@ Final Solver Statistics: Slow Steps: nsts = 10001 Fast Steps: nstf = 120012 - Total RHS evals: Fs = 68877, Ff = 360046 + Total RHS evals: Fs = 68877, Ff = 370047 Slow Newton iters = 38883 Slow Newton conv fails = 0 Slow Jacobian evals = 501 diff --git a/examples/arkode/C_serial/ark_brusselator1D_imexmri_3_0.001.out b/examples/arkode/C_serial/ark_brusselator1D_imexmri_3_0.001.out index 30dba6ddc2..189c065b52 100644 --- a/examples/arkode/C_serial/ark_brusselator1D_imexmri_3_0.001.out +++ b/examples/arkode/C_serial/ark_brusselator1D_imexmri_3_0.001.out @@ -30,7 +30,7 @@ Final Solver Statistics: Slow Steps: nsts = 10001 Fast Steps: nstf = 120012 - Total RHS evals: Fs = 68877, Ff = 840121 + Total RHS evals: Fs = 68877, Ff = 850122 Slow Newton iters = 38883 Slow Newton conv fails = 0 Slow Jacobian evals = 501 diff --git a/examples/arkode/C_serial/ark_brusselator1D_imexmri_4_0.001.out b/examples/arkode/C_serial/ark_brusselator1D_imexmri_4_0.001.out index 7059273d48..e2baaa98f9 100644 --- a/examples/arkode/C_serial/ark_brusselator1D_imexmri_4_0.001.out +++ b/examples/arkode/C_serial/ark_brusselator1D_imexmri_4_0.001.out @@ -30,7 +30,7 @@ Final Solver Statistics: Slow Steps: nsts = 10001 Fast Steps: nstf = 110011 - Total RHS evals: Fse = 40005, Fsi = 78888, Ff = 330043 + Total RHS evals: Fse = 40005, Fsi = 78888, Ff = 340044 Slow Newton iters = 38883 Slow Newton conv fails = 0 Slow Jacobian evals = 501 diff --git a/examples/arkode/C_serial/ark_brusselator1D_imexmri_5_0.001.out b/examples/arkode/C_serial/ark_brusselator1D_imexmri_5_0.001.out index 827c560b02..569265cbfd 100644 --- a/examples/arkode/C_serial/ark_brusselator1D_imexmri_5_0.001.out +++ b/examples/arkode/C_serial/ark_brusselator1D_imexmri_5_0.001.out @@ -30,7 +30,7 @@ Final Solver Statistics: Slow Steps: nsts = 10001 Fast Steps: nstf = 110011 - Total RHS evals: Fse = 40005, Fsi = 78888, Ff = 1024335 + Total RHS evals: Fse = 40005, Fsi = 78888, Ff = 1034336 Slow Newton iters = 38883 Slow Newton conv fails = 0 Slow Jacobian evals = 501 diff --git a/examples/arkode/C_serial/ark_brusselator1D_imexmri_6_0.001.out b/examples/arkode/C_serial/ark_brusselator1D_imexmri_6_0.001.out index 79287bd749..71419632eb 100644 --- a/examples/arkode/C_serial/ark_brusselator1D_imexmri_6_0.001.out +++ b/examples/arkode/C_serial/ark_brusselator1D_imexmri_6_0.001.out @@ -30,7 +30,7 @@ Final Solver Statistics: Slow Steps: nsts = 10001 Fast Steps: nstf = 130013 - Total RHS evals: Fse = 60007, Fsi = 118894, Ff = 520062 + Total RHS evals: Fse = 60007, Fsi = 118894, Ff = 530063 Slow Newton iters = 58887 Slow Newton conv fails = 0 Slow Jacobian evals = 501 diff --git a/examples/arkode/C_serial/ark_brusselator1D_imexmri_7_0.001.out b/examples/arkode/C_serial/ark_brusselator1D_imexmri_7_0.001.out index c8dd757582..265bb4696b 100644 --- a/examples/arkode/C_serial/ark_brusselator1D_imexmri_7_0.001.out +++ b/examples/arkode/C_serial/ark_brusselator1D_imexmri_7_0.001.out @@ -30,7 +30,7 @@ Final Solver Statistics: Slow Steps: nsts = 10001 Fast Steps: nstf = 130013 - Total RHS evals: Fse = 60007, Fsi = 118894, Ff = 1936011 + Total RHS evals: Fse = 60007, Fsi = 118894, Ff = 1946012 Slow Newton iters = 58887 Slow Newton conv fails = 0 Slow Jacobian evals = 501 diff --git a/examples/arkode/C_serial/ark_brusselator_1D_mri.out b/examples/arkode/C_serial/ark_brusselator_1D_mri.out index b1968f6e9d..0af99eff68 100644 --- a/examples/arkode/C_serial/ark_brusselator_1D_mri.out +++ b/examples/arkode/C_serial/ark_brusselator_1D_mri.out @@ -112,7 +112,7 @@ Final Solver Statistics: Slow Steps: nsts = 1001 Fast Steps: nstf = 3171 (attempted = 3171) - Total RHS evals: Fs = 3004, Ff = 30611 + Total RHS evals: Fs = 3004, Ff = 31612 Total number of fast error test failures = 0 Total linear solver setups = 3118 Total RHS evals for setting up the linear system = 0 diff --git a/examples/arkode/C_serial/ark_brusselator_mri.out b/examples/arkode/C_serial/ark_brusselator_mri.out index 602c2e4177..61ce63eca1 100644 --- a/examples/arkode/C_serial/ark_brusselator_mri.out +++ b/examples/arkode/C_serial/ark_brusselator_mri.out @@ -31,4 +31,4 @@ Brusselator ODE test problem: Final Solver Statistics: Steps: nsts = 81, nstf = 2187 - Total RHS evals: Fs = 244, Ff = 6581 + Total RHS evals: Fs = 244, Ff = 6662 diff --git a/examples/arkode/C_serial/ark_kpr_mri_10_4_0.001_-100_100_0.5_1.out b/examples/arkode/C_serial/ark_kpr_mri_10_4_0.001_-100_100_0.5_1.out index 4a6b542e90..9e9c2d786e 100644 --- a/examples/arkode/C_serial/ark_kpr_mri_10_4_0.001_-100_100_0.5_1.out +++ b/examples/arkode/C_serial/ark_kpr_mri_10_4_0.001_-100_100_0.5_1.out @@ -22,52 +22,52 @@ Multirate nonlinear Kvaerno-Prothero-Robinson test problem: 0.800000 1.161186 1.374632 1.20e-11 2.83e-12 0.900000 1.144904 1.245763 1.23e-11 3.18e-12 1.000000 1.127010 1.691839 1.28e-11 2.23e-12 - 1.100000 1.107609 1.000489 1.13e-11 2.05e-12 - 1.200000 1.086821 1.677552 9.92e-12 2.03e-12 - 1.300000 1.064777 1.277775 7.66e-12 2.00e-12 - 1.400000 1.041625 1.342455 6.65e-12 2.48e-12 - 1.500000 1.017531 1.642940 6.43e-12 5.92e-12 - 1.600000 0.992673 1.012112 4.49e-12 3.23e-12 - 1.700000 0.967253 1.714058 3.11e-12 2.87e-12 - 1.800000 0.941488 1.183867 5.74e-14 3.89e-12 - 1.900000 0.915617 1.437465 1.88e-12 5.63e-12 - 2.000000 0.889903 1.577082 4.65e-12 9.04e-12 - 2.100000 0.864625 1.056467 6.53e-12 7.20e-12 - 2.200000 0.840089 1.730920 7.39e-12 4.70e-12 - 2.300000 0.816616 1.101047 1.16e-11 3.16e-12 - 2.400000 0.794546 1.525051 1.48e-11 8.77e-12 - 2.500000 0.774227 1.496993 1.92e-11 1.10e-11 - 2.600000 0.756013 1.126857 2.04e-11 1.34e-11 - 2.700000 0.740246 1.727536 2.11e-11 7.02e-12 - 2.800000 0.727247 1.038393 2.44e-11 6.35e-13 - 2.900000 0.717301 1.600759 2.66e-11 1.09e-11 - 3.000000 0.710636 1.406380 2.78e-11 1.16e-11 - 3.100000 0.707412 1.214353 2.84e-11 2.03e-11 - 3.200000 0.707709 1.704026 2.84e-11 9.86e-12 - 3.300000 0.711520 1.004391 2.77e-11 7.02e-12 - 3.400000 0.718750 1.661225 2.61e-11 1.05e-11 - 3.500000 0.729227 1.310102 2.42e-11 1.14e-11 - 3.600000 0.742712 1.310080 2.16e-11 2.60e-11 - 3.700000 0.758914 1.661237 1.99e-11 1.39e-11 - 3.800000 0.777506 1.004387 1.67e-11 1.43e-11 - 3.900000 0.798144 1.704019 1.39e-11 5.96e-12 - 4.000000 0.820474 1.214374 1.05e-11 1.12e-11 - 4.100000 0.844149 1.406358 7.58e-12 2.96e-11 - 4.200000 0.868832 1.600774 5.04e-12 4.97e-12 - 4.300000 0.894204 1.038382 2.82e-12 1.00e-11 - 4.400000 0.919964 1.727533 1.81e-12 1.06e-11 - 4.500000 0.945834 1.126875 1.89e-12 5.36e-12 - 4.600000 0.971557 1.496974 3.73e-12 1.53e-11 - 4.700000 0.996898 1.525070 5.90e-12 8.98e-13 - 4.800000 1.021641 1.101030 7.16e-12 2.06e-12 - 4.900000 1.045589 1.730922 6.80e-12 8.94e-12 + 1.100000 1.107609 1.000489 1.13e-11 1.92e-12 + 1.200000 1.086821 1.677552 9.92e-12 2.55e-12 + 1.300000 1.064777 1.277775 7.66e-12 1.74e-13 + 1.400000 1.041625 1.342455 6.65e-12 7.06e-13 + 1.500000 1.017531 1.642940 6.43e-12 2.73e-12 + 1.600000 0.992673 1.012112 4.49e-12 1.24e-12 + 1.700000 0.967253 1.714058 3.11e-12 3.19e-12 + 1.800000 0.941488 1.183867 5.76e-14 2.22e-13 + 1.900000 0.915617 1.437465 1.88e-12 1.29e-12 + 2.000000 0.889903 1.577082 4.65e-12 2.09e-12 + 2.100000 0.864625 1.056467 6.53e-12 1.44e-12 + 2.200000 0.840089 1.730920 7.39e-12 2.63e-12 + 2.300000 0.816616 1.101047 1.16e-11 1.62e-12 + 2.400000 0.794546 1.525051 1.48e-11 7.30e-13 + 2.500000 0.774227 1.496993 1.92e-11 2.40e-13 + 2.600000 0.756013 1.126857 2.04e-11 2.57e-12 + 2.700000 0.740246 1.727536 2.11e-11 8.85e-13 + 2.800000 0.727247 1.038393 2.44e-11 3.90e-12 + 2.900000 0.717301 1.600759 2.66e-11 7.89e-13 + 3.000000 0.710636 1.406380 2.78e-11 2.46e-12 + 3.100000 0.707412 1.214353 2.84e-11 4.12e-12 + 3.200000 0.707709 1.704026 2.84e-11 1.38e-12 + 3.300000 0.711520 1.004391 2.77e-11 6.21e-12 + 3.400000 0.718750 1.661225 2.61e-11 2.33e-12 + 3.500000 0.729227 1.310102 2.42e-11 4.77e-12 + 3.600000 0.742712 1.310080 2.16e-11 4.95e-12 + 3.700000 0.758914 1.661237 1.99e-11 2.79e-12 + 3.800000 0.777506 1.004387 1.67e-11 6.97e-12 + 3.900000 0.798144 1.704019 1.39e-11 2.45e-12 + 4.000000 0.820474 1.214374 1.05e-11 5.41e-12 + 4.100000 0.844149 1.406358 7.59e-12 8.30e-12 + 4.200000 0.868832 1.600774 5.04e-12 1.14e-11 + 4.300000 0.894204 1.038382 2.82e-12 3.27e-13 + 4.400000 0.919964 1.727533 1.81e-12 1.24e-11 + 4.500000 0.945834 1.126875 1.89e-12 8.42e-13 + 4.600000 0.971557 1.496974 3.73e-12 6.99e-12 + 4.700000 0.996898 1.525070 5.90e-12 7.03e-12 + 4.800000 1.021641 1.101030 7.16e-12 1.43e-12 + 4.900000 1.045589 1.730922 6.80e-12 9.68e-12 5.000000 1.068565 1.056480 9.34e-12 3.23e-12 ------------------------------------------------------ Final Solver Statistics: Steps: nsts = 5000, nstf = 510000 - u error = 1.533e-11, v error = 9.500e-12, total error = 1.275e-11 - Total RHS evals: Fse = 30001, Fsi = 57555, Ff = 2040050 + u error = 1.533e-11, v error = 4.203e-12, total error = 1.124e-11 + Total RHS evals: Fse = 30001, Fsi = 57555, Ff = 2045050 Slow Newton iters = 52554 Slow Newton conv fails = 0 Slow Jacobian evals = 250 diff --git a/examples/arkode/C_serial/ark_kpr_mri_11_2_0.001.out b/examples/arkode/C_serial/ark_kpr_mri_11_2_0.001.out index 0e1f1aff7f..66ed6d890d 100644 --- a/examples/arkode/C_serial/ark_kpr_mri_11_2_0.001.out +++ b/examples/arkode/C_serial/ark_kpr_mri_11_2_0.001.out @@ -13,61 +13,61 @@ Multirate nonlinear Kvaerno-Prothero-Robinson test problem: ------------------------------------------------------ 0.000000 1.224745 1.732051 0.00e+00 0.00e+00 0.100000 1.223724 1.077464 3.33e-07 4.20e-08 - 0.200000 1.220669 1.551800 4.24e-07 8.82e-09 - 0.300000 1.215593 1.467737 1.15e-06 1.85e-08 - 0.400000 1.208524 1.154583 5.07e-07 2.01e-09 - 0.500000 1.199497 1.721908 2.65e-07 4.66e-08 - 0.600000 1.188557 1.023517 7.96e-08 1.16e-08 - 0.700000 1.175764 1.622750 3.38e-07 5.31e-08 - 0.800000 1.161186 1.374632 2.38e-07 5.04e-08 - 0.900000 1.144903 1.245763 5.34e-07 3.96e-08 - 1.000000 1.127010 1.691839 2.21e-07 7.06e-08 - 1.100000 1.107609 1.000489 4.62e-08 8.93e-09 - 1.200000 1.086820 1.677552 2.34e-07 8.40e-08 - 1.300000 1.064776 1.277775 2.44e-07 6.06e-08 - 1.400000 1.041625 1.342455 5.10e-07 6.65e-08 - 1.500000 1.017531 1.642940 6.50e-08 8.37e-08 - 1.600000 0.992673 1.012112 1.90e-07 2.98e-08 - 1.700000 0.967253 1.714058 6.43e-08 9.85e-08 - 1.800000 0.941487 1.183866 9.42e-07 6.17e-08 - 1.900000 0.915617 1.437465 5.51e-07 8.34e-08 - 2.000000 0.889902 1.577082 5.63e-07 9.25e-08 - 2.100000 0.864625 1.056467 3.79e-07 4.69e-08 - 2.200000 0.840089 1.730920 1.91e-07 1.00e-07 - 2.300000 0.816616 1.101047 4.88e-07 5.26e-08 - 2.400000 0.794545 1.525051 4.88e-07 8.97e-08 - 2.500000 0.774227 1.496993 1.22e-07 9.15e-08 - 2.600000 0.756012 1.126857 5.41e-07 5.80e-08 + 0.200000 1.220669 1.551800 4.24e-07 8.85e-09 + 0.300000 1.215593 1.467737 1.15e-06 1.86e-08 + 0.400000 1.208524 1.154583 5.07e-07 2.20e-09 + 0.500000 1.199497 1.721908 2.65e-07 4.68e-08 + 0.600000 1.188557 1.023517 7.96e-08 1.14e-08 + 0.700000 1.175764 1.622750 3.38e-07 5.33e-08 + 0.800000 1.161186 1.374632 2.38e-07 5.06e-08 + 0.900000 1.144903 1.245763 5.34e-07 3.98e-08 + 1.000000 1.127010 1.691839 2.21e-07 7.09e-08 + 1.100000 1.107609 1.000489 4.62e-08 9.12e-09 + 1.200000 1.086820 1.677552 2.34e-07 8.42e-08 + 1.300000 1.064776 1.277775 2.44e-07 6.08e-08 + 1.400000 1.041625 1.342455 5.10e-07 6.67e-08 + 1.500000 1.017531 1.642940 6.50e-08 8.39e-08 + 1.600000 0.992673 1.012112 1.90e-07 3.00e-08 + 1.700000 0.967253 1.714058 6.43e-08 9.87e-08 + 1.800000 0.941487 1.183866 9.42e-07 6.18e-08 + 1.900000 0.915617 1.437465 5.51e-07 8.36e-08 + 2.000000 0.889902 1.577082 5.63e-07 9.28e-08 + 2.100000 0.864625 1.056467 3.79e-07 4.72e-08 + 2.200000 0.840089 1.730920 1.91e-07 1.01e-07 + 2.300000 0.816616 1.101047 4.88e-07 5.28e-08 + 2.400000 0.794545 1.525051 4.88e-07 9.00e-08 + 2.500000 0.774227 1.496993 1.22e-07 9.18e-08 + 2.600000 0.756012 1.126857 5.41e-07 5.83e-08 2.700000 0.740246 1.727536 1.69e-07 1.03e-07 - 2.800000 0.727247 1.038393 2.16e-07 4.27e-08 - 2.900000 0.717301 1.600759 4.45e-07 9.79e-08 - 3.000000 0.710636 1.406379 1.65e-07 8.68e-08 - 3.100000 0.707412 1.214353 5.06e-07 6.83e-08 - 3.200000 0.707710 1.704026 1.90e-07 1.01e-07 - 3.300000 0.711519 1.004391 1.00e-07 3.71e-08 - 3.400000 0.718749 1.661225 2.14e-07 1.00e-07 - 3.500000 0.729226 1.310102 2.53e-07 7.91e-08 - 3.600000 0.742711 1.310080 3.52e-07 8.01e-08 - 3.700000 0.758914 1.661237 1.20e-08 9.86e-08 - 3.800000 0.777506 1.004387 1.70e-07 3.99e-08 + 2.800000 0.727247 1.038393 2.16e-07 4.30e-08 + 2.900000 0.717301 1.600759 4.45e-07 9.81e-08 + 3.000000 0.710636 1.406379 1.65e-07 8.71e-08 + 3.100000 0.707412 1.214353 5.06e-07 6.86e-08 + 3.200000 0.707710 1.704026 1.90e-07 1.02e-07 + 3.300000 0.711519 1.004391 1.00e-07 3.73e-08 + 3.400000 0.718749 1.661225 2.14e-07 1.01e-07 + 3.500000 0.729226 1.310102 2.53e-07 7.93e-08 + 3.600000 0.742711 1.310080 3.52e-07 8.04e-08 + 3.700000 0.758914 1.661237 1.20e-08 9.89e-08 + 3.800000 0.777506 1.004387 1.70e-07 4.01e-08 3.900000 0.798144 1.704018 1.75e-08 1.03e-07 - 4.000000 0.820473 1.214374 1.10e-06 7.07e-08 - 4.100000 0.844149 1.406358 4.60e-07 8.74e-08 - 4.200000 0.868832 1.600774 3.92e-07 9.77e-08 - 4.300000 0.894203 1.038382 3.30e-07 5.28e-08 - 4.400000 0.919964 1.727533 1.58e-07 1.08e-07 - 4.500000 0.945833 1.126875 6.42e-07 6.60e-08 - 4.600000 0.971557 1.496973 4.87e-07 9.60e-08 + 4.000000 0.820473 1.214374 1.10e-06 7.09e-08 + 4.100000 0.844149 1.406358 4.60e-07 8.77e-08 + 4.200000 0.868832 1.600774 3.92e-07 9.80e-08 + 4.300000 0.894203 1.038382 3.30e-07 5.31e-08 + 4.400000 0.919964 1.727533 1.58e-07 1.09e-07 + 4.500000 0.945833 1.126875 6.42e-07 6.63e-08 + 4.600000 0.971557 1.496973 4.87e-07 9.63e-08 4.700000 0.996897 1.525070 8.90e-07 1.01e-07 - 4.800000 1.021640 1.101030 4.60e-07 6.45e-08 + 4.800000 1.021640 1.101030 4.60e-07 6.49e-08 4.900000 1.045589 1.730922 3.00e-07 1.08e-07 - 5.000000 1.068565 1.056480 2.32e-07 5.02e-08 + 5.000000 1.068565 1.056480 2.32e-07 5.06e-08 ------------------------------------------------------ Final Solver Statistics: Steps: nsts = 5000, nstf = 935000 - u error = 4.409e-07, v error = 7.386e-08, total error = 3.161e-07 - Total RHS evals: Fse = 15001, Fsi = 32981, Ff = 1870050 + u error = 4.409e-07, v error = 7.409e-08, total error = 3.161e-07 + Total RHS evals: Fse = 15001, Fsi = 32981, Ff = 1875050 Slow Newton iters = 17980 Slow Newton conv fails = 0 Slow Jacobian evals = 250 diff --git a/examples/arkode/C_serial/ark_kpr_mri_12_3_0.005.out b/examples/arkode/C_serial/ark_kpr_mri_12_3_0.005.out index f3b4cf92dc..2702eeeb8c 100644 --- a/examples/arkode/C_serial/ark_kpr_mri_12_3_0.005.out +++ b/examples/arkode/C_serial/ark_kpr_mri_12_3_0.005.out @@ -13,61 +13,61 @@ Multirate nonlinear Kvaerno-Prothero-Robinson test problem: ------------------------------------------------------ 0.000000 1.224745 1.732051 0.00e+00 0.00e+00 0.100000 1.223725 1.077464 1.04e-07 1.78e-10 - 0.200000 1.220669 1.551800 1.03e-07 3.41e-10 - 0.300000 1.215594 1.467737 1.04e-07 8.22e-10 - 0.400000 1.208524 1.154583 1.03e-07 1.27e-09 - 0.500000 1.199496 1.721908 1.01e-07 1.71e-09 - 0.600000 1.188557 1.023517 9.63e-08 2.09e-09 - 0.700000 1.175764 1.622751 9.18e-08 2.41e-09 - 0.800000 1.161186 1.374632 9.21e-08 2.69e-09 - 0.900000 1.144904 1.245763 8.98e-08 2.96e-09 - 1.000000 1.127010 1.691839 8.66e-08 3.25e-09 - 1.100000 1.107609 1.000489 7.61e-08 3.49e-09 - 1.200000 1.086821 1.677552 6.53e-08 3.63e-09 - 1.300000 1.064777 1.277775 6.27e-08 3.72e-09 - 1.400000 1.041626 1.342455 5.85e-08 3.79e-09 - 1.500000 1.017531 1.642940 5.47e-08 3.89e-09 - 1.600000 0.992673 1.012112 3.94e-08 3.97e-09 - 1.700000 0.967253 1.714058 2.18e-08 3.99e-09 - 1.800000 0.941488 1.183867 1.09e-08 3.88e-09 - 1.900000 0.915617 1.437465 2.03e-09 3.68e-09 - 2.000000 0.889903 1.577082 3.28e-09 3.54e-09 - 2.100000 0.864625 1.056467 2.22e-08 3.40e-09 - 2.200000 0.840089 1.730920 4.49e-08 3.23e-09 - 2.300000 0.816616 1.101047 6.69e-08 2.88e-09 - 2.400000 0.794546 1.525051 8.32e-08 2.38e-09 - 2.500000 0.774227 1.496993 9.13e-08 1.92e-09 - 2.600000 0.756013 1.126857 1.10e-07 1.46e-09 - 2.700000 0.740246 1.727536 1.30e-07 9.94e-10 - 2.800000 0.727247 1.038393 1.52e-07 3.98e-10 - 2.900000 0.717301 1.600759 1.66e-07 3.09e-10 - 3.000000 0.710636 1.406380 1.70e-07 9.31e-10 - 3.100000 0.707412 1.214353 1.76e-07 1.61e-09 - 3.200000 0.707709 1.704026 1.78e-07 2.26e-09 - 3.300000 0.711519 1.004391 1.75e-07 2.89e-09 - 3.400000 0.718749 1.661225 1.66e-07 3.48e-09 - 3.500000 0.729227 1.310102 2.06e-07 4.61e-09 - 3.600000 0.742712 1.310080 1.46e-07 5.20e-09 - 3.700000 0.758914 1.661237 1.35e-07 5.53e-09 - 3.800000 0.777506 1.004387 1.13e-07 5.79e-09 - 3.900000 0.798144 1.704019 8.93e-08 6.17e-09 - 4.000000 0.820474 1.214374 7.47e-08 6.15e-09 - 4.100000 0.844149 1.406358 6.22e-08 6.02e-09 - 4.200000 0.868832 1.600774 5.40e-08 5.94e-09 - 4.300000 0.894204 1.038382 3.41e-08 5.84e-09 - 4.400000 0.919964 1.727533 1.30e-08 5.69e-09 - 4.500000 0.945834 1.126875 2.93e-09 5.39e-09 - 4.600000 0.971557 1.496974 1.25e-08 4.97e-09 - 4.700000 0.996898 1.525070 1.46e-08 4.61e-09 - 4.800000 1.021641 1.101030 2.63e-08 4.29e-09 - 4.900000 1.045589 1.730922 3.94e-08 3.99e-09 - 5.000000 1.068565 1.056480 5.40e-08 3.58e-09 + 0.200000 1.220669 1.551800 1.03e-07 3.02e-10 + 0.300000 1.215594 1.467737 1.04e-07 7.49e-10 + 0.400000 1.208524 1.154583 1.03e-07 1.17e-09 + 0.500000 1.199496 1.721908 1.01e-07 1.58e-09 + 0.600000 1.188557 1.023517 9.63e-08 1.93e-09 + 0.700000 1.175764 1.622751 9.18e-08 2.23e-09 + 0.800000 1.161186 1.374632 9.21e-08 2.49e-09 + 0.900000 1.144904 1.245763 8.98e-08 2.75e-09 + 1.000000 1.127010 1.691839 8.66e-08 3.02e-09 + 1.100000 1.107609 1.000489 7.61e-08 3.25e-09 + 1.200000 1.086821 1.677552 6.53e-08 3.39e-09 + 1.300000 1.064777 1.277775 6.27e-08 3.48e-09 + 1.400000 1.041626 1.342455 5.85e-08 3.54e-09 + 1.500000 1.017531 1.642940 5.47e-08 3.65e-09 + 1.600000 0.992673 1.012112 3.94e-08 3.74e-09 + 1.700000 0.967253 1.714058 2.18e-08 3.76e-09 + 1.800000 0.941488 1.183867 1.09e-08 3.66e-09 + 1.900000 0.915617 1.437465 2.03e-09 3.48e-09 + 2.000000 0.889903 1.577082 3.28e-09 3.36e-09 + 2.100000 0.864625 1.056467 2.22e-08 3.24e-09 + 2.200000 0.840089 1.730920 4.49e-08 3.09e-09 + 2.300000 0.816616 1.101047 6.69e-08 2.78e-09 + 2.400000 0.794546 1.525051 8.32e-08 2.32e-09 + 2.500000 0.774227 1.496993 9.13e-08 1.89e-09 + 2.600000 0.756013 1.126857 1.10e-07 1.47e-09 + 2.700000 0.740246 1.727536 1.30e-07 1.05e-09 + 2.800000 0.727247 1.038393 1.52e-07 4.97e-10 + 2.900000 0.717301 1.600759 1.66e-07 1.62e-10 + 3.000000 0.710636 1.406380 1.70e-07 7.36e-10 + 3.100000 0.707412 1.214353 1.76e-07 1.36e-09 + 3.200000 0.707709 1.704026 1.78e-07 1.97e-09 + 3.300000 0.711519 1.004391 1.75e-07 2.57e-09 + 3.400000 0.718749 1.661225 1.66e-07 3.12e-09 + 3.500000 0.729227 1.310102 2.06e-07 4.23e-09 + 3.600000 0.742712 1.310080 1.46e-07 4.79e-09 + 3.700000 0.758914 1.661237 1.35e-07 5.10e-09 + 3.800000 0.777506 1.004387 1.13e-07 5.35e-09 + 3.900000 0.798144 1.704019 8.93e-08 5.73e-09 + 4.000000 0.820474 1.214374 7.47e-08 5.72e-09 + 4.100000 0.844149 1.406358 6.22e-08 5.61e-09 + 4.200000 0.868832 1.600774 5.40e-08 5.54e-09 + 4.300000 0.894204 1.038382 3.41e-08 5.46e-09 + 4.400000 0.919964 1.727533 1.30e-08 5.34e-09 + 4.500000 0.945834 1.126875 2.93e-09 5.06e-09 + 4.600000 0.971557 1.496974 1.25e-08 4.68e-09 + 4.700000 0.996898 1.525070 1.46e-08 4.35e-09 + 4.800000 1.021641 1.101030 2.63e-08 4.06e-09 + 4.900000 1.045589 1.730922 3.94e-08 3.79e-09 + 5.000000 1.068565 1.056480 5.40e-08 3.42e-09 ------------------------------------------------------ Final Solver Statistics: Steps: nsts = 1001, nstf = 362362 - u error = 9.913e-08, v error = 3.753e-09, total error = 7.015e-08 - Total RHS evals: Fse = 4005, Fsi = 12096, Ff = 1087136 + u error = 9.913e-08, v error = 3.506e-09, total error = 7.014e-08 + Total RHS evals: Fse = 4005, Fsi = 12096, Ff = 1088137 Slow Newton iters = 8091 Slow Newton conv fails = 0 Slow Jacobian evals = 51 diff --git a/examples/arkode/C_serial/ark_kpr_mri_13_4_0.01.out b/examples/arkode/C_serial/ark_kpr_mri_13_4_0.01.out index 73178461e3..4e40afb1e6 100644 --- a/examples/arkode/C_serial/ark_kpr_mri_13_4_0.01.out +++ b/examples/arkode/C_serial/ark_kpr_mri_13_4_0.01.out @@ -14,35 +14,35 @@ Multirate nonlinear Kvaerno-Prothero-Robinson test problem: 0.000000 1.224745 1.732051 0.00e+00 0.00e+00 0.100000 1.223725 1.077464 7.51e-08 2.97e-08 0.200000 1.220669 1.551800 7.47e-08 5.67e-08 - 0.300000 1.215594 1.467737 7.40e-08 8.08e-08 + 0.300000 1.215594 1.467737 7.40e-08 8.09e-08 0.400000 1.208524 1.154583 7.27e-08 1.02e-07 0.500000 1.199496 1.721908 7.14e-08 1.21e-07 0.600000 1.188557 1.023517 6.91e-08 1.37e-07 0.700000 1.175764 1.622750 6.68e-08 1.51e-07 - 0.800000 1.161186 1.374632 6.39e-08 1.62e-07 + 0.800000 1.161186 1.374632 6.39e-08 1.63e-07 0.900000 1.144904 1.245763 6.08e-08 1.72e-07 - 1.000000 1.127010 1.691839 5.67e-08 1.78e-07 + 1.000000 1.127010 1.691839 5.67e-08 1.79e-07 1.100000 1.107609 1.000489 5.49e-08 1.83e-07 1.200000 1.086820 1.677552 4.79e-08 1.85e-07 1.300000 1.064777 1.277775 4.43e-08 1.85e-07 1.400000 1.041625 1.342455 3.64e-08 1.83e-07 - 1.500000 1.017531 1.642940 3.04e-08 1.78e-07 - 1.600000 0.992673 1.012112 2.26e-08 1.71e-07 + 1.500000 1.017531 1.642940 3.04e-08 1.79e-07 + 1.600000 0.992673 1.012112 2.26e-08 1.72e-07 1.700000 0.967253 1.714058 1.02e-08 1.62e-07 - 1.800000 0.941488 1.183866 6.48e-09 1.50e-07 + 1.800000 0.941488 1.183866 6.48e-09 1.51e-07 1.900000 0.915617 1.437465 3.83e-09 1.36e-07 - 2.000000 0.889903 1.577082 1.47e-08 1.19e-07 - 2.100000 0.864625 1.056467 2.49e-08 9.99e-08 - 2.200000 0.840089 1.730920 3.69e-08 7.77e-08 - 2.300000 0.816616 1.101047 5.28e-08 5.28e-08 - 2.400000 0.794546 1.525051 6.32e-08 2.50e-08 - 2.500000 0.774228 1.496993 7.57e-08 5.17e-09 - 2.600000 0.756013 1.126857 8.93e-08 3.76e-08 - 2.700000 0.740246 1.727536 1.01e-07 7.19e-08 - 2.800000 0.727248 1.038393 1.12e-07 1.07e-07 + 2.000000 0.889903 1.577082 1.47e-08 1.20e-07 + 2.100000 0.864625 1.056467 2.48e-08 1.00e-07 + 2.200000 0.840089 1.730920 3.69e-08 7.78e-08 + 2.300000 0.816616 1.101047 5.28e-08 5.29e-08 + 2.400000 0.794546 1.525051 6.32e-08 2.51e-08 + 2.500000 0.774228 1.496993 7.57e-08 5.16e-09 + 2.600000 0.756013 1.126857 8.92e-08 3.76e-08 + 2.700000 0.740246 1.727536 1.01e-07 7.20e-08 + 2.800000 0.727248 1.038393 1.12e-07 1.08e-07 2.900000 0.717301 1.600759 1.21e-07 1.44e-07 3.000000 0.710636 1.406380 1.27e-07 1.79e-07 - 3.100000 0.707413 1.214353 1.31e-07 2.13e-07 + 3.100000 0.707413 1.214353 1.31e-07 2.14e-07 3.200000 0.707710 1.704026 1.31e-07 2.45e-07 3.300000 0.711520 1.004391 1.28e-07 2.73e-07 3.400000 0.718750 1.661225 1.22e-07 2.97e-07 @@ -51,23 +51,23 @@ Multirate nonlinear Kvaerno-Prothero-Robinson test problem: 3.700000 0.758914 1.661237 9.11e-08 3.35e-07 3.800000 0.777506 1.004387 7.85e-08 3.36e-07 3.900000 0.798144 1.704019 6.30e-08 3.32e-07 - 4.000000 0.820474 1.214374 5.22e-08 3.23e-07 - 4.100000 0.844149 1.406358 4.01e-08 3.10e-07 + 4.000000 0.820474 1.214374 5.22e-08 3.24e-07 + 4.100000 0.844149 1.406358 4.01e-08 3.11e-07 4.200000 0.868832 1.600775 2.78e-08 2.94e-07 - 4.300000 0.894204 1.038382 1.74e-08 2.74e-07 - 4.400000 0.919964 1.727534 6.17e-09 2.52e-07 - 4.500000 0.945834 1.126875 2.12e-09 2.28e-07 + 4.300000 0.894204 1.038382 1.74e-08 2.75e-07 + 4.400000 0.919964 1.727534 6.17e-09 2.53e-07 + 4.500000 0.945834 1.126875 2.12e-09 2.29e-07 4.600000 0.971557 1.496974 1.37e-08 2.03e-07 4.700000 0.996898 1.525070 1.98e-08 1.77e-07 4.800000 1.021641 1.101030 2.80e-08 1.50e-07 4.900000 1.045589 1.730922 4.06e-08 1.23e-07 - 5.000000 1.068565 1.056480 4.09e-08 9.60e-08 + 5.000000 1.068565 1.056480 4.09e-08 9.61e-08 ------------------------------------------------------ Final Solver Statistics: Steps: nsts = 501, nstf = 202905 - u error = 7.089e-08, v error = 1.970e-07, total error = 1.480e-07 - Total RHS evals: Fse = 3007, Fsi = 8869, Ff = 811670 + u error = 7.089e-08, v error = 1.972e-07, total error = 1.482e-07 + Total RHS evals: Fse = 3007, Fsi = 8869, Ff = 812171 Slow Newton iters = 5862 Slow Newton conv fails = 0 Slow Jacobian evals = 26 diff --git a/examples/arkode/C_serial/ark_kpr_mri_1_0_0.01.out b/examples/arkode/C_serial/ark_kpr_mri_1_0_0.01.out index 2c625caeca..c69c229ef1 100644 --- a/examples/arkode/C_serial/ark_kpr_mri_1_0_0.01.out +++ b/examples/arkode/C_serial/ark_kpr_mri_1_0_0.01.out @@ -66,4 +66,4 @@ Multirate nonlinear Kvaerno-Prothero-Robinson test problem: Final Solver Statistics: Steps: nsts = 501, nstf = 50601 u error = 5.052e-05, v error = 7.684e-04, total error = 5.445e-04 - Total RHS evals: Fs = 1504, Ff = 151853 + Total RHS evals: Fs = 1504, Ff = 152354 diff --git a/examples/arkode/C_serial/ark_kpr_mri_2_4_0.002.out b/examples/arkode/C_serial/ark_kpr_mri_2_4_0.002.out index b8abfa84b0..37b8ce06e3 100644 --- a/examples/arkode/C_serial/ark_kpr_mri_2_4_0.002.out +++ b/examples/arkode/C_serial/ark_kpr_mri_2_4_0.002.out @@ -31,39 +31,39 @@ Multirate nonlinear Kvaerno-Prothero-Robinson test problem: 1.800000 0.941488 1.183867 1.32e-11 5.89e-11 1.900000 0.915617 1.437465 9.11e-12 5.33e-11 2.000000 0.889903 1.577082 3.33e-11 4.69e-11 - 2.100000 0.864625 1.056467 5.94e-11 3.57e-11 - 2.200000 0.840089 1.730920 8.72e-11 3.22e-11 - 2.300000 0.816616 1.101047 1.16e-10 1.97e-11 - 2.400000 0.794546 1.525051 1.47e-10 7.75e-12 - 2.500000 0.774227 1.496993 1.78e-10 2.45e-12 - 2.600000 0.756013 1.126857 2.08e-10 1.99e-11 - 2.700000 0.740246 1.727536 2.36e-10 2.32e-11 - 2.800000 0.727247 1.038393 2.62e-10 4.19e-11 - 2.900000 0.717301 1.600759 2.83e-10 5.92e-11 - 3.000000 0.710636 1.406380 2.99e-10 6.19e-11 - 3.100000 0.707412 1.214353 3.07e-10 9.20e-11 - 3.200000 0.707709 1.704026 3.08e-10 8.71e-11 + 2.100000 0.864625 1.056467 5.94e-11 3.62e-11 + 2.200000 0.840089 1.730920 8.72e-11 3.20e-11 + 2.300000 0.816616 1.101047 1.16e-10 1.85e-11 + 2.400000 0.794546 1.525051 1.47e-10 1.05e-11 + 2.500000 0.774227 1.496993 1.78e-10 1.19e-12 + 2.600000 0.756013 1.126857 2.08e-10 1.60e-11 + 2.700000 0.740246 1.727536 2.36e-10 2.55e-11 + 2.800000 0.727247 1.038393 2.62e-10 4.36e-11 + 2.900000 0.717301 1.600759 2.83e-10 5.41e-11 + 3.000000 0.710636 1.406380 2.99e-10 6.92e-11 + 3.100000 0.707412 1.214353 3.07e-10 8.37e-11 + 3.200000 0.707709 1.704026 3.08e-10 9.30e-11 3.300000 0.711520 1.004391 3.02e-10 1.08e-10 - 3.400000 0.718750 1.661225 2.88e-10 1.19e-10 - 3.500000 0.729227 1.310102 2.68e-10 1.13e-10 - 3.600000 0.742712 1.310080 2.43e-10 1.41e-10 - 3.700000 0.758914 1.661237 2.15e-10 1.18e-10 - 3.800000 0.777506 1.004387 1.85e-10 1.38e-10 - 3.900000 0.798144 1.704019 1.54e-10 1.31e-10 - 4.000000 0.820474 1.214374 1.24e-10 1.16e-10 - 4.100000 0.844149 1.406358 9.39e-11 1.38e-10 - 4.200000 0.868832 1.600774 6.55e-11 9.88e-11 - 4.300000 0.894204 1.038382 3.88e-11 1.20e-10 - 4.400000 0.919964 1.727533 1.40e-11 9.58e-11 - 4.500000 0.945834 1.126875 8.93e-12 8.01e-11 - 4.600000 0.971557 1.496974 3.00e-11 9.82e-11 - 4.700000 0.996898 1.525070 4.92e-11 4.94e-11 - 4.800000 1.021641 1.101030 6.67e-11 7.79e-11 - 4.900000 1.045589 1.730922 8.26e-11 3.90e-11 - 5.000000 1.068565 1.056480 9.70e-11 3.19e-11 + 3.400000 0.718750 1.661225 2.88e-10 1.14e-10 + 3.500000 0.729227 1.310102 2.68e-10 1.23e-10 + 3.600000 0.742712 1.310080 2.43e-10 1.28e-10 + 3.700000 0.758914 1.661237 2.15e-10 1.29e-10 + 3.800000 0.777506 1.004387 1.85e-10 1.34e-10 + 3.900000 0.798144 1.704019 1.54e-10 1.28e-10 + 4.000000 0.820474 1.214374 1.24e-10 1.28e-10 + 4.100000 0.844149 1.406358 9.39e-11 1.22e-10 + 4.200000 0.868832 1.600774 6.55e-11 1.14e-10 + 4.300000 0.894204 1.038382 3.88e-11 1.10e-10 + 4.400000 0.919964 1.727533 1.40e-11 9.70e-11 + 4.500000 0.945834 1.126875 8.93e-12 9.14e-11 + 4.600000 0.971557 1.496974 3.00e-11 7.93e-11 + 4.700000 0.996898 1.525070 4.92e-11 6.88e-11 + 4.800000 1.021641 1.101030 6.67e-11 6.10e-11 + 4.900000 1.045589 1.730922 8.26e-11 4.65e-11 + 5.000000 1.068565 1.056480 9.70e-11 4.02e-11 ------------------------------------------------------ Final Solver Statistics: Steps: nsts = 2501, nstf = 250100 - u error = 1.665e-10, v error = 7.714e-11, total error = 1.297e-10 - Total RHS evals: Fs = 12506, Ff = 1000450 + u error = 1.665e-10, v error = 7.685e-11, total error = 1.296e-10 + Total RHS evals: Fs = 12506, Ff = 1002951 diff --git a/examples/arkode/C_serial/ark_kpr_mri_3_2_0.001.out b/examples/arkode/C_serial/ark_kpr_mri_3_2_0.001.out index f5196d7797..de553f476b 100644 --- a/examples/arkode/C_serial/ark_kpr_mri_3_2_0.001.out +++ b/examples/arkode/C_serial/ark_kpr_mri_3_2_0.001.out @@ -66,4 +66,4 @@ Multirate nonlinear Kvaerno-Prothero-Robinson test problem: Final Solver Statistics: Steps: nsts = 5000, nstf = 750000 u error = 2.508e-08, v error = 2.443e-08, total error = 2.476e-08 - Total RHS evals: Fs = 10001, Ff = 1500050 + Total RHS evals: Fs = 10001, Ff = 1505050 diff --git a/examples/arkode/C_serial/ark_kpr_mri_4_3_0.001.out b/examples/arkode/C_serial/ark_kpr_mri_4_3_0.001.out index 5002013f25..6714cddd83 100644 --- a/examples/arkode/C_serial/ark_kpr_mri_4_3_0.001.out +++ b/examples/arkode/C_serial/ark_kpr_mri_4_3_0.001.out @@ -66,4 +66,4 @@ Multirate nonlinear Kvaerno-Prothero-Robinson test problem: Final Solver Statistics: Steps: nsts = 5000, nstf = 1085000 u error = 8.345e-10, v error = 2.743e-10, total error = 6.212e-10 - Total RHS evals: Fs = 15001, Ff = 3255050 + Total RHS evals: Fs = 15001, Ff = 3260050 diff --git a/examples/arkode/C_serial/ark_kpr_mri_5_4_0.001.out b/examples/arkode/C_serial/ark_kpr_mri_5_4_0.001.out index 8e408cac91..c2683d4888 100644 --- a/examples/arkode/C_serial/ark_kpr_mri_5_4_0.001.out +++ b/examples/arkode/C_serial/ark_kpr_mri_5_4_0.001.out @@ -21,49 +21,49 @@ Multirate nonlinear Kvaerno-Prothero-Robinson test problem: 0.800000 1.161186 1.374632 1.87e-11 5.82e-12 0.900000 1.144904 1.245763 1.77e-11 5.97e-12 1.000000 1.127010 1.691839 1.66e-11 6.30e-12 - 1.100000 1.107609 1.000489 1.52e-11 2.00e-12 - 1.200000 1.086821 1.677552 1.38e-11 6.20e-12 - 1.300000 1.064777 1.277775 1.22e-11 6.14e-12 - 1.400000 1.041625 1.342455 1.04e-11 1.56e-12 - 1.500000 1.017531 1.642940 8.47e-12 9.89e-12 - 1.600000 0.992673 1.012112 6.30e-12 4.47e-13 - 1.700000 0.967253 1.714058 3.95e-12 6.46e-12 - 1.800000 0.941488 1.183867 1.35e-12 7.16e-12 - 1.900000 0.915617 1.437465 1.47e-12 2.70e-12 - 2.000000 0.889903 1.577082 4.53e-12 1.16e-11 - 2.100000 0.864625 1.056467 7.80e-12 5.16e-12 - 2.200000 0.840089 1.730920 1.13e-11 6.35e-12 - 2.300000 0.816616 1.101047 1.50e-11 4.17e-12 - 2.400000 0.794546 1.525051 1.88e-11 8.29e-12 - 2.500000 0.774227 1.496993 2.27e-11 1.08e-11 - 2.600000 0.756013 1.126857 2.64e-11 1.42e-11 - 2.700000 0.740246 1.727536 3.00e-11 5.47e-12 - 2.800000 0.727247 1.038393 3.32e-11 3.03e-12 - 2.900000 0.717301 1.600759 3.58e-11 1.40e-11 - 3.000000 0.710636 1.406380 3.76e-11 7.68e-12 - 3.100000 0.707412 1.214353 3.86e-11 2.49e-11 - 3.200000 0.707709 1.704026 3.86e-11 4.61e-12 - 3.300000 0.711520 1.004391 3.77e-11 1.29e-11 - 3.400000 0.718750 1.661225 3.59e-11 1.68e-11 - 3.500000 0.729227 1.310102 3.33e-11 4.71e-12 - 3.600000 0.742712 1.310080 3.02e-11 3.30e-11 - 3.700000 0.758914 1.661237 2.66e-11 6.81e-12 - 3.800000 0.777506 1.004387 2.28e-11 2.15e-11 - 3.900000 0.798144 1.704019 1.89e-11 1.30e-11 - 4.000000 0.820474 1.214374 1.51e-11 4.33e-12 - 4.100000 0.844149 1.406358 1.14e-11 3.43e-11 - 4.200000 0.868832 1.600774 7.85e-12 5.29e-12 - 4.300000 0.894204 1.038382 4.53e-12 2.10e-11 - 4.400000 0.919964 1.727533 1.45e-12 8.06e-12 - 4.500000 0.945834 1.126875 1.40e-12 2.24e-12 - 4.600000 0.971557 1.496974 4.01e-12 1.69e-11 - 4.700000 0.996898 1.525070 6.40e-12 2.17e-13 - 4.800000 1.021641 1.101030 8.58e-12 1.01e-11 - 4.900000 1.045589 1.730922 1.06e-11 4.05e-12 + 1.100000 1.107609 1.000489 1.52e-11 2.13e-12 + 1.200000 1.086821 1.677552 1.38e-11 6.72e-12 + 1.300000 1.064777 1.277775 1.22e-11 4.31e-12 + 1.400000 1.041625 1.342455 1.04e-11 4.75e-12 + 1.500000 1.017531 1.642940 8.47e-12 6.69e-12 + 1.600000 0.992673 1.012112 6.30e-12 2.43e-12 + 1.700000 0.967253 1.714058 3.95e-12 6.77e-12 + 1.800000 0.941488 1.183867 1.35e-12 3.05e-12 + 1.900000 0.915617 1.437465 1.47e-12 4.22e-12 + 2.000000 0.889903 1.577082 4.53e-12 4.66e-12 + 2.100000 0.864625 1.056467 7.81e-12 6.12e-13 + 2.200000 0.840089 1.730920 1.13e-11 4.29e-12 + 2.300000 0.816616 1.101047 1.50e-11 6.09e-13 + 2.400000 0.794546 1.525051 1.88e-11 1.21e-12 + 2.500000 0.774227 1.496993 2.27e-11 7.39e-14 + 2.600000 0.756013 1.126857 2.64e-11 3.44e-12 + 2.700000 0.740246 1.727536 3.00e-11 6.68e-13 + 2.800000 0.727247 1.038393 3.32e-11 6.30e-12 + 2.900000 0.717301 1.600759 3.58e-11 3.89e-12 + 3.000000 0.710636 1.406380 3.76e-11 6.33e-12 + 3.100000 0.707412 1.214353 3.86e-11 8.76e-12 + 3.200000 0.707709 1.704026 3.86e-11 6.62e-12 + 3.300000 0.711520 1.004391 3.77e-11 1.21e-11 + 3.400000 0.718750 1.661225 3.59e-11 8.63e-12 + 3.500000 0.729227 1.310102 3.33e-11 1.15e-11 + 3.600000 0.742712 1.310080 3.02e-11 1.19e-11 + 3.700000 0.758914 1.661237 2.66e-11 9.88e-12 + 3.800000 0.777506 1.004387 2.28e-11 1.42e-11 + 3.900000 0.798144 1.704019 1.89e-11 9.52e-12 + 4.000000 0.820474 1.214374 1.51e-11 1.23e-11 + 4.100000 0.844149 1.406358 1.14e-11 1.30e-11 + 4.200000 0.868832 1.600774 7.85e-12 1.11e-11 + 4.300000 0.894204 1.038382 4.53e-12 1.12e-11 + 4.400000 0.919964 1.727533 1.45e-12 9.88e-12 + 4.500000 0.945834 1.126875 1.40e-12 8.44e-12 + 4.600000 0.971557 1.496974 4.01e-12 8.57e-12 + 4.700000 0.996898 1.525070 6.40e-12 6.35e-12 + 4.800000 1.021641 1.101030 8.58e-12 6.61e-12 + 4.900000 1.045589 1.730922 1.06e-11 4.80e-12 5.000000 1.068565 1.056480 1.23e-11 3.61e-12 ------------------------------------------------------ Final Solver Statistics: Steps: nsts = 5000, nstf = 1425000 - u error = 2.085e-11, v error = 1.132e-11, total error = 1.678e-11 - Total RHS evals: Fs = 30001, Ff = 5700050 + u error = 2.086e-11, v error = 7.078e-12, total error = 1.557e-11 + Total RHS evals: Fs = 30001, Ff = 5705050 diff --git a/examples/arkode/C_serial/ark_kpr_mri_6_5_0.001.out b/examples/arkode/C_serial/ark_kpr_mri_6_5_0.001.out index 2f083931c6..174ea42698 100644 --- a/examples/arkode/C_serial/ark_kpr_mri_6_5_0.001.out +++ b/examples/arkode/C_serial/ark_kpr_mri_6_5_0.001.out @@ -21,49 +21,49 @@ Multirate nonlinear Kvaerno-Prothero-Robinson test problem: 0.800000 1.161186 1.374632 3.73e-13 1.48e-13 0.900000 1.144904 1.245763 3.52e-13 3.93e-14 1.000000 1.127010 1.691839 3.32e-13 4.77e-14 - 1.100000 1.107609 1.000489 3.33e-13 4.42e-12 - 1.200000 1.086821 1.677552 2.90e-13 2.80e-13 - 1.300000 1.064777 1.277775 2.74e-13 3.47e-13 - 1.400000 1.041625 1.342455 2.24e-13 4.84e-12 - 1.500000 1.017531 1.642940 1.92e-13 3.64e-12 + 1.100000 1.107609 1.000489 3.33e-13 4.28e-12 + 1.200000 1.086821 1.677552 2.90e-13 2.44e-13 + 1.300000 1.064777 1.277775 2.74e-13 2.18e-13 + 1.400000 1.041625 1.342455 2.24e-13 1.65e-12 + 1.500000 1.017531 1.642940 1.92e-13 4.45e-13 1.600000 0.992673 1.012112 1.52e-13 5.55e-12 - 1.700000 0.967253 1.714058 9.33e-14 7.75e-13 - 1.800000 0.941488 1.183867 5.52e-14 1.87e-12 - 1.900000 0.915617 1.437465 1.53e-14 7.48e-12 - 2.000000 0.889903 1.577082 6.78e-14 7.44e-12 - 2.100000 0.864625 1.056467 1.36e-13 8.63e-12 - 2.200000 0.840089 1.730920 2.16e-13 3.66e-12 - 2.300000 0.816616 1.101047 2.76e-13 2.38e-12 - 2.400000 0.794546 1.525051 3.69e-13 9.12e-12 - 2.500000 0.774227 1.496993 4.38e-13 1.11e-11 - 2.600000 0.756013 1.126857 5.20e-13 1.28e-11 - 2.700000 0.740246 1.727536 5.97e-13 8.05e-12 - 2.800000 0.727247 1.038393 6.51e-13 7.73e-13 - 2.900000 0.717301 1.600759 7.23e-13 8.96e-12 - 3.000000 0.710636 1.406380 7.50e-13 1.40e-11 - 3.100000 0.707412 1.214353 7.81e-13 1.74e-11 - 3.200000 0.707709 1.704026 7.84e-13 1.33e-11 - 3.300000 0.711520 1.004391 7.58e-13 3.30e-12 - 3.400000 0.718750 1.661225 7.40e-13 6.43e-12 - 3.500000 0.729227 1.310102 6.75e-13 1.58e-11 - 3.600000 0.742712 1.310080 6.25e-13 2.14e-11 - 3.700000 0.758914 1.661237 5.52e-13 1.86e-11 - 3.800000 0.777506 1.004387 4.71e-13 9.68e-12 - 3.900000 0.798144 1.704019 4.06e-13 1.34e-12 - 4.000000 0.820474 1.214374 3.13e-13 1.57e-11 - 4.100000 0.844149 1.406358 2.24e-13 2.33e-11 - 4.200000 0.868832 1.600774 1.55e-13 1.56e-11 - 4.300000 0.894204 1.038382 8.57e-14 1.13e-11 - 4.400000 0.919964 1.727533 2.70e-14 7.79e-13 - 4.500000 0.945834 1.126875 3.24e-14 5.77e-12 - 4.600000 0.971557 1.496974 8.40e-14 9.76e-12 - 4.700000 0.996898 1.525070 1.31e-13 6.00e-12 - 4.800000 1.021641 1.101030 1.79e-13 4.81e-12 - 4.900000 1.045589 1.730922 2.13e-13 2.44e-13 + 1.700000 0.967253 1.714058 9.33e-14 1.09e-12 + 1.800000 0.941488 1.183867 5.52e-14 2.24e-12 + 1.900000 0.915617 1.437465 1.53e-14 5.52e-13 + 2.000000 0.889903 1.577082 6.75e-14 4.87e-13 + 2.100000 0.864625 1.056467 1.36e-13 2.86e-12 + 2.200000 0.840089 1.730920 2.15e-13 1.59e-12 + 2.300000 0.816616 1.101047 2.74e-13 2.40e-12 + 2.400000 0.794546 1.525051 3.67e-13 3.79e-13 + 2.500000 0.774227 1.496993 4.35e-13 3.14e-13 + 2.600000 0.756013 1.126857 5.16e-13 2.06e-12 + 2.700000 0.740246 1.727536 5.92e-13 1.91e-12 + 2.800000 0.727247 1.038393 6.45e-13 2.49e-12 + 2.900000 0.717301 1.600759 7.16e-13 1.19e-12 + 3.000000 0.710636 1.406380 7.43e-13 6.88e-15 + 3.100000 0.707412 1.214353 7.73e-13 1.22e-12 + 3.200000 0.707709 1.704026 7.76e-13 2.02e-12 + 3.300000 0.711520 1.004391 7.50e-13 2.48e-12 + 3.400000 0.718750 1.661225 7.31e-13 1.78e-12 + 3.500000 0.729227 1.310102 6.67e-13 4.31e-13 + 3.600000 0.742712 1.310080 6.17e-13 4.42e-13 + 3.700000 0.758914 1.661237 5.44e-13 1.88e-12 + 3.800000 0.777506 1.004387 4.64e-13 2.38e-12 + 3.900000 0.798144 1.704019 4.01e-13 2.16e-12 + 4.000000 0.820474 1.214374 3.08e-13 9.57e-13 + 4.100000 0.844149 1.406358 2.21e-13 2.06e-12 + 4.200000 0.868832 1.600774 1.53e-13 7.17e-13 + 4.300000 0.894204 1.038382 8.45e-14 1.60e-12 + 4.400000 0.919964 1.727533 2.65e-14 1.04e-12 + 4.500000 0.945834 1.126875 3.23e-14 4.35e-13 + 4.600000 0.971557 1.496974 8.37e-14 1.42e-12 + 4.700000 0.996898 1.525070 1.30e-13 1.38e-13 + 4.800000 1.021641 1.101030 1.79e-13 1.33e-12 + 4.900000 1.045589 1.730922 2.13e-13 5.01e-13 5.000000 1.068565 1.056480 2.51e-13 2.92e-13 ------------------------------------------------------ Final Solver Statistics: Steps: nsts = 5000, nstf = 1615000 - u error = 4.211e-13, v error = 8.987e-12, total error = 6.362e-12 - Total RHS evals: Fs = 50051, Ff = 9710101 + u error = 4.177e-13, v error = 1.555e-12, total error = 1.139e-12 + Total RHS evals: Fs = 50051, Ff = 9715101 diff --git a/examples/arkode/C_serial/ark_kpr_mri_7_2_0.002.out b/examples/arkode/C_serial/ark_kpr_mri_7_2_0.002.out index b45b167aaa..35ce8db2b6 100644 --- a/examples/arkode/C_serial/ark_kpr_mri_7_2_0.002.out +++ b/examples/arkode/C_serial/ark_kpr_mri_7_2_0.002.out @@ -13,61 +13,61 @@ Multirate nonlinear Kvaerno-Prothero-Robinson test problem: ------------------------------------------------------ 0.000000 1.224745 1.732051 0.00e+00 0.00e+00 0.100000 1.223725 1.077464 2.77e-08 1.95e-07 - 0.200000 1.220666 1.551800 2.88e-06 1.79e-08 - 0.300000 1.215594 1.467737 1.91e-09 1.21e-07 - 0.400000 1.208524 1.154583 1.40e-07 1.75e-07 - 0.500000 1.199497 1.721908 3.79e-07 2.40e-09 - 0.600000 1.188557 1.023517 3.85e-07 8.51e-08 - 0.700000 1.175764 1.622750 1.42e-08 3.18e-07 - 0.800000 1.161181 1.374632 5.67e-06 2.43e-07 - 0.900000 1.144904 1.245763 6.01e-08 5.50e-07 - 1.000000 1.127010 1.691838 7.31e-09 6.14e-07 - 1.100000 1.107609 1.000489 3.52e-07 3.21e-07 - 1.200000 1.086820 1.677551 1.85e-07 7.19e-07 - 1.300000 1.064777 1.277774 2.56e-08 7.35e-07 - 1.400000 1.041625 1.342455 6.88e-08 6.97e-07 - 1.500000 1.017531 1.642939 1.30e-08 6.97e-07 - 1.600000 0.992673 1.012112 3.27e-09 4.12e-07 - 1.700000 0.967251 1.714057 1.26e-06 6.48e-07 - 1.800000 0.941487 1.183866 5.95e-07 6.78e-07 - 1.900000 0.915617 1.437465 2.80e-09 7.03e-07 - 2.000000 0.889902 1.577081 8.56e-08 6.75e-07 - 2.100000 0.864625 1.056467 3.05e-08 4.34e-07 - 2.200000 0.840089 1.730920 2.80e-07 8.05e-07 - 2.300000 0.816616 1.101046 1.68e-08 5.59e-07 - 2.400000 0.794545 1.525051 5.06e-07 6.57e-07 - 2.500000 0.774227 1.496992 1.40e-09 6.01e-07 - 2.600000 0.756013 1.126856 1.29e-07 4.75e-07 - 2.700000 0.740246 1.727536 2.31e-07 6.14e-07 - 2.800000 0.727247 1.038393 7.35e-08 4.97e-07 - 2.900000 0.717301 1.600758 1.47e-08 6.62e-07 - 3.000000 0.710630 1.406379 6.27e-06 5.84e-07 - 3.100000 0.707412 1.214352 2.47e-08 5.12e-07 - 3.200000 0.707709 1.704026 3.06e-09 6.10e-07 - 3.300000 0.711519 1.004391 8.82e-08 3.18e-07 - 3.400000 0.718749 1.661224 2.15e-07 5.37e-07 - 3.500000 0.729227 1.310101 1.72e-08 4.60e-07 - 3.600000 0.742712 1.310079 1.13e-08 4.35e-07 - 3.700000 0.758914 1.661236 2.50e-08 4.85e-07 - 3.800000 0.777506 1.004387 5.18e-09 2.14e-07 - 3.900000 0.798143 1.704018 8.33e-07 4.86e-07 - 4.000000 0.820474 1.214373 7.45e-07 3.28e-07 - 4.100000 0.844149 1.406358 3.41e-09 3.70e-07 - 4.200000 0.868832 1.600774 1.40e-07 3.87e-07 - 4.300000 0.894204 1.038382 7.05e-08 1.61e-07 - 4.400000 0.919964 1.727533 3.53e-07 8.36e-08 - 4.500000 0.945834 1.126875 6.51e-09 8.35e-08 - 4.600000 0.971557 1.496973 7.24e-07 5.21e-08 - 4.700000 0.996898 1.525070 4.86e-08 6.22e-08 - 4.800000 1.021640 1.101030 1.21e-07 3.47e-08 - 4.900000 1.045589 1.730922 1.37e-07 1.60e-07 - 5.000000 1.068565 1.056481 2.77e-07 3.04e-07 + 0.200000 1.220666 1.551800 2.88e-06 1.72e-08 + 0.300000 1.215594 1.467737 5.07e-10 2.58e-08 + 0.400000 1.208524 1.154583 1.40e-07 8.86e-08 + 0.500000 1.199497 1.721908 3.78e-07 7.73e-08 + 0.600000 1.188557 1.023517 3.84e-07 1.66e-07 + 0.700000 1.175764 1.622750 1.13e-08 7.38e-08 + 0.800000 1.161181 1.374632 5.67e-06 2.19e-08 + 0.900000 1.144904 1.245763 5.40e-08 6.40e-09 + 1.000000 1.127010 1.691839 4.83e-09 1.22e-07 + 1.100000 1.107609 1.000490 3.50e-07 1.24e-07 + 1.200000 1.086820 1.677552 1.80e-07 1.28e-07 + 1.300000 1.064777 1.277775 2.08e-08 5.87e-08 + 1.400000 1.041625 1.342455 6.57e-08 8.60e-08 + 1.500000 1.017531 1.642940 1.02e-08 1.45e-07 + 1.600000 0.992673 1.012112 7.42e-10 8.75e-08 + 1.700000 0.967251 1.714058 1.26e-06 1.96e-07 + 1.800000 0.941487 1.183866 5.89e-07 4.82e-08 + 1.900000 0.915617 1.437465 8.48e-11 1.34e-07 + 2.000000 0.889902 1.577082 8.30e-08 1.60e-07 + 2.100000 0.864625 1.056467 2.81e-08 3.18e-08 + 2.200000 0.840089 1.730920 2.75e-07 2.23e-07 + 2.300000 0.816616 1.101047 1.41e-08 3.14e-08 + 2.400000 0.794545 1.525051 5.03e-07 1.81e-07 + 2.500000 0.774227 1.496993 7.88e-10 1.70e-07 + 2.600000 0.756013 1.126857 1.27e-07 8.49e-08 + 2.700000 0.740246 1.727536 2.32e-07 2.61e-07 + 2.800000 0.727247 1.038393 6.92e-08 2.11e-08 + 2.900000 0.717301 1.600759 1.26e-08 2.31e-07 + 3.000000 0.710630 1.406379 6.27e-06 1.95e-07 + 3.100000 0.707412 1.214352 2.29e-08 1.59e-07 + 3.200000 0.707709 1.704026 1.45e-09 2.91e-07 + 3.300000 0.711519 1.004391 8.68e-08 2.89e-08 + 3.400000 0.718749 1.661225 2.14e-07 2.74e-07 + 3.500000 0.729227 1.310102 1.60e-08 2.21e-07 + 3.600000 0.742712 1.310080 1.03e-08 2.20e-07 + 3.700000 0.758914 1.661236 2.40e-08 2.91e-07 + 3.800000 0.777506 1.004387 4.29e-09 3.73e-08 + 3.900000 0.798143 1.704018 8.32e-07 3.27e-07 + 4.000000 0.820474 1.214374 7.44e-07 1.84e-07 + 4.100000 0.844149 1.406358 2.75e-09 2.40e-07 + 4.200000 0.868832 1.600774 1.39e-07 2.70e-07 + 4.300000 0.894204 1.038382 6.99e-08 5.45e-08 + 4.400000 0.919964 1.727533 3.58e-07 3.16e-07 + 4.500000 0.945834 1.126875 7.57e-09 1.27e-07 + 4.600000 0.971557 1.496973 7.25e-07 2.44e-07 + 4.700000 0.996898 1.525070 4.95e-08 2.35e-07 + 4.800000 1.021640 1.101030 1.22e-07 1.22e-07 + 4.900000 1.045589 1.730922 1.36e-07 3.02e-07 + 5.000000 1.068565 1.056480 2.82e-07 6.29e-08 ------------------------------------------------------ Final Solver Statistics: Steps: nsts = 2501, nstf = 250100 - u error = 1.302e-06, v error = 4.719e-07, total error = 9.791e-07 - Total RHS evals: Fs = 6952, Ff = 500250 + u error = 1.301e-06, v error = 1.744e-07, total error = 9.284e-07 + Total RHS evals: Fs = 7002, Ff = 502751 Slow Newton iters = 4500 Slow Newton conv fails = 0 Slow Jacobian evals = 126 diff --git a/examples/arkode/C_serial/ark_kpr_mri_8_3_0.001_-100_100_0.5_1.out b/examples/arkode/C_serial/ark_kpr_mri_8_3_0.001_-100_100_0.5_1.out index 85bfb497b6..45395b8454 100644 --- a/examples/arkode/C_serial/ark_kpr_mri_8_3_0.001_-100_100_0.5_1.out +++ b/examples/arkode/C_serial/ark_kpr_mri_8_3_0.001_-100_100_0.5_1.out @@ -13,61 +13,61 @@ Multirate nonlinear Kvaerno-Prothero-Robinson test problem: ------------------------------------------------------ 0.000000 1.224745 1.732051 0.00e+00 0.00e+00 0.100000 1.223725 1.077464 4.02e-10 5.73e-11 - 0.200000 1.220669 1.551800 4.06e-10 1.04e-10 - 0.300000 1.215594 1.467737 3.94e-10 1.46e-10 - 0.400000 1.208524 1.154583 3.88e-10 1.81e-10 - 0.500000 1.199496 1.721908 3.80e-10 2.13e-10 - 0.600000 1.188557 1.023517 3.81e-10 2.48e-10 - 0.700000 1.175764 1.622751 3.29e-10 2.78e-10 - 0.800000 1.161186 1.374632 3.41e-10 2.97e-10 - 0.900000 1.144904 1.245763 3.23e-10 3.04e-10 - 1.000000 1.127010 1.691839 3.02e-10 3.14e-10 - 1.100000 1.107609 1.000489 2.71e-10 3.23e-10 - 1.200000 1.086821 1.677552 2.54e-10 3.27e-10 - 1.300000 1.064777 1.277775 2.27e-10 3.33e-10 - 1.400000 1.041625 1.342455 1.95e-10 3.31e-10 - 1.500000 1.017531 1.642940 1.57e-10 3.21e-10 - 1.600000 0.992673 1.012112 1.21e-10 3.14e-10 - 1.700000 0.967253 1.714058 7.79e-11 2.93e-10 - 1.800000 0.941488 1.183867 3.33e-11 2.75e-10 - 1.900000 0.915617 1.437465 1.79e-11 2.47e-10 - 2.000000 0.889903 1.577082 7.24e-11 2.14e-10 - 2.100000 0.864625 1.056467 1.32e-10 1.79e-10 - 2.200000 0.840089 1.730920 1.96e-10 1.31e-10 - 2.300000 0.816616 1.101047 2.61e-10 8.71e-11 - 2.400000 0.794546 1.525051 3.30e-10 3.06e-11 - 2.500000 0.774227 1.496993 4.23e-10 4.32e-11 - 2.600000 0.756013 1.126857 4.68e-10 1.03e-10 - 2.700000 0.740246 1.727536 5.36e-10 1.73e-10 - 2.800000 0.727247 1.038393 5.93e-10 2.37e-10 - 2.900000 0.717301 1.600759 5.07e-10 3.10e-10 - 3.000000 0.710636 1.406380 6.73e-10 3.77e-10 - 3.100000 0.707412 1.214353 6.94e-10 4.43e-10 - 3.200000 0.707709 1.704026 6.99e-10 5.06e-10 - 3.300000 0.711520 1.004391 6.73e-10 5.54e-10 - 3.400000 0.718750 1.661225 6.52e-10 6.03e-10 - 3.500000 0.729227 1.310102 6.01e-10 6.37e-10 - 3.600000 0.742712 1.310080 5.52e-10 6.60e-10 - 3.700000 0.758914 1.661237 4.89e-10 6.76e-10 - 3.800000 0.777506 1.004387 4.21e-10 6.73e-10 - 3.900000 0.798144 1.704019 3.62e-10 6.70e-10 - 4.000000 0.820474 1.214374 2.84e-10 6.49e-10 - 4.100000 0.844149 1.406358 3.44e-10 6.18e-10 - 4.200000 0.868832 1.600774 1.51e-10 5.77e-10 - 4.300000 0.894204 1.038382 9.09e-11 5.60e-10 - 4.400000 0.919964 1.727533 4.16e-11 5.12e-10 - 4.500000 0.945834 1.126875 1.62e-11 4.84e-10 - 4.600000 0.971557 1.496974 6.43e-11 4.18e-10 - 4.700000 0.996898 1.525070 1.06e-10 3.66e-10 - 4.800000 1.021641 1.101030 1.47e-10 3.27e-10 - 4.900000 1.045589 1.730922 1.85e-10 2.48e-10 - 5.000000 1.068565 1.056480 3.43e-10 2.19e-10 + 0.200000 1.220669 1.551800 4.06e-10 1.12e-10 + 0.300000 1.215594 1.467737 3.95e-10 1.60e-10 + 0.400000 1.208524 1.154583 3.88e-10 2.03e-10 + 0.500000 1.199496 1.721908 3.80e-10 2.39e-10 + 0.600000 1.188557 1.023517 3.81e-10 2.70e-10 + 0.700000 1.175764 1.622751 3.29e-10 3.02e-10 + 0.800000 1.161186 1.374632 3.41e-10 3.23e-10 + 0.900000 1.144904 1.245763 3.23e-10 3.41e-10 + 1.000000 1.127010 1.691839 3.03e-10 3.56e-10 + 1.100000 1.107609 1.000489 2.71e-10 3.60e-10 + 1.200000 1.086821 1.677552 2.54e-10 3.60e-10 + 1.300000 1.064777 1.277775 2.27e-10 3.64e-10 + 1.400000 1.041625 1.342455 1.95e-10 3.59e-10 + 1.500000 1.017531 1.642940 1.58e-10 3.46e-10 + 1.600000 0.992673 1.012112 1.21e-10 3.37e-10 + 1.700000 0.967253 1.714058 7.81e-11 3.14e-10 + 1.800000 0.941488 1.183867 3.34e-11 2.95e-10 + 1.900000 0.915617 1.437465 1.78e-11 2.65e-10 + 2.000000 0.889903 1.577082 7.23e-11 2.30e-10 + 2.100000 0.864625 1.056467 1.32e-10 1.95e-10 + 2.200000 0.840089 1.730920 1.96e-10 1.46e-10 + 2.300000 0.816616 1.101047 2.61e-10 1.01e-10 + 2.400000 0.794546 1.525051 3.30e-10 4.30e-11 + 2.500000 0.774227 1.496993 4.23e-10 3.21e-11 + 2.600000 0.756013 1.126857 4.68e-10 9.29e-11 + 2.700000 0.740246 1.727536 5.36e-10 1.64e-10 + 2.800000 0.727247 1.038393 5.93e-10 2.29e-10 + 2.900000 0.717301 1.600759 5.07e-10 3.03e-10 + 3.000000 0.710636 1.406380 6.73e-10 3.71e-10 + 3.100000 0.707412 1.214353 6.94e-10 4.36e-10 + 3.200000 0.707709 1.704026 6.99e-10 5.01e-10 + 3.300000 0.711520 1.004391 6.73e-10 5.49e-10 + 3.400000 0.718750 1.661225 6.52e-10 5.98e-10 + 3.500000 0.729227 1.310102 6.01e-10 6.31e-10 + 3.600000 0.742712 1.310080 5.52e-10 6.56e-10 + 3.700000 0.758914 1.661237 4.89e-10 6.71e-10 + 3.800000 0.777506 1.004387 4.21e-10 6.69e-10 + 3.900000 0.798144 1.704019 3.62e-10 6.66e-10 + 4.000000 0.820474 1.214374 2.84e-10 6.45e-10 + 4.100000 0.844149 1.406358 3.44e-10 6.14e-10 + 4.200000 0.868832 1.600774 1.51e-10 5.74e-10 + 4.300000 0.894204 1.038382 9.08e-11 5.56e-10 + 4.400000 0.919964 1.727533 4.15e-11 5.08e-10 + 4.500000 0.945834 1.126875 1.62e-11 4.80e-10 + 4.600000 0.971557 1.496974 6.43e-11 4.14e-10 + 4.700000 0.996898 1.525070 1.06e-10 3.63e-10 + 4.800000 1.021641 1.101030 1.47e-10 3.24e-10 + 4.900000 1.045589 1.730922 1.85e-10 2.45e-10 + 5.000000 1.068565 1.056480 3.43e-10 2.17e-10 ------------------------------------------------------ Final Solver Statistics: Steps: nsts = 5000, nstf = 510000 - u error = 3.763e-10, v error = 3.905e-10, total error = 3.835e-10 - Total RHS evals: Fs = 35263, Ff = 1530050 + u error = 3.764e-10, v error = 3.952e-10, total error = 3.859e-10 + Total RHS evals: Fs = 35313, Ff = 1535050 Slow Newton iters = 30312 Slow Newton conv fails = 0 Slow Jacobian evals = 250 diff --git a/examples/arkode/C_serial/ark_kpr_mri_9_3_0.001_-100_100_0.5_1.out b/examples/arkode/C_serial/ark_kpr_mri_9_3_0.001_-100_100_0.5_1.out index 969eb31845..4c01ea05c2 100644 --- a/examples/arkode/C_serial/ark_kpr_mri_9_3_0.001_-100_100_0.5_1.out +++ b/examples/arkode/C_serial/ark_kpr_mri_9_3_0.001_-100_100_0.5_1.out @@ -67,7 +67,7 @@ Multirate nonlinear Kvaerno-Prothero-Robinson test problem: Final Solver Statistics: Steps: nsts = 5000, nstf = 510000 u error = 1.860e-10, v error = 1.672e-10, total error = 1.769e-10 - Total RHS evals: Fse = 20001, Fsi = 35342, Ff = 1530050 + Total RHS evals: Fse = 20001, Fsi = 35342, Ff = 1535050 Slow Newton iters = 30341 Slow Newton conv fails = 0 Slow Jacobian evals = 250 diff --git a/examples/arkode/C_serial/ark_onewaycouple_mri.out b/examples/arkode/C_serial/ark_onewaycouple_mri.out index 3769f0e775..a0738fc01b 100644 --- a/examples/arkode/C_serial/ark_onewaycouple_mri.out +++ b/examples/arkode/C_serial/ark_onewaycouple_mri.out @@ -20,4 +20,4 @@ One way coupling ODE test problem: Final Solver Statistics: Steps: nsts = 1000, nstf = 12000 - Total RHS evals: Fs = 3001, Ff = 36010 + Total RHS evals: Fs = 3001, Ff = 37010 diff --git a/examples/arkode/C_serial/ark_reaction_diffusion_mri.out b/examples/arkode/C_serial/ark_reaction_diffusion_mri.out index aae34dd19e..a68ab7d0d5 100644 --- a/examples/arkode/C_serial/ark_reaction_diffusion_mri.out +++ b/examples/arkode/C_serial/ark_reaction_diffusion_mri.out @@ -69,7 +69,7 @@ Inequality constraint fails = 0 Initial step size = 2e-05 Last step size = 9.999999998289147e-06 Current step size = 2e-05 -Explicit RHS fn evals = 459183 +Explicit RHS fn evals = 462184 Implicit RHS fn evals = 0 NLS iters = 0 NLS fails = 0 diff --git a/examples/arkode/C_serial/ark_twowaycouple_mri.out b/examples/arkode/C_serial/ark_twowaycouple_mri.out index 8aee3f02b7..d079ae454a 100644 --- a/examples/arkode/C_serial/ark_twowaycouple_mri.out +++ b/examples/arkode/C_serial/ark_twowaycouple_mri.out @@ -30,4 +30,4 @@ Two way coupling ODE test problem: Final Solver Statistics: Steps: nsts = 2001, nstf = 102051 - Total RHS evals: Fs = 6004, Ff = 306173 + Total RHS evals: Fs = 6004, Ff = 308174 diff --git a/test/unit_tests/arkode/CXX_serial/ark_test_brusselator_mriadapt_--rtol_0.000004_--scontrol_0.out b/test/unit_tests/arkode/CXX_serial/ark_test_brusselator_mriadapt_--rtol_0.000004_--scontrol_0.out index 18ebb4b2b5..760c6d2b1d 100644 --- a/test/unit_tests/arkode/CXX_serial/ark_test_brusselator_mriadapt_--rtol_0.000004_--scontrol_0.out +++ b/test/unit_tests/arkode/CXX_serial/ark_test_brusselator_mriadapt_--rtol_0.000004_--scontrol_0.out @@ -40,4 +40,4 @@ Final Solver Statistics: Fast steps = 11777 (attempts = 16708, fails = 4931) u error = 1.83324e-06, v error = 1.63119e-06, w error = 5.54867e-05, total error = 3.20666e-05 Relative accuracy = 83.5081 - Total RHS evals: Fse = 5000, Fsi = 0, Ff = 78611 + Total RHS evals: Fse = 5000, Fsi = 0, Ff = 79611 diff --git a/test/unit_tests/arkode/CXX_serial/ark_test_kpr_mriadapt_--hs_0.002_--rtol_0.000004_--scontrol_0.out b/test/unit_tests/arkode/CXX_serial/ark_test_kpr_mriadapt_--hs_0.002_--rtol_0.000004_--scontrol_0.out index 919af7ddc9..8e57f80640 100644 --- a/test/unit_tests/arkode/CXX_serial/ark_test_kpr_mriadapt_--hs_0.002_--rtol_0.000004_--scontrol_0.out +++ b/test/unit_tests/arkode/CXX_serial/ark_test_kpr_mriadapt_--hs_0.002_--rtol_0.000004_--scontrol_0.out @@ -42,4 +42,4 @@ Final Solver Statistics: Fast steps = 12502 (attempts = 12502, fails = 0) u error = 4.31846e-11, v error = 9.52053e-09, total error = 6.7321e-09 Relative accuracy = 0.0160086 - Total RHS evals: Fse = 12500, Fsi = 0, Ff = 62512 + Total RHS evals: Fse = 12500, Fsi = 0, Ff = 65012 From 73fa151c6b00722bcf45ec4a61652dd9cbb5262d Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Mon, 2 Dec 2024 08:06:48 -0600 Subject: [PATCH 272/286] Fixed a few more Jenkins .out files --- .../C_serial/ark_brusselator1D_imexmri_2_0.001.out | 2 +- .../C_serial/ark_brusselator1D_imexmri_3_0.001.out | 2 +- examples/arkode/C_serial/ark_kpr_mri_6_5_0.001.out | 10 +++++----- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/examples/arkode/C_serial/ark_brusselator1D_imexmri_2_0.001.out b/examples/arkode/C_serial/ark_brusselator1D_imexmri_2_0.001.out index c9dfa5f415..8e29c07a32 100644 --- a/examples/arkode/C_serial/ark_brusselator1D_imexmri_2_0.001.out +++ b/examples/arkode/C_serial/ark_brusselator1D_imexmri_2_0.001.out @@ -30,7 +30,7 @@ Final Solver Statistics: Slow Steps: nsts = 10001 Fast Steps: nstf = 120012 - Total RHS evals: Fs = 68877, Ff = 370047 + Total RHS evals: Fs = 68887, Ff = 370047 Slow Newton iters = 38883 Slow Newton conv fails = 0 Slow Jacobian evals = 501 diff --git a/examples/arkode/C_serial/ark_brusselator1D_imexmri_3_0.001.out b/examples/arkode/C_serial/ark_brusselator1D_imexmri_3_0.001.out index 189c065b52..254fe649e5 100644 --- a/examples/arkode/C_serial/ark_brusselator1D_imexmri_3_0.001.out +++ b/examples/arkode/C_serial/ark_brusselator1D_imexmri_3_0.001.out @@ -30,7 +30,7 @@ Final Solver Statistics: Slow Steps: nsts = 10001 Fast Steps: nstf = 120012 - Total RHS evals: Fs = 68877, Ff = 850122 + Total RHS evals: Fs = 68887, Ff = 850122 Slow Newton iters = 38883 Slow Newton conv fails = 0 Slow Jacobian evals = 501 diff --git a/examples/arkode/C_serial/ark_kpr_mri_6_5_0.001.out b/examples/arkode/C_serial/ark_kpr_mri_6_5_0.001.out index 174ea42698..88573af8aa 100644 --- a/examples/arkode/C_serial/ark_kpr_mri_6_5_0.001.out +++ b/examples/arkode/C_serial/ark_kpr_mri_6_5_0.001.out @@ -23,12 +23,12 @@ Multirate nonlinear Kvaerno-Prothero-Robinson test problem: 1.000000 1.127010 1.691839 3.32e-13 4.77e-14 1.100000 1.107609 1.000489 3.33e-13 4.28e-12 1.200000 1.086821 1.677552 2.90e-13 2.44e-13 - 1.300000 1.064777 1.277775 2.74e-13 2.18e-13 + 1.300000 1.064777 1.277775 2.73e-13 2.18e-12 1.400000 1.041625 1.342455 2.24e-13 1.65e-12 - 1.500000 1.017531 1.642940 1.92e-13 4.45e-13 - 1.600000 0.992673 1.012112 1.52e-13 5.55e-12 - 1.700000 0.967253 1.714058 9.33e-14 1.09e-12 - 1.800000 0.941488 1.183867 5.52e-14 2.24e-12 + 1.500000 1.017531 1.642940 1.91e-13 4.45e-13 + 1.600000 0.992673 1.012112 1.51e-13 3.56e-12 + 1.700000 0.967253 1.714058 9.28e-14 1.09e-12 + 1.800000 0.941488 1.183867 5.50e-14 2.24e-12 1.900000 0.915617 1.437465 1.53e-14 5.52e-13 2.000000 0.889903 1.577082 6.75e-14 4.87e-13 2.100000 0.864625 1.056467 1.36e-13 2.86e-12 From 08fffdad62b9ab7450cf52c2ba6ba0e6f6c1c200 Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Mon, 2 Dec 2024 09:26:34 -0600 Subject: [PATCH 273/286] Fixed a few more Jenkins .out files --- .../arkode/F2003_serial/ark_kpr_mri_f2003.out | 2 +- .../ark_kpr_mri_f2003_0_0.002.out | 2 +- .../ark_kpr_mri_f2003_1_0.002.out | 2 +- .../F2003_serial/ark_kpr_mri_f2003_3_0.01.out | 2 +- .../ark_kpr_mri_f2003_4_0.002.out | 88 +++++++++---------- .../ark_kpr_mri_f2003_5_0.002.out | 58 ++++++------ .../ark_kpr_mri_f2003_6_0.005.out | 4 +- .../ark_kpr_mri_f2003_7_0.001.out | 72 +++++++-------- .../ark_kpr_mri_f2003_8_0.001.out | 2 +- .../ark_kpr_mri_f2003_9_0.001.out | 82 ++++++++--------- 10 files changed, 156 insertions(+), 158 deletions(-) diff --git a/examples/arkode/F2003_serial/ark_kpr_mri_f2003.out b/examples/arkode/F2003_serial/ark_kpr_mri_f2003.out index 9bdbea5dcb..5cbb350b61 100644 --- a/examples/arkode/F2003_serial/ark_kpr_mri_f2003.out +++ b/examples/arkode/F2003_serial/ark_kpr_mri_f2003.out @@ -63,4 +63,4 @@ Final Solver Statistics: Steps: nsts = 501, nstf = 50601 u error = 0.794E-06, v error = 0.825E-07, total error = 0.565E-06 - Total RHS evals: Fs = 1504, Ff = 151853 + Total RHS evals: Fs = 1504, Ff = 152354 diff --git a/examples/arkode/F2003_serial/ark_kpr_mri_f2003_0_0.002.out b/examples/arkode/F2003_serial/ark_kpr_mri_f2003_0_0.002.out index c5001c9ed2..0eff8ab4a8 100644 --- a/examples/arkode/F2003_serial/ark_kpr_mri_f2003_0_0.002.out +++ b/examples/arkode/F2003_serial/ark_kpr_mri_f2003_0_0.002.out @@ -63,4 +63,4 @@ Final Solver Statistics: Steps: nsts = 2501, nstf = 252601 u error = 0.467E-08, v error = 0.564E-09, total error = 0.333E-08 - Total RHS evals: Fs = 7504, Ff = 757853 + Total RHS evals: Fs = 7504, Ff = 760354 diff --git a/examples/arkode/F2003_serial/ark_kpr_mri_f2003_1_0.002.out b/examples/arkode/F2003_serial/ark_kpr_mri_f2003_1_0.002.out index c84e3cde4b..5cdfce99f9 100644 --- a/examples/arkode/F2003_serial/ark_kpr_mri_f2003_1_0.002.out +++ b/examples/arkode/F2003_serial/ark_kpr_mri_f2003_1_0.002.out @@ -63,4 +63,4 @@ Final Solver Statistics: Steps: nsts = 2501, nstf = 252601 u error = 0.316E-12, v error = 0.191E-11, total error = 0.137E-11 - Total RHS evals: Fs = 5003, Ff = 757853 + Total RHS evals: Fs = 5003, Ff = 760354 diff --git a/examples/arkode/F2003_serial/ark_kpr_mri_f2003_3_0.01.out b/examples/arkode/F2003_serial/ark_kpr_mri_f2003_3_0.01.out index fb98664760..2bd6749831 100644 --- a/examples/arkode/F2003_serial/ark_kpr_mri_f2003_3_0.01.out +++ b/examples/arkode/F2003_serial/ark_kpr_mri_f2003_3_0.01.out @@ -63,4 +63,4 @@ Final Solver Statistics: Steps: nsts = 501, nstf = 50601 u error = 0.505E-04, v error = 0.768E-03, total error = 0.545E-03 - Total RHS evals: Fs = 1504, Ff = 151853 + Total RHS evals: Fs = 1504, Ff = 152354 diff --git a/examples/arkode/F2003_serial/ark_kpr_mri_f2003_4_0.002.out b/examples/arkode/F2003_serial/ark_kpr_mri_f2003_4_0.002.out index 9aa6c31a91..0fa85a2c8c 100644 --- a/examples/arkode/F2003_serial/ark_kpr_mri_f2003_4_0.002.out +++ b/examples/arkode/F2003_serial/ark_kpr_mri_f2003_4_0.002.out @@ -18,53 +18,53 @@ 0.600000 1.188564 1.025537 0.74E-05 0.20E-02 0.700000 1.175763 1.622485 0.12E-05 0.27E-03 0.800000 1.161186 1.374900 0.25E-06 0.27E-03 - 0.900000 1.144904 1.246518 0.45E-06 0.75E-03 - 1.000000 1.127011 1.691383 0.85E-06 0.46E-03 - 1.100000 1.107615 1.002555 0.57E-05 0.21E-02 - 1.200000 1.086819 1.677049 0.18E-05 0.50E-03 - 1.300000 1.064782 1.278212 0.56E-05 0.44E-03 - 1.400000 1.041624 1.342668 0.13E-05 0.21E-03 - 1.500000 1.017531 1.642387 0.80E-06 0.55E-03 - 1.600000 0.992677 1.013922 0.34E-05 0.18E-02 - 1.700000 0.967249 1.713363 0.34E-05 0.70E-03 - 1.800000 0.941493 1.184574 0.53E-05 0.71E-03 - 1.900000 0.915615 1.437301 0.24E-05 0.16E-03 - 2.000000 0.889904 1.576560 0.13E-05 0.52E-03 - 2.100000 0.864627 1.057865 0.15E-05 0.14E-02 - 2.200000 0.840086 1.730082 0.26E-05 0.84E-03 - 2.300000 0.816622 1.102105 0.56E-05 0.11E-02 - 2.400000 0.794543 1.524597 0.33E-05 0.45E-03 - 2.500000 0.774230 1.496572 0.20E-05 0.42E-03 - 2.600000 0.756013 1.127777 0.20E-06 0.92E-03 - 2.700000 0.740244 1.726675 0.20E-05 0.86E-03 - 2.800000 0.727253 1.039846 0.53E-05 0.15E-02 - 2.900000 0.717298 1.600124 0.33E-05 0.63E-03 - 3.000000 0.710633 1.406188 0.31E-05 0.19E-03 - 3.100000 0.707411 1.214834 0.13E-05 0.48E-03 - 3.200000 0.707708 1.703186 0.13E-05 0.84E-03 - 3.300000 0.711524 1.006093 0.43E-05 0.17E-02 - 3.400000 0.718746 1.660457 0.34E-05 0.77E-03 - 3.500000 0.729231 1.310187 0.40E-05 0.85E-04 - 3.600000 0.742710 1.310183 0.22E-05 0.10E-03 - 3.700000 0.758913 1.660456 0.50E-06 0.78E-03 - 3.800000 0.777509 1.006081 0.30E-05 0.17E-02 - 3.900000 0.798140 1.703183 0.39E-05 0.84E-03 - 4.000000 0.820479 1.214815 0.46E-05 0.44E-03 - 4.100000 0.844146 1.406159 0.28E-05 0.20E-03 - 4.200000 0.868833 1.600098 0.40E-06 0.68E-03 - 4.300000 0.894205 1.039810 0.15E-05 0.14E-02 - 4.400000 0.919961 1.726622 0.29E-05 0.91E-03 - 4.500000 0.945839 1.127712 0.52E-05 0.84E-03 - 4.600000 0.971554 1.496517 0.34E-05 0.46E-03 - 4.700000 0.996899 1.524526 0.13E-05 0.54E-03 - 4.800000 1.021641 1.102047 0.10E-07 0.10E-02 - 4.900000 1.045587 1.730008 0.21E-05 0.91E-03 - 5.000000 1.068570 1.057757 0.52E-05 0.13E-02 + 0.900000 1.144904 1.246450 0.11E-06 0.69E-03 + 1.000000 1.127010 1.691322 0.54E-06 0.52E-03 + 1.100000 1.107615 1.002500 0.54E-05 0.20E-02 + 1.200000 1.086818 1.677003 0.21E-05 0.55E-03 + 1.300000 1.064782 1.278198 0.55E-05 0.42E-03 + 1.400000 1.041624 1.342655 0.14E-05 0.20E-03 + 1.500000 1.017531 1.642375 0.74E-06 0.56E-03 + 1.600000 0.992677 1.013911 0.34E-05 0.18E-02 + 1.700000 0.967249 1.713353 0.35E-05 0.71E-03 + 1.800000 0.941493 1.184579 0.54E-05 0.71E-03 + 1.900000 0.915615 1.437305 0.24E-05 0.16E-03 + 2.000000 0.889904 1.576564 0.13E-05 0.52E-03 + 2.100000 0.864627 1.057868 0.15E-05 0.14E-02 + 2.200000 0.840087 1.730117 0.24E-05 0.80E-03 + 2.300000 0.816622 1.102136 0.58E-05 0.11E-02 + 2.400000 0.794543 1.524625 0.31E-05 0.43E-03 + 2.500000 0.774230 1.496597 0.22E-05 0.40E-03 + 2.600000 0.756013 1.127800 0.77E-07 0.94E-03 + 2.700000 0.740244 1.726696 0.18E-05 0.84E-03 + 2.800000 0.727253 1.039861 0.53E-05 0.15E-02 + 2.900000 0.717298 1.600138 0.32E-05 0.62E-03 + 3.000000 0.710633 1.406200 0.30E-05 0.18E-03 + 3.100000 0.707411 1.214845 0.12E-05 0.49E-03 + 3.200000 0.707708 1.703196 0.12E-05 0.83E-03 + 3.300000 0.711524 1.006102 0.44E-05 0.17E-02 + 3.400000 0.718746 1.660466 0.34E-05 0.76E-03 + 3.500000 0.729231 1.310194 0.41E-05 0.93E-04 + 3.600000 0.742710 1.310190 0.22E-05 0.11E-03 + 3.700000 0.758913 1.660462 0.47E-06 0.77E-03 + 3.800000 0.777509 1.006087 0.31E-05 0.17E-02 + 3.900000 0.798140 1.703188 0.39E-05 0.83E-03 + 4.000000 0.820479 1.214819 0.46E-05 0.45E-03 + 4.100000 0.844147 1.406163 0.28E-05 0.20E-03 + 4.200000 0.868833 1.600102 0.42E-06 0.67E-03 + 4.300000 0.894205 1.039813 0.15E-05 0.14E-02 + 4.400000 0.919961 1.726651 0.28E-05 0.88E-03 + 4.500000 0.945839 1.127737 0.53E-05 0.86E-03 + 4.600000 0.971554 1.496541 0.33E-05 0.43E-03 + 4.700000 0.996899 1.524547 0.14E-05 0.52E-03 + 4.800000 1.021641 1.102066 0.86E-07 0.10E-02 + 4.900000 1.045587 1.730025 0.20E-05 0.90E-03 + 5.000000 1.068570 1.057773 0.53E-05 0.13E-02 ------------------------------------------------------ Final Solver Statistics: Steps: nsts = 2501, nstf = 250100 - u error = 0.349E-05, v error = 0.956E-03, total error = 0.676E-03 - Total RHS evals: Fs = 7093, Ff = 750350 + u error = 0.348E-05, v error = 0.953E-03, total error = 0.674E-03 + Total RHS evals: Fs = 7143, Ff = 752851 Slow Newton iters = 4641 Slow Newton conv fails = 0 Slow Jacobian evals = 126 diff --git a/examples/arkode/F2003_serial/ark_kpr_mri_f2003_5_0.002.out b/examples/arkode/F2003_serial/ark_kpr_mri_f2003_5_0.002.out index 48dd3ab5e5..3c6541a431 100644 --- a/examples/arkode/F2003_serial/ark_kpr_mri_f2003_5_0.002.out +++ b/examples/arkode/F2003_serial/ark_kpr_mri_f2003_5_0.002.out @@ -31,36 +31,34 @@ 2.000000 0.889903 1.577082 0.33E-10 0.47E-10 2.100000 0.864625 1.056467 0.59E-10 0.36E-10 2.200000 0.840089 1.730920 0.87E-10 0.32E-10 - 2.300000 0.816616 1.101047 0.12E-09 0.20E-10 - 2.400000 0.794546 1.525051 0.15E-09 0.78E-11 - 2.500000 0.774227 1.496993 0.18E-09 0.25E-11 - 2.600000 0.756013 1.126857 0.21E-09 0.20E-10 - 2.700000 0.740246 1.727536 0.24E-09 0.23E-10 - 2.800000 0.727247 1.038393 0.26E-09 0.42E-10 - 2.900000 0.717301 1.600759 0.28E-09 0.59E-10 - 3.000000 0.710636 1.406380 0.30E-09 0.62E-10 - 3.100000 0.707412 1.214353 0.31E-09 0.92E-10 - 3.200000 0.707709 1.704026 0.31E-09 0.87E-10 - 3.300000 0.711520 1.004391 0.30E-09 0.11E-09 - 3.400000 0.718750 1.661225 0.29E-09 0.12E-09 - 3.500000 0.729227 1.310102 0.27E-09 0.11E-09 - 3.600000 0.742712 1.310080 0.24E-09 0.14E-09 - 3.700000 0.758914 1.661237 0.22E-09 0.12E-09 - 3.800000 0.777506 1.004387 0.19E-09 0.14E-09 - 3.900000 0.798144 1.704019 0.15E-09 0.13E-09 - 4.000000 0.820474 1.214374 0.12E-09 0.12E-09 - 4.100000 0.844149 1.406358 0.94E-10 0.14E-09 - 4.200000 0.868832 1.600774 0.65E-10 0.99E-10 - 4.300000 0.894204 1.038382 0.39E-10 0.12E-09 - 4.400000 0.919964 1.727533 0.14E-10 0.96E-10 - 4.500000 0.945834 1.126875 0.89E-11 0.80E-10 - 4.600000 0.971557 1.496974 0.30E-10 0.98E-10 - 4.700000 0.996898 1.525070 0.49E-10 0.49E-10 - 4.800000 1.021641 1.101030 0.67E-10 0.78E-10 - 4.900000 1.045589 1.730922 0.83E-10 0.39E-10 - 5.000000 1.068565 1.056480 0.97E-10 0.32E-10 + 2.300000 0.816616 1.101047 0.12E-09 0.19E-10 + 2.400000 0.794546 1.525051 0.15E-09 0.11E-10 + 2.500000 0.774227 1.496993 0.18E-09 0.12E-11 + 2.600000 0.756013 1.126857 0.21E-09 0.16E-10 + 2.700000 0.740246 1.727536 0.24E-09 0.25E-10 + 2.800000 0.727247 1.038393 0.26E-09 0.44E-10 + 2.900000 0.717301 1.600759 0.28E-09 0.54E-10 + 3.000000 0.710636 1.406380 0.30E-09 0.69E-10 + 3.100000 0.707412 1.214353 0.31E-09 0.84E-10 + 3.200000 0.707709 1.704026 0.31E-09 0.93E-10 + 3.400000 0.718750 1.661225 0.29E-09 0.11E-09 + 3.500000 0.729227 1.310102 0.27E-09 0.12E-09 + 3.600000 0.742712 1.310080 0.24E-09 0.13E-09 + 3.700000 0.758914 1.661237 0.22E-09 0.13E-09 + 3.800000 0.777506 1.004387 0.19E-09 0.13E-09 + 4.000000 0.820474 1.214374 0.12E-09 0.13E-09 + 4.100000 0.844149 1.406358 0.94E-10 0.12E-09 + 4.200000 0.868832 1.600774 0.65E-10 0.11E-09 + 4.300000 0.894204 1.038382 0.39E-10 0.11E-09 + 4.400000 0.919964 1.727533 0.14E-10 0.97E-10 + 4.500000 0.945834 1.126875 0.89E-11 0.91E-10 + 4.600000 0.971557 1.496974 0.30E-10 0.79E-10 + 4.700000 0.996898 1.525070 0.49E-10 0.69E-10 + 4.800000 1.021641 1.101030 0.67E-10 0.61E-10 + 4.900000 1.045589 1.730922 0.83E-10 0.47E-10 + 5.000000 1.068565 1.056480 0.97E-10 0.40E-10 ------------------------------------------------------ Final Solver Statistics: Steps: nsts = 2501, nstf = 250100 - u error = 0.166E-09, v error = 0.771E-10, total error = 0.130E-09 - Total RHS evals: Fs = 12506, Ff = 1000450 + u error = 0.166E-09, v error = 0.768E-10, total error = 0.130E-09 + Total RHS evals: Fs = 12506, Ff = 1002951 diff --git a/examples/arkode/F2003_serial/ark_kpr_mri_f2003_6_0.005.out b/examples/arkode/F2003_serial/ark_kpr_mri_f2003_6_0.005.out index fa764c5633..489db047df 100644 --- a/examples/arkode/F2003_serial/ark_kpr_mri_f2003_6_0.005.out +++ b/examples/arkode/F2003_serial/ark_kpr_mri_f2003_6_0.005.out @@ -33,7 +33,7 @@ 2.200000 0.840089 1.730920 0.39E-08 0.13E-08 2.300000 0.816616 1.101047 0.53E-08 0.90E-09 2.400000 0.794546 1.525051 0.67E-08 0.45E-09 - 2.500000 0.774227 1.496993 0.80E-08 0.39E-10 + 2.500000 0.774227 1.496993 0.80E-08 0.42E-10 2.600000 0.756013 1.126857 0.94E-08 0.57E-09 2.700000 0.740246 1.727536 0.11E-07 0.11E-08 2.800000 0.727247 1.038393 0.12E-07 0.17E-08 @@ -63,4 +63,4 @@ Final Solver Statistics: Steps: nsts = 1001, nstf = 100100 u error = 0.757E-08, v error = 0.324E-08, total error = 0.582E-08 - Total RHS evals: Fs = 5006, Ff = 300350 + Total RHS evals: Fs = 5006, Ff = 301351 diff --git a/examples/arkode/F2003_serial/ark_kpr_mri_f2003_7_0.001.out b/examples/arkode/F2003_serial/ark_kpr_mri_f2003_7_0.001.out index ff922403a8..e891da3ce5 100644 --- a/examples/arkode/F2003_serial/ark_kpr_mri_f2003_7_0.001.out +++ b/examples/arkode/F2003_serial/ark_kpr_mri_f2003_7_0.001.out @@ -11,60 +11,60 @@ ------------------------------------------------------ 0.000000 1.224745 1.732051 0.00E+00 0.00E+00 0.100000 1.223725 1.077464 0.40E-09 0.57E-10 - 0.200000 1.220669 1.551800 0.41E-09 0.10E-09 - 0.300000 1.215594 1.467737 0.39E-09 0.15E-09 - 0.400000 1.208524 1.154583 0.39E-09 0.18E-09 - 0.500000 1.199496 1.721908 0.38E-09 0.21E-09 - 0.600000 1.188557 1.023517 0.38E-09 0.25E-09 - 0.700000 1.175764 1.622751 0.35E-09 0.28E-09 - 0.800000 1.161186 1.374632 0.34E-09 0.30E-09 - 0.900000 1.144904 1.245763 0.32E-09 0.30E-09 - 1.000000 1.127010 1.691839 0.30E-09 0.31E-09 - 1.100000 1.107609 1.000489 0.28E-09 0.33E-09 - 1.200000 1.086821 1.677552 0.25E-09 0.33E-09 - 1.300000 1.064777 1.277775 0.23E-09 0.34E-09 - 1.400000 1.041625 1.342455 0.20E-09 0.34E-09 - 1.500000 1.017531 1.642940 0.16E-09 0.33E-09 - 1.600000 0.992673 1.012112 0.12E-09 0.32E-09 - 1.700000 0.967253 1.714058 0.78E-10 0.30E-09 - 1.800000 0.941488 1.183867 0.35E-10 0.28E-09 - 1.900000 0.915617 1.437465 0.17E-10 0.25E-09 - 2.000000 0.889903 1.577082 0.70E-10 0.22E-09 - 2.100000 0.864625 1.056467 0.13E-09 0.18E-09 - 2.200000 0.840089 1.730920 0.20E-09 0.13E-09 - 2.300000 0.816616 1.101047 0.26E-09 0.90E-10 - 2.400000 0.794546 1.525051 0.33E-09 0.33E-10 - 2.500000 0.774227 1.496993 0.40E-09 0.31E-10 - 2.600000 0.756013 1.126857 0.47E-09 0.92E-10 - 2.700000 0.740246 1.727536 0.54E-09 0.16E-09 - 2.800000 0.727247 1.038393 0.59E-09 0.23E-09 + 0.200000 1.220669 1.551800 0.41E-09 0.11E-09 + 0.300000 1.215594 1.467737 0.39E-09 0.16E-09 + 0.400000 1.208524 1.154583 0.39E-09 0.20E-09 + 0.500000 1.199496 1.721908 0.38E-09 0.24E-09 + 0.600000 1.188557 1.023517 0.38E-09 0.27E-09 + 0.700000 1.175764 1.622751 0.35E-09 0.30E-09 + 0.800000 1.161186 1.374632 0.34E-09 0.32E-09 + 0.900000 1.144904 1.245763 0.32E-09 0.34E-09 + 1.000000 1.127010 1.691839 0.30E-09 0.36E-09 + 1.100000 1.107609 1.000489 0.28E-09 0.37E-09 + 1.200000 1.086821 1.677552 0.25E-09 0.37E-09 + 1.300000 1.064777 1.277775 0.23E-09 0.37E-09 + 1.400000 1.041625 1.342455 0.20E-09 0.36E-09 + 1.500000 1.017531 1.642940 0.16E-09 0.35E-09 + 1.600000 0.992673 1.012112 0.12E-09 0.34E-09 + 1.700000 0.967253 1.714058 0.78E-10 0.32E-09 + 1.800000 0.941488 1.183867 0.35E-10 0.30E-09 + 1.900000 0.915617 1.437465 0.17E-10 0.27E-09 + 2.000000 0.889903 1.577082 0.70E-10 0.23E-09 + 2.100000 0.864625 1.056467 0.13E-09 0.20E-09 + 2.200000 0.840089 1.730920 0.20E-09 0.15E-09 + 2.300000 0.816616 1.101047 0.26E-09 0.10E-09 + 2.400000 0.794546 1.525051 0.33E-09 0.45E-10 + 2.500000 0.774227 1.496993 0.40E-09 0.20E-10 + 2.600000 0.756013 1.126857 0.47E-09 0.82E-10 + 2.700000 0.740246 1.727536 0.54E-09 0.15E-09 + 2.800000 0.727247 1.038393 0.59E-09 0.22E-09 2.900000 0.717301 1.600759 0.75E-09 0.30E-09 3.000000 0.710636 1.406380 0.67E-09 0.37E-09 - 3.100000 0.707412 1.214353 0.69E-09 0.44E-09 + 3.100000 0.707412 1.214353 0.69E-09 0.43E-09 3.200000 0.707709 1.704026 0.70E-09 0.50E-09 3.300000 0.711520 1.004391 0.68E-09 0.55E-09 3.400000 0.718750 1.661225 0.65E-09 0.60E-09 3.500000 0.729227 1.310102 0.60E-09 0.63E-09 - 3.600000 0.742712 1.310080 0.55E-09 0.66E-09 + 3.600000 0.742712 1.310080 0.55E-09 0.65E-09 3.700000 0.758914 1.661237 0.50E-09 0.68E-09 - 3.800000 0.777506 1.004387 0.42E-09 0.68E-09 + 3.800000 0.777506 1.004387 0.42E-09 0.67E-09 3.900000 0.798144 1.704019 0.35E-09 0.67E-09 4.000000 0.820474 1.214374 0.29E-09 0.65E-09 4.100000 0.844149 1.406358 0.26E-09 0.62E-09 4.200000 0.868832 1.600774 0.15E-09 0.58E-09 4.300000 0.894204 1.038382 0.92E-10 0.56E-09 - 4.400000 0.919964 1.727533 0.36E-10 0.50E-09 + 4.400000 0.919964 1.727533 0.36E-10 0.49E-09 4.500000 0.945834 1.126875 0.14E-10 0.47E-09 - 4.600000 0.971557 1.496974 0.63E-10 0.41E-09 + 4.600000 0.971557 1.496974 0.63E-10 0.40E-09 4.700000 0.996898 1.525070 0.10E-09 0.35E-09 - 4.800000 1.021641 1.101030 0.15E-09 0.32E-09 - 4.900000 1.045589 1.730922 0.19E-09 0.24E-09 + 4.800000 1.021641 1.101030 0.15E-09 0.31E-09 + 4.900000 1.045589 1.730922 0.19E-09 0.23E-09 5.000000 1.068565 1.056480 0.39E-10 0.21E-09 ------------------------------------------------------ Final Solver Statistics: Steps: nsts = 5000, nstf = 510000 - u error = 0.380E-09, v error = 0.389E-09, total error = 0.385E-09 - Total RHS evals: Fs = 45263, Ff = 1530050 + u error = 0.380E-09, v error = 0.394E-09, total error = 0.387E-09 + Total RHS evals: Fs = 45313, Ff = 1535050 Slow Newton iters = 30312 Slow Newton conv fails = 0 Slow Jacobian evals = 250 diff --git a/examples/arkode/F2003_serial/ark_kpr_mri_f2003_8_0.001.out b/examples/arkode/F2003_serial/ark_kpr_mri_f2003_8_0.001.out index bd101638aa..db4d9b730c 100644 --- a/examples/arkode/F2003_serial/ark_kpr_mri_f2003_8_0.001.out +++ b/examples/arkode/F2003_serial/ark_kpr_mri_f2003_8_0.001.out @@ -64,7 +64,7 @@ Final Solver Statistics: Steps: nsts = 5000, nstf = 510000 u error = 0.179E-09, v error = 0.168E-09, total error = 0.174E-09 - Total RHS evals: Fse = 20001, Fsi = 50342, Ff = 1530050 + Total RHS evals: Fse = 20001, Fsi = 50342, Ff = 1535050 Slow Newton iters = 30341 Slow Newton conv fails = 0 Slow Jacobian evals = 250 diff --git a/examples/arkode/F2003_serial/ark_kpr_mri_f2003_9_0.001.out b/examples/arkode/F2003_serial/ark_kpr_mri_f2003_9_0.001.out index 6e504b619b..726b6372d1 100644 --- a/examples/arkode/F2003_serial/ark_kpr_mri_f2003_9_0.001.out +++ b/examples/arkode/F2003_serial/ark_kpr_mri_f2003_9_0.001.out @@ -20,51 +20,51 @@ 0.800000 1.161186 1.374632 0.12E-10 0.28E-11 0.900000 1.144904 1.245763 0.11E-10 0.31E-11 1.000000 1.127010 1.691839 0.13E-10 0.22E-11 - 1.100000 1.107609 1.000489 0.11E-10 0.21E-11 - 1.200000 1.086821 1.677552 0.95E-11 0.19E-11 - 1.300000 1.064777 1.277775 0.76E-11 0.19E-11 - 1.400000 1.041625 1.342455 0.52E-11 0.26E-11 - 1.500000 1.017531 1.642940 0.60E-11 0.58E-11 - 1.600000 0.992673 1.012112 0.38E-11 0.34E-11 - 1.700000 0.967253 1.714058 0.33E-11 0.27E-11 - 1.800000 0.941488 1.183867 0.24E-12 0.38E-11 - 1.900000 0.915617 1.437465 0.33E-11 0.58E-11 - 2.000000 0.889903 1.577082 0.66E-11 0.89E-11 - 2.100000 0.864625 1.056467 0.79E-11 0.74E-11 - 2.200000 0.840089 1.730920 0.67E-11 0.45E-11 - 2.300000 0.816616 1.101047 0.12E-10 0.30E-11 - 2.400000 0.794546 1.525051 0.15E-10 0.89E-11 - 2.500000 0.774227 1.496993 0.18E-10 0.11E-10 - 2.600000 0.756013 1.126857 0.22E-10 0.14E-10 - 2.700000 0.740246 1.727536 0.20E-10 0.69E-11 - 2.800000 0.727247 1.038393 0.25E-10 0.78E-12 - 2.900000 0.717301 1.600759 0.27E-10 0.11E-10 - 3.000000 0.710636 1.406380 0.28E-10 0.11E-10 - 3.100000 0.707412 1.214353 0.29E-10 0.20E-10 - 3.200000 0.707709 1.704026 0.28E-10 0.97E-11 - 3.300000 0.711520 1.004391 0.28E-10 0.71E-11 - 3.400000 0.718750 1.661225 0.26E-10 0.11E-10 - 3.500000 0.729227 1.310102 0.24E-10 0.11E-10 - 3.600000 0.742712 1.310080 0.21E-10 0.26E-10 - 3.700000 0.758914 1.661237 0.20E-10 0.14E-10 - 3.800000 0.777506 1.004387 0.16E-10 0.14E-10 - 3.900000 0.798144 1.704019 0.14E-10 0.60E-11 - 4.000000 0.820474 1.214374 0.10E-10 0.11E-10 - 4.100000 0.844149 1.406358 0.65E-11 0.30E-10 - 4.200000 0.868832 1.600774 0.36E-11 0.50E-11 - 4.300000 0.894204 1.038382 0.16E-11 0.10E-10 - 4.400000 0.919964 1.727533 0.23E-11 0.11E-10 - 4.500000 0.945834 1.126875 0.23E-11 0.55E-11 - 4.600000 0.971557 1.496974 0.52E-11 0.15E-10 - 4.700000 0.996898 1.525070 0.85E-11 0.77E-12 - 4.800000 1.021641 1.101030 0.85E-11 0.19E-11 - 4.900000 1.045589 1.730922 0.61E-11 0.88E-11 + 1.100000 1.107609 1.000489 0.11E-10 0.20E-11 + 1.200000 1.086821 1.677552 0.95E-11 0.25E-11 + 1.300000 1.064777 1.277775 0.76E-11 0.83E-13 + 1.400000 1.041625 1.342455 0.52E-11 0.62E-12 + 1.500000 1.017531 1.642940 0.60E-11 0.26E-11 + 1.600000 0.992673 1.012112 0.38E-11 0.14E-11 + 1.700000 0.967253 1.714058 0.33E-11 0.31E-11 + 1.800000 0.941488 1.183867 0.24E-12 0.36E-12 + 1.900000 0.915617 1.437465 0.33E-11 0.12E-11 + 2.000000 0.889903 1.577082 0.66E-11 0.19E-11 + 2.100000 0.864625 1.056467 0.79E-11 0.16E-11 + 2.200000 0.840089 1.730920 0.67E-11 0.25E-11 + 2.300000 0.816616 1.101047 0.12E-10 0.18E-11 + 2.400000 0.794546 1.525051 0.15E-10 0.57E-12 + 2.500000 0.774227 1.496993 0.18E-10 0.68E-13 + 2.600000 0.756013 1.126857 0.22E-10 0.27E-11 + 2.700000 0.740246 1.727536 0.20E-10 0.73E-12 + 2.800000 0.727247 1.038393 0.25E-10 0.40E-11 + 2.900000 0.717301 1.600759 0.27E-10 0.93E-12 + 3.000000 0.710636 1.406380 0.28E-10 0.26E-11 + 3.100000 0.707412 1.214353 0.29E-10 0.42E-11 + 3.200000 0.707709 1.704026 0.28E-10 0.15E-11 + 3.300000 0.711520 1.004391 0.28E-10 0.63E-11 + 3.400000 0.718750 1.661225 0.26E-10 0.24E-11 + 3.500000 0.729227 1.310102 0.24E-10 0.48E-11 + 3.600000 0.742712 1.310080 0.21E-10 0.50E-11 + 3.700000 0.758914 1.661237 0.20E-10 0.28E-11 + 3.800000 0.777506 1.004387 0.16E-10 0.70E-11 + 3.900000 0.798144 1.704019 0.14E-10 0.25E-11 + 4.000000 0.820474 1.214374 0.10E-10 0.54E-11 + 4.100000 0.844149 1.406358 0.65E-11 0.83E-11 + 4.200000 0.868832 1.600774 0.37E-11 0.11E-10 + 4.300000 0.894204 1.038382 0.16E-11 0.25E-12 + 4.400000 0.919964 1.727533 0.23E-11 0.12E-10 + 4.500000 0.945834 1.126875 0.23E-11 0.75E-12 + 4.600000 0.971557 1.496974 0.52E-11 0.69E-11 + 4.700000 0.996898 1.525070 0.85E-11 0.69E-11 + 4.800000 1.021641 1.101030 0.85E-11 0.16E-11 + 4.900000 1.045589 1.730922 0.61E-11 0.95E-11 5.000000 1.068565 1.056480 0.10E-10 0.34E-11 ------------------------------------------------------ Final Solver Statistics: Steps: nsts = 5000, nstf = 510000 - u error = 0.153E-10, v error = 0.950E-11, total error = 0.127E-10 - Total RHS evals: Fse = 30001, Fsi = 82555, Ff = 2040050 + u error = 0.153E-10, v error = 0.419E-11, total error = 0.112E-10 + Total RHS evals: Fse = 30001, Fsi = 82555, Ff = 2045050 Slow Newton iters = 52554 Slow Newton conv fails = 0 Slow Jacobian evals = 250 From 365515a4c955c52864a333a9c2ba36f6dc28a317 Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Mon, 2 Dec 2024 11:56:22 -0600 Subject: [PATCH 274/286] Fixed one more Jenkins .out file --- examples/arkode/F2003_serial/ark_kpr_mri_f2003_5_0.002.out | 2 ++ 1 file changed, 2 insertions(+) diff --git a/examples/arkode/F2003_serial/ark_kpr_mri_f2003_5_0.002.out b/examples/arkode/F2003_serial/ark_kpr_mri_f2003_5_0.002.out index 3c6541a431..c44676ab2e 100644 --- a/examples/arkode/F2003_serial/ark_kpr_mri_f2003_5_0.002.out +++ b/examples/arkode/F2003_serial/ark_kpr_mri_f2003_5_0.002.out @@ -41,11 +41,13 @@ 3.000000 0.710636 1.406380 0.30E-09 0.69E-10 3.100000 0.707412 1.214353 0.31E-09 0.84E-10 3.200000 0.707709 1.704026 0.31E-09 0.93E-10 + 3.300000 0.711520 1.004391 0.30E-09 0.11E-09 3.400000 0.718750 1.661225 0.29E-09 0.11E-09 3.500000 0.729227 1.310102 0.27E-09 0.12E-09 3.600000 0.742712 1.310080 0.24E-09 0.13E-09 3.700000 0.758914 1.661237 0.22E-09 0.13E-09 3.800000 0.777506 1.004387 0.19E-09 0.13E-09 + 3.900000 0.798144 1.704019 0.15E-09 0.13E-09 4.000000 0.820474 1.214374 0.12E-09 0.13E-09 4.100000 0.844149 1.406358 0.94E-10 0.12E-09 4.200000 0.868832 1.600774 0.65E-10 0.11E-09 From d1de35d010a8385392300339a59b7e5e7f89dd51 Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Tue, 3 Dec 2024 21:59:39 -0600 Subject: [PATCH 275/286] Apply minor suggestions from code review Co-authored-by: David Gardner --- CHANGELOG.md | 4 ++++ doc/shared/RecentChanges.rst | 4 ++++ src/arkode/arkode_mristep.c | 3 +-- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7e6b945dfb..faf52accd4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -81,6 +81,10 @@ Fixed loading the default IMEX-MRI method if `ARKodeSetOrder` is used to specify a third or fourth order method. Previously, the default second order method was loaded in both cases. +Fixed a bug in MRIStep where the data supplied to the Hermite interpolation module did +not include contributions from the fast right-hand side function. With this fix, users +will see one additional fast right-hand side function evaluation per slow step with the +Hermite interpolation option. Fixed a CMake configuration issue related to aliasing an `ALIAS` target when using `ENABLE_KLU=ON` in combination with a static-only build of SuiteSparse. diff --git a/doc/shared/RecentChanges.rst b/doc/shared/RecentChanges.rst index 45d99e61c6..0805f6c9f8 100644 --- a/doc/shared/RecentChanges.rst +++ b/doc/shared/RecentChanges.rst @@ -85,6 +85,10 @@ Fixed loading the default IMEX-MRI method if :c:func:`ARKodeSetOrder` is used to specify a third or fourth order method. Previously, the default second order method was loaded in both cases. +Fixed a bug in MRIStep where the data supplied to the Hermite interpolation module did +not include contributions from the fast right-hand side function. With this fix, users +will see one additional fast right-hand side function evaluation per slow step with the +Hermite interpolation option. Fixed a CMake configuration issue related to aliasing an ``ALIAS`` target when using ``ENABLE_KLU=ON`` in combination with a static-only build of SuiteSparse. diff --git a/src/arkode/arkode_mristep.c b/src/arkode/arkode_mristep.c index 0bc1005350..2e731dabd9 100644 --- a/src/arkode/arkode_mristep.c +++ b/src/arkode/arkode_mristep.c @@ -2601,13 +2601,12 @@ int mriStep_TakeStepMRISR(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr) #endif } - /* combine both RHS into Fse for ImEx problems, and zero Fsi[0] since + /* combine both RHS into Fse for ImEx problems since fast forcing function only depends on Omega coefficients */ if (step_mem->implicit_rhs && step_mem->explicit_rhs) { N_VLinearSum(ONE, step_mem->Fse[stage], ONE, step_mem->Fsi[stage], step_mem->Fse[stage]); - /*N_VConst(ZERO, step_mem->Fsi[stage]);*/ } } From cd426263f8a6dc6599df189a122a69e9441da7e1 Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Tue, 3 Dec 2024 22:13:26 -0600 Subject: [PATCH 276/286] Minor recommended documenation updates --- doc/arkode/guide/source/Mathematics.rst | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/doc/arkode/guide/source/Mathematics.rst b/doc/arkode/guide/source/Mathematics.rst index 119d19c41f..1e6814ca24 100644 --- a/doc/arkode/guide/source/Mathematics.rst +++ b/doc/arkode/guide/source/Mathematics.rst @@ -704,9 +704,9 @@ t_{n,i-1}^S)/(h^S \Delta c_i^S)` is the normalized time, the coefficients :math:`k` given by .. math:: - \omega_{i,j}(\tau) = \sum_{k\geq 1} \Omega_{i,j,k} \, \tau^{k-1} + \omega_{i,j}(\tau) = \sum_{\ell = 1}^{k} \Omega_{i,j,\ell} \, \tau^{\ell-1} \quad\text{and}\quad - \gamma_{i,j}(\tau) = \sum_{k\geq 1} \Gamma_{i,j,k} \, \tau^{k-1}. + \gamma_{i,j}(\tau) = \sum_{\ell = 1}^{k} \Gamma_{i,j,\ell} \, \tau^{\ell-1}. :label: ARKODE_MRI_coupling When the slow abscissa are repeated, i.e. :math:`\Delta c_i^S = 0`, the fast IVP @@ -716,10 +716,10 @@ stage is computed as .. math:: z_i = z_{i-1} - + h^S \sum_{j=1}^{i-1} \left(\sum_{k\geq 1} - \frac{\Omega_{i,j,k}}{k}\right) f^E(t_{n,j}^S, z_j) - + h^S \sum_{j=1}^i \left(\sum_{k\geq 1} - \frac{\Gamma_{i,j,k}}{k}\right) f^I(t_{n,j}^S, z_j). + + h^S \sum_{j=1}^{i-1} \left(\sum_{\ell = 1}^{k} + \frac{\Omega_{i,j,\ell}}{\ell}\right) f^E(t_{n,j}^S, z_j) + + h^S \sum_{j=1}^i \left(\sum_{\ell = 1}^{k} + \frac{\Gamma_{i,j,\ell}}{\ell}\right) f^I(t_{n,j}^S, z_j). :label: ARKODE_MRI_delta_c_zero Similarly, the embedded solution IVP, :eq:`MRI_embedding_fast_IVP`, is evolved From 3ca2c4204ad0ed7428a94a6a401887e07b1efd77 Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Tue, 3 Dec 2024 22:17:51 -0600 Subject: [PATCH 277/286] One more documentation recommendation --- doc/arkode/guide/source/Mathematics.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/arkode/guide/source/Mathematics.rst b/doc/arkode/guide/source/Mathematics.rst index d11d17a337..d550d65635 100644 --- a/doc/arkode/guide/source/Mathematics.rst +++ b/doc/arkode/guide/source/Mathematics.rst @@ -752,7 +752,7 @@ The IMEX-MRI-SR family of methods perform *both* the fast IVP evolution, (but these methods typically have far fewer stages than implicit MRI-GARK or IMEX-MRI-GARK methods). These methods are defined by a vector of slow stage time abscissae :math:`c^S \in \mathbb{R}^{s}`, a set of coupling tensors -:math:`\Omega\in\mathbb{R}^{(s+1)\times s\times \ell}`, and a Butcher table of +:math:`\Omega\in\mathbb{R}^{(s+1)\times s\times k}`, and a Butcher table of slow-implicit coefficients, :math:`\Gamma\in\mathbb{R}^{(s+1) \times s}`. The fast stage IVPs, :eq:`MRI_fast_IVP`, are evolved on overlapping From 14bcc339dd5fc2b2c0d4681bcaf9bc34006b4908 Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Tue, 3 Dec 2024 22:21:44 -0600 Subject: [PATCH 278/286] Additional documentation suggestions --- .../source/Usage/ERKStep/User_callable.rst | 2 +- .../source/Usage/LSRKStep/User_callable.rst | 84 ++++++++++--------- .../source/Usage/MRIStep/User_callable.rst | 2 +- .../guide/source/Usage/User_callable.rst | 2 +- 4 files changed, 47 insertions(+), 43 deletions(-) diff --git a/doc/arkode/guide/source/Usage/ERKStep/User_callable.rst b/doc/arkode/guide/source/Usage/ERKStep/User_callable.rst index 6ccc5f2a10..4d9506ff76 100644 --- a/doc/arkode/guide/source/Usage/ERKStep/User_callable.rst +++ b/doc/arkode/guide/source/Usage/ERKStep/User_callable.rst @@ -33,7 +33,7 @@ ERKStep supports the following categories: * temporal adaptivity * relaxation Runge--Kutta methods -ERKStep does not have forcing function support when converted to a +ERKStep also has forcing function support when converted to a :c:type:`SUNStepper` or :c:type:`MRIStepInnerStepper`. See :c:func:`ARKodeCreateSUNStepper` and :c:func:`ARKStepCreateMRIStepInnerStepper` for additional details. diff --git a/doc/arkode/guide/source/Usage/LSRKStep/User_callable.rst b/doc/arkode/guide/source/Usage/LSRKStep/User_callable.rst index a08e5918b4..0f9d53f581 100644 --- a/doc/arkode/guide/source/Usage/LSRKStep/User_callable.rst +++ b/doc/arkode/guide/source/Usage/LSRKStep/User_callable.rst @@ -31,6 +31,10 @@ LSRKStep supports the following categories: * temporal adaptivity +LSRKStep does not have forcing function support when converted to a +:c:type:`SUNStepper` or :c:type:`MRIStepInnerStepper`. See +:c:func:`ARKodeCreateSUNStepper` and :c:func:`ARKStepCreateMRIStepInnerStepper` +for additional details. .. _ARKODE.Usage.LSRKStep.Initialization: @@ -85,7 +89,7 @@ Optional input functions .. c:function:: int LSRKStepSetSTSMethod(void* arkode_mem, ARKODE_LSRKMethodType method); - This function selects the LSRK STS method that should be used. The list of allowable + This function selects the LSRK STS method that should be used. The list of allowable values for this input is below. :c:func:`LSRKStepCreateSTS` defaults to using :c:enumerator:`ARKODE_LSRK_RKC_2`. @@ -100,7 +104,7 @@ Optional input functions .. c:function:: int LSRKStepSetSSPMethod(void* arkode_mem, ARKODE_LSRKMethodType method); - This function selects the LSRK SSP method that should be used. The list of allowable + This function selects the LSRK SSP method that should be used. The list of allowable values for this input is below. :c:func:`LSRKStepCreateSSP` defaults to using :c:enumerator:`ARKODE_LSRK_SSP_S_2`. @@ -123,20 +127,20 @@ Allowable Method Families .. c:enumerator:: ARKODE_LSRK_RKL_2 - Second order Runge--Kutta--Legendre method + Second order Runge--Kutta--Legendre method .. c:enumerator:: ARKODE_LSRK_SSP_S_2 - Second order, s-stage SSP(s,2) method + Second order, s-stage SSP(s,2) method .. c:enumerator:: ARKODE_LSRK_SSP_S_3 - Third order, s-stage SSP(s,3) method + Third order, s-stage SSP(s,3) method .. c:enumerator:: ARKODE_LSRK_SSP_10_4 Fourth order, 10-stage SSP(10,4) method - + .. c:function:: int LSRKStepSetSTSMethodByName(void* arkode_mem, const char* emethod); @@ -199,7 +203,7 @@ Allowable Method Families * *ARK_SUCCESS* if successful * *ARKLS_MEM_NULL* if ``arkode_mem`` was ``NULL``. -.. note:: If LSRKStepSetDomEigFrequency routine is not called, then the default ``nsteps`` is set to :math:`25` as recommended in :cite:p:`VSH:04`. +.. note:: If LSRKStepSetDomEigFrequency routine is not called, then the default ``nsteps`` is set to :math:`25` as recommended in :cite:p:`VSH:04`. Calling this function with ``nsteps < 0`` resets the default value while ``nsteps = 0`` refers to constant dominant eigenvalue. @@ -217,16 +221,16 @@ Allowable Method Families * *ARKLS_MEM_NULL* if ``arkode_mem`` was ``NULL``. .. note:: If LSRKStepSetMaxNumStages routine is not called, then the default ``stage_max_limit`` is - set to :math:`200`. Calling this function with ``stage_max_limit < 2`` resets the default value. - This limit should be chosen with consideration of the following proportionality: :math:`s^2 \sim - h\lambda`, + set to :math:`200`. Calling this function with ``stage_max_limit < 2`` resets the default value. + This limit should be chosen with consideration of the following proportionality: :math:`s^2 \sim - h\lambda`, where :math:`s` is the number of stages used, :math:`h` is the current step size and :math:`\lambda` is the dominant eigenvalue. .. c:function:: int LSRKStepSetDomEigSafetyFactor(void* arkode_mem, sunrealtype dom_eig_safety); - Specifies a safety factor to use for the result of the dominant eigenvalue estimation function. - This value is used to scale the magnitude of the dominant eigenvalue, in the hope of ensuring - a sufficient number of stages for the method to be stable. This input is only used for RKC + Specifies a safety factor to use for the result of the dominant eigenvalue estimation function. + This value is used to scale the magnitude of the dominant eigenvalue, in the hope of ensuring + a sufficient number of stages for the method to be stable. This input is only used for RKC and RKL methods. **Arguments:** @@ -244,7 +248,7 @@ Allowable Method Families .. c:function:: int LSRKStepSetSSPStageNum(void* arkode_mem, int num_of_stages); Sets the number of stages, ``s`` in ``SSP(s, p)`` methods. This input is only utilized by SSPRK methods. - + * :c:enumerator:`ARKODE_LSRK_SSP_S_2` -- ``num_of_stages`` must be greater than or equal to 2 * :c:enumerator:`ARKODE_LSRK_SSP_S_3` -- ``num_of_stages`` must be a perfect-square greater than or equal to 4 * :c:enumerator:`ARKODE_LSRK_SSP_10_4` -- ``num_of_stages`` cannot be modified from 10, so this function should not be called. @@ -259,8 +263,8 @@ Allowable Method Families * *ARK_ILL_INPUT* if an argument had an illegal value (e.g. SSP method is not declared) .. note:: If LSRKStepSetSSPStageNum routine is not called, then the default ``num_of_stages`` is - set. Calling this function with ``num_of_stages <= 0`` resets the default values: - + set. Calling this function with ``num_of_stages <= 0`` resets the default values: + * ``num_of_stages = 10`` for :c:enumerator:`ARKODE_LSRK_SSP_S_2` * ``num_of_stages = 9`` for :c:enumerator:`ARKODE_LSRK_SSP_S_3` * ``num_of_stages = 10`` for :c:enumerator:`ARKODE_LSRK_SSP_10_4` @@ -301,36 +305,36 @@ LSRKStep re-initialization function ------------------------------------- To reinitialize the LSRKStep module for the solution of a new problem, -where a prior call to :c:func:`LSRKStepCreateSTS` or :c:func:`LSRKStepCreateSSP` -has been made, the user must call the function :c:func:`LSRKStepReInitSTS()` -or :c:func:`LSRKStepReInitSSP()`, accordingly. The new problem must have -the same size as the previous one. This routine retains the current settings -for all LSRKstep module options and performs the same input checking and -initializations that are done in :c:func:`LSRKStepCreateSTS` or +where a prior call to :c:func:`LSRKStepCreateSTS` or :c:func:`LSRKStepCreateSSP` +has been made, the user must call the function :c:func:`LSRKStepReInitSTS()` +or :c:func:`LSRKStepReInitSSP()`, accordingly. The new problem must have +the same size as the previous one. This routine retains the current settings +for all LSRKstep module options and performs the same input checking and +initializations that are done in :c:func:`LSRKStepCreateSTS` or :c:func:`LSRKStepCreateSSP`, but it performs no memory allocation as it -assumes that the existing internal memory is sufficient for the new problem. -A call to this re-initialization routine deletes the solution history that -was stored internally during the previous integration, and deletes any -previously-set *tstop* value specified via a call to +assumes that the existing internal memory is sufficient for the new problem. +A call to this re-initialization routine deletes the solution history that +was stored internally during the previous integration, and deletes any +previously-set *tstop* value specified via a call to :c:func:`ARKodeSetStopTime()`. Following a successful call to -:c:func:`LSRKStepReInitSTS()` or :c:func:`LSRKStepReInitSSP()`, +:c:func:`LSRKStepReInitSTS()` or :c:func:`LSRKStepReInitSSP()`, call :c:func:`ARKodeEvolve()` again for the solution of the new problem. -One important use of the :c:func:`LSRKStepReInitSTS()` and -:c:func:`LSRKStepReInitSSP()` function is in the treating of jump -discontinuities in the RHS function. Except in cases of fairly small -jumps, it is usually more efficient to stop at each point of discontinuity -and restart the integrator with a readjusted ODE model, using a call to this -routine. To stop when the location of the discontinuity is known, simply -make that location a value of ``tout``. To stop when the location of -the discontinuity is determined by the solution, use the rootfinding feature. +One important use of the :c:func:`LSRKStepReInitSTS()` and +:c:func:`LSRKStepReInitSSP()` function is in the treating of jump +discontinuities in the RHS function. Except in cases of fairly small +jumps, it is usually more efficient to stop at each point of discontinuity +and restart the integrator with a readjusted ODE model, using a call to this +routine. To stop when the location of the discontinuity is known, simply +make that location a value of ``tout``. To stop when the location of +the discontinuity is determined by the solution, use the rootfinding feature. In either case, it is critical that the RHS function *not* incorporate the -discontinuity, but rather have a smooth extension over the discontinuity, -so that the step across it (and subsequent rootfinding, if used) can be done -efficiently. Then use a switch within the RHS function (communicated through -``user_data``) that can be flipped between the stopping of the integration -and the restart, so that the restarted problem uses the new values (which -have jumped). Similar comments apply if there is to be a jump in the +discontinuity, but rather have a smooth extension over the discontinuity, +so that the step across it (and subsequent rootfinding, if used) can be done +efficiently. Then use a switch within the RHS function (communicated through +``user_data``) that can be flipped between the stopping of the integration +and the restart, so that the restarted problem uses the new values (which +have jumped). Similar comments apply if there is to be a jump in the dependent variable vector. diff --git a/doc/arkode/guide/source/Usage/MRIStep/User_callable.rst b/doc/arkode/guide/source/Usage/MRIStep/User_callable.rst index 028060a626..08cd106970 100644 --- a/doc/arkode/guide/source/Usage/MRIStep/User_callable.rst +++ b/doc/arkode/guide/source/Usage/MRIStep/User_callable.rst @@ -34,7 +34,7 @@ MRIStep supports the following categories: * temporal adaptivity * implicit nonlinear and/or linear solvers -MRIStep does not have forcing function support when converted to a +MRIStep also has forcing function support when converted to a :c:type:`SUNStepper` or :c:type:`MRIStepInnerStepper`. See :c:func:`ARKodeCreateSUNStepper` and :c:func:`ARKStepCreateMRIStepInnerStepper` for additional details. diff --git a/doc/arkode/guide/source/Usage/User_callable.rst b/doc/arkode/guide/source/Usage/User_callable.rst index 9a10c4dc6a..fc11496f61 100644 --- a/doc/arkode/guide/source/Usage/User_callable.rst +++ b/doc/arkode/guide/source/Usage/User_callable.rst @@ -4905,6 +4905,6 @@ block as a :c:type:`SUNStepper`. .. warning:: Currently, ``stepper`` will be equipped with an implementation for the :c:func:`SUNStepper_SetForcing` function only if ``inner_arkode_mem`` is - an ARKStep integrator. + an ARKStep, ERKStep, or MRIStep integrator. .. versionadded:: x.y.z From e02ec4c7b1bba038bb73f88bb262764b13b08583 Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Tue, 3 Dec 2024 22:48:02 -0600 Subject: [PATCH 279/286] Updated logic for calling UpdateF0 vs FullRHS based on whether MRIStep is used as an inner integrator --- src/arkode/arkode_mristep.c | 99 ++++++++++++++++++++++++++----------- 1 file changed, 69 insertions(+), 30 deletions(-) diff --git a/src/arkode/arkode_mristep.c b/src/arkode/arkode_mristep.c index 2e731dabd9..72e4b5969c 100644 --- a/src/arkode/arkode_mristep.c +++ b/src/arkode/arkode_mristep.c @@ -1765,6 +1765,7 @@ int mriStep_TakeStepMRIGARK(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPt sunbooleantype calc_fslow; sunbooleantype need_inner_dsm; sunbooleantype do_embedding; + sunbooleantype nested_mri; int nvec; /* access the MRIStep mem structure */ @@ -1832,20 +1833,37 @@ int mriStep_TakeStepMRIGARK(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPt } /* Evaluate the slow RHS functions if needed. NOTE: we decide between calling the - full RHS function (if ark_mem->fn is non-NULL) versus just updating the stored - values of Fse[0] and Fsi[0]. In either case, we use ARK_FULLRHS_START mode - because MRIGARK methods do not evaluate the RHS functions at the end of the - time step (so nothing can be leveraged). */ - if (ark_mem->fn != NULL) + full RHS function (if ark_mem->fn is non-NULL and MRIStep is not an inner + integrator) versus just updating the stored values of Fse[0] and Fsi[0]. In + either case, we use ARK_FULLRHS_START mode because MRIGARK methods do not + evaluate the RHS functions at the end of the time step (so nothing can be + leveraged). */ + nested_mri = step_mem->expforcing || step_mem->impforcing; + if (ark_mem->fn == NULL || nested_mri) { - retval = mriStep_FullRHS(ark_mem, ark_mem->tn, ark_mem->yn, ark_mem->fn, - ARK_FULLRHS_START); + retval = mriStep_UpdateF0(ark_mem, step_mem, ark_mem->tn, ark_mem->yn, + ARK_FULLRHS_START); if (retval) { return ARK_RHSFUNC_FAIL; } + + /* For a nested MRI configuration we might still need fn to create a predictor + but it should be fn only for the current nesting level which is why we use + UpdateF0 in this case rather than FullRHS */ + if (ark_mem->fn != NULL && nested_mri && step_mem->implicit_rhs) + { + if (step_mem->implicit_rhs && step_mem->explicit_rhs) + { + N_VLinearSum(ONE, step_mem->Fsi[0], ONE, step_mem->Fse[0], ark_mem->fn); + } + else + { + N_VScale(ONE, step_mem->Fsi[0], ark_mem->fn); + } + } } - else + else if (ark_mem->fn != NULL && !ark_mem->fn_is_current) { - retval = mriStep_UpdateF0(ark_mem, step_mem, ark_mem->tn, ark_mem->yn, - ARK_FULLRHS_START); + retval = mriStep_FullRHS(ark_mem, ark_mem->tn, ark_mem->yn, ark_mem->fn, + ARK_FULLRHS_START); if (retval) { return ARK_RHSFUNC_FAIL; } } ark_mem->fn_is_current = SUNTRUE; @@ -2256,6 +2274,7 @@ int mriStep_TakeStepMRISR(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr) sunbooleantype impl_corr; /* is slow correct. implicit? */ sunrealtype cstage; /* current stage abscissa */ sunbooleantype need_inner_dsm; + sunbooleantype nested_mri; int nvec, max_stages; const sunrealtype tol = SUN_RCONST(100.0) * SUN_UNIT_ROUNDOFF; @@ -2312,20 +2331,37 @@ int mriStep_TakeStepMRISR(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr) } /* Evaluate the slow RHS functions if needed. NOTE: we decide between calling the - full RHS function (if ark_mem->fn is non-NULL) versus just updating the stored - values of Fse[0] and Fsi[0]. In either case, we use ARK_FULLRHS_START mode - because MRISR methods do not evaluate the RHS functions at the end of the - time step (so nothing can be leveraged). */ - if (ark_mem->fn != NULL) + full RHS function (if ark_mem->fn is non-NULL and MRIStep is not an inner + integrator) versus just updating the stored values of Fse[0] and Fsi[0]. In + either case, we use ARK_FULLRHS_START mode because MRISR methods do not + evaluate the RHS functions at the end of the time step (so nothing can be + leveraged). */ + nested_mri = step_mem->expforcing || step_mem->impforcing; + if (ark_mem->fn == NULL || nested_mri) { - retval = mriStep_FullRHS(ark_mem, ark_mem->tn, ark_mem->yn, ark_mem->fn, - ARK_FULLRHS_START); + retval = mriStep_UpdateF0(ark_mem, step_mem, ark_mem->tn, ark_mem->yn, + ARK_FULLRHS_START); if (retval) { return ARK_RHSFUNC_FAIL; } + + /* For a nested MRI configuration we might still need fn to create a predictor + but it should be fn only for the current nesting level which is why we use + UpdateF0 in this case rather than FullRHS */ + if (ark_mem->fn != NULL && nested_mri && step_mem->implicit_rhs) + { + if (step_mem->implicit_rhs && step_mem->explicit_rhs) + { + N_VLinearSum(ONE, step_mem->Fsi[0], ONE, step_mem->Fse[0], ark_mem->fn); + } + else + { + N_VScale(ONE, step_mem->Fsi[0], ark_mem->fn); + } + } } - else + if (ark_mem->fn != NULL && !ark_mem->fn_is_current) { - retval = mriStep_UpdateF0(ark_mem, step_mem, ark_mem->tn, ark_mem->yn, - ARK_FULLRHS_START); + retval = mriStep_FullRHS(ark_mem, ark_mem->tn, ark_mem->yn, ark_mem->fn, + ARK_FULLRHS_START); if (retval) { return ARK_RHSFUNC_FAIL; } } ark_mem->fn_is_current = SUNTRUE; @@ -2694,6 +2730,7 @@ int mriStep_TakeStepMERK(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr) sunbooleantype solution; /* or solution stages */ sunrealtype cstage; /* current stage abscissa */ sunbooleantype need_inner_dsm; + sunbooleantype nested_mri; int nvec; /* access the MRIStep mem structure */ @@ -2750,20 +2787,22 @@ int mriStep_TakeStepMERK(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr) } } - /* Evaluate the slow RHS function if needed. NOTE: we decide between calling the full RHS - function (if ark_mem->fn is non-NULL) versus just updating the stored value of - Fse[0]. In either case, we use ARK_FULLRHS_START mode because MERK methods do not - evaluate Fse at the end of the time step (so nothing can be leveraged). */ - if (ark_mem->fn != NULL) + /* Evaluate the slow RHS function if needed. NOTE: we decide between calling the + full RHS function (if ark_mem->fn is non-NULL and MRIStep is not an inner + integrator) versus just updating the stored value of Fse[0]. In either case, + we use ARK_FULLRHS_START mode because MERK methods do not evaluate Fse at the + end of the time step (so nothing can be leveraged). */ + nested_mri = step_mem->expforcing || step_mem->impforcing; + if (ark_mem->fn == NULL || nested_mri) { - retval = mriStep_FullRHS(ark_mem, ark_mem->tn, ark_mem->yn, ark_mem->fn, - ARK_FULLRHS_START); + retval = mriStep_UpdateF0(ark_mem, step_mem, ark_mem->tn, ark_mem->yn, + ARK_FULLRHS_START); if (retval) { return ARK_RHSFUNC_FAIL; } } - else + if (ark_mem->fn != NULL && !ark_mem->fn_is_current) { - retval = mriStep_UpdateF0(ark_mem, step_mem, ark_mem->tn, ark_mem->yn, - ARK_FULLRHS_START); + retval = mriStep_FullRHS(ark_mem, ark_mem->tn, ark_mem->yn, ark_mem->fn, + ARK_FULLRHS_START); if (retval) { return ARK_RHSFUNC_FAIL; } } ark_mem->fn_is_current = SUNTRUE; From 2ef37b60134cccbbc815770d949f946b9a971c11 Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Tue, 3 Dec 2024 22:56:19 -0600 Subject: [PATCH 280/286] formatting --- src/arkode/arkode_mristep.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/src/arkode/arkode_mristep.c b/src/arkode/arkode_mristep.c index 72e4b5969c..fabc747ba7 100644 --- a/src/arkode/arkode_mristep.c +++ b/src/arkode/arkode_mristep.c @@ -1854,10 +1854,7 @@ int mriStep_TakeStepMRIGARK(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPt { N_VLinearSum(ONE, step_mem->Fsi[0], ONE, step_mem->Fse[0], ark_mem->fn); } - else - { - N_VScale(ONE, step_mem->Fsi[0], ark_mem->fn); - } + else { N_VScale(ONE, step_mem->Fsi[0], ark_mem->fn); } } } else if (ark_mem->fn != NULL && !ark_mem->fn_is_current) @@ -2352,10 +2349,7 @@ int mriStep_TakeStepMRISR(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr) { N_VLinearSum(ONE, step_mem->Fsi[0], ONE, step_mem->Fse[0], ark_mem->fn); } - else - { - N_VScale(ONE, step_mem->Fsi[0], ark_mem->fn); - } + else { N_VScale(ONE, step_mem->Fsi[0], ark_mem->fn); } } } if (ark_mem->fn != NULL && !ark_mem->fn_is_current) From 5f1821d279698679cdfad86d8cfdf51a904dd36f Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Wed, 4 Dec 2024 09:07:05 -0600 Subject: [PATCH 281/286] Updated Jenkins .out files to account for reduction in fast RHS calls due to recent updates --- .../ark_diffusion_reaction_p_--np_2_2_--mri-arkstep.out | 2 +- .../arkode/CXX_parhyp/ark_heat2D_hypre_pfmg_mri_--np_2_2.out | 2 +- examples/arkode/CXX_serial/ark_kpr_nestedmri.out | 2 +- examples/arkode/C_serial/ark_brusselator1D_imexmri_0_0.001.out | 2 +- examples/arkode/C_serial/ark_brusselator1D_imexmri_2_0.001.out | 2 +- examples/arkode/C_serial/ark_brusselator1D_imexmri_3_0.001.out | 2 +- examples/arkode/C_serial/ark_brusselator1D_imexmri_4_0.001.out | 2 +- examples/arkode/C_serial/ark_brusselator1D_imexmri_5_0.001.out | 2 +- examples/arkode/C_serial/ark_brusselator1D_imexmri_6_0.001.out | 2 +- examples/arkode/C_serial/ark_brusselator1D_imexmri_7_0.001.out | 2 +- examples/arkode/C_serial/ark_brusselator_1D_mri.out | 2 +- examples/arkode/C_serial/ark_brusselator_mri.out | 2 +- .../arkode/C_serial/ark_kpr_mri_10_4_0.001_-100_100_0.5_1.out | 2 +- examples/arkode/C_serial/ark_kpr_mri_11_2_0.001.out | 2 +- examples/arkode/C_serial/ark_kpr_mri_12_3_0.005.out | 2 +- examples/arkode/C_serial/ark_kpr_mri_13_4_0.01.out | 2 +- examples/arkode/C_serial/ark_kpr_mri_1_0_0.01.out | 2 +- examples/arkode/C_serial/ark_kpr_mri_2_4_0.002.out | 2 +- examples/arkode/C_serial/ark_kpr_mri_3_2_0.001.out | 2 +- examples/arkode/C_serial/ark_kpr_mri_4_3_0.001.out | 2 +- examples/arkode/C_serial/ark_kpr_mri_5_4_0.001.out | 2 +- examples/arkode/C_serial/ark_kpr_mri_6_5_0.001.out | 2 +- examples/arkode/C_serial/ark_kpr_mri_7_2_0.002.out | 2 +- .../arkode/C_serial/ark_kpr_mri_8_3_0.001_-100_100_0.5_1.out | 2 +- .../arkode/C_serial/ark_kpr_mri_9_3_0.001_-100_100_0.5_1.out | 2 +- examples/arkode/C_serial/ark_onewaycouple_mri.out | 2 +- examples/arkode/C_serial/ark_reaction_diffusion_mri.out | 2 +- examples/arkode/C_serial/ark_twowaycouple_mri.out | 2 +- 28 files changed, 28 insertions(+), 28 deletions(-) diff --git a/examples/arkode/CXX_parallel/ark_diffusion_reaction_p_--np_2_2_--mri-arkstep.out b/examples/arkode/CXX_parallel/ark_diffusion_reaction_p_--np_2_2_--mri-arkstep.out index b899fc5983..2ffc7a6d53 100644 --- a/examples/arkode/CXX_parallel/ark_diffusion_reaction_p_--np_2_2_--mri-arkstep.out +++ b/examples/arkode/CXX_parallel/ark_diffusion_reaction_p_--np_2_2_--mri-arkstep.out @@ -96,4 +96,4 @@ Fast Integrator: Steps = 470 Step attempts = 470 Error test fails = 0 - RHS reaction = 1959 + RHS reaction = 1940 diff --git a/examples/arkode/CXX_parhyp/ark_heat2D_hypre_pfmg_mri_--np_2_2.out b/examples/arkode/CXX_parhyp/ark_heat2D_hypre_pfmg_mri_--np_2_2.out index 89830fcbdd..6a538dcc0e 100644 --- a/examples/arkode/CXX_parhyp/ark_heat2D_hypre_pfmg_mri_--np_2_2.out +++ b/examples/arkode/CXX_parhyp/ark_heat2D_hypre_pfmg_mri_--np_2_2.out @@ -75,7 +75,7 @@ Final fast integrator statistics: Steps = 3003 Step attempts = 3003 Error test fails = 0 - RHS evals = 30862 + RHS evals = 30853 NLS iters = 17842 NLS fails = 0 LS iters = 10048 diff --git a/examples/arkode/CXX_serial/ark_kpr_nestedmri.out b/examples/arkode/CXX_serial/ark_kpr_nestedmri.out index dacfc6fd90..bc66d480bc 100644 --- a/examples/arkode/CXX_serial/ark_kpr_nestedmri.out +++ b/examples/arkode/CXX_serial/ark_kpr_nestedmri.out @@ -48,4 +48,4 @@ Final Solver Statistics: Fast steps = 129455 (attempts = 144940, fails = 15485) u error = 0.000228112, v error = 8.70956e-05, total error = 0.000169225 Relative accuracy = 6.75352 - Total RHS evals: Fse = 240, Fsi = 0, Fme = 4235, Fmi = 0, Ff = 710133 + Total RHS evals: Fse = 240, Fsi = 0, Fme = 4234, Fmi = 0, Ff = 709264 diff --git a/examples/arkode/C_serial/ark_brusselator1D_imexmri_0_0.001.out b/examples/arkode/C_serial/ark_brusselator1D_imexmri_0_0.001.out index 62373f3629..e1abd55567 100644 --- a/examples/arkode/C_serial/ark_brusselator1D_imexmri_0_0.001.out +++ b/examples/arkode/C_serial/ark_brusselator1D_imexmri_0_0.001.out @@ -30,7 +30,7 @@ Final Solver Statistics: Slow Steps: nsts = 10001 Fast Steps: nstf = 120012 - Total RHS evals: Fs = 30004, Ff = 874984 + Total RHS evals: Fs = 30004, Ff = 874975 Fast Newton iters = 504937 Fast Newton conv fails = 0 Fast Jacobian evals = 2308 diff --git a/examples/arkode/C_serial/ark_brusselator1D_imexmri_2_0.001.out b/examples/arkode/C_serial/ark_brusselator1D_imexmri_2_0.001.out index 8e29c07a32..39c475b902 100644 --- a/examples/arkode/C_serial/ark_brusselator1D_imexmri_2_0.001.out +++ b/examples/arkode/C_serial/ark_brusselator1D_imexmri_2_0.001.out @@ -30,7 +30,7 @@ Final Solver Statistics: Slow Steps: nsts = 10001 Fast Steps: nstf = 120012 - Total RHS evals: Fs = 68887, Ff = 370047 + Total RHS evals: Fs = 68887, Ff = 370038 Slow Newton iters = 38883 Slow Newton conv fails = 0 Slow Jacobian evals = 501 diff --git a/examples/arkode/C_serial/ark_brusselator1D_imexmri_3_0.001.out b/examples/arkode/C_serial/ark_brusselator1D_imexmri_3_0.001.out index 254fe649e5..89bbf34f58 100644 --- a/examples/arkode/C_serial/ark_brusselator1D_imexmri_3_0.001.out +++ b/examples/arkode/C_serial/ark_brusselator1D_imexmri_3_0.001.out @@ -30,7 +30,7 @@ Final Solver Statistics: Slow Steps: nsts = 10001 Fast Steps: nstf = 120012 - Total RHS evals: Fs = 68887, Ff = 850122 + Total RHS evals: Fs = 68887, Ff = 850113 Slow Newton iters = 38883 Slow Newton conv fails = 0 Slow Jacobian evals = 501 diff --git a/examples/arkode/C_serial/ark_brusselator1D_imexmri_4_0.001.out b/examples/arkode/C_serial/ark_brusselator1D_imexmri_4_0.001.out index e2baaa98f9..dce0ab719d 100644 --- a/examples/arkode/C_serial/ark_brusselator1D_imexmri_4_0.001.out +++ b/examples/arkode/C_serial/ark_brusselator1D_imexmri_4_0.001.out @@ -30,7 +30,7 @@ Final Solver Statistics: Slow Steps: nsts = 10001 Fast Steps: nstf = 110011 - Total RHS evals: Fse = 40005, Fsi = 78888, Ff = 340044 + Total RHS evals: Fse = 40005, Fsi = 78888, Ff = 340035 Slow Newton iters = 38883 Slow Newton conv fails = 0 Slow Jacobian evals = 501 diff --git a/examples/arkode/C_serial/ark_brusselator1D_imexmri_5_0.001.out b/examples/arkode/C_serial/ark_brusselator1D_imexmri_5_0.001.out index 569265cbfd..e8a70f3986 100644 --- a/examples/arkode/C_serial/ark_brusselator1D_imexmri_5_0.001.out +++ b/examples/arkode/C_serial/ark_brusselator1D_imexmri_5_0.001.out @@ -30,7 +30,7 @@ Final Solver Statistics: Slow Steps: nsts = 10001 Fast Steps: nstf = 110011 - Total RHS evals: Fse = 40005, Fsi = 78888, Ff = 1034336 + Total RHS evals: Fse = 40005, Fsi = 78888, Ff = 1034327 Slow Newton iters = 38883 Slow Newton conv fails = 0 Slow Jacobian evals = 501 diff --git a/examples/arkode/C_serial/ark_brusselator1D_imexmri_6_0.001.out b/examples/arkode/C_serial/ark_brusselator1D_imexmri_6_0.001.out index 71419632eb..4dba64aaf9 100644 --- a/examples/arkode/C_serial/ark_brusselator1D_imexmri_6_0.001.out +++ b/examples/arkode/C_serial/ark_brusselator1D_imexmri_6_0.001.out @@ -30,7 +30,7 @@ Final Solver Statistics: Slow Steps: nsts = 10001 Fast Steps: nstf = 130013 - Total RHS evals: Fse = 60007, Fsi = 118894, Ff = 530063 + Total RHS evals: Fse = 60007, Fsi = 118894, Ff = 530054 Slow Newton iters = 58887 Slow Newton conv fails = 0 Slow Jacobian evals = 501 diff --git a/examples/arkode/C_serial/ark_brusselator1D_imexmri_7_0.001.out b/examples/arkode/C_serial/ark_brusselator1D_imexmri_7_0.001.out index 265bb4696b..0ebb4a0a14 100644 --- a/examples/arkode/C_serial/ark_brusselator1D_imexmri_7_0.001.out +++ b/examples/arkode/C_serial/ark_brusselator1D_imexmri_7_0.001.out @@ -30,7 +30,7 @@ Final Solver Statistics: Slow Steps: nsts = 10001 Fast Steps: nstf = 130013 - Total RHS evals: Fse = 60007, Fsi = 118894, Ff = 1946012 + Total RHS evals: Fse = 60007, Fsi = 118894, Ff = 1946003 Slow Newton iters = 58887 Slow Newton conv fails = 0 Slow Jacobian evals = 501 diff --git a/examples/arkode/C_serial/ark_brusselator_1D_mri.out b/examples/arkode/C_serial/ark_brusselator_1D_mri.out index 0af99eff68..4442e9e3f9 100644 --- a/examples/arkode/C_serial/ark_brusselator_1D_mri.out +++ b/examples/arkode/C_serial/ark_brusselator_1D_mri.out @@ -112,7 +112,7 @@ Final Solver Statistics: Slow Steps: nsts = 1001 Fast Steps: nstf = 3171 (attempted = 3171) - Total RHS evals: Fs = 3004, Ff = 31612 + Total RHS evals: Fs = 3004, Ff = 31513 Total number of fast error test failures = 0 Total linear solver setups = 3118 Total RHS evals for setting up the linear system = 0 diff --git a/examples/arkode/C_serial/ark_brusselator_mri.out b/examples/arkode/C_serial/ark_brusselator_mri.out index 61ce63eca1..a9115a8c9e 100644 --- a/examples/arkode/C_serial/ark_brusselator_mri.out +++ b/examples/arkode/C_serial/ark_brusselator_mri.out @@ -31,4 +31,4 @@ Brusselator ODE test problem: Final Solver Statistics: Steps: nsts = 81, nstf = 2187 - Total RHS evals: Fs = 244, Ff = 6662 + Total RHS evals: Fs = 244, Ff = 6643 diff --git a/examples/arkode/C_serial/ark_kpr_mri_10_4_0.001_-100_100_0.5_1.out b/examples/arkode/C_serial/ark_kpr_mri_10_4_0.001_-100_100_0.5_1.out index 9e9c2d786e..fe552cf2b6 100644 --- a/examples/arkode/C_serial/ark_kpr_mri_10_4_0.001_-100_100_0.5_1.out +++ b/examples/arkode/C_serial/ark_kpr_mri_10_4_0.001_-100_100_0.5_1.out @@ -67,7 +67,7 @@ Multirate nonlinear Kvaerno-Prothero-Robinson test problem: Final Solver Statistics: Steps: nsts = 5000, nstf = 510000 u error = 1.533e-11, v error = 4.203e-12, total error = 1.124e-11 - Total RHS evals: Fse = 30001, Fsi = 57555, Ff = 2045050 + Total RHS evals: Fse = 30001, Fsi = 57555, Ff = 2045001 Slow Newton iters = 52554 Slow Newton conv fails = 0 Slow Jacobian evals = 250 diff --git a/examples/arkode/C_serial/ark_kpr_mri_11_2_0.001.out b/examples/arkode/C_serial/ark_kpr_mri_11_2_0.001.out index 66ed6d890d..f34f31abb5 100644 --- a/examples/arkode/C_serial/ark_kpr_mri_11_2_0.001.out +++ b/examples/arkode/C_serial/ark_kpr_mri_11_2_0.001.out @@ -67,7 +67,7 @@ Multirate nonlinear Kvaerno-Prothero-Robinson test problem: Final Solver Statistics: Steps: nsts = 5000, nstf = 935000 u error = 4.409e-07, v error = 7.409e-08, total error = 3.161e-07 - Total RHS evals: Fse = 15001, Fsi = 32981, Ff = 1875050 + Total RHS evals: Fse = 15001, Fsi = 32981, Ff = 1875001 Slow Newton iters = 17980 Slow Newton conv fails = 0 Slow Jacobian evals = 250 diff --git a/examples/arkode/C_serial/ark_kpr_mri_12_3_0.005.out b/examples/arkode/C_serial/ark_kpr_mri_12_3_0.005.out index 2702eeeb8c..248f0c3b32 100644 --- a/examples/arkode/C_serial/ark_kpr_mri_12_3_0.005.out +++ b/examples/arkode/C_serial/ark_kpr_mri_12_3_0.005.out @@ -67,7 +67,7 @@ Multirate nonlinear Kvaerno-Prothero-Robinson test problem: Final Solver Statistics: Steps: nsts = 1001, nstf = 362362 u error = 9.913e-08, v error = 3.506e-09, total error = 7.014e-08 - Total RHS evals: Fse = 4005, Fsi = 12096, Ff = 1088137 + Total RHS evals: Fse = 4005, Fsi = 12096, Ff = 1088088 Slow Newton iters = 8091 Slow Newton conv fails = 0 Slow Jacobian evals = 51 diff --git a/examples/arkode/C_serial/ark_kpr_mri_13_4_0.01.out b/examples/arkode/C_serial/ark_kpr_mri_13_4_0.01.out index 4e40afb1e6..868d51e963 100644 --- a/examples/arkode/C_serial/ark_kpr_mri_13_4_0.01.out +++ b/examples/arkode/C_serial/ark_kpr_mri_13_4_0.01.out @@ -67,7 +67,7 @@ Multirate nonlinear Kvaerno-Prothero-Robinson test problem: Final Solver Statistics: Steps: nsts = 501, nstf = 202905 u error = 7.089e-08, v error = 1.972e-07, total error = 1.482e-07 - Total RHS evals: Fse = 3007, Fsi = 8869, Ff = 812171 + Total RHS evals: Fse = 3007, Fsi = 8869, Ff = 812122 Slow Newton iters = 5862 Slow Newton conv fails = 0 Slow Jacobian evals = 26 diff --git a/examples/arkode/C_serial/ark_kpr_mri_1_0_0.01.out b/examples/arkode/C_serial/ark_kpr_mri_1_0_0.01.out index c69c229ef1..ef66f4a445 100644 --- a/examples/arkode/C_serial/ark_kpr_mri_1_0_0.01.out +++ b/examples/arkode/C_serial/ark_kpr_mri_1_0_0.01.out @@ -66,4 +66,4 @@ Multirate nonlinear Kvaerno-Prothero-Robinson test problem: Final Solver Statistics: Steps: nsts = 501, nstf = 50601 u error = 5.052e-05, v error = 7.684e-04, total error = 5.445e-04 - Total RHS evals: Fs = 1504, Ff = 152354 + Total RHS evals: Fs = 1504, Ff = 152305 diff --git a/examples/arkode/C_serial/ark_kpr_mri_2_4_0.002.out b/examples/arkode/C_serial/ark_kpr_mri_2_4_0.002.out index 37b8ce06e3..6a22e6fbc0 100644 --- a/examples/arkode/C_serial/ark_kpr_mri_2_4_0.002.out +++ b/examples/arkode/C_serial/ark_kpr_mri_2_4_0.002.out @@ -66,4 +66,4 @@ Multirate nonlinear Kvaerno-Prothero-Robinson test problem: Final Solver Statistics: Steps: nsts = 2501, nstf = 250100 u error = 1.665e-10, v error = 7.685e-11, total error = 1.296e-10 - Total RHS evals: Fs = 12506, Ff = 1002951 + Total RHS evals: Fs = 12506, Ff = 1002902 diff --git a/examples/arkode/C_serial/ark_kpr_mri_3_2_0.001.out b/examples/arkode/C_serial/ark_kpr_mri_3_2_0.001.out index de553f476b..00f9fbb881 100644 --- a/examples/arkode/C_serial/ark_kpr_mri_3_2_0.001.out +++ b/examples/arkode/C_serial/ark_kpr_mri_3_2_0.001.out @@ -66,4 +66,4 @@ Multirate nonlinear Kvaerno-Prothero-Robinson test problem: Final Solver Statistics: Steps: nsts = 5000, nstf = 750000 u error = 2.508e-08, v error = 2.443e-08, total error = 2.476e-08 - Total RHS evals: Fs = 10001, Ff = 1505050 + Total RHS evals: Fs = 10001, Ff = 1505001 diff --git a/examples/arkode/C_serial/ark_kpr_mri_4_3_0.001.out b/examples/arkode/C_serial/ark_kpr_mri_4_3_0.001.out index 6714cddd83..65f7d03033 100644 --- a/examples/arkode/C_serial/ark_kpr_mri_4_3_0.001.out +++ b/examples/arkode/C_serial/ark_kpr_mri_4_3_0.001.out @@ -66,4 +66,4 @@ Multirate nonlinear Kvaerno-Prothero-Robinson test problem: Final Solver Statistics: Steps: nsts = 5000, nstf = 1085000 u error = 8.345e-10, v error = 2.743e-10, total error = 6.212e-10 - Total RHS evals: Fs = 15001, Ff = 3260050 + Total RHS evals: Fs = 15001, Ff = 3260001 diff --git a/examples/arkode/C_serial/ark_kpr_mri_5_4_0.001.out b/examples/arkode/C_serial/ark_kpr_mri_5_4_0.001.out index c2683d4888..817fa1eff9 100644 --- a/examples/arkode/C_serial/ark_kpr_mri_5_4_0.001.out +++ b/examples/arkode/C_serial/ark_kpr_mri_5_4_0.001.out @@ -66,4 +66,4 @@ Multirate nonlinear Kvaerno-Prothero-Robinson test problem: Final Solver Statistics: Steps: nsts = 5000, nstf = 1425000 u error = 2.086e-11, v error = 7.078e-12, total error = 1.557e-11 - Total RHS evals: Fs = 30001, Ff = 5705050 + Total RHS evals: Fs = 30001, Ff = 5705001 diff --git a/examples/arkode/C_serial/ark_kpr_mri_6_5_0.001.out b/examples/arkode/C_serial/ark_kpr_mri_6_5_0.001.out index 88573af8aa..8f12b1e794 100644 --- a/examples/arkode/C_serial/ark_kpr_mri_6_5_0.001.out +++ b/examples/arkode/C_serial/ark_kpr_mri_6_5_0.001.out @@ -66,4 +66,4 @@ Multirate nonlinear Kvaerno-Prothero-Robinson test problem: Final Solver Statistics: Steps: nsts = 5000, nstf = 1615000 u error = 4.177e-13, v error = 1.555e-12, total error = 1.139e-12 - Total RHS evals: Fs = 50051, Ff = 9715101 + Total RHS evals: Fs = 50051, Ff = 9715052 diff --git a/examples/arkode/C_serial/ark_kpr_mri_7_2_0.002.out b/examples/arkode/C_serial/ark_kpr_mri_7_2_0.002.out index 35ce8db2b6..899ff3f7a8 100644 --- a/examples/arkode/C_serial/ark_kpr_mri_7_2_0.002.out +++ b/examples/arkode/C_serial/ark_kpr_mri_7_2_0.002.out @@ -67,7 +67,7 @@ Multirate nonlinear Kvaerno-Prothero-Robinson test problem: Final Solver Statistics: Steps: nsts = 2501, nstf = 250100 u error = 1.301e-06, v error = 1.744e-07, total error = 9.284e-07 - Total RHS evals: Fs = 7002, Ff = 502751 + Total RHS evals: Fs = 7002, Ff = 502702 Slow Newton iters = 4500 Slow Newton conv fails = 0 Slow Jacobian evals = 126 diff --git a/examples/arkode/C_serial/ark_kpr_mri_8_3_0.001_-100_100_0.5_1.out b/examples/arkode/C_serial/ark_kpr_mri_8_3_0.001_-100_100_0.5_1.out index 45395b8454..fe05e8f5db 100644 --- a/examples/arkode/C_serial/ark_kpr_mri_8_3_0.001_-100_100_0.5_1.out +++ b/examples/arkode/C_serial/ark_kpr_mri_8_3_0.001_-100_100_0.5_1.out @@ -67,7 +67,7 @@ Multirate nonlinear Kvaerno-Prothero-Robinson test problem: Final Solver Statistics: Steps: nsts = 5000, nstf = 510000 u error = 3.764e-10, v error = 3.952e-10, total error = 3.859e-10 - Total RHS evals: Fs = 35313, Ff = 1535050 + Total RHS evals: Fs = 35313, Ff = 1535001 Slow Newton iters = 30312 Slow Newton conv fails = 0 Slow Jacobian evals = 250 diff --git a/examples/arkode/C_serial/ark_kpr_mri_9_3_0.001_-100_100_0.5_1.out b/examples/arkode/C_serial/ark_kpr_mri_9_3_0.001_-100_100_0.5_1.out index 4c01ea05c2..6eaf5ec418 100644 --- a/examples/arkode/C_serial/ark_kpr_mri_9_3_0.001_-100_100_0.5_1.out +++ b/examples/arkode/C_serial/ark_kpr_mri_9_3_0.001_-100_100_0.5_1.out @@ -67,7 +67,7 @@ Multirate nonlinear Kvaerno-Prothero-Robinson test problem: Final Solver Statistics: Steps: nsts = 5000, nstf = 510000 u error = 1.860e-10, v error = 1.672e-10, total error = 1.769e-10 - Total RHS evals: Fse = 20001, Fsi = 35342, Ff = 1535050 + Total RHS evals: Fse = 20001, Fsi = 35342, Ff = 1535001 Slow Newton iters = 30341 Slow Newton conv fails = 0 Slow Jacobian evals = 250 diff --git a/examples/arkode/C_serial/ark_onewaycouple_mri.out b/examples/arkode/C_serial/ark_onewaycouple_mri.out index a0738fc01b..6b5ad2f798 100644 --- a/examples/arkode/C_serial/ark_onewaycouple_mri.out +++ b/examples/arkode/C_serial/ark_onewaycouple_mri.out @@ -20,4 +20,4 @@ One way coupling ODE test problem: Final Solver Statistics: Steps: nsts = 1000, nstf = 12000 - Total RHS evals: Fs = 3001, Ff = 37010 + Total RHS evals: Fs = 3001, Ff = 37001 diff --git a/examples/arkode/C_serial/ark_reaction_diffusion_mri.out b/examples/arkode/C_serial/ark_reaction_diffusion_mri.out index a68ab7d0d5..34af3937e9 100644 --- a/examples/arkode/C_serial/ark_reaction_diffusion_mri.out +++ b/examples/arkode/C_serial/ark_reaction_diffusion_mri.out @@ -69,7 +69,7 @@ Inequality constraint fails = 0 Initial step size = 2e-05 Last step size = 9.999999998289147e-06 Current step size = 2e-05 -Explicit RHS fn evals = 462184 +Explicit RHS fn evals = 462155 Implicit RHS fn evals = 0 NLS iters = 0 NLS fails = 0 diff --git a/examples/arkode/C_serial/ark_twowaycouple_mri.out b/examples/arkode/C_serial/ark_twowaycouple_mri.out index d079ae454a..96603859bf 100644 --- a/examples/arkode/C_serial/ark_twowaycouple_mri.out +++ b/examples/arkode/C_serial/ark_twowaycouple_mri.out @@ -30,4 +30,4 @@ Two way coupling ODE test problem: Final Solver Statistics: Steps: nsts = 2001, nstf = 102051 - Total RHS evals: Fs = 6004, Ff = 308174 + Total RHS evals: Fs = 6004, Ff = 308155 From 6c4c0e04a653e65477edf23fe5b7fa201d7ee714 Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Wed, 4 Dec 2024 10:23:35 -0600 Subject: [PATCH 282/286] Updated Jenkins .out files to account for reduction in fast RHS calls due to recent updates --- examples/arkode/F2003_serial/ark_kpr_mri_f2003.out | 2 +- examples/arkode/F2003_serial/ark_kpr_mri_f2003_0_0.002.out | 2 +- examples/arkode/F2003_serial/ark_kpr_mri_f2003_1_0.002.out | 2 +- examples/arkode/F2003_serial/ark_kpr_mri_f2003_3_0.01.out | 2 +- examples/arkode/F2003_serial/ark_kpr_mri_f2003_4_0.002.out | 2 +- examples/arkode/F2003_serial/ark_kpr_mri_f2003_5_0.002.out | 2 +- examples/arkode/F2003_serial/ark_kpr_mri_f2003_6_0.005.out | 2 +- examples/arkode/F2003_serial/ark_kpr_mri_f2003_7_0.001.out | 2 +- examples/arkode/F2003_serial/ark_kpr_mri_f2003_8_0.001.out | 2 +- examples/arkode/F2003_serial/ark_kpr_mri_f2003_9_0.001.out | 2 +- 10 files changed, 10 insertions(+), 10 deletions(-) diff --git a/examples/arkode/F2003_serial/ark_kpr_mri_f2003.out b/examples/arkode/F2003_serial/ark_kpr_mri_f2003.out index 5cbb350b61..036ba341ee 100644 --- a/examples/arkode/F2003_serial/ark_kpr_mri_f2003.out +++ b/examples/arkode/F2003_serial/ark_kpr_mri_f2003.out @@ -63,4 +63,4 @@ Final Solver Statistics: Steps: nsts = 501, nstf = 50601 u error = 0.794E-06, v error = 0.825E-07, total error = 0.565E-06 - Total RHS evals: Fs = 1504, Ff = 152354 + Total RHS evals: Fs = 1504, Ff = 152305 diff --git a/examples/arkode/F2003_serial/ark_kpr_mri_f2003_0_0.002.out b/examples/arkode/F2003_serial/ark_kpr_mri_f2003_0_0.002.out index 0eff8ab4a8..30dd3330cd 100644 --- a/examples/arkode/F2003_serial/ark_kpr_mri_f2003_0_0.002.out +++ b/examples/arkode/F2003_serial/ark_kpr_mri_f2003_0_0.002.out @@ -63,4 +63,4 @@ Final Solver Statistics: Steps: nsts = 2501, nstf = 252601 u error = 0.467E-08, v error = 0.564E-09, total error = 0.333E-08 - Total RHS evals: Fs = 7504, Ff = 760354 + Total RHS evals: Fs = 7504, Ff = 760305 diff --git a/examples/arkode/F2003_serial/ark_kpr_mri_f2003_1_0.002.out b/examples/arkode/F2003_serial/ark_kpr_mri_f2003_1_0.002.out index 5cdfce99f9..d49bb3b964 100644 --- a/examples/arkode/F2003_serial/ark_kpr_mri_f2003_1_0.002.out +++ b/examples/arkode/F2003_serial/ark_kpr_mri_f2003_1_0.002.out @@ -63,4 +63,4 @@ Final Solver Statistics: Steps: nsts = 2501, nstf = 252601 u error = 0.316E-12, v error = 0.191E-11, total error = 0.137E-11 - Total RHS evals: Fs = 5003, Ff = 760354 + Total RHS evals: Fs = 5003, Ff = 760305 diff --git a/examples/arkode/F2003_serial/ark_kpr_mri_f2003_3_0.01.out b/examples/arkode/F2003_serial/ark_kpr_mri_f2003_3_0.01.out index 2bd6749831..b3260e55ab 100644 --- a/examples/arkode/F2003_serial/ark_kpr_mri_f2003_3_0.01.out +++ b/examples/arkode/F2003_serial/ark_kpr_mri_f2003_3_0.01.out @@ -63,4 +63,4 @@ Final Solver Statistics: Steps: nsts = 501, nstf = 50601 u error = 0.505E-04, v error = 0.768E-03, total error = 0.545E-03 - Total RHS evals: Fs = 1504, Ff = 152354 + Total RHS evals: Fs = 1504, Ff = 152305 diff --git a/examples/arkode/F2003_serial/ark_kpr_mri_f2003_4_0.002.out b/examples/arkode/F2003_serial/ark_kpr_mri_f2003_4_0.002.out index 0fa85a2c8c..3814478dc7 100644 --- a/examples/arkode/F2003_serial/ark_kpr_mri_f2003_4_0.002.out +++ b/examples/arkode/F2003_serial/ark_kpr_mri_f2003_4_0.002.out @@ -64,7 +64,7 @@ Final Solver Statistics: Steps: nsts = 2501, nstf = 250100 u error = 0.348E-05, v error = 0.953E-03, total error = 0.674E-03 - Total RHS evals: Fs = 7143, Ff = 752851 + Total RHS evals: Fs = 7143, Ff = 752802 Slow Newton iters = 4641 Slow Newton conv fails = 0 Slow Jacobian evals = 126 diff --git a/examples/arkode/F2003_serial/ark_kpr_mri_f2003_5_0.002.out b/examples/arkode/F2003_serial/ark_kpr_mri_f2003_5_0.002.out index c44676ab2e..848386387e 100644 --- a/examples/arkode/F2003_serial/ark_kpr_mri_f2003_5_0.002.out +++ b/examples/arkode/F2003_serial/ark_kpr_mri_f2003_5_0.002.out @@ -63,4 +63,4 @@ Final Solver Statistics: Steps: nsts = 2501, nstf = 250100 u error = 0.166E-09, v error = 0.768E-10, total error = 0.130E-09 - Total RHS evals: Fs = 12506, Ff = 1002951 + Total RHS evals: Fs = 12506, Ff = 1002902 diff --git a/examples/arkode/F2003_serial/ark_kpr_mri_f2003_6_0.005.out b/examples/arkode/F2003_serial/ark_kpr_mri_f2003_6_0.005.out index 489db047df..20d2cb720a 100644 --- a/examples/arkode/F2003_serial/ark_kpr_mri_f2003_6_0.005.out +++ b/examples/arkode/F2003_serial/ark_kpr_mri_f2003_6_0.005.out @@ -63,4 +63,4 @@ Final Solver Statistics: Steps: nsts = 1001, nstf = 100100 u error = 0.757E-08, v error = 0.324E-08, total error = 0.582E-08 - Total RHS evals: Fs = 5006, Ff = 301351 + Total RHS evals: Fs = 5006, Ff = 301302 diff --git a/examples/arkode/F2003_serial/ark_kpr_mri_f2003_7_0.001.out b/examples/arkode/F2003_serial/ark_kpr_mri_f2003_7_0.001.out index e891da3ce5..980984a104 100644 --- a/examples/arkode/F2003_serial/ark_kpr_mri_f2003_7_0.001.out +++ b/examples/arkode/F2003_serial/ark_kpr_mri_f2003_7_0.001.out @@ -64,7 +64,7 @@ Final Solver Statistics: Steps: nsts = 5000, nstf = 510000 u error = 0.380E-09, v error = 0.394E-09, total error = 0.387E-09 - Total RHS evals: Fs = 45313, Ff = 1535050 + Total RHS evals: Fs = 45313, Ff = 1535001 Slow Newton iters = 30312 Slow Newton conv fails = 0 Slow Jacobian evals = 250 diff --git a/examples/arkode/F2003_serial/ark_kpr_mri_f2003_8_0.001.out b/examples/arkode/F2003_serial/ark_kpr_mri_f2003_8_0.001.out index db4d9b730c..5e9fd70305 100644 --- a/examples/arkode/F2003_serial/ark_kpr_mri_f2003_8_0.001.out +++ b/examples/arkode/F2003_serial/ark_kpr_mri_f2003_8_0.001.out @@ -64,7 +64,7 @@ Final Solver Statistics: Steps: nsts = 5000, nstf = 510000 u error = 0.179E-09, v error = 0.168E-09, total error = 0.174E-09 - Total RHS evals: Fse = 20001, Fsi = 50342, Ff = 1535050 + Total RHS evals: Fse = 20001, Fsi = 50342, Ff = 1535001 Slow Newton iters = 30341 Slow Newton conv fails = 0 Slow Jacobian evals = 250 diff --git a/examples/arkode/F2003_serial/ark_kpr_mri_f2003_9_0.001.out b/examples/arkode/F2003_serial/ark_kpr_mri_f2003_9_0.001.out index 726b6372d1..d4a07bc167 100644 --- a/examples/arkode/F2003_serial/ark_kpr_mri_f2003_9_0.001.out +++ b/examples/arkode/F2003_serial/ark_kpr_mri_f2003_9_0.001.out @@ -64,7 +64,7 @@ Final Solver Statistics: Steps: nsts = 5000, nstf = 510000 u error = 0.153E-10, v error = 0.419E-11, total error = 0.112E-10 - Total RHS evals: Fse = 30001, Fsi = 82555, Ff = 2045050 + Total RHS evals: Fse = 30001, Fsi = 82555, Ff = 2045001 Slow Newton iters = 52554 Slow Newton conv fails = 0 Slow Jacobian evals = 250 From dac0a6b52315596c0effa078597bd0a94b5fd71a Mon Sep 17 00:00:00 2001 From: "David J. Gardner" Date: Wed, 4 Dec 2024 09:23:03 -0800 Subject: [PATCH 283/286] match dividing lines --- src/arkode/arkode_mristep.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/arkode/arkode_mristep.c b/src/arkode/arkode_mristep.c index fabc747ba7..38e2267439 100644 --- a/src/arkode/arkode_mristep.c +++ b/src/arkode/arkode_mristep.c @@ -4221,7 +4221,7 @@ int mriStep_Hin(ARKodeMem ark_mem, sunrealtype tcur, sunrealtype tout, /*=============================================================== User-callable functions for a custom inner integrator - ---------------------------------------------------------------*/ + ===============================================================*/ int MRIStepInnerStepper_Create(SUNContext sunctx, MRIStepInnerStepper* stepper) { From eaea83f7847ad764c85ea755a23b71165c3982e4 Mon Sep 17 00:00:00 2001 From: "David J. Gardner" Date: Wed, 4 Dec 2024 09:38:40 -0800 Subject: [PATCH 284/286] add new line --- CHANGELOG.md | 1 + doc/shared/RecentChanges.rst | 1 + 2 files changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 61f91940fe..aa56fad501 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -85,6 +85,7 @@ Fixed a bug in MRIStep where the data supplied to the Hermite interpolation modu not include contributions from the fast right-hand side function. With this fix, users will see one additional fast right-hand side function evaluation per slow step with the Hermite interpolation option. + Fixed a CMake configuration issue related to aliasing an `ALIAS` target when using `ENABLE_KLU=ON` in combination with a static-only build of SuiteSparse. diff --git a/doc/shared/RecentChanges.rst b/doc/shared/RecentChanges.rst index 008e7b8508..9885baca5a 100644 --- a/doc/shared/RecentChanges.rst +++ b/doc/shared/RecentChanges.rst @@ -89,6 +89,7 @@ Fixed a bug in MRIStep where the data supplied to the Hermite interpolation modu not include contributions from the fast right-hand side function. With this fix, users will see one additional fast right-hand side function evaluation per slow step with the Hermite interpolation option. + Fixed a CMake configuration issue related to aliasing an ``ALIAS`` target when using ``ENABLE_KLU=ON`` in combination with a static-only build of SuiteSparse. From 66f9f7b8ea4dd829cafcc24cf388e4f1777ffcbe Mon Sep 17 00:00:00 2001 From: "David J. Gardner" Date: Wed, 4 Dec 2024 10:08:49 -0800 Subject: [PATCH 285/286] update answers submodule --- test/answers | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/answers b/test/answers index 75bd7fe761..294c370633 160000 --- a/test/answers +++ b/test/answers @@ -1 +1 @@ -Subproject commit 75bd7fe7617b1bad926f8203eac32430890880e3 +Subproject commit 294c3706336ef84e9719b419a4e29d9a551e7294 From 8ce81d87650026ae52ed790c2ff7ed1adf40fb14 Mon Sep 17 00:00:00 2001 From: Steven Roberts Date: Wed, 4 Dec 2024 11:00:01 -0800 Subject: [PATCH 286/286] Set and clear forcing in mriStepInnerStepper_EvolveSUNStepper --- src/arkode/arkode_mristep.c | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/src/arkode/arkode_mristep.c b/src/arkode/arkode_mristep.c index fabc747ba7..9d64474393 100644 --- a/src/arkode/arkode_mristep.c +++ b/src/arkode/arkode_mristep.c @@ -4564,14 +4564,21 @@ int mriStepInnerStepper_EvolveSUNStepper(MRIStepInnerStepper stepper, SUNStepper sunstepper = (SUNStepper)stepper->content; sunrealtype tret; - SUNErrCode err = sunstepper->ops->setstoptime(sunstepper, tout); - if (err != SUN_SUCCESS) - { - stepper->last_flag = sunstepper->last_flag; - return ARK_SUNSTEPPER_ERR; - } + SUNErrCode err = SUNStepper_SetForcing(sunstepper, stepper->tshift, + stepper->tscale, stepper->forcing, + stepper->nforcing); + stepper->last_flag = sunstepper->last_flag; + if (err != SUN_SUCCESS) { return ARK_SUNSTEPPER_ERR; } + + err = SUNStepper_SetStopTime(sunstepper, tout); + stepper->last_flag = sunstepper->last_flag; + if (err != SUN_SUCCESS) { return ARK_SUNSTEPPER_ERR; } + + err = SUNStepper_Evolve(sunstepper, tout, y, &tret); + stepper->last_flag = sunstepper->last_flag; + if (err != SUN_SUCCESS) { return ARK_SUNSTEPPER_ERR; } - err = sunstepper->ops->evolve(sunstepper, tout, y, &tret); + err = SUNStepper_SetForcing(sunstepper, ZERO, ONE, NULL, 0); stepper->last_flag = sunstepper->last_flag; if (err != SUN_SUCCESS) { return ARK_SUNSTEPPER_ERR; } @@ -4606,7 +4613,7 @@ int mriStepInnerStepper_FullRhsSUNStepper(MRIStepInnerStepper stepper, default: mode = SUN_FULLRHS_OTHER; break; } - SUNErrCode err = sunstepper->ops->fullrhs(sunstepper, t, y, f, mode); + SUNErrCode err = SUNStepper_FullRhs(sunstepper, t, y, f, mode); stepper->last_flag = sunstepper->last_flag; if (err != SUN_SUCCESS) { return ARK_SUNSTEPPER_ERR; } return ARK_SUCCESS; @@ -4692,7 +4699,7 @@ int mriStepInnerStepper_ResetSUNStepper(MRIStepInnerStepper stepper, sunrealtype tR, N_Vector yR) { SUNStepper sunstepper = (SUNStepper)stepper->content; - SUNErrCode err = sunstepper->ops->reset(sunstepper, tR, yR); + SUNErrCode err = SUNStepper_Reset(sunstepper, tR, yR); stepper->last_flag = sunstepper->last_flag; if (err != SUN_SUCCESS) { return ARK_SUNSTEPPER_ERR; } return ARK_SUCCESS;