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 "ReporterTimes.h" 11 : 12 : registerMooseObject("MooseApp", ReporterTimes); 13 : 14 : InputParameters 15 14289 : ReporterTimes::validParams() 16 : { 17 14289 : InputParameters params = Times::validParams(); 18 14289 : params.addRequiredParam<std::vector<ReporterName>>("reporters", 19 : "Reporter(s) containing the times."); 20 : 21 : // User reporter broadcasting behavior 22 14289 : params.set<bool>("auto_broadcast") = false; 23 : 24 14289 : params.addClassDescription("Import times from one or more reporters, for example other Times"); 25 14289 : return params; 26 0 : } 27 : 28 12 : ReporterTimes::ReporterTimes(const InputParameters & parameters) : Times(parameters) 29 : { 30 : // Attempt to obtain the positions. Will only succeed for other Times at this point 31 12 : initialize(); 32 : // Broadcast if needed 33 12 : finalize(); 34 12 : } 35 : 36 : void 37 34 : ReporterTimes::initialize() 38 : { 39 34 : clearTimes(); 40 : 41 34 : const auto & positions_reporters = getParam<std::vector<ReporterName>>("reporters"); 42 : 43 102 : for (const auto r_it : index_range(positions_reporters)) 44 : { 45 68 : const auto & reporter_name = positions_reporters[r_it]; 46 : 47 68 : const auto & reporter_data = _fe_problem.getReporterData(); 48 68 : if (reporter_data.getReporterContextBase(reporter_name).getProducerModeEnum() == 49 : REPORTER_MODE_DISTRIBUTED) 50 0 : mooseError("Distributed reporter not implemented yet"); 51 68 : const auto & data = reporter_data.getReporterValue<std::vector<Real>>(reporter_name); 52 : 53 272 : for (const auto & d : data) 54 : { 55 204 : _times.push_back(d); 56 : } 57 : } 58 34 : }