]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Rename a callback in PETScWrappers::TimeStepper.
authorWolfgang Bangerth <bangerth@colostate.edu>
Mon, 1 Jul 2024 03:25:29 +0000 (21:25 -0600)
committerWolfgang Bangerth <bangerth@colostate.edu>
Tue, 2 Jul 2024 16:54:47 +0000 (10:54 -0600)
include/deal.II/lac/petsc_ts.h
include/deal.II/lac/petsc_ts.templates.h

index 9266342c6ca08b53b7b6dc08fb5d8f5f4f2c74a1..b4fa23918cff7ef4122607ba3c7cdb8ee1ec01a3 100644 (file)
@@ -590,6 +590,13 @@ namespace PETScWrappers
      */
     std::function<IndexSet()> algebraic_components;
 
+    /**
+     * This callback is equivalent to `update_constrained_components`, but is
+     * deprecated. Use `update_constrained_components` instead.
+     */
+    DEAL_II_DEPRECATED_EARLY
+    std::function<void(const real_type t, VectorType &y)> distribute;
+
     /**
      * Callback to distribute solution to hanging nodes.
      *
@@ -603,7 +610,8 @@ namespace PETScWrappers
      * See there for a description of how to deal with errors and other
      * requirements and conventions.
      */
-    std::function<void(const real_type t, VectorType &y)> distribute;
+    std::function<void(const real_type t, VectorType &y)>
+      update_constrained_components;
 
     /**
      * Callback to set up mesh adaption.
index aea7f2951f974061cc5b9d6e7b8988f6f4207885..bd44fda0065a19f01025efce4cf2c007da0c5926 100644 (file)
@@ -608,7 +608,11 @@ namespace PETScWrappers
 
       const int lineno = __LINE__;
       const int err    = call_and_possibly_capture_ts_exception(
-        user->distribute,
+        // Call the user-provided callback. Use the new name if used,
+        // or the legacy name otherwise.
+        (user->update_constrained_components ?
+              user->update_constrained_components :
+              user->distribute),
         user->pending_exception,
         [user, ts]() -> void {
           user->error_in_function = true;
@@ -623,7 +627,7 @@ namespace PETScWrappers
         return PetscError(
           PetscObjectComm((PetscObject)ts),
           lineno + 1,
-          "distribute",
+          "update_constrained_components",
           __FILE__,
           PETSC_ERR_LIB,
           PETSC_ERROR_INITIAL,
@@ -1025,8 +1029,17 @@ namespace PETScWrappers
         AssertPETSc(KSPSetPC(ksp, solve_with_jacobian_pc.get_pc()));
       }
 
-    if (distribute)
-      AssertPETSc(TSSetPostStage(ts, ts_poststage));
+    if (distribute || update_constrained_components)
+      {
+        if (update_constrained_components)
+          Assert(!distribute,
+                 ExcMessage(
+                   "The 'distribute' callback name of the TimeStepper "
+                   "class is deprecated. If you are setting the equivalent "
+                   "'update_constrained_components' callback, you cannot also "
+                   "set the 'distribute' callback."));
+        AssertPETSc(TSSetPostStage(ts, ts_poststage));
+      }
 
     // Attach user monitoring routine.
     if (monitor)

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.