www.mooseframework.org
ComparisonPostprocessor.C
Go to the documentation of this file.
1 //* This file is part of the MOOSE framework
2 //* https://www.mooseframework.org
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 
38 bool
39 ComparisonPostprocessor::comparisonIsTrue(const Real & a, const Real & b) const
40 {
41  switch (_comparison_type)
42  {
45 
48 
51 
54 
57 
58  default:
59  mooseError("Invalid comparison type.");
60  }
61 }
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.
Definition: MooseUtils.h:346
static constexpr Real TOLERANCE
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
static InputParameters validParams()
This class is here to combine the Postprocessor interface and the base class Postprocessor object alo...
std::string getRawNames() const
Method for returning the raw name strings for this instance.
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...
static InputParameters validParams()
bool comparisonIsTrue(const Real &a, const Real &b) const
Performs the selected comparison on the two values.
bool absoluteFuzzyLessThan(const T &var1, const T2 &var2, const T3 &tol=libMesh::TOLERANCE *libMesh::TOLERANCE)
Function to check whether a variable is less than another variable within an absolute tolerance...
Definition: MooseUtils.h:437
This is a "smart" enum class intended to replace many of the shortcomings in the C++ enum type It sho...
Definition: MooseEnum.h:31
ComparisonPostprocessor(const InputParameters &parameters)
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
bool absoluteFuzzyLessEqual(const T &var1, const T2 &var2, const T3 &tol=libMesh::TOLERANCE *libMesh::TOLERANCE)
Function to check whether a variable is less than or equal to another variable within an absolute tol...
Definition: MooseUtils.h:415
bool absoluteFuzzyGreaterEqual(const T &var1, const T2 &var2, const T3 &tol=libMesh::TOLERANCE *libMesh::TOLERANCE)
Function to check whether a variable is greater than or equal to another variable within an absolute ...
Definition: MooseUtils.h:369
void mooseError(Args &&... args) const
Emits an error prefixed with object name and type.
void addParam(const std::string &name, const S &value, const std::string &doc_string)
These methods add an option parameter and a documentation string to the InputParameters object...
bool absoluteFuzzyGreaterThan(const T &var1, const T2 &var2, const T3 &tol=libMesh::TOLERANCE *libMesh::TOLERANCE)
Function to check whether a variable is greater than another variable within an absolute tolerance...
Definition: MooseUtils.h:392
const ComparisonType _comparison_type
Type of comparison to perform.
const Real _absolute_tolerance
Absolute tolerance for "fuzzy" comparisons.