Line data Source code
1 0 : // Distributed under the MIT License.
2 : // See LICENSE.txt for details.
3 :
4 : #pragma once
5 :
6 : #include <cstddef>
7 : #include <optional>
8 : #include <utility>
9 :
10 : #include "DataStructures/DataBox/DataBox.hpp"
11 : #include "DataStructures/DataBox/PrefixHelpers.hpp"
12 : #include "DataStructures/DataBox/Prefixes.hpp"
13 : #include "DataStructures/Tensor/Tensor.hpp"
14 : #include "DataStructures/Variables.hpp"
15 : #include "Domain/Tags.hpp"
16 : #include "Elliptic/Utilities/GetAnalyticData.hpp"
17 : #include "NumericalAlgorithms/Spectral/Mesh.hpp"
18 : #include "Parallel/AlgorithmExecution.hpp"
19 : #include "Parallel/GlobalCache.hpp"
20 : #include "ParallelAlgorithms/Initialization/MutateAssign.hpp"
21 : #include "ParallelAlgorithms/LinearSolver/Tags.hpp"
22 : #include "Utilities/TMPL.hpp"
23 :
24 : namespace elliptic::Actions {
25 :
26 : /*!
27 : * \brief Initialize the dynamic fields of the elliptic system, i.e. those we
28 : * solve for.
29 : *
30 : * Uses:
31 : * - System:
32 : * - `primal_fields`
33 : * - DataBox:
34 : * - `InitialGuessTag`
35 : * - `Tags::Coordinates<Dim, Frame::Inertial>`
36 : *
37 : * DataBox:
38 : * - Adds:
39 : * - `primal_fields`
40 : */
41 : template <typename System, typename InitialGuessTag>
42 1 : struct InitializeFields {
43 : private:
44 0 : using fields_tag = ::Tags::Variables<typename System::primal_fields>;
45 :
46 : public:
47 0 : using simple_tags = tmpl::list<fields_tag>;
48 0 : using compute_tags = tmpl::list<>;
49 0 : using const_global_cache_tags = tmpl::list<InitialGuessTag>;
50 :
51 : template <typename DbTagsList, typename... InboxTags, typename Metavariables,
52 : size_t Dim, typename ActionList, typename ParallelComponent>
53 0 : static Parallel::iterable_action_return_t 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*/) {
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 =
63 : elliptic::util::get_analytic_data<typename fields_tag::tags_list>(
64 : initial_guess, box, inertial_coords);
65 : ::Initialization::mutate_assign<simple_tags>(make_not_null(&box),
66 : std::move(initial_fields));
67 : return {Parallel::AlgorithmExecution::Continue, std::nullopt};
68 : }
69 : };
70 :
71 : } // namespace elliptic::Actions
|