Line data Source code
1 0 : 2 : // Distributed under the MIT License. 3 : // See LICENSE.txt for details. 4 : 5 : #pragma once 6 : 7 : #include <array> 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 1 : namespace Spectral { 20 : /*! 21 : * \brief Either the basis functions used by a spectral or discontinuous 22 : * Galerkin (DG) method, or the value `FiniteDifference` when a finite 23 : * 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. 27 : * For a spectral or DG method, the Basis also represents the choice 28 : * of basis functions used to represent a function on an Element, 29 : * which then provides a convenient choice for the operators used for 30 : * differentiation, interpolation, etc. For a finite difference 31 : * method, one needs to choose the order of the scheme (and hence the 32 : * weights, differentiation matrix, integration weights, and 33 : * interpolant) locally in space and time to handle discontinuous 34 : * solutions. 35 : * 36 : * \note Choose `Legendre` for a general-purpose spectral or DG mesh, unless 37 : * you have a particular reason for choosing `Chebyshev`. 38 : * 39 : * \note Choose two consecutive dimensions to have `SphericalHarmonic` to choose 40 : * a spherical harmonic basis. By convention, the first dimension represents 41 : * the polar/zentith angle (or colatitude), while the second dimension 42 : * represents the azimuthal angle (or longitude) 43 : */ 44 0 : enum class Basis { Chebyshev, Legendre, FiniteDifference, SphericalHarmonic }; 45 : 46 : /// All possible values of Basis 47 1 : std::array<Basis, 4> all_bases(); 48 : 49 : /// Convert a string to a Basis enum. 50 1 : Basis to_basis(const std::string& basis); 51 : 52 : /// Output operator for a Basis. 53 1 : std::ostream& operator<<(std::ostream& os, const Basis& basis); 54 : } // namespace Spectral 55 : 56 : template <> 57 0 : struct Options::create_from_yaml<Spectral::Basis> { 58 : template <typename Metavariables> 59 0 : static Spectral::Basis create(const Options::Option& options) { 60 : return create<void>(options); 61 : } 62 : }; 63 : 64 : template <> 65 0 : Spectral::Basis Options::create_from_yaml<Spectral::Basis>::create<void>( 66 : const Options::Option& options);