https://mooseframework.inl.gov
Loading...
Searching...
No Matches
SplineInterpolation.C
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#include "SplineInterpolation.h"
11
12// MOOSE includes
13#include "MooseError.h"
14
15// C++ includes
16#include <fstream>
17
19
21
22SplineInterpolation::SplineInterpolation(const std::vector<Real> & x,
23 const std::vector<Real> & y,
24 Real yp1 /* = _deriv_bound*/,
25 Real ypn /* = _deriv_bound*/)
26 : SplineInterpolationBase(), _x(x), _y(y), _yp1(yp1), _ypn(ypn)
27{
28 errorCheck();
29 solve();
30}
31
32void
33SplineInterpolation::setData(const std::vector<Real> & x,
34 const std::vector<Real> & y,
35 Real yp1 /* = _deriv_bound*/,
36 Real ypn /* = _deriv_bound*/)
37{
38 _x = x;
39 _y = y;
40 _yp1 = yp1;
41 _ypn = ypn;
42 errorCheck();
43 solve();
44}
45
46void
48{
49 if (_x.size() != _y.size())
50 mooseError("SplineInterpolation: vectors are not the same length");
51
52 bool error = false;
53 for (unsigned i = 0; !error && i + 1 < _x.size(); ++i)
54 if (_x[i] >= _x[i + 1])
55 error = true;
56
57 if (error)
58 mooseError("x-values are not strictly increasing");
59}
60
61void
66
67Real
72
78
79Real
84
85Real
90
91Real
93{
94 return _x[i];
95}
96
97Real
99{
100 return _y[i];
101}
102
103unsigned int
105{
106 return _x.size();
107}
DualNumber< Real, DNDerivativeType, true > ADReal
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application.
Definition MooseError.h:311
Real sampleDerivative(const std::vector< Real > &x, const std::vector< Real > &y, const std::vector< Real > &y2, Real x_int) const
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 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.
Real _yp1
boundary conditions
std::vector< Real > _y2
Second derivatives.
Real domain(int i) const
Real sampleDerivative(Real x) const
Real sample(Real x) const
This function will take an independent variable input and will return the dependent variable based on...
std::vector< Real > _x
void setData(const std::vector< Real > &x, const std::vector< Real > &y, Real yp1=_deriv_bound, Real ypn=_deriv_bound)
Set the x-, y- values and first derivatives.
Real sample2ndDerivative(Real x) const
std::vector< Real > _y
unsigned int getSampleSize()
This function returns the size of the array holding the points, i.e.
Real range(int i) const