20 const std::vector<Real> & y,
22 : _x(x), _y(y), _extrap(extrap)
30 if (
_x.size() !=
_y.size())
31 throw std::domain_error(
"Vectors are not the same length");
33 for (
unsigned int i = 0; i + 1 <
_x.size(); ++i)
34 if (
_x[i] >=
_x[i + 1])
36 std::ostringstream oss;
37 oss <<
"x-values are not strictly increasing: x[" << i <<
"]: " <<
_x[i] <<
" x[" << i + 1
38 <<
"]: " <<
_x[i + 1];
39 throw std::domain_error(oss.str());
49 mooseError(
"Trying to evaluate an empty LinearInterpolation");
59 return _y[0] + (x -
_x[0]) / (
_x[1] -
_x[0]) * (
_y[1] -
_y[0]);
62 (x -
_x.back()) / (
_x[
_x.size() - 2] -
_x.back()) * (
_y[
_y.size() - 2] -
_y.back());
72 auto upper = std::upper_bound(
_x.begin(),
_x.end(), x);
73 int i = std::distance(
_x.begin(), upper) - 1;
74 return _y[i] + (
_y[i + 1] -
_y[i]) * (x -
_x[i]) / (
_x[i + 1] -
_x[i]);
77 mooseException(
"Sample point in LinearInterpolation is a NaN.");
80 template Real LinearInterpolation::sample<Real>(
const Real &)
const;
81 template ADReal LinearInterpolation::sample<ADReal>(
const ADReal &)
const;
92 return (
_y[1] -
_y[0]) / (
_x[1] -
_x[0]);
94 return (
_y[
_y.size() - 2] -
_y.back()) / (
_x[
_x.size() - 2] -
_x.back());
104 auto upper = std::upper_bound(
_x.begin(),
_x.end(), x);
105 int i = std::distance(
_x.begin(), upper) - 1;
106 return (
_y[i + 1] -
_y[i]) / (
_x[i + 1] -
_x[i]);
109 mooseException(
"Sample point in LinearInterpolation is a NaN.");
112 template Real LinearInterpolation::sampleDerivative<Real>(
const Real &)
const;
113 template ADReal LinearInterpolation::sampleDerivative<ADReal>(
const ADReal &)
const;
120 for (
unsigned int i = 1; i <
_x.size(); ++i)
121 answer += 0.5 * (
_y[i] +
_y[i - 1]) * (
_x[i] -
_x[i - 1]);
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
DualNumber< Real, Real > ChainedReal
Real integrate()
This function returns the integral of the function.
T sample(const T &x) const
This function will take an independent variable input and will return the dependent variable based on...
unsigned int getSampleSize() const
This function returns the size of the array holding the points, i.e.
T sampleDerivative(const T &x) const
This function will take an independent variable input and will return the derivative of the dependent...
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real