https://mooseframework.inl.gov
Loading...
Searching...
No Matches
RealToBoolChainControl.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
11#include "MooseUtils.h"
12
14
17{
19
20 params.addClassDescription("Converts a Real-valued chain control data to boolean.");
21
22 params.addRequiredParam<std::string>("input",
23 "The Real-valued chain control data to convert to boolean.");
24
25 return params;
26}
27
29 : ChainControl(parameters),
30 _input(getChainControlData<Real>("input")),
31 _output(declareChainControlData<bool>("value"))
32{
33}
34
35void
37{
38 if (MooseUtils::absoluteFuzzyEqual(_input, 1.0))
39 _output = true;
40 else if (MooseUtils::absoluteFuzzyEqual(_input, 0.0))
41 _output = false;
42 else
43 mooseError("The current input value (", _input, ") is not equal to 1 or 0.");
44}
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application.
Definition MooseError.h:311
registerMooseObject("MooseApp", RealToBoolChainControl)
Control that additionally provides the capability to produce/consume data values, to allow control op...
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.
Converts a Real-valued chain control data to boolean.
const Real & _input
The value before conversion.
RealToBoolChainControl(const InputParameters &parameters)
virtual void execute() override
Execute the control.
static InputParameters validParams()
bool & _output
The converted value.