Flow123d
JS_before_hm-1921-g7df00d392
|
Go to the documentation of this file.
25 template <
class Value>
33 return it::Tuple(
"IndependentValue",
"Value of Field for time variable.")
39 "Value of the field in given stamp." )
43 template <
class Value>
46 return it::Record(
"TableFunction",
"Allow set variable series initialization of Fields.")
48 "Initizaliation values of Field." )
55 template <
class Value>
62 template <
class Value>
65 ASSERT( !this->initialized() ).error(
"TableFunction can't be initialized more than once.");
72 WarningOut().fmt(
"Nonascending order of declared stamps in TableFunction at address {}.\nStamp {} will be skipped.",
77 typename Value::return_type r_value;
79 value.init_from_input(
it->val<
typename Value::AccessType>(
"value") );
85 template <
class Value>
88 return ( table_values_.size() > 0 );
91 template <
class Value>
94 ASSERT( this->initialized() ).error(
"Compute value of uninitialized TableFunction.");
97 unsigned int last_idx = table_values_.size() - 1;
98 if (t < table_values_[0].t_) {
99 WarningOut().fmt(
"Value of stamp {} is out of range of TableFunction: <{}, {}>. Extrapolation of minimal value will be used.",
100 t, table_values_[0].t_, table_values_[last_idx].t_);
101 this->interpolated(0.0, 0);
102 }
else if (t > table_values_[last_idx].t_) {
103 WarningOut().fmt(
"Value of stamp {} is out of range of TableFunction: <{}, {}>. Extrapolation of maximal value will be used.",
104 t, table_values_[0].t_, table_values_[last_idx].t_);
105 this->interpolated(1.0, last_idx-1);
107 for (
unsigned int i=0; i<last_idx; ++i) {
108 if (t >= table_values_[i].t_ && t <= table_values_[i+1].t_) {
109 double coef = (t - table_values_[i].t_) / (table_values_[i+1].t_ - table_values_[i].t_);
110 this->interpolated(coef, i);
117 return this->r_value_;
120 template <
class Value>
123 ASSERT(coef >= 0 && coef <= 1)(coef).error();
124 ASSERT(idx >= 0 && idx <= table_values_.size()-2)(idx).error();
126 Value val_0(table_values_[idx].r_value_);
127 Value val_1(table_values_[idx+1].r_value_);
128 if (Value::is_scalable())
129 for(
unsigned int row=0; row<value_.n_rows(); row++)
130 for(
unsigned int col=0; col<value_.n_cols(); col++) {
131 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.
#define ASSERT(expr)
Allow use shorter versions of macro names if these names is not used with external library.
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()