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 :
8 : #include "DataStructures/DataBox/DataBox.hpp"
9 : #include "DataStructures/Tensor/Tensor.hpp"
10 : #include "DataStructures/Variables.hpp"
11 : #include "Domain/Tags.hpp"
12 : #include "Evolution/Systems/CurvedScalarWave/Worldtube/Tags.hpp"
13 : #include "NumericalAlgorithms/SphericalHarmonics/Tags.hpp"
14 : #include "Parallel/AlgorithmExecution.hpp"
15 : #include "Parallel/GlobalCache.hpp"
16 : #include "PointwiseFunctions/GeneralRelativity/Tags.hpp"
17 : #include "Utilities/Gsl.hpp"
18 : #include "Utilities/TMPL.hpp"
19 :
20 : namespace CurvedScalarWave::Worldtube {
21 :
22 : /// @{
23 : /*!
24 : * \brief Calculates the time derivative of `Psi0`, the constant coefficient of
25 : * the expansion of `Psi`.
26 : *
27 : * \details The derivation comes from expanding the scalar wave equation to
28 : * second order and reads
29 : *
30 : * \f{equation}
31 : * g^{00}_0 \ddot{\Psi}^R_0(t_s) + 2 g_0^{0i}
32 : * \dot{\Psi}^N_i(t_s) + 2 g_0^{ij} \Psi^N_{\langle ij \rangle}(t_s)
33 : * + \frac{2 \delta_{ij} g_0^{ij}}{R^2}
34 : * \left(\Psi^N_0(t_s) - \Psi^R_0(t_s) \right) -
35 : * \Gamma_0^0\dot{\Psi}R_0(t_s) - \Gamma_0^i \Psi_i^N(t_s) = 0.
36 : *\f}
37 : *
38 : * Here, \f$ \Gamma^\mu_0 \f$ and \f$ g^{\mu \nu}_0 \f$ are the trace of the
39 : * spacetime Christoffel symbol and the inverse spacetime metric, respectively,
40 : * evaluated at the position of the particle; \f$\Psi^N_0\f$, \f$\Psi^N_i\f$,
41 : * \f$\Psi^N_\langle i j \rangle\f$ are the monopole, dipole and quadrupole of
42 : * the regular field on the worldtube boundary transformed to symmetric
43 : * trace-free tensors and \f$ R\f$ is the worldtube radius.
44 : */
45 1 : struct TimeDerivativeMutator {
46 0 : static constexpr size_t Dim = 3;
47 :
48 0 : using variables_tag = ::Tags::Variables<tmpl::list<Tags::Psi0, Tags::dtPsi0>>;
49 0 : using dt_variables_tag = db::add_tag_prefix<::Tags::dt, variables_tag>;
50 0 : using return_tags = tmpl::list<dt_variables_tag>;
51 0 : using argument_tags = tmpl::list<
52 : variables_tag,
53 : Stf::Tags::StfTensor<Tags::PsiWorldtube, 0, Dim, Frame::Grid>,
54 : Stf::Tags::StfTensor<Tags::PsiWorldtube, 1, Dim, Frame::Grid>,
55 : Stf::Tags::StfTensor<Tags::PsiWorldtube, 2, Dim, Frame::Grid>,
56 : Stf::Tags::StfTensor<::Tags::dt<Tags::PsiWorldtube>, 1, Dim, Frame::Grid>,
57 : gr::Tags::InverseSpacetimeMetric<double, Dim, Frame::Grid>,
58 : gr::Tags::TraceSpacetimeChristoffelSecondKind<double, Dim, Frame::Grid>,
59 : Tags::ExcisionSphere<Dim>>;
60 :
61 0 : static void apply(
62 : const gsl::not_null<Variables<
63 : tmpl::list<::Tags::dt<Tags::Psi0>, ::Tags::dt<Tags::dtPsi0>>>*>
64 : dt_evolved_vars,
65 : const Variables<tmpl::list<Tags::Psi0, Tags::dtPsi0>>& evolved_vars,
66 : const Scalar<double>& psi_monopole,
67 : const tnsr::i<double, Dim, Frame::Grid>& psi_dipole,
68 : const tnsr::ii<double, Dim, Frame::Grid>& psi_quadrupole,
69 : const tnsr::i<double, Dim, Frame::Grid>& dt_psi_dipole,
70 : const tnsr::AA<double, Dim, Frame::Grid>& inverse_spacetime_metric,
71 : const tnsr::A<double, Dim, Frame::Grid>& trace_spacetime_christoffel,
72 : const ExcisionSphere<Dim>& excision_sphere);
73 : };
74 :
75 : namespace Actions {
76 0 : struct ComputeTimeDerivative {
77 0 : static constexpr size_t Dim = 3;
78 0 : using variables_tag = ::Tags::Variables<tmpl::list<Tags::Psi0, Tags::dtPsi0>>;
79 0 : using dt_variables_tag = db::add_tag_prefix<::Tags::dt, variables_tag>;
80 0 : using simple_tags = tmpl::list<
81 : dt_variables_tag, variables_tag,
82 : Stf::Tags::StfTensor<Tags::PsiWorldtube, 0, Dim, Frame::Grid>,
83 : Stf::Tags::StfTensor<Tags::PsiWorldtube, 1, Dim, Frame::Grid>,
84 : Stf::Tags::StfTensor<Tags::PsiWorldtube, 2, Dim, Frame::Grid>,
85 : Stf::Tags::StfTensor<::Tags::dt<Tags::PsiWorldtube>, 1, Dim, Frame::Grid>,
86 : gr::Tags::InverseSpacetimeMetric<double, Dim, Frame::Grid>,
87 : gr::Tags::TraceSpacetimeChristoffelSecondKind<double, Dim, Frame::Grid>>;
88 :
89 : template <typename DbTagsList, typename... InboxTags, typename Metavariables,
90 : typename ArrayIndex, typename ActionList,
91 : typename ParallelComponent>
92 0 : static Parallel::iterable_action_return_t apply(
93 : db::DataBox<DbTagsList>& box,
94 : tuples::TaggedTuple<InboxTags...>& /*inboxes*/,
95 : Parallel::GlobalCache<Metavariables>& /*cache*/,
96 : const ArrayIndex& /*array_index*/, ActionList /*meta*/,
97 : const ParallelComponent* /*meta*/) {
98 : if (db::get<Tags::ExpansionOrder>(box) >= 2) {
99 : db::mutate_apply<TimeDerivativeMutator>(make_not_null(&box));
100 : }
101 : return {Parallel::AlgorithmExecution::Continue, std::nullopt};
102 : }
103 : };
104 : /// @}
105 :
106 : } // namespace Actions
107 : } // namespace CurvedScalarWave::Worldtube
|