SpECTRE Documentation Coverage Report
Current view: top level - Domain/Creators/TimeDependence - UniformTranslation.hpp Coverage Total Hit
Commit: 0d1d717af84a81fb1284a20c4013708fe85cc2f0 Lines: 22.7 % 44 10
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 <cstddef>
       8              : #include <limits>
       9              : #include <memory>
      10              : #include <optional>
      11              : #include <string>
      12              : #include <unordered_map>
      13              : #include <vector>
      14              : 
      15              : #include "Domain/CoordinateMaps/CoordinateMap.hpp"
      16              : #include "Domain/CoordinateMaps/TimeDependent/Translation.hpp"
      17              : #include "Domain/Creators/TimeDependence/GenerateCoordinateMap.hpp"
      18              : #include "Domain/Creators/TimeDependence/TimeDependence.hpp"
      19              : #include "Options/String.hpp"
      20              : #include "Utilities/GetOutput.hpp"
      21              : #include "Utilities/TMPL.hpp"
      22              : 
      23              : /// \cond
      24              : namespace domain::FunctionsOfTime {
      25              : class FunctionOfTime;
      26              : }  // namespace domain::FunctionsOfTime
      27              : namespace domain::CoordinateMaps::TimeDependent {
      28              : template <typename Map1, typename Map2, typename Map3>
      29              : class ProductOf3Maps;
      30              : template <typename Map1, typename Map2>
      31              : class ProductOf2Maps;
      32              : }  // namespace domain::CoordinateMaps::TimeDependent
      33              : namespace domain {
      34              : template <typename SourceFrame, typename TargetFrame, typename... Maps>
      35              : class CoordinateMap;
      36              : }  // namespace domain
      37              : 
      38              : namespace Frame {
      39              : struct Distorted;
      40              : struct Grid;
      41              : struct Inertial;
      42              : }  // namespace Frame
      43              : /// \endcond
      44              : 
      45              : namespace domain::creators::time_dependence {
      46              : /*!
      47              :  * \brief A uniform translation in the \f$x-, y-\f$ and \f$z-\f$direction.
      48              :  *
      49              :  * The coordinates are adjusted according to:
      50              :  *
      51              :  * \f{align}{
      52              :  * x^i \to x^i + f^i(t)
      53              :  * \f}
      54              :  *
      55              :  * where \f$f^i(t)\f$ are the functions of time.
      56              :  *
      57              :  * \p Index is used to distinguish multiple `UniformTranslation`s from each
      58              :  * other in CompositionUniformTranslation.
      59              :  *
      60              :  * See the documentation for the constructors below: one constructor
      61              :  * takes two velocities, which correspond to two translations: one from
      62              :  * Frame::Grid to Frame::Distorted, and the other from Frame::Distorted to
      63              :  * Frame::Inertial.
      64              :  */
      65              : template <size_t MeshDim, size_t Index>
      66            1 : class UniformTranslation final : public TimeDependence<MeshDim> {
      67              :  private:
      68            0 :   using TranslationMap =
      69              :       domain::CoordinateMaps::TimeDependent::Translation<MeshDim>;
      70              : 
      71              :  public:
      72            0 :   using maps_list = tmpl::list<
      73              :       domain::CoordinateMap<Frame::Grid, Frame::Inertial, TranslationMap>,
      74              :       domain::CoordinateMap<Frame::Grid, Frame::Distorted, TranslationMap>,
      75              :       domain::CoordinateMap<Frame::Distorted, Frame::Inertial, TranslationMap>,
      76              :       domain::CoordinateMap<Frame::Grid, Frame::Inertial, TranslationMap,
      77              :                             TranslationMap>>;
      78              : 
      79            0 :   static constexpr size_t mesh_dim = MeshDim;
      80              : 
      81              :   /// \brief The initial time of the functions of time.
      82            1 :   struct InitialTime {
      83            0 :     using type = double;
      84            0 :     static constexpr Options::String help = {
      85              :         "The initial time of the functions of time"};
      86              :   };
      87              :   /// \brief The \f$x\f$-, \f$y\f$-, and \f$z\f$-velocity.
      88            1 :   struct Velocity {
      89            0 :     using type = std::array<double, MeshDim>;
      90            0 :     static constexpr Options::String help = {"The velocity of the map."};
      91              :   };
      92              : 
      93            0 :   using GridToInertialMapSimple =
      94              :       detail::generate_coordinate_map_t<Frame::Grid, Frame::Inertial,
      95              :                                         tmpl::list<TranslationMap>>;
      96              : 
      97            0 :   using GridToInertialMapCombined = detail::generate_coordinate_map_t<
      98              :       Frame::Grid, Frame::Inertial, tmpl::list<TranslationMap, TranslationMap>>;
      99              : 
     100            0 :   using GridToDistortedMap =
     101              :       detail::generate_coordinate_map_t<Frame::Grid, Frame::Distorted,
     102              :                                         tmpl::list<TranslationMap>>;
     103              : 
     104            0 :   using DistortedToInertialMap =
     105              :       detail::generate_coordinate_map_t<Frame::Distorted, Frame::Inertial,
     106              :                                         tmpl::list<TranslationMap>>;
     107              : 
     108            0 :   using options = tmpl::list<InitialTime, Velocity>;
     109              : 
     110            0 :   static constexpr Options::String help = {
     111              :       "A spatially uniform translation initialized with a constant velocity."};
     112              : 
     113            0 :   UniformTranslation() = default;
     114            0 :   ~UniformTranslation() override = default;
     115            0 :   UniformTranslation(const UniformTranslation&) = delete;
     116            0 :   UniformTranslation(UniformTranslation&&) = default;
     117            0 :   UniformTranslation& operator=(const UniformTranslation&) = delete;
     118            0 :   UniformTranslation& operator=(UniformTranslation&&) = default;
     119              : 
     120              :   /// If UniformTranslation is created using the constructor that
     121              :   /// takes a single velocity, then there is no distorted frame (so
     122              :   /// block_maps_grid_to_distorted() and
     123              :   /// block_maps_distorted_to_inertial() contain nullptrs), and the
     124              :   /// given velocity is the one that goes from Frame::Grid to
     125              :   /// Frame::Inertial.
     126            1 :   UniformTranslation(double initial_time,
     127              :                      const std::array<double, MeshDim>& velocity);
     128              : 
     129              :   /// If UniformTranslation is created using the constructor that
     130              :   /// takes two velocities, then the first velocity is the one
     131              :   /// describing a uniform translation that goes from Frame::Grid to
     132              :   /// Frame::Distorted, and the second velocity is the one that
     133              :   /// describes a uniform translation that goes from Frame::Distorted
     134              :   /// to Frame::Inertial.  In this case there are also two
     135              :   /// FunctionsOfTime, one for each of the two translation maps.
     136            1 :   UniformTranslation(
     137              :       double initial_time,
     138              :       const std::array<double, MeshDim>& velocity_grid_to_distorted,
     139              :       const std::array<double, MeshDim>& velocity_distorted_to_inertial);
     140              : 
     141            1 :   auto get_clone() const -> std::unique_ptr<TimeDependence<MeshDim>> override;
     142              : 
     143            1 :   auto block_maps_grid_to_inertial(size_t number_of_blocks) const
     144              :       -> std::vector<std::unique_ptr<domain::CoordinateMapBase<
     145              :           Frame::Grid, Frame::Inertial, MeshDim>>> override;
     146              : 
     147            1 :   auto block_maps_grid_to_distorted(size_t number_of_blocks) const
     148              :       -> std::vector<std::unique_ptr<domain::CoordinateMapBase<
     149              :           Frame::Grid, Frame::Distorted, MeshDim>>> override;
     150              : 
     151            1 :   auto block_maps_distorted_to_inertial(size_t number_of_blocks) const
     152              :       -> std::vector<std::unique_ptr<domain::CoordinateMapBase<
     153              :           Frame::Distorted, Frame::Inertial, MeshDim>>> override;
     154              : 
     155            1 :   auto functions_of_time(const std::unordered_map<std::string, double>&
     156              :                              initial_expiration_times = {}) const
     157              :       -> std::unordered_map<
     158              :           std::string,
     159              :           std::unique_ptr<domain::FunctionsOfTime::FunctionOfTime>> override;
     160              : 
     161            0 :   static std::string name() {
     162              :     return "UniformTranslation" + (Index == 0 ? "" : get_output(Index));
     163              :   }
     164              : 
     165              :  private:
     166              :   template <size_t LocalDim, size_t LocalIndex>
     167              :   // NOLINTNEXTLINE(readability-redundant-declaration)
     168            0 :   friend bool operator==(const UniformTranslation<LocalDim, LocalIndex>& lhs,
     169              :                          const UniformTranslation<LocalDim, LocalIndex>& rhs);
     170              : 
     171            0 :   GridToInertialMapSimple grid_to_inertial_map_simple() const;
     172            0 :   GridToInertialMapCombined grid_to_inertial_map_combined() const;
     173            0 :   GridToDistortedMap grid_to_distorted_map() const;
     174            0 :   DistortedToInertialMap distorted_to_inertial_map() const;
     175              : 
     176            0 :   double initial_time_{std::numeric_limits<double>::signaling_NaN()};
     177              :   // If distorted and inertial frames are equal, then
     178              :   // velocity_grid_to_distorted_ is the grid to inertial velocity, and
     179              :   // velocity_distorted_to_inertial_ is unused.
     180            0 :   std::array<double, MeshDim> velocity_grid_to_distorted_{};
     181            0 :   std::array<double, MeshDim> velocity_distorted_to_inertial_{};
     182            0 :   bool distorted_and_inertial_frames_are_equal_{true};
     183            0 :   inline static const std::string function_of_time_name_grid_to_distorted_{
     184              :       "Translation" + (Index == 0 ? "" : get_output(Index))};
     185            0 :   inline static const std::string function_of_time_name_distorted_to_inertial_{
     186              :       "TranslationDistortedToInertial" + (Index == 0 ? "" : get_output(Index))};
     187              : };
     188              : 
     189              : template <size_t Dim, size_t Index>
     190            0 : bool operator==(const UniformTranslation<Dim, Index>& lhs,
     191              :                 const UniformTranslation<Dim, Index>& rhs);
     192              : 
     193              : template <size_t Dim, size_t Index>
     194            0 : bool operator!=(const UniformTranslation<Dim, Index>& lhs,
     195              :                 const UniformTranslation<Dim, Index>& rhs);
     196              : }  // namespace domain::creators::time_dependence
        

Generated by: LCOV version 2.0-1