13#ifndef CD_LOOKUPTABLE1D_H
14#define CD_LOOKUPTABLE1D_H
24#include <CD_NamespaceHeader.H>
30template <typename T = Real, size_t N = 1, typename I = std::enable_if_t<std::is_floating_point<T>::value>>
34 static_assert(N >= 1,
"LookupTable1D<N> must have N >= 1");
58 template <
size_t M, typename... Ts>
60 slice(const Ts&... a_columns) const noexcept;
66 template <typename... Ts>
68 addData(const Ts&... x) noexcept;
75 addData(const std::array<T, N + 1>& x) noexcept;
85 swap(
size_t a_columnOne,
size_t a_columnTwo) noexcept;
93 scale(const T& a_scale) noexcept;
105 truncate(const T& a_min, const T& a_max,
size_t a_column) noexcept;
128 prepareTable(const
size_t& a_independentVariable, const
size_t& a_numPoints, const LookupTable::Spacing& a_spacing);
144 inline std::array<T, N + 1>
151 inline std::vector<std::array<T, N + 1>>&
158 inline std::vector<std::array<T, N + 1>>&
165 inline const std::vector<std::array<T, N + 1>>&
172 inline const std::vector<std::array<T, N + 1>>&
194 outputRawData(std::ostream& a_ostream = std::cout) const noexcept;
222 std::tuple<LookupTable::Spacing,
size_t, T, T, T>
m_grid;
240 outputData(std::ostream& a_ostream, const std::vector<std::array<T, N + 1>>& a_data) const noexcept;
248 writeToFile(const std::
string& a_file, const std::vector<std::array<T, N + 1>>& a_data) const noexcept;
259#include <CD_NamespaceFooter.H>
Declaration of a lookup table in one independent variable.
Declaration of a table for looking up coefficients etc.
Class for interpolation of f = f(x) data in one independent variable x.
Definition CD_LookupTable1D.H:32
LookupTable::OutOfRangeStrategy m_rangeStrategyLo
Out-of-range strategy on low end.
Definition CD_LookupTable1D.H:212
std::vector< std::array< T, N+1 > > m_rawData
Raw data.
Definition CD_LookupTable1D.H:227
std::vector< std::array< T, N+1 > > m_structuredData
Structured data. This is populated when calling prepareTable.
Definition CD_LookupTable1D.H:232
std::vector< std::array< T, N+1 > > & getStructuredData() noexcept
Access function for structured data.
Definition CD_LookupTable1DImplem.H:247
T interpolate(const T &a_x) const
Interpolation function for specific dependent variable K.
Definition CD_LookupTable1DImplem.H:448
void addData(const Ts &... x) noexcept
Add entry.
Definition CD_LookupTable1DImplem.H:49
bool m_isGood
Check if data can be interpolated.
Definition CD_LookupTable1D.H:207
void swap(size_t a_columnOne, size_t a_columnTwo) noexcept
Utility function for swapping columns.
Definition CD_LookupTable1DImplem.H:65
void setRangeStrategyLo(const LookupTable::OutOfRangeStrategy &a_strategy) noexcept
Set the out-of-range strategy on the low end.
Definition CD_LookupTable1DImplem.H:126
void truncate(const T &a_min, const T &a_max, size_t a_column) noexcept
Utility function for truncating raw data along one of the variables (either dependent or independent)...
Definition CD_LookupTable1DImplem.H:111
size_t getIndexLo(const T &a_x) const
Get the lower index that brackets the input variable between two data points in the structured grid.
Definition CD_LookupTable1DImplem.H:328
LookupTable::OutOfRangeStrategy m_rangeStrategyHi
Out-of-range strategy on high end.
Definition CD_LookupTable1D.H:217
void setRangeStrategyHi(const LookupTable::OutOfRangeStrategy &a_strategy) noexcept
Set the out-of-range strategy on the high end.
Definition CD_LookupTable1DImplem.H:133
virtual ~LookupTable1D() noexcept=default
Destructor (does nothing).
LookupTable1D() noexcept
Default constructor. Creates a table without any entries.
Definition CD_LookupTable1DImplem.H:28
void writeRawData(const std::string &a_file) const noexcept
Dump raw table data to file.
Definition CD_LookupTable1DImplem.H:268
void outputStructuredData(std::ostream &a_ostream=std::cout) const noexcept
Dump structured table data to file.
Definition CD_LookupTable1DImplem.H:289
void reset() noexcept
Reset everything.
Definition CD_LookupTable1DImplem.H:35
void outputRawData(std::ostream &a_ostream=std::cout) const noexcept
Dump raw table data to output stream.
Definition CD_LookupTable1DImplem.H:282
void prepareTable(const size_t &a_independentVariable, const size_t &a_numPoints, const LookupTable::Spacing &a_spacing)
Turn the raw data into uniform data for fast lookup.
Definition CD_LookupTable1DImplem.H:140
void scale(const T &a_scale) noexcept
Utility function which scales one of the columns (either dependent or independent variable)
Definition CD_LookupTable1DImplem.H:94
void writeToFile(const std::string &a_file, const std::vector< std::array< T, N+1 > > &a_data) const noexcept
Utility function for outputting data to a file.
Definition CD_LookupTable1DImplem.H:309
void writeStructuredData(const std::string &a_file) const noexcept
Dump structured table data to file.
Definition CD_LookupTable1DImplem.H:275
LookupTable1D< T, M, I > slice(const Ts &... a_columns) const noexcept
Slice this table, keeping only the user-specified columns.
Definition CD_LookupTable1DImplem.H:456
std::tuple< LookupTable::Spacing, size_t, T, T, T > m_grid
Underlying 1D grid. This is populated when calling prepareTable.
Definition CD_LookupTable1D.H:222
void outputData(std::ostream &a_ostream, const std::vector< std::array< T, N+1 > > &a_data) const noexcept
Utility function for outputting data.
Definition CD_LookupTable1DImplem.H:296
std::vector< std::array< T, N+1 > > & getRawData() noexcept
Access function for raw data.
Definition CD_LookupTable1DImplem.H:240