LCOV - code coverage report
Current view: top level - src/chaincontrols - ParsedChainControl.C (source / functions) Hit Total Coverage
Test: idaholab/moose framework: #32971 (54bef8) with base c6cf66 Lines: 30 31 96.8 %
Date: 2026-05-29 20:35:17 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 "ParsedChainControl.h"
      11             : #include "ChainControlParsedFunctionWrapper.h"
      12             : 
      13             : registerMooseObject("MooseApp", ParsedChainControl);
      14             : 
      15             : InputParameters
      16        3163 : ParsedChainControl::validParams()
      17             : {
      18        3163 :   InputParameters params = ChainControl::validParams();
      19        3163 :   params += MooseParsedFunctionBase::validParams();
      20             : 
      21        6326 :   params.addClassDescription(
      22             :       "Parses and evaluates a function expression to populate a control value.");
      23             : 
      24       18978 :   params.addRequiredCustomTypeParam<std::string>(
      25             :       "expression", "FunctionExpression", "Expression to parse to create the function to evaluate");
      26        9489 :   params.addParam<Point>("point", Point(), "Spatial point at which to evaluate the function");
      27             : 
      28        3163 :   return params;
      29           0 : }
      30             : 
      31          51 : ParsedChainControl::ParsedChainControl(const InputParameters & parameters)
      32             :   : ChainControl(parameters),
      33             :     MooseParsedFunctionBase(parameters),
      34          51 :     _function_expression(verifyFunction(getParam<std::string>("expression"))),
      35         102 :     _value(declareChainControlData<Real>("value")),
      36         153 :     _point(getParam<Point>("point"))
      37             : {
      38          51 : }
      39             : 
      40             : void
      41          51 : ParsedChainControl::buildFunction()
      42             : {
      43          51 :   if (!_function_ptr)
      44             :   {
      45          51 :     THREAD_ID tid = 0;
      46         153 :     if (isParamValid("_tid"))
      47         153 :       tid = getParam<THREAD_ID>("_tid");
      48             : 
      49          99 :     _function_ptr = std::make_unique<ChainControlParsedFunctionWrapper>(
      50          99 :         getMooseApp(), _pfb_feproblem, _function_expression, _vars, _vals, tid);
      51             :   }
      52          48 : }
      53             : 
      54             : void
      55          51 : ParsedChainControl::init()
      56             : {
      57          51 :   buildFunction();
      58             : 
      59             :   // Add dependencies for the chain control data used in the function expression
      60          72 :   for (auto & data_ptr : _function_ptr->getRealChainControlData())
      61          72 :     addChainControlDataDependency(data_ptr->name());
      62          96 :   for (auto & data_ptr : _function_ptr->getBoolChainControlData())
      63          96 :     addChainControlDataDependency(data_ptr->name());
      64          48 : }
      65             : 
      66             : void
      67        1214 : ParsedChainControl::execute()
      68             : {
      69        1214 :   _value = _function_ptr->evaluate(_t, _point);
      70        1214 : }

Generated by: LCOV version 1.14