LCOV - code coverage report
Current view: top level - src/functions - GradParsedFunction.C (source / functions) Hit Total Coverage
Test: idaholab/moose richards: #31405 (292dce) with base fef103 Lines: 15 16 93.8 %
Date: 2025-09-04 07:56:35 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 "GradParsedFunction.h"
      11             : #include "MooseParsedFunctionWrapper.h"
      12             : 
      13             : registerMooseObject("RichardsApp", GradParsedFunction);
      14             : 
      15             : InputParameters
      16         179 : GradParsedFunction::validParams()
      17             : {
      18         179 :   InputParameters params = MooseParsedFunction::validParams();
      19         179 :   params += MooseParsedFunction::validParams();
      20         358 :   params.addRequiredParam<RealVectorValue>(
      21             :       "direction",
      22             :       "The direction in which to take the derivative.  This must not be a zero-length vector");
      23         179 :   return params;
      24           0 : }
      25             : 
      26          82 : GradParsedFunction::GradParsedFunction(const InputParameters & parameters)
      27         164 :   : MooseParsedFunction(parameters), _direction(getParam<RealVectorValue>("direction"))
      28             : {
      29          82 :   _len = _direction.norm();
      30          82 :   if (_len == 0)
      31           1 :     mooseError("The direction in the GradParsedFunction must have positive length.");
      32             :   _direction /= 2.0; // note - so we can do central differences
      33          81 : }
      34             : 
      35             : Real
      36        6363 : GradParsedFunction::value(Real t, const Point & p) const
      37             : {
      38        6363 :   return (_function_ptr->evaluate<Real>(t, p + _direction) -
      39        6363 :           _function_ptr->evaluate<Real>(t, p - _direction)) /
      40        6363 :          _len;
      41             : }

Generated by: LCOV version 1.14