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 "AccumulateReporter.h" 11 : 12 : registerMooseObject("MooseApp", AccumulateReporter); 13 : 14 : InputParameters 15 14299 : AccumulateReporter::validParams() 16 : { 17 14299 : InputParameters params = GeneralReporter::validParams(); 18 14299 : params.addClassDescription("Reporter which accumulates the value of a inputted reporter value " 19 : "over time into a vector reporter value of the same type."); 20 14299 : params.addRequiredParam<std::vector<ReporterName>>("reporters", "The reporters to accumulate."); 21 : 22 42897 : params.set<ExecFlagEnum>("execute_on") = {EXEC_INITIAL, EXEC_TIMESTEP_END}; 23 14299 : params.suppressParameter<ExecFlagEnum>("execute_on"); 24 14299 : return params; 25 14299 : } 26 : 27 17 : AccumulateReporter::AccumulateReporter(const InputParameters & parameters) 28 17 : : GeneralReporter(parameters) 29 : { 30 17 : } 31 : 32 : void 33 17 : AccumulateReporter::declareLateValues() 34 : { 35 17 : const ReporterData & rdata = _fe_problem.getReporterData(); 36 129 : for (const auto & rname : getParam<std::vector<ReporterName>>("reporters")) 37 : { 38 112 : if (!rdata.hasReporterValue(rname)) 39 0 : paramError("reporters", "Reporter ", rname, " does not exist."); 40 : 41 211 : if (!declareAccumulateHelper<int>(rname) && !declareAccumulateHelper<Real>(rname) && 42 78 : !declareAccumulateHelper<dof_id_type>(rname) && 43 65 : !declareAccumulateHelper<std::string>(rname) && 44 52 : !declareAccumulateHelper<std::vector<int>>(rname) && 45 39 : !declareAccumulateHelper<std::vector<Real>>(rname) && 46 224 : !declareAccumulateHelper<std::vector<std::string>>(rname) && 47 13 : !declareAccumulateHelper<std::vector<dof_id_type>>(rname)) 48 0 : paramError("reporters", 49 : "Reporter value ", 50 : rname, 51 : " is of unsupported type ", 52 0 : rdata.getReporterContextBase(rname).type(), 53 : "."); 54 : } 55 17 : } 56 : 57 : void 58 270 : AccumulateReporter::execute() 59 : { 60 270 : unsigned int ind = static_cast<unsigned int>(_t_step); 61 1962 : for (auto & val : _accumulated_values) 62 1692 : val->accumulate(ind); 63 270 : }