https://mooseframework.inl.gov
MultiDimensionalInterpolation.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 #include "ADReal.h"
15 #include "MultiIndex.h"
16 #include <vector>
17 #include <string>
18 
22 template <typename T>
24 {
25 public:
30  MultiDimensionalInterpolationTempl(const std::vector<std::vector<Real>> & base_points,
31  const MultiIndex<Real> & data);
33 
34  virtual ~MultiDimensionalInterpolationTempl() = default;
35 
37  unsigned int dim() const { return _original_dim; }
38 
40  void setData(const std::vector<std::vector<Real>> & base_points, const MultiIndex<Real> & data);
41 
48  void linearSearch(std::vector<T> & values, MultiIndex<Real>::size_type & indices) const;
49 
55  T multiLinearInterpolation(const std::vector<T> & x) const;
56 
57 protected:
59  void errorCheck();
60 
65  unsigned int linearSearchHelper(T & x, const std::vector<Real> & vector) const;
66 
68  unsigned int _original_dim;
69 
71  std::vector<bool> _degenerate_index;
72 
79 
80 private:
81  std::vector<std::vector<Real>> _base_points;
83  bool _setup_complete = false;
84 };
85 
unsigned int linearSearchHelper(T &x, const std::vector< Real > &vector) const
linear search helper for a single std::vector; note that argument is non-const to handle smaller/larg...
T multiLinearInterpolation(const std::vector< T > &x) const
This function will take an independent variable input and will return the dependent variable based on...
void linearSearch(std::vector< T > &values, MultiIndex< Real >::size_type &indices) const
linearSearch finds the indices i_k of the base point such that base_point[d][i_k] <= values[d] < base...
MultiDimensionalInterpolationTempl< ADReal > DualMultiDimensionalInterpolation
virtual ~MultiDimensionalInterpolationTempl()=default
void setData(const std::vector< std::vector< Real >> &base_points, const MultiIndex< Real > &data)
sets data but also fixes degenerate dimensions in data
std::vector< std::vector< Real > > _base_points
std::vector< bool > _degenerate_index
this variable keeps track on which dimension is degenerate and was removed
DualMultiDimensionalInterpolation ADMultiDimensionalInterpolation
unsigned int dim() const
returns the dimensionality of this interpolation object
unsigned int _original_dim
original dimension is to allow checks on user inputs for cases where arrays are sliced ...
This class interpolates multi-dimensional data sets.
MultiDimensionalInterpolationTempl< Real > MultiDimensionalInterpolation
bool _degenerate_interpolation
if all dimensions have size one then there is only one value to return this corner case should be sup...
void errorCheck()
checks consistency of the data