]> https://gitweb.dealii.org/ - dealii.git/commitdiff
PETSc: support version 3.21 16767/head
authorStefano Zampini <stefano.zampini@gmail.com>
Wed, 20 Mar 2024 21:27:53 +0000 (00:27 +0300)
committerStefano Zampini <stefano.zampini@gmail.com>
Wed, 20 Mar 2024 21:27:53 +0000 (00:27 +0300)
include/deal.II/lac/petsc_ts.h
include/deal.II/lac/petsc_ts.templates.h

index 27f19e1b49464e4481453e9e9364d7c213415efb..908011c0fcfdffcba298dee4f81ff9bac07da64f 100644 (file)
@@ -63,6 +63,7 @@ namespace PETScWrappers
      * @param initial_step_size Initial step size.
      * @param max_steps Maximum number of steps allowed.
      * @param match_step Whether or not to exactly stop at final time or step over it.
+     * @param restart_if_remesh Whether or not to restart the step when remeshing is flagged.
      *
      * Error parameters:
      *
@@ -93,6 +94,7 @@ namespace PETScWrappers
       const real_type    initial_step_size = 0.0,
       const int          max_steps         = -1,
       const bool         match_step        = false,
+      const bool         restart_if_remesh = false,
       // Error parameters
       const std::string &ts_adapt_type        = "none",
       const real_type    minimum_step_size    = -1.0,
@@ -107,6 +109,7 @@ namespace PETScWrappers
       , initial_step_size(initial_step_size)
       , max_steps(max_steps)
       , match_step(match_step)
+      , restart_if_remesh(restart_if_remesh)
       , ts_adapt_type(ts_adapt_type)
       , minimum_step_size(minimum_step_size)
       , maximum_step_size(maximum_step_size)
@@ -160,6 +163,11 @@ namespace PETScWrappers
      */
     bool match_step;
 
+    /**
+     * Flag to indicate to restart the step if remeshing is flagged.
+     */
+    bool restart_if_remesh;
+
     /**
      * PETSc time step adaptor type.
      */
@@ -651,6 +659,12 @@ namespace PETScWrappers
      */
     PreconditionShell solve_with_jacobian_pc;
 
+    /**
+     * This flag is used to decide whether or not to restart the step if
+     * remeshing has been performed
+     */
+    bool restart_if_remesh;
+
     /**
      * This flag is set when changing the customization and used within solve.
      */
index bd4820fda88767ec57bda47a1346547ef0824650..aea7f2951f974061cc5b9d6e7b8988f6f4207885 100644 (file)
@@ -340,6 +340,9 @@ namespace PETScWrappers
                                       TS_EXACTFINALTIME_MATCHSTEP :
                                       TS_EXACTFINALTIME_STEPOVER));
 
+    // Store the boolean to be passed to TSSetResize.
+    this->restart_if_remesh = data.restart_if_remesh;
+
     // Adaptive tolerances
     const PetscReal atol = data.absolute_tolerance > 0.0 ?
                              data.absolute_tolerance :
@@ -1034,10 +1037,21 @@ namespace PETScWrappers
       {
         AssertThrow(interpolate,
                     StandardExceptions::ExcFunctionNotProvided("interpolate"));
-#  if DEAL_II_PETSC_VERSION_GTE(3, 20, 0)
+#  if DEAL_II_PETSC_VERSION_GTE(3, 21, 0)
         (void)ts_poststep_amr;
-        AssertPETSc(TSSetResize(ts, ts_resize_setup, ts_resize_transfer, this));
+        AssertPETSc(TSSetResize(ts,
+                                static_cast<PetscBool>(restart_if_remesh),
+                                ts_resize_setup,
+                                ts_resize_transfer,
+                                this));
 #  else
+        AssertThrow(!restart_if_remesh,
+                    ExcMessage(
+                      "Restart with remesh supported from PETSc 3.21."));
+#    if DEAL_II_PETSC_VERSION_GTE(3, 20, 0)
+        (void)ts_poststep_amr;
+        AssertPETSc(TSSetResize(ts, ts_resize_setup, ts_resize_transfer, this));
+#    else
         AssertPETSc(PetscObjectComposeFunction(
           (PetscObject)ts,
           "__dealii_ts_resize_setup__",
@@ -1050,6 +1064,7 @@ namespace PETScWrappers
           static_cast<PetscErrorCode (*)(TS, PetscInt, Vec[], Vec[], void *)>(
             ts_resize_transfer)));
         AssertPETSc(TSSetPostStep(ts, ts_poststep_amr));
+#    endif
 #  endif
       }
 

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.