LCOV - code coverage report
Current view: top level - src/actions - AddFunctionAction.C (source / functions) Hit Total Coverage
Test: idaholab/moose framework: d8769b Lines: 13 14 92.9 %
Date: 2025-11-07 20:01:30 Functions: 3 3 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 "AddFunctionAction.h"
      11             : #include "FEProblem.h"
      12             : 
      13             : registerMooseAction("MooseApp", AddFunctionAction, "add_function");
      14             : 
      15             : InputParameters
      16       33331 : AddFunctionAction::validParams()
      17             : {
      18       33331 :   InputParameters params = MooseObjectAction::validParams();
      19       33331 :   params.addClassDescription("Add a Function object to the simulation.");
      20       33331 :   return params;
      21           0 : }
      22             : 
      23       33083 : AddFunctionAction::AddFunctionAction(const InputParameters & params) : MooseObjectAction(params) {}
      24             : 
      25             : void
      26       32954 : AddFunctionAction::act()
      27             : {
      28       32954 :   FunctionParserBase<Real> fp;
      29       32954 :   std::string vars = "x,y,z,t,NaN,pi,e";
      30       32954 :   if (fp.Parse(_name, vars) == -1) // -1 for success
      31          10 :     mooseWarning(
      32             :         "Function name '",
      33          10 :         _name,
      34             :         "' can be interpreted as a parsed function expression. This can be problematic. As an "
      35             :         "example you may name a function 'x' whose functional form is 'xy'. You probably wouldn't "
      36             :         "do this, but let's assume for the sake of argument. You might also write somewhere in a "
      37             :         "consumer object 'function = x'. Well, MOOSE supports direct construction of parsed "
      38             :         "functions from 'FunctionName' parameters, so is this consumer going to end up using the "
      39             :         "functional form 'x' or 'xy'? It is undefined behavior.");
      40       32954 :   _problem->addFunction(_type, _name, _moose_object_pars);
      41       32821 : }

Generated by: LCOV version 1.14