SpECTRE Documentation Coverage Report
Current view: top level - Time - TimeStepId.hpp Hit Total Coverage
Commit: 2ae2b99409ac582030d56a4560a92a3e066a7e54 Lines: 6 26 23.1 %
Date: 2022-01-15 08:40:38
Legend: Lines: hit not hit

          Line data    Source code
       1           1 : // Distributed under the MIT License.
       2             : // See LICENSE.txt for details.
       3             : 
       4             : /// \file
       5             : /// Defines class TimeStepId.
       6             : 
       7             : #pragma once
       8             : 
       9             : #include <cstddef>
      10             : #include <cstdint>
      11             : #include <functional>
      12             : #include <iosfwd>
      13             : 
      14             : #include "Time/Time.hpp"
      15             : #include "Utilities/ErrorHandling/Assert.hpp"
      16             : 
      17             : namespace PUP {
      18             : class er;
      19             : }  // namespace PUP
      20             : 
      21             : /// \ingroup TimeGroup
      22             : ///
      23             : /// A unique identifier for the temporal state of an integrated
      24             : /// system.
      25           1 : class TimeStepId {
      26             :  public:
      27           0 :   TimeStepId() = default;
      28             :   /// Create a TimeStepId at the start of a step.  If that step is at the
      29             :   /// (evolution-defined) end of the slab the TimeStepId will be advanced
      30             :   /// to the next slab.
      31           1 :   TimeStepId(const bool time_runs_forward, const int64_t slab_number,
      32             :              const Time& time)
      33             :       : time_runs_forward_(time_runs_forward),
      34             :         slab_number_(slab_number),
      35             :         step_time_(time),
      36             :         substep_time_(time) {
      37             :     canonicalize();
      38             :   }
      39             :   /// Create a TimeStepId at a substep at time `substep_time` in a step
      40             :   /// starting at time `step_time`.
      41           1 :   TimeStepId(const bool time_runs_forward, const int64_t slab_number,
      42             :              const Time& step_time, const uint64_t substep,
      43             :              const Time& substep_time)
      44             :       : time_runs_forward_(time_runs_forward),
      45             :         slab_number_(slab_number),
      46             :         step_time_(step_time),
      47             :         substep_(substep),
      48             :         substep_time_(substep_time) {
      49             :     ASSERT(substep_ != 0 or step_time_ == substep_time_,
      50             :            "Initial substep must align with the step.");
      51             :     canonicalize();
      52             :   }
      53             : 
      54           0 :   bool time_runs_forward() const { return time_runs_forward_; }
      55           0 :   int64_t slab_number() const { return slab_number_; }
      56             :   /// Time at the start of the current step
      57           1 :   const Time& step_time() const { return step_time_; }
      58           0 :   uint64_t substep() const { return substep_; }
      59             :   /// Time of the current substep
      60           1 :   const Time& substep_time() const { return substep_time_; }
      61             : 
      62           0 :   bool is_at_slab_boundary() const {
      63             :     return substep_ == 0 and substep_time_.is_at_slab_boundary();
      64             :   }
      65             : 
      66             :   // NOLINTNEXTLINE(google-runtime-references)
      67           0 :   void pup(PUP::er& p);
      68             : 
      69             :  private:
      70           0 :   void canonicalize();
      71             : 
      72           0 :   bool time_runs_forward_{false};
      73           0 :   int64_t slab_number_{0};
      74           0 :   Time step_time_{};
      75           0 :   uint64_t substep_{0};
      76           0 :   Time substep_time_{};
      77             : };
      78             : 
      79           0 : bool operator==(const TimeStepId& a, const TimeStepId& b);
      80           0 : bool operator!=(const TimeStepId& a, const TimeStepId& b);
      81           0 : bool operator<(const TimeStepId& a, const TimeStepId& b);
      82           0 : bool operator<=(const TimeStepId& a, const TimeStepId& b);
      83           0 : bool operator>(const TimeStepId& a, const TimeStepId& b);
      84           0 : bool operator>=(const TimeStepId& a, const TimeStepId& b);
      85             : 
      86           0 : std::ostream& operator<<(std::ostream& s, const TimeStepId& id);
      87             : 
      88           0 : size_t hash_value(const TimeStepId& id);
      89             : 
      90             : namespace std {
      91             : template <>
      92             : struct hash<TimeStepId> {
      93             :   size_t operator()(const TimeStepId& id) const;
      94             : };
      95             : }  // namespace std

Generated by: LCOV version 1.14