23 const std::vector<Real> & y)
42 if (
_x.size() !=
_y.size())
43 throw std::domain_error(
"MonotoneCubicInterpolation: x and y vectors are not the same length");
47 " points is not enough data for a cubic interpolation");
50 for (
unsigned i = 0; !error && i + 1 <
_x.size(); ++i)
51 if (
_x[i] >=
_x[i + 1])
55 throw std::domain_error(
"x-values are not strictly increasing");
72 return 3. * t * t - 2. * t * t * t;
78 return 6. * t - 6. * t * t;
90 return t * t * t - t * t;
96 return 3. * t * t - 2. * t;
109 Real t = (xhi - x) / h;
117 Real t = (xhi - x) / h;
118 Real tPrime = -1. / h;
126 Real t = (xhi - x) / h;
127 Real tPrime = -1. / h;
135 Real t = (x - xlo) / h;
143 Real t = (x - xlo) / h;
144 Real tPrime = 1. / h;
152 Real t = (x - xlo) / h;
153 Real tPrime = 1. / h;
161 Real t = (xhi - x) / h;
169 Real t = (xhi - x) / h;
170 Real tPrime = -1. / h;
178 Real t = (xhi - x) / h;
179 Real tPrime = -1. / h;
187 Real t = (x - xlo) / h;
195 Real t = (x - xlo) / h;
196 Real tPrime = 1. / h;
204 Real t = (x - xlo) / h;
205 Real tPrime = 1. / h;
216 const Real & x)
const 218 return flo *
h1(xhi, xlo, x) + fhi *
h2(xhi, xlo, x) + dlo *
h3(xhi, xlo, x) +
219 dhi *
h4(xhi, xlo, x);
229 const Real & x)
const 242 const Real & x)
const 251 for (
unsigned int i = 1; i <
_n_knots - 1; ++i)
253 _y[i] * (
_h[i - 1] -
_h[i]) * (
_h[i - 1] +
_h[i])) /
254 (
_h[i - 1] *
_h[i] * (
_h[i - 1] *
_h[i]));
265 _yp[
_n_knots - 1] = (hsecond * ylast * (hsecond + 2 * hlast) +
std::pow(hlast, 2) * ythird -
266 ysecond *
std::pow(hsecond + hlast, 2)) /
267 (hsecond * hlast * (hsecond + hlast));
272 const Real & alpha,
const Real & beta,
const Real & delta, Real & yp_lo, Real & yp_hi)
275 Real alpha_star = alpha * tau;
276 Real beta_star = beta * tau;
277 yp_lo = alpha_star * delta;
278 yp_hi = beta_star * delta;
292 _h[i] =
_x[i + 1] -
_x[i];
332 unsigned int & khi)
const 336 while (khi - klo > 1)
338 unsigned int k = (khi + klo) >> 1;
351 assert(
_x.size() > 0);
353 unsigned int klo, khi;
361 unsigned int klo, khi;
369 unsigned int klo, khi;
377 unsigned int n = xnew.size();
378 std::vector<Real> ynew(n), ypnew(n), yppnew(n);
380 std::ofstream
out(filename.c_str());
381 for (
unsigned int i = 0; i < n; ++i)
383 ynew[i] =
sample(xnew[i]);
386 out << xnew[i] <<
", " << ynew[i] <<
", " << ypnew[i] <<
", " << yppnew[i] <<
"\n";
Real h1Prime(const Real &xhi, const Real &xlo, const Real &x) const
virtual Real sample2ndDerivative(const Real &x) const
This function will take an independent variable input and will return the second derivative of the de...
Real h2Prime(const Real &xhi, const Real &xlo, const Real &x) const
Real h3Prime(const Real &xhi, const Real &xlo, const Real &x) const
virtual unsigned int getSampleSize()
This method returns the length of the independent variable vector.
std::vector< Real > _alpha
Real h3DoublePrime(const Real &xhi, const Real &xlo, const Real &x) const
std::vector< Real > _beta
Real psiPrime(const Real &t) const
Real h4DoublePrime(const Real &xhi, const Real &xlo, const Real &x) const
ADRealEigenVector< T, D, asd > sqrt(const ADRealEigenVector< T, D, asd > &)
virtual void initialize_derivs()
virtual void modify_derivs(const Real &alpha, const Real &beta, const Real &delta, Real &yp_lo, Real &yp_hi)
Real psi(const Real &t) const
virtual Real pPrime(const Real &xhi, const Real &xlo, const Real &fhi, const Real &flo, const Real &dhi, const Real &dlo, const Real &x) const
virtual void setData(const std::vector< Real > &x, const std::vector< Real > &y)
Method generally used when MonotoneCubicInterpolation object was created using the empty constructor...
Real psiDoublePrime(const Real &t) const
Real phiPrime(const Real &t) const
virtual Real sampleDerivative(const Real &x) const
This function will take an independent variable input and will return the derivative of the dependent...
MonotoneCubicInterpolation()
Empty constructor.
unsigned int _internal_knots
Real phi(const Real &t) const
Real h4(const Real &xhi, const Real &xlo, const Real &x) const
Real sign(const Real &x) const
std::vector< Real > _delta
std::string stringify(const T &t)
conversion to string
virtual Real sample(const Real &x) const
This function will take an independent variable input and will return the dependent variable based on...
Real h1DoublePrime(const Real &xhi, const Real &xlo, const Real &x) const
Real h4Prime(const Real &xhi, const Real &xlo, const Real &x) const
Real h2(const Real &xhi, const Real &xlo, const Real &x) const
unsigned int _n_intervals
virtual Real pDoublePrime(const Real &xhi, const Real &xlo, const Real &fhi, const Real &flo, const Real &dhi, const Real &dlo, const Real &x) const
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
virtual void errorCheck()
virtual void dumpCSV(std::string filename, const std::vector< Real > &xnew)
This function takes an array of independent variable values and writes a CSV file with values corresp...
Real h3(const Real &xhi, const Real &xlo, const Real &x) const
virtual void findInterval(const Real &x, unsigned int &klo, unsigned int &khi) const
Real h1(const Real &xhi, const Real &xlo, const Real &x) const
virtual Real p(const Real &xhi, const Real &xlo, const Real &fhi, const Real &flo, const Real &dhi, const Real &dlo, const Real &x) const
Real phiDoublePrime(const Real &t) const
MooseUnits pow(const MooseUnits &, int)
Real h2DoublePrime(const Real &xhi, const Real &xlo, const Real &x) const