AddTemporalIdsToInterpolationTarget.hpp
1 // Distributed under the MIT License.
2 // See LICENSE.txt for details.
3 
4 #pragma once
5 
6 #include <algorithm>
7 
11 #include "Domain/Tags.hpp"
12 #include "NumericalAlgorithms/Interpolation/Tags.hpp"
14 #include "Parallel/Invoke.hpp"
16 
17 namespace intrp {
18 
19 namespace Actions {
20 /// \ingroup ActionsGroup
21 /// \brief Adds `temporal_id`s on which this InterpolationTarget
22 /// should be triggered.
23 ///
24 /// Uses:
25 /// - DataBox:
26 /// - `Tags::TemporalIds<Metavariables>`
27 ///
28 /// DataBox changes:
29 /// - Adds: nothing
30 /// - Removes: nothing
31 /// - Modifies:
32 /// - `Tags::TemporalIds<Metavariables>`
33 template <typename InterpolationTargetTag>
35  template <typename DbTags, typename... InboxTags, typename Metavariables,
36  typename ArrayIndex, typename ActionList,
37  typename ParallelComponent,
38  Requires<tmpl::list_contains_v<
39  DbTags, typename Tags::TemporalIds<Metavariables>>> = nullptr>
40  static void apply(db::DataBox<DbTags>& box,
41  const tuples::TaggedTuple<InboxTags...>& /*inboxes*/,
43  const ArrayIndex& /*array_index*/,
44  const ActionList /*meta*/,
45  const ParallelComponent* const /*meta*/,
47  temporal_ids) noexcept {
48  const bool begin_interpolation =
49  db::get<Tags::TemporalIds<Metavariables>>(box).empty();
50 
51  db::mutate<Tags::TemporalIds<Metavariables>>(
52  make_not_null(&box), [&temporal_ids](
54  Tags::TemporalIds<Metavariables>>*>
55  ids) noexcept {
56  ids->insert(ids->end(), std::make_move_iterator(temporal_ids.begin()),
57  std::make_move_iterator(temporal_ids.end()));
58  });
59 
60  // Begin interpolation if it is not already in progress
61  // (i.e. waiting for data), and if there are temporal_ids to
62  // interpolate. If there's an interpolation in progress, then a
63  // later interpolation will be started as soon as the earlier one
64  // finishes.
65  const auto& ids = db::get<Tags::TemporalIds<Metavariables>>(box);
66  if (begin_interpolation and not ids.empty()) {
67  auto& my_proxy =
68  Parallel::get_parallel_component<ParallelComponent>(cache);
70  typename InterpolationTargetTag::compute_target_points>(my_proxy,
71  ids.front());
72  }
73  }
74 };
75 } // namespace Actions
76 } // namespace intrp
Defines class tuples::TaggedTuple.
Definition: AddTemporalIdsToInterpolationTarget.hpp:17
temporal_ids on which to interpolate.
Definition: InterpolationTargetWedgeSectionTorus.hpp:29
An associative container that is indexed by structs.
Definition: TaggedTuple.hpp:272
Defines classes and functions used for manipulating DataBox&#39;s.
Definition: InterpolationTargetWedgeSectionTorus.hpp:24
Defines class Variables.
A Charm++ chare that caches constant data once per Charm++ node.
Definition: ConstGlobalCache.hpp:76
typename DataBox_detail::item_type_impl< TagList, Tag >::type item_type
Get the type that is returned by the Tag. If it is a base tag then a TagList must be passed as a seco...
Definition: DataBoxTag.hpp:410
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:863
Defines tags related to domain quantities.
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
Adds temporal_ids on which this InterpolationTarget should be triggered.
Definition: AddTemporalIdsToInterpolationTarget.hpp:34
Definition: SolvePoissonProblem.hpp:38
Defines classes SimpleTag, PrefixTag, ComputeTag and several functions for retrieving tag info...
Defines class template ConstGlobalCache.
Definition: ComputeTimeDerivative.hpp:28
Require a pointer to not be a nullptr
Definition: ConservativeFromPrimitive.hpp:12