Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update SUNDIALS to 7.1.1 #531

Merged
merged 8 commits into from
Oct 8, 2024
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 20 additions & 35 deletions Source/Reactions/ReactorArkode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -199,31 +199,31 @@ ReactorArkode::react(
if (use_erkstep == 0) {
marchdf marked this conversation as resolved.
Show resolved Hide resolved
arkode_mem = ARKStepCreate(
cF_RHS, nullptr, time, y, *amrex::sundials::The_Sundials_Context());
ARKStepSetUserData(arkode_mem, static_cast<void*>(user_data));
ARKodeSetUserData(arkode_mem, static_cast<void*>(user_data));
utils::set_sundials_solver_tols<Ordering>(
*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<ARKODE_ERKTableID>(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<void*>(user_data));
ARKodeSetUserData(arkode_mem, static_cast<void*>(user_data));
utils::set_sundials_solver_tols<Ordering>(
*amrex::sundials::The_Sundials_Context(), arkode_mem, user_data->ncells,
relTol, absTol, m_typ_vals, "erkstep", verbose);
ERKStepSetTableNum(arkode_mem, static_cast<ARKODE_ERKTableID>(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);
}

Expand All @@ -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;

Expand Down Expand Up @@ -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<void*>(user_data));
ARKodeSetUserData(arkode_mem, static_cast<void*>(user_data));
utils::set_sundials_solver_tols<Ordering>(
*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<void*>(user_data));
ARKodeSetUserData(arkode_mem, static_cast<void*>(user_data));
utils::set_sundials_solver_tols<Ordering>(
*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
Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -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);
}
Expand Down
11 changes: 6 additions & 5 deletions Source/Reactions/ReactorUtils.H
Original file line number Diff line number Diff line change
Expand Up @@ -146,11 +146,12 @@ 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 {
} 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) {
Expand Down
2 changes: 1 addition & 1 deletion Submodules/sundials
Submodule sundials updated 928 files
Loading