|
| Extrapolation () |
| Leave values uninitialized. More...
|
|
| Extrapolation (unsigned max, const ContainerType ©able) |
| Set maximum extrapolation order and allocate memory. More...
|
|
void | set_max (unsigned max, const ContainerType ©able) |
| Set maximum extrapolation order and allocate memory. More...
|
|
unsigned | get_max () const |
| Current extrapolation count. More...
|
|
bool | exists (value_type t) const |
| Check if time exists in current points. More...
|
|
template<class ContainerType0 > |
void | extrapolate (value_type t, ContainerType0 &new_x) const |
| Extrapolate value to given time. More...
|
|
template<class ContainerType0 > |
void | derive (value_type t, ContainerType0 &dot_x) const |
| Evaluate first derivative of interpolating polynomial More...
|
|
template<class ContainerType0 > |
void | extrapolate (ContainerType0 &new_x) const |
| Extrapolate value (equidistant version) More...
|
|
template<class ContainerType0 > |
void | derive (ContainerType0 &dot_x) const |
| Evaluate first derivative of interpolating polynomial (equidistant version) More...
|
|
template<class ContainerType0 > |
void | update (value_type t_new, const ContainerType0 &new_entry) |
| insert a new entry, deleting the oldest entry or update existing entry More...
|
|
template<class ContainerType0 > |
void | update (const ContainerType0 &new_entry) |
| insert a new entry More...
|
|
const ContainerType & | head () const |
| return the current head (the one most recently inserted) More...
|
|
ContainerType & | tail () |
| DEPRECATED write access to tail value ( the one that will be deleted in the next update, undefined if max==0) More...
|
|
const ContainerType & | tail () const |
| DEPRECATED read access to tail value ( the one that will be deleted in the next update, undefined if max==0) More...
|
|
template<class ContainerType>
struct dg::Extrapolation< ContainerType >
Extrapolate a polynomial passing through up to three points.
This class constructs an interpolating polynomial through up to three given points and evaluates its value or its derivative at a new point. The points can be updated to get a new polynomial.
The intention of this class is to provide an initial guess for iterative solvers based on past solutions:
\[ x_{init} = \alpha_0 x_0 + \alpha_{-1}x_{-1} + \alpha_{-2} x_{-2}\]
where the indices indicate the current (0) and past (negative) solutions. Choose between 1 (constant), 2 (linear) or 3 (parabola) extrapolation. The user can choose to provide a time value t_i
associated with the x_i
, which are then used to compute the coefficients alpha_i
(using Lagrange interpolation). Otherwise an equidistant distribution is assumed.
- Note
- Since extrapolation with higher order polynomials is so prone to oscillations anything higher than linear rarely leads to anything useful. So best stick to constant or linear extrapolation
-
The derivative of the interpolating polynomial at a new point reduces to familiar finite difference formulas
- Template Parameters
-
ContainerType | Any class for which a specialization of TensorTraits exists and which fulfills the requirements of the there defined data and execution policies derived from AnyVectorTag and AnyPolicyTag . Among others
dg::HVec (serial), dg::DVec (cuda / omp), dg::MHVec (mpi + serial) or dg::MDVec (mpi + cuda / omp)
std::vector<dg::DVec> (vector of shared device vectors), std::array<double, 4> (array of 4 doubles) or std::map < std::string, dg::DVec> ( a map of named vectors)
double (scalar) and other primitive types ...
If there are several ContainerTypes in the argument list, then TensorTraits must exist for all of them |
- See also
- See The dg dispatch system for a detailed explanation of our type dispatch system
-
https://en.wikipedia.org/wiki/Extrapolation
template<class ContainerType >
template<class ContainerType0 >
Evaluate first derivative of interpolating polynomial
Equivalent to constructing the interpolating polynomial, deriving it once and then evaluating it at the required point
- Parameters
-
t | time at which derivative of interpolating polynomial is evaluated |
dot_x | (write only) contains derived value on output |
- Note
- If t is chosen as the latest time of update t0, then the result coincides with the backward difference formula of order
max
- Attention
- If max==1, the result is 0 (derivative of a constant)
-
If the update function has not been called enough times to fill all values the result depends: (i) never called => dot_x is zero (ii) called at least once => the interpolating polynomial is constructed with all available values
- Template Parameters
-