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/WorldtubeInterfaceManager.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,
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::GhWorldtubeInterfaceManager`, and sends the data to the
116  * `EvolutionComponent` (template argument) if it is ready.
117  *
118  * \details This uses the `Cce::GhWorldtubeInterfaceManager` to perform all of
119  * the work of managing the buffer of data sent from the GH system and
120  * 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,
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](
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>>(
158  GhWorldtubeBoundary<Metavariables>>(cache),
159  get<0>(*gh_data), get<1>(*gh_data), get<2>(*gh_data),
160  get<3>(*gh_data));
161  }
162  });
163  }
164 };
165 
166 /// \cond
167 template <typename Metavariables, typename EvolutionComponent>
168 struct SendToEvolution<GhWorldtubeBoundary<Metavariables>, EvolutionComponent> {
169  template <typename ParallelComponent, typename... DbTags, typename ArrayIndex,
172  typename Metavariables::cce_boundary_communication_tags>,
173  DbTags>...>> = nullptr>
174  static void apply(db::DataBox<tmpl::list<DbTags...>>& box,
176  const ArrayIndex& /*array_index*/, const TimeStepId& time,
177  const tnsr::aa<DataVector, 3>& spacetime_metric,
178  const tnsr::iaa<DataVector, 3>& phi,
179  const tnsr::aa<DataVector, 3>& pi) noexcept {
181  make_not_null(&box), phi, pi, spacetime_metric,
182  db::get<InitializationTags::ExtractionRadius>(box),
183  db::get<Tags::LMax>(box));
185  typename Metavariables::cce_boundary_communication_tags>>(
186  Parallel::get_parallel_component<EvolutionComponent>(cache), time,
188  typename Metavariables::cce_boundary_communication_tags>>(box),
189  true);
190  }
191 };
192 /// \endcond
193 
194 } // namespace Actions
195 } // namespace Cce
void phi(gsl::not_null< tnsr::iaa< DataType, SpatialDim, Frame > *> phi, const Scalar< DataType > &lapse, const tnsr::i< DataType, SpatialDim, Frame > &deriv_lapse, const tnsr::I< DataType, SpatialDim, Frame > &shift, const tnsr::iJ< DataType, SpatialDim, Frame > &deriv_shift, const tnsr::ii< DataType, SpatialDim, Frame > &spatial_metric, const tnsr::ijj< DataType, SpatialDim, Frame > &deriv_spatial_metric) noexcept
Computes the auxiliary variable used by the generalized harmonic formulation of Einstein&#39;s equations...
Definition: VariablesTag.hpp:21
#define ERROR(m)
prints an error message to the standard error stream and aborts the program.
Definition: Error.hpp:36
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:51
The set of utilities for performing Cauchy characteristic evolution and Cauchy characteristic matchin...
Definition: BoundaryComputeAndSendToEvolution.hpp:28
constexpr bool flat_any_v
A non-short-circuiting logical OR between bools &#39;B"".
Definition: TMPL.hpp:529
Defines class TimeStepId.
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, placing the result in the passed DataBox.
Definition: BoundaryData.hpp:789
void spacetime_metric(gsl::not_null< tnsr::aa< DataType, Dim, Frame > *> spacetime_metric, const Scalar< DataType > &lapse, const tnsr::I< DataType, Dim, Frame > &shift, const tnsr::ii< DataType, Dim, Frame > &spatial_metric) noexcept
Computes the spacetime metric from the spatial metric, lapse, and shift.
double value() const noexcept
Approximate numerical value of the Time.
Definition: Time.hpp:44
A unique identifier for the temporal state of an integrated system.
Definition: TimeStepId.hpp:25
Component that supplies CCE worldtube boundary data.
Definition: WorldtubeBoundary.hpp:39
Defines classes and functions used for manipulating DataBox&#39;s.
constexpr bool is_same_v
Variable template for is_same.
Definition: TypeTraits.hpp:194
const Time & substep_time() const noexcept
Time of the current substep.
Definition: TimeStepId.hpp:61
A receive tag for the data sent to the CCE evolution component from the CCE boundary component...
Definition: ReceiveTags.hpp:16
Defines Parallel::printf for writing to stdout.
Definition: InterpolationTargetWedgeSectionTorus.hpp:25
Computes Bondi boundary data from GH evolution variables and sends the result to the EvolutionCompone...
Definition: BoundaryComputeAndSendToEvolution.hpp:60
A Charm++ chare that caches constant data once per Charm++ node.
Definition: ConstGlobalCache.hpp:136
void pi(gsl::not_null< tnsr::aa< DataType, SpatialDim, Frame > *> pi, const Scalar< DataType > &lapse, const Scalar< DataType > &dt_lapse, const tnsr::I< DataType, SpatialDim, Frame > &shift, const tnsr::I< DataType, SpatialDim, Frame > &dt_shift, const tnsr::ii< DataType, SpatialDim, Frame > &spatial_metric, const tnsr::ii< DataType, SpatialDim, Frame > &dt_spatial_metric, const tnsr::iaa< DataType, SpatialDim, Frame > &phi) noexcept
Computes the conjugate momentum of the spacetime metric .
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:1444
const auto & get(const DataBox< TagList > &box) noexcept
Retrieve the item with tag Tag from the DataBox.
Definition: DataBox.hpp:1134
Wraps the template metaprogramming library used (brigand)
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
Component that supplies CCE worldtube boundary data sourced from a running GH system.
Definition: WorldtubeBoundary.hpp:105
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
void simple_action(Proxy &&proxy) noexcept
Invoke a simple action on proxy
Definition: Invoke.hpp:112
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 macro ERROR.
Obtains the CCE boundary data at the specified time, and reports it to the EvolutionComponent via Act...
Definition: BoundaryComputeAndSendToEvolution.hpp:40
Definition: ComputeTimeDerivative.hpp:29
Require a pointer to not be a nullptr
Definition: Gsl.hpp:182