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