SpECTRE Documentation Coverage Report
Current view: top level - ControlSystem - FunctionOfTimeUpdater.cpp Hit Total Coverage
Commit: f1ddee3e40d81480e49140855d2b0e66fafaa908 Lines: 0 1 0.0 %
Date: 2020-12-02 17:35:08
Legend: Lines: hit not hit

          Line data    Source code
       1           0 : // Distributed under the MIT License.
       2             : // See LICENSE.txt for details.
       3             : 
       4             : #include "ControlSystem/FunctionOfTimeUpdater.hpp"
       5             : 
       6             : #include <algorithm>
       7             : #include <array>
       8             : 
       9             : #include "DataStructures/DataVector.hpp"
      10             : #include "Utilities/Gsl.hpp"
      11             : 
      12             : template <size_t DerivOrder>
      13             : FunctionOfTimeUpdater<DerivOrder>::FunctionOfTimeUpdater(
      14             :     Averager<DerivOrder>&& averager, Controller<DerivOrder>&& controller,
      15             :     TimescaleTuner&& timescale_tuner) noexcept
      16             :     : averager_{std::move(averager)},
      17             :       controller_{std::move(controller)},
      18             :       timescale_tuner_{std::move(timescale_tuner)} {}
      19             : 
      20             : template <size_t DerivOrder>
      21             : void FunctionOfTimeUpdater<DerivOrder>::measure(
      22             :     const double time, const DataVector& raw_q) noexcept {
      23             :   averager_.update(time, raw_q, timescale_tuner_.current_timescale());
      24             : }
      25             : 
      26             : template <size_t DerivOrder>
      27             : void FunctionOfTimeUpdater<DerivOrder>::modify(
      28             :     const gsl::not_null<
      29             :         domain::FunctionsOfTime::PiecewisePolynomial<DerivOrder>*>
      30             :         f_of_t,
      31             :     const double time, const double expiration_time) noexcept {
      32             :   if (averager_(time)) {
      33             :     std::array<DataVector, DerivOrder + 1> q_and_derivs = averager_(time).get();
      34             :     // get the time offset due to averaging
      35             :     const double t_offset_of_qdot = time - averager_.average_time(time);
      36             :     const double t_offset_of_q =
      37             :         (averager_.using_average_0th_deriv_of_q() ? t_offset_of_qdot : 0.0);
      38             : 
      39             :     const DataVector control_signal =
      40             :         controller_(timescale_tuner_.current_timescale(), q_and_derivs,
      41             :                     t_offset_of_q, t_offset_of_qdot);
      42             :     f_of_t->update(averager_.last_time_updated(), control_signal,
      43             :                    expiration_time);
      44             :     timescale_tuner_.update_timescale({{q_and_derivs[0], q_and_derivs[1]}});
      45             :   } else {
      46             :     f_of_t->reset_expiration_time(expiration_time);
      47             :   }
      48             : }
      49             : 
      50             : /// \cond
      51             : template class FunctionOfTimeUpdater<2>;
      52             : /// \endcond

Generated by: LCOV version 1.14