This class interpolates tabulated data with a bicubic function. More...
#include <BicubicInterpolation.h>
Public Member Functions | |
BicubicInterpolation (const std::vector< Real > &x1, const std::vector< Real > &x2, const std::vector< std::vector< Real >> &y) | |
virtual | ~BicubicInterpolation ()=default |
void | errorCheck () |
Sanity checks on input data. More... | |
Real | sample (const Real x1, const Real x2) const override |
Samples value at point (x1, x2) More... | |
ADReal | sample (const ADReal &x1, const ADReal &x2) const override |
ChainedReal | sample (const ChainedReal &x1, const ChainedReal &x2) const override |
virtual void | sampleValueAndDerivatives (Real x1, Real x2, Real &y, Real &dy1, Real &dy2) const override |
Samples value and first derivatives at point (x1, x2) Use this function for speed when computing both value and derivatives, as it minimizes the amount of time spent locating the point in the tabulated data. More... | |
virtual void | sampleValueAndDerivatives (const ADReal &x1, const ADReal &x2, ADReal &y, ADReal &dy1, ADReal &dy2) const override |
virtual void | sampleValueAndDerivatives (const ChainedReal &x1, const ChainedReal &x2, ChainedReal &y, ChainedReal &dy1, ChainedReal &dy2) const override |
Real | sampleDerivative (Real x1, Real x2, unsigned int deriv_var) const override |
Samples first derivative at point (x1, x2) More... | |
Real | sample2ndDerivative (Real x1, Real x2, unsigned int deriv_var) const override |
Samples second derivative at point (x1, x2) More... | |
void | precomputeCoefficients () |
Precompute all of the coefficients for the bicubic interpolation to avoid calculating them repeatedly. More... | |
virtual void | sampleValueAndDerivatives (Real, Real, Real &, Real &, Real &) const |
Samples value and first derivatives at point (x1, x2) Use this function for speed when computing both value and derivatives, as it minimizes the amount of time spent locating the point in the tabulated data. More... | |
virtual void | sampleValueAndDerivatives (const ADReal &, const ADReal &, ADReal &, ADReal &, ADReal &) const |
Samples value and first derivatives at point (x1, x2) Use this function for speed when computing both value and derivatives, as it minimizes the amount of time spent locating the point in the tabulated data. More... | |
virtual void | sampleValueAndDerivatives (const ChainedReal &, const ChainedReal &, ChainedReal &, ChainedReal &, ChainedReal &) const |
Samples value and first derivatives at point (x1, x2) Use this function for speed when computing both value and derivatives, as it minimizes the amount of time spent locating the point in the tabulated data. More... | |
virtual Real | sampleDerivative (const Real, const Real, unsigned int) const |
Samples first derivative at point (x1, x2) More... | |
virtual ADReal | sampleDerivative (const ADReal &, const ADReal &, unsigned int) const |
Samples first derivative at point (x1, x2) More... | |
virtual ChainedReal | sampleDerivative (const ChainedReal &, const ChainedReal &, unsigned int) const |
Samples first derivative at point (x1, x2) More... | |
virtual ADReal | sampleDerivative (const ADReal &, const ADReal &, unsigned int) const |
virtual ChainedReal | sampleDerivative (const ChainedReal &, const ChainedReal &, unsigned int) const |
Public Attributes | |
std::vector< Real > | _x1 |
Independent values in the x1 direction. More... | |
std::vector< Real > | _x2 |
Independent values in the x2 direction. More... | |
Protected Member Functions | |
template<typename T > | |
void | findInterval (const std::vector< Real > &x, const T &xi, unsigned int &klo, unsigned int &khi, T &xs) const |
Find the indices of the dependent values axis which bracket the point xi. More... | |
template<typename T > | |
T | sampleInternal (const T &x1, const T &x2) const |
template<typename T > | |
void | sampleValueAndDerivativesInternal (T x1, T x2, T &y, T &dy1, T &dy2) const |
void | tableDerivatives (std::vector< std::vector< Real >> &dy_dx1, std::vector< std::vector< Real >> &dy_dx2, std::vector< std::vector< Real >> &d2y_dx1x2) |
Provides the values of the first derivatives in each direction at all points in the table of data, as well as the mixed second derivative. More... | |
Protected Attributes | |
std::vector< std::vector< Real > > | _y |
The dependent values at (x1, x2) points. More... | |
std::vector< std::vector< std::vector< std::vector< Real > > > > | _bicubic_coeffs |
Matrix of precomputed coefficients There are four coefficients in each direction at each dependent value. More... | |
const std::vector< std::vector< int > > | _wt |
Matrix used to calculate bicubic interpolation coefficients (from Numerical Recipes) More... | |
This class interpolates tabulated data with a bicubic function.
In order to minimize the computational expense of each sample, the coefficients at each point in the tabulated data are computed once in advance, and then accessed during the interpolation.
As a result, this bicubic interpolation can be much faster than the bicubic spline interpolation method in BicubicSplineInterpolation.
Adapted from Numerical Recipes in C (section 3.6). The terminology used is consistent with that used in Numerical Recipes, where moving over a column corresponds to moving over the x1 coord. Likewise, moving over a row means moving over the x2 coord.
Definition at line 29 of file BicubicInterpolation.h.
BicubicInterpolation::BicubicInterpolation | ( | const std::vector< Real > & | x1, |
const std::vector< Real > & | x2, | ||
const std::vector< std::vector< Real >> & | y | ||
) |
Definition at line 17 of file BicubicInterpolation.C.
|
virtualdefault |
void BicubicInterpolation::errorCheck | ( | ) |
Sanity checks on input data.
Definition at line 425 of file BicubicInterpolation.C.
Referenced by BicubicInterpolation().
|
protected |
Find the indices of the dependent values axis which bracket the point xi.
Definition at line 387 of file BicubicInterpolation.C.
Referenced by sample2ndDerivative(), sampleDerivative(), sampleInternal(), and sampleValueAndDerivativesInternal().
void BicubicInterpolation::precomputeCoefficients | ( | ) |
Precompute all of the coefficients for the bicubic interpolation to avoid calculating them repeatedly.
Definition at line 256 of file BicubicInterpolation.C.
Referenced by BicubicInterpolation().
Samples value at point (x1, x2)
Implements BidimensionalInterpolation.
Definition at line 44 of file BicubicInterpolation.C.
Referenced by sampleInternal().
Implements BidimensionalInterpolation.
Definition at line 50 of file BicubicInterpolation.C.
|
overridevirtual |
Implements BidimensionalInterpolation.
Definition at line 56 of file BicubicInterpolation.C.
|
overridevirtual |
Samples second derivative at point (x1, x2)
Reimplemented from BidimensionalInterpolation.
Definition at line 128 of file BicubicInterpolation.C.
|
inlinevirtualinherited |
Reimplemented in BilinearInterpolation.
Definition at line 57 of file BidimensionalInterpolation.h.
|
inlinevirtualinherited |
Reimplemented in BilinearInterpolation.
Definition at line 62 of file BidimensionalInterpolation.h.
|
inline |
Samples first derivative at point (x1, x2)
Definition at line 52 of file BidimensionalInterpolation.h.
|
inline |
Samples first derivative at point (x1, x2)
Definition at line 62 of file BidimensionalInterpolation.h.
|
inline |
Samples first derivative at point (x1, x2)
Definition at line 57 of file BidimensionalInterpolation.h.
Samples first derivative at point (x1, x2)
Reimplemented from BidimensionalInterpolation.
Definition at line 79 of file BicubicInterpolation.C.
|
protected |
Definition at line 63 of file BicubicInterpolation.C.
Referenced by sample().
|
inline |
Samples value and first derivatives at point (x1, x2) Use this function for speed when computing both value and derivatives, as it minimizes the amount of time spent locating the point in the tabulated data.
Definition at line 99 of file BidimensionalInterpolation.h.
|
inline |
Samples value and first derivatives at point (x1, x2) Use this function for speed when computing both value and derivatives, as it minimizes the amount of time spent locating the point in the tabulated data.
Definition at line 90 of file BidimensionalInterpolation.h.
|
inline |
Samples value and first derivatives at point (x1, x2) Use this function for speed when computing both value and derivatives, as it minimizes the amount of time spent locating the point in the tabulated data.
Definition at line 84 of file BidimensionalInterpolation.h.
|
overridevirtual |
Samples value and first derivatives at point (x1, x2) Use this function for speed when computing both value and derivatives, as it minimizes the amount of time spent locating the point in the tabulated data.
Reimplemented from BidimensionalInterpolation.
Definition at line 196 of file BicubicInterpolation.C.
|
overridevirtual |
Reimplemented from BidimensionalInterpolation.
Definition at line 203 of file BicubicInterpolation.C.
|
overridevirtual |
Reimplemented from BidimensionalInterpolation.
Definition at line 209 of file BicubicInterpolation.C.
|
protected |
Definition at line 220 of file BicubicInterpolation.C.
Referenced by sampleValueAndDerivatives().
|
protected |
Provides the values of the first derivatives in each direction at all points in the table of data, as well as the mixed second derivative.
This is implemented using finite differencing, but could be supplied through other means (such as by sampling with cubic splines)
Definition at line 314 of file BicubicInterpolation.C.
Referenced by precomputeCoefficients().
|
protected |
Matrix of precomputed coefficients There are four coefficients in each direction at each dependent value.
Definition at line 116 of file BicubicInterpolation.h.
Referenced by BicubicInterpolation(), precomputeCoefficients(), sample2ndDerivative(), sampleDerivative(), sampleInternal(), and sampleValueAndDerivativesInternal().
|
protected |
Matrix used to calculate bicubic interpolation coefficients (from Numerical Recipes)
Definition at line 120 of file BicubicInterpolation.h.
Referenced by precomputeCoefficients().
|
inherited |
Independent values in the x1 direction.
Definition at line 37 of file BidimensionalInterpolation.h.
Referenced by BicubicInterpolation(), errorCheck(), precomputeCoefficients(), sample2ndDerivative(), sampleDerivative(), BilinearInterpolation::sampleDerivativeInternal(), BilinearInterpolation::sampleInternal(), sampleInternal(), sampleValueAndDerivativesInternal(), and tableDerivatives().
|
inherited |
Independent values in the x2 direction.
Definition at line 39 of file BidimensionalInterpolation.h.
Referenced by BicubicInterpolation(), errorCheck(), precomputeCoefficients(), sample2ndDerivative(), sampleDerivative(), BilinearInterpolation::sampleDerivativeInternal(), BilinearInterpolation::sampleInternal(), sampleInternal(), sampleValueAndDerivativesInternal(), and tableDerivatives().
|
protected |
The dependent values at (x1, x2) points.
Definition at line 112 of file BicubicInterpolation.h.
Referenced by errorCheck(), precomputeCoefficients(), and tableDerivatives().