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 <vector>
13 #include "libmesh/libmesh_common.h"
14 using libMesh::Real;
15 
17 {
18 public:
20 
21  virtual ~SplineInterpolationBase() = default;
22 
23  Real sample(const std::vector<Real> & x,
24  const std::vector<Real> & y,
25  const std::vector<Real> & y2,
26  Real x_int) const;
27 
28  Real sampleDerivative(const std::vector<Real> & x,
29  const std::vector<Real> & y,
30  const std::vector<Real> & y2,
31  Real x_int) const;
32 
33  Real sample2ndDerivative(const std::vector<Real> & x,
34  const std::vector<Real> & y,
35  const std::vector<Real> & y2,
36  Real x_int) const;
37 
38 protected:
42  void spline(const std::vector<Real> & x,
43  const std::vector<Real> & y,
44  std::vector<Real> & y2,
45  Real yp1 = _deriv_bound,
46  Real ypn = _deriv_bound);
47 
48  void findInterval(const std::vector<Real> & x,
49  Real x_int,
50  unsigned int & klo,
51  unsigned int & khi) const;
52 
53  void computeCoeffs(const std::vector<Real> & x,
54  unsigned int klo,
55  unsigned int khi,
56  Real x_int,
57  Real & h,
58  Real & a,
59  Real & b) const;
60 
67  Real sample(const std::vector<Real> & x,
68  const std::vector<Real> & y,
69  const std::vector<Real> & y2,
70  Real x_int,
71  unsigned int klo,
72  unsigned int khi) const;
73 
74  static const Real _deriv_bound;
75 };
76 
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, Real x_int, Real &h, Real &a, Real &b) const
Real sampleDerivative(const std::vector< Real > &x, const std::vector< Real > &y, const std::vector< Real > &y2, Real x_int) const
static PetscErrorCode Vec x
void findInterval(const std::vector< Real > &x, Real x_int, unsigned int &klo, unsigned int &khi) const
virtual ~SplineInterpolationBase()=default
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.