SendPointsToInterpolator.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/BlockLogicalCoordinates.hpp"
12 #include "Domain/Tags.hpp"
13 #include "NumericalAlgorithms/Interpolation/Tags.hpp"
15 #include "Parallel/Invoke.hpp"
16 
17 /// \cond
18 namespace intrp {
19 template <typename Metavariables>
20 struct Interpolator;
21 namespace Actions {
22 template <typename InterpolationTargetTag>
23 struct ReceivePoints;
24 } // namespace Actions
25 } // namespace intrp
26 /// \endcond
27 
28 namespace intrp {
29 
30 /// Sends to all the Interpolators a list of all the points that need
31 /// to be interpolated onto. Also clears information about data that
32 /// has already been interpolated, since calling this function triggers
33 /// a new interpolation.
34 ///
35 /// Called by InterpolationTargetTag::compute_target_points. This is not an
36 /// Action, but rather a helper function that is called by every
37 /// Action (LineSegment, Strahlkorper, etc.) that specifies a
38 /// particular set of points.
39 template <typename InterpolationTargetTag, typename DbTags,
40  typename Metavariables, size_t VolumeDim, typename Frame>
41 void send_points_to_interpolator(
43  const tnsr::I<DataVector, VolumeDim, Frame>& target_points,
44  const typename Metavariables::temporal_id::type& temporal_id) noexcept {
45  const auto& domain = db::get<::Tags::Domain<VolumeDim, Frame>>(box);
46  auto coords = block_logical_coordinates(domain, target_points);
47 
48  db::mutate<
49  Tags::IndicesOfFilledInterpPoints,
51  typename InterpolationTargetTag::vars_to_interpolate_to_target>>(
52  make_not_null(&box),
53  [&coords](
55  indices_of_filled,
57  typename InterpolationTargetTag::vars_to_interpolate_to_target>>*>
58  vars_dest) noexcept {
59  // Because we are sending new points to the interpolator,
60  // we know that none of these points have been interpolated to,
61  // so clear the list.
62  indices_of_filled->clear();
63 
64  // We will be filling vars_dest with interpolated data.
65  // Here we make sure it is allocated to the correct size.
66  if (vars_dest->number_of_grid_points() != coords.size()) {
67  *vars_dest = db::item_type<::Tags::Variables<
68  typename InterpolationTargetTag::vars_to_interpolate_to_target>>(
69  coords.size());
70  }
71  });
72 
73  auto& receiver_proxy =
74  Parallel::get_parallel_component<Interpolator<Metavariables>>(cache);
76  Actions::ReceivePoints<InterpolationTargetTag>>(
77  receiver_proxy, temporal_id, std::move(coords));
78 }
79 
80 } // namespace intrp
Definition: Variables.hpp:46
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:1099
Definition: BlockId.hpp:16
Definition: AddTemporalIdsToInterpolationTarget.hpp:17
Defines classes and functions used for manipulating DataBox&#39;s.
Indicates the Frame that a TensorIndexType is in.
Definition: IndexType.hpp:36
Definition: InterpolationTargetWedgeSectionTorus.hpp:24
Defines class Variables.
A Charm++ chare that caches constant data once per Charm++ node.
Definition: ConstGlobalCache.hpp:76
std::vector< block_logical_coord_holder< Dim > > block_logical_coordinates(const Domain< Dim, Frame > &domain, const tnsr::I< DataVector, Dim, Frame > &x) noexcept
Computes the block logical coordinates and the containing BlockId of a set of points, given coordinates in the Frame frame.
Definition: BlockLogicalCoordinates.cpp:25
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
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...
Defines class template ConstGlobalCache.
Definition: ComputeTimeDerivative.hpp:28
Require a pointer to not be a nullptr
Definition: ConservativeFromPrimitive.hpp:12