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