10 #include "libmesh/libmesh_config.h" 12 #ifdef LIBMESH_HAVE_FPARSER 25 params.
addClassDescription(
"Requests termination of the current solve based on the evaluation of" 26 " a parsed logical expression of the Postprocessor value(s).");
30 "FParser expression to process Postprocessor values into a boolean value. " 31 "Termination of the simulation occurs when this returns true.");
32 MooseEnum failModeOption(
"HARD SOFT",
"HARD");
36 "Abort entire simulation (HARD) or just the current time step (SOFT).");
37 params.
addParam<std::string>(
"message",
38 "An optional message to be output instead of the default message " 39 "when the termination condition is triggered");
41 MooseEnum errorLevel(
"INFO WARNING ERROR NONE",
"INFO");
42 errorLevel.addDocumentation(
"INFO",
"Output an information message once.");
43 errorLevel.addDocumentation(
"WARNING",
"Output a warning message once.");
44 errorLevel.addDocumentation(
"ERROR",
45 "Throw a MOOSE error, resulting in the termination of the run.");
46 errorLevel.addDocumentation(
"NONE",
"No message will be printed.");
50 "The error level for the message. A level of ERROR will always lead to a hard " 51 "termination of the entire simulation.");
61 _expression(getParam<
std::string>(
"expression")),
67 "Setting the error level to ERROR always causes a hard failure, which is " 68 "incompatible with `fail_mode=SOFT`.");
71 "Cannot specify `error_level=NONE` together with the `message` parameter.");
82 for (
unsigned int i = 0; i <
_pp_num; ++i)
98 if (!pp_exec.contains(flag) && flag !=
EXEC_FINAL)
100 "Postprocessor '" +
_pp_names[i] +
"' is not executed on " + flag.name() +
101 ", which it really should be to serve in the criterion " 102 "expression for throwing.");
112 message =
"Terminator '" +
name() +
"' is causing ";
114 message +=
"the execution to terminate.\n";
116 message +=
"a time step cutback by marking the current step as failed.\n";
119 message = getParam<std::string>(
"message");
144 for (
unsigned int i = 0; i <
_pp_num; ++i)
virtual void initialSetup() override
Gets called at the beginning of the simulation before this object is asked to do its job...
static InputParameters validParams()
Terminator(const InputParameters ¶meters)
const ExecFlagType & getCurrentExecuteOnFlag() const
Return/set the current execution flag.
registerMooseObject("MooseApp", Terminator)
void failStep()
Mark the current solve as failed due to external conditions.
std::vector< std::string > _pp_names
Postprocessor names.
void mooseInfoRepeated(Args &&... args)
Emit an informational message with the given stringified, concatenated args.
std::vector< Real > _params
Fparser parameter buffer.
void handleMessage()
handle output of the optional message
void setFailNextNonlinearConvergenceCheck()
Skip further residual evaluations and fail the next nonlinear convergence check.
virtual const std::string & name() const
Get the name of the class.
void mooseWarning(Args &&... args) const
Emits a warning prefixed with object name and type.
MooseApp & getMooseApp() const
Get the MooseApp this class is associated with.
std::string _expression
Expression of the criterion, to be parsed for evaluation.
bool isParamValid(const std::string &name) const
Test if the supplied parameter is valid.
std::vector< const PostprocessorValue * > _pp_values
Postprocessor values.
virtual void terminateSolve()
Allow objects to request clean termination of the solve.
const ExecFlagEnum & getExecuteOnEnum() const
Return the execute on MultiMooseEnum for this object.
enum Terminator::FailMode _fail_mode
This is a "smart" enum class intended to replace many of the shortcomings in the C++ enum type It sho...
void paramError(const std::string ¶m, Args... args) const
Emits an error prefixed with the file and line number of the given param (from the input file) along ...
This Userobject requests termination of the current solve based on the values of Postprocessors (and ...
const ExecFlagType EXEC_LINEAR
enum Terminator::ErrorLevel _error_level
Executioner * getExecutioner() const
Retrieve the Executioner for this App.
static InputParameters validParams()
virtual const PostprocessorValue & getPostprocessorValueByName(const PostprocessorName &name) const
Retrieve the value of the Postprocessor.
const ExecFlagType EXEC_NONLINEAR
FEProblemBase & _fe_problem
Reference to the FEProblemBase for this user object.
FixedPointSolve & fixedPointSolve()
const THREAD_ID _tid
Thread ID of this postprocessor.
IntRange< T > make_range(T beg, T end)
void mooseError(Args &&... args) const
Emits an error prefixed with object name and type.
void paramWarning(const std::string ¶m, Args... args) const
Emits a warning prefixed with the file and line number of the given param (from the input file) along...
const UserObject & getUserObjectBase(const std::string &name, const THREAD_ID tid=0) const
Get the user object by its name.
virtual void execute() override
Execute method.
FunctionParserBase< Real > _fp
Fparser object.
const ExecFlagType EXEC_FINAL