19 "Define a bicubic spline function from interpolated data defined by input parameters.");
21 MooseEnum normal_component(
"x=0 y=1 z=2",
"z");
25 "The component of the geometry that is normal to the spline x1/x2 values");
26 params.
addRequiredParam<std::vector<Real>>(
"x1",
"The first independent coordinate.");
27 params.
addRequiredParam<std::vector<Real>>(
"x2",
"The second independent coordinate.");
30 "yx11",
"The values of the derivative wrt x1 on the lower interpolation grid points.");
32 "yx1n",
"The values of the derivative wrt x1 on the upper interpolation grid points.");
34 "yx21",
"The values of the derivative wrt x2 on the lower interpolation grid points.");
36 "yx2n",
"The values of the derivative wrt x2 on the upper interpolation grid points.");
38 "yx1",
"1e30",
"The functional form of the derivative with respect to x1.");
40 "yx2",
"1e30",
"The functional form of the derivative with respect to x2.");
48 _normal_component(getParam<
MooseEnum>(
"normal_component")),
49 _yx1(getFunction(
"yx1")),
50 _yx2(getFunction(
"yx2"))
52 _x1 = getParam<std::vector<Real>>(
"x1");
53 _x2 = getParam<std::vector<Real>>(
"x2");
54 std::vector<Real> yvec = getParam<std::vector<Real>>(
"y");
64 unsigned int m =
_x1.size(), n =
_x2.size(), mn = yvec.size();
66 mooseError(
"The length of the supplied y must be equal to the lengths of x1 and x2 multiplied "
69 std::vector<std::vector<Real>> y(m, std::vector<Real>(n));
71 for (
unsigned int i = 0; i < m; ++i)
72 for (
unsigned int j = 0; j < n; ++j)
76 _yx11.resize(n, 1e30);
77 else if (
_yx11.size() != n)
78 mooseError(
"The length of the vectors holding the first derivatives of y with respect to x1 "
79 "must match the length of x2.");
82 _yx1n.resize(n, 1e30);
83 else if (
_yx1n.size() != n)
84 mooseError(
"The length of the vectors holding the first derivatives of y with respect to x1 "
85 "must match the length of x2.");
88 _yx21.resize(m, 1e30);
89 else if (
_yx21.size() != m)
90 mooseError(
"The length of the vectors holding the first derivatives of y with respect to x2 "
91 "must match the length of x1.");
94 _yx2n.resize(m, 1e30);
95 else if (
_yx2n.size() != m)
96 mooseError(
"The length of the vectors holding the first derivatives of y with respect to x2 "
97 "must match the length of x1.");
125 Real x1_begin =
_x1[0];
127 Real xn_begin =
_x1.back();
153 Real x1_begin =
_x1[0];
155 Real xn_begin =
_x1.back();
166 else if (deriv_var == 2)
170 Real x1_end =
_x2[0];
172 Real xn_end =
_x2.back();
191 RealGradient grad = RealGradient(0, 0, 0);
211 Real x1_begin =
_x1[0];
213 Real xn_begin =
_x1.back();
224 else if (deriv_var == 2)
228 Real x1_end =
_x2[0];
230 Real xn_end =
_x2.back();
registerMooseObject("MooseApp", BicubicSplineFunction)
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application.
Function that uses spline interpolation.
std::vector< Real > _yx21
std::vector< Real > _yx11
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,...
BicubicSplineFunction(const InputParameters ¶meters)
unsigned int _normal_component
std::vector< Real > _yx1n
BicubicSplineInterpolation _ipol
std::vector< Real > _yx2n
static InputParameters validParams()
virtual Real derivative(const Point &p, unsigned int deriv_var) const
virtual Real secondDerivative(const Point &p, unsigned int deriv_var) const
void setData(const std::vector< Real > &x1, const std::vector< Real > &x2, const std::vector< std::vector< Real > > &y, const std::vector< Real > &yx11=std::vector< Real >(), const std::vector< Real > &yx1n=std::vector< Real >(), const std::vector< Real > &yx21=std::vector< Real >(), const std::vector< Real > &yx2n=std::vector< Real >())
Set the x1, x2 and y values, and first derivatives at the edges.
Real sample2ndDerivative(Real x1, Real x2, unsigned int deriv_var, Real yp1=_deriv_bound, Real ypn=_deriv_bound)
Samples second derivative at point (x1, x2)
Real sampleDerivative(Real x1, Real x2, unsigned int deriv_var, Real yp1=_deriv_bound, Real ypn=_deriv_bound)
Samples first derivative at point (x1, x2)
Real sample(Real x1, Real x2, Real yx11=_deriv_bound, Real yx1n=_deriv_bound)
Samples value at point (x1, x2)
Interface for objects that need to use functions.
Base class for function objects.
static InputParameters validParams()
Class constructor.
virtual Real value(Real t, const Point &p) const
Override this to evaluate the scalar function at point (t,x,y,z), by default this returns zero,...
const T & getParam(const std::string &name) const
Retrieve a parameter for the object.
bool isParamValid(const std::string &name) const
Test if the supplied parameter is valid.
This is a "smart" enum class intended to replace many of the shortcomings in the C++ enum type It sho...