]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Rename a third callback in PETScWrappers::TimeStepper.
authorWolfgang Bangerth <bangerth@colostate.edu>
Tue, 9 Jul 2024 16:45:10 +0000 (10:45 -0600)
committerWolfgang Bangerth <bangerth@colostate.edu>
Tue, 9 Jul 2024 16:45:10 +0000 (10:45 -0600)
include/deal.II/lac/petsc_ts.h
include/deal.II/lac/petsc_ts.templates.h

index ccea3f433275faaf96c5c833c1b440e38a03ef1c..d698a0d14f631330fb71610d43e538b0a4b11e1d 100644 (file)
@@ -651,22 +651,33 @@ namespace PETScWrappers
       decide_and_prepare_for_remeshing;
 
     /**
-     * Callback to interpolate vectors and perform mesh adaption.
+     * @deprecated This callback is equivalent to `transfer_solution_vectors_to_new_mesh`, but is
+     * deprecated. Use `transfer_solution_vectors_to_new_mesh` instead.
+     */
+    DEAL_II_DEPRECATED_EARLY
+    std::function<void(const std::vector<VectorType> &all_in,
+                       std::vector<VectorType>       &all_out)>
+      interpolate;
+
+    /**
+     * Callback to perform mesh adaptation and transfer solution vectors
+     * from the old to the new mesh.
      *
      * Implementation of this function is mandatory if
-     * TimeStepper::decide_for_coarsening_and_refinement is used.
+     * TimeStepper::decide_and_prepare_for_remeshing is used.
      * This function must perform mesh adaption and interpolate the discrete
-     * functions that are stored in @p all_in onto the refined and/or coarsenend grid.
-     * Output vectors must be created inside the callback.
+     * functions that are stored in @p all_in onto the refined and/or coarsened grid.
+     * The output vectors must be sized correctly within this callback.
      *
      * @note This variable represents a
      * @ref GlossUserProvidedCallBack "user provided callback".
      * See there for a description of how to deal with errors and other
      * requirements and conventions.
      */
-    std::function<void(const std::vector<VectorType> &all_in,
+    std::function<void(const real_type                t,
+                       const std::vector<VectorType> &all_in,
                        std::vector<VectorType>       &all_out)>
-      interpolate;
+      transfer_solution_vectors_to_new_mesh;
 
   private:
     /**
index 12fcac4543fb8d4bee844ff6b6d23ef0c956e69b..f3c351885b3ead2912d8bfb09a7d079db817dd54 100644 (file)
@@ -486,7 +486,20 @@ namespace PETScWrappers
 
       const int lineno = __LINE__;
       const int err    = call_and_possibly_capture_ts_exception(
-        user->interpolate, user->pending_exception, {}, all_in, all_out);
+        (user->transfer_solution_vectors_to_new_mesh ?
+              // If we can, call the new callback
+           user->transfer_solution_vectors_to_new_mesh :
+              // otherwise, use the old one where we just ignore the time:
+           [user](const real_type /*t*/,
+                  const std::vector<VectorType> &all_in,
+                  std::vector<VectorType>       &all_out) {
+             user->interpolate(all_in, all_out);
+           }),
+        user->pending_exception,
+        {},
+        user->get_time(),
+        all_in,
+        all_out);
       if (err)
         return PetscError(
           PetscObjectComm((PetscObject)ts),
@@ -1065,8 +1078,24 @@ namespace PETScWrappers
               "the equivalent 'decide_and_prepare_for_remeshing' callback, you "
               "cannot also set the 'decide_for_coarsening_and_refinement' "
               "callback."));
-        AssertThrow(interpolate,
-                    StandardExceptions::ExcFunctionNotProvided("interpolate"));
+
+        // If we have the decide_and_prepare_for_remeshing callback
+        // set, then we also need to have the callback for actually
+        // transfering the solution:
+        AssertThrow(interpolate || transfer_solution_vectors_to_new_mesh,
+                    StandardExceptions::ExcFunctionNotProvided(
+                      "transfer_solution_vectors_to_new_mesh"));
+
+        if (transfer_solution_vectors_to_new_mesh)
+          Assert(
+            !interpolate,
+            ExcMessage(
+              "The 'interpolate' callback name "
+              "of the TimeStepper class is deprecated. If you are setting "
+              "the equivalent 'transfer_solution_vectors_to_new_mesh' callback, you "
+              "cannot also set the 'interpolate' "
+              "callback."));
+
 #  if DEAL_II_PETSC_VERSION_GTE(3, 21, 0)
         (void)ts_poststep_amr;
         AssertPETSc(TSSetResize(ts,

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.