Line data Source code
1 0 : // Distributed under the MIT License.
2 : // See LICENSE.txt for details.
3 :
4 : #pragma once
5 :
6 : #include <array>
7 : #include <cstddef>
8 : #include <optional>
9 :
10 : #include "DataStructures/DataVector.hpp"
11 : #include "DataStructures/SimpleSparseMatrix.hpp"
12 : #include "DataStructures/Tensor/TypeAliases.hpp"
13 : #include "DataStructures/Variables.hpp"
14 : #include "Evolution/Systems/GeneralizedHarmonic/ApplyTensorYlmFilter.hpp"
15 : #include "NumericalAlgorithms/Spectral/Mesh.hpp"
16 : #include "Utilities/Gsl.hpp"
17 :
18 : /// \cond
19 : class DataVector;
20 : namespace ylm {
21 : class Spherepack;
22 : } // namespace ylm
23 : /// \endcond
24 :
25 : namespace gh::power_monitor {
26 :
27 : /// Holds separate GH shell power monitors for each evolved GH variable.
28 1 : struct GhShellPowerMonitors {
29 0 : std::array<DataVector, 2> spacetime_metric{};
30 0 : std::array<DataVector, 2> pi{};
31 0 : std::array<DataVector, 2> phi{};
32 : };
33 :
34 : /// Sparse matrices for Cartesian-component to TensorYlm-basis transforms.
35 1 : struct CartToSphereMatrices {
36 0 : std::optional<SimpleSparseMatrix> i{};
37 0 : std::optional<SimpleSparseMatrix> ii{};
38 0 : std::optional<SimpleSparseMatrix> ij{};
39 0 : std::optional<SimpleSparseMatrix> ijj{};
40 : };
41 :
42 : /// Fill any missing Cartesian-to-TensorYlm sparse matrices with Spherepack
43 : /// normalization.
44 1 : void fill_cart_to_sphere_matrices(gsl::not_null<CartToSphereMatrices*> matrices,
45 : size_t ell_max);
46 :
47 : /*!
48 : * \brief Compute radial and angular power monitors for the evolved GH
49 : * variables on a spherical shell.
50 : *
51 : * Each monitor is an array containing the radial monitor at index 0 and the
52 : * angular monitor at index 1. Radial monitors are computed from the original
53 : * GH variables, matching SpEC's shell radial power monitor behavior. Angular
54 : * monitors are computed after transforming the GH variables to TensorYlm
55 : * coefficients. The Cartesian-to-TensorYlm matrices are filled on first use
56 : * and reused on subsequent calls.
57 : */
58 1 : GhShellPowerMonitors gh_shell_power_monitors(
59 : gsl::not_null<CartToSphereMatrices*> cart_to_sphere_matrices,
60 : const Variables<ylm::TensorYlm::filter_detail::gh_spacetime_vars_list>&
61 : gh_vars,
62 : const Mesh<3>& mesh,
63 : const InverseJacobian<DataVector, 3, Frame::Inertial, Frame::Grid>&
64 : jac_inertial_to_grid);
65 :
66 : } // namespace gh::power_monitor
|