LCOV - code coverage report
Current view: top level - src/reporters - ReporterInterface.C (source / functions) Hit Total Coverage
Test: idaholab/moose framework: #32971 (54bef8) with base c6cf66 Lines: 31 37 83.8 %
Date: 2026-05-29 20:35:17 Functions: 7 8 87.5 %
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 "ReporterInterface.h"
      11             : 
      12             : #include "FEProblemBase.h"
      13             : 
      14             : InputParameters
      15     1853850 : ReporterInterface::validParams()
      16             : {
      17     1853850 :   return emptyInputParameters();
      18             : }
      19             : 
      20      437425 : ReporterInterface::ReporterInterface(const MooseObject * moose_object)
      21      874850 :   : _ri_params(moose_object->parameters()),
      22     1749700 :     _ri_fe_problem_base(*_ri_params.getCheckedPointerParam<FEProblemBase *>("_fe_problem_base")),
      23      437425 :     _ri_reporter_data(_ri_fe_problem_base.getReporterData()),
      24      437425 :     _ri_moose_object(*moose_object)
      25             : {
      26      437425 : }
      27             : 
      28             : #ifdef MOOSE_KOKKOS_ENABLED
      29        7931 : ReporterInterface::ReporterInterface(const ReporterInterface & object,
      30        7931 :                                      const Moose::Kokkos::FunctorCopy &)
      31        7931 :   : _ri_params(object._ri_params),
      32        7931 :     _ri_fe_problem_base(object._ri_fe_problem_base),
      33        7931 :     _ri_reporter_data(object._ri_reporter_data),
      34        7931 :     _ri_moose_object(object._ri_moose_object)
      35             : {
      36        7931 : }
      37             : #endif
      38             : 
      39             : bool
      40           0 : ReporterInterface::hasReporterValue(const std::string & param_name) const
      41             : {
      42           0 :   if (!reportersAdded())
      43           0 :     _ri_moose_object.mooseError(
      44             :         "Cannot call hasReporterValue() until all Reporters have been constructed.");
      45             : 
      46           0 :   return hasReporterValueByName(getReporterName(param_name));
      47             : }
      48             : 
      49             : bool
      50         112 : ReporterInterface::hasReporterValueByName(const ReporterName & reporter_name) const
      51             : {
      52         112 :   if (!reportersAdded())
      53           0 :     _ri_moose_object.mooseError(
      54             :         "Cannot call hasReporterValueByName() until all Reporters have been constructed.");
      55             : 
      56         112 :   return _ri_reporter_data.hasReporterValue(reporter_name);
      57             : }
      58             : 
      59             : const ReporterContextBase &
      60         112 : ReporterInterface::getReporterContextBaseByName(const ReporterName & reporter_name) const
      61             : {
      62         112 :   if (!reportersAdded())
      63           0 :     _ri_moose_object.mooseError(
      64             :         "Cannot call getReporterContextBaseByName() until all Reporters have been constructed.");
      65             : 
      66         112 :   return _ri_reporter_data.getReporterContextBase(reporter_name);
      67             : }
      68             : 
      69             : const ReporterName &
      70        1017 : ReporterInterface::getReporterName(const std::string & param_name) const
      71             : {
      72        1017 :   if (!_ri_params.isParamValid(param_name))
      73           3 :     _ri_moose_object.mooseError(
      74             :         "When getting a Reporter, failed to get a parameter with the name \"",
      75             :         param_name,
      76             :         "\".",
      77             :         "\n\nKnown parameters:\n",
      78           3 :         _ri_moose_object.parameters());
      79             : 
      80        1014 :   if (_ri_params.isType<ReporterName>(param_name))
      81        1011 :     return _ri_params.get<ReporterName>(param_name);
      82             : 
      83           3 :   _ri_moose_object.mooseError("Supplied parameter with name \"",
      84             :                               param_name,
      85             :                               "\" of type \"",
      86           3 :                               _ri_params.type(param_name),
      87             :                               "\" is not an expected type for getting a Reporter.\n\n",
      88             :                               "The expected type is \"ReporterName\".");
      89             : }
      90             : 
      91             : bool
      92        4225 : ReporterInterface::reportersAdded() const
      93             : {
      94       12675 :   return _ri_fe_problem_base.getMooseApp().actionWarehouse().isTaskComplete("add_reporter");
      95             : }

Generated by: LCOV version 1.14