InterpolatorReceivePoints.hpp
1 // Distributed under the MIT License.
2 // See LICENSE.txt for details.
3 
4 #pragma once
5 
6 #include <cstddef>
7 #include <utility>
8 #include <vector>
9 
13 #include "NumericalAlgorithms/Interpolation/InterpolatedVars.hpp"
14 #include "NumericalAlgorithms/Interpolation/TryToInterpolate.hpp"
15 #include "Utilities/Gsl.hpp"
16 #include "Utilities/Requires.hpp"
18 
19 /// \cond
20 // IWYU pragma: no_forward_declare db::DataBox
21 namespace Parallel {
22 template <typename Metavariables>
23 class ConstGlobalCache;
24 } // namespace Parallel
25 namespace domain {
26 class BlockId;
27 } // namespace domain
28 template <typename IdType, typename DataType>
29 class IdPair;
30 namespace intrp {
31 namespace Tags {
32 struct NumberOfElements;
33 template <typename Metavariables>
34 struct InterpolatedVarsHolders;
35 } // namespace Tags
36 } // namespace intrp
37 /// \endcond
38 
39 namespace intrp {
40 namespace Actions {
41 
42 /// \ingroup ActionsGroup
43 /// \brief Receives target points from an InterpolationTarget.
44 ///
45 /// After receiving the points, interpolates volume data onto them
46 /// if it already has all the volume data.
47 ///
48 /// Uses:
49 /// - Databox:
50 /// - `Tags::NumberOfElements`
51 /// - `Tags::InterpolatedVarsHolders<Metavariables>`
52 /// - `Tags::VolumeVarsInfo<Metavariables>`
53 ///
54 /// DataBox changes:
55 /// - Adds: nothing
56 /// - Removes: nothing
57 /// - Modifies:
58 /// - `Tags::InterpolatedVarsHolders<Metavariables>`
59 ///
60 /// For requirements on InterpolationTargetTag, see InterpolationTarget
61 template <typename InterpolationTargetTag>
62 struct ReceivePoints {
63  template <typename DbTags, typename... InboxTags, typename Metavariables,
64  typename ArrayIndex, typename ActionList,
65  typename ParallelComponent, size_t VolumeDim,
66  Requires<tmpl::list_contains_v<
67  DbTags, typename ::intrp::Tags::NumberOfElements>> = nullptr>
68  static void apply(
70  const tuples::TaggedTuple<InboxTags...>& /*inboxes*/,
72  const ArrayIndex& /*array_index*/, const ActionList /*meta*/,
73  const ParallelComponent* const /*meta*/,
74  const typename Metavariables::temporal_id::type& temporal_id,
75  std::vector<IdPair<domain::BlockId, tnsr::I<double, VolumeDim,
76  typename ::Frame::Logical>>>&&
77  block_logical_coords) noexcept {
78  db::mutate<intrp::Tags::InterpolatedVarsHolders<Metavariables>>(
79  make_not_null(&box),
80  [
81  &temporal_id, &block_logical_coords
82  ](const gsl::not_null<
84  vars_holders) noexcept {
85  auto& vars_infos =
86  get<intrp::Vars::HolderTag<InterpolationTargetTag,
87  Metavariables>>(*vars_holders)
88  .infos;
89 
90  // Add the target interpolation points at this temporal_id.
91  vars_infos.emplace(std::make_pair(
92  temporal_id,
93  intrp::Vars::Info<VolumeDim, typename InterpolationTargetTag::
94  vars_to_interpolate_to_target>{
95  std::move(block_logical_coords)}));
96  });
97 
98  try_to_interpolate<InterpolationTargetTag>(
99  make_not_null(&box), make_not_null(&cache), temporal_id);
100  }
101 };
102 
103 } // namespace Actions
104 } // namespace intrp
A data structure that contains an ID and data associated with that ID.
Definition: IdPair.hpp:16
Defines class tuples::TaggedTuple.
Index a block of the computational domain.
Definition: BlockId.hpp:21
Definition: BlockId.hpp:16
Holds a Variables interpolated onto a list of points, and information about those points...
Definition: InterpolatedVars.hpp:32
Definition: AddTemporalIdsToInterpolationTarget.hpp:17
Contains functions that forward to Charm++ parallel functions.
Definition: Abort.hpp:13
Defines the type alias Requires.
constexpr auto apply(F &&f, const DataBox< BoxTags > &box, Args &&... args)
Apply the function f with argument Tags TagsList from DataBox box
Definition: DataBox.hpp:1595
Receives target points from an InterpolationTarget.
Definition: InterpolatorReceivePoints.hpp:62
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
Definition: DataBoxTag.hpp:29
A Charm++ chare that caches constant data once per Charm++ node.
Definition: ConstGlobalCache.hpp:76
Defines a list of useful type aliases for tensors.
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
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:863
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
Identifies a step in the linear solver algorithm.
Definition: IterationId.hpp:25
Definition: SolvePoissonProblem.hpp:38
Defines classes SimpleTag, PrefixTag, ComputeTag and several functions for retrieving tag info...
Definition: ComputeTimeDerivative.hpp:28
Require a pointer to not be a nullptr
Definition: ConservativeFromPrimitive.hpp:12
Indexes a particular Holder in the TaggedTuple that is accessed from the Interpolator&#39;s DataBox with ...
Definition: InterpolatedVars.hpp:87