From: David Wells Date: Mon, 23 May 2022 01:43:42 +0000 (-0400) Subject: Fix ARKODE for SUNDIALS 6. X-Git-Tag: v9.4.0-rc1~159^2~1 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e8ecda6dbfe33bd006229654b31dc12e4c283ca8;p=dealii.git Fix ARKODE for SUNDIALS 6. --- 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)