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 "Reporter.h" 11 : #include "InputParameters.h" 12 : #include "FEProblemBase.h" 13 : #include "MooseApp.h" 14 : 15 : InputParameters 16 913505 : Reporter::validParams() 17 : { 18 913505 : InputParameters params = emptyInputParameters(); 19 913505 : params += OutputInterface::validParams(); 20 : 21 913505 : params.registerBase("Reporter"); 22 913505 : return params; 23 0 : } 24 : 25 : // The OutputInterface automatic creation of the "variable" build list is disabled because the 26 : // output names for the reporters are more than just the block name. The list is updated manually 27 : // when each value is declared. 28 : 29 61774 : Reporter::Reporter(const MooseObject * moose_object) 30 : : OutputInterface(moose_object->parameters(), /*build_list=*/false), 31 61774 : _reporter_moose_object(*moose_object), 32 123548 : _reporter_params(_reporter_moose_object.parameters()), 33 61774 : _reporter_name(_reporter_params.get<std::string>("_object_name")), 34 61774 : _reporter_fe_problem( 35 61774 : *_reporter_params.getCheckedPointerParam<FEProblemBase *>("_fe_problem_base")), 36 123548 : _reporter_data(_reporter_fe_problem.getReporterData(ReporterData::WriteKey())) 37 : { 38 : // For the callback to declareLateValues() 39 61774 : _reporter_moose_object.getMooseApp().registerInterfaceObject(*this); 40 61774 : } 41 : 42 : void 43 1460 : Reporter::store(nlohmann::json & json) const 44 : { 45 1460 : json["type"] = _reporter_params.get<std::string>("_type"); 46 1460 : } 47 : 48 : const ReporterValueName & 49 146 : Reporter::getReporterValueName(const std::string & param_name) const 50 : { 51 146 : if (!_reporter_params.isParamValid(param_name)) 52 4 : _reporter_moose_object.mooseError( 53 : "When getting a ReporterValueName, failed to get a parameter with the name \"", 54 : param_name, 55 : "\".", 56 : "\n\nKnown parameters:\n", 57 4 : _reporter_moose_object.parameters()); 58 : 59 142 : if (_reporter_params.isType<ReporterValueName>(param_name)) 60 138 : return _reporter_params.get<ReporterValueName>(param_name); 61 : 62 4 : _reporter_moose_object.mooseError("Supplied parameter with name \"", 63 : param_name, 64 : "\" of type \"", 65 4 : _reporter_params.type(param_name), 66 : "\" is not an expected type for getting a Reporter value.\n\n", 67 : "The expected type is \"ReporterValueName\"."); 68 : }