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/ReceiveTags.hpp"
17 #include "Evolution/Systems/Cce/Tags.hpp"
18 #include "Evolution/Systems/Cce/WorldtubeDataManager.hpp"
19 #include "Parallel/GlobalCache.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  bool successfully_populated = false;
100  typename Metavariables::cce_boundary_communication_tags>>(
101  make_not_null(&box),
102  [&successfully_populated, &time](
104  worldtube_data_manager,
105  const gsl::not_null<Variables<
106  typename Metavariables::cce_boundary_communication_tags>*>
107  boundary_variables) noexcept {
108  successfully_populated =
109  (*worldtube_data_manager)
110  ->populate_hypersurface_boundary_data(
111  boundary_variables, time.substep_time().value());
112  });
113  if (not successfully_populated) {
114  ERROR("Insufficient boundary data to proceed, exiting early at time " +
115  std::to_string(time.substep_time().value()));
116  }
118  typename Metavariables::cce_boundary_communication_tags>>(
119  Parallel::get_parallel_component<EvolutionComponent>(cache), time,
121  typename Metavariables::cce_boundary_communication_tags>>(box),
122  true);
123  }
124 };
125 
126 /*!
127  * \ingroup ActionsGroup
128  * \brief Submits a request for CCE boundary data at the specified `time` to the
129  * `Cce::InterfaceManagers::GhInterfaceManager`, and sends the data to the
130  * `EvolutionComponent` (template argument) if it is ready.
131  *
132  * \details This uses the `Cce::InterfaceManagers::GhInterfaceManager` to
133  * perform all of the work of managing the buffer of data sent from the GH
134  * system and interpolating if necessary and supported. This dispatches then to
135  * `Cce::Actions::SendToEvolution<GhWorldtubeBoundary<Metavariables>,
136  * EvolutionComponent>` if the boundary data is ready, otherwise
137  * simply submits the request and waits for data to become available via
138  * `Cce::Actions::ReceiveGhWorldtubeData`, which will call
139  * `Cce::Actions::SendToEvolution<GhWorldtubeBoundary<Metavariables>,
140  * EvolutionComponent>` as soon as the data becomes available.
141  *
142  * \ref DataBoxGroup changes:
143  * - Adds: nothing
144  * - Removes: nothing
145  * - Modifies:
146  * - `Tags::GhInterfaceManager`
147  */
148 template <typename Metavariables, typename EvolutionComponent>
150  EvolutionComponent> {
151  template <typename ParallelComponent, typename... DbTags, typename ArrayIndex,
152  Requires<tmpl2::flat_any_v<std::is_same_v<
154  typename Metavariables::cce_boundary_communication_tags>,
155  DbTags>...>> = nullptr>
156  static void apply(db::DataBox<tmpl::list<DbTags...>>& box,
158  const ArrayIndex& /*array_index*/,
159  const TimeStepId& time) noexcept {
160  db::mutate<Tags::GhInterfaceManager>(
161  make_not_null(&box),
162  [&time, &cache](const gsl::not_null<
164  interface_manager) noexcept {
165  (*interface_manager)->request_gh_data(time);
166  const auto gh_data =
167  (*interface_manager)->retrieve_and_remove_first_ready_gh_data();
168  if (static_cast<bool>(gh_data)) {
170  GhWorldtubeBoundary<Metavariables>, EvolutionComponent>>(
173  get<0>(*gh_data), get<1>(*gh_data));
174  }
175  });
176  }
177 };
178 
179 /// \cond
180 template <typename Metavariables, typename EvolutionComponent>
181 struct SendToEvolution<GhWorldtubeBoundary<Metavariables>, EvolutionComponent> {
182  template <typename ParallelComponent, typename... DbTags, typename ArrayIndex,
183  Requires<tmpl2::flat_any_v<std::is_same_v<
185  typename Metavariables::cce_boundary_communication_tags>,
186  DbTags>...>> = nullptr>
187  static void apply(db::DataBox<tmpl::list<DbTags...>>& box,
189  const ArrayIndex& /*array_index*/, const TimeStepId& time,
190  const InterfaceManagers::GhInterfaceManager::gh_variables&
191  gh_variables) noexcept {
193  typename Metavariables::cce_boundary_communication_tags>>(
194  make_not_null(&box),
195  [&gh_variables](
196  const gsl::not_null<Variables<
197  typename Metavariables::cce_boundary_communication_tags>*>
198  boundary_variables,
199  const double extraction_radius, const double l_max) noexcept {
201  boundary_variables,
203  gh_variables),
205  gh_variables),
207  gh_variables),
208  extraction_radius, l_max);
209  },
210  db::get<InitializationTags::ExtractionRadius>(box),
211  db::get<Tags::LMax>(box));
213  typename Metavariables::cce_boundary_communication_tags>>(
214  Parallel::get_parallel_component<EvolutionComponent>(cache), time,
216  typename Metavariables::cce_boundary_communication_tags>>(box),
217  true);
218  }
219 };
220 /// \endcond
221 
222 } // namespace Actions
223 } // namespace Cce
get
constexpr Tag::type & get(Variables< TagList > &v) noexcept
Return Tag::type pointing into the contiguous array.
Definition: Variables.hpp:639
Parallel::GlobalCache
Definition: ElementReceiveInterpPoints.hpp:16
GlobalCache.hpp
Parallel::get_parallel_component
auto get_parallel_component(GlobalCache< Metavariables > &cache) noexcept -> Parallel::proxy_from_parallel_component< GlobalCache_detail::get_component_if_mocked< typename Metavariables::component_list, ParallelComponentTag >> &
Access the Charm++ proxy associated with a ParallelComponent.
Definition: GlobalCache.hpp:223
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:1116
db::mutate
void mutate(const gsl::not_null< DataBox< TagList > * > box, Invokable &&invokable, Args &&... args) noexcept
Allows changing the state of one or more non-computed elements in the DataBox.
Definition: DataBox.hpp:1003
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:1424
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
Parallel::receive_data
void receive_data(Proxy &&proxy, typename ReceiveTag::temporal_id temporal_id, ReceiveDataType &&receive_data, const bool enable_if_disabled=false) noexcept
Send the data args... to the algorithm running on proxy, and tag the message with the identifier temp...
Definition: Invoke.hpp:47
Gsl.hpp
Cce::Tags::H5WorldtubeBoundaryDataManager
A tag that constructs a MetricWorldtubeDataManager from options.
Definition: OptionTags.hpp:218
Cce::create_bondi_boundary_data
void create_bondi_boundary_data(const gsl::not_null< Variables< BoundaryTagList > * > 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:792
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:82
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
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
gsl::not_null
Require a pointer to not be a nullptr
Definition: Gsl.hpp:183
string