Line data Source code
1 0 : // Distributed under the MIT License.
2 : // See LICENSE.txt for details.
3 :
4 : #pragma once
5 :
6 : #include <cstddef>
7 : #include <optional>
8 : #include <tuple>
9 : #include <utility>
10 :
11 : #include "DataStructures/DataBox/DataBox.hpp"
12 : #include "Evolution/DgSubcell/Actions/Labels.hpp"
13 : #include "Evolution/DgSubcell/ActiveGrid.hpp"
14 : #include "Evolution/DgSubcell/Tags/ActiveGrid.hpp"
15 : #include "Parallel/AlgorithmExecution.hpp"
16 : #include "ParallelAlgorithms/Actions/Goto.hpp"
17 : #include "Utilities/ErrorHandling/Error.hpp"
18 : #include "Utilities/TMPL.hpp"
19 :
20 : /// \cond
21 : namespace Parallel {
22 : template <typename Metavariables>
23 : class GlobalCache;
24 : } // namespace Parallel
25 : namespace tuples {
26 : template <typename...>
27 : class TaggedTuple;
28 : } // namespace tuples
29 : /// \endcond
30 :
31 : namespace evolution::dg::subcell::Actions {
32 : /*!
33 : * \brief Goes to `Labels::BeginDg` or `Labels::BeginSubcell` depending on
34 : * whether the active grid is `Dg` or `Subcell`.
35 : *
36 : * GlobalCache: nothing
37 : *
38 : * DataBox:
39 : * - Uses:
40 : * - `subcell::Tags::ActiveGrid`
41 : */
42 1 : struct SelectNumericalMethod {
43 : template <typename DbTagsList, typename... InboxTags, typename Metavariables,
44 : typename ArrayIndex, typename ActionList,
45 : typename ParallelComponent>
46 0 : static Parallel::iterable_action_return_t apply(
47 : db::DataBox<DbTagsList>& box,
48 : const tuples::TaggedTuple<InboxTags...>& /*inboxes*/,
49 : const Parallel::GlobalCache<Metavariables>& /*cache*/,
50 : const ArrayIndex& /*array_index*/, ActionList /*meta*/,
51 : const ParallelComponent* const /*meta*/) {
52 : // Note: we jump to the `Label+1` because the label actions don't do
53 : // anything anyway
54 : if (db::get<Tags::ActiveGrid>(box) == subcell::ActiveGrid::Dg) {
55 : const size_t dg_index =
56 : tmpl::index_of<ActionList, ::Actions::Label<Labels::BeginDg>>::value +
57 : 1;
58 : return {Parallel::AlgorithmExecution::Continue, dg_index};
59 : } else if (db::get<Tags::ActiveGrid>(box) == subcell::ActiveGrid::Subcell) {
60 : const size_t subcell_index =
61 : tmpl::index_of<ActionList,
62 : ::Actions::Label<Labels::BeginSubcell>>::value +
63 : 1;
64 : return {Parallel::AlgorithmExecution::Continue, subcell_index};
65 : }
66 : ERROR(
67 : "Only know DG and subcell active grids for selecting the numerical "
68 : "method.");
69 : }
70 : };
71 : } // namespace evolution::dg::subcell::Actions
|