https://mooseframework.inl.gov
Loading...
Searching...
No Matches
VectorPostprocessorComparison.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
12
14
17{
19
20 params.addRequiredParam<VectorPostprocessorName>(
21 "vectorpostprocessor_a", "The first vector post-processor in the comparison");
22 params.addRequiredParam<VectorPostprocessorName>(
23 "vectorpostprocessor_b", "The second vector post-processor in the comparison");
24 params.addRequiredParam<std::string>(
25 "vector_name_a", "The name of the vector in the first vector post-processor to compare");
26 params.addRequiredParam<std::string>(
27 "vector_name_b", "The name of the vector in the second vector post-processor to compare");
28
30 "Compares two vector post-processors of equal size and produces a boolean value");
31
32 return params;
33}
34
36 : ComparisonPostprocessor(parameters),
37
38 _values_a(getVectorPostprocessorValue("vectorpostprocessor_a",
39 getParam<std::string>("vector_name_a"))),
40 _values_b(getVectorPostprocessorValue("vectorpostprocessor_b",
41 getParam<std::string>("vector_name_b"))),
42
43 _comparison_value(0.0)
44{
45}
46
47void
52
53void
55{
56 if (_values_a.size() != _values_b.size())
57 mooseError("The compared vector post-processors must have the same size");
58
59 // Set comparison value to "false" if comparison is false for any pair of elements
60 bool comparison_bool = true;
61 for (unsigned int i = 0; i < _values_a.size(); ++i)
62 comparison_bool = comparison_bool && comparisonIsTrue(_values_a[i], _values_b[i]);
63
64 _comparison_value = comparison_bool;
65}
66
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application.
Definition MooseError.h:311
Real PostprocessorValue
various MOOSE typedefs
Definition MooseTypes.h:230
registerMooseObject("MooseApp", VectorPostprocessorComparison)
Base class for comparing quantities and producing a boolean value.
bool comparisonIsTrue(const Real &a, const Real &b) const
Performs the selected comparison on the two values.
static InputParameters validParams()
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system.
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...
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.
Compares two vector post-processors of equal size and produces a boolean value.
virtual void execute() override
Execute method.
const VectorPostprocessorValue & _values_a
Values of the first vector post-processor to compare.
virtual PostprocessorValue getValue() const override
This will get called to actually grab the final value the postprocessor has calculated.
virtual void initialize() override
Called before execute() is ever called so that data can be cleared.
PostprocessorValue _comparison_value
The comparison value; 1 for all true and 0 for at least one false.
const VectorPostprocessorValue & _values_b
Values of the second vector post-processor to compare.
VectorPostprocessorComparison(const InputParameters &parameters)