Line data Source code
1 0 : // Distributed under the MIT License. 2 : // See LICENSE.txt for details. 3 : 4 : #pragma once 5 : 6 : #include <optional> 7 : #include <ostream> 8 : 9 : /// \cond 10 : namespace Options { 11 : class Option; 12 : template <typename T> 13 : struct create_from_yaml; 14 : } // namespace Options 15 : /// \endcond 16 : 17 : namespace domain::CoordinateMaps { 18 : 19 : /*! 20 : * \brief Distribution of grid points in one dimension 21 : * 22 : * Used to select a distribution of grid points in the input file. 23 : * 24 : * \see domain::CoordinateMaps::Wedge 25 : */ 26 0 : enum class Distribution { 27 : Linear, 28 : Equiangular, 29 : Logarithmic, 30 : Inverse, 31 : Projective 32 : }; 33 : 34 0 : std::ostream& operator<<(std::ostream& os, Distribution distribution); 35 : 36 : /*! 37 : * \brief A `Distribution` and the corresponding singularity position 38 : * 39 : * The `singularity_position` is only meaningful for `Distribution::Logarithmic` 40 : * and `Distribution::Inverse`. 41 : * 42 : * This class can be option-created like so: 43 : * - Just the name of the distribution for `Linear`, `Equiangular`, and 44 : * `Projective`. 45 : * - The name of the distribution and the singularity position for 46 : * `Logarithmic` and `Inverse`: 47 : * 48 : * ```yaml 49 : * Logarithmic: 50 : * SingularityPosition: 0.0 51 : * ``` 52 : */ 53 1 : struct DistributionAndSingularityPosition { 54 0 : Distribution distribution = Distribution::Linear; 55 0 : std::optional<double> singularity_position = std::nullopt; 56 : }; 57 : 58 0 : bool operator==(const DistributionAndSingularityPosition& lhs, 59 : const DistributionAndSingularityPosition& rhs); 60 : 61 : } // namespace domain::CoordinateMaps 62 : 63 : template <> 64 0 : struct Options::create_from_yaml<domain::CoordinateMaps::Distribution> { 65 : template <typename Metavariables> 66 0 : static domain::CoordinateMaps::Distribution create( 67 : const Options::Option& options) { 68 : return create<void>(options); 69 : } 70 : }; 71 : template <> 72 0 : domain::CoordinateMaps::Distribution 73 : Options::create_from_yaml<domain::CoordinateMaps::Distribution>::create<void>( 74 : const Options::Option& options); 75 : 76 : template <> 77 0 : struct Options::create_from_yaml< 78 : domain::CoordinateMaps::DistributionAndSingularityPosition> { 79 : template <typename Metavariables> 80 0 : static domain::CoordinateMaps::DistributionAndSingularityPosition create( 81 : const Options::Option& options) { 82 : return create<void>(options); 83 : } 84 : }; 85 : template <> 86 0 : domain::CoordinateMaps::DistributionAndSingularityPosition 87 : Options::create_from_yaml< 88 : domain::CoordinateMaps::DistributionAndSingularityPosition>:: 89 : create<void>(const Options::Option& options);