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 <pup.h> 8 : #include <string> 9 : #include <unordered_map> 10 : 11 : #include "DataStructures/Tensor/Tensor.hpp" 12 : #include "Domain/FunctionsOfTime/FunctionOfTime.hpp" 13 : #include "Domain/Structure/ObjectLabel.hpp" 14 : #include "Options/String.hpp" 15 : #include "ParallelAlgorithms/EventsAndTriggers/Trigger.hpp" 16 : #include "Utilities/Serialization/CharmPupable.hpp" 17 : #include "Utilities/TMPL.hpp" 18 : 19 : /// \cond 20 : namespace Frame { 21 : struct Grid; 22 : struct Inertial; 23 : struct Distorted; 24 : } // namespace Frame 25 : namespace domain::Tags { 26 : template <size_t VolumeDim> 27 : struct Domain; 28 : struct FunctionsOfTime; 29 : template <size_t VolumeDim> 30 : struct Element; 31 : template <ObjectLabel Label> 32 : struct ObjectCenter; 33 : } // namespace domain::Tags 34 : template <size_t VolumeDim> 35 : struct Domain; 36 : template <size_t VolumeDim> 37 : struct Element; 38 : namespace Tags { 39 : struct Time; 40 : } // namespace Tags 41 : /// \endcond 42 : 43 0 : namespace Triggers { 44 : /*! 45 : * \brief A standard trigger that monitors the separation between 46 : * `domain::Tags::ObjectCenter<A>` and `domain::Tags::ObjectCenter<B>` in the 47 : * inertial frame. Once the separation is smaller than (or equal to) the input 48 : * separation, then the `operator()` returns true. 49 : * 50 : * \note This trigger requires that 51 : * `domain::Tags::ObjectCenter<domain::ObjectLabel::A>` and 52 : * `domain::Tags::ObjectCenter<domain::ObjectLabel::B>` are in the DataBox. It 53 : * also requires that there are two ExcisionSphere%s in the Domain named 54 : * `ExcisionSphereA/B` and that these ExcisionSphere%s have had time dependent 55 : * maps injected into them. The coordinate maps from these ExcisionSphere%s will 56 : * be used to calculate the separation in the inertial frame. 57 : */ 58 1 : class SeparationLessThan : public Trigger { 59 : public: 60 : /// \cond 61 : SeparationLessThan() = default; 62 : explicit SeparationLessThan(CkMigrateMessage* /*unused*/) {} 63 : using PUP::able::register_constructor; 64 : WRAPPED_PUPable_decl_template(SeparationLessThan); // NOLINT 65 : /// \endcond 66 : 67 0 : struct Value { 68 0 : using type = double; 69 0 : static constexpr Options::String help = { 70 : "Separation of the two horizons to compare against."}; 71 : }; 72 : 73 0 : using options = tmpl::list<Value>; 74 0 : static constexpr Options::String help{ 75 : "Trigger when the separation between the two horizons is less than a " 76 : "certain distance."}; 77 : 78 0 : explicit SeparationLessThan(double separation); 79 : 80 0 : using argument_tags = 81 : tmpl::list<Tags::Time, domain::Tags::Domain<3>, 82 : domain::Tags::FunctionsOfTime, 83 : domain::Tags::ObjectCenter<domain::ObjectLabel::A>, 84 : domain::Tags::ObjectCenter<domain::ObjectLabel::B>>; 85 : 86 0 : bool operator()( 87 : const double time, const ::Domain<3>& domain, 88 : const std::unordered_map< 89 : std::string, 90 : std::unique_ptr<domain::FunctionsOfTime::FunctionOfTime>>& 91 : functions_of_time, 92 : const tnsr::I<double, 3, Frame::Grid>& grid_object_center_a, 93 : const tnsr::I<double, 3, Frame::Grid>& grid_object_center_b) const; 94 : 95 : // NOLINTNEXTLINE(google-runtime-references) 96 0 : void pup(PUP::er& p) override; 97 : 98 : private: 99 0 : double separation_{}; 100 : }; 101 : } // namespace Triggers