SpECTRE Documentation Coverage Report
Current view: top level - PointwiseFunctions/AnalyticData/NewtonianEuler - ShuOsherTube.hpp Hit Total Coverage
Commit: 1f2210958b4f38fdc0400907ee7c6d5af5111418 Lines: 2 61 3.3 %
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 <array>
       7             : #include <cstddef>
       8             : #include <limits>
       9             : 
      10             : #include "DataStructures/DataVector.hpp"
      11             : #include "DataStructures/Tensor/Tensor.hpp"
      12             : #include "DataStructures/Tensor/TypeAliases.hpp"
      13             : #include "Options/String.hpp"
      14             : #include "PointwiseFunctions/AnalyticData/AnalyticData.hpp"
      15             : #include "PointwiseFunctions/Hydro/EquationsOfState/EquationOfState.hpp"
      16             : #include "PointwiseFunctions/Hydro/EquationsOfState/IdealFluid.hpp"
      17             : #include "PointwiseFunctions/Hydro/Tags.hpp"
      18             : #include "PointwiseFunctions/InitialDataUtilities/InitialData.hpp"
      19             : #include "Utilities/MakeArray.hpp"
      20             : #include "Utilities/TMPL.hpp"
      21             : #include "Utilities/TaggedTuple.hpp"
      22             : 
      23             : /// \cond
      24             : namespace PUP {
      25             : class er;
      26             : }  // namespace PUP
      27             : /// \endcond
      28             : 
      29             : namespace NewtonianEuler::AnalyticData {
      30             : /*!
      31             :  * \brief Initial data for the Shu-Osher oscillatory shock tube \cite Shu1988439
      32             :  *
      33             :  * The general initial data is given by:
      34             :  *
      35             :  * \f{align*}{
      36             :  *  \{\rho,v^x,p\}=
      37             :  * \left\{
      38             :  * \begin{array}{ll}
      39             :  *   \left\{\rho_L, v^x_L, p_L\right\} &\mathrm{if} \;\;\; x<\Delta \\
      40             :  *   \left\{1+\epsilon\sin(\lambda x), v^x_R, p_R\right\} &\mathrm{if} \;\;\;
      41             :  *    x\ge \Delta
      42             :  * \end{array}\right.
      43             :  * \f}
      44             :  *
      45             :  * with the adiabatic index being 1.4.
      46             :  *
      47             :  * With the standard parameters given below, this is a Mach-3 shock moving into
      48             :  * a sinusoidal density profile.
      49             :  *
      50             :  * \f{align*}{
      51             :  *  \{\rho,v^x,p\}=
      52             :  * \left\{
      53             :  * \begin{array}{ll}
      54             :  *   \left\{3.857143, 2.629369, 10.33333\right\} &\mathrm{if} \;\;\; x<-4 \\
      55             :  *   \left\{1+0.2\sin(5x), 0, 1\right\} &\mathrm{if} \;\;\; x\ge -4
      56             :  * \end{array}\right.
      57             :  * \f}
      58             :  *
      59             :  * With these values the usual final time is 1.8.
      60             :  */
      61           1 : class ShuOsherTube : public evolution::initial_data::InitialData,
      62             :                      public MarkAsAnalyticData {
      63             :  public:
      64           0 :   using equation_of_state_type = EquationsOfState::IdealFluid<false>;
      65             : 
      66             :   /// Initial postition of the discontinuity
      67           1 :   struct JumpPosition {
      68           0 :     using type = double;
      69           0 :     static constexpr Options::String help = {
      70             :         "The initial position of the discontinuity."};
      71             :   };
      72             : 
      73           0 :   struct LeftMassDensity {
      74           0 :     using type = double;
      75           0 :     static constexpr Options::String help = {"The left mass density."};
      76           0 :     static type lower_bound() { return 0.0; }
      77             :   };
      78             : 
      79           0 :   struct LeftVelocity {
      80           0 :     using type = double;
      81           0 :     static constexpr Options::String help = {"The left velocity."};
      82             :   };
      83             : 
      84           0 :   struct LeftPressure {
      85           0 :     using type = double;
      86           0 :     static constexpr Options::String help = {"The left pressure."};
      87           0 :     static type lower_bound() { return 0.0; }
      88             :   };
      89             : 
      90           0 :   struct RightVelocity {
      91           0 :     using type = double;
      92           0 :     static constexpr Options::String help = {"The right velocity."};
      93             :   };
      94             : 
      95           0 :   struct RightPressure {
      96           0 :     using type = double;
      97           0 :     static constexpr Options::String help = {"The right pressure."};
      98           0 :     static type lower_bound() { return 0.0; }
      99             :   };
     100             : 
     101           0 :   struct Epsilon {
     102           0 :     using type = double;
     103           0 :     static constexpr Options::String help = {"Sinusoid amplitude."};
     104           0 :     static type lower_bound() { return 0.0; }
     105           0 :     static type upper_bound() { return 1.0; }
     106             :   };
     107             : 
     108           0 :   struct Lambda {
     109           0 :     using type = double;
     110           0 :     static constexpr Options::String help = {"Sinusoid wavelength."};
     111             :   };
     112             : 
     113           0 :   static constexpr Options::String help = {
     114             :       "1D Shu-Osher oscillatory shock tube."};
     115             : 
     116           0 :   using options =
     117             :       tmpl::list<JumpPosition, LeftMassDensity, LeftVelocity, LeftPressure,
     118             :                  RightVelocity, RightPressure, Epsilon, Lambda>;
     119             : 
     120           0 :   ShuOsherTube(double jump_position, double mass_density_l, double velocity_l,
     121             :                double pressure_l, double velocity_r, double pressure_r,
     122             :                double epsilon, double lambda);
     123           0 :   ShuOsherTube() = default;
     124           0 :   ShuOsherTube(const ShuOsherTube& /*rhs*/) = default;
     125           0 :   ShuOsherTube& operator=(const ShuOsherTube& /*rhs*/) = default;
     126           0 :   ShuOsherTube(ShuOsherTube&& /*rhs*/) = default;
     127           0 :   ShuOsherTube& operator=(ShuOsherTube&& /*rhs*/) = default;
     128           0 :   ~ShuOsherTube() override = default;
     129             : 
     130           0 :   auto get_clone() const
     131             :       -> std::unique_ptr<evolution::initial_data::InitialData> override;
     132             : 
     133             :   /// \cond
     134             :   explicit ShuOsherTube(CkMigrateMessage* msg);
     135             :   using PUP::able::register_constructor;
     136             :   WRAPPED_PUPable_decl_template(ShuOsherTube);
     137             :   /// \endcond
     138             : 
     139             :   template <typename DataType, typename... Tags>
     140           0 :   tuples::TaggedTuple<Tags...> variables(
     141             :       const tnsr::I<DataType, 1, Frame::Inertial>& x,
     142             :       tmpl::list<Tags...> /*meta*/) const {
     143             :     return {tuples::get<Tags>(variables(x, tmpl::list<Tags>{}))...};
     144             :   }
     145             : 
     146           0 :   const EquationsOfState::IdealFluid<false>& equation_of_state() const {
     147             :     return equation_of_state_;
     148             :   }
     149             : 
     150             :   // NOLINTNEXTLINE(google-runtime-references)
     151           0 :   void pup(PUP::er& p) override;
     152             : 
     153             :  private:
     154             :   template <typename DataType>
     155           0 :   auto variables(const tnsr::I<DataType, 1, Frame::Inertial>& x,
     156             :                  tmpl::list<hydro::Tags::RestMassDensity<DataType>> /*meta*/)
     157             :       const -> tuples::TaggedTuple<hydro::Tags::RestMassDensity<DataType>>;
     158             : 
     159             :   template <typename DataType>
     160           0 :   auto variables(const tnsr::I<DataType, 1, Frame::Inertial>& x,
     161             :                  tmpl::list<hydro::Tags::SpatialVelocity<
     162             :                      DataType, 1, Frame::Inertial>> /*meta*/) const
     163             :       -> tuples::TaggedTuple<
     164             :           hydro::Tags::SpatialVelocity<DataType, 1, Frame::Inertial>>;
     165             : 
     166             :   template <typename DataType>
     167           0 :   auto variables(const tnsr::I<DataType, 1, Frame::Inertial>& x,
     168             :                  tmpl::list<hydro::Tags::Pressure<DataType>> /*meta*/) const
     169             :       -> tuples::TaggedTuple<hydro::Tags::Pressure<DataType>>;
     170             : 
     171             :   template <typename DataType>
     172           0 :   auto variables(
     173             :       const tnsr::I<DataType, 1, Frame::Inertial>& x,
     174             :       tmpl::list<hydro::Tags::SpecificInternalEnergy<DataType>> /*meta*/) const
     175             :       -> tuples::TaggedTuple<hydro::Tags::SpecificInternalEnergy<DataType>>;
     176             : 
     177             :   friend bool
     178           0 :   operator==(  // NOLINT (clang-tidy: readability-redundant-declaration)
     179             :       const ShuOsherTube& lhs, const ShuOsherTube& rhs);
     180             : 
     181           0 :   double mass_density_l_ = std::numeric_limits<double>::signaling_NaN();
     182           0 :   double velocity_l_ = std::numeric_limits<double>::signaling_NaN();
     183           0 :   double pressure_l_ = std::numeric_limits<double>::signaling_NaN();
     184           0 :   double jump_position_ = std::numeric_limits<double>::signaling_NaN();
     185           0 :   double epsilon_ = std::numeric_limits<double>::signaling_NaN();
     186           0 :   double lambda_ = std::numeric_limits<double>::signaling_NaN();
     187           0 :   double velocity_r_ = std::numeric_limits<double>::signaling_NaN();
     188           0 :   double pressure_r_ = std::numeric_limits<double>::signaling_NaN();
     189           0 :   double adiabatic_index_ = 1.4;
     190           0 :   EquationsOfState::IdealFluid<false> equation_of_state_{adiabatic_index_};
     191             : };
     192             : 
     193           0 : bool operator!=(const ShuOsherTube& lhs, const ShuOsherTube& rhs);
     194             : }  // namespace NewtonianEuler::AnalyticData

Generated by: LCOV version 1.14