RemoveOptionsAndTerminatePhase.hpp
1 // Distributed under the MIT License.
2 // See LICENSE.txt for details.
3 
4 #pragma once
5 
6 #include <type_traits>
7 
10 #include "Parallel/ParallelComponentHelpers.hpp"
11 #include "Utilities/TMPL.hpp"
13 
14 namespace Initialization {
15 
16 /// \ingroup InitializationGroup
17 /// Available actions to be used in the initialization.
18 ///
19 /// The action list for initialization must end with the
20 /// `Initialization::Actions::RemoveOptionsAndTerminatePhase` action. For
21 /// example,
22 ///
23 /// \snippet Test_RemoveOptionsAndTerminatePhase.cpp actions
24 ///
25 namespace Actions {
26 /// \ingroup InitializationGroup
28  template <typename DbTagsList, typename... InboxTags, typename Metavariables,
29  typename ActionList, typename ArrayIndex,
30  typename ParallelComponent>
31  static auto apply(db::DataBox<DbTagsList>& box,
32  const tuples::TaggedTuple<InboxTags...>& /*inboxes*/,
34  const ArrayIndex& /*array_index*/, ActionList /*meta*/,
35  const ParallelComponent* const /*meta*/) noexcept {
36  using initialization_tags = Parallel::get_initialization_tags<ActionList>;
37  using initialization_tags_to_keep =
39  // Keep the tags that are in initialization_tags_to_keep.
40  using tags_to_remove = tmpl::remove_if<
41  initialization_tags,
42  tmpl::bind<tmpl::list_contains, tmpl::pin<initialization_tags_to_keep>,
43  tmpl::_1>>;
44  // Retrieve the `initialization_tags` that are still in the DataBox
45  // and remove them.
46  using tags_to_remove_this_time = tmpl::filter<
47  tags_to_remove,
48  tmpl::bind<
49  tmpl::list_contains,
50  tmpl::pin<typename db::DataBox<DbTagsList>::simple_item_tags>,
51  tmpl::_1>>;
52  static_assert(std::is_same<tmpl::back<ActionList>,
54  "The last action in the initialization phase must be "
55  "Initialization::Actions::RemoveOptionsAndTerminatePhase.");
56  return std::make_tuple(
57  db::create_from<tags_to_remove_this_time>(std::move(box)), true);
58  }
59 };
60 } // namespace Actions
61 } // namespace Initialization
Defines class tuples::TaggedTuple.
tmpl::remove_duplicates< tmpl::flatten< tmpl::list< AllocationTagsList, tmpl::transform< InitializationActionsList, detail::get_initialization_tags_from_action< tmpl::_1 > >> >> get_initialization_tags
Given a list of initialization actions, and possibly a list of tags needed for allocation of an array...
Definition: ParallelComponentHelpers.hpp:140
Definition: ConservativeSystem.hpp:34
tmpl::remove_duplicates< tmpl::flatten< tmpl::transform< InitializationActionsList, detail::get_initialization_tags_to_keep_from_action< tmpl::_1 > >> > get_initialization_tags_to_keep
Given a list of initialization actions, returns a list of the unique initialization_tags_to_keep for ...
Definition: ParallelComponentHelpers.hpp:151
An associative container that is indexed by structs.
Definition: TaggedTuple.hpp:273
Defines classes and functions used for manipulating DataBox&#39;s.
Definition: RemoveOptionsAndTerminatePhase.hpp:27
Definition: InterpolationTargetWedgeSectionTorus.hpp:24
A Charm++ chare that caches constant data once per Charm++ node.
Definition: ConstGlobalCache.hpp:135
Wraps the template metaprogramming library used (brigand)
Defines class template ConstGlobalCache.
Definition: ComputeTimeDerivative.hpp:28