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 NONE",
"HARD");
36 "Abort entire simulation (HARD), just the current time step (SOFT), or not at all (NONE).");
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 or NONE`.");
71 "Cannot specify `error_level=NONE` together with the `message` parameter.");
74 "With the current error level and fail mode settings, the terminator will not "
86 for (
unsigned int i = 0; i <
_pp_num; ++i)
97 for (
const auto i : make_range(
_pp_num))
102 if (!pp_exec.isValueSet(flag) && flag !=
EXEC_FINAL)
104 "Postprocessor '" +
_pp_names[i] +
"' is not executed on " + flag.name() +
105 ", which it really should be to serve in the criterion "
106 "expression for throwing.");
116 message =
"Terminator '" +
name() +
"' is ";
118 message +=
"causing the execution to terminate.\n";
120 message +=
"causing a time step cutback by marking the current step as failed.\n";
122 message +=
"outputting a message due to the criterion being met";
125 message = getParam<std::string>(
"message");
150 for (
unsigned int i = 0; i <
_pp_num; ++i)
void mooseInfoRepeated(Args &&... args)
Emit an informational message with the given stringified, concatenated args.
void mooseWarning(Args &&... args)
Emit a warning message with the given stringified, concatenated args.
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application.
const ExecFlagType EXEC_LINEAR
const ExecFlagType EXEC_NONLINEAR
const ExecFlagType EXEC_FINAL
registerMooseObject("MooseApp", Terminator)
FixedPointSolve & fixedPointSolve()
void setFailNextNonlinearConvergenceCheck()
Skip further residual evaluations and fail the next nonlinear convergence check(s)
const ExecFlagType & getCurrentExecuteOnFlag() const
Return/set the current execution flag.
const UserObject & getUserObjectBase(const std::string &name, const THREAD_ID tid=0) const
Get the user object by its name.
void failStep()
Mark the current solve as failed due to external conditions.
static InputParameters validParams()
Executioner * getExecutioner() const
Retrieve the Executioner for this App.
const std::string & name() const
Get the name of the class.
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 ...
bool isParamValid(const std::string &name) const
Test if the supplied parameter is valid.
MooseApp & getMooseApp() const
Get the MooseApp this class is associated with.
This is a "smart" enum class intended to replace many of the shortcomings in the C++ enum type It sho...
virtual const PostprocessorValue & getPostprocessorValueByName(const PostprocessorName &name) const
Retrieve the value of the Postprocessor.
virtual void terminateSolve()
Allow objects to request clean termination of the solve.
const ExecFlagEnum & getExecuteOnEnum() const
Return the execute on MultiMooseEnum for this object.
void paramWarning(const std::string ¶m, Args... args) const
This Userobject requests termination of the current solve based on the values of Postprocessors (and ...
std::vector< std::string > _pp_names
Postprocessor names.
std::string _expression
Expression of the criterion, to be parsed for evaluation.
static InputParameters validParams()
FailMode
What action the terminator takes when the criteria is met.
MessageType
What logging level the terminator message is output with.
enum Terminator::FailMode _fail_mode
std::vector< Real > _params
Fparser parameter buffer.
Terminator(const InputParameters ¶meters)
void handleMessage()
handle output of the optional message
std::vector< const PostprocessorValue * > _pp_values
Postprocessor values.
virtual void execute() override
Execute method.
FunctionParserBase< Real > _fp
Fparser object.
virtual void initialSetup() override
Gets called at the beginning of the simulation before this object is asked to do its job.
enum Terminator::MessageType _msg_type
FEProblemBase & _fe_problem
Reference to the FEProblemBase for this user object.
const THREAD_ID _tid
Thread ID of this postprocessor.