LCOV - code coverage report
Current view: top level - src/controllogic - ParsedFunctionControl.C (source / functions) Hit Total Coverage
Test: idaholab/moose thermal_hydraulics: #32971 (54bef8) with base c6cf66 Lines: 31 32 96.9 %
Date: 2026-05-29 20:41:18 Functions: 6 6 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 "ParsedFunctionControl.h"
      11             : #include "THMParsedFunctionWrapper.h"
      12             : 
      13             : registerMooseObject("ThermalHydraulicsApp", ParsedFunctionControl);
      14             : 
      15             : InputParameters
      16          32 : ParsedFunctionControl::validParams()
      17             : {
      18          32 :   InputParameters params = THMControl::validParams();
      19          32 :   params += MooseParsedFunctionBase::validParams();
      20          64 :   params.addRequiredCustomTypeParam<std::string>(
      21             :       "function", "FunctionExpression", "The function to be evaluated by this control.");
      22          32 :   params.addClassDescription("Control that evaluates a parsed function");
      23          32 :   return params;
      24           0 : }
      25             : 
      26          16 : ParsedFunctionControl::ParsedFunctionControl(const InputParameters & parameters)
      27             :   : THMControl(parameters),
      28             :     MooseParsedFunctionBase(parameters),
      29          16 :     _function(verifyFunction(getParam<std::string>("function"))),
      30          32 :     _value(declareComponentControlData<Real>("value"))
      31             : {
      32          16 : }
      33             : 
      34             : void
      35          24 : ParsedFunctionControl::buildFunction()
      36             : {
      37          24 :   if (!_function_ptr)
      38             :   {
      39          16 :     THREAD_ID tid = 0;
      40          32 :     if (isParamValid("_tid"))
      41          32 :       tid = getParam<THREAD_ID>("_tid");
      42             : 
      43          16 :     _function_ptr = std::make_unique<THMParsedFunctionWrapper>(
      44          16 :         *_sim, _pfb_feproblem, _function, _vars, _vals, tid);
      45             :   }
      46          24 : }
      47             : 
      48             : void
      49           8 : ParsedFunctionControl::initialSetup()
      50             : {
      51           8 :   buildFunction();
      52           8 : }
      53             : 
      54             : void
      55          16 : ParsedFunctionControl::init()
      56             : {
      57          16 :   buildFunction();
      58             : 
      59             :   // establish dependency so that the control data graph is properly evaluated
      60          44 :   for (auto & ctrl_name : _function_ptr->getRealControlData())
      61          44 :     getControlDataByName<Real>(ctrl_name->name());
      62          24 :   for (auto & ctrl_name : _function_ptr->getBoolControlData())
      63          24 :     getControlDataByName<bool>(ctrl_name->name());
      64          16 : }
      65             : 
      66             : void
      67          22 : ParsedFunctionControl::execute()
      68             : {
      69          22 :   _value = _function_ptr->evaluate(_t, Point(0., 0., 0.));
      70          22 : }

Generated by: LCOV version 1.14