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"
11 #include "Parallel/AlgorithmMetafunctions.hpp"
12 #include "Parallel/GlobalCache.hpp"
13 #include "Parallel/Invoke.hpp"
14 #include "Time/Tags.hpp"
15 #include "Time/TimeStepId.hpp"
16 #include "Utilities/Gsl.hpp"
17 #include "Utilities/TMPL.hpp"
18 
19 namespace Cce {
20 namespace Actions {
21 
22 /*!
23  * \ingroup ActionsGroup
24  * \brief Takes the boundary data needed to perform the CCE linear solves as
25  * arguments and puts them in the \ref DataBoxGroup, updating the
26  * `Cce::Tags::BoundaryTime` accordingly.
27  *
28  * \details The boundary data is computed by a separate component, and packaged
29  * into a `Variables<tmpl::list<BoundaryTags...>>` which is sent in the argument
30  * of the simple action invocation. The `TimeStepId` is also provided to confirm
31  * the time associated with the passed boundary data.
32  *
33  * \ref DataBoxGroup changes:
34  * - Adds: nothing
35  * - Removes: nothing
36  * - Modifies:
37  * - All tags in `BoundaryTags`
38  * - `Cce::Tags::BoundaryTime`
39  */
40 template <typename Metavariables>
42  using inbox_tags = tmpl::list<Cce::ReceiveTags::BoundaryData<
43  typename Metavariables::cce_boundary_communication_tags>>;
44 
45  template <
46  typename DbTags, typename... InboxTags, typename ArrayIndex,
47  typename ActionList, typename ParallelComponent,
48  Requires<
49  tmpl::list_contains_v<
50  tmpl::list<InboxTags...>,
52  typename Metavariables::cce_boundary_communication_tags>> and
53  tmpl::list_contains_v<DbTags, ::Tags::TimeStepId>> = nullptr>
55  db::DataBox<DbTags>& box,
57  const Parallel::GlobalCache<Metavariables>& /*cache*/,
58  const ArrayIndex& /*array_index*/,
59  const ActionList /*meta*/,
60  const ParallelComponent* const /*meta*/) noexcept {
62  typename Metavariables::cce_boundary_communication_tags>>(inboxes);
63  if (inbox.count(db::get<::Tags::TimeStepId>(box)) != 1) {
64  return {std::move(box), Parallel::AlgorithmExecution::Retry};
65  }
66 
67  tmpl::for_each<typename Metavariables::cce_boundary_communication_tags>(
68  [&inbox, &box ](auto tag_v) noexcept {
69  using tag = typename decltype(tag_v)::type;
70  db::mutate<tag>(
71  make_not_null(&box),
72  [&inbox](const gsl::not_null<typename tag::type*> destination,
73  const TimeStepId& time) noexcept {
74  *destination = get<tag>(inbox[time]);
75  },
76  db::get<::Tags::TimeStepId>(box));
77  });
78  inbox.erase(db::get<::Tags::TimeStepId>(box));
79  return {std::move(box), Parallel::AlgorithmExecution::Continue};
80  }
81  template <
82  typename DbTags, typename... InboxTags, typename ArrayIndex,
83  typename ActionList, typename ParallelComponent,
84  Requires<
85  not tmpl::list_contains_v<
86  tmpl::list<InboxTags...>,
88  typename Metavariables::cce_boundary_communication_tags>> or
89  not tmpl::list_contains_v<DbTags, ::Tags::TimeStepId>> = nullptr>
90  static auto apply(db::DataBox<DbTags>& box,
91  const tuples::TaggedTuple<InboxTags...>& /*inboxes*/,
92  const Parallel::GlobalCache<Metavariables>& /*cache*/,
93  const ArrayIndex& /*array_index*/,
94  const ActionList /*meta*/,
95  const ParallelComponent* const /*meta*/) noexcept {
96  ERROR(
97  "Required tags not present in the inbox or databox to transfer the CCE "
98  "boundary data");
99  // provided for return type inference. This line will never be executed.
100  return std::forward_as_tuple(std::move(box));
101  }
102 };
103 } // namespace Actions
104 } // namespace Cce
Parallel::AlgorithmExecution::Retry
@ Retry
Temporarily stop executing iterable actions, but try the same action again after receiving data from ...
Parallel::GlobalCache
Definition: ElementReceiveInterpPoints.hpp:15
GlobalCache.hpp
Cce::Actions::ReceiveWorldtubeData
Takes the boundary data needed to perform the CCE linear solves as arguments and puts them in the Dat...
Definition: ReceiveWorldtubeData.hpp:41
tuple
db::get
const auto & get(const DataBox< TagList > &box) noexcept
Retrieve the item with tag Tag from the DataBox.
Definition: DataBox.hpp:791
ERROR
#define ERROR(m)
prints an error message to the standard error stream and aborts the program.
Definition: Error.hpp:37
Cce::ReceiveTags::BoundaryData
A receive tag for the data sent to the CCE evolution component from the CCE boundary component.
Definition: ReceiveTags.hpp:16
Parallel::AlgorithmExecution::Continue
@ Continue
Leave the algorithm termination flag in its current state.
DataBox.hpp
tuples::TaggedTuple
An associative container that is indexed by structs.
Definition: TaggedTuple.hpp:271
Parallel::AlgorithmExecution
AlgorithmExecution
The possible options for altering the current execution of the algorithm, used in the return type of ...
Definition: AlgorithmMetafunctions.hpp:31
TimeStepId
Definition: TimeStepId.hpp:25
Variables.hpp
TimeStepId.hpp
Cce
The set of utilities for performing Cauchy characteristic evolution and Cauchy characteristic matchin...
Definition: CharacteristicExtractFwd.hpp:6
Gsl.hpp
make_not_null
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,...
Definition: Gsl.hpp:880
Requires
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
TMPL.hpp
gsl::not_null
Require a pointer to not be a nullptr
Definition: ReadSpecPiecewisePolynomial.hpp:13