www.mooseframework.org
SplineFunction.C
Go to the documentation of this file.
1 /****************************************************************/
2 /* DO NOT MODIFY THIS HEADER */
3 /* MOOSE - Multiphysics Object Oriented Simulation Environment */
4 /* */
5 /* (c) 2010 Battelle Energy Alliance, LLC */
6 /* ALL RIGHTS RESERVED */
7 /* */
8 /* Prepared by Battelle Energy Alliance, LLC */
9 /* Under Contract No. DE-AC07-05ID14517 */
10 /* With the U. S. Department of Energy */
11 /* */
12 /* See COPYRIGHT for full restrictions */
13 /****************************************************************/
14 
15 #include "SplineFunction.h"
16 
17 template <>
20 {
22  MooseEnum component("x=0 y=1 z=2", "x");
23  params.addParam<MooseEnum>(
24  "component", component, "The component of the geometry point to interpolate with");
25  params.addRequiredParam<std::vector<Real>>("x", "The abscissa values");
26  params.addRequiredParam<std::vector<Real>>("y", "The ordinate values");
27  params.addParam<Real>(
28  "yp1", 1e30, "The value of the first derivative of the interpolating function at point 1");
29  params.addParam<Real>(
30  "ypn", 1e30, "The value of the first derivative of the interpolating function at point n");
31 
32  return params;
33 }
34 
36  : Function(parameters),
37  _ipol(getParam<std::vector<Real>>("x"),
38  getParam<std::vector<Real>>("y"),
39  getParam<Real>("yp1"),
40  getParam<Real>("ypn")),
41  _component(getParam<MooseEnum>("component"))
42 {
43 }
44 
45 Real
46 SplineFunction::value(Real /*t*/, const Point & p)
47 {
48  return _ipol.sample(p(_component));
49 }
50 
52 SplineFunction::gradient(Real /*t*/, const Point & p)
53 {
54  RealGradient grad(0.0);
55  grad(0) = derivative(p);
56  return grad;
57 }
58 
59 Real
61 {
63 }
64 
65 Real
67 {
69 }
RealVectorValue RealGradient
Definition: Assembly.h:43
Base class for function objects.
Definition: Function.h:46
SplineFunction(const InputParameters &parameters)
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
InputParameters validParams< SplineFunction >()
void addRequiredParam(const std::string &name, const std::string &doc_string)
This method adds a parameter and documentation string to the InputParameters object that will be extr...
SplineInterpolation _ipol
virtual Real secondDerivative(const Point &p)
This is a "smart" enum class intended to replace many of the shortcomings in the C++ enum type It sho...
Definition: MooseEnum.h:37
virtual Real value(Real t, const Point &p) override
Override this to evaluate the scalar function at point (t,x,y,z), by default this returns zero...
virtual RealGradient gradient(Real t, const Point &p) override
Function objects can optionally provide a gradient at a point.
Real sample(Real x) const
This function will take an independent variable input and will return the dependent variable based on...
Real sample2ndDerivative(Real x) const
virtual Real derivative(const Point &p)
void addParam(const std::string &name, const S &value, const std::string &doc_string)
These methods add an option parameter and a documentation string to the InputParameters object...
int _component
Desired component.
InputParameters validParams< Function >()
Definition: Function.C:19
Real sampleDerivative(Real x) const