LCOV - code coverage report
Current view: top level - src/postprocessors - SumPostprocessor.C (source / functions) Hit Total Coverage
Test: idaholab/moose thermal_hydraulics: #30301 (3b550b) with base 2ad78d Lines: 23 27 85.2 %
Date: 2025-07-30 13:02:48 Functions: 5 5 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 "SumPostprocessor.h"
      11             : 
      12             : registerMooseObject("ThermalHydraulicsApp", SumPostprocessor);
      13             : 
      14             : InputParameters
      15        1835 : SumPostprocessor::validParams()
      16             : {
      17        1835 :   InputParameters params = GeneralPostprocessor::validParams();
      18        1835 :   params.addClassDescription("Sums the values of several postprocessors");
      19        3670 :   params.addParam<std::vector<PostprocessorName>>("values", "List of postprocessors to add");
      20        3670 :   params.addDeprecatedParam<PostprocessorName>("a", "First postprocessor", "Use 'values' instead.");
      21        3670 :   params.addDeprecatedParam<PostprocessorName>(
      22             :       "b", "Second postprocessor", "Use 'values' instead.");
      23             : 
      24        1835 :   return params;
      25           0 : }
      26             : 
      27         589 : SumPostprocessor::SumPostprocessor(const InputParameters & parameters)
      28         589 :   : GeneralPostprocessor(parameters)
      29             : {
      30        1178 :   if (isParamValid("a") && isParamValid("b"))
      31             :   {
      32           0 :     _values.push_back(&getPostprocessorValue("a"));
      33           0 :     _values.push_back(&getPostprocessorValue("b"));
      34             :   }
      35        1178 :   else if (isParamValid("values"))
      36             :   {
      37             :     const std::vector<PostprocessorName> & pps_names =
      38        1178 :         getParam<std::vector<PostprocessorName>>("values");
      39        1855 :     for (auto & name : pps_names)
      40        1266 :       _values.push_back(&getPostprocessorValueByName(name));
      41             :   }
      42             :   else
      43           0 :     mooseError("Use 'values' parameter to specify postprocessor names that will be added up.");
      44         589 : }
      45             : 
      46             : void
      47        3130 : SumPostprocessor::initialize()
      48             : {
      49        3130 : }
      50             : 
      51             : void
      52        3130 : SumPostprocessor::execute()
      53             : {
      54        3130 : }
      55             : 
      56             : PostprocessorValue
      57        3130 : SumPostprocessor::getValue() const
      58             : {
      59             :   Real sum = 0;
      60        9878 :   for (auto & v : _values)
      61        6748 :     sum += *v;
      62        3130 :   return sum;
      63             : }

Generated by: LCOV version 1.14