]> https://gitweb.dealii.org/ - dealii.git/commitdiff
PETScWrappers::TimeStepper: Fix for older versions of PETSc
authorStefano Zampini <stefano.zampini@gmail.com>
Mon, 24 Jul 2023 20:38:29 +0000 (23:38 +0300)
committerStefano Zampini <stefano.zampini@gmail.com>
Mon, 24 Jul 2023 20:44:36 +0000 (23:44 +0300)
include/deal.II/lac/petsc_ts.templates.h

index a403edb405aecf91d081d00baa910103c607e98d..ad2d87ded1421ca0882ff88b29f95952cf2c77ef 100644 (file)
@@ -562,6 +562,17 @@ namespace PETScWrappers
           PetscCall(TSSetSolution(ts, new_x));
           PetscCall(VecDestroy(&new_x));
         }
+#  if DEAL_II_PETSC_VERSION_LT(3, 17, 0)
+      // Older versions of PETSc assume that the user does not
+      // change the solution vector during TSPostStep
+      // We "fix" it by taking a reference to the object and
+      // increment its state so that the time stepper is restarted
+      // properly.
+      AssertPETSc(PetscObjectCompose((PetscObject)ts,
+                                     "__dealii_ts_resize_bug__",
+                                     (PetscObject)x));
+      petsc_increment_state_counter(x);
+#  endif
       PetscCall(VecDestroy(&x));
       PetscFunctionReturn(PETSC_SUCCESS);
     };

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.