19 params.
addClassDescription(
"Converges if multiple post-processors are all less than tolerances.");
22 "Postprocessors to check");
23 params.
addParam<std::vector<std::string>>(
25 "Description of each Postprocessor. If not provided, the Postprocessor names are used as "
26 "their descriptions.");
27 params.
addRequiredParam<std::vector<Real>>(
"tolerances",
"Tolerance for each Postprocessor");
35 const auto & pp_names = getParam<std::vector<PostprocessorName>>(
"postprocessors");
41 for (
const auto & pp_name : pp_names)
45 for (
const auto & pp_name : pp_names)
50 "The parameters 'postprocessors', 'descriptions', and 'tolerances' must be the same size.");
64 bool all_converged =
true;
65 std::ostringstream oss;
70 const Real abs_pp_value = std::abs(*
_pp_values[i]);
72 all_converged =
false;
90 std::size_t max_desc_length = 0;
92 max_desc_length = std::max(max_desc_length, description.length());
94 return max_desc_length;
100 const Real tol)
const
102 std::string color, compare_str;
103 if (std::abs(err) > tol)
114 std::ostringstream oss;
115 oss <<
" " << description <<
": " << color << std::scientific << std::setprecision(5)
116 << std::abs(err) <<
" " << compare_str <<
" " << tol << COLOR_DEFAULT <<
"\n";
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application.
registerMooseObject("MooseApp", MultiPostprocessorConvergence)
virtual void initialSetup() override
Gets called at the beginning of the simulation before this object is asked to do its job.
void verboseOutput(std::ostringstream &oss)
Outputs the stream to the console if verbose output is enabled.
MooseConvergenceStatus
Status returned by calls to checkConvergence.
Checks convergence based on the iteration count.
static InputParameters validParams()
const T & getParam(const std::string &name) const
Retrieve a parameter for the object.
bool isParamValid(const std::string &name) const
Test if the supplied parameter is valid.
Converges if multiple post-processors are all less than tolerances.
unsigned int getMaxDescriptionLength() const
Returns the maximum description length.
std::string comparisonLine(const std::string &description, const Real err, const Real tol) const
Generates a colored line for a tolerance comparison.
unsigned int _max_desc_length
Maximum description length.
static InputParameters validParams()
MultiPostprocessorConvergence(const InputParameters ¶meters)
const std::vector< Real > & _tolerances
Tolerance for each Postprocessor.
virtual void initialSetup() override
Gets called at the beginning of the simulation before this object is asked to do its job.
virtual MooseConvergenceStatus checkConvergenceInner(unsigned int n_iter) override
Inner check of convergence.
std::vector< const PostprocessorValue * > _pp_values
Postprocessor values.
std::vector< std::string > _descriptions
Description of each Postprocessor.
virtual const PostprocessorValue & getPostprocessorValueByName(const PostprocessorName &name) const
Retrieve the value of the Postprocessor.