]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Fix ARKODE for SUNDIALS 6.
authorDavid Wells <drwells@email.unc.edu>
Mon, 23 May 2022 01:43:42 +0000 (21:43 -0400)
committerDavid Wells <drwells@email.unc.edu>
Mon, 23 May 2022 01:43:42 +0000 (21:43 -0400)
source/sundials/arkode.cc

index 311748ce5c4ca519282d1e3d4a6f491155485889..fda97a4a05698e4ee4f84a994bfd00153f59ed76 100644 (file)
@@ -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<VectorType> : nullptr,
       implicit_function ? &implicit_function_callback<VectorType> : nullptr,
       current_time,
-      initial_condition_nvector);
-#    else
-    status = SUNContext_Create(&mpi_communicator, &arkode_ctx);
-    AssertARKode(status);
-
-    arkode_mem = ARKStepCreate(
-      explicit_function ? &explicit_function_callback<VectorType> : nullptr,
-      implicit_function ? &implicit_function_callback<VectorType> : 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)

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.