Skip to content

Commit

Permalink
allow terminator to stop time stepper idaholab#28930
Browse files Browse the repository at this point in the history
  • Loading branch information
YaqiWang committed Oct 27, 2024
1 parent dc26950 commit 29f5d75
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 2 deletions.
3 changes: 3 additions & 0 deletions framework/include/timesteppers/TimeStepper.h
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,9 @@ class TimeStepper : public MooseObject, public Restartable, public ScalarCouplea
void addSyncTime(const std::set<Real> & times);
///@}

/// Mark the current time step as failed due to external conditions
void failTimeStep() { _converged = false; }

protected:
/**
* Computes time step size for the initial time step
Expand Down
14 changes: 14 additions & 0 deletions framework/src/timesteppers/TimeStepper.C
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,8 @@ TimeStepper::constrainStep(Real & dt)
void
TimeStepper::step()
{
_converged = true;

if (!_executioner.legacyTimeExecution())
{
_fe_problem.execTransfers(EXEC_TIMESTEP_BEGIN);
Expand All @@ -177,6 +179,12 @@ TimeStepper::step()
}

_fe_problem.execute(EXEC_TIMESTEP_BEGIN);
if (!_converged)
{
_failure_count++;
_console << "Aborting by a Terminator" << std::endl;
return;
}
_fe_problem.outputStep(EXEC_TIMESTEP_BEGIN);
}

Expand All @@ -193,6 +201,12 @@ TimeStepper::step()
{
_fe_problem.onTimestepEnd();
_fe_problem.execute(EXEC_TIMESTEP_END);
if (!_converged)
{
_failure_count++;
_console << "Aborting by a Terminator" << std::endl;
return;
}

_fe_problem.execTransfers(EXEC_TIMESTEP_END);
if (!_fe_problem.execMultiApps(EXEC_TIMESTEP_END))
Expand Down
24 changes: 22 additions & 2 deletions framework/src/userobjects/Terminator.C
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@
#include "Terminator.h"
#include "MooseApp.h"
#include "MooseEnum.h"
#include "Executioner.h"
#include "Transient.h"
#include "FixedPointSolve.h"
#include "TimeStepper.h"

registerMooseObject("MooseApp", Terminator);

Expand Down Expand Up @@ -164,7 +166,25 @@ Terminator::execute()
_fe_problem.setFailNextNonlinearConvergenceCheck();
// Outside of a solve, trigger a time step fail
else
getMooseApp().getExecutioner()->fixedPointSolve().failStep();
{
auto executioner = getMooseApp().getExecutioner();
if (executioner->legacyTimeExecution())
executioner->fixedPointSolve().failStep();
else
{
if (_fe_problem.getCurrentExecuteOnFlag() == FixedPointSolve::EXEC_FIXEDPOINT_BEGIN ||
_fe_problem.getCurrentExecuteOnFlag() == FixedPointSolve::EXEC_FIXEDPOINT_END)
executioner->fixedPointSolve().failStep();
else
{
Transient * transient = dynamic_cast<Transient *>(executioner);
if (transient)
transient->getTimeStepper()->failTimeStep();
else
mooseError("Terminator must be used with Transient executioner.");
}
}
}
}
}
}
Expand Down

0 comments on commit 29f5d75

Please sign in to comment.