LCOV - code coverage report
Current view: top level - src/reporters - AccumulateReporter.C (source / functions) Hit Total Coverage
Test: idaholab/moose framework: #32971 (54bef8) with base c6cf66 Lines: 28 31 90.3 %
Date: 2026-05-29 20:35:17 Functions: 4 4 100.0 %
Legend: Lines: hit not hit

          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        3093 : AccumulateReporter::validParams()
      16             : {
      17        3093 :   InputParameters params = GeneralReporter::validParams();
      18        6186 :   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        9279 :   params.addRequiredParam<std::vector<ReporterName>>("reporters", "The reporters to accumulate.");
      21             : 
      22       12372 :   params.set<ExecFlagEnum>("execute_on") = {EXEC_INITIAL, EXEC_TIMESTEP_END};
      23        3093 :   params.suppressParameter<ExecFlagEnum>("execute_on");
      24        3093 :   return params;
      25        3093 : }
      26             : 
      27          16 : AccumulateReporter::AccumulateReporter(const InputParameters & parameters)
      28          16 :   : GeneralReporter(parameters)
      29             : {
      30          16 : }
      31             : 
      32             : void
      33          16 : AccumulateReporter::declareLateValues()
      34             : {
      35          16 :   const ReporterData & rdata = _fe_problem.getReporterData();
      36         152 :   for (const auto & rname : getParam<std::vector<ReporterName>>("reporters"))
      37             :   {
      38         104 :     if (!rdata.hasReporterValue(rname))
      39           0 :       paramError("reporters", "Reporter ", rname, " does not exist.");
      40             : 
      41         196 :     if (!declareAccumulateHelper<int>(rname) && !declareAccumulateHelper<Real>(rname) &&
      42          72 :         !declareAccumulateHelper<dof_id_type>(rname) &&
      43          60 :         !declareAccumulateHelper<std::string>(rname) &&
      44          48 :         !declareAccumulateHelper<std::vector<int>>(rname) &&
      45          36 :         !declareAccumulateHelper<std::vector<Real>>(rname) &&
      46         208 :         !declareAccumulateHelper<std::vector<std::string>>(rname) &&
      47          12 :         !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          16 : }
      56             : 
      57             : void
      58         254 : AccumulateReporter::execute()
      59             : {
      60         254 :   unsigned int ind = static_cast<unsigned int>(_t_step);
      61        1818 :   for (auto & val : _accumulated_values)
      62        1564 :     val->accumulate(ind);
      63         254 : }

Generated by: LCOV version 1.14