From: Stefano Zampini Date: Wed, 20 Mar 2024 21:27:53 +0000 (+0300) Subject: PETSc: support version 3.21 X-Git-Tag: v9.6.0-rc1~468^2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F16767%2Fhead;p=dealii.git PETSc: support version 3.21 --- diff --git a/include/deal.II/lac/petsc_ts.h b/include/deal.II/lac/petsc_ts.h index 27f19e1b49..908011c0fc 100644 --- a/include/deal.II/lac/petsc_ts.h +++ b/include/deal.II/lac/petsc_ts.h @@ -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. */ diff --git a/include/deal.II/lac/petsc_ts.templates.h b/include/deal.II/lac/petsc_ts.templates.h index bd4820fda8..aea7f2951f 100644 --- a/include/deal.II/lac/petsc_ts.templates.h +++ b/include/deal.II/lac/petsc_ts.templates.h @@ -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(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( ts_resize_transfer))); AssertPETSc(TSSetPostStep(ts, ts_poststep_amr)); +# endif # endif }