DetAndInverseSpatialMetric.hpp
1 // Distributed under the MIT License.
2 // See LICENSE.txt for details.
3 
4 #pragma once
5 
6 #include <cmath>
7 #include <cstddef>
8 #include <cstdint>
9 #include <utility>
10 
12 #include "DataStructures/DataBox/Tag.hpp"
15 #include "DataStructures/VariablesTag.hpp"
17 #include "PointwiseFunctions/GeneralRelativity/Tags.hpp"
18 #include "Utilities/ContainerHelpers.hpp"
19 #include "Utilities/Gsl.hpp"
20 #include "Utilities/TMPL.hpp"
21 #include "Utilities/TaggedTuple.hpp"
22 
23 /// \ingroup GeneralRelativityGroup
24 /// Holds functions related to general relativity.
25 namespace gr {
26 
27 namespace Tags {
28 /*!
29  * \brief Compute item for spatial metric determinant \f$g\f$
30  * and inverse \f$g^{ij}\f$ in terms of the spatial metric \f$g_{ij}\f$.
31  *
32  * \details Can be retrieved using `gr::Tags::DetSpatialMetric` and
33  * `gr::Tags::InverseSpatialMetric`.
34  */
35 template <size_t SpatialDim, typename Frame, typename DataType>
38  tmpl::list<DetSpatialMetric<DataType>,
39  InverseSpatialMetric<SpatialDim, Frame, DataType>>>,
41  using argument_tags = tmpl::list<SpatialMetric<SpatialDim, Frame, DataType>>;
42  using base = ::Tags::Variables<
43  tmpl::list<DetSpatialMetric<DataType>,
45  using return_type = typename base::type;
46  static constexpr auto function = static_cast<void (*)(
48  const Tensor<
49  DataType, tmpl::integral_list<std::int32_t, 1, 1>,
50  tmpl::list<SpatialIndex<SpatialDim, UpLo::Lo, Frame>,
53 };
54 
55 /*!
56  * \brief Compute item to get the square root of the determinant of the spatial
57  * metric \f$\sqrt{g}\f$ via `gr::Tags::DetAndInverseSpatialMetric`.
58  *
59  * \details Can be retrieved using `gr::Tags::SqrtDetSpatialMetric`.
60  */
61 template <size_t SpatialDim, typename Frame, typename DataType>
64  using argument_tags = tmpl::list<DetSpatialMetric<DataType>>;
65 
66  using return_type = Scalar<DataType>;
67 
68  static void function(const gsl::not_null<Scalar<DataType>*> result,
69  const Scalar<DataType>& det_spatial_metric) noexcept {
70  destructive_resize_components(result, get_size(get(det_spatial_metric)));
71  get(*result) = sqrt(get(det_spatial_metric));
72  }
73 
75 };
76 } // namespace Tags
77 } // namespace gr
db::ComputeTag
Marks a DataBoxTag as being a compute item that executes a function.
Definition: Tag.hpp:109
utility
get
constexpr Tag::type & get(Variables< TagList > &v) noexcept
Return Tag::type pointing into the contiguous array.
Definition: Variables.hpp:689
gr::Tags::DetAndInverseSpatialMetricCompute
Compute item for spatial metric determinant and inverse in terms of the spatial metric .
Definition: DetAndInverseSpatialMetric.hpp:36
DeterminantAndInverse.hpp
Tags::Variables
Definition: VariablesTag.hpp:21
cmath
get_size
decltype(auto) get_size(const T &t, SizeFunction size=GetContainerSize{}) noexcept
Retrieve the size of t if t.size() is a valid expression, otherwise if T is fundamental or a std::com...
Definition: ContainerHelpers.hpp:145
determinant_and_inverse
void determinant_and_inverse(const gsl::not_null< Scalar< T > * > det, const gsl::not_null< Tensor< T, Symm, tmpl::list< change_index_up_lo< Index1 >, change_index_up_lo< Index0 >>> * > inv, const Tensor< T, Symm, tmpl::list< Index0, Index1 >> &tensor) noexcept
Computes the determinant and inverse of a rank-2 Tensor.
Definition: DeterminantAndInverse.hpp:371
cstddef
cstdint
gr::Tags::SqrtDetSpatialMetricCompute
Compute item to get the square root of the determinant of the spatial metric via gr::Tags::DetAndInv...
Definition: DetAndInverseSpatialMetric.hpp:62
Scalar
Tensor< T, Symmetry<>, index_list<> > Scalar
Definition: TypeAliases.hpp:21
Gsl.hpp
gr
Definition: GaugeWave.hpp:27
Tensor.hpp
SpatialIndex
Tensor_detail::TensorIndexType< SpatialDim, Ul, Fr, IndexType::Spatial > SpatialIndex
Definition: IndexType.hpp:187
PartialDerivatives.hpp
Prefixes.hpp
TMPL.hpp
gr::Tags::InverseSpatialMetric
Inverse of the spatial metric.
Definition: Tags.hpp:33
gsl::not_null
Require a pointer to not be a nullptr
Definition: Gsl.hpp:183
destructive_resize_components
void destructive_resize_components(const gsl::not_null< Container * > container, const size_t new_size, DestructiveResizeFunction destructive_resize=ContainerDestructiveResize{}) noexcept
Checks the size of each component of the container, and resizes if necessary.
Definition: ContainerHelpers.hpp:177
gr::Tags::SqrtDetSpatialMetric
Definition: Tags.hpp:44