LCOV - code coverage report
Current view: top level - src/postprocessors - FunctionValuePostprocessor.C (source / functions) Hit Total Coverage
Test: idaholab/moose framework: 2bf808 Lines: 37 39 94.9 %
Date: 2025-07-17 01:28:37 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 "FunctionValuePostprocessor.h"
      11             : #include "Function.h"
      12             : 
      13             : registerMooseObject("MooseApp", FunctionValuePostprocessor);
      14             : 
      15             : InputParameters
      16       16281 : FunctionValuePostprocessor::validParams()
      17             : {
      18       16281 :   InputParameters params = GeneralPostprocessor::validParams();
      19       16281 :   params.addRequiredParam<FunctionName>("function",
      20             :                                         "The function which supplies the postprocessor value.");
      21             : 
      22       16281 :   params.addParam<std::vector<PostprocessorName>>(
      23             :       "point",
      24             :       "A set of three PostprocessorNames or constant values (or any mixture thereof) that will be "
      25             :       "passed to the function in the space argument");
      26             : 
      27       16281 :   params.addParam<Real>("scale_factor", 1, "A scale factor to be applied to the function");
      28       16281 :   params.addParam<std::vector<PostprocessorName>>(
      29             :       "indirect_dependencies",
      30             :       {},
      31             :       "If the evaluated function depends on other postprocessors they must be listed here to "
      32             :       "ensure proper dependency resolution");
      33             : 
      34       16281 :   params.addParam<PostprocessorName>("time",
      35             :                                      "The PostprocessorName or constant value that will be passed "
      36             :                                      "to the function in the time argument.");
      37       16281 :   params.declareControllable("scale_factor");
      38       16281 :   params.addClassDescription(
      39             :       "Computes the value of a supplied function at a single point (scalable)");
      40       16281 :   return params;
      41           0 : }
      42             : 
      43         990 : FunctionValuePostprocessor::FunctionValuePostprocessor(const InputParameters & parameters)
      44             :   : GeneralPostprocessor(parameters),
      45         990 :     _function(getFunction("function")),
      46         990 :     _scale_factor(getParam<Real>("scale_factor")),
      47         990 :     _has_space_pp(isParamValid("point")),
      48        1980 :     _time_pp(nullptr)
      49             : {
      50         990 :   if (isParamValid("time"))
      51          12 :     _time_pp = &getPostprocessorValue("time");
      52             : 
      53         990 :   if (_has_space_pp)
      54             :   {
      55         208 :     if (coupledPostprocessors("point") != 3)
      56           0 :       paramError("point", "Size must be 3");
      57         208 :     _point.resize(3);
      58         832 :     for (unsigned int j = 0; j < 3; ++j)
      59         624 :       _point[j] = &getPostprocessorValue("point", j);
      60             :   }
      61             : 
      62             :   const auto & indirect_dependencies =
      63         990 :       getParam<std::vector<PostprocessorName>>("indirect_dependencies");
      64         990 :   _depend_uo.insert(indirect_dependencies.begin(), indirect_dependencies.end());
      65         990 : }
      66             : 
      67             : void
      68        6956 : FunctionValuePostprocessor::initialize()
      69             : {
      70        6956 : }
      71             : 
      72             : void
      73        6956 : FunctionValuePostprocessor::execute()
      74             : {
      75        6956 : }
      76             : 
      77             : PostprocessorValue
      78        6956 : FunctionValuePostprocessor::getValue() const
      79             : {
      80        6956 :   Point p;
      81        6956 :   if (_has_space_pp)
      82       11716 :     for (unsigned int j = 0; j < 3; ++j)
      83        8787 :       p(j) = *_point[j];
      84        6956 :   if (_time_pp)
      85          66 :     return _scale_factor * _function.value(*_time_pp, p);
      86        6890 :   return _scale_factor * _function.value(_t, p);
      87             : }

Generated by: LCOV version 1.14