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