LCOV - code coverage report
Current view: top level - src/reporters - StochasticReporter.C (source / functions) Hit Total Coverage
Test: idaholab/moose stochastic_tools: #32971 (54bef8) with base c6cf66 Lines: 37 45 82.2 %
Date: 2026-05-29 20:40:35 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             : // Stocastic Tools Includes
      11             : #include "StochasticReporter.h"
      12             : #include "Sampler.h"
      13             : 
      14             : registerMooseObject("StochasticToolsApp", StochasticReporter);
      15             : 
      16             : InputParameters
      17        3552 : StochasticReporter::validParams()
      18             : {
      19        3552 :   InputParameters params = GeneralReporter::validParams();
      20        3552 :   params.addClassDescription(
      21             :       "Storage container for stochastic simulation results coming from Reporters.");
      22        7104 :   MooseEnum parallel_type("DISTRIBUTED=0 ROOT=1", "DISTRIBUTED");
      23        7104 :   params.addParam<MooseEnum>(
      24             :       "parallel_type",
      25             :       parallel_type,
      26             :       "This parameter will determine how the stochastic data is gathered. It is common for "
      27             :       "outputting purposes that this parameter be set to ROOT, otherwise, many files will be "
      28             :       "produced showing the values on each processor. However, if there are lot of samples, "
      29             :       "gathering on root may be memory restrictive.");
      30        3552 :   params.set<ExecFlagEnum>("execute_on", true).addAvailableFlags(EXEC_TRANSFER);
      31        3552 :   return params;
      32        3552 : }
      33             : 
      34        1767 : StochasticReporter::StochasticReporter(const InputParameters & parameters)
      35        3534 :   : GeneralReporter(parameters), _parallel_type(getParam<MooseEnum>("parallel_type"))
      36             : {
      37        1767 : }
      38             : 
      39             : void
      40        4894 : StochasticReporter::initialize()
      41             : {
      42       19692 :   for (auto & vector : _vectors)
      43       14798 :     vector->initialize();
      44        4894 : }
      45             : 
      46             : ReporterName
      47        2016 : StochasticReporter::declareStochasticReporterClone(const Sampler & sampler,
      48             :                                                    const ReporterData & from_data,
      49             :                                                    const ReporterName & from_reporter,
      50             :                                                    std::string prefix)
      51             : {
      52        2016 :   std::string value_name = (prefix.empty() ? "" : prefix + ":") + from_reporter.getObjectName() +
      53        4032 :                            ":" + from_reporter.getValueName();
      54             : 
      55        2016 :   if (!from_data.hasReporterValue(from_reporter))
      56           0 :     mooseError("Reporter value ", from_reporter, " has not been declared.");
      57             : 
      58             :   // Single quantities
      59        2016 :   if (from_data.hasReporterValue<bool>(from_reporter))
      60           0 :     declareStochasticReporter<bool>(value_name, sampler);
      61        2016 :   else if (from_data.hasReporterValue<int>(from_reporter))
      62          82 :     declareStochasticReporter<int>(value_name, sampler);
      63        1975 :   else if (from_data.hasReporterValue<Real>(from_reporter))
      64        3416 :     declareStochasticReporter<Real>(value_name, sampler);
      65         267 :   else if (from_data.hasReporterValue<std::string>(from_reporter))
      66          68 :     declareStochasticReporter<std::string>(value_name, sampler);
      67             :   // Vector quantities
      68         233 :   else if (from_data.hasReporterValue<std::vector<bool>>(from_reporter))
      69           0 :     declareStochasticReporter<std::vector<bool>>(value_name, sampler);
      70         233 :   else if (from_data.hasReporterValue<std::vector<int>>(from_reporter))
      71           0 :     declareStochasticReporter<std::vector<int>>(value_name, sampler);
      72         233 :   else if (from_data.hasReporterValue<std::vector<Real>>(from_reporter))
      73         402 :     declareStochasticReporter<std::vector<Real>>(value_name, sampler);
      74          32 :   else if (from_data.hasReporterValue<std::vector<std::string>>(from_reporter))
      75           0 :     declareStochasticReporter<std::vector<std::string>>(value_name, sampler);
      76             :   // Vector of vector quantities
      77          32 :   else if (from_data.hasReporterValue<std::vector<std::vector<bool>>>(from_reporter))
      78           0 :     declareStochasticReporter<std::vector<std::vector<bool>>>(value_name, sampler);
      79          32 :   else if (from_data.hasReporterValue<std::vector<std::vector<int>>>(from_reporter))
      80           0 :     declareStochasticReporter<std::vector<std::vector<int>>>(value_name, sampler);
      81          32 :   else if (from_data.hasReporterValue<std::vector<std::vector<Real>>>(from_reporter))
      82          60 :     declareStochasticReporter<std::vector<std::vector<Real>>>(value_name, sampler);
      83           2 :   else if (from_data.hasReporterValue<std::vector<std::vector<std::string>>>(from_reporter))
      84           0 :     declareStochasticReporter<std::vector<std::vector<std::string>>>(value_name, sampler);
      85             :   else
      86             :     return {}; // Empty ReporterName to show that reporter value is unsupported type
      87             : 
      88        2014 :   return {name(), value_name};
      89             : }

Generated by: LCOV version 1.14