SpECTRE  2021.08.02
Averager< DerivOrder > Class Template Reference

A weighted exponential averager of \(Q\) and its derivatives implementing Appendix A in [57]. More...

#include <Averager.hpp>

Public Member Functions

 Averager (double avg_timescale_frac, bool average_0th_deriv_of_q) noexcept
 avg_timescale_frac determines the exponential averaging timescale through \(\tau_\mathrm{avg} = \)avg_timescale_frac \(\times \tau\), where \(\tau\) is the damping time. avg_timescale_frac must be positive. average_0th_deriv_of_q determines whether the call operator returns an averaged or unaveraged quantity for the 0th derivative of \(Q\). true returns an averaged 0th derivative of \(Q\). false returns the raw 0th derivative of \(Q\). The derivatives are always averaged (to reduce noise due to numerical differentiation), so the average_0th_deriv_of_q option only specifies whether to return an averaged value for the 0th derivative piece of the function.
 
 Averager (Averager &&rhs) noexcept
 
Averageroperator= (Averager &&rhs) noexcept
 
 Averager (const Averager &)=delete
 
Averageroperator= (const Averager &)=delete
 
const std::optional< std::array< DataVector, DerivOrder+1 > > & operator() (double time) const noexcept
 Returns \(Q\) and its derivatives at \(t=\)time, provided there is sufficient data. The averager is limited by the need for at least (DerivOrder + 1) data points in order to provide the DerivOrder'th derivative. If sufficient data is available, it returns \(Q\) and averaged derivatives of \(Q\) up to the DerivOrder'th derivative, at \(t=\)time. If using_average_0th_deriv_of_q() is true, then the returned 0th derivative of \(Q\) is also averaged. In the case that there is insufficient data, the operator returns an invalid std::optional.
 
void clear () noexcept
 A function that allows for resetting the averager.
 
void update (double time, const DataVector &raw_q, const DataVector &timescales) noexcept
 The function responsible for updating the averaged values at \(t=\)time. Requires raw_q (the raw components of \(Q(t)\)) and timescales (the associated damping times for each component).
 
double last_time_updated () const noexcept
 Returns the latest time at which the averager has sufficient data to return \(Q\) and its derivatives.
 
double average_time (double time) const noexcept
 Returns the exponentially averaged time at \(t=\)time. The time is averaged along side \(Q\) to determine the effective time at which the average value is computed. The effective time is retarded, due to the weighting of past times.
 
bool using_average_0th_deriv_of_q () const noexcept
 Returns a bool corresponding to whether average_0th_deriv_of_q is true/false.
 

Detailed Description

template<size_t DerivOrder>
class Averager< DerivOrder >

A weighted exponential averager of \(Q\) and its derivatives implementing Appendix A in [57].

The purpose of the averager is to provide \(Q\) and 'smoothed' numerical derivatives of \(Q\) up to the DerivOrder'th derivative. The 0th derivative of \(Q\) is not typically averaged, since no differencing is necessary and no noise is introduced. The average_0th_deriv_of_q option allows for specifying that the 0th derivative should be averaged in addition to the derivatives. This may be desirable for control systems where \(Q\) contains some 'noise', e.g. size control typically uses an averaged \(Q\) since the raw computed \(Q\) is a function of the minimum on a surface and may jump around discontinuously.

The averager is designed to support an arbitrary DerivOrder, however the private get_derivs method currently only supports DerivOrder = 2. If an additional DerivOrder is needed, finite differencing needs to be implemented to specifically handle that order (as it seems like overkill to generalize the differencing stencil at this time).