SpECTRE Documentation Coverage Report
Current view: top level - PointwiseFunctions/AnalyticSolutions/WaveEquation - PlaneWave.hpp Hit Total Coverage
Commit: 1c32b58340e006addc79befb2cdaa7547247e09c Lines: 10 39 25.6 %
Date: 2024-04-19 07:30:15
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/Tensor/TypeAliases.hpp"
      14             : #include "Options/String.hpp"
      15             : #include "PointwiseFunctions/AnalyticSolutions/AnalyticSolution.hpp"
      16             : #include "PointwiseFunctions/InitialDataUtilities/InitialData.hpp"
      17             : #include "PointwiseFunctions/MathFunctions/MathFunction.hpp"
      18             : #include "Utilities/MakeArray.hpp"
      19             : #include "Utilities/Serialization/CharmPupable.hpp"
      20             : #include "Utilities/TMPL.hpp"
      21             : #include "Utilities/TaggedTuple.hpp"
      22             : 
      23             : /// \cond
      24             : class DataVector;
      25             : namespace ScalarWave::Tags {
      26             : struct Psi;
      27             : struct Pi;
      28             : template <size_t Dim>
      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 =
      82             :       tmpl::list<Tags::Psi, Tags::Pi, Tags::Phi<3>, ::Tags::dt<Tags::Psi>,
      83             :                  ::Tags::dt<Tags::Pi>, ::Tags::dt<Tags::Phi<Dim>>>;
      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           1 :   tuples::TaggedTuple<Tags::Psi, Tags::Pi, Tags::Phi<Dim>> variables(
     129             :       const tnsr::I<DataVector, Dim>& x, double t,
     130             :       tmpl::list<Tags::Psi, Tags::Pi, Tags::Phi<Dim>> /*meta*/) const;
     131             : 
     132             :   /// Retrieve the time derivative of the evolution variables at time `t` and
     133             :   /// spatial coordinates `x`
     134             :   ///
     135             :   /// \note This function's expected use case is setting the past time
     136             :   /// derivative values for Adams-Bashforth-like steppers.
     137             :   tuples::TaggedTuple<::Tags::dt<Tags::Psi>, ::Tags::dt<Tags::Pi>,
     138             :                       ::Tags::dt<Tags::Phi<Dim>>>
     139           1 :   variables(const tnsr::I<DataVector, Dim>& x, double t,
     140             :             tmpl::list<::Tags::dt<Tags::Psi>, ::Tags::dt<Tags::Pi>,
     141             :                        ::Tags::dt<Tags::Phi<Dim>>> /*meta*/) const;
     142             : 
     143             :   // NOLINTNEXTLINE(google-runtime-references)
     144           0 :   void pup(PUP::er& p) override;
     145             : 
     146             :  private:
     147             :   template <size_t LocalDim>
     148             :   // NOLINTNEXTLINE(readability-redundant-declaration)
     149           0 :   friend bool operator==(const PlaneWave<LocalDim>& lhs,
     150             :                          const PlaneWave<LocalDim>& rhs);
     151             :   template <size_t LocalDim>
     152             :   // NOLINTNEXTLINE(readability-redundant-declaration)
     153           0 :   friend bool operator!=(const PlaneWave<LocalDim>& lhs,
     154             :                          const PlaneWave<LocalDim>& rhs);
     155             : 
     156             :   template <typename T>
     157           0 :   T u(const tnsr::I<T, Dim>& x, double t) const;
     158             : 
     159           0 :   std::array<double, Dim> wave_vector_{};
     160           0 :   std::array<double, Dim> center_{};
     161           0 :   std::unique_ptr<MathFunction<1, Frame::Inertial>> profile_;
     162           0 :   double omega_{};
     163             : };
     164             : }  // namespace ScalarWave::Solutions

Generated by: LCOV version 1.14