Line data Source code
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 : 10 : #include "RelativeDifferencePostprocessor.h" 11 : 12 : registerMooseObject("MooseApp", RelativeDifferencePostprocessor); 13 : 14 : InputParameters 15 14541 : RelativeDifferencePostprocessor::validParams() 16 : { 17 14541 : InputParameters params = GeneralPostprocessor::validParams(); 18 : 19 14541 : params.addRequiredParam<PostprocessorName>("value1", "First post-processor"); 20 14541 : params.addRequiredParam<PostprocessorName>("value2", 21 : "Second post-processor, base for relative difference"); 22 : 23 14541 : params.addClassDescription("Computes the absolute value of the relative " 24 : "difference between 2 post-processor values."); 25 : 26 14541 : return params; 27 0 : } 28 : 29 138 : RelativeDifferencePostprocessor::RelativeDifferencePostprocessor(const InputParameters & parameters) 30 : : GeneralPostprocessor(parameters), 31 138 : _value1(getPostprocessorValue("value1")), 32 276 : _value2(getPostprocessorValue("value2")) 33 : { 34 138 : } 35 : 36 : void 37 729 : RelativeDifferencePostprocessor::initialize() 38 : { 39 729 : } 40 : 41 : void 42 729 : RelativeDifferencePostprocessor::execute() 43 : { 44 729 : } 45 : 46 : PostprocessorValue 47 729 : RelativeDifferencePostprocessor::getValue() const 48 : { 49 729 : if (MooseUtils::absoluteFuzzyEqual(_value2, 0)) 50 85 : return std::abs(_value1 - _value2); 51 : else 52 644 : return std::abs((_value1 - _value2) / _value2); 53 : }