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 14585 : ChainControlDataPostprocessor::validParams() 18 : { 19 14585 : InputParameters params = GeneralPostprocessor::validParams(); 20 : 21 14585 : params.addClassDescription("Gets a Real or bool chain control value."); 22 : 23 14585 : params.addRequiredParam<std::string>("chain_control_data_name", "Chain control data name"); 24 14585 : return params; 25 0 : } 26 : 27 160 : ChainControlDataPostprocessor::ChainControlDataPostprocessor(const InputParameters & parameters) 28 : : GeneralPostprocessor(parameters), 29 160 : _data_name(getParam<std::string>("chain_control_data_name")), 30 160 : _real_data(nullptr), 31 160 : _bool_data(nullptr) 32 : { 33 160 : } 34 : 35 : void 36 148 : ChainControlDataPostprocessor::initialSetup() 37 : { 38 148 : auto & chain_control_system = getMooseApp().getChainControlDataSystem(); 39 148 : if (chain_control_system.hasChainControlData(_data_name)) 40 : { 41 148 : if (chain_control_system.hasChainControlDataOfType<Real>(_data_name)) 42 108 : _real_data = &chain_control_system.getChainControlData<Real>(_data_name); 43 40 : else if (chain_control_system.hasChainControlDataOfType<bool>(_data_name)) 44 40 : _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 148 : } 52 : 53 : void 54 1225 : ChainControlDataPostprocessor::initialize() 55 : { 56 1225 : } 57 : 58 : void 59 1225 : ChainControlDataPostprocessor::execute() 60 : { 61 1225 : } 62 : 63 : Real 64 1225 : ChainControlDataPostprocessor::getValue() const 65 : { 66 1225 : if (_real_data) 67 1067 : 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 158 : return _bool_data->get(); 74 : } 75 : }