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

Generated by: LCOV version 1.14