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 337897 : Reporter::validParams() 17 : { 18 337897 : InputParameters params = emptyInputParameters(); 19 337897 : params += OutputInterface::validParams(); 20 : 21 337897 : params.registerBase("Reporter"); 22 337897 : 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 65875 : Reporter::Reporter(const MooseObject * moose_object) 30 : : OutputInterface(moose_object->parameters(), /*build_list=*/false), 31 65875 : _reporter_moose_object(*moose_object), 32 131750 : _reporter_params(_reporter_moose_object.parameters()), 33 65875 : _reporter_name(_reporter_moose_object.name()), 34 65875 : _reporter_fe_problem( 35 263500 : *_reporter_params.getCheckedPointerParam<FEProblemBase *>("_fe_problem_base")), 36 131750 : _reporter_data(_reporter_fe_problem.getReporterData(ReporterData::WriteKey())) 37 : { 38 : // For the callback to declareLateValues() 39 65875 : _reporter_moose_object.getMooseApp().registerInterfaceObject(*this); 40 65875 : } 41 : 42 : #ifdef MOOSE_KOKKOS_ENABLED 43 120 : Reporter::Reporter(const Reporter & object, const Moose::Kokkos::FunctorCopy & key) 44 : : OutputInterface(object, key), 45 120 : _reporter_moose_object(object._reporter_moose_object), 46 120 : _reporter_params(object._reporter_params), 47 120 : _reporter_name(object._reporter_name), 48 120 : _reporter_fe_problem(object._reporter_fe_problem), 49 120 : _reporter_data(object._reporter_data) 50 : { 51 120 : } 52 : #endif 53 : 54 : void 55 1602 : Reporter::store(nlohmann::json & json) const 56 : { 57 1602 : json["type"] = _reporter_moose_object.type(); 58 1602 : } 59 : 60 : const ReporterValueName & 61 169 : Reporter::getReporterValueName(const std::string & param_name) const 62 : { 63 169 : if (!_reporter_params.isParamValid(param_name)) 64 3 : _reporter_moose_object.mooseError( 65 : "When getting a ReporterValueName, failed to get a parameter with the name \"", 66 : param_name, 67 : "\".", 68 : "\n\nKnown parameters:\n", 69 3 : _reporter_moose_object.parameters()); 70 : 71 166 : if (_reporter_params.isType<ReporterValueName>(param_name)) 72 163 : return _reporter_params.get<ReporterValueName>(param_name); 73 : 74 3 : _reporter_moose_object.mooseError("Supplied parameter with name \"", 75 : param_name, 76 : "\" of type \"", 77 3 : _reporter_params.type(param_name), 78 : "\" is not an expected type for getting a Reporter value.\n\n", 79 : "The expected type is \"ReporterValueName\"."); 80 : }