www.mooseframework.org
Grad2ParsedFunction.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 "Grad2ParsedFunction.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 "
20  "vector. This function returned a finite-difference approx to "
21  "(direction.nabla)^2 function");
22  return params;
23 }
24 
25 Grad2ParsedFunction::Grad2ParsedFunction(const InputParameters & parameters)
26  : MooseParsedFunction(parameters), _direction(getParam<RealVectorValue>("direction"))
27 {
29  if (_len2 == 0)
30  mooseError("The direction in the Grad2ParsedFunction must have positive length.");
31 }
32 
33 Real
34 Grad2ParsedFunction::value(Real t, const Point & p)
35 {
36  return (_function_ptr->evaluate<Real>(t, p + _direction) -
37  2 * _function_ptr->evaluate<Real>(t, p) +
38  _function_ptr->evaluate<Real>(t, p - _direction)) /
39  _len2;
40 }
Grad2ParsedFunction(const InputParameters &parameters)
InputParameters validParams< Grad2ParsedFunction >()
virtual Real value(Real t, const Point &pt)
RealVectorValue _direction
central difference direction
Real _len2
|_direction|^2