From 480f40bc94b4a5251ac3f4bb0ee8fc47f21a68a2 Mon Sep 17 00:00:00 2001 From: Jon Rood Date: Wed, 2 Oct 2024 11:25:08 -0600 Subject: [PATCH 1/6] Update SUNDIALS to 7.1.1. --- Submodules/sundials | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Submodules/sundials b/Submodules/sundials index 2abd63bd6..c28eaa376 160000 --- a/Submodules/sundials +++ b/Submodules/sundials @@ -1 +1 @@ -Subproject commit 2abd63bd6cbc354fb4861bba8e98d0b95d65e24a +Subproject commit c28eaa3764a03705d61decb6025b409360e9d53f From e93a2e9d844a73cce3c1f26013a742a7318de3b6 Mon Sep 17 00:00:00 2001 From: Jon Rood Date: Mon, 7 Oct 2024 15:09:41 -0600 Subject: [PATCH 2/6] Update deprecated SUNDIALS calls. --- Source/Reactions/ReactorArkode.cpp | 56 +++++++++++++----------------- Source/Reactions/ReactorUtils.H | 4 +-- 2 files changed, 26 insertions(+), 34 deletions(-) diff --git a/Source/Reactions/ReactorArkode.cpp b/Source/Reactions/ReactorArkode.cpp index 95e3472a5..143a21bde 100644 --- a/Source/Reactions/ReactorArkode.cpp +++ b/Source/Reactions/ReactorArkode.cpp @@ -199,31 +199,31 @@ ReactorArkode::react( if (use_erkstep == 0) { arkode_mem = ARKStepCreate( cF_RHS, nullptr, time, y, *amrex::sundials::The_Sundials_Context()); - ARKStepSetUserData(arkode_mem, static_cast(user_data)); + ARKodeSetUserData(arkode_mem, static_cast(user_data)); utils::set_sundials_solver_tols( *amrex::sundials::The_Sundials_Context(), arkode_mem, user_data->ncells, relTol, absTol, m_typ_vals, "arkstep", verbose); ARKStepSetTableNum( arkode_mem, ARKODE_DIRK_NONE, static_cast(rk_method)); - int flag = ARKStepSetAdaptController(arkode_mem, sun_controller); + int flag = ARKodeSetAdaptController(arkode_mem, sun_controller); utils::check_flag(&flag, "ARKStepSetAdaptController", 1); BL_PROFILE_VAR( "Pele::ReactorArkode::react():ARKStepEvolve", AroundARKEvolve); - ARKStepEvolve(arkode_mem, time_out, y, &time_init, ARK_NORMAL); + ARKodeEvolve(arkode_mem, time_out, y, &time_init, ARK_NORMAL); BL_PROFILE_VAR_STOP(AroundARKEvolve); } else { arkode_mem = ERKStepCreate(cF_RHS, time, y, *amrex::sundials::The_Sundials_Context()); - ERKStepSetUserData(arkode_mem, static_cast(user_data)); + ARKodeSetUserData(arkode_mem, static_cast(user_data)); utils::set_sundials_solver_tols( *amrex::sundials::The_Sundials_Context(), arkode_mem, user_data->ncells, relTol, absTol, m_typ_vals, "erkstep", verbose); ERKStepSetTableNum(arkode_mem, static_cast(rk_method)); - int flag = ERKStepSetAdaptController(arkode_mem, sun_controller); + int flag = ARKodeSetAdaptController(arkode_mem, sun_controller); utils::check_flag(&flag, "ERKStepSetAdaptController", 1); BL_PROFILE_VAR( "Pele::ReactorArkode::react():ERKStepEvolve", AroundERKEvolve); - ERKStepEvolve(arkode_mem, time_out, y, &time_init, ARK_NORMAL); + ARKodeEvolve(arkode_mem, time_out, y, &time_init, ARK_NORMAL); BL_PROFILE_VAR_STOP(AroundERKEvolve); } @@ -250,11 +250,7 @@ ReactorArkode::react( user_data->rhoe_init, d_nfe, dt_react); N_VDestroy(y); - if (use_erkstep == 0) { - ARKStepFree(&arkode_mem); - } else { - ERKStepFree(&arkode_mem); - } + ARKodeFree(&arkode_mem); delete user_data; @@ -339,24 +335,24 @@ ReactorArkode::react( if (use_erkstep == 0) { arkode_mem = ARKStepCreate( cF_RHS, nullptr, time, y, *amrex::sundials::The_Sundials_Context()); - ARKStepSetUserData(arkode_mem, static_cast(user_data)); + ARKodeSetUserData(arkode_mem, static_cast(user_data)); utils::set_sundials_solver_tols( *amrex::sundials::The_Sundials_Context(), arkode_mem, user_data->ncells, relTol, absTol, m_typ_vals, "arkstep", verbose); BL_PROFILE_VAR( "Pele::ReactorArkode::react():ARKStepEvolve", AroundARKEvolve); - ARKStepEvolve(arkode_mem, time_out, y, &time_init, ARK_NORMAL); + ARKodeEvolve(arkode_mem, time_out, y, &time_init, ARK_NORMAL); BL_PROFILE_VAR_STOP(AroundARKEvolve); } else { arkode_mem = ERKStepCreate(cF_RHS, time, y, *amrex::sundials::The_Sundials_Context()); - ERKStepSetUserData(arkode_mem, static_cast(user_data)); + ARKodeSetUserData(arkode_mem, static_cast(user_data)); utils::set_sundials_solver_tols( *amrex::sundials::The_Sundials_Context(), arkode_mem, user_data->ncells, relTol, absTol, m_typ_vals, "erkstep", verbose); BL_PROFILE_VAR( "Pele::ReactorArkode::react():ERKStepEvolve", AroundERKEvolve); - ERKStepEvolve(arkode_mem, time_out, y, &time_init, ARK_NORMAL); + ARKodeEvolve(arkode_mem, time_out, y, &time_init, ARK_NORMAL); BL_PROFILE_VAR_STOP(AroundERKEvolve); } #ifdef MOD_REACTOR @@ -386,11 +382,7 @@ ReactorArkode::react( } N_VDestroy(y); - if (use_erkstep == 0) { - ARKStepFree(&arkode_mem); - } else { - ERKStepFree(&arkode_mem); - } + ARKodeFree(&arkode_mem); delete user_data; @@ -437,22 +429,22 @@ ReactorArkode::print_final_stats(void* arkode_mem) int flag; if (use_erkstep != 0) { - flag = ERKStepGetNumSteps(arkode_mem, &nst); - utils::check_flag(&flag, "ERKStepGetNumSteps", 1); - flag = ERKStepGetNumStepAttempts(arkode_mem, &nst_a); - utils::check_flag(&flag, "ERKStepGetNumStepAttempts", 1); - flag = ERKStepGetNumErrTestFails(arkode_mem, &netf); - utils::check_flag(&flag, "ERKStepGetNumErrTestFails", 1); + flag = ERKStepGetARKodes(arkode_mem, &nst); + utils::check_flag(&flag, "ERKStepGetARKodes", 1); + flag = ERKStepGetARKodeAttempts(arkode_mem, &nst_a); + utils::check_flag(&flag, "ERKStepGetARKodeAttempts", 1); + flag = ARKodeGetNumErrTestFails(arkode_mem, &netf); + utils::check_flag(&flag, "ARKodeGetNumErrTestFails", 1); flag = ERKStepGetNumRhsEvals(arkode_mem, &nfe); utils::check_flag(&flag, "ERKStepGetNumRhsEvals", 1); } else { - flag = ARKStepGetNumSteps(arkode_mem, &nst); - utils::check_flag(&flag, "ARKStepGetNumSteps", 1); - flag = ARKStepGetNumStepAttempts(arkode_mem, &nst_a); - utils::check_flag(&flag, "ARKStepGetNumStepAttempts", 1); - flag = ARKStepGetNumErrTestFails(arkode_mem, &netf); - utils::check_flag(&flag, "ARKStepGetNumErrTestFails", 1); + flag = ARKodeGetNumSteps(arkode_mem, &nst); + utils::check_flag(&flag, "ARKodeGetNumSteps", 1); + flag = ARKodeGetNumStepAttempts(arkode_mem, &nst_a); + utils::check_flag(&flag, "ARKodeGetNumStepAttempts", 1); + flag = ARKodeGetNumErrTestFails(arkode_mem, &netf); + utils::check_flag(&flag, "ARKodeGetNumErrTestFails", 1); flag = ARKStepGetNumRhsEvals(arkode_mem, &nfe, &nfi); utils::check_flag(&flag, "ARKStepGetNumRhsEvals", 1); } diff --git a/Source/Reactions/ReactorUtils.H b/Source/Reactions/ReactorUtils.H index 1cb89d8eb..5d7ee36cb 100644 --- a/Source/Reactions/ReactorUtils.H +++ b/Source/Reactions/ReactorUtils.H @@ -147,9 +147,9 @@ set_sundials_solver_tols( if (solvername == "cvode") { flag = CVodeSVtolerances(sundials_mem, relTol, atol); } else if (solvername == "arkstep") { - flag = ARKStepSVtolerances(sundials_mem, relTol, atol); + flag = ARKodeSVtolerances(sundials_mem, relTol, atol); } else if (solvername == "erkstep") { - flag = ERKStepSVtolerances(sundials_mem, relTol, atol); + flag = ARKodeSVtolerances(sundials_mem, relTol, atol); } else { amrex::Abort("setSundialsSolverTols not implemented for this solver type"); } From 5b80fe9eb86ec5023e55ff33063bd842e79c50ca Mon Sep 17 00:00:00 2001 From: Jon Rood Date: Mon, 7 Oct 2024 15:27:57 -0600 Subject: [PATCH 3/6] Fix name. --- Source/Reactions/ReactorArkode.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Source/Reactions/ReactorArkode.cpp b/Source/Reactions/ReactorArkode.cpp index 143a21bde..8fc75e1de 100644 --- a/Source/Reactions/ReactorArkode.cpp +++ b/Source/Reactions/ReactorArkode.cpp @@ -429,8 +429,8 @@ ReactorArkode::print_final_stats(void* arkode_mem) int flag; if (use_erkstep != 0) { - flag = ERKStepGetARKodes(arkode_mem, &nst); - utils::check_flag(&flag, "ERKStepGetARKodes", 1); + flag = ARKodeGetNumSteps(arkode_mem, &nst); + utils::check_flag(&flag, "ARKodeGetNumSteps", 1); flag = ERKStepGetARKodeAttempts(arkode_mem, &nst_a); utils::check_flag(&flag, "ERKStepGetARKodeAttempts", 1); flag = ARKodeGetNumErrTestFails(arkode_mem, &netf); From a43d8f12d50641a48919a2c13c4dfdbcbef9f6f1 Mon Sep 17 00:00:00 2001 From: Jon Rood Date: Mon, 7 Oct 2024 15:37:01 -0600 Subject: [PATCH 4/6] Fix names. --- Source/Reactions/ReactorArkode.cpp | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/Source/Reactions/ReactorArkode.cpp b/Source/Reactions/ReactorArkode.cpp index 8fc75e1de..abccc5eb2 100644 --- a/Source/Reactions/ReactorArkode.cpp +++ b/Source/Reactions/ReactorArkode.cpp @@ -428,23 +428,16 @@ ReactorArkode::print_final_stats(void* arkode_mem) long int nst, nst_a, netf, nfe, nfi; int flag; + flag = ARKodeGetNumSteps(arkode_mem, &nst); + utils::check_flag(&flag, "ARKodeGetNumSteps", 1); + flag = ARKodeGetNumStepAttempts(arkode_mem, &nst_a); + utils::check_flag(&flag, "ARKodeGetNumStepAttempts", 1); + flag = ARKodeGetNumErrTestFails(arkode_mem, &netf); + utils::check_flag(&flag, "ARKodeGetNumErrTestFails", 1); if (use_erkstep != 0) { - flag = ARKodeGetNumSteps(arkode_mem, &nst); - utils::check_flag(&flag, "ARKodeGetNumSteps", 1); - flag = ERKStepGetARKodeAttempts(arkode_mem, &nst_a); - utils::check_flag(&flag, "ERKStepGetARKodeAttempts", 1); - flag = ARKodeGetNumErrTestFails(arkode_mem, &netf); - utils::check_flag(&flag, "ARKodeGetNumErrTestFails", 1); flag = ERKStepGetNumRhsEvals(arkode_mem, &nfe); utils::check_flag(&flag, "ERKStepGetNumRhsEvals", 1); - } else { - flag = ARKodeGetNumSteps(arkode_mem, &nst); - utils::check_flag(&flag, "ARKodeGetNumSteps", 1); - flag = ARKodeGetNumStepAttempts(arkode_mem, &nst_a); - utils::check_flag(&flag, "ARKodeGetNumStepAttempts", 1); - flag = ARKodeGetNumErrTestFails(arkode_mem, &netf); - utils::check_flag(&flag, "ARKodeGetNumErrTestFails", 1); flag = ARKStepGetNumRhsEvals(arkode_mem, &nfe, &nfi); utils::check_flag(&flag, "ARKStepGetNumRhsEvals", 1); } From ddbb994c774e906895977c8c65f6fc53133fa4e7 Mon Sep 17 00:00:00 2001 From: Jon Rood Date: Tue, 8 Oct 2024 10:15:06 -0600 Subject: [PATCH 5/6] Fix names. Consolidate code paths. --- Source/Reactions/ReactorArkode.cpp | 4 ++-- Source/Reactions/ReactorUtils.H | 11 ++++++----- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/Source/Reactions/ReactorArkode.cpp b/Source/Reactions/ReactorArkode.cpp index abccc5eb2..e1a54b247 100644 --- a/Source/Reactions/ReactorArkode.cpp +++ b/Source/Reactions/ReactorArkode.cpp @@ -206,7 +206,7 @@ ReactorArkode::react( ARKStepSetTableNum( arkode_mem, ARKODE_DIRK_NONE, static_cast(rk_method)); int flag = ARKodeSetAdaptController(arkode_mem, sun_controller); - utils::check_flag(&flag, "ARKStepSetAdaptController", 1); + utils::check_flag(&flag, "ARKodeSetAdaptController", 1); BL_PROFILE_VAR( "Pele::ReactorArkode::react():ARKStepEvolve", AroundARKEvolve); ARKodeEvolve(arkode_mem, time_out, y, &time_init, ARK_NORMAL); @@ -220,7 +220,7 @@ ReactorArkode::react( relTol, absTol, m_typ_vals, "erkstep", verbose); ERKStepSetTableNum(arkode_mem, static_cast(rk_method)); int flag = ARKodeSetAdaptController(arkode_mem, sun_controller); - utils::check_flag(&flag, "ERKStepSetAdaptController", 1); + utils::check_flag(&flag, "ARKodeSetAdaptController", 1); BL_PROFILE_VAR( "Pele::ReactorArkode::react():ERKStepEvolve", AroundERKEvolve); ARKodeEvolve(arkode_mem, time_out, y, &time_init, ARK_NORMAL); diff --git a/Source/Reactions/ReactorUtils.H b/Source/Reactions/ReactorUtils.H index 5d7ee36cb..ad4d7a300 100644 --- a/Source/Reactions/ReactorUtils.H +++ b/Source/Reactions/ReactorUtils.H @@ -146,11 +146,12 @@ set_sundials_solver_tols( int flag; if (solvername == "cvode") { flag = CVodeSVtolerances(sundials_mem, relTol, atol); - } else if (solvername == "arkstep") { - flag = ARKodeSVtolerances(sundials_mem, relTol, atol); - } else if (solvername == "erkstep") { - flag = ARKodeSVtolerances(sundials_mem, relTol, atol); - } else { + } else if (solvername == "arkstep") + || (solvername == "erkstep") + { + flag = ARKodeSVtolerances(sundials_mem, relTol, atol); + } + else { amrex::Abort("setSundialsSolverTols not implemented for this solver type"); } if (utils::check_flag(&flag, "SVtolerances", 1) != 0) { From c2bb0d68430b9bedbfb245e483a04369f3b98885 Mon Sep 17 00:00:00 2001 From: Jon Rood Date: Tue, 8 Oct 2024 10:20:07 -0600 Subject: [PATCH 6/6] Add parantheses. --- Source/Reactions/ReactorUtils.H | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/Source/Reactions/ReactorUtils.H b/Source/Reactions/ReactorUtils.H index ad4d7a300..cd513883d 100644 --- a/Source/Reactions/ReactorUtils.H +++ b/Source/Reactions/ReactorUtils.H @@ -146,12 +146,9 @@ set_sundials_solver_tols( int flag; if (solvername == "cvode") { flag = CVodeSVtolerances(sundials_mem, relTol, atol); - } else if (solvername == "arkstep") - || (solvername == "erkstep") - { - flag = ARKodeSVtolerances(sundials_mem, relTol, atol); - } - else { + } else if ((solvername == "arkstep") || (solvername == "erkstep")) { + flag = ARKodeSVtolerances(sundials_mem, relTol, atol); + } else { amrex::Abort("setSundialsSolverTols not implemented for this solver type"); } if (utils::check_flag(&flag, "SVtolerances", 1) != 0) {