LCOV - code coverage report
Current view: top level - src/reporters - StochasticReporter.C (source / functions) Hit Total Coverage
Test: idaholab/moose stochastic_tools: f45d79 Lines: 31 40 77.5 %
Date: 2025-07-25 05:00:46 Functions: 3 3 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        7300 : StochasticReporter::validParams()
      18             : {
      19        7300 :   InputParameters params = GeneralReporter::validParams();
      20        7300 :   params.addClassDescription(
      21             :       "Storage container for stochastic simulation results coming from Reporters.");
      22       14600 :   MooseEnum parallel_type("DISTRIBUTED=0 ROOT=1", "DISTRIBUTED");
      23       14600 :   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        7300 :   return params;
      31        7300 : }
      32             : 
      33        3632 : StochasticReporter::StochasticReporter(const InputParameters & parameters)
      34        7264 :   : GeneralReporter(parameters), _parallel_type(getParam<MooseEnum>("parallel_type"))
      35             : {
      36        3632 : }
      37             : 
      38             : ReporterName
      39        4236 : StochasticReporter::declareStochasticReporterClone(const Sampler & sampler,
      40             :                                                    const ReporterData & from_data,
      41             :                                                    const ReporterName & from_reporter,
      42             :                                                    std::string prefix)
      43             : {
      44        4236 :   std::string value_name = (prefix.empty() ? "" : prefix + ":") + from_reporter.getObjectName() +
      45        8472 :                            ":" + from_reporter.getValueName();
      46             : 
      47        4236 :   if (!from_data.hasReporterValue(from_reporter))
      48           0 :     mooseError("Reporter value ", from_reporter, " has not been declared.");
      49             : 
      50             :   // Single quantities
      51        4236 :   if (from_data.hasReporterValue<bool>(from_reporter))
      52           0 :     declareStochasticReporter<bool>(value_name, sampler);
      53        4236 :   else if (from_data.hasReporterValue<int>(from_reporter))
      54         176 :     declareStochasticReporter<int>(value_name, sampler);
      55        4148 :   else if (from_data.hasReporterValue<Real>(from_reporter))
      56        7248 :     declareStochasticReporter<Real>(value_name, sampler);
      57         524 :   else if (from_data.hasReporterValue<std::string>(from_reporter))
      58         144 :     declareStochasticReporter<std::string>(value_name, sampler);
      59             :   // Vector quantities
      60         452 :   else if (from_data.hasReporterValue<std::vector<bool>>(from_reporter))
      61           0 :     declareStochasticReporter<std::vector<bool>>(value_name, sampler);
      62         452 :   else if (from_data.hasReporterValue<std::vector<int>>(from_reporter))
      63           0 :     declareStochasticReporter<std::vector<int>>(value_name, sampler);
      64         452 :   else if (from_data.hasReporterValue<std::vector<Real>>(from_reporter))
      65         896 :     declareStochasticReporter<std::vector<Real>>(value_name, sampler);
      66           4 :   else if (from_data.hasReporterValue<std::vector<std::string>>(from_reporter))
      67           0 :     declareStochasticReporter<std::vector<std::string>>(value_name, sampler);
      68             :   // Vector of vector quantities
      69           4 :   else if (from_data.hasReporterValue<std::vector<std::vector<bool>>>(from_reporter))
      70           0 :     declareStochasticReporter<std::vector<std::vector<bool>>>(value_name, sampler);
      71           4 :   else if (from_data.hasReporterValue<std::vector<std::vector<int>>>(from_reporter))
      72           0 :     declareStochasticReporter<std::vector<std::vector<int>>>(value_name, sampler);
      73           4 :   else if (from_data.hasReporterValue<std::vector<std::vector<Real>>>(from_reporter))
      74           0 :     declareStochasticReporter<std::vector<std::vector<Real>>>(value_name, sampler);
      75           4 :   else if (from_data.hasReporterValue<std::vector<std::vector<std::string>>>(from_reporter))
      76           0 :     declareStochasticReporter<std::vector<std::vector<std::string>>>(value_name, sampler);
      77             :   else
      78             :     return {}; // Empty ReporterName to show that reporter value is unsupported type
      79             : 
      80        4232 :   return {name(), value_name};
      81             : }

Generated by: LCOV version 1.14