Line data Source code
1 0 : // Distributed under the MIT License. 2 : // See LICENSE.txt for details. 3 : 4 : #pragma once 5 : 6 : #include "Options/String.hpp" 7 : #include "Parallel/GlobalCache.hpp" 8 : #include "Parallel/Local.hpp" 9 : #include "ParallelAlgorithms/EventsAndTriggers/Event.hpp" 10 : #include "Utilities/Serialization/CharmPupable.hpp" 11 : #include "Utilities/TMPL.hpp" 12 : 13 : namespace Events { 14 : /// \ingroup EventsAndTriggersGroup 15 : /// Sets the termination flag for the code to exit. 16 1 : class Completion : public Event { 17 : public: 18 : /// \cond 19 : explicit Completion(CkMigrateMessage* /*unused*/) {} 20 : using PUP::able::register_constructor; 21 : WRAPPED_PUPable_decl_template(Completion); // NOLINT 22 : /// \endcond 23 : 24 0 : using compute_tags_for_observation_box = tmpl::list<>; 25 0 : using options = tmpl::list<>; 26 0 : static constexpr Options::String help = { 27 : "Sets the termination flag for the code to exit."}; 28 : 29 0 : Completion() = default; 30 : 31 0 : using return_tags = tmpl::list<>; 32 0 : using argument_tags = tmpl::list<>; 33 : 34 : template <typename Metavariables, typename ArrayIndex, typename Component> 35 0 : void operator()(Parallel::GlobalCache<Metavariables>& cache, 36 : const ArrayIndex& array_index, 37 : const Component* const /*meta*/, 38 : const ObservationValue& /*observation_value*/) const { 39 : auto al_gore = Parallel::local( 40 : Parallel::get_parallel_component<Component>(cache)[array_index]); 41 : al_gore->set_terminate(true); 42 : } 43 : 44 0 : using is_ready_argument_tags = tmpl::list<>; 45 : 46 : template <typename Metavariables, typename ArrayIndex, typename Component> 47 0 : bool is_ready(Parallel::GlobalCache<Metavariables>& /*cache*/, 48 : const ArrayIndex& /*array_index*/, 49 : const Component* const /*meta*/) const { 50 : return true; 51 : } 52 : 53 1 : bool needs_evolved_variables() const override { return false; } 54 : }; 55 : } // namespace Events