Line data Source code
1 0 : // Distributed under the MIT License.
2 : // See LICENSE.txt for details.
3 :
4 : #pragma once
5 :
6 : #include <optional>
7 : #include <tuple>
8 :
9 : #include "DataStructures/DataBox/DataBox.hpp"
10 : #include "Evolution/Systems/Cce/OptionTags.hpp"
11 : #include "Evolution/Systems/Cce/Tags.hpp"
12 : #include "Parallel/AlgorithmExecution.hpp"
13 : #include "Parallel/GlobalCache.hpp"
14 : #include "Parallel/Invoke.hpp"
15 :
16 : /// \cond
17 : namespace Tags {
18 : struct TimeStepId;
19 : } // namespace Tags
20 : /// \endcond
21 :
22 : namespace Cce {
23 : namespace Actions {
24 :
25 : /*!
26 : * \ingroup ActionsGroup
27 : * \brief Terminates if the current `::Tags::TimeStepId` has time value later or
28 : * equal to `Tags::EndTime`.
29 : *
30 : * \details Uses:
31 : * - DataBox:
32 : * - `Cce::Tags::EndTime`
33 : * - `Tags::TimeStepId`
34 : *
35 : * \ref DataBoxGroup changes:
36 : * - Adds: nothing
37 : * - Removes: nothing
38 : * - Modifies: nothing
39 : *
40 : */
41 1 : struct ExitIfEndTimeReached {
42 : template <typename DbTags, typename... InboxTags, typename Metavariables,
43 : typename ArrayIndex, typename ActionList,
44 : typename ParallelComponent>
45 0 : static Parallel::iterable_action_return_t apply(
46 : db::DataBox<DbTags>& box,
47 : const tuples::TaggedTuple<InboxTags...>& /*inboxes*/,
48 : const Parallel::GlobalCache<Metavariables>& /*cache*/,
49 : const ArrayIndex& /*array_index*/, const ActionList /*meta*/,
50 : const ParallelComponent* const /*meta*/) {
51 : return {db::get<::Tags::TimeStepId>(box).substep_time() >=
52 : db::get<Tags::EndTime>(box)
53 : ? Parallel::AlgorithmExecution::Pause
54 : : Parallel::AlgorithmExecution::Continue,
55 : std::nullopt};
56 : }
57 : };
58 :
59 : } // namespace Actions
60 : } // namespace Cce
|