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 <pup.h>
8 : #include <vector>
9 :
10 : #include "DataStructures/Tensor/Tensor.hpp"
11 : #include "Evolution/Systems/CurvedScalarWave/Worldtube/Tags.hpp"
12 : #include "ParallelAlgorithms/EventsAndTriggers/Trigger.hpp"
13 : #include "Time/Tags/TimeStep.hpp"
14 : #include "Time/Time.hpp"
15 : #include "Utilities/Serialization/CharmPupable.hpp"
16 :
17 : namespace Triggers {
18 : /*!
19 : * \brief This trigger returns true when the scalar charge is about to cross one
20 : * of the specified areal radii.
21 : *
22 : * \details As the domain is adjusted to track the position of the scalar
23 : * charge, the time step needs to be dynamically adjusted accordingly. This
24 : * trigger can be used to set the time step according to the radial position of
25 : * the scalar charge which gives a good approximation of when the time step
26 : * should be adjusted.
27 : * The trigger only approximates whether the particle might cross during the
28 : * next time step and may therefore fire twice.
29 : */
30 1 : class OrbitRadius : public Trigger {
31 : public:
32 : /// \cond
33 : OrbitRadius() = default;
34 : explicit OrbitRadius(CkMigrateMessage* /*unused*/) {}
35 : using PUP::able::register_constructor;
36 : WRAPPED_PUPable_decl_template(OrbitRadius); // NOLINT
37 : /// \endcond
38 :
39 0 : struct Radii {
40 0 : using type = std::vector<double>;
41 0 : static constexpr Options::String help =
42 : "The orbital radii which should trigger when crossed by the "
43 : "scalar charge.";
44 : };
45 :
46 0 : static constexpr Options::String help =
47 : "Trigger that fires when the scalar charge crosses specified radii.";
48 0 : using options = tmpl::list<Radii>;
49 :
50 0 : explicit OrbitRadius(const std::vector<double>& radii);
51 :
52 0 : using argument_tags =
53 : tmpl::list<CurvedScalarWave::Worldtube::Tags::ParticlePositionVelocity<3>,
54 : Tags::TimeStep>;
55 :
56 0 : bool operator()(
57 : const std::array<tnsr::I<double, 3>, 2>& position_and_velocity,
58 : const TimeDelta& time_step) const;
59 :
60 : // NOLINTNEXTLINE(google-runtime-references)
61 0 : void pup(PUP::er& p) override;
62 :
63 : private:
64 0 : std::vector<double> radii_{};
65 : };
66 : } // namespace Triggers
|