SpECTRE Documentation Coverage Report
Current view: top level - Time/Triggers - Slabs.hpp Hit Total Coverage
Commit: 3c072f0ce967e2e56649d3fa12aa2a0e4fe2a42e Lines: 1 10 10.0 %
Date: 2024-04-23 20:50:18
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 <cstdint>
       7             : #include <memory>
       8             : #include <pup.h>
       9             : #include <pup_stl.h>
      10             : #include <utility>
      11             : 
      12             : #include "Options/ParseOptions.hpp"
      13             : #include "Options/String.hpp"
      14             : #include "ParallelAlgorithms/EventsAndTriggers/Trigger.hpp"
      15             : #include "Time/TimeSequence.hpp"
      16             : #include "Time/TimeStepId.hpp"
      17             : #include "Utilities/Serialization/CharmPupable.hpp"
      18             : #include "Utilities/TMPL.hpp"
      19             : 
      20             : /// \cond
      21             : namespace Tags {
      22             : struct TimeStepId;
      23             : }  // namespace Tags
      24             : /// \endcond
      25             : 
      26             : namespace Triggers {
      27             : /// \ingroup EventsAndTriggersGroup
      28             : /// \ingroup TimeGroup
      29             : /// Trigger at specified numbers of slabs after the simulation start.
      30           1 : class Slabs : public Trigger {
      31             :  public:
      32             :   /// \cond
      33             :   Slabs() = default;
      34             :   explicit Slabs(CkMigrateMessage* /*unused*/) {}
      35             :   using PUP::able::register_constructor;
      36             :   WRAPPED_PUPable_decl_template(Slabs);  // NOLINT
      37             :   /// \endcond
      38             : 
      39           0 :   static constexpr Options::String help{
      40             :     "Trigger at specified numbers of slabs after the simulation start."};
      41             : 
      42           0 :   explicit Slabs(std::unique_ptr<TimeSequence<uint64_t>> slabs)
      43             :       : slabs_(std::move(slabs)) {}
      44             : 
      45           0 :   using argument_tags = tmpl::list<Tags::TimeStepId>;
      46             : 
      47           0 :   bool operator()(const TimeStepId& time_id) const {
      48             :     const auto unsigned_slab =
      49             :         static_cast<std::uint64_t>(time_id.slab_number());
      50             :     return slabs_->times_near(unsigned_slab)[1] == unsigned_slab;
      51             :   }
      52             : 
      53             :   // NOLINTNEXTLINE(google-runtime-references)
      54           0 :   void pup(PUP::er& p) override { p | slabs_; }
      55             : 
      56             :  private:
      57           0 :   std::unique_ptr<TimeSequence<uint64_t>> slabs_{};
      58             : };
      59             : }  // namespace Triggers
      60             : 
      61             : template <>
      62           0 : struct Options::create_from_yaml<Triggers::Slabs> {
      63             :   template <typename Metavariables>
      64           0 :   static Triggers::Slabs create(const Option& options) {
      65             :     return Triggers::Slabs(
      66             :         options.parse_as<std::unique_ptr<TimeSequence<uint64_t>>,
      67             :                          Metavariables>());
      68             :   }
      69             : };

Generated by: LCOV version 1.14