InterpolatorReceiveVolumeData.hpp
1 // Distributed under the MIT License.
2 // See LICENSE.txt for details.
3 
4 #pragma once
5 
6 #include <unordered_map>
7 #include <utility>
8 
12 #include "Domain/Mesh.hpp"
13 #include "Domain/Tags.hpp"
14 #include "NumericalAlgorithms/Interpolation/Tags.hpp"
15 #include "NumericalAlgorithms/Interpolation/TryToInterpolate.hpp"
17 #include "Utilities/Gsl.hpp"
18 #include "Utilities/TMPL.hpp"
20 
21 namespace intrp {
22 namespace Actions {
23 
24 /// \ingroup ActionsGroup
25 /// \brief Adds volume data from an `Element`.
26 ///
27 /// Attempts to interpolate if it already has received target points from
28 /// any InterpolationTargets.
29 ///
30 /// Uses:
31 /// - DataBox:
32 /// - `Tags::NumberOfElements`
33 ///
34 /// DataBox changes:
35 /// - Adds: nothing
36 /// - Removes: nothing
37 /// - Modifies:
38 /// - `Tags::VolumeVarsInfo<Metavariables>`
39 /// - `Tags::InterpolatedVarsHolders<Metavariables>`
41  template <
42  typename DbTags, typename... InboxTags, typename Metavariables,
43  typename ArrayIndex, typename ActionList, typename ParallelComponent,
44  size_t VolumeDim,
46  nullptr>
47  static void apply(
49  const tuples::TaggedTuple<InboxTags...>& /*inboxes*/,
51  const ArrayIndex& /*array_index*/, const ActionList /*meta*/,
52  const ParallelComponent* const /*meta*/,
53  const typename Metavariables::temporal_id::type& temporal_id,
54  const ElementId<VolumeDim>& element_id, const ::Mesh<VolumeDim>& mesh,
55  Variables<typename Metavariables::interpolator_source_vars>&&
56  vars) noexcept {
57  db::mutate<Tags::VolumeVarsInfo<Metavariables>>(
58  make_not_null(&box),
59  [&temporal_id, &element_id, &mesh,
60  &vars ](const gsl::not_null<
62  container) noexcept {
63  if (container->find(temporal_id) == container->end()) {
64  container->emplace(
65  temporal_id,
67  typename Tags::VolumeVarsInfo<
68  Metavariables>::Info>{});
69  }
70  container->at(temporal_id)
71  .emplace(std::make_pair(
72  element_id,
74  mesh, std::move(vars)}));
75  });
76 
77  // Try to interpolate data for all InterpolationTargets.
78  tmpl::for_each<typename Metavariables::interpolation_target_tags>(
79  [&box, &cache, &temporal_id ](auto x) noexcept {
80  using tag = typename decltype(x)::type;
81  try_to_interpolate<tag>(make_not_null(&box), make_not_null(&cache),
82  temporal_id);
83  });
84  }
85 };
86 
87 } // namespace Actions
88 } // namespace intrp
Defines class tuples::TaggedTuple.
Definition: AddTemporalIdsToInterpolationTarget.hpp:17
An ElementId uniquely labels an Element. It is constructed from the BlockId of the Block to which the...
Definition: ElementId.hpp:36
Volume variables at all temporal_ids for all local Elements.
Definition: Tags.hpp:45
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
Defines the class template Mesh.
Definition: Tags.hpp:46
Adds volume data from an Element.
Definition: InterpolatorReceiveVolumeData.hpp:40
Wraps the template metaprogramming library used (brigand)
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
Defines tags related to domain quantities.
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...
Defines class template ConstGlobalCache.
Definition: ComputeTimeDerivative.hpp:28
Require a pointer to not be a nullptr
Definition: ConservativeFromPrimitive.hpp:12