ReceiveWorldtubeData.hpp
1 // Distributed under the MIT License.
2 // See LICENSE.txt for details.
3 
4 #pragma once
5 
6 #include <tuple>
7 
10 #include "Evolution/Systems/Cce/ReceiveTags.hpp"
12 #include "Parallel/Invoke.hpp"
13 #include "Time/Tags.hpp"
14 #include "Time/TimeStepId.hpp"
15 #include "Utilities/Gsl.hpp"
16 #include "Utilities/TMPL.hpp"
17 
18 namespace Cce {
19 namespace Actions {
20 
21 /*!
22  * \ingroup Actions
23  * \brief Takes the boundary data needed to perform the CCE linear solves as
24  * arguments and puts them in the \ref DataBoxGroup, updating the
25  * `Cce::Tags::BoundaryTime` accordingly.
26  *
27  * \details The boundary data is computed by a separate component, and packaged
28  * into a `Variables<tmpl::list<BoundaryTags...>>` which is sent in the argument
29  * of the simple action invocation. The `TimeStepId` is also provided to confirm
30  * the time associated with the passed boundary data.
31  *
32  * \ref DataBoxGroup changes:
33  * - Adds: nothing
34  * - Removes: nothing
35  * - Modifies:
36  * - All tags in `BoundaryTags`
37  * - `Cce::Tags::BoundaryTime`
38  */
39 template <typename Metavariables>
41  using inbox_tags = tmpl::list<Cce::ReceiveTags::BoundaryData<
42  typename Metavariables::cce_boundary_communication_tags>>;
43 
44  template <typename DbTags, typename... InboxTags, typename ArrayIndex,
45  typename ActionList, typename ParallelComponent,
46  Requires<tmpl::list_contains_v<
47  tmpl::list<InboxTags...>,
49  typename Metavariables::cce_boundary_communication_tags>>> =
50  nullptr>
51  static auto apply(db::DataBox<DbTags>& box,
54  const ArrayIndex& /*array_index*/,
55  const ActionList /*meta*/,
56  const ParallelComponent* const /*meta*/) noexcept {
58  typename Metavariables::cce_boundary_communication_tags>>(inboxes);
59  tmpl::for_each<typename Metavariables::cce_boundary_communication_tags>(
60  [&inbox, &box ](auto tag_v) noexcept {
61  using tag = typename decltype(tag_v)::type;
62  db::mutate<tag>(
63  make_not_null(&box),
64  [&inbox](const gsl::not_null<db::item_type<tag>*> destination,
65  const TimeStepId& time) noexcept {
66  *destination = get<tag>(inbox[time]);
67  },
68  db::get<::Tags::TimeStepId>(box));
69  });
70  inbox.erase(db::get<::Tags::TimeStepId>(box));
71  return std::forward_as_tuple(std::move(box));
72  }
73  template <typename DbTags, typename... InboxTags, typename ArrayIndex,
74  typename ActionList, typename ParallelComponent,
75  Requires<not tmpl::list_contains_v<
76  tmpl::list<InboxTags...>,
78  typename Metavariables::cce_boundary_communication_tags>>> =
79  nullptr>
80  static auto apply(db::DataBox<DbTags>& box,
81  const tuples::TaggedTuple<InboxTags...>& /*inboxes*/,
83  const ArrayIndex& /*array_index*/,
84  const ActionList /*meta*/,
85  const ParallelComponent* const /*meta*/) noexcept {
86  ERROR(
87  "Required tags not present in the inbox or databox to transfer the CCE "
88  "boundary data");
89  // provided for return type inference. This line will never be executed.
90  return std::forward_as_tuple(std::move(box));
91  }
92 
93  template <typename DbTags, typename... InboxTags, typename ArrayIndex,
94  Requires<tmpl::list_contains_v<
95  tmpl::list<InboxTags...>,
97  typename Metavariables::cce_boundary_communication_tags>>> =
98  nullptr>
99  static bool is_ready(
100  const db::DataBox<DbTags>& box,
101  const tuples::TaggedTuple<InboxTags...>& inboxes,
103  const ArrayIndex& /*array_index*/) noexcept {
105  typename Metavariables::cce_boundary_communication_tags>>(
106  inboxes)
107  .count(db::get<::Tags::TimeStepId>(box)) == 1;
108  }
109 
110  template <typename DbTags, typename... InboxTags, typename ArrayIndex,
111  Requires<not tmpl::list_contains_v<
112  tmpl::list<InboxTags...>,
114  typename Metavariables::cce_boundary_communication_tags>>> =
115  nullptr>
116  static bool is_ready(
117  const db::DataBox<DbTags>& /*box*/,
118  const tuples::TaggedTuple<InboxTags...>& /*inboxes*/,
120  const ArrayIndex& /*array_index*/) noexcept {
121  return false;
122  }
123 };
124 } // namespace Actions
125 } // namespace Cce
#define ERROR(m)
prints an error message to the standard error stream and aborts the program.
Definition: Error.hpp:36
Contains functionality for Cauchy Characteristic Extraction.
Definition: BoundaryComputeAndSendToEvolution.hpp:24
Takes the boundary data needed to perform the CCE linear solves as arguments and puts them in the Dat...
Definition: ReceiveWorldtubeData.hpp:40
constexpr Tag::type & get(Variables< TagList > &v) noexcept
Return Tag::type pointing into the contiguous array.
Definition: Variables.hpp:661
Defines class TimeStepId.
A unique identifier for the temporal state of an integrated system.
Definition: TimeStepId.hpp:25
An associative container that is indexed by structs.
Definition: TaggedTuple.hpp:273
Defines classes and functions used for manipulating DataBox&#39;s.
A receive tag for the data sent to the CCE evolution component from the CCE boundary component...
Definition: ReceiveTags.hpp:16
Definition: InterpolationTargetWedgeSectionTorus.hpp:24
Defines class Variables.
A Charm++ chare that caches constant data once per Charm++ node.
Definition: ConstGlobalCache.hpp:135
Wraps the template metaprogramming library used (brigand)
Defines functions and classes from the GSL.
gsl::not_null< T * > make_not_null(T *ptr) noexcept
Construct a not_null from a pointer. Often this will be done as an implicit conversion, but it may be necessary to perform the conversion explicitly when type deduction is desired.
Definition: Gsl.hpp:879
typename Requires_detail::requires_impl< B >::template_error_type_failed_to_meet_requirements_on_template_parameters Requires
Express requirements on the template parameters of a function or class, replaces std::enable_if_t ...
Definition: Requires.hpp:67
Defines class template ConstGlobalCache.
Defines tags related to Time quantities.
Definition: ComputeTimeDerivative.hpp:28
Require a pointer to not be a nullptr
Definition: Gsl.hpp:182