SpECTRE Documentation Coverage Report
Current view: top level - ParallelAlgorithms/EventsAndTriggers - Tags.hpp Hit Total Coverage
Commit: 1c32b58340e006addc79befb2cdaa7547247e09c Lines: 7 33 21.2 %
Date: 2024-04-19 07:30:15
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 tags related to Events and Triggers
       6             : 
       7             : #pragma once
       8             : 
       9             : #include <vector>
      10             : #include <memory>
      11             : 
      12             : #include "DataStructures/DataBox/Tag.hpp"
      13             : #include "Options/String.hpp"
      14             : #include "ParallelAlgorithms/EventsAndTriggers/EventsAndTriggers.hpp"
      15             : #include "Utilities/Serialization/Serialize.hpp"
      16             : #include "Utilities/TMPL.hpp"
      17             : 
      18             : namespace OptionTags {
      19             : /// \ingroup OptionTagsGroup
      20             : /// \ingroup EventsAndTriggersGroup
      21             : /// Contains the events and triggers
      22             : ///
      23             : /// In yaml this is specified as a map of triggers to lists of events:
      24             : /// \code{.yaml}
      25             : /// EventsAndTriggers:
      26             : ///   ? TriggerA:
      27             : ///       OptionsForTriggerA
      28             : ///   : - Event1:
      29             : ///         OptionsForEvent1
      30             : ///     - Event2:
      31             : ///         OptionsForEvent2
      32             : ///   ? TriggerB:
      33             : ///       OptionsForTriggerB
      34             : ///   : - Event3:
      35             : ///         OptionsForEvent3
      36             : ///     - Event4:
      37             : ///         OptionsForEvent4
      38             : /// \endcode
      39           1 : struct EventsAndTriggers {
      40           0 :   using type = ::EventsAndTriggers;
      41           0 :   static constexpr Options::String help = "Events to run at triggers";
      42             :   // When the template arguments to this struct are sufficiently
      43             :   // complicated, pretty_type::short_name() run on this struct returns
      44             :   // something that is neither pretty nor short, and leads to an
      45             :   // OptionParser run-time error saying that an option name is greater
      46             :   // than 21 characters.  Adding the name() function below bypasses
      47             :   // pretty_type::short_name().
      48           0 :   static std::string name() { return "EventsAndTriggers"; }
      49             : };
      50             : 
      51           0 : namespace EventsRunAtCleanup {
      52           0 : struct Group {
      53           0 :   static std::string name() { return "EventsRunAtCleanup"; }
      54           0 :   static constexpr Options::String help =
      55             :       "Options related to running events on failure.  This is generally "
      56             :       "intended for dumping volume data to diagnose failure reasons.";
      57             : };
      58             : 
      59             : /// \brief A list of events to run at cleanup.
      60             : ///
      61             : /// See `Actions::RunEventsOnFailure` for details and caveats.
      62           1 : struct Events {
      63           0 :   static std::string name() { return "Events"; }
      64           0 :   using type = std::vector<std::unique_ptr<::Event>>;
      65           0 :   static constexpr Options::String help =
      66             :       "Events to run during the cleanup phase.";
      67           0 :   using group = Group;
      68             : };
      69             : 
      70             : /// \brief Observation value for Actions::RunEventsOnFailure.
      71           1 : struct ObservationValue {
      72           0 :   using type = double;
      73           0 :   static constexpr Options::String help =
      74             :       "Observation value for events run during the cleanup phase.";
      75           0 :   using group = Group;
      76             : };
      77             : }  // namespace EventsRunAtCleanup
      78             : }  // namespace OptionTags
      79             : 
      80             : namespace Tags {
      81             : /// \ingroup EventsAndTriggersGroup
      82             : /// Contains the events and triggers
      83           1 : struct EventsAndTriggers : db::SimpleTag {
      84           0 :   using type = ::EventsAndTriggers;
      85           0 :   using option_tags = tmpl::list<::OptionTags::EventsAndTriggers>;
      86             : 
      87           0 :   static constexpr bool pass_metavariables = false;
      88           0 :   static type create_from_options(const type& events_and_triggers) {
      89             :     return deserialize<type>(serialize<type>(events_and_triggers).data());
      90             :   }
      91             : };
      92             : 
      93             : /// \brief Events to be run on elements during the
      94             : /// `Parallel::Phase::PostFailureCleanup` phase.
      95             : ///
      96             : /// Useful for troubleshooting runs that are failing.
      97           1 : struct EventsRunAtCleanup : db::SimpleTag {
      98           0 :   using type = std::vector<std::unique_ptr<::Event>>;
      99           0 :   using option_tags = tmpl::list<OptionTags::EventsRunAtCleanup::Events>;
     100             : 
     101           0 :   static constexpr bool pass_metavariables = false;
     102           0 :   static type create_from_options(const type& events_run_at_cleanup) {
     103             :     return deserialize<type>(serialize<type>(events_run_at_cleanup).data());
     104             :   }
     105             : };
     106             : 
     107             : /// \brief Observation value for Actions::RunEventsOnFailure.
     108           1 : struct EventsRunAtCleanupObservationValue : db::SimpleTag {
     109           0 :   using type = double;
     110           0 :   using option_tags =
     111             :       tmpl::list<OptionTags::EventsRunAtCleanup::ObservationValue>;
     112             : 
     113           0 :   static constexpr bool pass_metavariables = false;
     114           0 :   static type create_from_options(const type& value) { return value; }
     115             : };
     116             : }  // namespace Tags

Generated by: LCOV version 1.14