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 <cstdint> 8 : #include <iosfwd> 9 : #include <string> 10 : 11 : /// \cond 12 : namespace Options { 13 : class Option; 14 : template <typename T> 15 : struct create_from_yaml; 16 : } // namespace Options 17 : /// \endcond 18 : 19 : namespace Spectral { 20 : /*! 21 : * \brief Either the choice of quadrature method to compute integration weights 22 : * for a spectral or discontinuous Galerkin (DG) method, or the locations of 23 : * grid points when a finite difference method is used 24 : * 25 : * \details The particular choices of Basis and Quadrature determine 26 : * where the collocation points of a Mesh are located in an Element. For a 27 : * spectral or DG method, integrals using \f$N\f$ collocation points with Gauss 28 : * quadrature are exact to polynomial order \f$p=2N-1\f$. Gauss-Lobatto 29 : * quadrature is exact only to polynomial order \f$p=2N-3\f$, but includes 30 : * collocation points at the Element boundary. Gauss-Radau 31 : * quadrature is exact only to polynomial order \f$p=2N-2\f$, but includes a 32 : * collocation points at the lower or upper boundary of the Element. For a 33 : * finite difference method, one needs to choose the order of the scheme (and 34 : * hence the weights, differentiation matrix, integration weights, and 35 : * interpolant) locally in space and time to handle discontinuous 36 : * solutions. 37 : * 38 : * \note Choose `Gauss` or `GaussLobatto` when using Basis::Legendre or 39 : * Basis::Chebyshev. 40 : * 41 : * \note Choose `CellCentered` or `FaceCentered` when using 42 : * Basis::FiniteDifference. 43 : * 44 : * \note Choose `Equiangular` when using Basis::Fourier. 45 : * 46 : * \note When using Basis::SphericalHarmonic in consecutive dimensions, choose 47 : * `Gauss` for the first dimension and `Equiangular` in the second dimension. 48 : * 49 : * \note When using Basis::ZernikeB2 in consecutive dimensions, choose 50 : * `GaussRadauUpper` for the first dimension and `Equiangular` in the second 51 : * dimension. 52 : * 53 : * \note When using Basis::ZernikeB3 in consecutive dimensions, choose 54 : * `GaussRadauUpper` for the first dimension, `Gauss` for the second dimension, 55 : * and `Equiangular` in the third dimension. 56 : * 57 : * \remark We store these effectively as a 4-bit integer using the lowest 4 58 : * bits of a uint8_t. Unlike Basis, this does not need a bitshift. We cannot 59 : * have more than 16 quadratures to fit into the 4 bits, including the 60 : * `Uninitialized` value. 61 : */ 62 0 : enum class Quadrature : uint8_t { 63 : Uninitialized = 0, 64 : Gauss, 65 : GaussLobatto, 66 : CellCentered, 67 : FaceCentered, 68 : Equiangular, 69 : GaussRadauLower, 70 : GaussRadauUpper, 71 : AxialSymmetry, 72 : SphericalSymmetry 73 : }; 74 : 75 : /// All possible values of Quadrature 76 1 : std::array<Quadrature, 10> all_quadratures(); 77 : 78 : /// Convert a string to a Quadrature enum. 79 1 : Quadrature to_quadrature(const std::string& quadrature); 80 : 81 : /// Output operator for a Quadrature. 82 1 : std::ostream& operator<<(std::ostream& os, const Quadrature& quadrature); 83 : } // namespace Spectral 84 : 85 : template <> 86 0 : struct Options::create_from_yaml<Spectral::Quadrature> { 87 : template <typename Metavariables> 88 0 : static Spectral::Quadrature create(const Options::Option& options) { 89 : return create<void>(options); 90 : } 91 : }; 92 : 93 : template <> 94 0 : Spectral::Quadrature 95 : Options::create_from_yaml<Spectral::Quadrature>::create<void>( 96 : const Options::Option& options);