www.mooseframework.org
GradParsedFunction.C
Go to the documentation of this file.
1 /****************************************************************/
2 /* MOOSE - Multiphysics Object Oriented Simulation Environment */
3 /* */
4 /* All contents are licensed under LGPL V2.1 */
5 /* See LICENSE for full restrictions */
6 /****************************************************************/
7 
8 #include "GradParsedFunction.h"
9 #include "MooseParsedFunctionWrapper.h"
10 
11 template <>
12 InputParameters
14 {
15  InputParameters params = validParams<MooseParsedFunction>();
16  params += validParams<MooseParsedFunction>();
17  params.addRequiredParam<RealVectorValue>(
18  "direction",
19  "The direction in which to take the derivative. This must not be a zero-length vector");
20  return params;
21 }
22 
23 GradParsedFunction::GradParsedFunction(const InputParameters & parameters)
24  : MooseParsedFunction(parameters), _direction(getParam<RealVectorValue>("direction"))
25 {
26  _len = _direction.norm();
27  if (_len == 0)
28  mooseError("The direction in the GradParsedFunction must have positive length.");
29  _direction /= 2.0; // note - so we can do central differences
30 }
31 
32 Real
33 GradParsedFunction::value(Real t, const Point & p)
34 {
35  return (_function_ptr->evaluate<Real>(t, p + _direction) -
36  _function_ptr->evaluate<Real>(t, p - _direction)) /
37  _len;
38 }
RealVectorValue _direction
central difference direction
virtual Real value(Real t, const Point &pt)
Real _len
2*|_direction|
InputParameters validParams< GradParsedFunction >()
GradParsedFunction(const InputParameters &parameters)