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 "RealToBoolChainControl.h" 11 : #include "MooseUtils.h" 12 : 13 : registerMooseObject("MooseApp", RealToBoolChainControl); 14 : 15 : InputParameters 16 14397 : RealToBoolChainControl::validParams() 17 : { 18 14397 : InputParameters params = ChainControl::validParams(); 19 : 20 14397 : params.addClassDescription("Converts a Real-valued chain control data to boolean."); 21 : 22 14397 : params.addRequiredParam<std::string>("input", 23 : "The Real-valued chain control data to convert to boolean."); 24 : 25 14397 : return params; 26 0 : } 27 : 28 66 : RealToBoolChainControl::RealToBoolChainControl(const InputParameters & parameters) 29 : : ChainControl(parameters), 30 66 : _input(getChainControlData<Real>("input")), 31 132 : _output(declareChainControlData<bool>("value")) 32 : { 33 66 : } 34 : 35 : void 36 211 : RealToBoolChainControl::execute() 37 : { 38 211 : if (MooseUtils::absoluteFuzzyEqual(_input, 1.0)) 39 107 : _output = true; 40 104 : else if (MooseUtils::absoluteFuzzyEqual(_input, 0.0)) 41 100 : _output = false; 42 : else 43 4 : mooseError("The current input value (", _input, ") is not equal to 1 or 0."); 44 207 : }