BoundaryComputeAndSendToEvolution.hpp
1 // Distributed under the MIT License.
2 // See LICENSE.txt for details.
3 
4 #pragma once
5 
6 #include <string>
7 #include <tuple>
8 
10 #include "DataStructures/VariablesTag.hpp"
11 #include "ErrorHandling/Error.hpp"
12 #include "Evolution/Systems/Cce/Actions/ReceiveWorldtubeData.hpp"
13 #include "Evolution/Systems/Cce/Components/WorldtubeBoundary.hpp"
14 #include "Evolution/Systems/Cce/InterfaceManagers/GhInterfaceManager.hpp"
15 #include "Evolution/Systems/Cce/OptionTags.hpp"
16 #include "Evolution/Systems/Cce/ReadBoundaryDataH5.hpp"
17 #include "Evolution/Systems/Cce/ReceiveTags.hpp"
18 #include "Evolution/Systems/Cce/Tags.hpp"
20 #include "Parallel/Invoke.hpp"
21 #include "Parallel/Printf.hpp"
22 #include "Time/Tags.hpp"
23 #include "Time/TimeStepId.hpp"
24 #include "Utilities/Gsl.hpp"
25 #include "Utilities/TMPL.hpp"
26 #include "Utilities/TypeTraits.hpp"
27 
28 namespace Cce {
29 namespace Actions {
30 
31 /*!
32  * \ingroup ActionsGroup
33  * \brief Obtains the CCE boundary data at the specified `time`, and reports it
34  * to the `EvolutionComponent` via `Actions::ReceiveWorldtubeData`.
35  *
36  * \details See the template partial specializations of this class for details
37  * on the different strategies for each component type.
38  */
39 template <typename BoundaryComponent, typename EvolutionComponent>
41 
42 /*!
43  * \ingroup ActionsGroup
44  * \brief Computes Bondi boundary data from GH evolution variables and sends the
45  * result to the `EvolutionComponent` (template argument).
46  *
47  * \details After the computation, this action will call
48  * `Cce::Actions::ReceiveWorldtubeData` on the `EvolutionComponent` with each of
49  * the types from `typename Metavariables::cce_boundary_communication_tags` sent
50  * as arguments
51  *
52  * \ref DataBoxGroup changes:
53  * - Adds: nothing
54  * - Removes: nothing
55  * - Modifies:
56  * - `Tags::Variables<typename
57  * Metavariables::cce_boundary_communication_tags>` (every tensor)
58  */
59 template <typename BoundaryComponent, typename EvolutionComponent>
61 
62 /*!
63  * \ingroup ActionsGroup
64  * \brief Obtains the CCE boundary data at the specified `time`, and reports it
65  * to the `EvolutionComponent` via `Actions::ReceiveWorldtubeData`.
66  *
67  * \details This uses the `WorldtubeDataManager` to perform all of the work of
68  * managing the file buffer, interpolating to the desired time point, and
69  * compute the Bondi quantities on the boundary. Once readied, it sends each
70  * tensor from the the full `Variables<typename
71  * Metavariables::cce_boundary_communication_tags>` back to the
72  * `EvolutionComponent`
73  *
74  * Uses:
75  * - DataBox:
76  * - `Tags::H5WorldtubeBoundaryDataManager`
77  *
78  * \ref DataBoxGroup changes:
79  * - Adds: nothing
80  * - Removes: nothing
81  * - Modifies:
82  * - `Tags::Variables<typename
83  * Metavariables::cce_boundary_communication_tags>` (every tensor)
84  */
85 template <typename Metavariables, typename EvolutionComponent>
87  EvolutionComponent> {
88  template <typename ParallelComponent, typename... DbTags, typename ArrayIndex,
89  Requires<tmpl2::flat_any_v<std::is_same_v<
91  typename Metavariables::cce_boundary_communication_tags>,
92  DbTags>...>> = nullptr>
93  static void apply(db::DataBox<tmpl::list<DbTags...>>& box,
95  const ArrayIndex& /*array_index*/,
96  const TimeStepId& time) noexcept {
97  if (not db::get<Tags::H5WorldtubeBoundaryDataManager>(box)
98  .populate_hypersurface_boundary_data(
99  make_not_null(&box), time.substep_time().value())) {
100  ERROR("Insufficient boundary data to proceed, exiting early at time " +
101  std::to_string(time.substep_time().value()));
102  }
104  typename Metavariables::cce_boundary_communication_tags>>(
105  Parallel::get_parallel_component<EvolutionComponent>(cache), time,
107  typename Metavariables::cce_boundary_communication_tags>>(box),
108  true);
109  }
110 };
111 
112 /*!
113  * \ingroup ActionsGroup
114  * \brief Submits a request for CCE boundary data at the specified `time` to the
115  * `Cce::InterfaceManagers::GhInterfaceManager`, and sends the data to the
116  * `EvolutionComponent` (template argument) if it is ready.
117  *
118  * \details This uses the `Cce::InterfaceManagers::GhInterfaceManager` to
119  * perform all of the work of managing the buffer of data sent from the GH
120  * system and interpolating if necessary and supported. This dispatches then to
121  * `Cce::Actions::SendToEvolution<GhWorldtubeBoundary<Metavariables>,
122  * EvolutionComponent>` if the boundary data is ready, otherwise
123  * simply submits the request and waits for data to become available via
124  * `Cce::Actions::ReceiveGhWorldtubeData`, which will call
125  * `Cce::Actions::SendToEvolution<GhWorldtubeBoundary<Metavariables>,
126  * EvolutionComponent>` as soon as the data becomes available.
127  *
128  * \ref DataBoxGroup changes:
129  * - Adds: nothing
130  * - Removes: nothing
131  * - Modifies:
132  * - `Tags::GhInterfaceManager`
133  */
134 template <typename Metavariables, typename EvolutionComponent>
136  EvolutionComponent> {
137  template <typename ParallelComponent, typename... DbTags, typename ArrayIndex,
138  Requires<tmpl2::flat_any_v<std::is_same_v<
140  typename Metavariables::cce_boundary_communication_tags>,
141  DbTags>...>> = nullptr>
142  static void apply(db::DataBox<tmpl::list<DbTags...>>& box,
144  const ArrayIndex& /*array_index*/,
145  const TimeStepId& time) noexcept {
146  db::mutate<Tags::GhInterfaceManager>(
147  make_not_null(&box),
148  [&time, &cache](const gsl::not_null<
150  interface_manager) noexcept {
151  (*interface_manager)->request_gh_data(time);
152  const auto gh_data =
153  (*interface_manager)->retrieve_and_remove_first_ready_gh_data();
154  if (static_cast<bool>(gh_data)) {
156  GhWorldtubeBoundary<Metavariables>, EvolutionComponent>>(
159  get<0>(*gh_data), get<1>(*gh_data));
160  }
161  });
162  }
163 };
164 
165 /// \cond
166 template <typename Metavariables, typename EvolutionComponent>
167 struct SendToEvolution<GhWorldtubeBoundary<Metavariables>, EvolutionComponent> {
168  template <typename ParallelComponent, typename... DbTags, typename ArrayIndex,
169  Requires<tmpl2::flat_any_v<std::is_same_v<
171  typename Metavariables::cce_boundary_communication_tags>,
172  DbTags>...>> = nullptr>
173  static void apply(db::DataBox<tmpl::list<DbTags...>>& box,
175  const ArrayIndex& /*array_index*/, const TimeStepId& time,
176  const InterfaceManagers::GhInterfaceManager::gh_variables&
177  gh_variables) noexcept {
179  make_not_null(&box),
183  gh_variables),
184  db::get<InitializationTags::ExtractionRadius>(box),
185  db::get<Tags::LMax>(box));
187  typename Metavariables::cce_boundary_communication_tags>>(
188  Parallel::get_parallel_component<EvolutionComponent>(cache), time,
190  typename Metavariables::cce_boundary_communication_tags>>(box),
191  true);
192  }
193 };
194 /// \endcond
195 
196 } // namespace Actions
197 } // namespace Cce
Parallel::ConstGlobalCache
Definition: ElementReceiveInterpPoints.hpp:16
get
constexpr Tag::type & get(Variables< TagList > &v) noexcept
Return Tag::type pointing into the contiguous array.
Definition: Variables.hpp:689
Error.hpp
tmpl2::flat_any_v
constexpr bool flat_any_v
A non-short-circuiting logical OR between bools 'B"".
Definition: TMPL.hpp:530
Tags::Variables
Definition: VariablesTag.hpp:21
tuple
db::get
const auto & get(const DataBox< TagList > &box) noexcept
Retrieve the item with tag Tag from the DataBox.
Definition: DataBox.hpp:1134
Parallel::receive_data
void receive_data(Proxy &&proxy, typename ReceiveTag::temporal_id temporal_id, ReceiveDataType &&receive_data, const bool enable_if_disabled) noexcept
Send the data args... to the algorithm running on proxy, and tag the message with the identifier temp...
Definition: Invoke.hpp:50
ERROR
#define ERROR(m)
prints an error message to the standard error stream and aborts the program.
Definition: Error.hpp:36
db::apply
constexpr auto apply(F &&f, const DataBox< BoxTags > &box, Args &&... args) noexcept
Apply the invokable f with argument Tags TagsList from DataBox box
Definition: DataBox.hpp:1443
Cce::ReceiveTags::BoundaryData
A receive tag for the data sent to the CCE evolution component from the CCE boundary component.
Definition: ReceiveTags.hpp:16
Printf.hpp
DataBox.hpp
Cce::H5WorldtubeBoundary
Component that supplies CCE worldtube boundary data.
Definition: WorldtubeBoundary.hpp:39
GeneralizedHarmonic::Tags::Pi
Conjugate momentum to the spacetime metric.
Definition: Tags.hpp:29
gr::Tags::SpacetimeMetric
Definition: Tags.hpp:17
TimeStepId
Definition: TimeStepId.hpp:25
TimeStepId.hpp
GeneralizedHarmonic::Tags::Phi
Auxiliary variable which is analytically the spatial derivative of the spacetime metric.
Definition: Tags.hpp:40
Cce
The set of utilities for performing Cauchy characteristic evolution and Cauchy characteristic matchin...
Definition: BoundaryComputeAndSendToEvolution.hpp:28
Gsl.hpp
Parallel::get_parallel_component
auto get_parallel_component(ConstGlobalCache< Metavariables > &cache) noexcept -> Parallel::proxy_from_parallel_component< ConstGlobalCache_detail::get_component_if_mocked< typename Metavariables::component_list, ParallelComponentTag >> &
Access the Charm++ proxy associated with a ParallelComponent.
Definition: ConstGlobalCache.hpp:223
Cce::Actions::SendToEvolution
Computes Bondi boundary data from GH evolution variables and sends the result to the EvolutionCompone...
Definition: BoundaryComputeAndSendToEvolution.hpp:60
Cce::GhWorldtubeBoundary
Component that supplies CCE worldtube boundary data sourced from a running GH system.
Definition: WorldtubeBoundary.hpp:106
Parallel::simple_action
void simple_action(Proxy &&proxy) noexcept
Invoke a simple action on proxy
Definition: Invoke.hpp:111
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
std::unique_ptr
db::DataBox
Definition: InterpolationTargetWedgeSectionTorus.hpp:24
Cce::create_bondi_boundary_data
void create_bondi_boundary_data(const gsl::not_null< db::DataBox< DataBoxTagList > * > bondi_boundary_data, const tnsr::iaa< DataVector, 3 > &phi, const tnsr::aa< DataVector, 3 > &pi, const tnsr::aa< DataVector, 3 > &spacetime_metric, const double extraction_radius, const size_t l_max) noexcept
Process the worldtube data from generalized harmonic quantities to desired Bondi quantities,...
Definition: BoundaryData.hpp:797
TMPL.hpp
Cce::Actions::BoundaryComputeAndSendToEvolution
Obtains the CCE boundary data at the specified time, and reports it to the EvolutionComponent via Act...
Definition: BoundaryComputeAndSendToEvolution.hpp:40
ConstGlobalCache.hpp
gsl::not_null
Require a pointer to not be a nullptr
Definition: Gsl.hpp:183
string