SpECTRE Documentation Coverage Report
Current view: top level - PointwiseFunctions/Xcts - SpacetimeQuantities.hpp Hit Total Coverage
Commit: 5f37f3d7c5afe86be8ec8102ab4a768be82d2177 Lines: 3 45 6.7 %
Date: 2024-04-26 23:32:03
Legend: Lines: hit not hit

          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             : 
       8             : #include "DataStructures/CachedTempBuffer.hpp"
       9             : #include "DataStructures/DataBox/Prefixes.hpp"
      10             : #include "DataStructures/DataBox/Tag.hpp"
      11             : #include "DataStructures/DataVector.hpp"
      12             : #include "DataStructures/Tensor/Tensor.hpp"
      13             : #include "DataStructures/VariablesTag.hpp"
      14             : #include "Domain/Tags.hpp"
      15             : #include "Elliptic/Systems/Xcts/Tags.hpp"
      16             : #include "NumericalAlgorithms/LinearOperators/Divergence.hpp"
      17             : #include "NumericalAlgorithms/LinearOperators/PartialDerivatives.hpp"
      18             : #include "NumericalAlgorithms/Spectral/Mesh.hpp"
      19             : #include "PointwiseFunctions/GeneralRelativity/Tags.hpp"
      20             : #include "Utilities/Gsl.hpp"
      21             : #include "Utilities/TMPL.hpp"
      22             : 
      23             : namespace Xcts {
      24             : 
      25             : namespace detail {
      26             : template <typename DataType>
      27             : struct ConformalLaplacianOfConformalFactor : db::SimpleTag {
      28             :   using type = Scalar<DataType>;
      29             : };
      30             : template <typename DataType>
      31             : struct LongitudinalShiftMinusDtConformalMetric : db::SimpleTag {
      32             :   using type = tnsr::II<DataType, 3>;
      33             : };
      34             : }  // namespace detail
      35             : 
      36             : /// General-relativistic 3+1 quantities computed from XCTS variables.
      37           1 : using SpacetimeQuantities = CachedTempBuffer<
      38             :     Tags::ConformalFactor<DataVector>,
      39             :     Tags::LapseTimesConformalFactor<DataVector>,
      40             :     // Derivatives of XCTS variables
      41             :     ::Tags::deriv<Tags::ConformalFactor<DataVector>, tmpl::size_t<3>,
      42             :                   Frame::Inertial>,
      43             :     detail::ConformalLaplacianOfConformalFactor<DataVector>,
      44             :     ::Tags::deriv<Tags::LapseTimesConformalFactor<DataVector>, tmpl::size_t<3>,
      45             :                   Frame::Inertial>,
      46             :     ::Tags::deriv<Tags::ShiftExcess<DataVector, 3, Frame::Inertial>,
      47             :                   tmpl::size_t<3>, Frame::Inertial>,
      48             :     Xcts::Tags::ShiftStrain<DataVector, 3, Frame::Inertial>,
      49             :     Xcts::Tags::LongitudinalShiftExcess<DataVector, 3, Frame::Inertial>,
      50             :     ::Tags::div<Tags::LongitudinalShiftExcess<DataVector, 3, Frame::Inertial>>,
      51             :     detail::LongitudinalShiftMinusDtConformalMetric<DataVector>,
      52             :     // ADM quantities
      53             :     gr::Tags::SpatialMetric<DataVector, 3>,
      54             :     gr::Tags::InverseSpatialMetric<DataVector, 3>, gr::Tags::Lapse<DataVector>,
      55             :     gr::Tags::Shift<DataVector, 3>, gr::Tags::ExtrinsicCurvature<DataVector, 3>,
      56             :     gr::Tags::SpatialChristoffelSecondKind<DataVector, 3>,
      57             :     // Constraints
      58             :     gr::Tags::HamiltonianConstraint<DataVector>,
      59             :     gr::Tags::MomentumConstraint<DataVector, 3>>;
      60             : 
      61             : /// `CachedTempBuffer` computer class for 3+1 quantities from XCTS variables.
      62             : /// See `Xcts::SpacetimeQuantities`.
      63           1 : struct SpacetimeQuantitiesComputer {
      64           0 :   using Cache = SpacetimeQuantities;
      65             : 
      66           0 :   void operator()(gsl::not_null<Scalar<DataVector>*> conformal_factor,
      67             :                   gsl::not_null<Cache*> cache,
      68             :                   Tags::ConformalFactor<DataVector> /*meta*/) const;
      69           0 :   void operator()(
      70             :       gsl::not_null<Scalar<DataVector>*> lapse_times_conformal_factor,
      71             :       gsl::not_null<Cache*> cache,
      72             :       Tags::LapseTimesConformalFactor<DataVector> /*meta*/) const;
      73           0 :   void operator()(gsl::not_null<tnsr::ii<DataVector, 3>*> spatial_metric,
      74             :                   gsl::not_null<Cache*> cache,
      75             :                   gr::Tags::SpatialMetric<DataVector, 3> /*meta*/) const;
      76           0 :   void operator()(gsl::not_null<tnsr::II<DataVector, 3>*> inv_spatial_metric,
      77             :                   gsl::not_null<Cache*> cache,
      78             :                   gr::Tags::InverseSpatialMetric<DataVector, 3> /*meta*/) const;
      79           0 :   void operator()(
      80             :       gsl::not_null<tnsr::i<DataVector, 3>*> deriv_conformal_factor,
      81             :       gsl::not_null<Cache*> cache,
      82             :       ::Tags::deriv<Tags::ConformalFactor<DataVector>, tmpl::size_t<3>,
      83             :                     Frame::Inertial> /*meta*/) const;
      84           0 :   void operator()(
      85             :       gsl::not_null<tnsr::Ijj<DataVector, 3>*> spatial_christoffel_second_kind,
      86             :       gsl::not_null<Cache*> cache,
      87             :       gr::Tags::SpatialChristoffelSecondKind<DataVector, 3> /*meta*/) const;
      88           0 :   void operator()(
      89             :       gsl::not_null<Scalar<DataVector>*>
      90             :           conformal_laplacian_of_conformal_factor,
      91             :       gsl::not_null<Cache*> cache,
      92             :       detail::ConformalLaplacianOfConformalFactor<DataVector> /*meta*/) const;
      93           0 :   void operator()(
      94             :       gsl::not_null<tnsr::i<DataVector, 3>*> deriv_lapse_times_conformal_factor,
      95             :       gsl::not_null<Cache*> cache,
      96             :       ::Tags::deriv<Tags::LapseTimesConformalFactor<DataVector>,
      97             :                     tmpl::size_t<3>, Frame::Inertial> /*meta*/) const;
      98           0 :   void operator()(gsl::not_null<Scalar<DataVector>*> lapse,
      99             :                   gsl::not_null<Cache*> cache,
     100             :                   gr::Tags::Lapse<DataVector> /*meta*/) const;
     101           0 :   void operator()(gsl::not_null<tnsr::I<DataVector, 3>*> shift,
     102             :                   gsl::not_null<Cache*> cache,
     103             :                   gr::Tags::Shift<DataVector, 3> /*meta*/) const;
     104           0 :   void operator()(
     105             :       gsl::not_null<tnsr::iJ<DataVector, 3>*> deriv_shift_excess,
     106             :       gsl::not_null<Cache*> cache,
     107             :       ::Tags::deriv<Tags::ShiftExcess<DataVector, 3, Frame::Inertial>,
     108             :                     tmpl::size_t<3>, Frame::Inertial> /*meta*/) const;
     109           0 :   void operator()(
     110             :       gsl::not_null<tnsr::ii<DataVector, 3>*> shift_strain,
     111             :       gsl::not_null<Cache*> cache,
     112             :       Tags::ShiftStrain<DataVector, 3, Frame::Inertial> /*meta*/) const;
     113           0 :   void operator()(
     114             :       gsl::not_null<tnsr::II<DataVector, 3>*> longitudinal_shift_excess,
     115             :       gsl::not_null<Cache*> cache,
     116             :       Tags::LongitudinalShiftExcess<DataVector, 3, Frame::Inertial> /*meta*/)
     117             :       const;
     118           0 :   void operator()(
     119             :       gsl::not_null<tnsr::I<DataVector, 3>*> div_longitudinal_shift_excess,
     120             :       gsl::not_null<Cache*> cache,
     121             :       ::Tags::div<Tags::LongitudinalShiftExcess<
     122             :           DataVector, 3, Frame::Inertial>> /*meta*/) const;
     123           0 :   void operator()(
     124             :       gsl::not_null<tnsr::II<DataVector, 3>*>
     125             :           longitudinal_shift_minus_dt_conformal_metric,
     126             :       gsl::not_null<Cache*> cache,
     127             :       detail::LongitudinalShiftMinusDtConformalMetric<DataVector> /*meta*/)
     128             :       const;
     129           0 :   void operator()(gsl::not_null<tnsr::ii<DataVector, 3>*> extrinsic_curvature,
     130             :                   gsl::not_null<Cache*> cache,
     131             :                   gr::Tags::ExtrinsicCurvature<DataVector, 3> /*meta*/) const;
     132           0 :   void operator()(gsl::not_null<Scalar<DataVector>*> hamiltonian_constraint,
     133             :                   gsl::not_null<Cache*> cache,
     134             :                   gr::Tags::HamiltonianConstraint<DataVector> /*meta*/) const;
     135           0 :   void operator()(gsl::not_null<tnsr::I<DataVector, 3>*> momentum_constraint,
     136             :                   gsl::not_null<Cache*> cache,
     137             :                   gr::Tags::MomentumConstraint<DataVector, 3> /*meta*/) const;
     138             : 
     139             :   // XCTS variables
     140           0 :   const Scalar<DataVector>& conformal_factor_minus_one;
     141           0 :   const Scalar<DataVector>& lapse_times_conformal_factor_minus_one;
     142           0 :   const tnsr::I<DataVector, 3>& shift_excess;
     143             :   // Background
     144           0 :   const tnsr::ii<DataVector, 3>& conformal_metric;
     145           0 :   const tnsr::II<DataVector, 3>& inv_conformal_metric;
     146           0 :   const tnsr::ijj<DataVector, 3>& deriv_conformal_metric;
     147           0 :   const tnsr::ijj<DataVector, 3>& conformal_christoffel_first_kind;
     148           0 :   const tnsr::Ijj<DataVector, 3>& conformal_christoffel_second_kind;
     149           0 :   const tnsr::i<DataVector, 3>& conformal_christoffel_contracted;
     150           0 :   const Scalar<DataVector>& conformal_ricci_scalar;
     151           0 :   const Scalar<DataVector>& trace_extrinsic_curvature;
     152           0 :   const tnsr::i<DataVector, 3>& deriv_trace_extrinsic_curvature;
     153           0 :   const tnsr::I<DataVector, 3>& shift_background;
     154             :   const tnsr::II<DataVector, 3>&
     155           0 :       longitudinal_shift_background_minus_dt_conformal_metric;
     156             :   const tnsr::I<DataVector, 3>&
     157           0 :       div_longitudinal_shift_background_minus_dt_conformal_metric;
     158           0 :   const Scalar<DataVector>& energy_density;
     159           0 :   const tnsr::I<DataVector, 3>& momentum_density;
     160             :   // Grid
     161           0 :   const Mesh<3>& mesh;
     162             :   const InverseJacobian<DataVector, 3, Frame::ElementLogical, Frame::Inertial>&
     163           0 :       inv_jacobian;
     164             : };
     165             : 
     166             : namespace Tags {
     167             : /// Compute tag for the 3+1 quantities `Tags` from XCTS variables. The `Tags`
     168             : /// can be any subset of the tags supported by `Xcts::SpacetimeQuantities`.
     169             : template <typename Tags>
     170           1 : struct SpacetimeQuantitiesCompute : ::Tags::Variables<Tags>, db::ComputeTag {
     171           0 :   using base = ::Tags::Variables<Tags>;
     172           0 :   using argument_tags = tmpl::list<
     173             :       domain::Tags::Mesh<3>, ConformalFactorMinusOne<DataVector>,
     174             :       LapseTimesConformalFactorMinusOne<DataVector>,
     175             :       ShiftExcess<DataVector, 3, Frame::Inertial>,
     176             :       ConformalMetric<DataVector, 3, Frame::Inertial>,
     177             :       InverseConformalMetric<DataVector, 3, Frame::Inertial>,
     178             :       ::Tags::deriv<ConformalMetric<DataVector, 3, Frame::Inertial>,
     179             :                     tmpl::size_t<3>, Frame::Inertial>,
     180             :       ConformalChristoffelFirstKind<DataVector, 3, Frame::Inertial>,
     181             :       ConformalChristoffelSecondKind<DataVector, 3, Frame::Inertial>,
     182             :       ConformalChristoffelContracted<DataVector, 3, Frame::Inertial>,
     183             :       ConformalRicciScalar<DataVector>,
     184             :       gr::Tags::TraceExtrinsicCurvature<DataVector>,
     185             :       ::Tags::deriv<gr::Tags::TraceExtrinsicCurvature<DataVector>,
     186             :                     tmpl::size_t<3>, Frame::Inertial>,
     187             :       ShiftBackground<DataVector, 3, Frame::Inertial>,
     188             :       LongitudinalShiftBackgroundMinusDtConformalMetric<DataVector, 3,
     189             :                                                         Frame::Inertial>,
     190             :       ::Tags::div<LongitudinalShiftBackgroundMinusDtConformalMetric<
     191             :           DataVector, 3, Frame::Inertial>>,
     192             :       gr::Tags::Conformal<gr::Tags::EnergyDensity<DataVector>, 0>,
     193             :       gr::Tags::Conformal<gr::Tags::MomentumDensity<DataVector, 3>, 0>,
     194             :       domain::Tags::Mesh<3>,
     195             :       domain::Tags::InverseJacobian<3, Frame::ElementLogical, Frame::Inertial>>;
     196             :   template <typename... Args>
     197           0 :   static void function(const gsl::not_null<typename base::type*> result,
     198             :                        const Mesh<3>& mesh, const Args&... args) {
     199             :     const size_t num_points = mesh.number_of_grid_points();
     200             :     if (result->number_of_grid_points() != num_points) {
     201             :       result->initialize(num_points);
     202             :     }
     203             :     SpacetimeQuantities spacetime_quantities{num_points};
     204             :     const SpacetimeQuantitiesComputer computer{args...};
     205             :     tmpl::for_each<Tags>(
     206             :         [&spacetime_quantities, &computer, &result](const auto tag_v) {
     207             :           using tag = tmpl::type_from<std::decay_t<decltype(tag_v)>>;
     208             :           get<tag>(*result) = spacetime_quantities.get_var(computer, tag{});
     209             :         });
     210             :   }
     211             : };
     212             : }  // namespace Tags
     213             : 
     214             : }  // namespace Xcts

Generated by: LCOV version 1.14