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 3335 : RelativeDifferencePostprocessor::validParams() 16 : { 17 3335 : InputParameters params = GeneralPostprocessor::validParams(); 18 : 19 13340 : params.addRequiredParam<PostprocessorName>("value1", "First post-processor"); 20 13340 : params.addRequiredParam<PostprocessorName>("value2", 21 : "Second post-processor, base for relative difference"); 22 : 23 3335 : params.addClassDescription("Computes the absolute value of the relative " 24 : "difference between 2 post-processor values."); 25 : 26 3335 : return params; 27 0 : } 28 : 29 137 : RelativeDifferencePostprocessor::RelativeDifferencePostprocessor(const InputParameters & parameters) 30 : : GeneralPostprocessor(parameters), 31 137 : _value1(getPostprocessorValue("value1")), 32 411 : _value2(getPostprocessorValue("value2")) 33 : { 34 137 : } 35 : 36 : void 37 724 : RelativeDifferencePostprocessor::initialize() 38 : { 39 724 : } 40 : 41 : void 42 724 : RelativeDifferencePostprocessor::execute() 43 : { 44 724 : } 45 : 46 : PostprocessorValue 47 724 : RelativeDifferencePostprocessor::getValue() const 48 : { 49 724 : if (MooseUtils::absoluteFuzzyEqual(_value2, 0)) 50 84 : return std::abs(_value1 - _value2); 51 : else 52 640 : return std::abs((_value1 - _value2) / _value2); 53 : }