SpECTRE Documentation Coverage Report
Current view: top level - NumericalAlgorithms/Spectral/BasisFunctions - HalfFourier.hpp Hit Total Coverage
Commit: 107e15b340886ae54549b1baa4bfc92e676f667e Lines: 8 9 88.9 %
Date: 2026-09-17 16:38:56
Legend: Lines: hit not hit

          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 DataVector;
      10             : class Matrix;
      11             : namespace Spectral {
      12             : enum class Parity : uint8_t;
      13             : }  // namespace Spectral
      14             : /// \endcond
      15             : 
      16             : namespace Spectral {
      17             : 
      18             : /*!
      19             :  * \ingroup SpectralGroup
      20             :  *
      21             :  * \brief A collection of helper functions for the half-Fourier spectral basis
      22             :  *
      23             :  * \details The half-Fourier basis represents functions on the interval
      24             :  * \f$\phi \in [0, \pi)\f$ using \f$N\f$ equispaced interior collocation
      25             :  * points \f$\phi_j = (j + \tfrac{1}{2})\pi/N\f$ for \f$j = 0, \ldots, N-1\f$.
      26             :  *
      27             :  * Functions of even parity under \f$\phi \to -\phi\f$ (i.e. those satisfying
      28             :  * \f$f(-\phi)=f(\phi)\f$) are expanded in cosines:
      29             :  * \f[
      30             :  * f(\phi) = \sum_{n=0}^{N-1} a_n \cos(n\phi)
      31             :  * \f]
      32             :  *
      33             :  * Functions of odd parity under \f$\phi \to -\phi\f$ (i.e. those satisfying
      34             :  * \f$f(-\phi)=-f(\phi)\f$) are expanded in sines:
      35             :  * \f[
      36             :  * f(\phi) = \sum_{n=1}^{N} b_n \sin(n\phi)
      37             :  * \f]
      38             :  *
      39             :  * The derivative \f$\partial / \partial \phi\f$ maps even-parity functions to
      40             :  * odd-parity functions and vice versa.
      41             :  *
      42             :  * This basis is intended for use in the Cartoon method for axisymmetric
      43             :  * problems on a cylinder, where the azimuthal direction covers only half a
      44             :  * circle due to the reflection symmetry, and the parity boundary conditions
      45             :  * are internal to the spectral representation.
      46             :  */
      47           1 : class HalfFourier {
      48             :  public:
      49             :   /*!
      50             :    * \brief Collocation points \f$\{\phi_j\}\f$
      51             :    *
      52             :    * \details The collocation points on the interval \f$(0, \pi)\f$ are given
      53             :    * by
      54             :    * \f[
      55             :    * \phi_j = \frac{(j + \tfrac{1}{2})\pi}{N}
      56             :    * \f]
      57             :    */
      58           1 :   static DataVector collocation_points(size_t num_points);
      59             : 
      60             :   /*!
      61             :    * \brief Quadrature weights \f$\{w_j\}\f$
      62             :    *
      63             :    * \details The quadrature weights are uniform:
      64             :    * \f[
      65             :    * w_j = \frac{\pi}{N}
      66             :    * \f]
      67             :    */
      68           1 :   static DataVector quadrature_weights(size_t num_points);
      69             : 
      70             :   /*!
      71             :    * \brief Differentiation matrix \f$D^{\text{even}}_{ij}\f$ for even-parity
      72             :    * functions
      73             :    *
      74             :    * \details Maps an even-parity function (expanded in cosines) to its
      75             :    * derivative, which is an odd-parity function (expanded in sines).
      76             :    * Explicitly:
      77             :    * \f[
      78             :    * D^{\text{even}}_{ij} = \frac{2}{N} \sum_{n=1}^{N-1}
      79             :    * (-n) \sin(n\phi_i) \cos(n\phi_j)
      80             :    * \f]
      81             :    */
      82           1 :   static Matrix even_differentiation_matrix(size_t num_points);
      83             : 
      84             :   /*!
      85             :    * \brief Differentiation matrix \f$D^{\text{odd}}_{ij}\f$ for odd-parity
      86             :    * functions
      87             :    *
      88             :    * \details Maps an odd-parity function (expanded in sines) to its
      89             :    * derivative, which is an even-parity function (expanded in cosines).
      90             :    * Explicitly:
      91             :    * \f[
      92             :    * D^{\text{odd}}_{ij} = \frac{2}{N} \sum_{n=1}^{N-1}
      93             :    * n \cos(n\phi_i) \sin(n\phi_j)
      94             :    * \f]
      95             :    *
      96             :    * Note that \f$D^{\text{even}} = -(D^{\text{odd}})^T\f$.
      97             :    */
      98           1 :   static Matrix odd_differentiation_matrix(size_t num_points);
      99             : 
     100             :   /*!
     101             :    * \brief Interpolation matrix for even-parity functions to
     102             :    * \p target_points.
     103             :    *
     104             :    * \details Using the discrete cosine transform (DCT-II) representation, the
     105             :    * interpolation weights at a target point \f$x\f$ are:
     106             :    * \f[
     107             :    * I^{\text{even}}_j(x) = \frac{1}{N}\left[1 + 2\sum_{n=1}^{N-1}
     108             :    * \cos(nx)\cos(n\phi_j)\right]
     109             :    * \f]
     110             :    */
     111             :   template <typename T>
     112           1 :   static Matrix even_interpolation_matrix(size_t num_points,
     113             :                                           const T& target_points);
     114             : 
     115             :   /*!
     116             :    * \brief Interpolation matrix for odd-parity functions to
     117             :    * \p target_points.
     118             :    *
     119             :    * \details Using the discrete sine transform (DST-II) representation, the
     120             :    * interpolation weights at a target point \f$x\f$ are:
     121             :    * \f[
     122             :    * I^{\text{odd}}_j(x) = \frac{2}{N}\sum_{n=1}^{N-1}
     123             :    * \sin(nx)\sin(n\phi_j) + \frac{1}{N}\sin(Nx)\sin(N\phi_j)
     124             :    * \f]
     125             :    * where the Nyquist mode \f$n=N\f$ carries half the weight of the other
     126             :    * modes.
     127             :    */
     128             :   template <typename T>
     129           1 :   static Matrix odd_interpolation_matrix(size_t num_points,
     130             :                                          const T& target_points);
     131             : 
     132             :   /*!
     133             :    * \brief %Matrix used to interpolate to the \p target_points for a given
     134             :    * \p parity.
     135             :    *
     136             :    * \details Dispatches to `even_interpolation_matrix` when \p parity is
     137             :    * `Parity::Even` and to `odd_interpolation_matrix` when it is `Parity::Odd`.
     138             :    * This mirrors the interface of `Zernike<1>::interpolation_matrix`.
     139             :    */
     140             :   template <typename T>
     141           1 :   static Matrix interpolation_matrix(size_t num_points, const T& target_points,
     142             :                                      Parity parity);
     143             : };
     144             : }  // namespace Spectral

Generated by: LCOV version 1.14