26 "convergence_expression",
"FunctionExpression",
"Expression to parse for convergence");
28 "divergence_expression",
"FunctionExpression",
"Expression to parse for divergence");
29 params.
addParam<std::vector<std::string>>(
30 "symbol_names", {},
"Symbol names to use in the parsed expressions");
31 params.
addParam<std::vector<std::string>>(
34 "Values (Convergence names, Postprocessor names, Function names, and constants) " 35 "corresponding to each entry in 'symbol_names'");
43 _fe_problem(*getCheckedPointerParam<
FEProblemBase *>(
"_fe_problem_base")),
44 _symbol_names(getParam<
std::vector<
std::string>>(
"symbol_names")),
45 _symbol_values(getParam<
std::vector<
std::string>>(
"symbol_values")),
46 _convergence_function_params(_symbol_names.size(), 0.0),
47 _divergence_function_params(_symbol_names.size(), 0.0)
50 mooseError(
"The parameters 'symbol_names' and 'symbol_values' must have the same size.");
60 const auto convergence_expression = getParam<std::string>(
"convergence_expression");
63 const auto divergence_expression =
isParamValid(
"divergence_expression")
64 ? getParam<std::string>(
"divergence_expression")
66 if (divergence_expression.size())
121 catch (
const std::invalid_argument & e)
124 "The 'symbol_values' entry '",
126 "' is not a constant value or the name of a Convergence, Postprocessor, or Function.",
135 auto sym_function = std::make_shared<SymFunction>();
152 const Real diverged_real =
216 "' evaluated to the value ",
218 ", but it must only evaluate to either 0 or 1.");
GenericReal< is_ad > evaluate(SymFunctionPtr &, const std::string &object_name="")
Evaluate FParser object and check EvalError.
std::string join(Iterator begin, Iterator end, const std::string &delimiter)
Python-like join function for strings over an iterator range.
Base class for function objects.
virtual void initialSetup() override
Gets called at the beginning of the simulation before this object is asked to do its job...
std::shared_ptr< SymFunction > SymFunctionPtr
Shorthand for an smart pointer to an autodiff function parser object.
bool absoluteFuzzyEqual(const T &var1, const T2 &var2, const T3 &tol=libMesh::TOLERANCE *libMesh::TOLERANCE)
Function to check whether two variables are equal within an absolute tolerance.
std::vector< unsigned int > _function_indices
std::vector< std::string > _convergence_symbol_names
std::vector< Real > _convergence_function_params
Convergence function parameters.
static InputParameters validParams()
SymFunctionPtr _divergence_function
Parsed function for divergence.
void updateSymbolValues(unsigned int iter)
Updates non-constant symbol values.
const Parallel::Communicator & comm() const
void updateFunctionSymbolValues()
Evaluates convergence from a parsed expression.
virtual void initialSetup() override
Gets called at the beginning of the simulation before this object is asked to do its job...
void updatePostprocessorSymbolValues()
bool convertRealToBool(Real value, const std::string ¶m) const
Converts a Real value to a bool.
Specialization of SubProblem for solving nonlinear equations plus auxiliary equations.
void initializeFunctionSymbol(unsigned int i)
void initializePostprocessorSymbol(unsigned int i)
virtual Function & getFunction(const std::string &name, const THREAD_ID tid=0)
const std::string & name() const
Get the name of the class.
const ReporterData & getReporterData() const
Provides const access the ReporterData object.
std::vector< unsigned int > _pp_indices
Real value(unsigned n, unsigned alpha, unsigned beta, Real x)
Base class for convergence criteria.
virtual Convergence & getConvergence(const std::string &name, const THREAD_ID tid=0) const
Gets a Convergence object.
void updateConvergenceSymbolValues(unsigned int iter)
ParsedConvergence(const InputParameters ¶meters)
Real PostprocessorValue
various MOOSE typedefs
registerMooseObject("MooseApp", ParsedConvergence)
virtual bool hasConvergence(const std::string &name, const THREAD_ID tid=0) const
Returns true if the problem has a Convergence object of the given name.
std::vector< const PostprocessorValue * > _pp_values
Post-processor values in the provided symbols.
void parsedFunctionSetup(SymFunctionPtr &function, const std::string &expression, const std::string &variables, const std::vector< std::string > &constant_names, const std::vector< std::string > &constant_expressions, const libMesh::Parallel::Communicator &comm) const
Performs setup steps on a SymFunction.
std::vector< unsigned int > _convergence_indices
std::string stringify(const T &t)
conversion to string
const PostprocessorValue & getPostprocessorValueByName(const PostprocessorName &name, std::size_t t_index=0) const
Get a read-only reference to the value associated with a Postprocessor that exists.
MooseConvergenceStatus
Status returned by calls to checkConvergence.
std::vector< std::string > _symbol_values
Corresponding symbol values (Convergence, Function, Postprocessor, or constant)
std::vector< Convergence * > _convergences
Convergences in the provided symbols.
virtual MooseConvergenceStatus checkConvergence(unsigned int iter) override
Returns convergence status.
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
void initializeSymbols()
Initializes symbols used in the parsed expression.
SymFunctionPtr makeParsedFunction(const std::string &expression)
Makes a parsed function.
static InputParameters validParams()
void initializeConstantSymbol(unsigned int i)
void mooseError(Args &&... args) const
Emits an error prefixed with object name and type and optionally a file path to the top-level block p...
void initializeConvergenceSymbol(unsigned int i)
static InputParameters validParams()
bool hasReporterValue(const ReporterName &reporter_name) const
Return True if a Reporter value with the given type and name have been created.
bool isParamValid(const std::string &name) const
Test if the supplied parameter is valid.
std::vector< Real > _divergence_function_params
Divergence function parameters.
FEProblemBase & _fe_problem
virtual bool hasFunction(const std::string &name, const THREAD_ID tid=0)
std::vector< Function * > _functions
Functions in the provided symbols.
auto index_range(const T &sizable)
The Reporter system is comprised of objects that can contain any number of data values.
SymFunctionPtr _convergence_function
Parsed function for convergence.
std::vector< std::string > _symbol_names
User-defined symbols to use in parsed expression.