chombo-discharge
Loading...
Searching...
No Matches
CD_LookupTable1D.H
Go to the documentation of this file.
1/* chombo-discharge
2 * Copyright © 2021 SINTEF Energy Research.
3 * Please refer to Copyright.txt and LICENSE in the chombo-discharge root directory.
4 */
5
12#ifndef CD_LookupTable1D_H
13#define CD_LookupTable1D_H
14
15// Std includes
16#include <iostream>
17#include <vector>
18#include <array>
19#include <type_traits>
20
21// Our includes
22#include <CD_LookupTable.H>
23#include <CD_NamespaceHeader.H>
24
31{
32public:
33 static_assert(N >= 1, "LookupTable1D<N> must have N >= 1");
34
38 LookupTable1D() noexcept;
39
44
48 inline void
50
56 template <size_t M, typename... Ts>
57 LookupTable1D<T, M, I>
59
65 inline void
67
72 inline void
73 addData(const std::array<T, N + 1>& x) noexcept;
74
82 inline void
84
89 template <size_t K>
90 inline void
92
100 inline void
102
107 inline void
108 setRangeStrategyLo(const LookupTable::OutOfRangeStrategy& a_strategy) noexcept;
109
114 inline void
115 setRangeStrategyHi(const LookupTable::OutOfRangeStrategy& a_strategy) noexcept;
116
123 inline void
124 prepareTable(const size_t& a_independentVariable, const size_t& a_numPoints, const LookupTable::Spacing& a_spacing);
125
130 template <size_t K>
131 inline T
133
138 inline std::array<T, N + 1>
140
145 inline std::vector<std::array<T, N + 1>>&
147
152 inline std::vector<std::array<T, N + 1>>&
154
159 inline const std::vector<std::array<T, N + 1>>&
161
166 inline const std::vector<std::array<T, N + 1>>&
168
173 inline void
175
180 inline void
182
187 inline void
189
194 inline void
196
202
206 LookupTable::OutOfRangeStrategy m_rangeStrategyLo;
207
211 LookupTable::OutOfRangeStrategy m_rangeStrategyHi;
212
216 std::tuple<LookupTable::Spacing, size_t, T, T, T> m_grid;
217
222
227
233 inline void
235
241 inline void
243
248 inline size_t
250};
251
252#include <CD_NamespaceFooter.H>
253
254#include <CD_LookupTable1DImplem.H>
255
256#endif
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:31
LookupTable::OutOfRangeStrategy m_rangeStrategyLo
Out-of-range strategy on low end.
Definition CD_LookupTable1D.H:206
std::vector< std::array< T, N+1 > > m_rawData
Raw data.
Definition CD_LookupTable1D.H:221
std::vector< std::array< T, N+1 > > m_structuredData
Structured data. This is populated when calling prepareTable.
Definition CD_LookupTable1D.H:226
std::vector< std::array< T, N+1 > > & getStructuredData() noexcept
Access function for structured data.
Definition CD_LookupTable1DImplem.H:246
T interpolate(const T &a_x) const
Interpolation function for specific dependent variable K.
Definition CD_LookupTable1DImplem.H:447
void addData(const Ts &... x) noexcept
Add entry.
Definition CD_LookupTable1DImplem.H:48
bool m_isGood
Check if data can be interpolated.
Definition CD_LookupTable1D.H:201
void setRangeStrategyLo(const LookupTable::OutOfRangeStrategy &a_strategy) noexcept
Set the out-of-range strategy on the low end.
Definition CD_LookupTable1DImplem.H:125
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:327
void swap(const size_t a_columnOne, const size_t a_columnTwo) noexcept
Utility function for swapping columns.
Definition CD_LookupTable1DImplem.H:64
LookupTable::OutOfRangeStrategy m_rangeStrategyHi
Out-of-range strategy on high end.
Definition CD_LookupTable1D.H:211
void truncate(const T &a_min, const T &a_max, const size_t a_column) noexcept
Utility function for truncating raw data along one of the variables (either dependent or independent)...
Definition CD_LookupTable1DImplem.H:110
void setRangeStrategyHi(const LookupTable::OutOfRangeStrategy &a_strategy) noexcept
Set the out-of-range strategy on the high end.
Definition CD_LookupTable1DImplem.H:132
virtual ~LookupTable1D() noexcept=default
Destructor (does nothing).
LookupTable1D() noexcept
Default constructor. Creates a table without any entries.
Definition CD_LookupTable1DImplem.H:27
void writeRawData(const std::string &a_file) const noexcept
Dump raw table data to file.
Definition CD_LookupTable1DImplem.H:267
void outputStructuredData(std::ostream &a_ostream=std::cout) const noexcept
Dump structured table data to file.
Definition CD_LookupTable1DImplem.H:288
void reset() noexcept
Reset everything.
Definition CD_LookupTable1DImplem.H:34
void outputRawData(std::ostream &a_ostream=std::cout) const noexcept
Dump raw table data to output stream.
Definition CD_LookupTable1DImplem.H:281
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:139
void scale(const T &a_scale) noexcept
Utility function which scales one of the columns (either dependent or independent variable)
Definition CD_LookupTable1DImplem.H:93
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:308
void writeStructuredData(const std::string &a_file) const noexcept
Dump structured table data to file.
Definition CD_LookupTable1DImplem.H:274
LookupTable1D< T, M, I > slice(const Ts &... a_columns) const noexcept
Slice this table, keeping only the user-specified columns.
Definition CD_LookupTable1DImplem.H:455
std::tuple< LookupTable::Spacing, size_t, T, T, T > m_grid
Underlying 1D grid. This is populated when calling prepareTable.
Definition CD_LookupTable1D.H:216
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:295
std::vector< std::array< T, N+1 > > & getRawData() noexcept
Access function for raw data.
Definition CD_LookupTable1DImplem.H:239
Base class for a tracer particle solver. This solver can advance particles in a pre-defined velocity ...
Definition CD_TracerParticleSolver.H:37