www.mooseframework.org
LinearInterpolation.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 LINEARINTERPOLATION_H
16 #define LINEARINTERPOLATION_H
17 
18 #include <vector>
19 #include <string>
20 
21 #include "Moose.h"
22 
27 {
28 public:
29  /* Constructor, Takes two vectors of points for which to apply the fit. One should be of the
30  * independent variable while the other should be of the dependent variable. These values should
31  * correspond to one and other in the same position.
32  */
33  LinearInterpolation(const std::vector<Real> & X, const std::vector<Real> & Y);
34  LinearInterpolation() : _x(std::vector<Real>()), _y(std::vector<Real>()) {}
35 
36  virtual ~LinearInterpolation() = default;
37 
41  void setData(const std::vector<Real> & X, const std::vector<Real> & Y)
42  {
43  _x = X;
44  _y = Y;
45  errorCheck();
46  }
47 
48  void errorCheck();
49 
54  Real sample(Real x) const;
55 
61  Real sampleDerivative(Real x) const;
62 
67  void dumpSampleFile(std::string base_name,
68  std::string x_label = "X",
69  std::string y_label = "Y",
70  Real xmin = 0,
71  Real xmax = 0,
72  Real ymin = 0,
73  Real ymax = 0);
74 
79  unsigned int getSampleSize();
80 
84  Real integrate();
85 
86  Real domain(int i) const;
87  Real range(int i) const;
88 
89 private:
90  std::vector<Real> _x;
91  std::vector<Real> _y;
92 
93  static int _file_number;
94 };
95 
96 #endif // LINEARINTERPOLATION_H
std::vector< Real > _x
This class interpolates values given a set of data pairs and an abscissa.
unsigned int getSampleSize()
This function returns the size of the array holding the points, i.e.
Real integrate()
This function returns the integral of the function.
std::vector< Real > _y
Real sample(Real x) const
This function will take an independent variable input and will return the dependent variable based on...
static PetscErrorCode Vec x
Real sampleDerivative(Real x) const
This function will take an independent variable input and will return the derivative of the dependent...
Real range(int i) const
void setData(const std::vector< Real > &X, const std::vector< Real > &Y)
Set the x and y values.
void dumpSampleFile(std::string base_name, std::string x_label="X", std::string y_label="Y", Real xmin=0, Real xmax=0, Real ymin=0, Real ymax=0)
This function will dump GNUPLOT input files that can be run to show the data points and function fits...
Real domain(int i) const
virtual ~LinearInterpolation()=default