Template Class ExplicitCubicSplineInterpolator

Inheritance Relationships

Base Type

Class Documentation

template<typename T, typename MemorySpace>
class ExplicitCubicSplineInterpolator : public pcms::CubicSplineInterpolator<T, MemorySpace>

ExplicitCubicSplineInterpolator class.

This class provides methods for 1d explicit cubic spline interpolation and serves as a base class for higher dimensions and compact cubic spline interpolator implementations.

The 1d explicit cubic spline are evaluated using the following formula: s(x)=C(1,i)+(x-x(i))*C(2,i)+(x-x(i))**2*C(3,i)+(x-x(i))**3*C(4,i) for x(i).le.x.le.x(i+1) where C(1,i), C(2,i), C(3,i), and C(4,i) are the coefficients of the cubic spline.

Performance considerations: The memory cost of coeeficients are:

  • explicit – 4**dimension*(N1*N2*…*Nn)

  • compact – 2**dimension*(N1*N2*…*Nn) Explicit spline representation offers better performance in 1D cases. (Compact representations actually call the explicit spline setup functions.) Compact spline representation provides performance advantages in higher dimensions due to memory efficiency gains that outweigh the modest increase in computational cost.

Public Types

using execution_space = typename MemorySpace::execution_space
using member_type = typename Kokkos::TeamPolicy<execution_space>::member_type

Public Functions

ExplicitCubicSplineInterpolator(Rank1View<T, MemorySpace> x, Rank1View<T, MemorySpace> values, BoundaryCondition ibcxmin, T bcxmin, BoundaryCondition ibcxmax, T bcxmax)

Construct the interpolator object and set up the coefficients.

Parameters:
  • x – input grid points

  • values – values of given grid points

  • ibcxmin – bounday condition flag at x(0)

  • bcxmin – bounday condition data at x(0)

  • ibcxmax – bounday condition flag at x(-1)

  • bcxmax – bounday condition data at x(-1)

ExplicitCubicSplineInterpolator(Rank1View<T, MemorySpace> x, Rank1View<T, MemorySpace> values)

Construct the interpolator object and set up the coefficients with default boundary conditions.

The boundary condition flags are set to 0, which corresponds to not-a-knot boundary condition.

Parameters:
  • x – input grid points

  • values – values of given grid points

virtual void evaluate(Rank1View<T, MemorySpace> xvec, Rank2View<T, MemorySpace> fval) override

Evaluate the function value of cubic spline at given points.

The size of fval should match the size of xvec.

Parameters:
  • xvec – input points where the spline is evaluated

  • fval – output values of the spline at given points

virtual void evaluate(Kokkos::View<LO*, MemorySpace> selector, Rank1View<T, MemorySpace> xvec, Rank2View<T, MemorySpace> fval, T lookup_tol = 4.0e-7) override

Evaluate the cubic spline at given points with selector.

The size of fval should match the size of xvec and the size of selector. The selector array can be used to specify which derivatives to compute. For example, if selector = {1, 1, 0}, then the function value and first derivative will be computed.

Parameters:
  • selector – selector array indicating which derivatives to compute

  • xvec – input points where the spline is evaluated

  • fval – output values of the spline at given points

  • lookup_tol – tolerance for the lookup