From 65021919ecd0ba37c2beb9557f14abd67e277f8e Mon Sep 17 00:00:00 2001 From: Stefano Zampini Date: Mon, 24 Jul 2023 23:38:29 +0300 Subject: [PATCH] PETScWrappers::TimeStepper: Fix for older versions of PETSc --- include/deal.II/lac/petsc_ts.templates.h | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/include/deal.II/lac/petsc_ts.templates.h b/include/deal.II/lac/petsc_ts.templates.h index a403edb405..ad2d87ded1 100644 --- a/include/deal.II/lac/petsc_ts.templates.h +++ b/include/deal.II/lac/petsc_ts.templates.h @@ -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); }; -- 2.39.5