SpECTRE Documentation Coverage Report
Current view: top level - PointwiseFunctions/AnalyticSolutions/WaveEquation - PlaneWave.hpp Coverage Total Hit
Commit: 0d1d717af84a81fb1284a20c4013708fe85cc2f0 Lines: 25.6 % 39 10
Test Date: 2026-10-22 17:29:42
Legend: Lines:     hit not hit

            Line data    Source code
       1            1 : // Distributed under the MIT License.
       2              : // See LICENSE.txt for details.
       3              : 
       4              : /// \file
       5              : /// Defines WaveEquationSolutions::PlaneWave
       6              : 
       7              : #pragma once
       8              : 
       9              : #include <array>
      10              : #include <cstddef>
      11              : #include <memory>
      12              : 
      13              : #include "DataStructures/TaggedTuple.hpp"
      14              : #include "DataStructures/Tensor/TypeAliases.hpp"
      15              : #include "Options/String.hpp"
      16              : #include "PointwiseFunctions/AnalyticSolutions/AnalyticSolution.hpp"
      17              : #include "PointwiseFunctions/InitialDataUtilities/InitialData.hpp"
      18              : #include "PointwiseFunctions/MathFunctions/MathFunction.hpp"
      19              : #include "Utilities/MakeArray.hpp"
      20              : #include "Utilities/Serialization/CharmPupable.hpp"
      21              : #include "Utilities/TMPL.hpp"
      22              : 
      23              : /// \cond
      24              : class DataVector;
      25              : namespace ScalarWave::Tags {
      26              : struct Psi;
      27              : struct Pi;
      28              : template <size_t Dim, typename Frame>
      29              : struct Phi;
      30              : }  // namespace ScalarWave::Tags
      31              : namespace Tags {
      32              : template <typename Tag>
      33              : struct dt;
      34              : }  // namespace Tags
      35              : template <size_t VolumeDim, typename Fr>
      36              : class MathFunction;
      37              : 
      38              : namespace PUP {
      39              : class er;
      40              : }  // namespace PUP
      41              : /// \endcond
      42              : 
      43              : namespace ScalarWave::Solutions {
      44              : /*!
      45              :  * \brief A plane wave solution to the Euclidean wave equation
      46              :  *
      47              :  * The solution is given by \f$\Psi(\vec{x},t) = F(u(\vec{x},t))\f$
      48              :  * where the profile \f$F\f$ of the plane wave is an arbitrary one-dimensional
      49              :  * function of \f$u = \vec{k} \cdot (\vec{x} - \vec{x_o}) - \omega t\f$
      50              :  * with the wave vector \f$\vec{k}\f$, the frequency \f$\omega = ||\vec{k}||\f$
      51              :  * and initial center of the profile \f$\vec{x_o}\f$.
      52              :  *
      53              :  * \tparam Dim the spatial dimension of the solution
      54              :  */
      55              : template <size_t Dim>
      56            1 : class PlaneWave : public evolution::initial_data::InitialData,
      57              :                   public MarkAsAnalyticSolution {
      58              :  public:
      59            0 :   static constexpr size_t volume_dim = Dim;
      60            0 :   struct WaveVector {
      61            0 :     using type = std::array<double, Dim>;
      62            0 :     static constexpr Options::String help = {
      63              :         "The direction of propagation of the wave."};
      64              :   };
      65              : 
      66            0 :   struct Center {
      67            0 :     using type = std::array<double, Dim>;
      68            0 :     static constexpr Options::String help = {
      69              :         "The initial center of the profile of the wave."};
      70              :   };
      71              : 
      72            0 :   struct Profile {
      73            0 :     using type = std::unique_ptr<MathFunction<1, Frame::Inertial>>;
      74            0 :     static constexpr Options::String help = {"The profile of the wave."};
      75              :   };
      76              : 
      77            0 :   using options = tmpl::list<WaveVector, Center, Profile>;
      78              : 
      79            0 :   static constexpr Options::String help = {
      80              :       "A plane wave solution of the Euclidean wave equation"};
      81            0 :   using tags = tmpl::list<Tags::Psi, Tags::Pi, Tags::Phi<Dim, Frame::Inertial>,
      82              :                           ::Tags::dt<Tags::Psi>, ::Tags::dt<Tags::Pi>,
      83              :                           ::Tags::dt<Tags::Phi<Dim, Frame::Inertial>>>;
      84              : 
      85            0 :   PlaneWave() = default;
      86            0 :   PlaneWave(std::array<double, Dim> wave_vector, std::array<double, Dim> center,
      87              :             std::unique_ptr<MathFunction<1, Frame::Inertial>> profile);
      88            0 :   PlaneWave(const PlaneWave&);
      89            0 :   PlaneWave& operator=(const PlaneWave&);
      90            0 :   PlaneWave(PlaneWave&&) = default;
      91            0 :   PlaneWave& operator=(PlaneWave&&) = default;
      92            0 :   ~PlaneWave() override = default;
      93              : 
      94            0 :   auto get_clone() const
      95              :       -> std::unique_ptr<evolution::initial_data::InitialData> override;
      96              : 
      97              :   /// \cond
      98              :   explicit PlaneWave(CkMigrateMessage* msg);
      99              :   using PUP::able::register_constructor;
     100              :   WRAPPED_PUPable_decl_template(PlaneWave);
     101              :   /// \endcond
     102              : 
     103              :   /// The value of the scalar field
     104              :   template <typename T>
     105            1 :   Scalar<T> psi(const tnsr::I<T, Dim>& x, double t) const;
     106              : 
     107              :   /// The time derivative of the scalar field
     108              :   template <typename T>
     109            1 :   Scalar<T> dpsi_dt(const tnsr::I<T, Dim>& x, double t) const;
     110              : 
     111              :   /// The spatial derivatives of the scalar field
     112              :   template <typename T>
     113            1 :   tnsr::i<T, Dim> dpsi_dx(const tnsr::I<T, Dim>& x, double t) const;
     114              : 
     115              :   /// The second time derivative of the scalar field
     116              :   template <typename T>
     117            1 :   Scalar<T> d2psi_dt2(const tnsr::I<T, Dim>& x, double t) const;
     118              : 
     119              :   /// The second mixed derivatives of the scalar field
     120              :   template <typename T>
     121            1 :   tnsr::i<T, Dim> d2psi_dtdx(const tnsr::I<T, Dim>& x, double t) const;
     122              : 
     123              :   /// The second spatial derivatives of the scalar field
     124              :   template <typename T>
     125            1 :   tnsr::ii<T, Dim> d2psi_dxdx(const tnsr::I<T, Dim>& x, double t) const;
     126              : 
     127              :   /// Retrieve the evolution variables at time `t` and spatial coordinates `x`
     128              :   tuples::TaggedTuple<Tags::Psi, Tags::Pi, Tags::Phi<Dim, Frame::Inertial>>
     129            1 :   variables(const tnsr::I<DataVector, Dim>& x, double t,
     130              :             tmpl::list<Tags::Psi, Tags::Pi,
     131              :                        Tags::Phi<Dim, Frame::Inertial>> /*meta*/) const;
     132              : 
     133              :   /// Retrieve the time derivative of the evolution variables at time `t` and
     134              :   /// spatial coordinates `x`
     135              :   ///
     136              :   /// \note This function's expected use case is setting the past time
     137              :   /// derivative values for Adams-Bashforth-like steppers.
     138              :   tuples::TaggedTuple<::Tags::dt<Tags::Psi>, ::Tags::dt<Tags::Pi>,
     139              :                       ::Tags::dt<Tags::Phi<Dim, Frame::Inertial>>>
     140            1 :   variables(
     141              :       const tnsr::I<DataVector, Dim>& x, double t,
     142              :       tmpl::list<::Tags::dt<Tags::Psi>, ::Tags::dt<Tags::Pi>,
     143              :                  ::Tags::dt<Tags::Phi<Dim, Frame::Inertial>>> /*meta*/) const;
     144              : 
     145              :   // NOLINTNEXTLINE(google-runtime-references)
     146            0 :   void pup(PUP::er& p) override;
     147              : 
     148              :  private:
     149              :   template <size_t LocalDim>
     150              :   // NOLINTNEXTLINE(readability-redundant-declaration)
     151            0 :   friend bool operator==(const PlaneWave<LocalDim>& lhs,
     152              :                          const PlaneWave<LocalDim>& rhs);
     153              :   template <size_t LocalDim>
     154              :   // NOLINTNEXTLINE(readability-redundant-declaration)
     155            0 :   friend bool operator!=(const PlaneWave<LocalDim>& lhs,
     156              :                          const PlaneWave<LocalDim>& rhs);
     157              : 
     158              :   template <typename T>
     159            0 :   T u(const tnsr::I<T, Dim>& x, double t) const;
     160              : 
     161            0 :   std::array<double, Dim> wave_vector_{};
     162            0 :   std::array<double, Dim> center_{};
     163            0 :   std::unique_ptr<MathFunction<1, Frame::Inertial>> profile_;
     164            0 :   double omega_{};
     165              : };
     166              : }  // namespace ScalarWave::Solutions
        

Generated by: LCOV version 2.0-1