https://mooseframework.inl.gov
Loading...
Searching...
No Matches
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{
23public:
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 template <typename T>
80 T integratePartial(const T & x1, const T & x2) const;
81
82 Real domain(int i) const;
83 Real range(int i) const;
84
85private:
86 std::vector<Real> _x;
87 std::vector<Real> _y;
88
89 bool _extrap;
90};
91
92// for backwards compatibility
94
95// temporary fixes to avoid breaking bison
96template <typename T>
LinearInterpolation ADLinearInterpolation
This class interpolates values given a set of data pairs and an abscissa.
virtual ~LinearInterpolation()=default
void setData(const std::vector< Real > &X, const std::vector< Real > &Y)
Set the x and y values.
T sampleDerivative(const T &x) const
This function will take an independent variable input and will return the derivative of the dependent...
T sample(const T &x) const
This function will take an independent variable input and will return the dependent variable based on...
Real integrate()
This function returns the integral of the function over the whole domain.
Real range(int i) const
Real domain(int i) const
std::vector< Real > _x
std::vector< Real > _y
T integratePartial(const T &x1, const T &x2) const
Returns the integral of the function over a specified domain.
unsigned int getSampleSize() const
This function returns the size of the array holding the points, i.e.