SpECTRE Documentation Coverage Report
Current view: top level - PointwiseFunctions/Hydro - MassWeightedFluidItems.hpp Hit Total Coverage
Commit: 1f2210958b4f38fdc0400907ee7c6d5af5111418 Lines: 21 53 39.6 %
Date: 2025-12-05 05:03:31
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/DataBox/Tag.hpp"
       9             : #include "DataStructures/Tensor/TypeAliases.hpp"
      10             : #include "Evolution/Systems/GrMhd/ValenciaDivClean/TagsDeclarations.hpp"
      11             : #include "PointwiseFunctions/GeneralRelativity/TagsDeclarations.hpp"
      12             : #include "PointwiseFunctions/Hydro/TagsDeclarations.hpp"
      13             : #include "Utilities/TMPL.hpp"
      14             : 
      15             : /// \cond
      16             : namespace gsl {
      17             : template <typename>
      18             : struct not_null;
      19             : }  // namespace gsl
      20             : /// \endcond
      21             : 
      22             : namespace hydro {
      23             : 
      24           0 : enum class HalfPlaneIntegralMask { None, PositiveXOnly, NegativeXOnly };
      25             : 
      26           0 : std::ostream& operator<<(std::ostream& os, HalfPlaneIntegralMask mask);
      27             : 
      28           0 : std::string name(HalfPlaneIntegralMask mask);
      29             : 
      30             : /// Tag containing TildeD * SpecificInternalEnergy
      31             : /// Useful as a diagnostics tool, as input to volume
      32             : /// integral.
      33             : namespace Tags {
      34             : template <typename DataType>
      35           0 : struct MassWeightedInternalEnergy : db::SimpleTag {
      36           0 :   using type = Scalar<DataType>;
      37             : };
      38             : 
      39             : /// Tag containing TildeD * (LorentzFactor - 1.0)
      40             : /// Useful as a diagnostics tool, as input to volume
      41             : /// integral.
      42             : template <typename DataType>
      43           1 : struct MassWeightedKineticEnergy : db::SimpleTag {
      44           0 :   using type = Scalar<DataType>;
      45             : };
      46             : 
      47             : /// Contains TildeD restricted to regions marked as
      48             : /// unbound, using the u_t < -1 criterion.
      49             : template <typename DataType>
      50           1 : struct TildeDUnboundUtCriterion : db::SimpleTag {
      51           0 :   using type = Scalar<DataType>;
      52             : };
      53             : 
      54             : /// Contains TildeD restricted to x>0 or x<0. This provides the
      55             : /// normalization factor for integrals over the half plane
      56             : /// weighted by tildeD
      57             : template <typename DataType, HalfPlaneIntegralMask IntegralMask>
      58           1 : struct TildeDInHalfPlane : db::SimpleTag {
      59           0 :   using type = Scalar<DataType>;
      60           0 :   static std::string name() {
      61             :     return "TildeDMask(" + ::hydro::name(IntegralMask) + ")";
      62             :   }
      63             : };
      64             : 
      65             : /// Contains TildeD * (coordinates in frame Fr).
      66             : /// IntegralMask allows us to restrict the data to the x>0 or x<0
      67             : /// plane in grid coordinates (useful for NSNS).
      68             : template <typename DataType, size_t Dim, HalfPlaneIntegralMask IntegralMask,
      69             :           typename Fr = Frame::Inertial>
      70           1 : struct MassWeightedCoords : db::SimpleTag {
      71           0 :   using type = tnsr::I<DataType, Dim, Fr>;
      72           0 :   static std::string name() {
      73             :     return "MassWeightedCoordsMask(" + ::hydro::name(IntegralMask) + ")";
      74             :   }
      75             : };
      76             : }  // namespace Tags
      77             : 
      78             : /// @{
      79             : /// Compute $u_t=$
      80             : template <typename DataType, size_t Dim, typename Frame>
      81           1 : void u_lower_t(gsl::not_null<Scalar<DataType>*> result,
      82             :                const Scalar<DataType>& lorentz_factor,
      83             :                const tnsr::I<DataType, Dim, Frame>& spatial_velocity,
      84             :                const tnsr::ii<DataType, Dim, Frame>& spatial_metric,
      85             :                const Scalar<DataType>& lapse,
      86             :                const tnsr::I<DataType, Dim, Frame>& shift);
      87             : 
      88             : template <typename DataType, size_t Dim, typename Frame>
      89           1 : Scalar<DataType> u_lower_t(
      90             :     const Scalar<DataType>& lorentz_factor,
      91             :     const tnsr::I<DataType, Dim, Frame>& spatial_velocity,
      92             :     const tnsr::ii<DataType, Dim, Frame>& spatial_metric,
      93             :     const Scalar<DataType>& lapse, const tnsr::I<DataType, Dim, Frame>& shift);
      94             : /// @}
      95             : 
      96             : /// @{
      97             : /// Compute tilde_d * specific_internal_energy
      98             : /// Result of the calculation stored in result.
      99             : template <typename DataType>
     100           1 : void mass_weighted_internal_energy(
     101             :     gsl::not_null<Scalar<DataType>*> result, const Scalar<DataType>& tilde_d,
     102             :     const Scalar<DataType>& specific_internal_energy);
     103             : 
     104             : template <typename DataType>
     105           1 : Scalar<DataType> mass_weighted_internal_energy(
     106             :     const Scalar<DataType>& tilde_d,
     107             :     const Scalar<DataType>& specific_internal_energy);
     108             : /// @}
     109             : 
     110             : /// @{
     111             : /// Compute tilde_d * (lorentz_factor - 1.0)
     112             : /// Result of the calculation stored in result.
     113             : template <typename DataType>
     114           1 : void mass_weighted_kinetic_energy(gsl::not_null<Scalar<DataType>*> result,
     115             :                                   const Scalar<DataType>& tilde_d,
     116             :                                   const Scalar<DataType>& lorentz_factor);
     117             : template <typename DataType>
     118           1 : Scalar<DataType> mass_weighted_kinetic_energy(
     119             :     const Scalar<DataType>& tilde_d, const Scalar<DataType>& lorentz_factor);
     120             : /// @}
     121             : 
     122             : /// @{
     123             : /// Returns tilde_d in regions where u_t < -1 and 0 in regions where
     124             : /// u_t > -1 (approximate criteria for unbound matter, theoretically
     125             : /// valid for particles following geodesics of a time-independent metric).
     126             : template <typename DataType, size_t Dim, typename Fr = Frame::Inertial>
     127           1 : void tilde_d_unbound_ut_criterion(
     128             :     gsl::not_null<Scalar<DataType>*> result, const Scalar<DataType>& tilde_d,
     129             :     const Scalar<DataType>& lorentz_factor,
     130             :     const tnsr::I<DataType, Dim, Fr>& spatial_velocity,
     131             :     const tnsr::ii<DataType, Dim, Fr>& spatial_metric,
     132             :     const Scalar<DataType>& lapse, const tnsr::I<DataType, Dim, Fr>& shift);
     133             : 
     134             : template <typename DataType, size_t Dim, typename Fr = Frame::Inertial>
     135           1 : Scalar<DataType> tilde_d_unbound_ut_criterion(
     136             :     const Scalar<DataType>& tilde_d, const Scalar<DataType>& lorentz_factor,
     137             :     const tnsr::I<DataType, Dim, Fr>& spatial_velocity,
     138             :     const tnsr::ii<DataType, Dim, Fr>& spatial_metric,
     139             :     const Scalar<DataType>& lapse, const tnsr::I<DataType, Dim, Fr>& shift);
     140             : /// @}
     141             : 
     142             : /// @{
     143             : /// Returns tilde_d in one half plane and zero in the other
     144             : /// IntegralMask allows us to restrict the data to the x>0 or x<0
     145             : /// plane in grid coordinates (useful for NSNS).
     146             : template <HalfPlaneIntegralMask IntegralMask, typename DataType, size_t Dim>
     147           1 : void tilde_d_in_half_plane(
     148             :     gsl::not_null<Scalar<DataType>*> result, const Scalar<DataType>& tilde_d,
     149             :     const tnsr::I<DataType, Dim, Frame::Grid>& grid_coords);
     150             : 
     151             : template <HalfPlaneIntegralMask IntegralMask, typename DataType, size_t Dim>
     152           1 : Scalar<DataType> tilde_d_in_half_plane(
     153             :     const Scalar<DataType>& tilde_d,
     154             :     const tnsr::I<DataType, Dim, Frame::Grid>& grid_coords);
     155             : /// @}
     156             : 
     157             : /// @{
     158             : /// Returns tilde_d * compute_coords
     159             : /// IntegralMask allows us to restrict the data to the x>0 or x<0
     160             : /// plane in grid coordinates (useful for NSNS).
     161             : template <HalfPlaneIntegralMask IntegralMask, typename DataType, size_t Dim,
     162             :           typename Fr = Frame::Inertial>
     163           1 : void mass_weighted_coords(
     164             :     gsl::not_null<tnsr::I<DataType, Dim, Fr>*> result,
     165             :     const Scalar<DataType>& tilde_d,
     166             :     const tnsr::I<DataType, Dim, Frame::Grid>& grid_coords,
     167             :     const tnsr::I<DataType, Dim, Fr>& compute_coords);
     168             : 
     169             : template <HalfPlaneIntegralMask IntegralMask, typename DataType, size_t Dim,
     170             :           typename Fr = Frame::Inertial>
     171           1 : tnsr::I<DataType, Dim, Fr> mass_weighted_coords(
     172             :     const Scalar<DataType>& tilde_d,
     173             :     const tnsr::I<DataType, Dim, Frame::Grid>& grid_coords,
     174             :     const tnsr::I<DataType, Dim, Fr>& compute_coords);
     175             : /// @}
     176             : 
     177             : namespace Tags {
     178             : /// Compute item for mass-weighted internal energy
     179             : ///
     180             : /// Can be retrieved using `hydro::Tags::MassWeightedInternalEnergy'
     181             : template <typename DataType>
     182           1 : struct MassWeightedInternalEnergyCompute : MassWeightedInternalEnergy<DataType>,
     183             :                                            db::ComputeTag {
     184           0 :   using argument_tags = tmpl::list<grmhd::ValenciaDivClean::Tags::TildeD,
     185             :                                    SpecificInternalEnergy<DataType>>;
     186             : 
     187           0 :   using return_type = Scalar<DataType>;
     188             : 
     189           0 :   using base = MassWeightedInternalEnergy<DataType>;
     190             : 
     191           0 :   static constexpr auto function =
     192             :       static_cast<void (*)(const gsl::not_null<Scalar<DataType>*> result,
     193             :                            const Scalar<DataType>& tilde_d,
     194             :                            const Scalar<DataType>& specific_internal_energy)>(
     195             :           &mass_weighted_internal_energy<DataType>);
     196             : };
     197             : 
     198             : /// Compute item for mass-weighted internal energy
     199             : ///
     200             : /// Can be retrieved using `hydro::Tags::MassWeightedKineticEnergy'
     201             : template <typename DataType>
     202           1 : struct MassWeightedKineticEnergyCompute : MassWeightedKineticEnergy<DataType>,
     203             :                                           db::ComputeTag {
     204           0 :   using argument_tags = tmpl::list<grmhd::ValenciaDivClean::Tags::TildeD,
     205             :                                    LorentzFactor<DataType>>;
     206             : 
     207           0 :   using return_type = Scalar<DataType>;
     208             : 
     209           0 :   using base = MassWeightedKineticEnergy<DataType>;
     210             : 
     211           0 :   static constexpr auto function = static_cast<void (*)(
     212             :       const gsl::not_null<Scalar<DataType>*> result,
     213             :       const Scalar<DataType>& tilde_d, const Scalar<DataType>& lorentz_factor)>(
     214             :       &mass_weighted_kinetic_energy<DataType>);
     215             : };
     216             : 
     217             : /// Compute item for TildeD limited to unbound material (u_t<-1 criteria)
     218             : ///
     219             : /// Can be retrieved using `hydro::Tags::TildeDUnboundUtCriterion'
     220             : template <typename DataType, size_t Dim, typename Fr = Frame::Inertial>
     221           1 : struct TildeDUnboundUtCriterionCompute : TildeDUnboundUtCriterion<DataType>,
     222             :                                          db::ComputeTag {
     223           0 :   using argument_tags =
     224             :       tmpl::list<grmhd::ValenciaDivClean::Tags::TildeD, LorentzFactor<DataType>,
     225             :                  SpatialVelocity<DataType, Dim, Fr>,
     226             :                  gr::Tags::SpatialMetric<DataType, Dim, Fr>,
     227             :                  gr::Tags::Lapse<DataType>, gr::Tags::Shift<DataType, Dim, Fr>>;
     228             : 
     229           0 :   using return_type = Scalar<DataType>;
     230             : 
     231           0 :   using base = TildeDUnboundUtCriterion<DataType>;
     232             : 
     233           0 :   static constexpr auto function = static_cast<void (*)(
     234             :       const gsl::not_null<Scalar<DataType>*> result,
     235             :       const Scalar<DataType>& tilde_d, const Scalar<DataType>& lorentz_factor,
     236             :       const tnsr::I<DataType, Dim, Fr>& spatial_velocity,
     237             :       const tnsr::ii<DataType, Dim, Fr>& spacial_metric,
     238             :       const Scalar<DataType>& lapse, const tnsr::I<DataType, Dim, Fr>& shift)>(
     239             :       &tilde_d_unbound_ut_criterion<DataType, Dim, Fr>);
     240             : };
     241             : 
     242             : /// Compute tag for TildeD limited to the x>0 or x<0 half plane
     243             : template <typename DataType, size_t Dim, HalfPlaneIntegralMask IntegralMask,
     244             :           typename GridCoordsTag>
     245           1 : struct TildeDInHalfPlaneCompute : TildeDInHalfPlane<DataType, IntegralMask>,
     246             :                                   db::ComputeTag {
     247           0 :   using argument_tags =
     248             :       tmpl::list<grmhd::ValenciaDivClean::Tags::TildeD, GridCoordsTag>;
     249             : 
     250           0 :   using return_type = Scalar<DataType>;
     251             : 
     252           0 :   using base = TildeDInHalfPlane<DataType, IntegralMask>;
     253             : 
     254           0 :   static constexpr auto function = static_cast<void (*)(
     255             :       const gsl::not_null<Scalar<DataType>*> result,
     256             :       const Scalar<DataType>& tilde_d,
     257             :       const tnsr::I<DataType, Dim, Frame::Grid>& grid_coords)>(
     258             :         &tilde_d_in_half_plane<IntegralMask, DataType, Dim>);
     259             : };
     260             : 
     261             : /// Compute item for TildeD * (coordinates in frame Fr).
     262             : /// IntegralMask allows us to restrict the data to the x>0 or x<0
     263             : /// plane in grid coordinates (useful for NSNS).
     264             : ///
     265             : /// Can be retrieved using `hydro::Tags::MassWeightedCoords'
     266             : template <typename DataType, size_t Dim, HalfPlaneIntegralMask IntegralMask,
     267             :           typename GridCoordsTag, typename OutputCoordsTag,
     268             :           typename Fr = Frame::Inertial>
     269           1 : struct MassWeightedCoordsCompute : MassWeightedCoords<DataType, Dim,
     270             :                                    IntegralMask>, db::ComputeTag {
     271           0 :   using argument_tags = tmpl::list<grmhd::ValenciaDivClean::Tags::TildeD,
     272             :                                    GridCoordsTag, OutputCoordsTag>;
     273             : 
     274           0 :   using return_type = tnsr::I<DataType, Dim, Fr>;
     275             : 
     276           0 :   using base = MassWeightedCoords<DataType, Dim, IntegralMask, Fr>;
     277             : 
     278           0 :   static constexpr auto function = static_cast<void (*)(
     279             :       const gsl::not_null<tnsr::I<DataType, Dim, Fr>*> result,
     280             :       const Scalar<DataType>& tilde_d,
     281             :       const tnsr::I<DataType, Dim, Frame::Grid>& grid_coords,
     282             :       const tnsr::I<DataType, Dim, Fr>& compute_coords)>(
     283             :       &mass_weighted_coords<IntegralMask, DataType, Dim, Fr>);
     284             : };
     285             : }  // namespace Tags
     286             : }  // namespace hydro

Generated by: LCOV version 1.14