InitializeFields.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 
10 #include "DataStructures/DataBox/PrefixHelpers.hpp"
14 #include "Domain/Tags.hpp"
16 #include "Parallel/GlobalCache.hpp"
17 #include "ParallelAlgorithms/Initialization/MutateAssign.hpp"
19 #include "Utilities/TMPL.hpp"
20 
21 namespace elliptic::Actions {
22 
23 /*!
24  * \brief Initialize the dynamic fields of the elliptic system, i.e. those we
25  * solve for.
26  *
27  * Uses:
28  * - System:
29  * - `primal_fields`
30  * - DataBox:
31  * - `InitialGuessTag`
32  * - `Tags::Coordinates<Dim, Frame::Inertial>`
33  *
34  * DataBox:
35  * - Adds:
36  * - `primal_fields`
37  *
38  * \note This action relies on the `SetupDataBox` aggregated initialization
39  * mechanism, so `Actions::SetupDataBox` must be present in the `Initialization`
40  * phase action list prior to this action.
41  */
42 template <typename System, typename InitialGuessTag>
44  private:
46 
47  public:
48  using simple_tags = tmpl::list<fields_tag>;
49  using compute_tags = tmpl::list<>;
50 
51  template <typename DbTagsList, typename... InboxTags, typename Metavariables,
52  size_t Dim, typename ActionList, typename ParallelComponent>
53  static std::tuple<db::DataBox<DbTagsList>&&> apply(
54  db::DataBox<DbTagsList>& box,
55  const tuples::TaggedTuple<InboxTags...>& /*inboxes*/,
56  const Parallel::GlobalCache<Metavariables>& /*cache*/,
57  const ElementId<Dim>& /*array_index*/, const ActionList /*meta*/,
58  const ParallelComponent* const /*meta*/) noexcept {
59  const auto& inertial_coords =
60  get<domain::Tags::Coordinates<Dim, Frame::Inertial>>(box);
61  const auto& initial_guess = db::get<InitialGuessTag>(box);
62  auto initial_fields = variables_from_tagged_tuple(initial_guess.variables(
63  inertial_coords, typename fields_tag::tags_list{}));
64  ::Initialization::mutate_assign<simple_tags>(make_not_null(&box),
65  std::move(initial_fields));
66  return {std::move(box)};
67  }
68 };
69 
70 } // namespace elliptic::Actions
variables_from_tagged_tuple
Variables< tmpl::list< Tags... > > variables_from_tagged_tuple(const tuples::TaggedTuple< Tags... > &tuple) noexcept
Definition: Variables.hpp:842
utility
Parallel::GlobalCache
Definition: ElementReceiveInterpPoints.hpp:15
GlobalCache.hpp
Tags.hpp
Tags::Variables
Definition: VariablesTag.hpp:21
std::tuple
Tags.hpp
ElementId< Dim >
DataBox.hpp
cstddef
tuples::TaggedTuple
An associative container that is indexed by structs.
Definition: TaggedTuple.hpp:271
elliptic::Actions::InitializeFields
Initialize the dynamic fields of the elliptic system, i.e. those we solve for.
Definition: InitializeFields.hpp:43
Variables.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
Prefixes.hpp
TMPL.hpp
Mesh.hpp