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 
12 template <>
15 {
17 
18  MooseEnum comparison_type("equals greater_than_equals less_than_equals greater_than less_than");
19  params.addRequiredParam<MooseEnum>("comparison_type",
20  comparison_type,
21  "The type of comparison to perform. Options are: " +
22  comparison_type.getRawNames());
23 
24  params.addParam<Real>("absolute_tolerance",
25  libMesh::TOLERANCE * libMesh::TOLERANCE,
26  "Absolute tolerance used in comparisons");
27 
28  return params;
29 }
30 
32  : GeneralPostprocessor(parameters),
33 
34  _comparison_type(getParam<MooseEnum>("comparison_type").getEnum<ComparisonType>()),
35  _absolute_tolerance(getParam<Real>("absolute_tolerance"))
36 {
37 }
38 
39 bool
40 ComparisonPostprocessor::comparisonIsTrue(const Real & a, const Real & b) const
41 {
42  switch (_comparison_type)
43  {
46  break;
49  break;
52  break;
55  break;
58  break;
59  default:
60  mooseError("Invalid comparison type.");
61  }
62 }
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:231
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
InputParameters validParams< GeneralPostprocessor >()
void mooseError(Args &&... args) const
Definition: MooseObject.h:147
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...
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:322
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)
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:300
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:254
InputParameters validParams< ComparisonPostprocessor >()
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:277
const ComparisonType _comparison_type
Type of comparison to perform.
const Real _absolute_tolerance
Absolute tolerance for "fuzzy" comparisons.