www.mooseframework.org
SplineInterpolationBase.h
Go to the documentation of this file.
1 //* This file is part of the MOOSE framework
2 //* https://www.mooseframework.org
3 //*
4 //* All rights reserved, see COPYRIGHT for full restrictions
5 //* https://github.com/idaholab/moose/blob/master/COPYRIGHT
6 //*
7 //* Licensed under LGPL 2.1, please see LICENSE for details
8 //* https://www.gnu.org/licenses/lgpl-2.1.html
9 
10 #pragma once
11 
12 #include "MooseTypes.h"
13 #include <vector>
14 
16 {
17 public:
19 
20  virtual ~SplineInterpolationBase() = default;
21 
22  Real sample(const std::vector<Real> & x,
23  const std::vector<Real> & y,
24  const std::vector<Real> & y2,
25  Real x_int) const;
26  ADReal sample(const std::vector<Real> & x,
27  const std::vector<Real> & y,
28  const std::vector<Real> & y2,
29  const ADReal & x_int) const;
30 
31  Real sampleDerivative(const std::vector<Real> & x,
32  const std::vector<Real> & y,
33  const std::vector<Real> & y2,
34  Real x_int) const;
35 
36  Real sample2ndDerivative(const std::vector<Real> & x,
37  const std::vector<Real> & y,
38  const std::vector<Real> & y2,
39  Real x_int) const;
40 
41 protected:
45  void spline(const std::vector<Real> & x,
46  const std::vector<Real> & y,
47  std::vector<Real> & y2,
48  Real yp1 = _deriv_bound,
49  Real ypn = _deriv_bound);
50 
51  void findInterval(const std::vector<Real> & x,
52  Real x_int,
53  unsigned int & klo,
54  unsigned int & khi) const;
55 
56  template <typename T>
57  void computeCoeffs(const std::vector<Real> & x,
58  unsigned int klo,
59  unsigned int khi,
60  const T & x_int,
61  Real & h,
62  T & a,
63  T & b) const;
64 
71  template <typename T>
72  T sample(const std::vector<Real> & x,
73  const std::vector<Real> & y,
74  const std::vector<Real> & y2,
75  const T & x_int,
76  unsigned int klo,
77  unsigned int khi) const;
78 
79  static const Real _deriv_bound;
80 };
Real sample2ndDerivative(const std::vector< Real > &x, const std::vector< Real > &y, const std::vector< Real > &y2, Real x_int) const
Real sample(const std::vector< Real > &x, const std::vector< Real > &y, const std::vector< Real > &y2, Real x_int) const
void computeCoeffs(const std::vector< Real > &x, unsigned int klo, unsigned int khi, const T &x_int, Real &h, T &a, T &b) const
Real sampleDerivative(const std::vector< Real > &x, const std::vector< Real > &y, const std::vector< Real > &y2, Real x_int) const
void findInterval(const std::vector< Real > &x, Real x_int, unsigned int &klo, unsigned int &khi) const
virtual ~SplineInterpolationBase()=default
DualReal ADReal
Definition: ADRealForward.h:14
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
void spline(const std::vector< Real > &x, const std::vector< Real > &y, std::vector< Real > &y2, Real yp1=_deriv_bound, Real ypn=_deriv_bound)
This function calculates the second derivatives based on supplied x and y-vectors.