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 <tuple>
9 : #include <utility>
10 :
11 : #include "DataStructures/DataBox/DataBox.hpp"
12 : #include "Evolution/Systems/Cce/IntegrandInputSteps.hpp"
13 : #include "Evolution/Systems/Cce/OptionTags.hpp"
14 : #include "Evolution/Systems/Cce/PreSwshDerivatives.hpp"
15 : #include "Evolution/Systems/Cce/SwshDerivatives.hpp"
16 : #include "NumericalAlgorithms/SpinWeightedSphericalHarmonics/SwshDerivatives.hpp"
17 : #include "Parallel/AlgorithmExecution.hpp"
18 : #include "Parallel/GlobalCache.hpp"
19 : #include "Utilities/Gsl.hpp"
20 : #include "Utilities/TMPL.hpp"
21 :
22 : namespace Cce {
23 : namespace Actions {
24 :
25 : /*!
26 : * \ingroup ActionsGroup
27 : * \brief Calculates the Bondi quantities that are required for any of the
28 : * `CalculateScriPlusValue` mutators.
29 : *
30 : * \details Internally dispatches to the `PreSwshDerivatives` and
31 : * `Spectral::Swsh::AngularDerivatives` utilities to perform the radial and
32 : * angular differentiation that is required to prepare all of the Bondi
33 : * quantities needed for evaluating the scri+ values. This relies on the
34 : * typelists `Cce::all_pre_swsh_derivative_tags_for_scri`,
35 : * `Cce::all_boundary_pre_swsh_derivative_tags_for_scri`,
36 : * `Cce::all_swsh_derivative_tags_for_scri`, and
37 : * `Cce::all_boundary_swsh_derivative_tags_for_scri` to determine which
38 : * calculations to perform.
39 : */
40 1 : struct CalculateScriInputs {
41 0 : using const_global_cache_tags =
42 : tmpl::list<Tags::LMax, Tags::NumberOfRadialPoints>;
43 :
44 : template <typename DbTags, typename... InboxTags, typename Metavariables,
45 : typename ArrayIndex, typename ActionList,
46 : typename ParallelComponent>
47 0 : static Parallel::iterable_action_return_t apply(
48 : db::DataBox<DbTags>& box,
49 : const tuples::TaggedTuple<InboxTags...>& /*inboxes*/,
50 : const Parallel::GlobalCache<Metavariables>& /*cache*/,
51 : const ArrayIndex& /*array_index*/, const ActionList /*meta*/,
52 : const ParallelComponent* const /*meta*/) {
53 : tmpl::for_each<
54 : tmpl::append<all_pre_swsh_derivative_tags_for_scri,
55 : all_boundary_pre_swsh_derivative_tags_for_scri>>(
56 : [&box](auto pre_swsh_derivative_tag_v) {
57 : using pre_swsh_derivative_tag =
58 : typename decltype(pre_swsh_derivative_tag_v)::type;
59 : db::mutate_apply<PreSwshDerivatives<pre_swsh_derivative_tag>>(
60 : make_not_null(&box));
61 : });
62 :
63 : db::mutate_apply<
64 : Spectral::Swsh::AngularDerivatives<all_swsh_derivative_tags_for_scri>>(
65 : make_not_null(&box));
66 : boundary_derivative_impl(box, db::get<Tags::LMax>(box),
67 : all_boundary_swsh_derivative_tags_for_scri{});
68 :
69 : tmpl::for_each<
70 : all_swsh_derivative_tags_for_scri>([&box](auto derivative_tag_v) {
71 : using derivative_tag = typename decltype(derivative_tag_v)::type;
72 : ::Cce::detail::apply_swsh_jacobian_helper<derivative_tag>(
73 : make_not_null(&box), typename ApplySwshJacobianInplace<
74 : derivative_tag>::on_demand_argument_tags{});
75 : });
76 : return {Parallel::AlgorithmExecution::Continue, std::nullopt};
77 : }
78 :
79 : template <typename DbTags, typename... TagPack>
80 0 : static void boundary_derivative_impl(db::DataBox<DbTags>& box,
81 : const size_t l_max,
82 : tmpl::list<TagPack...> /*meta*/) {
83 : db::mutate<TagPack...>(
84 : [&l_max](const gsl::not_null<typename TagPack::type*>... derivatives,
85 : const typename TagPack::derivative_of::type&... arguments) {
86 : Spectral::Swsh::angular_derivatives<
87 : tmpl::list<typename TagPack::derivative_kind...>>(
88 : l_max, 1, make_not_null(&get(*derivatives))...,
89 : get(arguments)...);
90 : },
91 : make_not_null(&box), db::get<typename TagPack::derivative_of>(box)...);
92 : }
93 : };
94 : } // namespace Actions
95 : } // namespace Cce
|