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 "ChainControlDataPostprocessor.h" 11 : #include "MooseApp.h" 12 : #include "ChainControlDataSystem.h" 13 : 14 : registerMooseObject("MooseApp", ChainControlDataPostprocessor); 15 : 16 : InputParameters 17 14609 : ChainControlDataPostprocessor::validParams() 18 : { 19 14609 : InputParameters params = GeneralPostprocessor::validParams(); 20 : 21 14609 : params.addClassDescription("Gets a Real or bool chain control value."); 22 : 23 14609 : params.addRequiredParam<std::string>("chain_control_data_name", "Chain control data name"); 24 14609 : return params; 25 0 : } 26 : 27 172 : ChainControlDataPostprocessor::ChainControlDataPostprocessor(const InputParameters & parameters) 28 : : GeneralPostprocessor(parameters), 29 172 : _data_name(getParam<std::string>("chain_control_data_name")), 30 172 : _real_data(nullptr), 31 172 : _bool_data(nullptr) 32 : { 33 172 : } 34 : 35 : void 36 160 : ChainControlDataPostprocessor::initialSetup() 37 : { 38 160 : auto & chain_control_system = getMooseApp().getChainControlDataSystem(); 39 160 : if (chain_control_system.hasChainControlData(_data_name)) 40 : { 41 160 : if (chain_control_system.hasChainControlDataOfType<Real>(_data_name)) 42 117 : _real_data = &chain_control_system.getChainControlData<Real>(_data_name); 43 43 : else if (chain_control_system.hasChainControlDataOfType<bool>(_data_name)) 44 43 : _bool_data = &chain_control_system.getChainControlData<bool>(_data_name); 45 : else 46 0 : mooseError( 47 0 : "The chain control data '", _data_name, "' exists but is not of type 'Real' or 'bool'."); 48 : } 49 : else 50 0 : mooseError("The chain control data '", _data_name, "' does not exist."); 51 160 : } 52 : 53 : void 54 1336 : ChainControlDataPostprocessor::initialize() 55 : { 56 1336 : } 57 : 58 : void 59 1336 : ChainControlDataPostprocessor::execute() 60 : { 61 1336 : } 62 : 63 : Real 64 1336 : ChainControlDataPostprocessor::getValue() const 65 : { 66 1336 : if (_real_data) 67 1164 : return _real_data->get(); 68 : else 69 : { 70 : mooseAssert(_bool_data, "This point should not be reachable."); 71 : 72 : // for booleans, 'true' should convert to 1.0 and 'false' to 0.0. 73 172 : return _bool_data->get(); 74 : } 75 : }