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

Generated by: LCOV version 1.14