Flow123d
JB_transport-112d700
|
Go to the documentation of this file.
35 max_size(default_max_size),
36 automatic_size(false),
69 ASSERT_GT(
size, 0).error(
"Size of interpolation table must be positive number!.");
85 ASSERT_GT(init_size, 0).error(
"Maximal size of interpolation table must be positive number!.");
86 ASSERT_GE(
max_size, init_size).error(
"Maximal size of interpolation table is smaller than initial size.");
115 bool reinterpolate =
false;
119 reinterpolate =
true;
124 reinterpolate =
true;
129 MessageOut() <<
"Interpolation: Reinterpolating...\n";
160 interpolate_derivative(false)
183 f[i] = f[i] * this->
fact(i);
192 unsigned int result = 10;
239 MessageOut().fmt(
"Interpolation: Size of the table set automaticaly to: {} after {} cycles.\n",
size_, k);
258 WarningOut().fmt(
"Interpolation: User defined tolerance {} has not been satisfied with size of interpolation table {}).\n",
275 MessageOut().fmt(
"Interpolation: Interpolation error estimate is: {}.\n",
error_);
350 for(
unsigned int i = 0; i <
size_; i++)
365 for(
unsigned int i = 0; i <
size_; i++)
377 double new_size = 2*
size_;
387 for(
unsigned int i=0; i!=
size_; i++)
389 swap_f_vec.push_back(
f_vec[i]);
390 swap_f_vec.push_back(f[i]);
392 swap_f_vec.push_back(
f_vec.back());
398 for(
unsigned int i=0; i!=
size_; i++)
400 swap_df_vec.push_back(
df_vec[i]);
401 swap_df_vec.push_back(df[i]);
403 swap_df_vec.push_back(
df_vec.back());
418 double temp_x = temp_a;
426 for(
unsigned int i = 0; i !=
size_; i++)
428 temp_x = temp_a +
step*i;
430 f.push_back(
value.first);
431 df.push_back(
value.second);
435 tot_err = std::max( tot_err,
436 std::abs(
value.first - int_value.first) / (std::abs(
value.first) + tol)
437 + std::abs(
value.second - int_value.second) / (std::abs(
value.second) + tol)
444 for(
unsigned int i = 0; i !=
size_; i++)
446 temp_x = temp_a +
step*i;
447 f.push_back(
f_val(temp_x));
448 tot_err = std::max( tot_err,
449 std::abs(f.back() -
val_p1(temp_x)) / (std::abs(f.back()) + tol)
518 for(
unsigned long i = 0; i <
size_; i++ )
529 tot_err = std::pow(tot_err, 1.0/exponent);
543 interpolate_derivative(false),
544 explicit_interpolant(NULL),
566 return func_u->operator()(u);
double step
Chosen interpolation step.
EvalStatistics stats
Structure which keeps evaluation statistics. See InterpolantBase::eval_statistics.
void set_size(unsigned int size)
Sets size of the interpolation table. It is also equal to the number of intervals.
double f_val(double x, double y)
Returns interpolated value of the derivation.
const static double simpson_tolerance
Tolerance in Adaptive Simpson intergration.
#define ASSERT_GT(a, b)
Definition of comparative assert macro (Greater Than) only for debug mode.
double bound_a_
Left interval boundary.
double val(double u)
Returns interpolated value.
const static unsigned int n_derivatives
Defines how many derivatives we allow to be returned from Taylor's coeficients.
FunctorBase< T< double > > * func_diffn
Pointer to original functor with FADBAD T type.
double f_val(double x)
Returns value of the original functor.
virtual ~Interpolant(void)
Destructor.
std::vector< double > f_vec
Vector of function values at nodes.
long fact(long x)
Recursive factorial function (used in Taylor row expansion in n-th derivative computation).
static double AdaptSimpson(FunctorBase< double > &func, const double &a, const double &b, const double &tol)
main method that starts the evaluation and calls the recursion
double min
minimal x for which the evaluation was called outside the interval (initially is equal the left bound...
Interpolant()
Default constructor.
FuncExplicit< double > * func_u
void set_size_automatic(double user_tol, unsigned int init_size, unsigned int max_size=default_max_size)
Sets automatic choice of the size of the table.
std::vector< bool > checks
Vector of boolean values telling us which parameters are set or not.
static constexpr bool value
FunctorBase< B< double > > * func_diff
Pointer to original functor with FADBAD B type.
unsigned int size_
Number of dividing intervals.
double f_diffn(double x, unsigned int n)
double a_div_step
bound_ divided by step - precomputed value for evaluation
void compute_values()
Creates table of nodes and function values.
#define ASSERT_LT(a, b)
Definition of comparative assert macro (Less Than) only for debug mode.
double error_
Error of the interpolation.
virtual int interpolate()=0
Creates piecewise polynomial interpolation.
void set_norm(ErrorNorm::Type norm_type=ErrorNorm::max, double p=2)
Sets the type of norm used for computing estimate of the error of the interpolation.
virtual ~InterpolantImplicit(void)
destructor
#define ASSERT_PERMANENT(expr)
Allow use shorter versions of macro names if these names is not used with external library.
unsigned int interval_miss_a
counts left misses of the interval
unsigned int interval_miss_b
counts right misses of the interval
unsigned int total_calls
counts total calls of evaluation
virtual int interpolate()
Creates piecewise interpolation with polynomials of selected degree.
void interpolate_p1()
Creates piecewise linear interpolation.
void check_stats_and_reinterpolate(double percentage=0.3)
Can be called to check automatically the evaluation statistics and possibly reinterpolate.
std::vector< double > df_vec
Vector of function derivatives values at nodes.
ErrorNorm::Type norm_type
Type of norm used to compute error of the interpolation.
Interpolant * explicit_interpolant
DiffValue diff_p1(double x)
Finds interval on which x lies.
unsigned int max_size
Maximal size of the interpolation table.
Base class for interpolation.
void reset_stat()
Resets all measured statistics.
const static unsigned int default_max_size
Default maximal size of the interpolation table.
IFunctorBase< double > * func
void compute_error(double tol, std::vector< double > &f, std::vector< double > &df)
Creates piecewise linear interpolation.
double val_p1(double x)
Do NOT use, unless you are 100% sure.
virtual ~InterpolantBase()
Destructor.
bool interpolate_derivative
Is true if we want to interpolate the derivative too.
bool automatic_size
Is true if step/size should be chosen automatically.
std::pair< double, double > DiffValue
DiffValue f_diff(double x)
Returns 1st derivative of original functor using FADBAD.
double bound_a() const
Returns left boundary of the interval.
double user_tol
User set tolerance which is used during automatic step choice.
void swap_middle_values(std::vector< double > &f, std::vector< double > &df)
#define ASSERT_GE(a, b)
Definition of comparative assert macro (Greater or Equal) only for debug mode.
Extrapolation::Type extrapolation
#define WarningOut()
Macro defining 'warning' record of log.
double max
maximal x for which the evaluation was called outside the interval ((initially is equal the right bou...
#define ASSERT_LE(a, b)
Definition of comparative assert macro (Less or Equal) only for debug mode.
void set_interval(double bound_a, double bound_b)
Sets the interpolation interval boundaries.
void check_all()
Checks that the parameters are set before interpolation.
unsigned int size() const
Returns the size of the interpolation table.
IFunctorBase< T< double > > * func_diffn
InterpolantBase()
Default constructor.
void set_extrapolation(Extrapolation::Type extrapolation)
Sets the type of extrapolation. Functor type is default.
double bound_b() const
Returns right boundary of the interval.
double bound_b_
Right interval boundary.
InterpolantImplicit()
constructor
unsigned int n_nodes
Number of nodes in the interval .
#define DebugOut()
Macro defining 'debug' record of log.
IFunctorBase< B< double > > * func_diff
double p
Exponent used in norms and when computing error.
double error()
Returns error of the interpolation.
void fix_variable(IFixVariable::Type fix, double value)
virtual int interpolate()
Creates piecewise interpolation with polynomials of selected degree.
#define MessageOut()
Macro defining 'message' record of log.