SpECTRE Documentation Coverage Report
Current view: top level - ControlSystem - FutureMeasurements.hpp Coverage Total Hit
Commit: 0d1d717af84a81fb1284a20c4013708fe85cc2f0 Lines: 35.7 % 14 5
Test Date: 2026-10-22 17:29:42
Legend: Lines:     hit not hit

            Line data    Source code
       1            0 : // Distributed under the MIT License.
       2              : // See LICENSE.txt for details.
       3              : 
       4              : #pragma once
       5              : 
       6              : #include <cstddef>
       7              : #include <deque>
       8              : #include <optional>
       9              : #include <pup.h>
      10              : #include <utility>
      11              : 
      12              : /// \cond
      13              : namespace domain::FunctionsOfTime {
      14              : class FunctionOfTime;
      15              : }  // namespace domain::FunctionsOfTime
      16              : /// \endcond
      17              : 
      18              : namespace control_system {
      19              : /// Class for computing the upcoming measurement times for a control
      20              : /// system measurement.
      21              : ///
      22              : /// At any time, the \ref control_system::Tags::MeasurementTimescales
      23              : /// "measurement timescales" can be queried to find the spacing
      24              : /// between control system measurements.  Most uses, however, require
      25              : /// the actual measurement times, and sometimes need to know times of
      26              : /// control-system update triggers.  This class calculates these
      27              : /// quantities from the timescales.
      28            1 : class FutureMeasurements {
      29              :  public:
      30            0 :   FutureMeasurements() = default;
      31              : 
      32            0 :   FutureMeasurements(size_t measurements_per_update,
      33              :                      double first_measurement_time);
      34              : 
      35              :   /// Next measurement time, if known.
      36            1 :   std::optional<double> next_measurement() const;
      37              :   /// Next measurement that triggers an update, if known.
      38            1 :   std::optional<double> next_update() const;
      39              : 
      40              :   /// Remove the earliest measurement form the list, generally because
      41              :   /// it has been performed.
      42            1 :   void pop_front();
      43              : 
      44              :   /// Calculate and store measurement times up through the expiration
      45              :   /// time of the argument.
      46              :   ///
      47              :   /// Given a measurement time \f$t_i\f$, the next measurement will
      48              :   /// occur at \f$t_{i+1} = t_i + \tau_m(t_i)\f$, where
      49              :   /// \f$\tau_m(t)\f$ is the measurement timescale at time \f$t\f$.
      50            1 :   void update(
      51              :       const domain::FunctionsOfTime::FunctionOfTime& measurement_timescale);
      52              : 
      53            0 :   void pup(PUP::er& p);
      54              : 
      55            0 :   friend bool operator==(const FutureMeasurements& lhs,
      56              :                          const FutureMeasurements& rhs);
      57              : 
      58              :  private:
      59              :   // This stores the most recent (or current) measurement time,
      60              :   // followed by some future measurement times.  We need to keep one
      61              :   // old entry that isn't returned so that we can use it to calculate
      62              :   // a new first entry if we need to update an "empty" list.  The
      63              :   // bookkeeping is simpler if we keep it around even when we don't
      64              :   // need it.
      65            0 :   std::deque<double> measurements_{};
      66            0 :   size_t measurements_until_update_{};
      67            0 :   size_t measurements_per_update_{};
      68              : };
      69              : 
      70            0 : bool operator!=(const FutureMeasurements& lhs, const FutureMeasurements& rhs);
      71              : }  // namespace control_system
        

Generated by: LCOV version 2.0-1