rizer.cantera_ext
C++ Cantera 1-D plasma extension (custom Domain1D models and solvers)
Loading...
Searching...
No Matches
TableLookup.h
Go to the documentation of this file.
1
9
10#ifndef RIZER_TABLE_LOOKUP_H
11#define RIZER_TABLE_LOOKUP_H
12
13#include "numeric/Format.h"
16
17#include <string>
18
19namespace rizer
20{
21
30 [[noreturn]] inline void throwOutsideTable(const PropertyTable &table, double x,
31 const char *procedure,
32 const std::string &what, const char *unit,
33 const char *remedy)
34 {
35 throw TrialStateError(
36 procedure, what + " is evaluated at " + significant(x) + " " + unit +
37 ", outside its table [" + significant(table.first()) + ", " +
38 significant(table.last()) + "] " + unit + ". " + remedy);
39 }
40
50 inline double evalAtState(const PropertyTable &table, double x,
51 const char *procedure, const char *what,
52 const char *unit, const char *remedy)
53 {
54 if (!table.covers(x))
55 {
56 throwOutsideTable(table, x, procedure, what, unit, remedy);
57 }
58 return table.eval(x);
59 }
60
61} // namespace rizer
62
63#endif // RIZER_TABLE_LOOKUP_H
Number formatting for exception messages.
The error a closure raises for a state it cannot evaluate, so that the integrator proposing that stat...
double first() const
First abscissa of a non-empty table, in the table's own units.
double last() const
Last abscissa of a non-empty table, in the table's own units.
bool covers(double x) const
Whether eval() interpolates at x rather than holding an end value.
double eval(double T) const
Linearly interpolated value at T; clamped to the table endpoints.
TrialStateError(const std::string &procedure, std::string message)
std::string significant(double value)
value to 6 significant digits, for exception messages.
Definition Format.h:18
double evalAtState(const PropertyTable &table, double x, const char *procedure, const char *what, const char *unit, const char *remedy)
Value of table at x, refused outside its tabulated range.
Definition TableLookup.h:50
void throwOutsideTable(const PropertyTable &table, double x, const char *procedure, const std::string &what, const char *unit, const char *remedy)
Throw the TrialStateError for x outside table.
Definition TableLookup.h:30