/
Tags.hpp
283 lines (255 loc) · 11.4 KB
/
Tags.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
// Distributed under the MIT License.
// See LICENSE.txt for details.
#pragma once
#include <string>
#include "ApparentHorizons/Strahlkorper.hpp"
#include "ApparentHorizons/StrahlkorperGr.hpp"
#include "ApparentHorizons/TagsDeclarations.hpp" // IWYU pragma: keep
#include "ApparentHorizons/TagsTypeAliases.hpp"
#include "DataStructures/DataBox/DataBoxTag.hpp"
#include "DataStructures/DataVector.hpp"
#include "PointwiseFunctions/GeneralRelativity/TagsDeclarations.hpp" // IWYU pragma: keep
#include "Utilities/ForceInline.hpp"
#include "Utilities/TMPL.hpp"
// IWYU pragma: no_forward_declare gr::Tags::SpatialMetric
/// \cond
class DataVector;
class FastFlow;
/// \endcond
namespace ah {
namespace Tags {
struct FastFlow : db::SimpleTag {
static std::string name() noexcept { return "FastFlow"; }
using type = ::FastFlow;
};
} // namespace Tags
} // namespace ah
/// \ingroup SurfacesGroup
/// Holds tags and ComputeItems associated with a `::Strahlkorper`.
namespace StrahlkorperTags {
/// Tag referring to a `::Strahlkorper`
template <typename Frame>
struct Strahlkorper : db::SimpleTag {
static std::string name() noexcept { return "Strahlkorper"; }
using type = ::Strahlkorper<Frame>;
};
/// \f$(\theta,\phi)\f$ on the grid.
/// Doesn't depend on the shape of the surface.
template <typename Frame>
struct ThetaPhi : db::ComputeTag {
static std::string name() noexcept { return "ThetaPhi"; }
static aliases::ThetaPhi<Frame> function(
const ::Strahlkorper<Frame>& strahlkorper) noexcept;
using argument_tags = tmpl::list<Strahlkorper<Frame>>;
};
/// `Rhat(i)` is \f$\hat{r}^i = x_i/\sqrt{x^2+y^2+z^2}\f$ on the grid.
/// Doesn't depend on the shape of the surface.
template <typename Frame>
struct Rhat : db::ComputeTag {
static std::string name() noexcept { return "Rhat"; }
static aliases::OneForm<Frame> function(
const db::item_type<ThetaPhi<Frame>>& theta_phi) noexcept;
using argument_tags = tmpl::list<ThetaPhi<Frame>>;
};
/// `Jacobian(i,0)` is \f$\frac{1}{r}\partial x^i/\partial\theta\f$,
/// and `Jacobian(i,1)`
/// is \f$\frac{1}{r\sin\theta}\partial x^i/\partial\phi\f$.
/// Here \f$r\f$ means \f$\sqrt{x^2+y^2+z^2}\f$.
/// `Jacobian` doesn't depend on the shape of the surface.
template <typename Frame>
struct Jacobian : db::ComputeTag {
static std::string name() noexcept { return "Jacobian"; }
static aliases::Jacobian<Frame> function(
const db::item_type<ThetaPhi<Frame>>& theta_phi) noexcept;
using argument_tags = tmpl::list<ThetaPhi<Frame>>;
};
/// `InvJacobian(0,i)` is \f$r\partial\theta/\partial x^i\f$,
/// and `InvJacobian(1,i)` is \f$r\sin\theta\partial\phi/\partial x^i\f$.
/// Here \f$r\f$ means \f$\sqrt{x^2+y^2+z^2}\f$.
/// `InvJacobian` doesn't depend on the shape of the surface.
template <typename Frame>
struct InvJacobian : db::ComputeTag {
static std::string name() noexcept { return "InvJacobian"; }
static aliases::InvJacobian<Frame> function(
const db::item_type<ThetaPhi<Frame>>& theta_phi) noexcept;
using argument_tags = tmpl::list<ThetaPhi<Frame>>;
};
/// `InvHessian(k,i,j)` is \f$\partial (J^{-1}){}^k_j/\partial x^i\f$,
/// where \f$(J^{-1}){}^k_j\f$ is the inverse Jacobian.
/// `InvHessian` is not symmetric because the Jacobians are Pfaffian.
/// `InvHessian` doesn't depend on the shape of the surface.
template <typename Frame>
struct InvHessian : db::ComputeTag {
static std::string name() noexcept { return "InvHessian"; }
static aliases::InvHessian<Frame> function(
const db::item_type<ThetaPhi<Frame>>& theta_phi) noexcept;
using argument_tags = tmpl::list<ThetaPhi<Frame>>;
};
/// (Euclidean) distance \f$r_{\rm surf}(\theta,\phi)\f$ from the center to each
/// point of the surface.
template <typename Frame>
struct Radius : db::ComputeTag {
static std::string name() noexcept { return "Radius"; }
SPECTRE_ALWAYS_INLINE static auto function(
const ::Strahlkorper<Frame>& strahlkorper) noexcept {
return strahlkorper.ylm_spherepack().spec_to_phys(
strahlkorper.coefficients());
}
using argument_tags = tmpl::list<Strahlkorper<Frame>>;
};
/// `CartesianCoords(i)` is \f$x_{\rm surf}^i\f$,
/// the vector of \f$(x,y,z)\f$ coordinates of each point
/// on the surface.
template <typename Frame>
struct CartesianCoords : db::ComputeTag {
static std::string name() noexcept { return "CartesianCoords"; }
static aliases::Vector<Frame> function(
const ::Strahlkorper<Frame>& strahlkorper, const DataVector& radius,
const db::item_type<Rhat<Frame>>& r_hat) noexcept;
using argument_tags =
tmpl::list<Strahlkorper<Frame>, Radius<Frame>, Rhat<Frame>>;
};
/// `DxRadius(i)` is \f$\partial r_{\rm surf}/\partial x^i\f$. Here
/// \f$r_{\rm surf}=r_{\rm surf}(\theta,\phi)\f$ is the function
/// describing the surface, which is considered a function of
/// Cartesian coordinates
/// \f$r_{\rm surf}=r_{\rm surf}(\theta(x,y,z),\phi(x,y,z))\f$
/// for this operation.
template <typename Frame>
struct DxRadius : db::ComputeTag {
static std::string name() noexcept { return "DxRadius"; }
static aliases::OneForm<Frame> function(
const ::Strahlkorper<Frame>& strahlkorper, const DataVector& radius,
const db::item_type<InvJacobian<Frame>>& inv_jac) noexcept;
using argument_tags =
tmpl::list<Strahlkorper<Frame>, Radius<Frame>, InvJacobian<Frame>>;
};
/// `D2xRadius(i,j)` is
/// \f$\partial^2 r_{\rm surf}/\partial x^i\partial x^j\f$. Here
/// \f$r_{\rm surf}=r_{\rm surf}(\theta,\phi)\f$ is the function
/// describing the surface, which is considered a function of
/// Cartesian coordinates
/// \f$r_{\rm surf}=r_{\rm surf}(\theta(x,y,z),\phi(x,y,z))\f$
/// for this operation.
template <typename Frame>
struct D2xRadius : db::ComputeTag {
static std::string name() noexcept { return "D2xRadius"; }
static aliases::SecondDeriv<Frame> function(
const ::Strahlkorper<Frame>& strahlkorper, const DataVector& radius,
const db::item_type<InvJacobian<Frame>>& inv_jac,
const db::item_type<InvHessian<Frame>>& inv_hess) noexcept;
using argument_tags = tmpl::list<Strahlkorper<Frame>, Radius<Frame>,
InvJacobian<Frame>, InvHessian<Frame>>;
};
/// \f$\nabla^2 r_{\rm surf}\f$, the flat Laplacian of the surface.
/// This is \f$\eta^{ij}\partial^2 r_{\rm surf}/\partial x^i\partial x^j\f$,
/// where \f$r_{\rm surf}=r_{\rm surf}(\theta(x,y,z),\phi(x,y,z))\f$.
template <typename Frame>
struct LaplacianRadius : db::ComputeTag {
static std::string name() noexcept { return "LaplacianRadius"; }
static DataVector function(
const ::Strahlkorper<Frame>& strahlkorper, const DataVector& radius,
const db::item_type<ThetaPhi<Frame>>& theta_phi) noexcept;
using argument_tags =
tmpl::list<Strahlkorper<Frame>, Radius<Frame>, ThetaPhi<Frame>>;
};
/// `NormalOneForm(i)` is \f$s_i\f$, the (unnormalized) normal one-form
/// to the surface, expressed in Cartesian components.
/// This is computed by \f$x_i/r-\partial r_{\rm surf}/\partial x^i\f$,
/// where \f$x_i/r\f$ is `Rhat` and
/// \f$\partial r_{\rm surf}/\partial x^i\f$ is `DxRadius`.
/// See Eq. (8) of \cite Baumgarte1996hh.
/// Note on the word "normal": \f$s_i\f$ points in the correct direction
/// (it is "normal" to the surface), but it does not have unit length
/// (it is not "normalized"; normalization requires a metric).
template <typename Frame>
struct NormalOneForm : db::ComputeTag {
static std::string name() noexcept { return "NormalOneForm"; }
static aliases::OneForm<Frame> function(
const db::item_type<DxRadius<Frame>>& dx_radius,
const db::item_type<Rhat<Frame>>& r_hat) noexcept;
using argument_tags = tmpl::list<DxRadius<Frame>, Rhat<Frame>>;
};
/// `Tangents(i,j)` is \f$\partial x_{\rm surf}^i/\partial q^j\f$,
/// where \f$x_{\rm surf}^i\f$ are the Cartesian coordinates of the
/// surface (i.e. `CartesianCoords`) and are considered functions of
/// \f$(\theta,\phi)\f$.
///
/// \f$\partial/\partial q^0\f$ means
/// \f$\partial/\partial\theta\f$; and \f$\partial/\partial q^1\f$
/// means \f$\csc\theta\,\,\partial/\partial\phi\f$. Note that the
/// vectors `Tangents(i,0)` and `Tangents(i,1)` are orthogonal to the
/// `NormalOneForm` \f$s_i\f$, i.e.
/// \f$s_i \partial x_{\rm surf}^i/\partial q^j = 0\f$; this statement
/// is independent of a metric. Also, `Tangents(i,0)` and
/// `Tangents(i,1)` are not necessarily orthogonal to each other,
/// since orthogonality between 2 vectors (as opposed to a vector and
/// a one-form) is metric-dependent.
template <typename Frame>
struct Tangents : db::ComputeTag {
static std::string name() noexcept { return "Tangents"; }
static aliases::Jacobian<Frame> function(
const ::Strahlkorper<Frame>& strahlkorper, const DataVector& radius,
const db::item_type<Rhat<Frame>>& r_hat,
const db::item_type<Jacobian<Frame>>& jac) noexcept;
using argument_tags = tmpl::list<Strahlkorper<Frame>, Radius<Frame>,
Rhat<Frame>, Jacobian<Frame>>;
};
/// Computes the Euclidean area element on a Strahlkorper.
/// Useful for flat space integrals.
template <typename Frame>
struct EuclideanAreaElement : db::ComputeTag {
static std::string name() noexcept { return "EuclideanAreaElement"; }
static constexpr auto function =
::StrahlkorperGr::euclidean_area_element<Frame>;
using argument_tags = tmpl::list<
StrahlkorperTags::Jacobian<Frame>, StrahlkorperTags::NormalOneForm<Frame>,
StrahlkorperTags::Radius<Frame>, StrahlkorperTags::Rhat<Frame>>;
};
/// Computes the flat-space integral of a scalar over a Strahlkorper.
template <typename IntegrandTag, typename Frame>
struct EuclideanSurfaceIntegral : db::ComputeTag {
static std::string name() noexcept {
return "EuclideanSurfaceIntegral" + IntegrandTag::name();
}
static constexpr auto function =
::StrahlkorperGr::surface_integral_of_scalar<Frame>;
using argument_tags = tmpl::list<EuclideanAreaElement<Frame>, IntegrandTag,
StrahlkorperTags::Strahlkorper<Frame>>;
};
template <typename Frame>
using items_tags = tmpl::list<Strahlkorper<Frame>>;
template <typename Frame>
using compute_items_tags =
tmpl::list<ThetaPhi<Frame>, Rhat<Frame>, Jacobian<Frame>,
InvJacobian<Frame>, InvHessian<Frame>, Radius<Frame>,
CartesianCoords<Frame>, DxRadius<Frame>, D2xRadius<Frame>,
LaplacianRadius<Frame>, NormalOneForm<Frame>, Tangents<Frame>>;
} // namespace StrahlkorperTags
namespace StrahlkorperGr {
/// \ingroup SurfacesGroup
/// Holds tags and ComputeItems associated with a `::Strahlkorper` that
/// also need a metric.
namespace Tags {
/// Computes the area element on a Strahlkorper. Useful for integrals.
template <typename Frame>
struct AreaElement : db::ComputeTag {
static std::string name() noexcept { return "AreaElement"; }
static constexpr auto function = area_element<Frame>;
using argument_tags = tmpl::list<
gr::Tags::SpatialMetric<3, Frame>, StrahlkorperTags::Jacobian<Frame>,
StrahlkorperTags::NormalOneForm<Frame>, StrahlkorperTags::Radius<Frame>,
StrahlkorperTags::Rhat<Frame>>;
};
/// Computes the integral of a scalar over a Strahlkorper.
template <typename IntegrandTag, typename Frame>
struct SurfaceIntegral : db::ComputeTag {
static std::string name() noexcept {
return "SurfaceIntegral" + IntegrandTag::name();
}
static constexpr auto function = surface_integral_of_scalar<Frame>;
using argument_tags = tmpl::list<AreaElement<Frame>, IntegrandTag,
StrahlkorperTags::Strahlkorper<Frame>>;
};
} // namespace Tags
} // namespace StrahlkorperGr