InterpolationTarget.hpp
1 // Distributed under the MIT License.
2 // See LICENSE.txt for details.
3 
4 #pragma once
5 
6 #include <memory>
7 
10 #include "Domain/Domain.hpp"
12 #include "Parallel/Invoke.hpp"
13 #include "Utilities/TMPL.hpp"
14 
15 /// \cond
16 namespace intrp {
17 namespace Actions {
18 template <typename InterpolationTargetTag>
19 struct InitializeInterpolationTarget;
20 } // namespace Actions
21 } // namespace intrp
22 /// \endcond
23 
24 namespace intrp {
25 
26 /// \brief ParallelComponent representing a set of points to be interpolated
27 /// to and a function to call upon interpolation to those points.
28 ///
29 /// Each InterpolationTarget will communicate with the `Interpolator`.
30 ///
31 /// `InterpolationTargetTag` must contain the following type aliases:
32 /// - vars_to_interpolate_to_target: a `tmpl::list` of tags describing
33 /// variables to interpolate. Will be used
34 /// to construct a `Variables`.
35 /// - compute_items_on_source: a `tmpl::list` of compute items that uses
36 /// `Metavariables::interpolator_source_vars`
37 /// as input and computes the `Variables`
38 /// defined by `vars_to_interpolate_to_target`.
39 /// - compute_items_on_target: a `tmpl::list` of compute items that uses
40 /// `vars_to_interpolate_to_target` as input.
41 /// - compute_target_points: a `simple_action` of `InterpolationTarget`
42 /// that computes the target points and
43 /// sends them to `Interpolators`.
44 /// It takes a `temporal_id` as an extra
45 /// argument. `compute_target_points` can
46 /// (optionally) have an additional function
47 ///```
48 /// static auto initialize(db::DataBox<DbTags>&&,
49 /// const Parallel::ConstGlobalCache<Metavariables>&)
50 /// noexcept;
51 ///```
52 /// that adds arbitrary tags to the `DataBox`
53 /// when the `InterpolationTarget` is
54 /// initialized. If `compute_target_points`
55 /// has an `initialize` function, it
56 /// must also have a type alias
57 /// `initialization_tags`
58 /// which is a `tmpl::list` of the tags that
59 /// are added by `initialize`.
60 /// - post_interpolation_callback: a struct with a type alias
61 /// `const_global_cache_tags` (listing tags
62 /// that should be read from option parsing)
63 /// and with a static function
64 ///```
65 /// void apply(const DataBox<DbTags>&,
66 /// const intrp::ConstGlobalCache<Metavariables>&,
67 /// const Metavariables::temporal_id&) noexcept;
68 ///```
69 /// or
70 ///```
71 /// bool apply(const gsl::not_null<db::DataBox<DbTags>*>,
72 /// const gsl::not_null<intrp::ConstGlobalCache<Metavariables>*>,
73 /// const Metavariables::temporal_id&) noexcept;
74 ///```
75 /// that will be called when interpolation is
76 /// complete. `DbTags` includes everything in
77 /// `vars_to_interpolate_to_target`, plus everything
78 /// in `compute_items_on_target`. The second form
79 /// of the `apply` function should return false only
80 /// if it calls another `intrp::Action` that still
81 /// needs the volume data at this temporal_id (such
82 /// as another iteration of the horizon finder).
83 ///
84 /// `Metavariables` must contain the following type aliases:
85 /// - interpolator_source_vars: a `tmpl::list` of tags that define a
86 /// `Variables` sent from all `Element`s
87 /// to the local `Interpolator`.
88 /// - interpolation_target_tags: a `tmpl::list` of all
89 /// `InterpolationTargetTag`s.
90 /// - temporal_id: the type held by ::intrp::Tags::TemporalIds.
91 /// - domain_frame: The `::Frame` of the Domain.
92 /// `Metavariables` must contain the following static constexpr members:
93 /// - size_t domain_dim: The dimension of the Domain.
94 template <class Metavariables, typename InterpolationTargetTag>
96  using chare_type = ::Parallel::Algorithms::Singleton;
98  using action_list = tmpl::list<>;
99  using initial_databox =
101  InterpolationTargetTag>::template return_tag_list<Metavariables>>;
102  using options = tmpl::list<::OptionTags::DomainCreator<
103  Metavariables::domain_dim,
104  typename Metavariables::domain_frame>>;
105  using const_global_cache_tag_list = Parallel::get_const_global_cache_tags<
106  tmpl::list<typename InterpolationTargetTag::compute_target_points,
107  typename InterpolationTargetTag::post_interpolation_callback>>;
108 
109  static void initialize(
110  Parallel::CProxy_ConstGlobalCache<metavariables>& global_cache,
112  DomainCreator<Metavariables::domain_dim,
113  typename Metavariables::domain_frame>>
114  domain_creator) noexcept;
115  static void execute_next_phase(
116  typename metavariables::Phase /*next_phase*/,
117  const Parallel::CProxy_ConstGlobalCache<metavariables>&
118  /*global_cache*/) noexcept {}
119 };
120 
121 template <class Metavariables, typename InterpolationTargetTag>
123  Parallel::CProxy_ConstGlobalCache<metavariables>& global_cache,
125  DomainCreator<Metavariables::domain_dim,
126  typename Metavariables::domain_frame>>
127  domain_creator) noexcept {
128  auto& my_proxy = Parallel::get_parallel_component<InterpolationTarget>(
129  *(global_cache.ckLocalBranch()));
132  my_proxy, domain_creator->create_domain());
133 }
134 
135 } // namespace intrp
Definition: AddTemporalIdsToInterpolationTarget.hpp:17
Base class for creating Domains from an option string.
Definition: DomainCreator.hpp:89
Defines class template Domain.
tmpl::remove_duplicates< tmpl::join< tmpl::transform< ActionsList, Parallel_detail::get_const_global_cache_tags_from_action< tmpl::_1 > >> > get_const_global_cache_tags
Given a list of Actions, get a list of the unique tags specified in the actions&#39; const_global_cache_t...
Definition: ParallelComponentHelpers.hpp:72
Defines classes and functions used for manipulating DataBox&#39;s.
Wraps the template metaprogramming library used (brigand)
void simple_action(Proxy &&proxy) noexcept
Invoke a simple action on proxy
Definition: Invoke.hpp:112
typename DataBox_detail::compute_dbox_type< get_items< TagList >, get_compute_items< TagList > >::type compute_databox_type
Returns the type of the DataBox that would be constructed from the TagList of tags.
Definition: DataBox.hpp:1827
Definition: SolvePoissonProblem.hpp:38
Defines class template ConstGlobalCache.
Initializes an InterpolationTarget.
Definition: InitializeInterpolationTarget.hpp:104
The input file tag for the DomainCreator to use.
Definition: Tags.hpp:44
Definition: ComputeTimeDerivative.hpp:28
Defines class DomainCreator.
ParallelComponent representing a set of points to be interpolated to and a function to call upon inte...
Definition: InterpolationTarget.hpp:95