Line data Source code
1 0 : // Distributed under the MIT License.
2 : // See LICENSE.txt for details.
3 :
4 : #pragma once
5 :
6 : #include <cstddef>
7 : #include <iomanip>
8 : #include <map>
9 : #include <sstream>
10 : #include <string>
11 : #include <unordered_map>
12 :
13 : #include "DataStructures/DataBox/Prefixes.hpp"
14 : #include "DataStructures/Variables.hpp"
15 : #include "Domain/Structure/ElementId.hpp"
16 : #include "Evolution/Systems/CurvedScalarWave/Tags.hpp"
17 : #include "NumericalAlgorithms/LinearOperators/PartialDerivatives.hpp"
18 : #include "Parallel/InboxInserters.hpp"
19 : #include "Time/TimeStepId.hpp"
20 : #include "Utilities/TMPL.hpp"
21 :
22 : /// \cond
23 : namespace Frame {
24 : struct Grid;
25 : } // namespace Frame
26 : /// \endcond
27 :
28 1 : namespace CurvedScalarWave::Worldtube::Tags {
29 : /*!
30 : * \brief Inbox of the worldtube singleton chare which receives quantities
31 : * projected onto spherical harmonics.
32 : *
33 : * \details Each element abutting the worldtube projects both $\Psi$ and the
34 : * time derivative of $\partial_t Psi$ onto spherical harmonics by integrating
35 : * it over the worldtube surface/boundary it is touching. These coefficients are
36 : * sent to this inbox.
37 : */
38 : template <size_t Dim>
39 1 : struct SphericalHarmonicsInbox
40 : : Parallel::InboxInserters::Map<SphericalHarmonicsInbox<Dim>> {
41 0 : using temporal_id = TimeStepId;
42 0 : using tags_list = tmpl::list<CurvedScalarWave::Tags::Psi,
43 : ::Tags::dt<CurvedScalarWave::Tags::Psi>>;
44 0 : using type =
45 : std::map<temporal_id,
46 : std::unordered_map<ElementId<Dim>, Variables<tags_list>>>;
47 :
48 0 : static std::string output_inbox(const type& inbox,
49 : const size_t padding_size) {
50 : std::stringstream ss{};
51 : const std::string pad(padding_size, ' ');
52 :
53 : ss << std::scientific << std::setprecision(16);
54 : ss << pad << "SphericalHarmonicsInbox:\n";
55 : for (const auto& [current_time_step_id, element_id_and_vars] : inbox) {
56 : ss << pad << " Time: " << current_time_step_id << "\n";
57 : // We don't really care about the variables, just the elements
58 : for (const auto& [element_id, variables] : element_id_and_vars) {
59 : (void)variables;
60 : ss << pad << " ElementId: " << element_id << "\n";
61 : }
62 : }
63 :
64 : return ss.str();
65 : }
66 : };
67 :
68 : /*!
69 : * \brief Inbox of the element chares that contains the coefficients of a Taylor
70 : * Series of the regular field $\Psi^R$ as well as its time derivative. The
71 : * elements may evaluate the coefficients at their inertial coordinates.
72 : */
73 : template <size_t Dim>
74 1 : struct RegularFieldInbox
75 : : Parallel::InboxInserters::Value<RegularFieldInbox<Dim>> {
76 0 : using tags_to_send = tmpl::list<CurvedScalarWave::Tags::Psi,
77 : ::Tags::dt<CurvedScalarWave::Tags::Psi>>;
78 0 : using temporal_id = TimeStepId;
79 0 : using type = std::map<temporal_id, Variables<tags_to_send>>;
80 :
81 0 : static std::string output_inbox(const type& inbox,
82 : const size_t padding_size) {
83 : std::stringstream ss{};
84 : const std::string pad(padding_size, ' ');
85 :
86 : ss << std::scientific << std::setprecision(16);
87 : ss << pad << "RegularFieldInbox:\n";
88 : // We don't really care about the variables, just the times
89 : for (const auto& [current_time_step_id, variables] : inbox) {
90 : (void)variables;
91 : ss << pad << " Time: " << current_time_step_id << "\n";
92 : }
93 :
94 : return ss.str();
95 : }
96 : };
97 :
98 : /*!
99 : * \brief Inbox of the element chares that contains the current iteration of the
100 : * acceleration of the particle.
101 : */
102 : template <size_t Dim>
103 1 : struct SelfForceInbox : Parallel::InboxInserters::Value<SelfForceInbox<Dim>> {
104 0 : using temporal_id = TimeStepId;
105 0 : using type = std::map<temporal_id, Scalar<DataVector>>;
106 0 : static std::string output_inbox(const type& inbox,
107 : const size_t padding_size) {
108 : std::stringstream ss{};
109 : const std::string pad(padding_size, ' ');
110 : ss << std::scientific << std::setprecision(16);
111 : ss << pad << "SelfForceInbox:\n";
112 : // We don't really care about the variables, just the times
113 : for (const auto& [current_time_step_id, self_force_data] : inbox) {
114 : (void)self_force_data;
115 : ss << pad << " Time: " << current_time_step_id << "\n";
116 : }
117 : return ss.str();
118 : }
119 : };
120 :
121 : } // namespace CurvedScalarWave::Worldtube::Tags
|