www.mooseframework.org
MonotoneCubicInterpolation.h
Go to the documentation of this file.
1 /****************************************************************/
2 /* DO NOT MODIFY THIS HEADER */
3 /* MOOSE - Multiphysics Object Oriented Simulation Environment */
4 /* */
5 /* (c) 2010 Battelle Energy Alliance, LLC */
6 /* ALL RIGHTS RESERVED */
7 /* */
8 /* Prepared by Battelle Energy Alliance, LLC */
9 /* Under Contract No. DE-AC07-05ID14517 */
10 /* With the U. S. Department of Energy */
11 /* */
12 /* See COPYRIGHT for full restrictions */
13 /****************************************************************/
14 
15 #ifndef MONOTONECUBICINTERPOLATION_H
16 #define MONOTONECUBICINTERPOLATION_H
17 
18 #include <vector>
19 
20 #include "libmesh/libmesh_common.h"
21 
22 using libMesh::Real;
23 
32 {
33 public:
38 
45  MonotoneCubicInterpolation(const std::vector<Real> & x, const std::vector<Real> & y);
46 
47  virtual ~MonotoneCubicInterpolation() = default;
48 
56  virtual void setData(const std::vector<Real> & x, const std::vector<Real> & y);
57 
62  virtual Real sample(const Real & x) const;
63 
69  virtual Real sampleDerivative(const Real & x) const;
70 
76  virtual Real sample2ndDerivative(const Real & x) const;
77 
83  virtual void dumpCSV(std::string filename, const std::vector<Real> & xnew);
84 
88  virtual unsigned int getSampleSize();
89 
90 protected:
91  // Error check routines run during initialization
92  virtual void errorCheck();
93  Real sign(const Real & x) const;
94 
95  // Building blocks of Hermite polynomials
96  Real phi(const Real & t) const;
97  Real psi(const Real & t) const;
98  Real phiPrime(const Real & t) const;
99  Real psiPrime(const Real & t) const;
100  Real phiDoublePrime(const Real & t) const;
101  Real psiDoublePrime(const Real & t) const;
102 
103  // Cubic Hermite polynomials
104  Real h1(const Real & xhi, const Real & xlo, const Real & x) const;
105  Real h2(const Real & xhi, const Real & xlo, const Real & x) const;
106  Real h3(const Real & xhi, const Real & xlo, const Real & x) const;
107  Real h4(const Real & xhi, const Real & xlo, const Real & x) const;
108  Real h1Prime(const Real & xhi, const Real & xlo, const Real & x) const;
109  Real h2Prime(const Real & xhi, const Real & xlo, const Real & x) const;
110  Real h3Prime(const Real & xhi, const Real & xlo, const Real & x) const;
111  Real h4Prime(const Real & xhi, const Real & xlo, const Real & x) const;
112  Real h1DoublePrime(const Real & xhi, const Real & xlo, const Real & x) const;
113  Real h2DoublePrime(const Real & xhi, const Real & xlo, const Real & x) const;
114  Real h3DoublePrime(const Real & xhi, const Real & xlo, const Real & x) const;
115  Real h4DoublePrime(const Real & xhi, const Real & xlo, const Real & x) const;
116 
117  // Interpolating cubic polynomial and derivatives
118  virtual Real p(const Real & xhi,
119  const Real & xlo,
120  const Real & fhi,
121  const Real & flo,
122  const Real & dhi,
123  const Real & dlo,
124  const Real & x) const;
125  virtual Real pPrime(const Real & xhi,
126  const Real & xlo,
127  const Real & fhi,
128  const Real & flo,
129  const Real & dhi,
130  const Real & dlo,
131  const Real & x) const;
132  virtual Real pDoublePrime(const Real & xhi,
133  const Real & xlo,
134  const Real & fhi,
135  const Real & flo,
136  const Real & dhi,
137  const Real & dlo,
138  const Real & x) const;
139 
140  // Algorithm routines
141  virtual void initialize_derivs();
142  virtual void modify_derivs(
143  const Real & alpha, const Real & beta, const Real & delta, Real & yp_lo, Real & yp_hi);
144  virtual void solve();
145  virtual void findInterval(const Real & x, unsigned int & klo, unsigned int & khi) const;
146 
147  std::vector<Real> _x;
148  std::vector<Real> _y;
149  std::vector<Real> _h;
150  std::vector<Real> _yp;
151  std::vector<Real> _delta;
152  std::vector<Real> _alpha;
153  std::vector<Real> _beta;
154 
155  unsigned int _n_knots;
156  unsigned int _n_intervals;
157  unsigned int _internal_knots;
158 };
159 
160 #endif
Real psiPrime(const Real &t) const
Real h2(const Real &xhi, const Real &xlo, const Real &x) const
Real phiPrime(const Real &t) const
virtual unsigned int getSampleSize()
This method returns the length of the independent variable vector.
Real h2DoublePrime(const Real &xhi, const Real &xlo, const Real &x) const
Real h3(const Real &xhi, const Real &xlo, const Real &x) const
Real phi(const Real &t) const
virtual Real pPrime(const Real &xhi, const Real &xlo, const Real &fhi, const Real &flo, const Real &dhi, const Real &dlo, const Real &x) const
This class interpolates values given a set of data pairs and an abscissa.
static PetscErrorCode Vec x
Real psi(const Real &t) const
virtual void modify_derivs(const Real &alpha, const Real &beta, const Real &delta, Real &yp_lo, Real &yp_hi)
virtual Real sample2ndDerivative(const Real &x) const
This function will take an independent variable input and will return the second derivative of the de...
virtual void setData(const std::vector< Real > &x, const std::vector< Real > &y)
Method generally used when MonotoneCubicInterpolation object was created using the empty constructor...
Real h1DoublePrime(const Real &xhi, const Real &xlo, const Real &x) const
Real h1(const Real &xhi, const Real &xlo, const Real &x) const
MonotoneCubicInterpolation()
Empty constructor.
Real h4(const Real &xhi, const Real &xlo, const Real &x) const
virtual void findInterval(const Real &x, unsigned int &klo, unsigned int &khi) const
virtual ~MonotoneCubicInterpolation()=default
Real phiDoublePrime(const Real &t) const
Real h4DoublePrime(const Real &xhi, const Real &xlo, const Real &x) const
Real h1Prime(const Real &xhi, const Real &xlo, const Real &x) const
virtual Real sampleDerivative(const Real &x) const
This function will take an independent variable input and will return the derivative of the dependent...
virtual Real sample(const Real &x) const
This function will take an independent variable input and will return the dependent variable based on...
virtual Real pDoublePrime(const Real &xhi, const Real &xlo, const Real &fhi, const Real &flo, const Real &dhi, const Real &dlo, const Real &x) const
virtual void dumpCSV(std::string filename, const std::vector< Real > &xnew)
This function takes an array of independent variable values and writes a CSV file with values corresp...
Real h3DoublePrime(const Real &xhi, const Real &xlo, const Real &x) const
virtual Real p(const Real &xhi, const Real &xlo, const Real &fhi, const Real &flo, const Real &dhi, const Real &dlo, const Real &x) const
Real h4Prime(const Real &xhi, const Real &xlo, const Real &x) const
Real h3Prime(const Real &xhi, const Real &xlo, const Real &x) const
Real psiDoublePrime(const Real &t) const
Real sign(const Real &x) const
Real h2Prime(const Real &xhi, const Real &xlo, const Real &x) const