SpECTRE Documentation Coverage Report
Current view: top level - Time/Triggers - TimeCompares.hpp Hit Total Coverage
Commit: aabde07399ba7837e5db64eedfd0a21f31f96922 Lines: 1 16 6.2 %
Date: 2024-04-26 02:38:13
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 <limits>
       7             : #include <pup.h>
       8             : 
       9             : #include "Options/Comparator.hpp"
      10             : #include "Options/String.hpp"
      11             : #include "ParallelAlgorithms/EventsAndTriggers/Trigger.hpp"
      12             : #include "Utilities/Serialization/CharmPupable.hpp"
      13             : #include "Utilities/TMPL.hpp"
      14             : 
      15             : /// \cond
      16             : namespace Tags {
      17             : struct Time;
      18             : }  // namespace Tags
      19             : /// \endcond
      20             : 
      21             : namespace Triggers {
      22             : /// \ingroup EventsAndTriggersGroup
      23             : /// \ingroup TimeGroup
      24             : /// Trigger based on a comparison with the time.
      25           1 : class TimeCompares : public Trigger {
      26             :  public:
      27             :   /// \cond
      28             :   TimeCompares() = default;
      29             :   explicit TimeCompares(CkMigrateMessage* /*unused*/) {}
      30             :   using PUP::able::register_constructor;
      31             :   WRAPPED_PUPable_decl_template(TimeCompares);  // NOLINT
      32             :   /// \endcond
      33             : 
      34           0 :   struct Comparison {
      35           0 :     using type = Options::Comparator;
      36           0 :     constexpr static Options::String help = "Comparison type";
      37             :   };
      38             : 
      39           0 :   struct Value {
      40           0 :     using type = double;
      41           0 :     constexpr static Options::String help = "Value to compare to";
      42             :   };
      43             : 
      44           0 :   using options = tmpl::list<Comparison, Value>;
      45           0 :   static constexpr Options::String help{
      46             :       "Trigger based on a comparison with the time."};
      47             : 
      48           0 :   explicit TimeCompares(const Options::Comparator comparator, const double time)
      49             :       : comparator_(comparator), time_(time) {}
      50             : 
      51           0 :   using argument_tags = tmpl::list<Tags::Time>;
      52             : 
      53           0 :   bool operator()(const double& time) const { return comparator_(time, time_); }
      54             : 
      55             :   // NOLINTNEXTLINE(google-runtime-references)
      56           0 :   void pup(PUP::er& p) {
      57             :     p | comparator_;
      58             :     p | time_;
      59             :   }
      60             : 
      61             :  private:
      62           0 :   Options::Comparator comparator_{};
      63           0 :   double time_{};
      64             : };
      65             : }  // namespace Triggers

Generated by: LCOV version 1.14