From: Wolfgang Bangerth Date: Tue, 9 Jul 2024 16:45:10 +0000 (-0600) Subject: Rename a third callback in PETScWrappers::TimeStepper. X-Git-Tag: v9.6.0-rc1~87^2~2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3abe037fb6748e48b48edbcec3e19cab3f6ebdfd;p=dealii.git Rename a third callback in PETScWrappers::TimeStepper. --- diff --git a/include/deal.II/lac/petsc_ts.h b/include/deal.II/lac/petsc_ts.h index ccea3f4332..d698a0d14f 100644 --- a/include/deal.II/lac/petsc_ts.h +++ b/include/deal.II/lac/petsc_ts.h @@ -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 &all_in, + std::vector &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 &all_in, + std::function &all_in, std::vector &all_out)> - interpolate; + transfer_solution_vectors_to_new_mesh; private: /** diff --git a/include/deal.II/lac/petsc_ts.templates.h b/include/deal.II/lac/petsc_ts.templates.h index 12fcac4543..f3c351885b 100644 --- a/include/deal.II/lac/petsc_ts.templates.h +++ b/include/deal.II/lac/petsc_ts.templates.h @@ -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 &all_in, + std::vector &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,