SpECTRE Documentation Coverage Report
Current view: top level - Evolution/Systems/NewtonianEuler/Sources - LaneEmdenGravitationalField.hpp Hit Total Coverage
Commit: 3c2e9d3ed337bca2146eee9de07432e292a38c3a Lines: 3 25 12.0 %
Date: 2024-06-11 22:56:19
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/Tensor/Tensor.hpp"
       9             : #include "Evolution/Systems/NewtonianEuler/Sources/Source.hpp"
      10             : #include "Evolution/Systems/NewtonianEuler/TagsDeclarations.hpp"
      11             : #include "Options/String.hpp"
      12             : #include "Utilities/TMPL.hpp"
      13             : 
      14             : /// \cond
      15             : class DataVector;
      16             : 
      17             : namespace NewtonianEuler {
      18             : namespace Solutions {
      19             : struct LaneEmdenStar;
      20             : }  // namespace Solutions
      21             : }  // namespace NewtonianEuler
      22             : 
      23             : namespace PUP {
      24             : class er;
      25             : }  // namespace PUP
      26             : 
      27             : namespace Tags {
      28             : template <typename SolutionType>
      29             : struct AnalyticSolution;
      30             : }  // namespace Tags
      31             : 
      32             : namespace domain::Tags {
      33             : template <size_t Dim, typename Frame>
      34             : struct Coordinates;
      35             : }  // namespace domain::Tags
      36             : 
      37             : namespace gsl {
      38             : template <typename T>
      39             : class not_null;
      40             : }  // namespace gsl
      41             : /// \endcond
      42             : 
      43             : // IWYU pragma: no_include "Evolution/Systems/NewtonianEuler/Tags.hpp"
      44             : 
      45             : // IWYU pragma: no_forward_declare Tensor
      46             : 
      47             : namespace NewtonianEuler::Sources {
      48             : 
      49             : /*!
      50             :  * \brief Source giving the acceleration due to gravity in the spherical,
      51             :  * Newtonian Lane-Emden star solution.
      52             :  *
      53             :  * The gravitational field \f$g^i\f$ enters the NewtonianEuler system as source
      54             :  * terms for the conserved momentum and energy:
      55             :  *
      56             :  * \f{align*}
      57             :  * \partial_t S^i + \partial_j F^{j}(S^i) &= S(S^i) = \rho g^i
      58             :  * \partial_t e + \partial_j F^{j}(e) &= S(e) = S_i g^i,
      59             :  * \f}
      60             :  *
      61             :  * where \f$S^i\f$ is the conserved momentum density, \f$e\f$ is the conserved
      62             :  * energy, \f$F^{j}(u)\f$ is the flux of the conserved quantity \f$u\f$, and
      63             :  * \f$\rho\f$ is the fluid mass density.
      64             :  *
      65             :  * \note This source is specialized to the Lane-Emden solution because it
      66             :  * queries a LaneEmdenStar analytic solution for the gravitational field that
      67             :  * generates the fluid acceleration. This source does *not* integrate the fluid
      68             :  * density to compute a self-consistent gravitational field (i.e., as if one
      69             :  * were solving a coupled Euler + Poisson system).
      70             :  */
      71           1 : class LaneEmdenGravitationalField : public Source<3> {
      72             :  public:
      73             :   /// The central mass density of the star.
      74           1 :   struct CentralMassDensity {
      75           0 :     using type = double;
      76           0 :     static constexpr Options::String help = {
      77             :         "The central mass density of the star."};
      78           0 :     static type lower_bound() { return 0.; }
      79             :   };
      80             : 
      81             :   /// The polytropic constant of the polytropic fluid.
      82           1 :   struct PolytropicConstant {
      83           0 :     using type = double;
      84           0 :     static constexpr Options::String help = {
      85             :         "The polytropic constant of the fluid."};
      86           0 :     static type lower_bound() { return 0.; }
      87             :   };
      88             : 
      89           0 :   using options = tmpl::list<CentralMassDensity, PolytropicConstant>;
      90             : 
      91           0 :   static constexpr Options::String help = {
      92             :       "The gravitational field corresponding to a static, "
      93             :       "spherically-symmetric star in Newtonian gravity, found by "
      94             :       "solving the Lane-Emden equations, with a given central density and "
      95             :       "polytropic fluid. The fluid has polytropic index 1, but the polytropic "
      96             :       "constant is specifiable"};
      97             : 
      98           0 :   LaneEmdenGravitationalField(double central_mass_density,
      99             :                               double polytropic_constant);
     100             : 
     101           0 :   LaneEmdenGravitationalField() = default;
     102           0 :   LaneEmdenGravitationalField(const LaneEmdenGravitationalField& /*rhs*/) =
     103             :       default;
     104           0 :   LaneEmdenGravitationalField& operator=(
     105             :       const LaneEmdenGravitationalField& /*rhs*/) = default;
     106           0 :   LaneEmdenGravitationalField(LaneEmdenGravitationalField&& /*rhs*/) = default;
     107           0 :   LaneEmdenGravitationalField& operator=(
     108             :       LaneEmdenGravitationalField&& /*rhs*/) = default;
     109           0 :   ~LaneEmdenGravitationalField() override = default;
     110             : 
     111             :   /// \cond
     112             :   explicit LaneEmdenGravitationalField(CkMigrateMessage* msg);
     113             :   using PUP::able::register_constructor;
     114             :   WRAPPED_PUPable_decl_template(LaneEmdenGravitationalField);
     115             :   /// \endcond
     116             : 
     117             :   // NOLINTNEXTLINE(google-runtime-references)
     118           0 :   void pup(PUP::er& p) override;
     119             : 
     120           0 :   auto get_clone() const -> std::unique_ptr<Source> override;
     121             : 
     122           0 :   void operator()(
     123             :       gsl::not_null<Scalar<DataVector>*> source_mass_density_cons,
     124             :       gsl::not_null<tnsr::I<DataVector, 3>*> source_momentum_density,
     125             :       gsl::not_null<Scalar<DataVector>*> source_energy_density,
     126             :       const Scalar<DataVector>& mass_density_cons,
     127             :       const tnsr::I<DataVector, 3>& momentum_density,
     128             :       const Scalar<DataVector>& energy_density,
     129             :       const tnsr::I<DataVector, 3>& velocity,
     130             :       const Scalar<DataVector>& pressure,
     131             :       const Scalar<DataVector>& specific_internal_energy,
     132             :       const EquationsOfState::EquationOfState<false, 2>& eos,
     133             :       const tnsr::I<DataVector, 3>& coords, double time) const override;
     134             : 
     135             :  private:
     136           0 :   tnsr::I<DataVector, 3> gravitational_field(
     137             :       const tnsr::I<DataVector, 3>& x) const;
     138             : 
     139           0 :   double central_mass_density_ = std::numeric_limits<double>::signaling_NaN();
     140           0 :   double polytropic_constant_ = std::numeric_limits<double>::signaling_NaN();
     141             : };
     142             : }  // namespace NewtonianEuler::Sources

Generated by: LCOV version 1.14