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/SimpleSparseMatrix.hpp"
9 : #include "DataStructures/Tensor/TypeAliases.hpp"
10 : #include "DataStructures/Variables.hpp"
11 : #include "Evolution/Systems/GeneralizedHarmonic/ApplyTensorYlmFilter.hpp"
12 : #include "Utilities/Gsl.hpp"
13 :
14 : /// \cond
15 : class DataVector;
16 : namespace ylm {
17 : class Spherepack;
18 : } // namespace ylm
19 : /// \endcond
20 :
21 : namespace ylm::TensorYlm {
22 :
23 : /*!
24 : * \brief Transform Generalized Harmonic variables on a spherical shell to
25 : * tensor-Ylm coefficients of their spatial pieces.
26 : *
27 : * The `gh_vars` are nodal values on either a spherical slice
28 : * (`radial_extents == 1`) or a shell with `radial_extents` radial points and
29 : * S2 angular collocation points described by `spherepack`. The output
30 : * `gh_spatial_tensor_ylm_coefficients` has the GH spacetime tensors broken
31 : * into spatial pieces, transformed to the grid frame using
32 : * `jac_inertial_to_grid`, converted from nodal to modal S2 coefficients, and
33 : * finally transformed from Cartesian components to the TensorYlm
34 : * \f$(\ell, m, \bar m)\f$ basis.
35 : *
36 : * The output uses Spherepack spectral storage with the radial offsets
37 : * interleaved in the same layout as `Spherepack::phys_to_spec_all_offsets`.
38 : * Its tensor component labels are not Cartesian component labels. They are
39 : * TensorYlm basis labels: component index 0 denotes an \f$\ell\f$ basis index,
40 : * component index 1 denotes an \f$m\f$ basis index, and component index 2
41 : * denotes an \f$\bar m\f$ basis index.
42 : *
43 : * Scalar quantities are transformed by the nodal-to-modal spherical-harmonic
44 : * transform. Non-scalar quantities are then transformed from Cartesian
45 : * components to the TensorYlm basis with the supplied sparse matrices.
46 : *
47 : * For performance, the function does not allocate large buffers and does not
48 : * build the cartesian-to-spherical matrices. The caller supplies
49 : * `temp_storage` and precomputed matrices. `temp_storage` has the same type as
50 : * the output so the implementation can reuse one contiguous buffer as inertial
51 : * spatial pieces at the collocation points and as spectral coefficients. It
52 : * must have at least `radial_extents * spherepack.spectral_size()` grid points.
53 : * The `spherepack` must have `m_max == l_max`, matching the
54 : * cartesian-to-spherical matrices.
55 : *
56 : * \param gh_spatial_tensor_ylm_coefficients Output coefficients for the GH
57 : * variables broken into spatial pieces. The output is overwritten and must
58 : * have `radial_extents * spherepack.spectral_size()` grid points.
59 : * \param temp_storage Temporary storage allocated by the caller. It is
60 : * overwritten and must not alias `gh_spatial_tensor_ylm_coefficients`.
61 : * \param gh_vars Generalized Harmonic variables at collocation points. Must
62 : * have `radial_extents * spherepack.physical_size()` grid points.
63 : * \param jac_inertial_to_grid Jacobian taking spatial tensor components from
64 : * the inertial frame to the grid frame.
65 : * \param cart_to_sphere_matrix_i Cartesian-to-TensorYlm matrix for rank-1
66 : * spatial tensors.
67 : * \param cart_to_sphere_matrix_ii Cartesian-to-TensorYlm matrix for symmetric
68 : * rank-2 spatial tensors.
69 : * \param cart_to_sphere_matrix_ij Cartesian-to-TensorYlm matrix for rank-2
70 : * spatial tensors with no symmetry.
71 : * \param cart_to_sphere_matrix_ijj Cartesian-to-TensorYlm matrix for rank-3
72 : * spatial tensors symmetric on the last two indices.
73 : * \param spherepack The spherical-harmonic transform object describing the S2
74 : * grid and spectral storage.
75 : * \param radial_extents The number of radial grid points, or 1 for a single
76 : * spherical slice.
77 : */
78 1 : void gh_variables_to_tensor_ylm_coefficients(
79 : gsl::not_null<Variables<filter_detail::gh_spatial_vars_list<Frame::Grid>>*>
80 : gh_spatial_tensor_ylm_coefficients,
81 : gsl::not_null<Variables<filter_detail::gh_spatial_vars_list<Frame::Grid>>*>
82 : temp_storage,
83 : const Variables<filter_detail::gh_spacetime_vars_list>& gh_vars,
84 : const InverseJacobian<DataVector, 3, Frame::Inertial, Frame::Grid>&
85 : jac_inertial_to_grid,
86 : const SimpleSparseMatrix& cart_to_sphere_matrix_i,
87 : const SimpleSparseMatrix& cart_to_sphere_matrix_ii,
88 : const SimpleSparseMatrix& cart_to_sphere_matrix_ij,
89 : const SimpleSparseMatrix& cart_to_sphere_matrix_ijj,
90 : const Spherepack& spherepack, size_t radial_extents);
91 :
92 : } // namespace ylm::TensorYlm
|