www.mooseframework.org
GradParsedFunction.C
Go to the documentation of this file.
1 //* This file is part of the MOOSE framework
2 //* https://www.mooseframework.org
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 
14 
15 template <>
16 InputParameters
18 {
19  InputParameters params = validParams<MooseParsedFunction>();
20  params += validParams<MooseParsedFunction>();
21  params.addRequiredParam<RealVectorValue>(
22  "direction",
23  "The direction in which to take the derivative. This must not be a zero-length vector");
24  return params;
25 }
26 
27 GradParsedFunction::GradParsedFunction(const InputParameters & parameters)
28  : MooseParsedFunction(parameters), _direction(getParam<RealVectorValue>("direction"))
29 {
30  _len = _direction.norm();
31  if (_len == 0)
32  mooseError("The direction in the GradParsedFunction must have positive length.");
33  _direction /= 2.0; // note - so we can do central differences
34 }
35 
36 Real
37 GradParsedFunction::value(Real t, const Point & p)
38 {
39  return (_function_ptr->evaluate<Real>(t, p + _direction) -
40  _function_ptr->evaluate<Real>(t, p - _direction)) /
41  _len;
42 }
RealVectorValue _direction
central difference direction
returns the central difference approx to the derivative of the function, ie (f(t, p + direction) - f(...
virtual Real value(Real t, const Point &pt)
registerMooseObject("RichardsApp", GradParsedFunction)
Real _len
2*|_direction|
InputParameters validParams< GradParsedFunction >()
GradParsedFunction(const InputParameters &parameters)