LCOV - code coverage report
Current view: top level - src/vectorpostprocessors - StochasticResults.C (source / functions) Hit Total Coverage
Test: idaholab/moose stochastic_tools: #32971 (54bef8) with base c6cf66 Lines: 34 35 97.1 %
Date: 2026-05-29 20:40:35 Functions: 7 7 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 "StochasticResults.h"
      12             : 
      13             : // MOOSE includes
      14             : #include "Sampler.h"
      15             : #include "SamplerPostprocessorTransfer.h"
      16             : 
      17             : registerMooseObject("StochasticToolsApp", StochasticResults);
      18             : 
      19         758 : StochasticResultsData::StochasticResultsData(const VectorPostprocessorName & name,
      20         758 :                                              VectorPostprocessorValue * vpp)
      21         758 :   : name(name), vector(vpp)
      22             : {
      23         758 : }
      24             : 
      25             : InputParameters
      26        1428 : StochasticResults::validParams()
      27             : {
      28        1428 :   InputParameters params = GeneralVectorPostprocessor::validParams();
      29        1428 :   params.addClassDescription(
      30             :       "Storage container for stochastic simulation results coming from a Postprocessor.");
      31             : 
      32        2856 :   params.addDeprecatedParam<std::vector<SamplerName>>(
      33             :       "samplers",
      34             :       "A list of sampler names of associated data.",
      35             :       "This parameter is no longer needed, please remove it from your input file.");
      36             : 
      37             :   // If 'parallel_type = REPLICATED' broadcast the vector automatically
      38        1428 :   params.set<bool>("_auto_broadcast") = true;
      39        1428 :   return params;
      40           0 : }
      41             : 
      42         709 : StochasticResults::StochasticResults(const InputParameters & parameters)
      43         709 :   : GeneralVectorPostprocessor(parameters)
      44             : {
      45         709 : }
      46             : 
      47             : void
      48        1227 : StochasticResults::initialize()
      49             : {
      50             :   // Clear any existing data, unless the complete history is desired
      51        1227 :   if (!containsCompleteHistory())
      52        2461 :     for (auto & data : _sample_vectors)
      53        1255 :       data.vector->clear();
      54        1227 : }
      55             : 
      56             : void
      57        1227 : StochasticResults::finalize()
      58             : {
      59        1227 :   if (!isDistributed())
      60             :   {
      61        2473 :     for (auto & data : _sample_vectors)
      62        1261 :       _communicator.gather(0, data.current);
      63             :   }
      64             : 
      65        2503 :   for (auto & data : _sample_vectors)
      66             :   {
      67        1276 :     data.vector->insert(data.vector->end(), data.current.begin(), data.current.end());
      68        1276 :     data.current.clear();
      69             :   }
      70        1227 : }
      71             : 
      72             : void
      73        1182 : StochasticResults::setCurrentLocalVectorPostprocessorValue(
      74             :     const std::string & vector_name, const VectorPostprocessorValue && current)
      75             : {
      76        1182 :   auto data_ptr = std::find_if(_sample_vectors.begin(),
      77             :                                _sample_vectors.end(),
      78             :                                [&vector_name](StochasticResultsData & data)
      79        1252 :                                { return data.name == vector_name; });
      80             : 
      81             :   mooseAssert(data_ptr != _sample_vectors.end(),
      82             :               "Unable to locate a vector with the supplied name of '" << vector_name << "'.");
      83        1182 :   data_ptr->current = current;
      84        1182 : }
      85             : 
      86             : void
      87         758 : StochasticResults::initVector(const std::string & vector_name)
      88             : {
      89         758 :   _sample_vectors.emplace_back(vector_name, &declareVector(vector_name));
      90         758 : }

Generated by: LCOV version 1.14