www.mooseframework.org
BilinearInterpolation.h
Go to the documentation of this file.
1 //* This file is part of the MOOSE framework
2 //* https://www.mooseframework.org
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 // MOOSE includes
13 #include "ColumnMajorMatrix.h"
15 
16 // C++ includes
17 #include <vector>
18 
38 {
39 public:
46  BilinearInterpolation(const std::vector<Real> & xaxis,
47  const std::vector<Real> & yaxis,
48  const ColumnMajorMatrix & zsurface);
49 
50  virtual ~BilinearInterpolation() = default;
51 
56  Real sample(const Real s1, const Real s2) const override;
57  ADReal sample(const ADReal & s1, const ADReal & s2) const override;
58  ChainedReal sample(const ChainedReal & s1, const ChainedReal & s2) const override;
59 
63  Real sampleDerivative(const Real s1, const Real s2, unsigned int deriv_var) const override;
64  ADReal
65  sampleDerivative(const ADReal & s1, const ADReal & s2, unsigned int deriv_var) const override;
67  const ChainedReal & s2,
68  unsigned int deriv_var) const override;
69 
72  Real s1, Real s2, Real & y, Real & dy_ds1, Real & dy_ds2) const override;
73 
74  void getNeighborIndices(const std::vector<Real> & inArr,
75  Real x,
76  unsigned int & lowerX,
77  unsigned int & upperX) const;
78 
79 private:
81  template <typename T>
82  T sampleInternal(const T & s1, const T & s2) const;
83 
84  template <typename T>
85  T sampleDerivativeInternal(const T s1, const T s2, const unsigned int deriv_var) const;
86 
88  static int _file_number;
89 };
This class applies the Least Squares algorithm to a set of points to provide a smooth curve for sampl...
DualNumber< Real, Real > ChainedReal
Definition: ChainedReal.h:30
virtual void sampleValueAndDerivatives(Real, Real, Real &, Real &, Real &) const
Samples value and first derivatives at point (x1, x2) Use this function for speed when computing both...
BilinearInterpolation(const std::vector< Real > &xaxis, const std::vector< Real > &yaxis, const ColumnMajorMatrix &zsurface)
Constructor, Takes two vectors of points for which to apply the fit.
void sampleValueAndDerivatives(Real s1, Real s2, Real &y, Real &dy_ds1, Real &dy_ds2) const override
Samples value and first derivatives at point (x1, x2) Use this function for speed when computing both...
ColumnMajorMatrix _z_surface
Real sampleDerivative(const Real s1, const Real s2, unsigned int deriv_var) const override
Samples first derivative at point (s1, s2)
virtual ~BilinearInterpolation()=default
DualReal ADReal
Definition: ADRealForward.h:14
T sampleDerivativeInternal(const T s1, const T s2, const unsigned int deriv_var) const
T sampleInternal(const T &s1, const T &s2) const
sampleInternal only used by BilinearInterpolation, hence made private
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
Real sample(const Real s1, const Real s2) const override
This function will take an independent variable input and will return the dependent variable based on...
void getNeighborIndices(const std::vector< Real > &inArr, Real x, unsigned int &lowerX, unsigned int &upperX) const
This class interpolates tabulated data with a Bidimension function (either bicubic or bilinear)...