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 <iosfwd> 8 : #include <string> 9 : 10 : /// \cond 11 : namespace Options { 12 : class Option; 13 : template <typename T> 14 : struct create_from_yaml; 15 : } // namespace Options 16 : /// \endcond 17 : 18 : namespace Spectral { 19 : /*! 20 : * \brief Either the choice of quadrature method to compute integration weights 21 : * for a spectral or discontinuous Galerkin (DG) method, or the locations of 22 : * grid points when a finite difference method is used 23 : * 24 : * \details The particular choices of Basis and Quadrature determine 25 : * where the collocation points of a Mesh are located in an Element. For a 26 : * spectral or DG method, integrals using \f$N\f$ collocation points with Gauss 27 : * quadrature are exact to polynomial order \f$p=2N-1\f$. Gauss-Lobatto 28 : * quadrature is exact only to polynomial order \f$p=2N-3\f$, but includes 29 : * collocation points at the domain boundary. For a finite difference 30 : * method, one needs to choose the order of the scheme (and hence the 31 : * weights, differentiation matrix, integration weights, and 32 : * interpolant) locally in space and time to handle discontinuous 33 : * solutions. 34 : * 35 : * \note Choose `Gauss` or `GaussLobatto` when using Basis::Legendre or 36 : * Basis::Chebyshev. 37 : * 38 : * \note Choose `CellCentered` or `FaceCentered` when using 39 : * Basis::FiniteDifference. 40 : * 41 : * \note When using Basis::SphericalHarmonic in consecutive dimensions, choose 42 : * `Gauss` for the first dimension and `Equiangular` in the second dimension. 43 : */ 44 0 : enum class Quadrature { 45 : Gauss, 46 : GaussLobatto, 47 : CellCentered, 48 : FaceCentered, 49 : Equiangular 50 : }; 51 : 52 : /// All possible values of Quadrature 53 1 : std::array<Quadrature, 5> all_quadratures(); 54 : 55 : /// Convert a string to a Quadrature enum. 56 1 : Quadrature to_quadrature(const std::string& quadrature); 57 : 58 : /// Output operator for a Quadrature. 59 1 : std::ostream& operator<<(std::ostream& os, const Quadrature& quadrature); 60 : } // namespace Spectral 61 : 62 : template <> 63 0 : struct Options::create_from_yaml<Spectral::Quadrature> { 64 : template <typename Metavariables> 65 0 : static Spectral::Quadrature create(const Options::Option& options) { 66 : return create<void>(options); 67 : } 68 : }; 69 : 70 : template <> 71 0 : Spectral::Quadrature 72 : Options::create_from_yaml<Spectral::Quadrature>::create<void>( 73 : const Options::Option& options);