LCOV - code coverage report
Current view: top level - src/functions - MooseParsedGradFunction.C (source / functions) Hit Total Coverage
Test: idaholab/moose framework: 2bf808 Lines: 31 34 91.2 %
Date: 2025-07-17 01:28:37 Functions: 7 8 87.5 %
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 "MooseParsedGradFunction.h"
      11             : #include "MooseParsedFunctionWrapper.h"
      12             : 
      13             : registerMooseObjectAliased("MooseApp", MooseParsedGradFunction, "ParsedGradFunction");
      14             : 
      15             : InputParameters
      16       16194 : MooseParsedGradFunction::validParams()
      17             : {
      18       16194 :   InputParameters params = Function::validParams();
      19       16194 :   params.addClassDescription("Defines a function and its gradient using input file parameters.");
      20       16194 :   params += MooseParsedFunctionBase::validParams();
      21       16194 :   params.addDeprecatedParam<std::string>(
      22             :       "value", "User defined function.", "Use 'expression' instead.");
      23             :   // TODO Make required once deprecation is handled + add 0 default, see #19119
      24       16194 :   params.addParam<std::string>("expression", "User defined function.");
      25       16194 :   params.addParam<std::string>("grad_x", "0", "Partial derivative with respect to x.");
      26       16194 :   params.addParam<std::string>("grad_y", "0", "Partial derivative with respect to y.");
      27       16194 :   params.addParam<std::string>("grad_z", "0", "Partial derivative with respect to z.");
      28       16194 :   return params;
      29           0 : }
      30             : 
      31        1007 : MooseParsedGradFunction::MooseParsedGradFunction(const InputParameters & parameters)
      32             :   : Function(parameters),
      33             :     MooseParsedFunctionBase(parameters),
      34        1007 :     _value(verifyFunction(getRenamedParam<std::string>("value", "expression"))),
      35        3021 :     _grad_value(verifyFunction(std::string("{") + getParam<std::string>("grad_x") + "}{" +
      36        4028 :                                getParam<std::string>("grad_y") + "}{" +
      37        4028 :                                getParam<std::string>("grad_z") + "}"))
      38             : {
      39        1007 : }
      40             : 
      41        1994 : MooseParsedGradFunction::~MooseParsedGradFunction() {}
      42             : 
      43             : Real
      44     9230762 : MooseParsedGradFunction::value(Real t, const Point & p) const
      45             : {
      46             :   // Return a scalar value
      47     9230762 :   return _function_ptr->evaluate<Real>(t, p);
      48             : }
      49             : 
      50             : RealGradient
      51     1990284 : MooseParsedGradFunction::gradient(Real t, const Point & p) const
      52             : {
      53             :   // Return gradient (RealGradient = RealVectorValue)
      54     1990284 :   return _grad_function_ptr->evaluate<RealVectorValue>(t, p);
      55             : }
      56             : 
      57             : RealVectorValue
      58           0 : MooseParsedGradFunction::vectorValue(Real /*t*/, const Point & /*p*/) const
      59             : {
      60           0 :   mooseError("The vectorValue method is not defined in ParsedGradFunction");
      61             : }
      62             : 
      63             : void
      64         997 : MooseParsedGradFunction::initialSetup()
      65             : {
      66         997 :   THREAD_ID tid = 0;
      67         997 :   if (isParamValid("_tid"))
      68         997 :     tid = getParam<THREAD_ID>("_tid");
      69             : 
      70         997 :   if (!_function_ptr)
      71             :     _function_ptr =
      72         997 :         std::make_unique<MooseParsedFunctionWrapper>(_pfb_feproblem, _value, _vars, _vals, tid);
      73             : 
      74         997 :   if (!_grad_function_ptr)
      75         997 :     _grad_function_ptr = std::make_unique<MooseParsedFunctionWrapper>(
      76         997 :         _pfb_feproblem, _grad_value, _vars, _vals, tid);
      77         997 : }

Generated by: LCOV version 1.14