From e8ecda6dbfe33bd006229654b31dc12e4c283ca8 Mon Sep 17 00:00:00 2001 From: David Wells Date: Sun, 22 May 2022 21:43:42 -0400 Subject: [PATCH] Fix ARKODE for SUNDIALS 6. --- source/sundials/arkode.cc | 38 ++++++++++++++++++-------------------- 1 file changed, 18 insertions(+), 20 deletions(-) diff --git a/source/sundials/arkode.cc b/source/sundials/arkode.cc index 311748ce5c..fda97a4a05 100644 --- a/source/sundials/arkode.cc +++ b/source/sundials/arkode.cc @@ -626,19 +626,24 @@ namespace SUNDIALS const VectorType &solution) { last_end_time = current_time; - if (arkode_mem) - { - ARKStepFree(&arkode_mem); + int status; + (void)status; # if DEAL_II_SUNDIALS_VERSION_GTE(6, 0, 0) - const int status = SUNContext_Free(&arkode_ctx); - (void)status; + if (arkode_ctx) + { + status = SUNContext_Free(&arkode_ctx); AssertARKode(status); -# endif } + status = SUNContext_Create(&mpi_communicator, &arkode_ctx); + AssertARKode(status); +# endif - int status; - (void)status; + if (arkode_mem) + { + ARKStepFree(&arkode_mem); + // Initialization is version-dependent: do that in a moment + } // just a view on the memory in solution, all write operations on yy by // ARKODE will automatically be mirrored to solution @@ -652,23 +657,16 @@ namespace SUNDIALS Assert(explicit_function || implicit_function, ExcFunctionNotProvided("explicit_function || implicit_function")); -# if DEAL_II_SUNDIALS_VERSION_LT(6, 0, 0) arkode_mem = ARKStepCreate( explicit_function ? &explicit_function_callback : nullptr, implicit_function ? &implicit_function_callback : nullptr, current_time, - initial_condition_nvector); -# else - status = SUNContext_Create(&mpi_communicator, &arkode_ctx); - AssertARKode(status); - - arkode_mem = ARKStepCreate( - explicit_function ? &explicit_function_callback : nullptr, - implicit_function ? &implicit_function_callback : nullptr, - current_time, - initial_condition_nvector, - arkode_ctx); + initial_condition_nvector +# if DEAL_II_SUNDIALS_VERSION_GTE(6, 0, 0) + , + arkode_ctx # endif + ); Assert(arkode_mem != nullptr, ExcInternalError()); if (get_local_tolerances) -- 2.39.5