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 "Evolution/Systems/Cce/Tags.hpp"
9 : #include "NumericalAlgorithms/Spectral/Basis.hpp"
10 : #include "NumericalAlgorithms/Spectral/Quadrature.hpp"
11 : #include "NumericalAlgorithms/SpinWeightedSphericalHarmonics/SwshCollocation.hpp"
12 : #include "Utilities/Gsl.hpp"
13 :
14 : namespace Cce {
15 : /*!
16 : * \brief Computes the partial derivative along a particular direction
17 : * determined by the `dimension_to_differentiate`.
18 : * The input `u` is differentiated with the spectral matrix and the solution is
19 : * placed in `d_u`.
20 : *
21 : * \note This is placed in Cce Utilities for its currently narrow use-case. If
22 : * more general uses desire a single partial derivative of complex values, this
23 : * should be moved to `NumericalAlgorithms`. This utility currently assumes the
24 : * spatial dimensionality is 3, which would also need to be generalized, likely
25 : * by creating a wrapping struct with partial template specializations.
26 : */
27 1 : void logical_partial_directional_derivative_of_complex(
28 : gsl::not_null<ComplexDataVector*> d_u, const ComplexDataVector& u,
29 : const Mesh<3>& mesh, size_t dimension_to_differentiate);
30 :
31 : namespace Tags {
32 : /*!
33 : * \brief Compute tag for a manually-handled partial y derivative in the volume.
34 : *
35 : * \details Most of the partial y derivatives are handled by PreSwshDerivatives.
36 : * However, that infrastructure is specific to the CCE evolution system itself,
37 : * so it won't work for other uses (e.g. observers that are invoked
38 : * periodically). This compute tag instead manually computes a partial
39 : * y derivative.
40 : */
41 : template <typename Tag>
42 1 : struct DyCompute
43 : : Dy<Tag>, db::ComputeTag {
44 0 : using base = Dy<Tag>;
45 0 : using return_type = typename base::type;
46 :
47 0 : using argument_tags = tmpl::list<Tag, Tags::LMax>;
48 :
49 0 : static constexpr auto function(
50 : const gsl::not_null<
51 : Scalar<SpinWeighted<ComplexDataVector, Tag::type::type::spin>>*>
52 : dy_val,
53 : const Scalar<SpinWeighted<ComplexDataVector, Tag::type::type::spin>>& val,
54 : const size_t l_max) {
55 : if (get(*dy_val).size() != get(val).size()) {
56 : get(*dy_val).destructive_resize(get(val).size());
57 : };
58 : logical_partial_directional_derivative_of_complex(
59 : make_not_null(&get(*dy_val).data()), get(val).data(),
60 : Mesh<3>{
61 : {{Spectral::Swsh::number_of_swsh_theta_collocation_points(l_max),
62 : Spectral::Swsh::number_of_swsh_phi_collocation_points(l_max),
63 : get(val).size() /
64 : Spectral::Swsh::number_of_swsh_collocation_points(l_max)}},
65 : Spectral::Basis::Legendre,
66 : Spectral::Quadrature::GaussLobatto},
67 : // 2 for differentiating in y; coordinate ordering is:
68 : // {\phi, \theta, y}.
69 : 2);
70 : }
71 : };
72 :
73 : } // namespace Tags
74 :
75 : } // namespace Cce
|