LCOV - code coverage report
Current view: top level - src/reporters - AccumulateReporter.C (source / functions) Hit Total Coverage
Test: idaholab/moose framework: 2bf808 Lines: 28 31 90.3 %
Date: 2025-07-17 01:28:37 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       14297 : AccumulateReporter::validParams()
      16             : {
      17       14297 :   InputParameters params = GeneralReporter::validParams();
      18       14297 :   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       14297 :   params.addRequiredParam<std::vector<ReporterName>>("reporters", "The reporters to accumulate.");
      21             : 
      22       42891 :   params.set<ExecFlagEnum>("execute_on") = {EXEC_INITIAL, EXEC_TIMESTEP_END};
      23       14297 :   params.suppressParameter<ExecFlagEnum>("execute_on");
      24       14297 :   return params;
      25       14297 : }
      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         120 :   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