www.mooseframework.org
SplineFunction.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 "SplineFunction.h"
11 
13 
16 {
18  params.addClassDescription(
19  "Define a spline function from interpolated data defined by input parameters.");
20  MooseEnum component("x=0 y=1 z=2", "x");
21  params.addParam<MooseEnum>(
22  "component", component, "The component of the geometry point to interpolate with");
23  params.addRequiredParam<std::vector<Real>>("x", "The abscissa values");
24  params.addRequiredParam<std::vector<Real>>("y", "The ordinate values");
25  params.addParam<Real>(
26  "yp1", 1e30, "The value of the first derivative of the interpolating function at point 1");
27  params.addParam<Real>(
28  "ypn", 1e30, "The value of the first derivative of the interpolating function at point n");
29 
30  return params;
31 }
32 
34  : Function(parameters),
35  _ipol(getParam<std::vector<Real>>("x"),
36  getParam<std::vector<Real>>("y"),
37  getParam<Real>("yp1"),
38  getParam<Real>("ypn")),
39  _component(getParam<MooseEnum>("component"))
40 {
41 }
42 
43 Real
44 SplineFunction::value(Real /*t*/, const Point & p) const
45 {
46  return _ipol.sample(p(_component));
47 }
48 
49 ADReal
50 SplineFunction::value(const ADReal & /*t*/, const ADPoint & p) const
51 {
52  return _ipol.sample(p(_component));
53 }
54 
56 SplineFunction::gradient(Real /*t*/, const Point & p) const
57 {
58  RealGradient grad(0.0);
59  grad(0) = derivative(p);
60  return grad;
61 }
62 
63 Real
64 SplineFunction::derivative(const Point & p) const
65 {
67 }
68 
69 Real
70 SplineFunction::secondDerivative(const Point & p) const
71 {
73 }
Real sample(Real x) const
This function will take an independent variable input and will return the dependent variable based on...
Base class for function objects.
Definition: Function.h:37
SplineFunction(const InputParameters &parameters)
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
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 RealGradient gradient(Real t, const Point &p) const override
Function objects can optionally provide a gradient at a point.
virtual Real value(Real t, const Point &p) const override
Override this to evaluate the scalar function at point (t,x,y,z), by default this returns zero...
This is a "smart" enum class intended to replace many of the shortcomings in the C++ enum type It sho...
Definition: MooseEnum.h:31
DualReal ADReal
Definition: ADRealForward.h:14
Real sample2ndDerivative(Real x) const
registerMooseObject("MooseApp", SplineFunction)
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
virtual Real secondDerivative(const Point &p) const
Real sampleDerivative(Real x) const
virtual Real derivative(const Point &p) const
static InputParameters validParams()
void addClassDescription(const std::string &doc_string)
This method adds a description of the class that will be displayed in the input file syntax dump...
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.
static InputParameters validParams()
Class constructor.
Definition: Function.C:15
Function that uses spline interpolation.