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 : /// \cond 9 : class Matrix; 10 : template <size_t> 11 : class Mesh; 12 : namespace Spectral { 13 : enum class Basis : uint8_t; 14 : enum class Parity : uint8_t; 15 : enum class Quadrature : uint8_t; 16 : } // namespace Spectral 17 : /// \endcond 18 : 19 : namespace Spectral { 20 : /*! 21 : * \brief %Matrix used to transform from the nodal coefficients of a function to 22 : * its spectral coefficients (modes). Also referred to as the inverse 23 : * _Vandermonde matrix_. 24 : * 25 : * \details This is the inverse to the Vandermonde matrix \f$\mathcal{V}\f$ 26 : * computed in modal_to_nodal_matrix(size_t). It can be computed 27 : * analytically for Gauss quadrature by evaluating 28 : * \f$\sum_j\mathcal{V}^{-1}_{ij}u_j=\widetilde{u}_i= 29 : * \frac{(u,\Phi_i)}{\gamma_i}\f$ 30 : * for a Lagrange basis function \f$u(x)=l_k(x)\f$ to find 31 : * \f$\mathcal{V}^{-1}_{ij}=\mathcal{V}_{ji}\frac{w_j}{\gamma_i}\f$ where the 32 : * \f$w_j\f$ are the Gauss quadrature weights and \f$\gamma_i\f$ is the norm 33 : * square of the spectral basis function \f$\Phi_i\f$. 34 : * 35 : * \param num_points The number of collocation points 36 : * 37 : * \see modal_to_nodal_matrix(size_t) 38 : */ 39 : template <Basis BasisType, Quadrature QuadratureType> 40 1 : const Matrix& nodal_to_modal_matrix(size_t num_points); 41 : 42 : /*! 43 : * \brief %Matrix used to transform from the nodal coefficients of a function to 44 : * its spectral coefficients (modes). This two-index version is used for 45 : * two-dimensional basis function (i.e. Zernike with GaussRadauUpper 46 : * quadrature). 47 : * 48 : * For Zernike, \f$m\f$ is the angular index and \f$N\f$ is the 49 : * maximum supported spectral index (usually taken to be the maximum value, 50 : * \f$2 \, \texttt{num_points}-2\f$). Note that the size of a spectral space 51 : * vector is \f$(N - m) / 2 + 1\f$, using integer division. 52 : * 53 : * \see nodal_to_modal_matrix(size_t) 54 : */ 55 : template <Basis BasisType, Quadrature QuadratureType> 56 1 : const Matrix& nodal_to_modal_matrix(size_t num_points, size_t m, size_t N); 57 : 58 : /*! 59 : * \brief Transformation matrix from nodal to modal coefficients for a 60 : * one-dimensional mesh. 61 : * 62 : * \see nodal_to_modal_matrix(size_t) 63 : */ 64 1 : const Matrix& nodal_to_modal_matrix(const Mesh<1>& mesh); 65 : 66 : /*! 67 : * \brief Transformation matrix from nodal to modal coefficients for a 68 : * one-dimensional mesh with a Zernike basis. 69 : * 70 : * \see nodal_to_modal_matrix(size_t, size_t, size_t) 71 : */ 72 1 : const Matrix& nodal_to_modal_matrix(const Mesh<1>& mesh, size_t m, size_t N); 73 : 74 : /*! 75 : * \brief %Matrix used to transform from the nodal coefficients of a function to 76 : * its spectral coefficients (modes), for a parity-dependent basis such as 77 : * `Basis::HalfFourier`. 78 : * 79 : * \param num_points The number of collocation points 80 : * \param parity The parity of the function (`Parity::Even` or `Parity::Odd`) 81 : * 82 : * \see nodal_to_modal_matrix(size_t) 83 : */ 84 : template <Basis BasisType, Quadrature QuadratureType> 85 1 : const Matrix& nodal_to_modal_matrix(size_t num_points, Parity parity); 86 : 87 : /*! 88 : * \brief Transformation matrix from nodal to modal coefficients for a 89 : * one-dimensional mesh with a parity-dependent basis such as 90 : * `Basis::HalfFourier`. 91 : * 92 : * \see nodal_to_modal_matrix(size_t, Parity) 93 : */ 94 1 : const Matrix& nodal_to_modal_matrix(const Mesh<1>& mesh, Parity parity); 95 : } // namespace Spectral