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) const
38 {
39  return (_function_ptr->evaluate<Real>(t, p + _direction) -
40  _function_ptr->evaluate<Real>(t, p - _direction)) /
41  _len;
42 }
GradParsedFunction::_direction
RealVectorValue _direction
central difference direction
Definition: GradParsedFunction.h:35
GradParsedFunction::_len
Real _len
2*|_direction|
Definition: GradParsedFunction.h:38
GradParsedFunction::value
virtual Real value(Real t, const Point &pt) const
Definition: GradParsedFunction.C:37
GradParsedFunction
returns the central difference approx to the derivative of the function, ie (f(t, p + direction) - f(...
Definition: GradParsedFunction.h:26
GradParsedFunction::GradParsedFunction
GradParsedFunction(const InputParameters &parameters)
Definition: GradParsedFunction.C:27
validParams< GradParsedFunction >
InputParameters validParams< GradParsedFunction >()
Definition: GradParsedFunction.C:17
GradParsedFunction.h
registerMooseObject
registerMooseObject("RichardsApp", GradParsedFunction)