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 : 9 : #include "DataStructures/Tensor/TypeAliases.hpp" 10 : #include "DataStructures/Variables.hpp" 11 : #include "Evolution/Systems/GeneralizedHarmonic/ApplyTensorYlmFilter.hpp" 12 : #include "Evolution/Systems/GeneralizedHarmonic/SphericalShellPowerMonitor.hpp" 13 : #include "NumericalAlgorithms/Spectral/Mesh.hpp" 14 : #include "Utilities/Gsl.hpp" 15 : 16 : /// \cond 17 : class DataVector; 18 : /// \endcond 19 : 20 0 : namespace gh::power_monitor { 21 : 22 : /// Holds separate GH filled-sphere power monitors for each evolved GH 23 : /// variable. Index 0 is the radial monitor and index 1 is the angular monitor. 24 1 : struct GhFilledSpherePowerMonitors { 25 0 : std::array<DataVector, 2> spacetime_metric{}; 26 0 : std::array<DataVector, 2> pi{}; 27 0 : std::array<DataVector, 2> phi{}; 28 : }; 29 : 30 : /*! 31 : * \brief Compute radial and angular power monitors for the evolved GH 32 : * variables on a filled-sphere element. 33 : * 34 : * Each monitor is an array with the radial monitor at index 0 and the angular 35 : * monitor at index 1. Both monitors are computed after transforming the GH 36 : * variables to TensorYlm coefficients in the grid frame using 37 : * `jac_inertial_to_grid`. 38 : * 39 : * **Radial monitor** (index 0): groups squared Jacobi spectral coefficients by 40 : * the radial mode index \f$\text{mode} = (n+1)/2\f$ where 41 : * \f$n = \ell + 2k\f$ is the total ZernikeB3 degree, \f$\ell\f$ is the 42 : * angular degree, and \f$k\f$ is the Jacobi radial index. The result has 43 : * \f$n_r\f$ entries. 44 : * 45 : * **Angular monitor** (index 1): groups squared Jacobi spectral coefficients 46 : * by angular degree \f$\ell\f$. Spin-weighted spherical harmonic modes with 47 : * \f$\ell < |s|\f$ (where \f$s\f$ is the spin weight of the TensorYlm 48 : * component) contribute zero to both the sum and the count, following the same 49 : * convention as `gh_shell_power_monitors`. The result has \f$\ell_\max + 1\f$ 50 : * entries. 51 : * 52 : * The Cartesian-to-TensorYlm matrices in `cart_to_sphere_matrices` are filled 53 : * on first use and reused on subsequent calls. 54 : * 55 : * \param cart_to_sphere_matrices Cache for Cartesian-to-TensorYlm sparse 56 : * matrices. 57 : * \param gh_vars Generalized Harmonic variables at collocation points on the 58 : * B3 ball mesh. 59 : * \param mesh The ZernikeB3 mesh. 60 : * \param jac_inertial_to_grid Inverse Jacobian mapping inertial-frame spatial 61 : * tensor components to the grid frame. 62 : */ 63 1 : GhFilledSpherePowerMonitors gh_filled_sphere_power_monitors( 64 : gsl::not_null<CartToSphereMatrices*> cart_to_sphere_matrices, 65 : const Variables<ylm::TensorYlm::filter_detail::gh_spacetime_vars_list>& 66 : gh_vars, 67 : const Mesh<3>& mesh, 68 : const InverseJacobian<DataVector, 3, Frame::Inertial, Frame::Grid>& 69 : jac_inertial_to_grid); 70 : 71 : } // namespace gh::power_monitor