www.mooseframework.org
VectorPostprocessorComparison.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 
12 
14 
16 
19 {
21 
22  params.addRequiredParam<VectorPostprocessorName>(
23  "vectorpostprocessor_a", "The first vector post-processor in the comparison");
24  params.addRequiredParam<VectorPostprocessorName>(
25  "vectorpostprocessor_b", "The second vector post-processor in the comparison");
26  params.addRequiredParam<std::string>(
27  "vector_name_a", "The name of the vector in the first vector post-processor to compare");
28  params.addRequiredParam<std::string>(
29  "vector_name_b", "The name of the vector in the second vector post-processor to compare");
30 
31  params.addClassDescription(
32  "Compares two vector post-processors of equal size and produces a boolean value");
33 
34  return params;
35 }
36 
38  : ComparisonPostprocessor(parameters),
39 
40  _values_a(getVectorPostprocessorValue("vectorpostprocessor_a",
41  getParam<std::string>("vector_name_a"))),
42  _values_b(getVectorPostprocessorValue("vectorpostprocessor_b",
43  getParam<std::string>("vector_name_b"))),
44 
45  _comparison_value(0.0)
46 {
47 }
48 
49 void
51 {
52  _comparison_value = 0.0;
53 }
54 
55 void
57 {
58  if (_values_a.size() != _values_b.size())
59  mooseError("The compared vector post-processors must have the same size");
60 
61  // Set comparison value to "false" if comparison is false for any pair of elements
62  bool comparison_bool = true;
63  for (unsigned int i = 0; i < _values_a.size(); ++i)
64  comparison_bool = comparison_bool && comparisonIsTrue(_values_a[i], _values_b[i]);
65 
66  _comparison_value = comparison_bool;
67 }
68 
71 {
72  return _comparison_value;
73 }
VectorPostprocessorComparison::initialize
virtual void initialize() override
Called before execute() is ever called so that data can be cleared.
Definition: VectorPostprocessorComparison.C:50
MooseObject::mooseError
void mooseError(Args &&... args) const
Definition: MooseObject.h:141
VectorPostprocessorComparison::_values_b
const VectorPostprocessorValue & _values_b
Values of the second vector post-processor to compare.
Definition: VectorPostprocessorComparison.h:51
ComparisonPostprocessor::validParams
static InputParameters validParams()
Definition: ComparisonPostprocessor.C:15
VectorPostprocessorComparison.h
VectorPostprocessorInterface.h
VectorPostprocessorComparison::_values_a
const VectorPostprocessorValue & _values_a
Values of the first vector post-processor to compare.
Definition: VectorPostprocessorComparison.h:49
VectorPostprocessorComparison::_comparison_value
PostprocessorValue _comparison_value
The comparison value; 1 for all true and 0 for at least one false.
Definition: VectorPostprocessorComparison.h:54
VectorPostprocessorComparison::VectorPostprocessorComparison
VectorPostprocessorComparison(const InputParameters &parameters)
Definition: VectorPostprocessorComparison.C:37
VectorPostprocessorComparison
Compares two vector post-processors of equal size and produces a boolean value.
Definition: VectorPostprocessorComparison.h:36
InputParameters
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system.
Definition: InputParameters.h:53
PostprocessorValue
Real PostprocessorValue
MOOSE typedefs.
Definition: MooseTypes.h:189
defineLegacyParams
defineLegacyParams(VectorPostprocessorComparison)
VectorPostprocessorComparison::execute
virtual void execute() override
Execute method.
Definition: VectorPostprocessorComparison.C:56
ComparisonPostprocessor
Base class for comparing quantities and producing a boolean value.
Definition: ComparisonPostprocessor.h:33
InputParameters::addClassDescription
void addClassDescription(const std::string &doc_string)
This method adds a description of the class that will be displayed in the input file syntax dump.
Definition: InputParameters.C:70
VectorPostprocessorComparison::getValue
virtual PostprocessorValue getValue() override
This will get called to actually grab the final value the postprocessor has calculated.
Definition: VectorPostprocessorComparison.C:70
ComparisonPostprocessor::comparisonIsTrue
bool comparisonIsTrue(const Real &a, const Real &b) const
Performs the selected comparison on the two values.
Definition: ComparisonPostprocessor.C:41
VectorPostprocessorComparison::validParams
static InputParameters validParams()
Definition: VectorPostprocessorComparison.C:18
std
Definition: TheWarehouse.h:80
registerMooseObject
registerMooseObject("MooseApp", VectorPostprocessorComparison)
InputParameters::addRequiredParam
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...
Definition: InputParameters.h:1176