Go to the documentation of this file.
26 template <
class Value>
34 return it::Tuple(
"IndependentValue",
"Value of Field for time variable.")
40 "Value of the field in given stamp." )
44 template <
class Value>
47 return it::Record(
"TableFunction",
"Allow set variable series initialization of Fields.")
49 "Initizaliation values of Field." )
56 template <
class Value>
63 template <
class Value>
66 ASSERT( !this->initialized() ).error(
"TableFunction can't be initialized more than once.");
73 WarningOut().fmt(
"Nonascending order of declared stamps in TableFunction at address {}.\nStamp {} will be skipped.",
78 typename Value::return_type r_value;
86 template <
class Value>
89 return ( table_values_.size() > 0 );
92 template <
class Value>
95 ASSERT( this->initialized() ).error(
"Compute value of uninitialized TableFunction.");
98 unsigned int last_idx = table_values_.size() - 1;
99 if (t < table_values_[0].t_) {
100 WarningOut().fmt(
"Value of stamp {} is out of range of TableFunction: <{}, {}>. Extrapolation of minimal value will be used.",
101 t, table_values_[0].t_, table_values_[last_idx].t_);
102 this->interpolated(0.0, 0);
103 }
else if (t > table_values_[last_idx].t_) {
104 WarningOut().fmt(
"Value of stamp {} is out of range of TableFunction: <{}, {}>. Extrapolation of maximal value will be used.",
105 t, table_values_[0].t_, table_values_[last_idx].t_);
106 this->interpolated(1.0, last_idx-1);
108 for (
unsigned int i=0; i<last_idx; ++i) {
109 if (t >= table_values_[i].t_ && t <= table_values_[i+1].t_) {
110 double coef = (t - table_values_[i].t_) / (table_values_[i+1].t_ - table_values_[i].t_);
111 this->interpolated(coef, i);
118 return this->r_value_;
121 template <
class Value>
124 ASSERT(coef >= 0 && coef <= 1)(coef).error();
125 ASSERT(idx >= 0 && idx <= table_values_.size()-2)(idx).error();
127 Value val_0(table_values_[idx].r_value_);
128 Value val_1(table_values_[idx+1].r_value_);
129 if (Value::is_scalable())
130 for(
unsigned int row=0; row<value_.n_rows(); row++)
131 for(
unsigned int col=0; col<value_.n_cols(); col++) {
132 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).
Basic time management class.
static constexpr bool value
double read_time(Input::Iterator< Input::Tuple > time_it, double default_time=std::numeric_limits< double >::quiet_NaN()) const
void interpolated(double coef, unsigned int idx)
Store value in one t stamp.
Representation of one time step..
Value::return_type return_type
static const Input::Type::Record & get_input_type()
#define WarningOut()
Macro defining 'warning' record of log.
const return_type & value(double t)
void init_from_input(const Input::Record &rec, const TimeStep &time)
Initialize actual values of the field given from the given Input::Record rec.
TableFunction()
Default constructor.
static const Input::Type::Tuple & get_input_time_type(double lower_bound=-std::numeric_limits< double >::max(), double upper_bound=std::numeric_limits< double >::max())
static const Input::Type::Tuple & get_input_type_val()