From 45ae8ba14f2a14e8f692c83a3b675883f7018bfd Mon Sep 17 00:00:00 2001 From: Jon Rood Date: Tue, 8 Oct 2024 10:43:35 -0600 Subject: [PATCH] Update SUNDIALS to 7.1.1 (#531) --- Source/Reactions/ReactorArkode.cpp | 55 +++++++++++------------------- Source/Reactions/ReactorUtils.H | 6 ++-- Submodules/sundials | 2 +- 3 files changed, 23 insertions(+), 40 deletions(-) diff --git a/Source/Reactions/ReactorArkode.cpp b/Source/Reactions/ReactorArkode.cpp index 95e3472a5..e1a54b247 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); - utils::check_flag(&flag, "ARKStepSetAdaptController", 1); + int flag = ARKodeSetAdaptController(arkode_mem, sun_controller); + utils::check_flag(&flag, "ARKodeSetAdaptController", 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); - utils::check_flag(&flag, "ERKStepSetAdaptController", 1); + int flag = ARKodeSetAdaptController(arkode_mem, sun_controller); + utils::check_flag(&flag, "ARKodeSetAdaptController", 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; @@ -436,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 = 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 = 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 = 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..cd513883d 100644 --- a/Source/Reactions/ReactorUtils.H +++ b/Source/Reactions/ReactorUtils.H @@ -146,10 +146,8 @@ set_sundials_solver_tols( int flag; if (solvername == "cvode") { flag = CVodeSVtolerances(sundials_mem, relTol, atol); - } else if (solvername == "arkstep") { - flag = ARKStepSVtolerances(sundials_mem, relTol, atol); - } else if (solvername == "erkstep") { - flag = ERKStepSVtolerances(sundials_mem, relTol, atol); + } else if ((solvername == "arkstep") || (solvername == "erkstep")) { + flag = ARKodeSVtolerances(sundials_mem, relTol, atol); } else { amrex::Abort("setSundialsSolverTols not implemented for this solver type"); } 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