* @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:
*
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,
, 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)
*/
bool match_step;
+ /**
+ * Flag to indicate to restart the step if remeshing is flagged.
+ */
+ bool restart_if_remesh;
+
/**
* PETSc time step adaptor type.
*/
*/
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.
*/
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 :
{
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__",
static_cast<PetscErrorCode (*)(TS, PetscInt, Vec[], Vec[], void *)>(
ts_resize_transfer)));
AssertPETSc(TSSetPostStep(ts, ts_poststep_amr));
+# endif
# endif
}