Line data Source code
1 : //* This file is part of the MOOSE framework
2 : //* https://mooseframework.inl.gov
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 :
15 : class SplineInterpolationBase
16 : {
17 : public:
18 : SplineInterpolationBase();
19 :
20 326 : 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:
42 : /**
43 : * This function calculates the second derivatives based on supplied x and y-vectors
44 : */
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 :
65 : /**
66 : * Sample value at point x_int given the indices of the vector of
67 : * dependent values that bound the point. This method is useful
68 : * in bicubic spline interpolation, where several spline evaluations
69 : * are needed to sample from a 2D point.
70 : */
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 : };
|