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 <cstddef> 8 : #include <memory> 9 : #include <optional> 10 : #include <string> 11 : #include <variant> 12 : 13 : #include "DataStructures/DataVector.hpp" 14 : #include "Domain/Creators/TimeDependentOptions/FromVolumeFile.hpp" 15 : #include "Domain/FunctionsOfTime/FunctionOfTime.hpp" 16 : #include "Options/Auto.hpp" 17 : #include "Options/Context.hpp" 18 : #include "Options/Options.hpp" 19 : #include "Options/String.hpp" 20 : #include "Utilities/TMPL.hpp" 21 : 22 0 : namespace domain::creators::time_dependent_options { 23 : /*! 24 : * \brief Class that holds hard coded expansion map options from the input file. 25 : * 26 : * \details This class can also be used as an option tag with the \p type type 27 : * alias, `name()` function, and \p help string. 28 : */ 29 : template <bool AllowSettleFoTs> 30 1 : struct ExpansionMapOptions { 31 0 : using type = Options::Auto< 32 : std::variant<ExpansionMapOptions<AllowSettleFoTs>, FromVolumeFile>, 33 : Options::AutoLabel::None>; 34 0 : static std::string name() { return "ExpansionMap"; } 35 0 : static constexpr Options::String help = { 36 : "Options for a time-dependent expansion of the coordinates. Specify " 37 : "'None' to not use this map."}; 38 : 39 0 : struct InitialValues { 40 0 : using type = std::array<double, 3>; 41 0 : static constexpr Options::String help = 42 : "Initial values for the expansion map, its velocity and acceleration."; 43 : }; 44 : 45 0 : struct InitialValuesOuterBoundary { 46 0 : using type = std::array<double, 3>; 47 0 : static constexpr Options::String help = { 48 : "Initial values for the expansion map, its velocity and acceleration " 49 : "at the outer boundary."}; 50 : }; 51 : 52 0 : struct DecayTimescaleOuterBoundary { 53 0 : using type = double; 54 0 : static constexpr Options::String help = { 55 : "A timescale for how fast the outer boundary expansion approaches its " 56 : "asymptotic value."}; 57 : }; 58 : 59 0 : struct DecayTimescale { 60 0 : using type = double; 61 0 : static constexpr Options::String help = { 62 : "A timescale for how fast the expansion approaches its asymptotic " 63 : "value with a SettleToConstant function of time."}; 64 : }; 65 : 66 0 : struct AsymptoticVelocityOuterBoundary { 67 0 : using type = double; 68 0 : static constexpr Options::String help = { 69 : "The constant velocity of the outer boundary expansion."}; 70 : }; 71 : 72 0 : using common_options = tmpl::list<InitialValues, DecayTimescaleOuterBoundary>; 73 0 : using settle_options = 74 : tmpl::push_back<common_options, InitialValuesOuterBoundary, 75 : DecayTimescale>; 76 0 : using non_settle_options = 77 : tmpl::push_back<common_options, AsymptoticVelocityOuterBoundary>; 78 : 79 0 : using options = tmpl::conditional_t< 80 : AllowSettleFoTs, 81 : tmpl::list<Options::Alternatives<settle_options, non_settle_options>>, 82 : non_settle_options>; 83 : 84 0 : ExpansionMapOptions() = default; 85 : // Constructor for SettleToConstant functions of time 86 0 : ExpansionMapOptions( 87 : const std::array<double, 3>& initial_values_in, 88 : double decay_timescale_outer_boundary_in, 89 : const std::array<double, 3>& initial_values_outer_boundary_in, 90 : double decay_timescale_in, const Options::Context& context = {}); 91 : // Constructor for non SettleToConstant functions of time 92 0 : ExpansionMapOptions(const std::array<double, 3>& initial_values_in, 93 : double decay_timescale_outer_boundary_in, 94 : double asymptotic_velocity_outer_boundary_in, 95 : const Options::Context& context = {}); 96 : 97 0 : std::array<DataVector, 3> initial_values{}; 98 0 : std::array<DataVector, 3> initial_values_outer_boundary{}; 99 0 : double decay_timescale_outer_boundary{}; 100 0 : std::optional<double> decay_timescale; 101 0 : std::optional<double> asymptotic_velocity_outer_boundary; 102 : }; 103 : 104 : /*! 105 : * \brief Helper functions that take the variant of the expansion map options, 106 : * and return the fully constructed expansion functions of time. 107 : * 108 : * \details The function of time will have a new \p initial_time and \p 109 : * expiration_time, unless it is read from a file and is replaying. 110 : */ 111 : template <bool AllowSettleFoTs> 112 1 : FunctionsOfTimeMap get_expansion( 113 : const std::variant<ExpansionMapOptions<AllowSettleFoTs>, FromVolumeFile>& 114 : expansion_map_options, 115 : double initial_time, double expiration_time); 116 : } // namespace domain::creators::time_dependent_options