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 <memory>
8 :
9 : #include "Parallel/Algorithms/AlgorithmNodegroupDeclarations.hpp"
10 : #include "Parallel/ArrayCollection/CreateElementCollection.hpp"
11 : #include "Parallel/ArrayCollection/DgElementArrayMember.hpp"
12 : #include "Parallel/ArrayCollection/DgElementArrayMemberBase.hpp"
13 : #include "Parallel/ArrayCollection/Tags/ElementCollection.hpp"
14 : #include "Parallel/ArrayCollection/TransformPdalForNodegroup.hpp"
15 : #include "Parallel/GlobalCache.hpp"
16 : #include "Parallel/Local.hpp"
17 : #include "Parallel/ParallelComponentHelpers.hpp"
18 : #include "Parallel/Printf/Printf.hpp"
19 : #include "ParallelAlgorithms/Actions/TerminatePhase.hpp"
20 : #include "Utilities/Gsl.hpp"
21 : #include "Utilities/TMPL.hpp"
22 :
23 : namespace Parallel {
24 : /*!
25 : * \brief A collection of DG elements on a node.
26 : *
27 : * The `PhaseDepActionList` is the PDAL that was used for the array
28 : * approach. Some actions will require updating to support nodegroups if they
29 : * haven't already been.
30 : */
31 : template <size_t Dim, class Metavariables, class PhaseDepActionList>
32 1 : struct DgElementCollection {
33 : /// \brief The `DgElementCollection` is currently a nodegroup.
34 : ///
35 : /// It should be possible to generalize this to work as a group too.
36 1 : using chare_type = Parallel::Algorithms::Nodegroup;
37 0 : static constexpr bool checkpoint_data = true;
38 : /// \brief The metavariables
39 1 : using metavariables = Metavariables;
40 : /// \brief The simple tags necessary from option parsing.
41 1 : using simple_tags_from_options = Parallel::get_simple_tags_from_options<
42 : Parallel::get_initialization_actions_list<PhaseDepActionList>>;
43 : /// \brief The type of the `Parallel::DgElementArrayMember` with all
44 : /// template parameters.
45 1 : using dg_element_array_member =
46 : Parallel::DgElementArrayMember<Dim, Metavariables, PhaseDepActionList,
47 : simple_tags_from_options>;
48 : /// \brief The tag `Parallel::Tags::ElementCollection` of this
49 : /// `DgElementCollection`
50 1 : using element_collection_tag =
51 : Parallel::Tags::ElementCollection<Dim, Metavariables, PhaseDepActionList,
52 : simple_tags_from_options>;
53 :
54 : /// \brief The phase dependent action lists.
55 : ///
56 : /// These are computed using
57 : /// `Parallel::TransformPhaseDependentActionListForNodegroup` from the
58 : /// `PhaseDepActionList` template parameter.
59 1 : using phase_dependent_action_list = tmpl::append<
60 : tmpl::list<Parallel::PhaseActions<
61 : Parallel::Phase::Initialization,
62 : tmpl::list<Actions::CreateElementCollection<Dim, Metavariables,
63 : PhaseDepActionList,
64 : simple_tags_from_options>,
65 : Parallel::Actions::TerminatePhase>>>,
66 : TransformPhaseDependentActionListForNodegroup<PhaseDepActionList>>;
67 :
68 : /// @{
69 : /// \brief The tags for the global cache.
70 : ///
71 : /// These are computed from the `PhaseDepActionList` template parameter.
72 1 : using const_global_cache_tags = tmpl::remove_duplicates<
73 : typename Parallel::detail::get_const_global_cache_tags_from_pdal<
74 : PhaseDepActionList>::type>;
75 1 : using mutable_global_cache_tags =
76 : typename Parallel::detail::get_mutable_global_cache_tags_from_pdal<
77 : PhaseDepActionList>::type;
78 : /// @}
79 :
80 : /// \brief Starts the next phase of execution.
81 1 : static void execute_next_phase(
82 : const Parallel::Phase next_phase,
83 : Parallel::CProxy_GlobalCache<Metavariables>& global_cache) {
84 : Parallel::printf("%s\n", next_phase);
85 : auto& local_cache = *Parallel::local_branch(global_cache);
86 : Parallel::get_parallel_component<DgElementCollection>(local_cache)
87 : .start_phase(next_phase);
88 : }
89 : };
90 : } // namespace Parallel
|