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 "ReporterPositions.h" 11 : 12 : registerMooseObject("MooseApp", ReporterPositions); 13 : 14 : InputParameters 15 14359 : ReporterPositions::validParams() 16 : { 17 14359 : InputParameters params = Positions::validParams(); 18 14359 : params.addRequiredParam<std::vector<ReporterName>>("reporters", 19 : "Reporter(s) containing the positions"); 20 : 21 : // Use reporter ordering 22 14359 : params.set<bool>("auto_sort") = false; 23 : // User reporter broadcasting behavior 24 14359 : params.set<bool>("auto_broadcast") = false; 25 : 26 14359 : params.addClassDescription( 27 : "Import positions from one or more reporters, for example other Positions"); 28 14359 : return params; 29 0 : } 30 : 31 47 : ReporterPositions::ReporterPositions(const InputParameters & parameters) : Positions(parameters) 32 : { 33 : // Attempt to obtain the positions. Will only succeed for other Positions at this point 34 47 : initialize(); 35 : // Sort if needed 36 47 : finalize(); 37 : // TODO Check execute_on. I'm not sure how to retrieve execute_on for reporters. 38 47 : } 39 : 40 : void 41 47 : ReporterPositions::initialize() 42 : { 43 47 : clearPositions(); 44 : 45 47 : const auto & positions_reporters = getParam<std::vector<ReporterName>>("reporters"); 46 47 : _positions_2d.resize(positions_reporters.size()); 47 : 48 107 : for (const auto r_it : index_range(positions_reporters)) 49 : { 50 60 : const std::string & reporter_name = positions_reporters[r_it]; 51 : 52 60 : const auto & reporter_data = _fe_problem.getReporterData(); 53 60 : if (reporter_data.getReporterContextBase(reporter_name).getProducerModeEnum() == 54 : REPORTER_MODE_DISTRIBUTED) 55 0 : mooseError("Distributed reporter not implemented yet"); 56 60 : const auto & data = reporter_data.getReporterValue<std::vector<Point>>(reporter_name); 57 : 58 248 : for (const auto & d : data) 59 : { 60 188 : _positions.push_back(d); 61 188 : _positions_2d[r_it].push_back(d); 62 : } 63 60 : } 64 47 : _initialized = true; 65 47 : }