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"
12 
14 
17 {
21  "direction",
22  "The direction in which to take the derivative. This must not be a zero-length vector");
23  return params;
24 }
25 
27  : MooseParsedFunction(parameters), _direction(getParam<RealVectorValue>("direction"))
28 {
29  _len = _direction.norm();
30  if (_len == 0)
31  mooseError("The direction in the GradParsedFunction must have positive length.");
32  _direction /= 2.0; // note - so we can do central differences
33 }
34 
35 Real
36 GradParsedFunction::value(Real t, const Point & p) const
37 {
38  return (_function_ptr->evaluate<Real>(t, p + _direction) -
39  _function_ptr->evaluate<Real>(t, p - _direction)) /
40  _len;
41 }
std::unique_ptr< MooseParsedFunctionWrapper > _function_ptr
auto norm() const -> decltype(std::norm(Real()))
RealVectorValue _direction
central difference direction
virtual Real value(Real t, const Point &pt) const
returns the central difference approx to the derivative of the function, ie (f(t, p + direction) - f(...
void addRequiredParam(const std::string &name, const std::string &doc_string)
static InputParameters validParams()
registerMooseObject("RichardsApp", GradParsedFunction)
Real _len
2*|_direction|
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
static InputParameters validParams()
void mooseError(Args &&... args) const
GradParsedFunction(const InputParameters &parameters)