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 "NumericalAlgorithms/Spectral/CollocationPointsAndWeights.hpp" 9 : 10 : /// \cond 11 : class DataVector; 12 : class Matrix; 13 : namespace Spectral { 14 : enum class Quadrature : uint8_t; 15 : enum class Parity : uint8_t; 16 : } // namespace Spectral 17 : /// \endcond 18 : 19 : namespace Spectral { 20 : 21 : /*! 22 : * \ingroup SpectralGroup 23 : * 24 : * \brief A collection of helper functions for the radial functions used in 25 : * Zernike polyomials 26 : * 27 : */ 28 : template <size_t Dim> 29 1 : class Zernike { 30 : public: 31 : /*! 32 : * \brief Value of the basis function \f$\Phi^m_n(\xi) = R^m_n(r)\f$, 33 : * where \f$r \equiv \frac{1}{2} (\xi + 1)\f$, implemented from 34 : * \cite Matsushima1995 35 : */ 36 : template <typename T> 37 1 : static T basis_function_value(size_t n, size_t m, const T& xi); 38 : 39 : /*! 40 : * \brief Collocation points \f${x_i}\f$ and quadrature weights \f${w_i}\f$ 41 : */ 42 : static std::pair<DataVector, DataVector> 43 1 : compute_collocation_points_and_weights(size_t num_points); 44 : 45 : /*! 46 : * \brief Matrix \f$D_{i,j}\f$ used to obtain the first derivative for a 47 : * given parity. 48 : * 49 : * Due to the clustering of Zernike collocation toward the upper side, the 50 : * generic implementation of derivatives with barycentric weights yields 51 : * large errors. By utilizing the fact that the Zernike bases' \f$m\f$ 52 : * corresponds to parity of representable functions, we can extend the 53 : * function to negative \f$r\f$ before forming the matrix, greatly improving 54 : * accuracy. 55 : */ 56 1 : static Matrix differentiation_matrix(size_t num_points, Parity parity); 57 : }; 58 : } // namespace Spectral