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 <pup.h> 8 : #include <string> 9 : 10 : #include "ControlSystem/ControlErrors/Size/Info.hpp" 11 : #include "ControlSystem/ControlErrors/Size/State.hpp" 12 : #include "Options/String.hpp" 13 : #include "Utilities/Serialization/CharmPupable.hpp" 14 : #include "Utilities/TMPL.hpp" 15 : 16 : namespace control_system::size::States { 17 0 : class DeltaRDriftInward : public State { 18 : public: 19 0 : using options = tmpl::list<>; 20 0 : static constexpr Options::String help{ 21 : "Controls the velocity of the excision surface to maintain a constant " 22 : "separation between the excision surface and the horizon surface with a " 23 : "small inward radial velocity. This is state 3 in SpEC."}; 24 0 : DeltaRDriftInward() = default; 25 1 : std::string name() const override { return "DeltaRDriftInward"; } 26 1 : size_t number() const override { return 3; } 27 0 : std::unique_ptr<State> get_clone() const override; 28 0 : std::string update(gsl::not_null<Info*> info, 29 : const StateUpdateArgs& update_args, 30 : const CrossingTimeInfo& crossing_time_info) const override; 31 : /// The return value is Q from Eq. 96 of \cite Hemberger2012jz, plus 32 : /// an inward velocity term. 33 1 : double control_error( 34 : const Info& info, 35 : const ControlErrorArgs& control_error_args) const override; 36 : 37 0 : WRAPPED_PUPable_decl_template(DeltaRDriftInward); // NOLINT 38 0 : explicit DeltaRDriftInward(CkMigrateMessage* const /*msg*/) {} 39 : }; 40 : 41 : // The following are helper functions that are used in many 42 : // of the states, for transitions to/from DeltaRDriftInward. 43 : 44 : /// Value of target_char_speed when state DeltaRDriftInward is in effect. 45 1 : double target_speed_for_inward_drift( 46 : double avg_distorted_normal_dot_unit_coord_vector, double min_char_speed, 47 : double inward_drift_velocity); 48 : 49 : /// Returs true if we should transition from state DeltaR to state 50 : /// DeltaRDriftInward. 51 1 : bool should_transition_from_state_delta_r_to_inward_drift( 52 : const std::optional<double>& crossing_time_drift_limit, double damping_time, 53 : const StateUpdateArgs& update_args); 54 : 55 : /// Returns true if we should transition from state DeltaRDriftInward 56 : /// to state DeltaRNoDrift. 57 1 : bool should_transition_from_state_inward_drift_to_delta_r_no_drift( 58 : const std::optional<double>& crossing_time_drift_limit, double damping_time, 59 : const StateUpdateArgs& update_args); 60 : 61 : /// Returns true if we should transition to DeltaRDriftInward rather than 62 : /// to DeltaR. 63 1 : bool should_activate_inward_drift(const StateUpdateArgs& update_args); 64 : 65 : /// Returns true if either CharSpeed approaches min_allowed_char_speed 66 : /// or DeltaR approaches min_allowed_radial_distance close enough 67 : /// that it would be ok to turn off state DeltaRNoDrift. 68 1 : bool ok_to_return_to_state_deltar(const StateUpdateArgs& update_args); 69 : 70 : } // namespace control_system::size::States