Flow123d
release_3.0.0-968-gc87a28e79
|
Go to the documentation of this file.
24 template <
class Value>
27 return it::Tuple(
"IndependentValue",
"Value of Field for independent variable.")
29 "Independent variable of stamp." )
31 "Value of the field in given stamp." )
35 template <
class Value>
38 return it::Record(
"TableFunction",
"Allow set variable series initialization of Fields.")
40 "Initizaliation values of Field." )
47 template <
class Value>
54 template <
class Value>
57 ASSERT( !this->initialized() ).error(
"TableFunction can't be initialized more than once.");
62 double t =
it->val<
double>(
"t");
64 WarningOut().fmt(
"Nonascending order of declared stamps in TableFunction at address {}.\nStamp {} will be skipped.",
69 typename Value::return_type r_value;
71 value.init_from_input(
it->val<
typename Value::AccessType>(
"value") );
77 template <
class Value>
80 return ( table_values_.size() > 0 );
83 template <
class Value>
86 ASSERT( this->initialized() ).error(
"Compute value of uninitialized TableFunction.");
89 unsigned int last_idx = table_values_.size() - 1;
90 if (t < table_values_[0].t_) {
91 WarningOut().fmt(
"Value of stamp {} is out of range of TableFunction: <{}, {}>. Extrapolation of minimal value will be used.",
92 t, table_values_[0].t_, table_values_[last_idx].t_);
93 this->interpolated(0.0, 0);
94 }
else if (t > table_values_[last_idx].t_) {
95 WarningOut().fmt(
"Value of stamp {} is out of range of TableFunction: <{}, {}>. Extrapolation of maximal value will be used.",
96 t, table_values_[0].t_, table_values_[last_idx].t_);
97 this->interpolated(1.0, last_idx-1);
99 for (
unsigned int i=0; i<last_idx; ++i) {
100 if (t >= table_values_[i].t_ && t <= table_values_[i+1].t_) {
101 double coef = (t - table_values_[i].t_) / (table_values_[i+1].t_ - table_values_[i].t_);
102 this->interpolated(coef, i);
109 return this->r_value_;
112 template <
class Value>
115 ASSERT(coef >= 0 && coef <= 1)(coef).error();
116 ASSERT(idx >= 0 && idx <= table_values_.size()-2)(idx).error();
118 Value val_0(table_values_[idx].r_value_);
119 Value val_1(table_values_[idx+1].r_value_);
120 if (Value::is_scalable())
121 for(
unsigned int row=0; row<value_.n_rows(); row++)
122 for(
unsigned int col=0; col<value_.n_cols(); col++) {
123 value_(row,col) = val_0(row,col) + coef * (val_1(row,col) - val_0(row,col));
bool initialized()
Return true if TableFunction is initialized (method init_from_input was called).
#define ASSERT(expr)
Allow use shorter versions of macro names if these names is not used with external library.
static constexpr bool value
void interpolated(double coef, unsigned int idx)
Store value in one t stamp.
Value::return_type return_type
static const Input::Type::Record & get_input_type()
#define WarningOut()
Macro defining 'warning' record of log.
void init_from_input(const Input::Record &rec)
Initialize actual values of the field given from the given Input::Record rec.
const return_type & value(double t)
TableFunction()
Default constructor.
static const Input::Type::Tuple & get_input_type_val()