https://mooseframework.inl.gov
Loading...
Searching...
No Matches
SplineFunction.C
Go to the documentation of this file.
1//* This file is part of the MOOSE framework
2//* https://mooseframework.inl.gov
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{
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
43Real
44SplineFunction::value(Real /*t*/, const Point & p) const
45{
46 return _ipol.sample(p(_component));
47}
48
50SplineFunction::value(const ADReal & /*t*/, const ADPoint & p) const
51{
52 return _ipol.sample(p(_component));
53}
54
55RealGradient
56SplineFunction::gradient(Real /*t*/, const Point & p) const
57{
58 RealGradient grad(0.0);
59 grad(0) = derivative(p);
60 return grad;
61}
62
63Real
64SplineFunction::derivative(const Point & p) const
65{
67}
68
69Real
71{
73}
DualNumber< Real, DNDerivativeType, true > ADReal
registerMooseObject("MooseApp", SplineFunction)
Base class for function objects.
Definition Function.h:30
static InputParameters validParams()
Class constructor.
Definition Function.C:16
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system.
void addParam(const std::string &name, const S &value, const std::string &doc_string)
These methods add an optional parameter and a documentation string to the InputParameters object.
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...
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.
This is a "smart" enum class intended to replace many of the shortcomings in the C++ enum type It sho...
Definition MooseEnum.h:55
Function that uses spline interpolation.
SplineInterpolation _ipol
int _component
Desired component.
virtual Real derivative(const Point &p) const
virtual RealGradient gradient(Real t, const Point &p) const override
Function objects can optionally provide a gradient at a point.
virtual Real secondDerivative(const Point &p) const
SplineFunction(const InputParameters &parameters)
static InputParameters validParams()
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,...
Real sampleDerivative(Real x) const
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