SpECTRE Documentation Coverage Report
Current view: top level - PointwiseFunctions/AnalyticSolutions/RadiationTransport/MonteCarlo - HomogeneousSphere.hpp Coverage Total Hit
Commit: 0d1d717af84a81fb1284a20c4013708fe85cc2f0 Lines: 34.7 % 49 17
Test Date: 2026-10-22 17:29:42
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 <array>
       7              : #include <memory>
       8              : #include <pup.h>
       9              : 
      10              : #include "DataStructures/TaggedTuple.hpp"
      11              : #include "DataStructures/Tensor/TypeAliases.hpp"
      12              : #include "Evolution/Particles/MonteCarlo/Tags.hpp"
      13              : #include "Options/String.hpp"
      14              : #include "PointwiseFunctions/AnalyticSolutions/AnalyticSolution.hpp"
      15              : #include "PointwiseFunctions/AnalyticSolutions/GeneralRelativity/Minkowski.hpp"
      16              : #include "PointwiseFunctions/AnalyticSolutions/GeneralRelativity/WrappedGr.hpp"
      17              : #include "PointwiseFunctions/GeneralRelativity/Tags.hpp"
      18              : #include "PointwiseFunctions/Hydro/EquationsOfState/Factory.hpp"
      19              : #include "PointwiseFunctions/Hydro/Tags.hpp"
      20              : #include "PointwiseFunctions/Hydro/TagsDeclarations.hpp"
      21              : #include "PointwiseFunctions/InitialDataUtilities/Tags/InitialData.hpp"
      22              : #include "Utilities/TMPL.hpp"
      23              : 
      24              : /// \cond
      25              : class DataVector;
      26              : /// \endcond
      27              : 
      28              : namespace RadiationTransport::MonteCarlo::Solutions {
      29              : 
      30              : /*!
      31              :  * \brief Homogeneous sphere as fluid background to MC run
      32              :  *
      33              :  * Provides background fluid variables for a
      34              :  * fluid with constant density, temperature, Ye
      35              :  * in Minkowski spacetime.
      36              :  *
      37              :  */
      38            1 : class HomogeneousSphere : public evolution::initial_data::InitialData,
      39              :                           public MarkAsAnalyticSolution {
      40              :  public:
      41            0 :   constexpr static bool IsRelativistic = true;
      42            0 :   using equation_of_state_type =
      43              :       EquationsOfState::EquationOfState<IsRelativistic, 3>;
      44              : 
      45              :   const EquationsOfState::EquationOfState<IsRelativistic, 3>&
      46            0 :   equation_of_state() const {
      47              :     return *equation_of_state_;
      48              :   }
      49              : 
      50            0 :   static const size_t volume_dim = 3;
      51              : 
      52              :   /// The radius of the sphere
      53            1 :   struct Radius {
      54            0 :     using type = double;
      55            0 :     static constexpr Options::String help = {"The radius of the sphere."};
      56              :   };
      57              :   /// The density inside and outside the sphere
      58            1 :   struct Densities {
      59            0 :     using type = std::array<double, 2>;
      60            0 :     static constexpr Options::String help = {"Density inside and outside."};
      61              :   };
      62              :   /// The temperature inside and outside the sphere
      63            1 :   struct Temperatures {
      64            0 :     using type = std::array<double, 2>;
      65            0 :     static constexpr Options::String help = {"Temperature inside and outside."};
      66              :   };
      67              :   /// The electron fraction inside and outside the sphere
      68            1 :   struct ElectronFractions {
      69            0 :     using type = std::array<double, 2>;
      70            0 :     static constexpr Options::String help = {"Ye inside and outside."};
      71              :   };
      72              : 
      73            0 :   using options = tmpl::list<
      74              :       Radius, Densities, Temperatures, ElectronFractions,
      75              :       hydro::OptionTags::InitialDataEquationOfState<IsRelativistic, 3>>;
      76            0 :   static constexpr Options::String help = {
      77              :       "Background for uniform sphere with constant rho, T, Ye"};
      78              : 
      79            0 :   HomogeneousSphere() = default;
      80            0 :   HomogeneousSphere(const HomogeneousSphere& /*rhs*/);
      81            0 :   HomogeneousSphere& operator=(const HomogeneousSphere& /*rhs*/);
      82            0 :   HomogeneousSphere(HomogeneousSphere&& /*rhs*/) = default;
      83            0 :   HomogeneousSphere& operator=(HomogeneousSphere&& /*rhs*/) = default;
      84            0 :   ~HomogeneousSphere() override = default;
      85              : 
      86            0 :   HomogeneousSphere(
      87              :       const double& radius, const std::array<double, 2>& densities,
      88              :       const std::array<double, 2>& temperatures,
      89              :       const std::array<double, 2>& electron_fractions,
      90              :       std::unique_ptr<EquationsOfState::EquationOfState<IsRelativistic, 3>>
      91              :           local_eos);
      92              : 
      93            0 :   auto get_clone() const
      94              :       -> std::unique_ptr<evolution::initial_data::InitialData> override;
      95              : 
      96              :   /// \cond
      97              :   explicit HomogeneousSphere(CkMigrateMessage* msg);
      98              :   using PUP::able::register_constructor;
      99              :   WRAPPED_PUPable_decl_template(HomogeneousSphere);
     100              :   /// \endcond
     101              : 
     102              :   /// @{
     103              :   /// Retrieve fluid variables at `(x, t)`
     104              :   template <typename DataType>
     105            1 :   auto variables(const tnsr::I<DataType, 3>& x, double /*t*/,
     106              :                  tmpl::list<hydro::Tags::RestMassDensity<DataType>> /*meta*/)
     107              :       const -> tuples::TaggedTuple<hydro::Tags::RestMassDensity<DataType>>;
     108              : 
     109              :   template <typename DataType>
     110            1 :   auto variables(const tnsr::I<DataType, 3>& x, double /*t*/,
     111              :                  tmpl::list<hydro::Tags::ElectronFraction<DataType>> /*meta*/)
     112              :       const -> tuples::TaggedTuple<hydro::Tags::ElectronFraction<DataType>>;
     113              : 
     114              :   template <typename DataType>
     115            1 :   auto variables(const tnsr::I<DataType, 3>& x, double /*t*/,
     116              :                  tmpl::list<hydro::Tags::Temperature<DataType>> /*meta*/) const
     117              :       -> tuples::TaggedTuple<hydro::Tags::Temperature<DataType>>;
     118              : 
     119              :   template <typename DataType>
     120            1 :   auto variables(const tnsr::I<DataType, 3>& x, double /*t*/,
     121              :                  tmpl::list<hydro::Tags::LorentzFactor<DataType>> /*meta*/)
     122              :       const -> tuples::TaggedTuple<hydro::Tags::LorentzFactor<DataType>>;
     123              : 
     124              :   template <typename DataType>
     125            1 :   auto variables(
     126              :       const tnsr::I<DataType, 3>& x, double /*t*/,
     127              :       tmpl::list<hydro::Tags::SpecificInternalEnergy<DataType>> /*meta*/) const
     128              :       -> tuples::TaggedTuple<hydro::Tags::SpecificInternalEnergy<DataType>>;
     129              : 
     130              :   template <typename DataType>
     131            1 :   auto variables(const tnsr::I<DataType, 3>& x, double /*t*/,
     132              :                  tmpl::list<hydro::Tags::Pressure<DataType>> /*meta*/) const
     133              :       -> tuples::TaggedTuple<hydro::Tags::Pressure<DataType>>;
     134              : 
     135              :   template <typename DataType>
     136            1 :   auto variables(const tnsr::I<DataType, 3>& x, double /*t*/,
     137              :                  tmpl::list<hydro::Tags::SpecificEnthalpy<DataType>> /*meta*/)
     138              :       const -> tuples::TaggedTuple<hydro::Tags::SpecificEnthalpy<DataType>>;
     139              : 
     140              :   template <typename DataType>
     141            1 :   auto variables(const tnsr::I<DataType, 3>& x, double /*t*/,
     142              :                  tmpl::list<hydro::Tags::SpatialVelocity<DataType, 3>> /*meta*/)
     143              :       const -> tuples::TaggedTuple<hydro::Tags::SpatialVelocity<DataType, 3>>;
     144              : 
     145              :   template <typename DataType>
     146            1 :   auto variables(const tnsr::I<DataType, 3>& x, double /*t*/,
     147              :                  tmpl::list<hydro::Tags::MagneticField<DataType, 3>> /*meta*/)
     148              :       const -> tuples::TaggedTuple<hydro::Tags::MagneticField<DataType, 3>>;
     149              : 
     150              :   template <typename DataType>
     151            1 :   auto variables(
     152              :       const tnsr::I<DataType, 3>& x, double /*t*/,
     153              :       tmpl::list<hydro::Tags::DivergenceCleaningField<DataType>> /*meta*/) const
     154              :       -> tuples::TaggedTuple<hydro::Tags::DivergenceCleaningField<DataType>>;
     155              :   /// @}
     156              : 
     157              :   /// Retrieve a collection of hydro variables at `(x, t)`
     158              :   template <typename DataType, typename... Tags>
     159            1 :   tuples::TaggedTuple<Tags...> variables(const tnsr::I<DataType, 3>& x,
     160              :                                          double t,
     161              :                                          tmpl::list<Tags...> /*meta*/) const {
     162              :     static_assert(sizeof...(Tags) > 1,
     163              :                   "The generic template will recurse infinitely if only one "
     164              :                   "tag is being retrieved.");
     165              :     return {get<Tags>(variables(x, t, tmpl::list<Tags>{}))...};
     166              :   }
     167              : 
     168              :   /// Retrieve the metric variables
     169              :   template <typename DataType, typename Tag,
     170              :             Requires<not tmpl::list_contains_v<
     171              :                 tmpl::push_back<hydro::grmhd_tags<DataType>,
     172              :                                 hydro::Tags::SpecificEnthalpy<DataType>>,
     173              :                 Tag>> = nullptr>
     174            1 :   tuples::TaggedTuple<Tag> variables(const tnsr::I<DataType, 3>& x,
     175              :                                      double t, tmpl::list<Tag> /*meta*/) const {
     176              :     return background_spacetime_.variables(x, t, tmpl::list<Tag>{});
     177              :   }
     178              : 
     179              :   // NOLINTNEXTLINE(google-runtime-references)
     180            0 :   void pup(PUP::er& /*p*/) override;
     181              : 
     182              :  private:
     183            0 :   friend bool operator==(const HomogeneousSphere& lhs,
     184              :                          const HomogeneousSphere& rhs);
     185              : 
     186            0 :   double radius_ = std::numeric_limits<double>::signaling_NaN();
     187            0 :   std::array<double, 2> densities_{
     188              :       {std::numeric_limits<double>::signaling_NaN(),
     189              :        std::numeric_limits<double>::signaling_NaN()}};
     190            0 :   std::array<double, 2> temperatures_{
     191              :       {std::numeric_limits<double>::signaling_NaN(),
     192              :        std::numeric_limits<double>::signaling_NaN()}};
     193            0 :   std::array<double, 2> electron_fractions_{
     194              :       {std::numeric_limits<double>::signaling_NaN(),
     195              :        std::numeric_limits<double>::signaling_NaN()}};
     196              : 
     197            0 :   std::unique_ptr<equation_of_state_type> equation_of_state_;
     198              :   gh::Solutions::WrappedGr<gr::Solutions::Minkowski<3>>
     199            0 :       background_spacetime_{};
     200              : };
     201              : 
     202            0 : bool operator!=(const HomogeneousSphere& lhs, const HomogeneousSphere& rhs);
     203              : }  // namespace RadiationTransport::MonteCarlo::Solutions
        

Generated by: LCOV version 2.0-1