https://mooseframework.inl.gov
LinearInterpolation.h
Go to the documentation of this file.
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 "Moose.h"
13 #include "MooseTypes.h"
14 
15 #include <vector>
16 #include <string>
17 
22 {
23 public:
24  /* Constructor, Takes two vectors of points for which to apply the fit. One should be of the
25  * independent variable while the other should be of the dependent variable. These values should
26  * correspond to one and other in the same position.
27  */
28  LinearInterpolation(const std::vector<Real> & X,
29  const std::vector<Real> & Y,
30  const bool extrap = false);
31  LinearInterpolation() : _x(std::vector<Real>()), _y(std::vector<Real>()), _extrap(false) {}
32 
33  virtual ~LinearInterpolation() = default;
34 
38  void setData(const std::vector<Real> & X, const std::vector<Real> & Y)
39  {
40  _x = X;
41  _y = Y;
42  errorCheck();
43  }
44 
45  void errorCheck();
46 
51  template <typename T>
52  T sample(const T & x) const;
53 
59  template <typename T>
60  T sampleDerivative(const T & x) const;
61 
66  unsigned int getSampleSize() const;
67 
71  Real integrate();
72 
79  Real integratePartial(Real x1, Real x2) const;
80 
81  Real domain(int i) const;
82  Real range(int i) const;
83 
84 private:
85  std::vector<Real> _x;
86  std::vector<Real> _y;
87 
88  bool _extrap;
89 };
90 
91 // for backwards compatibility
93 
94 // temporary fixes to avoid breaking bison
95 template <typename T>
97 {
98 public:
100 };
std::vector< Real > _x
Real integratePartial(Real x1, Real x2) const
Returns the integral of the function over a specified domain.
This class interpolates values given a set of data pairs and an abscissa.
LinearInterpolation ADLinearInterpolation
Real integrate()
This function returns the integral of the function over the whole domain.
T sample(const T &x) const
This function will take an independent variable input and will return the dependent variable based on...
std::vector< Real > _y
unsigned int getSampleSize() const
This function returns the size of the array holding the points, i.e.
Real range(int i) const
Real domain(int i) const
T sampleDerivative(const T &x) const
This function will take an independent variable input and will return the derivative of the dependent...
void setData(const std::vector< Real > &X, const std::vector< Real > &Y)
Set the x and y values.
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
virtual ~LinearInterpolation()=default