SpECTRE Documentation Coverage Report
Current view: top level - Elliptic/Systems/Xcts - HydroQuantities.hpp Hit Total Coverage
Commit: ecb8a275e1aebab77dcce48a5e098ed4e486ab4b Lines: 2 6 33.3 %
Date: 2026-08-22 01:05:40
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 <type_traits>
       7             : #include <utility>
       8             : 
       9             : #include "DataStructures/DataBox/MetavariablesTag.hpp"
      10             : #include "DataStructures/DataBox/Tag.hpp"
      11             : #include "DataStructures/Tensor/Tensor.hpp"
      12             : #include "DataStructures/Variables.hpp"
      13             : #include "DataStructures/VariablesTag.hpp"
      14             : #include "Domain/Tags.hpp"
      15             : #include "Elliptic/Tags.hpp"
      16             : #include "PointwiseFunctions/GeneralRelativity/Tags.hpp"
      17             : #include "PointwiseFunctions/Hydro/Tags.hpp"
      18             : #include "PointwiseFunctions/InitialDataUtilities/Background.hpp"
      19             : #include "Utilities/CallWithDynamicType.hpp"
      20             : #include "Utilities/Gsl.hpp"
      21             : #include "Utilities/TMPL.hpp"
      22             : 
      23           1 : namespace Xcts::Tags {
      24             : namespace detail {
      25             : 
      26             : template <typename Background, typename HydroTags, typename = std::void_t<>>
      27             : struct has_hydro_variables : std::false_type {};
      28             : 
      29             : template <typename Background, typename HydroTags>
      30             : struct has_hydro_variables<
      31             :     Background, HydroTags,
      32             :     std::void_t<decltype(std::declval<const Background&>().variables(
      33             :         std::declval<const tnsr::I<DataVector, 3, Frame::Inertial>&>(),
      34             :         HydroTags{}))>> : std::true_type {};
      35             : 
      36             : }  // namespace detail
      37             : 
      38             : /*!
      39             :  * \brief MHD quantities retrieved from the background solution/data
      40             :  *
      41             :  * Retrieve the `HydroTags` from the background solution/data so they can be
      42             :  * written out to disk. These quantities don't take part in a pure XCTS solve,
      43             :  * (which only solves for the gravity sector given the matter profile) except
      44             :  * for their contributions to the matter source terms in the XCTS equations.
      45             :  * However, the matter source terms are computed and stored separately, so these
      46             :  * hydro quantities are only used for observations.
      47             :  */
      48             : template <typename HydroTags>
      49           1 : struct HydroQuantitiesCompute : ::Tags::Variables<HydroTags>, db::ComputeTag {
      50           0 :   using base = ::Tags::Variables<HydroTags>;
      51           0 :   using argument_tags = tmpl::list<
      52             :       domain::Tags::Coordinates<3, Frame::Inertial>,
      53             :       elliptic::Tags::Background<elliptic::analytic_data::Background>,
      54             :       Parallel::Tags::Metavariables>;
      55             :   template <typename Metavariables>
      56           0 :   static void function(const gsl::not_null<Variables<HydroTags>*> result,
      57             :                        const tnsr::I<DataVector, 3>& inertial_coords,
      58             :                        const elliptic::analytic_data::Background& background,
      59             :                        const Metavariables& /*meta*/) {
      60             :     using background_classes =
      61             :         tmpl::at<typename Metavariables::factory_creation::factory_classes,
      62             :                  elliptic::analytic_data::Background>;
      63             :     *result = call_with_dynamic_type<Variables<HydroTags>, background_classes>(
      64             :         &background, [&inertial_coords](const auto* const derived) {
      65             :           using derived_type = std::decay_t<decltype(*derived)>;
      66             :           if constexpr (detail::has_hydro_variables<derived_type,
      67             :                                                     HydroTags>::value) {
      68             :             return variables_from_tagged_tuple(
      69             :                 derived->variables(inertial_coords, HydroTags{}));
      70             :           } else {
      71             :             return Variables<HydroTags>{inertial_coords.begin()->size(), 0.};
      72             :           }
      73             :         });
      74             :   }
      75             : };
      76             : 
      77             : }  // namespace Xcts::Tags

Generated by: LCOV version 1.14