Line data Source code
1 0 : // Distributed under the MIT License. 2 : // See LICENSE.txt for details. 3 : 4 : #pragma once 5 : 6 : #include <memory> 7 : #include <optional> 8 : #include <pup.h> 9 : 10 : /// \cond 11 : namespace control_system::size { 12 : struct State; 13 : } // namespace control_system::size 14 : /// \endcond 15 : 16 : namespace control_system::size { 17 : 18 : /// Holds information that is saved between calls of SizeControl. 19 1 : struct Info { 20 0 : Info() = default; 21 0 : Info(const Info& rhs); 22 0 : Info& operator=(const Info& rhs); 23 0 : Info(Info&& rhs) = default; 24 0 : Info& operator=(Info&& rhs) = default; 25 : 26 0 : Info(std::unique_ptr<State> in_state, double in_damping_time, 27 : double in_target_char_speed, double in_target_drift_velocity, 28 : std::optional<double> in_suggested_time_scale, 29 : bool in_discontinuous_change_has_occurred); 30 : 31 : // Info needs to be serializable because it will be 32 : // stored inside of a ControlError. 33 0 : void pup(PUP::er& p); 34 : 35 : /// The current state of size control. 36 1 : std::unique_ptr<State> state; 37 : /// The current damping time associated with size control. 38 1 : double damping_time; 39 : /// target_char_speed is what the characteristic speed is driven 40 : /// toward in state Label::AhSpeed. 41 1 : double target_char_speed; 42 : /// target_drift_velocity is what dr/dt (where r and t are distorted frame 43 : /// variables) of the excision boundary is driven toward in state 44 : /// Label::Initial. 45 1 : double target_drift_velocity; 46 : /// Sometimes State::update will request that damping_time 47 : /// be changed; the new suggested value is suggested_time_scale. If it is a 48 : /// `std::nullopt` then there is no suggestion. 49 1 : std::optional<double> suggested_time_scale; 50 : /// discontinuous_change_has_occurred is set to true by 51 : /// State::update if it changes anything in such a way that 52 : /// the control signal jumps discontinuously in time. 53 1 : bool discontinuous_change_has_occurred; 54 : 55 : /// Reset `discontinuous_change_has_occurred` and `suggested_time_scale` 56 1 : void reset(); 57 : 58 : private: 59 0 : void set_all_but_state(const Info& info); 60 : }; 61 : 62 : /// Holds information about crossing times, as computed by 63 : /// ZeroCrossingPredictors. 64 1 : struct CrossingTimeInfo { 65 0 : CrossingTimeInfo( 66 : const std::optional<double>& char_speed_crossing_time, 67 : const std::optional<double>& comoving_char_speed_crossing_time, 68 : const std::optional<double>& delta_radius_crossing_time); 69 : /// t_char_speed is the time (relative to the current time) when the 70 : /// minimum characteristic speed is predicted to cross zero (or nullopt if 71 : /// the minimum characteristic speed is increasing). 72 1 : std::optional<double> t_char_speed; 73 : /// t_comoving_char_speed is the time (relative to the current time) when the 74 : /// minimum comoving characteristic speed is predicted to cross zero 75 : /// (or nullopt if the minimum comoving characteristic speed is increasing). 76 1 : std::optional<double> t_comoving_char_speed; 77 : /// t_delta_radius is the time (relative to the current time) when the 78 : /// minimum distance between the horizon and the excision boundary is 79 : /// predicted to cross zero (or nullopt if the minimum distance is 80 : /// increasing). 81 1 : std::optional<double> t_delta_radius; 82 : /// Extra variables to simplify the logic; these indicate whether 83 : /// the characteristic speed or the excision boundary (or neither) are 84 : /// expected to cross zero soon. 85 1 : bool char_speed_will_hit_zero_first{false}; 86 0 : bool horizon_will_hit_excision_boundary_first{false}; 87 : }; 88 : } // namespace control_system::size