InitializeBackgroundFields.hpp
1 // Distributed under the MIT License.
2 // See LICENSE.txt for details.
3 
4 #pragma once
5 
6 #include <cstddef>
7 #include <tuple>
8 #include <utility>
9 
13 #include "Domain/Tags.hpp"
14 #include "ParallelAlgorithms/Initialization/MutateAssign.hpp"
15 #include "Utilities/Gsl.hpp"
16 #include "Utilities/TMPL.hpp"
17 #include "Utilities/TaggedTuple.hpp"
18 
19 /// \cond
20 namespace Parallel {
21 template <typename Metavariables>
22 struct GlobalCache;
23 } // namespace Parallel
24 /// \endcond
25 
26 namespace elliptic::Actions {
27 
28 /*!
29  * \brief Initialize the variable-independent background fields for an elliptic
30  * solve.
31  *
32  * Examples for background fields would be a background metric, associated
33  * curvature quantities, or matter sources such as a mass-density in the XCTS
34  * equations.
35  *
36  * This action retrieves the `System::background_fields` from the
37  * `BackgroundTag`.
38  *
39  * Uses:
40  * - System:
41  * - `background_fields`
42  * - DataBox:
43  * - `BackgroundTag`
44  * - `domain::Tags::Coordinates<Dim, Frame::Inertial>`
45  *
46  * DataBox:
47  * - Adds:
48  * - `::Tags::Variables<background_fields>`
49  */
50 template <typename System, typename BackgroundTag>
52  private:
53  using background_fields_tag =
55 
56  public:
57  using simple_tags = tmpl::list<background_fields_tag>;
58  using compute_tags = tmpl::list<>;
59 
60  template <typename DbTags, typename... InboxTags, typename Metavariables,
61  size_t Dim, typename ActionList, typename ParallelComponent>
62  static std::tuple<db::DataBox<DbTags>&&> apply(
63  db::DataBox<DbTags>& box,
64  const tuples::TaggedTuple<InboxTags...>& /*inboxes*/,
65  const Parallel::GlobalCache<Metavariables>& /*cache*/,
66  const ElementId<Dim>& /*array_index*/, const ActionList /*meta*/,
67  const ParallelComponent* const /*meta*/) noexcept {
68  const auto& background = db::get<BackgroundTag>(box);
69  const auto& inertial_coords =
70  get<domain::Tags::Coordinates<Dim, Frame::Inertial>>(box);
71  auto background_fields = variables_from_tagged_tuple(background.variables(
72  inertial_coords, typename background_fields_tag::tags_list{}));
73  ::Initialization::mutate_assign<simple_tags>(make_not_null(&box),
74  std::move(background_fields));
75  return {std::move(box)};
76  }
77 };
78 
79 } // namespace elliptic::Actions
variables_from_tagged_tuple
Variables< tmpl::list< Tags... > > variables_from_tagged_tuple(const tuples::TaggedTuple< Tags... > &tuple) noexcept
Definition: Variables.hpp:819
utility
Parallel::GlobalCache
Definition: ElementReceiveInterpPoints.hpp:15
Tags.hpp
Tags::Variables
Definition: VariablesTag.hpp:21
tuple
ElementId< Dim >
DataBox.hpp
cstddef
elliptic::Actions::InitializeBackgroundFields
Initialize the variable-independent background fields for an elliptic solve.
Definition: InitializeBackgroundFields.hpp:51
tuples::TaggedTuple
An associative container that is indexed by structs.
Definition: TaggedTuple.hpp:271
Variables.hpp
Gsl.hpp
Tensor.hpp
make_not_null
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,...
Definition: Gsl.hpp:880
Parallel
Functionality for parallelization.
Definition: ElementReceiveInterpPoints.hpp:13
TMPL.hpp