https://mooseframework.inl.gov
Loading...
Searching...
No Matches
ComparisonPostprocessor.C
Go to the documentation of this file.
1//* This file is part of the MOOSE framework
2//* https://mooseframework.inl.gov
3//*
4//* All rights reserved, see COPYRIGHT for full restrictions
5//* https://github.com/idaholab/moose/blob/master/COPYRIGHT
6//*
7//* Licensed under LGPL 2.1, please see LICENSE for details
8//* https://www.gnu.org/licenses/lgpl-2.1.html
9
11
14{
16
17 MooseEnum comparison_type("equals greater_than_equals less_than_equals greater_than less_than");
18 params.addRequiredParam<MooseEnum>("comparison_type",
19 comparison_type,
20 "The type of comparison to perform. Options are: " +
21 comparison_type.getRawNames());
22
23 params.addParam<Real>("absolute_tolerance",
25 "Absolute tolerance used in comparisons");
26
27 return params;
28}
29
31 : GeneralPostprocessor(parameters),
32
33 _comparison_type(getParam<MooseEnum>("comparison_type").getEnum<ComparisonType>()),
34 _absolute_tolerance(getParam<Real>("absolute_tolerance"))
35{
36}
37
38bool
39ComparisonPostprocessor::comparisonIsTrue(const Real & a, const Real & b) const
40{
41 switch (_comparison_type)
42 {
44 return MooseUtils::absoluteFuzzyEqual(a, b, _absolute_tolerance);
45
47 return MooseUtils::absoluteFuzzyGreaterEqual(a, b, _absolute_tolerance);
48
50 return MooseUtils::absoluteFuzzyLessEqual(a, b, _absolute_tolerance);
51
53 return MooseUtils::absoluteFuzzyGreaterThan(a, b, _absolute_tolerance);
54
56 return MooseUtils::absoluteFuzzyLessThan(a, b, _absolute_tolerance);
57
58 default:
59 mooseError("Invalid comparison type.");
60 }
61}
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application.
Definition MooseError.h:311
bool comparisonIsTrue(const Real &a, const Real &b) const
Performs the selected comparison on the two values.
const ComparisonType _comparison_type
Type of comparison to perform.
static InputParameters validParams()
const Real _absolute_tolerance
Absolute tolerance for "fuzzy" comparisons.
ComparisonPostprocessor(const InputParameters &parameters)
This class is here to combine the Postprocessor interface and the base class Postprocessor object alo...
static InputParameters validParams()
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system.
void addParam(const std::string &name, const S &value, const std::string &doc_string)
These methods add an optional parameter and a documentation string to the InputParameters object.
void addRequiredParam(const std::string &name, const std::string &doc_string)
This method adds a parameter and documentation string to the InputParameters object that will be extr...
std::string getRawNames() const
Method for returning the raw name strings for this instance.
This is a "smart" enum class intended to replace many of the shortcomings in the C++ enum type It sho...
Definition MooseEnum.h:55
static constexpr Real TOLERANCE